mathematical logic 2 - theory and logicfirst-order logic 1.1 formulas an in nite set xis called...

36
Mathematical Logic 2 Stefan Hetzl [email protected] Vienna University of Technology Summer Term 2011

Upload: others

Post on 01-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Mathematical Logic 2

Stefan [email protected]

Vienna University of Technology

Summer Term 2011

Page 2: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

ii

Page 3: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Contents

1 First-Order Logic 1

1.1 Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Definability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.3 Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.4 Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.5 Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2 Arithmetic 17

2.1 Recursive Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.2 Representability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.3 Arithmetisation of Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.4 Incompleteness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

iii

Page 4: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

iv

Page 5: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Chapter 1

First-Order Logic

1.1 Formulas

An infinite set X is called countably infinite if there is a bijection ϕ : N Ñ X. A set is calledcountable if it is finite or countably infinite.

A language L consists of a countable set of constant symbols, typically written as a, b, c, c1, c2, . . .,for each i ¥ 1 a countable set of function symbols of arity i, using letters f, g, f1, f2, . . . and foreach i ¥ 1 a countable set of predicate symbols of arity i, using P,Q,R, P1, P2, . . .. In additionwe assume a countably infinite reservoir of variables x, y, z, x1, x2, . . .. If f is a function symbolof arity i we express this by writing f{i and similarly for predicate symbols. Constant symbolscan be identified with function symbols of arity 0.

Example 1.1. The language of arithmetic LN � t0{0, s{1,�{2, �{2,  {2u, the language of groupsLG � t�{2, e{1,

�1 {1u.

Definition 1.1. For a language L, the set of L-terms are defined inductively:

1. Variables are L-terms

2. Constant symbols in L are L-terms

3. If t1, . . . , tn are L-terms and f is a function symbol of arity n, then fpt1, . . . , tnq is anL-term

Definition 1.2. For a language L, the set of L-formulas is defined inductively:

1. If P is an n-ary predicate symbol of L, and t1, . . . , tn are L-terms, then P pt1, . . . , tnq is anL-formula.

2. If t1 and t2 are L-terms, then t1 � t2 is an L-formula.

3. K is a formula.

4. If A and B are L-formulas, then pA^Bq, pA_Bq, p Aq, pAÑ Bq, p@xAq and pDxAq areL-formulas.

For example, pP pfpc, dqq_p Qpeqqq is a formula in the language containing the constant symbolsc, d, e, the binary function symbol f and the two unary predicate symbols P and Q. pP pfpcqq_Qpeqq is not a formula in this language, and neither is pP pcq _ P pdq ^ P peqq. To simplify the

1

Page 6: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

notation we will omit the outermost parentheses as well as those around the unary connectives , @ and D, so e.g. pp@x p@y P px, yqqq Ñ pDz P pz, zqqq is written as @x@yP px, yq Ñ DzP pz, zq.Furthermore, we assume that ^ and _ bind stronger than Ñ, so pA ^ Bq Ñ pC _Dq can bewritten as A ^ B Ñ C _ D. Furthermore, implication is right-associative, so A Ñ B Ñ Cmeans AÑ pB Ñ Cq.

So far, formulas are mere syntactic objects without any meaning attached to them (although, ofcourse, the chosen symbols already provoke some intuition). To make the meaning of a formulaprecise, we introduce the concept of a structure (often also called interpretation).

Definition 1.3. For a language L, an L-structure is a pair M � pM,Φq where M is a non-empty set, called the domain, and Φ maps each constant symbol c in L to an element Φpcq PM ,each function symbol f of arity n is mapped to an n-ary function Φpfq : Mn Ñ M and eachpredicate symbol P of arity n is mapped to an n-ary relation ΦpP q �Mn.

Example 1.2. pZ,Φq is an LG-structure where LG is the language of groups for Φ being definedas Φpeq � 0, Φp�qpm,nq � m � n and Φp�1qpmq � �m. Also pN,Φq with Φpeq and Φp�q asabove and Φp�1qpmq � m is an LG-structure even though it is not a group.

Definitions of the above kind are often abbreviated by writing pZ, 0,�,�q for pZ,Φq where theassignment Φ is assumed to be understood implicitly.

Definition 1.4. Let M � pM,Φq be an L-structure. Let t be a variable-free L-term, then thevalue Φptq of t in M is defined inductively:

1. If t is a constant symbol, then Φptq is already defined.

2. If t � fpt1, . . . , tnq, then Φptq � ΦpfqpΦpt1q, . . . ,Φptnqq.

Definition 1.5. The free variables FVpAq and bound variables BVpAq of a formula A aredefined inductively:

1. If A is an atom, then FVpAq is the set of variables appearing in A and BVpAq � H.

2. If � P t^,_,Ñu then FVpA �Bq � FVpAq Y FVpBq, BVpA �Bq � BVpAq Y BVpBq.

3. FVp Aq � FVpAq and BVp Aq � BVpAq.

4. FVpQxAq � FVpAqztxu and BVpQxAq � BVpAq Y txu.

A formula A with FVpAq � H is called sentence.

Definition 1.6. Let M � pM,Φq be an L-structure, let A be an L-sentence. We define whatit means for M to satisfy A, written as M ( A, by induction on A.

1. M ( P pt1, . . . , tnq if pΦpt1q, . . . ,Φptnqq P ΦpP q.

2. M ( t1 � t2 if Φpt1q � Φpt2q.

3. M * K

4. M ( A^B if M ( A and M ( B.

5. M ( A_B if M ( A or M ( B.

6. M ( A if M * A.

2

Page 7: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

7. M ( AÑ B if M ( A implies M ( B.

8. M ( @xA if for all m P M : pM,Φ1q ( Arxzcs where c is a constant symbol and Φ1 �ΦY tc ÞÑ mu.

9. M ( DxA if there is an m P M : pM,Φ1q ( Arxzcs where c is a constant symbol andΦ1 � ΦY tc ÞÑ mu.

For a formula A with free variables x1, . . . , xn we define M ( A as M ( @x1 � � � @xnA.

Note that in the above clauses for the quantifiers c will usually be a fresh constant, i.e. one thatdoes not appear in L. However, we do not formally require this. But if c P L, then for theexpression Φ1 � Φ Y tc ÞÑ mu to make sense we must have Φpcq � m and thus Φ1 � Φ. Thisconvention will be practical to simplify the notation at some points.

From now on, we simplify our notation by omitting the explicit reference to the language, so thatinstead of L-structure, L-formula, etc. we write structure, formula, etc. Usually the languagewill be either arbitrary or obvious from the context.

The above definition is the basis for a number of central concepts that we will encounter through-out the course. If M ( A then M is called a model of A. A sentence is called satisfiable if it hasa model. A sentence is called valid if every structure is a model of it. Let Γ be a set of sentences,then a structure M is a model of Γ if it is a model of every A P Γ. A set of sentences Γ impliesa sentence A, written Γ ( A if for every structure M s.t. M ( Γ also M ( A. Two sentencesA and B are logically equivalent if A implies B and B implies A. We write ñ and ô for logicalimplication and equivalence. As a general rule, we use formal symbols like ^,@,ñ, . . . for theobject language and words like and, for all, implies, . . . for the meta-language.

Example 1.3. In this example we will see the definition of the semantics of formulas at work. Wewant to show that Dx@yP px, yq Ñ @yDxP px, yq is a valid sentence, i.e. that for every structurepM,Φq we have pM,Φq ( Dx@yP px, yq Ñ @yDxP px, yq, i.e. whenever pM,Φq ( Dx@yP px, yqthen pM,Φq ( @yDxP px, yq. Unfolding the first formula we see that pM,Φq ( Dx@yP px, yq iffthere exists an m PM s.t.

pM,ΦY tc ÞÑ muq ( @yP pc, yq

iff there exists an m PM s.t. for all n PM

pM,ΦY tc ÞÑ m, d ÞÑ nuq ( P pc, dq

Unfolding the second formula we find that pM,Φq ( @yDxP px, yq iff for all k PM

pM,ΦY td ÞÑ kuq ( DxP px, dq

iff for all k PM there is an l PM s.t.

pM,ΦY td ÞÑ k, c ÞÑ luq ( P pc, dq

Given any k, let l :� m and n :� k, then by the first formula we obtain

pM,ΦY tc ÞÑ l, d ÞÑ kuq ( P pc, dq

which is what we wanted to show.

3

Page 8: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

1.2 Definability

One of the most fundamental questions that can be asked about a (formal) language is: Whatis the expressive power of that language ? Or to put it in another way: what can and whatcannot be defined in the language ? This question, posed for first-order logic, lies at the heart ofmodel theory. Our first result in this direction shows that we can define the property of havingat least a certain number of elements.

Proposition 1.1. For n ¡ 1 define Ln :� @x1 . . .@xn�1Dxnpxn � x1 ^ . . .^ xn � xn�1q wheret � s is an abbreviation for t � s. Then M ( Ln iff |M| ¥ n.

Proof. M,H ( @x1 . . .@xn�1Dxnpxn � x1 ^ . . .^ xn � xn�1q

iff for all m1 PM : M, tc1 ÞÑ m1u ( @x2 . . .@xn�1Dxnpxn � c1 ^ . . .^ xn � xn�1q

...

iff for all m1, . . . ,mn�1 PM

M, tc1 ÞÑ m1, . . . , cn�1 ÞÑ mn�1u ( Dxnpxn � c1 ^ . . .^ xn � cn�1q

iff for all m1, . . . ,mn�1 PM there is mn PM

M, tc1 ÞÑ m1, . . . , cn ÞÑ mnu ( cn � c1 ^ . . .^ cn � cn�1

iff for all m1, . . . ,mn�1 PM there is mn PM s.t. for all i � 1, . . . , n� 1

M, tc1 ÞÑ m1, . . . , cn ÞÑ mnu ( cn � ci

iff for all m1, . . . ,mn�1 PM there is mn PM s.t. for all i � 1, . . . , n� 1

M, tc1 ÞÑ m1, . . . , cn ÞÑ mnu * cn � ci

iff for all m1, . . . ,mn�1 PM there is mn PM s.t. for all i � 1, . . . , n� 1 : mn � mi

In other words:

iff M contains at least n elements.

So we have seen formulas that are only satisfied in models of a certain (finite) minimal size. Itis now easy to construct formulas that are only satisfied in models of size at most n as well asin models with exactly n elements. Let

Un :� Ln�1

then M ( Un iff M * Ln�1 iff |M| § n� 1, i.e. |M| ¤ n. Let

En :� Ln ^ Un

then M ( En iff |M| � n. Furthermore, letting Γ � tLn | n ¥ 1u it is easy to show thatM ( Γ iff M is infinite (exercise!). Now, Γ being an infinite set, a natural question is whetherthere is a finite set of sentences in the empty language that has exactly the inifite structures asmodels. We will see later that no such set exists – but we are not ready to prove this yet asthis result relies on the compactness theorem. On the other hand, if we are willing to extendthe language we can at least find sentences that have only infinite models.

4

Page 9: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Proposition 1.2. Define the sentences

A1 :� @xDy Rpx, yq

A2 :� @x@y@z pRpx, yq ^Rpy, zq Ñ Rpx, zqq

A3 :� @x Rpx, xq

A :� A1 ^A2 ^A3

then M ( A implies that M is infinite.

Proof. Let M � pM,Φq. M is non-empty, so let m0 P M . As M ( A1 there is an m1 P Mwith pm0,m1q P ΦpRq. By repeating this step we obtain an infinite sequence m0,m1, . . . P Ms.t. pmi,mi�1q P ΦpRq. Note that the mi are not necessarily distinct at this point. As M ( A2

we have pmi,mjq P ΦpRq if i   j. Therefore, by M ( A3, mi � mj for i   j.

At this point we can ask if we can do even better. Can we find a formula which is only satisfiedby uncountable models ? The Lowenheim-Skolem theorem will answer this question negatively.It’s proof requires non-trivial techniques that we will get to know in the next few chapters.

1.3 Proofs

In the above sections we have considered logic from the point of view of truth. We have definedwhat it means for a formula to be true in a structure and we have asked questions aboutdefinability: what is the set of structures in which a certain formula is true. There is anotherpoint of view on formulas motivated by the question what we do with them, i.e. how we usethem for reasoning and carrying out proofs. This latter viewpoint leads to proof theory.

Definition 1.7. A proof in natural deduction for classical logic NK is a tree of formulas. Aleaf of this tree is called axiom if it is of the form A_ A for some formula A or t � t for someterm t. Otherwise a leaf is an assumption. Each assumption is either open or discharged. Anopen assumption is just a formula A, it can be discharged by a rule below it and is then writtenas rAsi where i is the number of the rule which has discharged it.

A proof of a formula A possibly containing axioms as well as open or discharged assumptionsis written using dots as

....A

To emphasise the presence of certain open or discharged assumptions they are mentioned ex-plicitly as in

B....A or

rBsi....A as well as

Γ....A

for a set Γ of open assumptions.

The set of NK-proofs is defined inductively allowing the formation of new proofs by applyingany of the following rules:

....A

....AÑ BB

ÑE

rAsi....B

AÑ BÑi

I

....A

.... AK

E

rAsi....K A

iI

....KA

efq

5

Page 10: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

....A

....B

A^B^I

....A^BA

^E1

....A^BB

^E2

....A

A_B_I1

....B

A_B_I2

....A_B

rAsi....C

rBsi....C

C_i

E

....@xAArxzts

@E

....Arxzts

DxADI

provided t does not contain a variable that is bound in A

....Arxzαs

@xA@I

provided α does not occur in A nor in the open assumptions of the proof

....DxB

rBrxzαssi....A

ADiE

provided α does not occur in A nor in B nor in the open assumptions of the right-hand proof ofA. In the cases @I and DE, α is called eigenvariable and the side condition is called eigenvariablecondition.

....s � t

....Arxzss

Arxzts�

....s � t

....Arxzts

Arxzss�

provided s and t do not contain variables that are bound in A.

If π is a proof of A from the open assumptions B1, . . . , Bn this is written as π : B1, . . . , Bn $ A.A formula A is called provable if there is a proof π s.t. π : $ A, i.e. there is a proof of A withoutopen assumptions.

Example 1.4. Some proofs (make sure you understand how they are constructed step by stepsuccessively discharging assumptions):

r A_Bs1

r As3 rAs2

K E

Befq

rBs3

B_3

E

AÑ BÑ2

I

p A_Bq Ñ AÑ BÑ1

I

6

Page 11: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

For the next proof we assume that x R FVpBq and use this assumption at the @E-inference:

π1 �

Arxzαs

@x pAÑ Bq

Arxzαs Ñ B@E

BÑE

π2 �DxA

rArxzαss1@x pAÑ Bq

Arxzαs Ñ B@E

BÑE

BD1

E

π3 � rDxAs2rArxzαss1

r@x pAÑ Bqs3

Arxzαs Ñ B@E

BÑE

BD1

E

DxAÑ BÑ2

I

@x pAÑ Bq Ñ pDxAÑ BqÑ3

I

We have π1 : Arxzαs,@x pAÑ Bq $ B and π2 : DxA,@x pAÑ Bq $ B andπ3 : @x pAÑ Bq Ñ pDxAÑ Bq.

Let F be Dx@y pP pxq _ P pyqq. The proof of F uses the axiom F _ F in an essential way.

F _ F

r F s1

r F s1

rP pαqs2

P pαq _ P pβq_I1

@y pP pαq _ P pyqq@I

FDI

K E

P pαq 2

I

P p0q _ P pαq_I2

@y pP p0q _ P pyqq@I

FDI

K E

Fefq

rF s1

F_1

E

Short Digression: The Curry-Howard Isomorphism

One of the central motivations for studying natural deduction comes from computer science.The Curry-Howard isomorphism constitutes a strong link between proof theory and the theoryof programming languages. In order to understand this link, we have to introduce the lambdacalculus first. The set of lambda terms is defined as follows:

1. Variables x, y, z, x1, x2, . . . are lambda terms.

2. If M is a lambda term and x is a variable, then λx.M is a lambda term.

3. If M and N are lambda terms, then M �N , often written as MN is a lambda term.

The first construction is called abstraction and formalises the creation of a function from a term.For example, x � 5 is a term in an arithmetical language. The function that assign to each xthe value x � 5 is expressed by λx.x � 5 in the lambda calculus. The second construction iscalled application and formalizes the application of a function to an argument. For example,

7

Page 12: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

the application of the above function to the number 3 would be written as pλx.x � 5q3. Thelambda calculus is a theoretical model for functional programming languages such as LISP.

It is natural to assign a type to each term that will indicate what kind of arguments the termaccepts and what kind of values it will produce. For example we can imagine a functionG : pN Ñ Nq Ñ N Ñ N, i.e. G takes as input a function of type N Ñ N as well as a naturalnumber and delivers a natural number as output, e.g. Gpf, nq �

°ni�0 fpiq. To systematically

assign types to lambda terms one considers type inference systems that contain rules of the form

M1 : A1 . . . Mn : An

M : A

where typically M is composed of the Mi and the rule is to be interpreted as: if Mi has type Ai

for i � 1, . . . , n, then M has type A. For the case of the lambda calculus we will consider typesthat are built from the type constructor Ñ where A Ñ B means “function with argument oftype A and value of type B”. The following typing rules suggest themselves:

M : A N : AÑ BNM : B

rx : As....

M : Bλx.M : AÑ B

We can now observe that the type-part of the above type inference rules corresponds exactly tothe logical rules for the implicational fragment of natural deduction. This kind of correspondencebetween proof systems and type systems is called Curry-Howard isomorphism and applies tomuch more systems than just the one described here. Furthermore, it also connects computationrules for the lambda calculus with the important proof transformation of normalisation.

End of Digression

Having now seen these two points of view on formulas, the first one emphasising their meaningand leading to the notion of truth in a structure and the second one emphasising their use andleading to the notion of proof it is natural to ask how these two approaches compare. Whatis the relationship between provability and validity? It will turn out, and this is the centralresult of the first chapter, that the provable formulas are exactly the valid formulas. The easierdirection of this equivalence is the soundness theorem that we will prove below. Before thathowever let us make two basic observations.

Lemma 1.1. Let pM,Φq be a structure, A be a formula and s, t variable-free terms s.t. Φpsq �Φptq. Then pM,Φq ( Arxzss iff pM,Φq ( Arxzts.

Proof. left as exercise.

Lemma 1.2. If π : Γ $ A and t is a term not containing any variable that appears in π, thenΓrxzts $ Arxzts is provable.

Proof. left as exercise.

Theorem 1.1 (Soundness). If A is provable then A is valid.

Proof. Let π : Γ $ A and, writing Γ Ñ A for the formula�

BPΓB Ñ A, we show by inductionon π that Γ Ñ A is valid. As Γ and A might contain free variables, the formula Γ Ñ A isvalid iff @x pΓ Ñ Aq is valid where x � px1, . . . , xnq and tx1, . . . , xnu � FVpΓq Y FVpAq. Butnow @x pΓ Ñ Aq is valid iff for all pM,Φq and for all m1, . . . ,mn P M : pM,Φ Y tc ÞÑ muq (

8

Page 13: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Γrxzcs Ñ Arxzcs. We abbreviate ΦY tc ÞÑ mu as Φ1, as well as pM,Φ1q as M1 and Γrxzcs as Γ1

and Arxzcs as A1, etc.

If π is an axiom of the form A _ A or t � t, then π : $ A _ A or π : $ t � t respectively,which are valid formulas. The case of π being an assumption A is also immediate: A Ñ A isvalid.

Let π be a proof of the form

Γ....A

∆....B

A^B^I

Let M � pM,Φq be any structure, let tx1, . . . , xnu � FVpΓqYFVp∆qYFVpAqYFVpBq and letm1, . . . ,mn PM , then by induction hypothesis M ( Γ Ñ A so M1 ( Γ1 Ñ A1 and M ( ∆ Ñ Bso M1 ( ∆1 Ñ B1. Therefore M1 ( Γ1 ^∆1 Ñ A1 ^B1 hence M ( Γ^∆ Ñ A^B.

Let π be a proof of the form

Γ....Arxzts

DxADI

let M � pM,Φq be a structure, tx1, . . . , xnu � FVpΓq Y FVpArxztsq and let m1, . . . ,mn P Mthen by induction hypothesis M ( Γ Ñ Arxzts so M1 ( Γ1 Ñ A1rxzt1s. Assume M1 ( Γ1,then M1 ( A1rxzt1s and by the variable condition t1 is variable-free so m :� Φ1pt1q P M and byLemma 1.1 we have pM,Φ1 Y tc ÞÑ muq ( A1rxzcs, i.e. M1 ( DxA1 hence M ( Γ Ñ DxA.

Let π be a proof of the form

Γ....DxB

∆ rBrxzαssi....A

ADiE

let M � pM,Φq be a structure, tx1, . . . , xnu � pFVpΓq Y FVp∆q Y FVpAq Y FVpBqqztxu andlet m1, . . . ,mn P M , then by the induction hypothesis M ( Γ Ñ DxB so M1 ( Γ1 Ñ DxB1

and M ( ∆ ^ Brxzαs Ñ A. Therefore M1 ( ∆1 ^ B1rxzαs Ñ A1 as α � xi because α doesnot appear free in ∆, A,B by the eigenvariable condition and by Lemma 1.2 it can be renamedif it appears in Γ. Assume now M1 ( Γ1 ^∆1, then M1 ( DxB1 and M1 ( B1rxzαs Ñ A1 i.e.M1 ( @x pB1 Ñ A1q i.e. M1 ( DxB1 Ñ A1 so M1 ( A1 hence M ( Γ^∆ Ñ A.

Let π be a proof of the form

Γ....s � t

∆....Arxzss

Arxzts�

let M � pM,Φq be a structure and tx1, . . . , xnu � pFVpΓq YFVp∆q YFVps � tq YFVpAqqztxuand let m1, . . . ,mn P M . By induction hypothesis M ( Γ Ñ s � t so M1 ( Γ1 Ñ s1 � t1 andM ( ∆ Ñ Arxzss so M1 ( ∆1 Ñ A1rxzs1s. Assume now M1 ( Γ1 ^ ∆1, then M1 ( s1 � t1

and by the variable condition s1 and t1 are variable-free, hence Φ1ps1q � Φ1pt1q. FurthermoreM1 ( A1rxzs1s and by Lemma 1.1 also M1 ( A1rxzt1s so M ( Γ^∆ Ñ Arxzts.

We did not treat the cases ^E1 ,^E2 ,_I1 ,_I2 , I, E, efq,ÑI,ÑE,@I,@E. These are left asexercise to the reader.

9

Page 14: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

On the other hand, it will turn out that also every valid formula is provable. This result is thecompleteness theorem. In order to prove it we have to develop some more technology in thenext sections.

Example 1.5. To finish this section about proofs here are some non-proofs that each contain aviolation of a side condition at the rule marked with p�q, but are otherwise correct, and proveinvalid formulas.

0 � 0

rα � 0s1

@xx � 0 @p�qI

α � 0 Ñ @xx � 0Ñ1

I

@y py � 0 Ñ @xx � 0q@I

0 � 0 Ñ @xx � 0@E

@xx � 0ÑE

α � αDy α � y

DI

@xDy x � y@I

Dy y � 1 � y @p�qE

r0 � 2 � 0s1

Dy y � 2 � yDI

rz � 2 � zs2α � α@z z � z

@I

@z z � 2 � z �p�q

@z z � 2 � zD2

E

0 � 2 � 0 Ñ @z z � 2 � zÑ1

I

1.4 Theories

Before we start to work with one of the most central notions of mathematical logic – that of atheory – it will be useful to make some observations about countable sets.

Lemma 1.3.

1. A set X is countable iff there is a surjection ψ : NÑ X.

2. If X is countable and Y � X then Y is countable.

3. If X and Y are countable, then X Y Y is countable.

4. If X and Y are countable, then X � Y is countable.

5. If X is countable and k ¥ 1 then Xk is countable.

6. If Xi is countable for each i P N, then�

iPNXi is countable.

7. If X is countable, then�

kPNXk is countable.

Proof. 1. IfX is countably infinite note that every bijection is a surjection. IfX � tx0, . . . , xnuis finite, let ψpiq � xi for 0 ¤ i ¤ n and ψpjq � xn for j ¡ n. For the other direction,let ψ be a surjection, then X is tψp0q, ψp1q, ψp2q, . . .u and removing duplicates from thesequence pψpiqqi¥0 yields a bijective ϕ : NÑ X.

2. Obvious if Y is finite. Otherwise, let ϕ : NÑ X be a bijection and let y0 P Y . Define

ψ : NÑ Y, n ÞÑ

"ϕpnq if ϕpnq P Yy0 otherwise

which is a surjection.

10

Page 15: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

3. Let ϕ : N Ñ X and ψ : N Ñ Y be bijections. We can obtain a bijection χ : N Ñ X Y Yby setting

χpnq :�

"ϕpkq if n � 2kψpkq if n � 2k � 1

We can picture χ in a diagram as

X � � �

Y � � ���

�������

??

��

�������

??

��

�������

??

��

where the first line represents X in the order given by ϕ and the second line Y in theorder given by ψ and the bijection χ is a path through the infinite graph X Y Y thattouches every vertex exactly once.

4. We can write X � Y and a bijection χ : NÑ X � Y as a diagram

� � �

� � �

� � �

� � �

� � �

......

......

.... . .

//

����

���

��

��

�������

??

�������

?? //

����

���

��

����

���

��

����

���

��

��

�������

??

�������

??

�������

??

??

5. By induction on k. If k � 1 it is obvious. For k � 1 observe that Xk�1 � Xk � X, byassumption X is countable and by induction hypothesis Xk is countable, so by 4 alsoXk�1 is countable.

6. By assumption, there are bijections ϕi : N Ñ Xi for every i P N. Define ψ : N � N Ñ�iPNXi by ψpi, nq � ϕipnq, then ψ is a surjection. By 4 there is a bijection χ : NÑ N�N,

so ψ � χ : NÑ�

iPNXi is a surjection hence�

iPNXi is countable.

7. by 5 and 6.

Given a language L we can assign a number to each symbol that might appear in a formula ofL and so we can identify a formula (as well as a term) in L containing k symbols with a k-tupleof natural numbers. By the above result the set of terms as well as the set of formulas of agiven language (and any subset of it, in particular the set of sentences) is countable.

Definition 1.8. Let Γ be a set of sentences. The deductive closure ClpΓq of Γ is defined astA sentence | Γ $ Au.

A set of sentences is called theory if it is deductively closed, i.e. ClpT q � T .

A theory T in a language L is called Henkin theory if for each sentence DxA in L there is aconstant cA in L s.t. T $ DxAÑ ArxzcAs.

A theory T 1 in a language L1 is an extension of a theory T in a language L if L � L1 and T � T 1.

11

Page 16: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

A theory T 1 is a conservative extension of a theory T in a language L if it is an extension andif for every L-sentence A: T 1 $ A implies T $ A.

A theory T 1 is a Henkin extension of a theory T if it is an extension and a Henkin theory.

Our first task will be to construct Henkin theories. These will turn out to be very useful for theproof of the completeness theorem. Sentences of the form DxA Ñ ArxzcAs are called Henkinaxioms, the cA are called Henkin constants. Let T be a theory in a language L. A first naiveattempt to obtaining an Henkin extension of T might be to define

L� :� LY tcA | DxA sentence in Lu, and

T � :� ClpT Y tDxAÑ ArxzcAsu | DxA sentence in Luq

Note that L� is countable because L as well as the set of L-sentences are.

Lemma 1.4. If π : Γ $ A, c is a constant and x a variable which does not appear in π, thenπrczxs : Γrczxs $ Arczxs.

Proof. left as exercise (cf. Lemma 1.2).

Lemma 1.5. T � is a conservative extension of T .

Proof. It is obviously an extension. For conservativity suppose T � $ A with A in L. Thenthere are Γ � T , Henkin axioms H1, . . . ,Hn s.t. Γ, H1, . . . ,Hn $ A. We proceed by inductionon n. For n � 0, T $ A. For n ¡ 0, let Hn � DxB Ñ BrxzcBs. Then

Γ, H1, . . . ,Hn�1 $ pDxB Ñ BrxzcBsq Ñ A.

By Lemma 1.4Γ, H1, . . . ,Hn�1 $ pDxB Ñ Brxzysq Ñ A

soΓ, H1, . . . ,Hn�1 $ @y ppDxB Ñ Brxzysq Ñ Aq

and using quantifier shiftings

Γ, H1, . . . ,Hn�1 $ pDxB Ñ Dy Brxzysq Ñ A

henceΓ, H1, . . . ,Hn�1 $ A.

We obtain T $ A by induction hypothesis.

Lemma 1.6. Let T be a theory, define T0 :� T , Tn�1 :� T �n and Tω :��

i¥0 Ti. Then Tω is aconservative Henkin extension of T .

Proof. Note that Ti � Ti�1 and hence�

i¥0 ClpTiq � Clp�

i¥0 Tiq (see exercises). Therefore

Tω �¤i¥0

Ti �¤i¥0

ClpTiq � Clp¤i¥0

Tiq � ClpTωq

is a theory. It is conservative because Tω $ A implies that there is a k s.t. Tk $ A and Tkis conservative over T by induction using Lemma 1.5. Tω is a Henkin theory because for DxAin Lω, DxA is in some Lk so cA is in Lk�1 and Tk�1 $ DxA Ñ ArxzcAs so cA is in Lω andTω $ DxAÑ ArxzcAs (where Li is the language of Ti).

12

Page 17: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Definition 1.9. A theory T in a language L is called complete if for every sentence A in L:T $ A or T $ A.

A theory T is called consistent if T & K.

Lemma 1.7. Every consistent theory T has a consistent complete extension T 1 in the samelanguage.

Proof. Let L be the language of T and let Ai be an enumeration of all sentences in L. Define

T0 :� T

Tn�1 :�

"ClpTn Y tAnuq if ClpTn Y tAnuq is consistentTn otherwise

Tω :�¤i¥0

Ti

Then Tω is consistent for suppose Tω $ K, then there are A1, . . . , An P Tω s.t. A1, . . . , An $ Kand therefore there is a k s.t. Tk $ K but all Tk are consistent. Furthermore Tω is complete: LetA be in L, then A � Ak for some k. If ClpTk Y tAkuq is consistent, then Tk�1 $ Ak. OtherwiseClpTk Y tAkuq is inconsistent, i.e. Tk, Ak $ K, but then Tk $ Ak Ñ K hence Tk $ Ak by I.

1.5 Completeness

A central technical tool for the proof of the completeness theorem is the canonical structure ofa theory, sometimes also called term model. Let T be a theory in a language L. We constructthe canonical structure M � pM,Φq of T as follows. For variable-free terms t, s of T writet � s for T $ t � s. Note that � is an equivalence relation, for a term t we write rts for its�-equivalence class. The elements of M are the equivalence classes of �. We now define Φ by

1. Φpcq � rcs for a constant symbol c,

2. Φpfqprt1s, . . . , rtnsq � rfpt1, . . . , tnqs for a function symbol f , and

3. prt1s, . . . , rtnsq P ΦpP q iff T $ P pt1, . . . , tnq for a predicate symbol P .

For the above items 2 and 3 to be well-defined we have to verify that the definition does notdepend on the choice of the representative ti of the equivalence class rtis. Suppose we hadchosen different representatives s1, . . . , sn, then, as si � ti also T $ si � ti and by the equalityrules of NK we have T $ fps1, . . . , snq � fpt1, . . . , tnq hence fps1, . . . , snq � fpt1, . . . , tnq andT $ P pt1, . . . , tnq iff T $ P ps1, . . . , snq so Φ is well-defined.

Lemma 1.8. Let T be a consistent complete Henkin theory, M be its canonical structure, A bea sentence. Then M ( A iff T $ A.

Proof. Let M � pM,Φq. We first show Φptq � rts by induction

1. Φpcq � rcs by definition of Φ.

2. Φpfpt1, . . . , tnqq � ΦpfqpΦpt1q, . . . ,Φptnqq �IH Φpfqprt1s, . . . , rtnsq � rfpt1, . . . , tnqs.

Now we proceed to show M ( A iff T $ A by induction on A

13

Page 18: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

1. M ( P pt1, . . . , tnq iff pΦpt1q, . . . ,Φptnqq P ΦpP q iff prt1s, . . . , rtnsq P ΦpP q iff T $ P pt1, . . . , tnq.

2. M ( s � t iff Φpsq � Φptq iff rss � rts iff s � t iff T $ s � t.

3. M ( A iff M * A iff (by IH) T & A.

T & A implies T $ A by completeness and T $ A implies T & A by consistency.

4. M ( A_B iff M ( A or M ( B iff, by induction hypothesis, T $ A or T $ B.

Then T $ A _ B because T is deductively closed. If, on the other hand, T $ A _ B,then T $ A or T $ B for suppose T & A and T & B then by completeness T $ A andT $ B which contradicts consistency of T .

5. M ( DxA iff there is a rts P M s.t., for Φ1 � Φ Y tc ÞÑ rtsu for a fresh constant symbolc, pM,Φ1q ( Arxzcs. Now Φ1pcq � Φ1ptq so by applying Lemma 1.1, pM,Φ1q ( Arxzcs iffpM,Φ1q ( Arxzts. But c does not appear inArxzts, so pM,Φ1q ( Arxzts iff pM,Φq ( Arxztswhich, by induction hypothesis, is equivalent to T $ Arxzts. To sum up, we have provedM ( DxA iff there is a t s.t. T $ Arxzts.

If T $ Arxzts then, by T being deductively closed, also T $ DxA. For the other direction,let T $ DxA, then as T is a Henkin theory, there is a constant cA s.t. T $ ArxzcAs andletting t � cA we obtain M ( DxA.

The other cases are left as exercises or alternatively follow from normal form theorems.

We have already seen that the set of terms in a countable language is itself countable. Theelements of the canonical model of a theory are equivalence classes of terms and therefore acanonical model is countable, i.e. has a countable domain.

Lemma 1.9 (Main Lemma). Every consistent theory T has a countable model.

Proof. By Lemma 1.6 there exists a conservative, and thus consistent, Henkin extension T 1 ofT . By Lemma 1.7 there is a consistent and complete extension T � of T 1. T � is a Henkin theorytoo because T � and T 1 are in the same language. Let M be the canonical structure of T �, thenM ( T � by Lemma 1.8 and M ( T because T � is an extension of T .

Theorem 1.2 (Completeness). If A is a valid sentence then A is provable.

Proof. If A is valid then A is unsatisfiable. So, by Lemma 1.9, Clpt Auq is inconsistent, i.e.there is a proof

r Asi....KA raai

The completeness theorem can also be stated in a more general form w.r.t. a theory T .

Theorem 1.3. If T ( A then T $ A.

14

Page 19: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Proof. Suppose T & A, then ClpT Y t Auq is consistent for suppose T, A $ K, then by

T r Asi....KA raai

also T $ A. So T Y t Au has a model M, i.e. M ( T and M * A, so T * A.

Theorem 1.4 (Compactness). Let Γ be a set of sentences. If every finite Γ0 � Γ is satisfiable,then Γ is satisfiable.

Proof. Suppose Γ is unsatisfiable, then ClpΓq � Γ is unsatisfiable and by Lemma 1.9, ClpΓq isinconsistent, i.e. there is a proof π of Γ $ K. Letting Γ0 � Γ be the finite set of assumptionsused in π, we have a proof of Γ0 $ K and therefore Γ0 is unsatisfiable.

The compactness theorem is a very useful tool for the construction of models as it allows to“pass to the limit” after one has carried out a model construction on all finite subsets. Forexample, we have seen in Section 1.2 that there is an infinite set of sentence Γ � tLn | n ¥ 1uin the empty language s.t. M ( Γ iff M is infinite. This set Γ is an infinite set of sentences –a natural question is now whether it is possible to strenghten this characterisation by findinga finite set having the same property. It turns out that such a set does not exist and thecompactness theorem enables us to proves this:

Corollary 1.1. There is no finite set of sentences Γ in the empty language s.t. M ( Γ iff Mis infinite.

Proof. Suppose that such a à exists and let I ��

Γ. We have M ( I iff M is finite. Consider∆ � t Iu Y tLn | n ¥ 1u. Let ∆0 be a finite subset of ∆, then ∆0 � t Iu Y tLn | 1 ¤ n ¤ mufor some m and every structure of size m� 1 is a model of ∆0. So by the compactness theorem∆ would have a model which is impossible as it could be neither finite nor infinite.

Another of the important limitative theorems about first-order logic is the following:

Theorem 1.5 (Lowenheim-Skolem). Every satisfiable set of sentences has a countable model.

Proof. Let Γ be a set of sentences. First, if Γ is satisfiable then ClpΓq is consistent, for supposeClpΓq would not be consistent, then there would be a proof of Γ0 Ñ K for Γ0 � Γ, so Γ0 wouldnot be satisfiable and hence also Γ. Then, by Lemma 1.9 we obtain a countable model M ofClpΓq hence of Γ.

The above-mentioned set tLn | n ¥ 1u has exactly the infinite structures as models. Anothernatural generalisation of this characterisation would be a set of sentences having only uncount-able models. However, the Lowenheim-Skolem theorem shows that such a set does not exist.

Corollary 1.2. There is no set of sentences having only uncountable models.

Theorem 1.6 (Upward Lowenheim-Skolem). Every set of sentences that has an infinite modelhas an uncountable model.

Without Proof.

15

Page 20: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Short Digression: Set theory and the Skolem paradox

A motivation for the above Skolem-Lowenheim theorem is the following argument, known asSkolem paradox: Consider an axiom system for set theory such as ZFC. Such axiom systemswork in a simple language which contains P as only predicate symbol and every element of thedomain is a set. ZFC is a very strong theory and allows the formalisation of (most) mathematicalproofs, in particular, let F be a sentence of the form Dϕpϕ : N Ñ R ^ ϕ bijectionq whichexpresses the fact that R is uncountable, then ZFC $ F .

Now, by the Lowenheim-Skolem theorem ZFC has a countable model, say M and therefore alsoM ( F , and so M * Dϕpϕ : N Ñ R ^ ϕ bijectionq. However, by countability of M there areonly countable many real numbers in M (real numbers are represented as certain kinds of sets),so there exists a bijection f between N and the reals in M.

The solution to this paradoxical situation is the insight that while this f does indeed exist itdoes not exist in M, i.e. there is no set in the domain of M which represents f .

End of Digression

16

Page 21: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Chapter 2

Arithmetic

In the first chapter we have given an answer to the following question: Is there a syntacticcharacterization of the set of valid sentences, i.e. of tA sentence | M ( A for all Mu? Theanswer is yes, one such characterization is the calculus NK as shown by the soundness andcompleteness theorems. There are many equivalent other proof calculi that could have beenused instead.

In this chapter we are going to ask the analogous question for the case of arithmetic: Is therea syntactic characterization of the set of all arithmetically true sentences, i.e. of tA sentence |N ( Au? Here N � pN,Φq is the standard-model of arithmetic which is an LN-structure withthe natural numbers as its domain and Φ being the standard interpretation, i.e. Φp0q � 0, Φpsqis the successor function, Φp�q is addition, etc. The answer to this question is no and will begiven by the first incompleteness theorem.

There are two points worth mentioning here. First of all, in order to answer such a questionpositively it is enough to provide a certain particular characterization (in our case: NK) andargue that it is obviously a syntactic characterization. However, in order to answer such aquestion negatively it is necessary to make mathematically precise what the phrase “syntacticcharacterization” is supposed to mean. This will be done later by introducing the notion ofaxiomatisable theory.

Secondly, note that the two questions above are of a fundamentally different nature. In thesetting of first-order logic we ask about the set of valid sentences, i.e. sentences which are truein all models. The point of view taken here is that of a theory which describes many structures,mathematical examples are the theory of groups or the theory of vector spaces. In studyingtheories of arithmetic however we are in a different situation: Here we have a particular intendedmodel, namely the standard model described above. Arithmetical theories, in contrast to e.g.the theory of groups, are therefore (usually) intended to describe this particular model. Theformer kind of theory, intended to describe many structures, has been called modern and thelatter, intended to describe a certain particular structure, has been called classical by Shoenfield.

2.1 Recursive Functions

One of the central questions of computability theory is

Which functions are computable?

17

Page 22: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

To understand that this question makes sense it is first necessary to see that there are uncom-putable functions. To that aim consider the following

Proposition 2.1. The set tf : NÑ t0, 1uu is uncountable.

On the other hand, every programming language has only countably many programs, each oneof them can be associated to a finite string, hence a finite sequence of zeros and ones, i.e. anatural number. Therefore “most”, i.e. uncountably many, functions are not computable.

Proof of Proposition 2.1. We identify a function f : N Ñ t0, 1u with an infinite sequence ofzeros and ones. Suppose there is a list a1, a2, . . . of all infinite zero-one sequences. We writeai,j for the j-th element of the i-th sequence. Define an infinite zero-one sequence d by settingdi � 1� ai,i. Then d is not in the list paiqi¥1 for suppose there would be a k s.t. d � ak, thendk � ak,k but at the same time dk � 1� ak,k. Contradiction.

The above proof is also known as Cantor’s diagonal argument and it plays a central role incomputability theory. We will also encounter it later in the proof of the incompleteness theorems.The above result also entails that the set of real numbers is uncountable if some care concerningthe binary representations of real numbers is taken.

In this section we will introduce the recursive functions which are composed of building blockswhich are obviously computable and so all recursive functions are computable.

Definition 2.1 (basic functions).

1. For any n ¥ 0 define a zero function zn : Nn Ñ N as znpx1, . . . , xnq � 0

2. For any n ¥ 1 and any k P t1, . . . , nu define a projection function idnk : Nn Ñ N as

idnkpx1, . . . , xnq � xk.

3. Define the successor function s : NÑ N as spxq � x� 1.

Definition 2.2 (composition). For f : Nn Ñ N and g1, . . . , gn : Nk Ñ N define the compositionCnrf, g1, . . . , gns : Nk Ñ N by Cnrf, g1, . . . , gnspx1, . . . , xkq � fpg1px1, . . . , xkq, . . . , gnpx1, . . . , xkqq.

If for a composition n � 1, then Cnrf, gs � f � g, for example if fpxq � x2 and gpx, yq � x� y,then Cnrf, gspx, yq � pf � gqpx, yq � fpgpx, yqq � px� yq2.

Example 2.1. Every constant function cnk : Nn Ñ N, px1, . . . , xnq ÞÑ k can be obtained from thebasic functions by composition as cn0 � zn and cnk�1 � Cnrs, cnk s.

Definition 2.3 (primitive recursion). For f : Nn Ñ N and g : Nn�2 Ñ N define the functionPrrf, gs : Nn�1 Ñ N by

Prrf, gspx1, . . . , xn, 0q � fpx1, . . . , xnq

Prrf, gspx1, . . . , xn, y � 1q � gpx1, . . . , xn, y,Prrf, gspx1, . . . , xn, yqq

So for example if h � Prrf, gs, then hpx, 2q � gpx, 1, hpx, 1qq � gpx, 1, gpx, 0, hpx, 0qqq �gpx, 1, gpx, 0, fpxqqq. Algorithmically this means to first compute fpxq as basis of the recur-sion and the to use g for the recursion step to as many times as necessary to compute hpx, yq.

A function is called primitive recursive if it can be obtained from the basic functions by com-position and primitive recursion.

18

Page 23: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Example 2.2. Binary addition of natural numbers is primitive recursive. Let f : N3 Ñ N,px1, x2, x3q ÞÑ x3 � 1 and define g : N2 Ñ N as g � Prrid1

1, f s. Let us now prove that gpx, yq �x � y by induction of y. If y � 0 then gpx, 0q � id1

1pxq � x. For the induction step we havegpx, y � 1q � fpx, y, gpx, yqq � fpx, y, x� yq � x� y � 1.

Let D � Nn. A function f : D Ñ N is called partial function from Nn to N, written asf : Nn

ãÑ N.

Definition 2.4 (Minimization). For f : Nn�1ãÑ N define the partial function Mnrf s : Nn

ãÑ Nby Mnrf spx1, . . . , xnq � y if fpx1, . . . , xn, yq is defined and � 0 and for all z   y, fpx1, . . . , xn, zqis defined and � 0. If there is no such y, Mnrf spx1, . . . , xnq is undefined.

A partial function is called partial recursive function if it can be obtained from the basic functionsby composition, primitive recursion and minimization. A total recursive function is a partialrecursive function which is defined for every n P N.

Example 2.3. The subtraction function which to pm,nq associates m�n is defined on the naturalnumbers only if m ¥ n. We can obtain it from minimization by observing

m� n � �pm,nq � minktm � n� ku � min

ktχ�pm,n� kq � 1u � min

ktχ�pm,n� kq � 0u

� MnrCnrχ�, id31,Cnr�, id3

2, id33ssspm,nq

So � is a partial recursive function (because χ� is a recursive function (which we did not proveformally yet)).

Each of the above basic functions as well as each function built up from them by composi-tion, primitive recursion or minimization is obviously computable in the sense that we caneasily imagine an algorithm that computes it. So we can say that all recursive functions arecomputable.

One question however remains: is every function that is computable also recursive ? This ques-tion is not a mathematical one as it contains a term, “computable”, which is not mathematicallydefined. The Church-Turing thesis is the statement that the answer to the above question isyes, in other words: that every computable function is recursive.

This statement being not mathematical we cannot expect a mathematical proof of it. Thereis however compelling empirical evidence for the truth of the Church-Turing thesis which con-sists mainly in a number of very different computation formalisms that are all equivalent tothe recursive functions, for example the lambda calculus which is closely related to functionalprogramming languages or register- and Turing-machines which have a structure similar to aprocessor architecture.

So far, we have only considered functions to be (primitive) recursive. These notions can beextended to sets of tuples of natural numbers in a straightforward way by considering thecharacterstic functions of such sets.

Definition 2.5. For S � Nk the function χS : Nk Ñ t0, 1u, defined by

χSpx1, . . . , xkq �

"1 if px1, . . . , xkq P S0 otherwise

is called characteristic function of S.

A set S � Nk is called primitive recursive / recursive if χS is a primitive recursive / recursivefunction.

19

Page 24: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Definition 2.6. A set S � Nk is called recursively enumerable (often abbreviated as r.e.) ifthere is a partial recursive function f : Nk

ãÑ N s.t. dompfq � S.

A function f : N ãÑ Nk : x ÞÑ pf1pxq, . . . , fnpxqq is called primitive recursive / recursive / totalif all fi are primitive recursive / recursive / total.

Proposition 2.2. Let S � Nk. The following are equivalent

1. S is recursively enumerable.

2. S is the range of a partial recursive function f : N ãÑ Nk.

3. S is either H or the range of a total recursive function f : NÑ Nk.

4. There is a recursive R � Nk�1 s.t. x P S iff there is a y s.t. px, yq P R.

Without Proof.

Short Digression: The arithmetical and polynomial hierarchies.

In the above item 4 we have defined a certain class of sets (the r.e. sets) by quantifying over acertain simpler class of sets (the recursive sets). This definition-principle can be carried muchfurther: The arithmetical hierarchy consists of sets Σ0

n, Π0n and ∆0

n for n ¥ 0 and is defined asfollows:

1. Σ00 � Π0

0 � the recursive sets

2. A P Σ0n�1 if there is a B P Π0

n s.t.

x P A iff there is y P N s.t. px, yq P B

3. A P Π0n�1 if there is a B P Σ0

n s.t.

x P A iff for all y P N : px, yq P B

4. ∆0n :� Σ0

n XΠ0n

So the r.e. sets are exactly those in Σ01. This hierarchy is called arithmetical because a set in a

the class Σ0n can be defined by an arithmetical formula

Dx1@x2Dx3 . . . QnxnRpx1, . . . , xnq

where R is recursive and Qn � D for n odd and Qn � @ for n even. Similarly a set in Π0n can

be defined by an arithmetical formula

@x1Dx2@x3 . . . QnxnRpx1, . . . , xnq

where R is recursive and Qn � @ for n odd and Qn � D for n even.

In your course on computational complexity you might have seen already that a set S � N, orproblem in the terminology of complexity theory, is in NP, i.e. the set of problems solvable bya non-deterministic algorithm in polynomial time, iff there is a binary relation R � N2 in P,i.e. decidable by a deterministic algorithm in polynomial time, s.t. x P S iff there is a y P Nwhose length is bounded by a polynomial in the length of x and px, yq P R. Note the apparentsimilarity with items 1 and 4 of the above Proposition. The polynomial hierarchy consists ofsets Σp

n,Πpn and ∆p

n for n ¥ 0 and is defined as follows:

20

Page 25: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

1. Σp0 � Πp

0 � P

2. A P Σpn�1 if there is a B P Πp

n and a polynomial q s.t.

x P A iff there is a y P N with |y|   qp|x|q s.t. px, yq P B

where |x| denotes the length of the binary representation of x.

3. A P Πpn�1 if there is a B P Σp

n and a polynomial q s.t.

x P A iff for all y P N with |y|   qp|x|q : px, yq P B

4. ∆pn :� Σp

n XΠpn

So NP � Σp1 and the pair P/NP plays the same role for the polynomial hierarchy as the pair

recursive/r.e. does for the arithmetical hierarchy.

End of Digression.

2.2 Representability

Definition 2.7. The theory Q of minimal arithmetic is the deductive closure of the followingset of axioms:

@x 0 � spxq

@x@y pspxq � spyq Ñ x � yq

@xx � 0 � 0

@x@y x � spyq � px � yq � x

@xx� 0 � x

@x@y x� spyq � spx� yq

@xx ¢ 0

@x@y px   spyq Ø px   y _ x � yqq

@x@y px   y _ x � y _ y   xq

In the above definition the symbol Ø, which is not part of the object-language, has been used.The formula AØ B is an abbreviation of the formula pAÑ Bq ^ pB Ñ Aq.

Note that each natural number n can be represented in a canonical way in an arithmeticaltheory by the variable-free term snp0q. These terms are called numerals and the numeral of nis denoted by sn.

Definition 2.8. An arithmetical theory T encodes finite sequences if there are formulas Seqpxq,Lenpx, yq, Entrypx, y, zq s.t. for all pn1, . . . , nkq P Nk there is s P N s.t.

1. T $ Seqpssq,2. T $ @y pLenpss, yq Ø y � skq, and

3. for all i P t1, . . . , ku: T $ @z pEntrypss,si, zq Ø z � sniqLemma 2.1. Q encodes finite sequences.

Without Proof.

In the following it will often be useful to write F px1, . . . , xnq for a formula F with FVpF q �tx1, . . . , xnu and F pt1, . . . , tnq for F rx1zt1, . . . , xnztns.

21

Page 26: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Definition 2.9. Let T be a theory in the language of arithmetic. Let f : NkãÑ N be a partial

function and F px1, . . . , xn, yq be a formula. Then F px1, . . . , xn, yq is said to represent f if forall n1, . . . , nk,m P N:

fpn1, . . . , nkq � m implies T $ @y pF p�n1, . . . ,�nk, yq Ø y � smqExample 2.4. Define the (truncated) predecessor function pred : NÑ N by

predp0q � 0, and

predpn� 1q � n.

This function is representable in Q: let F be px � 0^ y � 0q _ x � spyq, then for all n,m P Nwith predpnq � m: Q $ @y pF psn, yq Ø y � smq as the reader is invited to verify as an exercise.

Definition 2.10. Let T be a theory in the language of arithmetic and R � Nk. A formulaApx1, . . . , xkq is said to represent R if for all n1, . . . , nk P N

1. pn1, . . . , nkq P R implies T $ Ap�n1, . . . ,�nkq and

2. pn1, . . . , nkq R R implies T $ Ap�n1, . . . ,�nkq.Lemma 2.2. The set R � Nk is representable in T iff χR is representable in T .

Proof. Let R � Nk be representable in T by a formula Apx1, . . . , xkq. Then the formula

F px1, . . . , xkq :� pApx1, . . . , xkq ^ y � s1q _ p Apx1, . . . , xkq ^ y � 0q

represents χR. To prove this, consider the case pn1, . . . , nkq P R, then as A represents R weknow that T $ Ap�n1, . . . ,�nkq so

T $ @y py � s1 Ø pAp�n1, . . . ,�nkq ^ y � s1qqand

T $ @y ppAp�n1, . . . ,�nkq ^ y � s1q Ø F p�n1, . . . ,�nkqqhence

T $ @y pF p�n1, . . . ,�nkq Ø y � s1q.For the case pn1, . . . , nkq R R it is possible to use an analogous proof, so F represents χR in T .

Now, for the other direction, assume some formula F px1, . . . , xn, yq represents χR. ThenApx1, . . . , xnq :� F px1, . . . , xn,s1q representsR. For the case pn1, . . . , nkq P R, i.e. χRpn1, . . . , nkq �1 we know that T $ @y pF p�n1, . . . ,�nk, yq Ø y � 1q, then T $ F pn1, . . . , nk, 1q Ø 1 � 1, henceT $ Apn1, . . . , nkq. The case of pn1 . . . , nkq R R can be treated analogously so A represents Rin T .

Theorem 2.1 (representability). Every recursive function and predicate is representable in Q.

Proof. In light of the above Lemma 2.2 it suffices to prove representability of all recursivefunctions. We proceed by induction on the operator representation of a recursive function.

For the case zn : Nn Ñ N, pm1, . . . ,mnq ÞÑ 0 let F px1, . . . , xn, yq be y � 0. Then Q $ @ypy �0 Ø y � 0q so zn is represented by F in Q.

For the identity function idnk : Nn Ñ N, pm1, . . . ,mnq ÞÑ mk let F px1, . . . , xn, yq be y � xk. For

m1, . . . ,mn P N and idnkpm1, . . . ,mnq � mk we find that Q $ @y py � �mk Ø y � �mkq so idn

k isrepresented in Q.

22

Page 27: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

For the successor function s : N Ñ N, x ÞÑ x � 1 let F px, yq be y � spxq. Let n P N, thenQ $ @ypy � spsnq Ø y � �n� 1q so s is represented by F px, yq in Q.

For the case of composition, assume we have f : NlãÑ N and g1, . . . , gl : Nk

ãÑ N s.t. gi isrepresented in Q by Gipx1, . . . , xk, yiq for i � 1, . . . , l and f is represented by F py1, . . . , yl, zq.We can choose the variables in which a function is represented by a simple renaming. Then theformula

Hpx1, . . . , xk, zq :� Dy1 . . . DylpG1px1, . . . , xk, y1q ^ . . .^Glpx1, . . . , xk, ylq ^ F py1, . . . , yl, zqq

will represent Cnrf, g1, . . . , gks. Let m1, . . . ,mk, o P N s.t. Cnrf, g1, . . . , gnspm1, . . . ,mkq � o,then there are n1 � g1pm1, . . . ,mkq, . . . , nl � glpm1, . . . ,mkq s.t. fpn1, . . . , nlq � o, so byinduction hypothesis:

Q $ @y1 pG1p�m1, . . . , �mk, y1q Ø y1 ��n1q

...

Q $ @yn pGnp�m1, . . . , �mk, ylq Ø yn � �nnqQ $ @z pF p�n1, . . . , snl, zq Ø z � soq

We have to show thatQ $ @z pHp�m1, . . . , �mk, zq Ø z � soq,

which, by definition of H and representability of the gi, is equivalent to

Q $ @z pDy1 . . . Dyl py1 ��n1 ^ . . .^ yl � snl ^ F py1, . . . , yl, zqq Ø z � soq,which in turn is equivalent to

Q $ @z pF p�n1, . . . , snl, zq Ø z � soqwhich is asserted by the representability of f .

For primitive recursion let f : NkãÑ N and g : Nk�2

ãÑ N s.t. f is represented by a formulaF px1, . . . , xk, zq and g by a formula Gpx1 . . . , xk, y, w, zq. The central idea for this case is toencode primitive recursion as a finite sequence containing all intermediate values. To that aimlet us define a formula Hpx1, . . . , xk, y, zq that will represent h � Prrf, gs : Nk�1

ãÑ N as

Ds p Seqpsq ^

Du pEntryps, 0, uq ^ F px1, . . . , xk, uqq ^

@u   y DvDw pEntryps, u, vq ^ Entryps, spuq, wq ^Gpx1, . . . , xk, u, v, wqq^

Entryps, y, zq q

Let n1, . . . , nk, l P N and assume hpn1, . . . , nk, lq is defined, then for all i P t0, . . . , lu there is avalue mi � hpn1, . . . , nk, iq P N. Let us first show that Q $ Hp�n1, . . . ,�nk,sl,�mlq. As Q encodesfinite sequences there is an s P N encoding the sequence pm0, . . . ,mlq s.t.

Q $ Seqpssqand

Q $ Entrypss,si,�miq

for all i P t0, . . . , lu. Now m0 � fpn1, . . . , nkq, so Q $ F p�n1, . . . ,�nk, �m0q hence

Q $ Du pEntryps, 0, uq ^ F pn1, . . . , nk, uqq

23

Page 28: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Let now i   l, then Q $ Entrypss,si,�miq and Q $ Entrypss,�i� 1,�mi�1q and by representation ofg and the definition of h we also have Q $ Gp�n1, . . . ,�nk,si,�mi,�mi�1q, so

Q $ @u   y DvDw pEntrypss, u, vq ^ Entrypss, spuq, wq ^Gpx1, . . . , xk, u, v, wqq

Finally Q $ Entrypss,sl,�mlq, therefore

Q $ z � �ml Ñ Hp�n1, . . . ,�nk,sl, zq.It remains to show the other direction, i.e. that Q $ Hp�n1, . . . ,�nk,sl, zq Ñ z � �ml. Let us nowgive a description of the proof of this formula in Q: assume Hp�n1, . . . ,�nk,sl, zq, then for someeigenvariable σ we have

Seqpσq and

Du pEntrypσ, 0, uq ^ F p�n1, . . . ,�nk, uqq and

@u   sl DvDw pEntrypσ, u, vq ^ Entrypσ, spuq, wq ^Gp�n1, . . . ,�nk, u, v, wqq and

Entrypσ,sl, zq.It suffices to prove Entrypσ,sl,�mlq to obtain z � �ml as the l-th entry of σ is unique. In fact, wewill prove Entrypσ,si,�miq by induction on i. For i � 0 we have Entrypσ, 0, µq and F p�n1, . . . ,�nk, µqand as F represents f and m0 � fpn1, . . . , nkq also µ � �m0, therefore Entrypσ, 0, �m0q. For the in-duction step we obtain fromH that Entrypσ,si, νq and Entrypσ,�i� 1, ωq andGp�n1, . . . ,�nk, i, ν, ωqfor new eigenvariables ν and ω. We have Entrypσ,si,�miq by induction hypothesis, so ν ��mi and therefore Gp�n1, . . . ,�nk, i,�mi, ωq. But as G represents g we have ω � �mi�1 henceEntrypσ,�i� 1,�mi�1q.

For the case of minimisation, let f : Nk�1ãÑ N be represented by a formula F px1, . . . , xk, y, zq

and let g � Mnrf s : NkãÑ N. We define

Gpx1, . . . , xk, yq :� F px1, . . . , xk, y, 0q ^ @u   y F px1, . . . , xk, u, 0q.

Let n1, . . . , nk P N, abbreviate ai :� fpn1, . . . , nk, iq and m � gpn1, . . . , nkq. For every i ¤ mwe have

Q $ F p�n1, . . . ,�nk,si, zq Ø z � saihence

Q $ F p�n1, . . . ,�nk,si, 0q Ø 0 � sai.Now if i   m then ai � 0 and Q $ sai � 01, so

Q $ F p�n1, . . . ,�nk,si, 0q for i   m (2.1)

but am � 0 soQ $ F p�n1, . . . ,�nk, sm, 0q. (2.2)

ThereforeQ $ F p�n1, . . . ,�nk, sm, 0q ^ @u   sm F p�n1, . . . ,�nk, u, 0q

henceQ $ y � smÑ Gp�n1, . . . ,�nk, yq.

For the other direction, argue again in Q: assume Gp�n1, . . . ,�nk, yq, i.e.

F p�n1, . . . ,�nk, y, 0q (2.3)

1Exercise: for all m,n P N: if m � n then Q $ sm � sn

24

Page 29: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

and

@u   y F p�n1, . . . ,�nk, u, 0q. (2.4)

From 2.1 and 2.3 we obtain y ¥ sm and from 2.2 and 2.4 we obtain sm ¥ y hence y � sm. So

Q $ Gp�n1, . . . ,�nk, yq Ñ y � sm

2.3 Arithmetisation of Syntax

So far, our notions of being recursive, primitive recursive, etc. have only applied to sets ofnatural numbers. We can extend these notions to another countable set X by fixing a suitableinjection ϕ : X Ñ N and calling a set Y � X recursive if ϕpY q � tϕpyq | y P Y u is recursive.We will now construct such ϕ for X being the set of terms, the set of formulas and the set ofproofs over some first-order language. Such an injection is often called Godel-numbering andcan, from the point of view of computer science, best be thought of as an encoding, or dataformat, for X. An encoding of finite sequences of natural numbers as natural numbers inducesan injection from Nω �

�k¥1 Nk to N. For a px1, . . . , xnq P Nω let #px1, . . . , xnq denote the

value of the injection used in Lemma 2.1

Definition 2.11. Let L be a language with predicate symbols Pn0 , P

n1 , . . . of arity n ¥ 1, with

function symbols fn0 , fn1 , . . . of arity n ¥ 1 and constant symbols f0

0 , f01 , . . .. We define the

Godel-numbers of symbols as

#xi � #p0, iq

#Pni � #p1, n, iq

#fni � #p2, n, iq

# p � #p3, 0q

# q � #p3, 1q

# , � #p3, 2q

# � #p3, 3q

# _ � #p3, 4q

etc.

The function # on the symbols as above is injective.

Definition 2.12. Let t be an L-term, then t is a finite sequence of symbols ps0, s1, . . . , snq andwe define #t :� #p#s0,#s1, . . . ,#snq.

Example 2.5.

#f20 px0, x1q � #p#f2

0 ,#p,#x0,#, ,#x1,#qq

� #p#p2, 2, 0q,#p3, 0q,#p0, 0q,#p3, 2q,#p0, 1q,#p3, 1qq P N

which can be evaluated given a concrete definition of #.

Definition 2.13. Let F be an L-formula, then F is a finite sequence of symbols ps0, s1, . . . , snqand we define #F :� #p#s0,#s1, . . . ,#snq. A set Γ of formulas is called primitive recur-sive/recursive/recursively enumerable if #Γ � t#F | F P Γu is.

For example, the set of all formulas is recursive, the set of all sentences is recursive. In a similarway as we have already encoded terms and formulas as natural numbers it is also possible toencode proofs. We do not go through this process in detail as it is rather straightforward. Justa sketch of one possibility to do it: a leaf of a proof that consists of the formula A is encoded asa pair #pi,#Aq where i P N is 0 if the leaf is an open assumption or an axiom and i ¡ 0 if the

25

Page 30: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

leaf is an assumption discharged by the rule with the index i. We assign codes to rule labels#^I,#^E1 , . . . and represent inferences by tuples, e.g. an ^I-inference

.... π1

A

.... π2

BA^B

^I

is encoded as #p#^I,#pA ^ Bq,#π1,#π2q. A tree of tuples as the ones above does notnecessarily represent a correct proof. However, whether such a tree of tuples does indeedrepresents a correct proof can be checked by a primitive recursive function that for the aboveexample would e.g. have to test wether π1 does indeed end with A and π2 does indeed end withB, a proof-checking algorithm. This also plays a role in the encoding of rules that dischargehypotheses. For example, the proof

π �

.... π1

A_B

rAsi.... π2

C

rBsi.... π3

CC

_iE

is encoded as follows: π2 contains A as open assumption. Define π12 as the derivation where Ais replaced by rAsi, then π12 is not a correct proof anymore because a correct proof uses onlythe discharge-indices of existing inferences. But π12 and – analogously – π13 are used for definingthe encoding #π � p#_E, i,#C,#π1,#π

12,#π

13q. The other rules are encoded analogously.

Definition 2.14. Let F be the set of formulas and Π be the set of NK-proofs. A functionf : Π� F Ñ t0, 1u is called primitive recursive / recursive if #f : N� NÑ t0, 1u defined by

#fpx, yq �

"fpπ,Aq if x � #π for a proof π and y � #A for a formula A0 otherwise

is primitive recursive / recursive. A predicate P � Π�F is called primitive recursive / recursiveif its characteristic function χP is.

Lemma 2.3. The proof predicate

Prf :� tpx, yq P N2 | x � #π, y � #A where π is a proof of the sentence Au.

is primitive recursive.

Proof Sketch. Check whether x is the code of a proof and whether y is the code of a formula.If both is true, check whether the proof encoded by x ends with the formula encoded by y anddoes not contain any open assumptions.

Theorem 2.2 (Abstract Completeness). The set of valid sentences is recursively enumerable.

Proof. A sentence F is provable iff there is x P N s.t. px,#F q P Prf. The proof predicate isrecursive so the set of provable sentences is in Σ0

1, i.e. recursively enumerable and by soundnessand completeness (of NK) the set of valid sentences is the set of provable sentences.

The above formulation of the completeness theorem is more abstract than Theorem 1.2 in thatit does not mention a particular calculus in its statement (though of course in its proof we usea particular calculus in the Prf-predicate).

26

Page 31: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

2.4 Incompleteness

We will now make precise what is meant by a syntactic characterization of the set of arithmeti-cally true sentences.

Definition 2.15. A theory T is called axiomatisable if there is a recursive set Γ � T s.t.T � ClpΓq.

The above recursive set Γ can best be thought of as a set of axioms for T which motivates thechoice of the term axiomatisable. Being axiomatisable is a property which we require in orderto accept a characterisation of a theory as a syntactic one.

Lemma 2.4. If T is an axiomatisable theory then it is recursively enumerable.

Proof. Let T � ClpΓq and Γ be recursive. Let A0, A1, A2, . . . be an enumeration of all valid sen-tences in the language of arithmetic which exists by the abstract completeness theorem (Theo-rem 2.2). The following algorithm enumerates T :

Input: i P Nif Ai is of the form B1 ^ . . .^Bk Ñ C and Bj P Γ for j � 1, . . . , k then

print Celse

print Dend if

where D is any sentence provable in T .

Lemma 2.5. If T is an axiomatisable and complete theory then it is recursive.

Proof. If T is inconsistent, it is the set of all sentences which is recursive. So assume T isconsistent. Then, as T is also complete, T & A iff T $ A. Let A0, A1, A2, . . . be a recursiveenumeration of T which exists by Lemma 2.4. The following algorithm is a decision procedurefor T :

Input: formula Ak Ð 0loop

if Ak � A thenreturn 1

end ifif Ak � A then

return 0end if

end loop

By completeness of T the above algorithm terminates for every input A.

The kernel of the proof of the first incompleteness theorem is a diagonal argument which wefirst formulate in a general, abstract form. Let R � N2, for m P N we write Rm for tn P N |pm,nq P Ru.

Lemma 2.6 (Diagonal Lemma). If R � N2 and P � tn P N | pn, nq R Ru then P � Rm for allm.

27

Page 32: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Proof. Suppose P � Rm, then pm,mq P R iff m P Rm iff m P P iff pm,mq R R.

Lemma 2.7. If T � Q is a consistent theory, then T is not recursive.

Proof. We fix a variable z. For a formula A define

EpAq :� tn P N | T $ ArzzsnsuFor every recursive set S � N there is a formula A which represents S in T by the representabilitytheorem, i.e.

1. n P S implies T $ Arzzsns hence n P EpAq and

2. n R S implies T $ Arzzsns which, by consistency of T , implies T & Arzzsns hencen R EpAq.

Therefore S � EpAq. Let now

R :� tpm,nq P N2 | m � #F, T $ F rzzsnsuand observe that

R#A � tn P N | T $ Arzzsnsu � EpAq.

Furthermore, let

P : � tn P N | pn, nq R Ru� tn P N | n � #F or n � #F, T & F rzzsnsu.

By the diagonal lemma P � Rm for all m so, in particular, P � R#A for all A so P � EpAqfor all A. But every recursive set is representable in Q hence in T therefore P is not recursive.Then also T is not recursive for suppose it would be, then also P would be recursive.

Theorem 2.3 (First Incompleteness Theorem). If T � Q is a consistent and axiomatisabletheory, then T is not complete.

Proof. Suppose T � Q is consistent, axiomatisable and complete. By consistency and Lemma 2.7it is not recursive. But by axiomatizability and completeness and Lemma 2.5 it is recursive.Contradiction.

Corollary 2.1. ThpN q is not axiomatisable.

Proof. ThpN q � Q because the axioms of Q are true in N . Also ThpN q is (as every theory ofa structure) consistent and complete.

Corollary 2.2 (Undecidability of First-Order Logic). The set of valid sentences is not recursive.

Proof. Let A be the conjunction of the axioms of Q. Suppose the set of valid sentences wouldbe recursive then also Q would be recursive because Q $ B iff A Ñ B is valid. But Q is notrecursive by the above Lemma 2.7.

28

Page 33: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

The set of valid sentences is therefore an example for a set which is recursively enumerable butnot recursive. There are more direct proofs of the undecidability of first-order logic which donot use the first incompleteness theorem.

A sentence A is called undecidable in a theory T if T & A and T & A. Be careful to notconfuse this notion with that of a decidable set (which in our terminology is a recursive set).The first incompleteness theorem shows that every consistent and axiomatisable extension ofQ has an undecidable sentence. However, the above proof does not directly give an example ofsuch a sentence. We will now carry out an alternative proof by constructing such a sentenceexplicitely. This other proof will also be useful for the second incompleteness theorem. Beforethat we need some preparatory steps:

Definition 2.16. A bounded quantifier is a quantifier of the form Dx px   t ^ Bq or @x px  tÑ Bq.

A formula A is called Σ1-formula if it is logically equivalent to a formula of the form Dx1 � � � DxnBwhere all quantifiers in B are bounded.

A formula A is called Π1-formula if it is logically equivalent to a formula of the form @x1 � � � @xnBwhere all quantifiers in B are bounded.

Lemma 2.8 (Σ1-completeness of Q). If A is a Σ1-sentence with N ( A, then Q $ A.

Without Proof.

Lemma 2.9. There is a Σ1-formula Numpx, yq s.t. for all k, n P N with n � #sk:

Q $ @y pNumpsk, yq Ø y � snqThere is a Σ1-formula Subpx1, x2, x3, x4q s.t. for all a, v, t, b P N where a � #A for a formulaA, v � #z for a variable z, t � #s for a term s and b � #Arzzts:

Q $ @y pSubpsa, sv, ss, yq Ø y � sbqIf T is an axiomatisable theory, then there is a Σ1-formula ProvT pxq s.t. for all n P N

Q $ ProvT psnq iff n � #A and T $ A

for some formula A.

Proof Sketch. The corresponding functions and predicate are recursive.

We will use Godel-numerals, these are the numerals of Godel-numbers. More precisely, for anexpression (i.e. a term, a formula,...) e, the Godel-numeral of e is defined as xey :� �#e.Example 2.6. 0 P N and s0 � 0 is also an LN-term. x0y is again an LN-term, but x0y � 0 becausex0y � �#0 � �#p2, 0, 0q and #p2, 0, 0q P N and #p2, 0, 0q � 0.

For any expression e: Q $ @y pNumpxey, yq Ø y � xxeyyq.

We can now give an alternative proof of a slightly modified version of the first incompletenesstheorem.

Theorem 2.4. If T is a consistent and axiomatisable theory with ThpN q � T � Q then T isincomplete.

29

Page 34: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

In the proof of Lemma 2.7 we have used sets R P N2 and P P N s.t.

#A P P iff p#A,#Aq R R iff T & ArzzxAys

Proof. Now we will formalise the above condition inside the language of arithmetic. To thataim define the formula

Bpzq :� DuDv pNumpz, uq ^ Subpz, xzy, u, vq ^ ProvT pvqq.

which exists as T is axiomatisable. Let us define the so-called Godel-sentence G :� BpxByqwhich expresses that G is not provable in T because:

N ( G iff N * DuDv pNumpxBy, uq ^ SubpxBy, xzy, u, vq ^ ProvT pvqq

iff T & BrzzxBys

iff T & G

Suppose N * G, then by the above T $ G. Furthermore, G is a Π1-sentence, so G is aΣ1-sentence and by Σ1-completeness we know that N ( G implies T $ G and T would beinconsistent, contradiction, so

N ( G.

Suppose now T $ G, then N ( G, contradiction, so

T & G.

Suppose T $ G then N * G by the above so N ( G and by Σ1-completeness T $ G whichcontradicts consistency, so

T & G.

The above sentence G of a theory T is therefore true but undecidable in T . The secondincompleteness theorem will give another example of a sentence which is undecidable in T : thesentence which expresses the consistency of T

ConT :� ProvT pxKyq.

The second incompleteness theorem applies to arithmetical theories which are stronger thanminimal arithmetic. The reason for this is that the proof of the second incompleteness theoremis essentially a formalisation in T of the above alternative proof of the first incompletenesstheorem about T .

Definition 2.17. The arithmetical theory of Peano Arithmetic (PA) is defined as the deductiveclosure of Q and all sentences of the form

Ap0q Ñ @x pApxq Ñ Apspxqqq Ñ @xApxq,

the induction axioms.

Theorem 2.5 (Second Incompleteness Theorem). If T � PA is consistent and axiomatisable,then T & ConT .

30

Page 35: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

Proof. Let G be the Godel-sentence for T . Then

T $ GÑ ProvT px Gyq

because PA proves the Σ1-completeness of Q. On the other hand

G � DuDv pNumpxBy, uq ^ SubpxBy, xzy, u, vq ^ ProvT pvqq

and by Σ1-completeness

T $ NumpxBy, xxByyq and T $ SubpxBy, xzy, xxByy, xGyq,

hence using representability of the Num- and Sub-functions

T $ GÑ ProvT pxGyq.

Furthermore, T proves that ProvT is closed under the inference rules of NK so

T $ GÑ ProvT pxKyq,

i.e.

T $ ConT Ñ G

but as we have seen in the alternative proof of the first incompleteness theorem

T & G

and therefore

T & ConT .

In order to fully appreciate the importance of the incompleteness theorems of Godel it is nec-essary to say a few words about the historical context. Godel’s work is a reaction to Hilbert’sprogramme, which called for a formalisation of mathematical reasoning and for a proof of theconsistency of this formalism by “finitary” means. It has never been made completely precisewhat should be understood as “finitary” but the intention of providing such a proof was toobtain an absolute justification of mathematical reasoning. So the methods employed in thisconsistency proof should themselves be undoubtable. The second incompleteness theorem showsthat this program cannot be fulfilled: for proving the consistency of a theory the theory mustbe transcended.

Finally one should discuss the mathematical significance of the incompleteness theorems. Theexamples of undecidable sentences we have seen so far, the Godel-sentence of a theory as wellas the consistency of a theory, are purely logical statements. One might think at first sight thatthis incompleteness phenomenon only manifests itself on such self-referential statements whichare – outside of logic – hardly used in mathematics. However, this impression is not justified.There are sentences of purely mathematical (as opposed to logical) nature that have been shownto be independent of strong theories. The primary example is the continuum hypothesis, thefirst of Hilbert’s famous 23 problems. We again work in the language of set theory; the linearordering of sets by comparing their cardinality is given by

x ¤ y :� Dϕ pϕ : xÑ y ^ injectivepϕqq

31

Page 36: Mathematical Logic 2 - Theory and LogicFirst-Order Logic 1.1 Formulas An in nite set Xis called countably in nite if there is a bijection ’: N Ñ X. A set is called countable if

andx   y :� x ¤ y ^ y ¤ x

Then the continuum hypothesis is the statement

CH � Dx pN   x   Rq

which has been shown to be independent of Zermelo-Fraenkel set theory ZFC by Godel andCohen.

32