4 predicate / first order logic

93
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

Upload: others

Post on 03-Feb-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 4 Predicate / First Order Logic

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

Page 2: 4 Predicate / First Order Logic

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

Page 3: 4 Predicate / First Order Logic

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, . . . relation symbols,p/n relation symbol with arity n,g, h, . . . function symbols,g/n function symbol with arity n,a, b, . . . constant symbols,X, Y , . . . variables,

I Agreement In the following we assume that R, F , and V are given.

First Order Logic (28th November 2007) 3

Page 4: 4 Predicate / First Order Logic

Terms

I Definition 4.2The 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

Page 5: 4 Predicate / First Order Logic

Predicate Logic Formulas

I Definition 4.3 The set of atomic formulas (or, briefly, atoms) of the languageL(R, F, V) is the set of strings of the form p(t1, . . . , tn), where p/n ∈ Rand {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) isthe 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 (possibly indexed) denotes an atom,F , G, H (possibly indexed) denote formulas.

First Order Logic (28th November 2007) 5

Page 6: 4 Predicate / First Order Logic

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 Exercise.

First Order Logic (28th November 2007) 6

Page 7: 4 Predicate / First Order Logic

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 followingconditions:

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 onthe values of foo for t1, . . . , tn.

I Example

foo(T ) =

8<:0 if T is a variable,1 if T is a constant symbol,Pn

i=1 foo(ti) if T is of the form f(t1, . . . , tn).

I Likewise for formulas Exercise.

First Order Logic (28th November 2007) 7

Page 8: 4 Predicate / First Order Logic

Subterms and Subformulas

I Definition 3.6 (propositional subformulas) can be extended toterms 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

Page 9: 4 Predicate / First Order Logic

Free and Bound Occurrences of Variables

I Definition 4.5 The free occurrences of a variable in a predicate logic formula aredefined 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

Page 10: 4 Predicate / First Order Logic

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

Page 11: 4 Predicate / First Order Logic

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

Page 12: 4 Predicate / First Order Logic

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 toa mapping bσ : T (F, V) → T (F, V) as follows: Let t ∈ T (F, V), then

tbσ =

8<:tσ if t ∈ V ,t if t is a constant,f(t1bσ, . . . , tnbσ) if t is of the form f(t1, . . . , tn).

tbσ is called instance of t under bσ.

If tbσ is closed, then tbσ is called ground instance of t under bσ,and bσ is said to be a ground substitution for t.

First Order Logic (28th November 2007) 12

Page 13: 4 Predicate / First Order Logic

Composition of Substitutions

I Definition 4.9 Let σ and θ be substitutions.The composition σθ of σ and θ is the substitution

{X 7→ tbθ | X 7→ t ∈ σ and X 6= tbθ}∪ {Y 7→ s | Y 7→ s ∈ θ and Y 6∈ dom(σ)}.

I Proposition 4.11 Let σ and θ be substitutions.For every term t, we have t( cσθ) = (tbσ)bθ.

I Proof Structural induction over t Exercise.

First Order Logic (28th November 2007) 13

Page 14: 4 Predicate / First Order Logic

Composition of Substitutions (continued)

I Proposition 4.12 Let t ∈ T (F, V) and σ, θ and λ be substitutions. Then:

1. t( ̂(σθ)λ) = t(σ̂(θλ)).2. t(cεσ) = tbσ = t(cσε).

I Proof

1. t( ̂(σθ)λ)= (t( cσθ))bλ (Proposition 4.11)= ((tbσ)bθ)bλ (Proposition 4.11)= (tbσ)(cθλ) (Proposition 4.11)= t(σ̂(θλ)) (Proposition 4.11)

2. Exercise qed

I Notation From now on we write σ instead of bσ.

First Order Logic (28th November 2007) 14

Page 15: 4 Predicate / First Order Logic

Applications of Substitutions to Formulas

I Definition 4.13 Let σ be a substitution.

σX =

σ if X 6∈ dom(σ)σ \ {X 7→ t} 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

Page 16: 4 Predicate / First Order Logic

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 thatE1 = 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 sofar in the context, then E2 is a new variant of E1.

First Order Logic (28th November 2007) 16

Page 17: 4 Predicate / First Order Logic

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

Page 18: 4 Predicate / First Order Logic

Some Preliminaries

I Let D be a set.

D2 = D × D = {(d1, d2) | d1 ∈ D and d2 ∈ D}Dn = Dn−1 × D = {(t, dn) | t ∈ Dn−1 and dn ∈ D}

