Download presentation

Presentation is loading. Please wait.

Published byCarol Hatchett Modified about 1 year ago

1
1 Space Complexity

2
2 Def: Let M be a deterministic Turing Machine that halts on all inputs. Space Complexity of M is the function f:N N, where f(n) is the maximum number of tape cells that M scans on any input of length n. Def: Let f :N N be a function. SPACE(f(n))={L | L is a language decided by an O(f(n)) space DTM} NSPACE(f(n))={L | L is a language decided by an O(f(n)) space NTM}

3
3 Eg. SAT is NP-complete. SAT can be solved in linear(O(m)) space. M 1 =“On input, where is a Boolean formula: 1. For each truth assignment to the variables x 1,…x m of . 2. Evaluate on that truth assignment. 3. If ever evaluate to 1, ACCEPT; if not, REJECT.” 000 … 0 x 1 x 2 x 3 … x n

4
4 Let ALL NFA ={ | A is a NFA and L(A)= *} Eg. ALL NFA can be decided in nondeterministic linear space, but not known to be in NP or co-NP. N= “ On input where M is an NFA: 1. Place a marker on the start state of the NFA. 2. Repeat 2 q times, where q is the number of states of M. 3. Non-deterministically select an input symbol and change the positions of the markers on M ’ s states to simulate reading that symbol. 1. Accept if Stages 2 and 3 reveal some string that M rejects, that is, if at some point none of the markers lie on accept states of M. Otherwise, reject. “ Why 2 q ?

5
5 Savitch ’ s Theorem(1970): For any function f:N N, where f(n) n, NSPACE(f(n)) SPACE(f 2 (n)). pf: N: an non-deterministic TM deciding a language A in space f(n). Goal: Construct a det TM M deciding A in space f 2 (n). Let be an input string to N. t: integer; c 1,c 2 : configurations of N on .

6
6 CANYIELD(c 1,c 2,t) accept if starting from c 1 N has a branch entering configuration c 2 in t steps; o/w rejects. CANYIELD= “ On input c 1,c 2 and t: 1. If t=1, test whether c 1 =c 2 or c 1 ├ c 2, then accept; else reject. 2. If t>1, then for each configuration c m of N on using space f(n). 3. Run CANYIELD(c 1,c m, ) 4. Run CANYIELD(c m,c 2, ) 5. If 3 & 4 both accept, then accept; else reject. ”

7
7 c accept : accept configuration. c start : start configuration of N on . Select a constant d so that N has no more than 2 df(n) configurations using f(n) tape space, n=| |. M= “ On input output the result of CANYIELD(c start, c accept, 2 df(n) ). ” CANYIELD is a recursive procedure: Recursive depth:log 2 2 df(n) =O(f(n)) Each recursive call of CANYIELD use O(f(n)) space. Thus, it uses O(f 2 (n)) space.

8
8 PSPACE is the class of languages (or problems) that are decidable in polynomial space on a det. TM. PSPACE= SPACE(n k ). Thm: P NP PSPACE=NPSPACE EXPTIME= TIME( ) Def: (PSPACE completeness) A language (or problem) B is PSPACE-complete if it satisfies 2 conditions: (1) B is in PSPACE, and (2) Every A in PSPACE is poly-time reducible to B.

9
9 universal quantifier, existential quantifier, = ~quantified Boolean formula ~fully quantified Boolean formula

10
10 TQBF: given a fully quantified Boolean formula, is it true? Thm: TQBF is PSPACE-complete. pf: TQBF is in PSPACE: T= “ On input : a fully quantified Boolean formula: 1) If has no quantifier, then it is an expression with only constants, so evaluate and accept if it is true; otherwise reject.

11
11 2) If = x , recursively call T on , first with x=0, and then x=1. If either result is accept, then accept; o/w reject. 3) If = x , recursively call T on with x=0, and x=1. If both results are accept, then accept; o/w reject. ” TQBF is PSPACE-hard: Let A be a language decided by a TM M in space n k for some constant k. Show A p TQBF.

12
12 M accepts iff is true. c 1,c 2 : configurations, t: integer; Construct a formula c1,c2,t = Cstart,Caccept,h, h=2 df(n). c1,c2,t = m 1, (c 3,c 4 ) {(c 1,m 1 ),(m 1,c 2 )} [ c3,c4, ] Configuration size: O(f(n)) Recursion depth: lg2 df(n) =O(f(n)) Formula size: O(f 2 (n)) c1,c2,t = m, [ c1,m, m,c2, ] What is the formula size? f x {y, z}[...] x[(x=y) (x=z) ...]

