You are on page 1of 95

Classical and Fuzzy Logic

Part II
Dr S.Natarajan
Professor and Key Resource Person
Department of Information Science and Engineering
PES Institute of Technology
Bengaluru
natarajan@pes.edu
9945280225
CLASSICAL LOGIC AND FUZZY LOGIC
Part I Logic

Classical Predicate Logic – tautologies,


Contradictions, Equivalence, Exclusive Or Exclusive
Nor, Logical Proofs, Deductive Inferences
Fuzzy Logic, Approximate Reasoning, Fuzzy
Tautologies, Contradictions, Equivalence and Logical
Proofs, Other forms of the Implication Operation

Part II Fuzzy Systems

Natural language processing, Linguistic Hedges, Rule


Based Systems, Multiple conjunctve antecedents ,
Aggregation of Fuzzy Rules, Graphical techniques of
inference 2
3
NATURAL LANGUAGE


Is perhaps the most powerful form of conveying
information.

Despite its vagueness and ambiguity it is the
vehicle for human communication, and it seems
appropriate that a mathematical theory that deals
with fuzziness and ambiguity is also the same
tool used to express and interpret the linguistic
character of our language. Natural language is
used in the expression of knowledge form
known as RULE BASED SYSTEMS
NATURAL LANGUAGE

Cognitive scientists tell us that human base
their thinking primarily on conceptual patterns
and mental images rather than on any
numerical quantities. In fact the expert system
paradigm known as “Frames” is based on the
notion of a cognitive picture in one's mind.
Furthermore, humans communicate with their
own natural language by referring to previous
mental images with rather vague but simple
terms. Despite the vagueness and ambiguity in
natural language, humans communicating in a
common language have very little trouble in
basic understanding.

since a vast amount of information involved in
human communication involves natural language
terms that, by their very nature, are often vague,
imprecise, ambiguous, and fuzzy, we will propose
the use of fuzzy sets as the mathematical
foundation of our natural language (NL).

NL consists of
- atomic terms :The fundamental terms.
Ex: slow, medium, young, beautiful etc.
- composite : a collection of of atomic terms or
set of terms.
Ex: very slow horse, heavy-weight female,
fairly beautiful painting, etc
Natural Language

The time interval x was the period exhibiting a 100 percent maximum of
possible values as measured along some arbitrary social scale, [and]
the interval x was the period of time exhibiting 100 percent minimum of
these values as measured along the same scale.

Crisp version of this passage is identical to that posed by the law of


excluded middle of probability theory.

The decomposition of compound rules into canonical (equivalent)


forms and the treatment of rules forms as logical propositions. The
characterization of the confidence in a particular rule is addressed
by using the truth qualifications. The expression of rules as a
collection of logical implications manipulated by inference schemes

7
Knowledge & Mappings
• Knowledge is a collection of “facts” from
some domain.
• What we need is a representation of facts
that can be manipulated by a program.
– Some symbolic representation is necessary.
– Need to be able to map facts to symbols.
– Need to be able to map symbols to facts?

8
A.I. Problems & K.R.
• Game playing - need rules of the game,
strategy, heuristic function(s).
• Expert Systems - list of rules, methods to
extract new rules.
• Learning - the space of all things learnable
(domain representation), concept
representation.
• Natural Language - symbols, groupings,
semantic mappings, ...
9
Representation Properties
Representational Adequacy - Is it possible to
represent everything of interest ?
Inferential Adequacy - Can new information
be inferred?
Inferential Efficiency - How easy is it to infer
new knowledge?
Acquisitional Efficiency - How hard is it to
gather information (knowledge)?
10
Search and State Representation
• Each state could be represented as a
collection of facts.
• Keeping many such states in memory may
be impossible.
• Most facts will not change when we move
from one state to another.

11
The Frame Problem
• Determining how to best represent facts that
change from state to state along with those
facts that do not change is the Frame
Problem.
• Sometimes the hard part is determining
which facts change and which do not.

12
Fuzzy Rule-based systems
Using fuzzy sets as a calculus to interpret natural
language. It is vague, imprecise, ambiguous and fuzzy.
Fundamental terms  atoms
Collection of atomic terms  composite or set of terms
An atomic term (a linguistic variable) can be interpreted
using fuzzy sets.
An atomic term  in the universe of natural language, X.
Define a fuzzy set A in the universe of interpretations or
~
meanings, Y as a specific meaning of .

