Tutorial On Fuzzy Logic PDF
Tutorial On Fuzzy Logic PDF
Tutorial On Fuzzy Logic PDF
Abstract
Fuzzy logic is based on the theory of fuzzy sets, where an object’s membership of a set is
gradual rather than just member or not a member. Fuzzy logic uses the whole interval of
real numbers between zero (False) and one (True) to develop a logic as a basis for rules of
inference. Particularly the fuzzified version of the modus ponens rule of inference enables
computers to make decisions using fuzzy reasoning rather than exact.
Contents
1 Introduction 2
3 Fuzzy Logic 13
3.1 Propositions 13
3.2 Inference 20
4 Fuzzy Rules 23
4.1 Linguistic Variables 24
4.2 Modus Ponens Inference 25
5 Summary 27
References 28
Kongens Lyngby, DENMARK. Tech. report no 98-E 868 (logic), revised 17 Jun 2008.
1
1 Introduction
An assertion can be more or less true in fuzzy logic. In classical logic an assertion is
either true or false — not something in between — and fuzzy logic extends classical logic
by allowing intermediate truth values between zero and one. Fuzzy logic enables a computer
to interpret a linguistic statement such as
’if the washing machine is half full, then use less water.’
It adds intelligence to the washing machine since the computer infers an action from a set of
such if-then rules. Fuzzy logic is ’computing with words,’ quoting the creator of fuzzy logic,
Lotfi A. Zadeh.
The objective of this tutorial is to explain the necessary and sufficient parts of the theory,
such that engineering students understand how fuzzy logic enables fuzzy reasoning by
computers.
Although the brace notation {·} is practical for listing sets of a few elements, it is
impractical for large sets and impossible for infinite sets. How do we then define a set with a
large number of members?
An answer requires a few more concepts. A proposition is an assertion (declarative
statement) which can be classified as either true or false. By a predicate in x we understand
an assertion formed using a formula in x. For instance, ’0 < x ≤ 3’, or ’x > 10 volts’
are predicates. They are not propositions, however, since they are not necessarily true or
false. Only if we assign a value to the variable x, each predicate becomes a proposition. A
predicate P (x) in x defines a set X by the convention that the members of X are exactly
those objects a such that P (a) is true. In mathematical notation:
{x | P (x)} ,
read ’the set of all x such that P (x).’ Thus a ∈ {x | P (x)} iff P (a) is a true proposition.
A system in which propositions must be either true or false, but not both, uses a
two-valued logic. As a consequence, what is not true is false and vice versa; that is the law of
the excluded middle. This is only an approximation to human reasoning, as Zadeh observed:
3
Clearly, the "class of all real numbers which are much greater than 1," or "the
class of beautiful women," or "the class of tall men," do not constitute classes or sets
in the usual mathematical sense of these terms. (Zadeh, 1965[12])
Zadeh’s challenge we might call it, because for instance ’tall’ is an elastic property. To
define the set of tall men as a classical set, one would use a predicate P (x), for instance
x ≥ 176, where x is the height of a person, and the right hand side of the inequality a
threshold value in centimeters (176 centimeters ' 5 foot 9 inches). This is an abrupt
approximation to the concept ’tall’. From an engineering viewpoint, it is likely that the
measurement is uncertain, due to a source of noise in the equipment. Thus, measurements
within the narrow band 176 ± ε, where ε expresses variation in the noise, could fall on either
side of the threshold randomly.
Following Zadeh a membership grade allows finer detail, such that the transition from
membership to non-membership is gradual rather than abrupt. The membership grade for all
members defines a fuzzy set (Fig. 1). Given a collection of objects U, a fuzzy set A in U is
defined as a set of ordered pairs
A ≡ {hx, μA (x)i | x ∈ U} (1)
where μA (x) is called the membership functionfor the set of all objects x in U — for the
symbol ’≡’ read ’defined as’. The membership function relates to each x a membership
grade μA (x), a real number in the closed interval [0, 1]. Notice it is now necessary to
work with pairs hx, μA (x)i whereas for classical sets a list of objects suffices, since their
membership is understood. An ordered pair hx, yi is a list of two objects, in which the
object x is considered first and y second (note: in the set {x, y} the order is insignificant).
The term ’fuzzy’ (indistinct) suggests an image of a boundary zone, rather than an abrupt
frontier. Indeed, fuzzy logicians speak of classical sets being crisp sets,to distinguish them
from fuzzy sets. As with crisp sets, we are only guided by intuition in deciding which
objects are members and which are not; a formal basis for how to determine the membership
grade of a fuzzy set is absent. The membership grade is a precise, but arbitrary measure: it
rests on personal opinion, not reason.
The definition of a fuzzy set extends the definition of a classical set, because membership
values μ are permitted in the interval 0 ≤ μ ≤ 1, and the higher the value, the higher the
membership. A classical set is consequently a special case of a fuzzy set, with membership
values restricted to μ ∈ {0, 1}.
A single pair hx, μ(x)i is a fuzzy singleton; thus the whole set can be viewed as the
union of its constituent singletons.
4
1
0.8
--- fuzzy
Membership
0.6
0.4
--- crisp
0.2
0
150 160 170 180 190 200
Height [cm]
Figure 1. Two definitions of the set of "tall men", a crisp set and a fuzzy set. (figtall.m)
Members of a fuzzy set are taken from a universe of discourse, or universefor short. The
universe is all objects that can come into consideration, confer the set U in (1). The universe
depends on the context, as the next example shows.
Example 3 Universes
(a) The set x À 1 could have as a universe all real numbers, alternatively all positive
integers.
(b) The set of young people could have all human beings in the world as its universe.
Alternatively it could have the numbers between 0 and 100; these would then represent age
in years.
(c) The universe depends on the measuring unit; a duration in time depends on whether
it is measured in hours, days, or weeks.
(d) A non-numerical quantity, for instance taste, must be defined on a psychological
continuum; an example of such a universe is U = {bitter, sweet, sour, salt, hot}.
A programmer can exploit the universe to suppress faulty measurement data, for instance
negative values for a duration of time, by making the program consult the universe.
5
1 1
0.8 0.8
Membership
Membership
0.6 0.6
0.4 0.4
0.2 0.2
0 0
06 08 10 12 14 16 18 06 08 10 12 14 16 18
a) b)
1 1
0.8 0.8
Membership
Membership
0.6 0.6
0.4 0.4
0.2 0.2
0 0
06 08 10 12 14 16 18 06 08 10 12 14 16 18
c) d)
Figure 2. Around noon. Four possible membership functions representing the time ’around
noon’: a) trapeziodal, b) triangular, c) smooth trapezoid, and d) smooth triangular. The
universe is the hours of the day in 24-hour format. (figmf0.m)
6
and c ≤ x ≤ d by a nonlinear function, for instance a half period of a cosine function,
⎧ ⎫
⎪
⎪ 0 ,x ≤ a ⎪
⎪ 1 + 1 cos( x−b π) , a ≤ x ≤ b ⎪
⎪ ⎪
⎪
⎨ 2 2 b−a ⎬
μST rapezoid (x; a, b, c, d) = 1 ,b ≤ x ≤ c ,x ∈ R
⎪
⎪ 1 1 x−c ⎪
⎪
⎪
⎪ + cos( π) , c ≤ x ≤ d ⎪
⎪
⎩ 2 2 d−c ⎭
0 ,d ≤ x
We call it here STrapezoid for ’smooth trapezoid’ or ’soft trapezoid’. Figures 2 (c-d)
illustrate the smooth membership functions. Other possibilities exist for generating smooth
trapezoidal functions, for example Gaussian, generalized bell, and sigmoidal membership
functions (Jang et al., 1997[4]).
Discrete fuzzy sets are defined by means of a discrete variable xi (i = 1, 2, . . .). A
discrete fuzzy set A is defined by ordered pairs,
A = {hx1 , μ(x1 )i , hx2 , μ(x2 )i , . . . | xi ∈ U, i = 1, 2, . . .}
Each membership value μ(xi ) is an evaluation of the membership function μ at a discrete
point xi in the universe U, and the whole set is a collection, usually finite, of pairs
hxi , μ(xi )i.
As a crude rule of thumb, the continuous form is more computing intensive, but less
storage demanding than the discrete form.
Zadeh writes that a fuzzy set induces a possibility distribution on the universe, meaning,
one can interpret the membership values as possibilities. How are then possibilities related
to probabilities? First of all, probabilities must add up to one, or the area under a density
curve must be one. Memberships may add up to anything (discrete case), or the area under
the membership function may be anything (continuous case). Secondly, a probability
distribution concerns the likelihood of an event to occur, based on observations, whereas
7
a possibility distribution (membership function) is subjective. The word ’probably’ is
synonymous with presumably, assumably, doubtless, likely, presumptively. The word
’possible’ is synonymous with doable, feasible, practicable, viable, workable. Their
relationship is best described in the sentence: what is probable is always possible, but not
vice versa. This is illustrated next.
Equality and inclusion are defined by means of membership functions. Two fuzzy sets A
and B are equal, iff they have the same membership function,
A = B ≡ μA (x) = μB (x) (3)
for all x. A fuzzy set A is a subset of (included in) a fuzzy set B, iff the membership of A is
less than equal to that of B,
A ⊆ B ≡ μA (x) ≤ μB (x) (4)
for all x.
8
A B A B A B
a) b) c)
A B A B A B
d) e) f)
Figure 3. Set operations. The top row are classical Venn diagrams; the universe is repre-
sented by the points within the rectangle, and sets by the interior of the circles. The bottom
row their fuzzy equivalents; the universal set is represented by a horisontal line at member-
ship μ = 1, and sets by membership functions. The shaded areas are: a) and d) union A ∪ B,
b) and e) intersection A ∩ B, and c) and f) complement A ∪ B. (figvenn2.m)
9
shows an intuitively acceptable modification of the Venn diagrams. The following fuzzy set
operations are defined accordingly:
Let A and B be fuzzy sets defined on a mutual universe U. The fuzzy union of A and B
is
A ∪ B ≡ {hx, μA∪B (x)i | x ∈ U and μA∪B (x) = max (μA (x) , μB (x))}
The fuzzy intersection of A and B is
A ∩ B ≡ {hx, μA∩B (x)i | x ∈ U and μA∩B (x) = min (μA (x) , μB (x))}
The fuzzy complement of A is
A ≡ {hx, μA (x)i | x ∈ U and μA (x) = 1 − μA (x)}
While the notation may look cumbersome, it is in practice easy to apply the fuzzy set
operations max, min, and 1 − μ.
In mathematics the word ’relation’ is used in the sense of relationship, for example the
10
predicates: x is less than y, or y is a function of x. A binary relation R is a set of ordered
pairs. We may write it xRy which reads: ’x is related to y.’ There are established symbols
for various relations, for example x = y, x < y. One simple relation is the set of all pairs
hx, yi, such that x is a member of a set X and y is a member of a set Y. This is the (classical)
cartesian product of X and Y,
X × Y = {hx, yi | x ∈ X , y ∈ Y}
In fact, any binary relation xRy is a subset of the cartesian product X × Y, and we can think
of those instances of X × Y, that are members of R as having membership 1.
By analogy, a binary fuzzy relation consists of pairs hx, yi with an associated fuzzy
membership value. For example, given X = Y = {1, 2, 3} we can set up a relation
’approximately equal’ between all pairs of the three numbers, most clearly displayed in a
tabular arrangement,
Y
1 2 3
1 1 0.8 0.3
X 2 0.8 1 0.8
3 0.3 0.8 1
In the fuzzy cartesian product each object is defined by a pair: the object, which is a pair
itself, and its membership. Let A and B be fuzzy sets defined on X and Y respectively, then
the cartesian product A × B is a fuzzy set in X × Y with the membership function
© ® ª
A × B = hx, yi , μA×B (x, y) | x ∈ X , y ∈ Y, μA×B (x, y) = min (μA (x), μB (y))
For example, assume X and Y are as above, and μA (xi ) = h0, 0.5, 1i, with i = 1, 2, 3, and
μB (yj ) = h1, 0.5, 0i , with j = 1, 2, 3, then A × B is a two-dimensional fuzzy set
B
1 0.5 0
0 0 0 0
A 0.5 0.5 0.5 0
1 1 0.5 0
The element at row i and column j is the intersection of μA (xi ) and μB (yj ). Again
we note that to each object hxi , yj i is associated a membership μA×B (xi , yj ), whereas the
classical cartesian product consists of objects hxi , yj i only.
In order to see how to combine relations, let us look at an example from the cartoon
Donald Duck.
11
Let us assume another relation between nephews Dewey and Louie on the one side, and uncle
Donald on the other, a matrix with two rows and one column,
Donald
R2 = Dewey 0.5
Louie 0.6
We wish to find out how much Huey resembles Donald by combining the information in the
two matrices. Observe that
(i) Huey resembles Dewey (R1 (1, 1) = 0.8), and Dewey in turn resembles Donald (R2 (1, 1) =
0.5), or
(ii) Huey resembles Louie (R1 (1, 2) = 0.9), and Louie in turn resembles Donald (R2 (2, 1) =
0.6).
Assertion (i) contains two relationships combined by ’and’; it seems reasonable to take
the intersection. With our definition, this corresponds to choosing the smallest membership
value for the (transitive) Huey-Donald relationship, or min(0.8, 0.5) = 0.5. Similarly with
statement (ii). Thus from chains (i) and (ii), respectively, we deduce that
(iii) Huey resembles Donald to the degree 0.5, or
(iv) Huey resembles Donald to the degree 0.6.
Although the results in (iii) and (iv) differ, we are equally confident in either result; we have
to choose either one or the other, so it seems reasonable to take the union. With our definition,
this corresponds to choosing the largest membership value, or max (0.5, 0.6) = 0.6. Thus,
the answer is that Huey resembles Donald to the degree 0.6.
12
For the tables R1 and R2 above, the inner product yields,
0.5
R1 ◦ R2 = 0.8 0.9 ◦ = (0.8 ∩ 0.5) ∪ (0.9 ∩ 0.6) = 0.5 ∪ 0.6 = 0.6
0.6
which agrees with the previous result.
3 Fuzzy Logic
Logic started as the study of language in arguments and persuasion, and it can be used
to judge the correctness of a chain of reasoning — in a mathematical proof for instance.
The goal of the theory is to reduce principles of reasoning to a code. The ’truth’ or ’falsity’
assigned to a proposition is its truth-value. In fuzzy logic a proposition may be true or
false, or an intermediate truth-value such as maybe true. The sentence ’John is a tall man’
is an example of a fuzzy proposition. For convenience we shall here restrict the possible
truth-values to a discrete domain {0, 0.5, 1} for false, maybe true, and true. In doing so we
are in effect restricting the theory to multi-valued logic, or rather three-valued logic to be
specific. In practice one would subdivide the unit interval into finer divisions, or work with a
continous truth-domain. Nevertheless, much of what follows is valid even in a continuous
domain as we shall see.
3.1 Propositions
In daily conversation and mathematics, sentences are connected with the words and, or,
if-then (or implies), and if and only if. These are called connectives. A sentence which is
modified by the word ’not’ is called the negation of the original sentence.The word ’and’ is
used to join two sentences to form the conjunction of the two sentences. The word ’or’ is
used to join two sentences to form the disjunction of the two sentences. From two sentences
we may construct one, of the form ’If ... then ...’; this is called an implication. The sentence
following ’If’ is the antecedent, and the sentence following ’then’ is the consequent. Other
idioms which we shall regard as having the same meaning are ’p implies q’, ’p only if q’, ’q
if p’, etc.
Letters and special symbols make the connective structure stand out. Our choice of
symbols is
¬ for ’not’
∧ for ’and’
∨ for ’or’
⇒ for ’if-then’ (implication)
⇔ for ’if and only if’ (equivalence)
The next example illustrates how the symbolic forms expose the underlying logical structure.
13
Consider the assertion about four baseball teams: If either the Pirates or the Cubs loose and
the Giants win, then the Dodgers will be out of first place, and I will loose a bet. Since it is
an implication, it may be symbolised in the form r ⇒ s. The antecedent is composed from
the three sentences p (The Pirates lose), c (The Cubs lose), and g (The Giants win). The
consequent is the conjunction of d (The Dodgers will be out of first place) and b (I will lose
a bet). The original sentence may thus be represented by ((p ∨ c) ∧ g) ⇒ (d ∧ b).
14
From ’nand’ (’not and’) we derive ’and’ by negating the entries of the table (’not not and’ =
’and’),
And
¬ ((¬p) ∨ (¬q))
0 1 →q
0 0 0
1 0 1
↓
p
Notice that it was possible to define ’and’ by means of ’or’ and ’not’, rather than assume its
definition given as an axiom.
By means of ’or’ and ’not’ we can proceed to define ’implication’. Classical logic
defines implication ¬p ∨ q, which is called material implication. We negate the p-axis of the
’or’ table, which is equivalent to reversing the axis and permuting the entries back in the
usual ascending order, thus
Implication
¬p ∨ q
0 1 →q
0 1 1
1 0 1
↓
p
Equivalence is taken to mean (p ⇒ q) ∧ (q ⇒ p), which is equivalent to the conjunction of
each entry of the implication table with the elements of the transposed table, element by
element, or
Equivalence
(p ⇒ q) ∧ (q ⇒ p)
0 1 →q
0 1 0
1 0 1
↓
p
It is possible to evaluate, in principle at least, a logical proposition by an exhaustive test
of all combinations of truth-values of the variables, and this is the idea behind array based
logic (Franksen, 1979[1]). The next example illustrates an application of array based logic.
15
’I win the bet’ (b = 0), then the following table results
p c g d b
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
1 0 0 0 0
1 0 0 1 0
1 1 0 0 0
1 1 0 1 0
There are thus 10 winning outcomes out of 32 possible.
16
Nand And
(¬p) ∨ (¬q) ¬((¬p) ∨ (¬q))
0 0.5 1 →q 0 0.5 1 →q
0 1 1 1 0 0 0 0 (7)
0.5 1 0.5 0.5 0.5 0 0.5 0.5
1 1 0.5 0 1 0 0.5 1
↓ ↓
p p
It is reassuring to observe that even though the truth-table for ’and’ is derived from the
truth-table for ’or’, the truth-table for ’and’ is identical to one generated using the min
operation, set intersection.
The implication, however, has always troubled fuzzy logicians. If we define it as material
implication, ¬p ∨ q, then we get a fuzzy truth-table which is unsuitable, as it causes several
useful logical laws to break down. It is important to realise, that we must make a design
choice at this point, in order to proceed with the definition of implication and equivalence.
The choice is which logical laws we wish to apply.
Not all laws known from two-valued logic can be valid in fuzzy logic. Take for instance
the propositional form
p ∨ ¬p ⇔ 1 (8)
which is equivalent to the law of the excluded middle. Testing with the truth-value p = 0.5
(fuzzy logic) the left hand side yields
0.5 ∨ ¬0.5 = max (0.5, 1 − 0.5) = 0.5.
This is different from the right hand side, and thus the law of the excluded middle is
invalid in fuzzy logic. If a proposition is true with a truth-value of 1, for any combination
of truth-values assigned to the variables, we shall say it is valid. Such a proposition is a
tautology. If the proposition is true for some, but not all combinations, we shall say it is
satisfiable. Thus (8) is satisfiable, since it is true in two-valued logic, but not in three-valued
logic.
One tautology that we definitely wish to apply in fuzzy logic applications is
Tautology 1: [p ∧ (p ⇒ q)] ⇒ q (9)
Or in words: If p, and p implies q, then q. We have labelled it tautology 1, because we need
it later in connection with the modus ponens rule of inference. Another tautology that we
definitely wish to apply in fuzzy logic applications is the transitive relationship
Tautology 2: [(p ⇒ q) ∧ (q ⇒ r)] ⇒ (p ⇒ r) (10)
Or in words from left to right: if p implies q which in turn implies r, then p implies
r. Whether these propositions are valid in fuzzy logic depends on how we define the
connectives. Or rather, we must define the connectives, implication in particular, such that
those propositions become valid (Jantzen, 1995[5]).
Many researchers have proposed definitions for the implication connective (e.g., Zadeh,
1973; Mizumoto, Fukami & Tanaka, 1979; Fukami, Mizumoto & Tanaka, 1980; Wenstøp,
1980[13, 9, 2, 11]; see also the survey by Lee, 1990[7]). In fact Kiszka, Kochanska &
17
Sliwinska list 72 alternatives to choose from (1985[6]). One candidate, not necessarily the
best, is the so-called sharp implication. It can be defined
p⇒q≡p≤q (11)
This choice is motivated by the following argument. When the crisp set X is included in the
crisp set Y, then X is said to imply Y. The fuzzy set A is included in the fuzzy set B, iff
μA (x) ≤ μB (x) by (4), therefore we define implication by (11).
Once it is agreed that p ⇔ q is the same as (p ⇒ q) ∧ (q ⇒ p), the truth-table for
equivalence (⇔) is determined from implication and conjunction,
Implication Equivalence
p≤q (p ⇒ q) ∧ (q ⇒ p)
0 0.5 1 →q 0 0.5 1 →q
0 1 1 1 0 1 0 0 (12)
0.5 0 1 1 0.5 0 1 0
1 0 0 1 1 0 0 1
↓ ↓
p p
The example indicates that fuzzy logic provides more solutions, compared to two-valued
logic, and it requires more computational effort.
It is straight forward to test whether tautologies 1 and 2 are valid, because it is possible
to perform an exhaustive test of all combinations of truth-values of the variables, provided
the domain of truth-values is discrete and limited.
18
values, there will be 32 = 9 possible combinations to test. The truth-table has 9 rows,
p q p⇒q [p ∧ (p ⇒ q)] [p ∧ (p ⇒ q)] ⇒ q
0 0 1 0 1
0 0.5 1 0 1
0 1 1 0 1
0.5 0 0 0 1
0.5 0.5 1 0.5 1
0.5 1 1 0.5 1
1 0 0 0 1
1 0.5 0 0 1
1 1 1 1 1
Columns 1 and 2 are the input combinations of p and q. Column 3 is the result of sharp
implication, and column 4 is the left hand side of tautology 1. Since the rightmost column is
all 1’s, the proposition is a tautology, even in three-valued logic.
19
fuzzy set in X × Y with the membership function
{hhx, yi , μA0 ⇒0 B (x, y)i | x ∈ X , y ∈ Y, μA0 ⇒0 B (x, y) = min (μA (x), μB (y))}
Notice the definition is similar to the definition of the fuzzy cartesian product. Its Cayley
table, using the minimum operation, is
Mamdani ’implication’
min(p, q)
0 0.5 1 →q
0 0 0 0
0.5 0 0.5 0.5
1 0 0.5 1
↓
p
One discovers by inspection that only one out of the four corner-values matches the truth-
table for two-valued implication. Therefore, it is not an implication, and Mamdani ’inference’
would be a more appropriate name, as we shall see later.
3.2 Inference
Logic provides principles of reasoning, by means of inference, the drawing of conclusions
from assertions. The verb ’to infer’ means to conclude from evidence, deduce, or to have as
a logical consequence (do not confuse ’inference’ with ’interference’). Rules of inference
specify conclusions drawn from assertions known or assumed to be true.
One such rule of inference is modus ponens. It is often presented in the form of an
argument:
P
P ⇒Q
Q
In words: If 1) P is known to be true, and 2) we assume that P ⇒ Q is true, then 3) Q
must be true. Restricting for a moment to two-valued logic, we see from the truth-table for
implication,
Implication
p⇒q
0 1 →q
0 1 1 , (13)
1 0 1
↓
p
whenever P ⇒ Q and P are true then so is Q; by P true we consider only the second row,
leaving Q true as the only possibility. In such an argument the assertions above the line
are the premises, and the assertion below the line the conclusion. Notice the premises are
assumed to be true, we are not considering all possible truth combinations as we did when
proving tautologies.
On the other hand, underlying modus ponens is tautology 1, which expresses the same,
20
but is valid for all truth-values. Therefore modus ponens is valid in fuzzy logic, if tautology
1 is valid in fuzzy logic.
The inference mechanism in modus ponens can be generalised. The pattern is: given
a relation R connecting logical variables p and q, we infer the possible values of q given
a particular instance of p. Switching to vector-matrix representation, to emphasize the
computer implementation, with p a (column) vector and R a two-dimensional truth-table,
with the p-axis vertical, the inference is defined
qt = pt ◦ R
The operation ◦ is an inner ∨ − ∧ product. The ∧ operation is the same as in p ∧ (p ⇒ q)
and the ∨ operation along the columns yields what can possibly be implied about q, confer
21
the rightmost implication in [p ∧ (p ⇒ q)] ⇒ p. Assuming p is true corresponds to setting
µ ¶
0
p= .
1
But the scheme is more general, because we could also assume p is false, compose with R
and study what can be inferred about q. Take for instance modus ponens, thus
µ ¶
1 1
R=
0 1
which is the truth-table for p ⇒ q. Assigning p as above,
µ ¶
t t
¡ ¢ 1 1 ¡ ¢
q =p ◦R= 0 1 ◦ = 0 1
0 1
The outcome qt is a truth-vector pointing at q true as the only possible conclusion, as
expected. Testing for instance with p = (1 0)t yields
µ ¶
t t
¡ ¢ 1 1 ¡ ¢
q =p ◦R= 1 0 ◦ = 1 1
0 1
Thus q could be anything, true or false, as expected. The inference could even proceed in the
reverse direction, from q to p, but then we must compose from the right side of R to match
the axes. Assume for instance q is true, or q = (1 0)t , then
µ ¶ µ ¶ µ ¶
1 1 1 1
p=R◦q= ◦ =
0 1 0 0
To interpret: if q is false and p ⇒ q, then p is false (modus tollens).
The array based inference mechanism is even more general, because R can be any
dimension n (n > 0 and integer). Given values of n − 1 variables, the possible outcomes
of the remaining variable can be inferred by an n-dimensional inner product. Furthermore,
given values of n − d variables (d integer and 0 < d < n), then the truth-array connecting
the remaining d variables can be inferred.
Generalising to three-valued logic p and q are vectors of three elements, R a 3-by-3
matrix, and the inner ∨ − ∧ product interpreted as the inner max-min product. Assuming p
is true, corresponds to assigning ⎛ ⎞
0
p = ⎝ 0.5 ⎠
1
In modus ponens ⎛ ⎞
1 1 1
R = ⎝ 0 1 1 ⎠,
0 0 1
which is the truth-table for sharp implication. With p as above,
⎛ ⎞
¡ ¢ 1 1 1 ¡ ¢
qt = pt ◦ R = 0 .5 1 ◦ ⎝ 0 1 1 ⎠ = 0 .5 1
0 0 1
To interpret, p true and p ⇒ q true, implies q true, as expected because tautology 1 is valid
22
in three valued logic.
The inner product pt ◦ R can be decomposed into three operations.
1. A cartesian product
⎛ ⎞ ⎛ ⎞
0 ¡ ¢ 0 0 0
R1 = p × 1t = ⎝ 0.5 ⎠ × 1 1 1 = ⎝ 0.5 0.5 0.5 ⎠
1 1 1 1
called the cylindrical extension. The result is a matrix whose columns are the vector p
repeated as many times as necessary to fit the size of R.
2. An element-wise intersection
⎛ ⎞ ⎛ ⎞ ⎛ ⎞
0 0 0 1 1 1 0 0 0
R2 = R1 ∧ R = ⎝ 0.5 0.5 0.5 ⎠ ∧ ⎝ 0 1 1 ⎠ = ⎝ 0 0.5 0.5 ⎠
1 1 1 0 0 1 0 0 1
This operation does not have a name in the literature.
3. An ∨-operation along the columns of R2 ,
_ ¡ ¢
qt = 2
rpq = 0 0.5 1
p
4 Fuzzy Rules
A fuzzy rule has the form
If x is A then y is B,
in which A and B are fuzzy sets, defined on universes X and Y, respectively. This is an
implication, where the antecedent is ’x is A’, and the consequent is ’y is B’. Examples of
such rules in everyday conversation are
1. If it is dark, then drive slowly
2. If the tomato is red, then it is ripe
3. If it is early, then John can study
4. If the room is cold, then increase the heat
5. If the washing machine is half full, then wash shorter time
23
Other forms can be transcribed into the if-then form, for example ’when in Rome, do
like the Romans’ becomes ’if in Rome, then do like the Romans’. Examples 4 and 5 could
appear in a computer embedded in a heating unit or a washing machine.
To understand how a computer can infer a conclusion, take rule 3,
If it is early, then John can study
Assume that ’early’ is a fuzzy set defined on the universe
U = h4, 8, 12, 16, 20, 24i .
These are times t of the day, in steps of four hours, in 24 hour format to distinguish night
from day numerically. Define ’early’ as a fuzzy set on U,
early = {h4, 0i , h8, 1i , h12, 0.9i , h16, 0.7i , h20, 0.5i , h24, 0.2i}
For simplicity define ’can study’ as a singleton fuzzy set μstudy = 1. If the hour is truly
early, for instance 8 o’clock in the morning, then μearly (8) = 1, and thus John can study to
the fullest degree, that is μstudy = 1. However, at 20 (8 pm) then μearly (20) = 0.5, and
accordingly John can study to the degree 0.5. The degree of fulfillment of the antecedent
(the if -side) weights the degree of fulfillment of the conclusion — a useful mechanism, that
enables one rule to cover a range of hours. The procedure is: given a particular time instant
t0 , the resulting truth-value is computed as min(μearly (t0 ), μstudy ).
A hedge is a word that acts on a term and modifies its meaning. For example, in the
sentence ’very near zero’, the word ’very’ modifies the term ’near zero’. Examples of other
hedges are ’a little’, ’more or less’, ’possibly’, and ’definitely’. In fuzzy reasoning a hedge
operates on a membership function, and the result is a membership function.
Even though it is difficult precisely to say what effect the hedge ’very’ has, it does have
an intensifying effect. The hedge ’more or less’ (or ’morl’ for short) has the opposite effect.
Given a fuzzy term with the label A and membership function μA (x) defined on the universe
24
X , the hedges ’very’ and ’morl’ are defined
© ® ª
very A ≡ x, μvery A (x) | μvery A (x) = μ2A (x), x ∈ X
n 1
o
morl A ≡ hx, μmorl A (x)i | μmorl A (x) = μA2
(x), x ∈ X
We have applied squaring and square root, but a whole family of hedges is generated by μkA
1
or μA
k
(with integer k). For example
© ® ª
extremely A ≡ x, μvery A (x) | μvery A (x) = μ3A (x), x ∈ X
n ® 1
o
slightly A ≡ x, μvery A (x) | μvery A (x) = μA
3
(x), x ∈ X
A derived hedge is for example somewhat A defined as morl A and not slightly A. For
1
the special case where k = 2, the operation μ2 is concentration and μ 2 is dilation. With
k = ∞ the hedge μkA could be named exactly, because it would suppress all memberships
lower than 1.
A primary term is a term that must be defined a priori, for example Young and Old in Fig.
4, whereas the sets Very young and Not very young are modified sets. The primary terms can
be modified by negation (’not’) or hedges (’very’, ’more or less’), and the resulting sets can
be connected using connectives (’and’, ’or’, ’implies’, ’equals’). Long sentences can be built
using this vocabulary, and the result is still a membership function.
25
1 1
Membership
0.6 0.6 ----- More or less old
--- Young
0 0
0 20 40 60 80 100 0 20 40 60 80 100
Age Age
Figure 4. The membership functions for very young and not very young are derived from
young (left), and the membership function for more or less old from old (right). (figage.m)
It is based on modus ponens, but the premise A0 is slightly different from A and thus the
conclusion B 0 is slightly different from B. For instance, given the rule ’if x is High, then y
is Low’; if x in fact is ’very high’, we would like to conclude that y is ’very low’.
Let A and A0 be fuzzy sets defined on X , and B a fuzzy set defined on Y. Then the fuzzy
set B 0 , induced by ’x is A’ from the fuzzy rule
if x is A then y is B,
is given by
B 0 = A0 ◦ (A ⇒ B) .
The operation ◦ is composition, the inner ∨ − ∧ product.
26
The matrix is displayed with boxes and axis annotations to make the construction of the
table clear: each element rxy is the evaluation of μHigh (x) ≤ μLow (y). The numbers on
the vertical axis correspond to μHigh and the numbers on the horisontal axis correspond to
μLow . Assuming altitude is High, we find by modus ponens
μt = μtHigh ◦ R
⎛ ⎞
1 1 1 1 1
⎜ 1 1 1 1 0 ⎟
¡ ¢ ⎜ ⎟
= 0 .25 .5 .75 1 ◦ ⎜
⎜ 1 1 1 0 0 ⎟
⎟
⎝ 1 1 0 0 0 ⎠
1 0 0 0 0
¡ ¢
= 1 .75 .5 .25 0
The result is identical to Low, thus modus ponens returns a result as expected in that case.
Assume instead altitude is Very High,
¡ ¢
μtV eryHigh = 0 .06 .25 .56 1 ,
the square of μtHigh . Modus ponens yields
μt = μtV eryHigh ◦ R
⎛ ⎞
1 1 1 1 1
⎜ 1 1 1 1 0 ⎟
¡ ¢ ⎜ ⎟
= 0 .06 .25 .56 1 ◦⎜
⎜ 1 1 1 0 0 ⎟
⎟
⎝ 1 1 0 0 0 ⎠
1 0 0 0 0
¡ ¢
= 1 .56 .25 .06 0
The result is identical to the square of μLow . Written as an argument, we have
Very High
High ⇒ Low
Very Low
This is not always the case, though. With a slightly different definition of Low, say,
Low = {h0, 1i , h25, 0.8i , h50, 0.5i , h75, 0.3i , h100, 0i}
the resulting vector μt would be the same as previously, but only approximately equal to Very
Low.
5 Summary
Fuzzy reasoning is based on fuzzy logic, which is again based on fuzzy set theory. The
idea of a fuzzy set is basic and simple: an object is allowed to have a gradual membership
of a set. This simple idea pervades all derived mathematical aspects of set theory. In fuzzy
27
logic an assertion is allowed to be more or less true. A truth value in fuzzy logic is a real
number in the interval [0, 1], rather than just the set of two truth values {0, 1} of classical
logic. Classical logic can be fuzzified in many ways, but the central problem is to find a
suitable definition for the connective ’implication’. Fuzzy reasoning is based on the modus
ponens rule of inference, which again rests on the definition of ’implication’.
Not all laws in classical logic can be valid in fuzzy logic, therefore the design of a fuzzy
system is a trade-off between mathematical rigour and engineering requirements.
A backward approach is recommended:
1. Start by deciding which laws are required to hold;
2. define ’and’, ’or’, ’not’, ’implication’, and ’equivalence’;
3. check by means of their truth tables whether the laws in step 1 hold; and
4. if not, go to 2.
An assumption made in the tutorial is that the laws can be checked by just checking
all combinations of three truth-values {0, 0.5, 1} . This is true for all expressions involving
variables connected with ∧, ∨, and ¬, but one must be cautious with expressions involving
implication, as these generally cannot be reduced to those three connectives. Furthermore, it
is assumed in the tutorial that truth-values are taken from a finite, discrete set of truth-values.
This is not the case in general.
References
[1] O. I. Franksen. Group representation of finite polyvalent logic. In A. Niemi, editor,
Proceedings 7th Triennial World Congress, Helsinki, 1978. International federation of
automatic control, IFAC, Pergamon.
[2] S. Fukami, M. Mizumoto, and K. Tanaka. Some considerations of fuzzy conditional
inference. Fuzzy Sets and Systems, 4:243–273, 1980.
[3] Mai Gerhke, Carol L. Walker, and Elbert A. Walker. Normal forms and truth tables for
fuzzy logics. Fuzzy Sets And Systens, 138:25–51, 2003.
[4] J.-S. R. Jang, C.-T. Sun, and E. Mizutani. Neuro-Fuzzy and Soft Computing. Number
isbn 0-13-261066-3 in Matlab Curriculum Series. Prentice Hall, Upper Saddle River,
NJ, USA, 1997.
[5] J. Jantzen. Array approach to fuzzy logic. Fuzzy Sets and Systems, 70:359–370, 1995.
[6] J. B. Kiszka, M. E. Kochanska, and D. S. Sliwinska. The influence of some fuzzy
implication operators on the accuracy of a fuzzy model. Fuzzy Sets and Systems,
15:(Part1) 111–128; (Part 2) 223 – 240, 1985.
[7] C. C. Lee. Fuzzy logic in control systems: Fuzzy logic controller. IEEE Trans.
Systems, Man & Cybernetics, 20(2):404–435, 1990.
[8] E. H. Mamdani. Application of fuzzy logic to approximate reasoning using linguistic
28
synthesis. IEEE Transactions on Computers, C-26(12):1182–1191, December 1977.
[9] M. Mizumoto, S. Fukami, and K. Tanaka. Some methods of fuzzy reasoning. In
Gupta, Ragade, and Yager, editors, Advances in Fuzzy Set Theory Applications.
North-Holland, New York, 1979.
[10] Robert R. Stoll. Set Theory And Logic. Dover Publications, New York, dover edition,
1979. (org 1963).
[11] F. Wenstøp. Quantitative analysis with linguistic values. Fuzzy Sets and Systems,
4(2):99–115, 1980.
[12] L. A. Zadeh. Fuzzy sets. Inf. and control, 8:338–353, 1965.
[13] L. A. Zadeh. Outline of a new approach to the analysis of complex systems and
decision processes. IEEE Trans. Systems, Man & Cybernetics, 1:28–44, 1973.
[14] L. A. Zadeh. The concept of a linguistic variable and its application to approximate
reasoning. Information Sciences, 8:43–80, 1975.
[15] L. A. Zadeh. Fuzzy logic. IEEE Computer, 21(4):83–93, April 1988.
[16] H.-J. Zimmermann. Fuzzy set theory - and its applications. Kluwer, Boston, second
edition, 1993. (1. ed. 1991).
29