Lecture04 (Fuzzy Logic)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Adama Science and Technology

University

EPCE6202 Intelligent Control


and Its Applicatons
(Fuzzy Logic)

ASTU
School of EEC

1. Classical logic
Juliet, would
you marry
me?

Juliet says yes or no.

1
Contd
Juliet, would
you take my
heart?

Juliet is impressed.

Contd
Am I tall?

1foot= 30.48cm

2
Contd
(Definition) Classical logic
Logic is defined as the study of human thinking and
its principles.

Classical logic (or binary logic) deals only with


propositions that have a truth value of either true or
false as a result

true false
yes no
1 0

Contd
This has evolved into three-valued logic, in which
there are three truth values indicating true, false and
indeterminate, as well as n-valued logic.

true false indeterminate


yes no indeterminate
1 0 indeterminate

3
Contd
(Definition) Proposition(or statement)
A proposition is a sentence(subject + predicate) that
is either true or false. If a proposition is true, then we
say its truth value is true, and vice versa.
For example
(1) Ethiopia is in Africa. (true)
(2) 12+8= 20 (true)
(3) 6  2 (false)
(4) What is this? (not proposition)
Note that (2) and (3) are formulas, but they can be
described in sentence form.

2. Classical connectives
Connectives
• Sentences are connected with the words 'not',
'and', 'or', and 'if-then'.
• not negates the original sentence.
• and joins two sentences to form the conjunction
of the two sentences.
• or joins two sentences to form the disjunction of
the two sentences.
• if-then is called an implication.
For example,
if food is rancid or service is poor, then tip is cheap
if food is good and service is good, then tip is
average

4
Contd
(Definition) Negation
Logical negation is an operator that results false
when the proposition is true and vice versa, denoted
by 'not p' or p.
p p
0 1
1 0

For example
p: ASTU is located in Adama. p= 1 (true)
p : ASTU is not located in Adama  p = 0 (false)

Contd
(Definition) Disjunction (Inclusive or)
'Inclusive or' is a connective that results true when at
least one of the propositions is true, denoted by pq.

p q pq
0 0 0
0 1 1
1 0 1
1 1 1

5
Contd
For example
p: 2  2 p= 0
q: 5  2 q= 1
pq: ( 2  2) or ( 5  2) pq= 1

For example
p: 5 is a prime number p= 1
q: 18 is an odd number q= 0
pq: 5 is a prime number or 18 is an odd number
 pq= 1

Contd
(Definition) Disjunction (Exclusive or)
'Exclusive or (XOR)' is a logical operator which
results true when either of the propositions are true
(one is true and the other one is false) but both are
not true, denoted by 'pq'.

p q pq
0 0 0
XOR
0 1 1
1 0 1
1 1 0

6
Contd
For example
p: A tossing coin's face is head p= 1
q: A tossing coin's face is tail q= 0
pq: A tossing coin's face is head or a
tossing coin's face is tail  pq= 1

A: 1 1 0
B: 0 1 1

A: 110
B: 011
S 001
CPU Adder Cout 1

Contd
A: 1 1 0 CPU Adder
XOR
B: 0 1 1 XOR

AND

OR
AND

A: 110
B: 011
S 001
Cout 0

7
Contd
A: 1 1 0 CPU Adder
XOR
B: 0 1 1 XOR

AND

OR
AND

A: 110
B: 011
S 001
Cout 1

Contd
A: 1 1 0 CPU Adder
XOR
B: 0 1 1 XOR

AND

OR
AND

A: 110
B: 011
S 001
Cout 1

8
Contd
(Definition) Conjunction
Conjunction is a logical operator which results true
when both p and q are true, denoted by pq.

p q pq
0 0 0
0 1 0
1 0 0
1 1 1

Contd
For example
p: 2+2= 4  p=1
q: 3+2= 9  q= 0
pq: (2+2= 4) and (3+2)= 9  pq= 0

For example
p:  is a real number  p= 1
q:  > 3.14  q= 1
pq:  is a real number and  > 3.14
 pq= 1

9
Contd
(Definition) Implication
Implication ('if-then') is a logical connective that
represents a type of relationship between two
statements as:

