Algorithm Search⌘K

Proofs: Linear speedup theorem

These are the human proofs of Linear speedup theorem, at full length.

Compressing m symbols into one cell speeds up a multitape machine by the factor m

This proof shows: linear-speedup.

Statement. Let k≥2k \ge 2 and let MM be a deterministic kk-tape machine (as on the multitape Turing machine page) that halts on every input and decides LL. Let n0≥0n_0 \ge 0 and m≥1m \ge 1 be integers, and let tt be a function with t(n)≥nt(n) \ge n such that on every input of length n≥n0n \ge n_0 the machine MM halts within t(n)t(n) steps. Then there is a deterministic kk-tape machine M′M' with L(M′)=LL(M') = L such that on every input of length nn the machine M′M' halts within

$$ T'(n) \le n + 1 \quad \text{if } n < n_0, \qquad T'(n) \le n + \lceil n/m \rceil + 6\lceil t(n)/m \rceil - 1 \quad \text{if } n \ge n_0 . $$

For every ε>0\varepsilon > 0, the choice m=⌈14/ε⌉m = \lceil 14/\varepsilon \rceil and n0=⌈8/ε⌉n_0 = \lceil 8/\varepsilon \rceil (and n0≥n_0 \ge the bound from which tt holds) gives T′(n)≤ε t(n)+n+2T'(n) \le \varepsilon\, t(n) + n + 2 for all nn.

Setup. The tapes of MM and M′M' are infinite to the right, with cells numbered 0,1,…0, 1, \ldots. A head on cell 00 that moves LL stays. The input w=w1⋯wnw = w_1 \cdots w_n is in cells 00 to n−1n-1 of tape 1. Let Γ\Gamma be the tape alphabet of MM, with blank ⊔\sqcup. Write q0q_0 for its start state. Let t′≥1t' \ge 1 be the running time of MM on ww. The value t′≥1t' \ge 1 holds because the start state is not a halting state. For n≥n0n \ge n_0 we have t′≤t(n)t' \le t(n).

The tape alphabet of M′M' is Γ∪(Γm×{0,1})\Gamma \cup (\Gamma^m \times \{0, 1\}). A block is an element (a0,…,am−1;e)(a_0, \ldots, a_{m-1}; e) of Γm×{0,1}\Gamma^m \times \{0,1\}. The bit ee is the end flag. A cell of M′M' that holds ⊔\sqcup is read as the block (⊔,…,⊔;0)(\sqcup, \ldots, \sqcup; 0).

The roles of the tapes. Tape 11 of MM is kept on tape 22 of M′M'. Tape 22 of MM is kept on tape 11 of M′M'. Tape ii of MM is kept on tape ii of M′M' for i≥3i \ge 3. This swap is the place where k≥2k \ge 2 is used: tape 11 of M′M' holds the input at the start, and it is free for use after the input is copied. Let τ(i)\tau(i) be the tape of M′M' that keeps tape ii of MM. Let o2=no_2 = n and oi=0o_i = 0 for i≠2i \ne 2. For b≥0b \ge 0, block bb of tape ii of MM is the cell oi+bo_i + b of tape τ(i)\tau(i) of M′M'. It holds the cells bm,bm+1,…,bm+m−1bm, bm+1, \ldots, bm+m-1 of tape ii of MM, in this order. Only block 00 has the end flag e=1e = 1.

The finite control. The state of M′M' holds a state qq of MM, an offset pi∈{0,…,m−1}p_i \in \{0, \ldots, m-1\} for each tape ii, and a bounded buffer: at most mm symbols during the copy, at most n0−1n_0 - 1 symbols of the input, and three blocks for each tape during a simulation round. All of these come from finite sets, so M′M' has finitely many states.

Proof.

