28
Fuzzy Logic Jan Jantzen [email protected] www.inference.dk 2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on logic.

Fuzzy Logic Jan Jantzen [email protected] 2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

Embed Size (px)

Citation preview

Page 1: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

Fuzzy Logic

Jan Jantzen

[email protected]

www.inference.dk

2013

Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on logic.

Page 2: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

2

Summary

• Fuzzy logic is computing with words (Zadeh)• Approximate reasoning • Consistency Computers can make

decisions even with statements that are true to a degree between 0 and 1

If we build a logic on fuzzy sets, will the usual laws still hold?

Intelligent computers

Page 3: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

3

Inference by Computer

• If room is warm then set cooling power to 500 watts

• Temperature is 21 deg C• Cooling = 250 watts

• If T > 21 C then Cooling = on• If T ≤ 21 C then Cooling = off

Fuzzy controller

Classical controller

Page 4: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

4

Key Concepts

• And, or, not, nor, xor, etc.• implication*, equivalence*• rules of inference*, tautologies*• *) difficult

Page 5: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

5

Fuzzy reasoning: True Love

Wife: Do you love me?

Husband (Boolean logician): Yes.

Wife: How much?

Page 6: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

6

FAQ: Why fuzzy logic?

A: • It is tolerant• Mathematically consistent (almost)• Operational (= executable by computers)• A way to communicate with computers

Page 7: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

7

Example: Betting On Baseball

If either the Pirates or the Cubs loose and the Giants win, then the Dodgers will be out of first place, and I will loose a bet.

(( p c) g) ( d b)

This expression can be programmed on a computer.

Page 8: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

8

Exhaustive Search Solution

• 25 = 32 possible combinations• 23 legal combinations, 9 illegal• 10 possible cases where I will win the bet

(b=1)

p c g d b

0 0 0 0 1

0 0 0 1 1

0 1 0 0 1

0 1 0 1 1

1 0 0 0 1

1 0 0 1 1

1 1 0 0 1

1 1 0 1 1

1 1 1 0 1

1 1 1 1 1The validity is guaranteed !

Page 9: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

9

BOOLEAN LOGIC

Page 10: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

10

Define disjunction (OR)

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

Truth table

Page 11: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

11

Boolean OR as a Cayley Table

p q

0 1 q

0 0 1

1 1 1

p

It contains the same information, only reorganised into a two-dimensional array.

Page 12: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

12

Define negation (NOT)

p = 1 - p

p = p

The law of involution is valid

If p is 0 then 'not p' = 1, and if p is 1 then 'not p' = 0.

Page 13: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

13

Assume DeMorgan's Laws

qpqp

qpqp

These two laws provide a connection between AND and OR by means of negation.

Page 14: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

14

Derive NAND

qpqp

The left hand side is clearly 'not AND', which is NAND. The right hand side contains only OR and NOT, which we have already defined previously. We have thus derived a new operation based on existing definitions.

Page 15: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

15

NAND table

(p) (q)

0 1 q

0 1 1

1 1 0

p

Example. Suppose p = 0 and q = 0, corresponding to the upper left cell. Then NOT p = 1 and NOT q = 1. Use the previously defined OR table to find the result 1, which is the truth value in the upper left cell.

Page 16: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

16

Derive conjunction (AND)

qpqp

The left hand side is obviously AND. The right hand side is the negation of NAND, which is also AND. It contains only OR and NOT, which we have already defined previously. We have again derived a new operation based on existing definitions.

Page 17: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

17

AND table

((p) (q))

0 1 q

0 0 0

1 0 1

p

We get this from the NAND table by negating the content of all cells.

Page 18: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

18

Short recap

• Starting from OR, NOT, and DeMorgan's laws,

• we derived NAND and AND • (and also NOR, not shown but easy; even

XOR could be derived in a similar manner)

Page 19: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

19

Fuzzy OR

p q p q 0 0 0 0 0.5 0.5 0 1 1

0.5 0 0.5 0.5 0.5 0.5 0.5 1 1 1 0 1 1 0.5 1 1 1 1

We work with only three truth values 0, 0.5 and 1 to preserve space. Actually, these three are sufficient representatives of all truth values, as long as we only work with AND, OR, and NOT.

Page 20: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

20

Fuzzy OR as a Cayley Table

p q

0 0.5 1 q

0 0 0.5 1

0.5 0.5 0.5 1

1 1 1 1

p

It contains the same information, only reorganised into a two-dimensional array.

Page 21: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

21

Derive fuzzy NAND

(p) (q)

0 0.5 1 q

0 1 1 1

0.5 1 0.5 0.5

1 1 0.5 0

p

We do exactly as before in order to find the contents of the cells.

Page 22: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

22

Derive fuzzy AND

((p) (q))

0 0.5 1 q

0 0 0 0

0.5 0 0.5 0.5

1 0 0.5 1

p

Again, we get this from the NAND table by negating the content of each cell.

Page 23: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

23

Short recap

• When fuzzy OR is defined as MAX,• then the derived fuzzy AND is consistent

with MIN• (we could go on and derive fuzzy NOR

and fuzzy XOR)

Page 24: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

24

Fuzzy Baseball Example

If either the Pirates or the Cubs loose and the Giants win, then the Dodgers will be out of first place, and I will loose a bet.

(( p c) g) ( d b)

Page 25: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

25

Exhaustive Search Solution

• 35 = 243 (was 32) possible combinations• 33 (was 10) possible cases where I will

win the bet (b = 1) p c g d b

0.5 0.5 0 1 1

One example of awinning outcome:

Could be interpreted as 'maybe'

Page 26: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

26

Triangular Norms

xyyxyx

xyyx

:sum ticProbabilis

:Product

If we define AND as product (×), instead of min, then OR must be 'probabilistic sum' in order to keep the DeMorgan laws satisfied. In that case, we go through the previously developed scheme again in order to derive the remaining operations.

Candidates for AND. OR candidates are called triangular conorms.

Page 27: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

27

Summary

• Fuzzy and, or, not, nor, etc. can be defined in a consistent manner (DeMorgans laws hold).

Page 28: Fuzzy Logic Jan Jantzen jj@inference.dk  2013 Logic is based on set theory, and when we switch to fuzzy sets it will have an effect on

28

Applications

• Automatic control, robots• Expert systems• Medical diagnosis• Financial decision support• Image processing• Intelligent computers