=: {(d1, . . . , dn) | di ∈ D, 1 ≤ i ≤ n}, n > 2D1 = D =: {(d) | d ∈ D}D0 = = {( )}

I Relations

R ⊆ D2 R = {(n, m) | n, m ∈ N and n < m}R ⊆ D3 R = {(x, y, z) | x, y, z ∈ N and x2 + y2 = z2}R ⊆ D1 R = {(n) | n ∈ N and n even}R ⊆ D0 R = ∅ or R = {( )}

First Order Logic (28th November 2007) 18

Page 19: 4 Predicate / First Order Logic

Some Preliminaries – Continued

I Remember Let D be a set.

D2 = D × D = {(d1, d2) | d1 ∈ D and d2 ∈ D}Dn = Dn−1 × D = {(t, dn) | t ∈ Dn−1 and dn ∈ D}

=: {(d1, . . . , dn) | di ∈ D, 1 ≤ i ≤ n}, n > 2D1 = D =: {(d) | d ∈ D}D0 = = {( )}

I Functions+ : N2 → N +(2, 3) 7→ 5succ : N1 → N succ(3) 7→ 40 : N0 → N 0( ) 7→ 0

First Order Logic (28th November 2007) 19

Page 20: 4 Predicate / First Order Logic

4.3.1 Interpretations and Models

I Definition 4.18 A predicate logic interpretation I for a predicate logic languageL(R, F, V) consists of a non-empty set D and a mapping ·I, which satisfies thefollowing conditions:

1. Every n-ary function symbol g/n ∈ Fis mapped to an n-ary function gI : Dn → D.

2. Every n-ary relation symbol p/n ∈ Ris mapped to an n-ary relation pI ⊆ Dn.

D is called domain of the interpretation.

First Order Logic (28th November 2007) 20

Page 21: 4 Predicate / First Order Logic

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 XZ .

Let Z be a variable assignment and d ∈ D.{X 7→ d}Z denotes the variable assignment, where:

Y{X 7→d}Z =

d if Y = X,Y Z otherwise.

First Order Logic (28th November 2007) 21

Page 22: 4 Predicate / First Order Logic

Interpretation of Terms

I Definition 4.20 Let I = (D, ·I) be an interpretation and Z a variable assignmentwrt I. The meaning tI,Z of a term t ∈ T (F, V) is defined as follows:

1 For every variable X ∈ V we have XI,Z = XZ .2 For every term of the form g(t1, . . . , tn) we have

[g(t1, . . . , tn)]I,Z = gI(tI,Z

1 , . . . , tI,Zn ),

where g/n ∈ F and t1, . . . , tn are terms.

First Order Logic (28th November 2007) 22

Page 23: 4 Predicate / First Order Logic

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

. addm/1, which appends m to a word at the right, and function

. conc/2, which concatenates two words.

a h g XZ g(h(a), h(h(a))) g(h(X), g(h(a), h(X)))

I1 0 s + 4 3 11I2 1 p − 8 1 14I3 o addm conc omo omomm omomomomom

First Order Logic (28th November 2007) 23

Page 24: 4 Predicate / First Order Logic

Interpretation of Formulas

I Definition 4.21 Let I = (D, ·I) be an interpretation and Z a variable assignmentwrt I. I and Z assign every formula F ∈ L(R, F, V) a truth value F I,Z asfollows:

1. [p(t1, . . . , tn)]I,Z = > iff (tI,Z1 , . . . , tI,Z

n ) ∈ pI.2. [¬F ]I,Z = ¬∗(F I,Z).3. [(F1 ◦ F2)]I,Z = (F I,Z

1 ◦∗ F I,Z2 ) for all binary connectives ◦/2.

4. [(∀X) F ]I,Z = > iff for all d ∈ D: F I,{X 7→d}Z = >.5. [(∃X) F ]I,Z = > iff for some d ∈ D: F I,{X 7→d}Z = >.

First Order Logic (28th November 2007) 24

Page 25: 4 Predicate / First Order Logic

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 Exercise.

First Order Logic (28th November 2007) 25

Page 26: 4 Predicate / First Order Logic

Models

I Proposition 4.21”If F ∈ L(R, F, V) is closed, then F I,Z = F I,Z′

for any I, Z and Z ′.

I Proof Exercise.

. If formulas are closed, then their meaning is independent of avariable assignment.

I Notation If F is closed, then we write F I instead of F I,Z .

I Definition 4.22Let 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

Page 27: 4 Predicate / First Order Logic

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 topredicate 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 |= (〈F1, . . . , Fn〉 → F ).

First Order Logic (28th November 2007) 27

Page 28: 4 Predicate / First Order Logic

