Turing machine


A Turing machine is a mathematical model of computation that defines an abstract machine, which manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, given any computer algorithm, a Turing machine capable of simulating that algorithm's logic can be constructed.
The machine operates on an infinite memory tape divided into discrete "cells". The machine positions its "head" over a cell and "reads" or "scans" the symbol there. Then, as per the symbol and the machine's own present state in a "finite table" of user-specified instructions, the machine writes a symbol in the cell, then either moves the tape one cell left or right, then either proceeds to a subsequent instruction or halts the computation.
The Turing machine was invented in 1936 by Alan Turing, who called it an "a-machine". 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" ; similarly, 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.
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 unsuitable 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 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 a general example of a central processing unit that controls all data manipulation done by a computer, with the canonical machine using sequential memory to store data. More specifically, it is a machine capable of enumerating some arbitrary subset of valid strings of an alphabet; these strings are part of a recursively enumerable set. A Turing machine has a tape of infinite length on which it can perform read and write operations.
Assuming a black box, the Turing machine cannot know whether it will eventually enumerate any one specific string of the subset with a given program. This is due to the fact that the halting problem is unsolvable, which has major implications for the theoretical limits of computing.
The Turing machine is capable of processing an unrestricted grammar, which further implies that it is capable of robustly evaluating first-order logic in an infinite number of ways. This is famously demonstrated through lambda calculus.
A Turing machine that is able to simulate any other Turing machine is called a universal Turing machine. A more mathematically oriented definition with a similar "universal" nature was introduced by Alonzo Church, whose work on lambda calculus intertwined with Turing's in a formal theory of computation known as the Church–Turing thesis. The thesis states that Turing machines indeed capture the informal notion of effective methods in logic and mathematics, and provide a precise definition of an algorithm or "mechanical procedure". Studying their abstract properties yields many insights into computer science and complexity theory.

Physical description

In his 1948 essay, "Intelligent Machinery", Turing wrote that his machine consisted 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:
  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, a Turing machine can be formally defined as a 7-tuple where
A relatively uncommon 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 :
Initially all tape cells are marked with.

Additional details required to visualize or implement Turing machines

In the words of van Emde Boas, p. 6: "The set-theoretical object provides only partial information on how the machine will behave and what its computations will look like."
For instance,
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 in The Undecidable, p. 126-127 and Davis :
Other authors p. 119, Hopcroft and Ullman p. 158, 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.
N3qiSjPrintNone Nqm"blank" = S0, 1=S1, etc.
4qiSjNone NLeft Lqm
5qiSjNone NRight Rqm
6qiSjNone NNone NqmDirect "jump"
7qiSjEraseLeft Lqm
8qiSjEraseRight Rqm
9qiSjEraseNone Nqm

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, Boolos & Jeffrey, Davis-Sigal-Weyuker ); also see more at Post–Turing machine.

The "state"

The word "state" used in context of Turing machines can be a source of confusion, as it can mean two things. Most commentators after Turing have used "state" to mean the name/designator of the current instruction to be performed—i.e. the contents of the state register. But Turing made a strong distinction between a record of what he called the machine's "m-configuration", and the machine's "state of progress" through the computation - the current state of the total system. What Turing called "the state formula" includes both the current instruction and all the symbols on the tape:
Earlier in his paper Turing carried this even further: he gives an example where he placed a symbol of the current "m-configuration"—the instruction's label—beneath the scanned square, together with all the symbols on the tape ; this he calls "the complete configuration". To print the "complete configuration" on one line, he places the state-label/m-configuration to the left of the scanned symbol.
A variant of this is seen in Kleene where Kleene shows how to write the Gödel number of a machine's "situation": he places the "m-configuration" symbol q4 over the scanned square in roughly the center of the 6 non-blank squares on the tape and puts it to the right of the scanned square. But Kleene refers to "q4" itself as "the machine state". Hopcroft and Ullman call this composite the "instantaneous description" and follow the Turing convention of putting the "current state" to the left of the scanned symbol.
Example: total state of 3-state 2-symbol busy beaver after 3 "moves" :
This means: after three moves the tape has... 000110000... on it, the head is scanning the right-most 1, and the state is A. Blanks can be part of the total state as shown here: B01; the tape has a single 1 on it, but the head is scanning the 0 to its left and the state is B.
"State" in the context of Turing machines should be clarified as to which is being described: the current instruction, or the list of symbols on the tape together with the current instruction, or the list of symbols on the tape together with the current instruction placed to the left of the scanned symbol or to the right of the scanned symbol.
Turing's biographer Andrew Hodges has noted and discussed this confusion.

