Handout 5 Summary of This Handout: Multitape Machines — Multidimensional Machines — Universal Turing Machine — Turing Completeness — Church’S Thesis
Total Page:16
File Type:pdf, Size:1020Kb
06-05934 Models of Computation The University of Birmingham Spring Semester 2009 School of Computer Science Volker Sorge February 16, 2009 Handout 5 Summary of this handout: Multitape Machines — Multidimensional Machines — Universal Turing Machine — Turing Completeness — Church’s Thesis III.5 Extending Turing Machines In this handout we will study a few alterations to the basic Turing machine model, which make pro- gramming with Turing machines simpler. At the same time, we will show that these alterations are for convenience only; they add nothing to the expressive power of the model. 44. Extending the tape alphabet. One extension that we have already seen in the previous handout is the extension of the tape alphabet, such that it contains more auxiliary symbols than just the blank. For example, for every input symbol x it can contain an auxiliary symbol x′. By overwriting a symbol with the corresponding primed version, we are able to mark fields on the tape without destroying their contents. However, extended alphabets do not really add anything to the power of Turing machines. If we only have the basic alphabets Σ = {a, b} and T = {a, b, }, then we can simulate a larger alphabet by grouping tape cells together, and by coding symbols from the larger alphabet as strings from the smaller. For example, if we group three cells together, then we have 3∗3∗3 = 27 possibilities for coding symbols. Given a Turing machine transition table for the large alphabet we can easily design an equivalent table for the original alphabet. Whenever the first machine makes one move, the simulating machine makes at least three moves, scanning the three cells used for coding individual symbols and remembering their contents in the state. It will then probably need some more moves to execute the operation that the original machine wanted to do. All in all, the simulating machine will be slower than the original machine by some constant factor, but will be able to perform the same computation. 45. Multitape Turing machines. In the next variant we provide several tapes, each with its own read/write head. The transition table for a multitape machine is more complicated than that of a single tape machine because in each step a decision is taken on the basis of the current state of the control unit and the contents of all cells under the heads of each tape. The action performed consists of actions for each head individually, in particular, each head can move independently of the others; they do not have to all move in one direction. Even a single extra tape is quite useful, because we can use it as a kind of “scratch pad”. This will allow the machine to count steps: each time the head on the main tape moves, the head on the scratch pad tape marks down a symbol, e.g., x. Example: Let us build a two-tape Turing Machine M that consists of one input tape T1 and one output tape T2, which is intially empty. The machine’s task is to read an input string, duplicate each symbol in the string and write it as output. So, for example, if the input is abab the output should be aabbaabb. We define the input alphabet for M as Σ= {a, b} and the tape alphabet as T = {a, b, }. The transition function δ : Q × T × T → Q × T × T for M is then: δ (a, a) (b, b) (a, ) (b, ) ( , ) q0 = 0 (1, a, a) (1, b, b) (0, r, ) 1 (1, a, r) (1, b, r) (2, a, a) (2, b, b) 2 (2, r, r) (2, r, r) (1, a, a) (1, b, b) stop Observe that the above table only contains those transitions that can actually occur. In particular we have omitted all the input combinations that should never happen under the assumption that tape T2 is empty, that is, we save 4 columns. We could compress the table even further by exploiting the observation that columns for (a,a) and (b,b) as well as for (a, ) and (b, ) are similar. By defining α ∈ {a, b} we can 52 replace the a’s and b’s by α, thus compressing the table to three columns only. This is often quite helpful when dealing with machines consisting of several tapes and larger alphabets. Nevertheless multitape machines are not more powerful than single tape machines, as their computations can be simulated by single tape machines. We outline the construction for a two-tape machine. The idea is to interleave the contents of the two tapes on a single tape, as in the following picture: a a b a tape 1 read/write head 1 b b a tape 2 read/write head 2 control unit 112 2 112 2 112 2 11 2 2 1 H1 a abbH2 b a a In addition, before each data field we leave a blank, which can hold a marker to indicate the position of a head (I have written H for this, but it could be any symbol different from blank.). Whenever the two-tape machine makes one step, the simulating machine has to do many steps. This works as follows. At the beginning of a simulation, the single head of the simulating machine is at the left hand side of the current working region. It first scans across the whole working region to read the data that is currently scanned by the various heads. It can find out about this, because we have included markers to indicate the position of heads. This information (which is finite and of fixed size!) is stored in the state. The simulating machine will then make all changes that the multitape machine would do in its single step. To this purpose, the simulating machine will visit each head marker and either change the field to the right of it, or move the marker to an adjacent valid position (four fields away in the picture above). Note that the simulation of one single step of a multitape machine not only takes many steps on the single-tape machine but that these simulations take more and more time as the tape fills up with data. However, we are currently interested in computing power and not in computing speed. Example: Suppose we want to simulate the two tape machine M, from the previous example, on a single ′ tape Turing machine M using this construction. First we extend the tape alphabet by two symbols H1 and H2. We then have a look at how the tape will look like for the example input abab: Before the computation H1aH2 b a b and after the computation a a b a a b b bH1 a a b b H2 We design M ′ with a high-level diagram. Before doing so, however, we shall first define a couple component machines to search for and move the headers H1, H2 and thus ease the design of the overall machine. We assume that we have the machines r,l,R,L as defined in the previous handout. In addition we assume that for each symbol in the tape alphabet we have a machine that writes that symbol to the tape, i.e. we have machines a,b, ,H1,H2. Given these basic machines, we now define some larger machines as follows: H1 H1 RH1 : r −→ stop move right until H1 is found LH1 : l −→ stop move left until H1 is found H2 H2 RH2 : r −→ stop move right until H2 is found LH2 : l −→ stop move left until H2 is found 4r: rrrr −→ stop go four cells right 4l: llll −→ stop go four cells left 53 MRH1 : 4rH1 −→ stop Move head 1 marker one position (four cells) to the right MRH2 : 4rH2 −→ stop Move head 2 marker one position (four cells) to the right Finally we can put together the entire machine M ′. Its main idea is to first find the start of the input string (i.e., H1), then write the first character twice on the “second tape” marked with H2, thereby moving H2 twice, and finally return left to H1 and move it one position right. We continue with this until the input string is processed. a RH2 ralMRH2 ralMRH2 LH1 MRH1 r a b start RH1 r stop a b RH2 rblMRH2 rblMRH2 LH1 MRH1 r b 46. Multidimensional Tapes In this variant the machine has a multidimensional tape at its disposal, and in each step it can move the head in each direction. For example, on a two-dimensional storage medium, the head can move up, down, left and right. The following picture illustrates such a machine and its simulation. a a b a b b b b ∗aa ∗ ba ∗ bbbb ∗ This variant offers yet more than even a multitape machine because on a two-dimensional tape we can consider the rows as each constituting a tape by itself. What we then have is a machine which has an unbounded number of infinite tapes at its disposal. However, we again do not gain any computing power, only convenience. We indicate how a two- dimensional tape machine can be simulated by a machine with two one-dimensional tapes. This in turn can be simulated on a single tape, as we saw in the previous section. The simulation works as follows: At each stage in the computation, the two-dimensional machine will have filled only finitely many cells with non-blank symbols. We can draw an imaginary rectangle around this region, as in picture above. The rows of this rectangle can be placed on a one-dimensional tape, separated by some special auxiliary symbol (∗, say).