Logic II Lecture Notes

Josef Schicho RISC Linz Johannes Kepler University, A-4040 Linz

           e-mail: Schicho@risc.uni-linz.ac.at

March 29, 2001

Contents

0 Introduction 1 1 Formal Theories 3 2 Theory of Recursion 6 3 Equational Theories 13 4 Predicate Logic 20 5 The Completeness Theorem 25 6 First order theories 29 7 Elementary Theory of Real Numbers 33 8 Formal Euclidean Geometry 36 9 Formal Number Theory 42 10 Hilbert’s 10th problem 47 11 λ-calculus 52 12 Higher Order Logic 59 13 Constructive Logic 64

14 Constructive Analysis 69

0 Introduction

There are two motivations for the desire to formalize reasoning. On the one hand, one wants to have some sort of “quality control”, in order to check and improve reliability and efficiency of proofs. This was the impetus behind Euclid’s efforts to formalize geometry. It was also the motivation of Frege, Russell, Hilbert, Dedekind, …, to construct a universe of mathematics based on formal systems. Historically, the efforts of axiomatization led to the discovery of antinomies, which in turn increased the necessity to improve on reliability. A more modern example are the efforts of Buchberger to improve the “quality of proofs” of his students in his famous Thinking-Speaking-Writing course.

A completely different goal is the desire to automatically generate or verify theorems. This idea can be traced back to Lullus (around 1300, “ars magna”) and Leibniz (1646–1716), who distinguishes decision methods “ars iudicandi” and generation methods “ars inveniendi”. Modern computer science adopted this vision as the core of the “Artificial Intelligence” program. Even though limitations of this approach became clear, we have now many useful algorithms. Most notably are Robinson’s resolution algorithm and Collins’ quantifier elimination algorithm.

The theory of formal calculi of reasoning is called meta-theory, while the theory of relations between formal calculi and their semantics is called model theory. In this course, we discuss selected topics from these two main branches of logics.

Predicate calculus (also called first order logic). We give proofs for Church’s result of undecidability of predicate calculus, Gödel’s completeness theorem, and Herbrand’s theorem.

Formal analysis . We give an axiomatization of the first order theory of the real numbers and the decidability due to Tarski. As an application, we give an axiomatization of geometry (also due to Tarski), which is also decidable. In contrast to this, we discuss constructive analysis in an informal way.

Formal number theory . Two famous negative results - Gödel’s incompleteness theorem and the unsolvability of Hilbert’s 10th problem - are obtained as immediate consequences of two positive results (which are closely related): any recursively enumerable set is arithmetic (Gödel) and any recursively enumerable set is diophantine (Matijasevic).

For the preparation of these notes, I leaned on the book [16], as far as predicate logic and formal number theory is concerned. The section on formal geometry is based on [10], the section on constructive analysis is based on [3], and the section on Hilbert’s 10th problem is based on [15]. Several former and present participants also have contributed to the notes, among them Florina Piroi (completeness theorem), Temur Kutsia (completeness theorem), Cleo Pau (formal number theory), and Igor Rents (Hilbert’s 10th problem).

For further study, I recommend [30, 11, 25, 13, 26, 17, 9, 18, 8, 2] for studying predicate logic and [12, 7, 19, 6, 21, 28, 29, 3] for studying the theory of reals and geometry. For automated theorem proving, I refer to the lectures [14] and to [5].

1 Formal Theories

In this section, we introduce the main concepts of logic, draw the distinctions between object theory, metatheory, and semantics, and explain the objectives and the methods of each of these topics. We conclude this section by giving some philosophical positions on the role and the relations between these topics.

A formal theory consists of

• linguistical part:

– symbols (predicate symbols, function symbols, logical connectives, variables, …

– terms (described by a syntax)

– formulas, sentences (described by a syntax)

• logical part:

– logical axioms

– inference rules

• material part:

– material axioms

A formal theorem is either an axiom or an immediate consequence of other formal theorems by some inference rule. A proof is a sequence of theorems such that each theorem is either an axiom or an immediate consequence of theorems before it.

The purpose of a formal theory is to formally describe reasoning/proving in some informal “real world” theory (number theory, analysis, set theory …).

Metatheory is reasoning about the formal theory (which is also called object theory when the distinction to metatheory is emphasized). Metatheory is again an informal theory.

In contrast to semantics, a metatheory investigates a formal system as formal system, abstracting from the informal theory which is going to be formalized. In finding problems and solutions, it may be guided by the informal system, but in the final statement and in the proof, the use of the interpretation is prohibited.

Typical problems:

• Consistency (does there exists a non-theorem?)

• Completeness (can every formula be either be proven or refuted?)

• Decidability (does there exist an algorithm that decides whether a given formula is a theorem?) ^{1} • Proof theoretical questions:

1The fact that theorems are constructed by a procedure which is usually recursive—the application of inference rules—makes sure that the set of theorems is recursively enumerable.

– Do there exist canonical proofs?

– Given a theorem, how long can the shortest proof be?

Model Theory investigates the relation of the formal system and the informal theory which is going to be formalized. Typical problems:

• Correctness (is every theorem true in the model?)

• Completeness w.r.t. the interpretation, or relative completeness (is every true statement in the model a theorem?)

• Definability (is every statement in the model expressible in the theory?)

• Categoricity (do there exist non-standard models?)

These disciplines are not always strictly separated. For instance, the usual method for showing consistency is to give a model, i.e. a metatheoretic question is given a model theoretic answer.

In the discussion about foundations of mathematics in the beginning of this century, there arose a doubt on the validity of such consistency proofs, because they used the existence of certain mathematical objects. But do these things really exist or is this merely an illusion? It is interesting to listen to the answers given by various schools.

The viewpoint of formalism (Hilbert) is the following. In mathematics, an object exists - by definition - if it can be described consistently. As far as “mathematical truth” is concerned, we need nothing more than a formal theory. Truth is then defined as provability in this theory.

From the formalistic point of view, consistency proofs are a fundamental task, in order to guarantee existence of mathematical objects. But of course, it is not allowed to prove consistency by model theory, because we would fall into a vicious circle. Thus, we ask for a consistency proof with purely meta-theoretic methods, accepting only a small subset of mathematics as the tools for such a proof. Hilbert and his followers required more specifically, that the meta-theory should be restricted to “finitary means”.

In the original sense, Hilbert’s program broke down: there cannot be a finitary proof of the theory of natural numbers, as a consequence of Gödel’s second incompleteness theorem.

On the other hand, there is the viewpoint of intuitionism (Brouwer): certain mathematical object do exist because they exist in the human imagination. In order to justify “mathematical existence”, one has to establish the connection to this intuition. Mathematical proofs are as true as the conviction they carry.

A formalization of any mathematical theory is just an abstract description of the reasoning/proving within that theory. The formalization is correct only if it follows intuition. Consistency alone is not sufficient: ‘An incorrect theory which is not stopped by a contradiction is none the less incorrect, just as a criminal policy unchecked by a reprimanding court is none the less criminal.’ In this sense, Brouwer critizized many mathematical theories as not related to any human imagination; these were born just by overtaking “logical principles” from another theory without justification.

In particular, Brouwer attacks the universal use of the principle of excluded middle, because it is not convincing when applied to undecided statements. It should be pointed out that Brouwer did not claim that the principle of excluded middle is false, he just stated that it is not true universally.

The viewpoint of platonism claims that a formalization of a mathematical theory is an approximate description of a mathematical world which is independant of our reasoning. In this world, every statement is either true or false, no matter of our knowledge of it. The platonist therefore upholds the principle of excluded middle. He/she is able to prove more theorems than the intuitionist, but at the same time he is forced to admit that there are theorems which can never be proven. They are just true (in the mathematical world), but we finite brains can never have the insight of recognizing their truth. And this is provably so.

The most popular viewpoint among mathematicians is the pragmatic. People believe that the abandonment of the principle of excluded middle would cripple mathematics, as many theorems cannot be proven and for others, the proofs become more difficult. They are not willing to pay such a prize just because of metaphysical considerations. Therefore the principle of excluded middle is accepted.

There is, however, a modern successor of intuitionism without any metaphysical ambitions. The constructivists point out that any theorem proven without the excluded middle has an algorithmic meaning, and the proof automatically entails an algorithm, at least implicitly. Thus, a proof with intuitionistic logic is preferred to a proof with classical logic.

2 Theory of Recursion

In this section, we give a survey on the theory of recursion, including the existence of recursively enumerable sets which are not recursive.

Intuitively, a recursive function is a function from ℕ^{k} to ℕ which can be computed by a finite computer program executed on a virtual machine with infinite memory. To make this definition more formal, one needs a theoretical model for computation.

Since this model has only a theoretical purpose, one wants to keep the set of primitive operations as small as possible. A well-known model is the one of Turing machines, which can be imagined as a single read-write button attached to an infinite memory strip.

Another model is the model of recursion. Here one tries to define computable functions in a machine-independant way, reflecting the idea that one should not write programs for existing machines but devise machines so that they are able to execute existing programs (Dijkstra).

We start by defining base functions. These are:

1. the successor function ′ : ℕ → ℕ, x′ := x + 1;

2. the constant functions c_{q}^{k} : ℕ^{k} → ℕ, c_{q}(x_{1}, …, x_{k}) := q;

3. the projection functions p_{i}^{k} : ℕ^{k} → ℕ, p_{i}(x_{1}, …, x_{k}) := x_{i}.

Now, let g : ℕ^{k−1} → ℕ, h : ℕ^{k+1} → ℕ be two functions. Then the primitive recursion f of g and h is defined as the unique function satisfying

• f(0, x_{2}, …, x_{k}) = g(x_{2}, …, x_{k}),

• f(x′, x_{2}, …, x_{k}) = h(x, f(x, x_{2}, …, x_{k}), x_{2}, …, x_{k}).

A function is called primitive recursive iff it can be obtained from base functions by compositions and primitive recursions. A construction of f by compositions, primitive recursions, and base functions, is called a program for f.

Example 1 Addition is primitive recursive, because we have the primitive recursion

0 + y = y, x′ + y = (x + y)′,

which gives + as the primitive recursion of p_{1}^{1} and the composed function (p_{2}^{3})′. In other words, PrimRec[p_{1}^{1}, (p_{2}^{3})′] is a program for +.

Multiplication is primitive recursive because

0 · y = 0, x′ · y = (x · y) + y.

This representations has the program PrimRec[c_{0}^{1}, PrimRec[p_{1}^{1}, (p_{2}^{3})′](p_{2}^{3}, p_{3}^{3})].

Exercise 1 Show that the functions exponentiation, predecessor, difference (defined as zero if the second argument is bigger than the first), minimum, maximum, zerotest, symmetric difference, remainder, quotient are all primitive recursive.

A predicate P (x_{1}, …, x_{n}) is called primitive recursive iff the characterstic function

χ_{P} (x_{1}, …, x_{n}) = \{ \begin{matrix}1 & if P (x_{1}, …, x_{n}) is true, \\ 0 & otherwise \end{matrix}

is primitive recursive. A subset L ⊂ ℕ is primitive recursiv iff the predicate “is contained in L” is primitive recursive.

For examples, the predicates “less than” (binary), “divisible” (binary), “prime” (unary) are all primitive recursive.

Let g : ℕ^{k+1} → ℕ be a function. Then the minimalization f of g is defined by

f(x_{1}, …, x_{n}) = \{ \begin{matrix}the smallest x such that g(x, x_{1}, …, x_{n}) = 0, if exists; \\ undefined otherwise. \end{matrix}

The minimalization is a partial function from ℕ^{k} to ℕ.

If g is itself a partial function, then f(x_{1}, …, x_{n}) is defined only in the case when there is an x such that g(x, x_{1}, …, x_{n}) = 0 and g(y, x_{1}, …, x_{n}) is defined for all y < x. Composition and primitive recursion is generalized to partial functions in the obvious way.

The partial function is called partial recursive iff it can be obtained from the base functions by compositions, primitive recursions, and minimalizations. A partial function which is defined everywhere is called a recursive function.

There are recursive functions which are not primitive recursive, for example the Ackermann function, which is defined by the following double recursion:

• ack(0, y) = y′′,

• ack(x′, 0) = ack(x, 1)′,

• ack(x′, y′) = ack(x, ack(x′, y)).

It is obvious that for each fixed x, the function y ↦ ack(x, y) is primitive recursive.

Theorem 1 The binary Ackermann function is not primitive recursive.

Proof: The proof proceeds in a series of claims, each depending on the previous claims.

Claim 1: ack(x, y) > y. This is proved by double induction. For x = 0, the claim is true by definition. Assume the claim holds for x = x_{0}. We prove that it holds for x = x′_{0}, by induction on y. For y = 0, the claim is true by definition. Assume that the claim holds for y = y_{0}. Then

ack(x′_{0}, y′_{0}) = ack(x_{0}, ack(x′_{0}, y_{0})) ≥ ack(x′_{0}, y_{0}) + 1 ≥ y_{0} + 2 > y′_{0},

where we have used both induction hypotheses in the inequality.

Claim 2: ack(x, y′) > ack(x, y). This is proved by case distinction. If x = 0, then statement is equivalent to y′′′ > y′′, which is true. If x = z′, then we get

ack(z′, y′) = ack(z, ack(z′, y)) > ack(z′, y)

by claim 1.

Claim 3: ack is strictly monotonic in the second argument. This is immediate from claim 2.

Claim 4: ack(1, y) = 2y + 4. Proof by induction on y.

Claim 5: ack(x, y′) < ack(x′, y). Proof by double induction. For x = 0, the claim is equivalent to y + 3 < 2y + 4 by claim 4, and this is clearly true. Assume the claim holds for x = x_{0}. We prove that it holds for x = x′_{0}, by induction on y. For y = 0, the claim is true by definition. Assume that the claim is true for y = y_{0}. Then

ack(x′_{0}, y′′_{0}) = ack(x_{0}, ack(x′_{0}, y′_{0})) < ack(x′_{0}, ack(x′_{0}, y′_{0}) − 1) <
ack(x′_{0}, ack(x′′_{0}, y_{0})) = ack(x′′_{0}, y′_{0}).

Here we used the induction hypothesis on x and, in the second inequation, claim 3 and the inequality

ack(x′_{0}, y′_{0}) − 1 < ack(x′_{0}, y′_{0}) < ack(x′′_{0}, y_{0})

that follows from the induction hypothesis on y.

Claim 6: ack(x, y) < ack(x′, y). Immediate from claim 2 and claim 5.

Claim 7: ack is strictly monotonic in the first argument. This is immediate from claim 6.

Claim 8: For any x_{1}, x_{2}, we have ack(x_{1}, ack(x_{2}, y)) < ack(x_{3}, y), where x_{3} = max(x_{1} + 2, x_{2} + 1). This is so because

ack(x_{1}, ack(x_{2}, y)) ≤ ack(x_{3} − 2, ack(x_{3} − 1, y)) = ack(x_{3} − 1, y′) < ack(x_{3}, y),

where the two inequalities follow from claim 7 and claim 5.

Claim 9: For any n-ary primitive recursive function f, there is a number c such that

f(x_{1}, …, x_{n}) < ack(c, x_{1} + ⋯ + x_{n})).

(We also say that f is bounded by c.) For the constant functions, the successor function, and the projection functions, the claim is true: choose c := 0 for the successor function and for the projections, and choose c to be the corresponding constant in the case of constant functions.

Let g be an n-ary function bounded by c, and let h_{1}, …, h_{n} be m-ary functions bounded by d. Then we can bound the composition by

f(h_{1}(x_{1}, …, x_{m}), …, h_{n}(x_{1}, …, x_{m})) <
ack(c, h_{1}(x_{1}, …, x_{m}) + ⋯ + h_{n}(x_{1}, …, x_{m})) <
ack(c, n ack(d, x_{1} + ⋯ + x_{m})) < ack(e, x_{1} + ⋯ + x_{m})

by claim 3 and claim 8.

Let g be n − 1-ary bounded by c and h be n + 1-ary bounded by d. Then we can bound the primitive recursion f by e := max(c, d + 2). We prove this by induction on the main argument x of f. If x = 0, then

f(0, x_{2}, …, x_{n}) = g(x_{2}, …, x_{n}) < ack(c, max(x_{2}, …, x_{n})),

and the bound follows from the assumption. Suppose the bound holds for x = x_{0}. Then we have

f(x′_{0}, x_{2}, …, x_{n}) = h(x_{0}, f(x_{0}, x_{2}, …, x_{n}), x_{2}, …, x_{n}) <
ack(d, max(x_{0}, f(x_{0}, x_{2}, …, x_{n}), x_{2}, …, x_{n})) <

ack(e − 2, ack(e − 1, max(x_{0}, x_{2}, …, x_{n})) = ack(e − 1, max(x_{0}, x_{2}, …, x_{n})′) <

ack(e, max(x′_{0}, x_{2}, …, x_{n}))

by claim 1, claim 3, and claim 8.

If the Ackermann function were primitive recursive, then we could bound it by some number, say c. Then we get

ack(c, c) < ack(c, max(c, c)) = ack(c, c),

a contradiction.

The following theorem is interesting, but it will not be used later.

Theorem 2 Any partial recursive function f has a program with only a single minimalization.

Proof: For any function h(x_{1}, …, x_{n}), define the bounded minimalization m of h by

m(x_{1}, …, x_{n}) = \{ \begin{matrix}the smallest y < x_{1} such that h(y, x_{2}, …, x_{n}) = 0, if exists; \\ x_{1} otherwise. \end{matrix}

One can show that the bounded minimalization of h can be obtained by primitive recursion and composition from h and the base functions. Therefore, the bounded minimalization of a primitive recursive function is primitive recursive.

Now, let f be any partial recursive function. Let f_{0} be the primitive recursion with one more argument, obtained by replacing all minimalizations by a bounded minimalization. Let f_{1} be the function obtained from f_{0} that behaves like f_{0} but “propagates the error due to bounding”, i.e. it outputs x_{1} whenever x_{1} was obtained as the answer of a bounded minimalization. It is easy to show that also f_{1} is primitive recursive. Let g_{1} be the minimalization of f_{1}. Then it holds that f(x_{1}, …, x_{n}) = f_{1}(g(x_{1}, …, x_{n}), x_{1}, …, x_{n}).

At this point, it should be intuitively clear that “recursion” is a universal programming language like Turing machines, ANSI-C, or Fortran 77. Since the number of available primitives is small, real programming would be cumbersome. But in principle we get the same computational power.

A predicate or subset of natural numbers is called recursively enumerable iff it is the domain of definition (abbreviation: DEF) of a partial recursive function. A predicate or subset P is called recursive iff both P and the complement of P are recursively enumerable.

Theorem 3 a) A predicate is recursive iff its characteristic function is recursive.

b) A function is recursive iff its graph (a predicate with arity one higher) is recursive.

c) A partial function is recursively enumerable iff its graph is recursively enumerable.

Proof: (a), ⇒: let X_{y} and X_{n} be two programs with domains of definition P and the complement of P. The following program with input x_{1}, …, x_{n},

run X_{y} and X_{n} in parallel; if X_{y} stops first, then return y; if X_{n} stops first, then return n

returns a result for all input values, and computes the characteristic function.

(a), ⇐: let X be a program for the characteristic function of the predicate P (in other words, a program deciding P). the following program with input x_{1}, …, x_{n}, run X on x_{1}, …, x_{n}; if the result is 1, then return 1; else loop forever

has the elements satisfying P as its domain of definition. Similarily, one constructs a program with the complement as its domain of definition.

(b), ⇒: let X be a program computing f. The following program with input x_{1}, …, x_{n}, y,

compute f(x_{1}, …, x_{n}) using X;

if the result is y, return 1;

else return 0

computes the graph of f.

(b), ⇐: let X be a program computing the graph of f. The following program with input x_{1}, …, x_{n},

for i from 0 to infinity

if X applied to x_{1}, …, x_{n}, i gives 1, return i

always terminates and computes f.

(c), ⇒: let X be a program computing f. The following program with input x_{1}, …, x_{n}, y,

compute f(x_{1}, …, x_{n}) using X;

if the result is y, return 1;

else loop forever

has the graph of f as its domain of definition.

(c), ⇐: let X be a program with the graph of f as its domain of definition. Let X′ be the program with one more argument obtained by replacing all minimalizations by bounded minimalizations. The following program with input x_{1}, …, x_{n}

for i from 0 to infinity

for j from 0 to i

apply X′ to i − j, x_{1}, …, x_{n}, j if the result is 1, return j

computes f.

Interpreters are programs that have programs as an input and simulate the behavior of the input program. In order to express an interpreter as a recursive function, we need a coding function C from the set of all programs to ℕ. The precise definition of the function is not really relevant (except for the interpreter), provided that it fulfills some requirements:

• the coding is unique, i.e. C is injective; • given a number, we can get its outermost constructor. In other words, the

predicates “is a code of a composite” and so on are all recursive;

• we can parse the code. More precisely: given the code of a program, we can compute the codes of all its subprograms, i.e. the corresponding functions are recursive;

• the codes of the subprograms are smaller than the codes of the main program.

For all reasonable codes one can think of (e.g. ASCII code), the requirements are fulfilled even with primitive recursive destructors.

Theorem 4 The binary predicate “m is the code of program of an n-ary partial recursive function” is recursive.

Proof: Write a parser (a program that parses codes for programs). Remark: if the coding has primitive recursive destructors, then one can write a primitive recursive parser, so that the binary predicate above becomes even primitive recursive.

Theorem 5 For any n, the n + 1-ary partial function

i_{n}(z, x_{1}, …, x_{n}) = \{ \begin{matrix}f(x_{1}, …, x_{n}) & if z is the code of program \\ & for a partial recursive function f \\ undefined otherwise. \end{matrix}

is partial recursive.

Proof: Write an interpreter.

Theorem 6 There exists a recursively enumerable set which is not recursive.

Proof: Let R ⊂ ℕ be the domain of definition of the function x ↦ i_{1}(x, x). Then R is recursively enumerable. We show that the complement is not recursive.

Suppose indirectly, that there exists a unary partial recursive function f with DEF (f) = ℕ − R. By definition, x ∈ DEF (f) iff either x is the code of a program X such that x ∉ DEF (X), or x is not the code of a program of a unary partial function.

Let y be the code of a program Y for f. Then y ∈ DEF (Y) iff y ∉ DEF (Y), and this is a contradiction.

3 Equational Theories

An equational theory is has the following elements.

Linguistical part:

• variables (infinitely many)

• function symbols (including constant symbols)

• one binary predicate “=” Terms are words in the symbols above according to the following syntax:

• a variable is a term;

• if t_{1}, …, t_{n} are terms, and f is a n-ary function symbol, then f(t_{1}, …, t_{n}) is a term.

If t_{1}, t_{2} are terms and x is a variable, then we write t_{1}[x := t_{2}] for the term obtained by replacing all occurences of x by t_{2}. Sometimes, we write more informally t_{1}(x) for a term in which we want to substitute x, and t_{1}(t_{2}) for the result of the substitution.

Logical part:

• Axioms of the form t_{1} = t_{2};

• Inference rules:

1. t = t;

2. t_{1} = t_{2} ⊢ t_{2} = t_{1};

3. t_{1} = t_{2}, t_{2} = t_{3} ⊢ t_{1} = t_{3};

4. s_{1} = t_{1}, …, s_{n} = t_{n} ⊢ f(s_{1}, …, s_{n}) = f(t_{1}, …, t_{n});

5. t_{1} = t_{2} ⊢ t_{1}[x := t] = t_{2}[x := t]. All theorems are equations of the type t_{1} = t_{2}. If t_{1} = t_{2} is provable in the

theory, then we also say that t_{1} and t_{2} are convertible. Clearly, convertibility is an equivalence relation. A theory is consistent if there are at least two terms which are not convertible. Example 2 The equational theory of groups has the binary function symbol mult, unary function symbol inv, and constant symbol one. The axioms are the following.

1. mult(mult(x, y), z) = mult(x, mult(y, z));

2. mult(x, one) = x;

3. mult(one, x) = x; 4. mult(x, inv(x)) = one;

5. mult(inv(x), x) = one.

Let T be an equational theory. A structure for T is a set S, together with a function f : S^{n} → S for each n-ary function symbol f. An assignment is a function from the set of variables to S. An interpretation is a structure together with an assignment.

For any term, one can define its value under some interpretation I recursively. An equation is true in some interpretation iff the left hand side and the right hand side evaluate to the same element in S. A structure is a model for T iff all axioms are true for all assignments. For instance, the models for the example above are precisely the groups.

It is clear that equational theories are semantically consistent: if an equation is provable, then it is true in every model under any interpretation. The converse (semantical completeness) is also true.

Theorem 7 If an equation is true for all models and all assignments, then it is provable.

Proof: Here is a construction of a model M_{0} and an assignment A_{0}, for which only the provable equations are true.

Let H be the Herbrand structure of T , defined as the set of all terms in T . The functions f : H^{n} → H are defined in the obvious way: f(t_{1}, …, t_{n}) := f(t_{1}, …, t_{n}).

Denote the convertibility relation by ∼. Then all functions f are well-defined for equivalence classes. Thus, H/∼ is a structure for T .

Let A be an assignment and let t_{1} = t_{2} be an axiom. The assignment defines a substitution S, and by inference rule 4 we have that t_{1}[S] = t_{2}[S]. Hence the values of t_{1} and t_{2} are equal in the structure H/∼ and assignment A. Therefore M_{0} := H/∼ is a model for T .

The assignment A_{0} maps each variable to itself.

Now, let t_{1} = t_{2} a formula which is true in this model and assignment. Then t_{1} and t_{2} are convertible, i.e. t_{1} = t_{2} is provable in T .

The class of all models for a fixed theory is called a variety, and it has a lot of interesting properties (closed under products, subobjects, quotients). Such structures are studied in universal algebra.

In order to analyze convertibility, it is often useful to consider an asymmetric variant of it—reduction.

Let T be the set of terms of a theory T . A reduction on T is just a binary relation on T, written t_{1} → t_{2}.

A reduction is called compatible (with the function symbols) iff t_{1} → t_{2} implies f(s_{1}, …, s_{i−1}, t_{1}, s_{i+1}, …, s_{n}) → f(s_{1}, …, s_{i−1}, t_{2}, s_{i+1}, …, s_{n}). A reduction is called substitutive if t_{1} → t_{2} implies t_{1}[x := t] → t_{2}[x := t].

The reflexive/transitive/symmetric/compatible/substitutive closure of → is the smallest relation extending →. The reflexive transitive closure is also denoted by →^{∗}, and the reflexive transitive symmetric closure is denoted by ↔^{∗}.

Given a theory, one gets a reduction by replacing each axiom t_{1} = t_{2} by a relation t_{1} → t_{2}, which is also called a rewrite rule. The reduction → is defined as the compatible substitutive closure of the set of rewrite rules. Clearly, compatibility is the reflexive transitive symmetric closure of →.

A reduction → has the diamond property iff for all t, t_{1}, t_{2} such that t → t_{1} and t → t_{2}, there exists t_{3} such that t_{1} → t_{3} and t_{2} → t_{3}.

A reduction → is Church-Rosser (or confluent) iff →^{∗} has the diamond property.

A term t is called a normal form iff there is no t′ such that t → t′. A term t_{1} is called a normal form of t_{2} iff it is a normal for and t_{1} ↔^{∗} t_{2}.

Lemma 1 If → has the diamond propery, then →^{∗} has the diamond property.

Proof: By a diagram chase (see [1], p 59).

Theorem 8 Let → be a Church-Rosser reduction. Let ↔^{∗} be its symmetric transitiv closure. Let t_{1} ↔^{∗} t_{2}. Then there exists t_{3} such that t_{1} →^{∗} t_{3} and

t_{2} →^{∗} t_{3}.

Proof: By another diagram chase (see [1], p 54).

Corollary 1 Let → be Church-Rosser. Then the following hold.

a) If t_{1} has a normal form t_{2}, then t_{1} →^{∗} t_{2}.

b) A term can have at most one normal form.

