Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cooperating Intelligent Systems Logical agents Chapter 7, AIMA This presentation owes some to V. Rutgers and D. OSU.

Similar presentations


Presentation on theme: "Cooperating Intelligent Systems Logical agents Chapter 7, AIMA This presentation owes some to V. Rutgers and D. OSU."— Presentation transcript:

1 Cooperating Intelligent Systems Logical agents Chapter 7, AIMA This presentation owes some to V. Pavlovic @ Rutgers and D. Byron @ OSU

2 Motivation for knowledge representation The search programs so far have been ”special purpose” – we have to code everything into them. We need something more general, where it suffices to tell the rules of the game.

3 1 234 1 2 3 4 The Wumpus World

4 1 234 1 2 3 4 Start position = (1,1) Always safe

5 1 234 1 2 3 4 The Wumpus World Goal: Get the gold

6 1 234 1 2 3 4 The Wumpus World Problem 1: Big, hairy, smelly, dangerous Wumpus. Will eat you if you run into it, but you can smell it a block away. You have one (1) arrow for shooting it.

7 1 234 1 2 3 4 The Wumpus World Problem 2: Big, bottomless pits where you fall down. You can feel the breeze when you are near them.

8 1 234 1 2 3 4 The Wumpus WorldWumpus PEAS description Performance measure: +1000 for gold -1000 for being eaten or falling down pit -1 for each action -10 for using the arrow Environment: 44 grid of ”rooms”, each ”room” can be empty, with gold, occupied by Wumpus, or with a pit. Actuators: Move forward, turn left 90, turn right 90 Grab, shoot Sensors: Olfactory – stench from Wumpus Touch – breeze (pits) & hardness (wall) Vision – see gold Auditory – hear Wumpus scream when killed

9 1 234 1 2 3 4 The Wumpus WorldWumpus PEAS description Performance measure: +1000 for gold -1000 for being eaten or falling down pit -1 for each action -10 for using the arrow Environment: 44 grid of ”rooms”, each ”room” can be empty, with gold, occupied by Wumpus, or with a pit. Acuators: Move forward, turn left 90, turn right 90 Grab, shoot Sensors: Olfactory – stench from Wumpus Touch – breeze (pits) & hardness (wall) Vision – see gold Auditory – hear Wumpus scream when killed

10 Exploring the Wumpus world A ok Slide adapted from V. Pavlovic Agent senses nothing (no breeze, no smell,..)

11 Exploring the Wumpus world B A ok P? Agent feels a breeze Slide adapted from V. Pavlovic A

12 Exploring the Wumpus world B ok P? Agent feels a foul smell Slide adapted from V. Pavlovic A S W?

13 Exploring the Wumpus world B ok P? Wumpus can’t be here since there was no smell there... Slide adapted from V. Pavlovic A S W? Pit can’t be there since there was no breeze here... ok

14 Exploring the Wumpus world B ok P? P Slide adapted from V. Pavlovic S W W? A ok A Agent senses nothing (no breeze, no smell,..) ok P W

15 Exploring the Wumpus world B ok P? P Slide adapted from V. Pavlovic S W W? ok A Agent senses breeze, smell, and sees gold! ok A BSG

16 Exploring the Wumpus world B ok P? P Slide adapted from V. Pavlovic S W W? ok Grab the gold and get out! ok A BSG A

17 Exploring the Wumpus world B ok P? Wumpus can’t be here since there was no smell there... Slide adapted from V. Pavlovic A S W? Pit can’t be there since there was no breeze here... How do we automate this kind of reasoning? (How can we make these inferences automatically?)

18 Logic Logic is a formal language for representing information such that conclusions can be drawn A logic has –Syntax that specifies symbols in the language and how they can be combined to form sentences –Semantics that specifies what facts in the world a semantics refers to. Assigns truth values to sentences based on their meaning in the world. –Inference procedure, a mechanical method for computing (deriving) new (true) sentences from existing sentences

