74
FUZZY LOGIC

FUZZY LOGIC

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: FUZZY LOGIC

FUZZY LOGIC

Page 2: FUZZY LOGIC

Origins and Evolution of Fuzzy Logic

• Origin: Fuzzy Sets Theory (Zadeh, 1965)

• Aim: Represent vagueness and impre-cission

of statements in natural language

• Fuzzy sets: Generalization of classical sets

• In the 70s: From FST to Fuzzy Logic

• Nowadays: Applications to control systems

– Industrial applications

– Domotic applications, etc.

Page 3: FUZZY LOGIC

What is a set

Page 4: FUZZY LOGIC

Classical Sets

Classical sets – either an element belongs to the set or it does not.

For example, for the set of integers, either an integer is even or it is not (it is odd).

Page 5: FUZZY LOGIC

Classical sets are also called crisp (sets).

Lists: A = {apples, oranges, cherries, mangoes}

A = {a1,a2,a3 }

A = {2, 4, 6, 8, …}

Formulas: A = {x | x is an even natural number}

A = {x | x = 2n, n is a natural number}

Membership or characteristic function

Ax

Axx

A if 0

if 1)(

Classical Sets

Page 6: FUZZY LOGIC

Introduction to fuzzy logic

Page 7: FUZZY LOGIC

Introduction to fuzzy logic

Page 8: FUZZY LOGIC

Fuzzy Sets

Sets with fuzzy boundaries

A = Set of tall people

Heights5’10’’

1.0

Crisp set A

Membershipfunction

Heights5’10’’6’2’’

.5

.9

Fuzzy set A1.0

Page 9: FUZZY LOGIC

Membership Functions (MFs) Characteristics of MFs:

Subjective measures Not probability functions

MFs

Heights5’10’’

.5

.8

.1

“tall” in Asia

“tall” in the US

“tall” in NBA

Page 10: FUZZY LOGIC

Fuzzy Sets

Formal definition:A fuzzy set A in X is expressed as a set of

ordered pairs:

A x x x XA {( , ( ))| }

Universe oruniverse of discourse

Fuzzy setMembership

function(MF)

A fuzzy set is totally characterized by amembership function (MF).

Page 11: FUZZY LOGIC

An Example• A class of students

(E.G. MCA. Students taking „Fuzzy Theory”)• The universe of discourse: X

• “Who does have a driver’s licence?”• A subset of X = A (Crisp) Set• (X) = CHARACTERISTIC FUNCTION

• “Who can drive very well?” (X) = MEMBERSHIP FUNCTION

1 0 1 1 0 1 1

0.7 0 1.0 0.8 0 0.4 0.2

Page 12: FUZZY LOGIC

Crisp or Fuzzy Logic Crisp Logic

A proposition can be true or false only.• Bob is a student (true)• Smoking is healthy (false)

The degree of truth is 0 or 1.

Fuzzy Logic The degree of truth is between 0 and 1.

• William is young (0.3 truth) • Ariel is smart (0.9 truth)

Page 13: FUZZY LOGIC

Fuzzy Sets Crisp Sets

Membership Characteristic

function function

]1,0[XA }1,0{XmA

Page 14: FUZZY LOGIC

Set-Theoretic Operations

Page 15: FUZZY LOGIC

Set-Theoretic Operations Subset

Complement

Union

Intersection

( ) ( ), A BA B x x x U

( ) max( ( ), ( )) ( ) ( )C A B A BC A B x x x x x

( ) min( ( ), ( )) ( ) ( )C A B A BC A B x x x x x

( ) 1 ( )AAA U A x x

Page 16: FUZZY LOGIC

Set-Theoretic Operations

A B

A B

A

A B

Page 17: FUZZY LOGIC

Properties Of Crisp Set

A AInvolution

A B B A Commutativity

A B B A

A B C A B C Associativity A B C A B C

A B C A B A C Distributivity A B C A B A C

A A A Idempotence

A A A

A A B A Absorption A A B A

A B A B

De Morgan’s laws

A B A B

Page 18: FUZZY LOGIC

Properties The following properties are invalid

for fuzzy sets: The laws of contradiction

The laws of exclude middleA A

A A U

Page 19: FUZZY LOGIC

Properties of Fuzzy Set

Page 20: FUZZY LOGIC

height0

1

short tall

Page 21: FUZZY LOGIC

Example we have two discrete fuzzy sets

Page 22: FUZZY LOGIC

Example (cont..)

Page 23: FUZZY LOGIC

Summarize propertiesInvolution

Commutativity AB=BA, AB=BA

AssociativityABC=(AB)C=A(BC),ABC=(AB)C=A(BC)

DistributivityA(BC)=(AB)(AC),A(BC)=(AB)(AC)

Idempotence AA=A, AA=A

Absorption A(AB)=A, A(AB)=A

Absorption of complement

Abs. by X and AX=X, A=Identity A=A, AX=A

Law of contradiction

Law of excl. middle

DeMorgan’s laws

AA

BABAA

BABAA

AA

XAA

BABABABA

Page 24: FUZZY LOGIC

Fuzzy and Crisp

Operations

Page 25: FUZZY LOGIC

Fuzzy Set Operations

Page 26: FUZZY LOGIC

Crisp Set Operations

Page 27: FUZZY LOGIC

Representation of Crisp set

Page 28: FUZZY LOGIC

Fuzzy and crisp Relations

Page 29: FUZZY LOGIC

CARTESIAN PRODUCT

An ordered sequence of r elements, written in the form (a1, a2, a3, . . . , ar), is called an ordered r-tuple.

For crisp sets A1,A2, . . . ,Ar, the set of all r-tuples(a1, a2, a3, . . . , ar), where a1 A1,a2 A2, ∈ ∈and ar Ar, is called the ∈ Cartesian product of A1,A2, . . . ,Ar, and is denoted by

A1×A2×···×Ar.

(The Cartesian product of two or more sets is not the same thing as the arithmetic product of two or more sets.)

Page 30: FUZZY LOGIC

Crisp Relations

A subset of the Cartesian product A1×A2×···×Ar is called an r-ary relation over A1,A2, . . . ,Ar.

If three, four, or five sets are involved in a subset of the full Cartesian product, the relations are called ternary, quaternary, and quinary

Page 31: FUZZY LOGIC

Cartesian product

The Cartesian product of two universes X and Y is determined as

X ×Y = {(x, y) | x X, y Y}∈ ∈ which forms an ordered pair of every x X with ∈

every y Y, forming unconstrained∈ matches between X and Y. That is, every element

in universe X is related completely to every element in universe Y.

Page 32: FUZZY LOGIC

Fuzzy Relations

Triples showing connection between two sets:

(a,b,#): a is related to b with degree #

Fuzzy relations are set themselves

Fuzzy relations can be expressed as matrices

32

Page 33: FUZZY LOGIC

Fuzzy Relations Matrices

Example: Color-Ripeness relation for tomatoes

R1(x, y) unripe semi ripe ripe

green 1 0.5 0

yellow 0.3 1 0.4

Red 0 0.2 1

33

Page 34: FUZZY LOGIC

Fuzzy Relations

A fuzzy relation R is a 2D MF:

( ,,( , ) ( , )) |R x yx y x yR X Y

Page 35: FUZZY LOGIC

35

Fuzzy relation

A fuzzy relation is a fuzzy set defined on the Cartesian product of crisp sets A1, A2, ..., An where tuples (x1, x2, ..., xn) may have varying degrees of membership within the relation.

The membership grade indicates the strength of the relation present between the elements of the tuple.

1 2

1 2 1 2 1 1 2 2

: ... [0,1]

(( , ,..., ), ) | ( , ,..., ) 0, , ,..., R n

n R R n n n

A A A

R x x x x x x x A x A x A

Page 36: FUZZY LOGIC

Compositions

Page 37: FUZZY LOGIC

A fuzzy relation defined on X an Z.

Max-Min Composition

X Y ZR: fuzzy relation defined on X and Y.

S: fuzzy relation defined on Y and Z.

R。 S: the composition of R and S.

( , ) max min ( , ), ( , )R S y R Sx z x y y z

( , ) ( , )y R Sx y y z

Page 38: FUZZY LOGIC

38

Max-min composition

Example

( , ) max[min( ( , ), ( , ))]

[ ( , ) ( , )]

S R R Sy

R Sy

x z x y y z

x y y z

( , ) , ( , )x y A B y z B C

Page 39: FUZZY LOGIC

39

Example

(1, ) max[min(0.1,0.9),min(0.2,0.2),min(0.0,0.8),min(1.0,0.4)]

max[0.1,0.2,0.0,0.4] 0.4S R

Page 40: FUZZY LOGIC

40

Example

(1, ) max[min(0.1,0.0),min(0.2,1.0),min(0.0,0.0),min(1.0,0.2)]

max[0.0,0.2,0.0,0.2] 0.2S R

Page 41: FUZZY LOGIC

41

Page 42: FUZZY LOGIC

Max-Product Composition

( , ) max ( , ) ( , )R S v R Sx y x v v y

A fuzzy relation defined on X an Z.

X Y ZR: fuzzy relation defined on X and Y.

S: fuzzy relation defined on Y and Z.

R。 S: the composition of R and S.

Max-min composition is not mathematically tractable, therefore other compositions such as max-product composition have been suggested.

Page 43: FUZZY LOGIC

43

Max Product

Max product: C = A・ B=AB= Example

12 ?C

Page 44: FUZZY LOGIC

44

Max product

Example

12 0.1C

Page 45: FUZZY LOGIC

45

Max product

Example

13 0.5C

Page 46: FUZZY LOGIC

46

Max product

Example

C

Page 47: FUZZY LOGIC

Fuzzy System

Page 48: FUZZY LOGIC

Introduction

Fuzzify crisp inputs to get the fuzzy inputs Defuzzify the fuzzy outputs to get crisp outputs

Page 49: FUZZY LOGIC

Fuzzy Systems

Fuzzy Knowledge base

Input FuzzifierInferenceEngine

Defuzzifier Output

Page 50: FUZZY LOGIC

Propositional logic

A proposition is a statement- in which English is a declarative sentence and logic defines the way of putting symbols together to form a sentences that represent facts

Every proposition is either true or false.

Page 51: FUZZY LOGIC

Example of PL

The conjunction of the two sentences: Grass is greenPigs don't flyis the sentence: Grass is green and pigs don't flyThe conjunction of two sentences will

be true if, and only if, each of the two sentences from which it was formed is true.

Page 52: FUZZY LOGIC

Statement symbols and variables

Statement: A simple statement is one

that does not contain any other statement as a part.

A compound statement is one that has two or more simple statement as parts called components.

Page 53: FUZZY LOGIC

Symbols for connective

ASSERTION P “P IS TRUE”

NEGATION ¬P ~

! NOT “P IS FALSE”

CONJUCTION

P^Q . & && AND “BOTH P AND Q ARE TRUE

DISJUNCTION

PvQ || | OR “ EITHER P OR Q IS TRUE”

IMPLICATION P-> Q ⇒ IF…THEN

“IF P IS TRUE THEN Q IS TRUE.”

EQUIVALENCE

P⇔Q =⇔

IF AND ONLY IF

“P AND Q ARE EITHER BOTH TRUE OR FALSE”

Page 54: FUZZY LOGIC

Truth Value

The truth value of a statement is truth or falsity.

P is either true or false ~p is either true of false p^q is either true or false, and

so on. Truth table is a convenient way of

showing relationship between several propositions..

Page 55: FUZZY LOGIC

Case 1

Case 2

Truth Table for Negation

As you can see “P” is a true statement then its negation “~P” or “not P” is false.

If “P” is false, then “~P” is true.

P

T

TF

F

~P

Page 56: FUZZY LOGIC

Truth Table for Conjunction

P QCase 1

Case 2

Case 3

Case 4

T

T

F

F

T

F

T

F

T

F

F

F

P Λ Q

Page 57: FUZZY LOGIC

Truth Table for Disjunction

P QCase 1

Case 2

Case 3

Case 4

T

T

F

F

T

F

T

F

T

T

T

F

P V Q

Page 58: FUZZY LOGIC

Tautology

Tautology is a proposition formed by combining other proposition (p,q,r…)which is true regardless of truth or falsehood of p,q,r…

DEF: A compound proposition is called a tautology if no matter what truth values its atomic propositions have, its own truth value is T.

Page 59: FUZZY LOGIC

59L3

Tautology example

Demonstrate that

[¬p (p q )]qis a tautology in two ways:

1. Using a truth table – show that [¬p (p q )]q is always true.

Page 60: FUZZY LOGIC

60L3

Tautology by truth table

p q ¬p p q ¬p (p q ) [¬p (p q )]q

T T

T F

F T

F F

Page 61: FUZZY LOGIC

61L3

Tautology by truth table

p q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F

T F F

F T T

F F T

Page 62: FUZZY LOGIC

62L3

Tautology by truth table

p q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F T

T F F T

F T T T

F F T F

Page 63: FUZZY LOGIC

63L3

Tautology by truth table

p q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F T F

T F F T F

F T T T T

F F T F F

Page 64: FUZZY LOGIC

64L3

Tautology by truth table

p q ¬p p q ¬p (p q ) [¬p (p q )]q

T T F T F T

T F F T F T

F T T T T T

F F T F F T

Page 65: FUZZY LOGIC

Modus Ponens and Modus Tollens

Modus ponens -- If A then B, observe A, conclude B

Modus tollens – If A then B, observe not-B, conclude not-A

Page 66: FUZZY LOGIC

Modus Ponens and Tollens

If Joan understood this book, then she would get a good grade. If P then Q Joan understood .: she got a good grade. This uses modus ponens. P .: Q

If Joan understood this book, then she would get a good grade. If P then Q She did not get a good grade .: she did

not understand this book. ~Q .: ~P This uses modus tollens.

Page 67: FUZZY LOGIC

Fuzzy QuantifiersThe scope of fuzzy propositions can be

extended using fuzzy quantifiers

• Fuzzy quantifiers are fuzzy numbers that take

part in fuzzy propositions

• There are two different types:

– Type #1 (absolute): Defined on the set of real

numbers

• Examples: “about 10”, “much more than 100”, “at least

about 5”, etc.

– Type #2 (relative): Defined on the interval [0, 1]

• “almost all”, “about half”, “most”, etc.

Page 68: FUZZY LOGIC

Fuzzification

The fuzzification comprises the process of transforming crisp values into grades of membership for linguistic terms of fuzzy sets. The membership function is used to associate a grade to each linguistic term.

Measurement devices in technical systems provide crisp measurements, like 110.5 Volt or 31,5 °C. At first, these crisp values must be transformed into linguistic terms (fuzzy sets) . This is called fuzzification.

Page 69: FUZZY LOGIC

FuzzifierFuzzy

Knowledge baseFuzzy

Knowledge base

I nput FuzzifierI nference

EngineDefuzzifier OutputI nput Fuzzifier

I nferenceEngine

Defuzzifier Output

Converts the crisp input to a linguistic

variable using the membership functions

stored in the fuzzy knowledge base.

Page 70: FUZZY LOGIC

Fuzzy interference

If x is A and y is B then z = f(x, y)

Fuzzy Sets Crisp Function

f(x, y) is very often a

polynomial function w.r.t. x

and y.

Page 71: FUZZY LOGIC

Examples

R1: if X is small and Y is small then z = x +y +1

R2: if X is small and Y is large then z = y +3

R3: if X is large and Y is small then z = x +3

R4: if X is large and Y is large then z = x + y + 2

Page 72: FUZZY LOGIC
Page 73: FUZZY LOGIC

Defuzzification

• Convert fuzzy grade to Crisp output The max criterion method finds the point at

which the membership function is a maximum.

The mean of maximum takes the mean of those points where the membership function is at a maximum.

Page 74: FUZZY LOGIC

Defuzzification