ProofComplete

Proof of the Recursion Theorem

The recursion theorem (Kleene's fixed-point theorem) is a fundamental result guaranteeing that self-referential programs exist. It states that for any computable transformation of programs, there is a fixed point — a program that computes the same function as its own transformation.


Statement

Theorem5.3Kleene's Recursion Theorem

For every total computable function f:NNf: \mathbb{N} \to \mathbb{N}, there exists nNn \in \mathbb{N} such that φn=φf(n)\varphi_n = \varphi_{f(n)}, where φe\varphi_e denotes the partial function computed by the ee-th Turing machine.


Proof

Proof

By the ss-mm-nn theorem, there is a total computable function ss such that φs(x,y)(z)=φx(y,z)\varphi_{s(x,y)}(z) = \varphi_x(\langle y, z \rangle) for all x,y,zx, y, z.

Define a total computable function dd by d(x)=s(x,x)d(x) = s(x, x). Then φd(x)(z)=φx(x,z)\varphi_{d(x)}(z) = \varphi_x(\langle x, z \rangle).

Now, given the total computable function ff, define a computable function hh by h(y,z)=φf(d(y))(z)h(\langle y, z \rangle) = \varphi_{f(d(y))}(z). Let ee be an index for hh, so φe(y,z)=φf(d(y))(z)\varphi_e(\langle y, z \rangle) = \varphi_{f(d(y))}(z).

Set n=d(e)n = d(e). Then: φn(z)=φd(e)(z)=φe(e,z)=φf(d(e))(z)=φf(n)(z).\varphi_n(z) = \varphi_{d(e)}(z) = \varphi_e(\langle e, z \rangle) = \varphi_{f(d(e))}(z) = \varphi_{f(n)}(z).

Thus φn=φf(n)\varphi_n = \varphi_{f(n)}. \square


Applications

ExampleSelf-Printing Programs (Quines)

A quine is a program that outputs its own source code. The recursion theorem guarantees their existence: let ff be any total computable function (e.g., f(e)f(e) = index of the machine that prints ee). The fixed point nn with φn=φf(n)\varphi_n = \varphi_{f(n)} is a program that prints its own index.

RemarkAlternative Proof of Halting Problem

The recursion theorem gives an elegant alternative proof that the halting problem is undecidable. Suppose HH decides K={e:φe(e)}K = \{e : \varphi_e(e) \downarrow\}. Define f(e)=f(e) = index of the machine that on all inputs does the opposite of what HH predicts about ee. By the recursion theorem, there exists nn with φn=φf(n)\varphi_n = \varphi_{f(n)}, leading to nK    nKn \in K \iff n \notin K.

ExampleMyhill's Isomorphism Theorem

Two sets are recursively isomorphic (there is a computable bijection f:NNf: \mathbb{N} \to \mathbb{N} with f(A)=Bf(A) = B) if and only if they are many-one equivalent (AmBA \leq_m B and BmAB \leq_m A). The proof of the forward direction of this uses the recursion theorem to construct the isomorphism by a back-and-forth argument.