19 Entailment The sentence A entails the sentence B If A is true, then B must also be true B is a ”logical consequence” of A Let’s explore this concept a bit... A ⊨ B

20 Example: Wumpus entailment Agent’s knowledge base (KB) after having visited (1,1) and (1,2): 1)The rules of the game (PEAS) 2)Nothing in (1,1) 3)Breeze in (1,2) Which models (states of the world) match these observations? 1 234 1 2 3 4

21 Example: Wumpus entailment We only care about neighboring rooms, i.e. {(2,1),(2,2),(1,3)}. We can’t know anything about the other rooms. We care about pits, because we have detected a breeze. We don’t want to fall down a pit. There are 2 3 =8 possible arrangements of {pit, no pit} in the three neighboring rooms. 1 234 1 2 3 4 Possible conclusions:  1 : There is no pit in (2,1)  2 : There is no pit in (2,2)  3 : There is no pit in (1,3)

22 The eight possible situations...

23 The eight possible situations......let’s explore this conclusion  1 : There is no pit in (2,1)

24 KB = The set of models that agrees with the knowledge base (the observed facts) [The KB is true in these models]  1 = The set of models that agrees with conclusion  1 [conclusion  1 is true in these models] If KB is true, then  1 is also true. KB entails  1. KB ⊨  1  1 : There is no pit in (2,1)

25 KB = The set of models that agrees with the knowledge base (the observed facts) [The KB is true in these models]  2 = The set of models that agrees with conclusion  2 [conclusion  2 is true in these models] KB ⊭  2 If KB is true, then  2 is not also true. KB does not entail  2.  2 : There is no pit in (2,2)

26 KB = The set of models that agrees with the knowledge base (the observed facts) [The KB is true in these models]  3 = The set of models that agrees with conclusion  3 [conclusion  3 is true in these models] ?  3 : There is no pit in (1,3) 33

27 KB = The set of models that agrees with the knowledge base (the observed facts) [The KB is true in these models]  3 = The set of models that agrees with conclusion  3 [conclusion  3 is true in these models] If KB is true, then  3 is not also true. KB does not entail  3.  3 : There is no pit in (1,3) KB ⊭  3 33

28 Inference engine We need an algorithm (a method) that automatically produces the entailed conclusions. We will call this an ”inference engine”

29 Inference engine ”A is derived from KB by inference engine i ” Truth-preserving: i only derives entailed sentences Complete: i derives all entailed sentences KB ⊢ i A We want inference engines that are both truth-preserving and complete

30 Atomic sentence = a single propositional symbol e.g. P, Q, P 13, W 31, G 32, T, F Complex sentence = combination of simple sentences using connectives ¬ (not) negation ∧ (and) conjunction ∨ (or) disjunction ⇒ (implies) implication ⇔ (iff = if and only if) biconditional Propositional (boolean) logic Syntax Wumpus in room (3,1)Pit in room (1,3) P 13 ∧ W 31 W 31 ⇒ S 32 W 31 ∨ ¬ W 31 Precedence: ¬,∧,∨,⇒,⇔

31 Semantics: The rules for whether a sentence is true or false T (true) is true in every model F (false) is false in every model The truth values for other proposition symbols are specified in the model. Truth values for complex sentences are specified in a truth table Propositional (boolean) logic Semantics Atomic sentences

32 Boolean truth table PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False True False True Please complete this table...

33 Boolean truth table PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False TrueFalse True FalseTrue FalseTrue False TrueFalse TrueFalse True FalseTrue

34 Boolean truth table Not P is the opposite of P PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False TrueFalse True FalseTrue FalseTrue False TrueFalse TrueFalse True FalseTrue

35 Boolean truth table PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False TrueFalse True FalseTrue FalseTrue False TrueFalse TrueFalse True FalseTrue P ∧ Q is true only when both P and Q are true