13
13 Winning Strategies for games: = x 1 x 2 x 3 … Qx k [ ] Q represents either a or an quantifier. Two players: player A; player E. Take turns selecting the values of x 1,…, x k. Player A selects values for the variables that are bound to . Player E selects values for the variables that are bound to . Player E wins, if is TRUE. Player A wins, if is FALSE.

14
14 Eg. Let 1 = x 1 x 2 x 3 [(x 1 x 2 ) (x 2 x 3 ) (x 2 x 3 )] Player E has a winning strategy. Let 2 = x 1 x 2 x 3 [(x 1 x 2 ) (x 2 x 3 ) (x 2 x 3 )] Player A has a winning strategy.

15
15 FORMULA-GAME={ | player E has a winning strategy in the formula game associated with }. Thm: FORMULA-GAME is PSPACE-complete. pf: TQBF exactly when FORMULA-GAME.

16
16 Geography Game:

17
17 Generalized geography:(GG) Eg. Player 1: moves first. Player 2: moves second. Player 1 has a winning strategy: Starts at node 1, Player 1 choose 3 Player 2 choose 5 Player 1 choose 6 Player 2 cannot move anywhere Thus, player 1 wins.

18
18 GG={ | player 1 has a winning strategy for the generalized geography game played on graph G starting at node b.} Thm: GG is PSPACE-complete. Pf: M= “ On input, G: directed graph; b: a node of G. 0. REJECT if b has no outgoing edge. 1. Remove node b and all arrows touching it to get a new graph G For each of the nodes b 1,b 2, …,b k that b originally pointed at, recursively call M on. 3. If all of these accept, player 2 has a winning strategy in the original game, so REJECT. O/w player 2 doesn ’ t have a winning strategy, so player 1 has, thus ACCEPT. “

19
19 The only space required is for storing the recursion stack. The level of recursion can be at most m, which is the number of node in G. Each level uses poly. Space, thus in total M uses poly. space.

20
20 Next need to show GG is PSPACE-hard: FORMULA-GAME p GG. = x 1 x 2 x 3 … Qx k p Player 1 in GG ~ player E in formula game. Player 2 in GG ~ player A in formula game. In conjunctive normal form.

21
21 = x 1 x 2 … Qx k [(x 1 x 2 x 3 ) (x 2 x 3 … ) … ( … )] For simplicity, let Q=

22
22 1) If is FALSE, player 2 may win by selecting the unsatisfied clause. Then any literal that player 1 may pick is FALSE and is connected to the side the diamond that hasn ’ t been played. Thus player 2 may choose the node in the diamond, then player 1 cannot move and lose.

23
23 2) If is TRUE, any clause that player 2 picks contains a TRUE literal. Player 1 choose that TRUE literal. ∵ it is true, ∴ it is connected to the side of the diamond that has been chosen. So, player 2 cannot move and lose.

24
24 The class of L and NL L=SPACE(log n) NL=NSPACE(log n) Eg. PATH={ | G is a directed graph that has a directed path from s to t}. PATH: Given a directed graph G and two vertices s and t, is there a directed path from s to t?

25
25 Def: If M is a TM: M read only input tape working tape A configuration of M on is a setting of the state, work tape, and the position of the tape heads.

26
26 If M runs in f(n) space on , | |=n, then the number of configurations of M on is: g f(n) f(n) c n 2 O(f(n)) c: state number. g: number of tape symbol Possibl e work tape. State position. Possible state. Head position of input head. f(n)

27
27 Savitch ’ s theorem is true for f(n) lgn; note that the definition of configurations is different for small space case. But the proof is the same.

28
28 NL-completeness: NL=?L Def: (log space reducibility) 1) A log space transducer is a TM with (1) a read – only input tape (2) a write-only output tape (3) a read/write work tape. 2) A log space transducer M computes a function f: * *, where f(n) is the string remaining on the output tape after M halts when it starts with on input tape. f is called log space computable function. 3) A L B, if A is mapping reducible to B by using a log space computable function. May contain O(logn) symbols.

29
29 Def: A language B is NL-complete if 1. B NL and 2. Every A in NL is log space reducible to B. Thm: If A L B and B L then A L. Cor: If any NL-complete language is in L then L=NL.

