220 likes | 857 Views
FOL: Extra problems to solve. IT 422: intelligent systems. Tutorial #7: Q4. For each pair of atomic sentences, give the most general unifier if it exists : P(a,b,b ), P(x, y, z). { x /a , y /b , z /b } b. Q(y, G(a, b)), Q(G(x, x), y).
E N D
FOL: Extra problems to solve IT 422: intelligent systems
Tutorial #7: Q4 • For each pair of atomic sentences, give the most general unifier if it exists: • P(a,b,b), P(x, y, z). { x /a , y /b , z /b } b. Q(y, G(a, b)), Q(G(x, x), y). No unifier ({y/G(A,B),G(A,B)/G(x,x)}? x cannot take both the values a and b.
Tutorial #7: Q4 c. Older(Father(y), y), Older(Father(x), John). { y / John , x / John } d. Knows(Father(y), y), Knows(x, x). fail. Start with (partial) substitution x/father(y). One clause is now knows(father(y),y), and the other knows(father(y),father(y)). Unification fails here because we can’t unify y and father(y), due to the occurs check.
Tutorial #7: Q7 Consider the following axioms: • All hounds howl at night. • Anyone who has any cats will not have any mice. • Light sleepers do not have anything which howls at night. • Ali has either a cat or a hound. • Using FOL translate each of the above axioms into a well formed formula (WFF). • Given the fact that Ali is a light sleeper, give the sequence of inference rules to prove that Ali does not have any mice.
Q7: Translating the sentences into WFF • All hounds howl at night. R1: ∀ x (Hound(x) ⇒ Howl(x)) • Anyone who has any cats will not have any mice. R2: ∀ x ∀y ∀z (Have(x, y) ^ Cat(y) ⇒ ¬(Have(x, z) ^ Mouse(z))) • Light sleepers do not have anything which howls at night. R3: ∀ x ∀y (LS(x) ⇒ ¬(Have(x, y) ⋀Howl(y)) • Ali has either a cat or a hound. R4: Ǝx(Have(Ali, x) ^ (Cat(x) V Hound(x)))
Q7: Ali does not have any mice? Cont. • Given the fact that Ali is a light sleeper, give the sequence of inference rules to prove that Ali does not have any mice. • Translate: (if Ali is a light sleeper then Ali does not have any mice)into WFF R5: LS(Ali) ⇒¬Ǝz (Have(Ali, z) ^ Mouse(z))
Q7: Ali does not have any mice? Cont.Negated conclusion • To prove LS(Ali) ⇒¬Ǝz (Have(Ali, z) ^ Mouse(z)) • Negate the conclusion, and convert the premise and the negated conclusion into conjunctive normal form. • Use resolution to show that the conclusion follows from the premise ( you should find a contradiction, an empty clause).
Q7: CNF Write the set of sentences (KB) as CNF in order to use the resolution rule. • ∀ x (Hound(x) ⇒ Howl(x) ¬Hound(x) V Howl(x) • ∀ x ∀y ∀z (Have(x, y) ^ Cat(y) ⇒ ¬(Have(x, z) ^ Mouse(z))) ¬Have(x, y) V ¬Cat(y) V ¬Have(x, z) V ¬Mouse(z) • ∀ x ∀y (LS(x) ⇒ ¬(Have(x, y) ⋀Howl(y)) ¬LS(x) V ¬Have(x, y) V ¬Howl(y) • Ǝx (Have(Ali, x) ^ (Cat(x) V Hound(x))) Have(Ali, A) ^(Cat(A) V Hound(A)) (Skolemize, it is CNF)
Q7: CNF 5. ¬R5 (negated conclusion) ¬ (LS(Ali) ⇒¬Ǝz (Have(Ali, z) ^ Mouse(z))) ¬ (¬LS(Ali) V (¬Ǝz (Have(Ali, z) ^ Mouse(z)))) LS(Ali) ^Ǝz (Have(Ali, z) ^ Mouse(z) LS(Ali) ^Have(Ali, B) ^ Mouse(B) (Skolemize) • It is written in CFN
Q7: The set of clauses obtained The set of clauses are: 1. ¬Hound(x) V Howl(x) 2. ¬Have(x, y) V ¬Cat(y) V ¬Have(x, z) V ¬Mouse(z) 3. ¬LS(x) V ¬Have(x, y) V ¬Howl(y) 4. (a) Have(Ali, A) (b) Cat(A) V Hound(A) 5. (a) LS(Ali) (b) Have(Ali, B) (c) Mouse(B)
Q7: Apply the resolution rule ¬Hound(x) V Howl(x), Cat(A) V Hound(A) Subst(θ, Howl(x) V Cat(A)) where θ={x/A} The conclusion is Howl(A) V Cat(A)
Q7: Apply the resolution rule ¬Have(x, y) V ¬Cat(y) V ¬Have(x, z) V ¬Mouse(z), Mouse(B) Subst(θ, ¬Have(x, y) V ¬Cat(y) V ¬Have(x, z)) Where θ={z/B} The conclusion is: ¬Have(x, y) V ¬Cat(y) V ¬Have(x, B)
Q7: Apply the resolution rule ¬Have(x, y) V ¬Cat(y) V ¬Have(x, B), Have(Ali,B) Subst(θ, ¬Have(x, y) V ¬Cat(y)) Where θ={x/Ali} The conclusion ¬Have(Ali, y) V ¬Cat(y)
Q7: Apply the resolution rule Howl(A) V Cat(A), ¬Have(Ali, y) V ¬Cat(y) Subst(θ, Howl(A) V ¬Have(Ali, y)) Where θ={y/A} is Howl(A) V ¬Have(Ali, A)
Q7: Apply the resolution rule Have(Ali,A), Howl(A) V ¬Have(Ali, A) Howl(A) ¬LS(x) V ¬Have(x, y) V ¬Howl(y), Howl(A) Subst(θ, ¬LS(x) V ¬Have(x, y)) Where θ={y/A} is¬LS(x) V ¬Have(x, A)
Q7: Apply the resolution rule ¬LS(x) V ¬Have(x, A), Have(Ali,A) Subst(θ, ¬LS(x)) Where θ={x/Ali} is ¬LS(Ali) And finally, ¬LS(Ali), LS(Ali) – emptyContradiction Ali does not have any mice
Problem 1 • Consider the following knowledge base: • 1. boss(sami) = nabil • 2. boss(nabil) = fatima • 3. paycut(fatima) • 4. x (paycut(boss(x)) paycut(x)) Draw a resolution proof to show that Sami is getting a paycutie • 5: paycut(sami)?.
Problem 1: solution • CNF : • paycut(boss(x)) paycut(x) paycut(boss(sami)) • 6 : paycut(boss(sami)) paycut(boss(sami)) unify {x/sami} ,5 • 7: paycut(boss(sami)) 5+ 6 • 8: paycut(nabil) 1+7 • 9: paycut(boss(nabil)) unify {x/nabil} , 5+9 • 10: paycut(fatima) 2+9 • 11: {} 10+3
Problem 2 Express the following sentences in first-order logic: (a) All students love AI (b) Some students love AI (c) At least two students love AI (d) Exactly two students love AI (e) At most two students love AI
Problem 2: solution • All students love AI • ∀ x Student(x) => Loves(x, AI) • Some students love AI • Ǝ x Student(x) Loves(x, AI) • At least two students love AI • Ǝ x,y ┐(x=y) Student(x) Loves(x,AI) Student(y) Loves(y,AI) • or • ∃x∃y (Student(x) Loves(x,AI )∧ Student(y) Loves(y,AI) ∧ x ≠ y • Exactly two students love AI • Ǝ x,y (x≠y Student(x) Loves(x,AI) Student(y) Loves(y,AI) ∀ z (Student(z) Loves(z,AI) < --> (x=z V y=z)) ) • At most two students love AI • ∀ x,y ,z Student(x) Loves(x,AI) Student(y) Loves(y,AI) Student(z) Loves(z,AI) (x=y Vx=z V y=z)