Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial - 2 Course: CS60045 Pallab Dasgupta Professor,

Similar presentations


Presentation on theme: "Tutorial - 2 Course: CS60045 Pallab Dasgupta Professor,"— Presentation transcript:

1 Tutorial - 2 Course: CS60045 Pallab Dasgupta Professor,
Dept. of Computer Sc & Engg

2 Using Propositional Logic
Suppose we know the following: If Tom is evil, then Ron is not blonde or Harry is not stupid If Harry is stupid then Hermione is lovely If Hermione is lovely and Ron is blonde then Tom is evil Ron is blonde Write the above sentences in propositional logic. Can we deduce that Harry is not stupid? Or is it possible that Harry is stupid? Use resolution rules for propositional logic to formally determine the answer. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

3 Solution If Tom is evil, then Ron is not blonde or Harry is not stupid
If Harry is stupid then Hermione is lovely If Hermione is lovely and Ron is blonde then Tom is evil Ron is blonde Step 0 – Define the Atoms Tom is evil – TE Ron is blonde – RB Harry is stupid – HS Hermione is lovely – HL Step 1 - Encoding sentences in Propositional Logic TE ⟹ ¬RB V ¬ HS HS ⟹ HL HL ⋀ RB ⟹ TE RB INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

4 Determining if Harry is Stupid – HS Step 2: Eliminating Implication
Knowledge TE ⟹ ¬RB V ¬HS HS ⟹ HL HL ⋀ RB ⟹ TE RB Determining if Harry is Stupid – HS ¬TE V ¬RB V ¬ HS ¬HL V ¬RB V TE C1 C3 ¬RB V ¬HS V ¬HL ¬HS V HL C2 ¬RB V ¬HS Step 2: Eliminating Implication ¬TE V ¬RB V ¬HS ¬HS V HL ¬HL V ¬RB V TE RB RB C4 ¬HS INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

