Turing machine


A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algorithm.
The machine operates on an infinite memory tape divided into discrete cells, each of which can hold a single symbol drawn from a finite set of symbols called the alphabet of the machine. It has a "head" that, at any point in the machine's operation, is positioned over one of these cells, and a "state" selected from a finite set of states. At each step of its operation, the head reads the symbol in its cell. Then, based on the symbol and the machine's own present state, the machine writes a symbol into the same cell, and moves the head one step to the left or the right, or halts the computation. The choice of which replacement symbol to write, which direction to move the head, and whether to halt is based on a finite table that specifies what to do for each combination of the current state and the symbol that is read.
As with a real computer program, it is possible for a Turing machine to go into an infinite loop which will never halt.
The Turing machine was invented in 1936 by Alan Turing, who called it an "a-machine". It was Turing's doctoral advisor, Alonzo Church, who later coined the term "Turing machine" in a review. With this model, Turing was able to answer two questions in the negative:
  • Does a machine exist that can determine whether any arbitrary machine on its tape is "circular" ?
  • Does a machine exist that can determine whether any arbitrary machine on its tape ever prints a given symbol?
Thus by providing a mathematical description of a very simple device capable of arbitrary computations, he was able to prove properties of computation in general—and in particular, the uncomputability of the Entscheidungsproblem, or 'decision problem'.
Turing machines proved the existence of fundamental limitations on the power of mechanical computation.
While they can express arbitrary computations, their minimalist design makes them too slow for computation in practice: real-world computers are based on different designs that, unlike Turing machines, use random-access memory.
Turing completeness is the ability for a model of computation or a system of instructions to simulate a Turing machine. A programming language that is Turing complete is theoretically capable of expressing all tasks accomplishable by computers; nearly all programming languages are Turing complete if the limitations of finite memory are ignored.

Overview

A Turing machine is an idealised model of a central processing unit that controls all data manipulation done by a computer, with the canonical machine using sequential memory to store data. Typically, the sequential memory is represented as a tape of infinite length on which the machine can perform read and write operations.
In the context of formal language theory, a Turing machine is capable of enumerating some arbitrary subset of valid strings of an alphabet. A set of strings which can be enumerated in this manner is called a recursively enumerable language. The Turing machine can equivalently be defined as a model that recognises valid input strings, rather than enumerating output strings.
Given a Turing machine M and an arbitrary string s, it is generally not possible to decide whether M will eventually produce s. This is due to the fact that the halting problem is unsolvable, which has major implications for the theoretical limits of computing.
A Turing machine that is able to simulate any other Turing machine is called a universal Turing machine. Another mathematical formalism, lambda calculus, with a similar "universal" nature was introduced by Alonzo Church. Church's work intertwined with Turing's to form the basis for the Church–Turing thesis. This thesis states that Turing machines, lambda calculus, and other similar formalisms of computation do indeed capture the informal notion of effective methods in logic and mathematics and thus provide a model through which one can reason about an algorithm or "mechanical procedure" in a mathematically precise way without being tied to any particular formalism. Studying the abstract properties of Turing machines has yielded many insights into computer science, computability theory, and complexity theory.

Physical description

In his 1948 essay, "Intelligent Machinery", Turing wrote that his machine consists of:

Description

The Turing machine mathematically models a machine that mechanically operates on a tape. On this tape are symbols, which the machine can read and write, one at a time, using a tape head. Operation is fully determined by a finite set of elementary instructions such as "in state 42, if the symbol seen is 0, write a 1; if the symbol seen is 1, change into state 17; in state 17, if the symbol seen is 0, write a 1 and change to state 6;" etc. In the original article, Turing imagines not a mechanism, but a person whom he calls the "computer", who executes these deterministic mechanical rules slavishly.
More explicitly, a Turing machine consists of:
  • A tape divided into cells, one next to the other. Each cell contains a symbol from some finite alphabet. The alphabet contains a special blank symbol and one or more other symbols. The tape is assumed to be arbitrarily extendable to the left and to the right, so that the Turing machine is always supplied with as much tape as it needs for its computation. Cells that have not been written before are assumed to be filled with the blank symbol. In some models the tape has a left end marked with a special symbol; the tape extends or is indefinitely extensible to the right.
  • A head that can read and write symbols on the tape and move the tape left and right one cell at a time. In some models the head moves and the tape is stationary.
  • A state register that stores the state of the Turing machine, one of finitely many. Among these is the special start state with which the state register is initialised. These states, writes Turing, replace the "state of mind" a person performing computations would ordinarily be in.
  • A finite table of instructions that, given the state the machine is currently in and the symbol it is reading on the tape, tells the machine to do the following in sequence :
  1. Either erase or write a symbol.
  2. Move the head.
  3. Assume the same or a new state as prescribed.