Proof: (a): by theorem 8, t_{1} and t_{2} both reduce to common reductum t_{3}. Because t_{2} is a normal form, it follows t_{2} = t_{3}.

(b): suppose that there are two equivalent normal forms t_{1}, t_{2}. By (a), we have a reduction t_{1} →^{∗} t_{2}. Since t_{1} is a normal form, it follows t_{1} = t_{2}.

Suppose that → is a reduction such that ↔^{∗} is convertibility, for instance the compatible substitutive closure of the rewrite rules. Suppose moreover that → is Church-Rosser. Given two terms t_{1}, t_{2}, one can try to reduce each term until no more reduction is possible, in order to get normal forms for t_{1} and t_{2}. Then compatibility may be decided by comparing the normal forms on a syntactical level.

In the case of λ-calculus, the above strategy goes down and gives an algorithm for recognizing compatibility. The algorithm may not terminate, in the case where the terms do not have a normal form.

Other cases are particularily nice: when reduction is a finite process.

A reduction path is a sequence

t_{0} → t_{1} → t_{2} ….

A reduction is called noetherian (or strongly normalizing) iff every reduction path is finite.

In a noetherian reduction, any term has a normal form. Thus, we have a decision algorithm for compatibility when a reduction is noetherian and Church-Rosser (under the assumption that one can decide whether one-step reduction is possible).

Moreover, the noetherian property allows to weaken the second assumption: A reduction → is called weakly Church-Rosser (or local confluent) iff for

all t, t_{1}, t_{2} such that t → t_{1} and t → t_{2}, there exists t_{3} such that t_{1} →^{∗} t_{3} and

t_{2} →^{∗} t_{3}.

Theorem 9 (Newman) If a reduction is noetherian and weakly Church-Rosser, then it is Church-Rosser.

Proof: Call an element ambiguous iff it reduces to two different normal forms. We give an indirect proof for the non-existence of ambiguous elements.

Let t_{1} be ambiguous with the two distinct normal forms t_{2} and t_{3}. Obviously, t_{1} is not a normal form, therefore the reductions to t_{2} and t_{3} are at least of length one. Therefore we have elements t_{4} and t_{5}, obtained from t_{1} by a one step reduction, t_{4} in the path to t_{2} and t_{5} on the path to t_{3}. By the weak Church-Rosser property, there is an element t_{6} such that t_{4} and t_{5} both reduce to t_{6}. Let t_{8} be a reduction of t_{7} to a normal form.

Clearly, we have either t_{2} ≠ t_{8} or t_{3} ≠ t_{8}. If t_{2} ≠ t_{8}, then t_{4} is ambiguous, since it reduces to the normal forms t_{2} and t_{8}. If t_{3} ≠ t_{8}, then t_{5} is ambiguous, since it reduces to the normal forms t_{3} and t_{8}. In any case, one finds an ambiguous reductum.

Since t_{1} was an arbitrary ambiguous element, we can repeat the construction and obtain a reduction path of infinite length, contradicting noetherianity.

Suppose that we are in the noetherian case, but our reduction is not weakly Church-Rosser: there are t, t_{1}, t_{2} such that t → t_{1} and t → t_{2}, and t_{1} and t_{2} have no common reductum. Then one can try to force the weak Church-Rosser property by adjoining t_{1} → t_{2} as a new rewrite rule.

A priori, the search space for counter-examples to weak Church-Rosser is infinite, even if there only finitely many rewrite rules. The theorem of Knuth-Bendix reduces the search space considerably.

Two terms t_{1}, t_{2} are called unifiable if there exists a substitution θ (called unifier) with the property t_{1}[θ] = t_{2}[θ]. A most general unifier is a unifier σ such that for any unifier θ there exists a substitution λ with θ = σλ. Most general unifiers are unique up to a renaming of variables.

Theorem 10 (Unification) If t_{1} and t_{2} are unifiable, then there exists a most general unifier.

Proof: By induction over the number of variables in t_{1} and t_{2}.

If there are no variable, the theorem is trivially true.

The disagreement set is the set of the two subexpressions beginning with the first symbol where t_{1} and t_{2} disagree. Any unifier must unify the disagreement set; this is possible only if one of the expressions is a variable x and the other is a term t which does not contain x. Let α := {x←t}, t′_{1} := t_{1}α, t′_{2} := t_{2}α. Then any unifier θ can be written as θ = αθ′, where θ′ is a unifier of t′_{1} and t′_{2}. If t′_{1} and t′_{2} are not unifiable, then t_{1} and t_{2} are not unifiable and the theorem is true. Otherwise, there exists a most general unifier σ′ for t′_{1} and t′_{2} by the induction hypothesis, because t′_{1} and t′_{2} do not contain the variable x. Then, σ := ασ′ is a most general unifier for t_{1}, t_{2}.

Exercise 2 Determine whether g(x, y, z) and g(f(y, y), f(z, z), f(x, x)) are unifiable. If yes, obtain a most general unifier.

Let s_{1} → t_{1} and s_{2} → t_{2} be two rewrite rules. Let p be a subterm of s_{2} which is not a variable, and suppose that s_{1} and p are unifiable. Then the two rewrite rule and the subterm occurence define a critical pair, in the following way:

First, we rename variables so that the two rewrite rules habe no variable in common.

Let σ be the most general unifier of p and s_{1}. Then p[σ] is a subterm of s_{2}[σ]. Let p_{1} := s_{2}[σ]{p[σ]/t_{1}[σ]} be the result of replacing this subterm by t_{1}[σ]}. (Note that p_{1} depends not just on the subterm, but also on the occurence of the subterm in the whole term!) Then the critical pair is the pair of terms (p_{1}, p_{2}), where p_{2} := t_{2}[σ].

Since → (the reduction defined by the rewrite rules) is compatible and substitutive, we have that s_{2} → p_{1} and s_{2} → p_{2}, and consequently p_{1} ↔^{∗} p_{2}.

Theorem 11 (Knuth-Bendix) A system of rewrite rules defines a weakly Church-Rosser reduction iff for any critical pair (p_{1}, p_{2}) there exists a term q such that p_{1} →^{∗} q and p_{2} →^{∗} q.

Proof: See [33], p 53f.

This is the idea of the Knuth-Bendix completion procedure for establishing a system of rewrite rules with unique normal form.

1. form all critical pairs;

2. for each critical pair (p_{1}, p_{2}), reduce p_{i} to a normal form q_{i}; 3. if q_{1} ≠ q_{2}, add q_{1} → q_{2} or q_{2} → q_{1} as a new rewrite rule;

4. repeat;

Noetherianity is a crucial point in this procedure. One has to make sure somehow that noetherianity is also preserved when new rules are added.

Example 3 We start with the rewrite rules obtained from the axioms in example 2.

In order to ensure noetherianity, we observe that the left hand side is always shorter than or equal to the right side. In case of equal length, the reductions always shift function symbols to the right. Whenever we add new rules, we orient the critical pair so that these are preserved.

The left side of the first rewrite rules unifies with its subterm mult(x, y). After renaming variables, we look for the most general unifier of mult(mult(x, y), z) and mult(u, v). It is (u := mult(x, y), v := z). Then the critical pair is

mult(mult(x, mult(y, z)), w), mult(mult(x, y), mult(z, w))).

By applying the first rewrite rule twice to the first and once to the second element, one obtains the normal form

mult(x, mult(y, mult(z, w))).

Thus, we have no new rewrite rule for this critical pair.

The left sides of the third and fourth rewrite rule are unifiable. The most general unifier of mult(one, x) and mult(y, inv(y)) is (x := inv((one)), y := one). We obtain the critical pair (inv((one)), one), where both sides are already normal forms. Thus, we have to add the new rewrite rule

inv((one)) → one.

Continuing this way, one obtains a system of 12 rewrite rules which defines a reduction with unique normal form.

Of course, it is not guaranteed that Knuth-Bendix completion terminates. For a more complete treatment of the Knuth-Bendix and related methods,

we refer to [31]. A general framework of “critical pair completion” strategies, which also includes Buchberger’s Gröbner bases algorithm [4], can be found in [27].

There are undecidable equational theories (e.g. λ-calculus). The intrinsical difficulty is not substitution (because here we have unification) but compatibility. A well-known problem which is closely related to equational theories is the word problem.

Let Σ be an alphabet of constants. We consider the terms formed by Σ and an associative binary function which we write as concatenation (omitting brackets). Let Γ be a set of equations without variables. Then the word problem for Γ is the following: given an equation s = t without variables, decide if s = t is provable in the theory with axioms Γ (and associativity, of course).

Theorem 12 (Post,Markov) There is a finite set of equations with an undecidable word problem.