30
30 Pf: It has been shown in class that PATH NL. Need to show that for any A NL, A L PATH. Let M be a NTM that decides A in O(log n) space. Given an input , construct a graph G and 2 vertices s and t in log space, where G has a directed path from s to t iff M accepts . V(G): configurations of M on . (c 1,c 2 ) E(G) if c 1 ├ c 2. s: start configuration, t: accept configuration. Thm: PATH is NL-complete.

31
31 Need to show that reduction operates in log space. I.e. need to describe G ’ s vertices and edges in log space. Each configuration needs c logn space, for some constant c. Try all c logn bit string and test with M on to see if it is a legal configuration, if yes, put it into vertex set. For any c 1, c 2, test if c 1 ├ c 2 with M on . Takes O(log n) space.

32
32 Cor: NL P. PATH P NL P (?) co-NL = {B : B is in NL} B = {x : x B } Thm: NL = co-NL.

33
33 Thm: NL = co-NL. 1. Robert Szelepcs ’ enyi, “ The method of forcing for nondeterminitic automata, ” Bull of the EATCS, 33, p , N. Immerman, “ Nondeterministic space is closed under complementation, “ SIAM J. on computing 17, p , G ö del award.

34
34 pf: PATH is NL-complete PATH co-NL. If PATH, then there is no directed path in G from s to t. Every A co-NL has A L PATH. The rest shows PATH NL. Thm: NL = co-NL.

35
35 M= “ On input G, s, t: 1. c 0 =1 /* counter */ 2. For i=0 to m-1 /* m=#of vertex */ 3. c i+1 =0 4. d=0 5. For each node v in G 6. For each node u in G 7. Non-det. Either skip or perform the following steps: 8. Non-det. Follow a path of length i from s, and if non of the nodes met are u, reject. 9. Increase d. 10. If (u,v) E(G), then increase c i+1 and goto 6 with next v. 11. If d c i, then reject.

36
For each node u in G 13. Non-det., either skip or perform these steps: 14. nondeterminitically follow a path of length i from s and if none of the nodes met are u, reject. 15. If u=t, then reject. 16. Increase d. 17. If d c m, then reject, otherwise accept.” The algorithm needs to store c i, d, i, j and a pointer to the head of a path. Thus, it runs in log space. A i ={u : u is reachable from s within i steps.} C i =|A i |, s A i A i+1.

37
37 Nondeterminitic Space is Closed under Complement NSPACE = co-NSPACE. L NSPACE L co-NSPACE. Robert Szelepcse’nyi: “The method of forcing for nondeterministic automaya,” Bull of the EATCS, 33, p , N. Immerman: “Nondeterministic space in closed under complementation,” SIAM J. on computing, 17, p , 1988.

38
38 M: a nondeterminitic S(n)-bounded-space TM. Each configuration of M can be described in O(S(n)). c 0 : Initial configuration of M. Rch M,x (t): The number of configurations reachable by computation on input x in at most t steps starting at c 0.

39
39 M 0 : Input: x, n, t, u; accept if u is reachable in t=1 steps. 1. m:=0 2. for each configuration v of M do non-det simulate M on x during at most t steps, checking if v is reached. if so, then m:=m+1 if M on input x goes from v to u then accept. 3. if m=n then reject else abort by halting in a nonfinal state.

40
40 M 1 : Input: x; n:=1; t:=0; for t from 1 to t(|x|) do m:=0; for each configuration u do if u is reachable from c 0 in t+1 steps then m:=m+1 n:=m Call M 0 (x,n,t,u)

41
41 n is Rch M,x (t) for each t. Thm: If S(n) log n and S is space constructible then NSPACE(S) is closed under complementation. pf: Call M 1 on x to compute Rch M,X (t|x|). For each configuration u call M 0 on. If No accepting configuration accessible, then accept.

42
42 I 1 :=0; for each conf. C do if C 0 ├ 1 C then I 1 :=I 1 +1; D:=I 1 ; K:=1; While K<2 S(n) { I 2 :=0 ; for each conf. C 2 do { I 1 :=0; for each conf. C 1 do { guess path C 0 ├ K C 1 ; if a correct path, I 1 ++; if C 1 ├ 1 C 2 then { if C 2 is accept conf., STOP & REJECT; else { I 2 ++; exit inner loop;} } } if I 1 D, then STOP; } if (D=I 2 ) then ACCEPT; else K++; D:=I 2 ; } Input: M, s, x. Compute initial conf. C 0. I 1 : Rch(k-1) I 2 : Rch(k) NTM accept L(M).

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google