chapter 4: inference techniques reasoning inference forward chaining backward chaining 1

47
Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

Upload: paul-reeves

Post on 21-Jan-2016

268 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

1

Chapter 4: Inference Techniques

ReasoningInferenceForward Chaining Backward Chaining

Page 2: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

2

Introduction

• How does the inference engine work?

Page 3: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

Modus Ponens

• => (implies) (X => Y)

______X____ :. Y

– If it rains, then the streets will be wet. – It is raining. – Infer the conclusion: The streets will be wet.

3

Review:

Page 4: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

4

The Conditional and Its Variants

مخالف

معكوس

قلب

معكوس

Review:

Page 5: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

Modus tollens

(X => Y)____ ~Y _____

:. ~ X– If it rains, then the streets will be wet. – The streets are not wet. – Infer the conclusion: It is not raining.

• NOTE: Avoid mistakes – If it rains, then the streets will be wet. – The streets are not wet. – cannot conclude that it is raining.

5

Review:

Page 6: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

6

Syllogism

• chain implications to deduce a conclusion (X => Y) __ (Y => Z)__ :. (X => Z)

6

Review:

Page 7: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

Resolution

(X v Y) (~Y v Z) :. (X v Z)

•basis for the inference mechanism in the Prolog language and some theorem provers

7

Review:

Page 8: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

8

Reasoning(استدالل)

• The process of working with knowledge, facts, and problem solving strategies to draw conclusions

Page 9: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

9

Reasoning Methods

• Deductive Reasoning (استدالل استنباطي)• Inductive Reasoning (استدالل استقرايي)• Abductive Reasoning (استدالل انتزاعي)• Analogical Reasoning (استدالل قياسي)• Common-Sense Reasoning (استدالل عقل سليم)• Non-monotonic Reasoning (استدالل غيريكنواخت)

Page 10: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

10

