Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inference in First-Order Logic Chapter 9

Similar presentations


Presentation on theme: "Inference in First-Order Logic Chapter 9"— Presentation transcript:

1 Inference in First-Order Logic Chapter 9

2 Some Basic Definitions
A free variable is a variable that isn't bound by a quantifier. $y Likes(x,y) x is free, y is bound A sentence is a well-formed formula where all variables are quantified. CLICK EACH SUB

3 Rules of Inference x P(x) __________  P(c) if cU
Universal instantiation P(c) for an arbitrary cU ___________________  x P(x) Universal generalization x P(x) ______________________  P(c) for some element cU Existential instantiation P(c) for some element cU ____________________  x P(x) Existential generalization

4 An example of U.G. x(Ontable(x, T1)  Upturned(x, T2))
xy(Upturned(x, y)  Empty(x, y))

5 An example of U.G. Ontable(b2, T1) Assumption
Ontable(b2, T1)  Upturned(b2, T2) -  , 1 Upturned (b2, T2) -  , 3, 4 Upturned(b2, T2)  Empty(b2, T2) -  , 2 Empty(b2, T2)  , 5, 6 Ontable(b2, T1)  Empty(b2, T2) +  , 7 x(Ontable(x, T1)  Empty(x, T2)) +  , 8

6 An example of E.I. b1 b2 b3 b1 b2 b3 T1 T2
x(Bottle(x,T1)  Upturned(x, T2)) xy(Upturned(x, y)  Empty(x, y)) x(Full(x, T1) & Empty(x, T2)  Wet(Floor)) x (Bottle(x, T1) & Full(x, T1))

7 An example of E.I. Bottle(b1, T1) & Full(b1, T1)) - EI assumption
Upturned (b1, T2) -  , 1 , -  , 6 Empty(b1, T2) -  , 2 , -  , 7 Full(b1, T1) & Empty (b1, T2) + & , 7, 9 Wet(Floor)  , 3, -  , 10 Wet(Floor) EI conclusion

8 Prove (x(P(x)  Q))  (xP(x)  Q)
x(P(x)  Q) Assumption xP(x) Assumption P(x) -  Ass. P(x)  Q +  , 1 Q -  3, 4 Q -  Conc. xP(x)  Q +  2, 6 (x(P(x)  Q))  (xP(x)  Q) +  1, 7

9 Prove (xP(x)  Q)  (x(P(x)  Q))
(xP(x)  Q) Assumption P(x) Assumption xP(x) +  Q  1, 3 P(x) Q -  2, 4 x(P(x)  Q) +  5 (xP(x)  Q)  (x(P(x)  Q)) +  1, 6

10 Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) Knows(John,x) Knows(y,OJ) Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

11 Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

12 Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

13 Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)} Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

14 Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)} Knows(John,x) Knows(x,OJ) {fail} Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

15 Unification To unify Knows(John,x) and Knows(y,z),
θ = {y/John, x/z } or θ = {y/John, x/John, z/John} The first unifier is more general than the second. There is a single most general unifier (MGU) that is unique up to renaming of variables. MGU = { y/John, x/z }

16 The unification algorithm

17 The unification algorithm

18 Example Knowledge Base
Mark was a man. Mark was a Pompeian. All Pompeians were Romans. Caesar was a ruler. All Romans were either loyal to Caesar or hated him. Everyone is loyal to someone. People only try to assassinate rulers they are not loyal to. Mark tried to assassinate Caesar.

19 Example Knowledge Base
(1) Mark was a man. man(Mark) Was Mark loyal to Caesar? (2) Mark was a Pompeian. Pompeian(Mark) (3) All Pompeians were Romans. x (Pompeian(x)  Roman(x)) (4) Caesar was a ruler. ruler(Caesar) (5) All Romans were either loyal to Caesar or hated him. x (Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)) (6) Everyone is loyal to someone. x y loyalto(x, y) (7) People only try to assassinate rulers they are not loyal to. x y (person(x)  ruler(y)  tryassassinate(x, y)  loyalto(x, y)) (8) Mark tried to assassinate Caesar. tryassassinate(Mark, Caesar)