36 Boolean truth table P ∨ Q is true when either P or Q is true PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False TrueFalse True FalseTrue FalseTrue False TrueFalse TrueFalse True FalseTrue

37 Boolean truth table PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False TrueFalse True FalseTrue FalseTrue False TrueFalse TrueFalse True FalseTrue P ⇒ Q : If P is true then we claim that Q is true, otherwise we make no claim

38 Boolean truth table PQ ¬P¬PP∧QP∧QP∨QP∨QP⇒QP⇒QP⇔QP⇔Q False TrueFalse True FalseTrue FalseTrue False TrueFalse TrueFalse True FalseTrue P ⇔ Q is true when the truth values for P and Q are identical

39 Boolean truth table PQ P⊕QP⊕Q False True FalseTrue False The exlusive or (XOR) is different from the OR

40 Example: Wumpus KB Knowledge base 1 234 1 2 3 4 1.Nothing in (1,1) 2.Breeze in (1,2) R1:R1: ¬ P 11 R2:R2: ¬ B 11 R3:R3: ¬ W 11 R4:R4: ¬ S 11 R5:R5: ¬ G 11 R6:R6:B 12 R7:R7: ¬ P 12 R8:R8: ¬ S 12 R9:R9: ¬ W 12 R 10 : ¬ G 12 KB = R 1 ∧ R 2 ∧ R 3 ∧ R 4 ∧ R 5 ∧ R 6 ∧ R 7 ∧ R 8 ∧ R 9 ∧ R 10 Interesting sentences [tell us what is in neighbor squares] Plus the rules of the game

41 Example: Wumpus KB Knowledge base 1 234 1 2 3 4 1.Nothing in (1,1) 2.Breeze in (1,2) KB = R 1 ∧ R 2 ∧ R 3 ∧ R 4 ∧ R 5 ∧ R 6 ∧ R 7 ∧ R 8 ∧ R 9 ∧ R 10 R1:R1: ¬ P 11 R2:R2: ¬ B 11 ⇔ ¬ (P 21 ∨ P 12 ) R3:R3: ¬ W 11 R4:R4: ¬ S 11 ⇔ ¬ (W 21 ∨ W 12 ) R5:R5: ¬ G 11 R6:R6:B 12 ⇔ (P 11 ∨ P 22 ∨ P 13 ) R7:R7: ¬ P 12 R8:R8: ¬ S 12 ⇔ ¬ (W 11 ∨ W 21 ∨ W 13 ) R9:R9: ¬ W 12 (already in R 4 ) R 10 : ¬ G 12 We infer this from the rules of the game Plus the rules of the game

42 Inference by enumerating models What is in squares (1,3), (2,1), and (2,2)? #W 21 W 22 W 13 P 21 P 22 P 13 R2R2 R4R4 R6R6 R8R8 10000001101 20000011111 30000101111 40000111111 50001000101 ⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮ 630111110110 641111110010 We have 6 interesting sentences: W 21, W 22, W 13, P 21, P 22, P 13 : 2 6 = 64 comb. KB (interesting sentences) KB true

43 Inference by enumerating models What is in squares (1,3), (2,1), and (2,2)? #W 21 W 22 W 13 P 21 P 22 P 13 R2R2 R4R4 R6R6 R8R8 10000001101 20000011111 30000101111 40000111111 50001000101 ⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮ 630111110110 641111110010 KB true What do we deduce from this?

44 Inference by enumerating models What is in squares (1,3), (2,1), and (2,2)? #W 21 W 22 W 13 P 21 P 22 P 13 R2R2 R4R4 R6R6 R8R8 10000001101 20000011111 30000101111 40000111111 50001000101 ⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮ 630111110110 641111110010 KB true KB ⊨ ¬ W 21 ∧ ¬ W 22 ∧ ¬ W 13 ∧ ¬ P 21

