Turing machine: Difference between revisions

Content deleted Content added
m Use British English(?)
 
(33 intermediate revisions by 16 users not shown)
Line 2:
{{Other uses}}
{{Turing}}
[[File:Turing Machine Model Davey 2012.jpg|alt=A physical Turing machine constructed by Mike Davey|thumb|A physical Turing machine model. A true Turing machine would have unlimited tape on both sides,; however, physical models can only have a finite amount of tape.]]
{{Automata theory}}
 
A '''Turing machine''' is a [[mathematical model of computation]] describing an [[abstract machine]]<ref>Minsky 1967:107 "In his 1936 paper, A. M. Turing defined the class of abstract machines that now bear his name. A Turing machine is a finite-state machine associated with a special kind of environment -- its tape -- in which it can store (and later recover) sequences of symbols," also Stone 1972:8 where the word "machine" is in quotation marks.</ref> that manipulates symbols on a strip of tape according to a table of rules.<ref>Stone 1972:8 states "This "machine" is an abstract mathematical model", also cf. Sipser 2006:137ff that describes the "Turing machine model". Rogers 1987 (1967):13 refers to "Turing's characterization", Boolos Burgess and Jeffrey 2002:25 refers to a "specific kind of idealized machine".</ref> Despite the model's simplicity, it is capable of implementing any [[computer algorithm]].<ref>Sipser 2006:137 "A Turing machine can do everything that a real computer can do".</ref>
 
