Cite

This course has no released version yet: the text at this address may change. Cite a released version when one exists.

/courses/models-of-computation/equivalence-of-models
@misc{models-of-computation-equivalence-of-models,
  title = {{Equivalence of the models}},
  howpublished = {Lesson 12 of \emph{Models of computation}, Computability Theory course notes},
  url = {/courses/models-of-computation/equivalence-of-models},
  note = {Unreleased working version}
}

To cite a single statement, use the # link that appears next to its heading.

Lesson 12 of 13

Equivalence of the models

Arithmetization of Turing machines, proof of Kleene's normal form theorem, simulation of register machines by Turing machines, and the universal partial recursive function.

45 min5 questions
Models of computation · lesson 12 of 13
  1. Algorithms and partial functions
  2. Turing machines
  3. Programming Turing machines
  4. Register machines
  5. Primitive recursive functions
  6. Coding finite sequences
  7. The Ackermann function
  8. Minimization and partial recursive functions
  9. LOOP and WHILE programs
  10. The λ-calculus
  11. Computing with λ-terms
  12. Equivalence of the models
  13. The Church–Turing thesis

We have met five definitions of computable partial function. Some equivalences are already proved:

  • WHILE-computable   ⟺  \iff partial recursive (Theorem 9.6);
  • partial recursive   ⟺  \iff λ-definable (Theorem 11.7 and Theorem 11.8);
  • WHILE-computable   ⟹  \implies URM-computable (Proposition 9.8); the converse follows from the other implications below, and is also the last exercise of the lesson on WHILE programs.

It remains to connect Turing machines to the other models. In this lesson we prove that every Turing-computable function is partial recursive, by arithmetizing the computations of Turing machines, and that every URM-computable function is Turing-computable, by simulation. Along the way we obtain Kleene’s normal form theorem and a universal partial recursive function.

Theorem 12.1 (Equivalence of the models).#

For a partial function f:Nk⇀Nf : \nat^k \rightharpoonup \nat, the following are equivalent:

  1. ff is Turing-computable;
  2. ff is URM-computable;
  3. ff is WHILE-computable;
  4. ff is partial recursive;
  5. ff is λ-definable.

12.1 Arithmetization of Turing machines

Fix a Turing machine MM. Without loss of generality its states are 0,1,…,m0, 1, \dots, m with initial state 00 and halting state 11, and its alphabet is {0,1,…,a}\{0, 1, \dots, a\}, where 00 stands for the blank ⊔\sqcup and 11 for the symbol 11. We use the sequence coding […][\ldots] of the lesson Coding finite sequences, with the primitive recursive operations lh\mathrm{lh}, (s)i′(s)'_i, concatenation ∗*, and

  • cons(b,s)=[b]∗s\mathrm{cons}(b, s) = [b] * s, which adds bb in front of ss;
  • hd(s)=(s)0′\mathrm{hd}(s) = (s)'_0 if lh(s)>0\mathrm{lh}(s) > 0, and 00 otherwise;
  • tl(s)=[(s)1′,…,(s)lh(s)−1′]\mathrm{tl}(s) = [(s)'_1, \dots, (s)'_{\mathrm{lh}(s) - 1}] if lh(s)>0\mathrm{lh}(s) > 0, and [ ][\,] otherwise.

These are primitive recursive; for instance tl(s)=∏i+1<lh(s)pi(s)i+1\mathrm{tl}(s) = \prod_{i + 1 < \mathrm{lh}(s)} p_i^{(s)_{i+1}}.

Coding configurations. A configuration (q,τ,h)(q, \tau, h) is coded by a triple ⟨q,ℓ,r⟩\langle q, \ell, r \rangle where rr is the code of the sequence τ(h),τ(h+1),…,τ(h+j)\tau(h), \tau(h+1), \dots, \tau(h + j) and ℓ\ell is the code of τ(h−1),τ(h−2),…,τ(h−i)\tau(h-1), \tau(h-2), \dots, \tau(h - i), for some i,ji, j large enough that all non-blank cells are covered. The left part is stored in reverse order, so that the cells adjacent to the head are at the front of both sequences. Several codes represent the same configuration, differing by trailing blanks; this causes no problem, since all functions below treat a missing cell as a blank, via hd\mathrm{hd}.

One step. Define Next(c)\mathrm{Next}(c) for c=⟨q,ℓ,r⟩c = \langle q, \ell, r \rangle as follows. If q=1q = 1 (halting), Next(c)=c\mathrm{Next}(c) = c. Otherwise let b=hd(r)b = \mathrm{hd}(r) be the scanned symbol and δ(q,b)=(q′,b′,D)\delta(q, b) = (q', b', D). Then