45 Inference by enumerating models Implement as a depth-first search on a constraint graph (backtracking) Time complexity ~ O(2 n ) where n is the number of relevant sentences Space complexity ~ O(n) Not very efficient...

46 Inference methods 1.Model checking (enumerating) - Just seen that 2.Using rules of inference - Coming next

47 Some definitions Equivalence: A ≡ B iff A ⊨ B and B ⊨ A Validity: A valid sentence is true in all models (a tautology) A ⊨ B iff (A ⇒ B) is valid Satisfiability: A sentence is satisfiable if it is true in some model A ⊨ B iff (A ∧ ¬ B) is unsatisfiable Let’s explore satisfiability first...

48 KB = The set of models that agrees with the knowledge base (the observed facts) [The KB is true in these models]  1 = The set of models that agrees with conclusion  1 [conclusion  1 is true in these models] If KB is true, then  1 is also true. KB entails  1. KB ⊨  1 KB ⊆  1 ¬1¬1 KB ^ ¬  1 never true

49 Some definitions Equivalence: A ≡ B iff A ⊨ B and B ⊨ A Validity: A valid sentence is true in all models (a tautology) A ⊨ B iff (A ⇒ B) is valid Satisfiability: A sentence is satisfiable if it is true in some model A ⊨ B iff (A ∧ ¬ B) is unsatisfiable AB A⇒BA⇒BA∧¬BA∧¬B False TrueFalse True False TrueFalse True False

50 Some definitions Equivalence: A ≡ B iff A ⊨ B and B ⊨ A Validity: A valid sentence is true in all models (a tautology) A ⊨ B iff (A ⇒ B) is valid Satisfiability: A sentence is satisfiable if it is true in some model A ⊨ B iff (A ∧ ¬ B) is unsatisfiable AB A⇒BA⇒BA∧¬BA∧¬B False TrueFalse True False TrueFalse True False

51 Some definitions Equivalence: A ≡ B iff A ⊨ B and B ⊨ A Validity: A valid sentence is true in all models (a tautology) A ⊨ B iff (A ⇒ B) is valid Satisfiability: A sentence is satisfiable if it is true in some model A ⊨ B iff (A ∧ ¬ B) is unsatisfiable A ⊨ B means that the set of models where A is true is a subset of the models where B is true: A ⊆ B B ⊨ A means that the set of models where B is true is a subset of the models where A is true: B ⊆ A Therefore, the set of models where A is true must be equal to the set of models where B is true: A ≡ B A B B A A≡BA≡B

52 Some definitions Equivalence: A ≡ B iff A ⊨ B and B ⊨ A Validity: A valid sentence is true in all models (a tautology) A ⊨ B iff (A ⇒ B) is valid Satisfiability: A sentence is satisfiable if it is true in some model A ⊨ B iff (A ∧ ¬ B) is unsatisfiable AB A⇒BA⇒B False True FalseTrue False True KB ⊨  1

53 Logical equivalences (A ∧ B) ≡ (B ∧ A) ∧ is commutative (A ∨ B) ≡ (B ∨ A) ∨ is commutative ((A ∧ B) ∧ C) ≡ (A ∧ (B ∧ C)) ∧ is associative ((A ∨ B) ∨ C) ≡ (A ∨ (B ∨ C)) ∨ is associative ¬ ( ¬ A) ≡ ADouble-negation elimination (A ⇒ B) ≡ ( ¬ B ⇒ ¬ A) Contraposition (A ⇒ B) ≡ ( ¬ A ∨ B) Implication elimination (A ⇔ B) ≡ ((A ⇒ B) ∧ (B ⇒ A)) Biconditional elimination ¬ (A ∧ B) ≡ ( ¬ A ∨ ¬ B) ”De Morgan” ¬ (A ∨ B) ≡ ( ¬ A ∧ ¬ B) ”De Morgan” (A ∧ (B ∨ C)) ≡ ((A ∧ B) ∨ (A ∧ C))Distributivity of ∧ over ∨ (A ∨ (B ∧ C)) ≡ ((A ∨ B) ∧ (A ∨ C))Distributivity of ∨ over ∧

