









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










So far we have defined complexity measures based on the time used by algorithms. Now we shall do a similar analysis based on the space used. In the Turing Machine model of computation this is again easy to measure — just count the number of tape cells read during the computation. Definition The space complexity of a Turing Machine T is the function SpaceT such that SpaceT (x) is the number of distinct tape cells visited during the computation T (x) (Note that if T (x) does not halt, then SpaceT (x) is undefined.)
Now we are in a position to divide up the decidable languages into classes, according to their space complexity. Definition The space complexity class SPACE[f] is defined to be the class of all languages with space complexity in O(f ) (Note, it is sometimes called DSPACE[f ] - for Deterministic Space)
As with time, we can obtain a robust space complexity class by considering all polynomial space complexity classes Definition PSPACE =
k≥ 0
SPACE[nk^ ]
Visiting a cell takes at least one time step, so we have Theorem TIME[f ] ⊆ SPACE[f ] A more subtle analysis, based on the fact that there are only |Σ|f^ (n)^ different possible contents in f (n) tape cells, gives Theorem SPACE[f ] ⊆ TIME[kf^ ]
The previous result suggests that a given amount of space is more useful than the same amount of time This is because space can be reused For example, SATISFIABILITY can be solved in linear space, by trying each possible assignment, one at a time, reusing the same space. It follows that: NP ⊆ PSPACE
Instance : A quantified Boolean formula Φ = (Q 1 x 1 )(Q 2 x 2 ) · · · (Qnxn)φ(x 1 , x 2 ,... , xn) where each xi is a Boolean variable, φ(x 1 , x 2 ,... , xn) is a CNF formula involving x 1 , x 2 ,... , xn and each Qi is a quantifier (that is, ∃ or ∀). Question: Is Φ logically valid?
Theorem QSAT is PSPACE -complete.
(^1) Sometimes called QUANTIFIED BOOLEAN FORMULA (QBF)
For an input formula Φ, do If Φ has no quantifiers, then it has no variables, only constants (TRUE and FALSE). Evaluate Φ and accept iff it is TRUE. If Φ = ∃xΨ then Φ is valid iff at least one of Ψ[x = TRUE] and Ψ[x = FALSE] is valid. Recursively call this algorithm on Ψ[x = TRUE] and Ψ[x = FALSE] and accept iff one of them is accepted. If Φ = ∀xΨ then Φ is valid iff both Ψ[x = TRUE] and Ψ[x = FALSE] are valid. Recursively call this algorithm on Ψ[x = TRUE] and Ψ[x = FALSE] and accept iff both of them are accepted. The algorithm uses O(n) space because the depth of recursion is n (the number of variables), and on every level we need to store only the value of one variable.
The game is played by two players, ∃ and ∀. Given a CNF formula φ over x 1 ,... , xn, the players take turns assigning truth values to the variables (in order). When all variables are instantiated, ∃ wins if the formula evaluates to TRUE. Otherwise ∀ wins.
FORMULA GAME Instance : A CNF formula φ over x 1 ,... , xn Question: Does ∃ have a winning strategy in the game on φ?
Theorem FORMULA GAME is PSPACE -complete. Proof. FORMULA GAME is the same problem as QSAT.
Instance : A game for 2 players consisting of a directed graph G, and a start node s. Players take turns to move along the edges from the current node. A player who cannot move without returning to a node already visited loses Question: Is there a winning strategy for the first player?
GENERALISED GEOGRAPHY can be shown to be PSPACE -complete by reduction from QSAT. For any quantified Boolean formula we can construct a game graph such that the first player has a winning strategy if and only if the formula is valid (see Sipser Theorem 8.11 for details) Many other 2-player games are also PSPACE -complete.
An alternating TM N decides a language L if N accepts all strings in L and rejects all other strings. Definition A language L belongs to the complexity class AP (alternating polynomial time) iff it can be decided by an alternating Turing machine, all computations on which on input x halt after at most p(|x|) steps, where p is a polynomial.
Theorem AP = PSPACE. (See Sipser Theorem 10.18.) Thus, the problems in PSPACE are the problems of deciding winning strategies in certain 2-player games.