367 Lambda Calculus and the Curry–Howard Correspondence

Thesis. The \(\lambda \)-calculus is the internal language of currying, the adjunction

\begin{equation} \mathcal C(C\times A,B)\cong \mathcal C(C,B^A) \tag{21958}\end{equation}
of Section 344.

Terms and reduction.

Data. Numbers are iterations (Church numerals, the free monoid \(\{1\}^{*}\)). Booleans are the two projections, and branching is elimination on \(\mathbf 2\).

Fixed points. Self-application \(xx\) is the diagonal. In the untyped calculus every term has a fixed point, by the \(Y\) combinator, which is Lawvere’s fixed-point theorem applied in the positive direction. The same theorem in the negative direction gives Russell, Cantor and Gödel. So the untyped calculus has no consistent reading as logic, while typing forbids \(xx\) and makes every term terminate.

Curry–Howard. Typed terms are proofs: \(\rightarrow \), \(\times \), \(+\), \(0\) are \(\Rightarrow \), \(\wedge \), \(\vee \), \(\bot \). \(\beta \)-reduction is cut elimination (Section 364); dependent types add \(\forall \), \(\exists \) and the identity type with \(\mathsf {refl}\).

Computability. \(\lambda \)-definable, Turing-computable and general recursive functions coincide; this is a theorem. That they capture all effective computation is the Church–Turing thesis.

367.1 Terms, substitution and \(\alpha \)-equivalence

Syntax.

\begin{equation} M,N\ ::=\ x\ \mid \ \lambda x.M\ \mid \ M\,N . \tag{21959}\end{equation}

\(\alpha \)-equivalence. Terms differing only in the names of bound variables are identified, \(\lambda x.M=\lambda y.M[x:=y]\) for fresh \(y\). A bound variable is a position, not a name.

Substitution. \(M[x:=N]\) replaces the free occurrences of \(x\) in \(M\) by \(N\), renaming bound variables of \(M\) to avoid capturing the free variables of \(N\):

\begin{equation} (\lambda y.\,x)[x:=y]=\lambda z.\,y, \qquad \text {not}\quad \lambda y.\,y . \tag{21960}\end{equation}
Substitution is the transport of Section 343: if \(x=N\), then whatever holds of \(x\) holds of \(N\).

367.2 \(\beta \) and \(\eta \) from the currying adjunction

Reductions.

\begin{equation} (\lambda x.M)\,N\ \to _\beta \ M[x:=N], \qquad \lambda x.(M\,x)\ \to _\eta \ M\quad (x\notin \mathrm {FV}(M)). \tag{21961}\end{equation}

Categorical reading. In a cartesian closed category, a term \(M\) with free variable \(x:A\) in context \(\Gamma \) is an arrow \(m:\Gamma \times A\to B\). Then:

Identity. The projection \(\pi _2:\Gamma \times A\to A\) transposes to \(\lambda x.x:\Gamma \to A^A\), which names \(\mathrm {id}_A\):

\begin{equation} (\lambda x.x)\,N\ \to _\beta \ N . \tag{21962}\end{equation}

Examples.

\begin{equation} (\lambda x.\,x+1)\,3\to _\beta 3+1, \qquad (\lambda x.\,x\cdot x)\,5\to _\beta 5\cdot 5, \qquad (\lambda x.\,f\,x)\,A\to _\beta f\,A . \tag{21963}\end{equation}

367.3 Confluence

Church–Rosser theorem. If \(M\twoheadrightarrow N_1\) and \(M\twoheadrightarrow N_2\), there is \(P\) with \(N_1\twoheadrightarrow P\) and \(N_2\twoheadrightarrow P\).

Proof sketch (Tait–Martin-Löf). Define parallel reduction \(\Rightarrow \), which contracts any set of redexes at once. It satisfies the diamond property, which follows from the substitution lemma

