Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.

Similar presentations


Presentation on theme: "Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence."— Presentation transcript:

1 Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #10

2 Resolution Theorem Proving Given: –KB – a set of first-order sentences –Query Q – a logical sentence Calling procedure: 1.Add  Q to KB 2.Convert KB into clausal form 3.Run resolution. If we derive {}, return TRUE.

3 Clausal Form Every FOL formula is consistency- equivalent to conjunction of F.O. clauses. First-order clause –Only universal quantifiers (which are implicit) –Disjunction of literals (atoms or their negation)

4 Conversion to Clausal Form 1.“  ” replaced by “  ”, ”  ” 2.Negations in front of atoms 3.Standardize variables (unique vars.) 4.Eliminate existentials (Skolemization) 5.Drop all universal quantifiers 6.Move disjunctions in (put into CNF) 7.Rename vars. (standardize vars. apart)

5 Quantifier Scope Switching the order of universal quantifiers does not change the meaning: –(  x)(  y)P(x,y) (  y)(  x) P(x,y) Similarly, you can switch the order of existential quantifiers: –(  x)(  y)P(x,y) (  y)(  x) P(x,y) Switching the order of universals and existential does change meaning: –Everyone likes someone: (  x)(  y) likes(x,y) –Someone is liked by everyone: (  y)(  x) likes(x,y)

6 Quantifiers Universal quantifiers are often used with “implies” to form “rules”: –(  x) student(x) => smart(x) means “All students are smart” Universal quantification is rarely used to make blanket statements about every individual in the world: –(  x)student(x)^smart(x) means “Everyone in the world is a student and is smart” Existential quantifiers are usually used with “and” to specify a list of properties about an individual: –(  x) student(x) ^ smart(x) means “There is a student who is smart” A common mistake is to represent this English sentence as the FOL sentence: –(  x) student(x) => smart(x) What’s the problem?

7 First-Order Resolution Resolution inference rule: C1: P(t1,…,tk)  C1’(t1,…,tk) C2:  P(s1,…,sk)  C2’(s1,…,sk) mgu(, ) = {r1,…,rn} -------------------------------------------- C3: (C1’  C2’) {r1,…,rn}

8 First-Order Resolution Resolution algorithm (saturation): 1.While there are unresolved C1,C2: (1)Select C1, C2 in KB (2)If C1, C2 are resolvable, resolve them into a new clause C3 (3)Add C3 to KB (4)If C3={ } return T. 2.STOP C1: P(t1,…,tk)  C1’(t1,…,tk) C2:  P(s1,…,sk)  C2’(s1,…,sk) mgu(, ) = {r1,…,rn} -------------------------------------------- C3: (C1’  C2’) {r1,…,rn}

9 Resolution in Action On board Negated Query KB C1: P(t1,…,tk)  C1’(t1,…,tk) C2:  P(s1,…,sk)  C2’(s1,…,sk) mgu(, ) = {r1,…,rn} -------------------------------------------- C3: (C1’  C2’) {r1,…,rn}

10 First-Order Resolution Resolution algorithm (saturation): 1.While there are unresolved C1,C2: (1)Select C1, C2 in KB (2)If C1, C2 are resolvable, resolve them into a new clause C3 (3)Add C3 to KB (4)If C3={ } return T. 2.STOP C1: P(t1,…,tk)  C1’(t1,…,tk) C2:  P(s1,…,sk)  C2’(s1,…,sk) mgu(, ) = {r1,…,rn} -------------------------------------------- C3: (C1’  C2’) {r1,…,rn}

11 First-Order Resolution Rule (2) If C1, C2 are resolvable, resolve them into a new clause C3 If C1,C2 have two literals l1,l2 with same predicates (P) and opposite polarity, and If l1= P(t1,…,tk), l2=  P(s1,…,sk), unifiable with mgu (most general unifier) {r1,…,rn}, then… C1: P(t1,…,tk)  C1’(t1,…,tk) C2:  P(s1,…,sk)  C2’(s1,…,sk) mgu(, ) = {r1,…,rn} -------------------------------------------- C3: (C1’  C2’) {r1,…,rn}

