Computational Complexity Theory, Fall 2010 August 27 Lecture 2: Tape reduction and Time Hierarchy Lecturer: Peter Bro Miltersen Scribe: Andreas Hummelshøj Jakobsen Tape reduction Theorem 1 (k-tapes 2-tape reduction). Suppose L is computed by a k-tape T (n) time-bounded turing machine M. Then L is computed by a 2-tape O(T (n) log(t (n)) time-bounded turing machine M. Proof. (sketch) Tape 1 is a two-way infinite tape with 3 tracks for each of the k-tapes. The tape cells are divided into blocks of cells..., B 2, B 1, B 0, B 1, B 2...,, of sizes B i = B i = 2 i 1 cells, see figure 1 (NOTE: The picture shows only the layout, had we used only 2 tracks for each tape). 2-tracks b -3 b -2 b -1 b 0 b 1 b 2 b 3-5 -3-1 -6-4 -2 0 1 2 3 4 5 6 Figure 1: The numbers on the block parts indicates how the simulated tape is placed on the 3 tracks, only full parts is an actual part of the tape, the orginal tape is placed {..., 6, 5, 4 3, 2, 1, 0, 1, 2, 3, 4, 5, 6,... }, parts numbered < 0 is to the left of the current position of the tape head, and parts > 0 is to the right of the current position of the tape head. Tape 2 is a scratch tape. The intuition behind the reduction is: move data not tape heads scratch b 0 holds the storage symbols scanned by each of the tape heads. When simulating a move data is then transported in the opposite direction of the move for the tracks of the tape head being moved. Invariant In each block, each track is either full (i.e. contains content of original tapes) or completely empty (i.e. contains a special symbol indicating this). b 0 contains one cell of the original tape; that at the position of the head of the orignal tape. Definition 2. A block is clean if either 1 or 2 tracks (of the 3 tracks) are full. Procedure: step(k) Simulates 2 k steps of the original machine M. Precondition: Blocks b (k+1) through b k+1 are all clean. Postconditions: Only blocks b (k+1) through b k+1 are touched; of these b k through b k are left clean. And the number of full/empty tracks in b (k+1) and b k+1 change by at most 1. 1
If k = 0, do a single step of M and shift tape by 1, using b 1 and b 1. Otherwise: step(k 1) clean(k) step(k 1) clean(k), where clean is defined below. Procedure: clean(k) Ensures that block b ±k are clean. Scan to block b k. If 0 tracks are filled, take the innermost filled track of block b k+1 (Note: such a filled track exists!), split it in two and move the halves to b k If 3 are filled, merge the two outermost tracks of b k and move them to b k+1 (Note: there is an empty track available for this!). Repeat for b k Time complexity The times for step and clean are: ( k ) Time clean (k) = O 2 i i=0 = O (2 k) Time step (k) = 2 Time step (k 1) + O(2 k ) = O(2 k k) If k = log T (n) we then have that Time step (k) = O(T (n) log(t (n))). Problem: We don t know the correct k to use for the initial call (We don t assume that we can compute T (n)). Solution: Try for all k in sequence, k = 1, k = 1, etc. until the simulation is successful. This only adds a constant factor overhead in the time complexity. 2
Time complexity classes Definition 3. DTIME ( T (n) ) = { Class of languages computed by a multitape O(T (n)) timebounded turing machine }. PTIME := k>0 DTIME(n k ) EXP := k>0 DTIME(2 nk ) Universal Turing Machine Recall the existence of efficient an universal Turing machine M k : Takes a description of a Turing Machine M (and input) as input. Simulates a run of M. U k is defined as: has k + 1 tapes put encoding of M, a k-tape turing machine on tape k + 1 then U k can simulate M on input x with a constant overhead. If M is T (n) time-bounded then U k runs for O(T (n)) steps where the constant only depends on M. Time-constructible Definition 4. T (n) is time-constructible iff there is a Turing machine that on input 1 n halts with 1 T (n) on a given tape in time O(T (n)). Time Hierachy Theorem Theorem 5. Let T 2 (n) be time-constructable, and assume T 1 (n) fulfills T 1 (n) log(t 1 (n)) = o(t 2 (n)) and T 1 (n), T 2 (n) n. Then DTIME(T 1 (n)) DTIME(T 2 (n)), meaning at least one thing that can be computed in DT IME(T 2 (n)) cannot be computed in DT IME(T 1 (n)). Proof. We want to prove that the time class DT IME(T 2 (n)) is strictly larger than the time class DT IME(T 1 (n)). We do this by constructing a machine M which cannot be in DT IME(T 1 (n)), by diagonalization, and we then show that M is in DT IME(T 2 (n)). Contruction of M For a input x, where x = n, we use the time-constructibility to put a clock 1 T 2(n) on a spare tape, and then we run the remaining parts below for at most T 2 (n) steps. We can write x on the form x = 0 i 1w, for i N, now M does: test if w is an encoding of a 2-tape turing machine M, if not reject. simulate M on input x, using U 2. 3
if M halts then accept iff M rejects (diagonalization). if time runs out, then reject. Analysis Clearly M is O(T 2 (n)) time-bounded. Assume L(M) is computed by a T 1 (n) time-bounded turing machine. By 2-tape reduction we get a 2-tape TM M, which is O(T 1 (n) log(t 1 (n))) time bounded, that computes L(M). Look at the simulation of M with input x = 0 i 1w, on M. Since T 1 (n) log(t 1 (n)) = o(t 2 (n)) the simulation of M will succeed for all sufficiently large i. For these inputs the machines M and M disagree, and hence M cannot compute the language L(M). From this theorem we now directly get P = k>0 DT IME(n k ) DT IME(2 n ) DT IME(2 n2 ) EXP. because n2 n = o(2 n2 ). Nondeterministic Turing Machines Definition 6. Nondeterministic TM. Exactly like a [deterministic] TM, execpt replace δ with Definition 7. Language of a nondet. TM. δ : Q Γ k 2 (Q Γk {L,R} k ) A nondeterministic TM accepts an input x if at least one possible computation accepts x. Definition 8. Time Complexity of nodet. TM. Time complexity of M on x is still worst-case, so we use the longest computation path possible on x. Definition 9. NTIME ( T (n) ) = { Class of languages computed by a multitape O(T (n)) timebounded non-deterministic turing machine }. NP := k>0 NTIME(n k ) NEXP := k>0 NTIME(2 nk ) Tape reduction, non-deterministic Theorem 10 ((non-det) k-tapes 2-tape reduction). Suppose L is accepted by a k-tape T (n) time-bounded non-deterministic TM M. Then L is accepted by a 2-tape O(T (n)) time-bounded non-deterministic TM M. Furthermore, M has at most 2 choices; δ(r) 2 for all r Q Γ k Proof. Homework. 4
Nondeterministic Time Hierachy Theorem Theorem 11. Let T 1 and T 2 be functions such that T 2 (n) = ω(n) and T 2 is time-constructible. T 1 (n + 1) = o(t 2 (n)). Then NTIME(T 1 (n)) NTIME(T 2 (n)). Proof. Next lecture. 5