\begin{equation} M[x:=N][y:=L]=M[y:=L][x:=N[y:=L]]\quad (x\notin \mathrm {FV}(L)), \tag{21964}\end{equation}
and its reflexive–transitive closure equals that of \(\to _\beta \). The diamond property passes to the closure. \(\square \)

Consequence. A term has at most one normal form. Evaluation order (eager as in Python, lazy as in Haskell) can change whether a normal form is reached, but not which one.

367.4 Data as iteration and projection

Church numerals.

\begin{equation} \mathbf n=\lambda f.\lambda x.\,f^n(x), \qquad \mathbf 0=\lambda f.\lambda x.\,x, \qquad \mathbf 1=\lambda f.\lambda x.\,f\,x . \tag{21965}\end{equation}
A numeral is "iterate \(n\) times", the free monoid \(\{1\}^{*}\) acting on functions (Section 350.10).

Arithmetic.

\begin{align} \mathsf {succ}&=\lambda n.\lambda f.\lambda x.\,f\,(n\,f\,x), \tag{21966}\\ \mathsf {plus}&=\lambda m.\lambda n.\lambda f.\lambda x.\,m\,f\,(n\,f\,x), \tag{21967}\\ \mathsf {mult}&=\lambda m.\lambda n.\lambda f.\,m\,(n\,f), \tag{21968}\\ \mathsf {exp}&=\lambda m.\lambda n.\,n\,m . \tag{21969}\end{align}

Addition concatenates iterations, multiplication composes them, and exponentiation iterates iteration. Predecessor is definable by iterating on pairs, \((k,k+1)\mapsto (k+1,k+2)\), and reading off the first component.

Booleans.

\begin{equation} \mathsf {true}=\lambda x.\lambda y.\,x, \qquad \mathsf {false}=\lambda x.\lambda y.\,y, \qquad \mathsf {if}\ b\ \mathsf {then}\ M\ \mathsf {else}\ N=b\,M\,N . \tag{21970}\end{equation}
The two Booleans are the two projections, and branching is elimination on \(\mathbf 2\), as for controlled gates (Section 343). Negation is \(\lambda b.\,b\,\mathsf {false}\,\mathsf {true}\), an involution.

Pairs.

\begin{equation} \langle M,N\rangle =\lambda s.\,s\,M\,N, \qquad \pi _1=\lambda p.\,p\,\mathsf {true}, \qquad \pi _2=\lambda p.\,p\,\mathsf {false}. \tag{21971}\end{equation}

367.5 Self-application and fixed points

Self-application. \(xx\) applies a term to itself: the diagonal, \(x\mapsto (x,x)\) followed by evaluation. The term

\begin{equation} \Omega =(\lambda x.\,xx)(\lambda x.\,xx)\ \to _\beta \ \Omega \tag{21972}\end{equation}
reduces to itself forever: it has no normal form.

The \(Y\) combinator.

\begin{equation} Y=\lambda f.\,(\lambda x.\,f(xx))(\lambda x.\,f(xx)), \qquad Y\,F=_\beta F\,(Y\,F) \tag{21973}\end{equation}
for every term \(F\). Every term has a fixed point.

Lawvere. Let \(D\) be a model of the untyped calculus, an object with \(D\cong D^D\), as in Scott’s domains. Then \(D\to D^D\) is surjective, and Lawvere’s theorem (Section 350) gives every \(f:D\to D\) a fixed point. \(Y\) is that fixed point: \(\lambda x.f(xx)\) is the map \(x\mapsto g(e(x)(x))\) of the proof.

Two directions of one theorem.

Setting Surjection \(X\to Y^X\)? Conclusion
untyped \(\lambda \), \(D\cong D^D\) yes every \(f\) has a fixed point (\(Y\))
sets, \(\{0,1\}^X\) no, \(\neg \) has no fixed point Russell, Cantor
arithmetic, provability diagonal lemma Gödel, Tarski

Least fixed points. In a Scott domain, \(Y\,f\) is the least fixed point \(\bigsqcup _nf^n(\bot )\) (Kleene). The supremum over all \(n\) is a limit of an \(\omega \)-chain, so this form is conditional on the declaration of Section 458; the equation \(Y\,F=_\beta F(Y\,F)\) itself is finite.