Logical Consequence

I Definition 4.23 A closed formula F is a (predicate logic) consequence of a set Gof closed formulas, in symbols G |= F ,iff every model for G is also a model for F .

First Order Logic (28th November 2007) 28

Page 29: 4 Predicate / First Order Logic

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

Page 30: 4 Predicate / First Order Logic

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 languageL(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

Page 31: 4 Predicate / First Order Logic

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 = qI1 = rI1 = T (F). I1 is a model for F .

I2: pI2 = qI2 = rI2 = ∅. I2 is not a model for F .

I3: pI3 = {g(g(a)), g(g(g(g(a)))), . . .}, qI3 = {a, g(a)}, rI3 = {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

Page 32: 4 Predicate / First Order Logic

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

Page 33: 4 Predicate / First Order Logic

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 forfirst-order formulas.

First Order Logic (28th November 2007) 33

Page 34: 4 Predicate / First Order Logic

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 ∧ G)((∃X) F ∨ (∃X) G) ≡ (∃X) (F ∨ G)

(∀X) (∀Y ) F ≡ (∀Y ) (∀X) F

(∃X) (∃Y ) F ≡ (∃Y ) (∃X) F

((∀X) F ∧ G) ≡ (∀X) (F ∧ G), if X does not occur free in G.((∀X) F ∨ G) ≡ (∀X) (F ∨ G), if X does not occur free in G.((∃X) F ∧ G) ≡ (∃X) (F ∧ G), if X does not occur free in G.((∃X) F ∨ G) ≡ (∃X) (F ∨ G), if X does not occur free in G.

First Order Logic (28th November 2007) 34

Page 35: 4 Predicate / First Order Logic

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 ¬∗[(∀X) F ]I,Z = >iff [(∀X) F ]I,Z = ⊥iff F I,{X 7→d}Z = > does not hold for all d ∈ D

iff F I,{X 7→d}Z = ⊥ holds for some d ∈ D

iff ¬∗F I,{X 7→d}Z = > holds for some d ∈ D

iff [(∃X) ¬F ]I,Z = >.

qed

First Order Logic (28th November 2007) 35

Page 36: 4 Predicate / First Order Logic

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, ifno two quantifiers occurring in F bind the same variable, and no variable occursboth free and bound.

I Proposition 4.27 For every formula, there is a semantically equivalent formulawhere the variables are standardized apart.

I Auxiliary Proposition Let Q be a quantifier, F a formula of the form (QX) G, andY a variable not occurring in F . Then F ≡ (QY ) G{X 7→ Y } holds.

I Proof Exercise.

First Order Logic (28th November 2007) 36

Page 37: 4 Predicate / First Order Logic

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 replacedaccording 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

Page 38: 4 Predicate / First Order Logic

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 asemantically equivalent sentence F ′ in prenex normal form.

First Order Logic (28th November 2007) 38

Page 39: 4 Predicate / First Order Logic

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

¬(∃X) G

(∀X) ¬G

((QX) G ∧ H)(QX) (G ∧ H)

(G ∧ (QX) H)(QX) (G ∧ H)

((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 Exercise.

First Order Logic (28th November 2007) 39

Page 40: 4 Predicate / First Order Logic

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 arecalled Skolem function symbols. Nullary Skolem function symbols are also calledSkolem 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 it-self does not contain any further quantifier.

First Order Logic (28th November 2007) 40

Page 41: 4 Predicate / First Order Logic

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

Page 42: 4 Predicate / First Order Logic

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 vari-ables are standardized apart, and F ′ be the formula obtained from F by a singleapplication of the replacement rule. Then the following holds: F is satisfiable iffF ′ is satisfiable.

Proof of Auxiliary Proposition Exercise.

I Let E be the proposition: F ′ is a formula in prenex normal form, where all vari-ables are standardized apart, and is satisfiable iff F is satisfiable.

I With F = F ′ 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 ′ is in Skolem normal form. qed

First Order Logic (28th November 2007) 42

Page 43: 4 Predicate / First Order Logic

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 G′ be a formula in clause form which is semantically equivalent to G.

. F is satisfiable iff ∀G′ is satisfiable.

. F is unsatisfiable iff ∀G′ is unsatisfiable.

First Order Logic (28th November 2007) 43

Page 44: 4 Predicate / First Order Logic

Example: Proving Mathematical Theorems by Machines

I Theorem: Let G be a group with · as binary operator in infix notation and e asidentity element. If, for all elements X of G, the property X · X = e holds, thenG 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 withproperty 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

Page 45: 4 Predicate / First Order Logic

Proving Mathematical Theorems by Machines (continued)

I The group axioms can be represented as follows:

A′1 (∀X1)(∀Y1)(∃Z1) p(X1, Y1, Z1)

A′2 ((∀X2)(∀Y2)(∀Z2)(∀U2)(∀V2)(∀W2)

〈(p(X2, Y2, U2), p(Y2, Z2, V2), p(U2, Z2, W2)〉 → p(X2, V2, W2))∧(∀X3)(∀Y3)(∀Z3)(∀U3)(∀V3)(∀W3)(〈p(X3, Y3, U3), p(Y3, Z3, V3), p(X3, V3, W3)〉 → p(U3, Z3, W3)))

A′3 ((∀X4) p(X4, e, X4) ∧ (∀X5) p(e, X5, X5))

A′4 ((∀X6) p(X6, f(X6), e) ∧ (∀X7) p(f(X7), X7, e))

First Order Logic (28th November 2007) 45

Page 46: 4 Predicate / First Order Logic

Proving Mathematical Theorems by Machines (continued)

I The conclusion of the theorem can be represented as follows:

C′ ((∀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:

F = (〈A′1, A

′2, A

′3, A

′4〉 → C

′)

I The theorem is proven if F is valid, or, equivalently, if

¬F = 〈A′1, A

′2, A

′3, A

′4, ¬C

′〉

is unsatisfiable.

First Order Logic (28th November 2007) 46

Page 47: 4 Predicate / First Order Logic

Proving Mathematical Theorems by Machines (continued)

I As clause form of ¬F we obtain:

∀ 〈 [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 How can we show unsatisfiablity of a predicate logic formula?

First Order Logic (28th November 2007) 47

Page 48: 4 Predicate / First Order Logic

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

{̇s1 ≈ t1, . . . , sn ≈ tn}̇

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 besimultaneously unifiable and σ is said to be a unifier for the unification problem.

First Order Logic (28th November 2007) 48

Page 49: 4 Predicate / First Order Logic

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

Page 50: 4 Predicate / First Order Logic

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 see lecture Foundations of LP.(iii) Proof of Soundness. see lecture Foundations of LP.

First Order Logic (28th November 2007) 50

Page 51: 4 Predicate / First Order Logic

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 .U := U \̇ {̇s ≈ t}̇.Apply one of the following rules:

(1) If s ≈ t is of the form X ≈ r or r ≈ X and variable X does notoccur 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

Page 52: 4 Predicate / First Order Logic

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

Page 53: 4 Predicate / First Order Logic

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

Page 54: 4 Predicate / First Order Logic

The Resolution Rule

I Definition 4.42 Let

C1 = [p(s1, . . . , sk), L1, . . . , Lm]

andC2 = [¬p(t1, . . . , tk), Lm+1, . . . , Ln]

be clauses, where k, m, n ≥ 0.

If {̇si ≈ ti | 1 ≤ i ≤ k}̇ is unifiable with mgu σ then

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

Page 55: 4 Predicate / First Order Logic

The Factoring Rule

I Definition 4.43 Let

C = [p(s1, . . . , sk), p(t1, . . . , tk), L1, . . . , Lm]

orC = [¬p(s1, . . . , sk), ¬p(t1, . . . , tk), L1, . . . , Lm]

be clauses, where k, m ≥ 0.

If {̇si ≈ ti | 1 ≤ i ≤ k}̇ is unifiable with mgu σ then

C′ = [p(t1, . . . , tk), L1, . . . , Lm]σ

andC

′ = [¬p(t1, . . . , tk), L1, . . . , Lm]σ,

are factors of C, respectively.

C′ has been obtained by applying the factoring rule to C.

First Order Logic (28th November 2007) 55

Page 56: 4 Predicate / First Order Logic

Resolution Derivations and Refutations

I Definition 4.44 Let F = ∀ 〈C1, . . . , Cn〉 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 elementsfrom (Ci | 1 ≤ i ≤ m), then (Ci | 1 ≤ i ≤ m + 1) is a resolutionderivation for F .

3. A resolution derivation for F which contains the empty clause [ ] is calledresolution 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

Page 57: 4 Predicate / First Order Logic

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) 〈[p(0)], [¬p(X), p(h(X))], [¬p(h(h(h(h(0)))))]〉.

I Resolution refutation of the matrix:

1 [p(0)]2 [¬p(X), p(h(X))]3 [¬p(h(h(h(h(0)))))]4 [¬p(X1), p(h(h(X1)))] res(2,2)5 [¬p(X3), p(h(h(h(h(X3)))))] res(4,4)6 [p(h(h(h(h(0)))))] res(1,5)7 [ ] res(3,6)

First Order Logic (28th November 2007) 57

Page 58: 4 Predicate / First Order Logic

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 ) 〈[p(X, X), p(b, X)], [¬p(b, Y ), ¬p(Y, Y )]〉.

I Resolution refutation of the matrix:

1 [p(X, X), p(b, X)]2 [¬p(b, Y ), ¬p(Y, Y )]3 [p(b, b)] fac(1)4 [¬p(b, b)] fac(2)5 [ ] res(3,4)

First Order Logic (28th November 2007) 58

Page 59: 4 Predicate / First Order Logic

Resolution Proof

I Definition 4.43” Let F = ∀ 〈C1, . . . , Cn〉 be a predicate logic formula in clauseform 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

Page 60: 4 Predicate / First Order Logic

Proving Mathematical Theorems by Machines (continued)

1 [p(X1, Y1, g(X1, Y2))]2 [¬p(X2, Y2, U2), ¬p(Y2, Z2, V2), ¬p(U2, Z2, W2), p(X2, V2, W2)]3 [¬p(X3, Y3, U3), ¬p(Y3, Z3, V3), ¬p(X3, V3, W3), p(U3, Z3, W3)]4 [p(X4, e, X4)]5 [p(e, X5, X5)]6 [p(X6, f(X6), e)]7 [p(f(X7), X7, e)]8 [p(X8, X8, e)]9 [p(a, b, c)]

10 [¬p(b, a, c)]11 [p(X9, V2, e), ¬p(Y9, U9, V9), ¬p(X2, Y2, U2)] res(2, 8)13 [p(X10, V10, W10), ¬p(e, Z10, W10), ¬p(X10, Z10, V10)] res(2, 8)14 [p(X11, V11, U11), ¬p(Y11, e, V11), ¬p(X11, Y11, U11)] res(2, 4)40 [p(X12, e, W12), ¬p(e, X12, W12)] res(13, 8)43 [p(X13, V13, Z13), ¬p(X13, Z13, V13)] res(13, 5)67 [p(X14, g(X14, Z14), Z14)] res(43, 1)

3239 [p(e, V15, Y15), ¬p(Y15, e, V15)] res(14, 5)3325 [¬p(Y16, e, a), ¬p(b, Y16, c)] res(10, 14)3627 [¬p(g(b, c), e, a)] res(3325, 67)4630 [p(e, Z17, X17), ¬p(X17, Z17, e)] res(3239, 43)5199 [p(Z18, e, X18), ¬p(X18, Z18, e)] res(40, 4630)5800 [¬p(a, g(b, c), e)] res(3627, 5199)

518609 [p(a, V19, e), ¬p(b, c, V19)] res(11, 9)645778 [p(a, g(b, c), e)] res(518609, 1)646029 [ ] res(645778, 5800)

First Order Logic (28th November 2007) 60

Page 61: 4 Predicate / First Order Logic

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

Page 62: 4 Predicate / First Order Logic

Completeness of the Resolution Method – Overview

{F1, . . . , Fn} |= Fm Theorem 3.15 (extended)

(〈F1, . . . , Fn〉 → F ) is validm Theorem 3.12 (extended)

¬(〈F1, . . . , Fn〉 → F ) is unsatisfiable⇓ Theorem 4.32

G is unsatisfiable, where G is a clause form of ¬(〈F1, . . . , Fn〉 → F )m Theorem 4.55

{Cσ | C is clause in G and σ is ground substitution for C} is unsatisfiablem Bijection ground atoms – propositional variables

H is unsatisfiable, where H is the set of propositional clauses corresponding to {Cσ | . . .}⇓ Corollary 3.40

finite subset H′ ⊆ H is unsatisfiable⇓ Theorem 3.42

there is a propositional resolution refutation for H′

m Bijection ground atoms – propositional variablesthere is a first-order resolution refutation for H′

⇓ Lemma 4.58there is a first-order resolution refutation for G

m Definition 4.44there is a first-order resolution proof for (〈F1, . . . , Fn〉 → F )

First Order Logic (28th November 2007) 62

Page 63: 4 Predicate / First Order Logic

4.8.1 Herbrand Interpretations

I F = {a/0, f/1} and R = {p/1, q/1, r/1}.

I G = (∀X)(∀Y )〈[p(X), q(X)], [r(f(Y ))]〉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))), . . .}

