TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính
ARTIFICIAL INTELLIGENCE Tutorial 4 Solutions PROPOSITIONAL LOGIC Question 1. Let p, q, and r be the following propositions: p: You get an A on the final exam. q: You do every exercise in the book. r: You get an A in this class. Write the following formulas using p, q, and r and logical connectives. a. You get an A in this class, but you do not do every exercise in the book. b. To get an A in this class, it is necessary for you to get an A on the final. c. Getting an A on the final and doing every exercise in the book is sufficient for getting an A in this class. Solution: a. r ∧ ¬q b. r ⇒ p c. p ∧ q ⇒ r Question 2. Represent the following statements in propositional logic. a. There are only two formats for photos: round and square. b. Photos are either color or black and white. c. If the photo is square, then it is a black and white picture. d. If it is round, it is a digital color picture. e. If the photo is digital or in black and white, then it is a portrait, else not. f. If it is a portrait, then it is a picture of my friend. Use the atoms A, B, C, D, E, F, G represented as follows: A: The photo is in color B: The photo is in black and white C: The photo is square D: The photo is round E: The photo is digital 1
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính F: The photo is a portrait G: The photo is a picture of my friend Assume that the statements about the photo above the author found yesterday. Using resolution, can you answer the author’s question: Is the photo I found yesterday the picture of my friend? Solution: a. C ∨ D b. (A ∧ ¬B) ∨ (¬A ∧ B) c. C ⇒ B d. D ⇒ A ∧ E e. (B ∨ E ⇒ F) ∧ (F ⇒ B ∨ E) f. F ⇒ G Yes. Question 3. Decide whether each of the following sentences is valid, inconsistent or neither. Using equivalence rules. a. Smoke ⇒ Smoke b. Smoke ⇒ Fire c. (Smoke ⇒ Fire) ⇒ (¬Fire ⇒ ¬Smoke) d. Smoke ⇒ Fire ⇒ ¬Fire e. ((Smoke ∧ Heat) ⇒ Fire) ⇔ ((Smoke ⇒ Fire) ∨ (Heat ⇒ Fire)) f. (Smoke ⇒ Fire) ⇒ ((Smoke ∧ Heat) ⇒ Fire) g. Big ∨ Dumb ∨ (Big ⇒ Dumb) h. (Big ∧ Dumb) ∨ ¬Dumb Solution: S: Smoke F: Fire H: Heat a. S ⇒ S ≡ ¬S ∨ S (valid) b. S ⇒ F (neither) c. (S ⇒ F) ⇒ (¬F ⇒ ¬S) ≡ ¬(¬S ∨ F) ∨ (F ∨ ¬S) ≡ (S ∧ ¬F) ∨ (F ∨ ¬S) ≡ (S ∨ F ∨ ¬S) ∧ (¬F ∨ F ∨ ¬S) (valid)
2
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính d. S ⇒ F ⇒ ¬F ≡ ¬S ∨ F ⇒ ¬F ≡ (S ∧ ¬F) ∨ ¬F ≡ ¬F (neither)
e. ((S ∧ H) ⇒ F) ⇔ ((S ⇒ F) ∨ (H ⇒ F)) ≡ (¬(S ∧ H) ∨ F) ⇔ ((¬S ∨ F) ∨ (¬H ∨ F)) ≡ (¬S ∨ ¬H ∨ F) ⇔ (¬S ∨ ¬H ∨ F) (valid) f. (S ⇒ F) ⇒ ((S ⇒ H) ⇒ F) ≡ (S ∧ ¬F) ∨ ((S ∧ ¬H) ∨ F) ≡ S ∨ (S ∧ ¬H) ∨ F ≡ S ∨ F (neither) Question 4. Using resolution to prove the following logical consequences: a. Implication introduction: P |= (Q ⇒ P) b. Implication distribution: (P ⇒ (Q⇒R)) |= ((P ⇒ Q) ⇒ (P⇒R)) c. Contradiction realization: (Q ⇒ ¬P) |= ((Q⇒P) ⇒ ¬Q) d. Bidirectional Dilemma: ((P ⇒ Q) ∧ (R ⇒ S) ∧ (P ∨ ¬S)) |= (Q ∨ ¬R) Solution: a. KB = {P} α = ¬Q ∨ P KB ∪ {¬α} = {P, Q, ¬P} Resolution: P ---- ¬P [] b. KB = {¬P ∨ ¬Q ∨ R} α = {¬ (¬P ∨ Q) ∨ (¬P ∨ R)} KB ∪ {¬α} = {¬P ∨ ¬Q ∨ R, ¬P ∨ Q, P, ¬R} Resolution: ¬P ∨ ¬Q ∨ R ---- P ¬Q ∨ R ¬Q ∨ R ---- ¬P ∨ Q ¬P ∨ R ¬P ∨ R ---- P R R ---- ¬R []
3
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính c. KB = {¬Q ∨ ¬P} α = ¬ (¬Q ∨ P) ∨ ¬Q KB ∪ {¬α} = {¬Q ∨ ¬P, ¬Q ∨ P, Q} Resolution: ¬Q ∨ ¬P ---- Q ¬P ¬P ---- ¬Q ∨ P ¬Q ¬Q ---- Q [] d. KB = {¬P ∨ Q, ¬R ∨ S, P ∨ ¬S} α = Q ∨ ¬R KB ∪ {¬α} = {¬P ∨ Q, ¬R ∨ S, P ∨ ¬S, ¬Q, R} Resolution: ¬P ∨ Q ---- ¬Q ¬P ¬P ---- P ∨ ¬S ¬S ¬S ---- ¬R ∨ S ¬R ¬R ---- R [] Question 5. Assuming that we have three propositional-logic-based KBs as follows: a. If the temperature and the pressure are constant then it does not rain. The temperature remained constant. It rained. Using resolution to answer the question: Did the pressure remain constant or not? b. John eats when he is hungry. John always wears his best suit to eat. At this moment John is not hungry. Using resolution to answer the question: Is John wearing his best suit or not? c. In the Roman Senate (I) Mark Anthony: "It was Cassius or Brutus (or both)." (II) Cassius: "I did not do it. Mark Anthony is lying" (III) Brutus: "I did not do it" 4
TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM Khoa Khoa học & Kỹ thuật Máy tính Assuming that liars always lie, that truthful Romans always speak the truth, and that only one of them is telling the truth. Using resolution to answer the questions: Who did it? Who is telling the truth? Solution: a. T: the temperature is constant P: the pressure is constant R: it’s rain KB = {T ∧ P ⇒ ¬R, T, R} = {¬T ∨ ¬P ∨ ¬R, T, R} Assume the pressure didn’t remain constant: α = ¬P KB ∪ {¬α} = {¬T ∨ ¬P ∨ ¬R, T, R, P} Resolution: ¬T ∨ ¬P ∨ ¬R ---- T ¬P ∨ ¬R ¬P ∨ ¬R ---- R ¬P ¬P ---- P [] Thus, the pressure didn’t remain constant. b. E: John eats H: John is hungry S: John wears his best suit KB = {H ⇒ E, E ⇒ S, ¬H} = {¬H ∨ E, ¬E ∨ S, ¬H} Assume John is wearing his best suit: α = S KB ∪ {¬α} = {¬H ∨ E, ¬E ∨ S, ¬H, ¬S} Resolution: ¬H ∨ E ---- ¬E ∨ S ¬H ∨ S ¬H ∨ S ---- ¬S ¬H Assume John is not wearing his best suit: α = ¬S KB ∪ {¬α} = {¬H ∨ E, ¬E ∨ S, ¬H, S} Resolution: ¬H ∨ E ---- ¬E ∨ S ¬H ∨ S Thus, we can’t conclude John is wearing his best suit or not. c. Assume Mark Anthony, Cassius, Brutus is telling the truth respectively, then solve the problem. -- End -5