Download presentation
Presentation is loading. Please wait.
Published byKristopher Osborne Modified over 8 years ago
1
Theory of Computational Complexity Yuji Ishikawa Avis lab. M1
2
Outline Chapter 8 : Definition of Space Complexity Savitch’s Theorem The Class PSPACE PSPACE-Completeness TQBF Problem
3
Space Complexity Time and Space are both important We use Turing Machine as a model for measuring the space used by an algorithm
4
Space Complexity Definition 8.1 Let M be a deterministic TM that halts on all inputs The space complexity of M : the function f : N -> N where f(n) is the maximum number of tape cells that M scans on any input of length n If the space complexity of M is f(n), we say that M runs in space f(n)
5
Space Complexity accept Computation tree of a DTM …... f(n) : max number of used cells q 0 a0 a1a3 … an q accept b0 b1b3 … bi … b f(n)
6
Space Complexity Definition 8.1 Let M be a non-deterministic TM that halts on all inputs The space complexity of M : the function f : N -> N where f(n) is the maximum number of tape cells that M scans on any branch of its computation for any input of length n
7
Space Complexity Definition 8.2 Let f : be a function. The space complexity classes are defined as follows. 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 }
8
Space Complexity e.g. SAT is in SPACE(n) SAT can be solved with a deterministic linear space algorithm. SAT = { 〈 φ 〉 | φ is a satisfiable Boolean formula} TRUE if x = 1, y = 0
9
Space Complexity e.g. SAT is in SPACE(n) M = “On input 〈 φ 〉, where φ is a Boolean formula: 1. For each assignment to the variables of φ: 2. Evaluate φ on that assignment 3. If φ ever evaluated to 1, accept; if not, reject.”
10
Space Complexity e.g. SAT is in SPACE(n) M needs to store only the current assignment and which can be done with O(m) space. (m is the number of variables) m < n, so M runs in space O(n)
11
Outline Chapter 8 : Definition of Space Complexity Savitch’s Theorem The Class PSPACE PSPACE-Completeness TQBF Problem
12
Savitch’s Theorem One of the earliest results concerning space complexity. (Walter Savitch in 1970) It shows that deterministic machines can simulate nondeterministic machines by using a very small amount of space
13
Savitch’s Theorem Theorem 8.5 For any function f :, where f(n) >= n, Proof Suppose a language A can be decided by a f(n) space NTM. We shall show that it can be decided by an O(f^2(n)) space DTM.
14
Savitch’s Theorem Proof How can we simulate a NTM by a DTM? Given two configurations of a NTM, c1 and c2, with a number t. Can the NTM get from c1 to c2 within t steps? We solve a yieldability problem.
15
Savitch’s Theorem P roof To solve this problem, we define a recursive function, called, CAN_YIELD(c1, c2, t). It returns accept if a nondeterministic TM N can get from c1 to c2 within t steps on input w, and returns reject if not. For convenience, we assume that t is a power of 2
16
Savitch’s Theorem CANYIELD = “On input c1, c2 and t: 1. If t=1, test whether c1=c2 or whether c1 yields c2 in one step according to the rules of N. Accept if either test succeeds; reject if both fail. 2. If t>1, for each configuration cm using space f(n): 3. Run CANYIELD(c1, cm, t/2) 4. Run CANYIELD(cm, c2, t/2) 5. If both accept, then accept. 6. If haven’t yet accepted, reject.”
17
Savitch’s Theorem CANYIELD(c1, c2, t) f c1cmcm c2 CANYIELD(c1, cm, t/2) CANYIELD(cm, c2, t/2)
18
Select a constant d so that N has no more than configurations. (which provides an upper bound on the N’s running time) Savitch’s Theorem Proof Now we define DTM M to simulate NTM N as follows, Modify N so that when it accepts, it clears the tape and moves the head to the leftmost cell. We denote such a configuration Let be the start configuration of N on w. C start C accept.
19
Savitch’s Theorem Proof By using this new N, we can make a DTM M that simulates N as follows, M = “On input w, 1. Output the result of CANYIELD(,, ) ” C accept C start
20
Savitch’s Theorem Algorithm CANYIELD obviously solves the yieldability problem, and hence M correctly simulates N.
21
Savitch’s Theorem Analysis Whenever CANYIELD invokes itself recursively, it stores the values of c1, c2 and t on a stack. And when it returns, these values may be restored. Each level of recursion uses O(f(n)) additional space
22
Savitch’s Theorem Analysis The depth of the recursion is O(log ) or O(f(n)). Therefore, the total space used is O(f^2(n))
23
Outline Chapter 8 : Definition of Space Complexity Savitch’s Theorem The Class PSPACE PSPACE-Completeness TQBF Problem
24
The Class PSPACE Definition 8.6 PSPACE is the class of languages that are decidable by a polynomial space DTM.
25
The Class PSPACE We define NPSPACE in the same way However, according to Savitch’s Theorem, PSPACE = NPSPACE, because the square of a polynomial function is still a polynomial.
26
Outline Chapter 8 : Definition of Space Complexity Savitch’s Theorem The Class PSPACE PSPACE-Completeness TQBF Problem
27
PSPACE-Completeness Definition 8.8 A language B is PSPACE-complete if it satisfies two conditions: 1. B is in PSPACE, and 2. every A in PSPACE is polynomial time reducible to B. If B merely satisfies condition 2, we say that it is PSPACE-hard.
28
TQBF TQBF is an example of a PSPACE-complete problem. It is the quantified version of SAT.
29
TQBF TQBF = { 〈 φ 〉 | φ is a true fully quantified Boolean formula} e.g. is in TQBF is not in TQBF
30
TQBF is in PSPACE we give a polynomial space algorithm T deciding TQBF. T = “On input 〈 φ 〉, 1. If φ has no quantifiers, then evaluate it. 2. If φ = x ψ(x), call T on ψ(0) and ψ(1): accept if both are true; reject if not. 3. If φ = x ψ(x), call T on ψ(0) and ψ(1): accept if either is true; reject if not. ”
31
TQBF is in PSPACE x y[( x y) (x y)] y[( 0 y) (0 y)] y[( 1 y) (1 y)] ( 0 0) (0 0) ( 0 1) (0 1) ( 1 0) (1 0) ( 1 1) (1 1) 100 1 11 1
32
TQBF is in PSPACE The depth of recursion is at most the number of variables. At each level we need only store the value of one variable, So the total space used is O(m) = O(n). (m is the number of variables)
33
TQBF is PSPACE-Hard We prove TQBF is PSPACE-hard in a similar way to Savitch’s theorem. Let A be a language decided by a TM M in space for some constant k. We give a polynomial time reduction from A to TQBF.
34
TQBF is PSPACE-Hard In other words, based on input string w, we want to construct a quantified Boolean formula φ that is true iff M accepts w. q0q0 w0 w1w3 … wn “M accepts w?” PP “φ is true ?” x y z …[…]
35
TQBF is PSPACE-Hard Using two collections of variables denoted c1 and c2, representing two configurations of M, and a number t > 0, we construct a formula is true iff M can go from c1 to c2 in at most t steps. φ c1,c2,t
36
TQBF is PSPACE-Hard Let f M,w (c1, c2) be the function evaluating to true iff M on input w can go from c1 to c2 in a single step.
37
TQBF is PSPACE-Hard If t = 1, = f M,w (c1, c2) (c1=c2) If t > 1, we construct φ recursively. = m (c3,c4) ∈ {(c1, m), (m, c2)}[ ] φ c1,c2,t φ c3,c4,t/2
38
TQBF is PSPACE-Hard Finally, we construct and are the start and accept configurations of M on input w. h = for a constant d, chosen so that M has no more than possible configurations on an input of length n. φ c start,c accept,h C start C accept
39
TQBF is PSPACE-complete φ is constructible in polynomial-time. Thus, any PSPACE language can be reduced to TQBF in polynomial-time. Since TQBF ∈ PSPACE, it is PSPACE-complete TQBF is PSPACE-hard
40
Winning strategies for games Games are closely related to quantiers. Let be a quantied Boolean formula. Here Q represents a or an quantifier.
41
Winning strategies for games Formula game ・ Two players, called A and E, take turns selecting the values of the variables x1, …,xk. ・ A selects values for variables that are bound to ∀ quantifiers and E selects those to ∃ quantifiers. ・ At the end, if ψ is true, E wins, otherwise A wins.
42
Winning strategies for games FORMULA-GAME = { 〈 φ 〉 |Player E has a winning strategy in the formula game associated with φ }
43
Winning strategies for games Theorem : FORMULA-GAME is PSPACE-complete Proof : FORMULA-GAME is exactly TQBF. φ ∈ TQBF if and only if φ ∈ FORMULA-GAME.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.