if p, then q  pq
• 'pq' means 'p implies q'. 'implies' is used in the
strongest possible sense.
• 'pq' is false only when p=1 and q=0, and is
always true in the others.

Contd

if p, then q  pq

p q pq pq (pq)p


0 0 1 1 1
0 1 1 1 1
1 0 0 0 0
1 1 1 1 1

Note that pq is equal to pq and (pq)p.

10
Contd
For example
p= Janice has a driver's license
q= Janice can drive

if p(= 0), then q(= 0) (true)


if p(= 0), then q(= 1) (true)
if p(= 1), then q(= 0) (false)
if p(= 1), then q(= 1) (true)

Contd
Logical implication does not work both ways.

For example
p= the sky is clear
q= the sun is visible
If p(= 0), then q(= 1) (true)
However,
If q(= 1), then p(= 0) (not necessarily true. It might be
not clear or clear)

11
3. Classical rules of inference
Classical rules of inference
• An inference rule is a process of deriving a new
proposition or logical expression from a proposition
or a logical expression.
• New propositions or logical expressions must not
have logical contradictions with existing propositions
or logical expressions. That is, logical consequences
must always be true.
• Typical reasoning rules are modus ponens, modus
tollens, and hypothetical syllogism.

Contd
(Definition) Modus Ponens(MP)
Modus ponens leads to a new proposition q (result)
from two propositions p (fact) and p→q (premise or
rule), which is intuitively expressed as follows:

fact : p
rule : if p, then q (or p q)
result: q

The final result of modus ponens is always true


regardless of the value of p and q.

12
Contd
For example
fact : Jones doesn't breathe
rule : if x doesn't breathe, then it will die
result: Jones will die

For example
fact : The pine tree is a plant
rule : If x is a plant, then it needs water, air
and sunlight
result: The pine tree needs water, air and sunlight

Contd
fact :p
rule or premise : p q
result :q
can be expressed simply as (p(pq))q
p q pq p(pq) (p(pq))q
0 0 1 0 1
0 1 1 0 1
1 0 0 0 1
1 1 1 1 1

13
Contd
(Definition) Modus Tollens(MT)
Modus tollens leads to a new proposition p (result)
from two propositions q (fact) and p→q (premise or
rule), which is intuitively expressed as follows:

fact : q
rule : if p, then q (or p q)

result : p
The final result of modus tollens is always true
regardless of the value of p and q.

Contd
fact : q
rule : p q
result : p

For example
fact : RoboCop does not die
rule : if x is a human being, then one will die
result : RoboCop isn't a human being

fact : A cow doesn't breathe


rule : if x is alive, then it breathes
result : It is not alive

14
Contd
fact :q
rule : p q
result :p
can be expressed simply as (q(pq))p
p(p) q(q) pq q(pq) (q(pq))p
0(1) 0(1) 1 1 1
0(1) 1(0) 1 0 1
1(0) 0(1) 0 0 1
1(0) 1(0) 1 0 1

Contd
(Definition) Hypothetical syllogism(HS)
Syllogism leads to a new proposition pr (result)
from two propositions pq and qr, which are
intuitively expressed as follows:

fact : if p, then q or pq)


rule : if q, then r(or q r)
result : if p, then r or pr)

The final result of modus tollens is always true


regardless of the value of p, q and r.

15
Contd
fact : pq
rule : q r
result : pr
For example
fact : if x is a robocop, then it patrols
rule : if x patrols, then it needs a motorbike
result : if x is a robocop, then it need a motorbike

fact : If a cow is alive, then it breathes


rule : if x breathes, then it needs air
result : if a cow is alive, then it needs air

Contd
fact : pq
rule : qr
result : pr
can be expressed as ((pq)(qr))(pr)
(pq) ((pq)(qr))
p q r pq qr pr
(qr) (pr)
0 0 0 1 1 1 1 1
0 0 1 1 1 1 1 1
0 1 0 1 0 1 0 1
0 1 1 1 1 1 1 1
1 0 0 0 1 0 0 1
1 0 1 0 1 1 0 1
1 1 0 1 0 0 0 1
1 1 1 1 1 1 1 1

