Fuzzy Logic for Social Simulation Using NetLogo

Fuzzy Logic is a framework particularly useful to formalise and deal with imprecise concepts and statements expressed in natural language. This paper has three related aims. First, it aims to provide a short introduction to the basics of Fuzzy Logic within the context of social simulation. Secondly, it presents a well-documented NetLogo extension that facilitates the use of Fuzzy Logic within NetLogo. Finally, by providing a concrete example, it shows how researchers can use the Fuzzy Logic extension to build agent-based models in which individual agents hold their own fuzzy concepts and use their own fuzzy rules, which may also change over time. We argue that Fuzzy Logic and the tools provided here can be useful in Social Simulation in different ways. For example, they can assist in the process of analysing the robustness of a certain social theory expressed in natural language to different specifications of the imprecise concepts that the theory may contain (such as e.g. "wealthy", "poor" or "disadvantaged"). They can also facilitate the exploration of the effect that heterogeneity in concept interpretations may have in a society (i.e. the significance of the fact that different people may have different interpretations of the same concept). Thus, this paper and the tools included in it can make the endeavour of translating social theories into computer programs easier and also more rigorous.


Introduction
''The main contribution of fuzzy logic is a methodology for computing with words. No other methodology serves this purpose' ' Zadeh (1996, 103) Motivation 1.1 Imagine someone tells you: "A tall, blonde, middle-aged guy with long hair and casually dressed is waiting for you at the lobby". We believe most people would find this instruction sufficiently precise as to start walking towards the lobby with confidence that they will find the described person. However, it would not be straightforward to implement an artificial agent who behaves in the same confident manner. Even if the agent could perceive the precise height, age, colour and length of hair -and all other relevant features -of all the people in the lobby, the task would not be trivial. The reason is that terms such as "tall", "blonde", "middle-aged" and "long" are imprecise (or vague [1] ) in nature.
1.2 Focusing on the word "tall" for concreteness, a possible approach would be to define a numeric threshold x such that a person is considered "tall" if and only if his height is at least x. This approach, which can be suitably applied to the other linguistic terms too, would identify a subset of people satisfying all the conditions in the provided instruction, but what happens if such a subset is empty, or if it contains more than one person? More importantly, do we (human beings) deal with imprecise terms in this way? (i.e. do we really reduce the gradual nature of properties such as tallness to two clearly defined categories such that everyone in one category is definitely "tall" while everyone in the other category is definitely "not tall", leaving nothing in between these extremes?) 1.3 It seems clear that defining hard thresholds for imprecise terms does not capture the essence of how we use and reason with such concepts. Most people are reluctant to state that a person of height x is definitely "tall", but a person 1 mm shorter is definitely "not tall". [2] Concepts such as "tall" are not binary in nature; they are fuzzy. Consequently, most often we do not find it natural to assert that the proposition "Person x is tall" is definitely true or definitely false. Instead, we seem to be more comfortable conceding that such propositions may be true to some extent (i.e. they may have a truth value that lies somewhere in between the two absolute extremes true and false). Allowing for more than two truth values (besides the traditional true and false) takes us into the realm of many-valued logics, of which a particularly relevant instance for Social Simulation is Fuzzy Logic.
1.4 To summarise, it seems that: 1. Human beings have evolved to feel remarkably comfortable using, communicating and reasoning with imprecise or fuzzy terms whose applicability is a (potentially subjective) matter of degree. 2. Computers, however, do not readily share our remarkable ability to deal and reason with imprecise concepts. 3. Fuzzy logic is a type of many-valued logic that is particularly useful to formalise and reason with imprecise concepts. Consequently, many scholars see it as "a step towards formalizing human reasoning" (Freksa 1994, 21).
Thus, we believe Fuzzy Logic and this paper will be of interest to anyone interested in building Social Simulation models that contain artificial agents who can follow rules that include imprecise terms (e.g. "find an inexpensive flat which is close to work"), an ability that seems naturally intrinsic to humankind.
Brief History of Fuzzy Logic "All traditional logic habitually assumes that precise symbols are being employed. It is therefore not applicable to this terrestrial life but only to an imagined celestial existence" Russell (1923, pp. 88-89) 1.5 The scientific quest for an adequate "theory of vagueness" (i.e. a sound theoretical framework suitable to deal with vague or imprecise concepts) dates back at least to the early 20 th century (Russell 1923;Black 1937). Since then, the scientific study of vagueness has been approached in different ways in various fields, including philosophy, logic, mathematics, linguistics, computer science, physics and medicine (see a nice historical account by Seising (2008)).