20 Reasoning Backward loyalto(Mark, Caesar) (x/Mark) (y/Caesar)
(1) man(Mark) (2) Pompeian(Mark) (3) x (Pompeian(x)  Roman(x)) (4) ruler(Caesar) (5) x (Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)) (6) x y loyalto(x, y) (7) x y (person(x)  ruler(y)  tryassassinate(x, y)  loyalto(x, y)) (8) tryassassinate(Mark, Caesar) loyalto(Mark, Caesar) (x/Mark) (y/Caesar) person(Mark) ruler(Caesar) tryassassinate(Mark, Caesar)

21 Reasoning Backward loyalto(Mark, Caesar) (x/Mark) (y/Caesar)
(1) man(Mark) (2) Pompeian(Mark) (3) x (Pompeian(x)  Roman(x)) (4) ruler(Caesar) (5) x (Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)) (6) x y loyalto(x, y) (7) x y (person(x)  ruler(y)  tryassassinate(x, y)  loyalto(x, y)) (8) tryassassinate(Mark, Caesar) (9) x (man(x)  person(x)) loyalto(Mark, Caesar) (x/Mark) (y/Caesar) person(Mark) ruler(Caesar) tryassassinate(Mark, Caesar) (x/Mark) Man(Mark)

22 Functions and Predicates
(1) Mark was a man. man(Mark) (2) Mark was a Pompeian. Pompeian(Mark) (3) Mark was born in 40 A.D. born(Mark, 40) (4) All men are mortal. x (man(x)  mortal(x)) (5) A volcano erupted in 79 A.D. erupted(volcano, 79) (6) AllPompeians died in 79 A.D. x (Pompeian(x)  died(x,79)) (7) No mortal lives longer than 150 years. x t1 t2 (mortal(x)  born(x, t1)  gt(t2-t1, 150)  dead(x, t2)) (8) It is now 2010. now = 2010 Is Mark alive?

23 Functions and Predicates
(1) man(Mark) (2) Pompeian(Mark) (3) born(Mark, 40) (4) x (man(x)  mortal(x)) (5) erupted(volcano, 79) (6) x (Pompeian(x)  died(x,79)) (7) x t1 t2 (mortal(x)  born(x, t1)  gt(t2-t1, 150)  dead(x, t2)) (8) now = 2010  alive(Mark, now)

24 Functions and Predicates - Filling in the Blanks
(1) man(Mark) (2) Pompeian(Mark) (3) born(Mark, 40) (4) x (man(x)  mortal(x)) (5) erupted(volcano, 79) (6) x (Pompeian(x)  died(x,79)) (7) x t1 t2 (mortal(x)  born(x, t1)  gt(t2-t1, 150)  dead(x, t2)) (8) now = 2010 (9a) x t (dead(x,t)  alive(x, t)) (9b) x t (alive(x, t)  dead(x, t)) (10) x t1 t2 (died(x, t1)  gt(t2, t1)  dead(x, t2))  alive(Mark, now) 24 24

25 Showing that Mark is Not Alive
 alive(Mark, now) (9a) (x/Mark) (t/now) dead(Mark, now) (10)(x/Mark)(t2/now) (7) (Mark/x)(now/t2) died(Mark, t1) gt(now, t1) mortal(Mark) born(Mark, t1) gt(now-t1,150) (6)(x/Mark) (t1/79) (4) (x/Mark) (3) (t1/40) Pompeian(Mark) gt(now, 79) man(Mark) born(Mark, 40) gt(now-40,150) (2) subst (1) subst T gt(2010, 79) T T gt( ,150) eval eval T T 25 25

26 A Harder One Given: x [Roman(x)  know(x, Mark)] 
[hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] Roman(Isaac) hate(Isaac, Caesar) hate(Paulus, Mark) thinkcrazy(Isaac, Paulus) Prove: know(Isaac, Mark) 26 26