No consistent logic. Reading untyped terms as propositions is inconsistent. With implication \(\supset \), set \(C=Y(\lambda x.\,x\supset P)\), so \(C=C\supset P\). Then \(C\supset C\) gives \(C\supset (C\supset P)\), hence \(C\supset P\), hence \(C\), hence \(P\), for arbitrary \(P\) (Curry’s paradox). The fixed point that makes the calculus universal is the one that defeats it as logic.

367.6 Types: what typing removes

Simple types.

\begin{equation} A,B\ ::=\ o\ \mid \ A\to B , \tag{21974}\end{equation}
with the rules
\begin{equation} \frac {\Gamma ,x:A\vdash M:B}{\Gamma \vdash \lambda x.M:A\to B}, \qquad \frac {\Gamma \vdash M:A\to B\qquad \Gamma \vdash N:A}{\Gamma \vdash M\,N:B}. \tag{21975}\end{equation}

No self-application. \(xx\) has no type: if \(x:A\) and \(x:A\to B\), then \(A=A\to B\), which no finite type satisfies. \(\Omega \) and \(Y\) are untypable.

Strong normalisation (Tait). Every typed term reaches a normal form by every reduction sequence. Define, by induction on types, the reducible terms: at a base type, the strongly normalising terms; at \(A\to B\), terms sending reducible arguments to reducible results. Then every reducible term is strongly normalising, and every typed term is reducible.

Consistency. There is no closed normal term of the empty type, so the corresponding logic is consistent. Typing removes the surjection \(D\to D^D\), and with it the general fixed point.

367.7 Curry–Howard–Lambek

Logic Type theory Category
proposition \(A\) type \(A\) object
proof of \(A\Rightarrow B\) term \(\lambda x.M:A\to B\) arrow, exponential
\(A\wedge B\) product \(A\times B\) right adjoint of \(\Delta \)
\(A\vee B\) sum \(A+B\) left adjoint of \(\Delta \)
\(\bot \) empty type \(0\) initial object
\(A\Rightarrow A\) \(\lambda x.x:A\to A\) \(\mathrm {id}_A\)
detour elimination, cut \(\beta \)-reduction triangle identity
uniqueness of proofs \(\eta \) uniqueness of transpose
normal proof normal form —

Simply typed \(\lambda \)-calculus with products and sums, intuitionistic propositional natural deduction, and bicartesian closed categories are three presentations of one structure.

Extensions.

Two identities. In proof assistants, \(\mathtt {id}:A\to A\) (the function \(\lambda x.x\)) and \(\mathtt {rfl}:a=a\) (Lean), or \(\mathtt {eq\_refl}\) (Coq), are different terms of different types: the first proves the implication \(A\Rightarrow A\); the second inhabits the identity type. Both are forms of the identity: one as an arrow, one as an identification.

367.8 Computability

Theorem (Kleene, Church, Turing). For functions \(\mathbb N\to \mathbb N\), the following coincide:

Each formalism simulates the others: a Turing machine configuration is encoded as a \(\lambda \)-term, and \(\beta \)-reduction steps are simulated by a machine.

Church–Turing thesis. These functions are exactly the effectively computable ones. This is a thesis about an informal notion; the agreement of the three formal definitions is its evidence.

Undecidability. No \(\lambda \)-term decides whether two terms have the same normal form. By the Scott–Curry theorem, any nontrivial set of terms closed under \(\beta \)-equality is undecidable, the analogue of the halting problem. The proof is again a diagonal: a decider \(d\) would yield a term that does the opposite of what \(d\) predicts about it.

367.9 Programming languages

Language Function Evaluation
Haskell \x -> x + 1 lazy, typed
OCaml fun x -> x + 1 eager, typed
Python lambda x: x + 1 eager, dynamically typed
JavaScript (x) => x + 1 eager, dynamically typed
Lean, Coq fun x => x + 1 dependent types, normalising core