Next(c)={⟨q′, cons(b′,ℓ), tl(r)⟩if D=R,⟨q′, tl(ℓ), cons(hd(ℓ), cons(b′,tl(r)))⟩if D=L.\mathrm{Next}(c) = \begin{cases} \langle q',\ \mathrm{cons}(b', \ell),\ \mathrm{tl}(r) \rangle & \text{if } D = R, \\ \langle q',\ \mathrm{tl}(\ell),\ \mathrm{cons}(\mathrm{hd}(\ell),\ \mathrm{cons}(b', \mathrm{tl}(r))) \rangle & \text{if } D = L. \end{cases}

This is a definition by cases over the finitely many pairs (q,b)(q, b), plus one case for symbols bb out of range. Hence Next\mathrm{Next} is primitive recursive.

Iteration. Let Init(x⃗)=⟨0,[ ],wx⃗⟩\mathrm{Init}(\vec x) = \langle 0, [\,], w_{\vec x} \rangle, where wx⃗w_{\vec x} is the code of the word 1x1+1 0 1x2+1 0⋯0 1xk+11^{x_1 + 1}\, 0\, 1^{x_2 + 1}\, 0 \cdots 0\, 1^{x_k + 1}; it is primitive recursive (for instance as a concatenation of codes of constant sequences, computed by bounded products). Define by primitive recursion

Conf(x⃗,0)=Init(x⃗),Conf(x⃗,t+1)=Next(Conf(x⃗,t)).\begin{gathered} \mathrm{Conf}(\vec x, 0) = \mathrm{Init}(\vec x), \\ \mathrm{Conf}(\vec x, t + 1) = \mathrm{Next}(\mathrm{Conf}(\vec x, t)). \end{gathered}

Then Conf(x⃗,t)\mathrm{Conf}(\vec x, t) codes the configuration after tt steps if MM has not halted before step tt, and the halting configuration otherwise — this is why Next\mathrm{Next} fixes halting configurations.

Halting and output. The predicates Halt(c)  ⟺  π0(c)=1\mathrm{Halt}(c) \iff \pi_0(c) = 1 (where π0\pi_0 extracts the state from the triple) and Std(c)\mathrm{Std}(c): “every entry of ℓ\ell is 00, and rr consists of y+1y + 1 entries equal to 11 followed only by 00s, for some yy” are primitive recursive, by bounded quantification over the indices of ℓ\ell and rr. The output Out(c)\mathrm{Out}(c), the number of leading 11s of rr minus one, is primitive recursive by bounded minimization.

Proposition 12.2.#

Every Turing-computable partial function is partial recursive.

Let MM compute ff. Let t0(x⃗)≃μt Halt(Conf(x⃗,t))t_0(\vec x) \simeq \mu t\, \mathrm{Halt}(\mathrm{Conf}(\vec x, t)) and c(x⃗)≃Conf(x⃗,t0(x⃗))c(\vec x) \simeq \mathrm{Conf}(\vec x, t_0(\vec x)), the final configuration. Then

f(x⃗)≃Out(c(x⃗))+0⋅μz [χStd(c(x⃗))=1].f(\vec x) \simeq \mathrm{Out}(c(\vec x)) + 0 \cdot \mu z\, [\chi_{\mathrm{Std}}(c(\vec x)) = 1].

If MM does not halt, t0(x⃗) ⁣ ⁣↑t_0(\vec x)\diverge. If it halts in a non-standard configuration, the second summand is a search which never succeeds, so the expression diverges — here we use the convention that 0⋅e0 \cdot e is undefined when ee is. If it halts in a standard configuration, the second summand is 00 and the value is the output. All functions involved are primitive recursive, except for the two minimizations.

12.2 Kleene’s normal form theorem

The construction above depends on the machine MM only through its transition table, a finite object. Code each machine by an integer ee, say e=[m,a,d]e = [m, a, d] where dd codes the list of the transitions δ(q,b)=(q′,b′,D)\delta(q, b) = (q', b', D) as quintuples. Integers which do not code a machine are treated as coding a fixed machine that never halts. Then the step function Next(e,c)\mathrm{Next}(e, c) is primitive recursive in both arguments: the transition is found by a bounded search in the list dd.

Theorem 12.3 (Kleene’s normal form).#

For each k≥1k \geq 1 there are a primitive recursive predicate Tk(e,x⃗,s)T_k(e, \vec x, s) and a primitive recursive function U(s)U(s) such that:

  1. for every ee and x⃗\vec x, there is at most one ss with Tk(e,x⃗,s)T_k(e, \vec x, s);
  2. for every Turing machine with code ee, the function it computes is x⃗↦U(μs Tk(e,x⃗,s))\vec x \mapsto U(\mu s\, T_k(e, \vec x, s)).