. I2 = ∅.

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}, qI = {0}, rI = {0}.

I We can construct a corresponding Herbrand interpretation!

First Order Logic (28th November 2007) 63

Page 64: 4 Predicate / First Order Logic

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 conditionis satisfied: for all relation symbols p/n holds:

p(t1, . . . , tn)I = > iff p(t1, . . . , tn) ∈ J.

First Order Logic (28th November 2007) 64

Page 65: 4 Predicate / First Order Logic

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}, qI = {0}, rI = {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

Page 66: 4 Predicate / First Order Logic

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 isalso 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 qed

First Order Logic (28th November 2007) 66

Page 67: 4 Predicate / First Order Logic

Interpretations vs. Herbrand Interpretations (continued)

I Theorem 4.53 A predicate logic sentence F in Skolem normal form is unsatisfiableiff 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 qed

First Order Logic (28th November 2007) 67

Page 68: 4 Predicate / First Order Logic

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′ = {p(a)} is the Herbrand interpretation corresponding to I.

. F I′= ⊥ Lemma 4.52 does not carry over.

. For I′′ = ∅ we find F I′′= ⊥ Theorem 4.53 does not carry over.

First Order Logic (28th November 2007) 68

Page 69: 4 Predicate / First Order Logic

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,

FI,{X1 7→t1}...{Xn 7→tn}Z = [F {X1 7→ t1, . . . , Xn 7→ tn}]I,Z

.

I Proof Exercise.

First Order Logic (28th November 2007) 69

Page 70: 4 Predicate / First Order Logic

Further Properties (continued)

I Theorem 4.55 Let F = ∀ 〈C1, . . . , Cn〉 be a sentence in clause form. F issatisfiable iff {Ciσ | 1 ≤ i ≤ n, σ is a ground substitution for Ci} is satisfiable.

I Proof Let X1, . . . , Xk be all variables occurring in 〈C1, . . . , Cn〉.

. F is satisfiable iff there exists a Herbrand model for F (Lemma 4.52).

. I |= F iff [〈C1, . . . , Cn〉]I,{X1 7→t1}...{Xk 7→tk}Z = >for all t1, . . . , tk ∈ T (F) and arbitrary Z

iff [〈C1, . . . , Cn〉{X1 7→ t1, . . . , Xk 7→ tk}]I = >for all t1, . . . , tk ∈ T (F) (Proposition 4.54)

iff [〈C1, . . . , Cn〉σ]I = >for all ground substitutions σ for 〈C1, . . . , Cn〉

iff [Ciσ]I = >for 1 ≤ i ≤ n and all ground substitutions σ for Ci

iff I |= {Ciσ | 1 ≤ i ≤ n, σ ground substitution for Ci}.qed

First Order Logic (28th November 2007) 70

Page 71: 4 Predicate / First Order Logic

Example

I Let F = {a/0, s/1}, R = {p/1, q/1} and X, Y ∈ V .

I Consider:F = ∀ 〈C1, C2〉

= (∀X)(∀Y ) 〈[p(X)], [¬q(s(Y ))]〉.

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

Page 72: 4 Predicate / First Order Logic

4.8.2 Soundness and Completeness Theorems

I First Order Resolution Lemma 4.56Let F = ∀〈C1, . . . , Cn〉 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 fromF . Then F ≡ ∀ 〈C1, . . . , Cn, C〉.

I Proof Observe: ∀ 〈C1, . . . , Cn, C〉 ≡ (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

C′ = [p(s1, . . . , sk), L1, . . . , Lm] andC′′ = [¬p(t1, . . . , tk), Lm+1, . . . , Ln],

where C′ and C′′ are new variants of clauses from F

and σ is a mgu for {̇si ≈ ti | 1 ≤ i ≤ k}̇.

First Order Logic (28th November 2007) 72

Page 73: 4 Predicate / First Order Logic

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′σ) and I |= ∀ (C′′σ).

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. qed

First Order Logic (28th November 2007) 73

Page 74: 4 Predicate / First Order Logic

Example

I Consider the sentence:

((∀X)p(X) ∧ (∀Y ) (p(Y ) → q(Y ))).

I It’s clause form is:

(∀X)(∀Y ) 〈[p(X)], [¬p(Y ), q(Y )]〉.

I As a resolvent of new variants of the two clauses we obtain:

[q(Z)].

I We find:

∀ 〈[p(X)], [¬p(Y ), q(Y )]〉 ≡ ∀ 〈[p(X)], [¬p(Y ), q(Y )], [q(Z)]〉.

First Order Logic (28th November 2007) 74

Page 75: 4 Predicate / First Order Logic

Generalized Resolution Lemma

I Lemma 4.56’ Let F = ∀ 〈C1, . . . , Cn〉 be a predicate logic sentence in clause-form and (Ci | 1 ≤ i ≤ m) a resolution derivation for F . Then:

F ≡ ∀ 〈C1, . . . , Cm〉.

I ProofStructural 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 ≡ ∀ 〈C1, . . . , Cm〉.II From Lemma 4.56 we conclude:

∀ 〈C1, . . . , Cm〉 ≡ ∀ 〈C1, . . . , Cm, Cm+1〉.II Because ≡ is transitive, we conclude F ≡ ∀ 〈C1, . . . , Cm+1〉.

. The proposition follows by an application of the induction theorem.qed

First Order Logic (28th November 2007) 75

Page 76: 4 Predicate / First Order Logic

Lifting-Lemma 1

I Lemma 4.57 (Lifting-Lemma 1) Let C1 and C2 be clausesand σ a ground substitution for C1 and C2.

(i) If C is a resolvent of C1σ and C2σ, then there exists a resolvent C′ of C1

and C2 as well as a substitution λ, such that C′λ = C holds.(ii) If C is a factor of C1σ, then there exists a factor C′ of C1 as well as a

substitution λ, such that C′λ = C holds.

First Order Logic (28th November 2007) 76

Page 77: 4 Predicate / First Order Logic

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 = [L1, . . . , Ln]σ.

. σ is a unifier for U = {̇s1 ≈ t1, . . . , sk ≈ tk}̇.

. We find an mgu θ for U and λ, such that: θλ = σ (Theorem 4.38).

. C′ = [L1, . . . , Ln]θ is resolvent for C1 and C2.

. C′λ = [L1, . . . , Ln]θλ = [L1, . . . , Ln]σ = C.

I (ii) Exercise qed

First Order Logic (28th November 2007) 77

Page 78: 4 Predicate / First Order Logic

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

C′ = [¬q(X)]

I With λ = {X 7→ a} we find C′λ = C and θλ = σ.

First Order Logic (28th November 2007) 78

Page 79: 4 Predicate / First Order Logic

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 aresolution derivation (Bi | 1 ≤ i ≤ m) for 〈C1σ1, . . . , Cnσn〉, then there isa resolution derivation (B′

i | 1 ≤ i ≤ m) for ∀ 〈C1, . . . , Cn〉 and a sequence(λi | 1 ≤ i ≤ m) of substitutions such that B′

iλ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 B′i = 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 (B′i | 1 ≤ i ≤ m) of length

l for ∀ 〈C1, . . . , Cn〉 and a sequence (λi | 1 ≤ i ≤ m) of substitutionswith B′

iλi = Bi for all 1 ≤ i ≤ m. (∗)

1st Bm+1 is a factor Exercise2nd Bm+1 is a resolvent next slide

First Order Logic (28th November 2007) 79

Page 80: 4 Predicate / First Order Logic

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 B′j and λj with B′

jλj = Bj.

I Let B′′j be a new variant of B′

j. Then there is a substitution θj with B′′j θj = B′

j.

I Alltogether: Bj = B′jλj = (B′′

j θj)λj = B′′j (θjλj).

I Analogously we find B′′k , λk and θk with Bk = B′

kλk = (B′′kθk)λk = B′′

k (θkλk).

I Because B′′j and B′′

k are new variants, we conclude:dom((θjλj)|V ar(B′′

j)) ∩ dom((θkλk)|V ar(B′′

k)) = ∅.

I Let σ = (θjλj)|V ar(B′′j

) ∪ (θkλk)|V ar(B′′k

).

I Hence we obtain: B′′j σ = Bj and B′′

kσ = Bk.

I Because of Lifting Lemma 1 we find a resolvent B′m+1 of B′′

j and B′′k as well as a

substitution λm+1 with B′m+1λm+1 = Bm+1.

I Together with (∗) we obtain a resolution derivation (Bi | 1 ≤ i ≤ m + 1) and asequence (λi | 1 ≤ i ≤ m + 1) with B′

iλi = Bi for all 1 ≤ i ≤ m + 1.

I An application of the induction theorem yields the desired result. qed

First Order Logic (28th November 2007) 80

Page 81: 4 Predicate / First Order Logic

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 [¬p(f(g(a)))] B′1 [¬p(W )]

B2 [p(f(g(a))), ¬q(g(a))] B′2 [p(f(X)), ¬q(X)]

B3 [q(g(a)), ¬r(a)] B′3 [q(g(Y )), ¬r(Y )]

B4 [r(a)] B′4 [r(Z)]

B5 [¬q(g(a))] B′5 [¬q(X2)] res(1,2)

B6 [¬r(a)] B′6 [¬r(Y3)] res(3,5)

B7 [ ] B′7 [ ] res(4,6)

First Order Logic (28th November 2007) 81

Page 82: 4 Predicate / First Order Logic

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 [p(a)] B′1 [p(a)]

B2 [¬p(a), p(f(a))] B′2 [¬p(X), p(f(X))]

B3 [¬p(f(a)), p(f(f(a)))] B′3 [¬p(Y ), p(f(Y ))]

B4 [¬p(f(f(a)))] B′4 [¬p(f(f(a)))]

B5 [¬p(a), p(f(f(a)))] B′5 [¬p(X1), p(f(f(X1)))] res(2,3)

B6 [p(f(f(a)))] B′6 [p(f(f(a)))] res(1,5)

B7 [ ] B′7 [ ] res(4,6)

First Order Logic (28th November 2007) 82

Page 83: 4 Predicate / First Order Logic

Closed Formulas and Propostional Logic

I Let F be a generalized conjunction of ground-instantiated clauses.

F = 〈[p(a)], [¬p(f(f(a)))], [¬p(a), p(f(a))], [¬p(f(a)), p(f(f(a)))]〉

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

Page 84: 4 Predicate / First Order Logic

The Resolution Theorem

I Theorem 4.59 (Resolution Theorem)Let F = ∀ 〈C1, . . . , Cl〉 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 ≡ ∀ 〈C1, . . . , Cm〉.

. Because of Cm = [ ] and Theorem 3.17 (unsatisfiability)we conclude F ≡ [ ].

. Hence, F is unsatisfiable.

First Order Logic (28th November 2007) 84

Page 85: 4 Predicate / First Order Logic

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 variablesuch that any two atoms are mapped to different variables.

. Then, we find a finite subset {C1σ1, . . . , Cmσm} ⊆ G, which is proposi-tionally unsatisfiable (Corollary 3.40).

. Then, we find a propositional resolution refutation for〈C1σ1, . . . , Cmσm〉 (Theorems 3.12 and 3.42).

. Then, we find a predicate logic resolution refutation for∀ 〈C1, . . . , Cm〉 (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}). qed