13
Suppose we define a specific atomic term in the
universe of NL, X, as element a and we define
fuzzy set A in the universe of interpretations , or
meanings, Y, as a specific meaning for the term a.
then NL can be expressed as a mapping, M from a
set of atomic terms in X to a corresponding set of
interpretations defined on Y.


Each atomic term a in X corresponds to a fuzzy
set A in Y, which is the “interpretation” of a
Fuzzy Rule-based systems

 A
~

X MA
~
 
~ Y

Mapping of a linguistic atom  to a cognitive interpretation A~


 M  , y    A  y 
~ ~

 
2 1


1   y 25  
 y  25
  25  
 M  youg  y     
~

 1 y  25
 15
Fuzzy Rule-based systems
Composite

 or  :
 or   y   max   y  ,    y 
 and  :
 and   y   min    y  ,    y 
Not    :   y   1    y 

16
LINGUISTIC HEDGES


In linguistics, fundamental atomic terms are often
modified with adjectives (nouns) or
adverbs (verbs) .
like very, low, slight, almost, more-or-less, etc

Using fuzzy sets as the calculus of interpretation,
these linguistic hedges have the effect of
modifying the membership function for a basic
atomic term
Define a= ma(y)/y, then
y

“very” a = a2 =ʃ [μα(y)]2/y

“Very, very” a = a4

“plus” a=a1.25


“slightly” a =sqrt (a) = ʃ [ μα(y))]0.5/y

“minus” a = a0.75

The first three equations are called
“concentrations”

Another operation on linguistic fuzzy sets is
known as intensification.

Intensification can be expressed by numerous
algorithms, one of which, proposed by Zadeh, is

2ma2(y) for 0<= ma(y) <= 0.5



“intensify” a = = 1-2[1-ma (y)]2
for 0.5 <= ma(y) <= 1

Combination of concentration and dilation

Parentheses may be used to change the precedence
order and ambiguities may be resolved by the use
of association-to-the-right. For example, “plus
very minus” as plus(very(minus))
Concentration
m of A m
1 1 Dilation of A

0 x 0 x

Intensification
of A
Concentration – reduces the degree of membership of the elements
which are “partly” in the set
Hedge “very” with membership of .9 reduced by 10 percent to a value
.81 – whereas, membership value of .1 is reduced by an order of
magnitude .01.
Decrease – Manifestation of the properties of the properties of the
membership value itself for 0 ≤µ ≤ 1 then µ >= µ2
Dilation- Stretch or dilate fuzzy set by increasing the membership
of elements that are ‘partly’ in the set
For the hedge ‘slightly’ membership value .81 is increased by 11% to
get 0.9 and the membership value of 0.01 is increased by an order
of magnitude to 0.1

21
Precedence for linguistic hedges
and logical operations

Precedence Operation

First Hedge, not

Second and

Third or
Linguistic Hedges
Very  2
  y
2
   
y y
Very very    4
plus    1.25
1
Slightly   2

  y
5
 2      
1

y y
Minus    0.75
 2  2  y  0    y   0.5

Intensify   It increases contrast.
1  21    y   2 0.5    y   1
 

23
Precedence of the Operations

Example:
Suppose we have a universe of integers, Y = {1,2,3,4,5}.
We define the following linguistic terms as a mapping onto
Y:
“small” = 1 .8 .6 .4 .2 
     
1 2 3 4 5
“large” =  .2 .4 .6 .8 .1
     
1 2 3 4 5

24
Example (contd)

Then we construct a phrase, or a composite term:


 = “not very small and not very, very large”
which involves the following set-theoretic operations:
 .36 .64 .84 .96   1 1 .9 .6 
         
 2 3 4 5  1 2 3 4
 .36 .64 .6 
   
 2 3 4

Suppose we want to construct a linguistic variable


“intensely small” (extremely small); we will make use of the
equation defined before to modify “small” as follows:

25
Example (contd)

1  21  1 2 1  21  0.8 2 1  21  0.6 2 


   
 1 2 3 
“Intensely small” =  
 2 0.4  2 0.2
2 2


 4 5 

1 0.92 0.68 0.32 0.08 
     
1 2 3 4 5 

26
Rule-based systems

In the field of AI there are various ways to
represent knowledge.
IF premise (antecedent), THEN conclusion

(consequent)

Commonly referred to as the IF-THEN rule-based
form