1.6
A major breakthrough was triggered by the publication of Zadeh's (1965) paper on fuzzy sets. Fuzzy sets are an extension of classical (often called "crisp") sets in the sense that, besides full membership and full non-membership, fuzzy sets allow for partial membership. That is, an element may belong to a certain fuzzy set, may not belong, or may belong to some extent. Thus, graded concepts, such as "tall", can be naturally modelled as fuzzy sets, with individual people belonging to the set "tall" to a greater or a lesser degree (which can be interpreted as the truth value of the proposition "Person x is tall").
1.7 Zadeh's (1965) paper led to the emergence of a whole new field called Fuzzy Logic, aimed at developing "a methodological framework which is tolerant of imprecision and partial truths" (Zadeh 1973, 29). Early on, the approach taken by Zadeh to formalise vagueness started to be applied to "fuzzify" many disciplines by virtue of Zadeh's "extension principle" (Zadeh 1975a(Zadeh , 1975b(Zadeh , 1975c. In Zadeh's (1994a) words, "any field X can be fuzzified -and hence generalized -by replacing the concept of a crisp set in X by a fuzzy set." Thus, the theory of fuzzy sets led to the foundation and development of various new fields, such as fuzzy topology (Chang 1968), fuzzy clustering (Bellman et al. 1966;Ruspini 1969), fuzzy control (Zadeh 1972(Zadeh , 1973Mamdani & Assilian 1975;Mamdani 1974Mamdani , 1976, fuzzy graphs ( Rosenfeld 1975;Yeh & Bang 1975;Mordeson & Nair 2000), fuzzy algebra ( Dubois & Prade 1979), fuzzy calculus ( Dubois & Prade 1982a, 1982b, 1982c and fuzzy time series (Song & Chissom 1993a, 1993b Zimmermann 2001), professional logicians started to work on its formal foundations. This important branch of Fuzzy Logic (FL), which is often named "Mathematical Fuzzy Logic" or "Fuzzy Logic in the narrow sense" (Zadeh 1994a(Zadeh , 1994bHájek 1998Hájek , 2002Hájek , 2010Wang et al. 2007;Novák 2012) traces its roots to Goguen's (1969) work [3] , and had its first monograph written by Hájek (1998). The aim of FL in the narrow sense is "to show that fuzzy logic as a logic of imprecise (vague) propositions does have well developed formal foundations and that most things usually named "fuzzy inference" can be naturally understood as logical deduction" (Hájek 1998, preface); and it achieves this aim by providing and developing a "systematic treatment of deductive aspects and structures of fuzzy logic understood as many valued logic" (Hájek 1998, preface).

1.9
Fuzzy Logic in the narrow sense remains an active line of research (Cintula, Hájek & Noguera 2011a, 2011b, albeit it is relatively small when compared with all the work conducted in "Fuzzy Logic in the wider sense" (which is more or less synonymous with the theory of fuzzy sets and its applications -both technical and theoretical (Zadeh 1994a)). Thus, FL in the wider sense is "an extensive agenda whose primary aim is to utilize the apparatus of fuzzy set theory for developing sound concepts, principles and methods for representing and dealing with knowledge expressed by statements in natural language" (Wang et al. 2007, foreword) [4] .
1.10 It is also important to recognise FL is not the only approach to formalise and deal with imprecise or vague concepts (see e.g. Keefe (2000), Shapiro (2006) and various different perspectives in Cintula et al. (2011)), but it is a valid and solid logical framework for the purpose (Hájek 1998(Hájek , 2002, the most advanced and widely used approach and, possibly, the most successful mathematical theory of the vagueness phenomenon to date (Novák 2005).
Aims and Scope 1.11 This paper has three related aims, namely: 1. To provide a short introduction to the basics of Fuzzy Logic within a Social Simulation context. 2. To present and disseminate a well-documented NetLogo extension that facilitates the use of Fuzzy Logic within NetLogo (Wilensky 1999). 3. To illustrate with a concrete example how researchers can use the Fuzzy Logic extension to build agent-based models in which individual agents hold their own fuzzy concepts and use their own fuzzy rules, which may change over time.
1.12 It is important to note that the content of FL included in this paper is very limited. We only present the most fundamental concepts, which are, naturally, covered in the first chapters of any monograph on Fuzzy Set Theory or FL. The interested reader can find more advanced material in excellent textbooks written by Klir & Yuan (1995) and Zimmermann (2001) and in a shorter review by Zimmermann (2010). Political scientists may find Cioffi-Revilla's (1981) presentation especially attractive, as he explains the basic concepts of the theory for purposes of modelling and theory building, and focuses on the context of international relations, presenting several potential applications. Engineering-oriented readers will enjoy instructive textbooks written by Ross (2010) and Driankov et al. (1996).
1.13 Our approach here is more computationally oriented and practical. As such, it should be most attractive to scientists interested in building computer simulation models, especially agent-based models, which may include imprecise terms. To this end, we pay special attention to various practical aspects. In particular, we provide: a. A NetLogo extension that facilitates the implementation of models with fuzzy components (Appendix A); b. A detailed documentation on how to use it (Appendix B); c. A step-by-step tutorial that guides the reader through the whole process of implementing an agent-based model in which individual agents hold their own fuzzy concepts, and follow rules that contain such concepts (Appendix C).
1.14 The rest of the paper explains the basics of FL in a Social Simulation context (section 2), presents an outline of the functions included in the NetLogo extension (section 3) and provides a brief description of the fuzzy agent-based model used in the tutorial (section 4).
An Introduction to Fuzzy Logic in a Social Simulation Context "The theory of fuzzy sets is, basically, a theory of graded concepts -a theory in which everything is a matter of degree" Zadeh, in Zimmermann's (2001) foreword Fuzzy sets and membership functions 2.1 Fuzzy sets are generalizations of conventional sets (also called "crisp" sets). A conventional (crisp) set S can be defined by a membership function μ S (x) that specifies for each possible element x in a certain universe of discourse X, whether the element belongs to the set S or not. If an element x belongs to S, then the membership function of set S applied to element x equals 1. If an element x does not belong to S, then the membership function of set S applied to element x equals 0. Thus: For instance, the crisp set EvenNumbers contains the elements {2, 4, 6…}, so its membership function equals 1 when applied to each of such numbers (e.g. μ EvenNumbers (2) = 1). By contrast, the membership function of the crisp set EvenNumbers equals 0 when applied to numbers such as 1, 3, or 5 (e.g. μ EvenNumbers (5) = 0).

2.2
The sharp dichotomy in the concept of "belonging" in conventional sets (i.e. an element belongs to the set or it does not) is relaxed with fuzzy sets, which allow for partial membership. This can be useful to define and reason with imprecise terms, such as "tall" or "young," whose applicability to any particular object is a matter of degree. Thus, a fuzzy set, representing a fuzzy concept such as "tall", can be defined by assigning to each possible element within a certain universe of discourse (e.g. all the people in the world) a value between 0 and 1 that denotes the extent to which that element belongs to the fuzzy set (i.e. the extent to which that particular individual is tall) [5] . The value assigned by the membership function of a fuzzy set F to a particular element x is called the degree of membership of the element x in the fuzzy set F and is denoted μ F (x).

2.3
Sometimes one wishes to define a fuzzy set such that the degree of membership of any element x in the set depends solely on one single measurable property of the element x. For instance, one may want to formalise the concept "young person" in a certain context using a fuzzy set whose membership function depends only on the person's age. In those cases, rather than providing the whole mapping μ F (x) that assigns a degree of membership to each and every possible element x, one can define the membership function of the fuzzy set as a function of the property, which is sometimes called the base variable. [6] As an example, one could define the fuzzy set representing "young" with a membership function whose argument is a real number [7] a(x) ∈ [0,150] that denotes the age of person x measured in years. Fig. 1 shows one possible function. The fuzzy set "young" shown in Fig. 1 would assign a degree of membership 1 to every person with age 0 years, a degree of membership 0.94 to every person with age 17 years and a degree of membership 0.32 to every person with age 75 years.

2.5
The degree of membership of an element x in a fuzzy set F, i.e. μ F (x), can be interpreted as the truth value of the proposition "x belongs to F." That is: TruthValue(x belongs to F) = μ F (x) If the fuzzy set represents a fuzzy concept such as "young", then μ young (x) can be interpreted as the truth value of the proposition "x is young" (Zadeh 1973(Zadeh , 1975aKlir & Yuan 1995, 215-216), [8] implying: TruthValue (x is young) = μ young (x) This interpretation naturally leads to a many-valued logic with a continuum of truth values in the interval [0,1] (Zadeh 1965). [9] 2.6 Importantly, note that FL by no means aims at providing a universal definition of vague concepts (such as "young") which should be valid for everyone in every context. On the contrary, scholars using FL naturally recognise that vague concepts are often used in different ways by different people in different contexts. In this regard, what FL provides is a framework within which people can explicitly formalise their own personal definition of any particular vague concept in a specific context. Partial truth is not probability "We are not concerned with the likelihood that a man is short, after many trials; we are concerned with the shortness of one observation" Goguen (1969, p. 333) 2.7 A common misunderstanding is to confuse partial truth (or graded membership) in FL with probability (or randomness) in probability theory. This point is clarified in many papers (e.g. Zadeh (1965, 339), Zadeh (1975a, 210-211), Zadeh (1975b, 302), Bezdek (1993), Dubois et al. (1994), Dubois & Prade (1997, 2001 or Novák (2005)), but an intuitive illustration may be appropriate here. As already described, fuzzy sets are particularly useful to formalise imprecise terms (e.g. "young") whose fulfilment is a matter of degree. The imprecision is inherent to the term in natural language and has nothing to do with randomness, probability or uncertainty about the occurrence of events. (Henceforth we use the term "uncertainty" to refer to situations where there is something unknown yet to be discovered.) The following example clarifies this issue.

2.8
Imagine someone has a 1-litre bottle filled with 900 ml of water (90% of its capacity) in front of her.
There is no uncertainty about the bottle's content or its capacity; indeed, this person is free to conduct as many tests as she deems appropriate to convince herself that the bottle is indeed filled to 90% of its capacity. Looking at the bottle she may be willing to attribute a truth value of 0.9 to the proposition: "The bottle is full". (In other words, she may be willing to state that the bottle belongs to the fuzzy set "full" with degree of membership 0.9.) It is important to realise this assertion would be about what the term "full" means to this person (who naturally considers the term "full" to be a matter of degree to some extent), and would have nothing to do with any uncertainty about reality, as this person has full knowledge of the situation.

2.9
A very different matter would be to assign a probability of 0.9 to the proposition "The bottle is full". The probability assignment implies some uncertainty about the content of the bottle; it means that there is a 90% chance that the bottle is full and a 10% chance that it is not. In particular, the probability assignment presupposes the term "full" is absolutely precise (i.e. the bottle is either full or it is not) and it should be perfectly clear when it is in one state or the other. (A necessary condition to assign meaningful probabilities to events is that we can distinguish them.) Besides assuming the term "full" is perfectly defined in a dichotomic fashion, the probabilistic assignment also implies some ignorance about the state of the bottle and, therefore, it would be inappropriate to hold in our situation of certainty and perfect knowledge.
2.10 The differences between FL and probability theory are not only interpretative; they are also formal. For a start, probability is not compositional (or truth-functional) (i.e. the probability of a compound event (e.g. P(A ⋃ B)) does not generally depend only on the probabilities of the individual events that compose it (P(A ⋃ B) = P(A) + P(B) − P(A ⋂ B))). There can be different forms of dependencies between the events (in our example, the relation of dependence between A and B would affect the value of P(A ⋂ B)). By contrast, we will see in the next section that FL, like classical logic, is indeed truth-functional (i.e. the truth value of a formula only depends on the truth values of its subformulae). For a formal treatment of the differences (and similarities) between probability theory and (one of) fuzzy logics, see Gaines (1978).
Operations with fuzzy sets and logical connectives "What's crucial to realize is that fuzzy logic is a logic OF fuzziness, not a logic which is ITSELF fuzzy" Kantrowitz, Horstkotte & Joslyn (1997) 2.11 In this section we explain the fuzzy set operators Intersection, Union and Complement, which are the ordinary set-theoretic forms of the logical operations AND (or logical conjunction), OR (or logical disjunction) and NOT (or logical negation) respectively.
Fuzzy intersection and logical conjunction (AND) 2.12 The membership function of the intersection A⋂B of two sets A and B is a function of the membership functions of A and B. Formally: In terms of truth values of propositions, and assuming that the fuzzy sets represent fuzzy predicates: [10], [11] TruthValue There are many functions T that can be used to compute the intersection of fuzzy sets (see Zimmermann 2010). The usual requirement is that the function must be a Triangular norm (T-norm; Klement et al. 2000). A T-norm is a function T: [0,1] × [0,1] → [0,1] that satisfies the following axioms: These axioms ensure, in particular, the fuzzy intersection is a correct generalization of its crisp counterpart (i.e. T(1, 1) = 1 and T(0, 0) = T(0, 1) = T(1, 0) = 0). They also guarantee that a decrease in the membership value in the fuzzy set A or in the fuzzy set B cannot produce an increase in the membership value in the fuzzy set A⋂B.
2.13 The use of one T-norm or another leads to different fuzzy logics (Hájek 1998). Here we mention the two functions that are most widely used in FL in the broad sense (i.e. the minimum (or Gödel T-norm) and the product). As an example, let us compute the degree to which a certain person x is "Tall AND middleaged", assuming the assigned truth value to the proposition "x is Tall" is 0.8 and the assigned truth value to the proposition "x is Middle-aged" is 0.4. Using the minimum function as the conjunctive operator, we would obtain: By contrast, if we used the product function as conjunctive operator, we would obtain: TruthValue(x is Tall AND x is Middle-aged) = = product(TruthValue(x is Tall), TruthValue(x is Middle-aged)) = = product(0.8, 0.4) = 0.32 2.14 The decision to use one function or another will depend on the context and on the purpose of the modelling exercise. Zimmermann (2010) reviewed several T-norms, some of them dependent on a parameter, and argued "it is very unlikely that a single nonparametric operator can model appropriately the meaning of 'and' or 'or' context independently, that is, for all persons, at any time and in each context" (Zimmermann 2010, 324). Thus, care should be put into selecting the function for the context at hand. Zimmermann (2010) provides some guidance (and further references) on how to do this selection.
Fuzzy union and logical disjunction (inclusive OR) 2.15 The membership function of the union A⋃B of two sets A and B is a function of the membership functions of A and B. Formally: In terms of truth values of propositions: [12] TruthValue(x is A OR x is B) = S(TruthValue(x is A), TruthValue(x is B)) As with intersection, there are many functions S that can be used to compute the union of fuzzy sets (see Zimmermann 2010). The usual requirement is that the function must be a Triangular co-norm (also called S-norm; Klement et al. 2000). An S-norm is a function S: [0,1] × [0,1] → [0,1] that is commutative, associative, non-decreasing (see previous section) and has 0 as its identity element, i.e. S(a, 0) = a. The selection of an S-norm guarantees, in particular, the fuzzy union is a correct generalization of its crisp counterpart (i.e. S(0, 0) = 0 and S(0, 1) = S(1, 0) = S(1, 1) = 1). In FL, the two most widely used Snorms are the maximum (dual to the minimum T-norm) and the probabilistic sum (dual to the product Tnorm; probSum(a,b) = a + b − a·b).
2.16 As an example, let us compute the degree to which the person x in the previous example is "Tall OR middle-aged". Using the maximum function as the disjunctive operator, we would obtain: By contrast, if we used the probabilistic sum as disjunctive operator, we would obtain: As with the conjunctive operator AND, the decision to use one S-norm or another for the OR operator will depend on the context and purpose of the modelling exercise.
Fuzzy complement and logical negation (NOT) 2.17 It is clear that the function used to compute the membership function of the complement A c of a fuzzy set A should be non-increasing and assign 0 to 1 and vice versa. The natural (and most widely used) function is the additive complement: where A c denotes the complement of set A In terms of truth values of propositions: Using the numbers in the example above, we would obtain: The axiom of contradiction and the axiom of excluded middle 2.18 It is important to note that the following two axioms are not postulated in FL (see e.g. Gaines 1978) and, in stark contrast to classical logic, they do not generally hold: Axiom of contradiction: In sets: A ⋂ A c = ∅ where ∅ denotes the empty set.
In logical terms: TruthValue(x is A AND x is NOT A) = 0 Axiom of excluded middle: In sets: A ⋃ A c = X where X denotes the universal set.
In logical terms: TruthValue(x is A OR x is NOT A) = 1 This observation can be illustrated for person x (for whom the truth value of the proposition "x is Tall" is 0.8) using min for the logical AND and max for the logical OR: TruthValue(x is Tall AND x is NOT Tall) = = min(TruthValue(x is Tall), TruthValue(x is NOT Tall)) = min(0.8, 1 − 0.8) = 0.2 ≠ 0 Thus, in this example we would assign a truth value of 0.2 to the proposition "x is tall and not tall" (which may not be necessarily undesirable). Similarly, TruthValue(x is Tall OR x is NOT Tall) = = max(TruthValue(x is Tall), TruthValue(x is NOT Tall)) = max(0.8, 1 − 0.8) = 0.8 ≠ 1 Linguistic hedges 2.19 Linguistic hedges are terms that complete our natural language. They alter or adjust fuzzy adjectives, allowing for the expression of hues and nuances of meaning that are not possible through the use of adjectives alone (Zadeh 1975a). Examples of hedges are words such as "very", "fairly", "slightly", "roughly" or "extremely", which modify the linguistic term they accompany to express its meaning in finer gradations. Hedges can potentiate (concentrate) the gradable characteristic (e.g., "extremely popular") or dilute it ("fairly large").

2.20
The effect of applying a hedge (e.g. "very") to a fuzzy concept (e.g. "hot") can be modelled by using a function h: [0,1] → [0,1] to modify the membership function of the original fuzzy set. A common family of functions is h α (a) = a α . For example, one could compute the membership function of the fuzzy sets representing "very hot" and "extremely hot" as follows (see Fig. 2): μ very hot (x) = h 2 (μ hot (x)) = (μ hot (x)) 2 μ extremely hot (x) = h 6 (μ hot (x)) = (μ hot (x)) 6 Figure 2. Membership function of one set (in green, on the left), its square (in black, in the middle), and the green set powered to the 6 th (in red, on the right).
2.21 Note that the use of the modifier h α (a) = a α with exponents α greater than 1 reduces the truth value of the fuzzy predicate to which it is applied, something that may be appropriate for hedges such as "very" and "extremely". By contrast, the use of the modifier h α (a) = a α with exponents α smaller than 1 increases the truth value of the original fuzzy predicate, so it may be appropriate to model hedges such as "slightly" or "fairly".
Systems of fuzzy IF-THEN rules 2.22 In this section we explain the so-called "Interpolation Method" for systems of fuzzy IF-THEN rules (Zadeh 1983, 215-216;Klir & Yuan 1995, section 11.4, 317-12) [13] , including fuzzification and defuzzification. A particular instance of this method is the so-called max-min rule (also named the Mamdani inference, Mamdani-Assilian inference or max-min inference), which is often used in fuzzy control (Driankov et al. 1996). Another particular instance is the max-prod inference (also called the scaled inference).
"This method of interpretation of fuzzy IF-THEN rules is very convenient when we need a nice tool for the approximation of functions but it is less convenient as a model of human reasoning" Novák (2012, 35) 2.23 Within a Social Simulation context the interpolation method can be useful to define a function by means of a collection of fuzzy rules. The procedure is best understood with an example. Suppose we want to implement an artificial agent who must select a suitable house from several options, and his two main concerns are the price of the house and the distance from the house to the agent's workplace.
2.24 A possible approach would be to implement a function f(p, d) that takes numerical inputs p (for price) and d (for distance from work), and produces a numerical score s (for suitability) as the output, i.e. s = f(p, d). The interpolation method (including fuzzification and defuzzification) is a procedure that allows us to specify such a function f(p, d) using a collection of fuzzy rules of the form "IF Antecedent THEN Consequent" such as: R1: IF (House is Inexpensive OR Close-to-work), THEN Suitability is Good. R2: IF (House is Expensive OR Far-from-work), THEN Suitability is Low. R3: IF (House is Averagely-priced AND About-50-km-from-work), THEN Suitability is Regular.
2.25 Naturally, as part of the process not only will we need to provide the collection of rules, but we will also have to explicitly define the fuzzy concepts contained in the rules (e.g. "Inexpensive" or "Close-towork") and make a number of assumptions regarding the functions we want to use for the logical AND, for the logical OR and for computing the output of each rule. Depending on our choices of these functions, we will obtain the max-min inference, the max-prod inference, or some other type of inference.
2.26 Fig. 3, which illustrates the max-min inference (or the Mamdani inference), includes a representation of the nine fuzzy sets involved in the definition of the rules (i.e. fuzzy sets "Inexpensive", "Expensive" and "Averagely-priced", with price (p) as base variable; fuzzy sets "Close-to-work", "Far-from-work" and "About-50-km-from-work", with distance (d) as base variable; and fuzzy sets "Good Suitability", "Low Suitability" and "Regular Suitability", with suitability (s) as base variable). Suitability is measured here as a score than ranges from 0 (lowest suitability) to 10 (highest suitability). Figure 3. Illustration of the max-min inference with defuzzification (centre of gravity). A numerical suitability (6.03845) is computed from numerical inputs price = 50 (in €1,000s) and distance = 35 km.

2.27
The general algorithm has 5 steps:

Fuzzification of inputs (optional)
Inputs may be crisp values (e.g. price = 50) or fuzzy sets (e.g. price is reasonable). If an input is crisp, it may optionally be fuzzified, i.e. turned into a fuzzy set first (Zadeh 1975a). Fuzzification of crisp values may be appropriate if the inputs are known only approximately or if they come from imprecise measurements or observations. [14] The example represented in Fig. 3 does not include fuzzification.

Computation of degrees of consistency between facts (inputs) and antecedents
In this step we evaluate the extent to which the antecedent of each IF-THEN rule is satisfied for the given inputs. The degree of consistency r Antecedent (x 0 ) between a crisp value x 0 and a fuzzy set Antecedent is simply the degree of membership of x 0 in the fuzzy set, i.e. r Antecedent (x 0 ) = μ Antecedent (x 0 ). The degree of consistency between two fuzzy sets Input and Antecedent is determined by the height of the intersection of the two sets, i.e. r Antecedent (Input) = height(Input ⋂Antecedent). [15] As an example, consider the first rule (R1), represented at the top row of Fig. 3, which has as antecedent: "House is Inexpensive OR Close-to-work". The computation for a house with crisp price p = 50 and crisp distance d = 35, using the function Maximum (Max) for the logical OR, would be: Max(μ Inexpensive (p=50), μ Close-to-work (d=35)) = Max(0.75, 0.51) = 0.75 The result of this step is a number for each rule (i.e. the degree of consistency between the inputs and each rule's antecedent).

Reshaping of consequents
In this step we reshape the original consequent of each rule given the degree of consistency between the inputs and the rule's antecedent. The underlying idea is that the consequent of a rule should be applied to the extent that its antecedent is satisfied. Possible operators for the reshaping method are Truncate (or minimum) and Product (which acts as a scaling operator). [16] As an example, consider again the first rule (R1), represented at the top row of Fig. 3. Assuming that the function Truncate is used as reshaping operator, the membership function of the truncated set would be: μ Truncated Good suitability (x) = min(μ Good suitability (x), 0.75) Thus, the result for the first rule would be the fuzzy set Good suitability truncated at level 0.75 (see the grey-filled fuzzy set represented at the top right chart of Fig. 3). Truncate (i.e. min) is the function used in the max-min inference. Another possibility (which is used in the max-prod inference) is to use the Product as reshaping operator. This alternative can be seen in the interactive figure provided in Appendix D. In this case, the membership function of the reshaped consequent of the first rule is: μ Scaled Good suitability (x) = μ Good suitability (x) · 0.75 In any case, the result of the reshaping step is a fuzzy set for each rule.

Aggregation of all the reshaped consequents
In this step, the reshaped consequents are aggregated to provide one single fuzzy set. Possible operators for the aggregation are e.g. the Maximum, the Probabilistic Sum (ProbabilisticSum(a,b) := a + b − a·b) or the Sum Clipped at 1 (ClippedSum(a,b) := min(1, a + b)). In the example shown in Fig. 3 we used the Maximum. The output of this step is the fuzzy set filled in grey with the label "Aggregated Suitability" at the bottom right chart of Fig. 3.

Defuzzification of the aggregated fuzzy set (optional)
The defuzzification transforms the aggregated fuzzy set into a single crisp number.
Zimmermann ( 2.28 In the example shown in Fig. 3, the COG was used to reduce the aggregated fuzzy set labelled SUITABILITY to the crisp value 6.03845. 2.29 It is clear that the researcher has to make several decisions within this general framework. Specifically, there is a choice of operators for the logical AND, the logical OR, the reshaping method, the aggregation method and the defuzzification method. These decisions lead to different functions f(p, d). The consequences of choosing one or another operator can be seen in the interactive version of Fig. 3, which is provided in Appendix D.

2.30
The max-min (or Mamdani) inference appears when choosing the Minimum for the logical AND, the Maximum for the logical OR, Truncate as the reshaping method and Maximum as the aggregation method. By contrast, the max-prod inference uses the Product function as its reshaping method, so the original consequents of each of the rules are scaled down, rather than truncated. This leads to a different aggregated fuzzy set with a different centre of gravity. It is important to emphasise that the procedure described in this section produces a specific function f(p, d) that takes numerical inputs p (for price) and d (for distance from work), and produces a numerical score s (for suitability) as its output, i.e. s = f(p, d). The particular function corresponding to the max-min inference system with three rules (illustrated in Fig. 3 for particular values price = 50 and distance = 35), is plotted in Fig. 4 for any price and distance, for the sake of clarity. The interpolation method is not logical deductive inference "The whole procedure is quite reasonable and gives good results. However, it has to be stressed that it is not a logical inference, i.e., a procedure aiming at the derivation of new facts from some other known ones using formal deduction rules. No logical implication is inside and thus, no modus ponens proceeds." Klawonna & Novák (1996, 331) 2.31 The interpolation method described in the previous section was originally conceived to mimic the functioning of human operators in charge of controlling an industrial process (Mamdani & Assilian 1975;Mamdani 1974Mamdani , 1976Mamdani , 1977. The aim was to condense the operator's experience into a set of (linguistic) rules that could be used by a machine to automatically control the process. This aspiration of capturing human declarative knowledge is still widespread in the literature, with scholars from different fields posing the interpolation method as a "natural framework to include expert knowledge in the form of linguistic rules" (Cordón et al. 2001, 15) or a tool that somewhat aims at "imitating human judgment in common sense reasoning" (Bojadziev & Bojadziev 2007, 128). However, it is important to emphasise that, while such statements may not be necessarily inexact in their context, the intuitive appeal of the method should not mislead us to believe it follows some kind of logical deductive inference.
2.32 As an illustrative observation, note that conflicting rules may be fired simultaneously. In the previous example, an inexpensive house which is far away from work will have both good suitability (according to rule 1) and low suitability (according to rule 2). In such cases, no inconsistency warnings will be issued, but a sort of average will be silently computed. This may not be necessarily inadequate for certain purposes (see Bojadziev & Bojadziev 2007, chapter 4), but it does indicate the method is best seen as an interpolation technique, rather than as a tool for logical deductive inference. Another important observation in this regard is that the inference rule modus ponens is not necessarily satisfied in the interpolation method in the sense that an input in full accordance with the antecedent of a rule may lead to an output that does not satisfy the rule's consequent to the same degree (see a clear illustration in ).

2.33
The fact that the interpolation method is not a proper tool for deductive inference is well known and discussed in many papers (see Klawonna & Novák 1996;Bodenhofer et al. 2007) and textbooks (see e.g. Klir & Yuan 1995, chapter 11;Hájek 1998, chapter 7). Izquierdo and Izquierdo (2015) use several examples to illustrate the wide range of problems that may appear when interpreting the interpolation method as logical deductive inference.
2.34 Nonetheless, as an interpolation technique, the method does have very convenient properties. For a start, it can approximate any continuous real function on a closed domain to any degree of accuracy (Cao et al. 2001), so it is a very flexible and powerful approach, especially when combined with tuning techniques (see e.g. Driankov et al. 1996, chapter 5;Cordón 2011). Its success in this area is mainly due to its rule-based structure, which allows individual rules to be suitably adapted for specific regions of the state space without affecting the fitting achieved in neighbouring regions (Mamdani 1994).

2.35
The interpolation method has been used in various fields besides fuzzy control, such as management and finance (Bojadziev & Bojadziev 2007;Korol 2012), economics (Stojic 2012;West & Linster 2003), risk assessment (Nait-Said et al. 2008;Darbra et al. 2008  3.2 Our extension has been released under the GNU general public licence version 3 (GPLv3), which is one of the licences that scores best against the criteria set out by Polhill and Edmonds (2007) for releasing scientific software. GNU GPLv3 grants the right to inspect, copy and distribute the source code, to modify it, and also to copy and distribute any modifications. It also guarantees that any modifications will be issued under a licence that preserves these rights (i.e. copyleft protection). Following Polhill and Edmonds' (2007) guidelines and example , we have also devoted a substantial amount of work to facilitate the process of scientific critique of this research by carefully commenting the code, providing extensive documentation (Appendix B) and creating a tutorial on how to build an agent-based model using the extension (Appendix C).

3.3
The functionality of the NetLogo extension (which is internally coded in Java) was initially implemented as a library of functions directly written in NetLogo language. This set of NetLogo functions -together with its own documentation and tutorial -is provided in Appendix E. The advantage of the extension over the library is that it is computationally more efficient (both in terms of speed and memory usage) and it is easier to use. Some researchers may still find the original NetLogo library useful if they plan to inspect and/or modify the code within NetLogo.

3.4
The following is a list of the main functions provided in the extension: Functions to create fuzzy sets: fuzzy:discrete-numeric-set, fuzzy:piecewise-linear-set, fuzzy:trapezoidal-set, fuzzy:logistic-set, fuzzy:gaussian-set, fuzzy:exponential-set, fuzzy:interval-withpoints-set.
Function to plot fuzzy sets: fuzzy:plot.

3.5
To illustrate the use of the extension, we include here the implementation of the Mamdani system explained in section 2.6 and displayed in Fig. 3. Our objective here is to show that implementing a system of fuzzy IF-THEN rules using the NetLogo extension requires very few lines of simple code. For a detailed explanation of each of the functions used, see the documentation in Appendix B. 3.6 Step 1: Implementation of a procedure that creates the fuzzy sets: see Fig. 5. 3.7 Step 2: Implementation of a procedure that takes a price and a distance as inputs and reports a numerical suitability: see Fig. 6. 3.8 With the two procedures shown above in place, one could execute the code "compute-suitability 50 35" to obtain the number 6.03845, as shown in Fig. 3.
A simple agent-based model with fuzzy components "It is a familiar fact that concepts change with time and user" Goguen (1969, 339) 4.1 In this section we provide a general description of a simple agent-based model in which agents hold their own fuzzy concepts and follow fuzzy rules. The model is described in full detail in Appendix C, which provides a step-by-step tutorial to implement systems of fuzzy IF-THEN rules. The aim is to illustrate a possible way of using FL in an agent-based model.

4.2
Our model runs in discrete time steps. Initially, a group of agents conduct a sightseeing tour of a city/location, which they may later recommend with a certain probability. The probability of recommending the tour depends on a) the price paid for the tour; and b) the temperature during the tour. The price of the tour is a parameter of the model and the temperature is generated randomly every time a tour takes place. The function used by each agent to compute the probability of recommending is defined using fuzzy rules such as: IF (price is inexpensive AND temperature is nice), THEN it is likely that I will recommend. IF (price is expensive OR temperature is extreme), THEN it is unlikely that I will recommend.

4.3
The rules are the same for every agent, but their perceptions are different. Thus, each individual agent has its own concept (i.e. fuzzy set) of nice temperature, extreme temperature, inexpensive price, expensive price, likely, and unlikely. Fig. 7 shows the fuzzy sets representing nice and extreme temperature for different agents. Figure 7. A representation of various fuzzy sets corresponding to different agents. Each agent has its own fuzzy sets representing nice (in blue) and extreme (in red) temperature.

4.4
Thus, even though the price and the temperature are the same for every agent in any specific tour, the assessment of these two variables by each agent is different. Using the interpolation method described in the section 'Systems of fuzzy IF-THEN rules', each agent computes an individual probability with which it will recommend the tour.

4.5
In the model, each agent is given a number of opportunities to recommend the tour to neighbours in its social network. At the end of the period, after all agents have been given the opportunity to recommend the tour (according to their individually computed probabilities), we have a new set of agents who have been recommended to attend the tour and will do so if there are available places (each tour is limited in size). The following time period starts with a new tour (with different temperature conditions) that will be assessed by the new set of agents. These new attendees will compute their own probability to recommend the tour to their own social contacts. In this way, the iterative process can go on indefinitely.

4.6
Importantly, the fuzzy sets of each individual agent do not necessarily have to be created in a completely unbiased way. They could be created using specific templates for optimistic agents (i.e. those who tend to assess experiences with a favourable bias), neutral agents or pessimistic agents. Thus, one could study the effects of different grades of homophily (or assortativity) in the agents' social networks. Specifically, it is clear the number of tour attendants in the model will be affected by the extent to which optimistic agents (who are more likely to recommend) tend to relate to each other.
Conclusions 5.1 Social Simulation as a scientific field, and this journal in particular, are devoted to the exploration and understanding of social processes by means of computer simulation (Gilbert & Troitzsch 2005, preface). This aim often requires the translation of social theories and concepts expressed in natural language into algorithms written in formal languages that computers can understand. This paper shows that FL can be useful in such endeavour, since it provides a framework within which we can formalise and deal with imprecise concepts that are expressed in natural language.

5.2
However, the use of FL in Social Simulation should not be taken lightly. For a start, constructing appropriate fuzzy sets on imprecise concepts is not a trivial task. As put by Kvist (2007): "Fuzzy sets are not fuzzy in the sense of being imprecise or ambiguous. On the contrary, fuzzy sets need designing to accurately reflect theoretical concepts and analytical constructs that have precise meaning to those researchers using them. Fuzzy sets provide a way of operationalizing a concept into the 0-to-1 metric, from being 'fully out' to 'fully in' a set" (Kvist 2007, 477). In essence, by constructing a fuzzy set on an imprecise concept we are effectively making the concept precise in a particular way. We have also discussed a common way of using fuzzy IF-THEN rules, i.e. the interpolation method. Importantly, the interpolation method is not a method of logical deductive inference; thus, care should be taken when using it and interpreting the results obtained with it.

5.3
This paper also provides a set of well-documented functions written for NetLogo (Wilensky 1999) that facilitate the use of FL within this platform. Using these functions, it becomes simple to implement agent-based models where individual agents hold their own fuzzy sets (representing subjective imprecise concepts) and follow fuzzy rules which may affect the way agents behave and interact.Appendix C is a step-by-step tutorial that shows how to do this. As an example of a potentially useful application, our extension makes it particularly easy to analyse the robustness of a certain social theory expressed in natural language to different specifications of the imprecise concepts that the theory contains, such as e.g. "wealthy" (which may be represented with different fuzzy sets). Also, it facilitates the exploration of the effect that heterogeneity in concept interpretations may have in a society (i.e. the significance of the fact that different people may have different interpretations of the same concept).

5.4
Obviously, neither FL nor our extension are strictly necessary to build models with agents holding different instances of imprecise concepts, but the work presented here helps implement such models in a natural and transparent way. Thus, we hope that this paper and the tools included in it will make the endeavour of translating social theories into computer programs easier and more rigorous at the same time.
Notes 1 In the following, and in accordance with the literature, we use the terms imprecise and vague indistinctively.
2 However, if one assumes the opposite, i.e., that "a person who is only 1 mm shorter than a tall person is also tall", then it is not difficult to prove in classical logic that "everyone is tall" (assuming there is at least one person who is tall). For a crystal-clear and fascinating analysis of this ancient (Sorites) paradox, see Goguen (1969).
3 A detailed historic account of the development of fuzzy logic in the narrow sense can be found in chapter 10 of Hájek (1998). 4 The quote goes on as follows: "Although work in fuzzy logic in the broad sense is not directly concerned with the issues that are investigated under fuzzy logic in the narrow sense, the importance of the latter is that it provides the former with solid theoretical foundations" (Wang, Ruan & Kerre 2007, foreword). 5 One could legitimately argue that a partial ordering would be sufficient to capture the graduation of membership (see e.g. footnote 3 in Zadeh (1965)), and that numerical graduation of membership is hard to justify for the representation of cognitive concepts (see e.g. Freksa (1994)).
11 Note that fuzzy propositions may also refer to elements belonging to different universes of discourse.
12 Notation: In logic, the disjunctive connective is usually denoted by ∨, rather than by the word OR. 13 The interpolation method is actually a special case of the compositional rule of inference, where the fuzzy relation is the Minimum or the Product (see e.g. Klir & Yuan 1995, 318-320;Wang 1997, 98). However, note that neither the Minimum nor the Product define a relation of logical implication in the sense that they do not collapse to the classical implication when truth values are restricted to 0 and 1.
14 The simplest way of fuzzifying a crisp value x 0 is to convert it into -or interpret it as -a fuzzy singleton, i.e. a fuzzy set whose membership function equals 1 at x 0 and equals 0 for any other element. Here, the crisp input price = 50 can be interpreted as the fuzzy singleton F50 with μ F50 (50) = 1, and μ F50 (price) = 0 for price ≠ 50. We use the term "interpretation" because this type of fuzzification has no effect in the subsequent steps of the procedure. Naturally, other fuzzifications are possible and may be more appropriate in certain cases. 15 The height of a fuzzy set is the largest degree of membership obtained by any element in that set.
Thus, if the function minimum is used as intersection operator, the degree of consistency between fuzzy sets Input and Antecedent would reduce to: r Antecedent (Input) = sup x∈X min(μ Input (x), μ Antecedent (x)). 16 Some authors (see e.g. Mamdani 1977;Driankov et al. 1996, chapter 2;Cordón et al. 2001, 8;Ross 2010, chapter 5) and computational packages (see e.g. Matlab 2014) refer to these functions as "Implication operators". We prefer to avoid this terminology because these functions do not define a relation of implication in the logical sense; in particular, they do not generalize the implication operator of classical logic, in the sense that they do not collapse to the classical implication when truth values are restricted to 0 and 1 (see e.g. the excellent explanations by Klir and Yuan (1995, section 11.2) and Hájek (1998, p. 177)). The implication connective x→y tries to quantify the degree by which the consequent y is at least as true as the antecedent x (see e.g. Smets & Magrez 1987;Hájek 1998, 28-29, section 2.1.4). In mathematical fuzzy logic, it is most often defined as the residuum of a (leftcontinuous) T-norm (Hájek 1998, 29, definition 2.1.5). The implication connectives derived from each of the three fundamental T-norms are: Łukasiewicz implication (residuum of Łukasiewicz T-norm), Godel implication (residuum of minimum T-norm) and Goguen -or product -implication (residuum of product T-norm) (Hájek 1998 Find the latest release at: https://github.com/luis-r-izquierdo/netlogo-fuzzy-logic-library/releases