unit 4 resolution
unit 4 resolution
1
A resolution proof tree
Let C = { (-P(w) | Q(w)), (-Q(y) | S(y)), (P(x) | R(x)), (-R(z) | S(z)) }
C { P(w) Q(w), Q(y) S(y), 1 P(x) R(x), R(z) S(z) }
Prove that C |= S(A) for any A.
An Example
• Assumptions:
– Fido is a dog
– All dogs are animals
– All animals will die
• Goal: Convert to clauses:
– Fido will die 1. dog(fido)
Translate in FOL: 2. dog(X) animal(X)
• Assumptions: 3. animal(X) die(X)
4. die(fido)
– dog(fido) // negation of Goal
– X dog(X) animal(X)
– X animal(X) die(X)
• Goal:
– die(fido)
2
Resolution
proof for the
“dog Fido”
problem.
Convert to clauses:
1. dog(fido)
2. dog(X) animal(X)
3. animal(X) die(X)
4. die(fido) 5
• Using Resolution:
1. Convert either X or (A B) into a set S of
clauses;
2. Derive the empty clause from S.
6
3
Resolution Example
• Axioms A:
1. allergies(X) sneeze(X)
2. cat(Y) allergic-to(X, Y) allergies(X)
3. cat(Felix)
4. allergic-to(Liz, Felix)
• Goal B:
sneeze(Liz)
y/Felix
sneeze(z) v ¬allergic-to(z, Felix) allergic-to(Liz, Felix)
z/Liz
Axioms A:
sneeze(Liz) sneeze(Liz)
1. allergies(X) sneeze(X)
2. cat(Y) allergic-to(X, Y)
allergies(X)
3. cat(Felix)
4. allergic-to(Liz, Felix) negated gaol
Goal B:
sneeze(Liz)
8
4
Inference Rule of Factoring
• Resolution is not complete in FOL.
– E.g., S = { (p(x) | p(y)), (p(u) | p(v)) } is unsatisfiable:
– Sθ = { (p(a) | p(a)), (p(a) | p(a)) } = { (p(a)), (p(a)) }
with θ = [ x/a, y/a, u/a, v/a ].
– Resolvent from S: (p(z) | p(w)) ––– no other resolvents
• Factoring Rule:
– Premise: (A1 A2 ... An)
– Result: (A1 A2 ... An)
if is a mgu of Ai and Aj, ij
• Ex 1: (p(x) | p(y)) generates (p(x)) with θ = [ y/x ]
• Ex 2: (p(u) | p(v)) generates (p(u)) with θ = [ v/u ]
Russell’s Paradox
A barber shaves men if and only if they do not shave
themselves. Should the barber shave himself or not?
Translate in FOL:
(A1) x Shaves(x, x) Shaves(barber, x)
(A2) y Shaves(barber, y) Shaves (y, y)
Convert to Clauses:
(C1) Shaves(x, x) Shaves(barber, x)
(C2) Shaves(barber, y) Shaves(y, y)
Four possible resolutions between C1 and C2:
(C1.1, C2.1) Shaves(barber, barber) Shaves(barber, barber)
(C1.1, C2.2) Shaves(barber, x) Shaves(barber, x)
(C1.2, C2.1) Shaves(barber, x) Shaves(barber, x)
(C1.2, C2.2) Shaves(barber, barber) Shaves(barber, barber)
32
10
5
Russell’s Paradox
A barber shaves men if and only if they do not shave
themselves. Should the barber shave himself or not?
Translate in FOL:
(A1) x Shaves(x, x) Shaves(barber, x)
(A2) y Shaves(barber, y) Shaves (y, y)
Convert to Clauses:
(C1) Shaves(x, x) Shaves(barber, x)
(C2) Shaves(barber, y) Shaves(y, y)
Factoring:
(From C1): Shaves(barber, barber)
(From C2): Shaves (barber, barber)
Now it’s easy to get the empty clause.
32
11
12
6
Resolution and Factoring as a
Search Procedure
• Resolution and factoring can be thought of as a search
procedure with the empty clause as the search goal.
• The resolution proof tree is a demonstration of how the
empty clause is found, starting from the clauses
generated from the axioms and the negation of the
theorem.
• When a pair of clauses generates a new resolvent
clause, a new node is added to the tree with arcs
directed from the two parent clauses to the resolvent.
• When a clause C’ is generated from C by factoring, a
new node is added to the tree with arc from C to C’.
13
13
Resolution Strategies
• A strategy defines the policy for picking two clauses
for resolution.
• A strategy is complete if its use guarantees that the
empty clause can be derived whenever it is entailed.
• There carried over from Propositional Logic:
– Breadth-first
– Depth-first/Linear Resolution
– Length heuristics/Unit Resolution
– Input resolution
– Positive/Negative Resolution
– Set of support
– Ordered resolution 14
14
7
Breadth-First Search
• Definition of Level k:
– Level 0 clauses are the original input clauses
– Level k clauses are the resolvents computed
from two clauses, one of which must be from
level k-1 and the other from any level < k.
• Breadth-first: Compute all possible level 1 clauses,
then all possible level 2 clauses, etc.
• Complete (with factoring), but very inefficient
15
15
16
8
Length Heuristics/Unit Resolution
• Shortest-clause heuristic:
Generate a clause with the fewest literals first
• Unit resolution:
Prefer resolution steps in which at least one
parent clause is a “unit clause,” i.e., a clause
containing a single literal
–Not complete in general, but complete
(without factoring) for Horn clauses
17
17
Horn clauses
• A Horn clause is a sentence of the form:
P1(x) P2(x) … Pn(x) Q(x)
or P1(x) P2(x) ... Pn(x) Q(x)
where
– there are 0 or more Pis and 0 or 1 Q
– the Pis and Q are atoms (positive literals)
• Special cases:
– P1 P2 … Pn false
– true Q
• Non-Horn clauses: p(a) q(a), p(x) q(x) r(x) s(x)
• Prolog is based on Horn clauses
18
18
9
Input Resolution
• Input resolution
– At least one parent must be one of the input
clauses.
– Not complete in general, but complete (without
factoring) for Horn clauses
– Prolog uses this strategy
19
Positive/Negative Resolution
• Positive Resolution:
One parent of the resolution must be positive
(all literals are positive)
• Negative Resolution:
One parent of the resolution must be negative
(all literals are negative)
–Prolog uses this strategy
• Both are complete (with factoring)
20
20
10
Set of Support
• A subset of input clauses is designed as the set of
support. Usually, the clauses derived from the
negation of the theorem are in the set-of-support.
• At least one parent clause must be in the set-of-
support (i.e., derived from a goal clause).
• Resolvents are always put into the set of support.
• Prolog uses this strategy
• Complete with factoring (assuming all possible set-
of-support clauses are derived)
• Gives a goal-directed character to the search
21
21
Ordered Resolution
• The user provides a partial order > over atomic formulas.
• > is stable under substitution: A > B implies A > B
for any .
• > is total on ground formulas (Herbrand base).
• > is well-founded: no infinite sequences of
A1>A2>…>An>…
• Ordered Resolution:
– Parent 1: (P1 P2 ... Pn)
– Parent 2: (Q1 Q2 ... Qm)
– Resolvent: (P2 ... Pn Q2 ... Qm)
– if is a mgu of P1 and Q1, and both P1 and Q1 are
maximal in the parent clauses.
22
22
11
“Happy Student” Problem
23
23
24
CSC411
24
12
Refutation
proof tree
for the
“happy
student”
problem.
25
25
26
13
Exciting life problem
• y read(y) smart(y)
• read(John) poor(John)
• x poor(x) smart(x) happy(x)
• z happy(z) exciting(z)
• w exciting(w) // conclusion.
Convert into clauses:
• read(y) smart(y)
• read(John)
• poor(John)
• poor(x) smart(x) happy(x)
• happy(z) exciting(z)
exciting(w) // the negation of conclusion.
27
•
27
Resolution
proof for the
“exciting
life”
problem.
read(Y) smart(Y)
read(John)
poor(John)
poor(X) smart(X) happy(X)
happy(Z) exciting(Z)
exciting(W) // the negation of conclusion.
28
28
14
Clauses generated up to two levels for the
“exciting life” problem by breadth-first search
29
29
The unit,
input,
linear,
negative,
set-of-
support
resolution
proofs on
the
“exciting
life”
problem.
30
30
15
Is this proof
a unit, input,
linear,
positive,
negative, set-
of-support,
or ordered
resolution
proof?
Unit: No
Input: Yes
Linear: Yes
Positive: No
Negative: No
Set-of-support: Yes
Ordered: Yes if exciting > happy > smart > poor > read 31
31
Another
resolution
proof for
the
“exciting
life”
problem
32
32
16
Is this proof
a unit,
input,
linear,
positive,
negative,
set-of-
support, or
ordered
resolution
proof? 33
33
Answer Extraction
• Extract correct answer to a problem from a
resolution refutation by retaining information on
the unification substitutions made in the resolution
refutation
• “Exciting life problem”
– Those people who read are not stupid. John can
read and is wealthy. All people who are not poor
and are smart are happy. Happy people have
exciting lives.
– Who can be found with an exciting life?
– Answer: John.
34
34
17
Simplification Strategies
• Tautology deletion:
Remove any clause containing two
complementary literals (tautology)
• Pure literal deletion:
If a predicate symbol always appears with the
same “sign,” remove all the clauses that contain it
• Subsumption:
Eliminate all clauses that are subsumed by another
clause (details in the next slide)
35
35
Subsumption
• Propositional Logic: clause B is subsumed by another
clause A if every literal of A appears in B.
– E.g., (p | q | r) is subsumed by (p | q).
• FOL: clause B is subsumed by another clause A if there
exists a substitution such that every literal of A
appears in B.
– (p(y) | q(y) | r(y)) is subsumed by (p(x) | q(x)) with = [ x/y ]
– (p(A) | q(A)) is subsumed by (p(x) | q(x)) with = [ x/A ]
– (p(f(a), f(a)) is subsumed by (p(f(x), y) | p(y, f(x))) with = [
x/a, y/f(a) ].
– Factoring rule will generate (p(f(x), f(x))) from (p(f(x), y) |
p(y, f(x))) with = [ y/f(x) ].
36
36
18
Unit Deletion
• Propositional Logic: literal A can be deleted from (A |
) if (A) is a unit clause, since unit resolution can
generate () which subsumes (A | ).
• FOL: literal A can be deleted from (A | ) if (B) is a
unit clause, and there exists substitution such that A =
B since unit resolution can generate () which
subsumes (A | ).
• Example: p(a) can be removed from (p(a) | q(y) | r(y))
if there exists a clause (-p(x)).
37
37
Is this proof
a unit,
input,
linear,
positive,
negative,
set-of-
support, or
ordered
resolution
proof? 38
38
19
Simplification Strategies
• Tautology deletion:
Remove any clause containing two
complementary literals (tautology)
• Pure literal deletion:
If a predicate symbol always appears with the
same “sign,” remove all the clauses that contain it
• Subsumption:
Eliminate all clauses that are subsumed by another
clause
• Unit deletion:
Eliminate all literals whose complements are
instances of unit clauses (details in the next slide) 39
39
40
20
Life Cycle of a Clause in Resolution
proc resolution(C) C: input clauses
1 G := preprocessing(C); // G: given clauses N: New clauses
2 K := ; // K: kept clauses Line 13-14: work
3 while (G ) do D: member of N, line 11
4 A := pickClause(G); Line 8: birth
5 G := G – {A}; Line 10: Pass test
6 N := ; // new clauses from A and K G: Given clauses
7 for B K if resolvable(A,B) do Line 1: birth from C
8 D := resolve(A,B); Line 15: birth from N
9 if D = ( ) return false; Line 10: work
A: member of G, line 4
10 if subsumedBy(D, G K) continue;
Line 8: reproduce
11 N := N factoring(D);
Line 13: death
12 K := K {A};
Line 12: promotion
13 for A G if subsumedBy(A, N) do G := G – {A};
K: Kept clauses
14 for B K if subsumedBy(B, N) do K := K – {B}; Line 10: work
15 G := G N; B: member of G, line 7
16 return true; // K is saturated by resolution Line 8: reproduce
Line 14: death
41
42
21
Example: Hoofers Club…
Translation into FOL Sentences (closed formulas)
Let S(x) mean x is a skier, M(x) mean x is a mountain climber, and
L(x,y) mean x likes y, where the domain of x is Hoofers Club
members, and the domain of y is snow and rain. We can now
translate the English sentences into the following FOL :
1. x S(x) M(x)
2. (x M(x) L(x, Rain))
3. x S(x) L(x, Snow)
4. y L(Liz, y) L(Tony, y)
5. L(Tony, Rain)
6. L(Tony, Snow)
7. Goal: x M(x) S(x)
8. Negation of the Goal: (x M(x) S(x))
43
44
22
Unsatisfiable Core: unsatisfiable
subset of clauses
Conversion to Clause Form and Resolution…
1. (S(x1) | M(x1))
From resolution
2. (~M(x2) | ~L(x2, Rain))
proof, we can
3. (~S(x3) | L(x3, Snow))
identify a core
4. (~L(Tony, x4) | ~L(Liz, x4)) of 5 clauses:
5. (L(Tony, x5) | L(Liz, x5)) 1, 3, 4, 7, 8
6. (L(Tony, Rain))
7. (L(Tony, Snow))
8. (~M(x8) | S(x8)) // Negation of the Goal
9. (S(x1)) // 1 and 8 with 1 = [x8/x1]
10. (L(x1, Snow)) // 3 and 9 with 2 = [x3/x1]
11. (~L(Tony, Snow)) // 4 and 10 with 3 = [x1/Liz, x4/Snow]
12. // 7 and 11
45
33
46
23
Russell’s Paradox in Prover9
Input:
-Shaves(x,x) -> Shaves(barber,x).
Shaves(barber,y) -> - Shaves(y,y).
Output:
1 -Shaves(x,x) -> Shaves(barber,x) # label(non_clause).
[assumption].
2 Shaves(barber,x) -> -Shaves(x,x) # label(non_clause).
[assumption].
3 Shaves(x,x) | Shaves(barber,x). [clausify(1)].
4 -Shaves(barber,x) | -Shaves(x,x). [clausify(2)].
5 Shaves(barber,barber). [factor(3,a,b)].
6 $F. [factor(4,a,b),unit_del(a,5)].
34
47
48
24
Cat Tuna Problem
A. x Dog(x) Owns(Jack, x)
B. x (y Dog(y) Owns(x, y)) AnimalLover(x)
C. x AnimalLover(x) (y Animal(y) Kills(x, y))
D. Kills(Jack, Tuna) Kills(Curiosity, Tuna)
E. Cat(Tuna)
F. x Cat(x) Animal(x)
G. Kills(Curiosity, Tuna)
Prover9’s input:
exists x (dog(x) & owns(Jack, x)).
all x (exists y (dog(y) & owns(x, y)) -> animalLover(x)).
all x all y (animalLover(x) -> (animal(y) -> -kills(x, y))).
kills(Jack, Tuna) | kills(Curiosity, Tuna).
cat(Tuna).
all x (cat(x) -> animal(x)).
-kills(Curiosity, Tuna). 49
49
50
25
Prover9’s Proof
% ==================== Proof ====================
1 (exists x (dog(x) & owns(Jack,x))) # label(non_clause).
[assumption].
2 (all x ((exists y (dog(y) & owns(x,y))) -> animalLover(x))) #
label(non_clause). [assumption].
3 (all x (animalLover(x) -> (all y (animal(y) -> -kills(x,y))))) #
label(non_clause). [assumption].
4 (all x (cat(x) -> animal(x))) # label(non_clause). [assumption].
5 -dog(x) | -owns(y,x) | animalLover(y). [clausify(2)].
6 dog(c1). [clausify(1)].
7 -owns(x,c1) | animalLover(x). [resolve(5,a,6,a)].
8 owns(Jack,c1). [clausify(1)].
9 animalLover(Jack). [resolve(7,a,8,a)].
10 -animalLover(x) | -animal(y) | -kills(x,y). [clausify(3)].
11 -cat(x) | animal(x). [clausify(4)].
12 cat(Tuna). [assumption].
13 animal(Tuna). [resolve(11,a,12,a)].
14 -animal(x) | -kills(Jack,x). [resolve(9,a,10,a)].
15 kills(Jack,Tuna) | kills(Curiosity,Tuna). [assumption].
16 -kills(Curiosity,Tuna). [assumption].
17 -kills(Jack,Tuna). [resolve(13,a,14,a)].
18 $F. [back_unit_del(15),unit_del(a,17),unit_del(b,16)].
51
51
52
26
A resolution refutation proof
A1. (Dog(D))
A2. (Owns(Jack, D))
B. (Dog(y) | Owns(x, y) | AnimalLover(x))
C. (AnimalLover(u) | Animal(v) | Kills(u, v))
D. (Kills(Jack, Tuna) | Kills(Curiosity, Tuna))
E. Cat(Tuna)
F. (Cat(z) | Animal(z))
G: (Kills(Curiosity, Tuna))
R1: G, D, [ ] (Kills(Jack, Tuna))
R2: R1, C, [ u/Jack, v/Tuna ] (AnimalLover(Jack) | Animal(Tuna))
R3: R2, B, [ x/Jack ] (Dog(y) | Owns(Jack, y) | Animal(Tuna))
R4: R3, A1, [ y/D ] (Owns(Jack, D) | Animal(Tuna))
R5: R4, A2, [ ] (-Animal(Tuna))
R6: R5, F, [ z/Tuna ] (-Cat(Tuna))
R7: R6, E, [ ] // empty clause
53
54
27
Prover9’s Resolution Strategies
• Binary resolution, Set-of-Support, Ordered resolution
• Hyper-resolution
– Hyper-resolution consists of a sequence of positive
resolutions between one non-positive clause (called
nucleus) and a set of positive clauses (called satellites),
until a positive clause or the empty clause is produced.
• Ex: (r(a) | r(b) | r(c)) is the result of hyper-resolution from
{c1: (-p(x) | -q(x) | r(x)), c2: (q(a) | r(b)), c3: (p(a) | r(c))}
– c1 is the nucleus; c2 and c3 are satellites.
– The resolvent from c1 and c2 is (p(a) | r(a) | r(b)), which
produces the second resolvent (r(a) | r(b) | r(c)) with c3.
55
55
56
28
Applications of Prover9
• Bill McCune and Larry Wos
– Argonne National Laboratories
– FO resolution provers: EQP, Otter, Prover9
• Robbins Problem (axioms of Boolean algebras)
– Stated 60+ years ago, mathematicians failed
– 1996: EQP solved in 8 days in 1996 (+human work)
• General application to algebraic axiomatisations
– Generate possible axioms for algebras
– Prove new axioms equivalent to old
57
Umbrellas Puzzle
• You know the following things:
– Someone living in your house is wet
– If a person is wet, it is because of the rain, the sprinklers, or both
– If a person is wet because of the sprinklers, the sprinklers must be
on
– If a person is wet because of rain, that person must not be carrying
any umbrella
– There is an umbrella in your house, which is not in the closet
– An umbrella that is not in the closet must be carried by some person
who lives in that house
– Nobody are carrying any umbrella
• Can you conclude that the sprinklers are on?
58
29
(Extremely informal statement of)
Gödel’s Incompleteness Theorem
• First-order logic is not rich enough to model
basic arithmetic.
• For any consistent system of axioms that is rich
enough to capture basic arithmetic (in particular,
mathematical induction), there exist true
sentences that cannot be proved from those
axioms.
59
• Prove:
– Something is its own spouse
60
30
More challenging exercise
• There are exactly 3 objects in the world,
– There exist x, y, z: (NOT(x=y) AND NOT(x=z) AND NOT
(y=z))
– for all w, x, y, z: (w=x OR w=y OR w=z OR x=y OR x=z
OR y=z)
• If x is the spouse of y, then y is the spouse of x, i.e., spouse
defines a commutative relation.
– for all x, y: ((Spouse(x)=y) => (Spouse(y)=x))
• The negation of “Something is its own spouse”
– for all x, y: ((Spouse(x)=y) => NOT(x=y))
61
62
31
FOL for Latin Square Problems
• A Latin square of size N is an N by N square such that each
row and each column is a permutation of S ={ 0, 1, …, N-1}.
• A Latin square can be defined by function *: S, S S, x*y =
z iff the entry at row x and column y is z.
• To specify that each row has no duplicate elements:
• (x * z = y * z) x = y.
• To specify that each column has no duplicate elements:
• (x * y = x * z) y = z.
• A Latin square can be encoded in propositional logic by
variables px,y,z such that px,y,z = 1 iff x*y = z.
• In general, f(a, b, …, c) = y, we encode it by pa,b,…,c,y. if the
domain is finite.
63
63
formulas(assumptions).
% Latin square axioms
x * z != y * z | x = y. % from (x * z = y * z) x = y
x * y != x * z | y = z. % from (x * y = x * z) y = z
end_of_list.
64
64
32
Mace4: Input for Latin squares with
constraint qg5.
Mace4 output:
assign(domain_size, 8).
[ function(*(_,_),
formulas(assumptions). [ 0, 2, 6, 5, 1, 4, 7, 3,
7, 1, 5, 6, 2, 3, 0, 4,
x * z != y * z | x = y.
3, 6, 2, 1, 5, 7, 4, 0,
x * y != x * z | y = z. 1, 7, 4, 3, 0, 6, 2, 5,
x * x = x. 6, 3, 0, 7, 4, 1, 5, 2,
(((y * x) * y) * y) = x. 2, 0, 3, 4, 7, 5, 1, 6,
end_of_list. 5, 4, 7, 0, 3, 2, 6, 1,
4, 5, 1, 2, 6, 0, 3, 7 ])
]).
65
66
33
How to Translate FOL Clauses into PL
1. The domain must be finite, i.e., { 0, 1, …, n-1 }
assign(domain_size, 8).
2. Each clause must be flattened: each atom must be
either p(a1, a2, …, an) or f(a1, …, an) = b, where ai‘s
are either variables or constants.
x * (x \ y) = y becomes (x * z = y) | (x \ y = z)
(((y * x) * y) * y) = x becomes
(u*y = x) | (y*x = z) | (z*y = u)
3. The functional axiom must be added for each function.
(x*y = u) | (x*y = v) | (u = v) // each cell has one value
4. Replace each variable by all the values in the domain.
67
68
68
34
Importance of Equality “=’’
69
69
70
35
Inductive Theorem Proving with
Equations
71
71
36