Turing machine "state" diagrams

To the right: the above table as expressed as a "state transition" diagram.
Usually large tables are better left as tables. They are more readily simulated by computer in tabular form. However, certain concepts—e.g. machines with "reset" states and machines with repeating patterns —can be more readily seen when viewed as a drawing.
Whether a drawing represents an improvement on its table must be decided by the reader for the particular context. See Finite state machine for more.
The reader should again be cautioned that such diagrams represent a snapshot of their table frozen in time, not the course of a computation through time and space. While every time the busy beaver machine "runs" it will always follow the same state-trajectory, this is not true for the "copy" machine that can be provided with variable input "parameters".
The diagram "Progress of the computation" shows the three-state busy beaver's "state" progress through its computation from start to finish. On the far right is the Turing "complete configuration" at each step. If the machine were to be stopped and cleared to blank both the "state register" and entire tape, these "configurations" could be used to rekindle a computation anywhere in its progress.

Models equivalent to the Turing machine model

Many machines that might be thought to have more computational capability than a simple universal Turing machine can be shown to have no more power. They might compute faster, perhaps, or use less memory, or their instruction set might be smaller, but they cannot compute more powerfully.
A Turing machine is equivalent to a single-stack pushdown automaton that has been made more flexible and concise by relaxing the last-in-first-out requirement of its stack. In addition, a Turing machine is also equivalent to a two-stack PDA with standard last-in-first-out semantics, by using one stack to model the tape left of the head and the other stack for the tape to the right.
At the other extreme, some very simple models turn out to be Turing-equivalent, i.e. to have the same computational power as the Turing machine model.
Common equivalent models are the multi-tape Turing machine, multi-track Turing machine, machines with input and output, and the non-deterministic Turing machine as opposed to the deterministic Turing machine for which the action table has at most one entry for each combination of symbol and state.
Read-only, right-moving Turing machines are equivalent to DFAs.
For practical and didactical intentions the equivalent register machine can be used as a usual assembly programming language.
An interesting question is whether the computation model represented by concrete programming languages is Turing equivalent. While the computation of a real computer is based on finite states and thus not capable to simulate a Turing machine, programming languages themselves do not necessarily have this limitation. Kirner et al., 2009 have shown that among the general-purpose programming languages some are Turing complete while others are not. For example, ANSI C is not Turing-equivalent, as all instantiations of ANSI C imply a finite-space memory. This is because the size of memory reference data types, called pointers, is accessible inside the language. However, other programming languages like Pascal do not have this feature, which allows them to be Turing complete in principle.
It is just Turing complete in principle, as memory allocation in a programming language is allowed to fail, which means the programming language can be Turing complete when ignoring failed memory allocations, but the compiled programs executable on a real computer cannot.

Choice c-machines, oracle o-machines

Early in his paper Turing makes a distinction between an "automatic machine"—its "motion... completely determined by the configuration" and a "choice machine":
Turing does not elaborate further except in a footnote in which he describes how to use an a-machine to "find all the provable formulae of the calculus" rather than use a choice machine. He "suppose that the choices are always between two possibilities 0 and 1. Each proof will then be determined by a sequence of choices i1, i2,..., in, and hence the number 2n + i12n-1 + i22n-2 +... +in completely determines the proof. The automatic machine carries out successively proof 1, proof 2, proof 3,..."
This is indeed the technique by which a deterministic Turing machine can be used to mimic the action of a nondeterministic Turing machine; Turing solved the matter in a footnote and appears to dismiss it from further consideration.
An oracle machine or o-machine is a Turing a-machine that pauses its computation at state "o" while, to complete its calculation, it "awaits the decision" of "the oracle"—an unspecified entity "apart from saying that it cannot be a machine".

Universal Turing machines

As Turing wrote in The Undecidable, p. 128 :
This finding is now taken for granted, but at the time it was considered astonishing. The model of computation that Turing called his "universal machine"—"U" for short—is considered by some to have been the fundamental theoretical breakthrough that led to the notion of the stored-program computer.
In terms of computational complexity, a multi-tape universal Turing machine need only be slower by logarithmic factor compared to the machines it simulates. This result was obtained in 1966 by F. C. Hennie and R. E. Stearns.

Comparison with real machines

