Turing Machine
Turing Machine
Despite its simplicity, a Turing machine can be adapted to simulate the logic of any computer algorithm, and is particularly useful in explaining the functions of a CPU inside a computer. The Turing machine was described by Alan Turing in 1936, who called it an "(automatic)-machine". The Turing machine is not intended as a practical computing technology, but rather as a thought experiment representing a computing machine. Turing machines help computer scientists understand the limits of mechanical computation A Turing machine that is able to simulate any other Turing machine is called a universal Turing machine (UTM, or simply a universal 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 ChurchTuring thesis. The thesis states that Turing machines indeed capture the informal notion of effective method in logic and mathematics, and provide a precise definition of an algorithm or 'mechanical procedure'.
Informal description
Turing imagines not a mechanism, but a person whom he calls the "computer", who executes these deterministic mechanical rules slavishly (or as Turing puts it, "in a desultory manner"). The head is always over a particular square of the tape; only a finite stretch of squares is given. The instruction to be performed (q4) is shown over the scanned square. (Drawing after Kleene (1952) p.375.) Here, the internal state (q1) is shown inside the head, and the illustration describes the tape as being infinite and pre-filled with "0", the symbol serving as blank. The system's full state (its configuration) consists of the internal state, the contents of the shaded squares including the blank scanned by the head ("11B"), and the position of the head. (Drawing after Minsky (1967) p. 121). More precisely, a Turing machine consists of:
1. A tape which is divided into cells, one next to the other. Each cell
contains a symbol from some finite alphabet. The alphabet contains a special blank symbol (here written as 'B') and one or more other symbols. The tape is assumed to be arbitrarily extendable to the left and to the right, i.e., the Turing machine is always supplied with as much tape as it needs for its computation. Cells that have not been written to 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.
2. 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.
3. A finite table (occasionally called an action table or transition
function) of instructions (usually quintuples [5-tuples] : qiajqi1aj1dk, but sometimes 4-tuples) that, given the state(qi) the machine is currently in and the symbol(aj) it is reading on the tape (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 (instead of aj, write aj1), and then Move the head (which is described by dk and can have values: 'L' for one step left or 'R' for one step right or 'N' for staying in the same place), and then Assume the same or a new state as prescribed (go to state qi1).
In the 4-tuple models, erase or write a symbol (a j1) and move the head left or right (dk) are specified as separate instructions. Specifically, the table tells the machine to (ia) erase or write a symbol or (ib) move the head left or right, and then (ii) assume the same or a new state as prescribed, but not both actions (ia) and (ib) 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.
4. A state register that stores the state of the Turing machine, one of
finitely many. There is one special start state with which the state register is initialized. These states, writes Turing, replace the "state of mind" a person performing computations would ordinarily be in. Note that every part of the machineits state and symbol-collectionsand its actionsprinting, erasing and tape motionis finite, discrete and distinguishable; it is the potentially unlimited amount of tape that gives it an unbounded amount of storage space. Turing machine examples: 1. Turing's very first machine
"1. A machine can be constructed to compute the sequence 0 1 0 1 0 1..." (0 <blank> 1 <blank> 0...)
With regard to what actions the machine actually does, Turing (1936) states the following:
"This [example] table (and all succeeding tables of the same kind) is to be understood to mean that for a configuration described in the first two columns the operations in the third column are carried out successively, and the machine then goes over into the m-configuration in the final column." He makes this very clear when he reduces the above table to a single instruction called "b", but his instruction consists of 3 lines. Instruction "b" has three different symbol possibilities {None, 0, 1}. Each possibility is followed by a sequence of actions until we arrive at the rightmost column, where the final m-configuration is "b":
As observed by a number of commentators including Turing (1937) himself, (e.g., Post (1936), Post (1947), Kleene (1952), Wang (1954)) the Turing instructions are not atomic further simplifications of the model can be made without reducing its computational power. As stated in the article Turing machine, Turing proposed that his table be further atomized by allowing only a single print/erase followed by a single tape movement L/R/N. He gives us this example of the first little table converted:
Turing's statement still implies five atomic operations. At a given instruction (m-configuration) the machine: 1. observes the tape-symbol underneath the head 2. based on the observed symbol goes to the appropriate instructionsequence to use
3. prints symbol Sj or erases or does nothing
4. moves tape left, right or not at all 5. goes to the final m-configuration for that symbol Because a Turing machine's actions are not atomic, a simulation of the machine must atomize each 5-tuple into a sequence of simpler actions. One
possibility used in the following examples of "behaviors" of his machine is as follows: (qi) Test tape-symbol under head: If the symbol is S 0 go to qi.01, if symbol S1 go to qi.11, if symbol S2 go to qi.21, etc. (qi.01) print symbol Sj0 or erase or do nothing then go to qi.02 (qi.02) move tape left or right nor not at all then go to qm0 (qi.11) print symbol Sj1 or erase or do nothing then go to qi.12 (qi.12) move tape left or right nor not at all then go to qm1 (qi.21) print symbol Sj2 or erase or do nothing then go to qi.22 (qi.22) move tape left or right nor not at all then go to qm2 (etc all symbols must be accounted for) So-called "canonical" finite state machines do the symbol tests "in parallel"; see more at microprogramming. In the following example of what the machine do, we will note some peculiarities of Turing's models: "The convention of writing the figures only on alternate squares is very useful: I shall always make use of it." Thus when printing he skips every other square. The printed-on squares are called F-squares; the blank squares in between may be used for "markers" and are called "E-squares" as in "liable to erasure." The F-squares in turn are his "Figure squares" and will only bear the symbols 1 or 0 symbols he called "figures" (as in "binary numbers"). In this example the tape starts out "blank", and the "figures" are then printed on it. For brevity only the TABLE-states are shown here:
1. Copy routine This is a very important subroutine used in the "multiply" routine. The example Turing machine handles a string of 0s and 1s, with 0 represented by the blank symbol. Its task is to double any series of 1s encountered on the tape by writing a 0 between them. For example, when the head reads "111", it will write a 0, then "111". The output will be "1110111". In order to accomplish its task, this Turing machine will need only 5 states of operation, which are called {s1, s2, s3, s4, s5}. Each state does 4 actions: 1. Read the symbol under the head 2. Write the output symbol decided by the state 3. Move the tape to the left or to the right decided by the state 4. Switch to the following state decided by the current state
The behavior of this machine can be described as a loop: it starts out in s1, replaces the first 1 with a 0, then uses s 2 to move to the right, skipping over 1s and the first 0 encountered. s3 then skips over the next sequence of 1s (initially there are none) and replaces the first 0 it finds with a 1. s4 moves back to the left, skipping over 1s until it finds a 0 and switches to s5. s5 then moves to the left, skipping over 1s until it finds the 0 that was originally written by s1. It replaces that 0 with a 1, moves one position to the right and enters s1 again for another round of the loop. This continues until s1 finds a 0 (this is the 0 in the middle of the two strings of 1s) at which time the machine halts.
1. 3-state busy beaver
The following Turing table of instructions was derived from Peterson (1988), Peterson moves the head; in the following model the tape moves.
The "state" drawing of the 3-state busy beaver shows the internal sequences of events required to actually perform "the state". As noted above Turing (1937) makes it perfectly clear that this is the proper interpretation of the 5-tuples that describe the instruction (Undecidable, p. 119). For more about the atomization of Turing 5-tuples see Post-Turing machine:
The following table shows the "compressed" run just the Turing states:
Formal definition
Hopcroft and Ullman (1979) formally define a (one-tape) Turing machine as a 7-tuple
where
Q is a finite, non-empty set of states is a finite, non-empty set of the tape alphabet/symbols
is the blank symbol (the only symbol allowed to occur on the tape infinitely often at any step during the computation)
is the set of input symbols is the initial state is the set of final or accepting states. is a partial function called the transition function, where L is left shift, R is right shift. (A relatively uncommon variant allows "no shift", say N, as a third element of the latter set.)
Anything that operates according to these specifications is a Turing machine. The 7-tuple for the 3-state busy beaver looks like this (see more about this busy beaver at Turing machine examples):
Q = { A, B, C, HALT } = { 0, 1 } b = 0 = "blank" ={1} = see state-table below q0 = A = initial state F = the one element set of final states {HALT}
Usually large TABLES are better left as tables (Booth, p. 74). They are more readily simulated by computer in tabular form (Booth, p. 74). However, certain conceptse.g. machines with "reset" states and machines with repeating patterns (cf Hill and Peterson p. 244ff)can be more readily seen when viewed as a drawing. The reader should again be cautioned that such diagrams represent a snapshot of their TABLE frozen in time, not the course ("trajectory") of a computation through time and/or 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 3-state busy beaver's "state" (instruction) progress through its computation from start to finish. On the far right is the Turing "complete configuration" (Kleene "situation", HopcroftUllman "instantaneous description") 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 (cf Turing (1936).