The rule-based system is distinguished from
expert systems in the sense that the rules
comprising a rule-based system might derive from
sources other that human experts and, in this
context, are distinguished from expert systems.
Rule-based Systems

IF-THEN rule based form


Canonical Rule Forms
1. Assignment statements
x = large, x  y
2. Conditional statements
If A then B,
If A then B, else C
3. Unconditional statements
stop
go to 5
unconditional can be
If any conditions, then stop
If condition Ci, then restrict Ri

28
Canonical Rule Forms


Assignment statements
x = large
banana’s color = yellow
x approx= s

Conditional statements
IF the tomato is red THEN the tomato is ripe
IF x is very hot THEN stop

Unconditional statements
go to 9
stop
divide by x
turn the pressure higher

The rule base under consideration could be
described using a collection of conditional
restrictive statements. These statements may also
be modeled as fuzzy conditional statements, such
as
IF condition C1 THEN restriction R1.

The unconditional restrictions might be in the form
R1: The output is B1
AND
R2: The output is B2
AND
etc.
Where B1, B2, …. Are fuzzy consequents.

The canonical form for a fuzzy rule-based system

Rule 1: IF cond C1, THEN restriction R1


Rule 2: IF cond C2, THEN restriction R2
.
.
Rule n: IF cond Cn, THEN restriction Rn.

Example
if the temperature is hot, then the pressure is
rather high.
if the temperature is cold, then the pressure is
very low.

The vague term “rather high” in the first statement
places a fuzzy restriction on the pressure , based
on a fuzzy “hot” temperature condition in the
antecedent.
Decomposition of Compound Rule

Any compound rule structure can be decomposed and


reduced to a number of simple canonical rules.
The most commonly used techniques
Multiple Conjunctive Antecedents
If x is A and A2  A L, then y is B S
~ ~ ~ ~
Define A S  A1  A2    A L
~ ~ ~ ~

 A  x   min   A  x  ,  ,  A  x  
S 1 L
~  ~ ~ 

The rule can be rewritten.


S S
IF THEN
A B
~ ~
33
Decomposition of Compound Rules

A linguistic statement expressed by a human might
involve compound rule structures
as an example, consider a rule-based for a simple
home temperature control problem, which might
contain the following rules.
IF it is raining hard
THEN close the window.
IF the room temp is very hot,
THEN
IF the heat is on
THEN turn the heat lower
AND IF it is not raining hard
THEN open the window. etc..
Multiple Disjunctive Antecedents
1 2 L
If x is A
~
or A
~
or … or A
~

then y is B S
S 1 2 L
~
A  A  A   A
~ ~ ~ ~

 AS  x   max   A1  x  , ,  AL  x  
S S
IF A
~
THEN B
~

35

Multiple conjunctive antecedents
IF x is A1 and A2 … and AL THEN y is Bs
As = A1 n A2 n …n AL
mAs(x) = min [mA1(x), … , mAl(x)]
IF As THEN Bs

Multiple disjunctive antecedents
IF x is A1 or A2 … or AL THEN y is Bs
As = A1 U A2 U …U AL
mAs(x) = max [mA1(x), … , mAl(x)]
IF x is As THEN y is Bs
Condition Statements
1 2
1. IF A B ) decomposed into:
1
~
THEN ( B ELSE ~
1 1~ 1 2
IF A THEN B or IF NOT THENA B
~ ~ ~ ~
1
2. IF A
1 2
~ (THEN B ) unless A decomposed into:
~ ~
IF A1 THEN B1 or IF NOT THENANOT 2
B
1
~ ~ ~ ~
1 2
3. IF A A THEN ( B 2 )) decomposed into:
1
~
THEN ( B ELSE IF ~
1 1 ~ 1 ~ 2 2
IF A THEN B or IF NOT and A THENA NOT B
~ ~ ~ ~ ~

4. Nested IF-THEN rules 1


1 2 B
IF A THEN (IF A , THEN ( ~ )) becomes
~ ~
IF A1 and A2 THEN B1
~ ~ ~
Each canonical form is an implication, and we can reduce
the rules to a series of relations. 37
Condition Statements

“likely” “very likely” “highly likely” “true” “fairly true” “very true”
“false” “fairly false” “very false”
x  X
 anything  x   1
Let  be a fuzzy truth value “very true” “true” “fairly true”
“fairly false” “false”
A truth qualification proposition can be expressed as:
“x is isA”
~
or
x is is A =  A  x
~ ~

 A  x   0. 5
~ 38
Aggregation of fuzzy rule

The process of obtaining the overall consequent


(conclusion) from the individual consequent contributed by
each rule in the rule-base is known as aggregation of
rules.
Conjunctive System of Rules:
y  y1  y 2    y r
 
 y  y   min  y1  y  , ,  y r  y  y  Y

Disjunctive System of Rules:


y  y1  y 2    y r
 
 y  y   max  y1  y  , ,  y r  y  y  Y
39
Graphical Technique of Inference

If x1 is and x2 is then y is , k = 1,2,..., r


Graphical methods that emulate the inference process and
make manual computations involving a few simple rules.
Case 1: inputs x1, and x2 are crisp.
Memberships
1 x1 = input(i)
(x1) = (x1 – input(i)) =
0 otherwise

1 x2 = input(i)
(x2) = (x2 – input(i)) =
0 otherwise

40
Graphical Technique of Inference

For r disjunctive rules:


  
 B  y  max min   A  input  i   ,  A  input  j    
k k k
~
k
  ~1 ~2 
k  1,2,  , r
A11 refers to the first fuzzy antecedent of the first rule.
A12 refers to the second fuzzy antecedent of the first rule.

41
“highly unlikely” = “minus very very unlikely” = “(very
very unlikely)0.75” = 1/0 + 1/.1 + 1/.2 + .5/.3 + .3/.4}

