Professional Documents
Culture Documents
, where Z and Z
= if (P
, X
, Y
)
If P = P
, Y Y
)
If P < P
, Y Z
)
If P > P
then recursively do if (P
, Z X
, Z Y
)
Slide 406
Canonical Form of P Q
P
0 1
Q
0 1
P
f(x)dx
Slide 506
Expressiveness of Quantiers
All men are mortal :
x (man(x) mortal(x))
All mothers are female:
x female(mother(x))
There exists a unique x such that A, written !x A
x [A(x) y(A(y) y = x)]
V Logic and Proof 24
Slide 507
How do we interpret mortal(Socrates)?
Interpretation 1 = (D, I) of our rst-order language
Dis a non-empty universe
I maps symbols to real functions, relations
c a constant symbol I[c] D
f an n-place function symbol I[f] D
n
D
P an n-place relation symbol I[P] D
n
Slide 508
How do we interpret cousin(Charles, y)?
A valuation supplies the values of free variables
It is a function V : variables D
1
V
[t] extends V to a term t by the obvious recursion:
1
V
[x]
def
= V(x) if x is a variable
1
V
[c]
def
= I[c]
1
V
[f(t
1
, . . . , t
n
)]
def
= I[f](1
V
[t
1
], . . . , 1
V
[t
n
])
V Logic and Proof 25
Slide 509
The Meaning of Truth in FOL
For interpretation 1 and valuation V
|=
I,V
P(t) if I[P](1
V
[t]) holds
|=
I,V
t = u if 1
V
[t] equals 1
V
[u]
|=
I,V
A B if |=
I,V
Aand |=
I,V
B
|=
I,V
x A if |=
I,V{m/x}
Aholds for some m D
|=
I
A if |=
I,V
Aholds for all V
Ais satisable if |=
I
Afor some 1
VI Logic and Proof 26
Slide 601
Free v Bound Variables
All occurrences of x in x Aand x A are bound
An occurrence of x is free if it is not bound:
x yR(x, y, f(x, z))
May rename bound variables:
wy
R(w, y
, f(w, z))
Slide 602
Substitution for Free Variables
A[t/x] means substitute t for x in A:
(B C)[t/x] is B[t/x] C[t/x]
(x B)[t/x] is x B
(yB)[t/x] is yB[t/x] (x ,= y)
(P(u))[t/x] is P(u[t/x])
No variable in t may be bound in A!
(yx = y)[y/x] is not yy = y!
VI Logic and Proof 27
Slide 603
Some Equivalences for Quantiers
(x A) x A
(x A) B x (A B)
(x A) B x (A B)
(x A) (x B) x (A B)
(x A) B x (A B)
x A x A A[t/x]
Dual versions: exchange , and ,
Slide 604
Reasoning by Equivalences
x (x = a P(x)) x (x = a P(a))
x (x = a) P(a)
P(a)
z (P(z) P(a) P(b))
z P(z) P(a) P(b)
z P(z) P(a) P(b) P(a) P(b)
t
VI Logic and Proof 28
Slide 605
Sequent Calculus Rules for
A[t/x],
x A,
(l)
, A
, x A
(r)
Rule (l) can create many instances of x A
Rule (r) holds provided x is not free in the conclusion!
NOT allowed to prove
P(y) P(y)
P(y) yP(y)
(r)
Slide 606
Simple Example of the Rules
P(f(y)) P(f(y))
x P(x) P(f(y))
(l)
x P(x) yP(f(y))
(r)
VI Logic and Proof 29
Slide 607
Not-So-Simple Example of the Rules
P Q(y), P P, Q(y) Q(y)
P, P Q(y) Q(y)
(l)
P, x (P Q(x)) Q(y)
(l)
P, x (P Q(x)) yQ(y)
(r)
x (P Q(x)) P yQ(y)
(r)
In (l) we have replaced x by y
Slide 608
Sequent Calculus Rules for
A,
x A,
(l)
, A[t/x]
, x A
(r)
Rule (l) holds provided x is not free in the conclusion!
Rule (r) can create many instances of x A
Say, to prove
z (P(z) P(a) P(b))
VI Logic and Proof 30
Slide 609
Part of the Distributive Law
P(x) P(x), Q(x)
P(x) P(x) Q(x)
(r)
P(x) y(P(y) Q(y))
(r)
x P(x) y(P(y) Q(y))
(l)
similar
x Q(x) y . . .
(l)
x P(x) x Q(x) y(P(y) Q(y))
(l)
Second subtree proves x Q(x) y(P(y) Q(y)) similarly
In (r) we have replaced y by x
Slide 610
A Failed Proof
P(x), Q(y) P(x) Q(x)
P(x), Q(y) z (P(z) Q(z))
(r)
P(x), x Q(x) z (P(z) Q(z))
(l)
x P(x), x Q(x) z (P(z) Q(z))
(l)
x P(x) x Q(x) z (P(z) Q(z))
(l)
We cannot use (l) twice with the same variable
We rename the bound variable in x Q(x) and get yQ(y)
VII Logic and Proof 31
Slide 701
Clause Form
Clause: a disjunction of literals
K
1
K
m
L
1
L
n
Set notation: {K
1
, . . . , K
m
, L
1
, . . . , L
n
}
Kowalski notation: K
1
, , K
m
L
1
, , L
n
L
1
, , L
n
K
1
, , K
m
Empty clause:
EMPTY CLAUSE MEANS CONTRADICTION!
Slide 702
Outline of Clause Form Methods
To prove A, obtain a contradiction from A:
1. Translate A into CNF as A
1
A
m
2. This is the set of clauses A
1
, . . ., A
m
3. Transform the clause set, preserving consistency
Empty clause refutes A
Empty clause set means Ais satisable
VII Logic and Proof 32
Slide 703
The Davis-Putnam-Logeman-Loveland Method
1. Delete tautological clauses: {P, P, . . .}
2. For each unit clause {L},
delete all clauses containing L
delete L from all clauses
3. Delete all clauses containing pure literals
4. Perform a case split on some literal
Its a decision procedure: it nds either a contradiction or a model.
Slide 704
Davis-Putnam on a Non-Tautology
Consider P Q Q R
Clauses are {P, Q} {Q} {R}
{P, Q} {Q} {R} initial clauses
{P} {R} unit Q
{R} unit P (also pure)
unit R (also pure)
Clauses satisable by P t, Q f , R f
VII Logic and Proof 33
Slide 705
Example of a Case Split on P
{Q, R} {R, P} {R, Q} {P, Q, R} {P, Q} {P, Q}
{Q, R} {R, Q} {Q, R} {Q} if P is true
{R} {R} unit Q
unit R
{Q, R} {R} {R, Q} {Q} if P is false
{Q} {Q} unit R
unit Q
Slide 706
The Resolution Rule
From B Aand B C infer A C
In set notation,
{B, A
1
, . . . , A
m
} {B, C
1
, . . . , C
n
}
{A
1
, . . . , A
m
, C
1
, . . . , C
n
}
Some special cases:
{B} {B, C
1
, . . . , C
n
}
{C
1
, . . . , C
n
}
{B} {B}
i0
H
i
Herbrand Universe
HB
def
= {P(t
1
, . . . , t
n
) | t
1
, . . . , t
n
H
and P is an n-place predicate symbol in S}
VIII Logic and Proof 39
Slide 807
Example of an Herbrand Model
even(1)
even(2)
even(X Y) even(X), even(Y)
clauses
H = {1, 2, 1 1, 1 2, 2 1, 2 2, 1 (1 1), . . .}
HB = {even(1), even(2), even(1 1), even(1 2), . . .}
I[even] = {even(2), even(1 2), even(2 1), even(2 2), . . .}
(for model where means product; could instead use sum!)
Slide 808
A Key Fact about Herbrand Interpretations
Let S be a set of clauses.
S is unsatisable no Herbrand interpretation satises S
Holds because some Herbrand model mimicks every real model
We must consider only a small class of models
Herbrand models are syntactic, easily processed by computer
VIII Logic and Proof 40
Slide 809
Herbrands Theorem
Let S be a set of clauses.
S is unsatisable there is a nite unsatisable set S
of ground
instances of clauses of S.
Finite: we can compute it
Instance: result of substituting for variables
Ground: and no variables remain: its propositional!
IX Logic and Proof 41
Slide 901
Unication
Finding a common instance of two terms
Logic programming (Prolog)
Polymorphic type-checking (ML)
Constraint satisfaction problems
Resolution theorem proving for FOL
Many other theorem proving methods
Slide 902
Substitutions
A nite set of replacements
= [t
1
/x
1
, . . . , t
k
/x
k
]
where x
1
, . . ., x
k
are distinct variables and t
i
,= x
i
f(t, u) = f(t, u) (terms)
P(t, u) = P(t, u) (literals)
{L
1
, . . . , L
m
} = {L
1
, . . . , L
m
} (clauses)
IX Logic and Proof 42
Slide 903
Composing Substitutions
Composition of and , written , satises for all terms t
t( ) = (t)
It is dened by (for all relevant x)
def
= [ (x)/ x, . . . ]
Consequences include [] = , and associativity:
( ) = ( )
Slide 904
Most General Uniers
is a unier of terms t and u if t = u
is more general than if =
is most general if it is more general than every other unier
If unies t and u then so does :
t( ) = t = u = u( )
A most general unier of f(a, x) and f(y, g(z)) is [a/y, g(z)/x]
The common instance is f(a, g(z))
IX Logic and Proof 43
Slide 905
Algorithm for Unifying Two Terms
Represent terms by binary trees
Each term is a Variable x, y. . ., Constant a, b. . ., or Pair (t, t
)
Constants do not unify with different Constants
Constants do not unify with Pairs
Variable x and term t: unier is [t/x] unless x occurs in t
Cannot unify f(x) with x!
Slide 906
Unifying Two Pairs
unies (t, t
) with (u, u
)
if unies t with u and
unies t
with u
(t, t
)(
) = (t, t
= (t
, t
)
= (u
, u
)
= (u, u
= (u, u
)(
)
IX Logic and Proof 44
Slide 907
Examples of Unication
f(x, b) f(x, x) f(x, x) j(x, x, z)
f(a, y) f(a, b) f(y, g(y)) j(w, a, h(w))
f(a, b) ? ? j(a, a, h(a))
[a/x, b/y] FAIL FAIL [a/w, a/x, h(a)/z]
We always get a most general unier
Slide 908
Theorem-Proving Examples
(yx R(x, y)) (x yR(x, y))
Clauses after negation are {R(x, a)} and {R(b, y)}
R(x, a) and R(b, y) have unier [b/x, a/y]: contradiction!
(x yR(x, y)) (yx R(x, y))
Clauses after negation are {R(x, f(x))} and {R(g(y), y)}
R(x, f(x)) and R(g(y), y) are not uniable: occurs check
Formula is not a theorem!
IX Logic and Proof 45
Slide 909
Variations on Unication
Efcient unication algorithms: near-linear time
Indexing & Discrimination networks: fast retrieval of a uniable term
Order-sorted unication: type-checking in Haskell
Associative/commutative operators: problems in group theory
Higher-order unication: support -calculus
Boolean unication: reasoning about sets
X Logic and Proof 46
Slide 1001
Binary Resolution
{B, A
1
, . . . , A
m
} {D, C
1
, . . . , C
n
}
{A
1
, . . . , A
m
, C
1
, . . . , C
n
}
provided B = D
First rename variables apart in the clauses! say, to resolve
{P(x)} and {P(g(x))}
Always use a most general unier (MGU)
Soundness? Same argument as for the propositional version
Slide 1002
Factorisation
Collapsing similar literals in one clause:
{B
1
, . . . , B
k
, A
1
, . . . , A
m
}
{B
1
, A
1
, . . . , A
m
}
provided B
1
= = B
k
, A
, 2A
(2r)
A,
3A,
(3l)
, A
, 3A
(3r)
def
= {2B | 2B } Erase non-2assumptions
def
= {3B | 3B } Erase non-3goals!
XI Logic and Proof 54
Slide 1107
A Proof of the Distribution Axiom
AB, A B, AB
A B, AB
(l)
A B, 2AB
(2l)
2(A B), 2AB
(2l)
2(A B), 2A2B
(2r)
And thus 2(A B) (2A 2B)
Must apply (2r) rst!
Slide 1108
Part of an Operator String Equivalence
3A3A
23A3A
(2l)
323A3A
(3l)
2323A3A
(2l)
2323A23A
(2r)
In fact, 2323A 23A also 22A 2A
The S4 operator strings are 2 3 23 32 232 323
XI Logic and Proof 55
Slide 1109
Two Failed Proofs
A
3A
(3r)
A23A
(2r)
BA B
B3(A B)
(3r)
3A, 3B3(A B)
(3l)
Can extract a countermodel from the proof attempt
XII Logic and Proof 56
Slide 1201
Simplifying the Sequent Calculus
7 connectives (or 9 for modal logic):
(2 3)
Left and right: so 14 rules (or 18) plus basic sequent, cut
Idea! Work in Negation Normal Form
Fewer connectives: (2 3)
Sequents need one side only!
Slide 1202
Simplied Calculus: Left-Only
A, A,
(basic)
A, A,
(cut)
A, B,
A B,
(l)
A, B,
A B,
(l)
A[t/x],
x A,
(l)
A,
x A,
(l)
Rule (l) holds provided x is not free in the conclusion!
XII Logic and Proof 57
Slide 1203
Left-Only Sequent Rules for S4
A,
2A,
(2l)
A,
3A,
(3l)
def
= {2B | 2B } Erase non-2assumptions
From 14 (or 18) rules to 4 (or 6)
Left-side only system uses proof by contradiction
Right-side only system is an exact dual
Slide 1204
Proving x (P Q(x)) P yQ(y)
Move the right-side formula to the left and convert to NNF:
P yQ(y), x (P Q(x))
P, Q(y), P P, Q(y), Q(y)
P, Q(y), P Q(y)
(l)
P, Q(y), x (P Q(x))
(l)
P, yQ(y), x (P Q(x))
(l)
P yQ(y), x (P Q(x))
(l)
XII Logic and Proof 58
Slide 1205
Adding Unication
Rule (l) now inserts a new free variable:
A[z/x],
x A,
(l)
Let unication instantiate any free variable
In A, B, try unifying Awith B to make a basic sequent
Updating a variable affects entire proof tree
What about rule (l)? Skolemize!
Slide 1206
Skolemization from NNF
Follow tree structure; dont pull out quantiers!
[yz Q(y, z)] x P(x) to [yQ(y, f(y))] P(a)
Better to push quantiers in (called miniscoping)
Proving x y[P(x) P(y)]
Negate; convert to NNF: x y[P(x) P(y)]
Push in the y: x [P(x) yP(y)]
Push in the x : x P(x) yP(y)
Skolemize: x P(x) P(a)
XII Logic and Proof 59
Slide 1207
A Proof of x y[P(x) P(y)]
y f(z)
P(y), P(f(y)), P(z), P(f(z))
(basic)
P(y), P(f(y)), P(z) P(f(z))
(l)
P(y), P(f(y)), x [P(x) P(f(x))]
(l)
P(y) P(f(y)), x [P(x) P(f(x))]
(l)
x [P(x) P(f(x))]
(l)
Unication chooses the term for (l)
Slide 1208
A Failed Proof
Try to prove x [P(x) Q(x)] x P(x) x Q(x)
NNF: x P(x) x Q(x), x [P(x) Q(x)]
Skolemize: P(a) Q(b), x [P(x) Q(x)]
y a
P(a), Q(b), P(y)
y b???
P(a), Q(b), Q(y)
P(a), Q(b), P(y) Q(y)
(l)
P(a), Q(b), x [P(x) Q(x)]
(l)
P(a) Q(b), x [P(x) Q(x)]
(l)
XII Logic and Proof 60
Slide 1209
The Worlds Smallest Theorem Prover?
prove((A,B),UnExp,Lits,FreeV,VarLim) :- !,
prove(A,[B|UnExp],Lits,FreeV,VarLim).
prove((A;B),UnExp,Lits,FreeV,VarLim) :- !,
prove(A,UnExp,Lits,FreeV,VarLim),
prove(B,UnExp,Lits,FreeV,VarLim).
prove(all(X,Fml),UnExp,Lits,FreeV,VarLim) :- !,
\+ length(FreeV,VarLim),
copy_term((X,Fml,FreeV),(X1,Fml1,FreeV)),
append(UnExp,[all(X,Fml)],UnExp1),
prove(Fml1,UnExp1,Lits,[X1|FreeV],VarLim).
prove(Lit,_,[L|Lits],_,_) :-
(Lit = -Neg; -Lit = Neg) ->
(unify(Neg,L); prove(Lit,[],Lits,_,_)).
prove(Lit,[Next|UnExp],Lits,FreeV,VarLim) :-
prove(Next,UnExp,[Lit|Lits],FreeV,VarLim).