1 / 55

Cooperating Intelligent Systems

Cooperating Intelligent Systems. Inference in first-order logic Chapter 9, AIMA. Reduce to propositional logic. Reduce the first order logic sentences to propositional (boolean) logic. Use the inference systems in propositional logic.

garan
Download Presentation

Cooperating Intelligent Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA

  2. Reduce to propositional logic • Reduce the first order logic sentences to propositional (boolean) logic. • Use the inference systems in propositional logic. We need a system for transfering sentences with quantifiers to sentences without quantifiers 

  3. FOL inference rules All the propositional rules (Modus Ponens, And Elimination, And introduction, etc.) plus: Universal Instantiation (UI) Where the variable x is replaced by the ground term a everywhere in the sentence w. Example: ∀x P(x,f(x),B) ⇒ P(A,f(A),B) Existential Instantiation (EI) Where the variable x is replaced by a ground term a (that makes the sentence true) in the sentence w. Example: ∃x Q(x,g(x),B) ⇒ Q(A,g(A),B) A must be a new symbol. Ground term = a term without variables

  4. Example: Kings... C is called a Skolem constant Making up names is called skolemization

  5. Example: Kings... C is called a Skolem constant Making up names is called skolemization

  6. Propositionalization Apply Universal Instantiation (UI) and Existential Instantiation (EI) so that every FOL KB is made into a propositional KB. ⇒ We can use the tools from propositional logic to prove theorems. Problem with function constants: Father(A), Father(Father(A)), Father(Father(Father(A))), etc. ad infinitum...infinite number of sentences...how can we prove this in finite time? Theorem: We can find every entailed sentence [Gödel, Herbrand], but the search is not guaranteed to stop for nonentailed sentences.(”Solution”: negation-as-failure, stop after a certain time and assume the sentence is false) Inefficient...generalized (lifted) inference rules better

  7. Notation: Substitution Subst(q,a) = Apply the substitution q to the sentence a. Example: • = {x/John} (replace x with John) a = (King(x) ∧ Greedy(x)) ⇒ Evil(x) (King(John) ∧ Greedy(John)) ⇒ Evil(John) General form: q = {v/g} where v is a variable and g is a ground term.

  8. KB p1 = King(John) q1 = King(x) ∀x (King(x) ∧ Greedy(x) ⇒ Evil(x)) p2 = Greedy(John) q2 = Greedy(x) q = {x/John} r = Evil(x) Generalized (lifted) Modus Ponens For atomic sentences pi, qi, and r where there exists a substitution q such that Subst(q,pi) = Subst(q,qi) for all i We have John who is King and is Greedy. If someone is King and Greedy then he/she/it is also Evil.

  9. KB p1 = King(John) q1 = King(x) ∀x (King(x) ∧ Greedy(x) ⇒ Evil(x)) p2 = Greedy(John) q2 = Greedy(x) q = {x/John} r = Evil(x) Generalized (lifted) Modus Ponens For atomic sentences pi, qi, and r where there exists a substitution q such that Subst(q,pi) = Subst(q,qi) for all i Subst(q,p1) = Subst(q,q1)

  10. KB p1 = King(John) q1 = King(x) ∀x (King(x) ∧ Greedy(x) ⇒ Evil(x)) p2 = Greedy(John) q2 = Greedy(x) q = {x/John} r = Evil(x) Generalized (lifted) Modus Ponens For atomic sentences pi, qi, and r where there exists a substitution q such that Subst(q,pi) = Subst(q,qi) for all i Subst(q,p2) = Subst(q,q2)

  11. KB p1 = King(John) q1 = King(x) ∀x (King(x) ∧ Greedy(x) ⇒ Evil(x)) p2 = Greedy(John) q2 = Greedy(x) q = {x/John} r = Evil(x) King(John), Greedy(John) Subst(q,r) = Evil(John) ⇒Evil(John) Generalized (lifted) Modus Ponens For atomic sentences pi, qi, and r where there exists a substitution q such that Subst(q,pi) = Subst(q,qi) for all i

  12. KB p1 = King(John) q1 = King(x) ∀x (King(x) ∧ Greedy(x) ⇒ Evil(x)) p2 = Greedy(John) q2 = Greedy(x) q = {x/John} r = Evil(x) King(John), Greedy(John) Subst(q,r) = Evil(John) ⇒Evil(John) Generalized (lifted) Modus Ponens For atomic sentences pi, qi, and r where there exists a substitution q such that Subst(q,pi) = Subst(q,qi) for all i Lifted inference rules make only the necessary substitutions

  13. Forward chaining example KB: • All cats like fish • Cats eat everything they like • Ziggy is a cat Example from Tuomas Sandholm @ CMU

  14. Forward chaining example KB: • All cats like fish • Cats eat everything they like • Ziggy is a cat Example from Tuomas Sandholm @ CMU

  15. Ziggy the cat eats the fish! Eats(Ziggy,Fish) Cat(x) ∧ Likes(x,y) ⇒ Eats(x,y)q = {x/Ziggy, y/Fish} Likes(Ziggy,Fish) Cat(x) ⇒ Likes(x,Fish)q = {x/Ziggy} Cat(Ziggy)

  16. Example: Arms dealer KB in Horn Form

  17. Example: Arms dealer KB in Horn Form Facts

  18. Forward chaining: Arms dealer Forward chaining generates all inferences (also irrelevant ones) We have proved thatWest is a criminal Criminal(West) American(x) ∧ Weapon(y) ∧ Hostile(z)∧ Sells(x,y,z) ⇒ Criminal(x)q = {x/West, y/M, z/NoNo} Weapon(M) Sells(West,M,NoNo) Hostile(NoNo) Missile(x) ∧ Owns(NoNo,x) ⇒Sells(West,x,NoNo)q = {x/M} Missile(x) ⇒ Weapon(x)q = {x/M} Enemy(x,America) ⇒ Hostile(x)q = {x/NoNo} American(West) Missile(M) Owns(NoNo,M) Enemy(NoNo,America)

  19. Example: Financial advisor KB in Horn Form • SavingsAccount(Inadequate) ⇒ Investments(Bank) • SavingsAccount(Adequate) ∧ Income(Adequate) ⇒ Investments(Stocks) • SavingsAccount(Adequate) ∧ Income(Inadequate) ⇒ Investments(Mixed) • ∀x (AmountSaved(x) ∧∃y (Dependents(y) ∧ Greater(x,MinSavings(y))) ⇒ SavingsAccount(Adequate)) • ∀x (AmountSaved(x) ∧∃y (Dependents(y) ∧¬Greater(x,MinSavings(y))) ⇒ SavingsAccount(Inadequate)) • ∀x (Earnings(x,Steady) ∧∃y (Dependents(y) ∧ Greater(x,MinIncome(y))) ⇒ Income(Adequate)) • ∀x (Earnings(x,Steady) ∧∃y (Dependents(y) ∧¬Greater(x,MinIncome(y))) ⇒ Income(Inadequate)) • ∀x (Earnings(x,UnSteady) ⇒ Income(Inadequate)) • AmountSaved($22000) • Earnings($25000,Steady) • Dependents(3) MinSavings(x) ≡ $5000•xMinIncome(x) ≡ $15000 + ($4000•x) Example from G.F. Luger, ”Artificial Intelligence” 2002

  20. FC financial advisor Investments(Mixed) SavingsAccount(Adequate) Income(Inadequate) ¬Greater($25000,MinIncome) Greater($22000,MinSavings) MinIncome = $27000MinSavings = $15000 AmountSaved($22000) Dependents(3) Earnings($25000,Steady)

  21. FOL CNF (Conjunctive Normal Form) Literal = (possibly negated) atomic sentence, e.g., ¬Rich(Me) Clause = disjunction of literals, e.g. ¬Rich(Me) ∨ Unhappy(Me) The KB is a conjunction of clauses Any FOL KB can be converted to CNF as follows: • Replace (P ⇒ Q) by (¬P ∨ Q) (implication elimination) • Move ¬ inwards, e.g., ¬∀x P(x) becomes ∃x ¬P(x) • Standardize variables apart, e.g., (∀x P(x) ∨∃x Q(x)) becomes (∀x P(x) ∨∃y Q(y)) • Move quantifiers left, e.g., (∀x P(x) ∨∃y Q(y)) becomes ∀x ∃y (P(x) ∨ Q(y)) • Eliminate ∃ by Skolemization • Drop universal quantifiers • Distribute ∧ over ∨, e.g., (P ∧ Q) ∨ R becomes (P ∨ R) ∧ (Q ∨ R) Slide from S. Russel

  22. CNF example ”Everyone who loves all animals is loved by someone” ∀x [∀y Animal(y) ⇒ Loves(x,y)] ⇒ ∃y Loves(y,x) Implication elimination∀x ¬[∀y ¬Animal(y) ∨ Loves(x,y)] ∨ ∃y Loves(y,x) Move ¬ inwards (¬∀y P becomes ∃y ¬P)∀x [∃y ¬(¬Animal(y) ∨ Loves(x,y))] ∨ ∃y Loves(y,x)∀x [∃y (Animal(y) ∧¬Loves(x,y))] ∨ ∃y Loves(y,x)∀x [∃y Animal(y) ∧¬Loves(x,y)] ∨ ∃y Loves(y,x) Standardize variables individually∀x [∃y Animal(y) ∧¬Loves(x,y)] ∨ ∃z Loves(z,x) Skolemize (Replace ∃ with constants)∀x [Animal(F(x)) ∧¬Loves(x,F(x))] ∨ Loves(G(x),x)Why not ∀x [Animal(A) ∧¬Loves(x,A)] ∨ Loves(B,x) ?? Drop ∀[Animal(F(x)) ∧¬Loves(x,F(x))] ∨ Loves(G(x),x) Distribute ∨ over ∧[Animal(F(x)) ∨ Loves(G(x),x)] ∧ [¬Loves(x,F(x)) ∨ Loves(G(x),x)]

  23. Notation: Unification Unify(p,q) = q means that Subst(q,p) = Subst(q,q)

  24. FOL resolution inference rule First-order literals are complementary if one unifies with the negation of the other Where Unify(li,¬mj) = q. Note that li and mj are removed

  25. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable Start fromthe top ¬ Arms dealer example

  26. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ∀x (American(x)∧Weapon(y)∧Hostile(z)∧Sells(x,y,z)⇒Criminal(x)) Translate to CNF: ∀x (¬(American(x)∧Weapon(y)∧Hostile(z)∧Sells(x,y,z))∨Criminal(x)) ∀x ((¬American(x)∨¬Weapon(y)∨¬Hostile(z)∨¬Sells(x,y,z))∨Criminal(x)) ∀x (¬American(x)∨¬Weapon(y)∨¬Hostile(z)∨¬Sells(x,y,z)∨Criminal(x)) ¬American(x)∨¬Weapon(y)∨¬Hostile(z)∨¬Sells(x,y,z)∨Criminal(x) • Any FOL KB can be converted to CNF as follows: • Replace (P ⇒ Q) by (¬P ∨ Q) (implication elimination) • Move ¬ inwards, e.g., ¬∀x P(x) becomes ∃x ¬P(x) • Standardize variables apart, e.g., (∀x P(x) ∨ ∃x Q(x)) becomes (∀x P(x) ∨ ∃y Q(y)) • Move quantifiers left, e.g., (∀x P(x) ∨ ∃y Q(y)) becomes ∀x ∃y (P(x) ∨ Q(y)) • Eliminate ∃ by Skolemization • Drop universal quantifiers • Distribute ∧ over ∨, e.g., (P ∧ Q) ∨ R becomes (P ∨ R) ∧ (Q ∨ R) ¬ Arms dealer example

  27. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ∀x (American(x)∧Weapon(y)∧Hostile(z)∧Sells(x,y,z)⇒Criminal(x)) Translate to CNF: ∀x (¬(American(x)∧Weapon(y)∧Hostile(z)∧Sells(x,y,z))∨Criminal(x)) ∀x ((¬American(x)∨¬Weapon(y)∨¬Hostile(z)∨¬Sells(x,y,z))∨Criminal(x)) ∀x (¬American(x)∨¬Weapon(y)∨¬Hostile(z)∨¬Sells(x,y,z)∨Criminal(x)) ¬American(x)∨¬Weapon(y)∨¬Hostile(z)∨¬Sells(x,y,z)∨Criminal(x) • Any FOL KB can be converted to CNF as follows: • Replace (P ⇒ Q) by (¬P ∨ Q) (implication elimination) • Move ¬ inwards, e.g., ¬∀x P(x) becomes ∃x ¬P(x) • Standardize variables apart, e.g., (∀x P(x) ∨ ∃x Q(x)) becomes (∀x P(x) ∨ ∃y Q(y)) • Move quantifiers left, e.g., (∀x P(x) ∨ ∃y Q(y)) becomes ∀x ∃y (P(x) ∨ Q(y)) • Eliminate ∃ by Skolemization • Drop universal quantifiers • Distribute ∧ over ∨, e.g., (P ∧ Q) ∨ R becomes (P ∨ R) ∧ (Q ∨ R) ¬ Arms dealer example

  28. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable Where Unify(li,¬mj) = q. ¬ Arms dealer example

  29. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable Where Unify(li,¬mj) = q. l1 = ¬American(x) l2 = ¬Weapon(y) l3 = ¬Sells(x,y,z) l4 = ¬Hostile(z) l5 = Criminal(x) m1 = Criminal(West) Unify(l5,¬m1) = q= {x/West} Subst(q,l1∨ l2∨ l3∨ l4) =... ¬ Arms dealer example

  30. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  31. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable l1 = ¬American(x) l2 = ¬Weapon(y) l3 = ¬Sells(x,y,z) l4 = ¬Hostile(z) l5 = Criminal(x) m2 = American(West) Unify(l1,¬m2) = q= {x/West} Subst(q,l2∨ l3∨ l4) =... ¬ Arms dealer example

  32. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  33. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  34. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ? ¬ Arms dealer example

  35. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable l2 = ¬Weapon(y) l3 = ¬Sells(x,y,z) l4 = ¬Hostile(z) m3 = Weapon(x) m4 = Missile(x) Unify(l2,¬m3) = q= {y/x} Subst(q,l2∨ l3∨ l4 ∨ m4) =... ¬ Arms dealer example

  36. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ? ¬ Arms dealer example

  37. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  38. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  39. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  40. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example

  41. Resolution proves KB ⊨a by proving (KB ∧¬a) is unsatisfiable ¬ Arms dealer example ∅

  42. Resolution example II • Problem Statement: Tony, Shikuo and Ellen belong to the Hoofers Club. Every member of the Hoofers Club is either a skier or a mountain climber or both. No mountain climber likes rain, and all skiers like snow. Ellen dislikes whatever Tony likes and likes whatever Tony dislikes. Tony likes rain and snow. • Query: Is there a member of the Hoofers Club who is a mountain climber but not a skier? Example from Charles Dyer (referenced by Tuomas Sandhom @ CMU)

  43. KB The rules only apply to members of the Hoofers club (our domain). Problem Statement: Tony, Shikuo and Ellen belong to the Hoofers Club. Every member of the Hoofers Club is either a skier or a mountain climber or both. No mountain climber likes rain, and all skiers like snow. Ellen dislikes whatever Tony likes and likes whatever Tony dislikes. Tony likes rain and snow.

  44. Query Query: Is there a member of the Hoofers Club who is a mountain climber but not a skier?

  45. KB + the negation of the Query

  46. (KB ∧¬Q) to Clause form...(I)

  47. (KB ∧¬Q) to Clause form...(II)

  48. (KB ∧¬Q) to Clause form...(III)

  49. (KB ∧¬Q) to Clause form...(IV)

  50. (KB ∧¬Q) in Clause form We drop the universal quantifiers... But introduce different notation to keepbetter track...

More Related