We have met five definitions of computable partial function. Some equivalences are already proved:
- WHILE-computable partial recursive (Theorem 9.6);
- partial recursive λ-definable (Theorem 11.7 and Theorem 11.8);
- WHILE-computable 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.
For a partial function , the following are equivalent:
- is Turing-computable;
- is URM-computable;
- is WHILE-computable;
- is partial recursive;
- is λ-definable.
12.1 Arithmetization of Turing machines
Fix a Turing machine . Without loss of generality its states are with initial state and halting state , and its alphabet is , where stands for the blank and for the symbol . We use the sequence coding of the lesson Coding finite sequences, with the primitive recursive operations , , concatenation , and
- , which adds in front of ;
- if , and otherwise;
- if , and otherwise.
These are primitive recursive; for instance .
Coding configurations. A configuration is coded by a triple where is the code of the sequence and is the code of , for some 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 .
One step. Define for as follows. If (halting), . Otherwise let be the scanned symbol and . Then
This is a definition by cases over the finitely many pairs , plus one case for symbols out of range. Hence is primitive recursive.
Iteration. Let , where is the code of the word ; it is primitive recursive (for instance as a concatenation of codes of constant sequences, computed by bounded products). Define by primitive recursion
Then codes the configuration after steps if has not halted before step , and the halting configuration otherwise — this is why fixes halting configurations.
Halting and output. The predicates (where extracts the state from the triple) and : “every entry of is , and consists of entries equal to followed only by s, for some ” are primitive recursive, by bounded quantification over the indices of and . The output , the number of leading s of minus one, is primitive recursive by bounded minimization.
Every Turing-computable partial function is partial recursive.
Let compute . Let and , the final configuration. Then
If does not halt, . 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 is undefined when is. If it halts in a standard configuration, the second summand is 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 only through its transition table, a finite object. Code each machine by an integer , say where codes the list of the transitions as quintuples. Integers which do not code a machine are treated as coding a fixed machine that never halts. Then the step function is primitive recursive in both arguments: the transition is found by a bounded search in the list .
For each there are a primitive recursive predicate and a primitive recursive function such that:
- for every and , there is at most one with ;
- for every Turing machine with code , the function it computes is .
Consequently every partial recursive function can be written for some .
Let state that codes the whole computation: with , for , halting and standard, and not halting for . This is a conjunction of bounded quantifications over , hence primitive recursive. Such an is unique: is fixed, each is determined by , and is the first index of a halting configuration. Let , the output read on the last configuration.
If the machine halts on in a standard configuration, is the code of its computation and returns the output. Otherwise no satisfies , 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
Every URM-computable partial function is Turing-computable.
Let compute , and let . We build a multi-tape Turing machine with tapes, following the conventions of Definition 3.5: tape holds the input and output, and tape , for , holds the content of in unary, as starting at the head position. The index of the current instruction is stored in the finite control of .
-
Initialization. reads the input on tape and copies the -th block to tape ; the other register tapes receive .
-
Simulation. For each instruction, has a group of states:
- : erase tape and write a single ;
- : append a at the end of the block on tape , and return;
- : erase tape and copy the block of tape onto it;
- : scan the blocks of tapes and 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 or accordingly.
When the current index exceeds , the simulation ends.
-
Output. erases tape , copies the block of tape (the register ) onto it, and halts with head on its first cell.
By induction on the number of steps of , after the simulation of instructions, the tapes of represent the registers of after steps. Hence computes . 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:
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.
The function is partial computable, and for every partial computable there is with for all . In particular, there is a universal Turing machine, which on input simulates the machine coded by on .
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 , the sequence 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
Show that the function is primitive recursive.
Solution
For a single argument, the code of is (each entry is coded by exponent ), a bounded product. The code of a separator is . The code of the whole word is obtained by concatenating these codes with the primitive recursive operation , and , where .
Using the uniform step function of the normal form theorem, show that the predicate : “the machine of code halts on input within steps, in a standard final configuration” is primitive recursive, and that is the domain of the universal function.
Solution
Let be the uniform version of the iteration function, defined by primitive recursion from , hence primitive recursive in . Since fixes halting configurations, , a primitive recursive predicate. The machine halts on in a standard configuration iff some satisfies , iff some satisfies , iff converges, iff (as is total).
Show that there is a total computable function such that the functions are exactly the primitive recursive functions of one argument, and deduce once more that is not primitive recursive.
Solution
Code derivations of unary primitive recursive functions by integers, mapping non-codes to a fixed derivation of . Each derivation can be translated computably into a Turing machine computing the same function; let be the code of the machine obtained from the derivation . Then is computable and total, since primitive recursive functions are total. If were primitive recursive, so would be , which differs from every at .
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 of the normal form theorem is often called Kleene’s -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.