CMPS 260: Turing Machines

The figures here are taken from An Introduction to Formal Languages and Automata, 6th edition, by Peter Linz.

In Example 9.10, Linz shows a TM that, given as input a string w ∈ {1}*, copies it, leaving ww on its tape.


Next is a TM that, given as input two positive integers represented in unary notation (i.e., as a sequence of 1's), "decides" whether the first one is greater than or equal to the second. That is, it answers the question "Is x≥y?" by terminating in a final state if the answer is YES and in a non-final state if the answer is NO. The two inputs are separated from each other by a zero.


Linz's next example (9.12) illustrates a TM that computes a function that has two cases. The machine must determine which case applies and then perform the actions appropriate to compute the result for that case.


Combining the logic used in the examples above for copying and for adding, one can design a TM that multiplies two numbers. Linz sketches that in Figure 9.10.

In the last section of Chapter 9, Linz discusses Turing's Thesis (also commonly called the Church-Turing Thesis, to include reference to Alonzo Church, another important figure in foundational computer science). Essentially, what the thesis says is

Any computation that can be "carried out by mechanical means" can be carried out by a Turing Machine.

It is not a provable statement because we have no precise definition of what constitutes "mechanical means". Linz suggests that, properly viewed, the Turing Thesis is really a definition of what constitutes a mechanical computation: any computation that can be performed by a TM.

Linz ponders whether this definition is sufficiently broad. Can a TM perform any computation that a real-life computer can? How about computers of the future? Linz says that it is not possible to arrive at a definitive answer, but he points to some strong arguments in favor of the thesis:

  1. Current digital computers have no more computational powers than do TMs (as a TM can be designed to simulate computations described by any computer's machine language).
  2. No one has described anything that has been accepted as being an "algorithm" that could not be implemented on a TM.
  3. Many alternative models of mechanical computation have been developed, and none of them is "more powerful" than the TM model. (One of these is Church's λ-calculus.)


In Chapter 10, Linz "challenges" Turing's Thesis by examining a number of ways that the standard TM model (of Chapter 9) can be enhanced, including by giving it more complex storage (e.g., multiple tapes, two-dimensional tape) and allowing nondeterminism. However, he finds that none of these enhancements increases the computational abilities of the standard model. This lends credibility to the thesis.

How does one compare the computational capabilities of one "model of computation" against another? A standard technique is simulation. As Linz describes on page 261, suppose that automaton M performs the computation

d0 ⊦ d1 ⊦ d2 ··· ⊦ dn ···

where each di is an instanteous description.

If automaton M' performs the computation

d'0* d'1* d'2 ··· ⊦* d'n ···

where each instantaneous description d'i of M' (algorithmically) maps to the instantaneous description di of M (so that from d'i we can determine di), then this computation of M' simulates that of M.

If M' can simulate every computation of M, then we say that M' can simulate M. If this is the case, then M' is capable of accepting any language, or computing any function, that M can. Which would mean that the class of automata of which M' is a member is "at least as powerful" as the class of automata of which M is a member.

This idea is not new to you, as the so-called Subset Algorithm by which an NFA is transformed into a DFA that accepts the same language produces a DFA that, in effect, simulates the original NFA. (If, after consuming a string x, the original NFA could have been in any of the states p1, p2, ..., pk, then the DFA would, after consuming x, be in the (single) state {p1, p2, ..., pk}.

To illustrate the idea of simulation, Linz considers a slightly-enhanced version of TMs in which there is a "stay option". In the standard TM model, each transition results in the TM's read/write head moving either one position to the left or to the right. What if a third option —stay in place— were available. Does that provide the model with any extra computational power? The answer is NO, proven by a simulation argument: Linz shows how one can take a TM M that makes use of the Stay-Option and, by adding some states and altering the transition function of M, produce a standard TM M' that simulates M. Thus, every computation doable by M is, in effect, doable by M'.

Another minor enhancement to the TM model is to allow its tape to have multiple (say two) tracks, which would mean, in effect, that each tape square contained a sequence of two symbols rather than a single symbol. But a TM having a two-track tape could be simulated by a standard TM that treats each pair of adjacent tape squares as a single unit. You can generalize from two tracks to any number k>1.

More generally, this enhancement can be understood as being nothing more than enlarging the alphabet (to a larger finite number of distinct symbols). But the symbols in any finite-sized alphabet can be encoded using a binary alphabet. Hence, one can devise a standard TM having a binary alphbet that simulates a multi-track-tape TM.

Linz goes on to illustrate how the multi-track tape idea can be used to show, by a simlation argument, that restricting a TM's tape to be semi-infinite (i.e., bounded on the left, say) would not restrict its computational capabilities.

The idea is that a TM M having a tape unbounded on both ends can be simulated by a TM M' whose tape is bounded on the left. M' does this by using a two-track tape. (This is justified by the fact, just discussed, that a TM with a multi-track tape can be simulated by a standard TM.) One track of M' stores the contents of the "right" part (of the unbounded tape of M) and the other track of M' stores the "left" part. (The right part begins, say, at the tape square where the read/write head was initially, as that is usually assumed to be where the input string begins.)

Linz goes on to show how an Off-Line TM can be simulated by a standard one (and vice-versa). Such a TM has a separate read-only input tape. This is really a simplified example of a multi-tape TM, which Linz gets to in Section 10.2.


Next Linz introduces the concept of a multi-tape TM:

He then sketches how a multi-tape TM M can be simulated by a standard TM M'. Once again the trick is for the standard TM to use a multi-track tape. It uses two tracks for each of the simulated TM's tapes, one to store the tape's contents and one to store a "mark" that indicates the position of the tape's read/write head. Each transition of M is simulated by M' having to traverse its tape to gather information about the symbols being scanned by the read/write heads of the tapes of M. Afterwards, it simulates the transition of M by again traversing its tape and making the appropriate changes within the tracks of its tape.


The last enhancement to a TM's storage unit that Linz considers is one that is multi-dimensional. For example, a "two-dimensional tape" would be one having rows and columns. He argues that such a machine can be simulated by a standard TM.


In Section 10.3, Linz considers nondeterminism. We saw that, in the realm of finite automata, nondeterminism did not add any computational power, in the sense that the languages accepted by NFA's are precisely the same as those accepted by DFA's. However, nondeterministic PDA's coincide with the class of context-free languages (CFL's), while deterministic PDA's coincide with the smaller class of deterministic CFL's. (That is, DCFL ⊆ CFL, but not the other way around.)

How about in the realm of TM's? Linz sketches how a standard (deterministic) TM can simulate a nondeterministic one. Basically, it performs a breadth-first search on the tree of all possible computations of the NTM. That is, the tape of the DTM would contain a description of each possible configuration that the NTM could be in (at some moment in time), and it would then update each of those configurations in accord with their possible successors.

Section 10.4 discusses the concept of a Universal Turing Machine, i.e., one that, given as input the description of any TM M and an input string w, simulates the computation of M upon w. Thus, a universal TM does, in effect, what your laptop computer does: You feed to it a Java program (which is analogous to a description of a TM) and input data, and your laptop computer executes/simulates that Java program, applied to that input. Linz's Figure 10.16 indicates that a convenient way to design a universal TM is to give it three tapes, one to store the TM M that it is simulating, one to store the contents of M's tape (together with an indication of which square the read/write head is visiting), and the third to store an encoding of M's current state. To simulate a single step of M, the universal TM has to find, within the description of M (on its 1st tape) that portion of it that describes the transition that M would take on its next move. Even doing that requires a lot of work, because it involves matching the description of M's current state (on the 3rd tape) and M's currently scanned symbol (on second tape) with the data describing M's transition function (on 1st tape).