Algorithm Search⌘K

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 MM be a deterministic kk-tape machine with input alphabet Σ\Sigma that decides L⊆Σ∗L \subseteq \Sigma^* and halts within t(n)t(n) steps on every input of length nn, where t(n)≥max⁡(n,1)t(n) \ge \max(n, 1). Then there is a deterministic one-tape machine SS that decides LL and halts on every input of length nn within t(n)2+(2k+4) t(n)t(n)^2 + (2k+4)\,t(n) steps. In particular SS halts within (2k+5) t(n)2(2k+5)\,t(n)^2 steps.

Setup. The machines are as on the multitape Turing machine page. Tape cells are numbered 0,1,…0, 1, \ldots. A head on cell 00 with the move LL stays. Let Γ\Gamma be the tape alphabet of MM, with blank ⊔\sqcup. Fix an input ww of length nn. Let t′≥1t' \ge 1 be the number of steps of MM on ww. We have t′≥1t' \ge 1 because the start state is not halting. We have t′≤t(n)t' \le t(n).

The alphabet of SS. The tape alphabet of SS is Σ\Sigma together with the tuples (c1,…,ck,f1,…,fk,e)(c_1, \ldots, c_k, f_1, \ldots, f_k, e). Here ci∈Γc_i \in \Gamma, fi∈{0,H}f_i \in \{0, H\}, and e∈{0,1}e \in \{0, 1\}. The blank of SS is the tuple with all ci=⊔c_i = \sqcup, all fi=0f_i = 0 and e=0e = 0. The input symbols of SS are those of Σ\Sigma. The alphabet is finite. The blank tuple also stands for blank cells of MM in later sweeps.

Meaning. Cell jj of the tape of SS is a column. It holds the content cic_i of cell jj of tape ii of MM for each ii. The flag fi=Hf_i = H means that head ii of MM is on cell jj. The bit ee is 11 exactly in cell 00, so that SS can find the left end.

The state of SS. It holds a state of MM, a phase name, and a bounded buffer: the at most kk symbols aia_i read, and the at most kk pending flags described below. All of these come from finite sets.

Invariant IsI_s. After ss simulated steps, SS is on cell 00, its state holds the state of MM after ss steps, and for every ii and jj: the component cic_i of cell jj is the content of cell jj of tape ii of MM, and fi=Hf_i = H in cell jj exactly when head ii is on cell jj.

Proof.

Step 1: start. Let n≥1n \ge 1. SS moves right from cell 00. In cell j<nj < n it reads wj+1w_{j+1} and writes the tuple with c1=wj+1c_1 = w_{j+1}, all other ci=⊔c_i = \sqcup, all fi=0f_i = 0 except that fi=Hf_i = H for all ii in cell 00, and e=1e = 1 in cell 00 only. It does this in nn transitions and arrives at cell nn. There it reads the blank of SS (a tuple that is not a symbol of Σ\Sigma) and moves left. It moves left once in each of cells n,n−1,…,1n, n-1, \ldots, 1, which is nn transitions, and arrives at cell 00. It finds the cell by e=1e = 1 when the next phase starts. If n=0n = 0, SS writes in one transition, on cell 00, the tuple with all ci=⊔c_i = \sqcup, all fi=Hf_i = H and e=1e = 1, and stays. So the start takes at most 2n+22n + 2 transitions. Now I0I_0 holds, since all heads of MM are on cell 00.

Step 2: one simulated step. Assume IsI_s with MM in a state qq that is not accept or reject. Let pip_i be the cell of head ii of MM and P=max⁡ipiP = \max_i p_i. Each head starts on cell 00 and moves at most one cell in each step, so P≤sP \le s.

  • Right sweep. SS moves right from cell 00. In each cell it reads the tuple. For each ii with fi=Hf_i = H it stores cic_i as aia_i. It moves right in cells 0,…,P−10, \ldots, P - 1, which is PP transitions. It does not need to know PP. It knows that it is in cell PP when it has stored all kk symbols a1,…,aka_1, \ldots, a_k after reading that cell.

  • Decision. After reading cell PP, the control computes δ(q,a1,…,ak)=(q′,b1,…,bk,D1,…,Dk)\delta(q, a_1, \ldots, a_k) = (q', b_1, \ldots, b_k, D_1, \ldots, D_k). If q′q' is accept or reject, SS halts in the same way, in the same transition. By IsI_s, SS then gives the verdict of MM. Otherwise SS starts the left sweep in cell PP, in this same transition.

  • Left sweep. SS moves left from cell PP to cell 00. In each cell jj it reads the tuple and writes it again with these changes, for every ii with fi=Hf_i = H (a cell with fi=Hf_i = H for some ii is a cell where a head of MM stands). It sets ci=bic_i = b_i. Then it changes the flag by DiD_i.

    • If Di=SD_i = S, the flag stays HH.
    • If Di=LD_i = L and e=0e = 0, the flag becomes 00, and the control remembers that the flag fi=Hf_i = H must be written in cell j−1j - 1 when SS gets there.
    • If Di=LD_i = L and e=1e = 1, the flag stays HH, by the rule for cell 00.
    • If Di=RD_i = R, the flag becomes 00. The control remembers that cell j+1j + 1 needs fi=Hf_i = H. This is the detour below.

    The changes apply to the flags that SS reads in cell jj. A pending flag is added after them, so it is not processed again in this sweep. A pending flag for cell j−1j - 1 is for a tape ii whose head was on cell jj. Cell j−1j - 1 holds no flag fi=Hf_i = H for this tape, since each tape has one head. So the new flag does not clash with an old one.

  • Detour. Let cell jj have heads with Di=RD_i = R (at least one). The cell jj is written in the way above, and SS moves right instead of left. In cell j+1j + 1 it sets fi=Hf_i = H for all those ii, without other change, and moves left. In cell jj 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 MM at most kk heads move right, so there are at most kk cells with a detour, and the detours cost at most 2k2k transitions.

  • Return. In cell 00 the left sweep ends: SS reads e=1e = 1, writes the cell, and the left-move rule keeps it on cell 00. Now Is+1I_{s+1} holds. Every head of MM has moved by DiD_i and every symbol is written.

The sweeps use PP right-moves, then P+1P + 1 transitions in the cells P,…,0P, \ldots, 0, so 2P+12P + 1 transitions, plus at most 2k2k for the detours. So simulated step number s+1s + 1 takes at most 2s+1+2k2s + 1 + 2k transitions of SS.

Step 3: correctness. Base: I0I_0 holds by step 1. Step: assume IsI_s (the induction hypothesis) and that MM has not halted after ss steps; step 2 gives Is+1I_{s+1}. So IsI_s holds for s=0,1,…,t′−1s = 0, 1, \ldots, t' - 1, and the simulation does not halt before the step in which MM halts. In the last step, step number t′t', SS halts with the verdict of MM.

Step 4: time. The total number of transitions of SS 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 n≤t(n)n \le t(n) and 1≤t(n)1 \le t(n) we have 2n+2≤4t(n)2n + 2 \le 4 t(n), and t′≤t(n)t' \le t(n). So the total is at most t(n)2+(2k+4) t(n)t(n)^2 + (2k + 4)\, t(n). Since t(n)≥1t(n) \ge 1, this is at most (2k+5) t(n)2(2k + 5)\, t(n)^2. ■\blacksquare

Back to Multitape simulation theorem