HA^{ω}, Constructive Reals and

λ-Calculus.

Lecture notes of the second half of a course on constructive mathematics and λ-calculus, held at Uppsala University, autumn 1998.

Anton Setzer January 18, 1999

2

Contents

0 Introduction 5

1 HA^{ω} and constructive reals 7

1.1 HA^{ω} (9.1.1 - 9.1.14) . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.1.1 λ-terms in HA^{ω} . . . . . . . . . . . . . . . . . . . . . . . . 11 1.1.2 The theories E − HA^{ω}, I − HA^{ω}. . . . . . . . . . . . . . . 12 1.1.3 Embedding of HA in HA^{ω} . . . . . . . . . . . . . . . . . . 13

1.2 Constructive real numbers (5.1 - 5.4, 6.1) . . . . . . . . . . . . . 15 1.2.1 Introduction of ℤ in HA, HA^{ω} (5.1.1) . . . . . . . . . . . 15 1.2.2 Introduction of ℚ in HA, HA^{ω} (5.1.1) . . . . . . . . . . . 15 1.2.3 Principal ideas for embedding ℝ into HA^{ω} (5.1.2) . . . . . 16 1.2.4 Theory in which the following can be formalized . . . . . 17 1.2.5 Introduction of ℝ in HA^{ω} (5.2.2) . . . . . . . . . . . . . . 17 1.2.6 The ordering of the reals (5.2.3 - 5.2.15) . . . . . . . . . . 18 1.2.7 Real valued functions (5.3.3) . . . . . . . . . . . . . . . . 23 1.2.8 Completeness of ℝ (5.4) . . . . . . . . . . . . . . . . . . . 27 1.2.9 Intermediate value and existence of minimum/maximum

theorems (6.1) . . . . . . . . . . . . . . . . . . . . . . . . 28

2 λ-calculus and combinatory logic 29

2.1 λ-calculus (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.1.2 Definition of λ-terms (1A, 1B) . . . . . . . . . . . . . . . 30 2.1.3 Substitution (In 1B) . . . . . . . . . . . . . . . . . . . . . 31 2.1.4 β-reduction (1C) . . . . . . . . . . . . . . . . . . . . . . . 33 2.1.5 β-equality (1D) . . . . . . . . . . . . . . . . . . . . . . . . 38

2.2 Combinatory logic (2) . . . . . . . . . . . . . . . . . . . . . . . . 39 2.2.1 Introduction (2A) . . . . . . . . . . . . . . . . . . . . . . 39 2.2.2 Weak reduction (2B) . . . . . . . . . . . . . . . . . . . . . 40 2.2.3 Definition of λ-abstraction in combinatory logic (2C) … 40 2.2.4 Weak equality (2D) . . . . . . . . . . . . . . . . . . . . . 42

2.3 The fixed point and quasi-leftmost-reduction theorem (3B, 3D) . 43 2.3.1 Introduction (3A) . . . . . . . . . . . . . . . . . . . . . . 43 2.3.2 The fixed-point theorem (3B) . . . . . . . . . . . . . . . . 44

2.3.3 The quasi-leftmost-reduction theorem (3D) . . . . . . . . 46 2.4 Representing the recursive functions (4) . . . . . . . . . . . . . . 47 2.5 The undecidablity theorem (5) . . . . . . . . . . . . . . . . . . . 54 2.6 The formal theories λβ and CL_{w} (6A) . . . . . . . . . . . . . . . 57

2.6.1 Definition of the theories (6A) . . . . . . . . . . . . . . . 57 2.6.2 First order theories and derivable rules (6B) . . . . . . . . 61

2.7 Extensionality in λ-calculus (7) . . . . . . . . . . . . . . . . . . . 64 2.7.1 Extensional equality . . . . . . . . . . . . . . . . . . . . . 64 2.7.2 λβη-reduction (7B) . . . . . . . . . . . . . . . . . . . . . 65 2.7.3 The postponent theorem (7.13 - 7.14) . . . . . . . . . . . 66

2.8 Extensionality in combinatory logic . . . . . . . . . . . . . . . . . 71 2.8.1 Extensional equality . . . . . . . . . . . . . . . . . . . . . 71 2.8.2 An axiomatisation of extensionality by finitely many equa-

tions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 2.8.3 βη-strong reduction . . . . . . . . . . . . . . . . . . . . . 78

2.9 The correspondence between λ and CL (9) . . . . . . . . . . . . . 80 2.9.1 The extensional equalities (9A, 9B) . . . . . . . . . . . . . 80 2.9.2 Combinatory β-equality (9C) . . . . . . . . . . . . . . . . 84

2.10 Models for CL_{w} (10) . . . . . . . . . . . . . . . . . . . . . . . . . 84 2.10.1 Applicative structures (10A) . . . . . . . . . . . . . . . . 84 2.10.2 Combinatory algebras (10B) . . . . . . . . . . . . . . . . . 86 2.10.3 A more abstract definition of combinatory algebras (10.25

- 10.28) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

2.11 Models for λβ (11) . . . . . . . . . . . . . . . . . . . . . . . . . . 91 2.11.1 The definition of a λ-model (11A) . . . . . . . . . . . . . 91 2.11.2 A syntax free definition of λ-models (11B) . . . . . . . . . 98 2.11.3 Scott-Meyer λ-models (11.21 - 11.27) . . . . . . . . . . . . 106

2.12 The λ-model D_{∞} (12) . . . . . . . . . . . . . . . . . . . . . . . . 109 2.12.1 Solutions of cpo-equations . . . . . . . . . . . . . . . . . . 109 2.12.2 D_{∞} and other λ-models . . . . . . . . . . . . . . . . . . . 118

2.13 The typed λ-Calculus . . . . . . . . . . . . . . . . . . . . . . . . 122 2.14 The Curry-Howard Isomorphism . . . . . . . . . . . . . . . . . . 132

3 Martin-Löf’s Type Theory 145 3.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 3.2 The Logical Framework . . . . . . . . . . . . . . . . . . . . . . . 147 3.3 The Sets in Martin-Löf’s Type Theory . . . . . . . . . . . . . . . 150 3.4 The Dependent Product of Types . . . . . . . . . . . . . . . . . . 161 3.5 The Language of Martin-Löf’s Type Theory . . . . . . . . . . . . 163

Chapter 0

Introduction

These lecture notes contain the later parts of my lecture “Constructive Mathematics and λ-calculus”, held in autumn 1998 at the Department of Mathematics, Uppsala University. The parts on HA_{ω} and real numbers in constructive mathematics are very much based on [TD88a] and [TD88b] and the parts about the λ-calculus are based on [HS86]. Numbers in brackets refer to the books, respectively. In the first part the following parts of [TD88a] were treated (the numbers in brackets refer to that book):

• 1. Introduction (1)

– 1.1. Examples of non-constructive proofs (1.2.)

– 1.2. Directions in the foundations of mathematics (1.1, 1.4)

– 1.3. The Brouwer-Heyting-Kolmogorov (BHK) interpretation of the logical connectives (1.3.1)

– 1.4. Brouwerian counter examples (1.3.2 - 1.3.7)

• 2. Predicate logic and constructivism (2) – 2.1. Natural deduction and intuitionistic logic (2.1, 2.3.2)

– 2.2. Logic with existence predicate (2.2.1. - 2.2.4)

– 2.3. The double negation translation (2.3.1. - 2.3.8)

– 2.4. Kripke Semantics (2.5.1 - 2.5.9, 2.5.11, 2.5.13)

– 2.5. Soundness and completeness for Kripke Semantics (2.6.)

• 3. Arithmetic (3)

– 3.1. Primitive recursive arithmetic (PRA) (3.2.)

– 3.2. Heyting Arithmetic (HA) (3.3.)

– 3.3. Friedman’s A-translation (3.5.1 - 4)

– 3.4. Disjunction property and explicit definability for numbers in HA (3.5.6 - 3.5.12, 3.5.14 - 3.5.17)

– 3.5. Kleene-realizability (4.4)

The notes are currently not very well checked, they are still on the way to be written. Therefore I welcome comments very much.

HA^{ω} and constructive reals ([TD88a, TD88b])

1.1 HA^{ω} (9.1.1 - 9.1.14)

Definition 1.1.1 (a) Let G be a non-empty set. The elements of G are called ground types.

The set of (finite) types T_{G} w.r.t. G is inductively defined by

• o ∈ G⇒o ∈ T_{G}.

• σ, τ ∈ T_{G}⇒(σ × τ), (σ→τ) ∈ T_{G}.

The elements of T_{G} are called types. Let in the following G be fixed and let σ, τ, ρ possibly with accents or subscripts denote elements of T_{G}, o be elements of T_{G}.

We will omit brackets:

• σ→τ→ρ := σ→(τ→ρ).

• σ × τ × ρ := σ × (τ × ρ).

(b) A language L w.r.t. T_{G} consists of a set of function symbols f^{σ} for every type σ, and a set of relation symbols R^{σ_{1},... ,σ_{n}} for every finite sequence of types σ_{1}, …, σ_{n}.

In the following f^{σ}, g^{σ}, h^{σ}, function symbols of type σ, R^{σ_{1},... ,σ_{n}}, relation symbols of type σ, both possibly with accents or subscripts.

We will only mention the types of a (function-, relation- ) symbol (or variable or later term) the first time it occurs, writing f instead of f^{σ}, x instead of x^{σ} etc.

(c) The set of terms of the language L is given by:

8 CHAPTER 1. HA^{ω} AND CONSTRUCTIVE REALS

• x^{σ} is a term of type σ, where we have infinitely many variables, denoted by x^{σ}, y^{σ}, z^{σ}, possibly with superscripts for every type σ, and omit after the occurrence the superscript σ.

• f^{σ} is a term of type σ.

• If s^{σ→τ}, t^{σ} are terms of type σ→τ, σ, (s t) is a term of type τ.

• If s^{σ}, t^{τ} are terms of types σ, τ, then ⟨s, t⟩ is a term of type σ × τ.

• If s^{σ×τ} is a term of type σ × τ, then s 0 is a term of type σ and s 1 is a term of type τ.

In the following r^{σ}, s^{σ}, t^{σ} denote terms of type σ, (as before with subscripts, accents and we will omit the superscript σ after the first occurrence). s_{1} ⋯ s_{n} := (⋯ (s_{1} s_{2}) ⋯ s_{n}).

(d) The set of prime formulas for a language L as before is given by: • ⊥ is a prime formula.

• s^{σ} =_{σ} t^{σ} is a prime formula.

• R^{σ_{1},... ,σ_{n}}(s^{σ_{1}}, …, s^{σ_{n}}) is a prime formula.

(e) The set of formulas L is given by:

• If A is a prime formula, then A is a formula.

• If A, B are formulas, x^{σ} is a variable, then (A∧B), (A∨B), (A→B), (∀x^{σ}.A), (∃x^{σ}.A) are formulas.

(f) Substitution, substitutability, free variables etc. are defined as usual.

Definition 1.1.2 (a) A domain for the finite types T_{G} is a tuple

⟨(M_{σ})_{σ∈T_{G}}, (=_{σ})_{σ∈T_{G}}, (Ap_{σ,ρ})_{σ,ρ∈T_{G}}, (π_{σ,ρ})_{σ,ρ∈T_{G}}, (pr_{0,σ,ρ})_{σ,ρ∈T_{G}}, (pr_{1,σ,ρ})_{σ,ρ∈T_{G}}⟩

such that • M_{σ} is a set,

• M_{o} ≠ ∅ for some o ∈ G,

• =_{σ} is an equivalence relation on M_{σ} written usually infix,

• Ap_{σ,ρ} ∈ (M_{σ→ρ} × M_{σ})→M_{ρ},

• π_{σ,ρ} ∈ (M_{σ} × M_{ρ})→M_{σ×ρ},

• pr_{0,σ,ρ} ∈ M_{σ×ρ}→M_{σ},

• pr_{1,σ,ρ} ∈ M_{σ×ρ}→M_{ρ},

• ∀a ∈ M_{σ}.∀b ∈ M_{ρ}(pr_{0,σ,ρ}(π_{σ,ρ}(a, b)) =_{σ} a ∧ pr_{1,σ,ρ}(π_{σ,ρ}(a, b)) =_{ρ} b),

1.1. HA^{ω} (9.1.1 - 9.1.14) 9

• ∀a ∈ M_{σ×ρ}.a =_{σ×ρ} π_{σ,ρ}(pr_{0,σ,ρ}(a), pr_{1,σ,ρ}(a)). and Ap_{σ,ρ}, π_{σ,ρ}, pr_{0,σ,ρ}, pr_{1,σ,ρ} respect equality, i.e.

• ∀a, b ∈ M_{σ,ρ}.∀c, d ∈ M_{σ}(a =_{σ→ρ} b∧c =_{σ} d)⇒Ap_{σ,ρ}(a, c) =_{ρ} Ap_{σ,ρ}(b, d),

• similarly for the π_{σ,ρ}, pr_{0,σ,ρ}, pr_{1,σ,ρ}.

(b) If not mentioned differently, a domain A for T_{G} will be of the form

A = ⟨(A_{σ})_{σ∈T_{G}}, (=_{σ})_{σ∈T_{G}}, (Ap_{σ,ρ})_{σ,ρ∈T_{G}}, (π_{σ,ρ})_{σ,ρ∈T_{G}}, (pr_{0,σ,ρ})_{σ,ρ∈T_{G}}, (pr_{1,σ,ρ})_{σ,ρ∈T_{G}}⟩

(c) A finite type structure M for the language L w.r.t. T_{G} consists of • a domain M for T_{G},

• for each function symbol f^{σ} of L an element f^{M} ∈ M_{σ};

• for each relation symbol R^{σ_{1},... ,σ_{n}} a relation R^{M} on M_{σ_{1}} ×⋯×M_{σ_{1}}. s. t.

∀a_{1}^{σ_{1}}, …, a_{n}^{σ_{n}}, b_{1}^{σ_{1}}, …, b_{n}^{σ_{n}}.  (a_{1} =_{σ_{1}} b_{1} ∧ ⋯ ∧ a_{n} =_{σ_{n}} b_{n})⇒
(R^{σ_{1},... ,σ_{n},M}(a_{1}, …, a_{n})⇔R^{σ_{1},... ,σ_{n},M}(b_{1}, …, b_{n})) .

(d) An assignment w.r.t. a finite type structure M as above is a function ξ mapping variables x_{σ} to elements of M_{σ}.

(e) A model of finite type structure L_{G} and language L is pair ⟨M, ξ⟩ where M is a finite type structure for L and ξ is an assignment for it.

(f) If ⟨M, ξ⟩ is a model for T_{G}, we define the interpretation t^{σ}^{M}[ξ] of terms

t^{σ} under it, which will be an element of M_{σ}:

• x^{M}[ξ] := ξ(x).

• f^{M}[ξ] := f^{M}.

• (s^{σ→τ} t^{σ})^{M}[ξ] := Ap_{σ,τ} (s^{M}[ξ], t^{M}[ξ]).

• (⟨s^{σ}, t^{τ} ⟩)^{M}[ξ] := π_{σ,τ} (s^{M}[ξ], t^{M}[ξ]).

• (s^{σ×τ} 0)^{M}[ξ] := pr_{0,σ,τ} (s^{M}[ξ]).

• (s^{σ×τ} 1)^{M}[ξ] := pr_{1,σ,τ} (s^{M}[ξ]).

(g) For formulas A of L we define whether M ⊧ A[ξ], where ⟨M, ξ⟩ is a model

of L as follows • M ⊧ ⊥[ξ] : ⇔⊥.

• M ⊧ s^{σ} =_{σ} t^{σ}[ξ] : ⇔s^{M}[ξ] =_{σ} t^{M}[ξ].

• M ⊧ R^{σ_{1},... ,σ_{n}}s_{1} ⋯ s_{n}[ξ] : ⇔R^{M}(s_{1}^{σ_{1}}[ξ], …, s_{n}^{σ_{n}}[ξ]).

• M ⊧ A ∧ B[ξ] : ⇔M ⊧ A[ξ] ∧ M ⊧ B[ξ], similar for ∨, →, ∀, ∃.

10 CHAPTER 1. HA^{ω} AND CONSTRUCTIVE REALS (h) M ⊧ A, ⊧ A etc. is defined as usual. Note that validity will be preserved

under logical and equality rules. Definition 1.1.3 (a) The language of HA^{ω} is the language for the set of finite

types T_{nat} with constants • 0^{nat},

• S^{nat→nat},

• k_{σ,τ}^{σ→(τ→σ)},

• s_{σ,ρ,τ}^{(σ→τ→ρ)→(σ→τ)→(σ→ρ)},

• p_{σ,ρ}^{σ→ρ→(σ×ρ)},

• proj_{0,σ,ρ}^{(σ×ρ)→σ},

• proj_{1,σ,ρ}^{(σ×ρ)→ρ},

• R_{σ}^{σ→(σ→nat→σ)→nat→σ}, and no relations (apart from equality).

(b) The rules and axioms of HA^{ω} are

• intuitionistic propositional logic with equality based on many sorts T_{{nat}};

• equations for the type structures:

– ∀x^{σ}, y^{τ} .(⟨x, y⟩0 = x ∧ ⟨x, y⟩1 = y),

– ∀x^{σ×τ} .x = ⟨x0, x1⟩;

• defining equations for the constants:

– ∀x^{σ}, y^{τ} .k_{σ,τ} x y =_{σ} x^{σ}.

– ∀x^{σ→τ→ρ}, y^{σ→τ} , z^{σ}.s_{σ,ρ,τ} x y z =_{τ} (x z) (y z).

– ∀x^{σ}.y^{ρ}p_{σ,ρ} x y =_{σ×ρ} ⟨x, y⟩.

– ∀x^{σ×ρ}.(proj_{0,σ,ρ} x = x0 ∧ proj_{1,σ,ρ} x = x1).

– ∀x^{σ}, y^{σ→nat→σ}, z^{nat}.(R_{σ} x y 0 =_{σ} x∧R_{σ} x y S(z) =_{σ} y (R_{σ} x y z) z).

• Arithmetical axioms:

– ∀x^{nat}, y^{nat}.(S x^{nat} =_{nat} S y^{nat}→x^{nat} =_{nat} y^{nat}).

– ∀x^{nat}.¬(0 =_{nat} S x^{nat}).

– If FV(A(x, y⃗) ⊆ {x, y⃗}, then

∀y⃗(A(0, y⃗)→∀x^{nat}(A(x, y⃗)→A(S x, y⃗))→∀x^{nat}A(x, y⃗) .

1.1.1 λ-terms in HA^{ω}

Definition 1.1.4 ‘

(a) For terms t^{ρ} in L_{HA} and variables x^{σ} we define (λx.t)^{σ→ρ} as follows:

First replace in t occurrences of ⟨r, s⟩, r0, r1 by p_{τ,τ′} r s, proj_{0,τ,τ′} r, proj_{1,τ,τ′} for appropriate τ, τ′. Let r be the resulting term, which is an element of the set Term′ of terms, which do not have ⟨s, t⟩, s0, s1 as subterms. Then λx.t := λ′x.r, where for terms r ∈ Term′ λ′x.r is defined by induction on the length of r as follows:

• Case: x ∉ FV(r). λ′x.r := k r.

• Case r ≡ s x, x ∉ FV(s). λ′x.r := s.

• Otherwise – Subcase r = x^{σ}, σ = ρ.

λ′x.r := s_{σ,σ→σ,σ}^{(σ→(σ→σ)→σ)→(σ→σ→σ)→σ→σ}k_{σ,σ→σ}^{σ→(σ→σ)→σ}k_{σ,σ}^{σ→σ→σ} .

– Subcase r = s^{τ→ρ} t^{τ}.

λ′x.r := s_{σ,τ,ρ}(λ′x.s)^{σ→τ→ρ}(λ′x.t)^{σ→τ} .

Note that λ′x.t = λx.t for t ∈ Term′, therefore we write in the following λ instead of λ′.

(b) λx_{1}, …, x_{n}.t := λx_{1}.λx_{2}…. λx_{n}.t. λx⃗.t := λx_{1}, …, x_{n}.t, if x⃗ = x_{1}, …, x_{n}.

Proposition 1.1.5 (9.1.8) Assume t^{ρ} is a term, x^{σ} a variable. Then the following follows:

(a) HA^{ω}⊢∀y^{σ}.(λx.t) y =_{ρ} t[x := y].

(b) FV(λx.t) ⊆ FV(t) \ {x}.

(c) If t = t′x, x ∉ FV(t′), then λx.t = t′.

Proof: Let s be defined for t as in Definition 1.1.4. Then, if the assertion holds for s, it holds for t as well, so prove the assertion for s by induction on s.

(c) follows immediately by definition and (b) follow easily using the IH. Proof of (a):

• Case x ∉ FV(s).

(λx.s) y ≡ k s y = s ≡ s[x := y] .

• Case s = s′ x, x ∉ FV(s′).

(λx.s) y ≡ s′ y ≡ s[x := y] .

• Otherwise.

– Subcase s = x.

(λx.s) y ≡ s k k y = k y (k y) = y ≡ s[x := y] .

– Subcase s = s_{1} s_{2}.

(λx.s) y ≡ s (λx.s_{1}) (λx.s_{2}) y
= (λx.s_{1}) y ((λx.s_{2}) y)
= s_{1}[x := y] s_{2}[x := y] ≡ s[x := y] .

Exercise 1.1 (a) For every types σ, ρ, τ, terms r^{τ}, t^{ρ}, variables x^{σ}, z^{ρ}, s.t.z ≢ x and z ∉ FV(t) ∨ x ∉ FV(r),

HA^{ω}⊢(λx.(t[z := r])) =_{σ→ρ} (λx.t)[z := r] .

(b) For every types σ, ρ, term t^{ρ}, variables x^{σ}, y^{σ} s.t.y ∉ FV(t), it follows

λx.t ≡ λy.(t[x := y]) .

1.1.2 The theories E − HA^{ω}, I − HA^{ω}.

Definition 1.1.6 (9.1.11)

(a) E − HA^{ω} is HA^{ω} with extensional equality:

E − HA^{ω} = HA^{ω} extended by the axioms (for every types σ, τ

(EXT) ∀y^{σ→τ} , z^{σ→τ} (∀x^{σ}(y x =_{τ} z x)→y =_{σ→τ} z) .

One easily verifies that the full type structure and HEO are models of E − HA^{ω}.

(b) I − HA^{ω} is HA^{ω} with intensional equality:

I − HA^{ω} = HA^{ω} extended by additional function symbols e^{σ→σ→nat} and the following axioms (for every type σ; let 1 := S 0)

(INT) ∀x^{σ}, y^{σ}.((e_{σ} x y =_{nat} 0∨e_{σ} x y =_{nat} 1)∧(e_{σ} x y =_{nat} 0↔x =_{σ} y)) .

One easily verifies that the full type structure and HRO are models of I − HA^{ω}.

Remark 1.1.7 In both E − HA^{ω} and I − HA^{ω}, the equality reduces to equality on nat as follows:

(a) Define for r^{σ}, s^{σ} r =_{e,σ} s by:

• r =_{e,nat} s := r =_{nat} s.

• r =_{e,σ→τ} s := ∀x^{σ}.r x =_{e,τ} s x.

• r =_{e,σ×τ} s := r0 =_{e,σ} s0 ∧ r1 =_{e,τ} s1.

Then it follows for every type σ

E − HA^{ω}⊢∀x^{σ}, y^{σ}(x =_{σ} y↔x =_{e,σ} y) .

(b) I − HA^{ω}⊢∀x^{σ}, y^{σ}.(x =_{σ} y↔e_{σ} x y =_{nat} 0).

1.1.3 Embedding of HA in HA^{ω} Definition 1.1.8 (9.1.10)

(a) For every n-ary primitive recursive function we define a closed term t_{f} of type \underbrace{nat→ ⋯ →nat}_{n times} →nat, s. t. if we replace in the defining axioms

for prim. rec. functions in HA^{ω} f(x_{1}, …, x_{n}) by t_{f} x_{1} ⋯ x_{n}, then the resulting formulas are provable in HA^{ω}. The definition is by recursion on the inductive definition of primitive recursive functions:

• f(x⃗) = 0: t_{f} := λx⃗.0.

• f(x) = S(x): t_{f} := S.

• f(x⃗) = x_{i}: t_{f} := λx⃗.x_{i}.

• f(x⃗) = g(h_{1}(x⃗), …, h_{n}(x⃗)): t_{f} := λx⃗.t_{g} (t_{h_{1}} x⃗) ⋯ (t_{h_{m}} x⃗).

• f(x⃗, 0) = g(x⃗), f(x⃗, S(y)) = h(x⃗, y, f(x⃗, y)).

t_{f} := λx⃗.R(t_{g} x⃗)(λy, z.t_{h} x⃗ z y) .

Verification of the axioms in the last case:

t_{f} x⃗ 0 ≡ R(t_{g} x⃗)(λy, z.t_{h} x⃗ z y) 0 = t_{g} x⃗.
t_{f} x⃗ (S y) ≡ R(t_{g} x⃗)(λy, z.t_{h} x⃗ z y) (S y)
= (λy, z.t_{h} x⃗ z y) (R(t_{g} x⃗)(λy, z.t_{h} x⃗ z y) y) y
= t_{h} x⃗ y (R(t_{g} x⃗)(λy, z.t_{h} x⃗ z y) y)
≡ t_{h} x⃗ y (t_{f} x⃗ y).

(b) If t is a term in L_{HA}, we define a term t^{∗} of type nat in L_{HA}^{ω} by • x^{∗} := x^{nat}.

• 0^{∗} := 0.

• (S t)^{∗} := S t^{∗}.

• f(t_{1}, …, t_{n}) := t_{f} (t_{1}^{∗}) ⋯ (t_{n}^{∗}).

(c) If A is a formula in L_{HA}, we define its translation A^{∗} in L_{HA}^{ω} by

• (s = t)^{∗} := s^{∗} =_{nat} t^{∗}.
• ⊥^{∗} := ⊥.
• (A ∘ B)^{∗} := A^{∗} ∘ B^{∗} (∘ ∈ {∧, ∨, →}).
• (Sx.A)^{∗} := Sx^{nat}.A^{∗}, where S ∈ {∀, ∃}.

Lemma 1.1.9 If HA⊢A then HA^{ω}⊢A^{∗}.

Proof: We show more generally: If HA⊢B_{1}, …, B_{n}⇒A, then HA^{ω}⊢B_{1}^{∗}, …, B_{n}^{∗}⇒A^{∗} by induction on HA⊢B_{1}, …, B_{n}⇒A.

• Defining equations of prim. rec. functions: see the Remark about these axioms in Definition 1.1.8 (a).

• Logical rules, arithmetical axioms, equality rules: they coincide in HA and HA^{ω}, ∗ commutes with the connectives.

Theorem 1.1.10 (9.1.14) I − HA^{ω} and E − HA^{ω} are conservative extensions of HA, i.e. if A ∈ L_{HA}, I − HA^{ω}⊢A^{∗} or E − HA^{ω}⊢A^{∗}, then HA⊢A.

Proof: Proof of the assertion for E − HA^{ω}: For every HA^{ω} formula A

HEO ⊧ A[x_{1} := n_{1}, …, x_{m} := n_{m}]

can be expressed as a formula in L_{HA} (depending on free variables n_{1}, …, n_{m}). (Note that this is not a formula depending on a Gödel-number for A).

1. Prove: If

E − HA^{ω}⊢B_{1}, …, B_{n}⇒A ,

FV(B_{1}) ∪ ⋯ ∪ FV(B_{n}) ∪ FV(A) ⊆ {x_{1}, …, x_{m}}, then

HA ⊢ ∀n_{1}, …, n_{m}.
(HEO ⊧ B_{1}[x⃗ := n⃗] ∧ ⋯ ∧ HEO ⊧ B_{n}[x⃗ := n⃗])
→HEO ⊧ A[x⃗ := n⃗]

This follows by an easy induction on the derivation. (One first observes, that HEO models E − HA^{ω}, and then verifies, that this proof can be formalized in HA.

2. Prove: If t is a term of L_{HA}, FV(t) ⊆ {x_{1}, …, x_{n}}, then

HA⊢∀n_{1}, …, n_{m}.t[x⃗ := n⃗] ≃ (t^{∗})^{HEO}[x^{nat} := n⃗]

(where [x^{nat} := n⃗] ≡ [x_{1}^{nat} := n_{1}, …, x_{m}^{nat} := n_{m}].)

• t = x_{i}: t[x⃗ := n⃗] ≡ n_{i},

(t^{∗})^{HEO}[x^{nat} := n⃗] ≡ (x_{i}^{nat})^{HEO}[x^{nat} := n⃗] ≡ n_{i} .

• t = f(t_{1}, …, t_{n}). t^{∗} ≡ f^{∗} t_{1}^{∗} ⋯ t_{n}^{∗}. We show easily

HA⊢∀k_{1}, …, k_{n}.f(k_{1}, …, k_{n}) ≃ {⋯ {{(f^{∗})^{HEO}}(k_{1})} ⋯ }(k_{n}) .

Now the assertion follows using the IH.

3. Show If A is a formula of L_{HA}^{ω}, FV(A) ⊆ {x_{1}, …, x_{n}}, then

HA⊢∀n_{1}, …, n_{m}(A[x⃗ := n⃗]↔HEO ⊧ A^{∗}[x^{nat} := n⃗]) .

For prime formulas it follows by 2. and for other formulas it follows since “⊧ commutes with the logical connectives”.

4. The assertion follows by 1. and 3. Assertion for I − HA^{ω}: Similar, using HRO instead of HEO.

1.2 Constructive real numbers (5.1 - 5.4, 6.1)

1.2.1 Introduction of ℤ in HA, HA^{ω} (5.1.1)

Let for z ∈ ℤ,

z^{∗} := \begin{cases}0 & if z = 0 \\ 2z & if z > 0 \\ 2(−z) + 1 & if z < 0 \end{cases}

This yields a bijection λz.z^{∗} : ℤ→ℕ. We can replace now formulas in which we have apart from nat a new ground type ℤ into formulas of HA (or HA^{ω}) as follows:

• interpret the ground type ℤ as nat.

• replace all functions and relations which originally referred to the ground type ℤ, by operations, which simulate this operation on the codes. E.g. if the original expression was z^{ℤ}+z′^{ℤ}, replace now + by a primitive recursive function +′ such that for all z, z′ ∈ ℤ, z^{∗} +′ z′^{∗} = (z + z′)^{∗}.

• Verify, that the standard properties of the functions and relations on ℤ after the translation can be shown.

Let in the following z (possibly with subscripts, indices) range over ℤ (with the above interpretation), and i, j, k, l, n, m range over ℕ.

1.2.2 Introduction of ℚ in HA, HA^{ω} (5.1.1)

In a similar way we can define a bijection ℚ→ℕ.

Exercise 1.2 Define such a bijection explicitly

We can interpret ℚ in HA as before. Let in the following r, s, t, q range over elements of ℚ (possibly with subscripts, accents).

1.2.3 Principal ideas for embedding ℝ into HA^{ω} (5.1.2)

There are two approaches:

1) Real numbers as equivalence classes of Cauchy sequences. Idea: Real numbers are represented by sequences (q_{n})_{n∈nat}, s. t.

∀m.∃N.∀k, l ≥ N|q_{k} − q_{l}| < 2^{−m}

Explanations for those who do not know Cauchy sequences: \sqrt{2} should be represented by a sequence of rationals which approximates \sqrt{2} better and better, i.e. we want

∀m.∃N.∀k ≥ N.|\sqrt{2} − q_{k}| < 2^{−m}

However, if we haven’t introduced the reals yet, we don’t know what |\sqrt{2} − q_{k}| < 2^{−m} means. However, if we assume q_{k} approximates \sqrt{2} “arbitrarily” well, and if ∀k, l ≥ N.|q_{k} −q_{l}| < 2^{−n}, then “|q_{n} −\sqrt{2}| ≤ 2^{−n}” holds.

2) Reals as Dedekind cuts. A Dedekind cut is a set ∅ ≠ A ⊆ ℚ s. t.

• A is bounded, i.e. ∃q ∈ ℚ.A < q.

• A is open, i.e. ∀q ∈ A∃r ∈ A.q < r.

• A is downward closed, i.e. ∀q ∈ A.∀q′ < q.q′ ∈ A.

(The above is the classical definition, for the constructive definitions there are several variants, see 5.5.1) Now identify reals with Dedekind cuts.

• Advantage: Suitable for systems of 2^{nd} order logic.

• Disadvantages:

– (−x) cannot be defined so easily

– not so concrete

In [TvD] both approaches are studied, we will only consider the first approach.

Not suitable approach Decimal representation is not a good representation. Problem: Not even multiplication by 3 can be computed. Consider the multiplication of 0.33333333333? by 3. If the next digit is 4, then we know the result starts with 1.00000000000. If it is 2 then we know the result starts with 0.99999999999. As long as we get only digits 0.333333 ⋯ we cannot determine therefore, what the first digit of the result is.

1.2.4 Theory in which the following can be formalized

We are going to work in HA^{ω} extended by the axiom of countable unique choice

(AC − NN!) (∀n.∃!m.A(n, m))→∃α^{nat→nat}.∀n.A(n, α(n))

To work without it is almost impossible. If we used the axiom of countable choice

(AC − NN) (∀n.∃m.A(n, m))→∃α^{nat→nat}.∀n.A(n, α(n))

the following would be easier.

Definition 1.2.1 (5.2.1)

(a) Let in the following

• α, β, γ range over elements of type nat→nat,

• n, m, i, j, k range over nat.

• z range over ℤ,

• q, r, s, t range over ℚ

• e write α(n) instead of α n, etc.

all with possible subscripts and accents.

(b) We denote functions from ℕ to ℚ (as well to other sets) by sequences (q_{n})_{n∈ℕ} or (q_{n})_{n} or even (q_{n}). If introduced as a new sequence (q_{n})_{n∈ℕ} should be read as λn.q_{n}.

1.2.5 Introduction of ℝ in HA^{ω} (5.2.2)

Definition 1.2.2 (2.2)

(a) A fundamental sequence is a sequence (q_{n})_{n∈ℕ} of rationals together with some β^{nat→nat} (called Cauchy-modulus) s. t.

∀k.∀m, m′ ≥ β(k).(|q_{m} − q_{m′}| < 2^{−k})

(b)

(q_{n}) ≈ (r_{n}) : ⇔∀k.∃N.∀m ≥ N.|q_{m} − r_{m}| < 2^{−k}

(c) We will usually only indicate the sequence (q_{n})_{n∈nat} of a fundamental sequence, and refer to the Cauchy-modulus as the “Cauchy-modulus of (q_{n})”.

(d) The set of Cauchy-reals ℝ is the set of equivalence classes of fundamental sequences modulo ≈. We write [(q_{n})] for the equivalence class of (q_{n}) modulo ≈.

Remark 1.2.3 (a) ≈ is an equivalence relation.

(b) With (AC − NN) we could define fundamental sequences by demanding

∀k.∃N.∀m, m′ ≥ N(|q_{m} − q_{m′}| < 2^{−k})

since (AC − NN) provides then immediately from this property a Cauchy-

modulus.

Definition 1.2.4 The set of reals can now be formalized as follows:

• ∀x^{ℝ} has to be replaced by

     ∀q^{nat→ℚ}.∀α^{nat→nat}.(q_{n}) is a fundamental sequence with Cauchy-modulus α→ · · ·

where in the following x has to be replaced by (q_{n}).

• Equality between elements of ℝ has to be replaced by ≈.

• Operations on reals have to be replaced by operations on the sequences, as will be introduced below.

Let in the following x, y, z range over ℝ (with indices and accents).

1.2.6 The ordering of the reals (5.2.3 - 5.2.15)

Definition 1.2.5 (a) Let HA^{+} be the extension of HA^{ω} by (AC − NN!).

(b) In the following all statements (in so far they are statements of HA^{+} can be proved in HA^{+}.

(c) We write (q_{n}) ∈ x for “the real number x is given by the fundamental sequence (q_{n})” (with some Cauchy modulus)

(d) We write ⟨(q_{n}), α⟩ ∈ x for “the real number x is given by the fundamental sequence (q_{n}) with Cauchy modulus α.

Remark 1.2.6 To define a function/relation on reals means in the following to define a function/relation on fundamental sequences such that HA^{+} proves, that it respects the equality ≈ on reals. From this it follows that the equality axioms with respect to the extension by symbols for the new functions and relations are provable in HA^{+} (i.e. their translation into formulas of L_{HA}^{ω} are theorems of HA^{+}, where the new relations and functions are translated by their definition).

Proposition 1.2.7 (Prop. 5.2.3) Assume (q_{n}), (r_{n}) are fundamental sequences with Cauchy-modulus α, β, (q_{n}) ≈ (r_{n}) and define γ(k) := max{α(k + 2), β(k + 2)}. Then

∀m, m′ ≥ γ(k).|q_{m} − r_{m′}| < 2^{−k} .

Proof: Assume k. Assume m_{0} s. t.

∀l ≥ m_{0}.|q_{l} − r_{l}| < 2^{−(k+2)} .

Define m_{1} := max{γ(k), m_{0}}. Then for all m, m′ ≥ γ(k) we have

|q_{m} − r_{m′}| ≤ |q_{m} − q_{m_{1}}| + |q_{m_{1}} − r_{m_{1}}| + |r_{m_{1}} − r_{m′}|
< 2^{−(k+2)} + 2^{−(k+2)} + 2^{−(k+2)} < 2^{−k}

Definition 1.2.8 (Def. 5.2.4) For fundamental sequences (q_{n}), (r_{n}) we define

(q_{n}) < (r_{n}) : ⇔∃k, N.∀m ≥ N.r_{m} > q_{m} + 2^{−k} .

Proposition 1.2.9 If (q_{n}) < (r_{n}), (q_{n}) ≈ (q′_{n}), (r_{n}) ≈ (r′_{n}), then (q′_{n}) < (r′_{n}).

Proof: (Not to be carried out in the lecture). There exists k, N_{1}, N_{2}, N_{3} s. t.

∀m ≥ N_{1} . r_{m} > q_{m} + 2^{−k}
∀m ≥ N_{2} . |q_{m} − q′_{m}| < 2^{−(k+2)}
∀m ≥ N_{3} . |r_{m} − r′_{m}| < 2^{−(k+2)}

Then with N := max{N_{1}, N_{2}, N_{3}} it follows

∀m ≥ N.r′_{m} > q′_{m} + 2^{−(k+2)}

Definition 1.2.10 (Def. 5.2.7.; <, ≤, # on ℝ) Let x, y ∈ ℝ (q_{n}) ∈ x, (r_{n}) ∈ y. We define

x < y : ⇔ (q_{n}) < (r_{n})
x ≤ y : ⇔ ¬(y < x)
x # y : ⇔ x < y ∨ y < x

# is called apartness. x # y is pronounced as “x is apart from y”. OBS x ≤ y is not defined as x ≤ y ∨ x = y.

Definition 1.2.11 (Definition 5.2.6.) Define

∗ : ℚ→ℝ
q ↦ q^{∗} := (q_{n}) with Cauch modulus λn.0

We identify q with q^{∗}.

Proposition 1.2.12 (Proposition 5.2.8.) Let x, y ∈ ℝ, (r_{n}) ∈ x, (s_{n}) ∈ y. Then

x # y↔∃k, N.∀n ≥ N.|q_{n} − r_{n}| > 2^{−k} .

Proof: Exercise.

Proposition 1.2.13

\begin{matrix}(AP1) & ¬(x # y) & ↔ & x = y \\ (AP2) & x # y & ↔ & y # x \\ (AP2) & x # y & → & ∀z(x # z ∨ z # y) \end{matrix}

Proof: (Not to be carried out in the lecture) (AP1): x = y→¬(x # y) is clear. Assume ¬(x # y) and show x = y. Let ⟨(q_{n}), α⟩ ∈ x, ⟨(r_{n}), β⟩ ∈ y. Assume k. By assumption

∀N.¬∀m ≥ N|q_{m} − r_{m}| > 2^{−(k+2)}  (∗)
∀m, m′ ≥ α(k + 2).|q_{m} − q_{m′}| ≤ 2^{−(k+2)}
∀m, m′ ≥ β(k + 2).|r_{m} − r_{m′}| ≤ 2^{−(k+2)}

Let

m ≥ N := max{α(k + 2), β(k + 2)} .

Assume

|q_{m} − r_{m}| ≥ 2^{−k} .

Then, for all m′ ≥ N

|q_{m′} − r_{m′}| ≥ |q_{m} − r_{m}| − |q_{m} − q_{m′}| − |r_{m} − r_{m′}|
≥ 2^{−k} − 2^{−(k+2)} − 2^{−(k+2)}
= 2^{−(k+1)}
> 2^{−(k+2)}

contradicting (∗). Therefore with N as above it follows the assertion. (AP 2): trivial. (AP 3): Exercise.

Corollary 1.2.14 (Corollary 5.2.10). Stability of = on ℝ:

∀x, y.(¬¬x = y↔x = y)

Proof:

¬¬(x = y)↔¬¬¬x # y↔¬x # y↔x = y .

1.2. CONSTRUCTIVE REAL NUMBERS (5.1 - 5.4, 6.1) 21

Proposition 1.2.15 (Proposition 5.2.11.) Assume x, y, z ∈ ℝ.

(a) (x ≤ y ∧ y ≤ x)→x = y.

(b) (x < y ∧ y < z)→x < z.

(c) x < y→(x < z ∨ z < y).

(d) (x < y ∧ y ≤ z)→x < z.

(e) (x ≤ y ∧ y < z)→x < z.

(f) (x ≤ y ∧ y ≤ z)→x ≤ z.

(g) x ≤ y→¬¬(x < y ∨ x = y).

(h) ¬¬(x ≤ y ∨ y ≤ x).

(i) ¬¬(x < y ∨ x = y ∨ y < x). Proof: (Not to be carried out in the lecture). (a):

x ≤ y ∧ y ≤ x → ¬(y < x) ∧ ¬(x < y)
→ ¬(y < x ∨ x < y)
↔ ¬x # y
↔ x = y

(b): Easy. (c): By x < y it follows

x # y

by (AP 3)

x # z ∨ z # y

therefore

(x < z ∨ z < x) ∨ (z < y ∨ y < z)

By (b) and x < y therefore

x < z ∨ z < y ∨ z < y ∨ x < z ,

the assertion.

(d) Assume (x < y) ∧ y ≤ z. By (c)

x < z ∨ z < y .

By y ≤ z we have ¬(z < y), therefore x < z .

(e) Similarly.

(f) Assume x ≤ y, y ≤ z. Assume

z < x .

Then

z < y  by x ≤ y, (d)
z < z  by y ≤ z, (d)
z # z
z ≠ z  contradiction.

(g) - (i): Exercise.

Weak counterexample for x = 0 ∨ x ≠ 0. If A(y) is a decidable statement s. t. whether ∀y.A(y) holds is not known, let α be defined by

q_{n} := \begin{cases}2^{−m} & if m ≤ n, ¬A(m), ∀k < m.A(k) \\ 2^{−n} & if ∀k ≤ n.A(k) \end{cases}

Then q_{n} is a fundamental sequence with Cauchy-modulus λn.n + 1, and with x given by (q_{n}),

∀n.A(n) → x = 0
∃n.¬A(n) → ∃n.x = 2^{−n} therefore x ≠ 0

therefore x = 0 ∨ x ≠ 0 is not constructively valid. Taking A(n) := ¬T(m, m, n) we get A(n)↔{m}(m) ↑, therefore from

∀x.(x = 0 ∨ x ≠ 0)

we could conclude

∀m({m}(m) ↓ ∨{m}(m) ↑)

which is not Kleene-realizable, therefore (since all theorems of HA^{+} are realizable) not provable in HA^{+}.

Definition 1.2.16 (Definition 5.2.13) For x, y ∈ ℝ we define x+y, x−y, |x| ∈ ℝ as follows: Let (q_{n}) ∈ x, (r_{n}) ∈ y. Then one verifies that for some appropriate Cauchy-moduli

(q_{n} + r_{n}) ,
(q_{n} − r_{n}) ,
(|q_{n}|) ,

are fundamental sequences. The definition respects ≈. Let now x + y, x − y, |x| be given by (q_{n} + r_{n}), (q_{n} − r_{n}), (|q_{n}|).

1.2. CONSTRUCTIVE REAL NUMBERS (5.1 - 5.4, 6.1) 23

Remark 1.2.17 For r ∈ ℚ

r > 0→x < x + r

Proof: Easy. Proposition 1.2.18 (Proposition 5.2.14)

x ≤ y↔∀k.x < y + 2^{−k} .

Proof: (Not to be carried out in the lecture). “→”: x ≤ y < y + 2^{−k}. “←” Assume ∀k.x < y + 2^{−k}, y < x. From the definition of < it follows immediately for some m

y + 2^{m} < x

Therefore

y + 2^{m} < x < y + 2^{m}

a contradiction. x ≤ y. Proposition 1.2.19 Assume x, y, z ∈ ℝ, (q_{n}) ∈ x.

(a) ∀m ≥ n(|q_{n} − q_{m}| ≤ 2^{−k}→|x − q_{n}| ≤ 2^{−k}

(b) |x − y| ≤ r↔x − r ≤ y ≤ x + r

(c) (|x − y| ≤ r ∧ |y − z| ≤ r′)→|x − z| ≤ r + r′ Proof: [TvD] or exercise.

1.2.7 Real valued functions (5.3.3) Definition 1.2.20 (a) σ^{k} := \underbrace{σ × ⋯ × σ}_{ktimes}.

(b) We write • (a_{1}, …, a_{n}) for ⟨a_{1}, ⟨a_{2}, … ⟨a_{n−1}, a_{n}⟩⟩⟩,

• f(a_{1}, …, a_{n}) for f((a_{1}, …, a_{n})),

• f(a) for f a. Lemma 1.2.21 (a) ∀x((∀k(|x| < 2^{−k})→x = 0).

(b) ∀x.∀k.∃q.|x − q| < 2^{−k}.

(c) ∀x.∃k.|x| < k.

(d) ∀x, y, z(|x − z| ≤ |x − y| + |y − z|).

(e) ∀x, x′, y, y′((x < y ∧ x′ < y′)→x + x′ < y + y′).

Proof: Easy exercise.

Definition 1.2.22 A function f : ℝ^{m}→ℝ is in the following given by functions

f_{0} : (nat→ℚ)^{m}→(nat→ℚ),
α : (nat→ℚ)^{m}→(nat→nat)^{m}→(nat→nat)

where α is called the Cauchy-modulus-function, such that

• If (q_{n}^{i}) are fundamental sequences with Cauchy-modulus β^{k}, then f_{0}((q_{n}^{1}), …, (q_{n}^{m})) is a fundamental sequence with Cauchy-modulus

α_{0}((q_{n}^{1}), …, (q_{n}^{m}), β_{0}, …, β_{m}) .

• If (q_{n}^{i}) ≈ (r_{n}^{i}), then

f_{0}((q_{n}^{1}), …, (q_{n}^{m})) ≈ f_{0}((r_{n}^{1}), …, (r_{n}^{m})) .

Remark 1.2.23 (a) What we really would like to have is that a function

f : ℝ^{m}→ℝ

is a function, which takes as arguments fundamental sequence (q_{n}^{i}), Cauchymoduli α_{i} and proofs that q_{n}^{i} are fundamental sequences with moduli α^{i} and maps this to a fundamental sequence (q′_{n}), a Cauchy-modulus β and a proof that (q′_{n}) is a fundamental sequence with modulus β together with a proof that this function respects ≈. However this cannot be expressed in HA^{+} (but for instance in dependent type theory), neither could we make use there of the proof that q_{n}^{i} are fundamental sequences except for the proof of q′_{n} being a fundamental sequence, and this dependency we have.

(b) It might be that f_{0} has to depend on the Cauchy-moduli α_{i} for (q_{n}^{i}) as well as well.

Definition 1.2.24 (Definition 5.3.1) Assume x⃗, y⃗ ∈ ℝ^{n} or x⃗, y⃗ ∈ ℚ^{n}, r ∈ ℚ. Let

0 := (0, …, 0) .

(a)

|x⃗ − y⃗| ≤ r := |x_{1} − y_{1}| ≤ r ∧ ⋯ ∧ |x_{n} − y_{n}| ≤ r .

(b)

|x⃗| ≤ r := |x⃗ − 0| ≤ r

Definition 1.2.25 (Definition 5.3.2) Let f : X^{n}→Y, where X, Y ∈ {ℚ, ℝ}.

(a) f is uniform continuous with modulus α iff

∀k.∀x⃗, y⃗ ∈ X^{n}(|x⃗ − y⃗| < 2^{−α(k)}→|f(x⃗) − f(y⃗)| < 2^{−k})

(b) f is locally continuous with modulus α iff

∀k, m.∀x⃗, y⃗ ∈ X^{n}  ((|x⃗| < m ∧ |y⃗| < m)
→|x⃗ − y⃗| < 2^{−α(k,m)}
→|f(x⃗) − f(y⃗)| < 2^{−k})

Remark 1.2.26 Under assumption of (AC − NN) we can omit the Cauchymodulus and replace the conditions above by demanding for all k (for all k, m) the existence of an i such that for all x⃗, y⃗ the matrix of the above formulas with α(k) (α(k, m)) replaced by i holds.

Definition 1.2.27 (Definition 5.3.4) Let f : ℚ^{n}→ℚ be locally continuous. Then the canonical extension f^{∗} : ℝ^{n}→ℝ is given by: If (q_{n}^{k})_{i} ∈ x_{i} then

f^{∗}(x⃗) := (f(q_{n}^{1}, …, q_{n}^{n}))_{n∈nat} ,

where the corresponding Cauchy-modulus-function and the proof that f^{∗} respects equality are left as an exercise.

Exercise 1.3 (a) Show ∀x ∈ ℝ∃n.|x| < n.

(b) Determine the Cauchy-modulus-function and the proof that f^{∗} respects equality in Definition 1.2.27.

Remark 1.2.28 For an arbitrary (not in general locally continuous) function f : ℚ^{n}→ℚ we cannot in general determine an extension f^{∗}. (Why? Do nonlocally continuous functions exists?)

Lemma 1.2.29 (Theorem 5.3.5) For every locally-continuous function f : ℚ^{n}→ℚ then f^{∗} is the unique locally continuous function f^{∗} : ℝ^{n}→ℝ extending f (i.e. such that

∀q⃗ ∈ ℚ^{n}.f^{∗}(q⃗) = f(q⃗) ) .

Proof: For notational simplicity assume f is uniformly continuous and n = 1. Let f be uniformly continuous with modulus α. We show f^{∗} is uniformly continuous with modulus λk.α(k + 1). Assume k, x, y, |x − y| < 2^{−α(k+1)}, (q_{n}) ∈ x, (r_{n}) ∈ y. There exists N s. t.

∀k ≥ N.|q_{k} − r_{k}| < 2^{−α(k+1)}

Then

∀k ≥ N.|f(q_{k}) − f(r_{k})| < 2^{−(k+1)}

and therefore

∀k ≥ N.|f(q_{k}) − f(r_{k})| + 2^{−(k+2)} < 2^{−k}
|f(x) − f(y)| < 2^{−k} .

Uniqueness of f. Let f^{o} be another locally continuous extension of f. We assume for simplicity f^{o} is uniformly continuous with modulus β. Let x ∈ ℝ, k ∈ ℕ. By the continuity of f^{∗} and f^{o} there exists l such that for y, |y −x| < 2^{−l}, we have

|f^{∗}(y) − f^{∗}(x)| < 2^{−(k+1)} ,
|f^{o}(y) − f^{o}(x)| < 2^{−(k+1)} .

Let q ∈ ℚ such that |x − q| < 2^{−l}. Then f^{∗}(q) = f(q) = f^{o}(q) and therefore

|f^{∗}(x) − f^{o}(x)| ≤ |f^{∗}(x) − f^{∗}(q)| + |f^{o}(q) − f^{o}(x)|
< 2^{−(k+1)} + 2^{−(k+1)}
= 2^{−k}

Since k is arbitrary it follows f^{∗}(x) = f^{o}(x).

Lemma 1.2.30 (Corollary 3.5, Prop 3.6, Prop 3.8)

(a) +, −, ·, |·| are the unique locally continuous extensions of the corresponding functions on ℚ to ℝ.

(b) λx, y. max{x, y}, λx, y. min{x, y} can be extended from ℚ to ℝ.

(c) Let φ(x_{1}, …, x_{n}), ψ(x_{1}, …, x_{n}) be terms build from Variables x_{i} using some q ∈ ℚ and +, −, ·, | · |, λx, y. max{x, y}, λx, y. min{x, y}. Then from

∀q_{1}, …, q_{n} ∈ ℚ.φ(q_{1}, …, q_{n}) = ψ(q_{1}, …, q_{n})

it follows

∀x_{1}, …, x_{n} ∈ ℚ.φ(x_{1}, …, x_{n}) = ψ(x_{1}, …, x_{n})

The same holds with = replaced by ≤.

Proof: (a), (b). Immediate.

(c) It follows easily that λx⃗.φ(x⃗), λx⃗.ψ(x⃗) are locally continuous and the unique extensions of the corresponding functions on ℚ. Therefore the assertion for = follows. For ≤ we show below in Lemma 1.2.31 (b)

x ≤ y↔ max{x, y} = y

and then the assertion follows by replacing the above equation by

max{φ(x⃗), ψ(x⃗)} = ψ(x⃗) .

1.2. CONSTRUCTIVE REAL NUMBERS (5.1 - 5.4, 6.1) 27

Lemma 1.2.31 (Proposition 5.3.7 and 5.3.9)

(a) (y < x ∨ y = x)→ (max{x, y} = x ∧ min{x, y} = x).

(b) x ≤ y↔ max{x, y} = y↔ min{x, y} = x

(c) |x − y| = max{x, y} − min{x, y}.

(d) x < y↔x + z < y + z.

(e) x ≤ y↔x + z ≤ y + z.

(f) |x − y| ≤ z↔x − z ≤ y ≤ x + z.

(g) min{x, y} ≤ x ≤ max{x, y}.

(h) min{x, y} ≤ y ≤ max{x, y}.

(i) |x − y| ≥ ||x| − |y||.

(j) x # y→(x + z) # (y + z).

(k) (x + y) # 0→(x # 0 ∨ y # 0).

(l) xy # 0→(x # 0 ∧ y # 0). Proof: [TvD]. But everybody should be able to do this by hand.

1.2.8 Completeness of ℝ (5.4) Definition 1.2.32 (a) A sequence of reals is a function

q : nat→nat→nat

written as

(q_{n,m})_{n,m∈nat} ,

together with a modulus of it

α : nat→nat→nat

such that for n ∈ nat

(q_{n,m})_{m∈nat} is a fundamental sequence with modulus α(n) . If x_{n} is the real given by

(q_{n,m})_{n,m∈nat} ,

then we denote such a sequence by (x_{n})_{n∈nat} .

(b) A sequence of reals (x_{n})_{n∈nat} converges against x iff there exists a modulus of convergence β : nat→nat such that

∀n.∀b ≥ β(n)(|x_{n} − x| < 2^{−n}) .

(c) A sequence of reals (x_{n})_{n∈nat} is a Cauchy sequence with Cauchy-modulus

β : nat→nat iff

∀k.∀l, m ≥ β(k)|x_{l} − x_{m}| < 2^{−k} .

Theorem 1.2.33 (Theorem 5.4.2) ℝ is Cauchy-complete, i.e. if (x_{n}) is a Cauchy sequence, then there exists an x ∈ ℝ such that x_{n} converges against x.

Proof: Let α be a modulus, β be a Cauchy-modulus for (x_{n}), (x_{n}) given by (q_{n,m})_{n,m}. Let γ defined by

γ(0) := β(0), γ(n + 1) := max{β(n + 1), γ(n)} + 1

γ is as well a Cauchy-modulus for (x_{n}) such that ∀n, m(n < m→γ(n) < γ(m)). Let

r_{n} := q_{α(γ(n),n),γ(n)} .

Then

|x_{γ(n)} − r_{n}| ≤ 2^{−n}

and therefore for m, m′ ≥ n

|r_{m} − r_{m′}| ≤ |r_{m} − x_{γ(m)}| + |x_{γ(m)} − x_{γ(m′)}| + |x_{γ(m′)} − r_{m′}|
≤ 2^{−n} + 2^{−n} + 2^{−n} < 2^{−n+2}

Therefore (r_{n}) is a fundamental sequence with modulus λn.n + 2. Let x be given by (r_{n}). (x_{n}) converges against x with modulus λn.γ(n + 3): Let m ≥ γ(n + 3). Then

|x − x_{m}| ≤ |x − r_{n+3}| + |r_{n+3} − x_{γ(n+3)}| + |x_{γ(n+3)} − x_{m}|
≤ 2^{−(n+1)} + 2^{−(n+3)} + 2^{−(n+3)}
< 2^{−n}

1.2.9 Intermediate value and existence of minimum/maximum theorems (6.1)

6.1. in [TvD] shows which variant of the intermediate value theorem and the theorem of the existence of minimum/maximum is constructively valid and which not (e.g. the theorem of the existence of minimum/maximum isn’t but the existence of a supremum/infimum for totally bounded functions is). This section is very easy to read and therefore not worked out here.

λ-Calculus and Combinatory Logic ([HS86])

Numbers will refer from now on to the book of Hindley and Seldin.

2.1 λ-calculus (1)

2.1.1 Introduction

30 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

We have already dealt considered λ-terms already in our investigations of HA^{ω}. λx.t was there the function, which applied to a term s yields t[x := s]. In the case of HA^{ω} we had obtained typed λ-terms: λx.t was of type σ→τ, and could only be applied to a term of type σ. Forming terms like this yields the typed λ-calculus. This excludes however the application of a function to itself. If we consider the identity function λx.x, then this function could be applied to any object, as well the function λx.x. So to form (λx.x)(λx.x) makes sense (this can be typed, but both occurrences of λx.x get different types), therefore as well (λx.xx)(λx.x) which should yield the above result. But the sub-term xx cannot be typed: x must have type σ→ρ and at the same time σ for some σ, ρ. In programming it is interesting to apply a program to itself. However we cannot expect that a program behaves very well. We will see is that the typed λ-calculus is strongly normalizing, i.e. when we reduce a term in a way as above described (applying such reductions to sub-terms as well), we always obtain an irreducible term, independent of the choice of reductions. For the untyped λ-calculus this is not the case: Take the term (λx.xx)(λx.xx). It reduces to itself, and has therefore an infinite reduction sequence. The relationship between typed λ-calculus and untyped λ-calculus is somehow similar to that of primitive recursive functions and partial recursive functions. Primitive recursive functions always terminate, but there are computable functions which are not primitive recursive. Partial recursive functions might terminate or might not, but they contain all recursive function (we will see that all partial recursive functions can be represented in the untyped λ-calculus; the class of definable functions in the typed λ-calculus is very small: it’s the least class of numeric functions containing projections, the constant functions, the signumbar function (0 ↦ 1), (S(n) ↦ 0) (from which the signum function 0 ↦ 0, S(n) ↦ 1 can be defined), addition, multiplication and is closed under composition). We can extend the class of primitive recursive functions, but as long as we do this in a recursively enumerable way (i.e. such that there is a recursively enumerable subset A of ℕ × ℕ such that the resulting class of functions is {{e}^{n} | ⟨e, n⟩ ∈ A}) we will not exhaust the class of recursive functions. Similarly, by extending a type system in such a way that, whether a term can by typed, is decidable and such that all terms which can be typed are normalizing, we will never obtain all normalizing terms. If we have a type system such that the set of terms which can be typed and map certain encodings of the natural numbers (so called Church-numerals) to such encodings is recursive enumerable, then there will always be a term mapping Church-numerals to Church-numerals which cannot be typed. We will start with the untyped λ-calculus and will later look at the typed one. Further, we will look as well at combinators, which allowed us in the case of HA^{ω} to define all λ-terms. Essentially the theory of combinators and the theory of λ-terms are equivalent, but there are fine distinctions to be made, which will be explored.

Definition 2.1.1 Some conventions

(a) Let m_{1}, …, m_{n} ↦ ⟨m_{1}, …, m_{n}⟩ some primitive recursive coding of sequence such that standard properties hold and such that 0 = ⟨⟩.

(b) If m = ⟨m_{1}, …, m_{k}⟩, (m)_{i} := m_{i} and the length of the sequence m (seqlength(m)) is defined as k.

(c) If m = ⟨m_{1}, …, m_{k}⟩, n = ⟨n_{1}, …, n_{l}⟩, m∗n := ⟨m_{1}, …, m_{k}, n_{1}, …, n_{l}⟩.

2.1.2 Definition of λ-terms (1A, 1B)

Definition 2.1.2 (Definition 1.1).

(a) Assume some infinite sequence of distinct symbols, called variables, and a (finite, infinite or empty) sequence of distinct symbols called constants.

(If the sequence of constants is empty, the system is called pure, otherwise applied).

The set of expressions called λ-terms is inductively defined as follows:

• All variables and constants are λ-terms (called atoms).

2.1. λ-CALCULUS (1) 31

• If M, N are λ-terms, so is (MN) (called an application).

• If M is a λ-term, x a variable, then (λx.M) is a λ-term (called an

abstraction).

(b) In this chapter capital roman letters will denote λ-terms. In this part x, y, z, u, v, w will denote variables.

(c) Parenthesis will be omitted with the following conventions • Application is associative to the left (MNP Q denotes (((MN)P)Q)).

• The scope of λx. is maximal (i.e. λx.P Q denotes λx.(P Q),

(d) λx_{1}, …, x_{n}.M := λx_{1}.λx_{2}…. λx_{n}.M.

(e) We write M ≡ N for syntactic identity of the terms M, N. Definition 2.1.3 (Definition 1.5)

(a) The length of a term M (written as lgh(M )) is defined as: • lgh(a) := 1 if a is an atom.

• lgh(MN) := lgh(M) + lgh(N).

• lgh(λx.M) := 1 + lgh(M). Induction on M means in the following (OBS!) induction on lgh(M).

Definition 2.1.4 We define the sets of free variables FV(N) and of bound variables BV(N) of a term N as follows:

• FV(a) := BV(a) := ∅ if a is a constant.

• FV(x) := {x}, BV(x) := ∅.

• FV(MN) := FV(M) ∪ FV(N), BV(MN) := BV(M) ∪ BV(N).

• FV(λx.M) := FV(M) \ {x}, BV(λx.M) := BV(M) ∪ {x}. Var(M) := FV(M) ∪ BV(M).

2.1.3 Substitution (In 1B) Definition 2.1.5 (1.11) For M, N, x we define M[x := N], the result of substituting N for x in M by induction on the M in such a way that, if N is a variable, then lgh(M[x := N]) = lgh[M], as follows:

• x[x := N] := N.

• a[x := N] := a (a an atom, a ≢ x).

• (P Q)[x := N] := (P [x := N])(Q[x := N]).

32 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

• (λx.P)[x := N] := λx.P.

• (λy.P)[x := N] := λy.(P [x := N]), if x ≢ y, y ∉ FV(N) ∨ x ∉ FV(P).

• (λy.P)[x := N] := λz.((P [y := z])[x := N]), if x ≢ y, y ∈ FV(N) ∧ x ∈

FV(P), z the first variable s. t. z ∉ FV(N) ∪ FV(P). Remark: The last clause in Definition 2.1.5 renames the bound variable y first, such that there is no variable clash and therefore N is now substitutable for x in the new term, and then carries out the substitution. Lemma 2.1.6 (1.14)

(a) M[x := x] ≡ M.

(b) x ∉ FV(M)⇒M[x := N] ≡ M.

(c) x ∈ FV(M)⇒FV(M[x := N]) = FV(N) ∪ (FV(M) \ {x}).

(d) lgh(M[x := y]) = lgh(M). Proof: Easy. Lemma 2.1.7 (1.15) Let x, y, v be distinct variables, BV(M) ∩ FV(vP Q) = ∅.

(a) v ∉ FV(M)⇒M[x := v][v := P] ≡ M[x := P].

(b) v ∉ FV(M)⇒M[x := v][v := x] ≡ M.

(c) y ∉ FV(P)⇒M[y := Q][x := P] ≡ M[x := P][y := Q[x := P]].

(d) M[x := Q][x := P] ≡ M[x := (Q[x := P])]. Proof: (a), (c): Induction on M. (b) follows from (a) and Lemma 2.1.6 (a), (d) from (c) and 2.1.6 (b). Definition 2.1.8 New version of (1.16) The relation M ≡_{α} N, M is α-equivalent to N is defined as follows:

• If a is an atom, a ≡_{α} a.

• If M ≡_{α} M′, N ≡_{α} N′, then MN ≡_{α} M′N′.

• If v ∉ Var(M) ∪ Var(N), M[x := v] ≡_{α} N[y := v], then λx.M ≡_{α} λy.N. Lemma 2.1.9 (a) ≡_{α} is reflexive and symmetric.

(b) If M ≡_{α} N, then M[x := v] ≡_{α} N[x := v].

(c) ≡_{α} is an equivalence relation.

(d) If P ≡_{α} Q then FV(P) = FV(Q).

2.1. λ-CALCULUS (1) 33

(e) For every term P and x_{1}, …, x_{n} there exists P′ ≡_{α} P such that x_{1}, …, x_{n} ∉ BV(P′).

Proof: (a): trivial. (b): Easy induction on M, using Lemma 2.1.7 (a) and (c). (c): Induction on M, using (b) and Lemma 2.1.7 (a) in the case M ≡ λx.P.

(d) Trivial.

(e) Easy. Lemma 2.1.10 (1.18, 1.19) Let x, y, v be distinct variables.

(a) v ∉ FV(M)⇒M[x := v][v := P] ≡_{α} M[x := P].

(b) v ∉ FV(M)⇒M[x := v][v := x] ≡_{α} M.

(c) y ∉ FV(P)⇒M[y := Q][x := P] ≡_{α} M[x := P][y := Q[x := P]].

(d) M[x := Q][x := P] ≡_{α} M[x := (Q[x := P])].

(e) M ≡_{α} M′, N ≡_{α} N′ ⇒ M[x := N] ≡_{α} M′[x := N′]. Proof: as before, in (e) Induction on M. 2.1.4 β-reduction (1C) Definition 2.1.11 (a) Inductive definition of the relation M ⟶_{β} N:

• (λx.M)N ⟶_{β} M[x := N].

• If M ⟶_{β} M′ then

– MN ⟶_{β} M′N,
– NM ⟶_{β} NM′,
– λx.M ⟶_{β} λx.M′.

(b) ⟶_{β}^{∗} is the transitive reflexive closure of ⟶_{β} ∪ ≡_{α}.

(c) A term N is in β-normal form, if there is no term N′ s. t. N ⟶_{β} N′.

(d) If P ⟶_{β}^{∗} Q, Q is a term in β-normal form, then Q is called a β-normal form of P. P normalizes, if it has a β-normal form.

(e) We omit the subscript β in the above definitions, if there is no confusion. Example 2.1.12 (a) (λx.(λy.yx)z)v has β-normal form zv.

(b) Let L := (λx.xxy)(λx.xxy)

L ⟶_{β} Ly ⟶_{β} Lyy ⟶_{β} · · · .

L has no β-normal form.

(c) Let P := (λu.v)L, L as in (b). There are (among others) two reduction sequences:

• P ⟶_{β} v.

• P ⟶_{β} (λu.v)(Ly) ⟶_{β} (λu.v)(Lyy) ⟶_{β} · · ·.

P has normal form v, but also an infinite reduction sequence.

Lemma 2.1.13 (1.27) If P ≡_{α} P′, Q ≡_{α} Q′, P ⟶_{β}^{∗} Q, then P′ ⟶_{β}^{∗} Q′.

Proof: Trivial: P′ ≡_{α} P ⟶_{β}^{∗} Q ≡_{α} Q′.

Lemma 2.1.14 (1.28; Substitution lemma for β-reduction) Assume P ⟶_{β}^{∗} Q.

(a) FV(Q) ⊆ FV(P).

(b) M[x := P] ⟶_{β}^{∗} M[x := Q].

(c) P [x := N] ⟶_{β}^{∗} Q[x := N].

Proof: It suffices to consider the case P ⟶_{β} Q (the case P ≡_{α} Q follows by Lemma 2.1.10 (e), 2.1.9 (d)).

(a) By Lemma 2.1.6 (b), (c) FV(M[x := N]) ⊆ FV((λx.M)N).

(b) By Lemma 2.1.10 (e) we can assume BV(M)∩(Var(P)∪Var(Q)) = ∅. Now induction on M.

(c) Again assume BV(P) ∩ FV(N) = ∅. The only difficult case is where P ≡ (λy.H)J and Q ≡ H[y := J]. Then

P [x := N] ≡ ((λy.H)J)[x := N]
≡ ((λy.(H[x := N]))(J[x := N])
⟶_{β} H[x := N][y := J[x := N]]
≡ H[y := J][x := N] by Lemma 2.1.7 (c), 2.1.10 (c)
≡ Q[x := N]

Theorem 2.1.15 (1.29, Church-Rosser theorem for β-reduction) If P ⟶_{β} M, P ⟶_{β} N, then there exists T such that M ⟶_{β}^{∗} T, N ⟶_{β}^{∗} T.

Proof: We follow Takahashi, [Tak95]

Definition 2.1.16 (a) ([Tak95] 1.1)

The parallel β-reduction, denoted by ⟹_{β} is defined inductively defined as

• a ⟹_{β} a, if a is an atom.

• If v ∉ Var(M)∪Var(M′), M[x := v] ⟹_{β} M′[y := v], then λx.M ⟹_{β}

λy.M′.

2.1. λ-CALCULUS (1) 35

• If M ⟹_{β} M′, N ⟹_{β} N′, then MN ⟹_{β} M′N′.

• If M[x := u] ⟹_{β} M′, N ⟹_{β} N′, u ∉ Var(M) ∪ Var(N′), then

(λx.M)N ⟹_{β} M′[u := N′].

(b) For λ-terms M define M^{∗} by induction on M as follows: • a^{∗} := a (a an atom).

• (λx.M)^{∗} := λx.M^{∗}.

• (M_{1}M_{2})^{∗} := (M_{1}^{∗})(M_{2}^{∗}), if M_{1} not of the form λx.M′.

• ((λx.M_{1})M_{2})^{∗} := M_{1}^{∗}[x := M_{2}^{∗}]. Lemma 2.1.17 (a) M ⟹_{β} M.

(b) M ⟹_{β} M′, v ∉ Var(M) ∪ Var(M′), then M[x := v] ⟹_{β} M′[x := v].

(c) If M ≡_{α} M′ ⟹_{β} N′ ≡_{α} N, then M ⟹_{β} N.

(d) If M ⟹_{β} M′, then M[x := N] ⟹_{β} M′[x := N].

(e) If M ⟶_{β} M′, then M ⟹_{β} M′.

(f) If M ⟹_{β} M′, then M ⟶_{β}^{∗} M′.

(g) If M ⟹_{β} M′, N ⟹_{β} N′, then M[y := N] ⟹_{β} M′[y := N′].

(h) ⟶_{β}^{∗} is the transitive closure of ⟹_{β}.

(i) If M ⟹_{β} N then N ⟹_{β} M^{∗}. Proof: (a) - (d) are easy. (e) by Induction on M ⟶_{β} M′. (f), (g) by induction on M. (h) by (e), (f). (i): Induction on M: Case M ≡ a ⟹_{β} N:

N ≡ a ⟹_{β} a ≡ M^{∗} .

Case M ≡ λx.M_{1} ⟹_{β} N. Then N ≡ λy.N_{1} for some N_{1},

M_{1}[x := v] ⟹_{β} N_{1}[y := v]

for some variable v ∉ Var(M_{1}) ∪ Var(N_{1}). W.l.o.g. (by (b)) v ∉ Var(M_{1}^{∗}). M_{1}[x := v] has smaller length than N, therefore by IH N_{1}[y := v] ⟹_{β} M_{1}[x := v]^{∗} ≡ M_{1}^{∗}[x := v],

λy.N_{1} ⟹_{β} λx.M_{1}^{∗} ≡ M^{∗} .

Case M ≡ M_{1}M_{2} ⟹_{β} N, M not a β-redex. Then N ≡ N_{1}N_{2} for some N_{i} s. t. M_{i} ⟹_{β} N_{i} (i = 1, 2),

N_{1}N_{2} ⟹_{β} M_{1}^{∗}M_{2}^{∗} ≡ M^{∗} .

36 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

Case M ≡ (λx.M_{1})M_{2} ⟹_{β} N. Then

N ≡ (λx.N_{1})N_{2} or N ≡ N_{1}[x := N_{2}]

for some N_{i} s. t.

M_{i} ⟹_{β} N_{i}

(i = 1, 2). By IH

N_{i} ⟹_{β} M_{i}^{∗}

(i = 1, 2). Subcase N ≡ (λx.N_{1})N_{2}.

N ⟹_{β} M_{1}^{∗}[x := M_{2}^{∗}] ≡ M^{∗} .

Subcase N ≡ N_{1}[x := N_{2}].

N ⟹_{β} M_{1}^{∗}[x := M_{2}^{∗}] ≡ M^{∗}

by (g). Lemma 2.1.18 (Diamond property for ⟹_{β}) Assume

• M ⟹_{β} N_{1},

• M ⟹_{β} N_{2}, Then there exists some M′ such that

• N_{1} ⟹_{β} M′,

• N_{2} ⟹_{β} M′. Proof: M′ := M^{∗}. Definition 2.1.19 Define P ⟹_{β}^{k} Q by:

• P ⟹_{β}^{0} P.

• If P ⟹_{β}^{k} Q ⟹_{β} R, then P ⟹_{β}^{k+1} R. Lemma 2.1.20 If

• M ⟹_{β}^{k} N_{1},

• M ⟹_{β}^{l} N_{2}, then there exists some M′ s. t.

• N_{1} ⟹_{β}^{l} M′,

• N_{2} ⟹_{β}^{k} M′.

2.1. λ-CALCULUS (1) 37

Proof: First proof for l = 1 by induction on k: k = 0: N_{1} ≡ M, M′ := N_{2}. k→k + 1: Let

M ⟹_{β}^{k} N′_{1} ⟹_{β} N_{1} .

By IH there exists some M′′ s. t.

N′_{1} ⟹_{β} M′′,
N_{2} ⟹_{β}^{k} M′′ .

By the Diamond property Lemma 2.1.18 there exists M′ s. t.

N_{1} ⟹_{β} M′ ,
M′′ ⟹_{β} M′ .

Similarly follows now by induction on l the full assertion.

Proof of Theorem 2.1.15: Lemmata 2.1.20, 2.1.17 (h).

Corollary 2.1.21 (Corollary 1.29.1) If P has β-normal forms M, N then M ≡_{α} N.

Proof: There exists T, s. t.

M ⟶_{β}^{∗} T ,
N ⟶_{β}^{∗} T

By M, N in normal form follows

M ≡_{α} T
N ≡_{α} T

Lemma 2.1.22 (Lemma 1.30) The class of β-normal forms is the smallest class A s. t.

• All atoms are in A.

• If M_{1}, …, M_{N} ∈ A, a is any atom, then

aM_{1}, …, M_{n} ∈ A .

• If M ∈ A, then λx.M ∈ A.

Proof: Immediate.

38 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

2.1.5 β-equality (1D) Definition 2.1.23 (1.32) Let =_{β} be the symmetric and transitive closure of ⟶_{β}^{∗}. We say P is β-equal or β-convertible to Q if P =_{β} Q. It follows immediately that =_{β} is reflexive as well. Lemma 2.1.24 (1.33) If

P′ ≡_{α} P =_{β} Q ≡_{α} Q′

then

P′ =_{β} Q′ .

Lemma 2.1.25 (1.34, Substitution lemma for β-equality). Assume P =_{β} Q.

(a) M[x := P] =_{β} M[x := Q].

(b) P [x := N] =_{β} Q[x := N]. Theorem 2.1.26 (1.35; Church-Rosser theorem for β-equality) If

P =_{β} Q

then there exists T s. t.

P ⟶_{β}^{∗} T ←_{β}^{∗} Q

Proof: Define

P ≈_{β} Q : ⇔∃T.P ⟶_{β}^{∗} T ←_{β}^{∗} Q

Then we have • P ≈_{β} Q⇒P =_{β} Q.

• P ≡_{α} Q⇒P ≈_{β} Q.

• P ⟶_{β} Q⇒P ≈_{β} Q.

• ≈_{β} is symmetric.

• ≈_{β} is transitive. (By Church Rosser).

• =_{β}⊆≈_{β}.

• =_{β} and ≈_{β} coincide. Corollary 2.1.27 (Corollary 1.35.1) If

• P =_{β} Q

• Q in β-normal form then

P ⟶_{β}^{∗} Q .

Proof:

P ⟶_{β}^{∗} T ←_{β}^{∗} Q

for some T.

T ≡_{α} Q .
P ⟶_{β}^{∗} T ⟶_{β}^{∗} Q .

Corollary 2.1.28 (Corollary 1.35.2) If P =_{β} Q then

• either P and Q do not have β-normal forms or

• P and Q have the same β-normal forms.

Corollary 2.1.29 (Corollary 1.35.3) If P =_{β} Q, P, Q are in normal form then P ≡_{α} Q.

Corollary 2.1.30 (Corollary 1.35.4) A term can be β-equal to at most one β-normal form (up to ≡_{α}).

Corollary 2.1.31 (Corollary 1.35.5) Assume

xM_{1} ⋯ M_{m} =_{β} yN_{1} ⋯ N_{n}

Then x ≡ y, m = n, M_{i} =_{β} N_{i} for i = 1, …, m.

Proof: Let

xM_{1} ⋯ M_{m} ⟶_{β}^{∗} T ←_{β}^{∗} yN_{1}, …, N_{n}

Then T must be of the form xT_{1}, …, T_{m} s. t. M_{i} ⟶_{β}^{∗} T_{i}. Similarly N_{j} ⟶_{β}^{∗} T_{i}, y ≡ x, n = m and the assertion.

2.2 Combinatory logic (2)

2.2.1 Introduction (2A)

Definition 2.2.1 (2.1, 2.2, 2.3, 2.4., 2.5)

(a) The set of terms in combinatory logic, in short set of CL-terms is defined as the set of λ-terms, but with two additional constants k and s and without closure under λ-abstraction.

(b) If k, s are the only constants, the system is called pure, otherwise applied

(c) In this section capital roman letters denote CL-terms. The other conventions are as in the last section.

(d) lgh(A), substitution is defined as for λ-terms.

40 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

2.2.2 Weak reduction (2B) Definition 2.2.2 (2.7, 2.8)

(a) Inductive definition of U ⟶_{w} V (U weakly contracts to V) for CL-terms

U, V:

• kxy ⟶_{w} x.

• sxyz ⟶_{w} xz(yz).

• If U ⟶_{w} V then XU ⟶_{w} XV, and UX ⟶_{w} V X.

(b) ⟶_{w}^{∗} is the reflexive and transitive closure of ⟶_{w}. We say U weakly reduces to V for U ⟶_{w}^{∗} V.

(c) A weak normal form is a term U s. t. U contracts to no other term.

(d) If U weakly reduces to a weak normal form X, then X is called the weak normal form of U.

This is a direct continuation of Handout 6. Lemma 2.2.3 (2.12; Substitution lemma for weak reduction) Assume P ⟶_{w}^{∗} Q.

(a) FV(Q) ⊆ FV(P).

(b) M[x := P] ⟶_{w}^{∗} M[x := Q].

(c) P [x := N] ⟶_{w}^{∗} Q[x := N]. Proof: As Lemma 2.1.14 (1.28). Theorem 2.2.4 (2.13, Church-Rosser theorem for weak reduction) If P ⟶_{w} M, P ⟶_{w} N, then there exists T such that M ⟶_{w}^{∗} T, N ⟶_{w}^{∗} T. Proof: An easy adaption of Takahashi’s proof. Left as an exercise.

2.2.3 Definition of λ-abstraction in combinatory logic (2C) As in HA^{ω} we can now introduce λ-terms: Definition 2.2.5 (a) For CL-terms M and variables x we define λ^{∗}x.M as

follows:

• Case: x ∉ FV(M). λ^{∗}x.M := k M.

• Case M ≡ N x, x ∉ FV(N). λ^{∗}x.M := N.

• Otherwise

– Subcase M = x.

λ^{∗}x.M := s k k .

– Subcase M = P Q.

λ^{∗}x.M := s (λ^{∗}x.P) (λ^{∗}x.Q) .

(b) λ^{∗}x_{1}, …, x_{n}.t := λ^{∗}x_{1}.λ^{∗}x_{2}…. λ^{∗}x_{n}.t. λ^{∗}x⃗.t := λ^{∗}x_{1}, …, x_{n}.t, if x⃗ = x_{1}, …, x_{n}.

Theorem 2.2.6 (2.15) (λ^{∗}x.M)N ⟶_{w}^{∗} M[x := N].

Proof: By Lemma 2.2.3 (c) it suffices to prove:

(λ^{∗}x.M) x ⟶_{w}^{∗} M .

Induction on lgh(M). Case: x ∉ FV(M).

(λ^{∗}x.M) x ≡ k M x ⟶_{w} M .

Case M ≡ N x, x ∉ FV(N).

(λ^{∗}x.M) x ≡ N x ≡ M .

Case Otherwise. Subcase M ≡ x.

(λ^{∗}x.x) x ≡ s k k x ⟶_{w} (k x) (k x) ⟶_{w} x

Subcase M ≡ P Q.

(λ^{∗}x.M) x ≡ s (λ^{∗}x.P) (λ^{∗}x.Q) x
⟶_{w} ((λ^{∗}x.P) x) ((λ^{∗}x.Q) x)
⟶_{w}^{∗} P Q ≡ M .

Lemma 2.2.7 (2.21; Substitution and abstraction lemma)

(a) FV(λ^{∗}M) = FV(M) \ {x}.

(b) If y ∉ FV(M), then

λ^{∗}x.M ≡ λ^{∗}y.(M[x := y])

(c) If y ∉ FV(x N), then

(λ^{∗}y.M)[x := N] ≡ λ^{∗}y.(M[x := N])

Proof: Induction on M.

2.2.4 Weak equality (2D)

Definition 2.2.8 (2.22) Let =_{w} be the symmetric and transitive closure of ⟶_{w}^{∗}. We say P is weakly equal or weakly convertible to Q if P =_{w} Q. It follows immediately that =_{w} is reflexive as well.

Lemma 2.2.9 (1.34, Substitution lemma for weak equality). Assume P =_{w} Q.

(a) M[x := P] =_{w} M[x := Q].

(b) P [x := N] =_{w} Q[x := N].

Theorem 2.2.10 (2.24; Church-Rosser theorem for weak equality) If

P =_{w} Q

then there exists T s. t.

P ⟶_{w}^{∗} T ←_{w}^{∗} Q

Proof: As for Theorem 2.1.26(1.35).

Corollary 2.2.11 (Corollary 2.24.1 - 5)

(a) If P =_{w} Q and Q is in weak normal form then P ⟶_{w}^{∗} Q .

(b) If P =_{w} Q then

• either P and Q do not have weak normal forms or • P and Q have the same weak normal forms.

(c) If P, Q are distinct weak normal forms, then P ≠_{w} Q. In particular s ≠_{w} k, =_{w} is nontrivial.

(d) If P =_{w} Q, P, Q are in normal form, then P ≡ Q.

(e) A term can be weakly equal to at most one weak normal form.

(f) Assume

xM_{1} ⋯ M_{m} =_{w} yN_{1} ⋯ N_{n}

Then x ≡ y, m = n, M_{i} =_{w} N_{i} for i = 1, …, m.

Remark 2.2.12 (Warning, 2.25) It seems that combinatory logic and λ-calculus are exactly the same. But there is one difference: In λ-calculus we have the so called ξ-rule:

M ⟶_{β} N⇒λx.M ⟶_{β} λx.N ,

which can be weakened to

M =_{β} N⇒λx.M =_{β} λx.N .

2.3. THE FIXED POINT AND QUASI-LEFTMOST-REDUCTION THEOREM (3B, 3D)43

However in general in combinatory logic we do not have M =_{w} N⇒λ^{∗}x.M =_{w} λ^{∗}x.N .

Counterexample

M := s x y z N := (x z) (y z)

We have

M =_{w} N
λ^{∗}x.M ≡ λ^{∗}x.(s x y z)
≡ s (λ^{∗}x.s x y) (λ^{∗}x.z)
≡ s (s (λ^{∗}x.s x) (λ^{∗}x.y)) (k z)
≡ s (s s (k y)) (k z) ,
λ^{∗}x.N ≡ λ^{∗}x.(x z) (y z)
≡ s (λ^{∗}x.x z) (λ^{∗}x.y z)
≡ s (s (λ^{∗}x.x) (λ^{∗}x.z)) (k (y z))
≡ s (s (s k k) (k z)) (k (y z))

λ^{∗}x.M and λ^{∗}x.N are in normal form and different, therefore λ^{∗}x.M ≠_{w} λ^{∗}x.N

2.3 The fixed point and quasi-leftmost-reduction

theorem (3B, 3D)

2.3.1 Introduction (3A) ‘ Notation 2.3.1 (3.1., 3.2.)

(a) This section works both for λ-calculus and CL. The notation used in this section should be read in λ-calculus and in CL as follows

Notation  Interpretation for λ Interpretation for CL
Term  λ-term  CL-term
X ≡ Y  X ≡_{α} Y  X, Y are identical
X ⟶_{β,w} Y X ⟶_{β} Y  X ⟶_{w} Y
X ⟶_{β,w}^{∗} Y X ⟶_{β}^{∗} Y  X ⟶_{w}^{∗} Y
X =_{β,w} Y  X =_{β} Y  X =_{w} Y
λx.Y  λx.Y  λ^{∗}x.Y
Combinator Closed Term not  Term that has
containing  as atoms only
constants  k and s
s  λx, y, z.x z (y z)  s
k  λx, y.x  k

44 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC (b)

I := λx.x  (in CL ≡ s k k)
B := λx, y, z.x (y z) (in CL ≡ s (k s) k)
W := λx, y.(x y) y (in CL ≡ s s (k I))

2.3.2 The fixed-point theorem (3B) Definition 2.3.2 (3.4) We define two fixed point combinators (there are others):

(a) Y_{Curry} := λx.V V with V := λy.x (y y)

(b) Y_{Turing} := Z Z with Z := λz, x.x (z z x).

(c) If not denoted differently Y will in the following be Y_{Turing} (if (a) of the next theorem suffices, one can use Y_{Curry} as well).

Theorem 2.3.3 (a) Y_{Curry} x =_{β,w} x (Y_{Curry} x)

(b) Y_{Turing} x ⟶_{β,w}^{∗} x (Y_{Turing} x) Proof: Only (b): Let Y := Y_{Turing}.

Y x ≡ Z Z x ≡ (λz, x.x (z z x)) Z x
⟶_{β,w}^{∗} x (Z Z x)
≡  x (Y x)

Theorem 2.3.4 (3.3.1, 3.3.2)

(a) In both λ and CL, for any term Z (possibly containing the variables

x, y_{1}, …, y_{n} free) and n ≥ 0 there is a term X s. t.

Xy_{1} ⋯ y_{n} ⟶_{β,w}^{∗} Z[x := X] .

(b) In both λ and CL, for any k > 0, n > 0, terms Z_{0}, …, Z_{k−1} (possibly containing the variables x_{0}, …, x_{k−1}, , y_{1}, …, y_{n} free) there exists terms X_{i} s. t.

X_{i} y_{1} ⋯ y_{n} ⟶_{β,w}^{∗} Z_{i}[x_{0} := X_{0}, …, x_{k−1} := X_{k−1}]
(i = 0, …, k − 1) .

(c) In both λ and CL, for any terms X, Y there exists P, Q s. t.

P ⟶_{β,w} X P Q Q =_{β,w} Y P Q 2.3. THE FIXED POINT AND QUASI-LEFTMOST-REDUCTION THEOREM (3B, 3D)45

Proof: (a):

X := Y (λx, y_{1}, …, y_{n}.Z) .
X y_{1} ⋯ y_{n}  ≡  Y (λx, y_{1}, …, y_{n}.Z)y_{1} ⋯ y_{n}
⟶_{β,w}^{∗} (λx, y_{1}, …, y_{n}.Z) X y_{1}, …, y_{n}
⟶_{β,w}^{∗} Z[x := X]

(b) We prove first the following Lemma:

Lemma 2.3.5 (2.26)

(a) There exists a pairing combinator p and corresponding projections p_{i} (i =

0, 1) s. t.

p_{i} (p x_{0} x_{1}) ⟶_{β,w}^{∗} x_{i} (i = 0, 1) .

(b) For every n ≥ 1 there exists sequence combinators p^{n} and corresponding projections p_{i}^{n} (i = 0, …, n − 1) s. t.

p_{i} (p_{i}^{n} x_{0} x_{1} ⋯ x_{n}) ⟶_{β,w}^{∗} x_{i} (i = 0, , …, n − 1) .

Proof: (a):

p := λx, y, z.z x y
p_{i} := λu.u(λx_{0}, x_{1}.x_{i})

Then

p_{i} (p x_{0} x_{1})  ≡  p_{i}((λx, y, z.z x y) x_{0} x_{1})
⟶_{β,w}^{∗} p_{i}(λz.z x_{0} x_{1})
≡  (λu.u (λx_{0}, x_{1}.x_{i})) (λz.z x_{0} x_{1})
⟶_{β,w}^{∗} (λz.z x_{0} x_{1}) (λx_{0}, x_{1}.x_{i})
⟶_{β,w}^{∗} (λx_{0}, x_{1}.x_{i}) x_{0} x_{1}
⟶_{β,w}^{∗} x_{i}

(b): Induction on n: n = 1: p^{1} := p_{0}^{1} := I. n ⟶ n + 1:

p^{n+1} := λx_{1}, …, x_{n+1}.p (p^{n} x_{1}, …, x_{n}) x_{n+1}
p_{i}^{n+1} := λu.p_{i}^{n} (p_{0} u) (i = 0, …, n − 1)
p_{n}^{n+1} := p_{1}

Proof of part (b) of Theorem 2.3.4:

Let

y⃗ := y_{1}, …, y_{k} ,
Z′_{i}  := Z_{i}[x_{0} := λy⃗.p_{0}^{k} (x y⃗), …, x_{k−1} := λy⃗.p_{k−1}^{k} (x y⃗)]
Z  := p^{k} Z′_{0} ⋯ Z′_{k−1}

X chosen according to 2.3.4 (a) s. t.

X y⃗ ⟶_{β,w} Z[x := X] ,
X_{i}  := λy⃗.p_{i}^{k}(X y⃗)

then

X_{i} y⃗ ≡ p_{i}^{k} (X y⃗)
⟶_{β,w}^{∗} p_{i}^{k} (Z[x := X])
⟶_{β,w}^{∗} Z′_{i}[x := X]
≡  Z_{i}[x_{0} := λy⃗.p_{0}^{k} (X y⃗), …, x_{k−1} := λy⃗.p_{k−1}^{k} (X y⃗)]
≡  Z_{i}[x_{0} := X_{0}, …, x_{k−1} := X_{k−1}]

Proof of part (c) of Theorem 2.3.4: Let in 2.3.4 (b) n := k := 2, Z_{i} := y_{i} (x_{0} y_{1} y_{2}) (x_{1} y_{1} y_{2}). Let X_{1}, X_{2} s. t.

X_{i} y_{1} y_{2} ⟶_{β,w} Z_{i}[x_{0} := X_{0}, x_{1} := X_{1}]

Let P := X_{0} X Y, Q := X_{1} X Y. Then

P ⟶_{β,w} Z_{0}[x_{0} := X, x_{1} := Y, y_{1} := X, y_{2} := Y]
≡  X (X_{0} X Y) (X_{1} X Y)
≡  X P Q

similarly

Q ⟶_{β_{w}} Y P Q

2.3.3 The quasi-leftmost-reduction theorem (3D)

The Quasi-leftmost reduction theorem will not be shown in this lecture. The only proof we could find is quite complicated, but we assume that using the new techniques available a simpler proof can be given.

Definition 2.3.6 (approx. 3.17, 3.18)

(a) We define N ⟶_{l,β} M and N ⟶_{l,w} M, where we write N ⟶_{l,β,w} M for either N ⟶_{l,β} M (in the case of λ-calculus) or N ⟶_{l,w} M (in the case of combinatory logic) and pronounce this expression as N leftmost weakly reduces/β-reduces to M, inductively by:

• k N M ⟶_{l,w} N;

• s N M P ⟶_{l,w} (N P) (M P);

• (λx.M) N ⟶_{l,β} M[x := N]; • If M ⟶_{l,β} N, then λx.M ⟶_{l,β} λx.N.

• If M ⟶_{l,β,w} N, M not of the form λx.P, k P, s P Q, then M R ⟶_{l,β,w} N R.

• If M ⟶_{l,β,w} N, R in normal form and not of the form λx.P, k P, s P Q, then R M ⟶_{l,β,w} R N.

So N ⟶_{l,β,w} M means, that the leftmost maximal redex in N is reduced in the reduction of N to M.

(b) N ⟶_{l,β,w}^{+} M : ⇔∃N′N ⟶_{β,w}^{∗} N′ ⟶_{l,β,w} M.

(c) A quasi-leftmost reduction of a term X is

• either a finite sequence (X_{1}, …, X_{n}) s. t.

X ≡ X_{1} ⟶_{l,β,w}^{+} X_{2} ⟶_{l,β,w}^{+} ⋯ ⟶_{l,β,w}^{+} X_{n}

and X_{n} is normal or

• an infinite sequence X_{1}, X_{2} ⋯ s. t.

X ≡ X_{1} ⟶_{l,β,w}^{+} X_{2} ⟶_{l,β,w}^{+} ⋯

Theorem 2.3.7 (Quasi-leftmost-reduction theorem 3.19, 3.19.1)

(a) In both λ-calculus and combinatory logic, if X has a normal form X^{∗}, then every quasi-leftmost reduction of X is finite and terminates at X^{∗}.

(b) In both λ-calculus and combinatory logic, X has no normal form iff some quasi-leftmost reduction of X is infinite.

Proof:

(b) follows directly by (a). (a) will not be proved.

2.4 Representing the recursive functions (4)

Notation 2.4.1 (a) The notation as in 2.3.1 apply to this section as well.

(b) i, j, k, m, n denote natural numbers.

Definition 2.4.2 (a) X^{0} Y := Y, X^{n+1} Y := X(X^{n} Y)

(or X^{n} Y = \underbrace{X(X(⋯ (X}_{n times} Y) ⋯)

(b) A partial function n-ary function on the natural numbers is a function ℕ^{n} ⟶ ℕ ∪ {⊥}, where ⊥ is a symbol for undefined. Abbreviations like f(n⃗) ↓, f(\underline{n}) ↑, f(\underline{n}) ≃ m are as usual. For terms t we define, whether it is defined, and for two terms s, t, whether s ≃ t, as usual (where for being defined we require that all sub-terms are defined, even if they are not needed in the computation of the whole term).

(c) If not defined differently let in the following ⟨X, Y ⟩ := p X Y, X0 := p_{0} x, X1 := p_{1} x.

Definition 2.4.3 (Church numerals, 4.2)

N_{n} := \underline{n} := λx, y.x^{n} y

(in Combinatory logic ≡ (s B)^{n} (k I)) .

\underline{n} is called the nth Church numeral or the Church numeral representing n

Therefore we have

\underline{n} F X ⟶_{β,w} F^{n} X .

There are other representations of the natural numbers. Proof of the above equality by induction on n:

\underline{0} ≡ λx, y.y
≡ λx.I
≡ k I
\underline{n + 1} ≡ λx, y.x (x^{n} y)
≡ λx.s (k x) (λy.x^{n} y)
≡ s (λx.s (k x)) (λx, y.x^{n} y)
≡ s (s (k s) k) \underline{n}
≡ (s B) (s B)^{n} (k I)
≡ (s B)^{n+1} (k I)

Definition 2.4.4 (4.4)

(a) Let f be an n-ary partial function. We say a λ-term X λ-defines or a CLterm combinatorially defines (or if talking about λ- or CL-terms a term defines) f iff for all m_{1}, …, m_{n} it holds

• f(m_{1}, …, m_{n}) ↓ iff X \underline{m_{1}} ⋯ \underline{m_{n}} has a normal form;

• If f(m_{1}, …, m_{n}) ↓ then

X \underline{m_{1}} ⋯ \underline{m_{n}} =_{β,w} \underline{f(m_{1}, …, m_{n})} .

Lemma 2.4.5 (a) A term defines at most one function.

(b) If a λ-term or CL-term defines f, then f is partial recursive.

Proof: (a): The Church numerals are in normal form and pairwise not α-equivalent. Since all normal forms of a term are (α)-equivalent and every term in normal form that is w/β-equivalent to a term is a normal form of it, it follows that the function is uniquely defined.

(b) Let X^{∗,n} be defined by

X^{∗,0} := X X^{∗,n+1} := (X^{∗,n})^{∗}

From Lemma 2.1.17 (h) and (i) it follows that if M is a normal form of a term N, then N ≡ M^{∗,k} for some k and for all l > k M^{∗,l} = M^{∗,k}. M^{∗,k} is primitive recursive in (a code for the) term M and k. Further we can determine from a term, which is a α-equivalent to a Church numeral the number it represents in a primitive recursive way (for instance since lgh(\underline{n}) = n · a + b for some global constant a, b) and of course a (code for

a) \underline{n} is primitive recursive in n. Therefore if N defines f we can compute f as follows: For input m_{1}, …, m_{n}, let U := N\underline{m_{1}} ⋯ \underline{m_{n}}. Evaluate U^{∗,k} until for some k U^{∗,k} ≡ U^{∗,k+1} (which is primitive recursively decidable). If this doesn’t happen, f(m_{1}, …, m_{n}) is undefined and the procedure doesn’t terminate. If there is some k, then U^{∗,k} is α-equivalent to a Church numeral \underline{n}. Determine n which is the result f(n_{1}, …, n_{k}). The above procedure can now be written as a partial recursive function, which determines f(n_{1}, …, n_{k}) on input n_{1}, …, n_{k}.

Next steps:We will show that every recursive function can be defined by a λ-term and a CL-term. We will first show that all primitive recursive functions can be defined in such a way.

Lemma 2.4.6 (a) The successor function can be defined by Ŝ := λu, x, y.x (u x y) (in CL this is ≡ s B). Ŝ is a combinator in normal form.

(b) \underline{0} is defined by \underline{0} (or k I), which is a combinator in normal form.

(c) The function f(n_{1}, …, n_{k}) = n_{i} is defined by λx_{1}, …, x_{k}.x_{i}, which is a combinator in normal form.

(d) If the n-ary functions g_{i} are defined by terms ĝ_{i}, the k-ary function h defined by ĥ and f(m⃗) = h(g_{1}(m⃗), …, g_{m}(m⃗)), then f is defined by f̂:= λx⃗.ĥ(ĝ_{1} x⃗) ⋯ (ĝ_{m} x⃗). If ĥ, ĝ_{i} are combinators in normal form, so is f̂.

(e) There is a combinator R s. t.

R X Y \underline{0} =_{β,w} X ,
R X Y \underline{k + 1} =_{β,w} Y \underline{k} (R X Y \underline{k}) .

R can be chosen as a combinator in normal form.

(f) Every primitive recursive function can be defined by a combinator f̂ in normal form.

Proof:

(a) In λ-calculus

Ŝ \underline{n} ⟶_{β}^{∗} λx, y.x (\underline{n} x y) ⟶_{β}^{∗} λx, y.x (x^{n} y) ≡ \underline{S(n)}

In CL

Ŝ \underline{n} ≡ (s B) (s B)^{n} (k I) ≡ (s B)^{S(n)} .

(b) - (d) Trivial.

(e) First step: For every term Y there exists a term Z_{Y} s. t.

∀n ∈ ℕ.Z_{Y} ⟨\underline{n}, x⟩ =_{β,w} ⟨\underline{n + 1}, (Y \underline{n} x)⟩ :

Define

Z_{Y} := λx.⟨Ŝ (x0), Y (x0) (x1)⟩ .

By ⟨x_{0}, x_{1}⟩i =_{β,w} x_{i} it follows the assertion. Second Step: Define

U_{X,Y} := λx.x Z_{Y} ⟨\underline{0}, X⟩

Then

U_{X,Y} \underline{0} =_{β,w} ⟨\underline{0}, X⟩
U_{X,Y} \underline{n + 1} =_{β,w} ⟨\underline{n}, Y \underline{n} ((U_{X,Y} \underline{n})1)⟩

The first assertion is clear, the second assertion follows by induction on n:

U_{X,Y} \underline{1} =_{β,w} Z_{Y} ⟨\underline{0}, X⟩
=_{β,w} ⟨\underline{1}, Y \underline{0} X⟩
=_{β,w} ⟨\underline{1}, Y \underline{0} ((U_{X,Y} \underline{0})1)⟩
U_{X,Y} \underline{n + 2} =_{β,w} Z_{Y}^{n+2} ⟨\underline{0}, X⟩
=_{β,w} Z_{Y} (Z_{Y}^{n+1} ⟨\underline{0}, X⟩)
=_{β,w} Z_{Y} (U_{X,Y} \underline{n + 1})
=_{β,w} Z_{Y} ⟨\underline{n + 1}, Y \underline{n} X⟩
=_{β,w} Z_{Y} ⟨\underline{n + 1}, (U_{X,Y} (\underline{n + 1})1)⟩
=_{β,w} ⟨\underline{n + 2}, Y \underline{n + 1} ((U_{X,Y} \underline{n + 1})1)⟩

Third Step:

R := λx, y, u.(U_{x,y} u)1

Then

R X Y \underline{0} =_{β,w} X
R X Y \underline{n + 1} =_{β,w} (U_{X,Y} \underline{n + 1})1
= ⟨\underline{n + 1}, Y \underline{n} ((U_{X,Y} \underline{n})1)⟩1
= ⟨\underline{n + 1}, Y \underline{n} (R X Y \underline{n})⟩1
= Y \underline{n} (R X Y \underline{n})

R is not in normal form, but one sees immediately that he reduces to a normal form. (f): All cases except of primitive recursion follow directly by (a) - (e). Case primitive recursion: Assume

f(n⃗, 0) = g(n⃗) f(n⃗, m + 1) = h(n⃗, m, f(n⃗, m))

Let ĝ, ĥ terms (in normal form) defining g, h.

f̂:= λx⃗.R (ĝ x⃗) (λu, v.ĥ x⃗ u v)

By induction on m follows

f̂(\underline{n_{1}}, …, \underline{n_{m}}, \underline{m}) =_{β,w} \underline{f(n_{1}, …, n_{m}, m)} .

Now we will show that all partial recursive functions can be defined by a normal combinator.

Lemma 2.4.7 (a) There exists a combinator E in normal form s. t.

E X Y \underline{0} =_{β,w} X ,
E X Y \underline{n + 1} =_{β,w} Y .

We write if x then y else z for E y z x.

(b) There exists a combinator μ̂ in normal form s. t.

μ̂ X Y =_{β,w} Y
if X Y =_{β,w} \underline{0} ,
μ̂ X Y =_{β,w} P X (Ŝ Y)
if X Y =_{β,w} \underline{n + 1} .

Especially we have therefore, if f̂ represents the unary function f,

μy ≥ n(f(y) = 0) ↓ ⇒μ̂ f̂ \underline{n} =_{β,w} \underline{μy ≥ n(f(y) = 0)} .

Proof:

(a) E := λx, y, z.z (k y) x.

E X Y \underline{0} ≡ \underline{0} (k Y) X
=_{β,w} (λx, y.y) (k Y) X ,
=_{β,w} X ,
E X Y \underline{n + 1} ≡ \underline{n + 1} (k Y) X
=_{β,w} (k Y)^{n+1} X
=_{β,w} Y .

(b) Define

T_{X} := λy. if y then (λu, v.v) else λu, v.u (X (Ŝ v)) u (Ŝ v)

Then we get

T_{X} (X Y) T_{X} Y =_{β,w} (λu, v.v) T_{X} Y
=_{β,w} Y
(if X Y =_{β,w} \underline{0}) ,
T_{X} (X Y) T_{X} Y =_{β,w} (λu, v.u (X (Ŝ v)) u (Ŝ v)) T_{X} Y
=_{β,w} T_{X} (X (Ŝ Y)) T_{X} (Ŝ Y)
(if X Y =_{β,w} \underline{n + 1}) .

Let

μ̂ := λx, y.T_{x} (x y) T_{x} y

Then μ̂ fulfills the equations of the assertion.

Next step: We will show that every total recursive function can be defined by a term:

Lemma 2.4.8 (Kleene, 4.15). Every recursive total function f can be defined by a combinator f̂.

Note that f̂ is an overloaded notation, since we introduced it as a term representing a primitive recursive function and a term defining a recursive function (and will define it as a term defining a partial-recursive function) and these definitions do not coincide. However this will not cause problems since later we need just one term defining a function, independently of how it is exactly defined.

Proof: By the Kleene normal form, f can be written as (with m⃗ := m_{1}, …, m_{n})

f(m⃗) = h(μk.g(m⃗, k) = 0) ,

where h and g are primitive recursive. Let in the following x⃗ = x_{1}, …, x_{n}, X⃗ := X_{1}, …, X_{n}. Let

N :≡ λx⃗, y.μ̂ (ĝ x⃗) y

Then

N X⃗ Y =_{β,w} μ̂ (ĝ X⃗) Y
=_{β,w} \begin{cases}Y & if ĝ X⃗ Y =_{β,w} \underline{0} , \\ N X⃗ (Ŝ Y) & if ĝ X⃗ Y =_{β,w} \underline{n + 1} . \end{cases}

Now

f̂:= λx⃗.\underline{h}(N x⃗ \underline{0}) .

Remark: The book claims that f̂ is in normal form, without giving a proof, but by saying that the proof is boring. The result is probably true here, but only because f is total and requires not (as said in the book) a boring but quite a sophisticated proof. Probably one needs to show that the terms defining the primitive recursive functions can be typed in the system F (this type system is not treated in this course), in the sense that if f is n-ary then f̂ is of type nat^{n} ⟶ nat, where nat = ∀α.(α ⟶ α) ⟶ α ⟶ α. Now one needs to show that N x⃗ \underline{0} can be assigned the type nat. Whether this is the case and exactly in which sense I don’t know, and it can only work, if f is total, since otherwise for suitable \underline{n} N \underline{n} \underline{0} does not normalize. If it can be done then f̂ can be typed as well and is therefore normalizing, so such an argument does not work for the term defined in the proof of the next theorem.

Theorem 2.4.9 In both λ-calculus and combinatory logic every partial-recursive function f can be defined by a combinator \underline{f} in normal form.

From the proof of Lemma 2.4.8 we obtain as well for partial recursive functions f a term f̂ s. t. if f(m⃗) is defined, then

f̂\underline{m} =_{β,w} \underline{f(m⃗)}

However, from this it does not follow that if f(m⃗) is undefined, f̂\underline{m} does not normalize. We will modify the definition given there in order to obtain a term which has the second property as well.

Proof: As before write f as

f(m⃗) ≃ h(μk.g(m⃗, k) = 0) ,

where h and g are primitive recursive. Let F be the term we obtained in 2.4.8 as f̂,

F :≡ λx⃗.ĥ(N x⃗ \underline{0}) .

Define

f̂:= λx⃗.((μ̂ (ĝ x⃗) \underline{0}) I (F x⃗) .

Assume m⃗ s. t. f(m⃗) is defined. Therefore there exists minimal j s. t. g(m⃗, j) = 0, and f(m⃗) = h(j). Then

f̂ ; \underline{m⃗} =_{β,w} \underline{j} I (F \underline{m⃗})
=_{β,w} I^{j}(F \underline{m⃗})
=_{β,w} F \underline{m⃗}
=_{β,w} \underline{f(m⃗)}

Assume now f(m⃗) ↑. Let p_{k} := g(m⃗, k) − 1. Since g(m⃗, k) > 0, g(m⃗, k) = p_{k} + 1. Define

X := ĝ \underline{m⃗}, G := F \underline{m⃗}
∀k.X \underline{k} =_{β,w} \underline{p_{k} + 1}

by Church-Rosser and since the Church-numerals are in normal form it follows

∀k.X \underline{k} ⟶_{β,w} \underline{p_{k} + 1}

We show f̂\underline{m⃗} has no normal form by giving an infinite quasi-left-most reduction and using Theorem 2.3.7 (b).

f̂ ; \underline{m⃗} ⟶_{β,w}^{∗} (μ̂ X \underline{0}) I G
⟶_{β,w}^{∗} (T_{X} (X \underline{0}) T_{X} \underline{0}) I G
⟶_{β,w}^{∗} (T_{X} (\underline{p_{0} + 1}) T_{X} \underline{0}) I G
⟶_{β,w}^{∗} (μ̂ X \underline{1}) I G
⟶_{β,w}^{∗} (T_{X} (X \underline{1}) T_{X} \underline{1}) I G

⟶_{β,w}^{∗} (T_{X} (\underline{p_{1} + 1}) T_{X} \underline{1}) I G
⟶_{β,w}^{∗} ⋯
X\underline{i} ⟶ \underline{p_{i} + 1}

must contain one left-most-reduction (otherwise the left most redex in X remains unchanged contradicting that \underline{p_{i} + 1} is in normal form, and therefore

(T_{X} (X \underline{1}) T_{X} \underline{1}) I G ⟶_{β,w}^{∗} (T_{X} (\underline{p_{1} + 1}) T_{X} \underline{1}) I G

must include one left-most reduction. Therefore the above sequence is an infinite quasi-left-most reduction. Remark \underline{f} is not normalizing in λ-calculus. Let g(m⃗) = 1. ĝx⃗ ⟶_{β,w} \underline{1} and with almost the same sequence as in the proof (replace f̂\underline{m⃗} by f̂ and everywhere \underline{m⃗} by x⃗) we get an infinite quasi-leftmost-reduction of f̂ (but not in combinatory logic, because the reduction will be “after the λ”).

2.5 The undecidablity theorem (5)

Notation 2.5.1 (5.1)

(a) Relative to earlier versions of this scriptum we have made the following changes:

• A term representing a (primitive recursive, recursive or partial recursive) function f will now be denoted by f̂.

• Therefore the standard term representing the successor function is therefore denoted by Ŝ.

• The function ℕ ∋ n ↦ \underline{n} will now be denoted by N (and the term representing it therefore N̂).

• We write μ̂ instead of P since

μy ≥ n(f(y) = 0) ↓ ⇒μ̂ f̂ \underline{n} =_{β,w} \underline{μy ≥ n(f(y) = 0)} .

(b) Again the notation as in 2.3.1 apply to this section as well.

(c) We assume some coding ⌜M⌝ of (λ- or CL-) terms s. t.

• there is a recursive (total) function ∘ s. t. ∘(⌜M⌝, ⌜N⌝) = ⌜M N⌝ and

• the function N : ℕ ∋ n ↦ ⌜\underline{n}⌝ is recursive.

(Of course both functions can be chosen primitive recursive).

(d) Let for A a set of terms

⌜A⌝ := {⌜M⌝ | M ∈ A} .

Note that this is the image of the function λx.⌜x⌝ to the set A, therefore it is a set and not a natural number.

Remark 2.5.2 In the book ⌜X⌝ is the Church numeral corresponding to the Gödelnumber of X. We write it as \underline{⌜X⌝}.

We can with almost no effort obtain the following undecidability theorem, which will then be generalized in Theorem 2.5.5.

Theorem 2.5.3 (a) Both =_{β} and =_{w} are undecidable.

(b) It is undecidable whether a term has a normal form.

Proof:

(a) Let the unary partial recursive function f be defined by

f(e) :≃ \begin{cases}0 & if \{e\}(e) ↓, \\ ⊥ & otherwise. \end{cases}

Let f̂ be a term defining f. Then

f̂ \underline{e} =_{β,w} \underline{0}⇔\{e\}(e) ↓ ,

so, if =_{β,w} were decidable, one could decide for e ∈ ℕ, whether {e}(e) ↓, which is undecidable. (b): For the same f̂

f̂ \underline{e} has a normal form⇔\{e\}(e) ↓ .

Definition 2.5.4 (5.4, 5.5)

(a) Assume A, B ⊆ ℕ. A, B are called recursively separable iff there is a recursive set C s. t. A ⊆ C, B ∩ C = ∅.

A, B are recursively inseparable, iff they are not recursively separable.

(b) A set of A of terms is closed under equality iff for all terms X, Y

(X ∈ A ∧ X =_{β,w} Y)⇒Y ∈ A .

The following theorem is a variant of the generalization of Rice’s theorem^{1}, which states that if A, B are disjoint nontrivial sets of recursive functions then the sets {e | {e} ∈ A} and {e | {e} ∈ B} are recursively inseparable. The proof is almost identical to the proof of that variant, which is more or less identical to the proof of the standard version of Rice’s theorem.

Theorem 2.5.5 (5.6, Scott-Curry undecidability theorem) For both λ-terms and β-equality and CL-terms and weak equality it holds: Assume A, B are sets of terms, s. t.

1We think that this variant is called as well Rice’s theorem, although we could not find this version in text books.

56 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

• A, B are closed under equality,

• A ∩ B = ∅,

• A ≠ ∅ ≠ B, then

⌜A⌝, ⌜B⌝ are recursively inseparable .

Proof: Assume ⌜A⌝, ⌜B⌝ can be recursively separated. Let

• ⌜A⌝ ⊆ C,

• C ∩ ⌜B⌝ = ∅,

• C a recursive subset of ℕ,

• f(x) = \begin{cases}1 & x ∈ C, \\ 0 & x ∉ C, \end{cases}

• f̂ define f. Therefore we have

X ∈ A ⇒ f̂ \underline{⌜X⌝} =_{β,w} \underline{1}
X ∈ B ⇒ f̂ \underline{⌜X⌝} =_{β,w} \underline{0}

Let ˆ∘, N̂ define the functions ∘, N, i.e.

ˆ∘ \underline{⌜M⌝} \underline{⌜N⌝} =_{β,w} \underline{⌜M N⌝}
N̂ \underline{n} =_{β,w} \underline{⌜\underline{n}⌝}

Let A ∈ A, B ∈ B. We will define a term J s. t.

J =_{β,w}if (f̂ \underline{⌜J⌝}) then A else B .

Then we have

f̂ \underline{⌜J⌝} =_{β,w} \underline{1} ⇒ J =_{β,w} B ⇒ J ∈ B
⇒ f̂ \underline{⌜J⌝} =_{β,w} \underline{0}
f̂ \underline{⌜J⌝} =_{β,w} \underline{0} ⇒ J =_{β,w} A ⇒ J ∈ A
⇒ f̂ \underline{⌜J⌝} =_{β,w} \underline{1}

Since f(\underline{⌜J⌝}) ∈ \{0, 1\},

f̂ \underline{⌜J⌝} =_{β,w} \underline{0} ∨ f̂ \underline{⌜J⌝} =_{β,w} \underline{1} ,

\underline{0} =_{β,w} \underline{1}

2.6. THE FORMAL THEORIES λβ AND CL_{W} (6A) 57

contradicting that \underline{0} and \underline{1} are in normal form and not ≡. We have to define J. We would like to use the fixed point theorem 2.3.4 (a), but it cannot be applied, since the term on the right side depends on ⌜J⌝, not on J. Instead we prove the following fixed point lemma, from which with

X := λy. if (f̂ y) then A else B

the existence of J follows.

Lemma 2.5.6 (Barendregt, 5.9.(c)) For every (λ- or CL-)term X there exists a term J s. t.

J =_{β,w} X \underline{⌜J⌝} .

Proof: Define

M := λy.X (ˆ∘ y (N̂ y))
J := M \underline{⌜M⌝}

Then

J =_{β,w} X (ˆ∘ \underline{⌜M⌝} (N̂ \underline{⌜M⌝}))
=_{β,w} X (ˆ∘ \underline{⌜M⌝} \underline{⌜\underline{⌜M⌝}⌝})
=_{β,w} X \underline{⌜M \underline{⌜M⌝}⌝}
≡ X \underline{⌜J⌝} .

Corollary 2.5.7 (5.6.1) If A is a set of λ- or CL-terms closed under =_{β,w}, and neither A nor its complement are nonempty, then A is non-recursive

Proof: Let B be the complement of A.

Theorem 2.5.3 follows from Corollary 2.5.7 now as a corollary:

• If =_{β,w} were decidable, then for a term N the set A := {M | M =_{β,w} N} would be a non-trivial recursive set closed under =_{β,w} contradicting Corollary 2.5.7.

• The set of terms with normal form is a non-trivial set closed under =_{β,w}, therefore non-recursive.

2.6 The formal theories λβ and CL_{w} (6A)

2.6.1 Definition of the theories (6A)

We will now introduce formal theories, which derive the relations ⟶_{β}, ⟶_{w}, =_{β}, =_{w}. These more abstract notions will allow us to define more easily extensions of these notions by e.g. extensional concepts.

58 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

Definition 2.6.1 (6.1)

(a) A formal theory I is a pair (F, R) s. t. • F is a set, the elements of it are called formulas,

• R is a set of pairs (Γ; A), where Γ is a set of formulas (i.e. Γ ⊆ F)

and A is a formula i.e. A ∈ F) As usual

• Γ, Δ denote in the following (possibly infinite) subsets of F,

• Γ, A := Γ ∪ {A},

• A_{1}, …, A_{n} := {A_{1}, …, A_{n}}. We will denote a rule (A_{1}, , …, A_{n}; A) by

\frac{A_{1} ⋯ A_{n}}{A}

(b) A rule (∅; F) of a formal theory is called an axiom, and will be denoted by F. We usually define theories by defining the set of formulas, the set of axioms and then the set of rules which are not axioms.

(c) If I = (F, R) we define for F ∈ F, Δ ⊆ F inductively

I, Δ⊢F or shorter Δ⊢_{I}F or sometimes even shorter Δ⊢F by:

• F ∈ Δ⇒Δ⊢_{I}F.

• If – (Γ; A) ∈ R,

– for all G ∈ Γ we have Δ⊢_{I}G, then Δ⊢_{I}A.

B if a theorem of I : ⇔I⊢B : ⇔⊢_{I}B : ⇔∅⊢_{I}B .

Definition 2.6.2 (6.2) The formal theory of β-equality in short λβ is defined as follows:

• Formulas:

Equations M = N for λ-terms M, N.

• Axioms: For all variables x, y and λ-terms M, N

(α) λx.M = λy.(M[x := y]) if y ∉ FV(M)
(β) (λx.M) N = M[x := N]
(ρ) M = M

2.6. THE FORMAL THEORIES λβ AND CL_{W} (6A) 59

• Rules:

(μ) \frac{M = M′}{N M = N M′} (τ) \frac{M = N N = P}{M = P}
(ν) \frac{M = M′}{M N = M′ N} (σ) \frac{M = N}{N = M}
(ξ) \frac{M = M′}{λx.M = λx.M′}

We write

λβ⊢M = N

for M = N provable in the above theory. (The names (α), (β) , … are from Curry and Feys, [CF58]). Definition 2.6.3 (6.3) The formal theory of β-reduction in short λβ (from the context it will be clear whether Definition 2.6.2 or 2.6.3 is meant) is defined as before, but with = replaced by ⟶ and omitting the rule (σ). For convenience we spell it out:

• Formulas:

M ⟶ N, where M, N are λ-terms .

• Axioms: For all variables x, y and λ-terms M, N

(α) λx.M ⟶ λy.(M[x :⟶ y]) if y ∉ FV(M)
(β) (λx.M) N ⟶ M[x :⟶ N]
(ρ) M ⟶ M

• Rules:

\begin{matrix}(μ) & \frac{M ⟶ M′}{N M ⟶ N M′} & (τ) & \frac{M ⟶ N N ⟶ P}{M ⟶ P} \\ (ν) & \frac{M ⟶ M′}{M N ⟶ M′ N} & (ξ) & \frac{M ⟶ M′}{λx.M ⟶ λx.M′} \end{matrix}

We write

λβ⊢M ⟶ N

for M ⟶ N provable in the above theory. Lemma 2.6.4 (6.4)

(a) M ⟶_{β}^{∗} N⇔λβ⊢M ⟶ N.

(b) M =_{β} N⇔λβ⊢M = N. Proof: Straightforward Definition 2.6.5 (6.5) The formal theory of weak equality in short CL_{w} is defined as follows:

• Formulas:

Equations M = N for CL-terms M, N.

• Axioms: For all CL-terms M, N

\begin{matrix}(k) & k M N = M. \\ (s) & s M N P = M P (N P). \\ (ρ) & M = M. \end{matrix}

• Rules:

\begin{matrix}(μ) & \frac{M = M′}{N M = N M′} & (τ) & \frac{M = N N = P}{M = P} \\ (ν) & \frac{M = M′}{M N = M′ N} & (σ) & \frac{M = N}{N = M} \end{matrix}

We write

CL_{w}⊢M = N

for M = N provable in the above theory.

Definition 2.6.6 (6.6) The formal theory of weak reduction in short CL_{w} (again from the context it will be clear whether Definition 2.6.5 or 2.6.6 is meant) is defined as before, but with = replaced by ⟶ and omitting the rule (σ). For convenience we spell it out:

• Formulas:

M ⟶ N, where M, N are λ-terms .

• Axioms: For all CL-terms M, N

\begin{matrix}(k) & k M N ⟶ M. \\ (s) & s M N P ⟶ M P (N P). \\ (ρ) & M ⟶ M. \end{matrix}

• Rules:

\begin{matrix}(μ) & \frac{M ⟶ M′}{N M ⟶ N M′} & (τ) & \frac{M ⟶ N N ⟶ P}{M ⟶ P} \\ (ν) & \frac{M ⟶ M′}{M N ⟶ M′ N} & (σ) & \frac{M ⟶ N}{N ⟶ M} \end{matrix}

We write

CL_{w}⊢M ⟶ N

for M ⟶ N provable in the above theory.

Lemma 2.6.7 (6.7)

(a) M ⟶_{w}^{∗} N⇔CL_{w}⊢M ⟶ N.

(b) M =_{w} N⇔CL_{w}⊢M = N.

Proof: Straightforward

Remark 2.6.8 (6.8) By the Church-Rosser theorem and Lemmata 2.6.4 and 2.6.7 it follows that λβ and CL_{w} are consistent, i.e. not all formulas are provable.

2.6.2 First order theories and derivable rules (6B)

Definition 2.6.9 (6.9)

(a) A first order theory is a pair (L, R), where

• L is a language, i.e. a collection of n-ary function and relation symbols; the set of terms and formulas is then defined as usual (w.r.t. the usual connectives of classical predicate calculus; = is always included unless mentioned)

• R is a set of rules given as before w.r.t. the set of formulas just defined

Axioms are then defined as before, and derivability in this theory means derivability in the formal theory given by:

• Formulas are the formulas in the language L.

• Rules are

– The rules in R.

– The rules of classical predicate calculus with equality axioms are rules of the formal theory.

(b) We might change the underlying logic as well, where a logic consists of:

• A set of n-ary connectives

• A set of quantifiers.

• The set of formulas of a first order language L w.r.t the above connectives and quantifiers is then defined as:

– Prime formulas of L in the usual sense are formulas.

– If A_{1}, …, A_{n} are formulas, ∘ an n-ary connective, then ∘(A_{1}, …, A_{n}) is a formula

– If A is a formula, Q a quantifier, x a variable, then Qx.A is a formula

• A set of rules w.r.t. the above set of formulas.

In this case a first order theory consists of:

• A language L defined as before.

• A logic.

• Rules as before w.r.t. the set of formulas in L w.r.t. the language L.

The Formulas of a language L w.r.t. a logic are the formulas of L w.r.t. the connectives and quantifiers of the logic.

Derivability etc. is now the straightforward generalization of part (a) of this definition.

There are lots of more generalizations possible (e.g. a sorted language, more generalized quantifiers).

Definition 2.6.10 (6.11) The theory CL_{w}^{+} is the theory in classical predicate calculus given by:

• Language: Two constants k, s and one binary function symbol Ap. We write (M N) instead of Ap(M, N), and identify terms with their corresponding CL-terms. No relation symbols (except of equality).

• Logic: Classical logic with equality axioms.

• Axioms:

∀x.y.(k x y = x)
∀x.y, z.(s x y z = x z (y z))
¬(s = k)

Lemma 2.6.11 (6.12) CL_{w}^{+} is a conservative extension of CL_{w}, i.e. provable equations of CL_{w}^{+} and CL_{w} coincide.

Proof: One first verifies easily that every equation provable in CL_{w} is provable as well in CL_{w}^{+}. On the other hand, we can see that the set of open CL-terms with

Ap(N, M) := N M ,

k, s interpreted by themselves and equality defined as =_{w} is a model M of CL_{w}^{+}. Further, we have that for every term N of the language of CL_{w}^{+}, N^{∗}[ξ] is the result of replacing x_{i} by ξ(x_{i}) and of replacing Ap(N, M) by N M. Especially, if ξ(x) = x, N^{∗}[ξ] is the CL-term we identify N with. Therefore we get for CL-terms N, M, with N′, M′ being the corresponding terms in CL_{w}^{+},

N′^{∗}[ξ] ≡ N, M′^{∗}[ξ] ≡ M ,

and

CL_{w}^{+}⊢N′ = M′

2.6. THE FORMAL THEORIES λβ AND CL_{W} (6A) 63

⇒ M ⊧ (N′ = M′)[ξ]
⇔ N′^{∗}[ξ] =_{w} M′^{∗}[ξ]
⇔ N =_{w} M
⇔ CL_{w}⊢N = M .

Definition 2.6.12 (6.13)

(a) A rule

\frac{A_{1} ⋯ A_{n}}{A}

of a formal theory is derivable in a theory I, if

A_{1}, …, A_{n}⊢_{I}A .

(b) A rule

\frac{A_{1} ⋯ A_{n}}{A}

of a formal theory is admissible in a theory I, if

(⊢_{I}A_{1} ∧ ⋯ ⊢_{I}A_{n})⇒⊢_{I}A

Lemma 2.6.13 (6.14)

(a) A rule R of a formal theory is admissible iff adding of R to the theory does not change the set of theorems.

(b) Derivable rules of a formal theory are admissible, but not vice-verca.

(c) If R is a derivable rule in a formal theory I, then R is derivable in any extension of I obtained by adding new rules.

Definition 2.6.14 (6.15) Let I, I′ be formal theories with the same set of formulas.

(a) I, I′ are theory-equivalent, iff every rule of I is admissible in I′ and vice verca.

(b) I, I′ are rule-equivalent, iff every rule of I is derivable in I′ and vice verca.

Lemma 2.6.15 (6.16) Two formal theories I, I′ with the same set of formulas are theorem equivalent iff they have the same set of theorems. Proof: trivial Definition 2.6.16 (6.17) If I is a formal theory and let some formulas be equations X = Y, X, Y terms according to some definition (usually clear from the context). Then the equality relation determined by I is called =_{I} and defined by

X =_{I} Y : ⇔⊢_{I}X = Y .

Lemma 2.6.17 (6.18) If I, I′ are formal theories with the same set of formulas and some equations be defined as in the previous definition. If I, I′ are theorem-equivalent, then =_{I} and =_{I′} coincide.

Proof: trivial.

2.7 Extensionality in λ-calculus (7)

2.7.1 Extensional equality

We usually treat equality as extensional: For two functions f, g

f = g⇔∀x.(f(x) = g(x)) .

In λβ, equality is not extensional but intensional.

f = g⇔f, g reduce to the same normal form .

For instance we have that y and λx.y x are extensional the same, but intensional different (they are both already in normal form).

Notation 2.7.1 (7.1) In this section, term means λ-term.

Definition 2.7.2 (7.1, 7.2)

(a) The following are possible additional rules, which can be added to λβ

(ext) \frac{M P = N P (for all terms P)}{M = N}
(ω) \frac{M P = N P (for all closed terms P)}{M = N}
(ζ) \frac{M x = N x}{M = N}  if x ∉ FV(M N)
(η) λx.M x = M  if x ∉ FV(M)

Note that the first two rules have infinitely many premises.

(b) The following 4 formal theories are extensions of λβ by the following rules

λβ + (ext) add (ext);
λβω  add (ω);
λβζ  add (ζ);
λβη  add (η);

2.7. EXTENSIONALITY IN λ-CALCULUS (7) 65

We will focus on (ext), (ζ), (η). (ext) is admissible in (ω) but the converse does not hold See [HS86].

Theorem 2.7.3 (7.4). λβ + (ext), λβζ, λβη are rule-equivalent (therefore as well theorem-equivalent).

Proof:

• (ext) is trivially derivable in λβζ.

• (ζ) is derivable in λβη: If M x = N x, x ∉ FV(M N), then

M = λx.M x = λx.N x = N .

• (η) is provable in λβ + (ext): (λx.M x)P = M P for all P, therefore ⊢_{λβ+(ext)}λx.M x = M.

Definition 2.7.4 (7.5) =_{βη} is the equality relation determined by λβη:

M =_{βη} N⇔⊢_{λβη}M = N

2.7.2 λβη-reduction (7B)

Definition 2.7.5 (7.6. - 7.9)

(a) ⟶_{η} is defined as ⟶_{β}, but based on λx.M x ⟶ M instead of (λx.M) N ⟶ M[x := N]. ⟶_{η}^{∗}, ⟶_{η,l} etc. are defined similarly

(b) ⟶_{βη}^{∗} is the transitive closure of ⟶_{β} ∪ ⟶_{η} ∪ ≡_{α}. Similarly we define ⟶_{lβη}.

(c) βη-normal forms are defined as β-normal forms, but w.r.t. ⟶_{β,η}^{∗}.

(d) The formal theory λβη of βη-reduction is the extension of the formal theory of β-reduction by

(η) λx.M x ⟶ M if x ∉ FV(M N)

Lemma 2.7.6

P ⟶_{β,η}^{∗} Q⇔λβη⊢P ⟶ Q .

Lemma 2.7.7 (7.11; Substitution lemma for βη-reduction) Assume P ⟶_{βη}^{∗} Q.

(a) FV(Q) ⊆ FV(P).

(b) M[x := P] ⟶_{βη}^{∗} M[x := Q].

(c) P [x := N] ⟶_{βη}^{∗} Q[x := N].

66 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

Proof: As usual, in (c) note, that If P ≡ λy.Q y, y ∉ FV(Q), then (λy.(Q y))[x := N] ⟶_{β,η} Q[x := N] .

Theorem 2.7.8 (7.12, Church-Rosser theorem for βη-reduction) If P ⟶_{βη} M, P ⟶_{βη} N, then there exists T such that M ⟶_{βη}^{∗} T, N ⟶_{βη}^{∗} T. Proof: Extend Takahashis proof. Note that, whether we reduce (λx.N x) M by an η-contraction or a β-reduction we obtain the same result. This is reflected by the precise definition of the extension of the definition of M^{∗}.

2.7.3 The postponent theorem (7.13 - 7.14) We will prove the following two theorems. Theorem 2.7.9 (7.13) A λ-term has a βη-normal form iff it has a β-normal form. Theorem 2.7.10 (Postponent-theorem, 7.14) If M ⟶_{β,η}^{∗} N then there exists some P s. t. M ⟶_{β}^{∗} P ⟶_{η}^{∗} N. We follow Takahashi [Tak95]. Definition 2.7.11 ([Tak95] 3.1) The parallel η-reduction, denoted by ⟹_{η} is defined inductively defined as

• a ⟹_{η} a, if a is an atom.

• If v ∉ Var(M) ∪ Var(M′), M[x := v] ⟹_{η} M′[y := v], then λx.M ⟹_{η} λy.M′.

• If M ⟹_{η} M′, N ⟹_{η} N′, then M N ⟹_{η} M′ N′.

• If M ⟹_{η} M′, z ∉ FV(M), then λz.M z ⟹_{η} M′. Lemma 2.7.12 (a) M ⟹_{η} M.

(b) M ⟹_{η} M′, v ∉ Var(M) ∪ Var(M′), then M[x := v] ⟹_{η} M′[x := v].

(c) If M ≡_{α} M′ ⟹_{η} N′ ≡_{α} N, then M ⟹_{η} N.

(d) If M ⟹_{η} M′, then M[x := N] ⟹_{η} M′[x := N].

(e) If M ⟶_{η} M′, then M ⟹_{η} M′.

(f) If M ⟹_{η} M′, then M ⟶_{η}^{∗} M′.

(g) If M ⟹_{η} M′, N ⟹_{η} N′, then M[y := N] ⟹_{η} M′[y := N′].

(h) ⟶_{η}^{∗} is the transitive closure of ⟹_{η}.

Definition 2.7.13 (a) We define M ⊳_{k} N (M is the k-fold η-expansion of N) by

• M ⊳_{0} M.

• M ⊳_{k+1} N iff M ≡ λz.M′ z for some M′ s. t. z ∉ FV(M′), M′ ⊳_{k} M.

(b) M ⊳ N iff M ⊳_{k} N for some k.

Lemma 2.7.14 ([Tak95] 3.2)

(a) M ⟹_{η} x iff M ⊳ x.

(b) M ⟹_{η} N_{1} N_{2} iff M ⊳ M_{1} M_{2} for some M_{i} s. t. M_{i} ⟹_{η} N_{i}.

(c) M ⟹_{η} λx.N iff M ⊳ (λy.M′) for some M′ s. t. for some z ∉ Var(M′) ∪ Var(N) M′[y := z] ⟹_{η} N[x := z].

Proof: (a): “⇒” Induction on M ⟹_{η} x. Case M ≡ x. Trivial. Case M ≡ λz.M′ z, z ∉ FV(M′), M′ ⟹_{η} x. By IH M′ ⊳_{k} x some k, M ⊳_{k+1} x. “⇐” trivial. (b), (c): similarly.

Lemma 2.7.15 ([Tak95] 3.3) Assume M ⟹_{β} M′, N ⟹_{β} N′, k ≥ 0.

(a) If M_{k} ⊳_{k} λx.M, then M_{k} ⟹_{β} λu.M′[x := u].

(b) If M_{k} ⊳_{k} λx.M, then M_{k} N ⟹_{β} M′[x := N′].

(c) If M_{k} ⊳_{k} M, then M_{k} N ⟹_{β} M′ N′.

Proof: Proof by induction on k. k = 0 is trivial. k ⟶ k + 1: (a), (b): Let

M_{k+1} ≡ λz.M_{k} z ,
M_{k} ⊳_{k} λx.M .

(a): By IH

M_{k} ⟹_{β} λu.M′[x := u] ,

Therefore

M_{k} v⇒M′[x := v] ,

(v fresh), therefore

M_{k+1} = λz.M_{k} z⇒λu.M′[x := u] .

(b) By IH (c) M_{k} u ⟹_{β} M′ u for some fresh u,

N ⟹_{β} N′ .
(M_{k} z)[z := u] ≡ M_{k} u ⟹_{β} M′ u ,

therefore

M_{k+1} N ⟹_{β} (M′ u)[u := N′] ≡ M′ N′ .

(c) Let

M_{k+1} = λz.M_{k} z M_{k} ⊳_{k} M , z ∉ FV(M_{k}) .

By IH

M_{k} u ⟹_{β} M′ u ,

therefore

M_{k+1} N ≡ (λz.M_{k} z) N ⟹_{β} (M′ u)[u := N′] ≡ M′ N′ .

Lemma 2.7.16 ([Tak95] 3.4)

M ⟹_{η} P ⟹_{β} N

implies

M ⟹_{β} P′ ⟹_{η} N

for some P′

Proof: Induction on P ⟹_{β} N. Case P an atom, P ≡ N. Trivial. Case

P ≡ λx.P_{1}, N ≡ λy.N_{1}, P_{1}[x := u] ⟹_{β} N_{1}[y := u] .

Then M ⊳ λz.M_{1} s. t.

M_{1}[z := v] ⟹_{η} P_{1}[x := v] .

W.l.o.g. v ≡ u. By IH

M_{1}[z := u] ⟹_{β} P′_{1} ⟹_{η} N_{1}[y := u]

for some P′_{1}.

M_{1}[z := u] ⟹_{β} P′_{1} M ⊳ λz.M_{1}
M_{1} ⟹_{β} P′_{1}[u := z]

therefore

M ⟹_{β} λu.P′_{1} ⟹_{η} λy.N_{1} ≡ N

Case P ≡ P_{1} P_{2}, N ≡ N_{1} N_{2}, P_{i} ⟹_{β} N_{i}. Then

M ⊳ M_{1} M_{2}

s. t. M_{i} ⟹_{η} P_{i}. By IH

M_{i} ⟹_{β} P′_{i} ⟹_{η} N_{i} .

therefore for some P_{3} s. t. P_{3} ⊳ P′_{1} P′_{2} we have

M ⟹_{β} P_{3} ⟹_{η} P′_{1} P′_{2} ⟹_{η} N

Case P ≡ (λx.P_{1}) P_{2}, P_{i} ⟹_{β} N_{i}, N ≡ N_{1}[x := N_{2}]. Then

M ⊳_{k} M′_{1} M_{2}, M′_{1} ⊳ λu.M_{1}

for some k, M_{i} s. t.

M_{2} ⟹_{η} P_{2} M_{1}[u := v] ⟹_{η} P_{1}[x := v] .

By IH

M_{2} ⟹_{β} P′_{2} ⟹_{η} N_{2} ,
M_{1}[u := v] ⟹_{β} P′_{1} ⟹_{η} N_{1}[x := v] .

Now

M′_{1} M_{2} ⟹_{β} P′_{1}[v := P′_{2}] ⟹_{η} N_{1}[x := N_{2}] ,

and for some P_{3} ⊳_{k} P′_{1}[v := P′_{2}] we get

M ⟹_{β} P_{3} ⟹_{η} P′_{1}[v := P′_{2}] ⟹_{η} N_{1}[x := N_{2}] .

Proof of Theorem 2.7.10: By Lemma 2.7.16, since ⟹_{β}, ⟹_{η} are the transitive closures of ⟶_{β}, ⟶_{η}.

Lemma 2.7.17 ([Tak95] 3.6, 3.7) Assume P ⟹_{η} Q.

(a) If P is in β-normal form, so is Q.

(b) If Q has a β-normal form, so has P.

Proof: In this proof normal form means β-normalform.

(a) Induction on P: Case P is atom:

P ≡ Q .

Case P ≡ λx.P′: Subcase Q ≡ λx.Q′, P′ ⟹_{η} Q′. P′ in normal form, by IH therefore Q′, therefore Q as well. Subcase

P′ ≡ P′′ x, x ∉ FV(P′′), P′′ ⟹_{η} Q .

P′′ is in normal form, by IH Q as well. Case P ≡ P_{1} P_{2}. Then

Q ≡ Q_{1} Q_{2}, P_{i} ⟹_{η} Q_{i} .

By IH Q_{i} in normal form, P_{1} is no application therefore Q_{1} neither, Q in normal form.

(b) By 2.7.16 it suffices to show the assertion for Q in normal form. We show:

P ⟹_{η} Q, Q in normal form ⇒ P has a normal form P^{∗} s. t.
P not an application ⇒ P^{∗} ⊳ N for some N s. t.

N is not an application:

Induction on Q: Case Q an atom: P ≡ Q. Case Q ≡ λx.Q′. Then

P ⊳ λx.P′ P′ ⟹_{η} Q′

Q is in normalform, therefore as well Q′, P′ has normal form P′′, P′ ⟹_{β}^{∗} P′′, therefore

P ⟹_{β}^{∗} λx.P′′ .

Case Q ≡ Q_{1} Q_{2}. Then Q_{1} is not an application.

P ⊳ P_{1} P_{2}, P_{i} ⟹_{η} Q_{i}

By IH P_{i} have normal form P_{i}^{∗}, P_{1}^{∗} ⊳ N_{1} where N_{1} not an application, and for some P′, P′′ s. t.

P′ ⊳ P_{1}^{∗} P_{2}^{∗}
P′′ ⊳ N P_{2}

we get

P ⟹_{β}^{∗} P′ ⟹_{β}^{∗} P′′ ,

P′′ in normal form.

Proof of Theorem 2.7.9. Assume N has βη-normal form M. Then

N ⟹_{β}^{∗} N′ ⟹_{η}^{∗} M .

M is in β-normal form, so N′ has β-normal form. Assume N has β-normal form N′. Since in every η-step, the length of a term is reduced, there is a N′′ s. t. N′′ has no η-redex and

N′ ⟹_{η}^{∗} N′′ .

N′ is in β-normal form, by Lemma 2.7.17 (a) as well N′′, therefore N′′ is in βη normal form.

2.8 Extensionality in combinatory logic

2.8.1 Extensional equality

Notation 2.8.1 (8.1) In this section, “term” means “CL-term”.

Definition 2.8.2 (8.1, 8.2)

(a) The following are possible additional rules, which can be added to CL_{w}

(ext) \frac{M P = N P (for all terms P)}{M = N}
(ζ) \frac{M x = N x}{M = N}  if x ∉ FV(M N)
(ξ) \frac{M = N}{λ^{∗}x.M = λ^{∗}x.N}

(η) λ^{∗}x.M x = M  if x ∉ FV(M)

((ω) will not be treated here;

(η) allows only to derive new equations, if we replace the definition of λ^{∗} by a different definition (see below) since with our definition for x ∉ FV(M)

λ^{∗}x.M x ≡ M ,

Note that the first two rules have infinitely many premises.

(b) The following 4 formal theories are extensions of CL_{w} by the following rules

CL + (ext) add (ext);
CL_{ζ}  add (ζ);
CL_{ξ}  add (ξ);

CL_{w} extended by (η) alone will not be treated because that is identical with CL_{w}.

72 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

Theorem 2.8.3 (8.4, 8.7).

(a) CL + (ext) and CL_{ζ} are theorem-equivalent.

(b) CL_{ζ} and CL_{ξ} are rule-equivalent and therefore as well theorem-equivalent. Remark CL + (ext) and CL_{ζ} are not rule-equivalent. (Consider e.g. k x = s x. From it it is probably not possible to prove in CL + (ext) that k = s, but in CL_{ζ} this is an instance of a rule. However to show

¬(k x = s x⊢_{CL+(ext)}k = s)

is probably not easy. Proof of Theorem 2.8.3:

• (ext) is trivially derivable in CL_{ζ}.

• (ζ) is admissible in CL + (ext):

Show that, if CL + (ext)⊢M = N, then

CL + (ext) ⊢ M[x_{1} := K_{1}, …, x_{n} := K_{n}] =

N[x_{1} := K_{1}, …, x_{n} := K_{n}]

by induction on the derivation.

We write [x⃗ := K⃗] for

[x_{1} := K_{1}, …, x_{n} := K_{n}] .

– If the last rule is a rule in CL this is clear.

– Case last rule (ext): Assume

M P = N P for all terms P

If we naively apply the IH to the premise of that rule we get

M[x⃗ := K⃗] P [x⃗ := K⃗] = N[x⃗ := K⃗] P [x⃗ := K⃗]

for all P which does not suffice to prove by using (ext).

M[x⃗ := K⃗] = N[x⃗ := K⃗] .

So we have to rename the variables in P appropriately. Let P be a term. Let x_{i}^{∗} be distinct variables s. t.

x_{i}^{∗} ∉ FV(M N P K_{1} ⋯ K_{n} x_{1} ⋯ x_{n})

P^{∗} := P [x_{1} := x_{1}^{∗}, …, x_{n} := x_{n}^{∗}] .

Write [x⃗ := x^{∗}] for [x := x_{1}^{∗}, …, x_{n} := x_{n}^{∗}]. Then

P^{∗}[x⃗ := K⃗, x^{∗} := x⃗] ≡ P ,

M[x⃗ := K⃗, x^{∗} := x⃗] ≡ M[x⃗ := K⃗] ,
N[x⃗ := K⃗, x^{∗} := x⃗] ≡ N[x⃗ := K⃗] ,

We have

CL + (ext)⊢M P^{∗} = N P^{∗}

therefore by IH

CL + (ext) ⊢ (M P^{∗})[x⃗ := K⃗, x^{∗} := x⃗]
= (N P^{∗})[x⃗ := K⃗, x^{∗} := x⃗] ,

therefore

CL + (ext)⊢M[x⃗ := K⃗] P = N[x⃗ := K⃗] P

and, since P was arbitrary, therfore by (ext)

CL + (ext)⊢M[x⃗ := K⃗] = N[x⃗ := K⃗]

Now if CL + (ext) proves M x = N x, x ∉ FV(M N), then it proves (substitute for x P)

M P = N P

for all P and therefore M = N, (ζ) is admissible in CL + (ext).

– (ζ) is derivable in (ξ): Assume M x = N x, x ∉ FV(M N), and show in CL_{ξ} M = N: By (ξ)

λ^{∗}x.M x = λ^{∗}x.N x ,

by definition

M ≡ λ^{∗}x.M x
N ≡ λ^{∗}x.N x

therefore M = N.

– (ξ) is derivable in (ζ): Assume M = N, and show in CL_{ζ} λx^{∗}M = λx^{∗}.N: Now

x ∉ FV(λ^{∗}x.M)(λ^{∗}x.N) ,

and

(λ^{∗}x.M) x = M = N = (λ^{∗}x.N) x

by ζ therefore

λ^{∗}x.M = λ^{∗}x.N .

Definition 2.8.4 (8.5) =_{cβη} is the equality relation determined by CL + (ext):

M =_{cβη} N⇔⊢_{CL+(ext)}M = N Remark 2.8.5 (8.6, 8.8)

(a) In combinatory logic we have trivially η and the rule which makes combinatory logic extensional is the ξ-rule.

(b) If we defined λ^{∗}x.M by not having the special case λ^{∗}x.M x := M if x ∉ FV(M), then we would get Theorem 2.8.3 (a), but in 2.8.3 (b) only: CL + (ζ) and CL + (ξ) + (η) are rule-equivalent.

2.8.2 An axiomatisation of extensionality by finitely many equations

(ζ) and (ξ) are difficult to handle:

• For verifying extensional equality using the (ζ)-rule, we need to need to test whether some subterm P of a term M, applied to a fresh variable x, is equal to another term of the form P′ x, in order to replace now using (ζ) P by P′, where the equation P x =_{c,ζ} P′ x might have a long derivation, so might not follow by only a one step reduction or expansion.

• For verifying extensional equality using the (ξ)-rule, we need to test, whether there is a subterm of a given term which is of the form λ^{∗}x.P, in order to replace it by λ^{∗}x.P′ for some other term P′ which is equal to P. This is decidable, but still complicated to check.

We will in the following develop an axiomatization of extensional equality in the form of finitely many equations of the form M = N. Then, one needs to verify only, whether a subterm of a given term is of the form of the left or right side of one of these equations in order to replace it by the other side. However, unless we have for a corresponding reduction we have Church-Rosser this will not provide us with an easy procedure for determining whether two terms are equal – we might need to expand a term first to apply one of the equations. The book does not treat how to derive a reduction system from these axioms, which is Church Rosser. (However the extension of the →_{w} by the (ξ) is Church Rosser, see [HS86], 9.16). However, it seems that the best way of checking equality of combinator terms is by translating them into λ-terms and test whether they are βη-equal. The interest of the following axioms is more theoretical. We will derive this axiomatization in 3 steps. In each step we will consider extensions of CL by finitely many equations as axioms.

Definition 2.8.6 A finite extension CL_{ax} of CL is the extension of CL by finitely many equations M_{i} = N_{i} as axioms.

Step 1: We have

λ^{∗}x.M N ≡ s (λ^{∗}x.M) (λ^{∗}x.N)

in case x ∈ FV(M N), N ≢ x ∨ x ∈ FV(N). If we replace λ^{∗} by λ, the above equation holds for λ-terms with ≡ replaced by =.

We will later show that extensional λ-calculus and combinatory logic prove the same equations w.r.t. this translation, so we want that in our proposed finite extension CL_{ax} of CL

CL_{ax}⊢λ^{∗}x.M N = s (λ^{∗}x.M) (λ^{∗}x.N) ,

which would then reduce proofs by induction over the form of λ^{∗}x.N only to cases N ≡ P Q and N an atom only.

Lemma 2.8.7 (8.10) Assume CL_{ax} is a finite extension of CL. Assume CL_{ax} proves

(Ax1) λ^{∗}x, y.s (k x) (k y) = λ^{∗}x, y.k (x y)
(Ax2)  λ^{∗}x.s (k x) I =  λ^{∗}x.x

Then for all M, N, x

CL_{ax}⊢λ^{∗}x.M N = s (λ^{∗}x.M) (λ^{∗}x.N) .

Proof: If x ∈ FV(M N) and x ∈ FV(M) ∨ N ≢ x,

λ^{∗}x.M N ≡ s (λ^{∗}x.M) (λ^{∗}x.N) .

In all other cases we will look at the above equation from left to right. Case x ∉ FV(M N):

s (λ^{∗}x.M) (λ^{∗}x.N) ≡ s (k M) (k N)
=_{w} (λ^{∗}x, y.s (k x) (k y)) M N
{Ax 1 \atop =} (λ^{∗}x, y.k (x y)) M N
=_{w} k (M N)
≡ λ^{∗}x.M N

Case x ∉ FV(M), N ≡ x.

s (λ^{∗}x.M) (λ^{∗}x.N) ≡ s (k M) I
=_{w} (λ^{∗}x.s (k x) I) M
{Ax 2 \atop =} (λ^{∗}x.x) M
=_{w} M
≡ λ^{∗}x.M N

Step 2 We want a finite extension CL_{ax} of CL s. t.

CL_{ax}⊢M = N⇒CL_{ax}⊢λ^{∗}x.M = λ^{∗}x.N .

If we have (Ax1), (Ax2) above fulfilled, the case where M, N is not an outermost redex reduces to subterms of M, N. The difficult case is when M, is a redex, i.e. we need to find a finite extension CL_{ax} s. t.

(1) CL_{ax} ⊢ λ^{∗}x.k M N = λ^{∗}x.M
(2) CL_{ax} ⊢ λ^{∗}x.s M N P = λ^{∗}x.(M P) (N P)

Now, if CL_{ax} proves (Ax1) (Ax2), then the left and right side of (1), (2) are, with

M^{∗} := λ^{∗}x.M
N^{∗} := λ^{∗}x.N
P^{∗} := λ^{∗}x.P

provable in CL_{ax} equal to

(1a)  λ^{∗}x.k M N {Lemma 2.8.7 \atop =} s (λ^{∗}x.k M) N^{∗}
{Lemma 2.8.7 \atop =} s (s (k k) M^{∗}) N^{∗}
(1b)  λ^{∗}x.M  ≡  M^{∗}
(2a)  λ^{∗}x.s M N P {Lemma 2.8.7 \atop =} s (λ^{∗}x.s M N) P^{∗}
{Lemma 2.8.7 \atop =} s (s (λ^{∗}x.s M) N^{∗}) P^{∗}
{Lemma 2.8.7 \atop =} s (s (s (k s) M^{∗}) N^{∗}) P^{∗}
(2b) λ^{∗}x.M P (N P) {Lemma 2.8.7 \atop =} s (λ^{∗}x.M P) (λ^{∗}x.N P)
{Lemma 2.8.7 \atop =} s (s M^{∗} P^{∗}) (s N^{∗} P^{∗})

Therefore, if CL_{ax} proves that the righthandsides of (1a), (1b) and of (2a), (2b) are equal, then (1), (2) follow. Now we just axiomatize this condition and get the following Lemma

Lemma 2.8.8 (8.11) Assume CL_{ax} is a finite extension of CL. Assume CL_{ax} proves (Ax1), (Ax2) from Lemma 2.8.8 and

(Ax3) λ^{∗}x, y.s (s (k k) x) y = λ^{∗}x, y.x
(Ax4) λ^{∗}x, y, z.s (s (s (k s) x) y) z =
λ^{∗}x, y, z.s (s x z) (s y z)

Then for all M, N, P, x

(1) CL_{ax} ⊢ λ^{∗}x.k M N = λ^{∗}x.M
(2) CL_{ax} ⊢ λ^{∗}x.s M N P = λ^{∗}x.(M P) (N P)

Proof: By the above and

(λ^{∗}x.Q) R = Q[x := R] .

Definition 2.8.9 (8.12)

(a) The combinatory βη-axioms are

(β − ax1) λ^{∗}x, y.s (k x) (k y) = λ^{∗}x, y.k (x y)
(β − ax2) λ^{∗}x.s (k x) I = λ^{∗}x.x
(β − ax3) λ^{∗}x, y.s (s (k k) x) y = λ^{∗}x, y.x
(β − ax4) λ^{∗}x, y, z.s (s (s (k s) x) y) z =
λ^{∗}x, y, z.s (s x z) (s y z)

Note that this axioms expand to purely combinatorial equations, which do not contain λ^{∗} (especially they are closed).

(b) CL_{βηax} is the extension of CL by the above axioms.

Theorem 2.8.10 (8.13) CL_{βηax} is theorem equivalent to CL_{ξ}, CL_{ζ} and CL + ext. Especially, the equality determined by CL_{βηax} is =_{cβη}.

Proof: We show CL_{βηax} is theorem equivalent to CL_{ξ}. First all additional axioms of CL_{βηax} are provable in CL_{ξ}: Any of the additional axioms is of the form

λ^{∗}x_{1}, …, x_{n}.M = λ^{∗}x_{1}, …, x_{n}.N .

By ξ it can be derived in CL_{ξ}, if

M = N

can be derived. Now M and N are in all cases w.r.t. ⟶_{w} irreducible terms. However, we have

M ≡ λ^{∗}u.M u N ≡ λ^{∗}u.N u

for some new variable u, and by ξ it suffices to show

M u = N u .

Now in all cases M u and N u reduce with ⟶_{w} to the same normalform, therefore M u = N u is provable in CL and the axiom is provable in CL_{ξ}. Verification of this:

(β − ax1)  s (k x) (k y) u = k x u (k y u)
= x y
= k (x y) u
(β − ax2)  s (k x) I u = k x u (I u)
= x u
(β − ax3)  s (s (k k) x) y u = s (k k) x u (y u)
= k k u (x u) (y u)
= k (x u) (y u)
= x u
(β − ax4) s (s (s (k s) x) y) z u = s (s (k s) x) y u (z u)
= s (k s) x u (y u) (z u)
= k s u (x u) (y u) (z u)
= s (x u) (y u) (z u)
= x u (z u) ((y u) (z u))
= s x z u (s y z u)
= s (s x z) (s y z) u .

For the other direction we show that (ξ) is admissible in CL_{βηax}, i.e.

CL_{βηax}⊢M = M′⇒CL_{βηax}⊢λ^{∗}x.M = λ^{∗}x.M′

by induction on the derivation of

CL_{βηax}⊢M = M′ .

Case: axiom (k) or (s): Lemma 2.8.8. Case: (ρ), i.e. M ≡ M′: trivial. Case: transitivity (τ) or symmetry (σ): by IH, (τ), (σ). Case: (μ), (ν). So assume

M ≡ N Q
M′ ≡ N′ Q′
CL_{βηax} ⊢ N = N′
CL_{βηax} ⊢ Q = Q′

(where in fact either N ≡ N′ or Q ≡ Q′). Then by IH (or the rule (ρ))

CL_{βηax} ⊢ λ^{∗}x.N = λ^{∗}x.N′
CL_{βηax} ⊢ λ^{∗}x.Q = λ^{∗}x.Q′

By Lemma 2.8.7 CL_{βηax} proves

λ^{∗}x.N Q = s (λ^{∗}x.N) (λ^{∗}x.Q)
= s (λ^{∗}x.N′) (λ^{∗}x.Q′)
= λ^{∗}x.N′ Q′ .

2.8.3 βη-strong reduction

Definition 2.8.11 (8.16)

(a) The formal theory of βη-strong reduction is obtained from the theory CL_{w} of weak reduction by replacing ⟶_{w} by ⟶_{s} and adding the rule

(ξ) \frac{M ⟶_{s} N}{λ^{∗}x.M ⟶_{s} λ^{∗}x.N} .

(b)

M ⟶_{s} N : ⇔CL_{w}⊢M ⟶_{s} N .

Theorem 2.8.12 (8.17)

(a) ⟶_{s} is transitive and reflexive.

(b) P ⟶_{s} Q⇒FV(Q) ⊆ FV(P).

(c) P ⟶_{s} Q⇒M[x := P] ⟶_{s} M[x := Q].

(d) P ⟶_{s} Q⇒P [x := N] ⟶_{s} Q[x := N].

(e) (Church-Rosser)

If P ⟶_{s} M, P ⟶_{s} N, then there exists T such that M ⟶_{s}^{∗} T, N ⟶_{s}^{∗} T.

Proof: (a) - (d) are easy. (e) can be proved in the next section, by translating combinatory logic into λ-calculus, using Church-Rosser there and then translating it back again.

Remark: ⟶_{s} does not behave very nicely: I is not in normal form: We have

s k ≡ λ^{∗}x, y.s k x y
⟶_{s}^{∗} λ^{∗}x, y.k y(x y)
⟶_{s}^{∗} λ^{∗}x, y.y
≡ k I

therefore

I ≡ s k k ⟶_{s}^{∗} k I k ,
I ⟶_{s}^{∗} k I k ⟶_{s}^{∗} k (k I k) k ⟶_{s}^{∗} k (k (k I k) k) k ⟶_{s}^{∗} ⋯

In order to get reduction which behaves better, one can add I as a constant (not a defined combinator) together with the reduction rule

I x ⟶_{s} x .

And when adding axioms I x = x, I x ⟶_{s} x, we get the same lemmata as before. But still, ⟶_{s} does not behave well, especially, when a term is in normal form is relatively complicated.

Definition 2.8.13 (3.7) Strong normal forms. The class of strong nomral forms or terms in strong normal form is inductively defined by

• If n ≥ 0, M_{1}, …, M_{n} are in strong normal form, a an atom which is not

s, k, then

a M_{1} ⋯ M_{n} is in strong normal form.

• If M is in strong normal form so is λ^{∗}x.M.

Definition 2.8.14 (8.19) A CL-term M has a strong normal form M^{∗} iff M^{∗} is in strong normal form and

M ⟶_{s} M^{∗}

Lemma 2.8.15 (a) A term M has at most one strong normal form.

(b) If M^{∗} is in strong normal form, N =_{cβη} M^{∗}, then M^{∗} is the strong normal form of N.

(c) M^{∗} is the strong normal from of M iff M^{∗} is in strong normal form and

M =_{cβη} M^{∗}

Proof: (c) follows from (b). If we had I is an atom as above, every strong normal form would be irreducible and the lemma follows. Without it, one needs to go via translation into λ-calculus.

2.9 The correspondence between λ and CL (9)

2.9.1 The extensional equalities (9A, 9B)

Definition 2.9.1 (9.2) For CL-terms M, we define its λ-transformation M^{λ} by

x^{λ} := x ,
k^{λ} := λx, y.x
s^{λ} := λx, y, z.x z (y z) ,
(MN)^{λ} := M^{λ} N^{λ}

Remark 2.9.2 (9.3, 9.13)

(a) M ↦ M^{λ} is injective (modulo ≡), we even have

M ≢ N⇒M^{λ} ≢_{α} N^{λ} .

(b) FV(M^{λ}) = FV(M).

(c) (M[x := N])^{λ} ≡_{α} M^{λ}[x := N^{λ}]. .

(d) I^{λ} =_{β} λx.x.

(e) (λ^{∗}x.M)^{λ} =_{βη} λx.M^{λ}.

Proof: (a) - (c) are clear. (d):

I^{λ} ≡ s^{λ} k^{λ} k^{λ}
=_{β} λz.k^{λ} z (k^{λ} z)
=_{β} λz.z .

(e): Induction on M: Case M ≡ x:

(λx.x)^{λ} ≡ I^{λ}

2.9. THE CORRESPONDENCE BETWEEN λ AND CL (9) 81

=_{β} λx.x
≡ λx.x^{λ} .

Case x ∉ FV(M). Then x ∉ FV(M^{λ}).

(λ^{∗}x.M)^{λ} ≡ (k M)^{λ}
≡_{α} (λz, x.z) k^{λ} M^{λ}
=_{β} λx.M^{λ}

(Note that in the last line we used x ∉ FV(M^{λ}) in order to guarantee that the bounded variable x is not replaced by a new one). Case M ≡ N x, x ∉ FV(N).

(λ^{∗}x.M)^{λ} ≡ N^{λ}
=_{η} λx.N^{λ} x
≡ λx.M^{λ} .

Case otherwise, M ≡ P Q.

(λ^{∗}x.M) ≡ s^{λ} (λ^{∗}x.P)^{λ} (λ^{∗}x.Q)^{λ}
=_{β} λx.(λ^{∗}x.P)^{λ} x((λ^{∗}x.Q)^{λ} x)
{IH \atop =}_{β} λx.(λx.P^{λ}) x((λx.Q^{λ}) x)
=_{β} λx.P^{λ} Q^{λ}
≡ λx.M^{λ}

Definition 2.9.3 (9.7) For each λ-term we associate a CL-term M^{cη} by

x^{cη} := x .
(M N)^{cη} := M^{cη} N^{cη} .
(λx.M)^{cη} := λ^{∗}x.(M^{cη}) .

Lemma 2.9.4 (9.10)

(a) FV(M^{cη}) = FV(M).

(b) M ≡_{α} N⇒M^{cη} ≡ N^{cη}.

(c) (M[x := N])^{cη} ≡ M^{cη}[x := N^{cη}].

Proof: (a): easy. (b): Prove first simultaneously (a) and (c) for N a variable by induction on M. (c): easy, using (b).

Theorem 2.9.5 (9.8, 9.14b)

(a) (M^{λ})^{cη} ≡ M.

(b) (M^{cη})^{λ} =_{βη} M.

Proof:

(a) Induction on M: M ≡ x: trivial. M ≡ N P: by IH. M ≡ k:

(k^{λ})^{cη} ≡ (λx, y.x)^{cη}
≡ λ^{∗}x.λ^{∗}y.x
≡ λ^{∗}x.k x
≡ k .

M ≡ s:

(s^{λ})^{cη} ≡ (λx, y, z.x z (y z))^{cη}
≡ λ^{∗}x.λ^{∗}y.λ^{∗}z.x z (y z)
≡ λ^{∗}x.λ^{∗}y.s (λ^{∗}z.x z) (λ^{∗}z.y z)
≡ λ^{∗}x.λ^{∗}y.s x y
≡ λ^{∗}x.s x
≡ s .

(b) Induction on M: M variable: trivial. M ≡ P Q: IH. M ≡ λx.N:

(M^{cη})^{λ}  ≡  (λ^{∗}x.N^{cη})^{λ}
{2.9.2 (e) \atop =_{βη}} λx.(N^{cη})^{λ}
{IH \atop =_{βη}} λx.N

Lemma 2.9.6 (9.5)

(a)

M ⟶_{w}^{∗} N⇒M^{λ} ⟶_{β}^{∗} N^{λ} .

(b)

M =_{w}^{∗} N⇒M^{λ} =_{β} N^{λ} .

(c)

M =_{cβη} N⇒M^{λ} =_{βη} N^{λ} .

Proof: (a): It suffices to consider the case M ⟶_{w} N. Induction on M ⟶_{w} N. (b): by (a).

(c): Assume M =_{cβη} N. Then

CL_{ξ}⊢M^{λ} =_{βη} N^{λ} .

Induction on this derivation. Only difficult case (ξ): Assume λ^{∗}x.M = λ^{∗}x.N is derived from M = N By IH

M^{λ} =_{βη} N^{λ} ,

therefore by Remark 2.9.2 (e)

(λ^{∗}x.M)^{λ} =_{βη} λx.M^{λ} =_{βη} λx.N^{λ} =_{βλ} (λ^{∗}x.N)^{λ} .

Lemma 2.9.7 (9.11)

M =_{βη} N⇒M^{cη} =_{cβη} N^{cη} .

Proof: Suffices to consider M ⟶_{β} N, M ⟶_{η} N, M ≡_{α} N. Difficult cases: Case M ≡_{α} N: by the above lemma. Case M ≡ (λx.P) Q, N ≡ P [x := Q].

M^{cη} ≡ (λ^{∗}x.P^{cη}) Q^{cη}
=_{w} P^{cη}[x := Q^{cη}]
≡ (P [x := Q])^{cη}

Case M ≡ λx.P x, x ∉ FV(P), N ≡ P.

M^{cη} ≡ λ^{∗}x.P^{cη} x
≡ P^{cη}
≡ N^{cη}

Case M ≡ λx.M′, N ≡ λx.N′, N ⟶_{β} N′ or N ⟶_{η} N′. By IH N^{cη} =_{cη} N′^{cη}, therefore

M^{cη} ≡ λ^{∗}x.N^{cη}
=_{cη} λ^{∗}x.N′^{cη}
≡ M′^{cη}

Theorem 2.9.8 (9.12, 9.14)

(a) M =_{cβη} N⇔M^{λ} =_{βη} N^{λ}.

(b) M =_{βη} N⇔M^{cη} =_{cβη} N^{cη}.

Proof:

(a) “⇒” Lemma 2.9.6 (c). “⇐” If M^{λ} =_{βη} N^{λ} then

M {2.9.5 (a) \atop ≡_{α}} (M^{λ})^{cη} {2.9.7 \atop =_{β}} (N^{λ})^{cη} {2.9.5 (a) \atop ≡_{α}} N .

(b) “⇒” Lemma 2.9.7. “⇐” If M^{cη} =_{βη} N^{cη} then

M {2.9.5 (b) \atop ≡_{α}} (M^{cη})^{λ} {(a) \atop =_{β}} (N^{cη})^{λ} {2.9.5 (b) \atop ≡_{α}} N .

2.9.2 Combinatory β-equality (9C)

In this section in [HS86] the relationship between =_{β} and a combinatory version of it is studied. The main tool is to redefine λ^{∗}x.N by omitting the special case λ^{∗}x.N x ≡ N if x ∉ FV(N), which automatically makes λ^{∗}x.M preserve η-equality. Unfortunately, the equality on combinators which corresponds to β-equality is of similar complexity as the cβη equality. We omit the details. The interested reader might look at the book where most details (but not all) are carried out.

2.10 Models for CL_{w} (10)

2.10.1 Applicative structures (10A)

Notation 2.10.1 (10.1)

(a) In this section, term means CL-term (without constants apart from k, s).

(b) Var will be the set of variables used in the definition of CL-terms.

Definition 2.10.2 (10.2, 10.1)

(a) An applicative structure is a pair D = (D, ·), s.t.

• D is a set with at least two elements, called the domain of D and

• · : D × D→D.

(b) Let in this subsection (D, ·) be an applicative structure, and a, b, c, d, e denote (in this section) elements of D.

(c) We write · infix and omit parenthesis with the convention that · is associative to the left, i.e.

a · b · c · d := (((a · b) · c) · d) .

2.10. MODELS FOR CL_{W} (10) 85 (d) An assignment w.r.t. D (in [HS86] it is called valuation) is a function

ρ : Var→D .

(e) If ρ is an assignment w.r.t. (D, ·), x ∈ Var, a ∈ D then ρ_{x}^{a} is the assignment

defined by

ρ_{x}^{a}(y) := \begin{cases}a & if x ≡ y, \\ ρ(y) & if x ≢ y. \end{cases}

(f) If t is any expression depending on d_{1}, …, d_{n} ∈ D, let

λ\ d_{1}, …, d_{n} ∈ D.t

or (if D is clear from the context)

λ\ d_{1}, …, d_{n}.t

be the (set theoretic) function, which assigns to d_{1}, …, d_{n} ∈ D t. Definition 2.10.3 (10.3, 10.4)

(a) A function f : D^{n}→D (n ≥ 1) is representable in (D, ·) or, if · is clear

from the context, short representable in D, iff there exists an a ∈ D s. t.

∀d_{1}, …, d_{n} ∈ D.f(d_{1}, …, d_{n}) = a · d_{1} · d_{2} · · · · · d_{n} ,

in other words

f = λ\ d_{1}, …, d_{n} ∈ D.a · d_{1} · d_{2} · · · · · d_{n} .

In this case a is called a representative of f.

(b) (D^{n}→_{rep}D) is the set of n-ary representable functions in D.

(c) For a ∈ D, Fun(a) is the unary function represented by a i.e.

Fun(a) : D→D, Fun(a)(d) := a · d ,

in other words

Fun(a) = λ\ d ∈ D.a · d .

(d) For f : D→D let

Rep(f) := {a | Fun(a) = f} .

Definition 2.10.4 (10.5, 10.7)

(a) For a, b ∈ D, a is extensionally equivalent to b, (a ∼ b) iff Fun(a) = Fun(b).

(b) For a ∈ D the extensional equvivalence class containing of a, ã is defined

by

ã := {b ∈ D | b ∼ a} .

Further

D/ ∼:= {ã | a ∈ D} .

(c) (D, ·) is extensional iff

∀a, b ∈ D.(Fun(a) = Fun(b)→a = b) .

Lemma 2.10.5 (10.6 d, 10.8)

(a) Rep is a bijection from D→_{rep}D to D/ ∼.

(b) The following are equivalent:

(a) (D, ·) is extensional.

(b) ∀a ∈ D.ã is a singleton.

(c) ∀f ∈ D→_{rep}D.Rep(f) is a singleton.

(d) F un : D→(D→_{rep}D) is injective.

(e) F un : D→(D→_{rep}D) is bijective.

2.10.2 Combinatory algebras (10B) Definition 2.10.6 (a) A model of CL_{w} is a quadrupel

(D, ·, k^{D}, s^{D})

s. t.

• (D, ·) is an applicative structure,

• k^{D}, s^{D} ∈ D,

• ∀a, b ∈ D(k^{D} · a · b = a).

• ∀a, b, c ∈ D(s^{D} · a · b · c = a · c · (b · c)).

(b) A combinatorial algebra is an applicative structure (D, ·) s. t. for some

k^{D}, s^{D} ∈ D

(D, ·, k^{D}, s^{D}) is a model of CL_{w} .

(c) Let in this subsection (D, ·, k^{D}, s^{D}) be a model of CL_{w}.

Remark 2.10.7 (a) k^{D} ≠ s^{D}.

(b) In an extensional combinatory algebra k^{D}, s^{D} are uniquely defined.

2.10. MODELS FOR CL_{W} (10) 87 Proof: (a) Otherwise

k^{D} · k^{D} = k^{D} · k^{D} · k^{D} · k^{D}
= s^{D} · k^{D} · k^{D} · k^{D}
= k^{D} · k^{D} · (k^{D} · k^{D})
= k^{D}

and for a, b ∈ D s. t. a ≠ b

a = k^{D} · a · b
= k^{D} · k^{D} · a · b
= s^{D} · k^{D} · a · b
= k^{D} · b · (a · b) = b .

(b) The equations

∀a, b ∈ D . (k^{D} · a · b = a) ,
∀a, b, c ∈ D . (s^{D} · a · b · c = a · c · (b · c)) .

determine k^{D}, s^{D} uniquely by extensionality. Definition 2.10.8 (10.10, 10.13)

(a) Let D = (D, ·, k^{D}, s^{D}) be a model of CL_{w}. For assignments ρ and terms

N we define [[ N ]]_{ρ}^{D} ∈ D by • [[ x ]]_{ρ}^{D} := ρ(x).

• [[ k ]]_{ρ}^{D} := k^{D}.

• [[ s ]]_{ρ}^{D} := s^{D}.

• [[ M N ]]_{ρ}^{D} := [[ M ]]_{ρ}^{D} · [[ N ]]_{ρ}^{D}. If there is no confusion we write [[ M ]], [[ M ]]_{ρ} or [[ M ]]^{D} instead of [[ M ]]_{ρ}^{D}.

(b)

D ⊧ M = N[ρ] : ⇔ [[ M ]]_{ρ}^{D} = [[ N ]]_{ρ}^{D} ,
D ⊧ M = N : ⇔ ∀ρ assignment.D ⊧ M = N[ρ] .

(c) A combinatory βη-model or model of CL_{βη_{ax}} or Curry-algebra is a model of CL_{w} which fulfills the βη axioms (Definition 2.8.9).

Lemma 2.10.9 (10.11, 10.11.1, 10.12)

(a) If ∀x ∈ FV(M).ρ(x) = σ(x) then [[ M ]]_{ρ} = [[ M ]]_{σ}.

(b) If FV(M) = ∅, for all ρ, σ [[ M ]]_{ρ} = [[ M ]]_{σ}.

88 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

(c) [[ M[x := N] ]]_{ρ} = [[ M ]]_{ρ_{x}^{[ [ N ] ]_{ρ}}} Lemma 2.10.10 Each model of CL_{w} or CL_{βηax} fulfills all the provable equations of the corresponding theory. Proof: trivial. Definition 2.10.11 (a) Let T be CL_{w} or CL_{βηax}.

Define for each CL-term M [M] := {N CL-term| T ⊢M = N}. The term model of T, M(T), is

(D, ·, k, s)

with • D = {[M] | MCL-term }.

• [M] · [N] := [M N].

• k^{D} := [k].

• s^{D} := [s]. Note that the domain of the term model are equivalence classes of open terms. Theorem 2.10.12 (10.20) Let D := (D, ·, k^{D}, s^{D}) be the term model of T, T ∈ {CL_{w}, CL_{βηax}}.

(a) · is well-defined.

(b) D is a model of T.

(c) If • FV(M) = {x_{1}, …, x_{n}},

• ρ(x_{i}) = [N_{i}] (i = 1, …, n) then

[[ M ]]_{ρ}^{D} = [M[x_{1} := N_{1}, …, x_{n} := N_{n}]] .

The following theorem will fail for the λ-calculus: Theorem 2.10.13 (10.22, the Submodel theorem). Assume

• T ∈ {CL_{w}, CL_{βηax}},

• D := (D, ·, k, s) is a model of T.

• D′ ⊆ D, • D′ closed under ·, k^{D}, s^{D}, i.e.

– ·[D′ × D′] ⊆ D′ (i.e. ∀d, d′ ∈ D′.d · d′ ∈ D′),

– k^{D}, s^{D} ∈ D′.

Then the submodel of D given by D′, D ↾ D′ := (D′, · ↾ (D′ × D′), k^{D}, s^{D}) is a model of T as well.

Proof: D′ has two elements (k^{D}, s^{D}) and fulfills all the axioms and is closed under all the rules, since D is.

Definition 2.10.14 (10.23). The interior, written as D^{o}, of a model of T D = (D, ·, k^{D}, s^{D}) (T ∈ {CL_{w}, CL_{βηax}}) is D ↾ D^{o} with

D^{o} := {[[ M ]]^{D} | M closed }.

Lemma 2.10.15 D^{o} is the least submodel of D:

• D^{o} is a submodel of D and

• for every other submodel D′ = (D′, …) we have D^{o} ⊆ D′.

Proof: D^{0} is the least subset of D closed under k, s, ·.

Remark 2.10.16 (10.24). One sees immediately, that every extensional model of CL_{w} is a model of CL_{βηax}. However, there are non-extensional models of CL_{βηax}: Plotkin ([Plo74]) has constructed closed λ-terms M, N s. t.

• λβ + (ext)⊢M Q = N Q for all closed λ-terms Q, but

• λβ + (ext) ⊬M = N.

With M′ := M^{cη}, N′ := N^{cη} it follows

• CL_{βηax}⊢M′ Q = N′ Q for all closed CL-terms Q, but

• CL_{βηax} ⊬M′ = N′.

Now the interior D of the term model of CL_{βηax} has domain

D = {[M] | M closed CL − term} .

Therefore for all x ∈ D, x = [Q] for some closed term Q and therefore

[M′] · x = [M′] · [Q]
= [M′ Q] = [N′ Q]
= [N′] · [Q]
= [N′] · x ,

but

[M′] ≠ [N′] .

2.10.3 A more abstract definition of combinatory algebras (10.25 - 10.28)

Definition 2.10.17 (10.26, 10.27)

(a) A combination of variables x_{1}, …, x_{n} is a CL-term built from atoms x_{1}, …, x_{n} only (especially no atoms k, s!).

(b) For combinations M of x_{1}, …, x_{n}, assignments ρ and applicative structures D := (D, ·) we define [[ M ]]_{ρ}^{D} by:

• [[ x ]]_{ρ}^{D} := ρ(x).

• [[ M N ]]_{ρ}^{D} := [[ M ]]_{ρ}^{D} · [[ N ]]_{ρ}^{D}.

(c) An applicative structure D := (D, ·) is combinatorially complete iff for any sequence u, x_{1}, …, x_{n} of variables and every combination M of x_{1}, …, x_{n} the formula

∃u.∀x_{1}, …, x_{n}.u x_{1} ⋯ x_{n} = M

is true in D, which means

∃a ∈ D.∀d_{1}, …, d_{n} ∈ D.a · d_{1} · · · · · d_{n} = [[ M ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}} ,

in other words there exists a ∈ D which represents

λ\ d_{1}, …, d_{n} ∈ D.[[ M ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}} .

Theorem 2.10.18 (10.28, combinatory completeness theorem. An applicative structure (D, ·) is combinatory complete iff it is a combinatory algebra.

Proof: If (D, ·) is combinatorially complete, then we can choose

• k^{D} ∈ D such that

λ\ d, e ∈ D.k^{D} · d · e = λ\ d, e ∈ D.[[ x ]]_{ρ_{x}^{d}_{y}^{e}}

• and s^{D} ∈ D such that

λ\ d, e, f ∈ D.s^{D} · d · e · f = λ\ d, e, f ∈ D.[[ x z (y z) ]]_{ρ_{x}^{d}_{y}^{e} _{z}^{f}}

On the other hand in a combinatory algebra D with correspdonding model of CL_{w} D′,

[[ λ^{∗}x_{1}, …, x_{n}.M ]]^{D′}

represents

λ\ d_{1}, …, d_{n}.[[ M ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}}^{D} :

2.11. MODELS FOR λβ (11) 91

For all d_{1}, …, d_{n} ∈ D

[[ λ^{∗}x_{1}, …, x_{n}.M ]]^{D′} · d_{1} · · · · · d_{n}
= [[ λ^{∗}x_{1}, …, x_{n}.M ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}}^{D} · [[ x_{1} ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}} · · · · · [[ x_{n} ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}}
= [[ (λ^{∗}x_{1}, …, x_{n}.M) x_{1} ⋯ x_{n} ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}}^{D}
= [[ M ]]_{ρ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xn}^{dn}}^{D} .

2.11 Models for λβ (11)

2.11.1 The definition of a λ-model (11A)

Notation 2.11.1 (11.1) In this section, term means λ-term.

Why not take models of combinatory logic as models for the λ-calculus? The definition of models of combinatory logic was easy this was just the straightforward of models for first order logic (in fact for essentially only the interpretation of terms was needed) to the combinatory logic. To define models for the λ-calculus however is quite complicated, since we have to interpret λx.t. Especially closed terms are built from open terms. A tempting trivial solution would be to choose an extension of combinatory logic which is via some translation equivalent to λβ. (Such an axiomatization was treated in chapter 9C of the book and yields a theory CL_{βax} similar to CL_{βηax}; the translation of λ-terms into CL just makes use of the variant λ^{w}x.M of λ^{∗}x.M which omits the case λ^{∗}x.M x = M for closed M). However in CL_{βax} the translation of the ξ-rule is admissible, but not derivable, and therefore the models of CL_{βax} fulfill all equations derivable (without assumptions) using the translation of the ξ-rule, but are not closed under it. Therefore as well, if we considered models of CL_{βax} as models of the λ-calculus via the translation into combinators, we would not get a model closed under the ξ-rule. (That we actually get models which violate the ξ-rule is shown in [HS86]).

We will in the following define in the following first λ-models in a almost trivial way. It will be very difficult to construct with this definition λmodels, therefore we will look then at more abstract concepts.

Definition 2.11.2 (11.1) If C, D are sets, f : C→D, g : D→C,

g ∘ f = id_{C} ,

then 92 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

• g is called a left inverse of f,

• f is called a right inverse of g,

• C is called a retract of C,

• (f, g) is called a retraction. Remark 2.11.3 Assume (f, g) is a retraction. Then

(a) h := f ∘ g is idempotent, i.e. h ∘ h = h,

(b) g is surjective, f is injective. Further we have that for every pair (f, g) with f : C→D, g : D→C which fulfill (a), (b), that (f, g) is a retraction, i.e. g ∘ f = id_{D}. Proof: That a retraction fulfills (a), (b) is easy. On the other hand, if f, g fulfill (a), (b), x ∈ C, then x = g(y) for some y ∈ D, and

f(x) = f(g(y)) = f(g(f(g(y)))) = f(g(f(x))) ,

therefore

g(f(x)) = x ,
g ∘ f = id_{C} .

Definition 2.11.4 (11.3) A λ-model or model of λβ is a tripel

D = (D, ·, [[ · ]])

s. t.

• (D, ·) is an applicative structure,

• [[ · ]] is a mapping from λ-terms M and valuations σ to elements [[ M ]]_{σ} of

D s. t. for all variables x, y, terms P, Q, M, d ∈ D, valuations σ, σ the following holds:

(a) [[ x ]]_{σ} = σ(x);

(b) [[ P Q ]]_{σ} = [[ P ]]_{σ} · [[ Q ]]_{σ}.

(c) [[ λx.P ]]_{σ} · d = [[ P ]]_{σ_{x}^{d}}.

(d) [[ M ]]_{σ} = [[ M ]]_{ρ} if σ ↾ FV(M) = ρ ↾ FV(M).

(e) [[ λx.M ]]_{σ} = [[ λy.(M[x := y]) ]]_{σ}, if y ∉ FV(M), (f) If

∀d ∈ D.[[ M ]]_{σ_{x}^{d}} = [[ N ]]_{σ_{x}^{d}} ,

then

[[ λx.M ]]_{σ} = [[ λx.N ]]_{σ} .

We write sometimes [[ M ]]_{σ}^{D}, instead of [[ M ]]_{σ}, (especially if there are several models involved) and omit σ, if [[ M ]] does not depend on σ. Further, if FV(M) ⊆ {x_{1}, …, x_{n}}, we write

[[ M ]]_{[x_{1}:=d_{1},... ,x_{n}:=d_{n}]}

for [[ M ]]_{σ}, where σ is any assignment s.t. σ(x_{i}) = d_{i}.

Definition 2.11.5 (11.11). Let D = (D, ·, [[ · ]]) be a λ-model. Then

D ⊧ M = N[σ] : ⇔ [[ M ]]_{σ} = [[ M ]]_{σ} ,
D ⊧ M = N : ⇔ ∀σ assignment D ⊧ M = N[σ]

We say D models or satisfies M = N for D ⊧ M = N.

Remark 2.11.6 (11.4).

(a) Conditions (a), (b) express compositionality of the model.

(b) Condition (c) express that [[ λx.P ]]_{σ} is a representative of the function

λ\ d ∈ D.[[ P ]]_{σ_{x}^{d}} : D→D .

(c) Condition (d) is needed, since only in extensional applicative structures [[ λx.M ]]_{σ} is by (c) completely defined which would guarantee (c). Otherwise [[ λx.M ]]_{σ} might really depend on the choice of other variables.

(d) Condition (e) corresponds to (α).

(e) Condition (f) corresponds to (ξ):

λ\ d.[[ M ]]_{σ_{x}^{d}} = λ\ d.[[ N ]]_{σ_{x}^{d}}⇒[[ λx.M ]]_{σ} = [[ λx.N ]]_{σ} .

(f) From condition (c) and (f) follows weak extensionality:

λ\ d.[[ M ]]_{σ_{x}^{d}} ∼ λd.[[ N ]]_{σ_{x}^{d}}⇒[[ λx.M ]]_{σ} = [[ λx.N ]]_{σ} .

(g) One can replace the conditions in Definition 2.11.5 (a) - (f) by the following conditions:

(a) [[ x ]]_{σ} = σ(x);

(b) [[ P Q ]]_{σ} = [[ P ]]_{σ} · [[ Q ]]_{σ}.

(c) [[ λx.P ]]_{σ} · d = [[ P ]]_{σ_{x}^{d}}.

(d) [[ λx.P ]]_{σ} ∼ [[ λy.Q ]]_{ρ}⇒[[ λx.P ]]_{σ} = [[ λy.Q ]]_{ρ}.

That the above four conditions hold will be proved below in Lemma 2.11.8 (b). Further from the new conditions follow of the original ones:

• (a) - (c) are new conditions as well,.

• (d) follows by induction on M,

• (e) follows by proving Lemma 2.11.7 (a) below from the new contitions by induction on M and then using the new condition (d),

• (f) follows directly by the new conditions (c) and (d).

Lemma 2.11.7 (11.7) Let (D, ·, [[ · ]]) be a λ-model.

(a) If y ∉ FV(M) then

[[ M ]]_{σ} = [[ M[x := y] ]]_{σ_{y}^{σ(x)}} .

(b) If

• FV(M) ⊆ {x_{1}, …, x_{n}},

• x_{1}, …, x_{n}, y_{1}, …, y_{n} are distinct,

• σ(x_{i}) = ρ(y_{i}) (i = 1, …, n)

then

[[ M[x_{1} := y_{1}, …, x_{n} := y_{n}] ]]_{ρ} = [[ M ]]_{σ} .

Proof: (a): Let d := σ(x).

[[ M ]]_{σ} = [[ M ]]_{σ_{x}^{d}}
= [[ λx.M ]]_{σ} · d
= [[ λy.M[x := y] ]]_{σ} · d
= [[ M[x := y] ]]_{σ_{y}^{d}}
= [[ M[x := y] ]]_{σ_{y}^{σ(x)}} .

(b)

\begin{matrix}∀y ∈ FV(M[x_{1} := y_{1}, …, x_{n} := y_{n}]).ρ(y) \\ = & σ_{y_{1}}^{σ(x_{1})}_{y_{2}}^{σ(x_{2})} ⋯_{y_{n}}^{σ(x_{n})} (y) \end{matrix}

therefore

[[ M ]]_{σ} {(a) \atop =} [[ M[x_{1} := y_{1}, …, x_{n} := y_{n}] ]]_{σ_{y_{1}}^{σ(x_{1})}_{y_{2}}^{σ(x_{2})}···_{yn}^{σ(xn)}x}
= [[ M[x_{1} := y_{1}, …, x_{n} := y_{n}] ]]_{ρ} .

Lemma 2.11.8 (11.8, Berry’s extensionality property) Let (D, ·, [[ · ]]) be a λ-model.

(a)

(∀d ∈ D.[[ P ]]_{σ_{x}^{d}} = [[ Q ]]_{ρ_{y}^{d}})⇒[[ λx.P ]]_{σ} = [[ λy.Q ]]_{ρ} .

(b)

[[ λx.P ]]_{σ} ∼ [[ λy.Q ]]_{ρ}⇒[[ λx.P ]]_{σ} = [[ λy.Q ]]_{ρ} .

Proof:

(b) follows by (a). (a): Assume

∀d ∈ D.[[ P ]]_{σ_{x}^{d}} = [[ Q ]]_{ρ_{y}^{d}} ,

and let

FV(P) \ {x} = {x_{1}, …, x_{m}} ,
FV(Q) \ {y} = {y_{1}, …, y_{n}} .

Let z, u_{1}, …, u_{m}, v_{1}, …, v_{n} be distinct fresh variables,

P′ := P [x := z, x_{1} := u_{1}, …, x_{n} := u_{n}] ,
Q′ := Q[y := z, y_{1} := v_{1}, …, y_{m} := v_{m}]
τ := σ_{u_{1}}^{σ(x_{1})}_{u_{2}}^{σ(x_{2})} ⋯_{u_{n}}^{σ(x_{n})} _{v_{1}}^{ρ(y_{1})}_{v_{2}}^{ρ(y_{2})} ⋯_{v_{m}}^{ρ(y_{m})}

Then

[[ P′ ]]_{τ_{z}^{d}}  {2.11.7 (b) \atop =} [[ P ]]_{σ_{x}^{d}}
=  [[ Q ]]_{ρ_{y}^{d}}
{2.11.7 (b) \atop =} [[ Q′ ]]_{τ_{z}^{d}}

and therefore

[[ λx.P ]]_{ρ}  =  [[ λz.P [x := z] ]]_{ρ}
{2.11.7 (b) \atop =} [[ λz.P′ ]]_{τ}
=  [[ λz.Q′ ]]_{τ}
{2.11.7 (b) \atop =} [[ λz.Q[x := z] ]]_{ρ}
=  [[ λy.Q ]]_{ρ}

Lemma 2.11.9 (11.10). Let (D, ·, [[ · ]]) be a λ-model.

(a)

[[ M[x := N] ]]_{σ} = [[ M ]]_{σ_{x}^{[ [ N ] ]_{σ}}} .

(b)

[[ (λx.M) N ]]_{σ} = [[ M[x := N] ]]_{σ} .

Proof: (a): Induction on M. Let b := [[ N ]]_{σ}. Case M ≡ x:

[[ M[x := N] ]]_{σ} = [[ N ]]_{σ} = b = [[ x ]]_{σ_{x}^{b}} = [[ M ]]_{σ_{x}^{b}} .

Case M ≡ y ≢ x:

[[ M[x := N] ]]_{σ} = [[ y ]]_{σ} = σ(y) = σ_{x}^{b}(y) = [[ M ]]_{σ_{x}^{b}} .

Case M ≡ P Q: Immediate by IH. Case M ≡ λx.P: x ∉ FV(M), therefore

[[ M[x := N] ]]_{σ} = [[ M ]]_{σ} = [[ M ]]_{σ_{x}^{b}} .

Case M ≡ λy.P, y ∉ FV(M): Since [[ · ]] respects α-equality, w.l.o.g. y ∉ FV(N). By IH follows for all d ∈ D

[[ P [x := N] ]]_{σ_{y}^{d}} = [[ P ]]_{σ_{y}^{d}_{x}^{b}} = [[ P ]]_{σ_{x}^{b}_{y}^{d}}

and by Lemma 2.11.8 (b) therefore

[[ λy.P [x := N] ]]_{σ} = [[ λy.P ]]_{σ_{x}^{b}} .

(b) Let b := [[ N ]]_{σ}.

[[ (λx.M) N ]]_{σ} = [[ λx.M ]]_{σ} · b
= [[ M ]]_{σ_{x}^{b}}
{(a) \atop =} [[ M[x := N] ]]_{σ} .

Theorem 2.11.10 (11.12). Every λ-model models all provable equations of λβ.

Proof: Induction on the derivation. Closure under (ρ) (reflexivity), (σ) (symmetry) and (τ) (transitivity) are trivial. Closure under (α), (μ), (ν), (ξ) follow by definition. Closure under (β) follows by Lemma 2.11.9 (b).

Corollary 2.11.11 (11.12.1) If (D, ·, [[ · ]]) is a λ-model, then (D, ·) is a combinatory algebra, especially combinatorially complete.

Proof:

k := [[ λx, y.x ]] s := [[ λx, y, z.x z (y z) ]] .

Definition 2.11.12 (11.14) A model of λβη is a λ-model which models λx.M x = M for all M and all x ∉ FV(M).

Remark 2.11.13 A model of λβη fulfills all provable equations of λβη.

Note that the following theorem does not hold for combinatory logic, see Remark 2.10.16.

Theorem 2.11.14 (11.15) A λ-model D is extensional iff it is a model of λβη.

Proof: Let D = (D, ·, [[ · ]]). Assume D is extensional, M a term. Then

[[ λx.M x ]]_{σ} · d = [[ M x ]]_{σ_{x}^{d}}
= [[ M ]]_{σ_{x}^{d}} · [[ x ]]_{σ_{x}^{d}}
= [[ M ]]_{σ} · d ,

therefore by extensionality

[[ λx.M x ]]_{σ} = [[ M ]]_{σ} .

Assume D is a model of λβη. Assume

∀d ∈ D.[[ M ]]_{σ} · d = [[ N ]]_{σ} · d ,

x ∉ FV(M N). Then

[[ M x ]]_{σ_{x}^{d}} = [[ M ]]_{σ} · d
= [[ N ]]_{σ} · d
= [[ N x ]]_{σ_{x}^{d}}

Therefore

[[ λx.M x ]]_{σ} = [[ λx.N x ]]_{σ}

and

[[ M ]]_{σ} = [[ λx.M x ]]_{σ}
= [[ λx.N x ]]_{σ}
= [[ N ]]_{σ} .

Definition 2.11.15 (11.16). Let T ∈ {λβ, λβη}. Define for λ-terms M

[M] := {N | T ⊢M = N} .

The term model of T, called MT is

(D, ·, [[ · ]])

with

D := {[M] | Mλ-term ,
[M] · [N] := [M N] ,

and, if FV(M) = {x_{1}, …, x_{n}}

[[ M ]]_{σ} := [M[x_{1} := σ(x_{1}), …, x_{n} := σ(x_{n})] .

Remark 2.11.16 In M(T) above · and [[ · ]] are well-defined and M(T) is a model of T.

2.11.2 A syntax free definition of λ-models (11B)

The above definition of a λ-model makes it difficult to define models, since we have to give a complete definition of [[ · ]] and verify all its properties. Instead we are going now to give a more abstract and more algebraic definition, on which the model D^{∞} we construct (and other models as well) will be based. The idea is to start with a combinatory algebra (D, ·) i.e.

(D, ·) is combinatorially complete  (1)

Based on it we try to define [[ M ]]_{ρ} by induction on M. Our definition should be general, i.e. we want to obtain all possible choices of [[ · ]] s.t.

(D, ·, [[ · ]]) is a λ-model ,

which means that in the course of developping [[ · ]] we will need to add additional parameters, which determine [[ · ]] on (D, ·). In fact, only one parameter, namely a function Λ : D→D will be needed. This Λ will define [[ · ]] completely, i.e. we will get that for every choice of [[ · ]] there exists a unique Λ corresponding to it, which fulfills certain equations and that for every Λ fulfilling these equations there will exists a unique [[ · ]] based on it. Case M ≡ x. By the conditions of λ-model there is no freedom of choice,

[[ M ]]_{σ} = σ(x) .

Case M ≡ P Q. If [[ P ]]_{σ}, [[ Q ]]_{σ} are chosen, there is only one choice possible for [[ M ]]_{σ}, namely

[[ P Q ]]_{σ} := [[ P ]]_{σ} · [[ Q ]]_{σ} .

Case M ≡ λx.P. If [[ P ]]_{ρ} is defined for all ρ we get the condition

[[ λx.P ]]_{σ} · d = [[ P ]]_{σ_{x}^{d}} ,

i.e. [[ λx.P ]]_{σ} must be one representative of the function

λ\ d.[[ P ]]_{σ_{x}^{d}} .

First we need to guarantee the existence of such a representative. Now we see immediately that we need to define something more generally, namely for every term M and variables x_{1}, …, x_{n} s.t. FV(M) ⊆ {x_{1}, …, x_{n}} an element a_{M,x_{1},... ,x_{n}} ∈ D s.t.

[[ M ]]_{σ} = a_{M,x_{1},... ,x_{n}} · σ(x_{1}) · · · · · σ(x_{n}) .

Note that for every choice of [[ · ]] there might be several choices of a_{M,x⃗}. However it is not necessary to consider all such choices, we need only to guarantee that we finally obtain all choices of [[ · ]]. It will be useful in the following to abbreviate for x⃗ = x_{1}, …, x_{n}, and a⃗ = a_{1}, …, a_{n}

b · σ(x⃗) := b · σ(x_{1}) · · · · · σ(x_{n}) ,
b · a⃗ := b · a_{1} · · · · · a_{n} .

We will show that we can find a_{M,x⃗} in the cases treated before. In case M ≡ x_{i} we could define

a_{M,x_{1},... ,x_{n}} := (λx_{1}, …, x_{n}.x_{i})^{∗}

where (λx_{1}, …, x_{n}.x_{i})^{∗} is a representative of the function

λ\ d_{1}, …, d_{n}.d_{i} ,

which exists by combinatorially completeness of (D, ·) (which one we choose does not matter). For convenience, in case the variables x_{i} occurs more than once in x_{1}, …, x_{n} we choose the last such occurrence. In case M ≡ P Q we can define

a_{P Q,x⃗} := (λu, v, x⃗.u x⃗ (v x⃗))^{∗} · a_{P,x⃗} · a_{Q,x⃗} ,

where (λu, v, x⃗.u x⃗ (v x⃗))^{∗} is a representative of the function

λ\ a, b, d⃗.a · d⃗ · (b · d⃗)

which again exists by (1). Now, back to the definition of [[ λx.P ]]_{σ}. If we have defined a_{P,x⃗,x}, then

a_{P,x⃗,x} · σ(x⃗)

is one representative of the function

λd.[[ P ]]_{σ_{x}^{d}}(= λd.a_{P,x⃗,x} · σ(x⃗) · d) .

(Note that because of our choice of interpretation of variables, if x ∈ x⃗ the last occurrence of x overrides this occurrence of x ∈ x⃗). However, there are several representatives possible. By Berry’s extensionality property we know 2.11.8 that

λd.[[ P ]]_{σ_{x}^{d}} = λd.[[ Q ]]_{ρ_{y}^{d}}⇒[[ λx.P ]]_{σ} = [[ λy.Q ]]_{ρ} ,

which means that

a_{P,x⃗,x} · σ(x⃗) ∼ a_{Q,y⃗,y} · ρ(y⃗)⇒[[ λx.P ]]_{σ} = [[ λy.Q ]]_{ρ} ,

i.e. in every model of the λ-calculus based on (D, ·) there is for every d ∈ D at most one Λ(d) s.t.

[[ λx.P ]]_{σ} = Λ(a_{P,x⃗,x} · σ(x⃗)) ,

and we have

d ∼ d′⇒Λ(d) = Λ(d′) .  (2)

On the other hand we have that

a_{x y,y,x} · d · a = d · a

i.e.

a_{x y,y,x} · d ∼ d ,

therefore in every equivalence class modulo ∼ of e there exists a d s.t. Λ(d) is defined. Therefore Λ can be extended in a unique way to a function

Λ : D→D

s.t. (2) holds. Therefore we get that for every semantic (D, ·, [[ · ]]) there exists a unique

Λ : D→D

fulfilling (2) and s.t.

[[ λx.P ]]_{σ} = Λ(a_{P,x⃗,x} · σ(x⃗)) ,  (+)

and to every function

Λ : D→D

fulfilling (2) there exists at most one semantics fulfilling (+). (Note that by (2) and (+) [[ λx.P ]]_{σ} is uniquely determined already by [[ P ]]_{σ_{x}^{d}} (d ∈ D), since for all choices of a_{P,x⃗,x} s.t. a_{P,x⃗,x} · σ(x⃗) represents λd.[[ M ]]_{σ_{x}^{d}} Λ(a_{P,x⃗,x} · σ(x⃗)) yields the same result. What remains is to find out the remaining conditions on Λ needed s.t. it corresponds to a semantics and to determine a_{λx.P,x⃗}. Since

[[ M ]]_{σ} = Λ(a_{M,x⃗,x} · σ(x⃗)) ∼ a_{M,x⃗,x} · σ(x⃗)

and for every d d ∼ a_{x y,y,x} · d, it follows

Λ(d) ∼ Λ(a_{x y,y,x}) ∼ a_{x y,y,x} ∼ d

i.e.

Λ(d) ∼ d .  (3)

Further we have

[[ λy.x y ]]_{[x:=d]} · a = [[ x y ]]_{[x:=d,y:=a]}
= d · a ,

therefore

[[ λy.x y ]]_{[x:=d]} ∼ d ,
[[ λy.x y ]]_{[x:=d]} = Λ(a_{x y,x,y} · d)
= Λ(d)
Λ = λ\ d.[[ λy.x y ]]_{[x:=d]}
= [[ λx, y.x y ]] · d

therefore

∃e ∈ D.∀d ∈ D.e · d = Λ(d) .  (4)

Once we have e according to (4) we can now define a_{λx.P,x⃗}:

[[ λx.P ]]_{σ} = Λ(a_{P,x⃗,x} · σ(x⃗))
= e · (a_{P,x⃗,x} · σ(x⃗))
= (λu, v, x⃗.u (v x⃗))^{∗} · e · a_{P,x⃗,x} · σ(x⃗) ,

i.e. we can define

a_{λx.P,x⃗} := (λu, v, x⃗.u (v x⃗))^{∗} · e · a_{P,x⃗,x} ,

where (λu, v, x⃗.u (v x⃗))^{∗} is a representative of the function

λ\ a, b, c⃗.a · (b · c⃗) .

We take now the conditions (1) - (4) as above as the definition of a syntax free λ-model and verify then, although this is already almost implicitly shown in the above discussion, that the new notion is equivalent to the notion of a λ-model, we had before.

Definition 2.11.17 (11.19). A syntax free λ-model or (if this does not cause confusion with the definition above λ-model) is a tripel

(D, ·, Λ)

where

• (D, ·) is an applicative structure,

• Λ : D→D, 102 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

s.t.

(a) (D, ·) is combinatorially complete,

(b) ∀a ∈ D.Λ(a) ∼ a,

(c) ∀a, b ∈ D.(a ∼ b⇒Λ(a) = Λ(b)),

(d) ∃e ∈ D.∀a ∈ D.e · a = Λ(a). Definition 2.11.18 (11.20, first part) Let (D, ·, Λ) be a syntax free λ-model. We define [[ · ]] s.t. (D, ·, [[ · ]]) is a λ-model as follows: Let for every combination M of distinct variables x_{1}, …, x_{n}

(λx_{1}, …, x_{n}.M)^{∗}

be an element in D representing this function. Let e be s.t.

∀a ∈ D.e · a = Λ(a) .

First define for every term N, distinct variables x_{1}, …, x_{n} s.t.

FV(N) ⊆ {x_{1}, …, x_{n}}

an element

a_{N,x_{1},... ,x_{n}} ∈ D

by (a)

a_{x_{i},x_{1},... ,x_{n}} := (λx_{1}, …, x_{n}.x_{i})^{∗}

(b)

a_{N M,x_{1},... ,x_{n}} :=
(λu, v, x_{1}, …, x_{n}.u x_{1} ⋯ x_{n} (v x_{1} ⋯ x_{n}))^{∗}
· a_{N,x_{1},... ,x_{n}} · a_{M,x_{1},... ,x_{n}}
i.e. a_{N M,x_{1},... ,x_{n}} represents the function
λ\ d_{1}, …, d_{n}.a_{N,x_{1},... ,x_{n}} · d_{1} · · · · · d_{n} · (a_{M,x_{1},... ,x_{n}} · d_{1} · · · · · d_{n}) .

(c)

\begin{matrix}a_{λx.N,x_{1},... ,x_{n}} := \\ (λu, v, x_{1}, …, x_{n}.u (v x_{1} ⋯ x_{n}))^{∗} · e · a_{N,x_{1},... ,x_{n},x} \end{matrix}

i.e. a_{λx.N,x_{1},... ,x_{n}} represents λ\ d_{1}, …, d_{n}.e · (a_{N,x_{1},... ,x_{n},x} · d_{1} · d_{2} · · · · · d_{n}) .

Then define, if FV(M) = {x_{1}, …, x_{n}}.

[[ M ]]_{σ} := a_{M,x_{1},... ,x_{n}} · σ(x_{1}) · · · · · σ(x_{n}) .

Theorem 2.11.19 (11.20, second part). Definition 2.11.18 yields a λ-model.

Proof: We first verify that the definition

[[ M ]]_{σ} := a_{M,x_{1},... ,x_{n}} · σ(x_{1}) · · · · · σ(x_{n}) .

is independent of the choice of distinct variables x_{1}, …, x_{n}, i.e. if

FV(M) ⊆ {x_{1}, …, x_{n}} ∩ {y_{1}, …, y_{m}}

then for all assignments

a_{M,x⃗} · σ(x⃗) = a_{M,y⃗} · σ(y⃗)

by induction on M. Case M ≡ x_{i} ≡ y_{j}:

a_{M,x⃗} · σ(x⃗) = σ(x_{i}) = σ(y_{j}) = a_{M,y⃗} · σ(y⃗) .

Case M ≡ P Q:

a_{M,x⃗} · σ(x⃗) = a_{P,x⃗} · σ(x⃗) · (a_{Q,x⃗} · σ(x⃗))
{IH \atop =} a_{P,y⃗} · σ(y⃗) · (a_{Q,y⃗} · σ(y⃗))
= a_{M,y⃗} · σ(x⃗)

Case M ≡ λx.P: By IH

∀d ∈ D.a_{P,x⃗,x} · σ(x⃗) · d = a_{P,y⃗,x} · σ(y⃗) · d ,

therefore

Λ(a_{P,x⃗,x} · σ(x⃗)) = Λ(a_{P,y⃗,x} · σ(y⃗))

and

a_{M,x⃗,x} · σ(x⃗) = e · (a_{P,x⃗,x} · σ(x⃗))
= Λ(a_{P,x⃗,x} · σ(x⃗))
= Λ(a_{P,y⃗,x} · σ(y⃗))
= e · (a_{P,y⃗,x} · σ(y⃗))
= a_{M,y⃗,x} · σ(y⃗) .

A similar proof (both assertions need to be shown simultaneously) shows

• M ≡_{α} N⇒a_{M,x⃗} = a_{N,x⃗} • If FV(M) ⊆ {x_{1}, …, x_{n}}, y_{i} distinct, then

a_{M,x⃗} = a_{M[x_{1}:=y_{1},... ,x_{n}:=y_{n}],y⃗} .

Now we verify that we obtain a λ-model:

[[ x ]]_{σ} = σ(x)

is obvious.

[[ P Q ]]_{σ} = [[ P ]]_{σ} · [[ Q ]]_{σ} ,

follows by definition.

[[ λx.P ]]_{σ} · d = [[ P ]]_{σ_{x}^{d}}
[[ λx.P ]]_{σ} · d = Λ(a_{P,x⃗,x} · σ(x⃗)) · d
=^{Λ(a)∼a} a_{P,x⃗,x} · σ(x⃗) · d
= [[ P ]]_{σ_{x}^{d}} .

[[ M ]]_{σ} = [[ N ]]_{σ} if σ ↾ FV(M) = σ ↾ FV(N)

is guaranteed by definition.

[[ λx.M ]]_{σ} = [[ λy.(M[x := y]) ]]_{σ}, if y ∉ FV(M)

has been verified above.

λ\ d.[[ M ]]_{σ_{x}^{d}} ∼ λ\ d.[[ N ]]_{σ_{x}^{d}}⇒[[ λx.M ]]_{σ} = [[ λx.N ]]_{σ} .

By assumption

a_{M,x⃗,x} · σ(x⃗) ∼ a_{N,x⃗,x} · σ(x⃗)

therefore

[[ λx.M ]]_{σ} = Λ(a_{M,x⃗,x} · σ(x⃗)) = Λ(a_{N,x⃗,x} · σ(x⃗)) = [[ λx.N ]]_{σ} .

Theorem 2.11.20 (11.20, third part) Let (D, ·, [[ · ]]) be a λ-model,

Λ := λ\ d.[[ λx.y x ]]_{[y:=d]} .

Then (D, ·, Λ) is a syntax free λ-model.

Proof: We verify the condition in Definition 2.11.4 (a) - (d): (a): (D, ·) is combinatorially complete. (b):

Λ(a) · d = [[ λx.y x ]]_{[y:=a]} · d
= [[ y x ]]_{[y:=a,x:=d]}
= a · d

therefore

Λ(a) ∼ a .

(c): If a ∼ b, then

[[ λx.y x ]]_{[y:=a]} · d = [[ y x ]]_{[y:=a,x:=d]}
= a · d
= b · d
= [[ λx.y x ]]_{[y:=b]} · d

therefore

Λ(a) = [[ λx.y x ]]_{[y:=a]} = [[ λx.y x ]]_{[y:=b]} = Λ(b) .

(d): Let e := [[ λx, y.y x ]]. Then for all d ∈ D

e · d = [[ λy, x.y x ]] · d
= [[ λx.y x ]]_{[y:=d]}
= Λ(d) .

Theorem 2.11.21 The constructions in Definition 2.11.18 and Theorem 2.11.20 are inverse.

Proof: Assume first a syntax free λ-modul (D, ·, Λ), let [[ · ]] be defined as in Definition 2.11.18. Show, that the Λ′ obtained in Theorem 2.11.20 from (D, ·, [[ · ]]) is Λ:

Λ′(d) = [[ λx.y x ]]_{[y:=d]} = Λ(a_{y x,y,x} · d) .
a_{y x,y,x} · d · e = d · e ,

therefore

a_{y x,y,x} · d ∼ d ,
Λ′(d) = Λ(a_{y x,y,x} · d) = Λ(d) .

Assume now a free λ-modul (D, ·, [[ · ]]), let Λ be defined as in Theorem 2.11.20. Show, that the [[ · ]]′ obtained in Definition 2.11.18 from (D, ·, Λ) is [[ · ]]. Show [[ M ]]_{σ} = [[ M ]]′_{σ} by induction on M:

• M ≡ x: both sides yield σ(x).

• M ≡ P Q: IH.

• M ≡ λx.N:

[[ λx.M ]]′_{σ} = Λ(a_{M,x⃗,x} · σ(x⃗))
= [[ λy.x y ]]_{[x:=a_{M,x⃗,x}·σ(x⃗)]} .

Now for all d ∈ D

[[ x y ]]_{[x:=a_{M,x⃗,x}·σ(x⃗)]_{y}^{d}} = a_{M,x⃗,x} · σ(x⃗) · d
{IH \atop =} [[ M ]]_{σ_{x}^{d}} ,

therefore

[[ λx.M ]]′_{σ} = [[ λy.x y ]]_{[x:=a_{M,x⃗,x}·σ(x⃗)]}
= [[ λx.M ]]_{σ} .

Theorem 2.11.22 (11.30) If (D, ·) is an extensional combinatory algebra, and let

Λ : D→D, a ↦ a .

Then (D, ·, Λ) is a syntax free λ-model and the only one extending (D, ·).

Proof: Uniqueness follows, since every Λ has to select out of every equivalence class modolu ∼ one element. The equivalence classes have one element only, therefore Λ(a) = a. With Λ as in the theorem follows immediately Λ(a) ∼ a, a ∼ b⇒Λ(a) ∼ Λ(b) and with e representing the identity we get e represents Λ.

2.11.3 Scott-Meyer λ-models (11.21 - 11.27)

Definition 2.11.17 can now be axiomatized as follows:

Definition 2.11.23 (11.21) Syntax free λ-models can be formalized by the following set of axioms in the language with a binary function symbol ·, written infix, and a unary function symbol Λ:

(a) ∃k.∀a, b.k · a · b = a.

(b) ∃s.∀a, b, c.s · a · b · c = (a · c) · (b · c).

(c) ∀a, b.Λ(a) · b = a · b.

(d) ∀a, b.((∀d.a · d = b · d)→Λ(a) = Λ(b)).

(e) ∃e.∀a.e · a = Λ(a).

From the last axiom one can see, that we can replace Λ(a) by e·a for some constant e. However, whereas to every λ-model corresponds a unique Λ s.t. we get a syntax free λ-model, there might be several e which represent the same Λ. Only, if we add that e is strict, where strict is defined as e · e = e, we get uniqueness. (Note that e strict in terms of Λ means Λ(e) = e, i.e. e is the “canonical choice”).

2.11. MODELS FOR λβ (11) 107

Definition 2.11.24 (11.22)

(a) Let (D, ·) be an applicative structure, e ∈ D. (D, ·, e) is called a loose Scott-Meyer λ-model, iff

(a) (D, ·) is combinatorially complete.

(b) ∀a, b ∈ D.e · a · b = a · b.

(c) ∀a, b ∈ D((∀d.a · d = b · d)→e · a = e · b).

(b) A loose Scott-Meyer model (D, ·, e) is a strict Scott-Meyer λ-model iff e · e = e .

Lemma 2.11.25 (approx. 11.23)

(a) If (D, ·, e), (D, ·, e_{0}) are two strict Scott-Meyer model (with the same applicative structure (D, ·)) s.t. e ∼ e_{0}, then e = e_{0}.

(b) If (D, ·, e) is a Scott-Meyer model, e_{0} := e · e, then (D, ·, e_{0}) is a strict Scott meyer model s.t. e_{0} ∼ e (i.e. e_{0} corresponds to the same Λ as e).

Proof: (a).

e = e · e
= Λ(e)
=^{e∼e_{0}} Λ(e_{0})
= e_{0} · e_{0}
= e_{0} .

(b): Λ(a) := e · a, then e_{0} = Λ(e) ∼ e,

e_{0} · e_{0} = Λ(Λ(e)) = Λ(e) = e_{0} .

Theorem 2.11.26 (a) Let (D, ·, Λ) be a syntax free λ-model, (D, ·, [[ · ]]) the

corresponding λ-model. Let

e := [[ λy, x.y x ]](= [[ \underline{1} ]]) .

Then (D, ·, e) is a strict Scott-Meyer λ-model.

(b) If (D, ·, e) is a loose Scott-Meyer λ-model, Λ : D→D defined by

Λ(d) := e · d .

Then (D, ·, Λ) is a syntax free λ-model.

(c) The constructions in (a) and (b) are inverse bijections, if (b) is restricted to strict Scott-Meyer models.

(d) If we apply the construction (b) and then (a) to a loose Scott-Meyer model (D, ·, e), we obtain a strict Scott-Meyer model (D, ·, e_{0}) s.t. e_{0} ∼ e.

Proof:

(a) By Theorem 2.11.21 it follows that

Λ(a) = [[ λx.y x ]]_{[y:=d]} ,

therefore

Λ(a) = [[ λx, y, x y ]] · d,

and e := [[ \underline{1} ]] fulfills the conditions of a loose Scott-Meyer model. Further for this e it follows

e · e = [[ λx, y.x y ]] · [[ λx, y.x y ]]
= [[ (λx, y.x y)λx, y.x y ]]
= [[ λx, y.x y ]]
= e ,

therefore (D, ·, e) is actually strict. (b): trivial. (c): If we apply (a) and then (b), we obtain the syntax free λ-model (D, ·, Λ), with

Λ′(a) = e · a = [[ λx.y x ]]_{[y:=d]} ,

where by Theorem 2.11.21 Λ(a) = Λ′(a). If we apply (b) and then (a), we obtain a strict Scott-Meyer model

(D, ·, e_{0})

s.t. e_{0} represents Λ which is

a ↦ e · a

for the e of the original Scott-Meyer model. Therefore

e ∼ e_{0} .

From this it follows (d), and if we started with a strict Scott-Meyer model by Lemma 2.11.25 it follows

e = e_{0} .

Remark 2.11.27 (11.26) Let (D, ·, Λ) be a syntax free λ-model, define

Repu : (D→_{rep}D)→D, Repu(f) = Λ(a) for a ∈ Rep(f) .

Since for b, c ∈ Rep(f), b ∼ c it follows that Repu is well-defined and

Repu ∘ Fun is the identity on D→_{rep}D .

Therefore Repu is a left inverse to Fun and D→_{rep}D is a retract of D. The image of Repu is a subset F of D which contains of every equivalenceclass of ∼ exactly one element.

2.12. THE λ-MODEL D_{∞} (12) 109

2.12 The λ-model D_{∞} (12)

2.12.1 Solutions of cpo-equations

We will in the following assume familiarity with cpo’s, as described in 12A and 12B of [HS86]. The model D_{∞} we are going to construct will be a non-trivial cpo s.t.

D_{∞} ≅ [D_{∞}→D_{∞}] .

Let α : D_{∞}→[D_{∞}→D_{∞}] be the isomorphism. Then we can define for a, b ∈ D_{∞}

a · b := α(a)(b) .

We will then verify that

(D_{∞}, ·)

is an extensional combinatory algebra (the extensionality is trivial, because α is an isomorphism), which can be (by defining Λ := id) extended by Theorem 2.11.22 to a λ-model. The construction generalizes very easily to solutions of more general cpoequations, and instead of restricting ourselves to the special case we treat arbitrary solutions of cpo-equations. There is even a more general version of this ([Set94, Str94]), which works for all cpo-enriched categories, where a category C is cpo-enriched iff C(A, B) have a cpo structure s.t.

∘ : C(B, C) × C(A, B)→C(A, C) is continuous.

We restrict ourselves to ordinary cpos. The following is based on [Set94], which is again based on [Str94]. First we need some extremely basic category theory:

Definition 2.12.1 (a) A category is a 6-tupel

C := (Obj, Mor, dom, cod, ∘, id)

s.t.

• Obj, Mor are classes (the elements of Obj are called objects and the elements of Mor morphisms of the category C),

• dom, cod : Mor→Obj,

• f ∘ g ∈ Mor is defined for all f, g ∈ Mor s.t. cod(g) = dom(f),

• id : Obj→Mor,

where we write, if f ∈ Mor, A, B ∈ Obj,

f : A→B : ⇔dom(f) = A ∧ cod(f) = B ,

and id_{A} for id(A) and have the following laws:

• dom(f ∘ g) = dom(g),

• cod(f ∘ g) = cod(f),

• dom(id_{A}) = cod(id_{A}) = A,

• h ∘ (g ∘ f) = (h ∘ g) ∘ f (if defined),

• if h : A→B, then id_{B} ∘ h = h, h ∘ id_{A} = h, Let C(A, B) := {f ∈ Mor | f : A→B}.

(b) A bifunctor from a category

C = (Obj_{C}, Mor_{C}, dom_{C}, cod_{C}, ∘_{C}, id^{C})

into a category

D = (Obj_{D}, Mor_{D}, dom_{D}, cod_{D}, ∘_{D}, id^{D}) ,

abbreviated by

F : (C^{op} × C)→D ,

is a function

F : Obj_{C} × Obj_{C}→Obj_{C}

together with for every every A, A′, B, B′ ∈ Obj_{C}, and f : A′→A, g : B→B′ a morphism in D

F (f, g) : F (A, B)→F (A′, B′)

(where we use the same name for F (A, B) and F (f, g) s.t.

• F (id_{A}, id_{B}) = id_{F (A,B)},

• if f : A′→A, f′ : A′′→A′, g : B→B′, g′ : B′→B′′ then

F (f′, g′) ∘ F (f, g) = F (f ∘ f′, g′ ∘ g) .

Definition 2.12.2 (a) The category of cpo’s cpo consists of • Obj: The class of cpo’s.

• Mor: The class of pairs (f, B), where f ∈ [dom(f)→B]. dom(f, B) = dom(f), cod(f, B) = B. We will usually write f instead of (f, B).

• (g, C) ∘ (f, B) := (g ∘ f, C).

• id_{A} := (λ\ d ∈ A.A, A).

(b) A bifunctor F : (cpo^{op} × cpo)→cpo is locally continuous, iff for all cpo’s A, A′, B, B′

F : [A′→A] × [B→B′]→[F (A, B)→F (A′, B′)]

is continuous.

2.12. THE λ-MODEL D_{∞} (12) 111 Lemma 2.12.3 (a) The bifunctor

F : (cpo^{op} × cpo)→cpo

defined by

F (A, B) = B, F (f, g) = g

is a locally continuous bifunctor.

(b) If

F, G : (cpo^{op} × cpo)→cpo

are locally continuous bifunctors, then

(F →G) : (cpo^{op} × cpo)→cpo

is as well a locally continous bifunctor, where F →G is defined by

(F →G)(A, B) := [F (B, A)→G(A, B)] ,

and if

f : A′→A, g : B→B′, h : F (B, A)→G(A, B)

then

(F →G)(f, g)(h) := G(f, g) ∘ h ∘ F (g, f) : F (B′, A′)→G(A′, B′) .

(c) If (F_{i}) : (cpo^{op} × cpo)→cpo are locally continuous bifunctors (i ∈ I), so

are

∏_{i∈I} F_{i} : (cpo^{op} × cpo)→cpo ,

defined by

(∏_{i∈I} F_{i})(A, B) := ∏_{i∈I}(F_{i}(A, B)) ,

with componentwise ordering,

(∏_{i∈I} F_{i})(f, g)((a_{i})_{i∈I}) = (F_{i}(f, g)(a_{i}))_{i∈I} .

and

∑_{i∈I} F_{i} : (cpo^{op} × cpo)→cpo ,

defined by

(∑_{i∈I} F_{i})(A, B) := ∑_{i∈I}(F_{i}(A, B)) ,

(disjoint union, with an additional ⊥ added)

(∑_{i∈I} F_{i})(f, g)(ι_{i}(a)) = ι_{i}(F_{i}(f, g)(a))

(where ι_{i} are the canonical injections

F_{i}(A, B)→ ∑_{i∈I} F_{i}(A, B) ),

(∑_{i∈I} F_{i})(f, g)(⊥) := ⊥ .

Proof: All easy. Definition 2.12.4 Let D, D′ be cpo’s. An embedding/projection pair is a pair

(e : D→D′, p : D′→D)

where • D, D′ are cpo’s,

• e : D→D′, p : D′→D are continuous functions, s.t.

• p ∘ e = id,

• e ∘ p ⊑ id. Remark 2.12.5 (a) If (e, p), (e, p′) are embedding/projection pairs, then p =

p′.

(b) If (e, p), (e′, p) are embedding/projection pairs, then e = e′.

(c) If (e, p) is an embedding/projection pair, then e, p are strict. Bevis: (a):

p = id ∘ p = p′ ∘ e ∘ p ⊑ p′ ∘ id = p′ ,

similarly

p′ ⊑ p .

(b):

e = e ∘ p ∘ e′ ⊑ id ∘ e′ = e′ ,

similarly

e′ ⊑ e .

(c) p(⊥) ⊑ p(e(⊥)) = ⊥, therefore

p(⊥) = ⊥ .

e(⊥) = e(p(⊥)) ⊑ id(⊥) = ⊥,

e(⊥) = ⊥ .

Lemma 2.12.6 Let (D_{n})_{n∈ℕ} be a sequence of cpo’s,

(e_{n} : D_{n}→D_{n+1}, p_{n} : D_{n+1}→D_{n})

a sequence of embedding/projection pairs. Then there exists a cpo D and a sequence of embedding/projection pairs

(i_{n} : D_{n}→D, ρ_{n} : D→D_{n}) ,

s.t.

(a) i_{n+1} ∘ e_{n} = i_{n}.

(b) ⊔_{n∈ℕ}i_{n} ∘ ρ_{n} = id_{D}.

Proof: Let

D := {u ∈ ∏_{n∈ℕ} D_{n} | ∀n ∈ ℕ.p_{n}(u_{n+1}) = u_{n}} .

D is a cpo with componentwise ordering:

⊥_{D} = ((⊥_{D_{n}})_{n∈ℕ}) ∈ D ,

since by strictness of p_{n}

p_{n}(⊥_{D_{n+1}}) = ⊥_{D_{n}} .

Assume B ⊆ D directed,

u_{n} := ⊔{v_{n}|v ∈ B} .

Then

p_{n}(u_{n+1}) = p_{n}(⊔{v_{n+1}|v ∈ B})
= ⊔{p_{n}(v_{n+1})|v ∈ B}
= ⊔{v_{n}|v ∈ B} = u_{n} ,

therefore u ∈ D. Further u ist the supremum of B in ∏_{n∈ℕ} D_{n}, therefore as well in D. Let for n < m

e_{n,m} := e_{m−1} ∘ ⋯ ∘ e_{n} : D_{n}→D_{m}
p_{m,n} := p_{n} ∘ ⋯ ∘ p_{m−1} : D_{m}→D_{n}

and e_{n,n} := p_{n,n} := Id_{D_{n}}. Define ρ_{n} : D→D_{n}, ρ_{n}(u) := u_{n}. Define i_{n} : D_{n}→D,

(i_{n}(a))_{m} := \begin{cases}e_{n,m}(a) & if n ≤ m \\ p_{n,m}(a) & if m ≤ n \end{cases} .

i_{n}(a) ∈ D:

If n < m then

p_{m}((i_{n}(a))_{m+1}) = p_{m}(e_{n,m+1}(a))
= p_{m} ∘ e_{m} ∘ e_{m−1} ∘ ⋯ ∘ e_{n}(a)
= e_{m−1} ∘ ⋯ ∘ e_{n}(a) = e_{n,m}(a) = (i_{n}(a))_{m} .

If m ≤ n then

p_{m}((i_{n}(a))_{m+1}) = p_{m}(p_{n,m+1}(a))
= p_{m} ∘ p_{m+1} ∘ p_{m+2} ∘ ⋯ ∘ p_{n−1}(a)
= p_{n,m}(a)
= (i_{n}(a))_{m} .

ρ_{n} is continuous, since it is monotone and for A ⊆ D directed

ρ_{n}(⊔A) = u_{n} = (⊔A)_{n}

with u := ⊔A. i_{n} is continuous, since it is monotone and for A ⊆ D directed

(i_{n}(⊔A))_{m} = e_{n,m}(⊔A) = ⊔e_{n,m}(A) = ⊔(i_{n}(A)_{m}) = (⊔i_{n}(A))_{m} ,

if n ≤ m and

(i_{n}(⊔A))_{m} = p_{n,m}(⊔A) = ⊔p_{n,m}(A) = ⊔(i_{n}(A)_{m}) = (⊔i_{n}(A))_{m} ,

if m ≤ n. Further

(i_{n+1} ∘ e_{n}(u))_{m} = \begin{cases}e_{n+1,m} ∘ e_{n}(u) & n + 1 ≤ m \\ p_{n+1,m} ∘ e_{n}(u) & m ≤ n \end{cases}

= \begin{cases}e_{n,m}(u) & n + 1 ≤ m \\ p_{n,m}(u) & m ≤ n \end{cases}
= (i_{n}(u))_{m} ,
i_{n+1} ∘ e_{n} = i_{n} .

For n ≥ m and u ∈ D it follows

((i_{n} ∘ ρ_{n})(u))_{m} = p_{n,m}(u_{n})
= p_{m} ∘ ⋯ ∘ p_{n−1}(u_{n})
= u_{m} .

Therefore

(⊔(i_{n} ∘ ρ_{n})(u)))_{m} = ⊔_{n≥m}(i_{n} ∘ ρ_{n}(u))_{m}
= ⊔_{n≥m}u_{m} = u_{m} ,
⊔(i_{n} ∘ ρ_{n}) = id .

2.12. THE λ-MODEL D_{∞} (12) 115

Remark 2.12.7 Let D_{n}, e_{n}, p_{n}, d, i_{n}, ρ_{n} as in Theorem 2.12.6. Then it follows (a) e_{n} = ρ_{n+1} ∘ i_{n}.

(b) p_{n} = ρ_{n} ∘ i_{n+1}.

(c) ρ_{n} = p_{n} ∘ ρ_{n+1}.

(d) i_{n+1} ∘ ρ_{n+1} ⊒ i_{n} ∘ ρ_{n}.

(e) e_{n,m} = ρ_{m} ∘ i_{n} (n ≤ m).

(f) p_{n,m} = ρ_{m} ∘ i_{n}.(m ≤ n). Proof: (a):

e_{n} = ρ_{n+1} ∘ i_{n+1} ∘ e_{n}
= ρ_{n+1} ∘ i_{n}

(b):

(ρ_{n} ∘ i_{n+1}) ∘ e_{n} = ρ_{n} ∘ (i_{n+1} ∘ e_{n})
= ρ_{n} ∘ i_{n} = id_{D_{n}} .
e_{n} ∘ (ρ_{n} ∘ i_{n+1}) = ρ_{n+1} ∘ i_{n} ∘ ρ_{n} ∘ i_{n+1}
⊑ ρ_{n+1} ∘ i_{n+1}
= id .

Therefore (e_{n}, ρ_{n} ∘ i_{n+1}) is an embedding/projection pair. By uniqueness it follows

ρ_{n} ∘ i_{n+1} = p_{n} .

(c):

(p_{n} ∘ ρ_{n+1}) ∘ i_{n} = p_{n} ∘ ρ_{n+1} ∘ i_{n+1} ∘ e_{n}
= p_{n} ∘ e_{n}
= id ,
i_{n} ∘ (p_{n} ∘ ρ_{n+1}) = i_{n} ∘ ρ_{n} ∘ i_{n+1} ∘ ρ_{n+1}
⊑ id ∘ id
= id .

Therefore

p_{n} ∘ ρ_{n+1} = ρ_{n} .

(d):

i_{n+1} ∘ ρ_{n+1} = i_{n+1} ∘ id ∘ ρ_{n+1}
⊒ i_{n+1} ∘ e_{n} ∘ p_{n} ∘ ρ_{n+1}
= i_{n} ∘ ρ_{n} .

116 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

(e): We show immediately by induction for n ≤ m

i_{m} ∘ e_{n,m} = i_{n} ,

therefore

e_{n,m} = e_{m−1} ∘ e_{n,m−1}
= ρ_{m} ∘ i_{m−1} ∘ e_{n,m−1}
= ρ_{m} ∘ i_{n} , for m > n und
e_{n,n} = ρ_{n} ∘ i_{n} .

(f): For n > m we have

p_{n,m} = p_{m} ∘ ⋯ ∘ p_{n−1}
= p_{m} ∘ ⋯ ∘ p_{n−3} ∘ p_{n−2} ∘ ρ_{n−1} ∘ i_{n}
= p_{m} ∘ ⋯ ∘ p_{n−3} ∘ ρ_{n−2} ∘ i_{n}
= p_{m} ∘ ⋯ ∘ ρ_{n−3} ∘ i_{n}
= ⋯ = ρ_{m} ∘ i_{n}

and for n = m

p_{n,m} = id = ρ_{m} ∘ i_{n} .

Lemma 2.12.8 Assume • F : (cpo^{op} × cpo)→cpo is a locally continuous bifunctor,

• D_{0} is a cpo,

• (e_{0} : D_{0}→F (D_{0}, D_{0}), p_{0} : F (D_{0}, D_{0})→D_{0}) is an embedding/projection

pair. Then there exists

• a cpo D,

• an embedding/projection pair

(e : D_{0}→D, p : D→D_{0})

together with

• an isomorphism (i.e. continuous bijection)

β : F (D, D) ⟶^{≅} D .

Proof: Define inductively cpo’s D_{n} for n ≥ 1 by

D_{n} := F (D_{n−1}, D_{n−1}) ,

and simultaneously for n ≥ 1 inductively 2.12. THE λ-MODEL D_{∞} (12) 117

• e_{n} := F (p_{n−1}, e_{n−1})

• p_{n} := F (e_{n−1}, p_{n−1}). Then

p_{n} ∘ e_{n} = id_{D_{n}} :

n = 0 is clear and

p_{n+1} ∘ e_{n+1} = F (e_{n}, p_{n}) ∘ F (p_{n}, e_{n})
= F (p_{n} ∘ e_{n}, p_{n} ∘ e_{n})
=^{IV} F (id, id) = id .

Further

e_{n} ∘ p_{n} ⊑ id_{D_{n+1}} :
e_{0} ∘ p_{0} ⊑ id_{D_{1}} ,
e_{n+1} ∘ p_{n+1} = F (p_{n}, e_{n}) ∘ F (e_{n}, p_{n})
= F (e_{n} ∘ p_{n}, e_{n} ∘ p_{n})
⊑^{IH} F (id, id) = id .

Therefore (e_{n}, p_{n}) is a sequence of embedding/projection pairs. By Lemma 2.12.6 there exists a cone of embedding/projection pairs

i_{n} : D_{n}→D, ρ_{n} : D→D_{n}

s.t.

• i_{n+1} ∘ e_{n} = i_{n},

• p_{n} ∘ ρ_{n+1} = ρ_{n},

• ⊔(i_{n} ∘ ρ_{n}) = id_{D}. Therefore

i_{n+1} ∘ F (i_{n}, ρ_{n}) = i_{n+1} ∘ F (i_{n+1} ∘ e_{n}, p_{n} ∘ ρ_{n+1})
= i_{n+1} ∘ F (e_{n}, p_{n}) ∘ F (i_{n+1}, ρ_{n+1})
= i_{n+1} ∘ p_{n+1} ∘ F (i_{n+1}, ρ_{n+1})
= i_{n+2} ∘ e_{n+1} ∘ p_{n+1} ∘ F (i_{n+1}, ρ_{n+1})
⊑ i_{n+2} ∘ id ∘ F (i_{n+1}, ρ_{n+1})
= i_{n+2} ∘ F (i_{n+1}, ρ_{n+1})
F (ρ_{n}, i_{n}) ∘ ρ_{n+1} = F (p_{n} ∘ ρ_{n+1}, i_{n+1} ∘ e_{n}) ∘ ρ_{n+1}
= F (ρ_{n+1}, i_{n+1}) ∘ F (p_{n}, e_{n}) ∘ p_{n+1} ∘ ρ_{n+2}
= F (ρ_{n+1}, i_{n+1}) ∘ e_{n+1} ∘ p_{n+1} ∘ ρ_{n+2}
⊑ F (ρ_{n+1}, i_{n+1}) ∘ id ∘ ρ_{n+2}
= F (ρ_{n+1}, i_{n+1}) ∘ ρ_{n+2}

Therefore there exists

β := ⊔(i_{n+1} ∘ F (i_{n}, ρ_{n})) ,
α := ⊔F (ρ_{n}, i_{n}) ∘ ρ_{n+1} .

and we get

β ∘ α = ⊔_{n,m∈ℕ}i_{n+1} ∘ F (i_{n}, ρ_{n}) ∘ F (ρ_{m}, i_{m}) ∘ ρ_{m+1}
= ⊔_{n,m∈ℕ}i_{n+1} ∘ F (ρ_{m} ∘ i_{n}, ρ_{n} ∘ i_{m}) ∘ ρ_{m+1}
= ⊔_{n,m∈ℕ}i_{n+1} ∘ F ({e_{n,m} \atop p_{n,m}}, {p_{m,n} \atop e_{m,n}}) ∘ ρ_{m+1}
= ⊔_{n,m∈ℕ}i_{n+1}∘ {p_{m+1,n+1} \atop e_{m+1,n+1}} ∘ρ_{m+1}
= ⊔_{n∈ℕ}i_{n+1} ∘ ρ_{n+1}
= id

α ∘ β = ⊔_{n,m∈ℕ}F (ρ_{n}, i_{n}) ∘ ρ_{n+1} ∘ i_{m+1} ∘ F (i_{m}, ρ_{m})
= ⊔_{n,m∈ℕ}F (ρ_{n}, i_{n})∘ {p_{m+1,n+1} \atop e_{m+1,n+1}} ∘F (i_{m}, ρ_{m})
= ⊔_{n,m∈ℕ}F (ρ_{n}, i_{n}) ∘ F ({e_{n,m} \atop p_{n,m}}, {p_{m,n} \atop e_{m,n}}) ∘ F (i_{m}, ρ_{m})
= ⊔_{n,m∈ℕ}F (id, id)
= id

Therefore β is an isomorphism, α = β^{−1}.

2.12.2 D_{∞} and other λ-models

Definition 2.12.9 (a) D_{∞} is defined as the in Lemma 2.12.8 constructed cpo where

• F (A, B) := A→B, F (g, f)(h) := f ∘ h ∘ g.

• D_{0} := ℕ_{⊥}.

• e_{0}(n) := λ\ m.n, p_{0}(f) := f(⊥).

(b) Let α : D_{∞}→[D_{∞}→D_{∞}] be the isomorphism, β its inverse.

Define · : D_{∞} × D_{∞}→D_{∞}, a · b := α(a)(b).

Define Λ := id_{D_{∞}} : D_{∞}→D_{∞}.

Theorem 2.12.10 (D_{∞}, ·, Λ) is a λ-model.

Proof: Let

k := β(λ\ a.β(λ\ b.a))
s := β(λ\ a.β(λ\ b.β(λ\ c.α(α(a)(c))(α(b)(c))))

2.12. THE λ-MODEL D_{∞} (12) 119

k, s are well-defined and

k · a · b = α(α(β(λ\ a.β(λ\ b.a)))(a))(b)
= α(β(λ\ b.a))(b)
= a ,
s · a · b · c
= α(α(α(β(λ\ a.β(λ\ b.β(λ\ c.α(α(a)(c))(α(b)(c))))))(a))(b))(c)
= α(α(β(λ\ b.β(λ\ c.α(α(a)(c))(α(b)(c)))))(b))(c)
= α(α(a)(c))(α(b)(c))
= a · c · (b · c) .

(D_{∞}, ·) is extensional, since if a ∼ b, then

∀c ∈ D_{∞}.α(a)(c) = a · c = b · c = α(b)(c)

α(a) = α(b) ,
a = b .

Therefore by Theorem 2.11.22

(D_{∞}, ·, λ\ d.d)

is a λ-model. Remark 2.12.11 In the above we could have replaced ℕ_{⊥} by any other (nontrivial) cpo. All the proofs above remain as before. Definition 2.12.12 Let D := D_{∞}, D_{n} as in the construction of D_{∞}, i.e.

• D_{0} := ℕ_{⊥},

• D_{n+1} := F (D_{n}, D_{n}), where

• F (D, E) = [D→E], F (g, f)(h) = f ∘ h ∘ g. For σ being an assignment of variables in D, M a λ-terms define [[ M ]]_{σ}^{n} ∈ D_{n} as follows:

• [[ x ]]_{σ}^{n} := ρ_{n}(σ(x)).

• [[ M N ]]_{σ}^{n} := [[ M ]]_{σ}^{n+1}([[ N ]]_{σ}^{n}).

• [[ λx.M ]]_{σ}^{0} := p_{0}(λ\ d ∈ D_{0}.[[ M ]]_{σ_{x}^{i_{0}(d)}}^{0}),

[[ λx.M ]]_{σ}^{n+1} := λ\ d ∈ D_{n}.[[ M ]]_{σ_{x}^{in(d)}}^{n}. (where one simultaneously shows immediately, that

λ\ d_{1}, …, d_{m} ∈ D.[[ M ]]_{σ_{x_{1}}^{d_{1}} _{x_{2}}^{d_{2}} ···_{xm}^{dm}}^{n} ∈ [D^{m}→D_{n}] ).

Lemma 2.12.13 Let M be a λ-term, σ be an assignment.

(a) i_{n}([[ M ]]_{σ}^{n}) ⊑ i_{n+1}([[ M ]]_{σ}^{n+1}).

(b) [[ M ]]_{σ} = ⊔_{n∈ℕ}i_{n}([[ M ]]_{σ}^{n}).

Proof: Let

α := ⊔(F (ρ_{n}, i_{n}) ∘ ρ_{n+1}) : D→F (D, D)
β := ⊔(i_{n+1} ∘ F (i_{n}, ρ_{n})) : F (D, D)→D

the inverse isomorphisms. We prove both (a) and (b) by induction on M: Case M ≡ x:

i_{n}([[ M ]]_{σ}^{n}) = i_{n}(ρ_{n}(σ(x)))
= (i_{n} ∘ ρ_{n})(σ(x)) .

Therefore it follows (a) by

i_{n} ∘ ρ_{n} ⊑ i_{n+1} ∘ ρ_{n+1}

and (b) by

⊔_{n∈ℕ}i_{n} ∘ ρ_{n} = id .

Case M ≡ P Q:

i_{n}([[ P Q ]]_{σ}^{n})
= i_{n}([[ P ]]_{σ}^{n+1}([[ Q ]]_{σ}^{n}))
= i_{n}((ρ_{n+1}(i_{n+1}([[ P ]]_{σ}^{n+1})))(ρ_{n}(i_{n}([[ Q ]]_{σ}^{n}))))
= (i_{n} ∘ ρ_{n+1}(i_{n+1}([[ P ]]_{σ}^{n+1})) ∘ ρ_{n})(i_{n}([[ Q ]]_{σ}^{n}))
= (F (ρ_{n}, i_{n}) ∘ ρ_{n+1})(i_{n+1}([[ P ]]_{σ}^{n+1}))(i_{n}([[ Q ]]_{σ}^{n}))

Let

g(n, m, k) := (F (ρ_{n}, i_{n}) ∘ ρ_{n+1})(i_{m+1}([[ P ]]_{σ}^{m+1}))(i_{k}([[ Q ]]_{σ}^{k})) .

Then g(n, m, k) is monotone in n, m, k. Therefore

i_{n}([[ P Q ]]_{σ}^{n}) = g(n, n, n)
⊑ g(n + 1, n + 1, n + 1)
= i_{n+1}([[ P Q ]]_{σ}^{n+1}) ,

and

⊔_{n}i_{n}([[ P Q ]]_{σ}^{n})
= ⊔_{n}g(n, n, n)
= ⊔_{n,m,k}g(n, m, k)
= (⊔_{n}(F (ρ_{n}, i_{n}) ∘ ρ_{n+1}))(⊔_{m}(i_{m+1}([[ P ]]_{σ}^{m+1})))(⊔_{k}(i_{k}([[ Q ]]_{σ}^{k})))
= α([[ P ]]_{σ})([[ Q ]]_{σ}) .

2.12. THE λ-MODEL D_{∞} (12) 121 Case M = λx.P.

i_{0}([[ λx.P ]]_{σ}^{0}) = i_{0}(p_{0}(λ\ d ∈ D_{0}.[[ P ]]_{σ_{x}^{i_{0}(d)}}^{0}))
= i_{1}(λ\ d ∈ D_{0}.[[ P ]]_{σ_{x}^{i_{0}(d)}}^{0})
= i_{1}([[ λx.P ]]_{σ}^{1}) .

Further

i_{n+1}([[ λx.P ]]_{σ}^{n})
= i_{n+1}(λ\ d ∈ D_{n}.[[ P ]]_{σ_{x}^{in(d)}}^{n})
= i_{n+1}(λ\ d ∈ D_{n}.ρ_{n}(i_{n}([[ P ]]_{σ_{x}^{in(d)}}^{n})))
= i_{n+1}(ρ_{n} ∘ (λ\ d ∈ D.i_{n}([[ P ]]_{σ_{x}^{d}}^{n})) ∘ i_{n})
= (i_{n+1} ∘ F (i_{n}, ρ_{n}))(λ\ d ∈ D.i_{n}([[ P ]]_{σ_{x}^{d}}^{n})) .

By

i_{n}([[ P ]]_{σ_{x}^{d}}^{n}) ⊑ i_{n+1}([[ P ]]_{σ_{x}^{d}}^{n+1})

therefore

λ\ d ∈ D.i_{n}([[ P ]]_{σ_{x}^{d}}^{n}) ⊑ λ\ d ∈ D.i_{n+1}([[ P ]]_{σ_{x}^{d}}^{n+1})

further

i_{n+1} ∘ F (i_{n}, ρ_{n}) ⊑ i_{n+2} ∘ F (i_{n+1}, ρ_{n+1})

therefore

i_{n+1}([[ λx.P ]]_{σ}^{n}) ⊑ i_{n+2}([[ λx.P ]]_{σ}^{n+1})

Further by the monotonicity just mentioned it follows ⊔_{n}i_{n+1}([[ λx.P ]]_{σ}^{n})

= (⊔_{n}(i_{n+1} ∘ F (i_{n}, ρ_{n})))(⊔_{m}(λ\ d ∈ D.i_{m}([[ P ]]_{σ_{x}^{d}}^{m})))
= β(λ\ d ∈ D.[[ P ]]_{σ_{x}^{d}})
= Λ(β(λ\ d ∈ D.[[ P ]]_{σ_{x}^{d}}))
= [[ λx.P ]]_{σ} .

We can easily define a non-extensional λ-model as well: Definition 2.12.14 Let

D + E := Σ_{i∈{0,1}}D_{i}

where

D_{0} := D, D_{1} := E .

Let ι_{i} : D_{i}→D_{0} + D_{1}, be the two canonical embeddings. Let D be a non-trivial solution of the cpo-equation

D ≅ [D→D] + [D→D] .

α : D→([D→D] + [D→D])

be the isomorphism and β its inverse. Define

a · b := f(b), if α(a) = ι_{i}(f) .

Let

Λ_{i} : D→D, Λ_{i}(e) = β(ι_{i}(f)) if α(e) = ι_{k}(f) .

Then (D, ·, Λ_{i}) are two structures which fulfill conditions (a) - (c) of Definition 2.11.17. Further for j = 0, 1

e_{j,i} := β(ι_{j}(Λ_{i}))

are two different choices of e s.t. condition (d) is fulfilled as well, i.e.

(D, ·, Λ_{i})

are two λ-models based on the same combinatory algebra, which are both not extensional and have each at least two possible solutions for e.

2.13 The typed λ-Calculus

We will in the following introduce the typed λ-calculus and prove strong normalization of it. In the next section, we will introduce the Curry-Howard isomorphism and show, how to prove normalization of intuitionistic predicate logic from normalization of the typed λ-calculus. It will turn out, that the type σ→τ corresponds to A→B and ∀x.A, and prime formulas of minimal logic to the ground type o. Other formula constructions will correspond to other types:

• A ∨ B will correspond to a type σ + τ which corresponds to the disjoint union of the types σ and τ.

• A ∧ B will correspond to a type σ ×_{0} τ, and ∃x.A will correspond to a product type σ×_{1} τ, where ×_{0} and ×_{1} will be two choices of product types which differ in the choice of the elimination rule.

• Further for the ⊥ we need a new type ∅.

We will in the following follow partly [MJ98]. For the new types new λ-terms have to be introduced.

Definition 2.13.1 (a) The set of types Type is inductively defined by

• ∅, o ∈ Type.

• If σ, τ ∈ Type, then σ→τ, σ ×_{0} τ, σ ×_{1} τ, σ + τ ∈ Type.

In the following σ, ρ, τ, possibly with sub/superscripts and/or accents denote elements of Type.

2.13. THE TYPED λ-CALCULUS 123

(b) We define inductively the set of terms Term together with their types. Here s^{σ} or s : σ means: s is a term of type σ. There are infinitely many variables x^{σ} for every σ given. In the following x, y, z, u, v denote variables possibly with subscripts and/or indides, and x^{σ}, y^{σ}, z^{σ}, u^{σ}, v^{σ} (again with accents or subscrips) denote variables of type σ.

• x^{σ} is a term of type σ.

• If r, s are terms of types as given by their superscripts below, then

– (λx^{σ}.s^{τ})^{σ→τ},

– ⟨r^{σ}, s^{τ} ⟩_{i}^{σ×_{i}τ}, (i = 0, 1)

– (ι_{0,τ} r^{σ})^{σ+τ},

– (ι_{1,τ} r^{σ})^{τ+σ},

– (r^{σ→τ} s^{σ})^{τ},

– (r^{σ×_{0}τ} 0)^{σ},

– (r^{σ×_{0}τ} 1)^{τ},

– (r^{σ×_{1}τ} [λx^{σ}, y^{τ} .s^{ρ}])^{ρ},

– (r^{σ+τ} [λx^{σ}.s^{ρ}, λy^{τ} .t^{ρ}])^{ρ}

– (r^{∅} efq_{σ})^{σ}

are terms of the type indicated by the superscript.

The length (lgh(s)) of a term s is the number of steps in the above definition needed in order to derive that s is a term.

Brackets are omitted as usual.

The type index in ι_{i,τ}, and efq_{σ} is only needed to make the typing of a term unique, and will be usually omitted.

In the following all λ-terms occurring are assumed to be elements of Term, if [λx, y.s] occurs, s is assumed to be a term of the corresponding type, and if [λx.s, λy.t] occurs, s, t are typed terms of the corresponding type.

(c) Good elimination terms are terms, 0, 1. Term_{0,1} is the set of good elimination terms.

For A ⊆ Term let A_{0,1} := A ∪ {0, 1}.

In the following r, s, t possibly with sub/superscripts, accents denote terms, r⃗, s⃗, t⃗ with the same extensions denote sequences of terms, unless they are stated as elements of a set of terms or sequences of terms extended by 0, 1, in which case they are good elimination terms.

Elimination terms are good elimination terms, efq_{σ}, [λx.r, λy.s] and [λx, y.r].

In the following R, S, T with the usual extensions denote elimination terms and R⃗, S⃗, T⃗ with the same extensions denote sequences of elimination terms.

(d) Free, bounded variables, substitution, α-conversion is defined as usual. We will in the following identify α-equivalent terms.

(e) A^{∗} is the set of finite (possibly empty) sequences of elements of A.

(f) The reduction relation ⟶⊆ Term × Term is inductively defined by

• (λx.r) s ⟶ r[x := s],

• ⟨r_{0}, r_{1}⟩_{0} i ⟶ r_{i},

• ⟨r_{0}, r_{1}⟩_{1} [λx_{0}, x_{1}.s] ⟶ s[x_{0} := r_{0}, x_{1} := r_{1}],

• ι_{i}(r) [λx_{0}.s_{0}, λx_{1}.s_{1}] ⟶ s_{i}[x_{i} := r].

• (r efq_{σ} S)^{ρ} ⟶ r efq_{ρ}.

• r [λx, y.s] S ⟶ r [λx, y.s S] (x, y ∉ FV(S)).

• r [λx.s, λy.t] S ⟶ r [λx.s S, λy.t S] (x, y ∉ FV(S)). (The last three reductions are called “permutative conversions”).

• If r ⟶ r′ then – λx.r ⟶ λx.r′,

– ⟨r, s⟩_{i} ⟶ ⟨r′, s⟩_{i},

– ⟨s, r⟩_{i} ⟶ ⟨s, r′⟩_{i},

– ι_{i}(r) ⟶ ι_{i}(r′),

– r S ⟶ r′ S,

– s r ⟶ s r′,

– s [λx, y.r] ⟶ s [λx, y.r′],

– s [λx.r, λy.t] ⟶ s [λx.r′, λy.t],

– s [λx.t, λy.r] ⟶ s [λx.t, λy.r′].

(g) ⟶^{∗} is the reflexive transitive closure of ⟶.

Remark 2.13.2 (a) λx.s, ⟨r, s⟩_{i}, ι_{i}(r) introduce new elements of the corresponding type. Therefore these constructions are called introductions. r s, r i, r efq_{σ}, r [λx, y.s], r [λx.s, λy.t], correspond to the formation of a new element of a different type from r, and one says that one eliminates r. Therefore these constructions are called eliminations.

(b) The notations for the elimination of +, ×_{1} and ∅ are non-standard. Standardnotations are for (the choice of letters C, E, efq varies)

E(r, (x, y)s) for r [λx, y.s] ,
C(r, (x)s, (y)t) for r [λx.s, λy.t] ,
efq_{σ}(r) for r efq_{σ} .

We use our notations because it will simplify the following proofs quite a lot: successive eliminations applied to a term r can be written as r S⃗.

Theorem 2.13.3 ⟶ is Church-Rosser.

Proof: As before.

Lemma 2.13.4 (a) If r ⟶ r′ then

r[x := s] ⟶ r′[x := s] .

(b) If s ⟶ s′, then

r[x := s] ⟶^{∗} r[x := s′] .

Proof: Easy.

A term is strongly normalizing, if every reduction sequence terminates. A better way of defining normalizing is the following.

Definition 2.13.5 (a) We define inductively the subset SN of strongly normalizing terms by:

∀r′.(r→r′⇒r′ ∈ SN)⇒r ∈ SN .

(b) For s ∈ SN_{0,1} define height(s) by:

r ∈ SN ⇒ height(r) = max({height(r′) + 1 | r ⟶ r′}

∪ {0}) , height(0) := height(1) := 0 .

We note that α-equivalent terms have the same height and that, since a term reduces only (up to α-equivalence) to finitely many terms, the height of elements of SN_{0,1} is finite.

Proof that the strongly normalizing terms are exactly those s.t. every reduction sequence terminates: First it follows immediately by induction on s that if s ∈ SN then every reduction sequence terminates after at most height(s) reductions. On the other hand, assume s ∉ SN. Define a sequence s = s_{0} ⟶ s_{1} ⟶ s_{1} ⟶ ⋯ s.t. for all n s_{n} ∉ SN as follows: s_{0} := s. s_{n+1} is the (w.r.t the Gödelnumbering) least term s.t. s_{n} ⟶ s_{n+1}, s_{n+1} ∉ SN. s is not normalizing in the original sense.

Remark 2.13.6 If r ∈ SN, r ⟶ r′, then height(r′) < height(r).

Definition 2.13.7 We define inductively the subset terms in S̃N, where r⃗ ∈ S̃N_{0,1}^{∗}. S̃N is defined by the following rules (i.e. if the premisses are fulfilled the conclusion holds).

(Var^{0}) \frac{r⃗ ∈ S̃N_{0,1}^{∗}}{x r⃗ ∈ S̃N} (Var^{1}) r⃗ ∈ S̃N_{0,1}^{∗} y^{σ} S⃗ ∈ S̃N

x r⃗ efq_{σ} S⃗ ∈ S̃N
(Var^{2}) \frac{r⃗ ∈ S̃N_{0,1}^{∗} s S⃗ ∈ S̃N}{x r⃗ [λx, y.s] S⃗ ∈ S̃N}

(Var^{3}) r⃗ ∈ S̃N_{0,1}^{∗} s S⃗ ∈ S̃N t S⃗ ∈ S̃N

x r⃗ [λx.s, λy.t] S⃗ ∈ S̃N
(λ^{0}) \frac{r ∈ S̃N}{λx.r ∈ S̃N}  (⟨⟩_{i}^{0}) \frac{r ∈ S̃N s ∈ S̃N}{⟨r, s⟩_{i} ∈ S̃N}

(ι^{0}) \frac{r ∈ S̃N}{ι_{i}(r) ∈ S̃N}

(λ^{1}) \frac{r[x := s] S⃗ ∈ S̃N s ∈ S̃N}{(λx.r) s S⃗ ∈ S̃N} (⟨⟩_{0}^{1}) \frac{r_{i} S⃗ ∈ S̃N r_{1−i} ∈ S̃N}{⟨r_{0}, r_{1}⟩_{0} i S⃗ ∈ S̃N}

(⟨⟩_{1}^{1}) \frac{s[x_{0} := r_{0}, x_{1} := r_{1}] S⃗ ∈ S̃N r_{0} ∈ S̃N r_{1} ∈ S̃N}{⟨r_{0}, r_{1}⟩_{1} [λx_{0}, x_{1}.s] S⃗ ∈ S̃N}

(ι^{1}) \frac{s_{i}[x_{i} := r] S⃗ ∈ S̃N s_{1−i} ∈ S̃N r ∈ S̃N}{ι_{i}(r) [λx_{0}.s_{0}, λx_{1}.s_{1}] S⃗ ∈ S̃N}

The length of a derivation of r ∈ S̃N (lghS̃N) is the number of rules needed for deriving r ∈ S̃N. This extends to r ∈ S̃N_{0,1} by lghS̃N(0) := lghS̃N(1) := 0.

Lemma 2.13.8

r ∈ SN⇔r ∈ S̃N

Remark: For the proof of the strong normalization theorem only ⇒ is really needed (we will prove that all typed terms are in S̃N and therefore in SN), although we will for convenience make use of that fact. But it is interesting to see that S̃N is just another definition of SN.

Proof: “⇒” (Soundness) We show for all rules of S̃N:

• If the premise holds with S̃N, S̃N_{0,1} replaced by SN, SN_{0,1},

• then the conclusion holds as well with the same replacement.

This will be proved for all rules by induction on the sum of the heights of the terms and elimination terms in the premise, and in case of (Var^{1}), (Var^{2}), (Var^{3}), (⟨⟩_{1}^{1}), (ι^{1}) by side-induction on the number of elimination terms in S⃗. Case (Var^{0}): If x r⃗ ⟶ t then t ≡ x r⃗_{0} r_{i} r⃗_{1} with r⃗ ≡ r⃗_{0} r′_{i} r⃗_{1} and r_{i} ⟶ r′_{i}. By IH t ∈ SN. Cases (Var^{1}), (Var^{2}), (Var^{3}), (λ^{0}), (⟨⟩_{i}^{0}), (ι^{0}): Again if the concluding term reduces to t, t can be derived by the same rule with sum of the heights of the premises smaller, or in the main case of a permutative conversion in (Var^{i}) by the same rule with the same premises (or with height ≤ the height of a premise), but with shorter S⃗. By IH follows t ∈ SN. Cases (λ^{1}), (⟨⟩_{i}^{1}), (ι^{1}): If the concluding term reduces to t, t is either the first premise, or (using Lemma 2.13.4) it can be derived by the same rule with sum of the heights of the premises smaller, or it is the result of a permutative conversion with the elimination term explicitely written in case (⟨⟩_{i}^{1}), (ι^{1}), and can be derived by the same rule, but with reduced length of S⃗. Therefore by main or side-IH t ∈ SN. “⇐” (Completeness) We show for all rules by induction on the height of the concluding term:

• If the conclusion holds with S̃N replaced by SN, then the premise holds with S̃N, S̃N_{0,1} replaced by SN, SN_{0,1}.

• If s is the term in the conclusion and r a term in the premise, then

height(r) < height(s) ∨ (height(r) = height(s) ∧ lgh(r) < lgh(s)) .

Since every term is the conclusion of one rule follows than by induction on height(s), side-induction on lgh(s)

s ∈ SN⇒s ∈ S̃N .

Case (Var^{i}), (λ^{0}), (⟨⟩_{i}^{0}), (ι^{0}): The height of the premises will be less than or equal the height of the conclusion and the length of them is less than the length of the concluding term: For the length this is clear and if for a premise r we have r ⟶ r′, than for the conclusion s there is a term s′ s.t. s ⟶ s′ and s′ can be derived from the same premises or a reduct of them and from r′. By IH these new premises are in SN_{0,1}, therefore r′ ∈ SN and therefore r as well and the assertion concerning the height follows. Case (λ^{1}), (⟨⟩_{i}^{1}), (ι^{1}): The first premise is a reduct of the conclusion therefore an element of SN with smaller height. The other premises have height less than or equal the conclusion and smaller length, by the same proof as before, using Lemma 2.13.4.

Lemma 2.13.9 (a) If t ∈ {(λx.r), ι_{i}(r), ⟨r, s⟩_{i}, ⟨s, r⟩_{i}, r R⃗, s r, s [λx, y.r], s [λx.r, λy.r′], s [λy.r′, λx.r]}, t ∈ S̃N, then r ∈ S̃N.

(b) r ∈ S̃N⇔r[x := y] ∈ S̃N.

Proof: (a) t ∈ S̃N, then t ∈ SN, and every reduction in r corresponds to a reduction in t, therefore by induction on height(t) it follows r ∈ SN = S̃N. (Induction on t ∈ S̃N is as well possible, but then one needs to prove as well: r[x := s] ∈ S̃N⇒r ∈ S̃N).

(b) Induction on the derivation of r ∈ S̃N or r[x := y] ∈ S̃N.

Lemma 2.13.10 For all types ρ and all r ∈ S̃N it follows

(a) If ρ ≡ ρ_{0}→ρ_{1}, r : ρ, s ∈ S̃N, then r s ∈ S̃N.

(b) If ρ ≡ ρ_{0} ×_{0} ρ_{1}, r : ρ then r 0, r 1 ∈ S̃N.

(c) If ρ ≡ ∅, r : ρ, y T⃗ ∈ S̃N, then r efq_{σ} T⃗ ∈ S̃N.

(d) If ρ ≡ ρ_{0} ×_{1} ρ_{1}, r : ρ, t T⃗ ∈ S̃N, then r [λx_{0}, x_{1}.t] T⃗ ∈ S̃N.

(e) If ρ ≡ ρ_{0} + ρ_{1}, r : ρ, t_{0} T⃗, t_{1} T⃗ ∈ S̃N, then r [λx_{0}.t_{0}, λx_{1}.t_{1}] T⃗ ∈ S̃N.

(f) If s^{ρ} ∈ S̃N then r[x^{ρ} := s^{ρ}] ∈ S̃N.

Proof: We prove (a) - (f) simultaneously by induction on ρ: Proof of (a) - (e) simultaneously by side-induction on r. Let the conclusion be r R⃗ ∈ S̃N: Case r ≡ x r⃗: r ∈ S̃N is derived by (Var^{0}). (a), (b) follows by (Var^{0}), (c) by (Var^{1}), (d) by (Var^{2}) (e) by (Var^{3}). Case r ≡ x r⃗ [λx_{0}, x_{1}.s] S⃗: then r ∈ S̃N is derived by (Var^{2}) from r_{i} ∈ S̃N_{0,1}, s S⃗ ∈ S̃N. The type of s S⃗ is the same as that of r and it is derived as an element of S̃N before r, therefore by side-IH it follows s S⃗ R⃗ ∈ S̃N and therefore r R⃗ ∈ S̃N. Case r ≡ x r⃗ efq_{σ} T⃗ or r ≡ x r⃗ [λx_{0}.s_{0}, λx_{1}.s_{1}] S⃗: similarly. Case r ≡ λx.r′ derived by (λ^{0}). Only (a) is possible, by main IH for (f) it follows r′[x := s] ∈ S̃N and therefore by (λ^{1}) r s ∈ S̃N. Case r ≡ ⟨r_{0}, r_{1}⟩_{0} derived by (⟨⟩_{0}^{0}). Only (c) is possible, and the conclusion follows by (⟨⟩_{0}^{1}). Case r ≡ ⟨r_{0}, r_{1}⟩_{1} derived by (⟨⟩_{1}^{0}): Only (d) is possible. By Lemma 2.13.9

(b) w.l.o.g. x_{i} ∉ FV(T⃗). Now we have

• r_{i} ∈ S̃N.

• By t T⃗ ∈ S̃N, r_{i} having type ρ_{i} smaller than ρ, main IH for (f) it follows t[x_{0} := r_{0}, x_{1} := r_{1}] T⃗ ≡ (t T⃗)[x_{0} := r_{0}, x_{1} := r_{1}] ∈ S̃N.

Therefore by (⟨⟩_{1}^{1}) it follows r R⃗ ∈ S̃N. Case r ≡ ι_{i}(r′) derived by (ι^{0}): Similarly, but we use additionally that from t_{1−i} T⃗ ∈ S̃N it follows t_{1−i} ∈ S̃N.

Case r ∈ S̃N derived by (λ^{1}), (⟨⟩_{i}^{1}), (ι^{1}). By side-IH follows the first premise for deriving r R⃗ ∈ S̃N, the other premises are the same as for r ∈ S̃N, therefore r R⃗ ∈ S̃N. Proof for (f) by side-induction on r: We will additionally use that (a) -

(e) is proved for ρ by the proof before. Case r ≡ y r_{1} ⋯ r_{n}, r_{i} ∈ S̃N. By side-IH

r_{i}[x := s] ∈ S̃N .

If x ≢ y follows the assertion by (Var^{0}), and if x ≡ y it follows by (a), (b), where we use the main IH or the just proved assertion for ρ. Case r ≡ y r_{1} ⋯ r_{n} [λx_{0}, x_{1}.t] S⃗ derived from r_{i} ∈ S̃N_{0,1}, s S⃗ ∈ S̃N. W.l.o.g. x_{i} ≢ x. By main IH

r_{i}[x := s] ∈ S̃N_{0,1} ,

and by side-IH

t S⃗[x := s] ∈ S̃N .

If x ≢ y follows by (Var^{2}) the assertion and if x ≡ y it follows by (a) - (e), where we use the main IH or the just proved assertion for ρ. Case r ≡ y r_{1} ⋯ r_{n} [λx_{0}.s_{0}, λx_{1}.s_{1}] S⃗, r ≡ y r_{1} ⋯ r_{n} efq_{σ} S⃗: Similarly. All other cases follow immediately by side-IH for (f).

Theorem 2.13.11 r ∈ SN.

Proof: By induction on the length of r using Lemma 2.13.10.

Definition 2.13.12 (a) A term r is in normal form iff ¬∃r′.r ⟶ r′.

(b) The set of terms NF is inductively defined as:

• x ∈ NF.

• If r_{i}, s, t ∈ NF_{0,1}, so are

– x r_{1} ⋯ r_{n},
– x r_{1}, …, r_{n} efq,
– x r_{1} ⋯ r_{n} [λy, z.s] and
– x r_{1} ⋯ r_{n} [λy.s, λz.t].

• If r, s ∈ NF, so are

λx.s, ⟨r, s⟩_{i}, ι_{i}(r) .

Lemma 2.13.13 r ∈ NF iff r is in normal form.

Remark: This means that terms in normal form are those which are the result of applying successively introduction steps to terms which are the result of applying successively eliminations to variables, where only the last elimination is an +-elimination, and such that for all terms used in eliminations the same holds. Proof of Lemma 2.13.13: “⇒”: immediate. “⇐”: Induction on lgh(r). If

r = λx.r′, ι_{i}(r′) ,

by IH r′ ∈ NF, r ∈ NF. If

r = ⟨r′, s′⟩_{i} ,

by IH r′, s′ ∈ NF, r ∈ NF. Otherwise

r = r_{0} R_{1} ⋯ R_{n} ,

s.t. r_{0} is not of the form

s S .

Then r_{0} must be a variable,

R_{0}, …, R_{n−1} ∈ Term_{0,1} ,
R_{i} ∈ NF_{0,1}(i=0 , …, n-1) ,
R_{n} ∈ NF_{0,1} or R_{n} ≡ efq or
R_{n} ≡ [λx, y.s] or R_{n} ≡ [λx.s, λy.t] with s, t ∈ NF ,
r ∈ NF .

Definition 2.13.14 (a) A term in normal form is in long η-normal form, iff for all maximal subterms of the form

s = x r_{1} ⋯ r_{n} R

it holds that

s : o or s : ∅ or R is of the form efq, [λx, y.t] or [λx.t_{0}, λy.t_{1}] .

(b) The set of terms η − NF is inductively defined as:

• If r_{i} ∈ (η − NF)_{0,1} (i = 1, …, n), x r_{1} ⋯ r_{n} : σ where σ ∈ {o, ∅},

then

x r_{1} ⋯ r_{n} ∈ (η − NF) .

• If r_{i}, s, t ∈ (η − NF)_{0,1}, then

x r_{1} ⋯ r_{n} efq, x r_{1} ⋯ r_{n} [λx, y.s], x r_{1} ⋯ r_{n} [λy.s, λz.t] ∈ η − NF .

2.13. THE TYPED λ-CALCULUS 131

• If r, s ∈ η − NF, so are

λx.s, ⟨r, s⟩_{i}, ι_{i}(r) ∈ η − NF .

(c) For terms of the form r ≡ x r_{1} ⋯ r_{n} with r_{i} ∈ Term_{0,1}, r : ρ we define

exp(r) by induction on ρ by: • If ρ = 0 or ρ = ∅, then exp(r) := r.

• If ρ = σ→τ, then exp(r) := λx.exp(r exp(x)) for a new variable x.

• If ρ = σ ×_{0} τ, exp(r) := ⟨exp(r 0), exp(r 1)⟩_{0}

• If ρ = σ ×_{1} τ, exp(r) := r [λx, y.⟨exp(x), exp(y)⟩_{1}].

• If ρ = σ + τ, exp(r) := r [λx.ι_{0}(exp(x)), λx.ι_{1}(exp(x))].

(d) We define for terms r in normal form by induction on the length of r the

η-expansion r^{η}:

• (x r_{0} ⋯ r_{n})^{η} := exp(x r_{0}^{η} ⋯ r_{n}^{η}).

• (x r_{0} ⋯ r_{n} efq)^{η} := x r_{0}^{η} ⋯ r_{n}^{η} efq.

• (x r_{0} ⋯ r_{n} [λx, y.s])^{η} := x r_{0}^{η} ⋯ r_{n}^{η} [λx, y.s^{η}].

• (x r_{0} ⋯ r_{n} [λx.s, λy.t])^{η} := x r_{0}^{η} ⋯ r_{n}^{η} [λx.s^{η}, λy.t^{η}].

• (λx.r)^{η} := λx.r^{η}.

• ⟨r, s⟩_{i}^{η} := ⟨r^{η}, s^{η}⟩_{i}.

• ι_{i}(r)^{η} := ι_{i}(r^{η}). Lemma 2.13.15 (a) r is in long η-normal form if r ∈ η − NF.

(b) If r ≡ x r_{1} ⋯ r_{n}, r_{i} ∈ (η − NF)_{0,1}, then exp(r) ∈ η − NF.

(c) If r is in normal form, then r^{η} ∈ η − NF. Proof: Easy Remark: η-reductions can now be defined for terms in normal form as follows: Take a maximal subterm of r of the form

s ≡ x r_{0} ⋯ r_{n} R : ρ .

Assume that then R ∈ Term_{0,1} and ρ is not a type o or ∅. Then replace s by

• λx.s x för x fresh,

• ⟨s 0, s 1⟩_{0},

• s [λx, y.⟨x, y⟩_{1}] or

• s [λx.ι_{0}(x), λx.ι_{1}(x)] (depending on the type of s). One can show now that η-reductions reduce a term t to its long η-normal form t^{η}.

2.14 The Curry-Howard Isomorphism

Assumption 2.14.1 In the following let L be some language for intuitionistic predicate logic.

Definition 2.14.2 (a) For every formula A in L we assign some type σ(A) (where ¬A is an abbreviation for A→⊥):

• If A is prime, A ≢ ⊥, then σ(A) := o.

• σ(⊥) := ∅.

• σ(A→B) := σ(A)→σ(B).

• σ(A ∨ B) := σ(A) + σ(B).

• σ(A ∧ B) := σ(A) ×_{0} σ(B).

• σ(∀x.A) := o→σ(A).

• σ(∃x.A) := o ×_{1} σ(A).

(b) We assume an assignment of either a formula A s.t. σ(A) = σ or, if σ = o,

the symbol nat, or if

σ = \underbrace{o→ ⋯ →o}_{n times} →o

an n-ary function symbol to every variable of type σ s.t. for every A and for nat there are infinitely many variables, to which this is assigned, and to every function symbol there is exactly one variable this is assigned.

We write

x^{A}, y^{A}, z^{A}

for variables to which A is assignment, sometimes as well

x : A, y : A, z : A

(as usual with indices and accents), and similarly with nat. We write f for the variable to which f is assigned.

Further we replace efq_{σ}, ι_{i,σ} by many copies efq_{A}, ι_{i,A} for every formula A s.t. σ(A) = σ, which are each treated as efq_{σ}, ι_{i,A} before.

(c) The set of ground terms r of type o with their assigned term t of L, written as r^{t} or r : t is inductively defined by:

•

x^{nat} : x .

• If f is a n-ary function symbol, s_{i} : t_{i}, then

f s_{1} ⋯ s_{n} : f(t_{1}, …, t_{n}) .

2.14. THE CURRY-HOWARD ISOMORPHISM 133 (d) The set of proof terms r together with the formula A it proves is induc-

tively defined by (we write r : A or r^{A} for r proves A)

• If A is a formula, then

x^{A} : A .

• If r : B, then

(λx^{A}.r) : A→B .

• If r : A, s : B then

⟨r, s⟩_{0} : A ∧ B .

• If r : A_{i}, then

ι_{i,A_{1−i}}(r) : A_{0} ∨ A_{1} .

• If r : A, x not free in B for y^{B} ∈ FV(r), then (λx^{nat}.r) : ∀x.A .

• If r : t, s : B[x := t], then

⟨r, s⟩_{1} : ∃x.B .

• If r : A→B, s : A, then

(r s) : B .

• If r : A_{0} ∧ A_{1}, then

(r i) : A_{i} .

• If r : A ∨ B, s : C, t : C, then (r [λx^{A}.s, λy^{B}.t]) : C .

• If r : ∀x.A, s : t, then

(r s) : A[x := t] .

• If r : ∃x.A, s : B, x ∉ FV(C) for y^{C} ∈ FV(s) then (r [λx^{nat}, y^{A}.s^{B}]) : B .

• If r : ⊥, then

(r efq_{A}) : A .

Brackets are omitted as usual.

(e) For each proof term r : A with free variables

x_{i}^{nat} (i = 1, …, n), y_{j}^{B_{j}} (j = 1, …, m) ,

and Γ s.t.

B_{i} ∈ Γ

assign we a derivation of Γ⇒A in natural deduction for intutionistic predicate calculus (without equality) (more precisely in the following the derivation depends on the choice of Γ, but this influences only the choice of weakenings):

• x^{A} corresponds

\begin{aligned}& A⇒A \\ (Weak) \\ & Γ⇒A \end{aligned}

• λx^{A}.r^{B} corresponds to

\begin{matrix}[r^{B}] \\ Γ, A⇒B \end{matrix} ; (→−I) ; Γ⇒A→B

• ⟨r^{A}, s^{B}⟩_{0} corresponds to

\begin{matrix}r^{A} \\ Γ⇒A \end{matrix}  \begin{matrix}s^{B} \\ Γ⇒B \end{matrix} (∧−I) Γ⇒A ∧ B

• ι_{i,A_{1−i}}(r^{A_{i}}) corresponds to

\begin{matrix}r^{A_{i}} \\ Γ⇒A_{i} \end{matrix} ; (∨−I)_{i} ; Γ⇒A_{0} ∨ A_{1}

• λx^{nat}.r^{A} corresponds to (where Δ are the formulas in Γ in which x does not occur free)

\begin{matrix}r^{A} \\ Δ⇒A \end{matrix} ; (∀−I) ; Δ⇒∀x.A (Weak) Γ⇒∀x.A

• ⟨r^{t}, s^{B}[x := t]⟩_{1} corresponds to

\begin{matrix}s^{B[x:=t]} \\ Γ⇒B[x := t] \end{matrix} (∃−I) Γ⇒∃x.B

• r^{A→B} s^{A} corresponds to

\begin{matrix}r^{A→B} \\ Γ⇒A→B \end{matrix}  \begin{matrix}s^{A} \\ Γ⇒A \end{matrix} (→−E) Γ⇒B

• r^{A_{0}∧A_{1}} i corresponds to

\begin{matrix}r^{A_{0}∧A_{1}} \\ Γ⇒A_{0} ∧ A_{1} \end{matrix} (∧−E_{i}) Γ⇒A_{i}

• r^{A∨B}[λx^{A}.s^{C}, λx^{B}.t^{C}] corresponds to

\begin{matrix}r^{A∨B} \\ Γ⇒A ∨ B \end{matrix}  \begin{matrix}s^{C} \\ Γ, A⇒C \end{matrix}  \begin{matrix}t^{C} \\ Γ, B⇒C \end{matrix} (∨−E) Γ⇒C
• r^{∀x.A} s^{t} corresponds to

\begin{matrix}r^{∀x.A} \\ Γ⇒∀x.A \end{matrix} ; (∀−E) ; Γ⇒A[x := t]

• r^{∃x.A}[λx^{nat}, y^{A}.s^{B}] corresponds to (where Δ are the formulas in Γ in which x does not occur free)

\begin{matrix}r^{∃x.A} \\ Γ⇒∃x.A \end{matrix}  \begin{matrix}s^{B} \\ Δ, A⇒B \end{matrix} (∃−E) Γ, Δ⇒B

• r^{⊥} efq_{A} corresponds to

\begin{matrix}r^{⊥} \\ Γ⇒⊥ \end{matrix} ; (EFQ) ; Γ⇒A

Remark: The above is the first part of the

Curry-Howard isomorphism,

in which to every one assigns to every proof of natural deduction a typed λterm. The second part will be, that normalization of the typed λ-calculus corresponds to normalization of proofs. If we identify all prime-formulas except ⊥, then elements of

σ(A)

in the standard intepretation of the types correspond to proofs in the Brouwer-Heyting-Kolmogorov-interpretation of the logical connectives (here o is interpreted as an arbitrary subset of the natural numbers, even possible empty, corresponding to the set of proofs of this prime-formula, about which BHK does not say anything):

• A BHK-proof of

A→B

is a method transforming an proof of A into a proof of B. An element of

σ(A)→σ(B)

is an algorithm, mapping elements of σ(A) to elements of σ(B).

• A BHK-proof of

A ∨ B

is a proof of A or a proof of B plus the information, which one it is. An element of

σ(A) + σ(B)

is either an element of σ(A) or of σ(B) plus the information which one it is. Etc.

Not every λ-term of type σ(A) will correspond now to a proof of A, since not all prime-formulas are equivalent. E.g. if

P ≢ Q

are diffferent prime-formulas, then

λx^{P} .x

is of type

σ(P →Q)

but not a proof of

P →Q .

However, every λ-term assigned to a proof in natural deduction is of course a proof of the corresponding formula, the set of terms build according the above is a subset of the λ-terms of type σ(A).

Definition 2.14.3 (a) In the following we assume, that if A ≢ A′, x_{i}^{A} ∈ FV(r) ∪ BV(r) for a proof term t, then x_{i}^{A′} ∉ FV(r) ∪ BV(r), similarly for A vs. nat.

(b) Two proof terms are α-equivalent,

if they are identical up to α-equivalence or replacing of bounded variables x^{A} by x^{A′} for A and A′ not α-equivalent, and their corresponding natural deduction derivations coinicide up to α-conversion of formulas. (A definition of this directly on proof terms becomes quite complicated – the better way of defining it directly is by defining it as α-equivalence of corresponding Martin-Löf type theory derivations).

(c) Substitution

r[x^{A} := s]

of an assumption variable x^{A} by a proof term s : A in a derivation r : B is defined as ordinary substitution, but by renaming of variables in such a way that the result is a proof term, in which all assumptions A indicated by

x^{A}

are replaced by the proof s, and other bounded variables possibly renamed s.t. all formulas remain α-equivalent.

Similarly

r[x^{nat} := s]

is defined for s : t, s.t. in the corresponding derivation, all formulas B, in which x is not later bound, are replaced by

B[x := s]

up to α-conversion.

Again a formal definition is better given in the context of Martin-Löf type theory.

(d) We identify in the following α-equivalent proof terms and formulas.

Lemma 2.14.4 (a) If r : A then r is a term of type σ(A).

(b) If

r : A, s : t ,

r has assumption variables

y_{1}^{A_{1}}, …, y_{m}^{A_{m}} ,

then

r[x := s] : A[x := t]

with assumption variables

y_{1}^{A_{1}[x:=t]}, …, y_{m}^{A_{m}[x:=t]} .

(c) If

r : A, s : B ,

r has assumption variables

y_{1}^{A_{1}}, …, y_{m}^{A_{m}}

and possibly y^{B}, then

r[y^{B} := s] : A ,

and has assumption variables

y_{1}^{A_{1}}, …, y_{m}^{A_{m}} .

Proof: Immediate (if one wants this precise, one better does it in the context of Martin-Löf type theory).

Theorem 2.14.5 Assume

r : A, r ⟶ s ,

and that, when substitutions are carried out, renamings of variables are carried out in accordance with Lemma 2.14.4. Then

s : A .

Proof: Immediate by Lemma 2.14.4.

We will look now at all reductions and see, what proof transformations are carried out. Further we will look at, how to justify them with the BHK-interpretation.

(λx.r) s ⟶ r[x := s] .

(λx^{A}.r^{B}) s^{A} corresponds to the following proof:

\begin{aligned}{[x^{A} : A] \atop ·} ; · ; · & {[x^{A} : A] \atop ·} ; · ; · & {[x^{A} : A] \atop ·} ; · ; · \\ & r : B \end{aligned} ; (→−I) ; λx.r : A→B  s : A (→−E) (λx.r) s : B

The proof r[x := s] is as follows:

\begin{aligned}{s : A \atop ·} ; · ; · & {s : A \atop ·} ; · ; · & {s : A \atop ·} ; · ; · \\ & r[x := s] : B \end{aligned}

So we replace in the proof r of A those assumptions of A denoted by

x^{A}

by the direct proof

s : A

and get therefore a proof of B, which does not make the detour via an introduction and then an elimination. In the BHK-interpretation this correponds to the following: Take a proof of B from a hypothetical proof of A. We get a proof of

A→B

as the function, which takes a proof of A and uses the method above to obtain a proof of B.

Instead we can however replace the hypothetical proof of A by the concrete proof of A in the proof of B and get again a proof of

B .

Note that the λ-term and therefore the proof as well might become longer, if the variable x occurs more than once. The above corresponds to the elimination of a lemma: If we have a lemma A and have a proof of B using as assumption A, then we get a proof of B without using A by making an →-introduction w.r.t. A and then an →-elimination with the proof of the lemma. We can get a direct proof of B by replacing each use of the lemma by a direct proof. If we use the lemma at most once, the resulting proof has the same size or shorter (if the length of the proof of the lemma is taken into consideration). However, if we use the lemma more than once, the direct proof will be longer. The other reductions (except permutative conversions) correspond to a generalization of the elimination of lemmata.

⟨r_{0}^{A_{0}}, r_{1}^{A_{1}}⟩_{0} i ⟶ r_{i} .

⟨r_{0}^{A_{0}}, r_{1}^{A_{1}}⟩_{0}) 0 corresponds to the following proof:

r_{0} : A_{0}  r_{1} : A_{1} (∧−I) ⟨r_{0}, r_{1}⟩_{0} : A_{0} ∧ A_{1} (∧−E) r_{i} : A_{i}

The reduced proof r_{i} is as follows:

r_{i} : A_{i}

In the BHK interpretation, one started with a proof of A_{0} and of A_{1}, got a proof of

A_{0} ∧ A_{1}

by forming the pair of proofs and then a proof of

A_{i}

by taking the ith component. However we could have taken directly the ith component. This reduction always reduces the length of the λ-term, but we might arrive at this reduction only after several other reduction steps.

ι_{i}(r^{A_{i}}) [λx_{0}^{A_{0}}.s_{0}^{D}, λx_{1}^{A_{1}}.s_{1}^{D}] ⟶ s_{i}^{D}[x_{i} := r] .

ι_{i}(r^{A_{i}}) [λx_{0}^{A_{0}}.s_{0}^{D}, λx_{1}^{A_{1}}.s_{1}^{D}] corresponds to the following derivation:

\begin{aligned}& r : A_{i} \\ (∨−I) \\ & ι_{i}(r) : A_{0} ∨ A_{1} \end{aligned}  {x_{0} : A_{0} \atop ·} ; · ; · ; s_{0} : D  {x_{1} : A_{1} \atop ·} ; · ; · ; s_{1} : D (∨−E)
ι_{i}(r^{A_{i}}) [λx_{0}^{A_{0}}.s_{0}^{D}, λx_{1}^{A_{1}}.s_{1}^{D}] : D

s_{i}[x_{i} := r] corresponds to

{r : A_{i} \atop ·} ; · ; · ; s_{i} : D

So we replace in the proof s_{i} of D all assumptions marked by

x_{i}^{A_{i}}

by the proof

r : A_{i} .

Note that this proof might be longer than the original proof. The relationship to the BHK-interpretation is again clear and will be omitted in the following.

(λx^{nat}.r^{A}) s^{t} ⟶ r[x := s]^{A[x:=t]} .

(λx^{nat}.r) s corresponds to the following derivation:

{x^{nat} \atop ·} ; · ; · ; r : A (∀−I) λx^{nat}.r : ∀x.A (∀−E) (λx^{nat}.r) s : A[x := t]

r[x := s] corresponds to

{s^{t} \atop ·} ; · ; · ; r[x := s] : A[x := t]

So we replace in the proof of A all occurrences of x by s and obtain a direct proof of A[x := t].

⟨r^{nat}, s^{A}⟩_{1} [λx^{nat}, y^{A}.t^{D}] ⟶ t[x := r, y := s] .

⟨r^{t}, s_{0}^{A[x:=t]}⟩_{1} [λx^{nat}, y^{A}.s_{1}^{D}] corresponds to

s_{1}[x := r, y := s_{0}] corresponds to

\begin{aligned}r^{nat} & s_{0} : A[z := r] \\ & · \end{aligned} ; · ; · ; s_{1}[x := r, y := s_{0}] : D

So we replace in the proof s_{1} of D, x by r and assumptions of A marked by y by the proof s of A[x := t].

r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.s_{0}^{C}, λx_{1}^{A_{1}}.s_{1}^{C}] R ⟶ r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.(s_{0}^{C} R), λx_{1}^{A_{1}}.(s_{1}^{C} R)] .

Let for instance C ≡ D→E, R is a term.

r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.s_{0}^{C}, λx_{1}^{A_{1}}.s_{1}^{C}] R

corresponds to

\begin{matrix}\begin{matrix}r : A_{0} ∨ A_{1} & {x_{0} : A_{0} \atop ·} ; · ; · ; s_{0} : D→E & {x_{1} : A_{1} \atop ·} ; · ; · ; s_{1} : D→E \\ r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.s_{0}^{C}, λx_{1}^{A_{1}}.s_{1}^{C}] : D→E \end{matrix} & R : D \\ r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.s_{0}^{C}, λx_{1}^{A_{1}}.s_{1}^{C}] R : E \end{matrix}

r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.s_{0}^{C} R, λx_{1}^{A_{1}}.s_{1}^{C} R] corresponds to

\begin{matrix}r : A_{0} ∨ A_{1} & \begin{matrix}{x_{0} : A_{0} \atop ·} ; · ; · ; s_{0} : D→E & R : D \\ s_{0} R : E \end{matrix} & \begin{matrix}{x_{1} : A_{1} \atop ·} ; · ; · ; s_{1} : D→E & R : D \\ s_{1} R : E \end{matrix} \\ r^{A_{0}∨A_{1}} [λx_{0}^{A_{0}}.s_{0}^{C} R, λx_{1}^{A_{1}}.s_{1}^{C} R] : E \end{matrix}

This reduction pushes the ∨-elimination as much down as possible (till an introduction is reached).

r^{∃x.A} [λx^{nat}, y^{A}.s^{C}] R ⟶ r^{∃x.A} [λx^{nat}, y^{A}.s^{C} R] .

Let for instance C ≡ ∃z.D, R ≡ [λz_{0}^{nat}, z_{1}^{D}.t^{E}]. r^{∃x.A} [λx^{nat}.y^{A}.s^{∃z.D}] [λz_{0}^{nat}, z_{1}^{D}.t^{E}] corresponds to

\begin{matrix}\begin{matrix}r : ∃x.A & \begin{aligned}x^{nat} & & y : A \\ & · \end{aligned} ; · ; · ; s : ∃z.D \\ r [λx, y.s] : ∃z.D \end{matrix} & \begin{aligned}z_{0}^{nat} & & z_{1}^{D} \\ & · \end{aligned} ; · ; · ; s : E \\ r [λx, y.s] [λz_{0}, z_{1}.s] : E \end{matrix}

r^{∃x.A} [λx^{nat}.y^{A}.s^{∃z.D} [λz_{0}^{nat}, z_{1}^{D}.t^{E}]] corresponds to

\begin{matrix}r : ∃x.A & \begin{matrix}\begin{aligned}x^{nat} & & y : A \\ & · \end{aligned} ; · ; · ; s : ∃z.D & \begin{aligned}z_{0}^{nat} & & z_{1}^{D} \\ & · \end{aligned} ; · ; · ; s : E \\ s [λz_{0}, z_{1}.s] : E \end{matrix} \\ r [λx, y.s [λz_{0}, z_{1}.s]] : ∃z.D \end{matrix}

Remark: A derivation in normal form looks now as follows: Its proof term is the result of application of introductions to a term which is the result of eliminations to a variable, and the same holds with all elimination terms. Therefore the derivation starts with an assumption (if we have additional axioms, they would be treated as assumptions), then several elimination rules are applied and to the final formal several introductions. Only the last of the elimination rules is an ∃- or ∨-elimination. A path from the derived formula through formulas proved by introduction rules and then through the main formulas of elimination rules till en assumed formula is called a main path (because of (∧ − I) there are several main path. Now the derivation of the side-formulas of elimination rules follows the same pattern, starting from assumptions (which can be in case of (∨ − E), (∃ − I) discharged assumption) through elimination rules and then introduction rules. The paths defined as the main path, but ending at a side-formula of an elimination rule are called side-paths.

Remark 2.14.6 All formulas in a normal derivation are subformulas of the derived formula or of assumptions.

Proof: Immediate, by the consideration before.

Lemma 2.14.7 If r is a proof term which derives A from assumption variables x_{i}^{A_{i}}, after renaming of variables r^{η} is a proof term deriving A from the same assumption variables Proof: First one shows that if

r_{i} : A_{i} normal orr_{i} ∈ {0, 1} ,

and

x r_{1} ⋯ r_{n}

is a proof term, then

exp(x r_{1} ⋯ r_{n})

is as well a proof term of the same formula with same assumption variables, by induction on the derived formula. Then one shows the assertion by induction on the length of r.

Remark: The η-expanded derivations is normal and has the property that if the last elimination rule of the path is not (∃-E) or (∨-E), then the resulting formula (or if there is no elimination rule at all the proved formula) is not of the form

A→B or A ∧ B .

144 CHAPTER 2. λ-CALCULUS AND COMBINATORY LOGIC

A Brief Introduction to Martin-Löf’s Type Theory

3.1 Motivation

In the last section we attached to a proof term two kinds of types: a simple type and a formula, which was something like a type. This led to some confusion and to technical problems. It is conceptually clearer, to treat formulas as real types. The first consequence is

• We need dependent types: In the rule (N will now be the set of natural

numbers)

\frac{r : ∀x : N.A(x) s : N}{r s : A(s)}

we see that the type A(x) depends on x : N.

Further we have that the types

∀x : N.B(x) and A→B

have the same rule for building elements (except that in A→B B does not depend on A). We write instead

Πx : N.B(x) and Πx : A.B .

Consequences

• Types which represent sets and which represents formulas (called in type theory propositions) can be identified.

• However, unless we restrict possibilities for building dependent basic formulas (those corresponding to prime formulas) to those built from elements of some basic types which represent sets only, types can now depend from proof terms.

• Therefore types have to be derived as terms. (E.g. the equality type

I(∀x : N.A(x), r, s)

which is the proposition

r, s are equal elements of ∀x : N.A(x)

can only be constructed, if we have proved before

r : ∀x : N.A(x)
s : ∀x : N.A(x) )

• Therefore we have two (so called) judgements:

A : type
r : A

• In order to organize equalities (w.r.t. α, β, η-conversion) we add two more judgements

A = B : type for A, B are (α, β, η-)equal types
r = s : A for A, B are (α, β, η-)equal elements of the type A .

The equality above is called judgemental equality.

In order to make sense of

∀x : N.A(x), A(s)

we introduce a dependend type structure on top of what we had before. The types before are now elements of a new type, called

Set ,

and A just mentioned is element of the type

N→Set .

Further because we have dependent types we need dependent judgements of the form

x_{1} : A_{1}, …, x_{n} : A_{n}⇒θ

where θ is a judgement as mentioned before.

3.2 The Logical Framework

The dependent λ-calculus on top of Set is called the logical framework (or a logical framework, there are variants). We will in the following first introduce rules of Martin-Löf’s type theory. We will then see and refer to an intuitive understanding what substitution

A[x := t]

and α conversion means. In the later Section 3.5 will we then give a precise definition of the language of Martin-Löf’s type theory and how substitution, α-conversion is defined. We will there distinguish between pre-types, which potentially occur as

A : type

(type will not be a pre-type) and pre-terms, objects which potentially occur as r in a judgement

r : A .

In the following

• a, b, c, n, f, g, r, s, t will be pre-terms,

• A, B, C pre-types,

• x, y, z, u, v, X, Y, Z variables (X, Y, Z stand for variabels which are supposed to be elements of real types whereas x, y, z, u, v are elements of sets),

• Δ, Γ pre-contexts (of the form x_{1} : A_{1}, …, x_{n} : A_{n}),

• θ pre-nondependent-judgements, i.e. expressions of the form r : A, r = s : A, A : type, A = B : type.

A judgement is an expression of the form

Γ⇒θ ,

with Γ, θ as before. We identify in the following α-equivalent pre-terms, pre-types, pre-contexts, pre-nondependent judgements and pre-judgements. We write

• ∅ for the empty context,

• θ (if used as a judgement) for ∅⇒θ.

Remark on the premisses of the rules: In the following rules some assumptions can be omitted. For instance it follows from the assumption

x : A⇒B : type

of (→-F)

A : type .

We take a choice which makes the rules look nice, so esthetic criteria govern our choice. The “official” version demands that all sub-judgements of a judgement have to be assumptions of the rule, where the set of subjudgements

D(Γ⇒A)

of a judgement Γ⇒A is defined as ( D^{+}(Γ⇒A) := D(Γ⇒A) ∪ {Γ⇒A} )

• D(Γ⇒A = B : type) := D^{+}(Γ⇒A : type) ∪ D^{+}(Γ⇒B : type).

• D(Γ⇒r = s : A : type) := D^{+}(Γ⇒r : A) ∪ D^{+}(Γ⇒s : A).

• D(Γ⇒r : A) := D^{+}(Γ⇒A : type).

• D(Γ, x : A⇒B : type) := D^{+}(Γ⇒Atype).

• D(∅⇒A : type) := ∅.

But this does not look very nice.

Assumption and Weakening

Γ⇒A : type

(Ass)

Γ, x : A⇒x : A

{Γ⇒A : type \atop Γ⇒θ} ; (Weak) ; Γ, x : A⇒θ (x ∉ FV(θ))

All the following rules, which are not axioms (i.e. no premisses) can be weakened by a context, i.e.

{Δ_{1}⇒θ_{1} \atop ⋯} ; Δ_{n}⇒θ_{n} (Rule ) Δ⇒θ

(n > 0) denotes the rule

{Γ, Δ_{1}⇒θ_{1} \atop ⋯} ; Γ, Δ_{n}⇒θ_{n} (Rule ) Γ, Δ⇒θ

Judgemental Equality rules 3.2. THE LOGICAL FRAMEWORK 149

A : type ; (Ref_{0}) ; A = A : type  \begin{aligned}& r : A \\ (Ref_{1}) \\ & r = r : A \end{aligned}
A = B : type ; (Sym_{0}) ; B = A : type  \begin{aligned}& r = s : A \\ (Sym_{1}) \\ & s = r : A \end{aligned}
A = B : type ; B = C : type

(Trans_{0})

A = C : type

{r = s : A \atop s = t : A} ; (Trans_{1}) ; r = t : A

\begin{matrix}r : A \\ A = B : type \end{matrix} ; (Repl_{0}) ; r : B

\begin{matrix}r = s : A \\ A = B : type \end{matrix} (Repl_{1}) r = s : B

The Type Set

(Set-I) Set : type

A : Set ; (Set-E) ; A : type A = B : Set ; (Set-E_{=}) ; A = B : type

Remark: Sometimes the last two rules are written as A : Set ; (Set-E^{∗}) ; El(A) : type

A = B : Set
(Set-E_{=}^{∗})

El(A) = El(B) : type

But this leads only to an unnecessary technical overload.

The Dependend Function Type

The formation rules of →:

A : type

x : A⇒B : type

(→-F)

(x : A)→B : type
A = A′ : type
x : A⇒B = B′ : type

(→-F_{=})

(x : A)→B = (x : A′)→B′ : type

The introduction rules of →:

A : type x : A⇒B : type

x : A⇒s : B (→-I) (x)s : (x : A)→B

A : type

x : A⇒B : type

x : A⇒s = s′ : B (→-I_{=}) (x)s = (x)s′ : (x : A)→B

The elimination rules of →:

A : type

x : A⇒B : type
r : (x : A)→B

s : A (→-E) r s : B[x := s]

A : type x : A⇒B : type

r = r′ : (x : A)→B

s = s′ : A (→-E) r s = r′ s′ : B[x := s]

The equality rules of →:

A : type

x : A⇒B : type
x : A⇒r : B

s : A (→-=) ((x)r)(s) = r[x := s] : B[x := s]

A : type x : A⇒B : type

r : (x : A)→B (→-η) r = (x)(r(x)) : (x : A)→B

Abbreviations:

• (x_{1} : A_{1}, …, x_{n} : A_{n})→B := (x_{1} : A_{1})→((x_{2} : A_{2})→ ⋯ →((x_{n} : A_{n})→B) ⋯).

• (x_{1} : A_{1}, …, x_{i−1} : A_{i−1}, A_{i}, x_{i+1} : A_{i+1}, …, x_{n} : A_{n})→B := (x_{1} : A_{1}, …, x_{i−1} : A_{i−1}, x_{i} : A_{i}, x_{i+1} : A_{i+1}, …, x_{n} : A_{n})→B

for a fresh variable x_{i},

• A→B := (A)→B.

• (x_{1}, …, x_{n})r := (x_{1})((x_{2}) ⋯ ((x_{n})r) ⋯).

The dependent product. It is useful to have dependent products as part of the logical framework as well, but it will not be needed for what follows. We will give their rules below in Subsection 3.4.

3.3 The Sets in Martin-Löf’s Type Theory

The sets of Martin-Löf’s type theory can be defined in the precense of the logical framework, except of equality rules, as axioms only. In implementations usually only the logical framework is predefined, the sets have to be defined by the user. The constructors of the following sets will however have quite a lot of additional parameters which seem to be unnecessary. For instance

instead of λx.t we have to write λ A; B (x)t ,

instead of r(s) we have to write Ap A B C r s ,

But it turns out that these additional premisses are necessary, without more statements can be proved. However, these premisses make the proof terms look quite complicated. Therefore, hiding mechanisms have been suggested, but the result still does not look very nice. One pragmatic approach was taken in the system Half, and the result looks rather harmonic: The dependent function and product type are extended in so far as, if

A : Set, x : A⇒B : Set ,

then

(x : A)→B, (x : A) × B : Set .

Therefore in the most common constructors

λ, Ap

we have only the really necessary arguments. Further the construtors in the introduction rules don’t have the additional parameters, and the elimination rules are replaced by definition by case distinction (so called pattern matching), which is more or less definition by recursion as we usually do it, and then only the parameters a function really depends on have to be spelled out. The resulting type theory looks good (except that unfortunately full recursion is allowed and therefore the type theory is inconsistent), and this seems to be a good pragmatic approach.

The Finite Sets

Let n ∈ ℕ.

(N_{n} − F) N_{n} : Set
(N_{n} − I_{k}) A_{k}^{n} : N_{n} (k = 0, …, n − 1)
(N_{n} − E) C_{n} : (X : N_{n}→Set,
u_{0} : X A_{0}^{n},
…,
u_{n−1} : X A_{n−1}^{n},
x : N_{n})
→X x

{B : N→Set \atop s_{0} : B A_{0}^{n}} ; ⋯; s_{n−1} : B A_{n−1}^{n} (N_{n}-= ) C_{n} B s_{0} … s_{n−1} A_{k}^{n} = s_{k} : B A_{k}^{n}

The original notation was n_{k} for A_{k}^{n}, but this leads often to confusion. N_{2} are the booleans, and we can define

true := A_{0}^{2}, false := A_{1}^{2}
if_{A} a then s_{0} else s_{1} := C_{2} A s_{0} s_{1} a .

N_{0} is the falsity: It has no elements, and the elimination rule is

C_{0} : (X : N_{0}→Set, x : N_{0})→X x

or ex falsum quodlibet with respect to every set X depending on N_{0}. Note that there is no equality rule for N_{0}. The elimination and equality rules can be derived from the introduction rules: From an element of a set we can define an element of another set, if we have for each way, the element is constructed we have one step function which tells us what to do. In the context of inductive-recursive definitions this derivation of elimination rules from introcuction rules is made precise. Therefore we will not add η-rules for the sets: they follow not in a direct way from the introduction rules but require additional considerations.

The Set of Natural Numbers

(N − F) N : Set
(N − I_{0}) 0 : N
(N − I_{S}) S : N→N
(N − E) P : (X : N→Set,
u_{0} : X 0,

u_{S} : (x : N, X x)→X (S x),

x : N)→X x

{A : N→Set \atop s_{0} : A 0} ; s_{S} : (x : N, A x)→A (S x) (N-=_{0} ) P A s_{0} s_{S} 0 = s_{0} : B 0

{A : N→Set \atop s_{0} : A 0} s_{S} : (x : N, A x)→A (S x)

r : N

(N-=_{S} )

P A s_{0} s_{S} (Sr) = s_{S} r (P A s_{0} s_{S} r) : B (S r)

The symbol P stands for primitive recursion. If A = (x)N the elimination rule yields ordinary primitive recursion: Assume

a : N, f : N→N→N .

Then

g := P ((x)N) a f : N→N

and we can derive

g 0 = a : N ,
g (Sn) = f n (g n) : N ,

If A is considered as a formula, depending on a natural number, this corresponds to induction: From proofs of

A 0 and x : N, A x⇒A (Sx) ,

i.e. from

r : A 0, s : (x : N, A x)→A (Sx)

and from

n : N

we can derive

A n

with proof term

P A r s n : A n .

The Disjoint Union of Sets

In the following we write A + B instead of + A B.

(+ − F) + : (X_{0} : Set, X_{1} : Set)→Set
(+ − I_{0}) i_{0} : (X_{0} : Set, X_{1} : Set, x : X_{0})→X_{0} + X_{1}
(+ − I_{1}) i_{1} : (X_{0} : Set, X_{1} : Set, x : X_{1})→X_{0} + X_{1}
(+ − E) D : (X_{0} : Set,

X_{1} : Set,

Y : (X_{0} + X_{1})→Set, u_{0} : (x : X_{0})→Y (i_{0} x), u_{1} : (x : X_{1})→Y (i_{1} x), x : X_{0} + X_{1})→Y x

{A_{0} : Set \atop A_{1} : Set}

B : (A_{0} + A_{1})→Set

s_{0} : (x : A_{0})→B (i_{0} x),
s_{1} : (x : A_{1})→B (i_{1} x),

a : A_{i} (+-=_{i} ) D A_{0} A_{1} B s_{0} s_{1} (i_{i} a) = s_{i} a : B (i_{i} a)

Note that the rules above are exactly the same as the rules for + in the simple typed λ-calculus, just with the additional type information added. For propositions A, B, A + B is therefore the proposition A ∨ B, and the above introduction and elimination rules correspond exactly to the introduction and elimination rules for ∨, the equality rule is the above mentioned proof transformation.

The Π-set

(Π − F) Π : (X : Set, Y : X→Set)→Set
(Π − I) λ : (X : Set, Y : X→Set, y : (x : X)→Y x)

→Π X Y

(Π − E) F : (X : Set,

Y : X→Set,

Z : (Π X Y)→Set,

u : (y : (x : X)→Y y)→Z (λ X Y y), x : (Π X Y))→Z x

\begin{matrix}A : Set \\ B : A→Set \end{matrix}

C : (Π A B)→Set

s : (y : (x : A)→B x)→C (λ A B y),

f : (x : A)→B x (Π-=) F A B C s (λ A B f) = s f : C (λ A B f)

The term

λ A B f

looks a bit too long for practical purposes, but we have indicated, how to remedy this: Use a version of → for Set. The elimination rule (F is called “Fun-split”) is non-standard, but as it stands, it is the exact counterpart of the introduction rule. We can define from it application

Ap := (X, Y, y, x,)
F X Y ((y) Y x)
((z)z x)
y
: (X : Set, Y : X→Set, y : Π X Y, x : X)→Y x

and can derive, if A, B, f, a have appropriate types,

Ap A B (λ A B f) a = f a : B a .

The only other application is that we can show propositional η-equality. If this is not needed, one could take appropriate rules for Ap as elimination rules for Π. We can define now

∀x : A.B(x) := Π(A, B)
A→_{prop}B := Π(A, (y)B) for y a new variable

where A→_{prop}B means the proposition “A implies B”. We get, if we had only the rules for Ap as elimination rules, the ordinary rules for ∀, and propositional implication →. The rules for F cannot be expressed in natural deduction. The would be needed to be written like

\frac{a : ∀x : A.B(x) (x : A)→B(x)⇒C}{C}

i.e. if we have a proof of

∀x.B(x)

and, whenever we have x : A⇒B(x) then C

then we have C. Such a rule does not make sense in ordinary natural deduction.

The Σ-set

(Σ − F) Σ : (X : Set, Y : X→Set)→Set
(Σ − I) p : (X : Set, Y : X→Set, x : X, y : Y x)
→Σ X Y
(Σ − E) E : (X : Set,
Y : X→Set,

Z : (Σ X Y)→Set,

u : (x : X, y : Y x)→Z (p X Y x y), x : (Σ X Y))→Z x

\begin{matrix}A : Set \\ B : A→Set \end{matrix}

C : (Σ A B)→Set s : (x : A, y : B x)→C (p A B x y), a : A

b : B (Σ-=)

\begin{matrix}E A B C s (p A B a b) = s a b \\ : C (p A B a b) \end{matrix}

Again, in order to reduce the complexity, one can make use of the logical framework product. For a set A and a proposition B(x) depending on x : A we can define now

∃x : A.B(x) := Σ A B

and get the usual rules for ∃. We can define as well for propositions A, B

A ∧ B := Σ A ((x)B) (x fresh) .

The elimination rule for ∧ corresponds now to a rule

\frac{A ∧ B A, B⇒C}{C}

One easily verifies that from this rule one can derive the ordinary elimination rules for ∧ and vice versa.

The Identity Set

(I − F) I : (X : Set, x : X, y : X)→Set
(I − I) r : (X : Set, x : X)→I X x x
(I − E) J : (X : Set,

Y : (x : X, y : X, z : I X x y)→Set, u : (x : X)→Y x x (r X x), x : X, y : X, z : I X x y)→Y x y z

A : Set B : (x : A, y : A, z : I A x y)→Set
s : (x : A)→B x x (r A x),

a : A (I-=) J A B s a a (r A a) = s a : C a a (r A a)

For a set A I A a b is the set corresponding to the proposition

a = b

(as elements of A, sometimes written as

a =_{A} b )

The introduction rule proves reflexivity

a = a .

But, since from a = b : A it follows

I A a a = I A a b : Set ,

we can prove a =_{A} b if we can prove a = b : A, i.e. if a, b are α, β, ηequivalent (with respect to the reductions, which correspond to our equational rules). If we take A = N and restrict us to terms build from functions for primitive recursive functions, α, β, η-equivalence for these terms means that their equality can be derived from the equality rules and defining equations for primitive recursive functions. In natural deduction, a proposition B as above cannot depend on a proof for a =_{A} b, therefore the elimination rules correspond to: If B(x, y) is a proposition, depending on x, y : A then we have the rule

\frac{a =_{A} b B(x, x)}{B(a, b)}

One sees easily from this rule we can derive symmetry, transitivity and congruence and vice versa. The nice thing is that J can be derived directly. However there is another rule, which was shown by Martin Hofmann in his thesis to be independent of J:

(I − E_{2}) K : (X : Set,
Y : (x : X, y : I X x x)→Set,
u : (x : X)→Y x (r X x),
x : X,
z : I X x x)→Y x z

A : Set B : (x : A, y : I A x x)→Set
s : (x : A)→B x (r A x),

a : A (I-=_{2}) K A B s a (r A a) = s a : C a (r A a)

We have

(X, x)
(K X
((y, v)I (I X y y) v (r X y))
((y)r (I X y y) (r X x)))
: (X : Set,
x : X,
v : I X x x)
→ I(I X x x) v (r X x) ,

i.e. with K we can prove (as a propositional equality) that there is only one equality proof of x =_{X} x, namely r X x. This is not provable with J.

We can make now precise that with F we can prove propositional ηequality for the Π-set: We have: If

• X : Set,

• Y : X→Set,

• x : (x : X)→Y x,

• x′ := λ X Y x

then we can prove (w.r.t. to judgemental equality

λ X Y ((y)Ap X Y x′ y) = λ X Y ((y)x(y)) = λ X Y x ≡ x′

i.e.

λ X Y ((y)Ap X Y x′ y) = x′ : Π X Y .

Therefore we can show

(X, Y)

F X Y ((x)I (Π X Y) x (λ X Y ((y)Ap X Y x y))) ((x)r (Π X Y) (λ X Y x)) : (X : Set, Y : X→Set, x : Π X Y)→I (Π X Y) x (λ X Y ((y)Ap X Y x y))

Therefore, also x and λ X Y ((y)Ap X Y x y) are not equal w.r.t judgemental equality, their equality can be shown.

The W-set

(W − F) W : (X : Set, Y : X→Set)→Set
(W − I) sup : (X : Set, Y : X→Set,

x : X, y : (Y x)→W X Y)

→W X Y
(W − E) R : (X : Set,
Y : X→Set,

Z : (W X Y)→Set,

u : (x : X,

y : (Y x)→W X Y,

z : (u : Y x)→Z (y u))→Z (sup X Y x y) x : (W X Y))→Z x A : Set B : A→Set C : (W A B)→Set

s : (x : A,
y : (B x)→W A B,
u : (u : B x)→C (y x))→C (sup A B x y)

a : A

b : (B a)→W A B (W-=) R A B C s (sup A B a b) = s a b ((x)R A B C s (b x))

: C (sup A B a b)

The elements of W A B are well-founded trees with branching degrees B x for x : A. The introduction rule constructs from an element

a : A

and an B a indexed collection of trees

b : (B a)→W A B

a new tree

sup a b

with label a and subtrees b x for x : A. The elimination rule is induction over sees trees. The step term is crucial: If we can for every a : A, b : (B a)→W A B from the induction hypothesis, which is an element

c : (x : B a)→C (b x) ,

derive an element of

C (sup A B a b)

then we can derive

(x : W A B))→C x .

With W we can simulate inductive definitions, but this is only interesting in order to explore the strength of the closed theory, we are defining in this section. When working in an implemented system, instead of simulating inductive definitions one defines them directly by following essentially the pattern according to which W A B is defined.

The Universe

A universe is a collection of sets. More precisely it is a collection of codes for sets, and simultaneously with the universe U we define its decoding function

T : U→Set ,

which assigns to a code the set it denotes. We define here a universe closed under all set constructions given before:

(U − F) U : Set
(T − F)  T : U→Set
(U − IN̂_{n}) N̂_{n} : U (n ∈ ℕ)
(U − IN̂) N̂ : U
(U − IΣ̂) Σ̂ : (x : U, y : (Tx)→U)→U
(U − IΠ̂) Π̂ : (x : U, y : (Tx)→U)→U
(U − IŴ) Ŵ : (x : U, y : (Tx)→U)→U
(U − Iˆ+) ˆ+ : (x : U, y : U)→U
(U − IÎ) Î :  (x : U, y : T x, y : T x)→U
aˆ+b := ˆ+ a b .

(T-=N̂_{n} ) T N̂_{n} = N_{n} : Set  (T-=N̂ ) T N̂ = N : Set

\begin{matrix}a : U \\ b : (T a)→U \end{matrix} (T-=Σ̂)

T(Σ̂ a b) = Σ (T a) ((x)T (b x)) : Set

\begin{matrix}a : U \\ b : (T a)→U \end{matrix} (T-=Π̂)

T(Π̂ a b) = Π (T a) ((x)T (b x)) : Set

\begin{matrix}a : U \\ b : (T a)→U \end{matrix} (T-=Ŵ)

T(Ŵ a b) = W (T a) ((x)T (b x)) : Set

{a : U \atop b : U} (T-= ˆ+)

T(aˆ+b) = (T a) + (T b) : Set

\begin{matrix}a : U \\ b : T a \end{matrix} ; c : T a (T-=Î)

T(Î a b c) = I (T a) b c : Set

An elimination rule as before can not be given for the universe, since we have infinitely many introduction rules (because for every n ∈ ℕ we have one introduction rule for

N_{n} : U .

However, one sees that we only need N_{0} and N_{1}. (For n > 1 can we define N_{n} as

\underbrace{N_{1} + ⋯ + N_{1}}_{ntimes} .)

Then one can define an elimination rule in the spirit of what was before. Applications of the elimination rule are however very limited, so we we do not spell out this rule here. According Martin-Löf, the real elimination rule for the U is T : U→Set. If one wants to prove ¬(0 = 1) i.e. give a term r s.t.

r : (I N 0 (S 0))→_{prop}N_{0}

one needs at least a microscopic universe, i.e. a universe which has one empty and one nonempty type.

3.4 The Dependent Product of Types

The Binary Product

The formation rules of ×:

A : type
x : A⇒B : type

(×-F)

(x : A) × B : type
A = A′ : type
x : A⇒B = B′ : type

(×-F_{=})

(x : A) × B = (x : A′) × B′ : type

The introduction rules of ×:

A : type x : A⇒B : type

r : A

s : B[x := r] (×-I) ⟨r, s⟩ : (x : A) × B

A : type

x : A⇒B : type

r = r′ : A

s = s′ : B[x := r] (×-I_{=}) ⟨r, s⟩ = ⟨r′, s′⟩ : (x : A) × B

The elimination rules of ×:

A : type x : A⇒B : type

r : (x : A) × B (×-E_{0}) r 0 : A

A : type

x : A⇒B : type

r = r′ : (x : A) × B (×-E_{0,=}) r 0 = r′ 0 : A

162 CHAPTER 3. MARTIN-LÖF’S TYPE THEORY

A : type x : A⇒B : type

r : (x : A) × B (×-E_{1}) r 1 : B[x := r 0]

A : type

x : A⇒B : type

r = r′ : (x : A) × B (×-E_{1,=}) r′ 1 = r′ 1 : B[x := r 0]

The equality rules for ×:

A : type x : A⇒B : type

r : A

s : B[x := r] (×-=_{0}) ⟨r, s⟩ 0 = r : A

A : type x : A⇒B : type

r : A

s : B[x := r] (×-=_{1}) ⟨r, s⟩ 1 = s : B[x := r 0]

A : type x : A⇒B : type

r : (x : A) × B (×-η) r = ⟨r 0, r 1⟩ : (x : A) × B

Abbreviations:

• (x_{1} : A_{1}, …, x_{n} : A_{n}) × B := (x_{1} : A_{1}) × ((x_{2} : A_{2}) × ⋯ × ((x_{n} : A_{n}) × B) ⋯).

• (x_{1} : A_{1}, …, x_{i−1} : A_{i−1}, A_{i}, x_{i+1} : A_{i+1}, …, x_{n} : A_{n}) × B :=

(x_{1} : A_{1}, …, x_{i−1} : A_{i−1}, x_{i} : A_{i}, x_{i+1} : A_{i+1}, …, x_{n} : A_{n}) × B for a fresh variable x_{i},

• A × B := (A) × B.

• ⟨r_{1}, …, r_{n}⟩ := ⟨r_{1}, ⟨r_{2}, …, ⟨r_{n−1}, r_{n}⟩⟩⟩.

• If r is introduced as an element of

(x_{1} : A_{1}, …, x_{n} : A_{n}) × B ,

one sometimes uses x_{i} as labels and writes

r_{x_{i}}

for

\begin{cases}r \underbrace{0 ⋯ 0}_{n − i + 1 times} 1 & n > 1 \\ r \underbrace{0 ⋯ 0}_{n times} & n = 1 \end{cases} .

One can write the above type as (x_{1} : A_{1}, …, x_{n} : A_{n}) × (x : B) and writes then

r_{x} for r 1 .

The problem is that one can then of course no longer replace x_{i} by different variabels.

The Empty Product

The formation and introduction rule of 1:

(1-F)  1 : type  (1-I)  ⟨⟩ : 1

The η-equality for 1:

\begin{aligned}& r : 1 \\ (1-η) \\ & r = ⟨⟩ : 1 \end{aligned}

3.5 The Language of Martin-Löf’s Type Theory

Definition 3.5.1 (a) We assume infinitely many variables be given. In the following x, y, z, u, v, X, Y, Z, possibly with subscripts and accents, are variables.

(b) The type constructors of Martin-Löf’s type theory are Set, 1.

(c) The set constructors of Martin-Löf’s type theory are:

• N, +, Π, Σ, I, W,

• U, T,

• for n ∈ ℕ N_{n}.

(d) The term constructors of Martin-Löf’s type theory are

• 0, S, P,

• i_{0}, i_{1}, D,

• λ, F,

• p, E,

• r, J, K,

• sup, R,

• N̂, ˆ+, Π̂, Σ̂, Î, Ŵ,

• ⟨⟩,

• and for n ∈ ℕ N_{n}, C_{n}, and 164 CHAPTER 3. MARTIN-LÖF’S TYPE THEORY

• for k < n A_{k}^{n}.

(e) The pre-terms are: • term constructors,

• set constructors and,

• if r, s are pre-terms, – (r s),

– ((x)r),

– ⟨r, s⟩,

– r 0,

– r 1. In the following a, b, c, n, f, g, r, s, t, possibly with subscripts and accents,will be pre-terms.

(f) The pre-sets are: • set constructors and,

• if p, q are pre-sets, – (p r),

– (p q),

– ((x)p),

– ⟨p, q⟩,

– p 0,

– p 1.

(g) The pre-types are: • type constructors,

• pre-sets, and,

• if A, B are pre-types, – (x : A)→B,

– (x : A) × B. In the following A, B, C, with accents or subscripts, denote pre-types.

(h) Pre-nondependent judgements are • A = B : type,

• A : type,

• r : A,

• r = s : A.

In the following θ, possibly with accents or indices, denote pre-nondependent judgements.

(i) Pre-contexts are

x_{1} : A_{1}, …, x_{n} : A_{n}

where n ∈ ℕ (including 0, this pre-context is denoted by ∅). In the following Γ, Δ, possibly with accents or indices, denote pre-contexts. If Γ, Δ are pre-contexts, Γ, Δ is as usual the concatenation of the precontexts.

(j) Pre-judgements are Γ⇒θ.

(k) We omit parentheses as usual (where r s t := (r s) t).

Definition 3.5.2 (a) For pre-terms and -types d we define the set of free

variables FV(d) by • If d ∈ {Set, 1} or d is a set- or term-constructor, then FV(d) := ∅.

• FV(d e) := FV(⟨d, e⟩) := FV(d) ∪ FV(e).

• FV(d i) := FV(d) (i = 0, 1).

• FV((z)d) := FV(d) \ {z}.

• FV((x : A) ∘ B) := FV(A) ∪ (FV(B) \ {x}). (∘ ∈ {→, ×}).

(b) For pre-terms and pre-types d, f we define the substitution of a variable x by f in d by induction on the d:

• If d ∈ {Set, 1} or d is a set- or term-constructor, then d[x := f] := d.

• (d e)[x := f] := (d[x := f] e[x := f]).

• ⟨d, e⟩[x := f] := ⟨d[x := f], e[x := f]⟩,

• (d i)[x := f] := (d[x := f] i) (i = 0, 1). •

((z)d)[x := f] := \begin{cases}(z)d & if x ≡ z \\ (z)(d[x := f]) & if x ≢ z, (x ∉ FV(d) ∨ y ∉ FV(f)) \\ (u)(d[z := u][x := f]) & otherwise, u minimal s.t. \\ & u ∉ FV(f d x) . \end{cases}

• If ((z)e)[x := f] = (z′)e′, then for ∘ ∈ {→, ×},

((z : d) ∘ e)[x := f] = (z : (d[x := f])) ∘ e′ .

(c) We define the α-equivalence on pre-terms and pre-types as least transitive

and reflexive relations on pre-terms and pre-types s.t.

• (z)d, (y)d[z := y] are α-equivalent, if y ∉ FV(d).

• (z : d) ∘ e, (y : d) ∘ (e[z := y]) are α-equivalent, if y ∉ FV(e).

• If d, d′ are α-equivalent, e, e′ are α-equivalent, so are – (d e) and (d′ e′),

– ⟨d, e⟩ and ⟨d′, e′⟩,

– d i and d′ i,

– (z)d and (z)d′,

– (z : d) ∘ e and (z : d′) ∘ e′, ∘ ∈ {→, ×}.

(d) • FV(A = B : type) := FV(A) ∪ FV(B), • FV(A : type) := FV(A),

• FV(r = s : A) := FV(r) ∪ FV(s) ∪ FV(A),

• FV(r : A) := FV(r) ∪ FV(A).

(e) α-equivalence of pre-nondependent judgements is the least reflexive rela-

tion s.t. if A, A′, r, r′, s, s′ are α-equivalent, respectively, so are • A = B : type and A′ = B′ : type,

• A : type and A′ : type,

• r : A and r′ : A′,

• r = s : A and r′ = s′ : A′.

(f) For pre-nondependent judgements θ and pre-terms and pre-types f we define θ[x := f] by:

• (A = B : type)[x := f] := A[x := f] = B[x := f] : type,

• (A : type)[x := f] := (A[x := f]) : type,

• (r : A)[x := f] := r[x := f] : A[x := f],

• (r = s : A)[x := f] := r[x := f] = s[x := f] : A[x := f].

(g) For pre-judgements Γ⇒θ we define FV(Γ⇒θ) by:

• FV(∅⇒θ) := FV(θ).

• FV(x : A, Γ⇒θ) := FV(A) ∪ (FV(Γ⇒θ) \ {x}).

(h) For pre-judgements Γ⇒θ and pre-terms and -types f we define

(Γ⇒θ)[x := f]

by:

(i) (∅⇒θ)[x := f] := ∅⇒(θ[x := f]).

(j) (x : A, Γ⇒θ)[x := f] := x : (A[x := f]), Γ⇒θ.

(k) If x ≢ y, y ∉ FV(Γ⇒θ) ∨ x ∉ FV(f), then

(x : A, Γ⇒θ)[y := f] := x : (A[y := f]), ((Γ⇒θ)[y := f]) .

(l) If x ≢ y, y ∈ FV(Γ⇒θ), x ∈ FV(f), then let u minimal s.t. u ∉ FV(Γ⇒θ), u ∉ FV(d x).

(x : A, Γ⇒θ)[y := f] := u : (A[y := f]), ((Γ⇒θ)[x := u][y := f]) .

(m) α-equivalence of pre-judgements is the least transitive and reflexive relation on pre-judgements s.t.

• If θ, θ are α-equivalent, so are ∅⇒θ and ∅⇒θ′.

• If A, A′ are α-equivalent and as well Γ⇒θ, Γ′⇒θ′, so are x : A, Γ⇒θ, x : A′, Γ′⇒θ′.

• If y ∉ FV(Γ⇒θ), then x : A, Γ⇒θ and y : A, ((Γ⇒θ)[x := y]) are α-equivalent.

168 CHAPTER 3. MARTIN-LÖF’S TYPE THEORY

Bibliography

[CF58] H. B. Curry and R. Feys. Combinatory Logic, Vol. I. North-Holland, Amsterdam, 1958.

[HS86] J. R. Hindley and J. P. Seldin. Introduction to Combinators and λcalculus. Cambridge University Press, Cambridge, 1986.

[MJ98] R. Matthes and F. Joachimski. Short proofs of normalization for the simply typed λ-calculus, permutative conversions and Gödel’s T. Draft, available via

http://www.tcs.uni-muenchen.de/ matthes/papers/snnew.ps.gz,

1998.

[Plo74] G. D. Plotkin. The λ-calculus is ω-complete. J. Symb. Logic, 39:313 – 317, 1974.

[Set94] A. Setzer. Lösen rekursiver Bereichsgleichungen. Seminar notes, based on some notes of Thomas Streicher, 1994.

[Str94] T. Streicher. Lösen rekursiver Bereichsgleichungen. Handwritten notes, 1994.

[Tak95] M. Takahashi. Parallel reductions in λ-calculus. Information and Computation, 118:120 – 127, 1995.

[TD88a] A. Troelstra and D. van Dalen. Constructivism in Mathematics. An Introduction, Vol. I. North-Holland, Amsterdam, 1988.

[TD88b] A. Troelstra and D. van Dalen. Constructivism in Mathematics. An Introduction, Vol. II. North-Holland, Amsterdam, 1988.