Knowledge Representation
Knowledge Representation
yx likes(x,y)
Final Answer:
p(c1,c2,c3) t(c5) s(c6,c7)
r(c1,c2,c4) t(c5) s(c6,c7)
Resolution
• Based on proof by contradiction.
• Basic step
Given two clauses:
p r
p
-------------
r
• Modus ponens: from pr and p, can infer r
More resolution examples
prt
p
-------------
rt
pr
pt
-------------
rt
More resolution examples
prt
psq
-------------
rtsq
p
p
-------------
(empty clause contradiction)
Resolution with Variables
prime(X) GT(X,2)
prime(5)
----------------------------------
GT(5,2)
Unification
• Resolution requires contradiction
between 2 literals
• Literals containing variables contradict if
One of them is negated and
The two predicates can be made
identical by consistently replacing
variables with values (unification)
Unifier
• The list of variables substitutions that
make two expressions identical is called a
unifier for the two expressions
• The unifier whose result subsumes any
other unifier’s result is known as most
general unifier [MGU]
• Example the MGU for prime(X) and
prime(5) is [X=5]
Another Example
p(x)
p(y)
Universe = {1, 3, 5}
-----------------------
Some possible unifiers
[x=1, y=1]
[x=3, y=3]
[x=5, y=5]
[x=y] //MGU
[y=x] //MGU
Unification cases
e1 e2 MGU
c1 c1 []
c1 c2 none
x x []
x y [x=y] or [y=x]
x c1 [x=c1]
x f(c1) [x=f(c1)]
x f(y) [x=f(y)]
x f(x) none
p(x) r(x) none
p(x,y) p(x) none
p(x,y,z) p(c1,c2,c3) [x=c1, y=c2, z=c3]
p(x,x) p(c1,c2) none
p(x,x) p(c1,c1) [x=c1]
Unification Algorithm
unify(E1, E2){
if (E1 or E2 is a variable or a constant){
if (E1 and E2 are identical) return [ ];
if (E1 is a variable)
if (E1 occurs in E2)
return none;
else
return [E1=E2]
if (E2 is a variable)
if (E2 occurs in E1)
return none;
else
return [E2=E1]
}//if
If (initial predicates in E1 and E2 are different) return none;
If (E1 and E2 have different number of arguments) return none;
RESULT=[ ];
for(I=1; I<=number of arguments; I++){
TEMP=unify(I’th_arg(E1), I’th_arg(E2));
if (TEMP== none) return none;
if (TEMP != [ ]){
apply TEMP to remainder of E1 and E2;
append TEMP to RESULT;
}//if
}//for
Return RESULT;
}
Example
Unify
p(X,Y,f(X,W),g(W,Z),X)
p(a,f(Z),f(Z,f(a)),g(f(X),a),Z)
Resolution Algorithm
above(b2,t)
Convert into clauses
1. on(U,V) above(U,V)
2. above(X,Y) above(Y,Z) above(X,Z)
3. on(b2,b1)
4. on(b1,t)
5. above(b2,t)
Iteration 1
5. above(b2,t)
2. above(X,Y) above(Y,Z) above(X,Z)
MGU: [V1=b1]
Resolution result:
9. on(b1,t)
Set of clauses C
1. on(U,V) above(U,V)
2. above(X,Y) above(Y,Z) above(X,Z)
3. on(b2,b1)
4. on(b1,t)
5. above(b2,t)
6. above(b2,Y1) above(Y1,t)
7. above(b2,U1) on(U1,t)
8. on(V1,t) on(b2,V1)
9. on(b1,t)
Iteration 5
9. on(b1,t)
4. on(b1,t)
MGU: [ ]
Resolution result:
10.
Set of clauses C
1. on(U,V) above(U,V)
2. above(X,Y) above(Y,Z) above(X,Z)
3. on(b2,b1)
4. on(b1,t)
5. above(b2,t)
6. above(b2,Y1) above(Y1,t)
7. above(b2,U1) on(U1,t)
8. on(V1,t) on(b2,V1)
9. on(b1,t)
10.