

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


We will show how a k-head Turing machine (LRTM) can simulate a k-tape TM for T steps in O(n + T ) time. The idea is to use have each consecutive group of k tape cells simulate one cell per tape. However, there are some complications. If we use cell ki + j for i ≥ 0 , 1 ≤ j ≤ k to simulate the i’th cell of tape j, to initialize this, we would need to copy the input to be on cells 1, k + 1, ..kn + 1. Since each of n symbols would need to be copied over Ω(n) cells away on average, this would take O(n^2 ) time. So we will only use the alternation after the first n symbols on the first tape. We first go to the end of the input and write a new marker symbol in place n + 1. Then we will use position n + 1 + ki + j to store the i’th symbol of tape j for 2 ≤ j ≤ k. For tape 1, we will use cell n + 1 + ki + 1 to store the n + i’th cell of the 1st tape. Now we initialize the tape heads simulating tapes 2 ≤ j ≤ k to be j spaces past the marker. In the new state, we will also keep track of whether the 1st tape head is to the left or right of the marker. We initialize the 1st tape head at the beginning of the input. This initialization takes O(n) time, since we need to move k − 1 tape heads a constant number of positions past the marker, at position n. To simulate a write, accept or reject action, we simply perform the same action. To simulate a left move on any of the tapes 2 ≤ j ≤ k, we move k stpes to the left. To simulate a right move on one of those tapes, we move k positions to the right unless we pass the marker, in which case we return to our starting position (we tried to move before the start of the tape). For the 1st tape, we either move 1 cell to the left or right if we are currently to the left of the marker, or k if we are to the right. If we pass the marker, we go only one more step in the same direction. Thus, initialization takes O(n) time, and each subsequent simulation of a step takes O(1) time. So the total time for the simulation is O(n + T ), which means that if T (n) ≥ n, what is decidable in O(T (n)) time on a k-tape TM is decidable in O(T (n)) time on a k-head one-tape TM.
To decide the language on a one-tape TM, we can do standard binary addition using a three-tape TM by copying x to the second tape and y to third tape, and then verifying the answer z on the first tape. This takes linear time. As shown in class, any multi-tape TM can be emulated in O(n^2 ) time by a one-tape machine. To prove the lower bound, we will use the Ω(n^2 ) lower bound proven in class for the language LEQ = {x#x | x ∈ Σ∗}
To show that L takes Ω(n^2 ) time on a one-tape TM, we will show how a Turing machine that decides L can be used to decide LEQ. On input x#y, our machine will prepend the string “0+” to the beginning of the input (the input will need to be shifted right two cells, which can be done in linear time). It then replaces
contains “0+”), and starts the machine to decide L. Note that the time taken by our machine is O(n) for pre-processing plus the time taken to decide L, say t. From our lower bound, we know that altogether our machine must take Ω(n^2 ), so t ∈ Ω(n^2 ).
Let L ∈ P. We need to show how to decide membership in L∗^ in polynomial time. We’ll use dynamic programming and create an array of bits B[1..n] where we want tos et B[I] = 1 iff x 1 ...xi ∈ L∗. (We present the algorithm in a high-level way, but we can simulate this on the RAM model by just using n consecutive memory locations, or in the Turing Machine model by using a new tape to store B. ) Assume we have computed B[1..I] and want to compute B[I + 1]. x 1 ..xI+1 ∈ L∗^ if and only if we can write it as w 1 ◦ w 2 ◦ ...wk where each wi in L. Then this is the same as writing x 1 ..xI+1 as v ◦ wk where v = w 1 ◦ w 2 ◦ ...wk− 1 ∈ L∗^ and wk ∈ L. v, wk will have to be of the form x 1 ..xJ and xJ+1...xI+1 for some 1 ≤ J ≤ I, and by the induction hypotheis, v ∈ L∗ is equivalent to B[J] = 1. So for each 1 ≤ J ≤ I where B[J] = 1, we check whether XJ+1...xI+1 ∈ L (e..g, by copying it over onto a fresh tape and using a TM for L). If so, we mark B[I + 1] = 1; if we get past J = I without finding a match, we mark B[I + 1] = 0. We return B[n]. This algorithm makes at most n calls to a procedure to decide L in each step, and is otherwise linear time in that step. So the total time is at most O(n(n + T (n)) where T (n) is the time to decide membership in L on inputs of size at most n. Since L ∈ P , T (n) can be polynomially bounded, and so the whole procedure is polynomial time.