Step 1: copy the input. Let c=⌈n/m⌉c = \lceil n/m \rceil.

  • Transition ii, for 1≤i≤n1 \le i \le n: head 11 reads wiw_i in cell i−1i - 1, writes ⊔\sqcup and moves right. The control keeps wiw_i in its buffer. If mm divides ii, head 22 writes the block (wi−m+1,…,wi; e)(w_{i-m+1}, \ldots, w_i;\ e) in its cell and moves right, with e=1e = 1 if i=mi = m and e=0e = 0 otherwise. Otherwise head 22 stays. In transition 11, heads 3,…,k3, \ldots, k write the block (⊔,…,⊔;1)(\sqcup, \ldots, \sqcup; 1) and stay.
  • Transition n+1n + 1: head 11 reads the blank in cell nn. If n<n0n < n_0, the control holds the whole input, because it keeps the first n0−1n_0 - 1 symbols. Then M′M' halts at once with the verdict of MM on ww. This verdict exists because MM halts on every input. So T′(n)=n+1T'(n) = n + 1 and the first claim holds. If n≥n0n \ge n_0, head 11 writes the block (⊔,…,⊔;1)(\sqcup, \ldots, \sqcup; 1) on its cell nn and stays. This is block 00 of tape 22 of MM. If n=0n = 0, transition 11 is this transition, and head 22 writes (⊔,…,⊔;1)(\sqcup, \ldots, \sqcup; 1) on cell 00 and stays, and heads 3,…,k3, \ldots, k do what transition 1 says. If n≥1n \ge 1 and m∤nm \nmid n, head 22 writes the last block, padded with ⊔\sqcup, with e=1e = 1 if n<mn < m, and stays on cell c−1c - 1. If n≥1n \ge 1 and m∣nm \mid n, head 22 moves left to cell c−1c - 1.
  • Transitions n+2,…,n+cn + 2, \ldots, n + c: head 22 moves left. It moves left in each cell where it reads e=0e = 0. It reads e=1e = 1 in cell 00 after c−1c - 1 moves. At that reading, the machine does not spend a separate transition. The reading is transition 1 of the read phase of round 1: it moves head 2 as that transition says (move SS), and the other heads, which are already on block 00, read their blocks in the same transition.

Now every head of M′M' is on block 00 of the tape that it keeps. The tapes hold the blocks of the initial configuration of MM: the blocks of tape 11 hold ww followed by blanks, and all other blocks are blank. The copy takes n+cn + c transitions if n≥1n \ge 1, and 11 transition if n=0n = 0.

Step 2: the invariant. A round simulates mm steps of MM. Let r≥0r \ge 0. We call the following statement IrI_r, for a round number rr with rm<t′rm < t'. After the copy and rr rounds, the control holds the state qq of MM after rmrm steps and the offsets pi=xi mod mp_i = x_i \bmod m, where xix_i is the position of head ii of MM after rmrm steps. Head τ(i)\tau(i) of M′M' is on block ⌊xi/m⌋\lfloor x_i / m \rfloor of its tape. Block bb of each tape holds the cells bm,…,bm+m−1bm, \ldots, bm + m - 1 of the corresponding tape of MM after rmrm steps. Statement I0I_0 holds at the end of step 1, since the head positions of MM are 00 at the start.

Step 3: a round, assuming IrI_r and rm<t′rm < t'. Let bi=⌊xi/m⌋b_i = \lfloor x_i / m \rfloor be the block of head ii.

  • Read (4 transitions). In parallel for each tape ii: the head of τ(i)\tau(i) makes the moves L,R,R,LL, R, R, L if the block bib_i has e=0e = 0, and the moves S,S,R,LS, S, R, L if it has e=1e = 1. After the four transitions the head is on block bib_i again, and the control has read the blocks bi−1b_i - 1 (if e=0e = 0), bib_i and bi+1b_i + 1 of each tape.
  • Decide (no transition). The control runs MM for up to mm steps from its state, in its memory, on the three blocks of each tape. This is possible because, in at most mm steps, head ii stays inside these three blocks. It starts at offset pip_i in block bib_i, and in j≤mj \le m steps it moves at most jj cells, so it stays in the cells bim−mb_i m - m to bim+2m−1b_i m + 2m - 1. If bi=0b_i = 0, the left block does not exist, and the head cannot move there, because the left-end rule keeps it on cell 00. The control knows when the head of MM is on cell 00: this holds exactly when e=1e = 1 and the offset is 00. Also, head ii cannot visit both the left block and the right block. To visit a cell of the left block (a cell with number below bimb_i m) and a cell of the right block (number at least bim+mb_i m + m), the head moves at least m+1m + 1 cells between the two visits, and it has only mm steps. So for each ii there is at most one neighbor block YiY_i that the head visits.
  • Halting. If MM halts within these mm steps, then M′M' halts at once, in transition 44 of the round, with the same verdict.
  • Write (2 transitions). Otherwise MM makes exactly mm steps and is not halted. Let q′q' be its new state and xi′x_i' the new position of head ii. The final block Fi=⌊xi′/m⌋F_i = \lfloor x_i' / m \rfloor is bib_i or the block YiY_i. In transition 55 the head of τ(i)\tau(i) writes the new content of block bib_i (with its old end flag) and moves toward YiY_i, or stays if YiY_i does not exist. In transition 66 it writes the new content of YiY_i, with its old end flag, and moves to FiF_i: it stays if Fi=YiF_i = Y_i, and it moves back to block bib_i if Fi=biF_i = b_i. If YiY_i does not exist, it does nothing in transition 66. The control now holds q′q' and the offsets xi′ mod mx_i' \bmod m.