16
4. Linguistic variables
(Definition) Linguistic variable
A variable which can take words in natural languages
as its values (linguistic value) is called a linguistic
variable. linguistic value(fuzzy set)
If error is big, then control is big
linguistic variable
small mediem big

error
0 5 10 15

5. Fuzzy modifiers
• Fuzzy modifiers(hedges) are terms that modify the
shape of fuzzy sets.
• They include adverbs such as very, somewhat,
quite, more or less and slightly.

17
Contd
Hedge Mathematical Graphical Representation
Expression

A little [A ( x )]1.3

Slightly [A ( x )]1.7

Very [A ( x )]2

Extremely [A ( x )]3

Contd
(Definition) Fuzzy logic
Fuzzy logic is described in the form of sentences, as
classical logic, but by using ambiguous words and
ambiguous sentences, the result can not be either true
or false.

For example
p: John is a handsome boy.
q: He is tall.
r: Lake Langano is beautiful.

18
6. Fuzzy logic: Definition
(Definition) Fuzzy proposition
A single fuzzy proposition is called a simple fuzzy
proposition, and it is called a compound fuzzy
proposition when they are combined with the
conjunction such as 'and', 'or', 'not' or 'if-then'.
single compound
p1: x is Small p3: x is Small or y is not Big
p2: y is Big p4: x is Small and y is Big

x, y: liguistic variables
Small, Big: liguistic values or fuzzy sets

7. Compound proposition
(Definition) Logical negation
Consider a fuzzy set A and a fuzzy proposition.
p: x is not A
'not A' can be expressed as a fuzzy complement:

A = {(u, A̅ (u)) | uA)

where the MF can be obtained by applying one of the


fuzzy set operators.

19
Contd
Standard:
A̅(u)= 1A(u)

Sugeno class:
1   A (u )
A̅(u)= , where  (-1,)
1   A (u )
Yager class:
1
A̅(u)= (1   A (u )) w
w
, where w(0,)

Contd
For example A(u) 1
U= {u| -2u2}
A= 'zero'= {(u,A(u))}
p: x is not A u
-0.5 0 0.5
not A can be written simply as A, and when the standard
operator is adopted, its MF is as follows:
A̅(u)
A̅(u)= 1A(u) 1

u
-0.5 0 0.5

20
Contd
(Definition) Disjunction
Given A= {(u,A(u))}, B= {(v,B(v))}, the compound
fuzzy proposition

p: x is A or y is B
results a fuzzy relation as
AB= {((u,v), AB(u,v)) | uA, vB)
where AB(u,v)= s[A(u),B(v)]

s can be one of the following s-norm operators.

Contd
Standard
AB(u,v)= A(u)B(v)
Algebraic
AB(u,v)= A(u)+B(v)-A(u)B(v)
Yager class
1
AB(u,v)=
min[1, (  A (u )   B (v)) w ]
w w
Bounded sum
AB(u,v)= min[1, A(u)+B(v)]
Drastic sum   A (u ), if  B (v)  0

AB(u,v)=   B (v), if  A (u )  0
 1, if  A (u ),  B (v)  0

21
Contd
a 1.0 
For example, U= {a, b, c, d}
b 0.8
A= 1.0/a + 0.8/b+0.5/c+0.3/d MA   
B= 0.3/a + 0.4/b+0.5/c+1.0/d c 0.5
 
d  0.3
a b c d
M B   0.3 0.4 0.5 1.0
Compound fuzzy proposition
using the standard operator is a b c d
p: x is A or y is B  AB a 1.0 1.0 1.0 1.0 
b 0.8 0.8 0.8 1.0 
 M A B  MA  MB 
c 0.5 0.5 0.5 1.0 
 
d  0.3 0.4 0.5 1.0 

Contd
For example, consider the relation matrices of fuzzy
sets A and B as
a b v w x
M A   0.5 0.7  M B   0.6 0.1 0.9

The compound fuzzy proposition using the algebraic


operator is
AB(u,v)= A(u)+B(v)-
p: x is A or y is B A(u)B(v)
v w x
a  0.8 0.55 0.95 
 M A B  