Proof: See [22].

4 Predicate Logic

First order predicate logic is probably the system which is most studied among all logical calculi. In this section, we will introduce the formal theory and prove some first meta-theorems about it.

Linguistical part:

• predicate symbols, function symbols

• connectives: →, ¬, ↔, ∧, ∨, ⊤, ⊥

• variables

• quantifiers: ∀, ∃

• terms, formulas

The binding conventions for conncetives and quantfiers are as follows:

1. quantifiers bind stronger than connectives

2. ¬ binds stronger than binary connectives

3. ∧ and ∨ bind stronger than →

4. → binds stronger than ↔

5. → binds from right to left, i.e. A → B → C parses as A → (B → C)

The set of predicate symbols and function symbols together with the arity information is called the signature of the predicate calculus.

An occurence of a variable x in a formula A is said to be bound iff the occurence is in a quantifier ∀x or ∃x or in the scope of a quantifier ∀x or ∃x. Otherwise, the occurence is called free.

A term t is said to be free for x in A iff no free occurence of x in A is in the scope of a quantifier where the quantified variable occurs in t.

In order to substitute a term t for a variable x in A, we require that t be free for x in A. Otherwise, some part of the term would become bound, and this may change meaning; for example, in the formula ∃xx = y, the term x + 1 is not free for y. Indeed, we see that the formula is true for all y (with the usual meaning of “=”), but substitution would yield ∃xx = x + 1, which is false.

A formula is called closed (or: a sentence) iff it has no free variables. Logical part:

• Axioms:

1. A → B → A

2. (A → B → C) → (A → B) → (A → C)

3. (¬A → ¬B) → (B → A)

4. ∀xA(x) → A(t), if x is free for t in A(x)

5. ∀x(C → A(x)) → C → ∀xA(x), if x is not free in C

6. (A → B) → (B → A) → (A ↔ B)

7. (A ↔ B) → (A → B)

8. (A ↔ B) → (B → A)

9. (A ∨ B) ↔ (¬A → B)

10. (A ∧ B) ↔ ¬(A → ¬B)

11. ⊥ ↔ (A ∧ ¬A)

12. ⊤ ↔ (A → A)

13. ∃xA(x) ↔ ¬∀x¬A(x)

• Inference rules:

• A → B, A ⊢ B (modus ponens)

• A(x) ⊢_{x} ∀xA(x) (generalization)

We say that the variable x is varied in the inference rules 2.

The letters A, B, C above stand for arbitrary formulae, so the axioms are actually axiom schemes. The actual axioms are the instantions of these schemes, which are infinitely many. Note that it is decidable whether a formula is an axiom, and whether a formula can be infererred from one or two other by modus ponens or by generalization.

The consequence relation ⊢:

A_{1}, …, A_{r} ⊢ C

iff there exists a sequence B_{1}, …, B_{n} = C (called derivation), such that each B_{i} is either an axiom, or one of the A_{i}, or an immediate consequence of some of B_{1}, …, B_{i−1} by the inference rules. If a variable is not varied in the derivation, then we say that it is held constant.

Here is a proof of A → A.

1. A → (A → A) → A axiom 1

2. (A → (A → A) → A) → (A → A → A) → (A → A) axiom 2

3. (A → A → A) → (A → A) modus ponens from 2 and 1

4. A → A → A axiom 1

5. A → A modus ponens from 3 and 4

We start with a useful meta-theorem.

Theorem 13 (Deduction theorem) If Γ, A⊢B with all free variables in A held constant, then Γ⊢A→B.

Proof: We give a proof by induction on the length k of the derivation Γ, A⊢B. If k = 1, then we distinguish two cases. Case 1: B is an axiom or a formula in Γ. Then one can derive A→B by B

and the axiom B→A→B.

Case 2: B is A. See above exercise.

For the inductive step, suppose that there exists a derivation of B of length k + 1.

If B is an axiom, a formula in Γ, or A, then the theorem follows as in the base case k = 1.

Suppose that B is obtained by modus ponens as an immediate consequence of two formulas C and C→B, which occur earlier in the proof. By induction hypothesis, the formulas A→C and A→C→B can be derived from Γ. Then, we apply modus ponens two times to the axiom

(A → C → B) → (A → C) → (A → B)

and derive A→B, as desired.

Suppose that B = ∀xC(x) is obtained by generalization as an immediate consequence of C(x), varying the variable x. By assumption, x also does not occur freely in A. By induction hypothesis, we have a derivation Γ ⊢ A → C(x). Then we can derive ∀x(A → C(x)) by generalization. By axiom 5, we have

∀x(A → C(x)) → A → ∀xC(x).

Then we can derive A → ∀xC(x) = A → B by modus ponens, as desired.

Remark 1 The assumption on the free variables in A is clearly necessary, because the generalization rule does not imply that

A(x) → ∀xA(x)

is provable. In fact, the formula is not logically valid, it is not hard to give assignments where it is false (e.g. A(x) :↔ x is a prime, x := 3).

We say that two formulas A and B are logically equivalent, A ∼ B, iff ⊢A↔B.

Exercise 3 Prove that ∼ is an equivalence relation.

Theorem 14 (Replacement theorem) Let C_{A} be a formula with a subformula A, and let C_{B} be the formula obtained when A is replaced by B in C_{A}.

If A∼B, then C_{A}∼C_{B}.

Proof: By induction on the length of the context, we can reduce to a finite number of statements. If the innermost context symbol is ∧, ∨, or ∃, we may replace both sides by the right hand sides in axioms 9, 10, 13, and use transitivity. Similarily for the context symbol ↔, because of the theorem

(A ↔ B) ↔ (A → B) ∧ (B ↔ A)

(left as an exercise). Thus, it suffices to show the following:

1. A ↔ B, C ↔ D ⊢ A → C ↔ B → D

2. A ↔ B ⊢ ¬A ↔ ¬B

3. A(x) ↔ B(x) ⊢ ∀xA(x) ↔ ∀xB(x)

The first 2 are left as exercises. We show statement 3. As a first step, we show that

A(x) → B(x), ∀xA(x) ⊢ ∀xB(x).

Indeed, here is a derivation.

1. ∀xA(x) → A(x) axiom 4

2. ∀xA(x) hypothesis 2

3. A(x) modus ponens from 1 and 2

4. A(x) → B(x) hypothesis 1

5. B(x) modus ponens from 4 and 3

6. ∀xB(x) generalization of 5

Obviously, x is not free in ∀xA(x). By the deduction theorem, we can derive ∀xA(x) → ∀xB(x) from A(x) → B(x).

Under the hypothesis A(x) ↔ B(x), we may derive A(x) → B(x) by axiom 7 and B(x) → A(x) by axiom 8. Then we can prove, as above, the implications ∀xA(x) → ∀xB(x) and ∀xB(x) → ∀xA(x). Using axiom 6 and applying modus ponens twice, we obtain the desired ∀xA(x) ↔ ∀xB(x).

A structure for a first order theory is a non-empty set S, together with an n-ary predicate P for each n-ary predicate symbol and an n-ary function f : S^{n} → S for each n-ary function symbol. An assignment is a map from the set of variables to S. An interpretation is a structure with an assignment.

For each term, we can define its value, an element in S, as in the equational theory.

For each formula, we specify when it is true under the interpretation, in the following way.

• A predicate symbol is true iff the corresponding predicate holds for the values of the argument terms.

• A∧B is true iff A is true and B is true.

• A∨B is true iff A is true or B is true.

• A→B is true iff A is not true or B is true.

• ¬A is true iff A is not true.

• ⊥ is not true.

• ∀xA(x) is true iff A(y) is true for all interpretations I′ extending I, where y is a new variable y (which may be assigned any value of S).

• ∃xA(x) is true iff A(y) is true for one interpretation I′ extending I, where y is a new variable y.

It is obvious that relative consistency holds: a provable formula is true in any interpretation (it suffices to check that the axioms are true, and that the inference rules preserve truth). As a consequence, we obtain consistency of first order logic (without additional axioms).

Theorem 15 (Consistency) ⊥ is not a theorem.

Proof: In any interpretation, ⊥ is not true.

Remark 2 The above proof is not finitary because it uses set theory. It is possible to give a finitary proof, all we have to do is to replace “S is a set” by “S is a finite set of integers”. Finiteness is necessary in order to give the definition of truth values of quantified formulas a finitary meaning.

Remark 3 We do not allow empty models, because in these, some axioms and inference rules would not be fulfilled (which?).

Corollary 2 A necessary condition for being a theorem is that a formula is true under all of its interpretations.

Exercise 4 Prove that the formula P (x)→∀xP (x) is not a theorem.

5 The Completeness Theorem

The goal of this section is to prove semantical completeness of predicate logic. In other words, we want to show that if a formula is true in any interpretation, then it is provable.

A more general result, which also gives some information about sets of formulae, will be useful later.

A set Γ of formulas is called consistent iff there is no derivation of ⊥ from Γ where all free variables occuring in Γ are held constant. This restriction is important, otherwise {P (x), ¬P (y)} would be inconsistent.

Now, we observe that semantical completeness follows from the statement that consistency implies satisfiability.

Proof: Let A be a formula which is true under all interpretations. Then the set {¬A} is not satisfiable. If the second theorem is true, then {¬A} is inconsistent. Thus, there is a derivation ¬A⊢⊥ helding the free variables in A constant. By the deduction theorem, ¬A→⊥ is a theorem. But A is a consequence of ¬A→⊥, hence A is a theorem.

Remark 4 By semantical correctness, it is clear that satisfiability implies consistency: if Γ has a model, then all theorems derivable from Γ are true in this model. But ⊥ is false in any interpretation, hence ⊥ is not a consequence of Γ.

A set Γ is called Henkin iff for any formula of the form ∃xA(x), there exists a term t such that Γ contains the formula ∃xA(x) → A(t).

A set Γ is called maximally consistent iff it is consistent and it is not contained properly in a consistent set.

Theorem 16 (Henkin) If Γ is Henkin and maximally consistent, then Γ is satisfiable.

Proof: The model is constructed as follows. H is the set of all terms. For any function symbol f, the function f : H^{n} → H is defined by f(t_{1}, …, t_{n}) := f(t_{1}, …, t_{n}). For any predicate symbol P, we define P(t_{1}, …, t_{n}) to be true iff P (t_{1}, …, t_{n}) ∈ Γ. The assignment I maps any variable to itself.

The remaining part of the proof shows that (H, I) is indeed a model. First, we note that if Γ is maximally consistent and Γ ⊢ A, then we have already A ∈ Γ. In a first step, we restrict to a language with only atoms, negation, conjunction, and existential quantifiers. We prove by induction over the number of logical connectives and quantifiers the following claim: any such formula is in Γ iff it is satisfied by the interpretation (H, I). We have to distinguish the following cases.

• A is an atom (base case). Obvious by the definition of H.

• A is a negation ¬B. If A ∈ Γ, then B ∉ Γ because Γ is consistent. By induction hypothesis, B is false under the interpretation (H, I). Thus, A is true under the interpretation.

Conversely, if A is true in the interpretation, then B is false. By the induction hypothesis, B ∉ Γ. Since Γ is maximally consistent, we have Γ, B ⊢ ⊥ with a derivation keeping all free variables constant. By the deduction theorem, it follows Γ ⊢ B → ⊥ which implies Γ ⊢ ¬B. Thus A ∈ Γ.

• A is a conjunction B ∧ C. If A ∈ Γ, then B, C ∈ Γ because they are consequences of A. By induction hypothesis, both B and C are true in the interpretation, thus A is true.

Conversely, if A is true, then both B and C are true. By induction hypothesis, B, C ∈ Γ. But B, C ⊢ A, hence A ∈ Γ.

• A is an existential quantification ∃xB(x). If A is true in the interpretation, then there exists a term t ∈ H such that B(t) is true. By induction, we have B(t) ∈ Γ. But B(t) ⊢ ∃xB(x), hence A ∈ Γ.

Conversely, let A be in Γ. Since Γ is Henkin, there is a term t such that A → B(t) ∈ Γ. Therefore B(t) ∈ Γ. By induction, B(t) is true. Therefore A is true.

If A is a general formula, then there is a formula B which is equivalent to A which has only atoms, negation, conjunction, and existential quantifiers. Therefore A is true iff B is true iff B ∈ Γ iff A ∈ Γ.

In the remaining part of the proof, we make the following reasonable assumptions.

• The set of all formulas is countable.

• There are infinitely many variables which are not free in Γ.

Remark 5 The first assumption can be weakened to the assumption that the set of all formulas can be well-ordered. The second assumption is essential. If it does not hold, then a set might be consistent by the unintended reason that there are not enough variables for deriving ⊥. Such a consistent set will not have a model.

Theorem 17 Let Γ be a consistent set of formulas. Then there is a set Γ′ which contains Γ and is consistent and is Henkin.

Proof: Let A_{1}(x_{1}), A_{2}(x_{2}), … be an enumeration of all formulas with a free variable x_{n} (the variables x_{n} are not necessarily distinct). We define recursively

Γ_{n} := Γ_{n−1} ∪ {∃x_{n}A_{n}(x_{n}) → A(y_{n})},

where y_{n} is a variable not free in Γ_{n}. We show that Γ_{n} is consistent, by induction on n.

Assume indirectly that Γ_{n} is inconsistent. B_{n} := ∃x_{n}A_{n}(x_{n}) → A(y_{n}). Then we have a derivation Γ_{n} ⊢ ⊥ keeping all free variables in Γ_{n} constant. By the deduction theorem, we have a derivation Γ_{n−1} ⊢ B_{n} → ⊥, where B_{n} := ∃x_{n}A_{n}(x_{n}) → A_{n}(y_{n}). The formula B_{n} → ⊥ is logically equivalent to ∃x_{n}A_{n}(x_{n}) ∧ (A(y_{n}) → ⊥), therefore we have derivations Γ_{n−1} ⊢ ∃xA_{n}(x_{n}) and Γ_{n−1} ⊢ A_{n}(y_{n}) → ⊥. By the third inference rule, we have A_{n}(y_{n}) → ⊥ ⊢ ∃y_{n}A_{n}(y_{n}) → ⊥, by a derivation that varies y_{n}. Now, ∃x_{n}A_{n}(x_{n}) is logically equivalent to ∃y_{n}A_{n}(y_{n}), and therefore we can derive Γ_{n−1} ⊢ ⊥ with a derivation that varies y_{n}. But y_{n} is not a free variable of Γ_{n−1}, hence Γ_{n−1} is inconsistent. This is a contradiction.

Let Γ′ := ∪_{n}Γ_{n}. If Γ′ were inconsistent, then there would be derivation of ⊥ with all free variables in Γ′ held constant. In this derivation, only finitely many formulas are used. All these finitely many formulas must be contained in some Γ_{n}. Therefore, Γ_{n} is inconsistent, but this contradicts the above. Hence Γ′ is consistent.

Theorem 18 Let Γ be consistent. Then there exists a maximally consistent set Γ′ containing Γ.

Proof: Let A_{1}, A_{2}, … be an enumeration of the set of all formulas. Define Γ_{n} recursively by Γ_{0} := Γ and

