Download 4 Predicate / First Order Logic

Document related concepts
no text concepts found
Transcript
4 Predicate / First Order Logic
4.1
Syntax
4.2
Substitutions
4.3
Semantics
4.4
Equivalence and Normal Forms
4.5
Unification
4.6
Proof Procedures
4.7
Implementation of Proof Procedures
4.8
Properties
First Order Logic (28th November 2007)
1
4.1 Syntax
I Definition 4.1 An alphabet of (first order) predicate logic consists of
. a finite or countably infinite set R of relation symbols,
. a finite or countably infinite set F of function symbols,
. a countably infinite set V of variables,
. the set {¬/1, ∧/2, ∨/2, → /2, ↔ /2} of connectives,
. the set {∀, ∃} of quantifiers, and
. the special characters “(”, “)”, and “,”.
First Order Logic (28th November 2007)
2
Syntax (Continued)
I ∀ is called universal quantifier, ∃ is called existential quantifier.
I An arity n ∈ N is assigned to each function and relation symbol.
I Nullary function symbols are called constant symbols.
I Notation
p, q, . . .
p/n
g, h, . . .
g/n
a, b, . . .
X, Y , . . .
relation symbols,
relation symbol with arity n,
function symbols,
function symbol with arity n,
constant symbols,
variables,
I Agreement In the following we assume that R, F , and V are given.
First Order Logic (28th November 2007)
3
Terms
I Definition 4.2
The set T (F , V ) of terms is the smallest set satisfying the following conditions:
1. Every variable X ∈ V is a term.
2. If g/n ∈ F and {t1, . . . , tn} ⊆ T (F , V ),
then the string g (t1, . . . , tn) is a term.
A term is closed or ground (instantiated), if it does not contain any variables.
The set of ground terms is denoted by T (F ).
I Notation We write g instead of g ().
First Order Logic (28th November 2007)
4
Predicate Logic Formulas
I Definition 4.3 The set of atomic formulas (or, briefly, atoms) of the language
L(R, F , V ) is the set of strings of the form p(t1, . . . , tn), where p/n ∈ R
and {t1, . . . , tn} ⊆ T (F , V ).
I Notation We write p instead of p().
I Definition 4.4 The set of predicate logic formulas of the language L(R, F , V ) is
the smallest set satisfying the following conditions:
1. Every atom is a formula.
2. If F is a formula, then ¬F is a formula.
3. If F1 and F2 are formulas and ◦/2 is a binary connective,
then (F1 ◦ F2) is a formula.
4. If F is a formula, Q is a quantifier and X ∈ V , then (QX ) F is a formula.
I Notation
A
F , G, H
(possibly indexed) denotes an atom,
(possibly indexed) denote formulas.
First Order Logic (28th November 2007)
5
Structural Induction
I Structural induction theorems can be formulated for T (F , V ) and L(R, F , V ).
I Every term in T (F , V ) has property E , if the following conditions are satisfied:
1. Induction basis: Every variable has property E .
2. Induction step:
If f /n is an n-ary function symbol, and the terms t1, . . . , tn in T (F , V )
have property E , then the term f (t1, . . . , tn) also has property E .
I Likewise for formulas
First Order Logic (28th November 2007)
Exercise.
6
Structural Recursion
I Structural recursion theorems can be formulated for T (F , V ) and L(R, F , V ).
I There is exactly one function foo over the set of terms satisfying the following
conditions:
1. Recursion base:
The value of foo for variables and constant symbols is explicitly defined.
2. Recursion step:
The value of foo for f (t1, . . . , tn), n > 0, is defined depending only on
the values of foo for t1, . . . , tn.
I Example
8
< 0
foo(T ) =
1
: Pn
i=1
foo(ti)
I Likewise for formulas
First Order Logic (28th November 2007)
if T is a variable,
if T is a constant symbol,
if T is of the form f (t1, . . . , tn).
Exercise.
7
Subterms and Subformulas
I Definition 3.6 (propositional subformulas) can be extended to
terms and first order formulas
Exercise.
I Example
. {g (f (X ), Y ), f (X ), X, Y }
is the set of subterms of the term g (f (X ), Y ).
. {
(∀X )(∃Y ) (q (X ) → p(g (a, b), f (f (Y )))),
(∃Y ) (q (X ) → p(g (a, b), f (f (Y )))),
(q (X ) → p(g (a, b), f (f (Y )))),
q (X ),
p(g (a, b), f (f (Y )))
is the set of subformulas of the formula
}
(∀X )(∃Y ) (q (X ) → p(g (a, b), f (f (Y )))).
First Order Logic (28th November 2007)
8
Free and Bound Occurrences of Variables
I Definition 4.5 The free occurrences of a variable in a predicate logic formula are
defined as follows:
1 The free occurrences of a variable in an atomic formula F
are the occurrences of a variable in F .
2 The free occurrences of a variable in a formula ¬F
are the free occurrences of a variable in F .
3 The free occurrences of a variable in a formula (F1 ◦ F2)
are the free occurrences of a variable in F1
together with the free occurrences of a variable in F2.
4 The free occurrences of a variable in a formula (QX ) F
are the free occurrences of a variable in F without the occurrences of X .
The occurrence of a variable is called bound, if it is not free.
First Order Logic (28th November 2007)
9
Closed Terms and Formulas
I Remember A term is closed if it does not contain any occurrence of a variable.
I Definition 4.6 A closed formula (or, briefly, a sentence) is a formula,
where every occurrence of a variable is bound.
First Order Logic (28th November 2007)
10
4.2 Substitutions
I Definition 4.7 A substitution is a mapping σ : V → T (F , V ),
where only a finite number of variables is not mapped to itself.
I Let σ be a substitution:
. dom(σ ) = {X | X ∈ V and σ (X ) 6= X}.
. |dom(σ )| is finite.
. σ can be represented by a finite set of pairs
{X 7→ σ (X ) | X ∈ dom(σ )}
and vice versa.
. If dom(σ ) = ∅, then σ is called empty substitution.
. ε denotes an empty substitution.
. The restriction of σ to a set U ⊆ V of variables is defined as
σ|U = {X 7→ t | X 7→ t ∈ σ and X ∈ U }.
First Order Logic (28th November 2007)
11
Instances
I Notation Instead of σ (X ) we will write Xσ in the sequel.
I Definition 4.8 Let σ be a substitution. σ : V → T (F , V ) is extended to
b : T (F , V ) → T (F , V ) as follows: Let t ∈ T (F , V ), then
a mapping σ
8
< tσ
tb
σ =
t
:
b , . . . , tnσ
b)
f ( t1 σ
if t ∈ V ,
if t is a constant,
if t is of the form f (t1, . . . , tn).
b.
tb
σ is called instance of t under σ
b,
If tb
σ is closed, then tb
σ is called ground instance of t under σ
b is said to be a ground substitution for t.
and σ
First Order Logic (28th November 2007)
12
Composition of Substitutions
I Definition 4.9 Let σ and θ be substitutions.
The composition σθ of σ and θ is the substitution
b | X 7→ t ∈ σ and X 6= tθ}
b
{X 7→ tθ
∪ {Y 7→ s | Y 7→ s ∈ θ and Y 6∈ dom(σ )}.
I Proposition 4.11 Let σ and θ be substitutions.
c ) = (tb
b.
For every term t, we have t(σθ
σ )θ
I Proof Structural induction over t
First Order Logic (28th November 2007)
Exercise.
13
Composition of Substitutions (continued)
I Proposition 4.12 Let t ∈ T (F , V ) and σ , θ and λ be substitutions. Then:
1. t((\
σθ )λ) = t(σ\
(θλ)).
c ) = tb
c ).
2. t(εσ
σ = t(σε
I Proof
1.
2.
t((\
σθ )λ)
c ))λ
b
= (t(σθ
b)λ
b
= ((tb
σ )θ
c)
= (tb
σ )(θλ
= t(σ\
(θλ))
Exercise
(Proposition 4.11)
(Proposition 4.11)
(Proposition 4.11)
(Proposition 4.11)
qed
b.
I Notation From now on we write σ instead of σ
First Order Logic (28th November 2007)
14
Applications of Substitutions to Formulas
I Definition 4.13 Let σ be a substitution.

σ
σX =
σ \ {X 7→ t}
if X 6∈ dom(σ )
if X 7→ t ∈ σ
I Definition 4.14 Let σ be a substitution.
The application of a substitution to a formula is defined as follows:
1 p(t1, . . . , tn)σ = p(t1σ, . . . , tnσ )
for every atom of the form p(t1, . . . , tn).
2 (¬F )σ = ¬(F σ ).
3 (F1 ◦ F2)σ = (F1σ ◦ F2σ ) for every binary connective ◦/2.
4 ((QX ) F )σ = (QX ) (F σX ) for every quantifier Q.
If F is a formula and F σ is closed,
then F σ is called ground instance of F under σ ,
and σ is said to be a ground substitution for F .
First Order Logic (28th November 2007)
15
Variants
I Definition 4.17 Let E1 and E2 be either two terms or two predicate logic formulas.
E1 and E2 are called variants, if there are substitutions σ and θ such that
E1 = E2σ and E2 = E1θ . In this case, we will call E1 variant of E2
and E2 variant of E1.
If E1 and E2 are variants and the variables occurring in E2 have not been used so
far in the context, then E2 is a new variant of E1.
First Order Logic (28th November 2007)
16
4.3 Semantics
I What is the meaning of predicate logic formulas?
I 4.3.1 Interpretations and Models
I 4.3.2 Herbrand-Interpretations
First Order Logic (28th November 2007)
17
Some Preliminaries
I Let D be a set.
D2
Dn
=
=
D×D
D n−1 × D
D1
D0
=
=
D
=
=
=:
=:
=
{(d1, d2) | d1 ∈ D and d2 ∈ D}
{(t, dn) | t ∈ D n−1 and dn ∈ D}
{(d1, . . . , dn) | di ∈ D, 1 ≤ i ≤ n}, n > 2
{(d) | d ∈ D}
{( )}
I Relations
R
R
R
R
⊆
⊆
⊆
⊆
D2
D3
D1
D0
R
R
R
R
First Order Logic (28th November 2007)
=
=
=
=
{(n, m) | n, m ∈ N and n < m}
{(x, y, z ) | x, y, z ∈ N and x2 + y 2 = z 2}
{(n) | n ∈ N and n even}
∅ or R = {( )}
18
Some Preliminaries – Continued
I Remember Let D be a set.
D2
Dn
=
=
D×D
D n−1 × D
D1
D0
=
=
D
I Functions
First Order Logic (28th November 2007)
=
=
=:
=:
=
+:
succ :
0:
{(d1, d2) | d1 ∈ D and d2 ∈ D}
{(t, dn) | t ∈ D n−1 and dn ∈ D}
{(d1, . . . , dn) | di ∈ D, 1 ≤ i ≤ n}, n > 2
{(d) | d ∈ D}
{( )}
N2 → N
N1 → N
N0 → N
+(2, 3) 7→ 5
succ(3) 7→ 4
0( ) 7→ 0
19
4.3.1 Interpretations and Models
I Definition 4.18 A predicate logic interpretation I for a predicate logic language
L(R, F , V ) consists of a non-empty set D and a mapping ·I , which satisfies the
following conditions:
1. Every n-ary function symbol g/n ∈ F
is mapped to an n-ary function g I : D n → D .
2. Every n-ary relation symbol p/n ∈ R
is mapped to an n-ary relation pI ⊆ D n.
D is called domain of the interpretation.
First Order Logic (28th November 2007)
20
Variable Assignments
I What is the meaning of a variable?
I Definition 4.19 A variable assignment wrt an interpretation I = (D, ·I )
is a mapping Z : V → D .
The image of a variable X under Z is denoted by X Z .
Let Z be a variable assignment and d ∈ D .
{X 7→ d}Z denotes the variable assignment, where:
Y
First Order Logic (28th November 2007)
{X7→d}Z

=
d
YZ
if Y = X ,
otherwise.
21
Interpretation of Terms
I Definition 4.20 Let I = (D, ·I ) be an interpretation and Z a variable assignment
wrt I . The meaning tI,Z of a term t ∈ T (F , V ) is defined as follows:
1 For every variable X ∈ V we have X I,Z = X Z .
2 For every term of the form g (t1, . . . , tn) we have
[g (t1, . . . , tn)]
I,Z
I
I,Z
= g ( t1
I,Z
, . . . , tn ),
where g/n ∈ F and t1, . . . , tn are terms.
First Order Logic (28th November 2007)
22
Example
I Let F = {h/1, g/2, a/0}.
I D1 = N with successor function s/1 and addition +/2.
I D2 = Z with predecessor function p/1 and subtraction −/2.
I D3 = set of words over Σ = {o, m} with function
. add m/1, which appends m to a word at the right, and function
. conc /2, which concatenates two words.
I1
I2
I3
a
0
1
o
h
s
p
add m
g
+
−
conc
First Order Logic (28th November 2007)
XZ
4
8
omo
g (h(a), h(h(a)))
3
1
omomm
g (h(X ), g (h(a), h(X )))
11
14
omomomomom
23
Interpretation of Formulas
I Definition 4.21 Let I = (D, ·I ) be an interpretation and Z a variable assignment
wrt I . I and Z assign every formula F ∈ L(R, F , V ) a truth value F I,Z as
follows:
I,Z
I
1. [p(t1, . . . , tn)]I,Z = > iff (tI,Z
1 , . . . , tn ) ∈ p .
2. [¬F ]I,Z = ¬∗(F I,Z ).
3. [(F1 ◦ F2)]I,Z = (F1I,Z ◦∗ F2I,Z ) for all binary connectives ◦/2.
4. [(∀X ) F ]I,Z = > iff for all d ∈ D : F I,{X7→d}Z = >.
5. [(∃X ) F ]I,Z = > iff for some d ∈ D : F I,{X7→d}Z = >.
First Order Logic (28th November 2007)
24
Substitutions and Variable Assignments
I Lemma 4.21’ Let s, t be terms, G a formula, Y a variable,
I = (D, ·I ) an interpretation and Z a variable assignment wrt I and d ∈ D .
If [t]I,Z = d, then:
1. [s{Y 7→ t}]I,Z = [s]I,{Y 7→d}Z ,
2. [G{Y 7→ t}]I,Z = [G]I,{Y 7→d}Z if t is free for Y in G.
I Proof induction on the structure of s and G
First Order Logic (28th November 2007)
Exercise.
25
Models
I Proposition 4.21”
0
If F ∈ L(R, F , V ) is closed, then F I,Z = F I,Z for any I , Z and Z 0.
I Proof
Exercise.
. If formulas are closed, then their meaning is independent of a
variable assignment.
I Notation If F is closed, then we write F I instead of F I,Z .
I Definition 4.22
Let I = (D, ·I ) be an interpretation and F ∈ L(R, F , V ) be closed.
I is called model for F , in symbols I |= F , if F I = > holds.
First Order Logic (28th November 2007)
26
Some Remarks
I In the sequel we consider only closed formulas if not mentioned otherwise.
I Many notions and results known from propositional logic can be extended to
predicate logic. For example:
. Validity, satisfiability, falsifiability, unsatisfiability.
. E.g., a closed formula F is valid iff all interpretations are models for F .
. Theorem 3.12 (extended)
A closed formula F is valid iff ¬F is unsatisfiable.
. Theorem 3.15 (extended) Let F, F1, . . . , Fn be closed formulas.
{F1, . . . , Fn} |= F iff |= (hF1, . . . , Fni → F ).
First Order Logic (28th November 2007)
27
Logical Consequence
I Definition 4.23 A closed formula F is a (predicate logic) consequence of a set G
of closed formulas, in symbols G |= F ,
iff every model for G is also a model for F .
First Order Logic (28th November 2007)
28
Propositional vs. First Order Logic
I What is the relation between propositional and first order logic?
I If all relation symbols in R are nullary,
then first order logic is equivalent to propositional logic.
I If no variables are occurring in the formulas,
then first order logic is equivalent to propositional logic.
First Order Logic (28th November 2007)
29
4.3.2 Herbrand-Interpretations
I In the following we assume that F contains at least one constant.
Otherwise we add a symbol a/0 to F .
I Definition 4.24 An interpretation I = (D, ·I ) for a predicate logic language
L(R, F , V ) is a Herbrand-interpretation, if the following conditions are satisfied:
1. D = T (F ); it is called Herbrand-universe.
2. For every t ∈ T (F ) we have tI = t.
I F = {a/0, b/0, h/1, g/2}.
T (F ) = {a, b, h(a), h(b), g (a, a), g (a, b), g (b, a), g (b, b), h(h(a)), . . .}.
First Order Logic (28th November 2007)
30
Herbrand-Interpretations and Formulas
I L({p/1, q/1, r/1}, {g/1, a/0}, V )
I F = ((∀X ) (p(X ) ∨ q (X )) ∧ (∀Y ) r (g (Y )))
I T (F ) = {a, g (a), g (g (a)), . . .}
I1: pI1 = q I1 = r I1 = T (F ).
I2: pI2 = q I2 = r I2 = ∅.
I1 is a model for F .
I2 is not a model for F .
I3: pI3 = {g (g (a)), g (g (g (g (a)))), . . .}, q I3 = {a, g (a)}, r I3 = {g (g (a))}.
I3 is not a model for F .
I Notation
. I1 = {p(a), q (a), r (a), p(g (a)), q (g (a)), r (g (a)), . . .}
. I2 = ∅
. I3 = {p(g (g (a))), p(g (g (g (g (a))))), . . . , q (a), q (g (a)), r (g (g (a)))}
First Order Logic (28th November 2007)
31
4.4 Equivalence and Normal Forms
4.4.1
Semantic Equivalence
4.4.2
Prenex Normal Form
4.4.3
Skolem Normal Form
4.4.4
Clause Form
First Order Logic (28th November 2007)
32
4.4.1 Semantic Equivalence
I In this subsection, formulas need not to be closed.
I Two formulas F and G are called semantically equivalent, in symbols F ≡ G
if F I,Z = GI,Z holds for all interpretations I and all variable assignments Z wrt I .
I Note For closed formulas we find G ≡ F if GI = F I for all interpretations I .
I Theorem 3.17 (propositional semantic equivalences) holds also for
first-order formulas.
First Order Logic (28th November 2007)
33
Some Semantic Equivalences
I Theorem 4.25 Let F and G be formulas.
The following equivalences hold:
¬(∀X ) F
¬(∃X ) F
≡
≡
(∃X ) ¬F
(∀X ) ¬F
((∀X ) F ∧ (∀X ) G)
((∃X ) F ∨ (∃X ) G)
≡
≡
(∀X ) (F ∧ G)
(∃X ) (F ∨ G)
(∀X ) (∀Y ) F
(∃X ) (∃Y ) F
≡
≡
(∀Y ) (∀X ) F
(∃Y ) (∃X ) F
≡
≡
≡
≡
(∀X ) (F
(∀X ) (F
(∃X ) (F
(∃X ) (F
((∀X ) F
((∀X ) F
((∃X ) F
((∃X ) F
∧ G)
∨ G)
∧ G)
∨ G)
First Order Logic (28th November 2007)
∧ G),
∨ G),
∧ G),
∨ G),
if X
if X
if X
if X
does not occur free in G.
does not occur free in G.
does not occur free in G.
does not occur free in G.
34
Proof for ¬(∀X) F ≡ (∃X) ¬F
I Let I = (D, ·I ) be an interpretation and Z a variable assignment wrt I . We find:
[¬(∀X ) F ]I,Z = >
iff
iff
iff
iff
iff
iff
¬∗[(∀X ) F ]I,Z = >
[(∀X ) F ]I,Z = ⊥
F I,{X7→d}Z = > does not hold for all d ∈ D
F I,{X7→d}Z = ⊥ holds for some d ∈ D
¬∗F I,{X7→d}Z = > holds for some d ∈ D
[(∃X ) ¬F ]I,Z = >.
qed
First Order Logic (28th November 2007)
35
Standardizing Apart
I Replacement Theorem 3.18 holds also for predicate logic formulas.
I Definition 4.26 The variables occurring in a formula F are standardized apart, if
no two quantifiers occurring in F bind the same variable, and no variable occurs
both free and bound.
I Proposition 4.27 For every formula, there is a semantically equivalent formula
where the variables are standardized apart.
I Auxiliary Proposition Let Q be a quantifier, F a formula of the form (QX ) G, and
Y a variable not occurring in F . Then F ≡ (QY ) G{X 7→ Y } holds.
I Proof
Exercise.
First Order Logic (28th November 2007)
36
Proof Sketch of Proposition 4.27
I Proof
. Let F be a predicate logic formula.
. We find only finitely many, say n, occurrences of subformulas of the form
(QX )G in F .
. We prove by induction on n that each of these occurrences can be replaced
according to the auxiliary proposition.
. Let G be the formula obtained from F in this way.
. The variables occurring in G are standardized apart.
qed
I Agreement From now on we assume wlog that variables are standardized apart.
First Order Logic (28th November 2007)
37
4.4.2 Prenex Normal Form
I Definition 4.28 A formula F is in prenex normal form, if it is of the form
(Q1X1) . . . (QnXn) G, where Qi ∈ {∀, ∃} and n ≥ 0 holds, X1, . . . , Xn
are variables, and G itself does not contain any further quantifier.
G is called matrix of F .
I Proposition 4.29 There is an algorithm which transforms each sentence F into a
semantically equivalent sentence F 0 in prenex normal form.
First Order Logic (28th November 2007)
38
An Algorithm for Transformation into Prenex Normal form
I While F is not in prenex normal form apply one of the following rules:
¬(∀X ) G
(∃X ) ¬G
((QX ) G ∧ H )
(QX ) (G ∧ H )
(G ∧ (QX ) H )
(QX ) (G ∧ H )
¬(∃X ) G
(∀X ) ¬G
((QX ) G ∨ H )
(QX ) (G ∨ H )
(G ∨ (QX ) H )
(QX ) (G ∨ H )
I Example
(¬(∃X ) (∀Y ) p(X, Y ) ∧ (∀Z ) q (Z ))
≡ ((∀X ) ¬(∀Y ) p(X, Y ) ∧ (∀Z ) q (Z ))
≡ ((∀X ) (∃Y ) ¬p(X, Y ) ∧ (∀Z ) q (Z ))
≡ (∀X ) ((∃Y ) ¬p(X, Y ) ∧ (∀Z ) q (Z ))
≡ (∀X ) (∃Y ) (¬p(X, Y ) ∧ (∀Z ) q (Z ))
≡ (∀X ) (∃Y ) (∀Z )(¬p(X, Y ) ∧ q (Z )).
I Soundness and termination
First Order Logic (28th November 2007)
Exercise.
39
4.4.3 Skolem Normal Form
I Idea We eliminate all existential quantifiers.
I Definition 4.30 Let L(R, F , V ) be a predicate logic language.
Let FS be a countable set of function symbols such that FS ∩ F = ∅ and FS
contains countably many function symbols for each arity. The elements of FS are
called Skolem function symbols. Nullary Skolem function symbols are also called
Skolem constant symbols.
I We now consider L(R, F ∪ FS , V ).
I Definition 4.31 A formula is in Skolem normal form if it is of the form
(∀X1) . . . (∀Xn) G, where n ≥ 0 holds, X1, . . . , Xn are variables, and G itself does not contain any further quantifier.
First Order Logic (28th November 2007)
40
Transformation into Skolem Normal Form
I Let F be a formula in prenex normal form (variables are standardized apart).
I While F is not in Skolem normal form apply the following rule:
(∀X1) . . . (∀Xn) (∃Y ) G
(∀X1) . . . (∀Xn) (G{Y 7→ g (X1, . . . , Xn)})
I Theorem 4.32 If G is a Skolem normal form of the sentence F ,
then F is satisfiable iff G is satisfiable.
I The transformation into Skolem normal form preserves satisfiability.
I Alternatively we could have eliminated the universal quantifiers:
. dual Skolem Normal Form,
. validity preserving.
First Order Logic (28th November 2007)
41
Proof Sketch of Theorem 4.32
I Suppose F is in prenex normal form and variables are standardized apart.
I Auxiliary Proposition Let F be a formula in prenex normal form, where the variables are standardized apart, and F 0 be the formula obtained from F by a single
application of the replacement rule. Then the following holds: F is satisfiable iff
F 0 is satisfiable.
Proof of Auxiliary Proposition
Exercise.
I Let E be the proposition: F 0 is a formula in prenex normal form, where all variables are standardized apart, and is satisfiable iff F is satisfiable.
I With F = F 0 proposition E holds before entering the while-loop.
I From the Auxiliary Proposition we learn that E is a loop invariant.
I From Theorem 3.25 we learn that E holds after the loop has been left.
I The loop is left only if F 0 is in Skolem normal form.
First Order Logic (28th November 2007)
qed
42
4.4.4 Clause Form
I Let F be a sentence and H a Skolem normal form of F .
I F is satisfiable iff H is satisfiable.
I H is of the form ∀G = (∀X1) . . . (∀Xn) G,
where X1, . . . , Xn are all the variables occurring in F .
I There are no quantifiers occurring in the matrix G.
I Every variable occurring in H is universally quantified.
I We can transform G into clause form.
I Let G0 be a formula in clause form which is semantically equivalent to G.
. F is satisfiable iff ∀G0 is satisfiable.
. F is unsatisfiable iff ∀G0 is unsatisfiable.
First Order Logic (28th November 2007)
43
Example: Proving Mathematical Theorems by Machines
I Theorem: Let G be a group with · as binary operator in infix notation and e as
identity element. If, for all elements X of G, the property X · X = e holds, then
G is a commutative group.
I A group G satisfies the following axioms:
A1
If X, Y ∈ G, then also X · Y ∈ G.
A2
For all X, Y, Z ∈ G holds (X · (Y · Z )) = ((X · Y ) · Z ).
A3
For all X ∈ G holds X · e = e · X = X .
A4
For every X ∈ G there exists a unique (inverse) element X −1 ∈ G with
property X · X −1 = X −1 · X = e.
I We represent X · Y = Z by p(X, Y, Z ) and X −1 by f (X ).
First Order Logic (28th November 2007)
44
Proving Mathematical Theorems by Machines (continued)
I The group axioms can be represented as follows:
A01
(∀X1)(∀Y1)(∃Z1) p(X1, Y1, Z1)
A02
((∀X2)(∀Y2)(∀Z2)(∀U2)(∀V2)(∀W2)
h(p(X2, Y2, U2), p(Y2, Z2, V2), p(U2, Z2, W2)i → p(X2, V2, W2))
∧
(∀X3)(∀Y3)(∀Z3)(∀U3)(∀V3)(∀W3)
(hp(X3, Y3, U3), p(Y3, Z3, V3), p(X3, V3, W3)i → p(U3, Z3, W3)))
A03
((∀X4) p(X4, e, X4) ∧ (∀X5) p(e, X5, X5))
A04
((∀X6) p(X6, f (X6), e) ∧ (∀X7) p(f (X7), X7, e))
First Order Logic (28th November 2007)
45
Proving Mathematical Theorems by Machines (continued)
I The conclusion of the theorem can be represented as follows:
C0
((∀X8) p(X8, X8, e)
→ ((∀U9)(∀V9)(∀W9) (p(U9, V9, W9) → p(V9, U9, W9))))
I Hence, the theorem is represented by the formula:
0
0
0
0
0
F = (hA1, A2, A3, A4i → C )
I The theorem is proven if F is valid, or, equivalently, if
0
0
0
0
0
¬F = hA1, A2, A3, A4, ¬C i
is unsatisfiable.
First Order Logic (28th November 2007)
46
Proving Mathematical Theorems by Machines (continued)
I As clause form of ¬F we obtain:
∀h
[p(X1, Y1, g (X1,Y1))],
[¬p(X2, Y2, U2), ¬p(Y2, Z2, V2), ¬p(U2, Z2, W2), p(X2, V2, W2)],
[¬p(X3, Y3, U3), ¬p(Y3, Z3, V3), ¬p(X3, V3, W3), p(U3, Z3, W3)],
[p(X4, e, X4)],
[p(e, X5, X5)],
[p(X6, f (X6), e],
[p(f (X7), X7, e)],
[p(X8, X8, e)],
[p(a, b, c)],
[¬p(b, a, c)]
i.
I How can we show unsatisfiablity of a predicate logic formula?
First Order Logic (28th November 2007)
47
4.5 Unification
I We consider terms from T (F , V ).
I Definition 4.33 An equation is an expression of the form s ≈ t,
where s and t are terms.
I Definition 4.34 A unification problem consists of a multiset of equations
˙ 1 ≈ t1, . . . , sn ≈ tn}˙
{s
and is the question, whether there exists a substitution σ such that siσ = tiσ
holds for all 1 ≤ i ≤ n.
If such a substitution σ exists, then the terms si and ti, 1 ≤ i ≤ n, are said to be
simultaneously unifiable and σ is said to be a unifier for the unification problem.
First Order Logic (28th November 2007)
48
Example
˙
I {X
≈ a, Y ≈ Z, g (W, X ) ≈ g (W, a)}˙
I Unifiers:
. σ1 = {X 7→ a, Y 7→ Z}
. σ2 = {X 7→ a, Z 7→ Y }
. σ3 = {X 7→ a, Y 7→ a, Z 7→ a}
. σ4 = {X 7→ a, Y 7→ g (a, U ), Z 7→ g (a, U ), W 7→ a}
I Do you prefer unifiers over other unifiers?
First Order Logic (28th November 2007)
49
Most General Unifiers
I Definition 4.35 Let σ and θ be substitutions. σ is more general than θ , in symbols
σ ≥ θ , if there is a substitution λ such that σλ = θ holds.
I Definition 4.36 Two substitutions σ and θ are said to be variants, in symbols
σ ∼ θ , if σ ≥ θ and θ ≥ σ hold.
I Definition 4.37 Let U be a unification problem.
A substitution σ is a most general unifier for U , if σ is a unifier for U and σ ≥ θ
holds for every unifier θ for U .
I Theorem 4.38 (Unification Theorem) Let U be a solvable unification problem.
There exists a most general unifier for U .
I Proof
(i) Specification of a unification algorithm.
(ii) Proof of Termination
(iii) Proof of Soundness.
First Order Logic (28th November 2007)
see lecture Foundations of LP.
see lecture Foundations of LP.
50
Unification Algorithm
Input A unification problem U .
Output A most general unifier θ for U , if U is solvable,
or not unifiable, otherwise.
θ := ε.
While U is non-empty do:
Select an equation s ≈ t from U .
˙ ≈ t}˙ .
U := U \˙ {s
Apply one of the following rules:
(1) If s ≈ t is of the form X ≈ r or r ≈ X and variable X does not
occur in the term r , then θ := θ{X 7→ r} and U := U {X 7→ r}.
(2) If s ≈ t is of the form X ≈ X , then do nothing.
(3) If s ≈ t is of the form X ≈ r or r ≈ X , variable X occurs in the term r
and r 6= X holds, then terminate with not unifiable.
(4) If s ≈ t is of the form f (s1, . . . , sn) ≈ f (t1, . . . , tn),
then add the equations s1 ≈ t1, . . . , sn ≈ tn to U .
(5) If s ≈ t is of the form f (s1, . . . , sn) ≈ g (t1, . . . , tm) where f 6= g ,
then terminate with not unifiable.
First Order Logic (28th November 2007)
51
4.6 Proof Methods
I Resolution
I Semantic Tableaus
I Calculus of Natural Deduction
I Hilbert Systems
I Sequent Calculus
I Connection Method
First Order Logic (28th November 2007)
52
4.6.1 Resolution
I It is a negative and analyzing calculus.
. The alphabet is the alphabet of predicate logic.
. The language is the set of predicate logic formulas in clause form.
. The only axiom is the empty clause.
. The derivation rules are the resolution and the factorization rule.
First Order Logic (28th November 2007)
53
The Resolution Rule
I Definition 4.42 Let
C1 = [p(s1, . . . , sk ), L1, . . . , Lm]
and
C2 = [¬p(t1, . . . , tk ), Lm+1, . . . , Ln]
be clauses, where k, m, n ≥ 0.
˙ i ≈ ti | 1 ≤ i ≤ k}˙ is unifiable with mgu σ then
If {s
C = [L1, . . . , Ln]σ
is called resolvent of C1 and C2 wrt p(s1, . . . , sk ) and ¬p(t1, . . . , tk ).
C has been obtained by applying the resolution rule to C1 and C2,
where p(s1, . . . , sk ) and ¬p(t1, . . . , tk ) are said to be the literals resolved upon.
First Order Logic (28th November 2007)
54
The Factoring Rule
I Definition 4.43 Let
C = [p(s1, . . . , sk ), p(t1, . . . , tk ), L1, . . . , Lm]
or
C = [¬p(s1, . . . , sk ), ¬p(t1, . . . , tk ), L1, . . . , Lm]
be clauses, where k, m ≥ 0.
˙ i ≈ ti | 1 ≤ i ≤ k}˙ is unifiable with mgu σ then
If {s
0
C = [p(t1, . . . , tk ), L1, . . . , Lm]σ
and
0
C = [¬p(t1, . . . , tk ), L1, . . . , Lm]σ,
are factors of C , respectively.
C 0 has been obtained by applying the factoring rule to C .
First Order Logic (28th November 2007)
55
Resolution Derivations and Refutations
I Definition 4.44 Let F = ∀ hC1, . . . , Cni be a sentence in clause form, where Ci,
1 ≤ i ≤ n, are clauses.
1 The sequence (Ci | 1 ≤ i ≤ n) is a resolution derivation for C .
2 If (Ci | 1 ≤ i ≤ m) is a resolution derivation for F , and Cm+1 is obtained
by applying the resolution or the factoring rule to new variants of elements
from (Ci | 1 ≤ i ≤ m), then (Ci | 1 ≤ i ≤ m + 1) is a resolution
derivation for F .
3. A resolution derivation for F which contains the empty clause [ ] is called
resolution refutation for F .
I Note
. A resolvent can be computed from two variants of one clause.
. F may contain already [ ].
. It suffices to consider refutations in which [ ] occurs only once.
. We may assume that [ ] is the last clause in a refutation.
First Order Logic (28th November 2007)
56
Example
I Is the following formula unsatisfiable?
¬((p(0) ∧ (∀X )(p(X ) → p(h(X )))) → p(h(h(h(h(0))))))
I Clause form:
(∀X ) h[p(0)], [¬p(X ), p(h(X ))], [¬p(h(h(h(h(0)))))]i.
I Resolution refutation of the matrix:
1
2
3
4
5
6
7
[p(0)]
[¬p(X ), p(h(X ))]
[¬p(h(h(h(h(0)))))]
[¬p(X1), p(h(h(X1)))]
[¬p(X3), p(h(h(h(h(X3)))))]
[p(h(h(h(h(0)))))]
[]
First Order Logic (28th November 2007)
res(2,2)
res(4,4)
res(1,5)
res(3,6)
57
Another Example
I “The barber shaves all male inhabitants, who do not shave themselves.”
(∀X )(¬p(X, X ) ↔ p(b, X ))
I Clause form:
(∀X )(∀Y ) h[p(X, X ), p(b, X )], [¬p(b, Y ), ¬p(Y, Y )]i.
I Resolution refutation of the matrix:
1
2
3
4
5
First Order Logic (28th November 2007)
[p(X, X ), p(b, X )]
[¬p(b, Y ), ¬p(Y, Y )]
[p(b, b)]
[¬p(b, b)]
[]
fac(1)
fac(2)
res(3,4)
58
Resolution Proof
I Definition 4.43” Let F = ∀ hC1, . . . , Cni be a predicate logic formula in clause
form and S = (Ci | 1 ≤ i ≤ m) a resolution derivation for F . The length of S
is m − n.
I Definition 4.44 Let F be a sentence and G a clause form of ¬F .
A resolution proof for F is a resolution refutation for G.
F is called theorem of the resolution calculus,
if there exists a resolution proof for F .
We denote with `r F that there exists a resolution proof for F .
First Order Logic (28th November 2007)
59
Proving Mathematical Theorems by Machines (continued)
1
2
3
4
5
6
7
8
9
10
11
13
14
40
43
67
3239
3325
3627
4630
5199
5800
518609
645778
646029
[p(X1 , Y1 , g (X1 , Y2 ))]
[¬p(X2 , Y2 , U2 ), ¬p(Y2 , Z2 , V2 ), ¬p(U2 , Z2 , W2 ), p(X2 , V2 , W2 )]
[¬p(X3 , Y3 , U3 ), ¬p(Y3 , Z3 , V3 ), ¬p(X3 , V3 , W3 ), p(U3 , Z3 , W3 )]
[p(X4 , e, X4 )]
[p(e, X5 , X5 )]
[p(X6 , f (X6 ), e)]
[p(f (X7 ), X7 , e)]
[p(X8 , X8 , e)]
[p(a, b, c)]
[¬p(b, a, c)]
[p(X9 , V2 , e), ¬p(Y9 , U9 , V9 ), ¬p(X2 , Y2 , U2 )]
[p(X10 , V10 , W10 ), ¬p(e, Z10 , W10 ), ¬p(X10 , Z10 , V10 )]
[p(X11 , V11 , U11 ), ¬p(Y11 , e, V11 ), ¬p(X11 , Y11 , U11 )]
[p(X12 , e, W12 ), ¬p(e, X12 , W12 )]
[p(X13 , V13 , Z13 ), ¬p(X13 , Z13 , V13 )]
[p(X14 , g (X14 , Z14 ), Z14 )]
[p(e, V15 , Y15 ), ¬p(Y15 , e, V15 )]
[¬p(Y16 , e, a), ¬p(b, Y16 , c)]
[¬p(g (b, c), e, a)]
[p(e, Z17 , X17 ), ¬p(X17 , Z17 , e)]
[p(Z18 , e, X18 ), ¬p(X18 , Z18 , e)]
[¬p(a, g (b, c), e)]
[p(a, V19 , e), ¬p(b, c, V19 )]
[p(a, g (b, c), e)]
[]
First Order Logic (28th November 2007)
res(2, 8)
res(2, 8)
res(2, 4)
res(13, 8)
res(13, 5)
res(43, 1)
res(14, 5)
res(10, 14)
res(3325, 67)
res(3239, 43)
res(40, 4630)
res(3627, 5199)
res(11, 9)
res(518609, 1)
res(645778, 5800)
60
4.8 Properties
4.8.1
Herbrand interpretations
. For each interpretation there is a corresponding Herbrand interpretation.
4.8.2
Soundness and completeness theorem
. |= F iff `r F .
4.8.3
Compactness theorem
. F is satisfiable iff each finite subset of F is satisfiable.
4.8.4
Undecidability theorem
. The question whether F |= G is undecidable in first-order logic.
First Order Logic (28th November 2007)
61
Completeness of the Resolution Method – Overview
{F1 , . . . , Fn } |= F
m
Theorem 3.15 (extended)
(hF1 , . . . , Fn i → F ) is valid
m
Theorem 3.12 (extended)
¬(hF1 , . . . , Fn i → F ) is unsatisfiable
⇓
Theorem 4.32
G is unsatisfiable, where G is a clause form of ¬(hF1 , . . . , Fn i → F )
m
Theorem 4.55
{Cσ | C is clause in G and σ is ground substitution for C} is unsatisfiable
m
Bijection ground atoms – propositional variables
H is unsatisfiable, where H is the set of propositional clauses corresponding to {Cσ | . . .}
⇓
Corollary 3.40
0
finite subset H ⊆ H is unsatisfiable
⇓
Theorem 3.42
0
there is a propositional resolution refutation for H
m
Bijection ground atoms – propositional variables
there is a first-order resolution refutation for H 0
⇓
Lemma 4.58
there is a first-order resolution refutation for G
m
Definition 4.44
there is a first-order resolution proof for (hF1 , . . . , Fn i → F )
First Order Logic (28th November 2007)
62
4.8.1 Herbrand Interpretations
I F = {a/0, f /1} and R = {p/1, q/1, r/1}.
I G = (∀X )(∀Y )h[p(X ), q (X )], [r (f (Y ))]i
I Herbrand universe: T (F ) = {a, f (a), f (f (a)) . . .}.
I Herbrand interpretations, e.g.:
. I1 = {p(a), q (a), r (f (a)), p(f (a)), q (f (a)), r (f (f (a))), . . .}
. I 2 = ∅.
I Different interpretations, e.g.: I3 = (D, ·I3 ) where
. D = {0, 1},
. a 7→ 0,
. f /1 7→ f ∗/1 : D → D with f ∗(0) = 1 and f ∗(1) = 0,
. pI = {0}, q I = {0}, r I = {0}.
I We can construct a corresponding Herbrand interpretation!
First Order Logic (28th November 2007)
63
Corresponding Herbrand Interpretations
I Definition 4.51 Let I = (D, ·I ) be an interpretation and {t1, . . . , tn} ⊆ T (F ).
A Herbrand interpretation J is called corresponding to I if the following condition
is satisfied: for all relation symbols p/n holds:
I
p(t1, . . . , tn) = > iff p(t1, . . . , tn) ∈ J.
First Order Logic (28th November 2007)
64
Example
I Consider again I3 = (D, ·I3 ) with
. D = {0, 1},
. a 7→ 0,
. f /1 7→ f ∗/1 : D → D mit f ∗(0) = 1 and f ∗(1) = 0,
. pI = {0}, q I = {0}, r I = {0}.
I Set of ground atoms:
{p(a), q (a), r (a), r (f (a)), p(f (a)), q (f (a)), r (f (f (a))), . . .}
I Meaning under I3:
p(a)
>
q (a)
>
r ( a)
>
r (f (a))
⊥
p(f (a))
⊥
q (f (a))
⊥
r (f (f (a)))
>
...
...
I Corresponding Herbrand interpretation:
J3 = {p(a), q (a), r (a), p(f (f (a))), . . .}
First Order Logic (28th November 2007)
65
Interpretation vs. Herbrand Interpretation
I Lemma 4.52 If an interpretation I is a model for a predicate logic sentence F
in Skolem normal form, then every Herbrand interpretation corresponding to I is
also a model for F .
I Proof
Exercise.
I Implication The real numbers cannot be characterized within predicate logic.
. Suppose, the real numbers can be characterized.
. Then there exists a sentence F such that for all I = (D, ·I ) we find:
F I = > iff D is uncountable.
. Select I with F I = >.
. Let J be the Herbrand interpretation corresponding to I .
. Then F J = >.
. But the domain of Herbrand interpretations is countable.
. Contradiction
First Order Logic (28th November 2007)
qed
66
Interpretations vs. Herbrand Interpretations (continued)
I Theorem 4.53 A predicate logic sentence F in Skolem normal form is unsatisfiable
iff F is mapped to ⊥ under each Herbrand interpretation.
I Proof
⇒ immediate.
⇐ Suppose, F is mapped to ⊥ under each Herbrand interpretation,
but is satisfiable.
. Then there exists an I with F I = >.
. Let J be the Herbrand interpretation corresponding to I .
. By Lemma 4.52 we find F J = >.
. Contradiction
First Order Logic (28th November 2007)
qed
67
Interpretations vs. Herbrand Interpretations (cont.)
I Lemma 4.52 and Theorem 4.53 hold only for formulas in Skolem normal form.
I Example Let F = {a/0}, R = {p/1} and X ∈ V .
Consider F = (p(a) ∧ (∃X )¬p(X )).
. Let I = ({1, 2}, ·I ) with aI = 1 and pI = {1}. Then,
(p(a) ∧ (∃X )¬p(X ))I
=
=
=
=
=
=
p(a)I ∧∗ ((∃X )¬p(X ))I
aI ∈ pI ∧∗ ((∃X )¬p(X ))I
1 ∈ {1} ∧∗ ((∃X )¬p(X ))I
> ∧∗ ((∃X )¬p(X ))I
((∃X )¬p(X ))I
> because 2 6∈ {1}
. T (F ) = {a}
. I 0 = {p(a)} is the Herbrand interpretation corresponding to I .
. F
I0
=⊥
Lemma 4.52 does not carry over.
. For I 00 = ∅ we find F I
First Order Logic (28th November 2007)
00
=⊥
Theorem 4.53 does not carry over.
68
Further Properties
I Proposition 4.54 Let F be a predicate logic formula, I a Herbrand interpretation,
Z a variable assignment wrt I , and t1, . . . , tn ∈ T (F ). Then,
F
I Proof
I,{X1 7→t1 }...{Xn 7→tn }Z
= [F {X1 7→ t1, . . . , Xn 7→ tn}]
I,Z
.
Exercise.
First Order Logic (28th November 2007)
69
Further Properties (continued)
I Theorem 4.55 Let F = ∀ hC1, . . . , Cni be a sentence in clause form. F is
satisfiable iff {Ciσ | 1 ≤ i ≤ n, σ is a ground substitution for Ci} is satisfiable.
I Proof Let X1, . . . , Xk be all variables occurring in hC1, . . . , Cni.
. F is satisfiable iff there exists a Herbrand model for F (Lemma 4.52).
. I |= F
iff
iff
iff
iff
iff
[hC1, . . . , Cni]I,{X17→t1}...{Xk 7→tk }Z = >
for all t1, . . . , tk ∈ T (F ) and arbitrary Z
[hC1, . . . , Cni{X1 7→ t1, . . . , Xk 7→ tk }]I = >
for all t1, . . . , tk ∈ T (F ) (Proposition 4.54)
[hC1, . . . , Cniσ ]I = >
for all ground substitutions σ for hC1, . . . , Cni
[ Ci σ ] I = >
for 1 ≤ i ≤ n and all ground substitutions σ for Ci
I |= {Ciσ | 1 ≤ i ≤ n, σ ground substitution for Ci}.
qed
First Order Logic (28th November 2007)
70
Example
I Let F = {a/0, s/1}, R = {p/1, q/1} and X, Y ∈ V .
I Consider:
F
=
=
∀ hC1, C2i
(∀X )(∀Y ) h[p(X )], [¬q (s(Y ))]i.
I We obtain:
G
=
=
{Ciσ | 1 ≤ i ≤ 2, σ ground substitution for Ci}
{[p(a)], [p(s(a))], . . .} ∪ {[¬q (s(a))], [¬q (s(s(a)))], . . .}
I Obviously:
I |= F iff I |= G.
First Order Logic (28th November 2007)
71
4.8.2 Soundness and Completeness Theorems
I First Order Resolution Lemma 4.56
Let F = ∀hC1, . . . , Cni be a first order sentence in clause form with clauses Ci,
1 ≤ i ≤ n, and let C be a resolvent or a factor of new variants of clauses from
F . Then F ≡ ∀ hC1, . . . , Cn, Ci.
I Proof Observe: ∀ hC1, . . . , Cn, Ci ≡ (F ∧ ∀ C ).
To show: for all I : I |= F iff I |= (F ∧ ∀ C ).
⇐ If I |= (F ∧ ∀ C ) then I |= F for all I .
⇒ Suppose, I |= F .
1st C is a factor
Exercise.
2nd Let C = [L1, . . . , Ln]σ resolvent of
C0
C 00
=
=
[p(s1, . . . , sk ), L1, . . . , Lm] and
[¬p(t1, . . . , tk ), Lm+1, . . . , Ln],
where C 0 and C 00 are new variants of clauses from F
˙ i ≈ ti | 1 ≤ i ≤ k}˙ .
and σ is a mgu for {s
First Order Logic (28th November 2007)
72
Proof of Lemma 4.56 (continued)
I Suppose, I is not a model for ∀C .
I Then we find a variable assignment Z wrt. I with
[L1 σ ]
I,Z
∗
∗
∨ . . . ∨ [Ln σ ]
I,Z
= ⊥.
(1)
I Because I |= F we find: I |= ∀ (C 0σ ) and I |= ∀ (C 00σ ).
I Hence:
[p(s1, . . . , sk )σ ]
I,Z
∗
∨ [L1 σ ]
I,Z
∗
∗
∨ . . . ∨ [Lm σ ]
I,Z
=>
(2)
and
[¬p(t1, . . . , tk )σ ]
I,Z
∗
∨ [Lm+1σ ]
I,Z
∗
∗
∨ . . . ∨ [Ln σ ]
I,Z
=>
(3)
I Because of (1) and (2) we conclude: [p(s1, . . . , sk )σ ]I,Z = >.
I Because of (1) and (3) we conclude: [¬p(t1, . . . , tk )σ ]I,Z = >.
I Contradiction, because siσ = tiσ for all 1 ≤ i ≤ k.
First Order Logic (28th November 2007)
qed
73
Example
I Consider the sentence:
((∀X )p(X ) ∧ (∀Y ) (p(Y ) → q (Y ))).
I It’s clause form is:
(∀X )(∀Y ) h[p(X )], [¬p(Y ), q (Y )]i.
I As a resolvent of new variants of the two clauses we obtain:
[q (Z )].
I We find:
∀ h[p(X )], [¬p(Y ), q (Y )]i ≡ ∀ h[p(X )], [¬p(Y ), q (Y )], [q (Z )]i.
First Order Logic (28th November 2007)
74
Generalized Resolution Lemma
I Lemma 4.56’ Let F = ∀ hC1, . . . , Cni be a predicate logic sentence in clauseform and (Ci | 1 ≤ i ≤ m) a resolution derivation for F . Then:
F ≡ ∀ hC1, . . . , Cmi.
I Proof
Structural induction on the length k = m − n of the resolution derivation.
IB k = 0: immediate because n = m.
IH Suppose the proposition holds for k.
IS Let (Ci | 1 ≤ i ≤ m + 1) be a resolution derivation of length k + 1.
II From IH we conclude: F ≡ ∀ hC1, . . . , Cmi.
II From Lemma 4.56 we conclude:
∀ hC1, . . . , Cmi ≡ ∀ hC1, . . . , Cm, Cm+1i.
II Because ≡ is transitive, we conclude F ≡ ∀ hC1, . . . , Cm+1i.
. The proposition follows by an application of the induction theorem.
qed
First Order Logic (28th November 2007)
75
Lifting-Lemma 1
I Lemma 4.57 (Lifting-Lemma 1) Let C1 and C2 be clauses
and σ a ground substitution for C1 and C2.
(i) If C is a resolvent of C1σ and C2σ , then there exists a resolvent C 0 of C1
and C2 as well as a substitution λ, such that C 0λ = C holds.
(ii) If C is a factor of C1σ , then there exists a factor C 0 of C1 as well as a
substitution λ, such that C 0λ = C holds.
First Order Logic (28th November 2007)
76
Proof of Lifting-Lemma 1
I Proof
(i) C1 = [p(s1, . . . , sk ), L1, . . . , Lm], C2 = [¬p(t1, . . . , tk ), Lm+1, . . . , Ln].
. siσ = tiσ for 1 ≤ i ≤ k,
because σ is a ground substitution for C1 and C2.
. C = [L 1 , . . . , L n ] σ .
˙ 1 ≈ t1, . . . , sk ≈ tk }˙ .
. σ is a unifier for U = {s
. We find an mgu θ for U and λ, such that: θλ = σ (Theorem 4.38).
. C 0 = [L1, . . . , Ln]θ is resolvent for C1 and C2.
. C 0λ = [L1, . . . , Ln]θλ = [L1, . . . , Ln]σ = C .
I (ii) Exercise
First Order Logic (28th November 2007)
qed
77
Example
I Consider:
C1 = [¬p(W )], C2 = [p(f (X )), ¬q (X )], σ = {X 7→ a, W 7→ f (a)}.
I Then:
C1σ = [¬p(f (a))], C2σ = [p(f (a)), ¬q (a)].
I As resolvent of C1σ and C2σ we obtain:
C = [¬q (a)]
I As resolvent of C1 and C2 with mgu θ = {W 7→ f (X )} we obtain
0
C = [¬q (X )]
I With λ = {X 7→ a} we find C 0λ = C and θλ = σ .
First Order Logic (28th November 2007)
78
Lifting Lemma 2
I Lemma 4.58 (Lifting Lemma 2)
Let Cj be clauses and σj ground substitutions for Cj , 1 ≤ j ≤ n. If there is a
resolution derivation (Bi | 1 ≤ i ≤ m) for hC1σ1, . . . , Cnσni, then there is
a resolution derivation (Bi0 | 1 ≤ i ≤ m) for ∀ hC1, . . . , Cni and a sequence
(λi | 1 ≤ i ≤ m) of substitutions such that Bi0 λi = Bi for all 1 ≤ i ≤ m.
I Proof Induction on the length l = m − n of the derivation (Bi | 1 ≤ i ≤ m).
IB l = 0: In this case n = m and the proposition follows with Bi0 = Ci and
λi = σi for all 1 ≤ i ≤ n.
IH Suppose the proposition holds for l.
IS Let (Bi | 1 ≤ i ≤ m + 1) be a resolution derivation of length l + 1.
Because of IH we find a resolution derivation (Bi0 | 1 ≤ i ≤ m) of length
l for ∀ hC1, . . . , Cni and a sequence (λi | 1 ≤ i ≤ m) of substitutions
(∗)
with Bi0 λi = Bi for all 1 ≤ i ≤ m.
1st Bm+1 is a factor
2nd Bm+1 is a resolvent
First Order Logic (28th November 2007)
Exercise
next slide
79
Proof Lifting Lemma 2 (Cont.)
I Let Bm+1 be the resolvent of Bj and Bk with j, k ≤ m.
I Because of (∗) we find Bj0 and λj with Bj0 λj = Bj .
I Let Bj00 be a new variant of Bj0 . Then there is a substitution θj with Bj00θj = Bj0 .
I Alltogether: Bj = Bj0 λj = (Bj00θj )λj = Bj00(θj λj ).
I Analogously we find Bk00, λk and θk with Bk = Bk0 λk = (Bk00θk )λk = Bk00(θk λk ).
I Because Bj00 and Bk00 are new variants, we conclude:
dom((θj λj )|V ar(B 00)) ∩ dom((θk λk )|V ar(B 00)) = ∅.
j
k
I Let σ = (θj λj )|V ar(B 00) ∪ (θk λk )|V ar(B 00).
j
k
I Hence we obtain: Bj00σ = Bj and Bk00σ = Bk .
0
00
00
I Because of Lifting Lemma 1 we find a resolvent Bm
+1 of Bj and Bk as well as a
0
substitution λm+1 with Bm
+1 λm+1 = Bm+1 .
I Together with (∗) we obtain a resolution derivation (Bi | 1 ≤ i ≤ m + 1) and a
sequence (λi | 1 ≤ i ≤ m + 1) with Bi0 λi = Bi for all 1 ≤ i ≤ m + 1.
I An application of the induction theorem yields the desired result.
First Order Logic (28th November 2007)
qed
80
Example 1
I Consider the clauses
[¬p(W )], [p(f (X )), ¬q (X )], [q (g (Y )), ¬r (Y )], [r (Z )]
with
σ = {W 7→ f (g (a)), X 7→ g (a), Y 7→ a, Z 7→ a}.
I We obtain the following derivations:
B1
B2
B3
B4
B5
B6
B7
[¬p(f (g (a)))]
[p(f (g (a))), ¬q (g (a))]
[q (g (a)), ¬r (a)]
[r (a)]
[¬q (g (a))]
[¬r (a)]
[]
First Order Logic (28th November 2007)
B10
B20
B30
B40
B50
B60
B70
[¬p(W )]
[p(f (X )), ¬q (X )]
[q (g (Y )), ¬r (Y )]
[r (Z )]
[¬q (X2)]
[¬r (Y3)]
[]
res(1,2)
res(3,5)
res(4,6)
81
Example 2
I Consider the clauses
[p(a)], [¬p(X ), p(f (X ))], [¬p(Y ), p(f (Y ))], [¬p(f (f (a)))]
with
σ = {X 7→ a, Y 7→ f (a)}.
I We obtain the derivations:
B1
B2
B3
B4
B5
B6
B7
[p(a)]
[¬p(a), p(f (a))]
[¬p(f (a)), p(f (f (a)))]
[¬p(f (f (a)))]
[¬p(a), p(f (f (a)))]
[p(f (f (a)))]
[]
First Order Logic (28th November 2007)
B10
B20
B30
B40
B50
B60
B70
[p(a)]
[¬p(X ), p(f (X ))]
[¬p(Y ), p(f (Y ))]
[¬p(f (f (a)))]
[¬p(X1), p(f (f (X1)))]
[p(f (f (a)))]
[]
res(2,3)
res(1,5)
res(4,6)
82
Closed Formulas and Propostional Logic
I Let F be a generalized conjunction of ground-instantiated clauses.
F = h[p(a)], [¬p(f (f (a)))], [¬p(a), p(f (a))], [¬p(f (a)), p(f (f (a)))]i
I Let G be the set of ground atoms occurring in F .
G = {p(a), p(f (a)), p(f (f (a)))}
I Let V be a sufficiently large set of propositional variables.
V = {p1, p2, p3}
I We find a bijection between G and V .
p(a) ⇔ p1, p(f (a)) ⇔ p2, p(f (f (a))) ⇔ p3
I All propositional results are applicable to F .
First Order Logic (28th November 2007)
83
The Resolution Theorem
I Theorem 4.59 (Resolution Theorem)
Let F = ∀ hC1, . . . , Cli be a sentence in clause form.
F is unsatisfiable iff there is a resolution refutation for F .
I Proof
⇐ Let (Ci | 1 ≤ i ≤ m) be a resolution refutation for F .
. Lemma 4.56’: F ≡ ∀ hC1, . . . , Cmi.
. Because of Cm = [ ] and Theorem 3.17 (unsatisfiability)
we conclude F ≡ [ ].
. Hence, F is unsatisfiable.
First Order Logic (28th November 2007)
84
Proof of the Resolution Theorem (cont.)
⇒ Suppose, F is unsatisfiable.
. Then, G = {Ciσ | 1 ≤ i ≤ l, σ ground substitution for Ci}
is unsatisfiable (Theorem 4.55).
. To each ground atom occurring in G we can assign a propositional variable
such that any two atoms are mapped to different variables.
. Then, we find a finite subset {C1σ1, . . . , Cmσm} ⊆ G , which is propositionally unsatisfiable (Corollary 3.40).
. Then, we find a propositional resolution refutation for
hC1σ1, . . . , Cmσmi (Theorems 3.12 and 3.42).
. Then, we find a predicate logic resolution refutation for
∀ hC1, . . . , Cmi (Lemma 4.58).
. By construction each Cj , 1 ≤ j ≤ m, is a clause occurring in F .
. Hence, we obtain a resolution refutation for F
(by eliminating variants of {C1, . . . , Cm}).
First Order Logic (28th November 2007)
qed
85
Example
I Consider:
F = h[p(a)], [¬p(X ), p(f (X ))], [¬p(f (f (a)))]i.
I The set of all ground instances of clauses occurring in F :
{[p(a)], [¬p(f (f (a)))], [¬p(a), p(f (a))], [¬p(f (a)), p(f (f (a)))], . . .}.
I Ground atoms can be replaced by propositional variables:
{[p1], [¬p3], [¬p1, p2], [¬p2, p3], . . .}.
I We find a finite subset which is propositionally unsatisfiable:
{[p1], [¬p3], [¬p1, p2], [¬p2, p3]}.
First Order Logic (28th November 2007)
86
Example (Cont.)
I We obtain the resolution refutations:
1
2
3
4
5
6
7
[p1]
[¬p1, p2]
[¬p2, p3]
[¬p3]
[¬p1, p3]
[p3]
[]
[p(a)]
[¬p(a), p(f (a))]
[¬p(f (a)), p(f (f (a)))]
[¬p(f (f (a)))]
[¬p(a), p(f (f (a)))]
[p(f (f (a)))]
[]
[p(a)]
[¬p(X ), p(f (X ))]
[¬p(Y ), p(f (Y ))]
[¬p(f (f (a)))]
[¬p(X1), p(f (f (X1)))]
[p(f (f (a)))]
[]
res(2,3)
res(1,5)
res(4,6)
I Clauses 2 und 3 in the last refutation are variants.
I After deleting one of them we obtain a refutation for:
F = h[p(a)], [¬p(X ), p(f (X ))], [¬p(f (f (a)))]i.
I In general we can not predict how many copies of a clause are needed to obtain a
resolution refutations.
First Order Logic (28th November 2007)
87
Soundness and Completeness of the Resolution Calculus
I Theorem 4.60 Let F be a sentence. |= F holds iff `r F holds.
I Proof
⇐ Soundness Suppose `r F holds.
. There is a resolution refutation of G, where G is a clause form of ¬F .
. Theorem 4.59: G ist unsatisfiable.
. Theorem 4.32: ¬F is unsatisfiable.
. F is valid, i.e., |= F holds.
⇒ Completeness Suppose |= F holds.
. F valid and ¬F unsatisfiable.
. Let G be a clause form of ¬F .
. Theorem 4.32: G ist unsatisfiable.
. Theorem 4.59: There exists a resulution refutation for G, i.e., `r F .
First Order Logic (28th November 2007)
qed
88
4.8.3 Compactness Theorem
I Theorem 4.63 Let F be a set of first order sentences.
F is satisfiable iff each finite subset of F is satisfiable.
I We may try to prove the Theorem directly as in propositional logic.
I Idea We use the compactness theorem of propositional logic
in order to find a simpler proof for Theorem 4.63.
I Problem F may be a countably infinite set of sentences.
In this chapter, however, all our main results dealt only with a single sentence.
I Task We must extend some of our results to sets.
First Order Logic (28th November 2007)
89
4.8.4 Undecidabilty of First Order Logic
I Is first order logic decidable?
I Yes/No-problems.
. Is a given word (e. g. “uhu”) a palindrome?
I A class of yes/no-questions is decidable, if there is a procedure which terminates
for each question from this class in finite time and answers the question correctly
with “yes” or “no”.
I Examples
. Are words over a given alphabet palindromes?
. Are propositional formulas over a given alphabet valid?
First Order Logic (28th November 2007)
90
Semi-Decidability
I Observing the predicate logic resolution calculus we find:
. If F is valid, then it terminates with “yes”.
. If F is not valid, then it either
II terminates with “no” or
II runs forever.
I Such problems are undecidable, but semi-decidable.
I Examples
. Halting problem of Turing machinses
. Acceptance problem of two-counter machines
. Post’s correspondence problem
First Order Logic (28th November 2007)
91
Post’s Correspondence Problem
I A Post’s correspondence task consists of an alphabet Σ containing at least two
symbols, a natural number n and two lists of words over Σ both having length n.
I A Post’s correspondence problem is the question of whether there exists a sequence (i1, . . . , ik ) of natural number, where ij ≤ n for all j ≥ 1, such that the
concatenation of the i1-st, i2-nd, etc. words taken from the first list and the concatenation of the corresponding words taken from the second list are identical.
I Example Σ = {0, 1}, n = 3, [010, 00, 100], [10, 000, 10].
. (2, 1) is a solution:
00010 (= 00 · 010 = 000 · 10)
. (3, 2) is a solution:
10000 (= 100 · 00 = 10 · 000)
I Theorem PKP Post’s corresponding problem is undecidable (Post:46).
First Order Logic (28th November 2007)
92
The Undecidability of First Order Logic
I Theorem 4.64 Let F be a set of first order sentences and G a first order sentence.
The question of whether F |= G holds is undecidable.
I Proof We show:
. Post’s correspondence problem is decidable
iff first order logic is decidable.
. Let P = (Σ, n, [α1, . . . , αn], [β1, . . . , βn]), where Σ = {0, 1}.
. Let F = {a/0, f0/1, f1/1} and R = {p/2}.
. Notation fσ1...σm (X ) := fσm (. . . (fσ1 (X )) . . .), where σi ∈ {0, 1}.
Vn
. FP = (( i=1 p(fαi (a), fβi (a))
(1)
Vn
∧ (∀X, Y ) (p(X, Y ) → i=1 p(fαi (X ), fβi (Y ))))
(2)
→ (∃Z ) p(Z, Z ))
. To show P has solution iff FP is valid
(3)
Exercise.
. Theorem 4.64 follows immediately from Theorem PKP.
First Order Logic (28th November 2007)
qed
93