First Order Logic (28th November 2007) 85

Page 86: 4 Predicate / First Order Logic

Example

I Consider:F = 〈[p(a)], [¬p(X), p(f(X))], [¬p(f(f(a)))]〉.

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

Page 87: 4 Predicate / First Order Logic

Example (Cont.)

I We obtain the resolution refutations:

1 [p1] [p(a)] [p(a)]2 [¬p1, p2] [¬p(a), p(f(a))] [¬p(X), p(f(X))]3 [¬p2, p3] [¬p(f(a)), p(f(f(a)))] [¬p(Y ), p(f(Y ))]4 [¬p3] [¬p(f(f(a)))] [¬p(f(f(a)))]5 [¬p1, p3] [¬p(a), p(f(f(a)))] [¬p(X1), p(f(f(X1)))] res(2,3)6 [p3] [p(f(f(a)))] [p(f(f(a)))] res(1,5)7 [ ] [ ] [ ] 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 = 〈[p(a)], [¬p(X), p(f(X))], [¬p(f(f(a)))]〉.

I In general we can not predict how many copies of a clause are needed to obtain aresolution refutations.

First Order Logic (28th November 2007) 87

Page 88: 4 Predicate / First Order Logic

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 . qed

First Order Logic (28th November 2007) 88

Page 89: 4 Predicate / First Order Logic

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 logicin 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

Page 90: 4 Predicate / First Order Logic

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 terminatesfor each question from this class in finite time and answers the question correctlywith “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

Page 91: 4 Predicate / First Order Logic

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” orII 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

Page 92: 4 Predicate / First Order Logic

Post’s Correspondence Problem

I A Post’s correspondence task consists of an alphabet Σ containing at least twosymbols, 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 se-quence (i1, . . . , ik) of natural number, where ij ≤ n for all j ≥ 1, such that theconcatenation of the i1-st, i2-nd, etc. words taken from the first list and the con-catenation 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

Page 93: 4 Predicate / First Order Logic

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 decidableiff 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}.

. FP = ((Vn

i=1 p(fαi(a), fβi

(a)) (1)

∧ (∀X, Y ) (p(X, Y ) →Vn

i=1 p(fαi(X), fβi

(Y )))) (2)

→ (∃Z) p(Z, Z)) (3). To show P has solution iff FP is valid Exercise.. Theorem 4.64 follows immediately from Theorem PKP. qed

First Order Logic (28th November 2007) 93