TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính
ARTIFICIAL INTELLIGENCE Tutorial 5 Solutions PREDICATE LOGIC Question 1. What is an English equivalent of the following formulas? Assume cow(x) means “x is a cow” and animal(x) means “x is an animal”. a. cow(daisy) b. ∃x: cow(x) c. ∀x: cow(x) animal(x) d. ∃x: animal(x) cow(x) Solution: a. Daisy is a cow. b. There is at least one cow. c. All cows are animals. d. Among the animals, there is at least one cow. Question 2. For each pair of atomic sentences, give the most general unifier if it exists:
a. P(A, B, B), P(x, y, z). b. Q(y, G(A, B)), Q(G(x, x), y). c. Older(Father(y), y), Older(Father(x), John). d. Knows(Father(y), y), Knows(x, x). Solution: a. {x/A, y/B, z/B} b. No unifier (x cannot bind to both A and B) c. {y/John, x/John} d. No unifier (because the occurs-check prevents unification of y with Father(y)) Question 3. Translate the following sentences into formulas in predicate logic: a. Horses, cows, and pigs are mammals. b. An offspring of a horse is a horse. c. Bluebeard is a horse. d. Bluebeard is Charlie's parent. 1
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính e. Offspring and parent are inverse relations. f. Every mammal has a parent. Solution: a. ∀x: Horse(x) ⇒ Mammal(x) ∀x: Cow(x) ⇒ Mammal(x) ∀x: Pig(x) ⇒ Mammal(x) b. ∀x∃y: Offspring(x, y) ∧ Horse(y) ⇒ Horse(x) c. Horse(Bluebeard) d. Parent(Bluebeard, Charlie) e. ∀x∀y: Offspring(x, y) ⇒ Parent(y, x) ∀x∀y: Parent(x, y) ⇒ Offspring(y, x) f. ∀x∃y: Mammal(x) ⇒ Parent(y, x) Question 4. Consider the following sentences: • • • • • •
John likes all kinds of food. Apples are food. Chicken is food. Anything anyone eats and isn’t killed by is food. Bill eats peanuts and is still alive. Sue eats everything Bill eats
a. Translate these sentences into formulas in predicate logic. b. Prove that John likes peanuts using backward chaining. c. Convert the formulas of part a into clause form. d. Prove that John likes peanuts using resolution. e. Use resolution to answer the question, “What food does Sue eat?” Solution: a. (1) ∀x: food(x) ⇒ like(John, x) (2) food(Apple) (3) food(Chicken) (4) ∀x∀y: eat(x, y) ∧ ¬killedby(x, y) ⇒ food(y)
(5) eat(Bill, Peanut) ∧ ¬killedby(Bill, Peanut) (6) ∀x : eat(Bill, x) ⇒ eat(Sue, x) b. like(John, Peanut) --(1, substitution)--> food(Peanut) --(4, substitution)--> eat(x, Peanut) ∧ ¬killedby(x, Peanut) --(5, substitution)--> eat(Bill, Peanut) ∧ ¬killedby(Bill, Peanut) 2
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính c. (1) ¬food(x) ∨ like(John, x) (2) food(Apple) (3) food(Chicken) (4) ¬eat(x, y) ∨ killedby(x, y) ∨ food(y) (5a) eat(Bill, Peanut)
(5b) ¬killedby(Bill, Peanut) (6) ¬eat(Bill, x) ∨ eat(Sue, x) d. α = like(John, Peanut) => ¬α = ¬like(John, Peanut) (*) Resolution:
(*) --{x/Peanut}-- (1) ¬food(Peanut) ¬food(Peanut) --{y/Peanut}-- (4) ¬eat(x, Peanut) ∨ killedby(x, Peanut) ¬eat(x, Peanut) ∨ killedby(x, Peanut) --{x/Bill}-- (5a) killedby(Bill, Peanut) killedby(Bill, Peanut) ---- (5b) [] e. α = food(z) ∧ eat(Sue, z) => ¬α = ¬food(z) ∨ ¬eat(Sue, z) (**) Resolution:
(**) --{x/z}-- (6) ¬food(z) ∨ ¬eat(Bill, z) ¬food(z) ∨ ¬eat(Bill, z) --{z/Peanut}-- (5a) ¬food(Peanut) ¬food(Peanut) --{y/Peanut}-- (4) ¬eat(x, Peanut) ∨ killedby(x, Peanut) ¬eat(x, Peanut) ∨ killedby(x, Peanut) --{x/Bill}-- (5a) killedby(Bill, Peanut) killedby(Bill, Peanut) ---- (5b) [] Cause we unified argument z with Peanut in the resolution process above, we can conclude that Sue eats peanuts. Question 5. Consider the following facts: • • • • •
The members of the Elm St. Bridge Club are Joe, Sally, Bill, and Ellen. Joe is married to Sally. Bill is Ellen’s brother. The spouse of every married person in the club is also in the club. The last meeting of the club was at Joe’s house.
a. Represent these facts in predicate logic. b. From the facts given above, most people would be able to decide on the truth of the following additional statements: 3
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính • •
The last meeting of the club was at Sally’s house. Ellen is not married.
Can you construct resolution proofs to demonstrate the truth of each of these statements given the five facts listed above? Do so if possible. Otherwise, add the facts you need and then construct the proofs. Solution: a. (1) member(Joe) (2) member(Sally) (3) member(Bill) (4) member(Ellen) (5) marry(Joe, Sally) (6) brother(Bill, Ellen) (7) ∀x∀y: member(x) ∧ marry(x, y) ⇒ member (y) Convert to clause form: ¬member(x) ∨ ¬marry(x, y) ∨ member (y) (8) lastmeetingAt(Joe) b. We need to add some facts to construct resolution proofs to demonstrate the truth of each of two statements given. • The last meeting of the club was at Sally’s house. α = lastmeetingAt(Sally) => ¬α = ¬lastmeetingAt(Sally) (*) Add the fact: ∀x∀y: lastmeetingAt (x) ∧ marry(x, y) ⇒ lastmeetingAt (y) Convert to clause form: (9) ¬lastmeetingAt (x) ∨ ¬marry(x, y) ∨ lastmeetingAt(y)
Resolution: (*) --{y/Sally}-- (9) ¬lastmeetingAt (x) ∨ ¬marry(x, Sally) ¬lastmeetingAt (x) ∨ ¬marry(x, Sally) --{x/Joe}-- (8) ¬marry(Joe, Sally) ¬marry(Joe, Sally) ---- (5) [] •
Ellen is not married.
α = ∀x: ¬marry(x, Ellen) => ¬α = ∃x: marry(x, Ellen) Convert ¬α into clause form: marry(A, Ellen) (**)
Add the facts: ∀x: ¬marry(x, x) ∀x∀y: brother(x, y) ⇒ ¬marry(x, y) ∀x∀y∀z: marry(x, y) ⇒ ¬marry(x, z) ∧ ¬marry(z, y) ∀x∀y: marry(x, y) ∧ member(y) ⇒ marry(Joe, y) ∨ marry(Sally, y) ∨ marry(Bill, y) ∨ marry(Ellen, y) Convert new facts into clause form: (10) ¬marry(x, x) (11) ¬brother(x, y) ∨ ¬marry(x, y) 4
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính (12a) ¬marry(x, y) ∨ ¬marry(x, z) (12b) ¬marry(x, y) ∨ ¬marry(z, y) (13) ¬marry(x, y) ∨ ¬member(y) ∨ marry(Joe, y) ∨ marry(Sally, y) ∨ marry(Bill, y) ∨ marry(Ellen, y) Resolution: (**) --{x/A, y/Ellen}-- (13) ¬member(Ellen) ∨ marry(Joe, Ellen) ∨ marry(Sally, Ellen) ∨ marry(Bill, Ellen) ∨ marry(Ellen, Ellen) (a) (a) ---- (4) marry(Joe, Ellen) ∨ marry(Sally, Ellen) ∨ marry(Bill, Ellen) ∨ marry(Ellen, Ellen) (b) (b) --{x/Joe, y/Ellen, z/Sally}-- (12b) marry(Bill, Ellen) ∨ marry(Ellen, Ellen) (c) (c) --{x/Ellen}-- (10) marry(Bill, Ellen) (d) (d) --{x/Bill, y/Ellen}-- (11) ¬brother(Bill, Ellen) (e)
(e) ---- (6) [] -- End --
5