Ex: if a fuzzy variable x has a membership value equal to .85 in


the fuzzy set A i.e., mA(x)=.85 as shown in the figure then its
membership values for the following truth qualification
statements are determined from figure

t: x is A is
true mA(xt) = .85
t: x is A is mA(a)
false 1
mA(xt) = .15
t: x is A is .96
fairly true .85
t: x is A is mA(xt) = .96
very false
.15
mA(xt) = .04
0 .85 1a
Aggregation of Fuzzy Rules

Conjunctive system of rules.
y = y1 and y2 and … and yr
Or
y = y1 ∩y2 ∩ … ∩ yr
Defined by my(y) = min (my1(y),…myr(y))
for y belongs to Y

Disjunctive system of rules
y = y1 or y2 or … or yr
Or
y = y 1 U y2 U … U y r
Defined by my(y) = max (my1(y), … my(r-1)(y), myr(y))
for y belongs to Y
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Graphical Technique of Inference
Case 1 : CRISP SETS max-min
Graphical Technique of Inference
Case 2: CRISP SETS: Using max-product (or correlation product)
implication technique, aggregated output for r rules would be:
 
 B k  y   max   Ak  input  i     Ak  input  j    k  1,2, , r
~
k  ~1 ~2 

 
 B k  y   max   Ak  input  i     Ak  input  j   
~
k  ~1 ~2 
k  1,2,  , r
Graphical Technique of Inference
Case 3: input(i) and input(j) are fuzzy variables
      
 B k  y   max min max   Ak  x     x1 , max   Ak  x     x 2   
~
   ~1   ~2  

      
 B k  y   max min max   Ak  x     x1 , max   Ak  x     x 2   
~
   ~1   ~2  
Graphical Technique of Inference
Case 4: input(I) and input(j) are fuzzy, inference using correlation
product
      
 B k  y   max min max   Ak  x     x1   max   Ak  x     x 2  
~
k
   ~1   ~2  
69
70
Graphical Technique of Inference
Example: 1 1 1
A A
Rule 1: if x1 is ~ 1 and x2 is ~ 2 , then y is ~ B
2 2 2
Rule 2: if x1 is A~ 1 or x2 is A~ 2 , then y is B~
input(i) = 0.35 input(j) = 55
72
73
74
75
76
Summary
• Fuzzy Modelling – subjectivity blessing rather than a curse
Vagueness present in the definition of the terms is consistent with
the information contained in the conditional rules developed by
the Engineer when observing some complex process
• Set of linguistic variables and their meanings is compatible and
consistent with set of conditional rules used, the outcome of the
qualitative process is translated into objective and quantifiable
results
• Fuzzy mathematical tools and the calculus of fuzzy IF-THEN
rule provide a most useful paradigm for the automation and
implementation of an extensive body of human knowledge which are
not embodied in the quantitative modelling process

77
78
79
80
Operation of a fuzzy expert system:

• Fuzzification: definition of fuzzy sets, and