b 0.88 0.73 0.97 

22
Contd
For example U= {u| -2u2}, V= {v| -3v3}
A= 'zero'= {(u,A(u))}, B= 'positive'= {(v,B(v))}

A(u) 1 B(v) 1

u v
-0.5 0 0.5 0 1

Compound fuzzy proposition


p: x is A or y is B

Contd
When a standard operator is adopted, its MF is
AB(u,v)= A(u)B(v).

AB(u,v)
1

0.5

0
2 2
0
0
v -2
-2
u

23
Contd
(Definition) Conjunction
Given A= {(u,A(u))}, B= {(v,B(v))}, the compound
fuzzy proposition

p: x is A and y is B
results a fuzzy relation as
AB= {((u,v), AB(u,v)) | uA, vB)
where AB(u,v)= t[A(u),B(v)]

where t can be one of the following t-norm operators.

Contd
Standard
AB(u,v)= A(u)B(v)
Algebraic
AB(u,v)= A(u)B(v)
Yager class 1
AB(u,v)= 1  min[1, ((1   A (u ))  (1   B (v)) ) ]
w w w

Bounded sum
AB(u,v)= max[0, A(u)+B(v)-1]
Drastic sum   A (u ), if  B (v)  1

AB(u,v)=   B (v), if  A (u )  1
 0, if  A (u ),  B (v)  1

24
Contd
a 1.0 
For example, U= {a, b, c, d}
b 0.8
A= 1.0/a + 0.8/b+0.5/c+0.3/d MA   
B= 0.3/a + 0.4/b+0.5/c+1.0/d c 0.5
 
d  0.3
a b c d
M B   0.3 0.4 0.5 1.0
Compound fuzzy proposition
using the standard operator is a b c d
p: x is A and y is B  AB a 0.3 0.4 0.5 1.0 
b 0.3 0.4 0.5 0.8
 M A B  MA  MB 
c 0.3 0.4 0.5 0.5
 
d 0.3 0.3 0.3 0.3

Contd
For example, consider the relation matrices of fuzzy
sets A and B as
a b v w x
M A   0.5 0.7  M B   0.6 0.1 0.9

The compound fuzzy proposition using the algebraic


operator is
AB(u,v)= A(u)B(v)
p: x is A and y is B
v w x
a  0.3 0.05 0.45
 M A B  
b 0.42 0.07 0.63

25
Contd
For example U= {u| -2u2}, V= {v| -3v3}
A= 'zero'= {(u,A(u))}, B= 'positive'= {(v,B(v))}

A(u) 1 B(v) 1

u v
-0.5 0 0.5 0 1

Compound fuzzy proposition


p: x is A and y is B

Contd
When a standard operator is adopted, its MF is
AB(u,v)= A(u)B(v).

AB(u,v) 0.5

0
2 2
0 0
-2
v -2
u

26
8. Fuzzy if-then statement
(Definition) Single if-then statement
Given A= {(u,A(u))}, B= {(v,B(v))}, the fuzzy
implication
if x is A, then y is B

can be simply written as AB that results a fuzzy


relation as

AB= {((u,v), AB(u,v))|uU, vV}

where AB(u,v) can be determined as

Contd
Boolean:
AB(u,v)= (1-A(u))B(v)
Zadeh(arithmetic):
AB(u,v)=1(1- A(u)+B(v))
Zadeh(max):
AB(u,v)=max[A(u)B(v),1-A(u)]
Mamdani(min):
AB(u,v)= A(u)B(v)
Larsen(product):
AB(u,v)= A(u)B(v)

27
Contd
For example U= {u| -2u2}, V= {v| -3v3}
A= 'zero'= {(u,A(u))}, B= 'positive'= {(v,B(v))}

A(u) 1 B(v) 1

u v
-0.5 0 0.5 0 1

Fuzzy implication
p: if x is A, then y is B

Contd
The MF using the min or product operator is
AB(u,v)= A(u)B(v) : min operator
AB(u,v)= A(u).B(v) : product operator

AB(u,v) AB(u,v)
1
1

