27.12.2023.
ETF
Beograd
Fuzzy Logic
Fuzzy Sets and Fuzzy Rules
Accompanying presentation for lectures 2023/2024
Contents
◼ Characteristics of Fuzzy Sets
◼ Operations
◼ Properties
◼ Fuzzy Sets Examples and Exercises
◼ Fuzzy Rules
◼ Fuzzy Sets & Rules Example
1
27.12.2023.
Characteristics of Fuzzy Sets
◼ The classical set theory developed in the late 19th century by Georg Cantor
describes how crisp sets can interact and these interactions are called
operations.
◼ Also fuzzy sets have well defined both operations and properties, as the
basis for the fuzzy sets to deal with uncertainty on the one hand and to
represent knowledge on the other.
Note: Continuous and discrete fuzzy sets and their membership Functions
◼ When a fuzzy set A is constructed over continuous universe of discourse X,
it is described by its continuous membership function:
A(x), xX
◼ When elements of a fuzzy set A belong to a finite universe of discourse:
X = {x1, x2, .., xn},
a fuzzy set is described by its discrete membership function and it is denoted
as:
A = A(xi)/xi + …………. + A(xn)/xn
where A(xi)/xi (a singleton) is a pair: “grade of membership” / element. 3
Operations of Fuzzy Sets
◼ Elements either belong to crisp sets in full or don’t belong at all.
◼ Operations of crisp sets:
Not A
B
A AA
Complement Containment
A B AA B
Intersection Union
◼ How do we make operations on fuzzy sets, which consist of
elements belonging partially to them?
4
2
27.12.2023.
Complement
◼ Crisp Sets: Who does not belong to the set?
◼ Fuzzy Sets: How much do elements not belong to the set?
◼ The complement of a set is an opposite of this set. For example, if
we have the set of tall men, its complement is the set of NOT tall
men. When we remove the tall men set from the universe of
discourse, we obtain the complement.
◼ If A is the fuzzy set, its complement A can be found as follows:
A(x) = 1 − A(x).
Containment
◼ Crisp Sets: Which sets belong to which other sets?
◼ Fuzzy Sets: How much sets belong to other sets?
◼ Similar to a Chinese box, a set can contain other sets. The smaller
set is called the subset. For example, the set of tall men contains
all tall men; very tall men is a subset of tall men. However, the tall
men set is just a subset of the set of men.
◼ In crisp sets, all elements of a subset entirely belong to a larger set.
◼ In fuzzy sets, however, each element can belong less to the subset
than to the larger set.
◼ Elements of the fuzzy subset have smaller memberships in
the subset than in the larger set.
◼ To be further discussed in Properties of fuzzy sets...
6
3
27.12.2023.
Intersection & Union
◼ Crisp Sets: Which element belongs Crisp Sets: Which element belongs to
to both sets? either set?
Fuzzy Sets: How much of the element is
◼ Fuzzy Sets: How much of the
in either set?
element is in both sets?
◼ In classical set theory, an In classical set theory, a union of two
intersection between two sets crisp sets consists of every element
contains the elements shared by that falls into either set.
these sets.
◼ In fuzzy sets, an element may partly In fuzzy sets, the union is the reverse of
belong to both sets with different the intersection. That is, the union is
memberships. A fuzzy intersection is the largest membership value of
the lower membership in both the element in either set.
sets of each element.
◼ The fuzzy intersection of two fuzzy The fuzzy operation for forming the union
sets A and B on universe of of two fuzzy sets A and B on universe
discourse X (std. definition): X is given (std. definition):
(xX ) AB(x) = min [A(x), B(x)]. (xX ) AB(x) = max [A(x), B(x)].
7
Operations of Fuzzy Sets
4
27.12.2023.
Properties of Fuzzy Sets
◼ Equality of two fuzzy sets
◼ Inclusion of one set into another fuzzy set
◼ Cardinality of a fuzzy set
◼ An empty fuzzy set
◼ -cuts (alpha-cuts)
Equality and Inclusion
◼ Fuzzy set A is equal to a fuzzy set B IF AND ONLY IF (IIF):
◼ A and B are both defined over the same universe X, and
◼ (xX) A(x) = B(x).
◼ Example: Consider discrete fuzzy sets A and B :
A = 0.3/1 + 0.5/2 + 1/3, B = 0.3/1 + 0.5/2 + 1/3.
Universe is the same X = {1, 2, 3}, and it is true that (xX) A(x) = B(x),
therefore A = B.
◼ Fuzzy set A is included in (is a subset of) fuzzy set B IF AND ONLY IF:
◼ A and B are both defined over the same universe X, and
◼ (xX) A(x) B(x).
◼ Example: A = 0.3/1 + 0.5/2 + 1/3, B = 0.5/1 + 0.55/2 + 1/3
Universe is the same X = {1, 2, 3}, and it is true that (xX) A(x) B(x),
therefore A B, or in words: A is a subset of B.
10
10
5
27.12.2023.
Empty Fuzzy Set
◼ A fuzzy set A, defined on universe X, is empty IF AND ONLY IF:
A(x) = 0, xX
◼ Example: Consider X = {1, 2, 3} and fuzzy set
A = 0/1 + 0/2 + 0/3,
then A is empty.
11
11
Alpha-Cut
◼ For a fuzzy set A, defined on universe X,
an -cut (-level set) of A is a crisp set A X
consisting of all elements with a membership grade greater or equal to :
A={xA(x) and xX}.
◼ Example: Consider X = {1, 2, 3} and set A = 0.3/1 + 0.5/2 + 1/3
then: A0.5 = {2, 3}, A0.1 = {1, 2, 3}, A1 = {3}.
◼ Example: Consider continuous universe X = [a, b] and fuzzy set A with
the membership function A(x). -cuts for some 1 and 2 are:
A(x)
1 A2 U
2
A1 U
1
0
X =[a, b]
a b 12
12
6
27.12.2023.
Fuzzy Set Normality
◼ A fuzzy set A over universe X is called normal if there exists at
least one element xX such that A(x) = 1.
◼ A fuzzy set that is not normal is called subnormal.
◼ All crisp sets, except for the null set, are normal.
◼ In fuzzy set theory, the concept of nullness essentially generalises
to subnormality.
◼ The height of a fuzzy set A is the largest membership grade of an
element in A:
height(A) = maxx(A(x)).
◼ Fuzzy set is called normal if and only if:
height(A) = 1.
13
13
Core and Support of Fuzzy Set
◼ Assume A is a fuzzy set over universe of discourse X.
◼ The support of A is the crisp subset of X
consisting of all elements with a non-zero membership grade:
supp(A) = {xA(x) 0 and xX}
◼ The core of A is the crisp subset of X
consisting of all elements with full membership grade:
core(A) = {xA(x) = 1 and xX}
◼ Example: height(A) = 1 (normal fuzzy set)
1
Membership
function has a
trapezoidal form
a b X = [a,b]
core(A)
supp(A) 14
14
7
27.12.2023.
Fuzzy Set Math Operations
◼ kA = {kA(x), xX}
Let k =0.5, and
A = 0.5/a + 0.3/b + 0.2/c + 1/d
then
kA = 0.25/a + 0.15/b + 0.1/c + 0.5/d
◼ Am = {A(x)m, xX}
Let m =2, and
A = 0.5/a + 0.3/b + 0.2/c + 1/d Mathematical
then
Hedge Expression Graphical Representation
Am = 0.25/a + 0.09/b + 0.04/c + 1/d A little [A ( x )]1.3
◼ Previosly given Hedges are really Slightly [A ( x )]1.7
mathematical operations on fuzzy sets!
Very [A ( x )]2
Extremely [A ( x )]3
15
15
Fuzzy Sets Examples 1/2
◼ Consider two fuzzy set over the universe
X = {a, b, c, d, e},
referred to as A and B, respectively:
A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e
and
B = 0.6/a + 0.9/b + 0.1/c + 0.3/d + 0.2/e
◼ Support: ◼ Complement:
supp(A) = {a, b, c, d} A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e
supp(B) = {a, b, c, d, e} A = 0/a + 0.7/b + 0.8/c + 0.2/d + 1/e
◼ Core: ◼ Union:
core(A) = {a} A B = 1/a + 0.9/b + 0.2/c + 0.8/d + 0.2/e
core(B) = {} ◼ Intersection:
A B = 0.6/a + 0.3/b + 0.1/c + 0.3/d + 0/e
16
16
8
27.12.2023.
Fuzzy Sets Examples 2/2
◼ Again, two fuzzy sets over the universe X = {a, b, c, d, e}:
A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e and
B = 0.6/a + 0.9/b + 0.1/c + 0.3/d + 0.2/e
◼ kA:
for k=0.5
kA = 0.5/a + 0.15/b + 0.1/c + 0.4/d + 0/e
◼ Am:
for m=2
Am = 1/a + 0.09/b + 0.04/c + 0.64/d + 0/e
◼ α-cut:
A0.2 = {a, b, c, d}
A0.3 = {a, b, d}
A0.8 = {a, d}
A1 = {a} 17
17
Fuzzy Sets Exercises
For
A = 0.2/a + 0.4/b + 1/c + 0.8/d + 0/e
B = 0/a + 0.9/b + 0.3/c + 0.2/d + 0.1/e
calculate the following:
◼ Support, Core, and Complement for A and B independently,
◼ Union and Intersection of A and B,
◼ the new set C = A2
◼ the new set D, which is the alpha cut at A0.5
18
18
9
27.12.2023.
Fuzzy Sets Solutions
A = 0.2/a + 0.4/b + 1/c + 0.8/d + 0/e
B = 0/a + 0.9/b + 0.3/c + 0.2/d + 0.1/e
Support Union
Supp(A) = {a, b, c, d} AB = 0.2/a + 0.9/b + 1/c + 0.8/d + 0.1/e
Supp(B) = {b, c, d, e}
Intersection
Core AB = 0/a + 0.4/b + 0.3/c + 0.2/d + 0/e
Core(A) = {c}
Core(B) = {} Math Operations
C=A 2
Complement C = 0.04/a + 0.16/b + 1/c + 0.64/d + 0/e
Comp(A) = {0.8/a, 0.6/b, 0/c, 0.2/d, 1/e}
Comp(B) = {1/a, 0.1/b, 0.7/c, 0.8/d, 0.9/e} -cut
D = A0.5 = {c, d}
19
19
Fuzzy Rules
◼ In 1973, Lotfi Zadeh published his second most influential paper. This
paper outlined a new approach to analysis of complex systems, in
which Zadeh suggested capturing human knowledge in fuzzy rules.
◼ A fuzzy rule can be defined as a conditional statement in the form:
IF x is A THEN y is B
where x and y are linguistic variables; and A and B are linguistic
values - fuzzy sets on the universe of discourses X and Y, respectively.
◼ For example:
IF project_duration is LONG THEN completion_risk is HIGH
IF speed is SLOW THEN stopping_distance is SHORT
20
20
10
27.12.2023.
Classical vs. Fuzzy Rules 1/2
◼ A classical IF-THEN rule uses binary logic, for example,
Rule 1: IF speed >100 THEN stopping_distance = long
Rule 2: IF speed < 40 THEN stopping_distance = short
◼ The variable speed can have any numerical value between 0 and
220 km/h, but the linguistic variable stopping_distance can take
either value long or short.
◼ In classical logic, rule is fired only if the antecedent is (strictly) true,
otherwise the consequent is not executed at all.
◼ In other words, classical rules are expressed in the black-and-white
language of Boolean logic.
21
21
Classical vs. Fuzzy Rules 2/2
◼ We can also represent the stopping distance rules in a fuzzy form:
Rule 1: IF speed is FAST THEN stopping_distance is LONG
Rule 2: IF speed is SLOW THEN stopping_distance is SHORT
◼ In fuzzy rules, the linguistic variable speed also has the range
(the universe of discourse) between 0 and 220 km/h, but this range
includes fuzzy sets, such as SLOW, MEDIUM and FAST.
◼ The universe of discourse of the linguistic variable stopping_distance
can be between 0 and 300 m and may include fuzzy sets such as
SHORT, MEDIUM and LONG.
◼ Fuzzy rules relate to fuzzy sets and the belonging of the linguistic
variables to them.
◼ In a fuzzy system, all rules fire to some extent (they are fired partially).
◼ If the antecedent is true to some degree,
then the consequent is also true to that same degree.
22
22
11
27.12.2023.
Firing Fuzzy Rules 1/2
◼ These fuzzy sets provide the basis for a weight estimation model.
The model is based on a relationship between a man’s height and
his weight:
IF height is tall THEN weight is heavy
Degree of Degree of
Membership Membership
1.0 1.0
Tall men Heavy men
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0.0 0.0
160 180 190 200 70 80 100 120
Height, cm Weight, kg
23
23
Firing Fuzzy Rules 2/2
◼ The value of the output or a truth membership grade of the rule
consequent can be estimated directly from a corresponding truth
membership grade in the antecedent. This form of fuzzy inference
uses a method called monotonic selection.
Degree of Degree of
Membership Membership
1.0 1.0
Tall men
0.8 0.8 Heavy men
0.6 0.6
0.4 0.4
0.2 0.2
0.0 0.0
160 180 190 200 70 80 100 120
Height, cm Weight, kg
24
24
12
27.12.2023.
Structure of Fuzzy Rules
◼ A fuzzy rule can have multiple antecedents, for example:
IF duration is LONG AND staffing is LARGE AND funding is INADEQUATE
THEN risk is HIGH
IF temp is WARM OR temp_trend is POSITIVE THEN speed is FAST
◼ The consequent of a fuzzy rule can also include multiple
parts, for instance:
IF water_temperature is HOT THEN hot_water_influx is REDUCED ;
cold_water _influx is INCREASED
25
25
Fuzzy Sets & Rules Example 1/6
◼ Air-conditioning involves the delivery of air which can be warmed or
cooled and have its humidity raised or lowered.
◼ An air-conditioner is an apparatus for controlling, especially
lowering, the temperature and humidity of an enclosed space. An
air-conditioner typically has a fan which blows/cools/circulates fresh
air and has cooler, and the cooler is under thermostatic control.
Generally, the amount of air being compressed is proportional to the
ambient temperature.
◼ Consider Johnny’s air-conditioner which has five control switches:
COLD, COOL, PLEASANT, WARM and HOT.
The corresponding speeds of the motor controlling the fan has the
graduations: MINIMAL, SLOW, MEDIUM, FAST and BLAST.
26
26
13
27.12.2023.
Fuzzy Sets & Rules Example 2/6
◼ The rules governing the air-conditioner are as follows:
RULE 1: IF temp is COLD THEN speed is MINIMAL
RULE 2: IF temp is COOL THEN speed is SLOW
RULE 3: IF temp is PLEASANT THEN speed is MEDIUM
RULE 4: IF temp is WARM THEN speed is FAST
RULE 5: IF temp is HOT THEN speed is BLAST
27
27
Fuzzy Sets & Rules Example 3/6
The temperature graduations
temp COLD COOL PLEASANT WARM HOT
are related to Johnny’s (0C)
perception of ambient
0 Y* N N N N
temperatures where:
5 Y Y N N N
10 N Y N N N
Y : temp value belongs to the
set (0<A(temp)<1) 12.5 N Y* N N N
15 N Y N N N
Y* : temp value is 17.5 N N Y* N N
the ideal member to the set 20 N N N Y N
(A(temp)=1) 22.5 N N N Y* N
25 N N N Y N
N : temp value is not a member 27.5 N N N N Y
of the set (A(temp)=0) 30 N N N N Y*
28
28
14
27.12.2023.
Fuzzy Sets & Rules Example 4/6
◼ The analytically expressed membership for the reference fuzzy subsets for
the temperature are:
◼ COLD: for 0 ≤ temp ≤ 10 COLD(temp) = – temp / 10 + 1
◼ COOL: for 0 ≤ temp ≤ 12.5 COOL(temp) = temp / 12.5
for 12.5 ≤ temp ≤ 17.5 COOL(temp) = – temp / 5 + 3.5
etc… Temperature Membership Functions
1
all based on 0.9
the linear equation 0.8
y = ax + b, i.e. 0.7
Degree of Membership
COLD(temp)
A(temp) = atemp + b 0.6
COOL(temp)
0.5 PLEASANT(temp)
WARM(temp)
0.4
HOT(temp)
0.3
0.2
0.1
0
0 5 10 15 20 25 30
temp [ oC] 29
29
Fuzzy Sets & Rules Example 5/6
Johnny’s perception of the speed MINIMAL SLOW MEDIUM FAST BLAST
speed of the motor is as (RPM)
follows: 0 Y* N N N N
10 Y N N N N
Y : speed value belongs to the 20 Y Y N N N
set (0<A(speed )<1) 30 N Y* N N N
40 N Y N N N
Y* : speed value is 50 N N Y* N N
the ideal member to the set 60 N N N Y N
(A(speed )=1) 70 N N N Y* N
80 N N N Y Y
N : speed value is not a member 90 N N N N Y
of the set (A(speed )=0) 100 N N N N Y*
30
30
15
27.12.2023.
Fuzzy Sets & Rules Example 6/6
◼ The analytically expressed membership for the reference fuzzy subsets for
the speed are:
◼ MINIMAL: for 0 ≤ speed ≤ 30 MINIMAL(speed) = – speed / 30 + 1
◼ SLOW: for 10 ≤ speed ≤ 30 SLOW(speed) = speed / 20 – 0.5
for 30 ≤ speed ≤ 50 SLOW(speed) = – speed / 20 + 2.5
etc… Speed Membership Functions
1
all based on 0.9
the linear equation 0.8
y = ax + b, i.e. 0.7
Degree of Membership
MINIMAL(speed)
A(speed) = aspeed + b 0.6
SLOW(speed)
0.5 MEDIUM(speed)
FAST(speed)
0.4
BLAST(speed)
0.3
0.2
0.1
0
0 10 20 30 40 50 60 70 80 90 100
speed [rpm]
31
31
16