Introduction to Automated Theorem Proving
Tudor Jebelean
Jan 2007
Contents
1
2
Propositional Logic
2
1.1
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
1.1.1
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
1.1.2
Interesting equivalences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
1.1.3
Transformation rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
1.1.4
The Resolution Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
1.1.5
The Method of Davis and Putnam . . . . . . . . . . . . . . . . . . . . . . . . . .
12
First-order Predicate Logic
14
2.1
Definition of syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
2.2
Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
2.3
Truth evaluation hϕiI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
2.3.1
Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
2.3.2
Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
2.3.3
Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
2.4
Skolem transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
2.5
Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
2.5.1
Resolution principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
2.5.2
Resolution method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
2.5.2.1
Correct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
2.5.2.2
Complete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
1
Chapter 1
Propositional Logic
1.1
Syntax
Propositional logic is a mathematical model of reasoning with elementary statements (or propositions).
Such a proposition (like “It rains.”) has the only characteristic that it can be true or false, and thus it is
denoted by a “propositional symbol” (also called “propositional variable”) about which we only know that
it can be true or false.
Example:
" |
it {z
rains
}
A
" |
it {z
rains
}
A
and
it is sunny "
| {z }
B
or for instance
and
it is not sunny "
|
{z
}
¬B
The syntax of propositional logic consists in the definition of the set of all propositional logic formulae, or
the language of propositional logic formulae, which will contain formulae like:
A∧B
L . . . Language
A ∧ ¬B
with "words" like
(¬A ∧ B) ⇔ (A ⇒ B)
A ∧ ¬A
The language L is defined over a certain set Σ of symbols: the parantheses, the logical connectives, the
logical constants, and an infinite set Θ of propositional variables.
Set of "symbols"
"alphabet"
Σ = {(, )} ∪ {¬, ∧, ∨, ⇒, ⇔} ∪ {T, F} ∪ Θ
Note: Θ is the set of propositional variables. for instance this could be {A, B, C, P, Q, . . . , A1 , A2 , . . . }. This
set Θ is infinite, but enumerable.
All formulae are words over this alphabet Σ.
2
3
CHAPTER 1. PROPOSITIONAL LOGIC
Generalized Inductive Definition
(0) T, F ∈ L or one can also write {T, F} ⊂ L
(1) if
ϑ
∈Θ
, then
ϑ
∈ L}
| {z
|{z}
"word", logical formula
"variable"
(2) if ϕ, ψ ∈ L , then
(a propositional variable ϑ "is" also a logical formula)
¬ϕ , (ϕ ∧ ψ), (ϕ ∨ ψ), (ϕ ⇒ ψ), (ϕ ⇔ ψ) ∈ L
|{z} | {z } | {z } | {z } | {z }
|
{z
}
"are also words in the language"
(3) These are all the formulae.
Note that Σ∗ also has the properties (0), (1) and (2). However, [3] means that L is the smallest set having
these properties. This allows us to use the structural induction principle in order to prove properties of
formulae.
Atoms and literals. Formulae consisting in a single propositional variable are called “atoms”. Formulae
consisting in an atom or a negated atom are called “literals”.
Notation: Sometimes we will denote ¬ϕ by ϕ. Also, if L is a literal, we will denote by L the opposite of
L (that is A if L is A, and A if L is A).
Exercise: Formulate the grammar for the language of propositional logic.
(
P =
Grammar G
= (
Σ
,
|{z}
"alphabet"
W →T|F|A|B|C
W → (¬W) | (W ∧ W) | . . .
ΣN
,
|{z}
"nonterminal
symbols"
S
,
|{z}
"nonterminal
start symbol"
P
)
|{z}
set of
productions
Σ = {T, F} ∪ Θ ∪ {(, ), ¬, ∨, ∧, ⇒, ⇔}
ΣN = {W}
S = ΣN
1.1.1
Semantics
Example: Intuitively, the meaning of “A ∧ B” is that "this is only true if both A and B are true".
fA∧B
T
F
T
T
F
F
F
F
Table 1.1: Semantic value of A ∧ B.
4
CHAPTER 1. PROPOSITIONAL LOGIC
The semantic value (or the meaning) of the formula A ∧ B is the function fA∧B : I{A,B} → {T, F}, where
I{A,B} = {I : {A, B} → {T, F}} is the set of all assignments of truth values to the variables A, B.
I is called an “interpretation” for the formula A ∧ B. I{A,B} is the “set of interpretations” for the formula
A ∧ B.
As syntax is defined as the set L of all correct formulae, the semantics is defined as the set S of all possible
semantic values:
S = {IV |V ⊆ Θ}.
The “semantic evaluation function” associates each formula ϕ from L to its semantic value fϕ from S. If
we denote by Var(ϕ) the set of propositional variables occuring in ϕ, then:
fϕ : IVar(ϕ) → {T, F}, fϕ (I) = hϕiI ,
where hϕiI is the “truth value of ϕ under the interpretation I”.
hϕiI (the truth evaluation of a formula ϕ under the interpretation I) is defined inductively on the structure
of formulae:
hFiI
hTiI
hviI
= F
= T
= I(ϑ), if v ∈ Θ
h¬ϕiI
hϕ ∨ ψiI
hϕ∧ψiI
...
= B¬ (hϕiI )
= B∨ (hϕiI , hψiI )
= B∧ (hϕiI , hψiI )
The functions B¬ , B∨ , B∧ , . . . (boolean evaluation functions) are defined explicitely by truth tables for
each logical connective, and they can be seen as the semantic values of the logical connectives.
T
F
B¬
F
T
B∧
T
F
T
T
F
F
F
F
B∨
T
F
T
T
T
F
T
F
B⇒
T
F
T
T
T
F
F
T
B⇔
T
F
Table 1.2: The semantics of logical connectives
Example
h(A ∧ (A ⇒ B)) ⇒ BiI
= B⇒ h(A ∧ (A ⇒ B))iI , hBiI
= B⇒ B∧ hAiI , h(A ⇒ B)iI , hBiI
= B⇒ B∧ hAiI , B⇒ hAiI , hBiI , hBiI
= B⇒ B∧ T, B⇒ (T, F) , F
| {z }
F
|
{z
}
F
= T
T
T
F
F
F
T
CHAPTER 1. PROPOSITIONAL LOGIC
5
Model, validity, satisfiability. If hϕiI = T, then we say “I satisfies ϕ” or “I is a model of ϕ”.
If for any I, fϕ (I) = T , then we say “ϕ is valid” (otherwise it is “invalid”)
If for any I, fϕ (I) = F , then we say “ϕ is unsatisfiable” (otherwise it is “satisfiable”)
(( The correct characterization for this is “unsatisfiable”:
Example. The formula A ∧ ¬A is (
"always
(((false":
for all interpretations I, fA∧¬A (I) = F.
(( Correct is to say that it is “valid”: for all I, h. . . i = T.
The formula (A ⇒ (A ⇒ B)) ⇒ B is (
"always
(((true".
I
The following formula is “invalid”, but “satisfiable”: A ∧ B (its truth value depends on I).
Logical consequence. We say “the formula ψ is a logical consequence of the formulae ϕ1 , . . . , ϕn ” (also
denoted as ϕ1 , . . . , ϕn |= ψ), if and only if:
for all I, whenever hϕ1 iI = . . . = hϕn iI = T, then also hψiI = T.
Two Basic Theorems. When working in mathematics, the typical shape of the theorems we want to
prove is ϕ1 , . . . , ϕn |= ψ. The following two theorems show how to reduce such a problem to establishing
the validity, respectively the insatisfiability, of a certain formula. The former is called “proof by refutation”
and corresponds in fact to the known proof technique of “proof by contradiction”.
Theorem 1.
ϕ1 , . . . , ϕn |= ψ if and only if (ϕ1 ∧ . . . ∧ϕn ) =⇒ ψ is valid.
Theorem 2.
ϕ1 , . . . , ϕn |= ψ if and only if ϕ1 ∧ . . . ∧ϕn ∧¬ψ is unsatisfiable.
Logical equivalence. We say “ϕ is equivalent to ψ”, (also denoted as ϕ ≡ ψ) if and only if ϕ |= ψ and
ψ |= ϕ.
1.1.2
Interesting equivalences
(
• Commutativity:
(
ϕ1 ∧ (ϕ2 ∧ ϕ3 ) ≡ (ϕ1 ∧ ϕ2 ) ∧ ϕ3
(same with ∨ )
(
ϕ∧ϕ≡ϕ
(same with ∨ )
• Associativity:
• Idempotence:
ϕ∧ψ≡ψ∧ϕ
(same with ∨ )
This can be extended for more complex expressions, for example:
(A ∨ ((A ∨ B) ∨ (C ∨ B))) ∨ C ≡ (A ∨ B ∨ C):
(((ϑ1 ∨ ϑ2 ) ∨ ϑ3 ) ∨ ϑ4 ) ∨ ϑ5
≡ ϑ1 ∨ ϑ2 ∨ ϑ3 ∨ ϑ4 ∨ ϑ5
_
this can also be denoted :
{ϑ1 , ϑ2 , ϑ3 , ϑ4 , ϑ5 }
6
CHAPTER 1. PROPOSITIONAL LOGIC
• Properties of negation
¬¬ϕ
¬ϕ ∨ ϕ
¬ϕ ∧ ϕ
¬(ϕ ∨ ψ)
¬(ϕ ∧ ψ)
≡
≡
≡
≡
≡
ϕ
T
F
(¬ϕ) ∧ (¬ψ)
(¬ϕ) ∨ (¬ψ)
• Distributivity
ϕ ∧ (ψ1 ∨ ψ2 )
ϕ ∨ (ψ1 ∧ ψ2 )
≡ (ϕ ∧ ψ1 ) ∨ (ϕ ∧ ψ2 )
≡ (ϕ ∨ ψ1 ) ∧ (ϕ ∨ ψ2 )
• Elimination of ⇒ and ⇔
ϕ ⇒ ψ ≡ (¬ϕ) ∨ ψ
ϕ ⇔ ψ ≡ (ϕ ⇒ ψ) ∧ (ψ ⇒ ϕ)
≡ (¬ϕ ∨ ψ) ∧ (¬ψ ∨ ϕ)
≡ (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)
Example usage of rules:
A ∨ B ∨ ¬A ≡
(A ∨ ¬A) ∨ B ≡
T∨B ≡
T
• Properties of truth constants
T∨ϕ≡T
T∧ϕ≡ϕ
¬T ≡ F
T⇒ϕ≡ϕ
(because T ⇒ ϕ ≡ (¬T) ∨ ϕ ≡ F ∨ ϕ ≡ ϕ)
ϕ⇒T≡T
F∨ϕ≡ϕ
F∧ϕ≡F
¬F ≡ T
F ⇒ ϕ ≡ T (false implies anything)
(because F ⇒ ϕ ≡ (¬F) ∨ ϕ ≡ T ∨ ϕ ≡ T)
ϕ ⇒ F ≡ ¬ϕ
Exercise: Write the rules for the elimination of the truth constants for ⇔ (in analogy to ϕ ⇒ T ≡
T and ϕ ⇒ F ≡ ¬ϕ)
Proofs of the equivalences For example, prove T ∨ ϕ ≡ T
By definition:
For any I :
fT∨ϕ (I)
hT ∨ ϕiI
B∨ (hTiI , hϕiI )
=?
=?
=?
=Yeah!
(note that again, this only refers to
the relevant interpretations as explained above)
fT (I)
hTiI
hTiI
T
7
CHAPTER 1. PROPOSITIONAL LOGIC
B∨
T
F
T
Either this case:T
T
F
or this case:T
F
Proof for ¬¬ϕ ≡ ϕ
=?
≡
≡
h¬¬ϕiI
h¬¬ϕiI
hϕiI
B¬ h¬ϕiI
B¬ B¬ hϕiI ≡! hϕiI
(
B¬ (B¬ (c)) ≡! c case
c = T B¬ (B¬ (T)) ≡Yeah! T
c = F B¬ (B¬ (F)) ≡Yeah! F
Another way to prove, is shown here with the example of proving ϕ ∧ (ψ1 ∨ ψ2 ) ≡ (ϕ ∧ ψ1 ) ∨ (ϕ ∧ ψ2 )
hϕiI
T
T
T
T
F
F
F
F
hψ1 iI
T
T
F
F
T
T
F
F
hψ2 iI
T
F
T
F
T
F
T
F
ψ1 ∨ ψ2
T
T
...
...
...
...
...
...
ϕ ∧ ψ1
T
T
...
...
...
...
...
...
LHS
T
T
...
...
...
...
...
...
ϕ ∧ ψ2
T
F
...
...
...
...
...
...
RHS
T
T
...
...
...
...
...
...
Note: LHS means Left Hand Side, RHS means Right Hand Side
Exercise: Complete this table.
1.1.3
Transformation rules
Equivalences can be used as transformation rules.
¬¬ϕ ≡ ϕ
¬ϕ ∨ ϕ ≡ T
Eliminate ¬
¬ϕ ∧ ϕ ≡ F
Push negation:
(
¬(ϕ ∨ ψ)
¬(ϕ ∧ ψ)
≡ (¬ϕ) ∧ (¬ψ)
≡ (¬ϕ) ∨ (¬ψ)
By repeated application of this rule, any formula can be transformed such that the negation sign occurs
only before atoms. Atoms and negated atoms are called “literals”. Atoms are called positive literals and
negated atoms are called negative literals.
Distributivity
ϕ ∨ (ψ1 ∧ ψ2 )≡ (ϕ ∨ ψ1 ) ∧ (ϕ ∨ ψ2 )
→
−
8
CHAPTER 1. PROPOSITIONAL LOGIC
Note: Every formula can be transformed to a conjunction of disjunctions of literals
!
Conjunctive Normal Form (CNF): (. . . ∨ . . . ∨ . . .) ∧ . . . ∧ (. . . ∨ . . . ∨ . . .)
Note: Each of these underlined “disjunction of literals” is called “clause”, so a formula in CNF is a
conjunction of clauses.
(A ∧ (A ⇒ B)) ⇒ B ≡
¬(A ∧ (¬A ∨ B)) ∨ B ≡
(¬A ∨ ¬(¬A ∨ B)) ∨ B ≡
(¬A ∨ (¬¬A ∧ ¬B)) ∨ B ≡
( (¬A ∨ A) ∧ (¬A ∨ ¬B)) ∨ B ≡
| {z }
T
(¬A ∨ (¬B ∨ B) )
| {z }
T
(Replace implications...)
(Push Negation/"De Morgan"...)
(Push Negation ...)
(Distributivity → Second solution below)
≡
T
Second solution:
(¬A ∨ (¬¬A ∧ ¬B)) ∨ B ≡
(¬A ∨ ((A ∨ B) ∧ (¬B ∨ B) )) ≡
| {z }
T
(¬A ∨ A) ∨ B
| {z }
T
|
{z
}
T
(Distributivity, other possiblity)
≡
T
Since every formula can be transformed into a CNF formula, it is sufficient to find proof methods for the
formulae in CNF.
1.1.4
The Resolution Principle
“Resolution inference rule”:
C1 : L ∨ C10
C2 : L ∨ C20
)
C10 ∨ C20
| {z }
"resolvent of the
clauses C1 , C2 "
7→
For example:
A∨ B∨C
A∨B∨P∨Q
)
7→
B∨C ∨P∨Q
9
CHAPTER 1. PROPOSITIONAL LOGIC
Correctness of the resolution rule
L ∨ C10 , L ∨ C 02
|= C10 ∨ C20
Remark: When C10 is missing, then the resolvent is C20 ,
when C20 is missing, then the resolvent is C10 ,
when both C10 and C20 are missing, then the resolvent is F.
Proof:
For an arbitrary interpretation I
E
D
L ∨ C10 I = T = L ∨ C20
I
hLi
I = T : otherwise
E
D
By cases
L = T : otherwise
I
D
E
L ∨ C20 = F
D
EI
L ∨ C10 = F
I
D E
D
E
C0 = T
0
0
D 2 EI
,
thus
in
either
case
C
∨
C
1
2 I =T
C10 = T
I
Remark.
(L ∨ C1 ) ∧ (L ∨ C2 )
(L ∨ C1 ) ∧ (L ∨ C2 )
.
≡
C10 ∨ C20 !
(L ∨ C1 ) ∧ (L ∨ C2 ) ∧ (C10 ∨ C20 )
“resolution principle” : resolution inference rule and resolution method
“resolution method” : apply the resolution inference rule until you reach the empty clause.
Theorem (Completeness of the resolution method).
If a set of clauses is unsatisfiable, then there exists a proof by resolution (that is: the empty clause can be
obtained by repeated applications of resolution inference rule to the original clauses and to the new ones).
We illustrate the idea of the proof through and example.
Consider the set of clauses:
1. A ∨ P
2. B ∨ P
3. A ∨ B
4. P
We represent all possible interpretations using a so called “semantic tree”, in which every path corresponds
to an interpretation:
A
B
P
B
B
P
P
A
A
P
P
B
B
P P
Figure 1.1: Semantic tree
P
P
10
CHAPTER 1. PROPOSITIONAL LOGIC
A←T
B←F
The path hA, B, Pi represents the interpretation
P←F
If the path leading to a node corresponds to an interpretation which falsifies a clause, then we say that “the
clause closes the node”. For instance, the clause (3) closes the node with the path hA, Bi.
A
B
A
A
B
B
B
B
x
P
P
P
P
P
x
x
x
x
x
P P
P
P
x
Figure 1.2: Semantic tree with closed nodes (1)
If every possible path has a closed node, than we say that “the tree is closed”. Note that a semantic
tree corresponding to an unsatisfiable formula is allways closed, because a path whose nodes are all open
defines an interpretation which satisfies the formula.
We convene to close every path as early as possible.
In a closed tree, there must be at least one node whose both sons are closed. If allways at least one of the
sons is open, then one can construct an open path:
x
x
both brothers closed
x
x
only one brother closed
Figure 1.3: Both brothers closed versus one brother closed
When both brothers are closed, let us consider the clauses C1 and C2 which close them, and the atom L
which corresponds to this branching. Since we close each path as early as possible, the atom L must occur
in C2 and the literal L must occur in C1 . Moreover, all the other literals present in C1 and C2 must be
falsified on the path leading to the father:
11
CHAPTER 1. PROPOSITIONAL LOGIC
C1
false
{
L1
..
.
Ln
L
L
x
x
C1
C2
! "# $ ! "# $
L∨C1! L∨C2!
Figure 1.4: Consequence if both brothers are closed
Therefore, the clauses C1 and C2 are resolvable over L, and the resulting clause C1 ∨C2 falsifies the father or
a node above it. By adding this resolvent to the set of clauses, we obtain a formula whose closed semantic
tree is smaller then before.
Thus, inductively, the closed tree will be reduced until the root is closed, which means that the empty clause
was produced.
In our example, one may apply this procedure as follows:
(1) A ∨ P
(2) B ∨ P
(3) A ∨ B
(4) P
(5) A from (1) and (4)
(6) B from (2) and (4)
(7) A from (3) and (6)
W
(8) {} from (5) and (7)
A
A
A
A
x
B
...
A
x
x
B
...
B
x
x
...
...
...
(empty clause)
s
Figure 1.5: Semantic tree with closed nodes.
A
12
CHAPTER 1. PROPOSITIONAL LOGIC
In conclusion, if we make all possible resolutions on an unsatisfiable set of clauses, then we will allways
obtain the empty clause.
1.1.5
The Method of Davis and Putnam
This method shows the unsatisfiability (or alternatively finds satisfying interpretations) of a set of propositional clauses by alternating two types of steps:
• unit propagation,
• split.
Unit propagation is applied when the set of clauses contains a “unit clause” (that is a clause having only
one literal, say L). In this case L is moved into a “list of assignments” and:
• all clauses containing L are removed (they cannot contribute better than L at obtaining the empty
clause)
• L (the opposite of L) is removed from all clauses where it occurs (this is just resolution).
By the former one may produce the empty clause, and then the current branch of the proof is closed. The
formula is unsatisfiable if this happens on all branches.
Note that by the former some new unit clauses may be produced. This process is repeated until there
are no unit clauses anymore. If the set of clauses becomes empty, then the formula is satisfiable and the
interpretation is given by the list of assignments which was constructed on the current branch.
Split is applied when there are no more unit clauses. One chooses one of the variables still present in the
clause set, say A, and splits the proof into two branches: one for A and one for A. These are taken as unit
clauses and then one may apply unit propagation.
Examples:
This is an unsatisfiable set of clauses. By split on P, one obtains the new set {Q, Q} on each branch, and
then the empty clause.
(
initial set
P∨Q
P∨Q
P∨Q
P∨Q
P
%
&
P
(
Q
Q
→
Q
Q
→
This is a satisfiable set of clauses. First we apply unit propagation on R (just move R into the list of
assignments). The by split on P one obtains the new set {Q} on each branch, and then by unit propagation
(just moving Q into the assignment list), one obtains the empty set.
∅
P:Q
P∨Q
P
∨Q
R
%
&
%
&
∅
∅
P:Q
%
&
∅
13
CHAPTER 1. PROPOSITIONAL LOGIC
R←T
.
T→P
↓
T→Q
&
P←T
↓
Q←T
Chapter 2
First-order Predicate Logic
Syntax
Semantics
function over
interpretations
formula
Figure 2.1: Syntax and Semantics
2.1
Definition of syntax
Formulae:
• terms
– variables, constants
– function symbols
• quantifiers
• logical connectives
(
2 Languages
Language of terms LT
Language of formulae LF
Language of terms
LT
ϑ ∈ Θ, c ∈ C : are terms
f ∈ F , t1 , . . . , tn : terms, then
f (t1 , . . . , tn ) is term
(these are all !)
14
15
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
variables constants
↓
↓
•
Θ
,
C
are (infinite) sets of symbols
• F : set of “functional symbols”
S
F = n∈N Fn
– each Fn is infinite
– Fn ∩ Fm = ∅ (disjoint)
– f ∈ Fn : “f has arity n”
∗ if n = 0, we don’t write f (), but f , which is a constant
∗ so C = F0
Language of formulae
LF
p ∈ P, t1 , . . . , tm : terms, then
P (t1 , . . . , tm ) is formula ("atom")
ϕ, ψ formulae, ϑ ∈ Θ : ∀ϑ ϕ, ∃ϑ ϕ,
¬ϕ, ϕ ∧ ψ, ϕ ∨ ψ,
ϕ ⇒ ψ, ϕ ⇔ ψ are formulae
(these are all !)
• P “predicate symbols”
– P=
S
m∈N
Pm , each Pm infinite,
– Pn ∩ Pm = ∅ (disjoint)
– p ∈ Pm : “p has arity m”
∗ if m = 0, we don’t write P(), but P
∗ P { propositional variable, so propositional logic is a subset of first-order predicate logic
Example
For every two points, there is one and only one line through the two points
∀ x ∀y P(x) ∧ P(y) ⇒
∃z ! (L(z) ∧ T (z, x, y))
P(x) : "x is point"
L(z) : "z is line"
T (z, x, y) : "z passes through x and y"
Schemata for “there exists exactly one”:
∃ x !P(x)
: ∃ x P(x) ∧ ∀y P(y) ⇒
(x = y)
| {z }
more precise: Equal(x, y)
Written without ∃!-Usage, and demonstrating terms “scope” and “bound”:
16
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
∀ x ∀y P(x) ∧ P(y) ⇒ ∃z (L(z) ∧ T (z, x, y)) ∧ ∀z (L(z) ∧ T (z, x, y)) ⇒ (t = z)
{z
}
|
scope
of
the
∀
quantifier
z
|
{z
}
scope of the ∃ quantifier,
variable z is bound in this scope
In the previous formula all variables are bound by quantifiers.
In the next formula there is an unbound (free) variable:
∃x
x
↑
bound
≤
y
↑
free
↑
which y ?
↑
no meaning is assigned to y
One cannot assign a semantics to this formula. Only the closed formulae (i. e. having no free variables)
have semantics.
2.2
Semantics
f∀x ∃y x≤y
:
I
→ {T, F}
↓
interpretations
An interpretation for a formula contains all the elements which are necessary in order to evaluate the truth
value of the formula: a domain for the variables, a concrete function for each function symbol (constants
will have elements of the domain), and a concrete predicate for each predicate symbol.
I
:
"domain" . . .
constant symbol . . .
functional symbol . . .
(arity n)
predicate symbol . . .
(arity m)
D,∅
cI ∈ D
fI : Dn → D
pI : Dm → {T, F}
Example:
∀ x ∃y x ≤ y
In order to evaluate quantified formulae, since the particular elements of the domain cannot occur in formulae, one uses the notion of “truth value under the interpretation and a certain assignment to the free
variables”. Not only that the formulae have truth values, but the terms also have values (under the interpretation and a certain assignment).
17
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
I:
D = {0, 1}
x\y 0
≤I : 0
T
1
F
1
T
T
D
E
∀ x ∃y x ≤ y = T iff foreach d ∈ D :
D
EI I
D
E
D
EI
∃y x ≤ y
∃
≤
y
∃y x ≤ y
y 0
{x←0}
IE
{x←d}
D
I
≤
y
hx ≤ yi{x←0,y←0}
y 1
∃
I
I
I
≤I hxi{x←0,y←0}
, hyi{x←0,y←0}
≤I (0, 0) = T
Example: predicate logic formula, interpretation and truth evaluation
∀ x (P (x) ⇒ Q ( f (x) , a))
for instance I :
D = {1, 2}
aI = 1 (∈ D) (
fI (1) = 1
fI : D → D
fI((2) = 1
PI (1) = T
PI : D → {T, F}
PI (2) = F
QI
1 2
QI : D2 → {T, F}
1
T F
2
F T
h∀ x (P (x) ⇒ Q ( f (x) , a))iI
I
hP (x) ⇒ Q ( f (x) , a)i{x←d}
=
iff
=
T
T
(for each d ∈ D)
So for each element of the domain there is a case:
• Case d = 1:
I
hP (x) ⇒ Q ( f (x) , a)i{x←1}
I
I
= B⇒ hP (x)i{x←1}
, hQ ( f (x) , a)i{x←1}
I
I
I
= B⇒ PI hxi{x←1}
, QI h f (x)i{x←1}
, hai{x←1}
I
I
I
= B⇒ PI hxi{x←1}
, QI fI hxi{x←1}
, hai{x←1}
I
= B⇒ PI (1) , QI fI hxi{x←1}
, aI
= B⇒ (T, QI ( fI (1) , 1)) = B⇒ (T, QI (1, 1))
= B⇒ (T, T) = T
• Case d = 2 :
I
hP (x) ⇒ Q ( f (x) , a)i{x←2}
= ... = T
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
2.3
2.3.1
Truth evaluation hϕiI
Formula
T, F
P (t1 , . . . , tn )
¬ϕ,
hP (t1 , . . . , tn )iαI = PI ht1 iαI , . . . , htn iαI
hϕΩψiαI = BΩ hϕiαI , hψiαI
h¬ϕiαI = B¬ hϕiαI
ϕΩψ
↑
∈ {∧, ∨, ⇒, ⇔}
∀ϑ ϕ
(ϑ : variable symbol)
∃ϑ ϕ
(ϑ : variable symbol)
h∀ϑ ϕiαI = T iff
I
(for each d ∈ D, hϕiα∪{ϑ←d}
= T)
(of the interpretation I)
h∃ϑ ϕiαI = T iff
I
(for some d ∈ D, hϕiα∪{ϑ←d}
= T)
(of the interpretation I)
∀ x P(x) ⇒ ∃y Q(x, y)
I
I
. . . h. . . i{x←d,y←d}
h. . . i{}I . . . h. . . i{x←d}
But what if x is already bound:
∀ x P(x) ⇒ ∃ x Q(x, x)
I
. . . h. . . iI
h. . . i{}I . . . h. . . i{x←d}
{x ← d, x ← d}
↑
which x ?
S
” ˇ ” : modify the assignment !
(replace any other {ϑ ← . . . } !
All variables must be bound.
All free variables are present in the assignment α
2.3.2
Term
ϑ (∈ variable symbol set)
c (∈ constant symbol set)
f (∈ functional symbol set)
I
hϑiαI = hϑi{...,ϑ←d,...
} =d
(assume that there is such an assignment ϑ ← d)
hciαI = cI
h f (t1 , . . . , tn )iαI = fI ht1 iαI , . . . , htn iαI
18
19
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
2.3.3
Equivalence
Syntax
Semantics
ϕ
fϕ = fψ
ψ
Figure 2.2: Syntax, Semantics and semantical equivalence
Then we can define equivalence of two formulae ϕ and ψ as that they’ve got the same semantical function.
Φ |= Ψ semantical logical consequence
♦:
♣:
¬ (∀ x ϕ) ≡ ∃ x (¬ϕ)
¬ (∃ x ϕ) ≡ ∀ x (¬ϕ)
∀ x (ϕ ∧ ψ) ≡ (∀ x ϕ) ∧ (∀ x ψ)
∃ x (ϕ ∨ ψ) ≡ (∃ x ϕ) ∨ (∃ x ψ)
∀ x (ϕ ∨ ψ) ≡ (∀ x ϕ) ∨ ψ
∃ x (ϕ ∧ ψ) ≡ (∃ x ϕ) ∧ ψ
)
˚
if x<ψ
"does not occur"
Substitution:
∀x ϕ
≡
∀y ϕ x←y
˚
if y<ϕ
∃x ϕ
≡
∃y ϕ x←y
We try to prove ♦:
For arbitary interpretation I :
h¬∀ x ϕiI = h¬∀ x ϕi{}I
B¬ h∀ x ϕi{}I
= F iff h∀ x ϕi{}I = T iff
=
I
for each d ∈ D : hϕi{x←d}
=T
= T iff . . .
h¬∃ x ϕi{}I = F
I
iff for some d ∈ D : hϕi{x←d}
=T
20
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
A formula in “prenex normal form” is of the form:
∀ x ∃y ∃z ∀t . . .
ϕ
|{z}
|
{z
}
all quantifiers quantifier-free formula
The quantifier-free formula part can be transformed into CNF
"prenex formula"
(with the quantifier free formula part in) CNF
)
"prenex normal form"
So, a formula in prenex normal form somehow looks like:
∀ x ∃y ∃z ∀t . . . ((· · · ∨ · · · ∨ . . . ) ∧ · · · ∧ (· · · ∨ · · · ∨ . . . ))
2.4
Skolem transformation
A “skolem transformation” is
∃ x P(x)
P(a)
if this is satisfiable → then → this is sat.
this is sat. ←
then ← if this is sat.
Assume that we have an interpretation I that satisfies ∃ x P(x)
D
PI : D → {T, F}
I:
for some d ∈ D : P (d) = T
I
I0 :
7→
(∃ x ϕ satisfiable) iff
and more interesting:
(∃ x ϕ unsatisfiable) iff
so PI 0 (aI ) = T
(ϕ x←a satisfiable)
(ϕ x←a unsatisfiable)
←[
∀ x ∃y P(x, y)
D
PI 0 = PI
a0 =d
I
∀ x P (x, f (x))
I . . . (D, PI , fI )
for each d ∈ D
PI (d, fI (d)) = T
I 0 . . . (D, PI )
for each d ∈ D
(there is d0 ∈ D,
PI (d, d0 ) = T)
take d0 = fI (d)
Note: Homework 5.5 was to show the other direction 7→. Hint: Take an interpretation which is sat on the
LHS and show that it is sat RHS.
∀ x ∃y ϕ unsatisfiable
and more generally:
∀ x1 . . . ∀ xn ∃y ϕ
iff
∀ x ϕy← f (x) unsatisfiable
˚
where f <ϕ
∀ x1 . . . ∀ xn ϕ x← f (x1 ,...,xn )
21
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
So, by skolem transformation, one can eliminate all the ∃-quantifiers.
((· · · ∨ · · · ∨ . . . ) ∧ · · · ∧ (· · · ∨ · · · ∨ . . . ))
|
{z
}
CNF
↓ "skolem transform"
∀ x1 . . . ∀ xn ((· · · ∨ · · · ∨ . . . ) ∧ · · · ∧ (· · · ∨ · · · ∨ . . . ))
|
{z
}
CNF
One does not need to write the quantifiers ∀ x1 . . . ∀ xn any more ! You simply assume that all are universally
quantified.
2.5
∀ x ∃y ∀z ∀t ∃w
Resolution
“Resolution principle”:
L ∨ C1
L ∨ C2
)
C1 ∨ C2
For example:
∀ x P(x) ⇒ Q(x)
P(a)
If (L1 σ = L2 σ),
L1 ∨ C1
L2 ∨ C2
)
P(x) ∨ Q(a)
P(a)
Q(a)
)
Q(a)
)
C1 σ ∨ C2 σ
For example:
instantiate
P(x, a) ∨ Q(x)
{x ← b}
P(b, a) ∨ Q(b)
−
−
−
−
−
−
→
−−−−−−→
P(b, y) ∨ R(y)
{y ← a}
P(b, a) ∨ R(a)
Substitution σ = {x ← b, y ← a}
Q(b) ∨ R(a)
∀ϑ ϕ |=
∀ϑ1 . . . ∀ϑn ϕϑ←t
{ϑ
,
.
.
1 . , ϑn } = FreeVars(t)
L1 ∨ C1 , L2 ∨ C2 |= C1 σ ∨ C2 σ ∀ x1 . . . ∀ xn (L1 ∨ C1 ) ∧ L2 ∨ C2 ⇒ (C1 ∨ C2 )
Correctness:
l
(where L1 σ = L2 σ)
%
∀ x1 . . . ∀ xn L1 ∨ C1
|= ∀ x1 . . . ∀ xn C1 ∨ C2
∀ x1 . . . ∀ xn L2 ∨ C2
& Completeness: If ϕ unsatisfiable, then ϕ `Res (the empty clause)
2.5.1
Resolution principle
The resolution principle, which is an inference rule:
)
L1 ∨ C1
L1 σ = L2 σ ` C1 σ ∨ C2 σ
L2 ∨ C2
formulae which are not ground are [∀ x ]
−−−→
implicitly universally quantified
P (x, f (a)) ∨ Q(x)
P(b, y) ∨ R(y)
Substitution σ = {x ← b, y ← f (x)}
Q(b) ∨ R ( f (x))
|
{z
}
"they are ground"
22
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
2.5.2
Resolution method
The resolution method is a proof system:
• Correct
• Complete
“Apply the resolution principle until you obtain the empty clause”.
2.5.2.1
Correct
L1 σ ∨ C 1 σ
L2 σ ∨ C 2 σ
I
Forall d ∈ D : hP(x)i{x←d}
=T
∀ x P(x)
P (x)
|=
x ← f (y)
`
∀ x P (x) ∨ Q (x)
∀ x P (x) ∨ R (x)
∀y P ( f (y))
P ( f (y))
|= ∀ x Q (x) ∨ R (x)
I
=T
For any d ∈ D : hQ (x) ∨ R (x)i{x←d}
D
EI
I
B∨ P (x)
, hQ (x)i{x←d}
{x←d} I
I
= B∨ B∨ hP (x)i{x←d}
, hQ (x)i{x←d}
...
2.5.2.2
Complete
For doing this, we will introduce a special domain (“Herbrand universe”)
H
H0
Hk+1
H
= {a, f (x) , f ( f (x)) , . . . } (set of ground terms, which is ∞enumerable )
= { constants }
= Hk ∪ { terms obtained by applying all functional symbols to all elements of Hk }
[
=
Hk (can be constructed in a systematic way)
k∈N
H
fI : H → H
fI (t) = ” f (” ` t ` ”)” (where ` denotes a concatenation of strings)
I:
P : H → {T, F}
I
M = {P (a) , P ( f (a)) , P ( f ( f (a))) , . . . } ("atom set": set of ground atoms, which is ∞enumerable )
An interpretation I is a list of ground literals (some are positive, some are not).
23
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
One can write all possible interpretations as a tree.
P (a)
P (a)
∞enumerable
..
.
..
.
¬
..
.
P (f (a))
¬
¬
¬
P (a)
..
.
..
.
¬
¬
..
.
..
.
P (f (f (a)))
..
.
Figure 2.3: ”Semantic tree”
H-satisfiable iff satisfiable
IH
⇐ (over some I/D)
(a)
(
(a))
”P ” , ”P f
Take M and evaluating ground terms M =
” ,...
↑
↑
P (a ) = T P ( f (a )) = T
I
I
I I
I
So practically it is sufficient so speak about terms ”P (a) ” instead of PI (aI ) = T
P(a)
(1)
(x)
(
(x))
P
∨
P
f
P ( f ( f (a)))
So we can close the nodes
P (a)
P (a)
P (x)
x
P (f (x))
¬
¬
x
¬
x
x
¬
x
¬
¬
P (f (f (a)))
x
Figure 2.4: Semantic tree with closed nodes
⇒ The semantic tree is closed
Now if it would not be closed, one would have an infinite path somewhere where all clauses evaluate to
true.
24
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
Conclusion: If ϕ is unsat, then the semantic tree is closed
A
A
A∨B
B∨C
• P(a)
.
P (x) ∨ P ( f (x))
• P ( f ( f (a)))
• P (a) ∨ P ( f (a))
• P ( f (a)) ∨ P ( f ( f (a)))
x←a
x ← f (a)
Herbrand Theorem: If a formula is unsatisfiable, then there exists an unsatisfiable set of ground instances
of the clauses in the formula.
1. This theorem shows the remarkable fact that for proving in first order logic it is enough to
reason about ground instances.
2. The theorem also suggests a procedure for proving: we enumerate all possible ground instances
of clauses, and for each new instance we test (by propositional logic!) whether the set is already
unsatisfiable.
3. Note that this is not a decision procedure: if the original set of clauses in satisfiable, then this
process will never terminate (thus, this is a semi-decision procedure).
4. However, this is the best we can hope for first order predicate logic: one can prove that there is
no general decision procedure.
5. This proving procedure is not efficient: resolution is more efficient because it finds (by unification) the instances which are more likely to lead to contradiction.
The Herbrand theorem is important because it is a first step towards proving the completeness of the
resolution method. Namely, since there exists an unsatisfiable set of ground instances of clauses, it follows
(using the construction of the semantic tree), that there exists a deduction by resolution of the empty clause,
over the ground instances of clauses.
The next step in proving the incompleteness is to show that there is a deduction by resolution of the empty
clause over the original set of clauses. This is done by “lifting” the ground deduction to a non-ground
deduction, using the Lifting Lemma. The Lifting Lemma states that every resolvent of two ground instances
of clause is itself an instance of a resolvent of two original instances. Thus, we can replace each grounde
resolution step by a resolution step over the non-ground clauses, and this is the “lifting” of the deduction.
The completeness of resolution is in fact equivalent to Gödel’s Completeness Theorem, which is of great
importance for the philosophy of logic and also of computer science.
Since resolution calculus is essentially equivalent to natural deduction calculus (used in Gödel’s theorem),
one has the following:
If a formula is unsatisfiable, then one can obtain a contradiction by natural deduction, thus False is a
logical consequence of it.
(A formula having the latter property is called inconsistent, and a formulae from which False does not
follow are called consistent.)
By contraposition (reversed implication between the negations) one obtains:
If a formula is consistent, than it has a model (that is: an interpretation for which the formula evaluates to
True).
This is the Gödel’s completeness theorem, which states the remarkable fact that for every noncontradictory
theory in first order predicate logic there exists a domain on which this theory holds.
CHAPTER 2. FIRST-ORDER PREDICATE LOGIC
25
Moreover, the proof is constructive and (similarly to the proof of the Herbrand theorem) it actually exhibits
a concrete domain on which the theory holds: this is the Herbrand universe (that is set of ground terms),
together with the functions and the predicates which occur in the theory, thus its construction only needs
the “syntactic material” which is already present in the respective theory.
When we want to solve a problem with the help of the computer, we start from an abstract model of the
problem (that is a logical theory) and we need to create a concrete domain on which the functions and
the predicates of the theory can be implemented. The completeness theorem shows that this is allways
possible, and also gives us a general method to realize the implementation.
© Copyright 2026 Paperzz