0.5
0.5

0
0
2 2
2 2 0
0 0
0 -2
-2
-2
v -2
v u u
min product

28
Contd
For example, a 0.2 
U= {a,b,c}, V={e,f,g} M A  b 0.6 
A= 0.2/a+0.6/b+1.0/c c 1.0 
B= 1.0/e+ 0.4/f+0.5/g e f g
Fuzzy implication M B  1.0 0.4 0.5
p: if x is A, then y is B
e f g
Applying the min operator gives
a 0.2 0.2 0.2 
 M A B  M A  M B  b 0.6 0.4 0.5
c 1.0 0.4 0.5

Contd
a 0.2  e f g
M A  b 0.6  M B  1.0 0.4 0.5
c 1.0 

Applying the product operator yields


e f g
a 0.2 0.08 0.1
 M A B  M A  M B  b 0.6 0.24 0.3
c 1.0 0.4 0.5

29
Contd
(Quiz 1) Given U= {u1,u2,u3,u4}, V={v1,v2,v3}
A= 0.7/u2+0.2/u3+0.3/u4, B= 0.6/v1+0.6/v3
obtain
p: if x is A, then y is B
using the Boolean and Zadeh(arithmetic) operators.

Note that
Boolean: AB(u,v)= (1-A(u))B(v)
Zadeh(arithmetic): AB(u,v)=1(1- A(u)+B(v))

Contd
Relation matrices of A and B
u1  0 
v1 v2 v3
u2 0.7 
MA  M B   0.6 0 0.6
u3  0.2 
 
u4  0.3 
Boolean: AB(u,v)= (1-A(u))B(v)
v1 v2 v3
u1 1.0 1.0 1.0 
u  0.6 0.3

0.6 
 M A B  2
u3  0.8 0.8 0.8 
 
u4 0.7 0.7 0.7 

30
Contd
Relation matrices of A and B
u1  0 
v1 v2 v3
u2 0.7 
MA  M B   0.6 0 0.6
u3  0.2 
 
u4  0.3 
Zadeh(arithmetic): AB(u,v)=1(1- A(u)+B(v))
v1 v2 v3
u1  1 1 1
u2 0.9 1 1

 M A B 
u3  1 0.8 1
 
u4  1 0.7 1

Contd
(Definition) Compound if-then statement
if x is A1, then y is B1 also
if x is A2, then y is B2 also
:
if x is An, then y is Bn
where x, y: linguistic variables
Ai, Bi(i=1,...,n): fuzzy sets

The above statement can be written by

A1B1 also A2B2 also ... also AnBn

31
Contd
In general, since the connective 'also' uses the max
operator, it can be calcuated as follows:

A1B1 also A2B2 also ... also AnBn

= {((u,v), (u,v))|uU, vV}


where
(u,v)= max[A1B1(u,v), A2B2(u,v),, AnBn(u,v) ]
= A1B1(u,v) A2B2(u,v)  AnBn(u,v)

Contd
For example, U= {a,b,c}, V= {e,f,g}
A1= 0.2/a+0.6/b+1.0/c, B1= 1.0/e+ 0.4/f
A2= 0.7/a+0.4/c, B2= 0.5/f+ 0.2/g

Fuzzy proposition
if x is A1, then y is B1 also
if x is A2, then y is B2

Applying the min operator for implication and the


max operator for also gives

32
Contd
Relation matrices of A1, B1 are
a 0.2  e f g
M A1  b 0.6  M B1  1.0 0.4 0
c 1.0 

Fuzzy implication A1B1 yields


e f g
a 0.2 0.2 0 
 M A1  B1  M A1  M B1  b 0.6 0.4 0 
c 1.0 0.4 0 

Contd
Relation matrices of A2, B2 are

a 0.7  e f g
M A2  b  0  M B 2   0 0.5 0.2
c  0.4 
Fuzzy implication A2B2 yields
e f g
a 0 0.5 0.2 
 M A2  B2  b 0 0 0 
c 0 0.4 0.2 

33
Contd
Therefore, A1B1 also A2B2 becomes

