P, NP and PSPACE
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Tree Language Theory Hitoshi Ohsaki National Institute of Advanced Industrial Science and Technology (AIST) seminar talk (6/10) 2009 VI. P & NP TM & k-TM k-TM (k > 1) : MTM with one control-unit one read-only tape (called input tape) k read/write tapes (called working tapes) k-NTM : non-deterministic k-TM Cf. TM , one control-unit + one read/write tape Corollary TM = k-TM = k-NTM (k > 1) Proof The left equivalence follows from the fact that MTM is simulated by TM and the reverse is trivial. Using a similar proof of the previous fact (see the slides of the previous talk), one can show that k-NTM is simulated by NTM and the reverse also holds. Since NTM is simulated by TM, the right equivalence follows. 2 2 Running time & working space Given k-TM = (Γ; Σ; Q; q ; Q ; ∆) M 0 fin time (w) : the number of moves until halts on input w M M (called running time of on w) M space (w) : the number of cells in working tapes which M M visited at least once until halts on input w M (called working space of on w) M For the length n of input T (n) : max time (w) w Σ∗ : w = n M f M j 2 j j g S (n) : max space (w) w Σ∗ : w = n M f M j 2 j j g Question How should we define TL (or SL) for language L ? 3 Linear speed-up Given k-TM , there exists (k + 1)-TM such that M1 M2 { ( ) = ( ) L M1 L M2 1 { T 2(n) 6 T 1(n) for sufficiently large n N M 2 M 2 if limn T 1(n)=n = !1 M 1 Proof Consider k = 1, but the following proof can be generalized to arbitrary k > 1. Let 1 = (Γ; Σ; Q; q0; Qfin; ∆), then define 2 = (Γ ; Σ; Q ; q ; Q ; ∆ ) with Γ = M M 0 0 0 fin0 0 0 (Γ Γ Γ) Σ, Q = (p; i) p Q; 1 i 3 q ; qacc; q and Q = qacc . × × [ 0 f j 2 6 6 g [ f 0 rejg fin0 f g Here the blank for 2 is (]; ]; ]), and the states q ; qacc; q are fresh symbols. M 0 rej Transition function ∆ is defined according to 1's move on each 3 cells (\chunk" 0 M of cells at 2i 1; 2i; 2i+ 1). That is, initially, for input a0 a1 an, 2 copies it to − · · · M (k+1)th working tape in compressed manner, e.g. (]; a0; a1) (a1; a2; a3) (an 1; an; ]) · · · − if n is even ; (]; a0; a1) (a1; a2; a3) (an 2; an 1; an) if n is odd. For this initialization, · · · − − including the running time to return the tape-head on (k+1)th working tape to the 1 leftmost position, 2 needs n + n + c moves (c constant). Next, using (k+1)th M 2 working tape as the input tape of 2, 2 simulates 1. (proof cont'd) M M M 4 Proof (cont'd) For the move of 2, suppose, for instance, that 1 with the state p reads y on M M i the input tape, and then 1 moves on the working tape as shown in the figure. If M 1's tape-head on the input tape stays, say on y + 1, in the same chunk even after M i the other head moves on to the cell of b6, ∆0 contains the following map : (p; 2); (];];]); (yi 1; yi; yi+ 1); (b3; b4; b5) (q; 3); (];];]); (yi 1; yi; yi+ 1); (c1; c2; c3); S; R; S h − i 7! h − i On the right-hand side of the above mapping, \S" stands for stay. Because 2's head on the input tape M working tape of 1 is no longer needed, it keeps staying on a blank. The M p head on (k+1)th-working tape also stays on the same cell, but the the current state must be changed from b1 b2 b3 b4 b5 b6 b7 (p; 2), meaning that 1's tape-head reads yi, to (q; 3), M . meaning that the head reads yi+ 1. During the compu- . tation, 2 should halt on qacc (resp. q ) if 1 ac- M rej M + cepts (rejects) the input. Moreover, since 1 is deter- M just after moving ministic, must be deterministic. By construction, 2 on to the cell of b6 q M 1 the simulation can be done within at most 2 T 1(n)+c0 M (c0 constant) moves. Since limn T 1(n)=n = , b1 b2 c1 c2 c3 b6 b7 !1 M1 1 we have that for large n N, T 2(n) 6 2 T 1(n). 2 2 M M 5 Remarks 1. The size of chunk is not necessarily 3. When the size is i (> 3), 1 the simulation can be done within i 1 T 1(n) − M 2. requires Σ i tape symbols and ( Q i) + 3 state symbols M2 j j j j × 2 3. If limn T 1(n)=n = , one can construct k-TM 2 that !1 M 1 M simulates k-TM (without introducing a new working tape) M1 4. From the proof, one can see that S 2(w) is also improved : M Proposition (Tape compression) Given k-TM , there exists (k + 1)-TM such that M1 M2 { ( ) = ( ) L M1 L M2 1 { S 2(n) 6 S 1(n) for sufficiently large n N M 2 M 2 Note If the size of the chunk is ( 3), the simulation can be done within 1 ( ) i i > i 1 S 1 n 6 − M DTIME & DSPACE Let T; S be 1-variable polynomials with positive coefficients DTIME(T ) : languages accepted by k-TM such that M T (n) 6 T (n) for every (sufficiently large) n N M 2 DSPACE(S) : languages accepted by k-TM such that M S (n) 6 S(n) for every (sufficiently large) n N M 2 Let be the set of 1-variable polynomials with positive coefficients P NP : DTIME(T ) T [2P NPSPACE : DSPACE(S) S [2P Note P PSPACE ⊆ 7 (* Polynomially time-bounded computation requires at most polynomial tape space) NTIME & NSPACE Let T; S be 1-variable polynomials with positive coefficients NTIME(T ) : languages accepted by k-NTM such that M T (n) 6 T (n) for every (sufficiently large) n N M 2 NSPACE(S) : languages accepted by k-NTM such that M S (n) 6 S(n) for every (sufficiently large) n N M 2 Let be the set of 1-variable polynomials with positive coefficients P NP : NTIME(T ) T [2P NPSPACE : NSPACE(S) S [2P Note P NP NPSPACE, PSPACE NPSPACE ⊆ ⊆ ⊆ 8 Example of P The membership problem for CFG in Chomsky normal form : instance is grammar = (Σ; Q; q ; Q ; ∆), word w in Σ G 0 fin ∗ solution is \yes" if w ( ) ; \no" otherwise 2 L G Proof (for the problem being in P) Let w = a1 a2 an (n 0). By assumption of the problem, transition rules in ∆ · · · > are in the forms of p q r, p a, q0 " for p Q, q; r Q q0 , a Σ. ! ! ! 2 2 − f g 2 1. If n = 0 and q0 " ∆, return \yes." for ( ` = 2 , ` n , `++ ) ! 2 6 2. Next, execute the following program : for ( i = 1 , i 6 n - ` + 1 , i++ ) for ( i = 1 , i 6 n , i++ ) j := i + ` - 2 ; if p ai in ∆ for ( k = i , k 6 j , k++ ) 9 ! T (i; i) := T (i; i) p ; if p q r in ∆ & [ f g 9 ! 3. Then, execute the program on the right. q T (i; k) & 9 2 4. If q0 T (1; n), return \yes" ; otherwise r T (k+1; j) 2 9 2 return \no." then T (i; j) := T (i; j) p ; [ f g The innermost loop is done in k1 n running time, hence this computation is done in 3 × 3 at most k2 n (k1; k2 constants). This implies that the problem is in DTIME(n ).2 × 9 Example of NP The bounded halting problem for NTM : instance is NTM = (Γ; Σ; Q; q0; Qfin; ∆), w in Σ , k in N M ∗ solution is \yes" if w ( ) within k moves ; \no" otherwise 2 L M Proof Suppose Ψ( ); Ψ(w) is the binary code for non-deterministic UTM , then h M i MNU the question if w ( ) is the membership problem Ψ( ); Ψ(w) ( ). 2 L M h M i 2 L MNU Let n be the size of input for this problem, then the total length of the word that 2 2 represents and w with delimiters is at most 2 Γ + 2 Q + Γ Q + w + c1. M 2 2 j j j j j j × j j j j Encoding and w by Ψ takes (c2 Γ Q )+(c3 w ) running time in proportion M ×j j ×j j 2 ×2 j j to n. The simulation of takes (c4 Γ Q ) + c5 for each move. In this M × j j × j j simulation, at each step, tries to find a transition rule which can be applied, MNU and then reflects the result on the tapes. By assumption, the simulation must be stopped within k iterations. Hence, the problem is in NTIME(n). 2 Consult books (e.g. [1]) or search on the web for more examples of NP-problems. [1] M.R. Garey & D.S. Johnson: Computers and Intractability { A Guide to the Theory of NP-completeness, Freeman, 1979.