> {~ng/v231//0DTimes New Roman@ @H@n@fDArialNew Roman@ @H@n@f DWingdingsRoman@ @H@n@f0DSymbolgsRoman@ @H@n@f@DEuclid Symboln@ @H@n@fPDTimes Symboln@ @H@n@f`DCourier Newln@ @H@n@f
`.
@n?" dd@ @@``@g

8
n$66fζThPNG
IHDRd<Q]sBITBPLTENtRNS@fbKGDHcmPPJCmp0712Om+IDAT8c```
eFe*F,Ȗ˘E&*YIENDB`n܄zbHyPNG
IHDRd<Q]sBITBPLTENtRNS@fbKGDHcmPPJCmp0712Om$IDAT8c```
eFeFe,F¨He`,(IENDB`
՜.+,D՜.+,y(h
8 ~
j
Vhttp://www.doc.ic.ac.uk/~sgc/teaching/v231//0DTimes New Roman@ @H@n@fDArialNew Roman@ @H@n@f DWingdingsRoman@ @H@n@f0DSymbolgsRoman@ @H@n@f@DEuclid Symboln@ @H@n@fPDTimes Symboln@ @H@n@f`DCourier Newln@ @H@n@f
`.
@n?" dd@ @@``@g!
 !
8
?$b$$66fζThb$܄zbHy0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?@8u'rʚ;2Nʚ;g4mdmdW`ppp@<4!d!dgʚ;<4ddddgʚ;<4ddddʚ;%P___PPT100(h
H
@ (___PPT9
(0
0\ Ph___PPT2001D<4X ___PPTMac11@f hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography h hnamd`
Arial&Monotype Typography (namd Symbol33ff hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography \ hnamd`
Arial&Monotype Typography 0 hnamd`
Arial&Monotype Typography $ hnamd`
Arial&Monotype Typography ?%b1Artificial Intelligence 8. The Resolution MethodHCourse V231
Department of Computing
Imperial College, London
Jeremy Gow(I>
RSoundness & CompletenessWant to prove theorem T from Axioms Ax
Chosen a set of inference rules R
A B means B is entailed by A
A B means B is derived from A using R
R should be sound: if A B then A B
Want R to be complete: if A B then A B'" )
$$((,,00$!; TChoose Your Search Space0Soundness and completeness of R isn t enough
We want a reasonable search space
R determines operators, so influences the space
Can I see where I m going? (Heuristic measure)
Can I restrict options at each state? (Branching)
Three main approaches
Forwards chaining: no heuristic guidance
Backwards chaining: large branching (many things entail KB)
Proof by refutation: clear goal (false), forwards inferenceO"`e; ,!3\(&<'9Proof by RefutationBProof by contradiction, reductio ad absurdum
Negate the theorem & add to axioms (T,Ax)
Use rules of inference to derive the False
So sentences (T,Ax) can t all be true (unsatisfiable)
But the axioms Ax are true
Hence the negated theorem T must be false
Hence the theorem T must be true@WlWt '>
U:The Resolution MethodProof by refutation with a single inference rule
No need to worry about choice of rule
Just how we apply the one rule
Resolution is complete for FOL
Refutationcomplete [Robinson 1965]
If (T,Ax) unsatisfiable it will derive a contradiction
So if will prove any true theorem of FOL
Even so, it might take a long time (> universe)
Even fairly trivial theorems can take a long time
Can use search heuristics to speed it up (next lecture)
No guarantees if it s not a theorem01E$8)0& #$$((,,0044)880<<A
C&!J!Binary Resolution (Propositional)Unit resolution rule (last lecture)
AB, B
A
Binary resolution rule
AB, BC
AC
The literals B and B are resolved$
#$
,? XBinary Resolution (FirstOrder)PBinary resolution rule
AB, CD
Subst(q, AD)
if substitution q s.t. Subst(q,B) = Subst(q,C)
The literals B and C are resolved
B and C have been made the same by q0$% $$ ((#,,00"%Y Resolution in FOL (This Lecture)What if KB contains nondisjuncts?
Preprocessing step: rewrite to CNF
How do we find substitution q?
The unification algorithm
But what if more than two disjuncts?
Extend binary resolution to full resolution##&,# &$$((,,00t 8 ;Conjunctive Normal FormA conjunction of clauses
Each clause is a disjunction of literals
Prop. literal: proposition or negated proposition
FO literal: predicate or negated predicate
No quantifiers (all variables implicitly universal)
Example FO clause
likes(george, X) likes(tony, houseof(george)) is_mad(maggie)
Any FO sentence can be rewritten as CNFFC))
%
!F C$$(((,,E<!Converting FOL to CNF (see notes)JEliminate implication/equivalence (rewrite)
Move inwards (rewrite)
Rename variables apart (substitution)
Move quantifiers outwards (rewrite)
Skolemise existential variables (substitution)
Distribute over (rewrite)
Flatten binary connectives (rewrite)
(Optional: Reintroduce implications).&lJ
=Example CNF ConversionPropositional example (B (A C)) (B A)
1. Remove implication:
(B (A C)) (B A)
2. Move inwards (De Morgan s x 2):
(B (A C)) (B A)
(B (A C)) (B A)
(Skip 3 to 5 as no variables.)f0ZZZ%Z7Z Z>Example CNF Conversion (Contd)(B (A C)) (B A)
6. Distribute over :
(B (B A)) ((A C) (B A))
7. Flatten connectives
(B B A) (A C B A)
Drop 1st clause (B B), remove duplicate from 2nd:
A C BZZZ)ZZ$Z6ZZ^}WKowalski Normal FormhCan reintroduce to CNF, e.g.
A C B becomes (A C) B
Kowalski form
(A1 & An) (B1 & Bn)
Binary resolution&
AB, BC
AC
Resembles Horn clauses (basis for Prolog)R#*H $$((,,0H04488<<*,fE^!
Skolemisation
,Replace $V with a something term
If no preceeding "U use fresh Skolem constant
Otherwise fresh Skolem function
parameterised by all preceeding "U
"X $Y (person(X) has(X, Y) heart(Y))
to
person(X) has(X, f(X)) heart(f(X))
(The particular heart f(X) depends on person X)#N#S0
# $$
((B,,000x(?Substitutions & Inference RulesPropositional inference rules used in firstorder logic
But in FOL we can make substitutions
Sometimes a substitution can allow a rule to be applied
cf. FO binary resolution
knows(john, X) hates(john, X)
knows(john, mary)
Substitution + Modus Ponens: infer hates(john, mary)
Need to find substitution that makes literals equal
Known as a unifier ]R3iO
Q3T $$(($b@Unifying PredicatesbWe unified these two predicates:
knows(john, X) and knows(john, mary)
By saying that X should be substituted by mary
Why? Because john = john and can {X\mary}
For knows(jack, mary) and knows(john, X)
john doesn t match jack
So we cannot unify the two predicates
Hence we cannot use the rule of inference!T,)hT+)hP}A UnificationWant an algorithm which:
Takes two FOL sentences as input
Outputs a substitution {X/mary, Y/Z, etc.}
Which assigns terms to variables in the sentences
So that the first sentence looks exactly like the second
Or fails if there is no way to unify the sentences
Example:
Unify( knows(john, X) , knows(john,mary) ) = {X/mary}
Unify( knows(john, X) , knows(jack,mary) ) = FailLk3 jLk3 $$((,,0044 88<<&
FB
%Functions Within the Unify Algorithmisa_variable(x)
checks whether x is a variable
isa_list(x)
checks whether x is a list
head(x)
outputs the head of a list (first term)
e.g., head([a,b,c]) = a
tail(x)
outputs the elements other than the head in a list
e.g., tail([a,b,c]) = [b,c]ZZZZZ(ZZZ3ZZ(3 $$C.More Internal Functions(Compound Expressions)%isa_compound(x)
checks whether x is compound expression
(either a predicate, a function or a connective)
args(x)
finds the subparts of the compound expression x
arguments of a predicate, function or connective
Returns the list of arguments
op(x)
predicate name/function name/connective symbolY01/Y1 $$/((jD&Two Parts of theUnification AlgorithmAlgorithm is recursive (it calls itself)
Passes around a set of substitutions, called mu
Making sure that new substitutions are consistent with old ones
unify(x,y) = unify_internal(x,y,{})
x and y are either a variable, constant, list, or compound
unify_internal(x,y,mu)
x and y are sentences, mu is a set of substitutions
finds substitutions making x look exactly like y
unify_variable(var,x,mu)
var is a variable
finds a single substitution (which may be in mu already)D)p$;eK)p$3 $$((,,0064488<<KbV`A E
unify_internalunify_internal(x,y,mu)

Cases
1.if (mu=failure) then return failure
2.if (x=y) then return mu.
3.if (isa_variable(x)) then return unify_variable(x,y,mu)
4.if (isa_variable(y)) then return unify_variable(y,x,mu)
5.if (isa_compound(x) and isa_compound(y)) then return
unify_internal(args(x),args(y),unify_internal(op(x),op(y),mu))
6.if (isa_list(x) and isa_list(y)) then return
unify_internal(tail(x),tail(y),unify_internal(head(x),head(y),mu))
7.return failure '
.99KsFunify_variable&unify_variable(var,x,mu)

Cases
1. if (a substitution var/val is in mu) then return unify_internal(val,x,mu)
2. if (a substitution x/val is in mu) then return unify_internal(var,val,mu)
3. if (var occurs anywhere in x) return failure
4. add var/x to mu and return 'Z'tH#%%DG"Notes on the Unification Algorithmgunify_internal will not match a constant to a constant, unless they are equal (case 2)
Case 5 in unify_internal checks that two compound operators are the same (e.g. same predicate name)
Case 6 in unify_internal causes the algorithm to recursivly unify the whole list
Cases 1 and 2 in unify_variable check that neither inputs have already been substitutedWeTXK9nHThe Occurs CheckhSuppose we needed to substitute X with f(X,Y)
This would give us f(X,Y) instead of X
But there is still an X in there,
so the substitution isn t complete:
we need f(f(X,Y),Y), then f(f(f(X,Y),Y),Y) and so on
We need to avoid this situation
Otherwise the algorithm won t stop
Case 3 in unify_variable checks this
Known as the occurs check
Occurs check slows the algorithm down
Order (n2), where n is size of expressions being unified.J%5 d&9.J%5 )& $$(
(0,,IAn Example UnificationSuppose we want to unify these sentences:
1. p(X,tony) q(george,X,Z)
2. p(f(tony),tony) q(B,C,maggie)
By inspection, this is a good substitution:
{X/f(tony), B/george, C/f(tony), Z/maggie}
This makes both sentences become:
p(f(tony),tony) q(george, f(tony), maggie)
Note that we want to substitute X for C
But we have substituted f(tony) for X already
See the notes for this as a worked example
Using the unification algorithm
Requires five iterations!*ZAZ,Z+Z"ZZ(Z.Z+Z:Z*
4,+"(. +$$:((jac"Binary Resolution (FirstOrder)pBinary resolution rule (using unification)
AB, CD
Subst(q, AD)
if Unify(B, C) = q
Unification algorithm finds Most General Unifier (MGU) q
Don t substitute any more than need to+:'+9 '$$,6W<he Full Resolution RuleIf Unify(Pj, Qk) = q
P1 & Pm, Q1 & Qn
Subst(q, P1 & (no Pj) & Pm Q1 & (no Qk) ... Qn)
Pj and Qk are resolved
Arbitrary number of disjuncts
Relies on preprocessing into CNFHYV
D $$(
(,,0044
88<<
$$((,,
004488<<? :
MUsing Full ResolutionSentences already in CNF
Pick two clauses
Pick positive literal P from first
Pick negative literal N from second
Find MGU q of P and N
Write both clauses as one big disjunction
With P and N missing
Apply q to the new clausef+/+P8OResolution Proof SearchKeep on resolving clause pairs
Eventually result in zerolength clause
This indicates that some literal K was true at the same time as the literal K
Only way to reduce sentence to be empty
Hence there was an inconsistency
Which proves the theorem
Topic of the next lecturebw(<w(<Z Coursework: War of Lifehttp://www.doc.ic.ac.uk/~sgc/teaching/v231/
Two player version of Game of Life
Implement several strategies in Prolog
Run a tournament
On CATE this afternoon
Submit via CATE (more to follow& )
Deadline: 3 weeks todayTPZ9ZQZP9!"+Dc
+z i` 3ffffƍ` 3f3fff̙3ff̙` ______` 3f33>?" dZ@$?lKd@
l@
P`lA n?" dd@ @@``PT @ ` `p>>$
(
<T
"h
s*"h
s*""
<5gG0*"p`
@
6
"@
T Click to edit Master title style!
!$
0"h "@
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
``
??" @
D*
`g
??":Z
D*
``[
??"5
H*^T
"n"
0G"r
B
T??B
s*h ? 3f3fff̙3ff̙ Capsules i 3(
6h"@
@ "
<I
G0*"pp
@
<> "4
W#Click to edit Master subtitle style$
$lT
"n"
B
0G"Rr
T??"L
`g
??" @
H*
`;[
??"
D*
`[
??"x
H*
`P2I
??"NnR
T Click to edit Master title style!
!B
s*h ? 3f3fff̙3ff̙8(
0 ;8
>*
0 u 8
@*
6 0;h
>*
6@ 0u h
@*H
06gq ? ̙3380___PPT10. trE* @0(
x
c$NR
x
c$ @
H
0h ? ̙33
* P \(
\l
\ CP
@
l
\ C ˜
@P
N
\
C&Asemcon` N
\
C&Asyncon
N
\
C&Asemcon`*
N
\
C&Asemconp0N
\
C&Asyncon`
N
\
C&AsynconH
\0h ? 3f3fff̙3ff̙80___PPT10.u
* ``( v/
`l
` Cf
@
l
` CC
@
H
`0h ? 3f3fff̙3ff̙80___PPT10.u,D
* p:(
r
S@
@
Sб
`
"P@08XH
0h ? 3f3fff̙3ff̙
* $(
r
S`
@
r
S
@P
H
0h ? 3f3fff̙3ff̙
* 48(
4r
4 S
@
r
4 Spl
0p
B
4
ZD??p
pB
4
ZD?? H
40h ? 3f3fff̙3ff̙z
* *"t(
tx
t c$ q
@
x
t c$r
0p
B
t
ZD??p pH
t0h ? 3f3fff̙3ff̙
* x( Kxobtvcaa
xl
x C
@
l
x C0
@
H
x0h ? 3f3fff̙3ff̙80___PPT10.u
* $(
r
Sv
@
r
Spw
H
0h ? 3f3fff̙3ff̙
* :(
r
S
@
S0
@
"P@08XH
0h ? 3f3fff̙3ff̙
* $(
r
S@J
@
r
SK
@
H
0h ? 3f3fff̙3ff̙
* $(
r
S`
@
r
S
@
H
0h ? 3f3fff̙3ff̙z
* *"p(
px
p c$p
@
x
p c$`
@P
B
p
ZD??
H
p0h ? 3f3fff̙3ff̙
* (
l
CY
@
l
C[
@
H
0h ? 3f3fff̙3ff̙
* $(
r
S
@
r
S
@
H
0h ? 3f3fff̙3ff̙
* 0$(
r
SP_
@
r
S
@
H
0h ? 3f3fff̙3ff̙
* @$(
r
Sp
@
r
S
(
H
0h ? 3f3fff̙3ff̙
* P$(
r
S0G
@
r
SH
H
0h ? 3f3fff̙3ff̙
* `$(
r
S
@
r
S
@
H
0h ? 3f3fff̙3ff̙
* p$(
r
S`
@
r
SВ
@
H
0h ? 3f3fff̙3ff̙
* $(
r
S9
@
r
S
`
H
0h ? 3f3fff̙3ff̙
* $$(
$r
$ SD
@
r
$ S
`@
H
$0h ? 3f3fff̙3ff̙
* ($(
(r
( S`:
@
r
( S
H
(0h ? 3f3fff̙3ff̙
* ,$(
,r
, S
@
r
, S
@
H
,0h ? 3f3fff̙3ff̙y
* 0$(
0r
0 S*
@
r
0 S
@
H
00h ? 3f3fff̙3ff̙___PPT10e+D=' =
@B +z
* *"(
x
c$8
@
x
c$P70p
B
ZD??p pH
0h ? 3f3fff̙3ff̙
* <(
<r
< Spx@
r
< Sy0@
B
<
ZD?? @ H
<0h ? 3f3fff̙3ff̙___PPT10e+D=' =
@B +
* @$(
@r
@ S@
r
@ S0@
H
@0h ? 3f3fff̙3ff̙
* P$(
Pr
P SP@
r
P S0@
H
P0h ? 3f3fff̙3ff̙
* 0(
l
 C@
l
 Cp`@P
H
0h ? 3f3fff̙3ff̙dxp^RЀ3ÿlHbP@AL
G@;b`B&VRT4W@B*^,c
s vd+(h
8 ~
j
Vhttp://www.doc.ic.ac.uk/~sgc/teachi?$b$$66fζThb$܄zbHy0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?@
Oh+'0 &hp $0
P\
ht'$Lecture 1 Characterisations of AISimon ColtonPC:\Program Files\Microsoft Office\Templates\Presentation Designs\Capsules.potSimon Colton261Microsoft PowerPoint@0Ib@wڵ@T=G$PICT$HH
HH l0>ḩ̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧+!ففففہf ܂Opyy Qq݁݉ vƝfy
܂A\p.33
33y݉3DD33ff nfآffff#"AA.ppp.Of0AAfyA.O."3DQ3DQ]3]g33]Q3gq33D0QD]333ϵ33D3y]3]D33qy3Qq3Dg3qUffffffffnՑffffffַffڭfffnfffvfnvfvfnf%"\..pAȟpґ0AyAyґȫAyҘOȥAyA"]33ϵ3ʗ33Qg33Ť3D0Q33Dq33D3Dϝ3y333Q]3Ť3q33Wfͷfffnֻfvff槧ڋ}ff֭f}ffڗ}ffvn}fڗ}ff}nvf&.\A.OAȘA ..ȑ0AȟAAAAAp.AAO33]33333Q 3DD3D(Q33Q3QQ3D3Dϝ333QQ3DQQ]DQDfvnfͭv}vfvf=nf}ff֧vfڭfvv}ffvvfvv}ffvfvvf'#.AAȘy\͑0A͘.fܑfܑAұܥ#3q333ٗ33Qq333Ե3D0QD3Q3yD3Dϗ3q33yDQ3ygDW}}nvnvfvffާf}ff֧vff淧ffvf}f淧ffvfn)y..sA.OAAy.0AͷOfOOyf$333333333DDD3Q3D0QD33ʝ33DDDg3y333DQQ33D33Xff}fvfvffffvvffڧ}vfffffnn}}ffffffvff}Dϗ3vq3Q}fՁfppyppypgqݐyyy݉yħށ.ypp333D3QDq33DQ333333nffffvfffffffnn]
\OO.AA\.\..O..pyOOO33
3Qy3]g3qQ3g3qD3Q33D]]33y33qy3Q]3y33g3q]3]3]333]3]3f
fffnfffnfff}f}fff}f}vfffffnfff}ffffffv}Y
OA\yA(yAґy呉ҘOpyyA\OOAȥ33]]3ʗ33]3)D333ʁ٤3ԗ3D33DqDϤ3ԗ3Q]3Q3QQϗ3333Ť3333y3ffvfffvffvfnĢ}}}}fff}}}}ffnfvfڗffބffvn}a.
OApAAAO.fAAOOAp.pfAAOA]D3DQ]DQDQ3]DQD33DԝD3DDDQDϝD3DQD33]]DQD3333gD3vfaffffvvffffvvfɻffvffffvffffffffvvfɭ}vffvve.
OA.ܥAܥyf.͑ͫ.͑AܥAffAҷD33DQDQ3݉D333D3qQQDϝ33DQDg3QωD3D33333vfafffnfnfnܝfvvffffvvffffffnnvffvv}e\
\OOfApf\.OןfAp333DQD33Q3QD333]33D33QQ3D]33DQD٪3QD3333D333]D3ff"fffff}ffff}ff}fffvfff$ffffff}f}fffɁɁӁӁ+̧̧̧̧̧̧̧̧̧Lffffffffffffffffsffffffffffffffffffffffffffffyffffffffffffffffffffffffffs f ffffffffffff fffffffffffmffffffffffffffffffff̧̧̧̧̧=ffffffffffffffffffffffffffffffāffffffffffffffffffffffffffffffffffffffffffffffff
fffffff fffff
ffffffffffffffffff fffff
fffffffffffffffffffffffffffffffffffffffffff4ffffff̧̧̧̧Offffffffffffffffffffffffffffffffffffffffffff
ff
fffffffffffffffffffffff
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4ffffff̧̧̧̧7̣3_ft̢3f̢3Gfu̢3?fo5̢3]f̢3f%:̹3af̧̧̧(ffffmffffffffffffffffffffs
fffffffffff
fffffffffffaffffffffffffffffffffgffffffffffffffffffff̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧̧
4'Onscreen ShowImperial College*&Times New RomanArial
WingdingsSymbolEuclid SymbolTimesCourier New Capsules2Artificial Intelligence 8. The Resolution MethodSoundness & CompletenessChoose Your Search SpaceProof by RefutationThe Resolution Method"Binary Resolution (Propositional) Binary Resolution (FirstOrder)!Resolution in FOL (This Lecture)Conjunctive Normal Form"Converting FOL to CNF (see notes)Example CNF ConversionExample CNF Conversion (Contd)Kowalski Normal FormSkolemisation Substitutions & Inference RulesUnifying PredicatesUnification&Functions Within the Unify Algorithm/More Internal Functions (Compound Expressions)'Two Parts of the Unification Algorithmunify_internalunify_variable#Notes on the Unification AlgorithmThe Occurs CheckAn Example Unification Binary Resolution (FirstOrder)The Full Resolution RuleUsing Full ResolutionResolution Proof SearchCoursework: War of LifeFonts UsedDesign Template
Slide Titles 8@_PID_HLINKS'A8m'rʚ;2Nʚ;g4mdmdW`ppp@<4!d!dgʚ;<4ddddgʚ;<4ddddʚ;%P___PPT100(man@ @H@n@f DWingdingsRoman@ @H@n@f0DSymbolgsRoman@ @H@n@f@DEuclid Symboln@ @H@n@fPDTimes Symboln@ @H@n@f`DCourier Newln@ @H@n@f
`.
@n?" dd@ @@``@g
}
!"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{~
8
?$b$$66fζThb$܄zbHy0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?@8m'rʚ;2Nʚ;g4mdmdWh
H
@ (___PPT9
&0
*\ Ph___PPT2001D<4X ___PPTMac11@f hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography h hnamd`
Arial&Monotype Typography (namd Symbol33ff hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography \ hnamd`
Arial&Monotype Typography 0 hnamd`
Arial&Monotype Typography $ hnamd`
Arial&Monotype Typography ?%b1Artificial Intelligence 8. The Resolution MethodHCourse V231
Department of Computing
Imperial College, London
Jeremy Gow(I>
RSoundness & CompletenessWant to prove theorem T from Axioms Ax
Chosen a set of inference rules R
A B means B is entailed by A
A B means B is derived from A using R
R should be sound: if A B then A B
Want R to be complete: if A B then A B'" )
$$((,,00$!; TChoose Your Search Space0Soundness and completeness of R isn t enough
We want a reasonable search space
R determines operators, so influences the space
Can I see where I m going? (Heuristic measure)
Can I restrict options at each state? (Branching)
Three main approaches
Forwards chaining: no heuristic guidance
Backwards chaining: large branching (many things entail KB)
Proof by refutation: clear goal (false), forwards inferenceO"`e; ,!3\(&<'9Proof by RefutationBProof by contradiction, reductio ad absurdum
Negate the theorem & add to axioms (T,Ax)
Use rules of inference to derive the False
So sentences (T,Ax) can t all be true (unsatisfiable)
But the axioms Ax are true
Hence the negated theorem T must be false
Hence the theorem T must be true@WlWt '>
U:The Resolution MethodProof by refutation with a single inference rule
No need to worry about choice of rule
Just how we apply the one rule
Resolution is complete for FOL
Refutationcomplete [Robinson 1965]
If (T,Ax) unsatisfiable it will derive a contradiction
So if will prove any true theorem of FOL
Even so, it might take a long time (> universe)
Even fairly trivial theorems can take a long time
Can use search heuristics to speed it up (next lecture)
No guarantees if it s not a theorem01E$8)0& #$$((,,0044)880<<A
C&!J!Binary Resolution (Propositional)Unit resolution rule (last lecture)
AB, B
A
Binary resolution rule
AB, BC
AC
The literals B and B are resolved$
#$
,? XBinary Resolution (FirstOrder)PBinary resolution rule
AB, CD
Subst(q, AD)
if substitution q s.t. Subst(q,B) = Subst(q,C)
The literals B and C are resolved
B and C have been made the same by q0$% $$ ((#,,00"%Y Resolution in FOL (This Lecture)What if KB contains nondisjuncts?
Preprocessing step: rewrite to CNF
How do we find substitution q?
The unification algorithm
But what if more than two disjuncts?
Extend binary resolution to full resolution##&,# &$$((,,00t 8 ;Conjunctive Normal FormA conjunction of clauses
Each clause is a disjunction of literals
Prop. literal: proposition or negated proposition
FO literal: predicate or negated predicate
No quantifiers (all variables implicitly universal)
Example FO clause
likes(george, X) likes(tony, houseof(george)) is_mad(maggie)
Any FO sentence can be rewritten as CNFFC))
%
!F C$$(((,,E<!Converting FOL to CNF (see notes)JEliminate implication/equivalence (rewrite)
Move inwards (rewrite)
Rename variables apart (substitution)
Move quantifiers outwards (rewrite)
Skolemise existential variables (substitution)
Distribute over (rewrite)
Flatten binary connectives (rewrite)
(Optional: Reintroduce implications).&lJ
=Example CNF ConversionPropositional example (B (A C)) (B A)
1. Remove implication:
(B (A C)) (B A)
2. Move inwards (De Morgan s x 2):
(B (A C)) (B A)
(B (A C)) (B A)
(Skip 3 to 5 as no variables.)f0ZZZ%Z7Z Z>Example CNF Conversion (Contd)(B (A C)) (B A)
6. Distribute over :
(B (B A)) ((A C) (B A))
7. Flatten connectives
(B B A) (A C B A)
Drop 1st clause (B B), remove duplicate from 2nd:
A C BZZZ)ZZ$Z6ZZ^}WKowalski Normal FormhCan reintroduce to CNF, e.g.
A C B becomes (A C) B
Kowalski form
(A1 & An) (B1 & Bn)
Binary resolution&
AB, BC
AC
Resembles Horn clauses (basis for Prolog)R#*H $$((,,0H04488<<*,fE^!
Skolemisation
,Replace $V with a something term
If no preceeding "U use fresh Skolem constant
Otherwise fresh Skolem function
parameterised by all preceeding "U
"X $Y (person(X) has(X, Y) heart(Y))
to
person(X) has(X, f(X)) heart(f(X))
(The particular heart f(X) depends on person X)#N#S0
# $$
((B,,000P(?Substitutions & Inference RulesPropositional inference rules used in firstorder logic
But in FOL we can make substitutions
Sometimes a substitution can allow a rule to be applied
cf. FO binary resolution
knows(john, X) hates(john, X)
knows(john, mary)
Substitution + Modus Ponens: infer hates(john, mary)
Need to find substitution that makes literals equal
Known as a unifier ]R3iO
Q3T $$((b@Unifying PredicatesbWe unified these two predicates:
knows(john, X) and knows(john, mary)
By saying that X should be substituted by mary
Why? Because john = john and can {X\mary}
For knows(jack, mary) and knows(john, X)
john doesn t match jack
So we cannot unify the two predicates
Hence we cannot use the rule of inference!T,)hT+)hP}A UnificationWant an algorithm which:
Takes two FOL sentences as input
Outputs a substitution {X/mary, Y/Z, etc.}
Which assigns terms to variables in the sentences
So that the first sentence looks exactly like the second
Or fails if there is no way to unify the sentences
Example:
Unify( knows(john, X) , knows(john,mary) ) = {X/mary}
Unify( knows(john, X) , knows(jack,mary) ) = FailLk3 jLk3 $$((,,0044 88<<&
FB
%Functions Within the Unify Algorithmisa_variable(x)
checks whether x is a variable
isa_list(x)
checks whether x is a list
head(x)
outputs the head of a list (first term)
e.g., head([a,b,c]) = a
tail(x)
outputs the elements other than the head in a list
e.g., tail([a,b,c]) = [b,c]ZZZZZ(ZZZ3ZZ(3 $$C.More Internal Functions(Compound Expressions)%isa_compound(x)
checks whether x is compound expression
(either a predicate, a function or a connective)
args(x)
finds the subparts of the compound expression x
arguments of a predicate, function or connective
Returns the list of arguments
op(x)
predicate name/function name/connective symbolY01/Y1 $$/((jD&Two Parts of theUnification AlgorithmAlgorithm is recursive (it calls itself)
Passes around a set of substitutions, called mu
Making sure that new substitutions are consistent with old ones
unify(x,y) = unify_internal(x,y,{})
x and y are either a variable, constant, list, or compound
unify_internal(x,y,mu)
x and y are sentences, mu is a set of substitutions
finds substitutions making x look exactly like y
unify_variable(var,x,mu)
var is a variable
finds a single substitution (which may be in mu already)D)p$;eK)p$3 $$((,,0064488<<KbV`A E
unify_internalunify_internal(x,y,mu)

Cases
1.if (mu=failure) then return failure
2.if (x=y) then return mu.
3.if (isa_variable(x)) then return unify_variable(x,y,mu)
4.if (isa_variable(y)) then return unify_variable(y,x,mu)
5.if (isa_compound(x) and isa_compound(y)) then return
unify_internal(args(x),args(y),unify_internal(op(x),op(y),mu))
6.if (isa_list(x) and isa_list(y)) then return
unify_internal(tail(x),tail(y),unify_internal(head(x),head(y),mu))
7.return failure '
.99KsFunify_variable&unify_variable(var,x,mu)

Cases
1. if (a substitution var/val is in mu) then return unify_internal(val,x,mu)
2. if (a substitution x/val is in mu) then return unify_internal(var,val,mu)
3. if (var occurs anywhere in x) return failure
4. add var/x to mu and return 'Z'tH#%%DG"Notes on the Unification Algorithmgunify_internal will not match a constant to a constant, unless they are equal (case 2)
Case 5 in unify_internal checks that two compound operators are the same (e.g. same predicate name)
Case 6 in unify_internal causes the algorithm to recursivly unify the whole list
Cases 1 and 2 in unify_variable check that neither inputs have already been substitutedWeTXK9nHThe Occurs CheckhSuppose we needed to substitute X with f(X,Y)
This would give us f(X,Y) instead of X
But there is still an X in there,
so the substitution isn t complete:
we need f(f(X,Y),Y), then f(f(f(X,Y),Y),Y) and so on
We need to avoid this situation
Otherwise the algorithm won t stop
Case 3 in unify_variable checks this
Known as the occurs check
Occurs check slows the algorithm down
Order (n2), where n is size of expressions being unified.J%5 d&9.J%5 )& $$(
(0,,IAn Example UnificationSuppose we want to unify these sentences:
1. p(X,tony) q(george,X,Z)
2. p(f(tony),tony) q(B,C,maggie)
By inspection, this is a good substitution:
{X/f(tony), B/george, C/f(tony), Z/maggie}
This makes both sentences become:
p(f(tony),tony) q(george, f(tony), maggie)
Note that we want to substitute X for C
But we have substituted f(tony) for X already
See the notes for this as a worked example
Using the unification algorithm
Requires five iterations!*ZAZ,Z+Z"ZZ(Z.Z+Z:Z*
4,+"(. +$$:((jac"Binary Resolution (FirstOrder)nBinary resolution rule (using unification)
AB, CD
Subst(q, AD)
if Unify(B, C) = q
Unification algorithm finds Most General Unifier (MGU) q
Don t substitute any more than need to+:'+9 '$$6}LThe Full Resolution RuleIf Unify(Pj, Qk) = q
P1 & Pm, Q1 & Qn
Subst(q, P1 & (no Pj) & Pm Q1 & (no Qk) ... Qn)
Pj and Qk are resolved
Arbitrary number of disjuncts
Relies on preprocessing into CNFHYV
D $$(
(,,0044
88<<
$$((,,
004488<<? :
MUsing Full ResolutionSentences already in CNF
Pick two clauses
Pick positive literal P from first
Pick negative literal N from second
Find MGU q of P and N
Write both clauses as one big disjunction
With P and N missing
Apply q to the new clausef+/+P8OResolution Proof SearchKeep on resolving clause pairs
Eventually result in zerolength clause
This indicates that some literal K was true at the same time as the literal K
Only way to reduce sentence to be empty
Hence there was an inconsistency
Which proves the theorem
Topic of the next lecturebw(<w(<Z Coursework: War of Lifehttp://www.doc.ic.ac.uk/~sgc/teaching/v231/
Two player version of Game of Life
Implement several strategies in Prolog
Run a tournament
On CATE this afternoon
Submit via CATE (more to follow& )
Deadline: 3 weeks todayTPZ9ZQZP9!"+Dc
+z
*"P(
x
c$@
x
c$ 0p
B
ZD??p pH
0h ? 3f3fff̙3ff̙rRc"s .d@3(h
8 ~
j
Vhttp://www.doc.ic.ac.uk/~sgc/teaching/v231//0DTimes New Roman@ @H@n@fDArialNew Roman@ @H@n@f DWingdingsRoman@ @H@n@f0DSymbolgsRoman@ @H@n@f@DEuclid Symboln@ @H@n@fPDTimes Symboln@ @H@n@f`DCourier Newln@ @H@n@f
`.
@n?" dd@ @@``@g!

8
!?$b$$66fζThb$܄zbHy0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?@8u'rʚ;2Nʚ;g4mdmdW`ppp@<4!d!dgʚ;<4ddddgʚ;<4ddddʚ;%P___PPT100(h
H
@ (___PPT9
(0
0\ Ph___PPT2001D<4X ___PPTMac11@f hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography h hnamd`
Arial&Monotype Typography (namd Symbol33ff hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography `ppp@<4!d!dgʚ;<4ddddgʚ;<4ddddʚ;%P___PPT100(h
Hhnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography \ hnamd`
Arial&Monotype Typography 0 hnamd`
Arial&Monotype Typography $ hnamd`
Arial&Monotype Typography ?%b1Artificial Intelligence 8. The Resolution MethodHCourse V231
Department of Computing
Imperial College, London
Jeremy Gow(I>
RSoundness & CompletenessWant to prove theorem T from Axioms Ax
Chosen a set of inference rules R
A B means B is entailed by A
A B means B is derived from A using R
R should be sound: if A B then A B
Want R to be complete: if A B then A B'" )
$$((,,00$!; TChoose Your Search Space0Soundness and completeness of R isn t enough
We want a reasonable search space
R determines operators, so influences the space
Can I see where I m going? (Heuristic measure)
Can I restrict options at each state? (Branching)
Three main approaches
Forwards chaining: no heuristic guidance
Backwards chaining: large branching (many things entail KB)
Proof by refutation: clear goal (false), forwards inferenceO"`e; ,!3\(&<'9Proof by RefutationBProof by contradiction, reductio ad absurdum
Negate the theorem & add to axioms (T,Ax)
Use rules of inference to derive the False
So sentences (T,Ax) can t all be true (unsatisfiable)
But the axioms Ax are true
Hence the negated theorem T must be false
Hence the theorem T must be true@WlWt '>
U:The Resolution MethodProof by refutation with a single inference rule
No need to worry about choice of rule
Just how we apply the one rule
Resolution is complete for FOL
Refutationcomplete [Robinson 1965]
If (T,Ax) unsatisfiable it will derive a contradiction
So if will prove any true theorem of FOL
Even so, it might take a long time (> universe)
Even fairly trivial theorems can take a long time
Can use search heuristics to speed it up (next lecture)
No guarantees if it s not a theorem01E$8)0& #$$((,,0044)880<<A
C&!J!Binary Resolution (Propositional)Unit resolution rule (last lecture)
AB, B
A
Binary resolution rule
AB, BC
AC
The literals B and B are resolved$
#$
,? XBinary Resolution (FirstOrder)PBinary resolution rule
AB, CD
Subst(q, AD)
if substitution q s.t. Subst(q,B) = Subst(q,C)
The literals B and C are resolved
B and C have been made the same by q0$% $$ ((#,,00"%Y Resolution in FOL (This Lecture)What if KB contains nondisjuncts?
Preprocessing step: rewrite to CNF
How do we find substitution q?
The unification algorithm
But what if more than two disjuncts?
Extend binary resolution to full resolution##&,# &$$((,,00t 8 ;Conjunctive Normal FormA conjunction of clauses
Each clause is a disjunction of literals
Prop. literal: proposition or negated proposition
FO literal: predicate or negated predicate
No quantifiers (all variables implicitly universal)
Example FO clause
likes(george, X) likes(tony, houseof(george)) is_mad(maggie)
Any FO sentence can be rewritten as CNFFC))
%
!F C$$(((,,E<!Converting FOL to CNF (see notes)JEliminate implication/equivalence (rewrite)
Move inwards (rewrite)
Rename variables apart (substitution)
Move quantifiers outwards (rewrite)
Skolemise existential variables (substitution)
Distribute over (rewrite)
Flatten binary connectives (rewrite)
(Optional: Reintroduce implications).&lJ
=Example CNF ConversionPropositional example (B (A C)) (B A)
1. Remove implication:
(B (A C)) (B A)
2. Move inwards (De Morgan s x 2):
(B (A C)) (B A)
(B (A C)) (B A)
(Skip 3 to 5 as no variables.)f0ZZZ%Z7Z Z>Example CNF Conversion (Contd)(B (A C)) (B A)
6. Distribute over :
(B (B A)) ((A C) (B A))
7. Flatten connectives
(B B A) (A C B A)
Drop 1st clause (B B), remove duplicate from 2nd:
A C BZZZ)ZZ$Z6ZZ^}WKowalski Normal FormhCan reintroduce to CNF, e.g.
A C B becomes (A C) B
Kowalski form
(A1 & An) (B1 & Bn)
Binary resolution&
AB, BC
AC
Resembles Horn clauses (basis for Prolog)R#*H $$((,,0H04488<<*,fE^!
Skolemisation
,Replace $V with a something term
If no preceeding "U use fresh Skolem constant
Otherwise fresh Skolem function
parameterised by all preceeding "U
"X $Y (person(X) has(X, Y) heart(Y))
to
person(X) has(X, f(X)) heart(f(X))
(The particular heart f(X) depends on person X)#N#S0
# $$
((B,,000P(?Substitutions & Inference RulesPropositional inference rules used in firstorder logic
But in FOL we can make substitutions
Sometimes a substitution can allow a rule to be applied
cf. FO binary resolution
knows(john, X) hates(john, X)
knows(john, mary)
Substitution + Modus Ponens: infer hates(john, mary)
Need to find substitution that makes literals equal
Known as a unifier ]R3iO
Q3T $$((b@Unifying PredicatesbWe unified these two predicates:
knows(john, X) and knows(john, mary)
By saying that X should be substituted by mary
Why? Because john = john and can {X\mary}
For knows(jack, mary) and knows(john, X)
john doesn t match jack
So we cannot unify the two predicates
Hence we cannot use the rule of inference!T,)hT+)hP}A UnificationWant an algorithm which:
Takes two FOL sentences as input
Outputs a substitution {X/mary, Y/Z, etc.}
Which assigns terms to variables in the sentences
So that the first sentence looks exactly like the second
Or fails if there is no way to unify the sentences
Example:
Unify( knows(john, X) , knows(john,mary) ) = {X/mary}
Unify( knows(john, X) , knows(jack,mary) ) = FailLk3 jLk3 $$((,,0044 88<<&
FB
%Functions Within the Unify Algorithmisa_variable(x)
checks whether x is a variable
isa_list(x)
checks whether x is a list
head(x)
outputs the head of a list (first term)
e.g., head([a,b,c]) = a
tail(x)
outputs the elements other than the head in a list
e.g., tail([a,b,c]) = [b,c]ZZZZZ(ZZZ3ZZ(3 $$C.More Internal Functions(Compound Expressions)%isa_compound(x)
checks whether x is compound expression
(either a predicate, a function or a connective)
args(x)
finds the subparts of the compound expression x
arguments of a predicate, function or connective
Returns the list of arguments
op(x)
predicate name/function name/connective symbolY01/Y1 $$/((jD&Two Parts of theUnification AlgorithmAlgorithm is recursive (it calls itself)
Passes around a set of substitutions, called mu
Making sure that new substitutions are consistent with old ones
unify(x,y) = unify_internal(x,y,{})
x and y are either a variable, constant, list, or compound
unify_internal(x,y,mu)
x and y are sentences, mu is a set of substitutions
finds substitutions making x look exactly like y
unify_variable(var,x,mu)
var is a variable
finds a single substitution (which may be in mu already)D)p$;eK)p$3 $$((,,0064488<<KbV`A E
unify_internalunify_internal(x,y,mu)

Cases
1.if (mu=failure) then return failure
2.if (x=y) then return mu.
3.if (isa_variable(x)) then return unify_variable(x,y,mu)
4.if (isa_variable(y)) then return unify_variable(y,x,mu)
5.if (isa_compound(x) and isa_compound(y)) then return
unify_internal(args(x),args(y),unify_internal(op(x),op(y),mu))
6.if (isa_list(x) and isa_list(y)) then return
unify_internal(tail(x),tail(y),unify_internal(head(x),head(y),mu))
7.return failure '
.99KsFunify_variable&unify_variable(var,x,mu)

Cases
1. if (a substitution var/val is in mu) then return unify_internal(val,x,mu)
2. if (a substitution x/val is in mu) then return unify_internal(var,val,mu)
3. if (var occurs anywhere in x) return failure
4. add var/x to mu and return 'Z'tH#%%DG"Notes on the Unification Algorithmgunify_internal will not match a constant to a constant, unless they are equal (case 2)
Case 5 in unify_internal checks that two compound operators are the same (e.g. same predicate name)
Case 6 in unify_internal causes the algorithm to recursivly unify the whole list
Cases 1 and 2 in unify_variable check that neither inputs have already been substitutedWeTXK9nHThe Occurs CheckhSuppose we needed to substitute X with f(X,Y)
This would give us f(X,Y) instead of X
But there is still an X in there,
so the substitution isn t complete:
we need f(f(X,Y),Y), then f(f(f(X,Y),Y),Y) and so on
We need to avoid this situation
Otherwise the algorithm won t stop
Case 3 in unify_variable checks this
Known as the occurs check
Occurs check slows the algorithm down
Order (n2), where n is size of expressions being unified.J%5 d&9.J%5 )& $$(
(0,,IAn Example UnificationSuppose we want to unify these sentences:
1. p(X,tony) q(george,X,Z)
2. p(f(tony),tony) q(B,C,maggie)
By inspection, this is a good substitution:
{X/f(tony), B/george, C/f(tony), Z/maggie}
This makes both sentences become:
p(f(tony),tony) q(george, f(tony), maggie)
Note that we want to substitute X for C
But we have substituted f(tony) for X already
See the notes for this as a worked example
Using the unification algorithm
Requires five iterations!*ZAZ,Z+Z"ZZ(Z.Z+Z:Z*
4,+"(. +$$:((jac"Binary Resolution (FirstOrder)nBinary resolution rule (using unification)
AB, CD
Subst(q, AD)
if Unify(B, C) = q
Unification algorithm finds Most General Unifier (MGU) q
Don t substitute any more than need to+:'+9 '$$6}LThe Full Resolution RuleIf Unify(Pj, Qk) = q
P1 & Pm, Q1 & Qn
Subst(q, P1 & (no Pj) & Pm Q1 & (no Qk) ... Qn)
Pj and Qk are resolved
Arbitrary number of disjuncts
Relies on preprocessing into CNFHYV
D $$(
(,,0044
88<<
$$((,,
004488<<? :
MUsing Full ResolutionSentences already in CNF
Pick two clauses
Pick positive literal P from first
Pick negative literal N from second
Find MGU q of P and N
Write both clauses as one big disjunction
With P and N missing
Apply q to the new clausef+/+P8OResolution Proof SearchKeep on resolving clause pairs
Eventually result in zerolength clause
This indicates that some literal K was true at the same time as the literal K
Only way to reduce sentence to be empty
Hence there was an inconsistency
Which proves the theorem
Topic of the next lecturebw(<w(<Z Coursework: War of Lifehttp://www.doc.ic.ac.uk/~sgc/teaching/v231/
Two player version of Game of Life
Implement several strategies in Prolog
Run a tournament
On CATE this afternoon
Submit via CATE (more to follow& )
Deadline: 3 weeks todayTPZ9ZQZP9!"+Dc
+rC"s ~d@(h
8 ~
j
Vhttp://www.doc.ic.ac.uk/~sgc/teaching/v231//0DTimes New Roman@ @H@n@fDArialNew RoRdO)T PicturesPowerPoint Document(SummaryInformation(P&
!"#$%&'()*+,.26789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz45DocumentSummaryInformation8Current User"D
!#,http://www.doc.ic.ac.uk/~sgc/teaching/v231/$_ҷ"Simon ColtonSimon Colton
@ (___PPT9
&0
*\ Ph___PPT2001D<4X ___PPTMac11@f hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography h hnamd`
Arial&Monotype Typography (namd Symbol33ff hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography hnamd`
Arial&Monotype Typography \ hnamd`
Arial&Monotype Typography 0 hnamd`
Arial&Monotype Typography $ hnamd`
Arial&Monotype Typography ?%pc1Artificial Intelligence 8. The Resolution MethodHCourse V231
Department of Computing
Imperial College, London
Jeremy Gow(I>
RSoundness & CompletenessWant to prove theorem T from Axioms Ax
Chosen a set of inference rules R
A B means B is entailed by A
A B means B is derived from A using R
R should be sound: if A B then A B
Want R to be complete: if A B then A B'" )
$$((,,00$!; TChoose Your Search Space0Soundness and completeness of R isn t enough
We want a reasonable search space
R determines operators, so influences the space
Can I see where I m going? (Heuristic measure)
Can I restrict options at each state? (Branching)
Three main approaches
Forwards chaining: no heuristic guidance
Backwards chaining: large branching (many things entail KB)
Proof by refutation: clear goal (false), forwards inferenceO"`e; ,!3\(&<'9Proof by RefutationBProof by contradiction, reductio ad absurdum
Negate the theorem & add to axioms (T,Ax)
Use rules of inference to derive the False
So sentences (T,Ax) can t all be true (unsatisfiable)
But the axioms Ax are true
Hence the negated theorem T must be false
Hence the theorem T must be true@WlWt '>
U:The Resolution MethodProof by refutation with a single inference rule
No need to worry about choice of rule
Just how we apply the one rule
Resolution is complete for FOL
Refutationcomplete [Robinson 1965]
If (T,Ax) unsatisfiable it will derive a contradiction
So if will prove any true theorem of FOL
Even so, it might take a long time (> universe)
Even fairly trivial theorems can take a long time
Can use search heuristics to speed it up (next lecture)
No guarantees if it s not a theorem01E$8)0& #$$((,,0044)880<<A
C&!J!Binary Resolution (Propositional)Unit resolution rule (last lecture)
AB, B
A
Binary resolution rule
AB, BC
AC
The literals B and B are resolved$
#$
,? XBinary Resolution (FirstOrder)PBinary resolution rule
AB, CD
Subst(q, AD)
if substitution q s.t. Subst(q,B) = Subst(q,C)
The literals B and C are resolved
B and C have been made the same by q0$% $$ ((#,,00"%Y Resolution in FOL (This Lecture)What if KB contains nondisjuncts?
Preprocessing step: rewrite to CNF
How do we find substitution q?
The unification algorithm
But what if more than two disjuncts?
Extend binary resolution to full resolution##&,# &$$((,,00t
8 ;Conjunctive Normal FormA conjunction of clauses
Each clause is a disjunction of literals
Prop. literal: proposition or negated proposition
FO literal: predicate or negated predicate
No quantifiers (all variables implicitly universal)
Example FO clause
likes(george, X) likes(tony, houseof(george)) is_mad(maggie)
Any FO sentence can be rewritten as CNFFC))
%
!F C$$(((,,$E<!Converting FOL to CNF (see notes)JEliminate implication/equivalence (rewrite)
Move inwards (rewrite)
Rename variables apart (substitution)
Move quantifiers outwards (rewrite)
Skolemise existential variables (substitution)
Distribute over (rewrite)
Flatten binary connectives (rewrite)
(Optional: Reintroduce implications).&lJ
=Example CNF ConversionPropositional example (B (A C)) (B A)
1. Remove implication:
(B (A C)) (B A)
2. Move inwards (De Morgan s x 2):
(B (A C)) (B A)
(B (A C)) (B A)
(Skip 3 to 5 as no variables.)f0ZZZ%Z7Z Z>Example CNF Conversion (Contd)(B (A C)) (B A)
6. Distribute over :
(B (B A)) ((A C) (B A))
7. Flatten connectives
(B B A) (A C B A)
Drop 1st clause (B B), remove duplicate from 2nd:
A C BZZZ)ZZ$Z6ZZ^}WKowalski Normal FormhCan reintroduce to CNF, e.g.
A C B becomes (A C) B
Kowalski form
(A1 & An) (B1 & Bn)
Binary resolution&
AB, BC
AC
Resembles Horn clauses (basis for Prolog)R#*H $$((,,0H04488<<*,fE^!
Skolemisation
,Replace $V with a something term
If no preceeding "U use fresh Skolem constant
Otherwise fresh Skolem function
parameterised by all preceeding "U
"X $Y (person(X) has(X, Y) heart(Y))
to
person(X) has(X, f(X)) heart(f(X))
(The particular heart f(X) depends on person X)#N#S0
# $$
((B,,000x(?Substitutions & Inference RulesPropositional inference rules used in firstorder logic
But in FOL we can make substitutions
Sometimes a substitution can allow a rule to be applied
cf. FO binary resolution
knows(john, X) hates(john, X)
knows(john, mary)
Substitution + Modus Ponens: infer hates(john, mary)
Need to find substitution that makes literals equal
Known as a unifier ]R3iO
Q3T $$(($b@Unifying PredicatesbWe unified these two predicates:
knows(john, X) and knows(john, mary)
By saying that X should be substituted by mary
Why? Because john = john and can {X\mary}
For knows(jack, mary) and knows(john, X)
john doesn t match jack
So we cannot unify the two predicates
Hence we cannot use the rule of inference!T,)hT+)hP}A UnificationWant an algorithm which:
Takes two FOL sentences as input
Outputs a substitution {X/mary, Y/Z, etc.}
Which assigns terms to variables in the sentences
So that the first sentence looks exactly like the second
Or fails if there is no way to unify the sentences
Example:
Unify( knows(john, X) , knows(john,mary) ) = {X/mary}
Unify( knows(john, X) , knows(jack,mary) ) = FailLk3 jLk3 $$((,,0044 88<<&OB
%Functions Within the Unify Algorithmisa_variable(x)
checks whether x is a variable
isa_list(x)
checks whether x is a list
head(x)
outputs the head of a list (first term)
e.g., head([a,b,c]) = a
tail(x)
outputs the elements other than the head in a list
e.g., tail([a,b,c]) = [b,c]ZZZZZ(ZZZ3ZZ(3 $$C.More Internal Functions(Compound Expressions)%isa_compound(x)
checks whether x is compound expression
(either a predicate, a function or a connective)
args(x)
finds the subparts of the compound expression x
arguments of a predicate, function or connective
Returns the list of arguments
op(x)
predicate name/function name/connective symbolY01/Y1 $$/((jD&Two Parts of theUnification AlgorithmAlgorithm is recursive (it calls itself)
Passes around a set of substitutions, called mu
Making sure that new substitutions are consistent with old ones
unify(x,y) = unify_internal(x,y,{})
x and y are either a variable, constant, list, or compound
unify_internal(x,y,mu)
x and y are sentences, mu is a set of substitutions
finds substitutions making x look exactly like y
unify_variable(var,x,mu)
var is a variable
finds a single substitution (which may be in mu already)D)p$;eK)p$3 $$((,,0064488<<KbV`A E
unify_internalunify_internal(x,y,mu)

Cases
1.if (mu=failure) then return failure
2.if (x=y) then return mu.
3.if (isa_variable(x)) then return unify_variable(x,y,mu)
4.if (isa_variable(y)) then return unify_variable(y,x,mu)
5.if (isa_compound(x) and isa_compound(y)) then return
unify_internal(args(x),args(y),unify_internal(op(x),op(y),mu))
6.if (isa_list(x) and isa_list(y)) then return
unify_internal(tail(x),tail(y),unify_internal(head(x),head(y),mu))
7.return failure '
.99KsFunify_variable&unify_variable(var,x,mu)

Cases
1. if (a substitution var/val is in mu) then return unify_internal(val,x,mu)
2. if (a substitution x/val is in mu) then return unify_internal(var,val,mu)
3. if (var occurs anywhere in x) return failure
4. add var/x to mu and return 'Z'tH#%%DG"Notes on the Unification Algorithmgunify_internal will not match a constant to a constant, unless they are equal (case 2)
Case 5 in unify_internal checks that two compound operators are the same (e.g. same predicate name)
Case 6 in unify_internal causes the algorithm to recursivly unify the whole list
Cases 1 and 2 in unify_variable check that neither inputs have already been substitutedWeTXK9nHThe Occurs CheckhSuppose we needed to substitute X with f(X,Y)
This would give us f(X,Y) instead of X
But there is still an X in there,
so the substitution isn t complete:
we need f(f(X,Y),Y), then f(f(f(X,Y),Y),Y) and so on
We need to avoid this situation
Otherwise the algorithm won t stop
Case 3 in unify_variable checks this
Known as the occurs check
Occurs check slows the algorithm down
Order (n2), where n is size of expressions being unified.J%5 d&9.J%5 )& $$(
(0,,IAn Example UnificationSuppose we want to unify these sentences:
1. p(X,tony) q(george,X,Z)
2. p(f(tony),tony) q(B,C,maggie)
By inspection, this is a good substitution:
{X/f(tony), B/george, C/f(tony), Z/maggie}
This makes both sentences become:
p(f(tony),tony) q(george, f(tony), maggie)
Note that we want to substitute X for C
But we have substituted f(tony) for X already
See the notes for this as a worked example
Using the unification algorithm
Requires five iterations!*ZAZ,Z+Z"ZZ(Z.Z+Z:Z*
4,+"(. +$$:((jac"Binary Resolution (FirstOrder)nBinary resolution rule (using unification)
AB, CD
Subst(q, AD)
if Unify(B, C) = q
Unification algorithm finds Most General Unifier (MGU) q
Don t substitute any more than need to+:'+9 '$$6}LThe Full Resolution RuleIf Unify(Pj, Qk) = q ( makes them unifiable)
P1 & Pm, Q1 & Qn
Subst(q, P1 & (no Pj) & Pm Q1 & (no Qk) ... Qn)
Pj and Qk are resolved
Arbitrary number of disjuncts
Relies on preprocessing into CNF`1YV
D $$((,,0
04488<<
$$((,,0044
88<< $$?(( 6
MUsing Full ResolutionSentences already in CNF
Pick two clauses
Pick positive literal P from first
Pick negative literal N from second
Find MGU q of P and N
Write both clauses as one big disjunction
With P and N missing
Apply q to the new clausef+/+P8OResolution Proof SearchKeep on resolving clause pairs
Eventually result in zerolength clause
This indicates that some literal K was true at the same time as the literal K
Only way to reduce sentence to be empty
Hence there was an inconsistency
Which proves the theorem
Topic of the next lecturebw(<w(<Z Coursework: War of Lifehttp://www.doc.ic.ac.uk/~sgc/teaching/v231/
Two player version of Game of Life
Implement several strategies in Prolog
Run a tournament
On CATE this afternoon
Submit via CATE (more to follow& )
Deadline: 3 weeks todayTPZ9ZQZP9!,+Dc
+
+P<(
<r
< S`@
r
< SК0@
B
<
ZD?? @ H
<0h ? 3f3fff̙3ff̙___PPT10e+D=' =
@B +rLs d@RdO)z PicturesPowerPoint Document(SummaryInformation(P&
!"#$%&'()*+,.6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz}DocumentSummaryInformation8Current User"D
!#,http://www.doc.ic.ac.uk/~sgc/teaching/v231/$_ҷhSimon ColtonSimon Colton5