5 Find the most general unifier for the following:
Q(h(x,y),w), Q(h(g(v),a),f(v)), Q(h(g(v),a),f((b)) Substitutions: {x\g(v)} ; Q(h(g(v),y),w), Q(h(g(v),a),f(v)), Q(h(g(v),a),f((b)) Substitutions: {x\g(v),y\a} ; Q(h(g(v),a),w), Q(h(g(v),a),f(v)), Q(h(g(v),a),f((b)) Substitutions: {x\g(v),y\a,w\f(v)} ; Q(h(g(v),a),f(v)), Q(h(g(v),a),f(v)), Q(h(g(v),a),f((b)) Substitutions: {x\g(v),y\a,w\f(v),v\b} ; Q(h(g(b),a),f(b)), Q(h(g(b),a),f(b)), Q(h(g(b),a),f((b)) INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

6 Find the most general unifier for the following:
2. p(a, X, h(g(Z))), p(Z, h(Y), h(Y)) Substitution: {Z\a} P(a,X,h(g(a))),p(a,h(Y),h(Y)) Substitution: {Z\a,X\h(Y)} P(a,h(Y),h(g(a))),p(a,h(Y),h(Y)) Substitution: {Z\a,X\h(Y),Y\g(a)} P(a,h(g(a)),h(g(a))),p(a,h(g(a)),h(g(a))) INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

7 Skolemization and Normalization in FOL: Example 1
Every philosopher writes at least one book. ∀x[Philo(x) → ∃y[Book(y) ∧ Write(x, y)]] Main Steps: Eliminate Implication: ∀x[¬Philo(x) ∨ ∃y[Book(y) ∧ Write(x, y)]] Skolemize: Substitute y by g(x) ∀x[¬Philo(x) ∨ [Book(g(x)) ∧ Write(x, g(x))]] INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

8 Skolemization and Normalization in FOL: Example 2
All students of a philosopher read one of their teacher’s books. ∀x∀y[Philo(x) ∧ StudentOf (y, x) → ∃z[Book(z) ∧ Write(x, z) ∧ Read(y, z)]] Main Steps: Eliminate Implication: ∀x∀y[¬Philo(x) ∨ ¬StudentOf (y, x) ∨ ∃z[Book(z) ∧ Write(x, z) ∧ Read(y, z)]] Skolemize: Substitute z by h(x, y) ∀x∀y[¬Philo(x) ∨ ¬StudentOf (y, x) ∨ [Book(h(x, y)) ∧ Write(x, h(x, y)) ∧ Read(y, h(x, y))]] INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

9 Skolemization and Normalization in FOL: Example 3
There exists a philosopher with students. ∃x∃y[Philo(x) ∧ StudentOf (y, x)] Main Steps: Skolemize: Substitute x by a and y by b Philo(a) ∧ StudentOf (b, a) INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

10 Encode in First Order Logic, Normalize and Prove
Encode the following sentences in FOL: Jack owns a dog Every dog owner is an animal lover No animal lover kills an animal Either Jack or Curiosity killed the cat, who is named Tuna Did Curiosity kill the cat? INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

11 Step 1: Encode Sentences in First Order Logic Jack owns a dog
x Owns(Jack,x) ∧ Dog(x) Every dog owner is an animal lover x,y Owns(x,y) ∧ Dog(y) → AnimalLover(x) No animal lover kills an animal x,y AnimalLover(x) ∧ Animal(y) → ¬ Kills(x,y) Either Jack or Curiosity killed the cat, who is named Tuna Killed(Jack,Tuna) V Killed(Curiosity,Tuna) Step 0: Predicates Dog(x) – x is a dog Owner(x,y) – x owns y AnimalLover(x) – x is an animal lover Animal(x) – x is an animal Kills(x,y) – x kills y INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

12 Killed(Curiosity,Tuna) Negated Goal (¬G) ¬Killed(Curiosity,Tuna)
Clauses Owns(Jack,D) Dog(D) 3. ¬Owns(x,y) V ¬Dog(y) V AnimalLover(x) 4. ¬AnimalLover(x) V ¬Animal(y) V ¬ Kills(x,y) 5. Killed(Jack,Tuna) V Killed(Curiosity,Tuna) Step2: Normalize 1. x Owns(Jack,x) ∧ Dog(x) {x\D}: Owns(Jack,D) ∧ Dog(D) 2. x,y Owns(x,y) ∧ Dog(y) → AnimalLover(x) ¬Owns(x,y) V ¬Dog(y) V AnimalLover(x) 3. x,y AnimalLover(x) ∧ Animal(y) → ¬ Kills(x,y) ¬AnimalLover(x) V ¬Animal(y) V ¬ Kills(x,y) 4. Killed(Jack,Tuna) V Killed(Curiosity,Tuna) Goal (G) Killed(Curiosity,Tuna) Negated Goal (¬G) ¬Killed(Curiosity,Tuna) INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

13 3. ¬Owns(x,y) V ¬Dog(y) V AnimalLover(x)
C5 Clauses Owns(Jack,D) Dog(D) 3. ¬Owns(x,y) V ¬Dog(y) V AnimalLover(x) 4. ¬AnimalLover(x) V ¬Animal(y) V ¬ Kills(x,y) 5. Killed(Jack,Tuna) V Killed(Curiosity,Tuna) 6. Cat(Tuna) 7. ¬Dog(x) V Animal(x) 8. ¬Cat(x) V Animal(x) Killed(Jack.Tuna) C4 {x\Jack, y\Tuna} ¬AnimalLover(Jack) V ¬Animal(Tuna) {x\Jack} C3 ¬Owns(Jack,y) V ¬Dog(y) V ¬Animal(Tuna) C2 {y\D} ¬Owns(Jack,D) V ¬Animal(Tuna) C8 {x\Tuna} ¬Owns(Jack,D) V ¬Cat(Tuna) INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

14 ¬Owns(Jack,D) V ¬Cat(Tuna)
Clauses Owns(Jack,D) Dog(D) 3. ¬Owns(x,y) V ¬Dog(y) V AnimalLover(x) 4. ¬AnimalLover(x) V ¬Animal(y) V ¬ Kills(x,y) 5. Killed(Jack,Tuna) V Killed(Curiosity,Tuna) 6. Cat(Tuna) 7. ¬Dog(x) ꓦ Animal(x) 8. ¬Cat(x) ꓦ Animal(x) ¬Owns(Jack,D) V ¬Cat(Tuna) C1 ¬Cat(Tuna) C6 False Curiosity killed Tuna INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

15 Practice Questions INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

16 Questions There are three suspects for a murder: Adams, Brown and Clark. Adams says “I didn’t do it. The victim was an old acquaintance of Brown’s. But Clark hated him.” Brown states “I didn’t do it. I didn’t even know the guy. Besides I was out of town all that week.” Clark says “I didn’t do it. I saw both Adams and Brown downtown with the victim that day; one of them must have done it.” Assume that the two innocent men are telling the truth, but that the guilty man might not be. Who did it? INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

17 2. Let’s consider a propositional language where
A =“Angelo comes to the party”, B =“Bruno comes to the party”, C =“Carlo comes to the party”, D =“David comes to the party”. Formalize the following sentences: “If David comes to the party then Bruno and Carlo come too” “Carlo comes to the party only if Angelo and Bruno do not come” “David comes to the party if and only if Carlo comes and Angelo doesn’t come” “If David comes to the party, then, if Carlo doesn’t come then Angelo comes” “Carlo comes to the party provided that David doesn’t come, but, if David comes, then Bruno doesn’t come” “A necessary condition for Angelo coming to the party, is that, if Bruno and Carlo aren’t coming, David comes” “Angelo, Bruno and Carlo come to the party if and only if David doesn’t come, but, if neither Angelo nor Bruno come, then David comes only if Carlo comes” INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

18 marble takes you to the centre.”
3. You are walking in a labyrinth and all of a sudden you find yourself in front of three possible roads: the road on your left is paved with gold, the one in front of you is paved with marble, while the one on your right is made of small stones. Each street is protected by a guardian. You talk to the guardians and this is what they tell you: The guardian of the gold street: “This road will bring you straight to the centre. Moreover, if the stones take you to the centre, then also the marble takes you to the centre.” The guardian of the marble street: “Neither the gold nor the stones will take you to the centre.” The guardian of the stone street: “Follow the gold and you’ll reach the centre, follow the marble and you will be lost.” Given that you know that all the guardians are liars, can you choose a road being sure that it will lead you to the centre of the labyrinth? If this is the case, which road you choose? Provide a propositional language and a set of axioms that formalize the problem and show whether you can choose a road being sure it will lead to the center. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

19 4. Express the following statements as propositional logic formulae.
(a) Fido is always either sleeping or barking. (b) When Fido is hungry Fido barks, but Fido’s barking does not necessarily mean that Fido is hungry. 5. According to political experts “A person who is a radical(R) is elected (E) if (s)he is conservative (C), but otherwise is not elected. Which of the following are correct representations of this assertion and why? (R ∧ E ) ⇔ C R ⇒ (E ⇔ C) R ⇒ ((C ⇒ E) ∨ ¬E ) INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

20 6. Which of the following sentences are valid, unsatisfiable, or neither.
Smoke ⇒ Smoke Smoke ⇒ Fire Smoke ∨ Fire ∨ ¬ Fire (Smoke ⇒ Fire) ⇒ (¬Smoke ⇒ ¬Fire) (Smoke ⇒ Fire) ⇒ (Smoke ∧ Heat ⇒ Fire) 7. Prove whether or not the following rule of inference is sound: (P ⇒ Q, ¬Q ) / ¬P 8. Convert the sentence A ⇔ (B ∨ E) to CNF, where your answer will be one or more “clauses”. Using the clauses obtained, and the clauses: (¬E ∨ D), (¬C ∨ ¬F ∨ ¬B), (¬E ∨ B ), (¬B ∨ F ), (¬B ∨ C), determine if ¬B is true using resolution refutation. Show the proof tree. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

21 9. Consider the following hypotheses:
If it rains, Joe brings his umbrella If Joe has an umbrella, he doesn’t get wet. If it doesn’t rain, Joe doesn’t get wet. Prove that Joe never gets wet. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

22 If this is the case, which trunk should he open?
10. Aladdin finds two trunks A and B in a cave. He knows that each of them either contains a treasure or a fatal trap. On trunk A is written: “At least one of these two trunks contains a treasure.” On trunk B is written: “In A there’s a fatal trap.” Aladdin knows that either both the inscriptions are true, or they are both false. Can Aladdin choose a trunk being sure that he will find a treasure? If this is the case, which trunk should he open? INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

23 Encode the above statements in first-order logic.
11. Tony, John and Mike belong to the Alpine club. Every member of the Alpine club is either a skier or a mountain climber or both. No mountain climber likes rain and all skiers like snow. Mike dislikes whatever Tony likes and likes whatever Tony dislikes. Tony likes rain and snow. Encode the above statements in first-order logic. Use resolution-refutation to prove that there is a member of the Alpine club who is a mountain climber but not a skier. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

24 12. Consider the following statements:
C1: All lions are fierce creatures C2: Some lions do not drink coffee Indicate the truth of the following statements with appropriate proof/counterexample: It follows from C1 that there is a fierce creature. It follows from C1 and C2, that there is a fierce creature. It follows from C1 and C2, that some fierce creatures do not drink coffee. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

25 Everybody loves somebody. There is somebody whom everybody loves.
13. Express the following statements in first order logic. Use Loves(x,y) for x loves y: Everybody loves Jerry. Everybody loves somebody. There is somebody whom everybody loves. Nobody loves everybody. There is somebody whom Tom does not love. There is somebody whom no one loves. There is exactly one person whom everybody loves. There are exactly two people whom Jerry loves. Everyone loves himself or herself. There is somebody who loves no one besides himself or herself. INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR


Download ppt "Tutorial - 2 Course: CS60045 Pallab Dasgupta Professor,"

Similar presentations


Ads by Google