It is often said that Turing machines, unlike simpler automata, are as powerful as real machines, and are able to execute any operation that a real program can. What is neglected in this statement is that, because a real machine can only have a finite number of configurations, this "real machine" is really nothing but a finite state machine. On the other hand, Turing machines are equivalent to machines that have an unlimited amount of storage space for their computations.
There are a number of ways to explain why Turing machines are useful models of real computers:
  1. Anything a real computer can compute, a Turing machine can also compute. For example: "A Turing machine can simulate any type of subroutine found in programming languages, including recursive procedures and any of the known parameter-passing mechanisms". A large enough FSA can also model any real computer, disregarding IO. Thus, a statement about the limitations of Turing machines will also apply to real computers.
  2. The difference lies only with the ability of a Turing machine to manipulate an unbounded amount of data. However, given a finite amount of time, a Turing machine can only manipulate a finite amount of data.
  3. Like a Turing machine, a real machine can have its storage space enlarged as needed, by acquiring more disks or other storage media.
  4. Descriptions of real machine programs using simpler abstract models are often much more complex than descriptions using Turing machines. For example, a Turing machine describing an algorithm may have a few hundred states, while the equivalent deterministic finite automaton on a given real machine has quadrillions. This makes the DFA representation infeasible to analyze.
  5. Turing machines describe algorithms independent of how much memory they use. There is a limit to the memory possessed by any current machine, but this limit can rise arbitrarily in time. Turing machines allow us to make statements about algorithms which will hold forever, regardless of advances in conventional computing machine architecture.
  6. Turing machines simplify the statement of algorithms. Algorithms running on Turing-equivalent abstract machines are usually more general than their counterparts running on real machines, because they have arbitrary-precision data types available and never have to deal with unexpected conditions.

Limitations of Turing machines

Computational complexity theory

A limitation of Turing machines is that they do not model the strengths of a particular arrangement well. For instance, modern stored-program computers are actually instances of a more specific form of abstract machine known as the random-access stored-program machine or RASP machine model. Like the universal Turing machine, the RASP stores its "program" in "memory" external to its finite-state machine's "instructions". Unlike the universal Turing machine, the RASP has an infinite number of distinguishable, numbered but unbounded "registers"—memory "cells" that can contain any integer, Hartmanis, and in particular Cook-Rechow. The RASP's finite-state machine is equipped with the capability for indirect addressing ; thus the RASP's "program" can address any register in the register-sequence. The upshot of this distinction is that there are computational optimizations that can be performed based on the memory indices, which are not possible in a general Turing machine; thus when Turing machines are used as the basis for bounding running times, a 'false lower bound' can be proven on certain algorithms' running times. An example of this is binary search, an algorithm that can be shown to perform more quickly when using the RASP model of computation rather than the Turing machine model.

Concurrency

Another limitation of Turing machines is that they do not model concurrency well. For example, there is a bound on the size of integer that can be computed by an always-halting nondeterministic Turing machine starting on a blank tape. By contrast, there are always-halting concurrent systems with no inputs that can compute an integer of unbounded size.

Interaction

In the early days of computing, computer use was typically limited to batch processing, i.e., non-interactive tasks, each producing output data from given input data. Computability theory, which studies computability of functions from inputs to outputs, and for which Turing machines were invented, reflects this practice.
Since the 1970s, interactive use of computers became much more common. In principle, it is possible to model this by having an external agent read from the tape and write to it at the same time as a Turing machine, but this rarely matches how interaction actually happens; therefore, when describing interactivity, alternatives such as I/O automata are usually preferred.

History

They were described in 1936 by Alan Turing.

Historical background: computational machinery

—a student of Alan Turing, and his lifelong friend—traces the lineage of the notion of "calculating machine" back to Charles Babbage and actually proposes "Babbage's Thesis":
Gandy's analysis of Babbage's Analytical Engine describes the following five operations :
  1. The arithmetic functions +, −, ×, where − indicates "proper" subtraction if.
  2. Any sequence of operations is an operation.
  3. Iteration of an operation.
  4. Conditional iteration.
  5. Conditional transfer.
Gandy states that "the functions which can be calculated by,, and are precisely those which are Turing computable.". He cites other proposals for "universal calculating machines" including those of Percy Ludgate, Leonardo Torres y Quevedo, Maurice d'Ocagne, Louis Couffignal, Vannevar Bush, Howard Aiken. However:

