1 / 45

Unification & Resolution Examples

Unification & Resolution Examples. Andrew Kuipers amkuiper@cpsc.ucalgary.ca Please include [CPSC433] in the subject line of any emails regarding this course. Unification – A Quick Review. Unification is needed to compute mgu (most general unifier) Yet another set-based search problem:

Download Presentation

Unification & Resolution Examples

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unification & Resolution Examples Andrew Kuipers amkuiper@cpsc.ucalgary.ca Please include [CPSC433] in the subject line of any emails regarding this course. CPSC 433 Artificial Intelligence

  2. Unification – A Quick Review Unification is needed to compute mgu(most general unifier) Yet another set-based search problem: States: set of term equations u  v, with  indicating failure Transitions: Extension Rules to generate new term equations Goal condition: all equations in the state have form x  t and Occurcheck and Substitute are not applicable CPSC 433 Artificial Intelligence

  3. Unification – A Quick Review Delete: E  {t  t} E Decompose: E  {f(t1,…,tn)  f(s1,…,sn)} E  {t1  s1,…,tn  sn} Orient: E  {t  x} (if t not a var) E  {x  t} CPSC 433 Artificial Intelligence

  4. Unification – A Quick Review Substitute: E  {x  t, t'  s'} E  {x  t, t'[xt]  s'[xt]} Occurcheck: E  {x  t}  Clash: E  {f(t1,…,tn)  g(s1,…,sn)}  if x not in t s[xt] : replace all x’s in s with t if x in t if f  g CPSC 433 Artificial Intelligence

  5. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) CPSC 433 Artificial Intelligence

  6. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { f(g(x, y), c) ≈ f(g(f(d, x), z), c) } CPSC 433 Artificial Intelligence

  7. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { f(g(x, y), c) ≈ f(g(f(d, x), z), c) } • Decompose E  {f(t1,…,tn)  f(s1,…,sn)} E  {t1  s1,…,tn  sn} E = { g(x, y) ≈ g(f(d,x),z), c ≈ c } CPSC 433 Artificial Intelligence

  8. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { g(x, y) ≈ g(f(d,x),z), c ≈ c } CPSC 433 Artificial Intelligence

  9. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { g(x, y) ≈ g(f(d,x),z), c ≈ c } 2. Delete E  {t  t} E E = { g(x, y) ≈ g(f(d,x),z) } CPSC 433 Artificial Intelligence

  10. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { g(x, y) ≈ g(f(d,x),z) } CPSC 433 Artificial Intelligence

  11. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { g(x, y) ≈ g(f(d,x),z) } 3. Decompose E  {f(t1,…,tn)  f(s1,…,sn)} E  {t1  s1,…,tn  sn} E = { x ≈ f(d, x), y ≈ z } CPSC 433 Artificial Intelligence

  12. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { x ≈ f(d, x), y ≈ z } CPSC 433 Artificial Intelligence

  13. Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { x ≈ f(d, x), y ≈ z } 4. Occurcheck E  {x  t} if x in t  E =  , f(g(x,y), c) and f(g(f(d,x),z),c) not unifiable CPSC 433 Artificial Intelligence

  14. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) CPSC 433 Artificial Intelligence

  15. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { h(c,d,g(x,y)) ≈ h(z,d,g(g(a,y),z)) } CPSC 433 Artificial Intelligence

  16. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { h(c,d,g(x,y)) ≈ h(z,d,g(g(a,y),z)) } 1. Decompose E  {f(t1,…,tn)  f(s1,…,sn)} E  {t1  s1,…,tn  sn} E = { c ≈ z, d ≈ d, g(x, y) ≈ g(g(a, y), z) } CPSC 433 Artificial Intelligence

  17. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, d ≈ d, g(x, y) ≈ g(g(a, y), z) } CPSC 433 Artificial Intelligence

  18. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, d ≈ d, g(x, y) ≈ g(g(a, y), z) } 2. Delete E  {t  t} E E = { c ≈ z, g(x, y) ≈ g(g(a, y), z) } CPSC 433 Artificial Intelligence

  19. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, g(x, y) ≈ g(g(a, y), z) } CPSC 433 Artificial Intelligence

  20. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, g(x, y) ≈ g(g(a, y), z) } 3. Decompose E  {f(t1,…,tn)  f(s1,…,sn)} E  {t1  s1,…,tn  sn} E = { c ≈ z, x ≈ g(a, y), y ≈ z } CPSC 433 Artificial Intelligence

  21. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, x ≈ g(a, y), y ≈ z } CPSC 433 Artificial Intelligence

  22. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, x ≈ g(a, y), y ≈ z } 4. Substitute E  {x  t, t'  s'} E  {x  t, t'[xt]  s'[xt]} E = { c ≈ z, x ≈ g(a, z), y ≈ z } CPSC 433 Artificial Intelligence

  23. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, x ≈ g(a, z), y ≈ z } CPSC 433 Artificial Intelligence

  24. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { c ≈ z, x ≈ g(a, z), y ≈ z } 5. Orient E  {t  x} E  {x  t} E = { z ≈ c, x ≈ g(a, z), y ≈ z } CPSC 433 Artificial Intelligence

  25. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { z ≈ c, x ≈ g(a, z), y ≈ z } CPSC 433 Artificial Intelligence

  26. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { z ≈ c, x ≈ g(a, z), y ≈ z } 6. Substitute E  {x  t, t'  s'} E  {x  t, t'[xt]  s'[xt]} E = { z ≈ c, x ≈ g(a, c), y ≈ c } CPSC 433 Artificial Intelligence

  27. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { z ≈ c, x ≈ g(a, c), y ≈ c } CPSC 433 Artificial Intelligence

  28. Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) ) E = { z ≈ c, x ≈ g(a, c), y ≈ c } No more applicable extensions! CPSC 433 Artificial Intelligence

  29. Resolution – A Quick Review Used to prove a consequence from a set of logical formulae States: Sets of clauses L1(t11,…,t1,n1)  …  Lm(tm1,…,tm,nm) - Li is a predicate symbol or its negation,- tij terms out of function symbols and variables (x,y…)- variables in different clauses are disjunct Initially: The consequence we want to prove is negated and added to the set of clauses representing the initial state Goal: Derive the empty clause (), ie: reductio ad absurdum CPSC 433 Artificial Intelligence

  30. Resolution – A Quick Review Transitions: New clauses generated by Resolution or Factorization Resolution: C  P , D  P’ (C  D) Factorization: C  P  P' (C  P) Note: clauses are commutative: pq  qp, pqr same as rpq where  = mgu(P,P’) where  = mgu(P,P’) CPSC 433 Artificial Intelligence

  31. Resolution Example 3: • ¬P(x)  P(f(x)) • ¬Q(a, y)  ¬R(y, x)  P(x) • R(b, g(a, z)) • Q(a, b) Goal: P(f(g(a, c))) CPSC 433 Artificial Intelligence

  32. Resolution Example 3: • Negate goal, add to folmulas 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) CPSC 433 Artificial Intelligence

  33. Resolution Example 3: • Negate goal, add to folmulas 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) CPSC 433 Artificial Intelligence

  34. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) CPSC 433 Artificial Intelligence

  35. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) ¬Q(a, y)  ¬R(y, x)  P(x), Q(a, b) ¬R(b, x)  P(x) σ = { y ≈ b } CPSC 433 Artificial Intelligence

  36. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) ¬Q(a, y)  ¬R(y, x)  P(x), Q(a, b) ¬R(b, x)  P(x) σ = { y ≈ b } CPSC 433 Artificial Intelligence

  37. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) CPSC 433 Artificial Intelligence

  38. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) ¬R(b, x)  P(x), R(b, g(a, z)) P(g(a, z)) σ = { x ≈ g(a,z) } CPSC 433 Artificial Intelligence

  39. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) ¬R(b, x)  P(x), R(b, g(a, z)) P(g(a, z)) σ = { x ≈ g(a,z) } CPSC 433 Artificial Intelligence

  40. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) • Resolve (7) and (1) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) CPSC 433 Artificial Intelligence

  41. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) • Resolve (7) and (1) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) P(g(a, z)), ¬P(x)  P(f(x)) P(f(g(a,z))) σ = { x ≈ g(a,z) } CPSC 433 Artificial Intelligence

  42. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) • Resolve (7) and (1) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) 8. P(f(g(a, z))) P(g(a, z)), ¬P(x)  P(f(x)) P(f(g(a,z))) σ = { x ≈ g(a,z) } CPSC 433 Artificial Intelligence

  43. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) • Resolve (7) and (1) • Resolve (8) and (5) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) 8. P(f(g(a, z))) CPSC 433 Artificial Intelligence

  44. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) • Resolve (7) and (1) • Resolve (8) and (5) 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) 8. P(f(g(a, z))) P(f(g(a, z))), ¬P(f(g(a, c))) □ σ = { z ≈ c } CPSC 433 Artificial Intelligence

  45. Resolution Example 3: • Negate goal, add to folmulas • Resolve (4) and (2) • Resolve (6) and (3) • Resolve (7) and (1) • Resolve (8) and (5) • Search complete, goal proved 1. ¬P(x)  P(f(x)) 2. ¬Q(a, y)  ¬R(y, x)  P(x) 3. R(b, g(a, z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, x)  P(x) 7. P(g(a, z)) 8. P(f(g(a, z))) 9. □ CPSC 433 Artificial Intelligence

More Related