A closure is a term \(\lambda x.M\) together with values for the free variables of \(M\), an element of \(B^A\) paired with its context. Recursion in general-purpose languages is the fixed point that typed cores exclude or restrict.

367.10 Summary

Item Form From
abstraction \(\lambda x.M\) transpose (currying)
application \(M\,N\) evaluation, counit
\(\beta \) \((\lambda x.M)N\to M[x:=N]\) triangle identity
\(\eta \) \(\lambda x.Mx\to M\) uniqueness of transpose
identity function \(\lambda x.x:A\to A\) \(\mathrm {id}_A\)
substitution capture-avoiding transport
confluence unique normal forms parallel reduction
numerals \(\lambda f.\lambda x.f^nx\) free monoid
Booleans projections, \(b\,M\,N\) elimination on \(\mathbf 2\)
self-application \(xx\), \(\Omega \to \Omega \) diagonal
\(Y\) \(YF=F(YF)\) Lawvere, positive direction
Curry’s paradox untyped logic inconsistent same fixed point
typing \(xx\) untypable no \(D\cong D^D\)
normalisation Tait reducibility
Curry–Howard proofs \(=\) terms bicartesian closed
dependent types \(\Pi ,\Sigma \), \(\mathsf {refl}\) adjoints, identity type
classical \(\mathsf {call/cc}\) : Peirce continuations
computability \(\lambda =\) Turing \(=\) recursive theorem
Church–Turing all effective computation thesis
undecidability Scott–Curry diagonal

367.11 Hilbert–Brouwer Dispute as \(A + \neg A = 1\)

The twentieth-century dispute between Hilbert’s formalism and Brouwer’s intuitionism reduces to a single partition:

\begin{equation} \underbrace {\text {Hilbert}}_{\text {classical logic}} \;+\; \underbrace {\text {Brouwer}}_{\text {intuitionistic logic}} \;=\; A + \neg A = 1 \tag{21976}\end{equation}

1. The dispute.




Hilbert Brouwer



Law of Excluded Middle \(A \vee \neg A = 1\) \(A \vee \neg A \neq 1\)
Double negation \(\neg \neg A = A\) \(\neg \neg A \neq A\)
Foundation Formal axioms Mental construction



2. Resolution: both are correct.

The apparent contradiction dissolves under the observer partition:

\begin{align} O = T \;&\Longrightarrow \; A \vee \neg A = 1 \quad \text {(Hilbert: total observer)} \tag{21977}\\ O < T \;&\Longrightarrow \; A \vee \neg A \neq 1 \quad \text {(Brouwer: partial observer)} \tag{21978}\end{align}

Hilbert describes \(T = 1\) from the outside. Brouwer describes \(O < T\) from the inside. Both are correct — they are two finitions of the same structure:

\begin{equation} \underbrace {A \vee \neg A = 1}_{\text {Hilbert }(O = T)} \;+\; \underbrace {A \vee \neg A \neq 1}_{\text {Brouwer }(O < T)} \;=\; A + \neg A = 1 \tag{21979}\end{equation}

3. Double negation as \(O < T\).

In intuitionistic logic:

\begin{equation} \neg \neg A \neq A \;\Longleftrightarrow \; O < T \;\Longleftrightarrow \; I > 0 \tag{21980}\end{equation}
The gap between \(\neg \neg A\) and \(A\) is exactly the information inaccessible to the partial observer \(O < T\). When \(O = T\):
\begin{equation} \neg \neg A = A \;\Longleftrightarrow \; O = T \;\Longleftrightarrow \; I = 0 \;\Longleftrightarrow \; A = A \tag{21981}\end{equation}

4. The dispute itself is \(A + \neg A = 1\).