determination of the degree of membership of crisp
inputs in appropriate fuzzy sets.
• Inference: evaluation of fuzzy rules to produce
an output for each rule.
• Composition: aggregation or combination of
the outputs of all rules.
• Defuzzification: computation of crisp output

October 2005 81
Fuzzy Expert Systems

 Recap
 Example: Air Conditioner
 Example: Cart Pole Problem
 Case Study: Building a Fuzzy Expert System
 Summary

October 2005 82
Example: Air Conditioner
1a. Specify the problem
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 a cooler. The cooler
is controlled by a thermostat. Generally, the amount of air
being compressed is proportional to the ambient
temperature.

1b. Define linguistic variables


• Ambient Temperature
• Air-conditioner Fan Speed
October 2005 83
Example: Air Conditioner
2. Determine Fuzzy Sets: Temperature
Temp COLD COOL PLEASANT WARM HOT
(0C).
0 Y* N N N N
0< (T)<1
5 Y Y N N N
10 N Y N N N
12.5 N Y* N N N
15 N Y N N N
17.5 N N Y* N N  (T)=1
20 N N N Y N
22.5 N N N Y* N
25 N N N Y N
 (T)=0 27.5 N N N N Y
30 N N N N Y*

October 2005 84
Example: Air Conditioner
2. Determine Fuzzy Sets: Temperature

Temperature Fuzzy Sets

1
0.9
0.8 Cold
Truth Value

0.7
0.6
Cool
Temperatu re Fuzzy Sets

Pleasent
1

0.5
0.9
0.8 Cold
0.7
0.6 Cool
0.5 Pleasent
0.4
Warm

Vu
ae
0.3

u
T
rh
t l
0.2 Hot
0.1
0
0 5 10 15 20 25 30

TemperatureDegrees C

0.4
0.3
Warm
0.2 Hot
0.1
0
0 5 10 15 20 25 30

Temperature Degrees C

October 2005 85
Example: Air Conditioner
2. Determine Fuzzy Sets: Fan Speed
Rev/sec MINIMAL SLOW MEDIUM FAST BLAST
(RPM)
0 Y* N N N N
10 Y N N N N
20 Y Y N N N
30 N Y* N N N
40 N Y N N N
50 N N Y* N N
60 N N N Y N
70 N N N Y* N
80 N N N Y Y
90 N N N N Y
100 N N N N Y*

October 2005 86
Example: Air Conditioner
2. Determine Fuzzy Sets: Fan Speed
Speed Fuzzy Sets

1
0.8 MINIMAL
Truth Value

0.6 SLOW
MEDIUM
0.4
FAST
0.2 BLAST
0
0 10 20 30 40 50 60 70 80 90 100
Speed

October 2005 87
Example: Air Conditioner
3. Elicit and construct fuzzy rules

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

October 2005 88
Example: Air Conditioner
3. Encode into an Expert System
4. Evaluate and tune the system
Consider a temperature of 16oC, use the system
to compute the optimal fan speed.

Operation of a Fuzzy Expert System


• Fuzzification
• Inference
• Composition
• Defuzzification

October 2005 89
Example: Air Conditioner
• Fuzzification
 Affected fuzzy sets: COOL and PLEASANT

COOL(T) = – T / 5 + 3.5 PLSNT(T) = T /2.5 - 6


= – 16 / 5 + 3.5 = 16 /2.5 - 6
= 0.3 = 0.4

Temp=16 mCOLD mCOOL mPLEASANT mWARM mHOT


0 0.3 0.4 0 0

October 2005 90
Example: Air Conditioner
• Inference

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

October 2005 91
Example: Air Conditioner
• Inference

RULE 2: IF temp is cool (0.3) THEN speed is slow (0.3)

RULE 3: IF temp is pleasant (0.4) THEN speed is medium (0.4)


October 2005 92
Example: Air Conditioner
• Composition

speed is slow (0.3) + speed is medium (0.4)


October 2005 93
Example: Air Conditioner
• Defuzzification

COG = 0.125(12.5) + 0.25(15) + 0.3(17.5+20+…+40+42.5) + 0.4(45+47.5+…+52.5+55) +


0.25(57.5)
0.125 + 0.25 + 0.3(11) + 0.4(5) + 0.25

= 45.54rpm

October 2005 94
Fuzzy Expert Systems

 Recap
 Example: Air Conditioner
 Example: Cart Pole Problem
 Case Study: Building a Fuzzy Expert System
 Summary

October 2005 95

You might also like