Download presentation
Presentation is loading. Please wait.
Published byHector Murphy Modified over 8 years ago
1
CPSC 433 Artificial Intelligence Unification & Resolution Examples Andrew Kuipers amkuiper@cpsc.ucalgary.ca Please include [CPSC433] in the subject line of any emails regarding this course.
2
CPSC 433 Artificial Intelligence 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
3
CPSC 433 Artificial Intelligence Unification – A Quick Review Delete:E {t t} E Decompose:E {f(t 1,…,t n ) f(s 1,…,s n )} E {t 1 s 1,…,t n s n } Orient:E {t x} (if t not a var) E {x t}
4
CPSC 433 Artificial Intelligence 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(t 1,…,t n ) g(s 1,…,s n )} if x not in t s[x t] : replace all x’s in s with t if x in t if f g
5
CPSC 433 Artificial Intelligence Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) )
6
CPSC 433 Artificial Intelligence 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) }
7
CPSC 433 Artificial Intelligence 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) } 1.Decompose E {f(t 1,…,t n ) f(s 1,…,s n )} E {t 1 s 1,…,t n s n } E = { g(x, y) ≈ g(f(d,x),z), c ≈ c }
8
CPSC 433 Artificial Intelligence 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 }
9
CPSC 433 Artificial Intelligence 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) }
10
CPSC 433 Artificial Intelligence 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) }
11
CPSC 433 Artificial Intelligence 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(t 1,…,t n ) f(s 1,…,s n )} E {t 1 s 1,…,t n s n } E = { x ≈ f(d, x), y ≈ z }
12
CPSC 433 Artificial Intelligence Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { x ≈ f(d, x), y ≈ z }
13
CPSC 433 Artificial Intelligence Unification Example 1: mgu( f(g(x,y),c), f(g(f(d,x),z),c) ) E = { x ≈ f(d, x), y ≈ z } 4. OccurcheckE {x t} if x in t E = , f(g(x,y), c) and f(g(f(d,x),z),c) not unifiable
14
CPSC 433 Artificial Intelligence Unification Example 2: mgu( h(c,d,g(x,y)), h(z,d,g(g(a,y),z)) )
15
CPSC 433 Artificial Intelligence 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)) }
16
CPSC 433 Artificial Intelligence 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(t 1,…,t n ) f(s 1,…,s n )} E {t 1 s 1,…,t n s n } E = { c ≈ z, d ≈ d, g(x, y) ≈ g(g(a, y), z) }
17
CPSC 433 Artificial Intelligence 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) }
18
CPSC 433 Artificial Intelligence 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) }
19
CPSC 433 Artificial Intelligence 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) }
20
CPSC 433 Artificial Intelligence 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(t 1,…,t n ) f(s 1,…,s n )} E {t 1 s 1,…,t n s n } E = { c ≈ z, x ≈ g(a, y), y ≈ z }
21
CPSC 433 Artificial Intelligence 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 }
22
CPSC 433 Artificial Intelligence 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 }
23
CPSC 433 Artificial Intelligence 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 }
24
CPSC 433 Artificial Intelligence 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 }
25
CPSC 433 Artificial Intelligence 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 }
26
CPSC 433 Artificial Intelligence 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 }
27
CPSC 433 Artificial Intelligence 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 }
28
CPSC 433 Artificial Intelligence 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!
29
CPSC 433 Artificial Intelligence Resolution – A Quick Review Used to prove a consequence from a set of logical formulae States: Sets of clauses L 1 (t 11,…,t 1,n1 ) … L m (t m1,…,t m,nm ) - L i is a predicate symbol or its negation, - t ij 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
30
CPSC 433 Artificial Intelligence 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’)
31
CPSC 433 Artificial Intelligence Resolution Example 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) Goal: P(f(g(a, c)))
32
CPSC 433 Artificial Intelligence 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)
33
CPSC 433 Artificial Intelligence 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)))
34
CPSC 433 Artificial Intelligence 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)))
35
CPSC 433 Artificial Intelligence 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 }
36
CPSC 433 Artificial Intelligence 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 }
37
CPSC 433 Artificial Intelligence 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)
38
CPSC 433 Artificial Intelligence 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) }
39
CPSC 433 Artificial Intelligence 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) }
40
CPSC 433 Artificial Intelligence 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))
41
CPSC 433 Artificial Intelligence 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) }
42
CPSC 433 Artificial Intelligence 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) }
43
CPSC 433 Artificial Intelligence 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)))
44
CPSC 433 Artificial Intelligence 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 }
45
CPSC 433 Artificial Intelligence 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. □
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.