07 Resolution Annot
07 Resolution Annot
G. Lakemeyer
KB|=↵(t1 , t2 , . . . , tn ).
Hence we are looking for a mechanism which either tests for validity, satisfiability,
or checks whether FALSE can be inferred.
We will now look at just such a method, using a language very close to FOL
(ignoring quantifiers for now).
AI/WS-2024/25 2 / 38
Clausal Form
Notation:
© G. Lakemeyer
⇠ p ) ¬p , ⇠ (¬p) ) p
AI/WS-2024/25 3 / 38
Interpreting clauses as FOL-formulas
t
first-orde logic
A formula is understood as a conjunction of clauses.
A clause is understood as a disjunction of literals.
Literals have their usual meaning.
Hence,
© G. Lakemeyer
In general, every formula (in the new sense) represents a wff in conjunctive
normal form.
AI/WS-2024/25 4 / 38
CNF and DNF
Tranformation to CNF
Every propositional wff ↵ can be converted to an ↵0 in conjunctive normal
form (CNF) such that |=↵ ⌘ ↵0 .
1 Eliminate and ⌘ with ↵ ) (¬↵ _ ) etc. up)
Push ¬ “inwards” with ¬(↵ ^ ) ) (¬↵ _ ¬ ) etc. En(ang) = (av
© G. Lakemeyer
AI/WS-2024/25 7 / 38
The Inference Rule of Resolution
Resolvent
Given two clauses, infer a new clause:
From {p} [ C1 and {⇠ p} [ C2 infer C1 [ C2 .
C1 [ C2 is called the resolvent of the input clauses relative to p.
Example:
The resolvent of [w , p, q ] and [w , s, ⇠ p] relative to p is [w , q , s].
© G. Lakemeyer
Special case:
[p] and [⇠ p] resolve to [ ]. (C1 and C2 are empty.)
AI/WS-2024/25 7 / 38
The Inference Rule of Resolution
Resolvent
Given two clauses, infer a new clause:
From {p} [ C1 and {⇠ p} [ C2 infer C1 [ C2 .
C1 [ C2 is called the resolvent of the input clauses relative to p.
Example:
The resolvent of [w , p, q ] and [w , s, ⇠ p] relative to p is [w , q , s].
© G. Lakemeyer
Special case:
[p] and [⇠ p] resolve to [ ]. (C1 and C2 are empty.)
Derivation
A derivation of a clause c from a set of clauses S is a sequence c1 , c2 , . . . , cn of
clauses, where cn = c and for all ci ,
1 ci 2 S or
2 ci is a resolvent of cj and ck with j , k < i.
AI/WS-2024/25 8 / 38
Why is Resolution Ok?
Special case:
[p] and [⇠ p] resolve to [ ].
Hence {[p], [⇠ p]}|=FALSE, or, {[p], [⇠ p]} is unsatisfiable.
AI/WS-2024/25 8 / 38
Derivation and Implication (1)
Theorem:
The previous theorem can be generalized to derivations:
If S ! c then S |=c.
Proof idea: Induction over the length of a derivation. Show, using case
© G. Lakemeyer
AI/WS-2024/25 9 / 38
Derivation and Implication (1)
Theorem:
The previous theorem can be generalized to derivations:
If S ! c then S |=c.
Proof idea: Induction over the length of a derivation. Show, using case
© G. Lakemeyer
Note:
The converse does not hold, that is, sometimes S |=c holds, yet S ! c does
not hold.
Example: {[⇠ p]}|=[⇠ p, ⇠ q ], i.e. ¬p|=(¬p _ ¬q ). But there is no derivation!
AI/WS-2024/25 9 / 38
Derivation and Implication (2)
Theorem:
Resolution is correct and complete for [ ].
AI/WS-2024/25 10 / 38
Computing implications
To determine whether KB|=↵ holds:
transform KB and ¬↵ into CNF (results in S);
test whether S ! [ ] (If KB = {}, then test if ↵ is valid.)
Non-deterministic method:
1 Test if [ ] in S is.
© G. Lakemeyer
↓
Show: KB|=Girl
[First_Grade] [~Child,~Male,Boy]
[~First_Grade,Child] [~Kindergarden,Child]
© G. Lakemeyer
[~Child,~Female,Girl]
[Child]
[Female]
[Girl,~Female]
[~Girl]
(Negation of the query)
[Girl]
AI/WS-2024/25 [] 12 / 38
Quantifiers
AI/WS-2024/25 13 / 38
Generalizing CNF
To generalize resolution, we first show how to convert FOL wffs into CNF.
FOL ! CNF
1 Eliminate and ⌘.
2 Push ¬ inside. (¬8x ↵ ) 9x ¬↵ etc.)
3 Rename variables to make them syntactically distinct.
(E.g. 9x [P (x )] ^ Q (x ) ) 9z [P (z )] ^ Q (x ), z a new variable)
© G. Lakemeyer
AI/WS-2024/25 14 / 38
Clauses with Variables
Main idea:
A literal with variables represents all its instances. We allow inference over all
instances.
Hence, given
[P (x , a), ⇠ Q (x )] and [⇠ P (b, y ), ⇠ R (b, f (y ))],
© G. Lakemeyer
AI/WS-2024/25 15 / 38
First-Order Resolution
Theorem
S ! [ ] iff S |=FALSE.
AI/WS-2024/25 16 / 38
Example 2
KB= {8x CS_Student (x ) Student (x ), 8x Student (x ) WorksHard (x ),
CS_Student (susi )}
Question: WorksHard (susi )
[~Student(x),WorksHard(x)] [~WorksHard(susi)]
x/susi
© G. Lakemeyer
[~CS_Student(x),Student(x)]
x/susi [~Student(susi)]
[CS_Student(susi)]
[~CS_Student(susi)]
:
results in {[⇠ On(x , y ), ⇠ Green(x ), Green(y )]} in CNF.
[On(b,c)] [~On(x,y),~Green(x),Green(y)]
[x/b,y/c]
© G. Lakemeyer
[~Green(b),Green(c)] [On(a,b)]
[x/a,y/b]
[~Green(c)] [~Green(a),Green(b)]
[Green(a)]
[~Green(b)]
[(Green(b)]
[Plus(0,x,x)] G
x/1,y/3,u/succ(v),z/v
↑
© G. Lakemeyer
[~Plus(1,3,v)]
I
x/0,y/3,v/succ(w),z/w
AI/WS-2024/25 19 / 38
Answer Extraction
Solution: Answer-predicates
Replace the query 9xP (x ) by 9x [P (x ) ^ ¬A(x )],
where A (the answer predicate) occurs nowhere else.
Instead of inferring [ ] infer a clause which contains only the answer predicate.
Still results in a sound and complete inference method.
AI/WS-2024/25 20 / 38
Example Using an Answer Predicate
[Happy(jack)] [~Student(x),~Happy(x),A(x)]
© G. Lakemeyer
[Student(jack)]
[~Student(jack),A(jack)]
AI/WS-2024/25 21 / 38
Disjunctive Answers
Example: KB= {Student (jack ), Student (susi ), Happy (jack ) _ Happy (susi )}
x/susi x/jack
© G. Lakemeyer
[~Happy(susi),A(susi)] [~Happy(jack),A(jack)]
[Happy(jack),Happy(susi)]
[Happy(jack),A(susi)]
Susi
i
o
[A(susi),A(jack)]
Note: Variables may appear in the answer.
AI/WS-2024/25 for the blocks world : [Ala bl Alb c)
.
,
,
22 / 38
Skolemization
AI/WS-2024/25 23 / 38
Why Skolemization is Ok
Theorem
↵ is satisfiable iff ↵0 is satisfiable, where ↵0 is the result of Skolemization.
AI/WS-2024/25 24 / 38
A Problem the
it X+ 1 <
y Xy
KB= {8x 8yLessThan(succ (x ), y ) LessThan(x , y )}
F = LessThan(null , null ) should fail because KB|6=F .
[LessThan(x,y),~LessThan(succ(x),y)]
[~LessThan(0,0)]
© G. Lakemeyer
x/0,y/0
[~LessThan(1,0)]
... x/1,y/0
[~LessThan(2,0)]
x/2,y/0
...
An infinite branch of resolvents! Simple DFS won’t work to derive [ ].
AI/WS-2024/25 25 / 38
Undecidability
AI/WS-2024/25 26 / 38
Resolution is Complete
If the set of clauses is unsatisfiable, then there is a branch with [ ] as a leaf
node.
© G. Lakemeyer
...
...
infinite
... []
branches
AI/WS-2024/25 27 / 38
Too Specific Unifiers
Termination or even efficiency cannot be guaranteed in general,
. . . but there is room for improvement.
One possibility:
Reduce search redundancy by keeping the search as general as possible.
Example:
© G. Lakemeyer
Example:
© G. Lakemeyer
names
of variables .
AI/WS-2024/25 29 / 38
Most General Unifier
MGU
✓ is a most general unifier (MGU) of the literals l1 and l2 iff
1 ✓ unifies l1 and l2
2 for every unifier ✓0 there is a substitution ✓⇤ such that ✓0 = ✓✓⇤
Example:
© G. Lakemeyer
Theorem
Resolution is complete when restricted to MGUs.
AI/WS-2024/25 29 / 38
Computing the MGU
5 Goto 2.
AI/WS-2024/25 30 / 38
Computing the MGU g(x ,, y ..., Xn)
J(xn- Xml)
of
9)f(x ,
Yo) , .. ..
. ..
2 If all li ✓ are identical, then success: ✓ is the MGU. X2(f(f(X0 x0) f(x x) , , ,
Note:
There are faster linear MGU-algorithms.
j(f(x ,
g(x y)) ,
,
h(z , x)
ta =
j) z
, h(f(n - v) , flaid)
1 .
DS =
g(x y)))
Gz , f(x , ,
0 : =
(z)f(x g(x y))) ,
Sy
,
<, 0 =
t20
j(f(x g(x h(ffabs)
© G. Lakemeyer
=
,
, 3) ,
2 .
DS =
EX u),
0 : =
0(u/X]
3 .
DS =
(v g(x y)) , ,
0 : =
04r(g(x y) ,
4 .
DS = y , Scably
AI/WS-2024/25 31 / 38
Herbrand Theorem
AI/WS-2024/25 32 / 38
Herbrand Theorem
Theorem
S is satisfiable iff the Herbrand base is satisfiable.
AI/WS-2024/25 32 / 38
Data
When is This Useful?
Hom clause
clans wat
f
=
most 1 P
Herbrand bases have no variables and are therefore propositional, but they
are generally infinite.
finite if the Herbrand universe is finite;
© G. Lakemeyer
y Perm(x)
> - Male(y) +X + y
Fy Male(s) (g-johnvy ben ...
Eyes
=
: =
Ey Perm(x) = (x =
johnr
+
X
..
V
= mayvX = ben
-
sles out "silly" substitutions
AI/WS-2024/25
Sathe (favorite
mans) >
wrong
type33 / 38
Resolution is Hard!
(and space
Is that a problem only of resolution?
Probably not!
Testing satisfiability of propositional clauses (SAT) is NP-complete [Cook 1971].
While not proven it seems unlikely that NP-complete problems can be solved in
polynomial time.
exist
but SAT-Solven
that can handle millions of
causes ,
AI/WS-2024/25 34 / 38
What Does That Mean for KR?
Problem: The entailments of a KB are usually only useful when they can be
derived fast.
Entailment in FOL is probably too hard for KR.
What to do?
Leave search control to the user.
© G. Lakemeyer
Note: Sometimes it’s ok to wait a long time (e.g. when proving mathematical
theorems).
AI/WS-2024/25 35 / 38
Strategies for Resolution
1. Eliminating clauses
Pure clauses
A clause contains a literal l, and ⇠ l occurs nowhere.
Such a clause can never help to derive [ ].
Tautologies [p -p]
© G. Lakemeyer
[a ,
b ,
~c] subsumes [b ,
a
,
ud ,
~c
,
e]
AI/WS-2024/25 36 / 38
Strategies 2
2. Ordering strategies
There are many ways to vary the order of search; a simple and effective way is
the unit clause preference Cclauses with I literal
Always try to resolve with unit clauses first, since those always “shorten” the
resolvent.
© G. Lakemeyer
3. Set of support
KB is usually satisfiable. Thus it makes little sense to resolve two clauses whose
ancestors are from the KB only.
Contradictions result from the interaction with the negation of the query (¬F).
Hence it is appropriate to require that one of the input clauses has an ancestor in
¬F.
AI/WS-2024/25 37 / 38
Strategies 3