\begin{equation} \boxed { \underbrace {\text {Hilbert}}_{\text {classical: } O=T} \;\Longleftrightarrow \; A \qquad \underbrace {\text {Brouwer}}_{\text {intuitionistic: } O<T} \;\Longleftrightarrow \; \neg A \qquad \text {Hilbert} + \text {Brouwer} = A + \neg A = 1 } \tag{21982}\end{equation}

Neither position is wrong. Each is the correct description of one side of the partition. The dispute could not be resolved within either framework because each framework was describing a different finition of the same \(T = 1\).

5. Topos theory connection.

In a Topos \(\mathcal {E}\), the subobject classifier \(\Omega \) instantiates \(A + \neg A = 1\):

\begin{equation} \Omega \;\Longleftrightarrow \; \{0, 1\} \;\Longleftrightarrow \; A + \neg A = 1 \;\Longleftrightarrow \; A = A \tag{21983}\end{equation}
When \(\Omega = \{0,1\}\) (classical, \(O = T\)): \(A \vee \neg A = \top \) — Hilbert’s logic holds. When \(\Omega \) is a Heyting algebra (intuitionistic, \(O < T\)): \(A \vee \neg A \neq \top \) — Brouwer’s logic holds. Both are instances of the same \(\Omega \), at different levels of the observer partition.

One-line summary.

\begin{equation} \text {Hilbert} = O = T = A = A, \qquad \text {Brouwer} = O < T = A + \neg A = 1, \qquad \text {both} = A = A \tag{21984}\end{equation}

Remark 367.1 (The Declaration of \(A\) Generates \(\neg A\)).

Every declaration of \(A\) automatically generates \(\neg A\). The act of drawing a boundary simultaneously creates an inside and an outside:

\begin{equation} A \text { declared} \;\Longrightarrow \; \neg A \text { generated} \;\Longrightarrow \; A + \neg A = 1. \tag{21985}\end{equation}
This is not a logical convention. It is the structural inevitability of partition: to name one side is to create the other.

Every dichotomy is one structure.

\begin{equation} \begin {array}{ll} \text {existence} / \text {non-existence} & \\ \text {true} / \text {false} & \\ \text {light} / \text {darkness} & \\ \text {observer} / \text {substrate} & O / U \\ \text {Hilbert} / \text {Brouwer} & (O=T) / (O<T) \\ \text {provable} / \text {unprovable} \\ \text {form} / \text {content} \\ \end {array} \tag{21986}\end{equation}
All satisfy:
\begin{equation} \boxed { A + \neg A = 1 \;\Longleftrightarrow \; A = A. } \tag{21987}\end{equation}

The moment of partition.

\begin{equation} \text {boundary drawn} \;\Longrightarrow \; \underbrace {\text {inside}}_A + \underbrace {\text {outside}}_{\neg A} = 1 \;\Longleftrightarrow \; A = A. \tag{21988}\end{equation}
Before the boundary: \(T = 1\), undivided. After the boundary: \(A + \neg A = 1\), partitioned. The content of \(T = 1\) is unchanged. Only the partition has been declared.

Again, Genesis 1 as partition declaration.

\begin{equation} \text {``Let there be light''} \;\Longrightarrow \; \underbrace {\text {light}}_{A} + \underbrace {\text {darkness}}_{\neg A} = 1 \;\Longleftrightarrow \; A + \neg A = 1 \;\Longleftrightarrow \; A = A. \tag{21989}\end{equation}
The declaration does not create \(T = 1\). \(T = 1\) was already complete. The declaration partitions \(T = 1\) into \((A, \neg A)\) — the first finition.

Complete structure.

\begin{equation} \boxed { A \text { declared} \;\Longrightarrow \; \neg A \text { generated} \;\Longrightarrow \; A + \neg A = 1 \;\Longleftrightarrow \; A = A. } \tag{21990}\end{equation}

Remark 367.2. Every formal system, every physical theory, every philosophical dispute, and every act of perception begins with a single declaration: \(A\). That declaration generates \(\neg A\). Their sum is \(T = 1\). \(T = 1\) was never divided. The declaration only revealed the partition already present in \(A = A\).