54 Example: DeMorgan (I) AB A ∧ B ¬ (A ∧ B) ¬A¬A ¬B¬B ¬ A ∨ ¬ B False True FalseTrueFalseTrue FalseTrue False TrueFalseTrue False ¬(A ∧ B) ≡ (¬A ∨ ¬B)

55 Logical equivalences (A ∧ B) ≡ (B ∧ A) ∧ is commutative (A ∨ B) ≡ (B ∨ A) ∨ is commutative ((A ∧ B) ∧ C) ≡ (A ∧ (B ∧ C)) ∧ is associative ((A ∨ B) ∨ C) ≡ (A ∨ (B ∨ C)) ∨ is associative ¬ ( ¬ A) ≡ ADouble-negation elimination (A ⇒ B) ≡ ( ¬ B ⇒ ¬ A) Contraposition (A ⇒ B) ≡ ( ¬ A ∨ B) Implication elimination (A ⇔ B) ≡ ((A ⇒ B) ∧ (B ⇒ A)) Biconditional elimination ¬ (A ∧ B) ≡ ( ¬ A ∨ ¬ B) ”De Morgan” ¬ (A ∨ B) ≡ ( ¬ A ∧ ¬ B) ”De Morgan” (A ∧ (B ∨ C)) ≡ ((A ∧ B) ∨ (A ∧ C))Distributivity of ∧ over ∨ (A ∨ (B ∧ C)) ≡ ((A ∨ B) ∧ (A ∨ C))Distributivity of ∨ over ∧ Work out some of these on paper for yourself, before we move on...

56 Inference rules Inference rules are written as If the KB contains the antecedent, you can add the consequent (the KB entails the consequent) Slide adapted from D. Byron

57 Inference rules Inference rules are written as If the KB contains the antecedent, you can add the consequent (the KB entails the consequent) Slide adapted from D. Byron

58 Commonly used inference rules Modus Ponens Modus Tolens Unit Resolution And Elimination Or introduction And introduction Slide adapted from D. Byron

59 Proof for Modus Ponens AB A ⇒ B 1False 2 TrueFalse 3TrueFalse 4True

60 Proof for Modus Ponens AB A ⇒ B 1False True 2FalseTrue 3 False 4True These are the cases when A is True

61 Proof for Modus Ponens AB A ⇒ B 1False True 2FalseTrue 3 False 4True These are the cases when A ⇒ B is True

62 Proof for Modus Ponens AB A ⇒ B 1False 2 TrueFalse 3TrueFalse 4True This is the case when both A and A ⇒ B is True B is also True here so we can safely add B = True to our KB

63 Proof for Unit Resolution AB A ∨ B ¬A¬A ¬B¬B 1False True 2FalseTrue False 3TrueFalseTrueFalseTrue 4 False

64 Proof for Unit Resolution AB A ∨ B ¬A¬A ¬B¬B 1False True 2FalseTrue False 3TrueFalseTrueFalseTrue 4 False These are the cases when A ∨ B is True

65 Proof for Unit Resolution AB A ∨ B ¬A¬A ¬B¬B 1False True 2FalseTrue False 3TrueFalseTrueFalseTrue 4 False These are the cases when ¬ B is True

66 Proof for Unit Resolution AB A ∨ B ¬A¬A ¬B¬B 1False True 2FalseTrue False 3TrueFalseTrueFalseTrue 4 False This is the case when both ¬ B and A ∨ B are True A is also True here so we can safely add A = True to our KB

67 Commonly used inference rules Modus Ponens Modus Tolens Unit Resolution And Elimination Or introduction And introduction Slide adapted from D. Byron Work out these on paper for yourself too

