Artificial Intelligence
CIS 342
The College of Saint RoseDavid Goldschmidt, Ph.D.
Expert knowledge oftenuses vague and inexact terms
Fuzzy Logic describes fuzziness by specifying degrees – e.g. degrees of height, speed,
distance, temperature, beauty, intelligence, etc.
Fuzzy Logic
Unlike Boolean logic, fuzzy logic is multi-valued – Fuzzy logic represents degrees of
membershipand degrees of truth
– Things can be part true and part false at the same time
Fuzzy Logic
(a) Boolean Logic. (b) Multi-valued Logic0 1 10 0.2 0.4 0.6 0.8 1001 10
A linguistic variable is a fuzzy variable– e.g. the fact “John is tall” implies linguistic
variable “John” takes the linguistic value “tall”
– Use linguistic variables to form fuzzy rules:
Linguistic Variables
IF ‘project duration’ is longTHEN risk is high
IF risk is very highTHEN ‘project funding’ is very low
What about linguistic values with qualifiers?– e.g. very tall, extremely short, etc.
Hedges are qualifying terms that modifythe shape of fuzzy sets– e.g. very, somewhat, quite, slightly,
extremely, etc.
Qualifiers & Hedges
Representing Hedges
Hedge MathematicalExpression
A little
Slightly
Very
Extremely
Graphical Representation
[A(x)]1.3
[A(x)]1.7
[A(x)]2
[A(x)]3
Representing Hedges
Hedge MathematicalExpression
A little
Slightly
Very
Extremely
Graphical Representation
[A(x)]1.3
[A(x)]1.7
[A(x)]2
[A(x)]3
Hedge MathematicalExpression
A little
Slightly
Very
Extremely
Graphical Representation
[A(x)]1.3
[A(x)]1.7
[A(x)]2
[A(x)]3
Representing Hedges
Hedge MathematicalExpression Graphical Representation
Very very
More or less
Indeed
Somewhat
2 [A(x )]2
A(x)
A(x)
if 0 A 0.5
if 0.5 < A 1
1 2 [1 A(x)]2
[A(x)]4
Representing Hedges
Hedge MathematicalExpression Graphical Representation
Very very
More or less
Indeed
Somewhat
2 [A(x )]2
A(x)
A(x)
if 0 A 0.5
if 0.5 < A 1
1 2 [1 A(x)]2
[A(x)]4
Hedge MathematicalExpression Graphical Representation
Very very
More or less
Indeed
Somewhat
2 [A(x )]2
A(x)
A(x)
if 0 A 0.5
if 0.5 < A 1
1 2 [1 A(x)]2
[A(x)]4
Linguistic Variables & Hedges
Short
Very Tall
ShortTall
DegreeofMembership
150 210180 190 200
1.0
0.0
0.2
0.4
0.6
0.8
160 170
Height, cm
Average
TallVery Short Very Tall
write a function or method called very() that
modifies the degree of membershipe.g. double x = very( tall( 185 ) );
Crisp set operations developed by Georg Cantor in the late 19th century:
Crisp Set Operations
Intersection Union
Complement
NotA
A
Containment
AA
B
BA AA B
Crisp set operations developed by Georg Cantor in the late 19th century (continued):
Crisp Set Operations
Intersection Union
Complement
NotA
A
Containment
AA
B
BA AA B
Complement– To what degree do elements not belong to
this set?
Fuzzy Set Operations
Intersection Union
Complement
NotA
A
Containment
AA
B
BA AA B
Complement
0x
1
(x)
0x
1
Containment
0x
1
0x
1
AB
Not A
A
Intersection
0x
1
0x
AB
Union0
1
ABAB
0x
1
0x
1
B
A
B
A
(x)
(x) (x)
¬A(x) = 1 – A(x)
Containment– Which sets belong to other sets?
Fuzzy Set Operations
Intersection Union
Complement
NotA
A
Containment
AA
B
BA AA B
Complement
0x
1
(x)
0x
1
Containment
0x
1
0x
1
AB
Not A
A
Intersection
0x
1
0x
AB
Union0
1
ABAB
0x
1
0x
1
B
A
B
A
(x)
(x) (x)
Each element of the fuzzysubset has smaller membership
than in the containing set
Intersection– To what degree is the element in both sets?
Fuzzy Set Operations
Intersection Union
Complement
NotA
A
Containment
AA
B
BA AA B
Complement
0x
1
(x)
0x
1
Containment
0x
1
0x
1
AB
Not A
A
Intersection
0x
1
0x
AB
Union0
1
ABAB
0x
1
0x
1
B
A
B
A
(x)
(x) (x)
A∩B(x) = min[ A(x), B(x) ]
Union– To what degree is the element in either or
both sets?
Fuzzy Set Operations
Intersection Union
Complement
NotA
A
Containment
AA
B
BA AA B
Complement
0x
1
(x)
0x
1
Containment
0x
1
0x
1
AB
Not A
A
Intersection
0x
1
0x
AB
Union0
1
ABAB
0x
1
0x
1
B
A
B
A
(x)
(x) (x)
AB(x) = max[ A(x), B(x) ]
1965 paper: “Fuzzy Sets” (Lotfi Zadeh)– Apply natural language terms to a formal
system of mathematical logic– http://www.cs.berkeley.edu/~zadeh
1973 paper outlined a new approach to capturing human knowledge and designing expert systems using fuzzy rules
Fuzzy Rules
A fuzzy rule is a conditional statementin the familiar form:
IF x is ATHEN y is B
– x and y are linguistic variables– A and B are linguistic values determined by
fuzzy sets on the universe of discourses X and Y, respectively
Fuzzy Rules
A linguistic variable is a fuzzy variable– e.g. the fact “John is tall” implies linguistic
variable “John” takes the linguistic value “tall”
– Use linguistic variables to form fuzzy rules:
Linguistic Variables
IF ‘project duration’ is longTHEN ‘risk’ is high
IF risk is very highTHEN ‘project funding’ is very low
A fuzzy expert system is an expert system thatuses fuzzy rules, fuzzy logic, and fuzzy sets
Many rules in a fuzzy logic systemwill fire to some extent– If the antecedent is true to some degree of
membership, then the consequent is true to the same degree
Fuzzy Expert Systems
Two distinct fuzzy sets describing tall and heavy:
Fuzzy Expert Systems
Tall men Heavy men
180
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Height, cm
190 200 70 80 100160
Weight, kg
120
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Tall men Heavy men
180
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Height, cm
190 200 70 80 100160
Weight, kg
120
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
IF height is tallTHENweight is heavy
Fuzzy Expert Systems
Tall menHeavy men
180
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Height, cm
190 200 70 80 100160
Weight, kg
120
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Other examples (multiple antecedents):– e.g. IF ‘project duration’ is long
AND ‘project staffing’ is largeAND ‘project funding’ is
inadequateTHEN risk is high
– e.g. IF service is excellentOR food is deliciousTHEN tip is generous
Fuzzy Expert Systems
Other examples (multiple consequents):– e.g. IF temperature is hot
THEN ‘hot water’ is reduced;‘cold water’ is increased
Fuzzy Expert Systems
Named after Ebrahim Mamdani, the Mamdani method for fuzzy inference is:1. Fuzzify the input variables2. Evaluate the rules3. Aggregate the rule outputs4. Defuzzify
Fuzzy Inference
Rule 1:IF x is A3OR y is B1THEN z is C1
Rule 2:IF x is A2AND y is B2THEN z is C2
Rule 3:IF x is A1THEN z is C3
Fuzzy Inference – Example
Rule 1:IF ‘project funding’ is adequateOR ‘project staffing’ is smallTHEN risk is low
Rule 2:IF ‘project funding’ is marginalAND ‘project staffing’ is largeTHEN risk is normal
Rule 3:IF ‘project funding’ is inadequateTHEN risk is high
x, y, and z are linguistic variablesA1, A2, and A3 are linguistic values on XB1 and B2 are linguistic values on YC1, C2, and C3 are linguistic values on Z
1.Fuzzification
Fuzzy Inference – Example
CrispInput
0.1
0.71
0y1
B1 B2
Y
CrispInput
0.20.5
1
0
A1 A2 A3
x1
x1 X(x =A1) = 0.5(x =A2) = 0.2
(y =B1) = 0.1(y =B2) = 0.7
project funding project staffing
inadequate
marginal large
small
2.Rule 1 evaluation
Fuzzy Inference – Example
A31
0 X
1
y10 Y
0.0
x1 0
0.1C1
1
C2
Z
1
0 X
0.2
0
0.2 C11
C2
Z
A2
x1
Rule 3: IF x isA1 (0.5)
A11
0 X 0
1
Zx1
THEN
C1 C2
1
y1
B2
0 Y
0.7
B10.1
C3
C3
C30.5 0.5
OR(max)
AND(min)
OR THENRule 1: IF x isA3 (0.0)
AND THENRule 2: IF x isA2 (0.2)
y isB1 (0.1) z isC1 (0.1)
y isB2 (0.7) z isC2 (0.2)
z isC3 (0.5)
project fundingproject staffing
adequate small
risk
low
2.Rule 2 evaluation
Fuzzy Inference – Example
A31
0 X
1
y10 Y
0.0
x1 0
0.1C1
1
C2
Z
1
0 X
0.2
0
0.2 C11
C2
Z
A2
x1
Rule 3: IF x isA1 (0.5)
A11
0 X 0
1
Zx1
THEN
C1 C2
1
y1
B2
0 Y
0.7
B10.1
C3
C3
C30.5 0.5
OR(max)
AND(min)
OR THENRule 1: IF x isA3 (0.0)
AND THENRule 2: IF x isA2 (0.2)
y isB1 (0.1) z isC1 (0.1)
y isB2 (0.7) z isC2 (0.2)
z isC3 (0.5)
project funding project staffing
marginal large
risk
normal
2.Rule 3 evaluation
Fuzzy Inference – Example
A31
0 X
1
y10 Y
0.0
x1 0
0.1C1
1
C2
Z
1
0 X
0.2
0
0.2 C11
C2
Z
A2
x1
Rule 3: IF x isA1 (0.5)
A11
0 X 0
1
Zx1
THEN
C1 C2
1
y1
B2
0 Y
0.7
B10.1
C3
C3
C30.5 0.5
OR(max)
AND(min)
OR THENRule 1: IF x isA3 (0.0)
AND THENRule 2: IF x isA2 (0.2)
y isB1 (0.1) z isC1 (0.1)
y isB2 (0.7) z isC2 (0.2)
z isC3 (0.5)
project funding
inadequate
risk
high
00.1
1C1
z isC1 (0.1)
C2
0
0.2
1
z isC2 (0.2)
0
0.5
1
z isC3 (0.5)
ZZZ
0.2
Z0
C30.5
0.1
3.Aggregation of the rule outputs
Fuzzy Inference – Example
risk
highnormallow
00.1
1C1
z isC1 (0.1)
C2
0
0.2
1
z isC2 (0.2)
0
0.5
1
z isC3 (0.5)
ZZZ
0.2
Z0
C30.5
0.1
4.Defuzzification– e.g. use the centroid method in
which a vertical lineslices the aggregate setinto two equal halves
– How can we calculate this?
Fuzzy Inference – Example
4.Defuzzification– Calculate the centre of gravity (cog):
Fuzzy Inference – Example
b
aA
b
aA
COG
x x dx
x dx
4.Defuzzification– Use a reasonable sampling of points
Fuzzy Inference – Example
4.675.05.05.05.02.02.02.02.01.01.01.0
5.0)100908070(2.0)60504030(1.0)20100(
COG
1.0
0.0
0.2
0.4
0.6
0.8
0 20 30 40 5010 70 80 90 10060
Z
DegreeofMembership
67.4
4.675.05.05.05.02.02.02.02.01.01.01.0
5.0)100908070(2.0)60504030(1.0)20100(
COG
1.0
0.0
0.2
0.4
0.6
0.8
0 20 30 40 5010 70 80 90 10060
Z
DegreeofMembership
67.4
Why use fuzzy expert systems or fuzzy control systems?– Apply fuzziness (and therefore accuracy) to
linguistically defined terms and rules– Lack of crisp or concrete mathematical models
exist
When do you avoid fuzzy expert systems?– Traditional approaches produce acceptable results– Crisp or concrete mathematical models exist and
are easily implemented
Applications of Fuzzy Logic
Real-world applications include:– Control of robots, engines, automobiles,
elevators, etc.– Cruise-control in automobiles– Temperature control– Reduce vibrations in camcorders
http://www.esru.strath.ac.uk/Reference/concepts/fuzzy/fuzzy_appl.de20.htm
– Handwriting recognition, OCR– Predictive and diagnostic systems (e.g.
cancer)
Applications of Fuzzy Logic