Institute for Advanced Management Systems Research Department of Information Technologies Faculty of Technology, Åbo Akademi University What is fuzzy logic and fuzzy ontology? Robert Fullér Directory • Table of Contents • Begin Article c 2010 March 4, 2010 rfuller@mail.abo.fi Table of Contents 1. Triangular and trapezoidal fuzzy numbers 2. Operations on fuzzy sets 3. Material implication 4. Fuzzy implications 5. The theory of approximate reasoning 6. Crisp relations 7. Fuzzy relations Table of Contents (cont.) 3 8. Simplified fuzzy reasoning schemes 9. Tsukamoto’s fuzzy reasoning scheme 10. Sugeno’s fuzzy reasoning scheme Toc JJ II J I Back J Doc Doc I Section 1: Triangular and trapezoidal fuzzy numbers 4 1. Triangular and trapezoidal fuzzy numbers A fuzzy set A of the real line R is defined by its membership function (denoted also by A) A : R → [0, 1]. If x ∈ R then A(x) is interpreted as the degree of membership of x in A. Figure 1: Membership functions for ”small” and ”big”. Toc JJ II J I Back J Doc Doc I Section 1: Triangular and trapezoidal fuzzy numbers 5 If x0 is the amount of the salary then x0 belongs to fuzzy set A1 = small with degree of membership A1 (x0 ) = and to 1− 0 x0 − 2000 4000 if 2000 ≤ x0 ≤ 6000 otherwise A2 = big with degree of membership 1 Toc 6000 − x0 A2 (x0 ) = 1− 4000 0 JJ II J if x0 ≥ 6000 if 2000 ≤ x0 ≤ 6000 otherwise I Back J Doc Doc I Section 1: Triangular and trapezoidal fuzzy numbers 6 Definition 1.1. A fuzzy set A is called triangular fuzzy number with peak (or center) a, left width α > 0 and right width β > 0 if its membership function has the following form a−t if a − α ≤ t ≤ a 1− α t−a A(t) = 1− if a ≤ t ≤ a + β β 0 otherwise and we use the notation A = (a, α, β). The support of A is (a − α, b + β). A triangular fuzzy number with center a may be seen as a fuzzy quantity ”x is close to a” or x is approximately equal to a”. Definition 1.2. A fuzzy set A is called trapezoidal fuzzy number with tolerance interval [a, b], left width α and right width β if its membership function Toc JJ II J I Back J Doc Doc I If A is not a fuzzy number then there exists an γ ∈ [0, 1] such that [A]γ not a convex of R. fuzzy numbers Section 1: isTriangular andsubset trapezoidal 1 a-! a a+" Fig. 1.2. Triangular fuzzy number. Figure 2: A triangular fuzzy number. has the Definition 1.1.4 A fuzzy set A is called triangular fuzzy number with peak (or center) a, left width α > 0 and right width β > 0 if its membership function has form the following form following a−t 1 −a − t if a − α ≤ t ≤ a α if a − α ≤ t ≤ a 1 − tα −a A(t) = 1− if a ≤ t ≤ a + β 1 β if a ≤ t ≤ b 0 otherwise A(t) = t−b β [A]γ = [a − (1 − γ)α, a + (1 − γ)β], ∀γ ∈ [0, 1]. 0 otherwise and we use the notation if aeasily ≤ tbe≤verified b + that β A1=−(a, α, β). It can The support of A is (a − α, b + β). A triangular fuzzy number with center a may the be seen as a fuzzy and we use notation Aquantity = (a, b, α, β). ”x is approximately equal to a”. A fuzzy set AJ is called trapezoidal fuzzy numberJ with toler- Doc I JJ 1.1.5 II I Doc Toc Definition Back 7 Section 1: Triangular and trapezoidal fuzzy numbers 8 and we use the notation A= b, α, β). A trapezoidal fuzzy number may be(a,seen as a fuzzy quantity (1.1) It can easily be shown that [A]γ = [a − (1 − γ)α, b + (1 − γ)β], ∀γ ∈ [0, 1]. ”x is approximately in the interval [a, b]”. The support of A is (a − α, b + β). 1 a-! a b b+" Fig. 1.3. Trapezoidal fuzzy number. Figure 3: Trapezoidal fuzzy number. A trapezoidal fuzzy number may be seen as a fuzzy quantity ”x is approximately in the interval [a, b]”. Definition 1.1.6 Any fuzzy number A ∈ F can be described as % & a−t L if t ∈ [a − α, a] α JJ II J I J Doc Toc Back Doc I 9 2. Operations on fuzzy sets The classical set theoretic operations from ordinary set theory can be extended to fuzzy sets. Let A and B are fuzzy subsets of a crisp set X. The intersection of A and B is defined as (A ∩ B)(t) = min{A(t), B(t)} = A(t) ∧ B(t), The union of A and B is defined as (A ∪ B)(t) = max{A(t), B(t)} = A(t) ∨ B(t), The complement of a fuzzy set A is defined as (¬A)(t) = 1 − A(t), for all t ∈ X. Toc JJ II J I Back J Doc Doc I Section 3: Material implication 10 3. Material implication Let p =0 x is in A0 and q =0 y is in B 0 are crisp propositions, where A and B are crisp sets for the moment. The full interpretation of the material implication p → q is that: the degree of truth of p → q quantifies to what extend q is at least as true as p, i.e. 1 if τ (p) ≤ τ (q) τ (p → q) = 0 otherwise τ (p) τ (q) 1 0 0 1 1 1 0 0 τ (p → q) 1 1 1 0 Table 1: Truth table for the material implication. Toc JJ II J I Back J Doc Doc I Section 4: Fuzzy implications 11 4. Fuzzy implications Consider the implication statement if pressure is high then volume is small Figure 4: Membership function for ”big pressure”. The membership function of the fuzzy set A, big pressure, can be interpreted as Toc JJ II J I Back J Doc Doc I Section 4: Fuzzy implications 12 • 1 is in the fuzzy set big pressure with grade of membership 0 • 2 is in the fuzzy set big pressure with grade of membership 0.25 • 4 is in the fuzzy set big pressure with grade of membership 0.75 • x is in the fuzzy set big pressure with grade of membership 1, x ≥ 5 1 if u ≥ 5 5−u A(u) = 1− if 1 ≤ u ≤ 5 4 0 otherwise The membership function of the fuzzy set B, small volume, can be interpreted as Toc JJ II J I Back J Doc Doc I Section 4: Fuzzy implications B(v) = 13 1 1− 0 v−1 4 if v ≤ 1 if 1 ≤ v ≤ 5 otherwise • 5 is in the fuzzy set small volume with grade of membership 0 • 4 is in the fuzzy set small volume with grade of membership 0.25 • 2 is in the fuzzy set small volume with grade of membership 0.75 • x is in the fuzzy set small volume with grade of membership 1, x ≤ 1 If p is a proposition of the form ’x is A’ where A is a fuzzy set, for example, big pressure and q is a proposition of the form ’y is B’ for example, small volume then we define the implication p → q as A(x) → B(y) Toc JJ II J I Back J Doc Doc I Section 4: Fuzzy implications 14 Figure 5: Membership function for ”small volume”. For example, x is big pressure → y is small volume ≡ A(x) → B(y) Remembering the full interpretation of the material implication 1 if τ (p) ≤ τ (q) p→q= 0 otherwise Toc JJ II J I Back J Doc Doc I Section 4: Fuzzy implications 15 We can use the definition A(x) → B(y) = 1 0 if A(x) ≤ B(y) otherwise 4 is big pressure → 1 is small volume A(4) → B(1) 0.75 → 1 = 1 The most often used fuzzy implication operators are listed in the following table. Toc JJ II J I Back J Doc Doc I Section 4: Fuzzy implications 16 Name Definition Early Zadeh Łukasiewicz Mamdani Larsen x→y x→y x→y x→y Standard Strict x→y Gödel x→y Gaines x→y Kleene-Dienes Kleene-Dienes-Łukasiewicz Yager x→y x→y x→y = max{1 − x, min(x, y)} = min{1, 1 − x + y} = min{x, y} = xy 1 if x ≤ y = 0 otherwise 1 if x ≤ y = y otherwise 1 if x ≤ y = y/x otherwise = max{1 − x, y} = 1 − x + xy = yx Table 2: Fuzzy implication operators. Toc JJ II J I Back J Doc Doc I 17 5. The theory of approximate reasoning In 1979 Zadeh introduced the theory of approximate reasoning. This theory provides a powerful framework for reasoning in the face of imprecise and uncertain information. Entailment rule: Conjuction rule: Toc JJ Mary is very young very young ⊂ young Mary is young pressure is not very high pressure is not very low pressure is not very high and not very low II J I Back J Doc Doc I Section 5: The theory of approximate reasoning 18 pressure is not very high or Disjunction rule: pressure is not very low pressure is not very high or not very low Projection rule: (x, y) is close to (3, 2) (x, y) is close to (3, 2) x is close to 3 y is close to 2 How to make inferences in fuzzy environment? <1 : if observation pressure is BIG then pressure is 4 conclusion Toc JJ volume is SMALL volume is 2 II J I Back J Doc Doc I Section 5: The theory of approximate reasoning 19 Figure 6: BIG(4) = SMALL(2) = 0.75. <1 : if observation pressure is BIG then pressure is 2 conclusion Toc JJ volume is SMALL volume is 4 II J I Back J Doc Doc I 20 6. Crisp relations A classical relation can be considered as a set of tuples, where a tuple is an ordered pair. A binary tuple is denoted by (u, v), an example of a ternary tuple is (u, v, w) and an example of n-ary tuple is (x1 , . . . , xn ). Definition 6.1. Let X1 , . . . , Xn be classical sets. The subsets of the Cartesian product X1 × · · · × Xn are called n-ary relations. If X1 = · · · = Xn and R ⊂ X n then R is called an n-ary relation in X. Let R be a binary relation in R. Then the characteristic function of R is defined as ( 1 if (u, v) ∈ R χR (u, v) = 0 otherwise Example 6.1. Let X be the domain of men {John, Charles, James} and Y the domain of women {Diana, Rita, Eva}, then the relation ”married to” on X × Y is, for example {(Charles, Diana), (John, Eva), (James, Rita) } Toc JJ II J I Back J Doc Doc I 21 7. Fuzzy relations Definition 7.1. Let X and Y be nonempty sets. A fuzzy relation R is a fuzzy subset of X × Y . If X = Y then we say that R is a binary fuzzy relation in X. Let R be a binary fuzzy relation on R. Then R(u, v) is interpreted as the degree of membership of (u, v) in R. Example 7.1. A simple example of a binary fuzzy relation on U = {1, 2, 3}, called ”approximately equal” can be defined as R(1, 1) = R(2, 2) = R(3, 3) = 1, R(1, 2) = R(2, 1) = R(2, 3) = R(3, 2) = 0.8, R(1, 3) = R(3, 1) = 0.3. The membership function of R is given by JJ II J I Toc Back J Doc Doc I Section 7: Fuzzy relations 22 1 0.8 R(u, v) = 0.3 if u = v if |u − v| = 1 if |u − v| = 2 In matrix notation it can be represented as 1 R = 0.8 0.3 0.8 1 0.8 0.3 0.8 1 Fuzzy relations are very important because they can describe interactions between variables. Toc JJ II J I Back J Doc Doc I 23 8. Simplified fuzzy reasoning schemes Suppose that we have the following rule base <1 : also <2 : if x is A1 then y is z1 if y is z2 <n : if x is A2 then ............ x is An then y is zn x is x0 fact: y is z0 action: where A1 , . . . , An are fuzzy sets. Toc JJ II J I Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 24 Suppose further that our data base consists of a single fact x0 . The problem is to derive z0 from the initial content of the data base, x0 , and from the fuzzy rule base < = {<1 , . . . , <n }. <1 : if salary is small then loan is z1 <2 : if salary is big then loan is z2 also fact: salary is x0 loan is z0 action: A deterministic rule base can be formed as follows Toc <1 : if 2000 ≤ s ≤ 6000 then loan is max 1000 <3 : if s ≥ 6000 then loan is max 2000 <4 : if JJ s ≤ 2000 then II J no loan at all J Doc Back I Doc I Section 8: Simplified fuzzy reasoning schemes 25 Figure 7: Discrete causal link between ”salary” and ”loan”. The data base contains the actual salary, and then one of the rules is applied to obtain the maximal loan can be obtained by the applicant. In fuzzy logic everything is a matter of degree. If x is the amount of the salary then x belongs to fuzzy set Toc JJ II J I Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 26 • A1 = small with degree of membership 0 ≤ A1 (x) ≤ 1 • A2 = big with degree of membership 0 ≤ A2 (x) ≤ 1 Figure 8: Membership functions for ”small” and ”big”. In fuzzy rule-based systems each rule fires. Toc JJ II J I Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 27 The degree of match of the input to a rule (wich is the firing strength) is the membership degree of the input in the fuzzy set characterizing the antecedent part of the rule. The overall system output is the weighted average of the individual rule outputs, where the weight of a rule is its firing strength with respect to the input. To illustrate this principle we consider a very simple example mentioned above <1 : if salary is small then loan is z1 <2 : if salary is big then loan is z2 also salary is x0 fact: loan is z0 action: Toc JJ II J I Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 28 Then our reasoning system is the following • input to the system is x0 • the firing level of the first rule is α1 = A1 (x0 ) • the firing level of the second rule is α2 = A2 (x0 ) • the overall system output is computed as the weghted average of the individual rule outputs α1 z1 + α2 z2 z0 = α1 + α2 that is A1 (x0 )z1 + A2 (x0 )z2 z0 = A1 (x0 ) + A2 (x0 ) A1 (x0 ) = Toc JJ 1 − (x0 − 2000)/4000 0 II J I if 2000 ≤ x0 ≤ 6000 otherwise Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 29 Figure 9: Example of simplified fuzzy reasoning. Toc JJ II J I Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 30 1 1 − (6000 − x0 )/4000 A2 (x0 ) = 0 if x0 ≥ 6000 if 2000 ≤ x0 ≤ 6000 otherwise It is easy to see that the relationship A1 (x0 ) + A2 (x0 ) = 1 holds for all x0 ≥ 2000. It means that our system output can be written in the form. z0 = α1 z1 + α2 z2 = A1 (x0 )z1 + A2 (x0 )z2 that is, 6000 − x0 x0 − 2000 z1 + 1 − z2 z0 = 1 − 4000 4000 if 2000 ≤ x0 ≤ 6000. And z0 = 1 if x0 ≥ 6000. And z0 = 0 if x0 ≤ 2000. Toc JJ II J I Back J Doc Doc I Section 8: Simplified fuzzy reasoning schemes 31 Figure 10: Input/output function derived from fuzzy rules. The (linear) input/oputput relationship is illustrated in figure 10. Toc JJ II J I Back J Doc Doc I 32 9. Tsukamoto’s fuzzy reasoning scheme All linguistic terms are supposed to have monotonic membership functions. The firing levels of the rules, denoted by αi , i = 1, 2, are computed by α1 = A1 (x0 ) ∧ B1 (y0 ), α2 = A2 (x0 ) ∧ B2 (y0 ) In this mode of reasoning the individual crisp control actions z1 and z2 are computed from the equations α1 = C1 (z1 ), α2 = C2 (z2 ) and the overall crisp control action is expressed as α1 z1 + α2 z2 z0 = α1 + α2 i.e. z0 is computed by the discrete Center-of-Gravity method. If we have n rules in our rule-base then the crisp control action is computed as Pn αi zi , z0 = Pi=1 n i=1 αi JJ II J I J Doc Doc I Toc Back Section 9: Tsukamoto’s fuzzy reasoning scheme 33 where αi is the firing level and zi is the (crisp) output of the i-th rule, i = 1, . . . , n Example 9.1. We illustrate Tsukamoto’s reasoning method by the following simple example <1 : also <2 : if x is A1 and y is B1 then z is C1 if x is A2 and y is B2 then z is C2 fact : x is x̄0 and y is ȳ0 consequence : z is C Then according to the figure we see that A1 (x0 ) = 0.7, B1 (y0 ) = 0.3 therefore, the firing level of the first rule is α1 = min{A1 (x0 ), B1 (y0 )} = min{0.7, 0.3} = 0.3 Toc JJ II J I Back J Doc Doc I Section 9: Tsukamoto’s fuzzy reasoning scheme 34 and from A2 (x0 ) = 0.6, B2 (y0 ) = 0.8 it follows that the firing level of the second rule is α2 = min{A2 (x0 ), B2 (y0 )} = min{0.6, 0.8} = 0.6, the individual rule outputs z1 = 8 and z2 = 4 are derived from the equations C1 (z1 ) = 0.3, C2 (z2 ) = 0.6 and the crisp control action is z0 = (8 × 0.3 + 4 × 0.6)/(0.3 + 0.6) = 6. Toc JJ II J I Back J Doc Doc I Section 9: Tsukamoto’s fuzzy reasoning scheme 35 Figure 11: Tsukamoto’s inference mechanism. Toc JJ II J I Back J Doc Doc I 36 10. Sugeno’s fuzzy reasoning scheme Sugeno and Takagi use the following architecture <1 : if x is A1 and y is B1 then z1 = a1 x + b1 y <2 : if x is A2 and y is B2 then z2 = a2 x + b2 y also fact : x is x̄0 and y is ȳ0 cons. : z0 The firing levels of the rules are computed by α1 = A1 (x0 ) ∧ B1 (y0 ), α2 = A2 (x0 ) ∧ B2 (y0 ) then the individual rule outputs are derived from the relationships z1∗ = a1 x0 + b1 y0 , z2∗ = a2 x0 + b2 y0 Toc JJ II J I Back J Doc Doc I Section 10: Sugeno’s fuzzy reasoning scheme 37 and the crisp control action is expressed as z0 = α1 z1∗ + α2 z2∗ α1 + α2 Figure 12: Sugeno’s inference mechanism. If we have n rules in our rule-base then the crisp control action is computed JJ II J I J Doc Doc I Toc Back Section 10: Sugeno’s fuzzy reasoning scheme 38 as Pn αi zi∗ z0 = Pi=1 , n i=1 αi where αi denotes the firing level of the i-th rule, i = 1, . . . , n Example 10.1. We illustrate Sugeno’s reasoning method by the following simple example <1 : if x is BIG and y is SMALL then fact : x0 is 3 and y0 is 2 <2 : z1 = x + y if x is MEDIUM and y is BIG then z2 = 2x − y conseq : z0 Then according to the figure we see that µBIG (x0 ) = µBIG (3) = 0.8, µSM ALL (y0 ) = µSM ALL (2) = 0.2 Toc JJ II J I Back J Doc Doc I Section 10: Sugeno’s fuzzy reasoning scheme 39 therefore, the firing level of the first rule is α1 = min{µBIG (x0 ), µSM ALL (y0 )} = min{0.8, 0.2} = 0.2 and from µM EDIU M (x0 ) = µM EDIU M (3) = 0.6, µBIG (y0 ) = µBIG (2) = 0.9 it follows that the firing level of the second rule is α2 = min{µM EDIU M (x0 ), µBIG (y0 )} = min{0.6, 0.9} = 0.6. the individual rule outputs are computed as z1∗ = x0 + y0 = 3 + 2 = 5, z2∗ = 2x0 − y0 = 2 × 3 − 2 = 4 so the crisp control action is z0 = (5 × 0.2 + 4 × 0.6)/(0.2 + 0.6) = 4.25. Toc JJ II J I Back J Doc Doc I Section 10: Sugeno’s fuzzy reasoning scheme 40 Figure 13: Example of Sugeno’s inference mechanism. Toc JJ II J I Back J Doc Doc I