27 Clause Form Simplifies the Process
Standard: x [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] Clausal: Roman(x)  know(x, Mark)  hate(x, Caesar)  hate(y, z)  thinkcrazy(x, z)

28 Conversion to Clause Form - Step 1
1. Eliminate , using the fact that a  b is equivalent to a  b x [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] x  [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))]

29 Conversion to Clause Form - Step 2
2. Reduce the scope of each  to a single term, using: (p) = p deMorgan’s laws x P(x)  x P(x) x P(x)  x P(x) x  [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] x [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  (y z  hate(y, z)  thinkcrazy(x, y))]

30 Conversion to Clause Form - Step 3
3. Standardize variables so that each quantifier binds a unique variable. x P(x)  x Q(x) x P(x)  y Q(y)

31 Conversion to Clause Form - Step 4
4. Move all quantifiers to the left without changing their relative order. x [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  (y z  hate(y, z)  thinkcrazy(x, y))] x y z [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y))] At this point, we have prenex normal form.

32 Conversion to Clause Form - Step 5
5. Eliminate existential quantifiers through the use of Skolem functions and constants. x Roman(x) Roman(S1) x z father-of(x, z) x father-of(x, S2(x))

33 Conversion to Clause Form - Step 6
6. Drop the prefix since all remaining quantifiers are universal. x y z [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y))] [ Roman(x)   know(x, Mark)] 

34 Conversion to Clause Form - Step 7
7. Convert the matrix into a conjunction of disjuncts by using: Associative properties of  and . [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y))]  Roman(x)   know(x, Mark)  hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y)) Distribution of  over . (P(x)  Q(x))  T(x) (P(x)  T(x))  (Q(x))  T(x))

35 Conversion to Clause Form - Step 8
8. Create a separate clause for each conjunct. (P(x)  T(x))  (Q(x)  T(x)) (P(x)  T(x)) (Q(x)  T(x))

36 Conversion to Clause Form - Step 9
9. Standardize apart the variables. (P(x)  T(x)) (Q(x)  T(x)) (Q(y)  T(y))

37 Resolution in Predicate Logic
p’ v q ~p v r (q v r) p(x) v q(x) ~p(a) v r(b) (q(x) v r(b)) [x/a] => q(a) v r(b) All variables assumed universally quantified. where p' = p where  = [x/a] 37 37

38 Importance of Standardizing Variables Apart
Consider: 1. father(x, y)  woman(x) {father(x, y) woman(x)} 2. mother(x, y)  woman(x) {mother(x, y)  woman(x)} 3. mother(Chris, Mary) 4. father(Chris, Bill) 1 2 * father(x, y)  mother(x, y) 3 x/Chris, y/Mary father(Chris, Mary)

39 Back to Mark (1) man(Mark) (2) Pompeian(Mark)
(3) Pompeian(x1)  Roman(x1) (4) ruler(Caesar) (5) Roman(x2)  loyalto(x2, Caesar)  hate(x2, Caesar) (6) loyalto(x3, S1(x3)) (7) man(x4)  ruler(y1)  tryassassinate(x4, y1)  loyalto(x4, y1) (8) tryassassinate(Mark, Caesar)

40 Proving Mark Not Loyal to Caesar
loyalto(M, C)  man(x4)  ruler(y1)  tryassassinate(x4, y1)  loyalto(x4, y1) (x4/M)(y1/C)  man(M)  ruler(C)  tryassassinate(M,C) man(M) ruler(C)  tryassassinate(M,C) ruler(C) tryassassinate(M,C) tryassassinate(M,C) nil

41 Does Isaac Know Mark? Given: 1. x [Roman(x)  know(x, Mark)] 
[hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] Roman(x)   know(x, Mark)  hate(x, Caesar)   hate(y, z)  thinkcrazy(x, y) 2. Roman(Isaac) 3. hate(Isaac, Caesar) 4. hate(Paulus, Mark) 5. thinkcrazy(Isaac, Paulus) Prove: know(Isaac, Mark) * know(Isaac, Mark)