12 Unification …P(t1,…,tk),  P(s1,…,sk), unifiable with mgu (most general unifier) σ={r1,…rk} Substitution: replace vars. by terms –Term: constant, variable, or a function of terms Composition of substitutions {x/g(w,v)} {w/A,v/f(B,z)} = {x/g(A,f(B,z),w/A,v/f(B,z)} (P(x) v Q(f(x)) v P(g(B,x)) v P(f(y))) {x/B,y/z} (P(B) v Q(f(B)) v P(g(B,B)) v P(f(z))) {x/B,y/z}{x/B,y/z,x/w}{x/B,y/z,z/w}

13 Unification Unification: find a substitution σ for C1: P(t1,…,tk)  C1’(t1,…,tk) C2:  P(s1,…,sk)  C2’(s1,…,sk) such that P(t1,…,tk)σ = P(s1,…,sk)σ P(A,y,g(x,y)){y/f(A)} = P(z,f(z),g(x,f(w))){z/A,w/A} σ={y/f(A),z/A,w/A} P(A,y,g(x,y)){y/f(w)} = P(z,f(w),g(x,f(w))){z/A} σ={y/f(w),z/A} Most general unifier

14 Unification Substitution σ1 more general than σ2 if there is substitution γ such that σ1 γ = σ2 P(A,y,g(x,y)){y/f(A)} = P(z,f(z),g(x,f(w))){z/A,w/A} σ={y/f(A),z/A,w/A} P(A,y,g(x,y)){y/f(w)} = P(z,f(w),g(x,f(w))){z/A} σ={y/f(w),z/A} Most general unifier

15 Unification Substitution σ1 more general than σ2 if there is substitution γ such that σ1 γ = σ2 σ2={y/f(A),z/A,w/A} σ1={y/f(w),z/A} Most general unifier γ={w/A}

16 Finding the MGU Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,w))

17 Finding the MGU Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,w))

18 Finding the MGU Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,w))

19 Finding the MGU Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,w))

20 Finding the MGU Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,w))

21 part(3,x) = y part(3,y) = f(w)part(1,x) = P part(1,y) = Ppart(2,x) = A part(2,y) = z Finding the MGU Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,w)) part(4,x) = g(x,f(w)) part(4,y) = g(v,w) F Occurs check

22 Finding the MGU: another example Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,f(w)))

23 Finding the MGU: another example Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,f(w)))

24 Finding the MGU: another example Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,f(w)))

25 Finding the MGU: another example Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,f(w)))

26 Finding the MGU: another example Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ x = P(A,y,g(x,y)) y = P(z,f(w),g(v,f(w)))

27 part(3,x) = y part(3,y) = f(w)part(1,x) = P part(1,y) = Ppart(2,x) = A part(2,y) = z Finding the MGU: another example Procedure MGU(x,y) 1.If x=y, return { } 2.If x or y are vars., return MGUvar(x,y) 3.If x or y are const.,or Len(x)=/=Len(y), return F. 4.σ ← { }; For i ← 1 to Len(x) 1.s ← MGU(part(i,x),part(i,y)); if s=F, return F. 2.σ ← compose(σ,s); x ← subst(x,σ); y ← subst(y,σ); 5.Return σ part(4,x) = g(x,f(w)) part(4,y) = g(v,f(w)) σ={y/f(w),z/A,v/x} x = P(A,y,g(x,y)) y = P(z,f(w),g(v,f(w)))

28 Correctness of FOL Resolution Soundness: Resolution is sound for first- order inference Refutation Completeness: Resolution will find the empty clause, if FALSE is entailed No guarantee of termination (saturation), if FALSE not entailed: FOL semi-decidable

29 Simple Efficiency Improvements Subsumption between clauses: –If clause C subsumes clause D (C entails D), then we can remove D from the KB. {P(A)}{P(A),P(B)} {P(A)}{~P(A)} {P(f(x),A),Q(g(x),B)}{P(f(v),y),Q(g(v),y)} Algorithm for checking subsumption? ╨ ╨ ╨ {P(A)}{P(t)} ╨

30 Simple Efficiency Improvements Subsumption within the clause: –If literal a subsumes literal b (a entails b), then we can remove a from the clause… –But, notice the variables’ scope {P(A),P(t)} {P(A),~P(B),P(t)} {P(A,x),P(y,B)} {P(x),Q(x),P(A)} {P(A)} {P(A),~P(B)} {P(A,x),P(y,B)} {P(x),Q(x),P(A)}

31 Properties of Resolution Unifying two literals of length n O(n 2 ) – because of occurs check Finding two resolvable clauses from m clauses of length n: O(m 2 n 2 ) – the simple bound Overall algorithm: –Semi-decidable –Unbounded length of proof as function of n,m

32 Summary Resolution theorem proving allows us to find contradictions and explanation. –The deduction theorem tells us how to ask queries from Resolution

33 Appendix: Temporal Representations

34 Situation Calculus A first-order language for describing the effects of actions and events over time –Constants: S0 – initial state; action constants –Functions: result(, ) –Predicates: “fluents” – properties that change over time at(1, S0) at(x,s)  at(x+1,result(move_fwd,s)) Query: at(1+1,s’)   ans(s’) ?  at(1+1,s’)  ans(s’)

35 Situation Calculus Requires axioms describing effects and non-effects of actions/events Can be used for planning, projection, diagnosis, filtering (tracking) Frame Problem: the compact and natural- language-like specification of effects of actions Qualification Problem: the preconditions of actions

36 Notations Substitutions –φσ σ = {x1/t1,…,xk/tk} –φ σ σ = [x1/t1,…,xk/tk]


Download ppt "Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence."

Similar presentations


Ads by Google