Γ_{n} := \{ \begin{matrix}Γ_{n−1} ∪ \{A_{n}\} & if Γ_{n−1} ∪ \{A_{n}\} is consistent, \\ Γ_{n−1} & otherwise. \end{matrix}

Then Γ_{n} is consistent for all n, by induction on n.

Let Γ′ := ∪_{n}Γ_{n}. If Γ′ were inconsistent, then there would be derivation of ⊥ with all free variables in Γ′ held constant. In this derivation, only finitely many formulas are used. All these finitely many formulas must be contained in some Γ_{n}. Therefore, Γ_{n} is inconsistent, but this contradicts the above. Hence Γ′ is consistent.

Let A_{n} be a formula not contained in Γ′. Then A_{n} ∉ Γ_{n}, and therefore Γ_{n−1} ∪ {A_{n}} is inconsistent by the recursive definition of Γ_{n}. Hence Γ′ ∪ {A_{n}} is inconsistent also. Since A_{n} was chosen arbitrarily, this shows that Γ′ is maximally consistent.

Theorem 19 (Completeness) Any consistent set is satisfiable.

Proof: Let Γ be a consistent set. By theorem 17, there is a consistent superset Γ′ which is Henkin. By theorem 18, there exists a superset Γ′′ of Γ′ which is maximal consistent. Any superset of a Henkin set is again Henkin, hence Γ′′ is also Henkin. By Henkin’s theorem, Γ′′ is satisfiable. Since Γ is a subset of Γ′′, it is satisfiable too.

Note that the Herbrand universe is countable, so we have in fact proved Löwenheim’s theorem: any consistent set with a countable set of formulas has a countable model.

Remark 6 The completeness theorem does not hold constructively. The weak point is the use of the excluded middle in the recursive definition of Γ_{n} in the proof of theorem 18.

Here is a corollary of the completeness theorem which turns out to have some interesting applications in the next chapter.

Theorem 20 (Compactness) A set Γ is satisfiable iff every finite subset of Γ is satisfiable.

Proof: If we replace “satisfiable” by “consistent”, then the statement is obviously true, because any derivation of ⊥ uses only finitely many formulas. But by correctness and completeness, satisfiability and consistency are equivalent.

6 First order theories

In this section, we discuss theories that are derived from predicate calculus by adding additional axioms. We will also prove undecidabilty of predicate logic from the undecidability of a special first order theory.

Predicate logic is expressive enough to formalize various theories within it. When doing so, the function symbols symbolize functions from the informal theory, and the predicate symbols symbolize predicates from the informal theory. The number of function symbols and predicate symbols may be finite or infinite. Usually, one has additional axioms. The set of axioms may be infinite, but it must be decidable (this is needed to be able to check proofs).

Formally, a first order theory is defined by a signature (a set of function symbols and predicate symbols together with arity information) and a recursively enumerable set Γ of formulas which is closed under logical consequence. The set Γ is the set of all true formulas in the theory.

Given a first order theory, a model is a structure such that all formulas in Γ are true under all assignments.

A subset Γ_{0} of Γ is called an axiomatization iff it is recursive and Γ_{0} ⊢ A for every A ∈ Γ.

Theorem 21 Any first order theory has an axiomatization.

Proof: Let A_{1}, A_{2}, … be a recursive enumeration of Γ. For each n, let B_{n} := A_{n} ∧ A_{n} ∧ A_{n} … (n times). Then we claim that Γ_{0} := {B_{1}, B_{2}, … } is an axiomatization.

In order to decide recursively whether a given formula A is in Γ_{0}, find the largest number m such that A is a conjunction of m identical formulas. This is easy because it can be done on a syntactical level. For each divisor of l of m, enumerate the first m formulas of Γ. Let A′ be the l-th formula. Let B be A′ ∧ A′ ∧ A′ … (l times). If A and B are identical, then A is in Γ_{0}. If the comparison is negative for all l, then A is not.

Obviously, A_{n} is a consequence of B_{n}, hence Γ_{0} is an axiomatization.

A theory is called consistent if it does not contain ⊥. By the completeness theorem, a theory is consistent iff it has a model.

A theory Γ is called complete iff it is consistent and for any closed formula A not contained in Γ, the set Γ ∪ {A} is inconsistent.

Exercise 5 Prove the following theorem:

A theorem is complete iff, for any closed formula A, we have either ⊢A or ⊢¬A (exclusive or).

A theory Γ is called decidable iff the set Γ is recursive. Any complete theory is decidable: in order to recursively decide whether A is in Γ, enumerate Γ.

Eventually, either A or ¬A will appear. In the first case, A ∈ Γ, in the second case A ∉ Γ.

One particular predicate is rather common: equality. It has the axioms

x = x,

x_{1} = y_{1} → … → x_{n} = y_{n} → f(x_{1}, …, x_{n}) = f(y_{1}, …, y_{n})

for any n-ary function symbol,

x_{1} = y_{1} → … → x_{n} = y_{n} → P (x_{1}, …, x_{n})→P (y_{1}, …, y_{n})

for any n-ary predicate symbol.

Exercise 6 Prove symmetry and transitivity.

Here is a first example of a first order theory: the “one point theory”.

• predicate symbols: “=”.

• no function symbols.

• axioms:

x = y

Exercise 7 Prove that the one point theory is complete.

Exercise 8 Give a formalization of a two points theory.

For any equational theory, one can also consider the corresponding first order theory with the same signature and axioms. In this way, one obtains the first order theory of semi-groups, groups, rings, commutative rings.

Theorem 22 The first order theory of groups is undecidable.

Proof: Let Σ be an alphabet and Γ be a finite set of equations with an undecidable word problem (see the theorem of Post-Markov in section 1). We reduce the word problem to the decision problem in the theory of groups, thereby showing undecidability of the second.

Let P be the conjunction of all equations in Γ. Given an equation A with words built from Σ, let E(A) be the formula P → A where the elements in Σ are considered as constants. We claim that the answer to the instance A of the word problem is yes iff E(A) is a theorem in the first order theory of groups. This achieves the required reduction.

If the answer to the instance of the word problem is yes, then there is a derivation in the equational theory. It is obvious that this derivation can be transformed to a derivation P ⊢ A in the first order theory helding all variables constant. By the deduction theorem, E(A) is provable.

Conversely, assume that E(A) is proveable. By semantical correctness, E(A) is true in the following interpretation: Let F be the semi-group of all words in Σ (in other words, the free semi-group generated by Σ). For two words s, t built from Σ, define s ∼ t modulo the equational theory defined by Γ. Clearly, this is an equivalence relation. Let S be the set of all equivalence classes. Then the semi-group operation is well-defined for classes, hence S is a model for the theory of semi-groups (i.e. S is a semi-group). Assign each variable in Σ to itself. By semantical correctness, E(A) is true in this interpretation. Since P is also true in this interpretation by construction, the conclusion A must also be true. Hence A is true in the equational theory, and therefore the answer to the instance of the word problem is yes.

Theorem 23 (Church) Predicate logic is undecidable.

Proof: Suppose indirectly that we had an algorithm M for deciding predicate logic. Then, we could use it to decide the theory of groups, as follows. Let A be a given formula in the theory of groups. The theory of groups has only finitely many axioms, which we now abbreviate by A_{1}, …, A_{r}. Then A is a theorem of group theory iff the formula

A_{1} → … → A_{r} → A

is a theorem of predicate logic. But this can be decided using the algorithm M. But the theory of groups is undecidable, a contradiction.

The first order theory of fields is obtained by adding the axiom x ≠ 0 → ∃y(xy = 1) to the equational theory of commutative rings.

The first order theory of ordered fields is obtained by adding a new unary predicate P (positive) to the theory of fields, together with the axioms

1. P (x) → ¬P (−x);

2. ¬P (0);

3. P (x) ∨ P (−x) ∨ x = 0;

4. P (x) ∧ P (y) → P (x + y);

5. P (x) ∧ P (y) → P (xy).

This is also a first example of a consistent theory without a finite model.

The first order theory of algebraically closed fields is obtained by adding an axiom

∃x(x^{n} + y_{1}x^{n−1} + ⋯ + y_{n} = 0)  (1)

for each positive integer n to the theory of fields. Of course, one has to write the powers by expanding them into products, in order to express them in the available language.

Theorem 24 The first order theory of algebraically closed fields is complete (and consequently decidable).

Proof: See [23].

The first order theory of real closed fields is obtained by adding an axiom 1 for each odd number n, and by adding the axiom

P (x) → ∃y(yy = x).

Theorem 25 The first order theory of real closed fields is complete (and consequently decidable).

Proof: See [23].

Exercise 9 Give a formalization of the theory of fields of characteristic zero.

Here is an example of a class of structures which is not the class of models of a first order theory.

Proposition 1 The class of finite groups is not the class of a first order theory.

Proof: Suppose indirectly that finite groups can be characterized by a first order theory Γ. Let A_{n} be the formula

∃(x_{1}, …, x_{n}) : (x_{1} ≠ x_{2} ∧ ⋯ ∧ x_{n−1} ≠ x_{n}).

The groups satisfying A_{n} are exactly the groups with at least n elements. Let Δ := {A_{1}, A_{2}, … }.

Any finite subset of Γ ∪ Δ is satisfiable by a group of sufficiently large order. By the compactness theorem, it follows that Γ ∪ Δ is satisfiable. Hence there is an infinite group satisfying Γ, a contradiction.

7 Elementary Theory of Real Numbers

We introduce a very important first order theory, the theory of real numbers. Methodologically, we assume a large part of classical methematics (especially algebra), because the participants are probably familiar with it.

Let F be the theory of fields, with predicate symbol “=”, function symbols +, −, 0, ·, 1, ring axioms, and the axiom

¬x = 0 → ∃y xy = 1.

The theory OF (ordered fields) is an extension with additional predicate symbol < and additional axioms

¬x < x, x < y→y < z→x < z,

x < y ∨ y < x ∨ x = y,

x < y → x + z < y + z,

0 < z → x < y → xz < yz.

Obviously, one can define the predicates >, ≤, ≥, ≠.

Remark 7 About defining new predicates: it is possible to interpretate the new predicates as metatheoretical abbreviations, e.g. t_{1}≤t_{2} is nothing but an abbreviation of t_{1} = t_{2}∨t_{1} < t_{2}. Alternatively, we can extend the formal system by adding the new predicate symbol and add the new axiom

x_{1}≤t_{2}↔(x1 = x_{2}∨x_{1} < x_{2}).

One can show formally that the original system and the extended system are equivalent, in the sense that derivations can be translated in both directions.

A very familiar model for the theory OF is Q.

By composition of the available function symbols, we get all multivariate polynomials with integral coefficients. We “identify” polynomials which provably coincide for all arguments, e.g. (x + x)·x = x·x + x·x + 0·x. Doing so, we can bring polynomials into normal form, and we can define the degree of a polynomial with respect to a variable. By definition, we say that the zero polynomial has degree −∞.

If a_{0}, …, a_{n} are variables, then the polynomial

Γ_{n} := a_{0} + … + a_{n}x^{n}

is called a generic polynomial of degree n (obviously, generic polynomials are unique up to renaming of variables).

The theory R of real numbers is an extension of OF by an infinite number of axioms, one for each natural number n:

Γ_{n}(x) < 0 → Γ_{n}(y) > 0 → ∃z(x < z < y∧Γ_{n}(z) = 0)

(called intermediate value axioms).

Of course, the intended model is the set of real numbers. Note, however, that this model is not a model in the sense as defined in the previous section, because real numbers cannot be finitely represented.

Here is a non-standard model which consists of finitely described objects: the set of all real algebraic numbers.

Exercise 10 Prove

x > 0 → ∃y(y^{2} = x).

Theorem 26 Let Γ_{n} := a_{0} + … + a_{n}x^{n}, n odd. Then

⊢ a_{n}≠0 → ∃xΓ_{n}(x) = 0.

Proof: Assume a_{n}≠0. For i = 0, …, n − 1, we know ∃b_{i} a_{n}b_{i} = a_{i}. For these b_{i},

∃b(b > −nb_{0}∧…∧b > −nb_{n−1}∧b > 1),

since < is a total order. For this b, we have b^{n} > −nb_{i}x^{i}, i = 0, …, n − 1. Therefore

b_{0} + … + b_{n−1}b^{n−1} + b^{n} > 0.

Similarily, we construct an a such that

b_{0} + … + b_{n−1}a^{n−1} + a^{n} < 0.

By the intermediate value axiom, the polynomial b_{0} + … + b_{n−1}x^{n−1} + x^{n} has a zero c. But then, we also have

a_{0} + … + a_{n}c^{n} = 0.

Some authors give a different axiomatization of R. They omit the intermediate value axioms; instead, they postulate the existence of square roots for positive elements (exercise 10), and the existence of roots of polynomials of odd degree (theorem 26). To show that the two axiomatizations are equivalent, one has to show the intermediate value statement from the exercise 10 and theorem 26.

Theorem 27 Let K be an ordered field such that any positive element has a square root and any polynomial of odd degree has a root. Then the intermediate value theorem holds in K.

Proof: See (Jacobson, Basic Algebra I).

We are now able to prove that the intermediate value axioms follow formally from exercise 10 and theorem 26. For any n, let I_{n} be the universal quantification of the n-th intermediate value statement. The negation ¬I_{n} together with OF and exercise 10 and theorem 26 is insatisfiable. By theorem ??, this set is inconsistent, hence there is a derivation of ⊥. By the deduction theorem, there is a derivation of ¬I_{n}→⊥ from the remaining axioms. From this we can formally deduce the intermediate value axioms.

Remark 8 Note that the proof above is not a finitary one, because it uses the infinite models. To obtain a finitary proof, it is necessary to translate the proof of theorem 27 into our formal language.

In one of the next sections, it is shown that R is complete, hence decidable. We already know that it is consistent, because it has a model. Caution: we do not yet have a finitary proof for consistency!

Actually, completeness will be obtained from the following theorem, which is interesting on its own.

Theorem 28 (Quantifier elimination) Let A be a formula in R. Then there exists a formula B without quantifiers, such that A∼B in R.

In other words, any definable n-ary is equivalent to a Boolean combination of polynomial equations and inequalities. Especially, any unary predicate is a finite union of intervals and points. For instance, the properties of being rational/integral cannot be expressed in the language R.

Completeness follows from the obvious fact that any closed formula without quantifiers is either a theorem or contradictory.

For later use, we mention Dedekind’s cuts. This is a scheme of formulas of the form

(A(x) → B(y) → x≤y)→∃b(A(x) → B(y) → x≤b≤y)

which is well-known from analysis. Since these formulae are true in R, and - as we will see - the system R is complete, the formulae can be proven from the axioms. Alternatively, one can also show that the Dedekind’s cuts are theorems by theorem 28.

8 Formal Euclidean Geometry

In this section, we present maybe the most outstanding result obtained of a long history of axiomatization: decidability of euclidean geometry. Most proofs are only sketched, due to the fact that they are lengthy but not surprising.

Usually, euclidean geometry is formalized using two types, points and lines (or points, lines, and planes). In our formalization, we follow Tarski, who observed that the type “lines” is eliminable.

In addition to equality, we have two predicates. The ternary predicate Bxyz has the following semantic interpretation: the three points x, y, z are collinear and y is between x and z (or coincides with x or z). The 4-ary predicate xy≅zw has the following semantic interpretation: the distance between x and y is equal to the distance of z and w. We define a new ternary predicate by

Cabc : ↔Babc ∨ Bbca ∨ Bcab,

which has the interpretation that a, b, c are collinear.

We have 10 axioms and one axiom scheme (which gives infinitely many axioms).

1. ab ≅ ba

2. ab ≅ pq → ab ≅ rs → pq ≅ rs

3. ab ≅ cc → a = b

4. ∃x(Bqax ∧ ax ≅ bc)

5. a≠b → Babc → Ba′b′c′ → ab≅a′b′ → bc≅b′c′ → ad≅a′d′ → bd≅b′d′ → cd≅c′d′

6. Baba → a = b

7. Bapc → Bbqc → ∃x(Bbxp ∧ Bqxa) (Pasch’s axiom)

8. ∃a∃b∃c¬Cabc (lower dimension axiom)

9. p≠q → ap ≅ aq → bp ≅ bq → cp ≅ cq → Cabc (upper dimension axiom)

10. Badt → Bbdc → a≠d → ∃x∃y(Babx ∧ Bacy ∧ Bxty)

(10) is equivalent to Euclid’s axiom of parallels. The axiom scheme is

∃a∀x∀y(A(x)→B(y)→Baxy) → ∃b∀x∀y(A(x)→B(y)→Bxby).

This is a geometric formulation of Dedekind’s axiom of cuts.

Obviously, the extended model is the Euclidean plan, with points as objects. Lines are superfluous because any assertion about lines can be expressed by the betweenness relation.

One can give an axiomatization for the Euclidean 3-space (or higher dimensional Euclidean spaces) by replacing axioms 8 and 9 by other axioms (see [10]).

Here are some easy theorems. Theorem 29 The following formulas are theorems.

1. ab ≅ ab

2. ab ≅ cd → cd ≅ ab

3. ab ≅ cd → cd ≅ ef → ab ≅ ef

4. aa ≅ bb

5. Babc → Ba′b′c′ → ab≅a′b′ → bc≅b′c′ → ac≅a′c′

6. q≠a → ∃!x(Bqax∧ax≅bc)

7. Babb

8. Babc → Bcba

9. Babc → Bbac → a = b

10. ∃x∃y x≠y

Proof: We prove the first, and the eigth assuming the seventh.

1. ba ≅ ab → ba ≅ ab → ab ≅ ab axiom 2

2. ba ≅ ab axiom 1

3. ba ≅ ab → ab ≅ ab modus ponens from 1 and 2

4. ab ≅ ab modus ponens from 3 and 2 To show the eigth, we assume Babc and Bbcc (by the seventh) and derive Bcba.

1. Babc → Bbcc → ∃x(Bbxb ∧ Bcxa) axiom 7

2. ∃x(Bbxb ∧ Bcxa) modus ponens two times By axiom 6, such an x is unique and it must be b, hence Bcba.

Exercise 11 Prove three of the above formal theorems (not the first and the eighth).

Here is a theorem which is geometrically more interesting.

Theorem 30 The following formula is a theorem.

Babc → Bdbe → ab≅db → bc≅be → ae≅cd

Proof: We distinguish the cases a≠b and a = b.

Assume a = b. Then d = b by the assumption ab≅db and axiom 3 (using the symmetry facts on ≅ which have been proved in the above exercise). Then the assumption bc≅be implies the conclusion ae≅cd.

Now, assume a≠b. By the specialization a′ = d, b′ = b, c′ = e, d′ = a, from axiom 5, we obtain

a≠b → Babc → Bdbe → ab≅db → bc≅be → ad≅da → bd≅ba → cd≅ea.

All assumptions of the axioms are fulfilled in our case, hence also the conclusion cd≅ea, which implies ae≅cd.

To be more flexible, we enrich our language a little bit. Similar to the definition of new predicates, we may also define new functions. Let ∃! be a shorthand for unique existence, i.e. ∃!xA(x) stands for

∃xA(x) ∧ (A(x)→A(y)→x = y).

Suppose that we have proven a theorem

∃!yA(x_{1}, …, x_{n}, y),

where A has no other free variables than x_{1}, …, x_{n}, y. Then we may extend the language by adding a new n-ary function symbol f and the new axiom

A(x_{1}, …, x_{n}, f(x_{1}, …, x_{n})).

One can show that this extension is an equivalence, in the sense that derivations can be translated in both directions. More precisely, we translate formulas of the kind P (s_{1}, …, s_{k−1}, f(t_{1}, …, t_{n}), s_{k+1}, …, s_{m}) into the formula

∃y(P (s_{1}, …, s_{k−1}, y, s_{k+1}, …, s_{m}) ∧ A(t_{1}, …, t_{n}, y)),

where y is a variable not occuring in the terms involved.

In this sense, we define a new binary function s (point reflection) by

Bbas(a, b) ∧ as(a, b)≅ab.

We also write s_{a}(b) instead of s(a, b). One can show that s_{a} is an involutory map preserving distance and between-ness:

s_{a}(s_{a}(b)) = b

Bbcd ↔ Bs_{a}(b)s_{a}(c)s_{a}(d)

bc≅de ↔ s_{a}(b)s_{a}(c)≅s_{a}(d)s_{a}(e)

Then, we define a new ternary predicate (right angle) by

Rabc : ↔ac ≅ s_{b}(a)c.

One can show that ∃!x(Baxb∧ax≅xb). We use this to define a binary function m (midpoint) by

Bam(a, b)b ∧ am(a, b)≅m(a, b)b.

We define a 4-ary predicate (parallel lines) by

ab||cd : ↔∃(x, y)(Rbax∧Raby∧Ccxd∧Ccyd∧ax≅by).

Exercise 12 Prove

Babc → Bade → ab≅ad → bc≅de → be≅cd

Our next goal is to show that our formalization G of Euclidean geometry is equivalent to R, the theory of real closed fields. This implies that G is decidable.

The idea goes back to Descartes. He had in mind an algorithm with the following specification.

Input: A formula A of G.

Output: A formula B = F (A) of R, which is a theorem iff A is a theorem.

To describe Descartes’ algorithm, we describe how to deal with the formulas a = b, Babc, and ab≅cd. These will be translated into certain formulas E(a_{1}, a_{2}, b_{1}, b_{2}), B(a_{1}, a_{2}, b_{1}, b_{2}, c_{1}, c_{2}), and D(a_{1}, a_{2}, b_{1}, b_{2}, c_{1}, c_{2}, d_{1}, d_{2}). The logical connectives ∧, ∨, neg, →, ⊥ are translated 1:1. The quantifiers are doubled, i.e. ∃x translates to ∃x_{1}∃x_{2}, and ∀x translates to ∀x_{1}∀x_{2}.

E is a_{1} = b_{1} ∧ a_{2} = b_{2},

B is a_{1}(b_{2} − c_{2}) + b_{1}(c_{2} − a_{2}) + c_{1}(a_{2} − b_{2}) = 0 ∧ (b_{2} − c_{2})(a_{2} − b_{2})≥0 ∧ (b_{1} − c_{1})(a_{1} − b_{1})≥0,

D is (a_{1} − b_{1})^{2} + (a_{2} − b_{2})^{2} = (c_{1} − d_{1})^{2} + (c_{2} − d_{2})^{2}.

Exercise 13 Give a translation of the predicates R and || (without formal proof).

Theorem 31 If A_{1}, …, A_{n} ⊢ C in G, then F (A_{1}), …, F (A_{n}) ⊢ F (C) in R.

Proof: (sketch) It suffices to prove the statement for all material axioms, because we did not do any changes in the logical structur (except for the duplication of quantifiers, but here all axioms/inference rules carry over).

The first 10 axioms can be checked automatically, this is cumbersome but easy.

Now, let A(x) and B(y) be formulas. Let D be the axiom arising from A and B by the Dedekind scheme. Let A(x_{1}, x_{2}) and B(x_{1}, x_{2}) be the real translations of A and B. Using some case distinction, we can derive F (D) from the formula

(A′(x) → B′(y) → x≤y)→∃b(A′(x) → B′(y) → x≤b≤y)

(Dedekind cuts). It can be shown that this formula is a theorem.

Corollary 3 G is consistent.

Proof: If ⊢ ⊥ in G, then ⊢ F (⊥) = ⊥ in R, but we know that R is consistent.

If we have a model (R, +, −, 0, ·, 1, <) of the theory R, then we can construct a model (G, B, ≅) as follows.

• Set G := R^{2}.

• Set B and ≅ as in the translation above.

It is obvious that the truth value of a closed formula A in the interpretation (G, B, ≅) is equal to the truth value of the formula F (A) in the interpretation (R, +, −, 0, ·, 1, <).

The following theorem states that every model can be constructed in this way.

Theorem 32 Let (G, B, ≅) be a model of G. Then there exists a model (R, +, −, 0, ·, 1, < ) of R, such that (G, B, ≅) is isomorphic to (R^{2}, B′, ≅′), where B′ and ≅′ are defined as above.

Proof: In G, one can prove the formula

∃(o, e_{1}, e_{2})(o ≠ e_{1} ∧ oe_{1} ≅ oe_{2} ∧ Re_{1}oe_{2}).

Since G is a model of G, there exist three elements in o, e_{1}, e_{2} ∈ G such that o ≠ e_{1}, oe_{1} ≅ oe_{2}, and Re_{1}oe_{2}.

We set R as the subset of G of all elements x for which Coe_{1}x is true (the first coordinate axis).

We set 0 := o and 1 := e_{1}. These points are in R because one can derive in G

o ≠ e_{1}, oe_{1} ≅ oe_{2}, Re_{1}oe_{2} ⊢ Coe_{1}o, Coe_{1}e_{1}.

For x, y ∈ R, we set x + y := s_{o}(m(x, y)). In order to show that these points are in R, one has to prove in G

o ≠ e_{1}, oe_{1} ≅ oe_{2}, Re_{1}oe_{2}, Coe_{1}x, Coe_{1}y ⊢ Coe_{1}s_{o}(m(x, y)).

For x ∈ R, we define −x := s_{o}(x) (again we have to show that this is in R).

For x, y ∈ R, we define x < y to be true iff ¬B(a − b)oe_{1} is true.

The definition of multiplication is a bit tricky. First, we prove in G the consequence

o ≠ e_{1}, oe_{1} ≅ oe_{2}, Re_{1}oe_{2}, Coe_{1}x, Coe_{1}y ⊢ ∃!zCoe_{1}z ∧ (∃w(Coe_{2}w ∧ e_{1}e_{2}||yw ∧ e_{2}x||wz)).

Then, for given x, y in R, we know that there exists a unique z for which the above existential formula is true. Moreover, this z is in R because Coe_{1}z is true. Thus, we can define x · y to be this z.

The next step is to show that the structure just defined satisfies all axioms of R. We will not do this here.

It remains to construct the isomorphism between G and R^{2}. This is done as follows.

For a ∈ G, define c_{1}(a) ∈ R as the unique element such that (Roc_{1}(a)a ∧ Coe_{1}c_{1}(a) is true (again one can show uniqueness and existence in G). Define c_{2}(a) ∈ R as the unique element such that

(Roc_{2}(a)a ∧ ∃u(Roua ∧ Coe_{2}u ∧ e_{1}e_{2}||uc_{2}(a))

is true. Then a ↦ (c_{1}(a), c_{2}(a)) defines a map from G to R^{2}. One can show that this map is an isomorphism, and finally that the this isomorphism takes the relations B and ≅ to the relations B′ and ≅′ as above.

Corollary 4 G is complete.

Proof: Assume indirectly that A be a closed formula of G such that A and ¬A are both not provable. Then G ∪ A is consistent. By the completeness theorem, there is a model (G, B, ≅) satisfying A. By the above theorem, we can assume that G = R^{2} for a real closed field R. Therefore R is a model for F (A). Because of semantical correctness, R ∪ F(A) is consistent. Because R is complete, F (A) is a theorem of R.

Likewise, G ∪ ¬A is consistent, so there is a model G′ satisfying ¬A, we may assume G′ = (R′)^{2}, and R′ is a model for F (¬A) = ¬F (A), so R ∪ ¬F(A) is consistent, so ¬F (A) is a theorem of R. But then ⊥ is a theorem of R, which contradicts consistency of R.

9 Formal Number Theory

A theory of natural numbers is fundamental for many parts of mathematics.

The formal system of number theory (also called the theory of arithmetic) has one constant 0, one unary function symbol ′ (successor) and two binary functions + and ·. There are various axiomatizations. A common one is Peano’s axioms:

1. a′ = b′ → a = b;

2. ¬a′ = 0;

3. a + 0 = a;

4. a + b′ = (a + b)′;

5. a · 0 = 0;

6. a · b′ = a · b + a;

7. A(0) → ∀x(A(x)→A(x←x′)) → A(x), where A is a formula.

In this section, we will not be very much with a specific axiomatization. Instead, we will show that there exists no complete axiomatization.

The standard model is the set ℕ, which can be constructed as the terms 0, 1 := 0′, 2 := 0′′, . . .. The natural numbers constructed this way are also called numerals. Addition and multiplication for numerals are defined as usual (there is a unique way which is consistent with the Peano axioms).

We will need meta-variables for numerals, which must not be confused with the variables in the formal system. Thus, we make the following convention:

• The letters a, b, c, d, e, x, y, z are reserved for variables.

• The letters i, j, k, l, m, n are reserved for meta-variables ranging over numerals.

• The function symbols + and · are used as a language element and as names for function on numerals. One has to look at the arguments to tell. We will not use ′ as a name for a function on numerals.

We say that an n-ary predicate P of numerals is arithmetic iff there exists a formula A(x_{1}, …, x_{n}) such that for every n-tuple (i_{1}, …, i_{n}) of numerals, P (i_{1}, …, i_{n}) is equivalent to the statement that A(i_{1}, …, i_{n}) is a true in the standard model.

A partial n-ary function f from numerals to numerals is called arithmetic iff the n + 1-ary predicate f(i_{1}, …, i_{n}) = j (the graph of f) is arithmetic.

Theorem 33 Let f_{1}, …, f_{m} be n-ary arithmetic functions of numerals, and let P be an P be an arithmetic predicate. Then the predicate P (f_{1}(i_{1}, …, i_{n}), …, f_{m}(i_{1}, …, i_{n})) is arithmetic.

Proof: Let f be a unary arithmetic function, expressed by the formulas F (x, y). Let P be a unary arithmetic predicate, expressed by the formula A(x). Then P (f(i)) holds if and only if there exists a numeral j such that F (i, j) and A(j) are both true in the standard model. Since the standard model contains exactly the numerals, this is equivalent to ∃z(F (i, z)∧A(z)) being true in the standard model. Thus, the compound predicate is expressed by the formula ∃z(F (x, z)∧A(z)).

The general case with several arguments is similar.

Corollary 5 The composition of arithmetic functions is arithmetic.

Proof: Apply theorem 33 to the graph of the outer function.

An essential feature of formal number theory is that one can construct tuples (i.e. finite sequences).

Theorem 34 (Gödel’s Beta-function) There is an arithmetic ternary function β on numerals, such that for any finite sequence i_{0}, …, i_{n} of numerals, there exist numerals j, k, such that β(j, k, m) = i_{m}.

Proof: The definition of β is quite simple, namely we take

β(j, k, m) := rem(j, 1 + (m + 1)k).

The hard part is to construct j and k for a given sequence. Let i_{0}, …, i_{n} be a sequence. Let l be the maximum of n, i_{0}, …, i_{n}, and take k := l!. Then the numerals 1 + k, 1 + 2k, …, 1 + (n + 1)k are pairwise relatively prime. By the Chinese remainder theorem, there exists a numeral j such that

rem(j, 1 + (m + 1)k) = i_{m}

for m = 0, …, n.

In order to see that β is arithmetic, it suffices to notice that β(i, j, k) = l is equivalent to the truth of

∃x((m′ · k)′ · x + l = j) ∧ ∃y(l + y′ = (m′ · k)′)

in the standard model.

Remark 9 In the following, we write B(x, y, z, w) for the formula expressing β(x, y, z) = w.

Recall the definition of recursive functions (see [32] or [24]), constructed from the zero function, the successor function, and the projection functions, by composition, primitive recursion, and minimalization. The partial recursive functions are defined analoguously, except that minimalization is defined in the following way: if g(i, j) is a partial recursive function, then the minimalization μ(g) is defined by μ(g)(j) is the smallest i such that g(i, j) = 0 and g(i′, j) is defined for all i′ < i.

Theorem 35 Any partial recursive function f is arithmetic.

Proof: Obviously, the constant zero function, the successor, and the projection functions are arithmetic. Composition was already proven to preserve arithmetic-ness.

Primitive recursion: let l be a numeral, and let h be a binary function expressed by the formula H(x_{1}, x_{2}, y). Then we claim that the primitive recursion f—defined by f(0) := l, f(n + 1) = h(i, f(i))—is expressed by the formula

F (x, y) := ∃(c, d)

(B(c, d, 0, l)∧

∀z(z < x → ∃(a, b)(B(c, d, z, a) ∧ B(c, d, z′, b) ∧ H(z, a, b))∧

B(c, d, x, y).

Suppose that f(i) = j. By the theorem of the β-function, there exist numerals m, n, such that β(m, n, k) = f(k) for all k = 0, …, i. Therefore the formulas B(m, n, k, f(k)) are true in the standard model. Since f(0) = l, the formula B(m, n, 0, l) is true. Since f(k + 1) = h(i, f(k)), the formulas B(m, n, k, f(k)), B(m, n, k′, f(k + 1)), and H(k, f(k), f(k + 1)) are true for all k < i. Since f(i) = j, the formula B(m, n, i, j) is true. This proves that F (i, j) is true in the standard model.

Conversely, assume that F (i, j) is true in the standard model. Then there exist numerals m, n such that the formulas

B(m, n, 0, l),
∀z(z < i → ∃(a, b)(B(m, n, z, a) ∧ B(m, n, z′, b) ∧ H(z, a, b)),
B(m, n, i, j)

are all true. The first implies β(m, n, 0) = l. The second implies that sequence i_{k} := β(c, d, k), k = 0, …, i − 1, fulfills the recursion h(k, i_{k}) = i_{k+1}. By the definition of f, it follows that f(k) = i_{k} for k = 0, …, i. Finally, the third formula being true implies that i_{i} = j. It follows that f(i) = j.

The general case with several arguments is treated analogously.

Minimalization: Suppose that g is an binary partial function described by the ternary formula G(x_{1}, x_{2}, y). Then we claim that the minimalization f of g—defined by f(i) is the smallest j such that g(j, i) = 0, supposed that g(j′, i) is defined for all j′ < j—can be described by the formula

F (x, y) := G(y, x, 0) ∧ ∀z(z < y→∃w(G(z, x, w) ∧ w ≠ 0)).

Let f(i) = j. Then g(i, j) = 0, hence G(y, x, 0) is true in the standard model. For all k < j, there exists l > 0 such that g(k, i) = l. It follows that F (i, j) is true.

Conversely, suppose that F (i, j) is true in the standard model. Then g(j, i) = 0, and for all k < j, there exists l > 0 such that g(k, i) = l. Hence f(i) = j be the definition of minimalization.

The general case with several arguments is treated analogously.

Corollary 6 For any recursively enumerable subset P of numerals, the property “contained in P ” is arithmetic.

Proof: Let P be a recursively enumerable set of numerals. It is well-known that a set is recursively enumerable iff it is the domain of a partial recursive function. By theorem 35, any such function is arithmetic. Let F (x, y) be the formula expressing a partial recursive function with domain P. Then the property “contained in P ” is expressed by A(x) := ∃yF (x, y).

Theorem 36 (Gödel’s incompleteness theorem) Any first order theory with equality, a constant symbol 0, a unary function symbol ′, and two binary function symbols + and ·, which is satisfied by the standard model ℕ, is incomplete.

Proof: Suppose, indirectly, that we have a complete axiomatization. Let Q be a recursively enumerable set of numerals which is not recursive. By corollary 6, the property “contained in Q” is arithmetic. Hence it can be expressed by a formula A(x).

For any given numeral n, we have either ⊢ A(n) or ⊢ ¬A(n) by completeness. Thus, we can produce algorithmically either a proof of A(n) or a proof of ¬A(n). Thus, we can decide whether n is contained in Q. This contradicts the assumption that Q is not recursive.

In contrast to the incompleteness theorem, consider the theory of Presburger arithmetic: one constant 0, one unary function symbol ′ (successor) and one binary functions +. The axioms are:

1. a′ = b′ → a = b;

2. ¬a′ = 0; 3. a + 0 = a;

4. a + b′ = (a + b)′;

5. A(0) → ∀x(A(x)→A(x←x′)) → A(x), where A is a formula. Theorem 37 (Presburger) The theory of Presburger arithmetic is complete (hence decidable).

Proof: See [23].

10 Hilbert’s 10th problem

In 1900, Hilbert formulated the problem of giving an algorithm to decide whether a given polynomial equation in several variables, P (x_{1}, …, x_{n}) = 0, has a solution in integers. In 1970, Matijasevic proved that such an algorithm is not possible. In this section, we will give a proof for this result, assuming a certain technical lemma (exponentiation is diophantine).

We say that an n-ary predicate P of numerals is diophantine iff there exists a numeral m and a polynomial Q ∈ ℤ[x_{1}, …, x_{n}, y_{1}, …, y_{m}], such that P (i_{1}, …, i_{n}) is true iff the diophantine equation

Q(i_{1}, …, i_{n}, y_{1}, …, y_{m}) = 0

has a solution (j_{1}, …, j_{m}) ∈ ℕ^{m}.

Proposition 2 Every diophantine predicate is recursively enumerable.

Proof: The following program, with input i_{1}, …, i_{n},

for all m-tuples (j_{1}, …, j_{m})
if Q(i_{1}, …, i_{n}, j_{1}, …, j_{m}) = 0, then exit

has Q as its domain of definition. In the for loop, one has to take care that all possible tuples are enumerated eventually.

The main result of this section will be the converse of this proposition. It is clear that every diophantine predicate is arithmetic, since it can be

expressed by the formula

∃(y_{1}, …, y_{m})(Q_{+}(x_{1}, …, x_{n}, y_{1}, …, y_{m}) = Q_{−}(x_{1}, …, x_{n}, y_{1}, …, y_{m})),

where Q is written as a difference Q_{+} − Q_{−} with polynomials with coefficients in ℕ.

Lemma 2 The conjunction and disjunction of diophantine predicates is diophantine.

Proof: Let

P_{1}(x_{1}, …, x_{n}) :↔ ∃(y_{1}, …, y_{m})(Q_{1}(x_{1}, …, x_{n}, y_{1}, …, y_{m}) = 0),
P_{2}(x_{1}, …, x_{n}) :↔ ∃(z_{1}, …, z_{l})(Q_{2}(x_{1}, …, x_{n}, z_{1}, …, z_{l}) = 0),

be diophantine predicates (negative coefficients of Q_{1} and Q_{2} have to be syntactically understood as coefficients on the right hand side of the equation). Then P_{1} ∧ P_{2} can be expressed by

∃(y_{1}, …, y_{m}, z_{1}, …, z_{l})(Q_{1}(x_{1}, …, y_{m})^{2} + Q_{2}(x_{1}, …, z_{l})^{2} = 0),

and P_{1} ∨ P_{2} can be expressed by ∃(y_{1}, …, y_{m}, z_{1}, …, z_{l})(Q_{1}(x_{1}, …, y_{m})Q_{2}(x_{1}, …, z_{l}) = 0).

Lemma 3 Existential quantification of diophantine predicates is diophantine. Proof: Let

P (x_{1}, …, x_{m}) :↔ ∃(y_{1}, …, y_{m})(Q(x_{1}, …, x_{n}, y_{1}, …, y_{m}) = 0) be a diophantine predicate. Then ∃x_{1}P (x_{1}, …, x_{m}) can be expressed by

∃(y_{1}, …, y_{m}, x_{1})(Q(x_{1}, …, x_{n}, y_{1}, …, y_{m}) = 0).

We say that an n-ary partial function is diophantine iff its graph (an n + 1ary predicate) is diophantine. For example, all polynomial partial functions— being undefined iff the result is negative—are diophantine, because they can be expressed by

∃()(Q_{+}(x_{1}, …, x_{n}) = Q_{−}(x_{1}, …, x_{n}) + y)

(zero quantifications). Especially, the functions + and · are diophantine. Lemma 4 Let f_{1}, …, f_{m} be n-ary diophantine functions, and let P be an P be a diophantine predicate. Then the predicate P (f_{1}(i_{1}, …, i_{n}), …, f_{m}(i_{1}, …, i_{n})) is diophantine. Proof: Replace “arithmetic” by “diophantine” in the proof of theorem 33. Corollary 7 The composition of diophantine functions is diophantine. Proof: Apply lemma 4 to the graph of the outer function. Exercise 14 Here are some diophantine predicates and functions:

x < y ↔ ∃z(x + z + 1 = y)

x|y ↔ ∃z(xz = y)
div(x, y) = z ↔ ∃(u, v)((u + v + 1 − y)^{2} + (u − x + zy)^{2} = 0)
rem(x, y) = z ↔ ∃(u, v)((z + u + 1 − y)^{2} + (z − x + vy)^{2} = 0)

Lemma 5 Gödel’s β-function is diophantine.

Proof: It suffices to observe that the β-function is a composite of the remainder function and polynomial functions.

At this point, we see that we could copy the proof of theorem 35, replacing by “arithmetic” by “diophantine”, if we only knew that bounded universal quantification of diophantine predicates is diophantine. The following lemmata are just here for the purpose to close exactly this gap.

Lemma 6 The functions (x, y) ↦ x^{y}, (x, y) ↦ \binom{x}{y}, and x ↦ x!, are diophantine.

Proof: We omit the proofs because they are technical. They can be found in [15] or in [20].

Lemma 7 Let P ∈ ℤ[b, z, x]. Let n be the total degree, and let m be a bound for the sum of the coefficients. Then the following formulas are equivalent over ℕ:

1. ∀z_{<u}∃xP (b, z, x) = 0;

2. ∃(y, v, w)(\binom{v}{u} | P (b, v, w)∧ \frac{v−u}{u−1} > m(b + u + y + 1)^{ny}∧ (u!)^{2} | v + 1 ∧ \binom{v}{u} | \frac{w!}{(w−y)!}).

Proof: Assume the first formula is true. Let x_{0}, …, x_{u−1} be such that P (b, z, x_{z}) = 0 for z = 0, …, u − 1. Let y be such that x_{z} < y for all x_{z}. Let v be such that the second and third condition are fulfilled, i.e. v is congruent −1 modulo (u!)^{2} and v > u + (u + 1)m(b + u + x + 1)^{ny}.

For z = 0, …, u − 1, the numbers u_{z} := \frac{v+1}{z+1} − 1 = \frac{v−z}{z+1} are integers, and they are pairwise relatively prime: if d is a common prime factor of u_{i} and u_{j} for i < j < u, then d divides (j + 1)u_{i} − (i + 1)v_{j} = j − i, hence d < u, hence d | u!, hence d | \frac{v+1}{i+1}; because also d | u_{i} = \frac{v+1}{i+1} − 1, we get d = 1.

By the Chinese remainder theorem, there exists w such that w is congruent x_{z} modulo u_{z}, for z = 0, …, u − 1. Moreover, we have that v is congruent z modulo u_{z}. Because P (b, z, x_{z}) = 0, it follows that P (b, v, w) is congruent 0 modulo u_{z}. Since the u_{z} are pairwise relatively prime, P (b, v, w) is divisible by their product, which is equal to \binom{v}{u}. This shows that the first condition is fulfilled.

For z = 0, …, u − 1, the number w − x_{z} is divisible by u_{z}. Since x_{z} < y, also \frac{w!}{(w−y)!} = w(w − 1) … (w − y + 1) is divisible by u_{z}. Again because the u_{z} are pairwise relatively prime, \frac{w!}{(w−y)!} is divisible by their product \binom{v}{u}. This shows that the fourth condition is fulfilled.

Now, assume that the second formula is true, i.e. we have y, v, w such that the four conditions hold. Let z be an arbitrary number less than u. Again, we define u_{z} := \frac{v−z}{z+1} . From the fourth condition, we conclude that u_{z} divides the product w(w − 1) … (w − y + 1). Therefore we can factor u_{z} into a product of y numbers, each dividing one factor w − j.

There must be a factor r of u_{z} and a factor w − x of the right product such that r^{y} ≥ u_{z}. Since v − z is divisible by u_{z} and therefore divisible by r, we get v congruent z modulo r. Since w − x is divisible by r, w is congruent x modulo r. By the first condition, P (b, v, w) is congruent 0 modulo u_{z}, and therefore congruent 0 modulo r. Hence P (b, z, x) is congruent 0 modulo r.

To turn the modulo equation into an absolute equation, we use a bound for the absolute value of the polynomial. In fact,

|P (b, z, x)| < m(b + z + x + 1)^{n} < m(b + u + y + 1)^{n} < u_{z}^{1/y} ≤ r,

where the third inequality is a consequence of the second condition. This implies P (b, z, x) = 0.

Because z was chosen arbitrary, we can construct such an x for each z less than u, and the first formula is true.

Lemma 8 Bounded universal quantification of diophantine predicates is diophantine.

Proof: For the case of one free variable and one existential quantifier, lemma 7 shows the claim (the second predicate is diophantine by the previous formula). The general case follows from a generalization of lemma 7 which is proven similarily.

Theorem 38 (Matijasevic) Any recursively enumerable set is diophantine.

Proof: Replace “arithmetic” by “diophantine” in the proof of theorem 35 and corollary 6.

If P is a unary recursively enumerable set which is expressed by

P (x) :↔ ∃(y_{1}, …, y_{m})(Q(x, y_{1}, …, y_{m}) = 0),

then the m + 1-ary polynomial function defined by the polynomial x(1 − 2Q^{2}) has value x if x ∈ P and is undefined (since the value is negative) otherwise. Therefore, we have as a consequence:

Corollary 8 Any recursively enumerable subset of ℕ is the image set of a polynomial partial function.

Remark 10 For a long time, experts in number theory believed that there is no “formula for primes”, i.e. no expression with all values being prime numbers. By the above corollory, there exists even a polynomial, and the value set is the set of all prime numbers.

Assume that we have a coding function of the set of all polynomials with integer coefficients to ℕ, subject to the conditions

• the coding is un-ambiguous (i.e. the function is injective);

• the code of a polynomial can be recursively computed from the coefficients.

It is easy to construct such codes.

Theorem 39 (recursive unsolvability of Hilbert’s 10th problem) The unary predicate “x is the code of a polynomial which has a zero in the natural numbers” is not recursive.

Proof: Let P be a unary predicate which is recursively enumerable but not recursive (it was shown in a previous section that such sets exist). By Matijasevic’s theorem, there is a polynomial Q such that

P (x) ↔ ∃(y_{1}, …, y_{m})(Q(x, y_{1}, …, y_{m}) = 0).

Suppose indirectly that there exists a recursive program X that decides whether the input is the code of a polynomial which has a zero. Then the following program with input u,

compute the code p_{u} of the polynomial Q[x := u] in y_{1}, …, y_{m};
apply X to p_{u}

would decide recursively whether u ∈ P, a contradiction.

Remark 11 The original problem asked for an algorithmic method for deciding the existence of a solution in integers, not in natural numbers. But also this problem is recursively unsolvable, because Q(x_{1}, …, x_{n}) has a solution in integers iff the polynomial

∏_{i_{1},...,i_{n}=0,1} Q((−1)^{i_{1}}x_{1}, …, (−1)^{i_{n}}x_{n})

has a solution in the natural numbers.

11 λ-calculus

In λ-calculus, one tries to formalize functions. Therefore, there is no metatheoretic distinction between informal functions and objects, because the objects are the informal functions. Terms can be built using only one formal function symbol: application. Instead of f(x), we write app(f, x) (where a is application).

Functions with several arguments are handled in the following way. There is a one-to-one correspondence between functions binary functions unary functions with values in the unary function space: for any binary function f and value x, let f_{x} be the unary function obtained by replacing the first argument by x. This assignment x ↦ f_{x} gives one direction. Reversely, for any function valued function g, one can construct a binary function by (x, y) ↦ app(app(f, x), y). By this isomorphism, we may consider any function as a univariate function.

We make the convention to write app(f, x) as fx, binding from the left, i.e. xyz = (xy)z = app(app(x, y), z). This has the advantage that terms built by application look like usual function terms in polish notation, e.g. the term corresponding infomally to a+b·c, which is app(app(+, a), app(app(·, b), c)), can be written +a(·bc).

λ-calculus is an equational theory with quantifiers. For any term t and any variable x, there is a quantified term λxt or λx.t, meaning the function mapping x to t. We make the convention that λ binds weaker than application, i.e. λx.yz = λx.(yz). We write λx_{1} … x_{n}.t as a shorthand for λx_{1}.λx_{2}…. λx_{n}.t. The free variables of a term are the variables which are not bounded by a λquantifier. A term is closed iff it does not have free variables. Closed terms are also called combinators and often denoted by capitalized letters. For any term, its closure is obtained by quantifying all free variables.

The axioms are the following:

equality axioms , except that the substitution rule must be restricted to the case where the variable is free for substitution of the term;

α-rule or renaming of bound variables: λx.t = λy.t[x := y], if x is free for y in t;

β-rule : (λx.p)q = p[x := q], if x is free for q in p.

Sometimes, one also wants to adjoin the following axiom:

η-rule : λx.tx = t, if x is not free in t.

This axiom is often called extensionality (a function can be recovered from its action on the arguments). In this section, we consider λ-calculus without η-rule.

Here are some prominent combinators. The identity combinator is defined as I := λx.x. The “loop forever” combinator Ω := (λx.xx)λx.xx has the property that it reduces to itself by a β-conversion. The combinators K := λxy.x and S := λxyz.xz(yz) are famous because every combinator can be expressed by K, S, and application. The most famous combinator is introduced in the following theorem.

Theorem 40 (Fixed point theorem) There is a combinator Y, such that for every f, we have f(Y f) = Y f, i.e. Y f is a fixed point of f.

Proof: Set Y := λy.(λx.y(xx))λx.y(xx). Then we have Y f = (λx.f(xx))λx.f(xx), which is equal to f((λx.f(xx))λx.f(xx)) = f(Y f) by the β-rule.

In order to get normal forms, we orient the β-rule from left to right. The α-rule cannot be oriented, but α-convertible terms differ only by a renaming of variables, so we identify α-convertible terms on a syntactic level.

We write t_{1} →^{β} t_{2} iff there is a subterm s_{1} of t_{1} which reduces by the β-rule to a subterm s_{2} of t_{2}, and the context s_{1} in t_{1} is equal to the context of s_{2} in t_{2}. Obviously, provable equality in the λ-calculus is the reflexive symmetric transitive closure of →^{β}.

Note that we have

Y f →^{β} f(Y f) →^{β} f(f(Y f)) →^{β} f(f(f(Y f))) →^{β} ….

This example also shows that β-reduction is not noetherian.

Unfortunately, →^{β} does not have the diamond property, as shown by the following example.

Let t_{1} := (λx.xx)λu.v. By reducing the subterm λu.v we obtain t_{2} := (λx.xx)v, and by reducing the first lambda, we get t_{3} := (λu.v)λu.v. By reducing t_{2}, we get the normal form t_{4} := vv. However, we do not have t_{3} →^{β} t_{4}, because we need two reduction steps to reduce t_{3} to t_{4}.

Here are some properties of the β reduction.

Theorem 41 The reduction →^{β} is substitutive.

Proof: Let t_{1} = (λx.p)q →^{β} t_{2} = p[x := q] be a β-reduction. Let y be a variable and r a term such that y is free for r in t_{1}, t_{2}. We distinguish two cases:

Case 1: y is different from x. Then we have t_{1}[y := r] = (λx.p[y := r])q[y := r]. On the other hand, we have t_{2}[y := r] = p[x := q][y := r] = p[y := r][x :=

q[y := r]], hence t_{1}[y := r] →^{β} t_{2}[y := r].

Case 2: y = x. Then t_{1}[x := r] = (λx.p)q[x := r], because x is not free in λx.p. On the other hand, t_{2}[x := r] = p[x := q][x := r] = p[x := q[x := r]], hence we have again t_{1}[x := r] →^{β} t_{2}[x := r].

Theorem 42 The reduction →^{β} is weakly Church-Rosser.

Proof: Suppose that t_{0} has two reducible subterms (redexes) s_{1} = (λx.p_{1})q_{1} and s_{2} = (λy.p_{2})q_{2}. Let t_{1} be the result obtained by reducing s_{1} to s′_{1} := p_{1}[x := q_{1}], and let t_{2} be the result obtained by reducing s_{2} to s′_{2} := p_{2}[x := q_{2}]. We have to show that t_{1} and t_{2} have a common reductum. The following cases have to be considered.

Case 1: s_{1} and s_{2} are disjoint. Then the reduction do not effect each other, and it is easy to close the diamond.

Case 2: s_{1} is a subterm of p_{2}, i.e.

t_{0} = … ((λy. … s_{1} …)q_{2}) …,

t_{1} = … ((λy. … s′_{1} …)q_{2}) …,

t_{2} = … (… s_{1} …)[y := q_{2}] ….

Then t_{1} reduces to

t_{3} = … (… s′_{1} …)[y := q_{2}] ….

By substitutivity, t_{2} also reduces to t_{3}.

Case 3: s_{2} is a subterm of q_{1}, i.e.

t_{0} = … ((λy.p_{2})(… s_{1} …)) …,

t_{1} = … ((λy.p_{2})(… s′_{1} …)) …,

t_{2} = … p_{2}[y := (… s_{1} …)] ….

Then t_{1} reduces to

t_{3} = … p_{2}[y := (… s′_{1} …)] ….

By induction on the structure of a term p, one proves easily that q →^{β} q′ implies p[x := q] →^{β∗} p[x := q′] (in general, several reduction steps are required, according to the number of free occurences of x). It follows that t_{2} also reduces to t_{3}.

The remaining cases are analogous.

The following theorem is more difficult. The book [1] discusses several proofs.

Theorem 43 The reduction →^{β} is Church-Rosser.

Corollary 9 The λ-calculus is consistent.

Proof: It suffices to exhibit two distinct normal forms. These are I and (for instance) λx(xx).

Not every λ-term has a normal form (think of Ω). But if t has a normal form, then there exists a reduction to it by corollary 1. Here is a theorem that tells how to find such a normal form.

Theorem 44 If a λ-term has a normal form, then one obtains a reduction to the normal form by reducing always the leftmost λ for which a reduction is possible.

Proof: See [1].

Example 4 The λ-term (λy.z)Ω = (λy.z)((λx.xx)(λx.xx)) reduces to z by reducing the left λ-term. The right λ-term Ω may also be reduced, but this reduction leads to an infinite loop.

The proof of the following result is also beyond the scope of this lecture.

Theorem 45 (Böhm) If t_{1} and t_{2} are two distinct normal forms, then the new axiom t_{1} = t_{2} leads to an inconsistency.

By Böhm’s theorem, one has to be careful when adding new axioms. In order to formalize informal theories in a reasonable way, it is necessary to introduce new constants. Doing this, we get applied λ-calculus.

Example 5 In some sense, we already gave lambda-theories when we introduced a name for a combinator. Namely, we added a new constant (e.g. I) and a new axiom (I = λx.x).

Example 6 A more interesting example is the following. We add the constants mult, one, inv, and the axioms

1. mult(mult xy)z = mult x(mult yz),

2. mult x one = mult one x = x,

3. mult x(inv x) = mult (inv x)x = one.

In many applications, the constants - denoting functions - come with a natural type information. This motivates to consider a variant of λ-calculus, called typed λ-calculus.

Here we have a collection of types with the following property: if A and B are types, then we also have a type A → B (the type of functions from A to B). Every term has a unique type. We write t : A for the statement t has type A.

Term forming by application is allowed only if the types match; more precisely, st is defined only if s : A → B and t : A, and we have st : B. λ-abstraction is unrestricted; if x : A and t : B, then λx.t : A → B. The axioms for λ-calculus hold whenever both sides are defined (it follows that both sides have the same type).

Example 7 The new axioms added in example 6 can be typed: one sets one : G, inv : G → G, mult : G → G → G.

The reduction →^{η} is Noetherian and Church-Rosser in the typed case. Therefore, we have decidable equality. Unfortunately, we may loose decidability by adding new axioms.

Some λ-terms are polymorphic, i.e. they can have several types. In this case, there is a most general type with the propery that any possible type as an instantiation. For instance, the identity function λx.x has most general type A → A, where A can be an arbitrary type. There is an algorithm that computes a most general type, if exists, for a given λ-term (type inference).

Example 8 • The most general type of K = λxy.x is A → B → A.

• The most general type of S = λxyz.xz(yz) is

(A → B → C) → (A → B) → A → C.

• The λ-term xx cannot by typed.

The λ-calculus can be used as a programming language. A program consists of a sequence of definitions of the form name = λ-term and of a single ‘command’, which is just a λ-term. The interpreter executes the command, using the given definitions. The definitions could in principle be eliminated, but they make programs shorter and better readable.

‘Executing a command’, i.e. a λ-term, means to reduce it by β-reduction (or some other reduction coming from an axiom) until a normal form is obtained. As we saw earlier, the order of reduction is important and may effect termination. A reduction order which always reduces an innermost reducible subterm is called applicative order. This is essentially the usual method used in procedure and function calls in most imperative and most programming languages: first we evaluate the arguments of a procudure or a function, and then we call the procedure/function. This method is called call by value.

Another reduction order is normal order, which always reduces an outermost reducible subterm. This order is used in Haskell (in case of several outermost subterms, the leftmost is chosen); it is also similar to the method call by name that has been used in the imperative language Algol60. As we saw, it always leads to a normal form if there exists one.

Normal order reduction allows to manipulate ‘infinite objects’, i.e. λ-terms without normal form, within programs.

Example 9 We use a typed λ-calculus with certain pre-defined types, constants and axioms (i.e. an applied λ-calculus).

type Bool
const True: Bool
const False: Bool
const Not: Bool -> Bool
axiom Not True = False
axiom Not False = True
const IfThenElse: Bool -> A -> A -> A
axiom IfThenElse True x y = x
axiom IfThenElse False x y = y
const FixedPoint: (A -> A) -> A
type List(A)
const Null: List(A)
const Head: List(A) -> A
const Tail: List(A) -> List(A)
const Put: A -> List(A) -> List(A)
axiom Head Put x y = x
axiom Tail Put x y = y
type Nat
const 0,1,2,3,...: Nat
const +,*,-: Nat -> Nat -> Nat
const IsDivisibleBy: Nat -> Nat -> Bool
const ==: Nat -> Nat -> Bool
const length: List(A) -> Nat

The constants +, ∗, ==, and IsDivisibleBy will be written in infix notation to improve readibility. They are supposed to fulfil the usual axioms. We also write (a,l) instead of tt Put a l.

The FixedPoint function allows to do recursive definitions. For instance, we can express the recursion

fac: Nat -> Nat
fac = \n IfThenElse n == 0 0 n*fac(n-1)

by

fac = FixedPoint \f \n IfThenElse n == 0 0 n*f(n-1)

From now on, we will write the IfThenElse by the usual ‘if .. then .. else’ construct, and we will use recursive definitions as usual.

Here are some auxiliary definitions. take i l takes the first i elements from the list l. from n produces the infinite list n, n + 1, n + 2, . . .. filter p l constructs the sublist of the elements fulfilling property p.

take: Nat -> List(A) -> List(A)
take = \n \l if n == 0 then Null else ( Head l, take (n-1) Tail l)
from: Nat -> List(Nat)
from = \n ( n, from (n+1))
filter: (a -> Bool) -> List(a) -> List(a)
filter = \p \l if Length(l) == 0 then Null else
if p Head l then ( Head l, filter p Tail l) else filter p Tail l

Note that the command from 2 causes an infinite loop, but the command take 4 from 2 gives the answer [2, 3, 4, 5].

In order to find the first 10 primes, we use the sieve of Erastothenes.

sieve: List(Nat) -> List(Nat)
sieve = \l ( Head l, sieve filter Not DivisibleBy Head l Tail l)
primes: List(Nat)
primes = sieve from 2
take 10 primes

The answer is 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.

12 Higher Order Logic

In this section, we describe a particular applied λ-calculus that models higher order logic. It should be emphasized that this is only one possible formalization, which is designed in order to emphasize the analogy and the differences to the given system of first order logic.

We have the type Bool and constants ⊤, ⊥ : Bool, ¬ : Bool → Bool, ∧, ∨, → , ↔: Bool → Bool → Bool. As usual, we write the binary functions infix. The binding conventions are the same as in the previous sections.

The existential and universal quantifiers are polymorphic constants ∀, ∃ : (A → Bool) → Bool. If A term of type boolean, and x is a variable of type A, then we cannot simply form the expression ∀xA(x); rather, we first form a predicate from A by λ-abstraction and then apply it to the ∀ function: ∀λx.A. After this has been clarified, we introduce the usual notation ∀xA(x) as a syntactic sugar for ∀λx.A.

In order to deal with ‘local’ equality, we introduce polymorphic constants “=” of type A → A → Bool and “ifthenelse” of type Bool → A → A → A.

Here are the axioms.

1. A → B → A = ⊤

2. (A → B → C) → (A → B) → (A → C) = ⊤

3. (¬A → ¬B) → (B → A) = ⊤

4. ∀λx.A → A[x := t] = ⊤, if x is free for t in A(x)

5. ∀x(C → A(x)) → C → ∀xA(x) = ⊤, if x is not free in C

6. ∨ = λAB.(¬A → B)

7. ∧ = λAB.¬(A → ¬B)

8. ↔= λAB.((A → B) ∧ (B → A))

9. ⊥ = ¬⊤

10. ∃ = λP.¬∀λx.¬(P x)

11. ⊤ → A = A

12. ∀λx.⊤ = ⊤

13. (A → B) → B = (B → A) → A

14. (x = y) = (y = x)

15. if T then x else y = x

16. if F then x else y = y 17. if (x = y) then x else y = y

Moreover, we adjoint the η-rule to the list of axioms.

Because HOL is an equational theory, we start by proving the replacement theorem.

Theorem 46 Let A, B : Bool such that A → B = ⊤ and B → A = ⊤. Then A = B.

Proof:

A = ⊤ → A = (B → A) → A = (A → B) → B = ⊤ → B = B.

Similarily, one can show that if (x = y) = T then x = y (using the axioms for “if then else”).

It is obvious that any formula in first order predicate logic can be translated into our system. Any such formula is a term of type boolean. The following states that proofs get preserved by this translation.

Theorem 47 Let Γ be a set of first order formulae, and let A be a first formula in first order formula such that Γ ⊢_{F OL} A. Then the formula A = ⊤ can be derived by higher order logic from the set of formulae {B = ⊤ | B ∈ Γ}.

Proof: We may replace every formula in Γ ∪ {A} by an equivalent formula containing only ¬, →, ∃; the resulting formulae are λ-convertible, so a derivation of the replaced formula by the replaced assumption is possible if and only if a derivation of the original formula is possible. Therefore we may restrict our attention to the kernel language.

For every first order axiom A in the kernel language, we have a higher order axiom A = ⊤.

Suppose that we have derived A by modus ponens from B → A and B. By induction hypothesis, there is a HOL derivation of B → A = ⊤ and of B = ⊤. Therefore we obtain

A = (⊤ → A) = (B → A) = ⊤.

Suppose that we have derived A = ∀λx.B by generalization from B. By induction hypothesis, there is a HOL derivation of B = ⊤. Then we get

∀λxB = ∀λx⊤ = ⊤.

An interpretation for typed λ calculus is given by a set S(A) for each type A, such that S(A → B) = S(B)^{S(A)}, the set of all functions from S(A) to S(B); and an element in S(A) for each constant and variable of type A. These data induce a valuation of λ-terms, such that the value of a term of type A is an element of S(A). For compound terms, the valuation is defined recursively:

• let p : A → B, q : A, then v(pq) := v(p)v(q) (the function v(p) applied to the argument v(q));

• let x : A, t : A, then v(λx.t) is the function from S(A) to S(B) that maps a ∈ A to v_{x/a}(t), where v_{x/a} is the valuation that coincides with v in all variables and constnats except for the value of x, which is a.

In the case of HOL, we set S(B) = {T, F }, and the values for ¬, ⊥, ∧, ∨, →, ↔ are defined as usual. For every type A, the value of ∀_{A} is the function that maps a predicate p ∈ {0, 1}^{S(A)} to T iff the predicate is always true. Likewise, the value of ∃_{A} is the function that maps a predicate p ∈ {0, 1}^{S(A)} to F iff the predicate is always false. The value of the constant “ =′′ is the diagonal, and the value of the constant “if then else” is the function that maps (T, x, y) to x and (F, x, y) to y.

Lemma 9 The value of a λ-term depends only on the values of its free variables.

Theorem 48 If a formula can be proven by HOL, then it is holds in any interpretation (i.e. the value of the left hand side is equal to the value of the right hand side).

Proof: The proof is tedious but not difficult. It suffices to show that every axiom holds in any interpretation.

The following corollary states that HOL subsumes FOL.

Theorem 49 Let Γ be a set of first order formulae, and let A be a first formula in first order formula. Then {B = ⊤ | B ∈ Γ} ⊢_{HOL} A = ⊤ iff Γ ⊢_{F OL} A.

Proof: If: this has already been proven above.

Only if: Suppose that {B = ⊤ | B ∈ Γ} ⊢_{HOL} A = ⊤. Let I be a FOL interpretation of Γ. Then we can extend I to an HOL interpretation I′ of {B = ⊤ | B ∈ Γ}. The value of the formulas in Γ ∪ A do not depend on the extension, because all constants and variables occuring in Γ are of type O or of type O → O or of type O → Bool, and for those three types all values are defined in I. By the correctness of HOL, any HOL interpretation that satisfies {B = ⊤ | B ∈ Γ} also satisfies A = ⊤. Thus, I′ ⊧ A = ⊤. By restricting valuation to FOL terms again, it follows that I ⊧ A. We have shown that any FOL interpretation of Γ also satisfies A.

By the completeness theorem of FOL, it follows that Γ ⊢_{F OL} A.

By lemma 9, the value of a formula without any free variables depends only on the sets S(A). The sets for function types are completely determined by the sets of their argument types, so the values actually depend only on the sets S(A) of non-function types A. If we have only two non-function types Bool and O (the type of ‘objects’), then the value of a non-closed formula determines only on the cardinality of S(O), because two sets having the same cardinality are isomorphic.

Example 10 Below we construct a formula without free variables that has value T if S(O) is countable, and F otherwise.

x, y : O, f : O → O, A, B : O → Bool

F unc, Inj, Surj, Bij : (O → O) → (O → Bool) → (O → Bool) → Bool

F unc = λfAB.∀xA(x) → B(fx)

Inj = λfAB.∀x∀y(A(x) → A(y) → (fx = fy) → (x = y))

Surj = λfAB.∀y∃x(B(y) → (A(x) ∧ (fx = y)))

Bij = λfAB.(Inj(f, A, B) ∧ Surj(f, A, B))

Inf : (O → Bool) → Bool

Inf = λA.∃f(F unc(f, A, A) ∧ Inj(f, A, A) ∧ ¬Surj(f, A, A))

EqCard : (O → Bool) → (O → Bool) → Bool

EqCard = λAB.∃f(F unc(f, A, B) ∧ Bij(f, A, B))

Universe : O → Bool

Universe = λx.T

Count : Bool

Count = Inf(Universe) ∧ ∀A(Inf(A) → EqCard(A, Universe)

Clearly, HOL is much more expressive than FOL. The other side of the medal is that we cannot expect to have a complete logical system.

Theorem 50 The given axiom system for HOL is incomplete: there are formulae which are true in any HOL interpretation but cannot be proven in HOL. Moreover, there is no complete axiomatization.

Proof: Assume, indirectly, that there is an axiomatization of HOL. Then the set of all formulae that hold in any interpretation is semi-decidable. Then we claim that we can also decide whether a given formula in FOL is a theorem, and this is known to be undecidable.

Here is an algorithm that decides whether a given closed FOL-formula A is a theorem in FOL.

1. Let B be a universal closure of A in the HOL system with non-function types O and Bool.

2. Let Count be a formula which has value true iff S(A) is countable. Then either the value of Count → B is true in any HOL model, or the value of C → ¬B is true in every HOL model, depending on the value of B in the countable model.

3. Determine which of the two alternatives in step 2 holds, by semi-deciding both possibilities in parallel.

4. In the first case, answer “yes”. In the second case, answer “no”.

The algorithm actually tells us if the formula A is true in every countable interpretation or not. If A is a FOL theorem, then it clearly is true in any countable interpretation. If A is not a FOL theorem, then its negation has a countable model by FOL completeness, and therefore is is not true in every countable interpretation.

13 Constructive Logic

The language of constructive logic is the same as the language of classical logic. The inference rules are also the same, the axioms are almost the same: axiom 10 is replaced by the axiom A → ¬A → B. The main difference is a semantical one: the logical connectives and the quantifiers are interpreted in a different way.

Informally speaking, a formula is considered true iff it is “witnessed” somehow, e.g. by a proof. We do not make this witnessing more precise at the moment. The logical connectives and quantifiers are then interpreted in the following way.

• A proof of A ∧ B is given by a proof of A and a proof of B.

• A proof of A ∨ B is given by a pointer to A or B and a proof of the subformula pointed at.

• A proof of A → B is given by a construction producing a proof of B when a proof of A is given.

• There is no proof of ⊥.

• A proof of ¬A is given by a construction producing a proof of ⊥ when a proof of A is given.

• A proof of ∀xA(x) is a construction producing a proof of A(c) when an object c is given.

• A proof of ∃xA(x) is given by an object c and a proof of A(c).

For instance, a proof of the formula ∀x∃yA(x, y) consists of a construction producing, for given x, a y and a proof for A(x, y).

The question “what precisely is a construction?” has been answered in different ways. One possible answer is to state “a construction is a recursive function” or equivalently “a construction is something that can be computed by a Turing machine”. The intuitionists answer this question negatively: a construction is a free creation of mind, and any precise definition would therefore limit the scope and is therefore already inadequate.

Interestingly enough, a large part of constructive mathematics can be developed without an explicit answer to the above question.

Remark 12 We observe that the A → ⊥ and ¬A have the same interpretation. Indeed, ¬ can be defined in constructive logic. This is the only example where one logical connective can be defined in others.

In contrast to this, we have much more inter-definability in classical logic. There, any connective can be defined in terms of → and ⊥.

On the ground of the interpretation, one can easily give proofs for all axioms.

Example 11 In the following, we write a ⊧ A for “a is a proof of A”. The pointers to the first and second part of a disjunctive formula are denoted by p_{1}, p_{2}. If a proof a has two parts (e.g. the proof of a conjunction), then q_{1}(a), q_{2}(a) are these two parts.

1. For a ⊧ A, the construction λba constructs a proof of a for any proof b of B. Hence λaλba is a proof for A → B → A.

2. The construction q_{1} is a proof for A ∧ B → A.

3. Any construction serves as a proof of ⊥ → A (since it is applied to the empty domain).

An important non-example is the principle of the excluded middle A ∨ ¬A. A proof of this disjunction is a pointer to the either A or ¬A and a proof of this pointed subformula. However, there are a lot of examples of propositions A for which we do not have such a proof. Thus, A ∨ ¬A is not universally valid in constructive logic.

On the other hand, one can show constructively that the negation of the principle of the excluded middle is inconsistent: Let c ⊢ ¬(A ∨ ¬A). If d ⊢ (A ∨ ¬A), then c(d) ⊢ ⊥. If e ⊢ A, then g := λec(p_{1}, e) is a proof for A → ⊥ = ¬A. If f ⊢ ¬A, then h := λfc(p_{2}, f) is a proof for ¬A → ⊥. Hence h(g) proves ⊥. The construction c ↦ h(g) as above is a proof for ¬¬(A ∨ ¬A).

Another non-example is the formula ¬∀x A(x) → ∃x ¬A(x). There are example of formulas for which we know constructively that ∀x A(x) is inconsistent, but we do not have an x_{0} for which ¬A(x_{0}), and so we cannot prove ∃x ¬A(x_{0}).

In the following, we describe a way for embedding classical predicate logic into constructive predicate logic.

A formula is called negative iff all atoms are negated and it does not contains ∨ or ∃.

It is not hard to define a “negative translation” A ↦ F (A) with the following properties:

• F (A) is negative;

• we have ⊢ A ↔ F (A) in classical logic.

To achieve this, we replace any disjunction A∨B by ¬(¬A∧¬B), any existential quantifier ∃xA(x) by ¬∀x¬A(x), and any atom P by ¬¬P.

Lemma 10 If A is negative, then ⊢ A ↔ ¬¬A.

Proof: For any formula A, we have ⊢ A → ¬¬A (exercise). The other direction is shown by induction on the structure of A. We have to distinguish the following cases:

• A is of the form ¬B for an atom B. Because one can show ¬¬¬B → ¬B (exercise), the statement holds for this case.

• A is of the form ¬A with A negative. This case can be treated as the previous one.

• A is of the form A ∧ B with A, B negative. One can show ¬¬(A ∧ B) → ¬¬A ∧ ¬¬B. Because A and B are negative, we have ¬¬A → A and ¬¬B → B by induction hypothesis. Thus, we get ¬¬(A ∧ B) → (A ∧ B).

• A is of the form A → B with A, B negative. One can show ¬¬(A → B) → (A → ¬¬B). Because B is negative, we have ¬¬B → B by induction hypothesis. Thus, we get ¬¬(A → B) → (A → B).

• A is of the form ∀xA(x) with A(x) negative. One can show ¬¬∀xA(x) → ∀x¬¬A(x). By induction hypothesis, ¬¬A(x) is equivalent to A(x), hence ¬¬∀xA(x) → ∀xA(x).

Theorem 51 Suppose that A_{1}, …, A_{n} ⊢ C in classical logic. Then F (A_{1}), …, F (A_{n}) ⊢ F (C) in constructive logic.

Proof: It suffices to show that F (A) is a theorem for every classical axiom, and that the above transformation of proofs works for every inference rule.

For the classical axioms 1-5, 9, 11, 13, the negative translation is of the same axiom scheme. Hence this are again axioms and therefore provable.

Axiom 6: The translation is F (A) → ¬(¬F (A)∨¬F (B)), and this is provable in constructive logic.

Axioms 7,12: analogously.

Axiom 10: The translation is ¬¬F (A) → F (A), and this is provable because F (A) is negative.

Axiom 8: The translation is

(F (A) → F (C)) → (F (B) → F (C)) → ¬(¬F (A) ∧ ¬F (B)) → F (C).

One can show

F (A) → F (C), F (B) → F (C), ¬(¬F (A) ∧ ¬F (B)), ¬F (C) ⊢ ⊥.

By the deduction theorem (which holds also in constructive logic, by the same proof), we can derive ¬¬F (C) from the first three hypotheses. But F (C) is negative, hence we can also derive F (C). By the deduction theorem applied three times, we get a proof of the translation.

Now for the inference rules. The translation of the first two inference rules is again of the same pattern, hence they are again valid. For the third inference rule, we have to show

F (A(x)) → F (C) ⊢ ¬∀x¬F (A(x)) → F (C),

where x does not occur free in F (C). One can derive

F (A(x)) → F (C), ¬∀x¬F (A(x)), ¬F (C) ⊢ ⊥.

Thus, ¬¬F (C) is a logical consequence of the first two hypotheses. Since F (C) is negative, F (C) is a consequence. By the deduction theorem, the validity of the inference rule is proven.

Constructive arithmetic is the theory with the same signature and axioms as formal number theory (the only difference is the logical axiom 10). It is easy to show that for any axiom A, the negative translation is provable.

Lemma 11 The following formulas are provable:

x = y ∨ ¬x = y, ¬¬x = y → x = y.

Proof: Let Q(x, y) be the formula x = y∨¬x = y. Then one can show the theorems Q(0, 0), Q(0, x) → Q(0, x′), Q(x, 0) → Q(x′, 0), and Q(x, y) → Q(x′, y′). Then one can show Q(x, y) by a double induction (see [30], proposition 2.6, p 124). The second formula follows from the first by propositional constructive logic.

Theorem 52 Let A be a formula in constructive arithmetic containing no existential quentifiers and no disjunctions. Then A is provable iff A is provable in classical arithmetic.

Proof: The “only if” implication is obvious. For the “if” implication, suppose that A is a formula without existential quentifiers and disjunctions that is provable in classical arithmetic. By theorem 51 and by the fact that all axioms translate into theorems, F (A) is provable. By the syntactic structure of A, the only difference in A and F (A) is that the atoms are doubly negated in F (A). But by lemma 11, we have P ↔ ¬¬P for any atom P. Hence A is equivalent to F (A), and therefore A is also provable.

Of course, we do not expect constructive arithmetic to be complete, since even classical arithmetic is not. Here is a famous formula scheme—the Markov principle—which is trivially classically provable but not constructively, at least not by the Peano axioms:

∀x(A(x) ∨ ¬A(x)) → ¬∀x¬A(x) → ∃xA(x).

Nevertheless, the Markov principle is commonly accepted as a new axiom scheme, on the ground of the following informal proof:

If a ⊧ ∀x(A(x) ∨ ¬A(x)), then a(x) is a pointer to either A(x) or ¬A(x) together with a proof of the pointed subformula. If q_{1}(a(x)) = p_{1}, then q_{2}(a(x)) is a proof for A(x). Thus, we can find a proof for ∃xA(x) by the following construction for x from 0 to ∞ do if q_{1}(a(x)) = p_{1}, then return (x, q_{2}(a(x))); exit loop

from the proof a. This construction terminates, because otherwise λx q_{2}(a(x)) would be a proof for ∀x¬A(x) contradicting the second hypothesis.

Recall our embedding of predicate calculus in λ-calculus in the previous chapter. We can do the same thing in constructive logic, except that the typ of propositions should not be called “boolean”, because its signature ∧, ∨, →, ¬ does not satisfy the axioms of a boolean algebra. The usual name for an algebra with this signature satisfying the propositional axioms of constructive logic is “Heyting algebra”.

Example 12 Let X be a topological space. Let H be the set of all open spaces in X. We define

• A ∧ B := A ∩ B,

• A ∨ B := A ∪ B,

• A → B := ⋃{C | C ∩ A ⊂ B},

• ⊥ := ∅,

• ¬A := A → ⊥.

Then H with these operations is a Heyting algebra.

The above example gives rise to an un-intended model for constructive logic: take an arbitrary topological space X, and give a typed λ-model with the proposition type being assigned the Heyting algebra above. This model is often useful to refute formula as constructively not provable.

14 Constructive Analysis

As a typical branch of mathematics, analysis is organized in a typed way. Therefore we give a formalization in typed λ-calculus. First, we introduce some conventions for making the language look more familiar.

We usually write ⊢ A as a shorthand for ⊢ A = T, and ∀_{x:A}P (x) as a shorthand for ∀_{X}λxP (x), and likewise for ∃. Moreover, we write the binary logical connectives in infix notation with the usual binding conventions, so that our formulas look very similar to predicate formulas.

Recall that we can define a new function whenever we can prove unique existence. We extend this concept in two ways. First, we can define a partial function f whenever we can prove A(x, y) → A(x, z) → y = z. We write B(f(x)) as a shorthand for ∃_{y}A(x, y) ∧ B(y), and E(f(x)) for ∃_{y}A(x, y) (the existence predicate). For terms containing partial functions, the conditions and inference rules have to be adapted. For instance, we have to replace axiom 12 by A(t) → E(t) → ∃_{x}A(x), if t contains partial functions.

Second, we can define an operation f whenever we can prove ∃y A(x, y). Syntactically, we use f as a function. In the constructive interpretation, f(x) selects just the y that must be provided by the existence proof of ∃y A(x, y). In the classical interpretation, f is a Skolem function. In contrast to true functions, operations do not satisfy in general the equality axiom x = y → f(x) = f(y).

Apart from ℕ, we need the basic type ℚ_{+} of positive rational numbers. This type occurs so often that we reserve the lowercase greek letters for the variables of this type.

If A is a type, then the predicate D : ℚ_{+} → A → A → H is called a metric for A iff the following axioms are fulfilled:

1. Dϵxy → Dϵyx,

2. δ < ϵ → (Dϵxy ∨ ¬Dδxy),

3. Dαxy → Dβyz → D(α + β)xz,

4. ∀_{ϵ}Dϵxy ↔ x = y,

5. ∀_{ϵ}(δ < ϵ → Dϵxy) → Dδxy,

6. ∃_{ϵ}Dϵxy,

where x, y, z : A. Informally, Dϵxy corresponds to d(x, y) < ϵ for a distance function d. We do not use distance functions because the target would be the reals, and up to now it is not yet clear what ℝ is from a constructive point of view.

We define a binary infix relation ≠: A → A → H by

x ≠ y := ∃_{ϵ}¬Dϵxy.

Theorem 53 For the predicate ≠, we can show the following theorems:

1. x ≠ y → y ≠ x,

2. x ≠ z → (x ≠ y ∨ y ≠ z),

3. ¬(x ≠ y) ↔ x = y.

Proof: (1) is trivial.

To show (2), assume we have a proof for ∃_{ϵ}¬Dϵxz. Then we have ϵ and a proof for ¬Dϵxz. By metric axiom 2, we have D \frac{ϵ}{2}xy or ¬D \frac{ϵ}{4}xy. In the second case, the conclusion is shown. Likewise, we have D \frac{ϵ}{2}yz or ¬D \frac{ϵ}{4}yz. In the second case, the conclusion is also shown. The only remaining case is D \frac{ϵ}{2}xy and D \frac{ϵ}{2}yz, which implies Dϵxz by metric axiom 3. But in this case, we get a contradiction, by the proof of ¬Dϵxz.

To show (3), observe that the left hand side is logically equivalent to ∀_{ϵ}¬¬Dϵxy. This is implied by the right hand side by metric axiom 4. To show the other direction, assume ϵ to be given. By metric axiom 2, we have Dϵxy or ¬D \frac{ϵ}{2}xy. Because of the assumption ∀_{ϵ}¬¬Dϵxy, the second alternative does not hold, hence we have proven Dϵxy.

Remark 13 A binary relation fulfilling the axioms above is also called an inequality relation or an apartness relation. Such relations need not exist for arbitrary type. A necessary and sufficient condition for the existence of an apartness relation is the “stability of equality” ¬¬x = y → x = y. In this case, ¬(x = y) is an apartness relation but usually not the only one. However, one can show that any metric apartness is equivalent to ¬(x = y) under the assumption of Markov’s principle.

A fundamental object is a function r : ℚ_{+} → A satisfying the condition

F (r) := ∀_{ϵ}∀_{δ}(δ < ϵ → D(ϵ − δ)(rϵ)(rδ)).

Informally speaking, r specifies an ϵ-ball with midpoint rϵ, for each ϵ. The condition F (r) states that these balls are contained one in another.

Trivial examples of fundamental objects are the constant functions λϵx. The function I := K_{A,ℚ_{+}} assigns any element in A its constant fundamental object.

We define the binary infix relation ∼: (ℚ_{+} → A) → (ℚ_{+} → A) → H as a partial relation restricted to fundamental objects by

r ∼ s := ∀_{ϵ}D(3ϵ)(rϵ)(sϵ).

Theorem 54 The relation ∼ is an equivalence relation.

Proof: Reflexivity and symmetry are obvious. To show transitivity, assume r ∼ s and s ∼ t. By F (r) and F (s), we have D \frac{3ϵ}{4}(rϵ)(r \frac{ϵ}{4}), and D \frac{3ϵ}{4}(rϵ)(r \frac{ϵ}{4}). By assumption, we have D \frac{3ϵ}{4}(r \frac{ϵ}{4})(s\frac{ϵ}{4}) and D \frac{3ϵ}{4}(s\frac{ϵ}{4})(t\frac{ϵ}{4}) By metric axiom 4, it follows D(3ϵ)(rϵ)(tϵ).

A metric space (i.e. a type together with a metric) is called complete iff every fundamental object is equivalent to a constant fundamental object.

At this point, we would like to introduce a new type \overline{A}, the completion of A with respect to D, whose objects are the equivalence classes of fundamental objects. To define a new type N, we need to do the four things:

1. specify the terms of N,

2. define an equality for N,

3. specify the functions from N to any other type,

4. specify what the quantifiers λ, ∀, ∃ should do.

Note that it is not necessary to specify the functions into the new type, because any function can be written as a λ-abstraction from a term.

In the case of \overline{A}, we proceed as follows.

1. The terms are the terms of ℚ_{+} → A. Each term becomes partial, and the existential predicate is R.

2. The equality is ∼.

3. Any function f : (ℚ_{+} → A) → B gives rise to an operation \overline{A} → B. The equality axiom does not hold because we have changed the equality.

4. The λ-quantifier works as usual, except that it produces now partial operations instead of functions.

5. The universal quantifier is defined by ∀_{x:\overline{A}}P (x) := ∀_{x:ℚ_{+}→A}(R(x) → P (x)).

6. The existential quantifier is defined by ∃_{x:\overline{A}}P (x) := ∃_{x:ℚ_{+}→A}(R(x)∧P (x)).

We define the relation \overline{D} : ℚ_{+} → \overline{A} → \overline{A} → H by

\overline{D}ϵ := ∃_{α}(α < ϵ ∧ ∀β(β < α → D(ϵ − α)(rβ)(sβ))).

Theorem 55 The relation \overline{D} induces a metric for \overline{A}.

Proof: Omitted. Note that it does not suffice to prove all metric axioms, we also have to show that \overline{D} is well-defined on \overline{A}.

Theorem 56 The completion of a metric space is complete.

Proof: Omitted.

Now, we define ℝ as the completion of ℚ with respect to the metric Dϵxy := |x − y| < ϵ.

A subset of a metric space A is just a predicate A → H. A subset P of ℝ is said to be bounded above iff

∃_{x:ℝ}∀_{y:ℝ}(P y → y ≤ x).

Such a real number x is called an upper bound for P. A real number b is called a supremum or least upper bound of P iff it is an upper bound and

∀_{ϵ}∃_{x:ℝ}(P x ∧ x > b − ϵ).

Dually, one defines lower bounds and infimums.

A set can have at most one supremum (infimum). Classically, every bounded set has a supremum. Constructively, this does not hold: imagine a set defined by a predicate which we cannot decide, in conjunction with the predicate |x| ≤ 1. This subset is surely bounded, but we do not know whether the set is empty or the whole interval [−1, 1].

Here is a constructive version of the lub-theorem.

Theorem 57 Let P be a subset of ℝ. Then P has a supremum iff the following conditions hold.

1. ∃_{x:ℝ}P x (P is inhabitated),

2. P is bounded above,

3. for all x, y : ℝ such that x < y, we have y is an upper bound or ∃_{a:ℝ}(P a ∧ x < a).

Proof: See [3], p 37.

At this point, we may redefine a metric as a function d : A → A → ℝ, satisfying the axioms

1. d(x, y) ≥ 0,

2. d(x, y) = 0 ↔ x = y,

3. d(x, y) = d(y, x),

4. d(x, y) + d(y, z) ≥ d(x, z),

where x, y, z : A. The old metric can be defined in terms of the new metric via D(ϵ, x, y) := d(x, y) < ϵ, and the new metric can be defined in terms of the old metric as the supremum of all ϵ such that D(ϵ, x, y).

Let A, B be metric spaces. A function f : A → B is called uniformly continuous iff there exists a function ω : ℚ_{+} → ℚ_{+}, such that

∀_{ϵ}∀_{x,y:A}(d_{A}(x, y) < ω(ϵ) → d_{B}(fx, fy) < ϵ).

Such a function is called a modulus of continuity.

The following theorem is useful to construct big classes of uniformly continuous functions.

Theorem 58 Let A and B be metric spaces, B complete. Let f : A → B be uniformly continuous with modulus ω. Then there exists a unique function \overline{f} : \overline{A} → B which coincides with f on A and which is uniformly continuous. Moreover, ω/2 is a modulus of continuity.

Proof: See [3], p92.

A more important concept than boundedness is the concept of totally boundedness, defines as follows: a metric space A is said to be totally bounded iff there exists a function a : ℕ → A such that

∀_{ϵ}∃_{n:ℕ}∀_{x:A}∃_{m:ℕ}(m < n ∧ d(am, x) < ϵ).

The function a is called a net for A. A subset of A is bounded iff it is totally bounded as a space on its own.

Example 13 The interval [0, 1] in ℝ is bounded: enumerate all pairs (i, j) of natural numbers such that i ≤ j and j ≠ 0, and define a(n) := i/j, where (i, j) is the n-th pair. For given ϵ, one selects n such that all pairs (i, j) with j < ϵ^{−1} having index less than n. This is possible because there are only finitely many of them.

Here is another constructive lub theorem.

Theorem 59 Any totally bounded subset of ℝ has a supremum.

Proof: See [3], p 38.

Classically, a subset of a totally bounded set is totally bounded. Constructively, we already have seen a counter-example. However, we can say the following.

Theorem 60 A subset P of a totally bounded space is totally bounded iff for all x : A the subset Qr := ∃_{y:A}(P y ∧ d(x, y) = r) has an infimum. A subset with such a property is called located.

Proof: See [3], p 95.

Here are some theorems that show the usefulness of totally boundedness.

Theorem 61 Let A be totally bounded and f : A → B be uniformly continuous. Then the image subset (fA)(y) := ∃_{x:A}fx = y is totally bounded.

Proof: If a is a net for A, then f ∘ a is a net for fA.

Corollary 10 Let A be totally bounded and f : A → ℝ be uniformly continuous. Then fA has a supremum.

Proof: Obvious from theorem 61 and theorem 59.

If f : ℝ → ℝ is uniformly continuous, and ∃_{x,y:ℝ}fx · fy < 0, then one can show that 0 is the infimum of the image of |f|. Classically, 0 is also in the image; this is the mean value theorem. Constructively this theorem does not hold in general: let u : ℝ be a real number for which we cannot decide whether u = 0, u < 0, or u > 0. Define fx := max(x − 1, (min(x, u)). Then f is uniformly continuous with modulus 1. Suppose that this function has a zero y. Then we could find information on the sign of u be deciding which of the parts of the disjunction y < 2/3 ∨ y > 1/3 holds.

One can prove a mean value theorem using stronger assumptions, e.g. strong monotony ∀_{x,y:ℝ}(x < y → fx < fy).

References

[1] Barendregt, H. The lambda calculus, its syntax and semantics. Springer, 1981.

[2] Beeson, M. Foundations of Constructive Mathematics. Springer, 1985.

[3] Bishop, E. Foundations of constructive analysis. McGraw-Hill, 1967.

[4] Buchberger, B. An Algorithm for Finding a Basis for the Residue Class Ring of a Zero-Dimensional Polynomial Ideal. PhD thesis, Universitat Innsbruck, Institut fur Mathematik, 1965. German.

[5] Chang, B., and Lee, C. Symbolic Logic and Mechanical Theorem Proving. Academic Press, 1973.

[6] Collins, G. E. Quantifier elimination for the elementary theory of real closed fields by cylindrical algebraic decomposition. In Lecture Notes In Computer Science (1975), Springer, pp. 134–183. Vol. 33.

[7] Dedekind, R. Stetigkeit und irrationale Zahlen. Vieweg, 1872.

[8] Dummett, M. Elements of Intuitionism. Clarendon Press, 1977.

[9] Ebbinghaus, H., Flum, J., and Thomas, W. Mathematical Logic. Springer, 1983.

[10] H. Schwabhäuser and W. Szmielev and A. Tarski. Metamathematische Methoden in der Geometrie. Springer, 1983.

[11] Heyting, A. Intuitionism. North-Holland, 1966.

[12] Hilbert, D. Grundlagen der Geometrie. Teubner, 1977.

[13] Hilbert, D., and Bernays, P. Grundlagen der Mathematik I und II. Springer, 1970.

[14] Jebelean, T. Automatic theorem proving 1 and 2. Lectures at the university of Linz, winter 1998/99 and summer 1999.

[15] Jones, A., and Matijasevic, Y. Proof of the recursive unsolvability of hilbert’s 10th problem. Am. Math. Monthly 98 (1991), 689–709.

[16] Kleene, S. Introduction to Metamathematics. North-Holland, 1967.

[17] Manin, Y. A course in mathematical logic. Springer, 1977.

[18] Margaris, A. First Order Mathematical Logic. Xerox, 1967.

[19] Pfalzgraf, J., and Wang, D. Automated practical reasoning. Springer, 1995.

[20] Podniek. Hilbert’s 10th problem. available via http://www.ltn.lv/ podnieks/gt4a.html.

[21] Renegar, J. On the computational complexity and geometry of the firstorder theory of the reals i,ii,iii. Journal of Symbolic Computation 13, 3 (1992), 255–352.

[22] Rolletschek, H. Decidability and complexity classes. Tech. rep., RISC-Linz, Univ. Linz, A-4040 Linz. lecture notes.

[23] Rolletschek, H. Decidable logical theories. Tech. rep., RISC-Linz, Univ. Linz, A-4040 Linz. lecture notes.

[24] Rolletschek, H. Theory of computability. Tech. rep., RISC-Linz, Univ. Linz, A-4040 Linz. lecture notes.

[25] Shoenfield, J. Mathematical Logic. Addison-Wesley, 1973.

[26] Smullyan, R. First order logic. Springer, 1968.

[27] Stokkermans, K. An axiomatic frame for critical-pair-completion procedures. Journal of Symbolic Computation 27 , 435–478.

[28] Tarski, A. A Decision Method for Elementary Algebra and Geometry, second ed. Univ. of California Press, Berkeley, 1951.

[29] Tarski, A. What is elementary geometry? In Proceedings of an International Symposium on the Axiomatic Method, with Special Reference to Geometry and Physics (1959), A. T. L. Henkin, P. Suppes, Ed., Studies in Logic and the Foundations of Mathematics, Amsterdam: North Holland, pp. 16–29.

[30] Troelstra, A., and van Dalen, D. Constructivism in Mathematics. North-Holland, 1988.

[31] Winkler, F. Rewriting in computer algebra and logic. Tech. rep., RISC-Linz, Univ. Linz, A-4040 Linz. lecture notes.

[32] Winkler, F. Theoretical computer science. Tech. rep., RISC-Linz, Univ. Linz, A-4040 Linz. lecture notes.

[33] Winkler, F. The Church-Rosser property in computer algebra and special theorem proving. PhD thesis, RISC-Linz, Univ. of Linz, 1984.