Turing’s 1936 model arises from an analysis of a human computing with pencil and paper. The paper is replaced by a one-dimensional tape divided into cells, each holding one symbol from a finite alphabet. The person’s attention is a head scanning one cell at a time. Their state of mind, which can only take finitely many values, is the state of the machine. At each step, the action depends only on the current state and on the scanned symbol, and consists in writing a symbol, moving one cell left or right, and changing state.
2.1 Definition
A Turing machine is a tuple where
- is a finite set of states, with an initial state and a halting state , ;
- is a finite alphabet containing at least the blank symbol and the symbol ;
- is the transition function.
An entry reads: in state , scanning , write , move in direction , and enter state . Since is defined on all pairs with , the machine can always perform a step unless it is in the halting state. A machine is a finite object: it can be written as a finite table, and there are only countably many machines (up to renaming of states and symbols).
To describe the state of a computation, we index the cells of the tape by .
A tape is a function such that for all but finitely many . A configuration of is a triple where , is a tape and is the head position. The configuration is halting if .
If is not halting and , the successor of is the configuration where
We write , or simply .
Every non-halting configuration has exactly one successor, and a halting configuration has none: Turing machines are deterministic.
The computation of from a configuration is the sequence , which is either infinite, or finite and ends with the first halting configuration . In the second case we say that halts from after steps, with final configuration .
2.2 Computing functions
To compute functions on integers we fix conventions for representing inputs and outputs on the tape. We use unary notation, representing by consecutive s:
Using rather than symbols ensures that every number, including , occupies at least one cell, so that a tuple of numbers separated by single blanks can be read unambiguously.
Let be a Turing machine and .
- The initial configuration on input is , where the tape contains the word written from cell onwards, and blanks elsewhere.
- A configuration is a standard final configuration with output if for and for all other : the tape contains exactly , and the head scans its first cell.
The partial function computed by is defined by: if the computation of from the initial configuration on input halts in a standard final configuration with output , and otherwise.
A partial function is Turing-computable if for some machine .
Note that is undefined both when the computation does not halt and when it halts in a non-standard configuration. With this convention every machine computes exactly one -ary partial function, for each .
The precise conventions — unary or binary notation, a tape infinite in one or both directions, a cleaned tape at the end or not — vary between textbooks. They change the machines, but not the class of Turing-computable functions. The robustness of the class under such changes is discussed in the next lesson.
2.3 First example: the successor function
Let be the machine with states , alphabet , and transitions
In state the head runs right across the input. On the first blank it writes a and turns back in state , runs left to the blank preceding the block, and steps back onto the first .
computes the successor function: for every .
Write for the tape containing s exactly on the cells . The initial configuration on input is . For , the cell contains , so by the first transition
Cell is blank, so the next configuration is . For the cell contains , so
Cell is blank, so the next configuration is . This is a standard final configuration with output , reached after steps.
The proof follows a pattern used for all such verifications: describe the configurations at the beginning and at the end of each phase of the computation, and check each phase by induction on the number of steps.
2.4 Second example: addition
The machine below computes . On input , it replaces the separating blank by a , which produces a block of ones; it then erases the last two s and returns to the beginning of the block.
The entries and are never used on inputs of the required form; they are only there to make total.
computes addition: for all .
The initial tape has s on the cells and , and a blank on cell . In state the head moves right to cell , writes there and moves to cell in state . Now the tape contains s exactly on . In state the head moves right to cell , which is blank, and moves back to cell in state . It erases this cell and moves to cell in state . Since , this cell belongs to the block written in the first phase and has not been erased, so it contains ; it is erased and the head moves to cell in state . The tape now contains s exactly on . As in the previous proof, runs left to cell , and the machine halts with the head on cell . The final configuration is standard with output .
2.5 Exercises
Give a machine computing the constant function , and prove that it is correct.
Solution
The machine must erase all s but the first and return to cell :
On input the head steps from cell to cell in state , erases cells and reaches the blank cell , moves back to cell in state , moves left over the blanks to cell , which contains , moves to cell in state , and finally halts on cell . The tape contains a single on cell : the output is . The entries and are never used.
Give a machine computing the projection .
Solution
Run right to the separator, step over it, erase the block until reaching the blank after it, then run left over blanks until the last of , then left over the s to cell , and step right:
In state , the head moves left over the erased cells and the separator until it reaches cell , the last of the first block.
Show that every Turing-computable partial function is computed by infinitely many machines. Show that there are only countably many Turing-computable partial functions , and deduce that there is a total function which is not Turing-computable.
Solution
Adding to a machine states that are never entered does not change its computations, so each computable function has infinitely many machines. Up to renaming, a machine is determined by finitely many data — the numbers of states and symbols, and the table of — so it can be described by a finite string over a finite alphabet, and there are countably many machines; hence countably many computable functions. The set of total functions is uncountable (by a diagonal argument, see The diagonal argument), so some total function is not computable.
2.6 Notes and references
Turing’s machines (1936) differ from ours in inessential details: they compute infinite binary sequences rather than functions, and halting plays no role. Post introduced an almost identical model independently in the same year. The representation of by strokes is that of Kleene (Introduction to Metamathematics, §67); the requirement of a standard final configuration, with the output alone on the tape and the head on its first cell, is close to the conventions of Boolos, Burgess and Jeffrey.
- E. L. Post, Finite combinatory processes — formulation 1, Journal of Symbolic Logic 1 (1936), 103–105.
- S. C. Kleene, Introduction to Metamathematics, North-Holland, 1952.
- G. Boolos, J. Burgess, R. Jeffrey, Computability and Logic, 5th edition, Cambridge University Press, 2007.