42 Proving Issac Doesn’t know Mark
know(Isaac, Mark) (x/I) Roman(I)  hate(I, C)   hate(y, z)  thinkcrazy(I, y) 2: Roman(I) hate(I, C)   hate(y, z)  thinkcrazy(I, y) 3: hate(I, C)  hate(y, z)  thinkcrazy(I, y) 4: hate(P, M) (y/P)(z/M) thinkcrazy(I, P) 5: thinkcrazy(I, P) nil 42

43 Question Answering When did Mark die? died(Mark, ??)
Mark must have died sometime, so we could try to prove: x died(Mark, x) by adding to the KB: x died(Mark, x). Converting to clause form: x died(Mark, x)

44 When Did Mark Die? But how do we retrieve the answer 79?
died(Mark, x) Pompeian(x1)  died(x1,79) (x1/Mark)(x/79) Pompeian(Mark) Pompeian(Mark) nil But how do we retrieve the answer 79?

45 When Did Mark Die? died(Mark, x)  died(Mark, x) Pompeian(x1)  died(x1,79) (x1/Mark)(x/79) Pompeian(Mark)  died(Mark, 79) Pompeian(Mark) died(Mark, 79) The underlined literal will get carried along and collect all the substitutions. We stop when we generate a clause that contains only it.

46 Resolution Strategies
Unit Preference: prefer to do resolutions where 1 sentence is a single literal, a unit clause goal is to produce the empty clause, focus search by producing resolvents that are shorter complete but too slow for medium sized problems Unit Resolution: requires at least 1 to be a unit clause complete for Horn Clauses

47 Unit Resolution Example (1)
1. p  q KB 2. ~p  r KB 3. ~q  r KB 4. ~r S 5. ~p 2, 4 6. ~q 3, 4 7. q 1, 5 8. p 1, 6 9. r 3, 7 10. nil 6, 7 11. r 2, 8 12. nil 5, 8

48 Unit Resolution Example(2)
1. p  q 2. ~p  q 3. p  ~q 4. ~p  ~q Cannot perform a single unit resolution since all clauses are of size 2!

49 Resolution Strategies (Cont.)
Set-of-Support (SoS): identify some subset of sentences, called SoS P and Q can be resolved if one is from SoS resolvent is added to the SoS common approach: ~query is the initial SoS, resolvents are added assumes KB is satisfiable complete if KB-SoS is satisfiable

50 Set of Support resolution example
1. p  q KB 2. ~p  r KB 3. ~q  r KB 4. ~r S 5. ~p 2, 4 add to S 6. ~q 3, 4 add to S 7. q 1, 5 add to S 8. p 1, 6 add to S 9. r 3, 7 10. nil 6, 7 11. r 2, 8 12. nil 5, 8

51 Resolution Strategies (Cont.)
Input Resolution: P and Q can be resolved if at least one is from the set of original clauses, i.e., KB and ~query complete for Horn Clauses Linear Resolution: a slight generalization of input resolution P and Q can be resolved if: P is from the set of the original clauses, or P is an ancestor of Q, in the proof tree complete

52 Input Resolution 2. ~p  q KB 3. p  ~q KB 4. ~p  ~q KB
Ex: p  q KB 2. ~p  q KB 3. p  ~q KB 4. ~p  ~q KB Cannot perform input resolution!

53 Linear Resolution p  q ~p  q p  ~q ~p  ~q q p ~q nil

54 Natural Deduction vs. Resolution
CNF is simpler to work with But, we loose readability and some useful control information x(judge(x) & ~crooked(x)  educated(x)) ~judge(x) v crooked(x) v educated(x)


Download ppt "Inference in First-Order Logic Chapter 9"

Similar presentations


Ads by Google