In the 4-tuple models, erasing or writing a symbol and moving the head left or right are specified as separate instructions. The table tells the machine to erase or write a symbol or move the head left or right, and then assume the same or a new state as prescribed, but not both actions and in the same instruction. In some models, if there is no entry in the table for the current combination of symbol and state, then the machine will halt; other models require all entries to be filled.
Every part of the machine and its actions is finite, discrete and distinguishable; it is the unlimited amount of tape and runtime that gives it an unbounded amount of storage space.

Formal definition

Following Hopcroft & Ullman, a Turing machine can be formally defined as a 7-tuple where
  • is a finite, non-empty set of tape alphabet symbols;
  • is the blank symbol ;
  • is the set of input symbols, that is, the set of symbols allowed to appear in the initial tape contents;
  • is a finite, non-empty set of states;
  • is the initial state;
  • is the set of final states or accepting states. The initial tape contents is said to be accepted by if it eventually halts in a state from.
  • is a partial function called the transition function, where L is left shift, R is right shift. If is not defined on the current state and the current tape symbol, then the machine halts; intuitively, the transition function specifies the next state transited from the current state, which symbol to overwrite the current symbol pointed by the head, and the next head movement.
A variant allows "no shift", say N, as a third element of the set of directions.
The 7-tuple for the 3-state busy beaver looks like this :
  • ;
  • ;
  • ;
  • ;
  • ;
  • ;
  • see state-table below.
Initially all tape cells are marked with.

Additional details required to visualise or implement Turing machines

In the words of van Emde Boas : "The set-theoretical object provides only partial information on how the machine will behave and what its computations will look like."
For instance,
  • There will need to be many decisions on what the symbols actually look like, and a failproof way of reading and writing symbols indefinitely.
  • The shift left and shift right operations may shift the tape head across the tape, but when actually building a Turing machine it is more practical to make the tape slide back and forth under the head instead.
  • The tape can be finite, and automatically extended with blanks as needed, but it is more common to think of it as stretching infinitely at one or both ends and being pre-filled with blanks except on the explicitly given finite fragment the tape head is on. The tape cannot be fixed in length, since that would not correspond to the given definition and would seriously limit the range of computations the machine can perform to those of a linear bounded automaton if the tape was proportional to the input size, or finite-state machine if it was strictly fixed-length.

    Alternative definitions

Definitions in literature sometimes differ slightly, to make arguments or proofs easier or clearer, but this is always done in such a way that the resulting machine has the same computational power. For example, the set could be changed from to, where N would allow the machine to stay on the same tape cell instead of moving left or right. This would not increase the machine's computational power.
The most common convention represents each "Turing instruction" in a "Turing table" by one of nine 5-tuples, per the convention of Turing/Davis and Davis ):
Other authors, Hopcroft and Ullman, Stone, adopt a different convention, with new state qm listed immediately after the scanned symbol Sj:
For the remainder of this article "definition 1" will be used.
Current stateScanned symbolPrint symbolMove tapeFinal state5-tuples
A01RB
A11LC
B01LA
B11RB
C01LB
C11NH

In the following table, Turing's original model allowed only the first three lines that he called N1, N2, N3. He allowed for erasure of the "scanned square" by naming a 0th symbol S0 = "erase" or "blank", etc. However, he did not allow for non-printing, so every instruction-line includes "print symbol Sk" or "erase". The abbreviations are Turing's. Subsequent to Turing's original paper in 1936–1937, machine-models have allowed all nine possible types of five-tuples:
Current m-configuration
Tape symbolPrint-operationTape-motionFinal m-configuration
5-tuple5-tuple comments4-tuple
N1qiSjPrintLeft Lqm "blank" = S0, 1=S1, etc.
N2qiSjPrintRight Rqm "blank" = S0, 1=S1, etc.
N3qiSjPrintqm "blank" = S0, 1=S1, etc.
4qiSjLeft Lqm
5qiSjRight Rqm
6qiSjqmDirect "jump"
7qiSjEraseLeft Lqm
8qiSjEraseRight Rqm
9qiSjEraseqm

Any Turing table can be constructed from the above nine 5-tuples. For technical reasons, the three non-printing or "N" instructions can usually be dispensed with. For examples see Turing machine examples.
Less frequently the use of 4-tuples are encountered: these represent a further atomization of the Turing instructions.