The machine operates on an infinite<ref>Cf. Sipser 2002:137. Also, Rogers 1987 (1967):13 describes "a paper tape of infinite length in both directions". Minsky 1967:118 states "The tape is regarded as infinite in both directions". Boolos Burgess and Jeffrey 2002:25 include the possibility of "there is someone stationed at each end to add extra blank squares as needed".</ref> memory tape divided into [[discrete mathematics|discrete]] cells,<ref>Cf. Rogers 1987 (1967):13. Other authors use the word "square" e.g. Boolos Burgess Jeffrey 2002:35, Minsky 1967:117, Penrose 1989:37.</ref> each of which can hold a single symbol drawn from a [[finite set]] of symbols called the [[Alphabet (formal languages)|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,<ref>Boolos Burgess Jeffry 2002:25 illustrate the machine as moving along the tape. Penrose 1989:36-37 describes himself as "uncomfortable" with an infinite tape observing that it "might be hard to shift!"; he "prefer[s] to think of the tape as representing some external environment through which our finite device can move" and after observing that the " 'movement' is a convenient way of picturing things" and then suggests that "the device receives all its input from this environment. Some variations of the Turing machine model also allow the head to stay in the same position instead of moving or halting.</ref> 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. Like 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]],<ref name=Hodges-2012>{{cite book |first=Andrew | last=Hodges |author-link =Andrew Hodges |year = 2012 |title =Alan Turing: The Enigma |publisher =[[Princeton University Press]] |isbn=978-0-691-15564-7 |edition=The Centenary }}</ref><ref>The idea came to him in mid-1935 (perhaps, see more in the History section) after a question posed by [[M. H. A. Newman]] in his lectures: "Was there a definite method, or as Newman put it, a "mechanical process" which could be applied to a mathematical statement, and which would come up with the answer as to whether it was provable" (Hodges 1983:93). Turing submitted his paper on 31 May 1936 to the London Mathematical Society for its ''Proceedings'' (cf. Hodges 1983:112), but it was published in early 1937 and offprints were available in February 1937 (cf. Hodges 1983:129).</ref> who called it an "a-machine" (automatic machine).<ref>See footnote in Davis 2000:151.</ref> It was Turing's doctoral advisor, [[Alonzo Church]], who later coined the term "Turing machine" in a review.<ref>see note in forward to The Collected Works of Alonzo Church ({{Cite book |url=https://mitpress.mit.edu/books/collected-works-alonzo-church |title=The Collected Works of Alonzo Church |date=2019-04-23 |publisher=MIT Press |isbn=978-0-262-02564-5 |editor-last=Burge |editor-first=Tyler |location=Cambridge, MA, US |language=en |editor-last2=Enderton |editor-first2=Herbert}})</ref> 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" (e.g., freezes, or fails to continue its computational task)?
* Does a machine exist that can determine whether any arbitrary machine on its tape ever prints a given symbol?<ref>Turing 1936 in ''The Undecidable'' 1965:132-134; Turing's definition of "circular" is found on page 119.</ref><ref>{{cite journal |first=Alan Mathison |last=Turing |title=On Computable Numbers, with an Application to the ''Entscheidungsproblem'' |journal=Proceedings of the London Mathematical Society |series=Series 2 |volume=42 |number=1 |pages=230–265 |year=1937 | doi=10.1112/plms/s2-42.1.230 |s2cid=73712 }} — Reprint at: {{cite web |url=http://www.turingarchive.org/viewer/?id=466&title=01e |access-date=9 July 2020 |first=Alan |last=Turing |title=On computable numbers, with an application to the Entscheidungsproblem |website=The Turing Digital Archive }}{{Dead link|date=March 2023 |bot=InternetArchiveBot |fix-attempted=yes }}</ref>
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 [[computability|uncomputability]] of the ''[[Entscheidungsproblem]]'' ('decision problem').<ref>Turing 1936 in ''The Undecidable'' 1965:145</ref>
 
Line 19:
 
==Overview==
A Turing machine is an idealised model of a [[central processing unit]] (CPU) 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 ([[automaton]]) is capable of [[enumeration|enumerating]] some arbitrary subset of valid strings of an [[alphabet (formal languages)|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.
Line 30:
 
===Physical description===
In his 1948 essay, "Intelligent Machinery", Turing wrote that his machine consistedconsists of:
 
{{quote|...an unlimited memory capacity obtained in the form of an infinite tape marked out into squares, on each of which a symbol could be printed. At any moment there is one symbol in the machine; it is called the scanned symbol. The machine can alter the scanned symbol, and its behavior is in part determined by that symbol, but the symbols on the tape elsewhere do not affect the behavior of the machine. However, the tape can be moved back and forth through the machine, this being one of the elementary operations of the machine. Any symbol on the tape may therefore eventually have an innings.<ref>See the definition of "[[wikt:innings|innings]]" on [[Wiktionary]]</ref>|Turing 1948, p. 3<ref>
Line 55:
* A ''head'' that can read and write symbols on the tape and move the tape left and right one (and only 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''<ref>Occasionally called an ''action table'' or ''transition function''.</ref> of instructions<ref>Usually quintuples [5-tuples]: q<sub>i</sub>a<sub>j</sub>→q<sub>i1</sub>a<sub>j1</sub>d<sub>k</sub>, but sometimes quadruples [4-tuples].</ref> that, given the ''state''(q<sub>i</sub>) the machine is currently in ''and'' the ''symbol''(a<sub>j</sub>) it is reading on the tape (the symbol currently under the head), tells the machine to do the following ''in sequence'' (for the 5-[[tuple]] models):
# Either erase or write a symbol (replacing a<sub>j</sub> with a<sub>j1</sub>).
# Move the head (which is described by d<sub>k</sub> and can have values: 'L' for one step left ''or'' 'R' for one step right ''or'' 'N' for staying in the same place).
Line 134:
* 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 (which is closest to the mathematical definition), 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. (Thisthis is, of course, not implementable in practice.). 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===
Line 154:
! Current state
! Scanned symbol
 
!
! Print symbol
! Move tape
Line 162:
| '''A'''
| 0
 
|
| 1
| R
Line 170:
| '''A'''
| 1
 
|
| 1
| L
Line 178:
| '''B'''
| 0
 
|
| 1
| L
Line 186:
| '''B'''
| 1
 
|
| 1
| R
Line 194:
| '''C'''
| 0
 
|
| 1
| L
Line 202:
| '''C'''
| 1
 
|
| 1
| N
Line 404:
Common equivalent models are the [[multi-tape Turing machine]], [[multi-track Turing machine]], machines with input and output, and the [[Non-deterministic Turing machine|''non-deterministic'' Turing machine]] (NDTM) as opposed to the ''deterministic'' Turing machine (DTM) for which the action table has at most one entry for each combination of symbol and state.
 
[[Read-only right moving Turing machines|Read-only, right-moving Turing machines]] are equivalent to [[Deterministic finite automaton|DFAs]] (as well as [[Nondeterministic finite automaton|NFAs]] by conversion using the [[NDFANFA to DFA conversion algorithm]] algorithm).
 
For practical and didacticaldidactic intentions, the equivalent [[register machine]] can be used as a usual [[Assembly language|assembly]] [[programming language]].
 
A relevant question is whether or not 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 complete, as all instantiations of ANSI C (different instantiations are possible as the standard deliberately leaves certain behaviour undefined for legacy reasons) 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 (programming language)|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.
 
Line 420:
This is indeed the technique by which a deterministic (i.e., a-) 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 entity unspecified entityby Turing "apart from saying that it cannot be a machine" (Turing (1939), ''The Undecidable'', p.&nbsp;166–168).
 
==Universal Turing machines==
Line 437:
==Comparison with real machines==
[[File:Lego Turing Machine.jpg|thumb|A Turing machine realization using [[Lego]] pieces]]
ItTuring ismachines oftenare believed{{whom|date=Decembermore 2021}}powerful thatthan Turingsome machinesother kinds of automata, unlikesuch simpleras [[finite-state machine]]s and [[pushdown automata]]. According to the [[Church–Turing thesis]], they 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'', it is nothing but a [[finite-state machine]], whereas a Turing machine has an unlimited amount of storage space available for its computations.
 
There are a number of ways to explain why Turing machines are useful models of real computers:
Line 446:
* 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 (DFA) on a given real machine has quadrillions. This makes the DFA representation infeasible to analyze.
* 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 (theoretically) hold forever, regardless of advances in ''conventional'' computing machine architecture.
* Turing machines simplify the statement of algorithms.{{dubious|Dubious benefits of Turing machines|date=September 2022}} Algorithms running on Turing-equivalent abstract machines are usually more general than their counterparts running on real machines, because theycan have arbitrary-precision data types available and never have to deal with unexpected conditions (including, but not limited to, running [[out of memory]]).
 
[[File:Turingmachine.jpg|thumb|Another Turing machine realization]]
Line 461:
 
Since the 1970s, [[interactivity|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 [[Input/output automaton|I/O automata]] are usually preferred.
 
== Comparison with the arithmetic model of computation ==
The [[arithmetic model of computation]] differs from the Turing model in two aspects: <ref name=":0">{{Cite Geometric Algorithms and Combinatorial Optimization}}</ref>{{Rp|page=32}}
 
* In the arithmetic model, every real number requires a single memory cell, whereas in the Turing model the storage size of a real number depends on the number of bits required to represent it.
* In the arithmetic model, every basic arithmetic operation on real numbers (addition, subtraction, multiplication and division) can be done in a single step, whereas in the Turing model the run-time of each arithmetic operation depends on the length of the operands.
 
Some algorithms run in polynomial time in one model but not in the other one. For example:
 
* The [[Euclidean algorithm]] runs in polynomial time in the Turing model, but not in the arithmetic model.
* The algorithm that reads ''n'' numbers and then computes <math>2^{2^n}</math> by [[repeated squaring]] runs in polynomial time in the Arithmetic model, but not in the Turing model. This is because the number of bits required to represent the outcome is exponential in the input size.
 
However, if an algorithm runs in polynomial time in the arithmetic model, and in addition, the binary length of all involved numbers is polynomial in the length of the input, then it is always polynomial-time in the Turing model. Such an algorithm is said to run in [[Strongly polynomial|strongly polynomial time]].
 
==History==
Line 471 ⟶ 484:
 
Gandy's analysis of Babbage's [[analytical engine]] describes the following five operations (cf. p.&nbsp;52–53):
*# The arithmetic functions +, −, ×, where − indicates "proper" subtraction: {{nowrap|''x'' − ''y'' {{=}} 0}} if {{nowrap|''y'' ≥ ''x''}}.
*# Any sequence of operations is an operation.
*# Iteration of an operation (repeating n times an operation P).
*# Conditional iteration (repeating n times an operation P conditional on the "success" of test T).
*# Conditional transfer (i.e., conditional "[[goto]]").
 
Gandy states that "the functions which can be calculated by (1), (2), and (4) are precisely those which are [[Turing computable]]." (p.&nbsp;53). He cites other proposals for "universal calculating machines" including those of [[Percy Ludgate]] (1909), [[Leonardo Torres Quevedo]] (1914),<ref name="LTQ1914es">L. Torres Quevedo. ''Ensayos sobre Automática – Su definicion. Extension teórica de sus aplicaciones,'' Revista de la Academia de Ciencias Exacta, Revista 12, pp. 391–418, 1914.</ref><ref name="LTQ1915fr">Torres Quevedo. L. (1915). [https://diccan.com/dicoport/Torres.htm "Essais sur l'Automatique - Sa définition. Etendue théorique de ses applications"], ''Revue Génerale des Sciences Pures et Appliquées'', vol. 2, pp. 601–611.</ref> [[Maurice d'Ocagne]] (1922), [[Louis Couffignal]] (1933), [[Vannevar Bush]] (1936), [[Howard Aiken]] (1937). However:
Line 482 ⟶ 495:
 
===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 [[Hilbert's tenth problem|problem #10]] had been floating about for almost 30 years before it was framed precisely. Hilbert's original expression for No. 10 is as follows:
 
{{quote|''10. Determination of the solvability of a Diophantine equation''. Given a [[Diophantine equation]] with any number of unknown quantities and with rational integral coefficients: To devise a process according to which it can be determined in a finite number of operations whether the equation is solvable in rational integers.
Line 497 ⟶ 510:
By the 1928 international congress of mathematicians, Hilbert "made his questions quite precise. First, was mathematics ''[[Completeness (logic)|complete]]'' ... Second, was mathematics ''[[Consistency proof|consistent]]'' ... And thirdly, was mathematics ''[[Decidability (logic)|decidable]]''?" (Hodges p.&nbsp;91, Hawking p.&nbsp;1121). The first two questions were answered in 1930 by [[Kurt Gödel]] at the very same meeting where Hilbert delivered his retirement speech (much to the chagrin of Hilbert); 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 (Post 1936), 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]] (1934). Church's paper (published 15 April 1936) showed that the Entscheidungsproblem was indeed "undecidable"<ref>The narrower question posed in [[Hilbert's tenth problem]], about [[Diophantine equation]]s, remains unresolved until 1970, when the relationship between [[recursively enumerable set]]s and [[Diophantine set]]s is finally laid bare.</ref> and beat Turing to the punch by almost a year (Turing's paper submitted 28 May 1936, published January 1937). 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.
 
{{quote|But what Church had done was something rather different, and in a certain sense weaker. ... the Turing construction was more direct, and provided an argument from first principles, closing the gap in Church's demonstration.|Hodges p. 112}}
Line 518 ⟶ 531:
Alan Turing invented the "a-machine" (automatic machine) in 1936.<ref name=Hodges-2012/> Turing submitted his paper on 31 May 1936 to the London Mathematical Society for its ''Proceedings'' (cf. Hodges 1983:112), but it was published in early 1937 and offprints were available in February 1937 (cf. Hodges 1983:129) It was Turing's doctoral advisor, [[Alonzo Church]], who later coined the term "Turing machine" in a review.<ref>see note in forward to The Collected Works of Alonzo Church ({{Cite book |url=https://mitpress.mit.edu/books/collected-works-alonzo-church |title=The Collected Works of Alonzo Church |date=2019-04-23 |publisher=MIT Press |isbn=978-0-262-02564-5 |editor-last=Burge |editor-first=Tyler |location=Cambridge, MA, US |language=en |editor-last2=Enderton |editor-first2=Herbert}})</ref> 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" (e.g., freezes, or fails to continue its computational task)?
* Does a machine exist that can determine whether any arbitrary machine on its tape ever prints a given symbol?<ref>Turing 1936 in ''The Undecidable'' 1965:132-134; Turing's definition of "circular" is found on page 119.</ref><ref>{{cite journal |first=Alan Mathison |last=Turing |title=On Computable Numbers, with an Application to the ''Entscheidungsproblem'' |journal=Proceedings of the London Mathematical Society |series=Series 2 |volume=42 |number=1 |pages=230–265 |year=1937 | doi=10.1112/plms/s2-42.1.230 |s2cid=73712 }} — Reprint at: {{cite web |url=http://www.turingarchive.org/viewer/?id=466&title=01e |access-date=9 July 2020 |first=Alan |last=Turing |title=On computable numbers, with an application to the Entscheidungsproblem |website=The Turing Digital Archive }}{{Dead link|date=March 2023 |bot=InternetArchiveBot |fix-attempted=yes }}</ref>
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 [[computability|uncomputability]] of the ''[[Entscheidungsproblem]]'' ('decision problem').<ref>Turing 1936 in ''The Undecidable'' 1965:145</ref>
 
Line 612 ⟶ 625:
* Brunfiel, Geoff, [http://www.nature.com/news/2007/071024/full/news.2007.190.html Student snags maths prize], ''Nature'', October 24. 2007.
* Jim Giles (2007), [https://www.newscientist.com/article/dn12826-simplest-universal-computer-wins-student-25000.html Simplest 'universal computer' wins student $25,000], New Scientist, October 24, 2007.
* Alex Smith, [http://www.wolframscience.com/prizes/tm23/TM23Proof.pdf Universality of Wolfram’sWolfram's 2, 3 Turing Machine], Submission for the Wolfram 2, 3 Turing Machine Research Prize.
* Vaughan Pratt, 2007, "[http://cs.nyu.edu/pipermail/fom/2007-October/012156.html Simple Turing machines, Universality, Encodings, etc.]", FOM email list. October 29, 2007.
* Martin Davis, 2007, "[http://cs.nyu.edu/pipermail/fom/2007-October/012132.html Smallest universal machine]", and [http://cs.nyu.edu/pipermail/fom/2007-October/012145.html Definition of universal Turing machine] FOM email list. October 26–27, 2007.