Proofs: Multitape simulation theorem
These are the human proofs of Multitape simulation theorem, at full length.
A one-tape machine simulates a k-tape machine in time t^2 + (2k+4)t
This proof shows: quadratic-simulation.
Statement. Let be a deterministic -tape machine with input alphabet that decides and halts within steps on every input of length , where . Then there is a deterministic one-tape machine that decides and halts on every input of length within steps. In particular halts within steps.
Setup. The machines are as on the multitape Turing machine page. Tape cells are numbered . A head on cell with the move stays. Let be the tape alphabet of , with blank . Fix an input of length . Let be the number of steps of on . We have because the start state is not halting. We have .
The alphabet of . The tape alphabet of is together with the tuples . Here , , and . The blank of is the tuple with all , all and . The input symbols of are those of . The alphabet is finite. The blank tuple also stands for blank cells of in later sweeps.
Meaning. Cell of the tape of is a column. It holds the content of cell of tape of for each . The flag means that head of is on cell . The bit is exactly in cell , so that can find the left end.
The state of . It holds a state of , a phase name, and a bounded buffer: the at most symbols read, and the at most pending flags described below. All of these come from finite sets.
Invariant . After simulated steps, is on cell , its state holds the state of after steps, and for every and : the component of cell is the content of cell of tape of , and in cell exactly when head is on cell .
Proof.
Step 1: start. Let . moves right from cell . In cell it reads and writes the tuple with , all other , all except that for all in cell , and in cell only. It does this in transitions and arrives at cell . There it reads the blank of (a tuple that is not a symbol of ) and moves left. It moves left once in each of cells , which is transitions, and arrives at cell . It finds the cell by when the next phase starts. If , writes in one transition, on cell , the tuple with all , all and , and stays. So the start takes at most transitions. Now holds, since all heads of are on cell .
Step 2: one simulated step. Assume with in a state that is not accept or reject. Let be the cell of head of and . Each head starts on cell and moves at most one cell in each step, so .
-
Right sweep. moves right from cell . In each cell it reads the tuple. For each with it stores as . It moves right in cells , which is transitions. It does not need to know . It knows that it is in cell when it has stored all symbols after reading that cell.
-
Decision. After reading cell , the control computes . If is accept or reject, halts in the same way, in the same transition. By , then gives the verdict of . Otherwise starts the left sweep in cell , in this same transition.
-
Left sweep. moves left from cell to cell . In each cell it reads the tuple and writes it again with these changes, for every with (a cell with for some is a cell where a head of stands). It sets . Then it changes the flag by .
- If , the flag stays .
- If and , the flag becomes , and the control remembers that the flag must be written in cell when gets there.
- If and , the flag stays , by the rule for cell .
- If , the flag becomes . The control remembers that cell needs . This is the detour below.
The changes apply to the flags that reads in cell . A pending flag is added after them, so it is not processed again in this sweep. A pending flag for cell is for a tape whose head was on cell . Cell holds no flag for this tape, since each tape has one head. So the new flag does not clash with an old one.
-
Detour. Let cell have heads with (at least one). The cell is written in the way above, and moves right instead of left. In cell it sets for all those , without other change, and moves left. In cell it moves left again, without change (it has already written the cell), and goes on with the left sweep. A detour takes 2 transitions beyond the ones counted in the sweep. In a step of at most heads move right, so there are at most cells with a detour, and the detours cost at most transitions.
-
Return. In cell the left sweep ends: reads , writes the cell, and the left-move rule keeps it on cell . Now holds. Every head of has moved by and every symbol is written.
The sweeps use right-moves, then transitions in the cells , so transitions, plus at most for the detours. So simulated step number takes at most transitions of .
Step 3: correctness. Base: holds by step 1. Step: assume (the induction hypothesis) and that has not halted after steps; step 2 gives . So holds for , and the simulation does not halt before the step in which halts. In the last step, step number , halts with the verdict of .
Step 4: time. The total number of transitions of is at most
$$ (2n + 2) + \sum_{s=0}^{t'-1} (2s + 1 + 2k) = 2n + 2 + t'(t'-1) + t' + 2k t' = t'^2 + 2k,t' + 2n + 2 . $$
Since and we have , and . So the total is at most . Since , this is at most .