68 Example: Proof in Wumpus KB Knowledge base 1 234 1 2 3 4 1.Nothing in (1,1) R1:R1: ¬ P 11 R2:R2: ¬ B 11 R3:R3: ¬ W 11 R4:R4: ¬ S 11 R5:R5: ¬ G 11

69 Proof in Wumpus KB B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination (P 12 ∨ P 21 ) ⇒ B 11 And elimination ¬ B 11 ⇒ ¬ (P 12 ∨ P 21 ) Contraposition ¬ B 11 ⇒ ¬ P 12 ∧ ¬ P 21 ”De Morgan”

70 Proof in Wumpus KB B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination (P 12 ∨ P 21 ) ⇒ B 11 And elimination ¬ B 11 ⇒ ¬ (P 12 ∨ P 21 ) Contraposition ¬ B 11 ⇒ ¬ P 12 ∧ ¬ P 21 ”De Morgan” (A ⇔ B) ≡ ((A ⇒ B) ∧ (B ⇒ A))

71 Proof in Wumpus KB B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination (P 12 ∨ P 21 ) ⇒ B 11 And elimination ¬ B 11 ⇒ ¬ (P 12 ∨ P 21 ) Contraposition ¬ B 11 ⇒ ¬ P 12 ∧ ¬ P 21 ”De Morgan”

72 Proof in Wumpus KB B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination (P 12 ∨ P 21 ) ⇒ B 11 And elimination ¬ B 11 ⇒ ¬ (P 12 ∨ P 21 ) Contraposition ¬ B 11 ⇒ ¬ P 12 ∧ ¬ P 21 ”De Morgan” (A ⇒ B) ≡ (¬B ⇒ ¬A)

73 Proof in Wumpus KB B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination (P 12 ∨ P 21 ) ⇒ B 11 And elimination ¬ B 11 ⇒ ¬ (P 12 ∨ P 21 ) Contraposition ¬ B 11 ⇒ ¬ P 12 ∧ ¬ P 21 ”De Morgan” ¬(A ∨ B) ≡ (¬A ∧ ¬B)

74 Proof in Wumpus KB B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination (P 12 ∨ P 21 ) ⇒ B 11 And elimination ¬ B 11 ⇒ ¬ (P 12 ∨ P 21 ) Contraposition ¬ B 11 ⇒ ¬ P 12 ∧ ¬ P 21 ”De Morgan” Thus, we have proved, in four steps, that no breeze in (1,1) means there can be no pit in either (1,2) or (2,1) The machine can come to this conclusion all by itself if we give the rules of the game. More efficient than enumerating models.

75 The Resolution rule An inference algorithm is guaranteed to be complete if it uses the resolution rule Unit resolution Full resolution (A  B)  B A

76 The Resolution rule An inference algorithm is guaranteed to be complete if it uses the resolution rule Unit resolution Full resolution A clause = a disjunction ( ∨ ) of literals (sentences)

77 The Resolution rule An inference algorithm is guaranteed to be complete if it uses the resolution rule Note: The resulting clause should only contain one copy of each literal.

78 Resolution truth table AB ¬B¬B C A∨BA∨B ¬B∨C¬B∨CA∨CA∨C 1011111 1101111 0101111 0011011 1010111 1100101 0100100 0010010 ((A ∨ B) ∧ ( ¬ B ∨ C)) ⇒ (A ∨ C)

79 Resolution truth table AB ¬B¬B C A∨BA∨B ¬B∨C¬B∨CA∨CA∨C 1011111 1101111 0101111 0011011 1010111 1100101 0100100 0010010 ((A ∨ B) ∧ ( ¬ B ∨ C)) ⇒ (A ∨ C) Proof for the resolution rule

80 Conjunctive normal form (CNF) Every sentence of propositional logic is equivalent to a conjunction or disjunction of literals. Sentences expressed in this way are in conjunctive normal form (CNF) [if conjunctions are used] A sentence with exactly k literals per clause is expressed in k -CNF This is good, it means we can get far with the resolution inference rule.

