47.02.05 · theoretical-cs / 02-complexity-fundamentals

Space Complexity: PSPACE, Savitch's Theorem, and PSPACE-Completeness

shipped3 tiersLean: nonepending prereqs

Anchor (Master): Arora and Barak 2009 Computational Complexity: A Modern Approach (Cambridge) §4.2-4.3 (Savitch's theorem with full proof, PSPACE-completeness, TQBF completeness with the inductive encoding of computation paths, the space hierarchy theorem, and connections to the polynomial hierarchy); Sipser 2013 §8.1-8.3; Papadimitriou 1994 Computational Complexity (Addison-Wesley) §7.2-7.3

Intuition Beginner

Time and memory are the two fundamental resources a computer uses. So far the focus has been on time: how many steps does a program need? But you can also ask a different question: how much memory does it need? This shift in perspective opens a new landscape of complexity classes and reveals structure that time alone cannot see.

The class PSPACE collects every problem that can be solved using an amount of memory that grows polynomially in the input size. Because a program that runs for a polynomial number of steps can touch at most a polynomial number of memory cells, every problem in P or NP also lives in PSPACE. The reverse is not known — PSPACE could be much larger — and the containment PSPACE within EXPTIME is known to be strict by the space hierarchy theorem.

A surprise awaits when you add nondeterminism to space-bounded computation. For time, adding nondeterminism is conjectured to add enormous power (P versus NP). For space, it adds almost nothing: Savitch's theorem shows that any problem solvable by a nondeterministic machine using cells of memory can also be solved by a deterministic machine using only cells. The quadratic overhead is the price of determinism, and it is remarkably small.

The canonical hard problem for PSPACE is evaluating fully quantified Boolean formulas — formulas where every variable is bound by an "exists" or "for all" quantifier, and the quantifiers can alternate. This problem, called TQBF, is to PSPACE what SAT is to NP: every PSPACE problem reduces to it, so if TQBF were easy then all of PSPACE would be easy.

Visual Beginner

The relationship between the main complexity classes discussed in this unit. Every class is contained in the ones above it.

                    EXPTIME
                   /       \
              PSPACE = NPSPACE
             /       |        \
            |       PH         |
             \      |        /
              NP -- coNP    /
                \   |      /
                  P

The key inclusions. P is inside NP inside PSPACE inside EXPTIME. NPSPACE collapses to PSPACE by Savitch. The polynomial hierarchy PH sits between NP and PSPACE but is not known to equal either. The strict inclusions P within EXPTIME and PSPACE within EXPTIME follow from hierarchy theorems.

inclusion reason
P within NP definition (deterministic is a special case of nondeterministic)
NP within PSPACE a poly-time nondeterministic computation uses at most poly space
PSPACE = NPSPACE Savitch's theorem: nondeterministic space squaring
PSPACE within EXPTIME poly-space machine has at most exponentially many configurations

Worked example Beginner

Consider a robot navigating a grid. The grid has rows and columns, with walls in some cells. The robot starts at the top-left corner and wants to reach the bottom-right corner. At each step it can move up, down, left, or right into an adjacent cell that is not a wall.

The question "can the robot reach the goal?" is a reachability problem. A naive depth-first search uses a stack that could grow as deep as the number of cells, which is . But you can also think about it differently: does there exist a path of length at most from start to goal?

Savitch's approach is recursive. To test whether there is a path of length at most from cell to cell , pick every intermediate cell and recursively ask: is there a path of length at most from to , and from to ? The recursion depth is , and each level stores one intermediate cell (which takes bits), so the total memory is .

For a grid of size , the longest possible path has length at most , so levels of recursion suffice. The total memory is — far less than storing the entire grid path. This is the essence of Savitch's theorem applied to a concrete problem.

Check your understanding Beginner

Formal definition Intermediate+

Let be a Turing machine with a read-only input tape and a read-write work tape. On input of length , define as the maximum number of work-tape cells that visits during its computation on . For a function , define

and

The classes and are the polynomial-bounded unions:

A configuration of a space- Turing machine on an input of length is a tuple where is the machine state, is the input head position, is the work-tape head position, and is the work-tape contents. The number of distinct configurations is at most . For , this is .

The configuration graph is a directed graph whose vertices are the configurations of on input , with an edge from to if can move from to in one step. Then accepts if and only if there is a path in from the start configuration to an accepting configuration.

A language is PSPACE-complete if and every language is polynomial-time reducible to : there is a polynomial-time computable function with . The language (True Quantified Boolean Formulas) is the set of all fully quantified Boolean formulas that evaluate to true:

where each and is a quantifier-free Boolean formula [Sipser §8.3].

Counterexamples to common slips Intermediate+

  • "Savitch's theorem implies P = NP because squaring space is cheap." Savitch addresses space, not time. The deterministic simulation of Savitch's theorem may take time exponential in the space bound (the recursive predicate has exponential time complexity because it enumerates all midpoints), so it gives no information about P versus NP.

  • "PSPACE-completeness is the same as NP-completeness but with more quantifiers." The analogy is useful but the technical difference matters. A PSPACE-complete problem allows an unbounded alternation of existential and universal quantifiers, while NP-complete problems involve a single block of existential quantifiers. The reduction must be polynomial-time, which is the same requirement, but the quantifier structure is what makes TQBF harder than SAT under standard assumptions.

  • "NPSPACE is larger than PSPACE because nondeterminism helps." This is precisely what Savitch's theorem disproves. The quadratic space overhead of simulating nondeterminism deterministically is modest enough that , so taking the union over all gives .

Key theorem with proof Intermediate+

The central result of this unit is Savitch's theorem, which collapses nondeterministic and deterministic space up to a quadratic factor. Together with PSPACE-completeness of TQBF, it establishes the structural landscape of space-bounded computation.

Theorem (Savitch). For any space-constructible with ,

In particular, .

Proof. Let , decided by a nondeterministic TM using space. The configuration graph has at most vertices. Define a recursive predicate:

For the base case : check whether or there is an edge from to (at most one step). For : there is a path of length at most from to if and only if there exists a midpoint such that both and hold.

The deterministic algorithm evaluates where is the start configuration, is any accepting configuration, and . It iterates over all possible midpoints (each represented in space), recursively checks both halves, and accepts if any midpoint works. The recursion depth is . At each level the algorithm stores one midpoint configuration using space, and the two recursive calls reuse the same space. Total space: .

Corollary. .

Proof. by Savitch. Taking the union over all gives . The reverse inclusion is immediate since deterministic machines are a special case.

Theorem (TQBF is PSPACE-complete). is PSPACE-complete.

Proof sketch. Membership in PSPACE: evaluate a fully quantified Boolean formula recursively. Try both values of ; if , accept if either recursive call accepts; if , accept if both accept. The recursion depth is and each level stores one assignment to the already-processed variables, using polynomial space total.

Hardness: given a PSPACE machine using space and an input , encode the computation as a quantified formula. The key idea is the same Savitch-style recursive predicate. Define to mean "configuration is reachable from in at most steps." Then holds if and only if there exists a midpoint such that for all intermediate configurations, both halves are reachable:

The alternation of quantifiers mirrors the recursion. Unrolling levels gives a fully quantified formula of polynomial size.

Bridge. This theorem is the foundational reason space-bounded complexity has a different character from time-bounded complexity: nondeterminism costs only a quadratic factor in space (Savitch) but is conjectured to cost an exponential factor in time (P versus NP), and this is exactly the structural asymmetry that makes PSPACE a natural home for alternating quantifiers and two-player games. The recursive PATH predicate builds toward the Immerman-Szelepcsenyi theorem 47.02.06, where the same configuration-graph reachability question is studied at the logarithmic level, and it appears again in the IP = PSPACE proof 47.03.04, where the arithmetisation of the quantifier alternations gives an interactive protocol. The central insight is that space can be reused — the two recursive calls in Savitch share the same memory — whereas time cannot, putting these together gives a deterministic simulation whose resource consumption is multiplicative in space but exponential in time, and the bridge is that TQBF packages this recursive reachability as a single formula whose alternating quantifiers are the logical fingerprint of PSPACE.

Exercises Intermediate+

Advanced results Master

The theory of PSPACE extends well beyond the core theorems. The results below develop the space hierarchy, sharpen the relationship between time and space, and explore the structure of PSPACE-complete problems.

Theorem 1 (Savitch's theorem, detailed analysis). The deterministic simulation in Savitch's theorem uses time even though space is only . This exponential time overhead is inherent in the recursive approach: the predicate explores all midpoints at each level, and the recursion has levels. Any improvement to polynomial time while maintaining polynomial space would resolve open questions in complexity theory, since would follow from polynomial-time simulation of nondeterministic logarithmic space [Arora-Barak §4.2].

Theorem 2 (TQBF completeness, full proof). The PSPACE-completeness of TQBF requires two directions. Membership was sketched above; the hardness direction encodes the PSPACE computation as a quantified formula using a technique analogous to the Cook-Levin construction 47.02.02. Given using space, let and be start and accepting configurations. Define to encode " is reachable from in at most steps." For , checks that or there is a single-step transition, expressible as a constant-size Boolean formula. For , apply the Savitch recursion:

where and . Unrolling levels gives a quantified formula of size polynomial in (each configuration is bits and , but the key observation is that the same variable names are reused across levels). The formula is true if and only if accepts , so the reduction is correct [Sipser §8.3].

Theorem 3 (space hierarchy theorem). For space-constructible with and , the inclusion is strict [Arora-Barak §4.1]. The proof diagonalises against all -space machines: construct a language that on input simulates on for space and flips the answer. As long as exceeds the simulation overhead, separates the classes. Important corollaries: and .

Theorem 4 (PSPACE and games). Many two-player games of polynomial length are PSPACE-complete. The generalised geography problem and the problem of deciding whether the first player has a winning strategy in generalised chess, Go, or checkers on an board are PSPACE-complete [Arora-Barak §4.3]. The correspondence between alternating quantifiers and alternating game moves is the structural reason: an existential quantifier corresponds to "there exists a move for Player 1" and a universal quantifier to "for every response by Player 2," so TQBF is equivalent to asking whether Player 1 has a winning strategy in a polynomial-depth game tree.

Theorem 5 (PSPACE and the polynomial hierarchy). The polynomial hierarchy satisfies . Each level involves alternating polynomial-length quantifiers over a polynomial-time predicate, and evaluating these quantifiers sequentially using polynomial space places . Whether is open; if they are equal, then the polynomial hierarchy collapses. This is dual to the P vs NP question: both ask whether additional quantifier alternation adds computational power [Arora-Barak §5.2].

Synthesis. The foundational reason the space complexity landscape differs from the time landscape is that space can be reused: Savitch's theorem exploits this by having two recursive calls share the same memory, which builds toward the surprising equality PSPACE = NPSPACE and this is exactly the structural fact that makes space more tractable than time as a resource to analyse. The alternating quantifiers in TQBF are dual to the alternating moves in two-player games, and this is exactly the bridge to interactive proofs 47.03.04, where the IP = PSPACE theorem shows that every PSPACE computation can be verified by a polynomial-time verifier interacting with a powerful prover. The central insight unifying these results is that the configuration graph of a space-bounded machine has polynomial diameter when measured in the logarithm of the number of configurations, and putting these together the Savitch recursion, the TQBF encoding, and the game-tree characterisation all express the same polynomial-space reachability question in different languages. The space hierarchy theorem 47.02.01 provides the strict separations that make this structure non-vacuous, and the generalises connection from PSPACE to the polynomial hierarchy 47.02.03 shows that space complexity subsumes the entire quantifier-alternation hierarchy.

Full proof set Master

Proposition 1 (Savitch's theorem). For space-constructible , .

Proof. Let be a nondeterministic TM deciding in space . The configuration graph has vertices. Define as above. The algorithm for : if , return 1 iff or is an edge. If , for each vertex (enumerated in space): compute ; if it returns 1, compute ; if both return 1, return 1. After all midpoints, return 0.

Space analysis: the recursion depth is . At each level, the algorithm stores one midpoint using space and one return value. The two recursive calls are sequential and reuse space. Total space: . Setting so that gives total space .

Proposition 2 (PSPACE = NPSPACE). .

Proof. For any , by Proposition 1. Union over : . The reverse inclusion is immediate.

Proposition 3 (TQBF is in PSPACE). The language TQBF is decidable in polynomial space.

Proof. Given a QBF , evaluate recursively. The recursive procedure takes a partial assignment to the first variables and evaluates the remaining quantifiers. For : try and ; accept if either recursive call accepts. For : accept if both recursive calls accept. When all variables are assigned, evaluate in polynomial time. Each recursive level stores one additional variable value, so the space is .

Proposition 4 (PSPACE-completeness of TQBF). Every language is polynomial-time reducible to TQBF.

Proof. Let decide in space for polynomial . For input , construct the formula using the recursive Savitch encoding with levels. At each level, a configuration is encoded by Boolean variables. The formula checks equality or single-step reachability with a constant-size circuit. The recursion introduces new variables per level and levels, giving a formula of total size . The formula is true iff accepts . The construction is polynomial-time since each level's encoding is polynomial and there are polynomially many levels.

Proposition 5 (space hierarchy). If is space-constructible and with space-constructible, then .

Proof. Define TM : on input of length , use space to simulate on (where is the machine encoded by , padded if needed). If attempts to use more than space, reject. Otherwise, output the complement of 's output. uses space, so .

Suppose . Then some machine decides in space for constant . For large enough , . Let encode with appropriate padding. Then on successfully simulates (which uses space) and outputs the opposite, so , contradicting deciding .

Connections Master

  • Time complexity and P/NP 47.02.01 provides the foundational complexity classes that PSPACE extends. The containment follows from P/NP theory, and the polynomial hierarchy 47.02.03 sits between NP and PSPACE. This unit owns the space-bounded analogue and the structural collapse PSPACE = NPSPACE.

  • NP-completeness 47.02.02 introduces the reduction technique that PSPACE-completeness mirrors. The Cook-Levin reduction from any NP machine to SAT is the template for the reduction from any PSPACE machine to TQBF, with the key difference being the unbounded quantifier alternation.

  • L, NL, and Immerman-Szelepcsenyi 47.02.06 studies space-bounded classes below PSPACE. Savitch's theorem applies at the logarithmic level too, giving , but the Immerman-Szelepcsenyi theorem gives the tighter result , which has no known time analogue.

  • Interactive proofs 47.03.04 establish that , giving a characterisation of PSPACE in terms of interactive protocols. The arithmetisation of the TQBF quantifier structure is the core of the LFKN-Shamir proof, and the PSPACE-completeness of TQBF developed here is the starting point for that construction.

  • Models of computation 42.04.01 supply the Turing machine model and configuration formalism that underlies the space-bounded analysis. The configuration graph is a refinement of the universal machine construction from that unit.

Historical & philosophical context Master

Walter Savitch proved his theorem in 1970 in his PhD thesis at the University of California, Berkeley, under the supervision of Manuel Blum. The result appeared in the Journal of Computer and System Sciences as "Relationships Between Nondeterministic and Deterministic Tape Complexities" (Savitch, 1970). At the time, the relationship between nondeterministic and deterministic space was wide open, and Savitch's quadratic bound was a strikingly strong result — it showed that nondeterminism is far less powerful in the space setting than was (and still is) conjectured for time [Sipser §8.2].

The PSPACE-completeness of TQBF was established by Larry Stockmeyer and Albert Meyer in 1973 in their paper "Word Problems Requiring Exponential Time," which also introduced the polynomial hierarchy. The connection between PSPACE and two-player games was explored by Schaefer (1978), who proved PSPACE-completeness for a wide range of games. The geography game reduction became a standard textbook example.

The equality IP = PSPACE, proved by Lund, Fortnow, Karloff, and Nisan (1990) and Shamir (1990), gave a completely unexpected characterisation of PSPACE through interaction rather than quantifiers, connecting this unit to the interactive proof framework. The space hierarchy theorem, a consequence of earlier work by Hartmanis, Lewis, and Stearns (1965), provides the strict inclusions that give the theory nontrivial content.

Bibliography Master

@article{savitch1970relationships,
  author  = {Savitch, Walter J.},
  title   = {Relationships between nondeterministic and deterministic tape complexities},
  journal = {Journal of Computer and System Sciences},
  volume  = {4},
  number  = {2},
  year    = {1970},
  pages   = {177--192}
}

@article{stockmeyer1973word,
  author  = {Stockmeyer, Larry J. and Meyer, Albert R.},
  title   = {Word problems requiring exponential time},
  journal = {Proceedings of the 5th Annual ACM Symposium on Theory of Computing},
  year    = {1973},
  pages   = {1--9}
}

@article{shamir1990ip,
  author  = {Shamir, Adi},
  title   = {{IP} = {PSPACE}},
  journal = {Journal of the ACM},
  volume  = {39},
  number  = {4},
  year    = {1992},
  pages   = {869--877}
}

@article{lund1990algebraic,
  author  = {Lund, Carsten and Fortnow, Lance and Karloff, Howard and Nisan, Noam},
  title   = {Algebraic methods for interactive proof systems},
  journal = {Proceedings of the 31st Annual Symposium on Foundations of Computer Science},
  year    = {1990},
  pages   = {2--10}
}

@article{schaefer1978complexity,
  author  = {Schaefer, Thomas J.},
  title   = {The complexity of {S}atisfiability problems},
  journal = {Proceedings of the 10th Annual ACM Symposium on Theory of Computing},
  year    = {1978},
  pages   = {216--226}
}

@book{sipser2013introduction,
  author    = {Sipser, Michael},
  title     = {Introduction to the Theory of Computation},
  publisher = {Cengage Learning},
  edition   = {3rd},
  year      = {2013}
}

@book{arora2009computational,
  author    = {Arora, Sanjeev and Barak, Boaz},
  title     = {Computational Complexity: A Modern Approach},
  publisher = {Cambridge University Press},
  year      = {2009}
}

@book{papadimitriou1994computational,
  author    = {Papadimitriou, Christos H.},
  title     = {Computational Complexity},
  publisher = {Addison-Wesley},
  year      = {1994}
}