Deductive Reasoning ( استدالل(استنباطي

• Reasoning where conclusions must follow from premises

• General to specific• Application: Generating conclusions

Implication: if every body standing in the rain, then he will get wet.Axiom: I am standing in the rainConclusion: I will get wet

Page 11: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

11

Inductive Reasoning ( استدالل(استقرايي

inference is from the specific case to the general

Application: Generating rules

Premise: Monkeys in the pittsburgh zoo eat bananasPremise: Monkeys in the cleveland zoo eat bananasConclusion: In general , all monkeys eat banana

Page 12: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

12

Abductive Reasoning ( استدالل(انتزاعي

• Reasoning back from a true conclusion to the premises that may have caused the condition

Implication: Ground is wet if it is rainingAxiom: Ground is wetConclusion: It is raining (?)

A plausible reasoning might be “it’s raining”

Page 13: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

13

Analogical Reasoning ( استدالل(قياسي

• inferring conclusions based on similarities with other situations ANN

Tiger Frame :Specialization of : AnimalsNumber of legs : 4Eats : meatLives : India and Southeast AsiaColor : tawny with stripes

If we state that a lion is like a tiger, we would naturally assume that they share many of the features

Page 14: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

14

Common-Sense Reasoning (استدالل عقل سليم)

• A combination of all based on our experience– it’s complicated

• Also named Heuristic reasoning• It’s valuable in applications that required quick

solution

A loose fan belt usually causes a strong noise A mechanic might have found this common-sense knowledge from his experience

Page 15: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

15

Non-monotonic Reasoning ( استدالل غير(يكنواخت

• New evidence may invalidate previous knowledge

• Truth maintenance System– Keep a record of what cause a fact to be asserted

If the wind blows, then the cradle will rock

If it’s windy, then the cradle is rock; but, after the wind is gone, we would expect the cradle to stop rocking.

Page 16: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

Reasoning Methods (summary)

deduction sound ◆ conclusions must follow from their premises

induction unsound ◆ inference from specific cases (examples) to the general

abduction unsound ◆ reasoning from a true conclusion to premises that may have caused the

conclusion

analogy unsound◆ a conclusion is drawn based on similarities to another situation

common-sense (heuristics) unsound ◆ rules of thumb, based on experience

non-monotonic unsound◆ new evidence may invalidate previous knowledge

16

Page 17: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

17

Inference(استنتاج)

• The process used in an expert system of deriving new information from known information.

• Reasoning has a general meaning, even it is used for the human case; but inference is used for machine, i.e. AI & ES.

Page 18: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

18

Some Rules of Inference

(Modus Ponens)

Page 19: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

19

Some Rules of Inference (continued)

Page 20: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

20

Features of Propositional LogicReview:

Artificial Intelligence: A modern approach, Norving & russel

Page 21: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

21

Quiz

با استفاده از قوانين منطق گزاره ای نشان دهيد، •روابط زير صحيح هستند:

• (A^B=>C)معادل با ((A=>C)V(B=>C))

Page 22: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

23

Forward and Backward Chaining

• Chain: a group of multiple inferences that connect a problem with its solution

• Search process: • Forward chaining: if the premise matches the situation, then

the process attempts to assert the conclusion

• Backward chaining: if the current goal is to determine the correct conclusion, then the process attempts to determine whether the premise clauses (facts) match the situation

Page 23: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

24

Froward Chaining Inference process

Page 24: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

25

Forward Chaining

• given a set of basic facts, we try to derive a conclusion from these facts

• example: What can we conclude about Clyde?IF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant (Clyde)

modus ponens: IF p THEN qp

q

Unification (pattern matching): find compatible values for variables

Page 25: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

26

IF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

elephant (Clyde)

IF elephant( x ) THEN mammal( x )

unification:find compatible values for variables

Forward Chaining Example

Page 26: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

27

Forward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

elephant (Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

unification:find compatible values for variables

Page 27: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

28

Forward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

elephant (Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

IF mammal( x ) THEN animal( x )

unification:find compatible values for variables

Page 28: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

29

Forward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

elephant (Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

IF mammal(Clyde) THEN animal(Clyde)

unification:find compatible values for variables

Page 29: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

30

Forward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

elephant (Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

IF mammal(Clyde) THEN animal(Clyde)

animal(Clyde)

unification:find compatible values for variables

Page 30: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

31

Forward Chaining

Page 31: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

32

Conflict Resolution

• Strategy used for choosing a rule-firing sequence when more than one rule can fire

• Steps of the conflict resolution strategies:1. Recognize. Find the rules that can fire (making the conflict set)

2. Resolve, If more than one rule can fire, choose one rule to fire according to some strategy.

3. Act. Fire the rule and add its conclusion to the working memory.

Page 32: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

33

Conflict Resolution Strategies

First rule that matches contents of working memory.1. Highest priority rule.2. Most specific rule, (more # of premises)3. Rule that refers to the element most recently added to

the working memory.4. Don't fire a rule that has already fired (preventing loop,

used in the most strategies). 5. Fire all rules with separate line of reasoning (parallel).

Page 33: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

34

Backward Chaining

• try to find supportive evidence (i.e. facts) for a hypothesis• example: Is there evidence that Clyde is an animal?

IF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant (Clyde)

modus ponens: IF p THEN qp

q

Unification (pattern matching): find compatible values for variables

Page 34: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

35

Backward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

IF mammal( x ) THEN animal( x )

animal(Clyde)

unification:find compatible values for variables

?

Page 35: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

36

Backward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

IF mammal(Clyde) THEN animal(Clyde)

animal(Clyde)

unification:find compatible values for variables

?

Page 36: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

37

Backward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

IF elephant( x ) THEN mammal( x )

IF mammal(Clyde) THEN animal(Clyde)

animal(Clyde)

unification:find compatible values for variables

?

?

Page 37: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

38

Backward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

IF elephant(Clyde) THEN mammal(Clyde)

IF mammal(Clyde) THEN animal(Clyde)

animal(Clyde)

unification:find compatible values for variables

?

?

Page 38: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

39

Backward Chaining ExampleIF elephant(x) THEN mammal(x)

IF mammal(x) THEN animal(x)

elephant(Clyde)

modus ponens:IF p THEN qp

q

elephant (Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

IF mammal(Clyde) THEN animal(Clyde)

animal(Clyde)

unification:find compatible values for variables

Page 39: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

40

Backward Chaining

Page 40: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

41

Forward-Chaining

Page 41: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

42

Backward-Chaining

Page 42: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

43

Forward Chaining v.s. Backward Chaining

Forward Chaining Backward Chainingplanning, monitoring, control diagnosis

data-driven goal-driven (hypothesis)

bottom-up processing top-down processing

find possible conclusions supported by given facts

find facts that support a given hypothesis

similar to breadth-first search

similar to depth-first search

CLIPS PROLOG

Page 43: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

46

Family Example: Facts

Page 44: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

47

Family Example: Rules

Page 45: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

48

PROLOG Sample Inference

Page 46: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

49

PROLOG Sample Inference

Page 47: Chapter 4: Inference Techniques Reasoning Inference Forward Chaining Backward Chaining 1

50

Mini Projects 1Chapter 4 (Inference Engine)

• Due date: 94/1/20