Consequently every partial recursive function ff can be written f(x⃗)≃U(μs Tk(e,x⃗,s))f(\vec x) \simeq U(\mu s\, T_k(e, \vec x, s)) for some ee.

Proof of Theorem 12.3.

Let Tk(e,x⃗,s)T_k(e, \vec x, s) state that ss codes the whole computation: s=[c0,…,ct]s = [c_0, \dots, c_t] with c0=Init(x⃗)c_0 = \mathrm{Init}(\vec x), ci+1=Next(e,ci)c_{i+1} = \mathrm{Next}(e, c_i) for i<ti < t, ctc_t halting and standard, and cic_i not halting for i<ti < t. This is a conjunction of bounded quantifications over i<lh(s)i < \mathrm{lh}(s), hence primitive recursive. Such an ss is unique: c0c_0 is fixed, each ci+1c_{i+1} is determined by cic_i, and tt is the first index of a halting configuration. Let U(s)=Out((s)lh(s)−1′)U(s) = \mathrm{Out}((s)'_{\mathrm{lh}(s) - 1}), the output read on the last configuration.

If the machine ee halts on x⃗\vec x in a standard configuration, μs Tk(e,x⃗,s)\mu s\, T_k(e, \vec x, s) is the code of its computation and UU returns the output. Otherwise no ss satisfies TkT_k, and the search diverges. The last statement follows once we know that every partial recursive function is Turing-computable. This is the chain of implications (4) ⇒ (3) ⇒ (2) ⇒ (1) of the last section, whose proof does not use the normal form theorem.

12.3 From register machines to Turing machines

Proposition 12.4.#

Every URM-computable partial function is Turing-computable.

Let P=I1,…,IsP = I_1, \dots, I_s compute f:Nk⇀Nf : \nat^k \rightharpoonup \nat, and let ρ=max⁡(ρ(P),k)\rho = \max(\rho(P), k). We build a multi-tape Turing machine NN with ρ+1\rho + 1 tapes, following the conventions of Definition 3.5: tape 11 holds the input and output, and tape n+1n + 1, for 1≤n≤ρ1 \leq n \leq \rho, holds the content of RnR_n in unary, as ⌜Rn⌝\ulcorner R_n \urcorner starting at the head position. The index of the current instruction is stored in the finite control of NN.

  1. Initialization. NN reads the input ⌜x1⌝⊔⋯⊔⌜xk⌝\ulcorner x_1 \urcorner \sqcup \cdots \sqcup \ulcorner x_k \urcorner on tape 11 and copies the nn-th block to tape n+1n + 1; the other register tapes receive ⌜0⌝\ulcorner 0 \urcorner.

  2. Simulation. For each instruction, NN has a group of states:

    • Z(n)Z(n): erase tape n+1n + 1 and write a single 11;
    • S(n)S(n): append a 11 at the end of the block on tape n+1n + 1, and return;
    • T(m,n)T(m, n): erase tape n+1n + 1 and copy the block of tape m+1m + 1 onto it;
    • J(m,n,q)J(m, n, q): scan the blocks of tapes m+1m + 1 and n+1n + 1 simultaneously from left to right; they have equal length iff both heads reach a blank at the same time. Return the heads, and enter the group of instruction qq or i+1i + 1 accordingly.

    When the current index exceeds ss, the simulation ends.

  3. Output. NN erases tape 11, copies the block of tape 22 (the register R1R_1) onto it, and halts with head 11 on its first cell.

By induction on the number of steps of PP, after the simulation of jj instructions, the tapes of NN represent the registers of PP after jj steps. Hence NN computes ff. By Theorem 3.6, so does some single-tape machine.

12.4 Proof of the equivalence

We can now complete the proof of Theorem 12.1. The following implications are established:

(1)⟹(4)⟹(3)⟹(2)⟹(1),(4)⟺(5).(1) \Longrightarrow (4) \Longrightarrow (3) \Longrightarrow (2) \Longrightarrow (1), \qquad (4) \Longleftrightarrow (5).

Indeed, (1) ⇒ (4) is Proposition 12.2; (4) ⇒ (3) is Theorem 9.6; (3) ⇒ (2) is Proposition 9.8; (2) ⇒ (1) is Proposition 12.4; and (4) ⇔ (5) was proved in the previous lesson. All five classes coincide.

From now on, we call these functions the partial computable functions, and their total members the computable functions.

12.5 The universal function

A consequence of the normal form theorem is that a single partial computable function evaluates all the others.

Corollary 12.5 (Universal function).#

The function Φ(e,x⃗)≃U(μs Tk(e,x⃗,s))\Phi(e, \vec x) \simeq U(\mu s\, T_k(e, \vec x, s)) is partial computable, and for every partial computable f:Nk⇀Nf : \nat^k \rightharpoonup \nat there is ee with f(x⃗)≃Φ(e,x⃗)f(\vec x) \simeq \Phi(e, \vec x) for all x⃗\vec x. In particular, there is a universal Turing machine, which on input (e,x⃗)(e, \vec x) simulates the machine coded by ee on x⃗\vec x.

Proof of Corollary 12.5.

Φ\Phi is partial recursive, as it is obtained from primitive recursive functions by one minimization and one composition. By the equivalence, it is computed by some Turing machine. The second statement is Theorem 12.3.

Writing Φe(x⃗)≃Φ(e,x⃗)\Phi_e(\vec x) \simeq \Phi(e, \vec x), the sequence Φ0,Φ1,Φ2,…\Phi_0, \Phi_1, \Phi_2, \dots is an enumeration of all partial computable functions. Its study is the subject of the course on the fundamentals of computability, starting with the lesson Programs as numbers.

12.6 Exercises

Exercise 12.6 ★.

Show that the function Init(x⃗)\mathrm{Init}(\vec x) is primitive recursive.

Solution

For a single argument, the code of 1x+11^{x+1} is ∏i≤xpi2\prod_{i \leq x} p_i^{2} (each entry 11 is coded by exponent 22), a bounded product. The code of a separator [0][0] is 22. The code of the whole word is obtained by concatenating these codes with the primitive recursive operation ∗*, and Init(x⃗)=⟨0,1,wx⃗⟩\mathrm{Init}(\vec x) = \langle 0, 1, w_{\vec x} \rangle, where 1=[ ]1 = [\,].

Exercise 12.7 ★★.

Using the uniform step function of the normal form theorem, show that the predicate H(e,x,t)H(e, x, t): “the machine of code ee halts on input xx within tt steps, in a standard final configuration” is primitive recursive, and that {(e,x):∃t H(e,x,t)}\{(e, x) : \exists t\ H(e, x, t)\} is the domain of the universal function.

Solution

Let Conf(e,x,t)\mathrm{Conf}(e, x, t) be the uniform version of the iteration function, defined by primitive recursion from Next(e,c)\mathrm{Next}(e, c), hence primitive recursive in e,x,te, x, t. Since Next\mathrm{Next} fixes halting configurations, H(e,x,t)  ⟺  Halt(Conf(e,x,t))∧Std(Conf(e,x,t))H(e, x, t) \iff \mathrm{Halt}(\mathrm{Conf}(e, x, t)) \wedge \mathrm{Std}(\mathrm{Conf}(e, x, t)), a primitive recursive predicate. The machine halts on xx in a standard configuration iff some tt satisfies HH, iff some ss satisfies T1(e,x,s)T_1(e, x, s), iff μs T1(e,x,s)\mu s\, T_1(e, x, s) converges, iff (e,x)∈dom⁡Φ(e, x) \in \dom \Phi (as UU is total).

Exercise 12.8 ★★★.

Show that there is a total computable function g:N2→Ng : \nat^2 \to \nat such that the functions g(e,⋅)g(e, \cdot) are exactly the primitive recursive functions of one argument, and deduce once more that gg is not primitive recursive.

Solution

Code derivations of unary primitive recursive functions by integers, mapping non-codes to a fixed derivation of ZZ. Each derivation can be translated computably into a Turing machine computing the same function; let t(e)t(e) be the code of the machine obtained from the derivation ee. Then g(e,x)=Φ(t(e),x)g(e, x) = \Phi(t(e), x) is computable and total, since primitive recursive functions are total. If gg were primitive recursive, so would be x↦g(x,x)+1x \mapsto g(x, x) + 1, which differs from every g(e,⋅)g(e, \cdot) at ee.

12.7 Notes and references

Turing sketched in an appendix to his 1936 paper that the λ-definable functions are computable by his machines, and proved the equivalence of the two notions in 1937; Kleene proved the equivalence of λ-definability with general recursiveness in 1936. The predicate TT of the normal form theorem is often called Kleene’s TT-predicate. The arithmetization of computations given here follows the treatment of register and Turing machines in Cutland’s and Odifreddi’s textbooks.

  • S. C. Kleene, General recursive functions of natural numbers, Mathematische Annalen 112 (1936), 727–742.
  • A. M. Turing, Computability and λ-definability, Journal of Symbolic Logic 2 (1937), 153–163.
  • N. Cutland, Computability: An Introduction to Recursive Function Theory, Cambridge University Press, 1980.
  • P. Odifreddi, Classical Recursion Theory, North-Holland, 1989, chapter I.