81 Wumpus CNF example B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination ( ¬ B 11 ∨ (P 12 ∨ P 21 )) ∧ ( ¬ (P 12 ∨ P 21 ) ∨ B 11 ) Implication elimination ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ (( ¬ P 12 ∧ ¬ P 21 ) ∨ B 11 ) ”De Morgan” ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ (( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨ ¬ P 21 )) Distributivity ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ ( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨ ¬ P 21 ) Voilá – CNF (A ⇒ B) ≡ ( ¬ A ∨ B) (A ⇔ B) ≡ ((A ⇒ B) ∧ (B ⇒ A)) ¬ (A ∨ B) ≡ ( ¬ A ∧ ¬ B) (A ∨ (B ∧ C)) ≡ ((A ∨ B) ∧ (A ∨ C))

82 Wumpus CNF example B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game B 11 ⇒ (P 12 ∨ P 21 ) ∧ (P 12 ∨ P 21 ) ⇒ B 11 Biconditional elimination ( ¬ B 11 ∨ (P 12 ∨ P 21 )) ∧ ( ¬ (P 12 ∨ P 21 ) ∨ B 11 ) Implication elimination ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ (( ¬ P 12 ∧ ¬ P 21 ) ∨ B 11 ) ”De Morgan” ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ (( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨ ¬ P 21 )) Distributivity ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ ( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨ ¬ P 21 ) Voilá – CNF

83 The resolution refutation algorithm Proves by the principle of contradiction: Show that KB ⊨  by proving that (KB ∧ ¬  ) is unsatisfiable. 1.Convert (KB ∧ ¬  ) to CNF 2.Apply the resolution inference rule repeatedly to the resulting clauses 3.Continue until: (a) No more clauses can be added, KB ⊭  (b) The empty clause ( ∅ ) is produced, KB ⊨ 

84 KB = The set of models that agrees with the knowledge base (the observed facts) [The KB is true in these models]  1 = The set of models that agrees with conclusion  1 [conclusion  1 is true in these models] If KB is true, then  1 is also true. KB entails  1. KB ⊨  1 KB ⊆  1 ¬1¬1 KB ^ ¬  1 never true

85 Wumpus resolution example B 11 ⇔ (P 12 ∨ P 21 ) Rule of the game ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ ( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨ ¬ P 21 ) CNF ¬ B 11 Observation ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ ( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨ ¬ P 21 ) ∧ ¬ B 11 KB in CNF ¬ P 21 Hypothesis (  ) KB ∧ ¬  = ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ ( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨¬ P 21 ) ∧¬ B 11 ∧ P 21

86 Wumpus resolution example KB ∧ ¬  = ( ¬ B 11 ∨ P 12 ∨ P 21 ) ∧ ( ¬ P 12 ∨ B 11 ) ∧ (B 11 ∨¬ P 21 ) ∧¬ B 11 ∧ P 21 ¬ P 21 (B 11 ∨ ¬ P 21 ), ¬ B 11 ∅ P 21, ¬ P 21 Not satisfied, we conclude that KB ⊨ 

87 Completeness of resolution S = Set of clauses RC(S) = Resolution closure of S RC(S) = Set of all clauses that can be derived from S by the resolution inference rule. RC(S) has finite cardinality (finite number of symbols P 1, P 2,..., P k ) ⇒ Resolution refutation must terminate.

88 Completeness of resolution The ground resolution theorem If a set S is unsatisfiable, then RC(S) contains the empty clause ∅. Left without proof.

89 Exercise Your knowledge base (KB) is this: Prove, using the resolution refutation algorithm, that A is True

90 Exercise Prove, using the resolution refutation algorithm, that A is True KB in CNF Hypothesis: A is True Your knowledge base (KB) is this:

91 Exercise KB ∧ ¬ 

92 Exercise KB ∧ ¬ 

93 Exercise KB ∧ ¬ 