The blocks other than bib_i and YiY_i do not change, because no head of MM visits them. So Ir+1I_{r+1} holds. Notice that the round uses 66 transitions if MM does not halt, and 44 transitions if it halts.

Step 4: correctness. By induction on rr using step 3, IrI_r holds for every round rr with rm<t′rm < t', and M′M' does not halt before round h=⌈t′/m⌉h = \lceil t'/m \rceil. In round hh the machine MM halts within the mm simulated steps, because (h−1)m<t′≤hm(h-1)m < t' \le hm. Then M′M' halts with the verdict of MM. So M′M' accepts ww exactly when MM accepts ww, for n≥n0n \ge n_0 by this argument and for n<n0n < n_0 by step 1.

Step 5: time. Let n≥n0n \ge n_0. Step 1 takes at most n+⌈n/m⌉n + \lceil n/m \rceil transitions if n≥1n \ge 1 and 11 transition if n=0n = 0. Rounds 1,…,h−11, \ldots, h - 1 take 66 transitions each, and round hh takes 44. So the total is at most

$$ (n + \lceil n/m \rceil) + 6(h - 1) + 4 = n + \lceil n/m \rceil + 6h - 2 \quad (n \ge 1), \qquad 1 + 6(h-1) + 4 = 6h - 1 \quad (n = 0). $$

In both cases it is at most n+⌈n/m⌉+6⌈t(n)/m⌉−1n + \lceil n/m \rceil + 6\lceil t(n)/m \rceil - 1, because h=⌈t′/m⌉≤⌈t(n)/m⌉h = \lceil t'/m \rceil \le \lceil t(n)/m \rceil. For n<n0n < n_0 the time is n+1n + 1 by step 1.

Step 6: the choice of mm and n0n_0. Let ε>0\varepsilon > 0, m=⌈14/ε⌉m = \lceil 14/\varepsilon \rceil and n0=⌈8/ε⌉n_0 = \lceil 8/\varepsilon \rceil (or larger, to meet the hypothesis on tt). If n<n0n < n_0, then T′(n)≤n+1≤ε t(n)+n+2T'(n) \le n + 1 \le \varepsilon\, t(n) + n + 2. Let n≥n0n \ge n_0. Use ⌈x⌉≤x+1\lceil x \rceil \le x + 1 and n≤t(n)n \le t(n):

$$ T'(n) \le n + \frac{n}{m} + 1 + \frac{6,t(n)}{m} + 6 - 1 \le n + 6 + \frac{7,t(n)}{m} \le n + 6 + \frac{\varepsilon, t(n)}{2}, $$

because m≥14/εm \ge 14/\varepsilon. Since t(n)≥n≥n0≥8/εt(n) \ge n \ge n_0 \ge 8/\varepsilon, we have ε t(n)/2≥4\varepsilon\,t(n)/2 \ge 4, so 6≤2+ε t(n)/26 \le 2 + \varepsilon\, t(n)/2. Hence T′(n)≤n+2+ε t(n)T'(n) \le n + 2 + \varepsilon\, t(n). ■\blacksquare

Back to Linear speedup theorem