e f g e f g
a 0.2 0.2 0  a  0 0.5 0.2 
 M A1  B1 also M A2  B 2  b 0.6 0.4 0   b 0 0 0 
c 1.0 0.4 0  c 0 0.4 0.2 
e f g
a 0.2 0.5 0.2 
 b 0.6 0.4 0 
c 1.0 0.4 0.2 

Contd
For example, U= {a,b,c}, V= {e,f,g}
A1= 0.2/a+0.6/b+1.0/c, B1= 1.0/e+ 0.4/f
A2= 0.7/a+0.4/c, B2= 0.5/f+ 0.2/g

Fuzzy proposition
if x is A1, then y is B1 also
if x is A2, then y is B2

Applying the product operator for implication and the


max operator for also gives

34
Contd
Relation matrices of A1, B1 are
a 0.2  e f g
M A1  b 0.6  M B1  1.0 0.4 0
c 1.0 

Fuzzy implication A1B1 yields


e f g
a 0.2 0.08 0 
 M A1  B1  M A1  M B1  b 0.6 0.24 0 
c 1.0 0.4 0 

Contd
Relation matrices of A2, B2 are

a 0.7  e f g
M A2  b  0  M B 2   0 0.5 0.2
c  0.4 
Fuzzy implication A2B2 yields
e f g
a 0 0.35 0.14 
 M A2  B2  b 0 0 0 
c 0 0.2 0.08 

35
Contd
Therefore, A1B1 also A2B2 becomes

e f g e f g
a 0.2 0.08 0  a 0 0.35 0.14 
 M A1  B1 also M A2  B 2  b 0.6 0.24 0   b 0 0 0 
c 1.0 0.4 0  c 0 0.2 0.08
e f g
a 0.2 0.35 0.14 
 b 0.6 0.24 0 
c 1.0 0.4 0.08

(Quiz 1) U= ‘Errors’= {0, 0.5, 1, 1.5, 2}

Error
0 0.5 1 1.5 2

Define your fuzzy set in U.

A= ‘Big error’

36
(Answer) U= ‘Errors’= {0, 0.5, 1.0, 1.5, 2}

Your answer may be different from this.


A= ‘Big error’= 0.1/0.5+0.3/1+0.6/1.5+1.0/2

Error
0 0.5 1 1.5 2

(Quiz 2) Consider U= {a, b, c, d} and


A= 1/a+0.5/c+0.2/d,

Obtain the standard A.

 A (u )  1   A (u )

37
U= {a, b, c, d} and
A= 1/a+0.5/c+0.2/d

 A (u )  1   A (u )

(Answer)

A= 1/b+0.5/c+0.8/d

(Quiz 3) Given two fuzzy relations defined in X, Y


X= {x1, x2}, xX, Y= {y1,y2,y3}, yY

R= 0.1/(x1,y1)+0.9/(x2,y1)+0.7/(x2,y3)
S= 0.2/(x1,y3) +0.6/(x2,y3)

(1) Write the relation matrices


(2) Obtain RS using the min operator
(3) Obtain RS using the max operator

38
(Answer)
(1) Write the relation matrices
MR y1 y2 y3 MS y1 y2 y3
x1 0.1 0 0 x1 0 0 0.2
x2 0.9 0 0.7 x2 0 0 0.6

(2) Obtain RS (3) Obtain RS


MRS y1 y2 y3 MRS y1 y2 y3
x1 0 0 0 x1 0.1 0 0.2
x2 0 0 0.6 x2 0.9 0 0.7

(Quiz 4) Given U= {x1,x2,x3,x4}, V={y1,y2,y3}


A= 0.1/x1+0.5/x3+0.8/x4, B= 0.7/y1+0.2/y3
obtain
p: if x is A, then y is B
using the product operator.

Note that
AB(u,v)= A(u)B(v)

39
(Answer)

x1 0.1
MA= x2 MAB y1 y2 y3
0
x3 0.5 x1 0.07 0 0.02
x4 0.8 x2 0 0 0
x3 0.35 0 0.1
MB=
y1 y2 y3 x4 0.56 0 0.16
0.7 0 0.2

40

You might also like