94 Exercise KB ∧ ¬ 

95 Exercise KB ∧ ¬ 

96 Exercise KB ∧ ¬ 

97 Exercise KB ∧ ¬  (KB ∧ ¬ ) is unsatisfiable so  is True.

98 Exercise KB ∧ ¬  We could have illustrated the resolution refutation steps with a graph......on the next slide...

99

100 Problem with resolution refutation It may expand all nodes (all statements) – exponential in both space and time Is there not a more efficient way to only expand those nodes (statements) that affect our query?

101 Horn clauses and forward- backward chaining Restricted set of clauses: Horn clauses disjunction of literals where at most one is positive, e.g., ( ¬ A 1 ∨ ¬ A 2 ∨ ⋯ ∨ ¬ A k ∨ B) or ( ¬ A 1 ∨ ¬ A 2 ∨ ⋯ ∨ ¬ A k ) Why Horn clauses? Every Horn clause can be written as an implication, e.g., ( ¬ A 1 ∨ ¬ A 2 ∨ ⋯ ∨ ¬ A k ∨ B) ≡ (A 1 ∧ A 2 ∧ ⋯ ∧ A k ) ⇒ B ( ¬ A 1 ∨ ¬ A 2 ∨ ⋯ ∨ ¬ A k ) ≡ (A 1 ∧ A 2 ∧ ⋯ ∧ A k ) ⇒ False Inference in Horn clauses can be done using forward- backward (F-B) chaining in linear time Slide adapted from V. Pavlovic

102 Forward or Backward? Inference can be run forward or backward Forward-chaining: –Use the current facts in the KB to trigger all possible inferences Backward-chaining: –Work backward from the query proposition Q –If a rule has Q as a conclusion, see if antecedents can be found to be true Slide adapted from D. Byron

103 Example AND gate OR gate KB We are going to check if Q is True KB in graph form

104 Example of forward chaining Slide adapted from V. Pavlovic (who borrowed from Lee?) KB A B L M P Q Agenda AND-OR graph Every step is Modus Ponens, e.g. We’ve proved that Q is true

105 Slide adapted from Lee Example of backward chaining KB Query: is Q true Yes, Q is true

106 Wumpus world revisited 1-16 B i,j ⇔ (P i,j+1 ∨ P i,j-1 ∨ P i-1,j ∨ P i+1,j ) ROG: Pits 17-32 S i,j ⇔ (W i,j+1 ∨ W i,j-1 ∨ W i-1,j ∨ W i+1,j ) ROG: Wumpus’ odor 33 (W 1,1 ∨ W 1,2 ∨ W 1,3 ∨ ⋯ ∨ W 4,3 ∨ W 4,4 ) ROG: #W ≥ 1 34-153 ¬ (W i,j ∧ W k,l ) ROG: #W ≤ 1 154 (G 1,1 ∨ G 1,2 ∨ G 1,3 ∨ ⋯ ∨ G 4,3 ∨ G 4,4 ) ROG: #G ≥ 1 155-274 ¬ (G i,j ∧ G k,l ) ROG: #G ≤ 1 275 ( ¬ B 11 ∧ ¬ W 11 ∧ ¬ G 11 ) ROG: Start safe Knowledge base (KB) in initial position (ROG = Rule of the Game) There are 5 ”on-states” for every square, {W,P,S,B,G}. A 4  4 lattice has 16  5 = 80 distinct symbols. Enumerating models means going through 2 80 models! The physics rules (1-32) are very unsatisfying – no generalization.

107 Summary Knowledge is in the form of sentences in a knowledge representation language. The representation language has syntax and semantics. Propositional logic: Proposition symbols and logical connectives. Inference: –Model checking –Inference rules, especially resolution Horn clauses


Download ppt "Cooperating Intelligent Systems Logical agents Chapter 7, AIMA This presentation owes some to V. Rutgers and D. OSU."

Similar presentations


Ads by Google