Space Complexity, PSPACE, and Savitch's Theorem
Learning Objectives
- Define the space complexity classes and , PSPACE, and L, and explain why sublinear space requires a read-only input tape.
- Place the classes in the chain and justify each inclusion.
- Prove Savitch's theorem, , with the recursive midpoint algorithm for reachability, and conclude PSPACE = NPSPACE.
- Explain why TQBF is PSPACE-complete and why that makes perfect play in generalized games PSPACE-hard.
Context & Motivation
algorithms-software/computability-complexity measured problems by time and organized them into P, NP, and coNP. Time is not the only resource. Memory is often the binding constraint: a router, a smart card, or a streaming algorithm (the previous concept) has far less memory than it has time. Measuring space instead of time produces a landscape with surprising differences. Time once spent is gone, but space can be reused, and that single fact makes nondeterminism much cheaper for space than it is believed to be for time.
The central results here, Savitch's theorem (1970) and the PSPACE-completeness of quantified Boolean formulas (Stockmeyer and Meyer, 1973), are core material in MIT's 18.404J (Theory of Computation, taught by Sipser) and in Arora and Barak's textbook. They also explain why ai-theory/artificial-intelligence's game-tree search is fundamentally hard: deciding who wins a game is the canonical PSPACE problem.
Core Theory
Space classes
A Turing machine's space usage on input is the number of work-tape cells it visits. For the classes below the input sits on a separate read-only tape that does not count, otherwise any machine would use at least cells just to hold its input and sublinear classes would be empty.
- : languages decided by a deterministic TM using work space.
- : the same for nondeterministic TMs.
- and .
- and : logarithmic space, enough for a constant number of pointers into the input.
The inclusion chain
- : try every certificate of polynomial length one at a time, reusing the same space for each check.
- : a machine using space has at most distinct configurations (state, head positions, tape contents); if it ran longer than that, it would repeat a configuration and loop forever. So a decider halts within exponential time.
- : an NL machine has only polynomially many configurations; accepting means a path exists in its configuration graph from start to accept, which breadth-first search decides in polynomial time.
The space hierarchy theorem gives and the time hierarchy theorem , so at least one inclusion in each half of the chain is strict, but which ones is unknown.
Savitch's theorem
Theorem. For , .
The proof reduces to reachability in the configuration graph: does the nondeterministic machine's start configuration reach an accepting one within steps? Define a recursive procedure that answers whether reaches in at most steps:
- If : check directly whether or moves to in one step.
- Otherwise, for each configuration (a candidate midpoint): if and , accept.
- Reject if no midpoint works.
Each recursive frame stores a few configurations, space. The recursion depth is because halves each time. The second recursive call reuses the space of the first. Total: . The running time is exponential, which is irrelevant to the space bound.
Since the square of a polynomial is a polynomial, PSPACE = NPSPACE: unlike the open P versus NP question, nondeterminism adds nothing to polynomial space. (A different, later result, Immerman-Szelepcsényi, shows .)
TQBF and games
A fully quantified Boolean formula has every variable bound by or , for example . TQBF asks whether such a formula is true.
- In PSPACE: evaluate recursively, trying both values of the outermost variable and reusing space for the second branch; depth equals the number of variables, each frame constant size.
- PSPACE-hard: for any PSPACE machine, a formula of polynomial size expresses "configuration reaches in steps" using the same midpoint idea as Savitch, with a quantifier letting one subformula check both halves instead of writing it twice (which would blow up the size).
TQBF is a game: the player chooses values to make the formula true, the player to make it false, alternating. Many two-player games of perfect information with polynomially bounded length (generalized geography, generalized Hex on boards) reduce from it and are PSPACE-complete. Games whose length can be exponential, such as generalized chess and Go with certain rules, are even EXPTIME-complete.
Worked Examples
Example 1: space versus time for a configuration graph
Problem: A nondeterministic machine uses work cells over a binary tape alphabet, with 20 states, on inputs of length . Bound the number of configurations, the deterministic space Savitch's simulation needs (in configurations stored), and its running time.
Trace: A configuration records the state (20), the work tape contents (), the work head position (40), and the input head position (): about configurations. Reachability needs paths of length up to , so the recursion depth is about 70 frames, each storing three configurations of about 70 bits: roughly bits of work space. The running time, however, is about midpoint attempts, astronomically large. Savitch trades enormous time for modest space, which is exactly the point of the theorem.
Example 2: evaluating a quantified formula as a game
Problem: Decide whether is true.
Trace: The matrix says exactly one of , is true, that is, . For : the player picks , and is true. For : pick , and is true. Both branches succeed, so the formula is true. The recursive evaluation stored only the current partial assignment, two bits, and explored the branches one at a time, the same space-reuse pattern as the PSPACE algorithm. Swapping the quantifiers, , makes it false: no single works for both values of .
Common Misconceptions & Pitfalls
- "PSPACE problems are just slow NP problems." PSPACE contains NP and coNP, and if PSPACE = NP then the polynomial hierarchy collapses; TQBF is believed to be strictly harder than SAT, because alternating quantifiers seem to need more than a single certificate.
- "Savitch shows nondeterminism is free." It shows it costs at most a square in space. For time, the analogous question is P versus NP, which remains open, and the best known deterministic simulation of nondeterministic time is exponential.
- "Logarithmic space is too little to do anything." L contains undirected graph connectivity (Reingold, 2005), arithmetic on input numbers, and many parsing tasks; a constant number of -bit counters and pointers is surprisingly powerful.
Summary
Space complexity counts work-tape cells with a read-only input, giving L, NL, PSPACE, and NPSPACE, which fit into the chain from L to EXPTIME through P and NP. Because space can be reused, Savitch's recursive midpoint algorithm simulates nondeterministic space in deterministic space , so PSPACE equals NPSPACE, in contrast with the open P versus NP question. TQBF, deciding fully quantified Boolean formulas, is PSPACE-complete, and its reading as a two-player game makes optimal play in many generalized games PSPACE-hard. The next concept asks a different question about resources: what changes when an efficient algorithm is allowed to flip coins?