The Entscheidungsproblem (the "decision problem"): Hilbert's tenth question of 1900

With regard to Hilbert's problems posed by the famous mathematician David Hilbert in 1900, an aspect of problem #10 had been floating about for almost 30 years before it was framed precisely. Hilbert's original expression for #10 is as follows:
By 1922, this notion of "Entscheidungsproblem" had developed a bit, and H. Behmann stated that
By the 1928 international congress of mathematicians, Hilbert "made his questions quite precise. First, was mathematics complete... Second, was mathematics consistent... And thirdly, was mathematics decidable?". The first two questions were answered in 1930 by Kurt Gödel at the very same meeting where Hilbert delivered his retirement speech ; the third—the Entscheidungsproblem—had to wait until the mid-1930s.
The problem was that an answer first required a precise definition of "definite general applicable prescription", which Princeton professor Alonzo Church would come to call "effective calculability", and in 1928 no such definition existed. But over the next 6–7 years Emil Post developed his definition of a worker moving from room to room writing and erasing marks per a list of instructions, as did Church and his two students Stephen Kleene and J. B. Rosser by use of Church's lambda-calculus and Gödel's recursion theory. Church's paper showed that the Entscheidungsproblem was indeed "undecidable" and beat Turing to the punch by almost a year. In the meantime, Emil Post submitted a brief paper in the fall of 1936, so Turing at least had priority over Post. While Church refereed Turing's paper, Turing had time to study Church's paper and add an Appendix where he sketched a proof that Church's lambda-calculus and his machines would compute the same functions.
And Post had only proposed a definition of calculability and criticized Church's "definition", but had proved nothing.

Alan Turing's a-machine

In the spring of 1935, Turing as a young Master's student at King's College Cambridge, UK, took on the challenge; he had been stimulated by the lectures of the logician M. H. A. Newman "and learned from them of Gödel's work and the Entscheidungsproblem... Newman used the word 'mechanical'... In his obituary of Turing 1955 Newman writes:
Gandy states that:
While Gandy believed that Newman's statement above is "misleading", this opinion is not shared by all. Turing had a lifelong interest in machines: "Alan had dreamt of inventing typewriters as a boy; Mrs. Turing had a typewriter; and he could well have begun by asking himself what was meant by calling a typewriter 'mechanical'". While at Princeton pursuing his PhD, Turing built a Boolean-logic multiplier. His PhD thesis, titled "Systems of Logic Based on Ordinals", contains the following definition of "a computable function":
When Turing returned to the UK he ultimately became jointly responsible for breaking the German secret codes created by encryption machines called "The Enigma"; he also became involved in the design of the ACE, " ACE proposal was effectively self-contained, and its roots lay not in the EDVAC , but in his own universal machine". Arguments still continue concerning the origin and nature of what has been named by Kleene Turing's Thesis. But what Turing did prove with his computational-machine model appears in his paper "On Computable Numbers, with an Application to the Entscheidungsproblem" :
Turing's example : If one is to ask for a general procedure to tell us: "Does this machine ever print 0", the question is "undecidable".

1937–1970: The "digital computer", the birth of "computer science"

In 1937, while at Princeton working on his PhD thesis, Turing built a digital multiplier from scratch, making his own electromechanical relays. "Alan's task was to embody the logical design of a Turing machine in a network of relay-operated switches...". While Turing might have been just initially curious and experimenting, quite-earnest work in the same direction was going in Germany, and in the United States and George Stibitz ; the fruits of their labors were used by both the Axis and Allied militaries in World War II. In the early to mid-1950s Hao Wang and Marvin Minsky reduced the Turing machine to a simpler form ; simultaneously European researchers were reducing the new-fangled electronic computer to a computer-like theoretical object equivalent to what was now being called a "Turing machine". In the late 1950s and early 1960s, the coincidentally parallel developments of Melzak and Lambek, Minsky, and Shepherdson and Sturgis carried the European work further and reduced the Turing machine to a more friendly, computer-like abstract model called the counter machine; Elgot and Robinson, Hartmanis, Cook and Reckhow carried this work even further with the register machine and random-access machine models—but basically all are just multi-tape Turing machines with an arithmetic-like instruction set.

1970–present: the Turing machine as a model of computation

Today, the counter, register and random-access machines and their sire the Turing machine continue to be the models of choice for theorists investigating questions in the theory of computation. In particular, computational complexity theory makes use of the Turing machine:

Primary literature, reprints, and compilations