PSPACE
Imagine a chess-playing program that must decide, from any board position, whether the player to move has a forced win. The search tree of possible games is astronomically large. It's far too big to store in memory. Yet a clever algorithm can still explore it using only a modest amount of scratch space. It reuses memory as it backtracks. This is the essence of PSPACE, the class of problems solvable using an amount of memory that grows only polynomially with the input size. This holds regardless of how much time the computation takes. PSPACE sits at a fascinating point in the complexity landscape. It contains both P and NP, yet nobody has proven it is strictly larger than either. What makes PSPACE special is a structural theorem — Savitch's Theorem. It shows that allowing nondeterminism costs essentially nothing extra in space. This is in sharp contrast to the (conjectured) enormous cost nondeterminism has in time. This single fact collapses an entire hierarchy of space-bounded nondeterministic classes into deterministic ones. This is a phenomenon with no known analogue for time. Problems capturing PSPACE completeness tend to involve games and quantified reasoning. Examples include deciding the winner of generalized Geography, evaluating quantified Boolean formulas, or determining whether a regular expression with squaring denotes all strings. These problems share a recursive structure. Solving them requires exploring a game tree of exponential size. But the recursion depth (hence memory) stays polynomial. This is because you only need to remember the current path, not the whole tree. This article builds PSPACE from first principles. It covers its formal definition via space-bounded Turing machines, the equivalence of deterministic and nondeterministic space classes, and its precise relationship to P and NP. It sets the stage for later study of PSPACE-completeness and the Quantified Boolean Formula problem, the canonical hard problem for this class.
- PSPACE is the class of languages decidable by a deterministic Turing machine using space for some constant , with no bound on time.
- NPSPACE is the nondeterministic analogue; Savitch's Theorem proves PSPACE = NPSPACE, so nondeterminism adds no extra power in the space-bounded world.
- The chain holds, and it is known that , so at least one of these inclusions is strict — but nobody knows which.
- PSPACE is closed under complement, union, intersection, and concatenation — closure under complement is immediate here, unlike the open question for NP.
- Canonical PSPACE problems involve alternating quantifiers or two-player games: TQBF (Quantified Boolean Formula satisfiability) is the flagship PSPACE-complete problem.
- Space is a more "reusable" resource than time: a machine can overwrite the same memory cells across different branches of computation, which is exactly what powers Savitch's algorithm.
PSPACE captures everything solvable with polynomial memory and unlimited time, and Savitch's Theorem shows that nondeterminism buys no extra space beyond a polynomial-degree penalty — so PSPACE = NPSPACE.
The idea
A language belongs to PSPACE if there is a deterministic Turing machine and a polynomial such that decides , and on every input of length , uses at most tape cells across all of its work tapes. Formally,
where denotes the class of languages decidable by a deterministic TM using space. Crucially, there is no restriction on running time — only on the number of distinct memory configurations the machine may touch. Since a machine with space and a fixed tape alphabet and state set has at most distinct configurations for some constant (accounting for tape contents, head positions, and control state), any machine that halts must halt within steps or else it revisits a configuration and loops forever. This gives a fundamental link: polynomial space implies at most exponential time, so
The nondeterministic analogue, NPSPACE, is defined the same way but for nondeterministic Turing machines: if some nondeterministic TM decides using space on every branch of its computation, for some . At first this looks like it should be a genuinely larger class — after all, NP (polynomial time, nondeterministic) is widely believed to be strictly larger than P. The remarkable fact, due to Savitch's Theorem, is that this intuition is wrong for space: . Nondeterminism, which seems to require exponentially many parallel guesses, can be simulated deterministically using only a polynomial (specifically, quadratic) blow-up in space, because a deterministic machine can reuse the same memory to sequentially check different guesses via recursive divide-and-conquer over configurations. This robustness — the fact that PSPACE doesn't care whether you allow nondeterminism — is what makes it such a clean and important class. It sits above both P and NP in the standard hierarchy of complexity classes, and it exactly captures the resources needed to solve two-player game problems with polynomially bounded game trees of unbounded depth pattern, and problems expressible with an unbounded (but fixed, polynomial) number of alternating quantifiers.
How it works
Space-bounded machines and configurations
To reason about PSPACE algorithms, it helps to fix the configuration graph model. A configuration of a Turing machine on space bound encodes: the current state, the contents of all work tapes (each of length ), and the positions of all tape heads. The number of distinct configurations is bounded by
for a machine with state set , tape alphabet , and a constant number of tapes/heads — this is whenever . Deciding whether accepts becomes equivalent to a reachability question on the (exponentially large but implicitly described) configuration graph: is there a path from the start configuration to an accepting configuration? This reachability view is the key to Savitch's Theorem. Rather than exploring the graph explicitly (which would take exponential space to store), the algorithm asks a recursive question: "Can I get from configuration to configuration in at most steps?" and answers it by guessing a midpoint and recursing on two halves, each requiring only steps. This halves the time budget at each level of recursion while only needing to remember the current path of midpoints — which is logarithmic in the number of recursive calls, hence polynomial in the original space bound.
Savitch's algorithm, in detail
Let be a nondeterministic TM deciding a language using space . Build the deterministic algorithm `CANREACH(c1, c2, t)` that decides whether can go from configuration to configuration in at most steps. ``` function CANREACH(c1, c2, t):
# Decide whether config c2 is reachable from config c1
# in at most t steps of the nondeterministic machine N. if t == 0: return (c1 == c2) if t == 1: return (c1 == c2) or (c2 is a valid successor of c1 in one step) for each configuration cmid in the configuration space of N:
# cmid ranges over all strings that encode a legal
# configuration using <= s(n) tape cells: this is
# at most 2^(O(s(n))) possibilities, enumerated one at a time if CANREACH(c1, cmid, ceil(t/2)) and CANREACH(cmid, c2, floor(t/2)): return true return false function SAVITCH_SIMULATE(N, w): n = length(w) s = space_bound(N, n) # e.g. s(n) = n^k for the given NPSPACE machine c_start = start_configuration(N, w) T = 2^(O(s(n))) # generous bound on N's running time
# (since N halts within this many steps or loops) for each accepting configuration c_accept of N with tape usage <= s(n): if CANREACH(c_start, c_accept, T): return ACCEPT return REJECT ``` The crucial resource analysis: at recursion depth , the time budget has been halved times, from down to , which happens after levels of recursion. At each level, the algorithm stores only the current pair of configurations being compared and the candidate midpoint being tried — each of size . Since there are levels of recursion stack, each holding bits, the total space used is
So a language decidable in nondeterministic space is decidable deterministically in space . When is already polynomial, is still polynomial — hence PSPACE = NPSPACE.
The diagram: recursive reachability
Each recursive call only needs to remember the configurations at its own level of the tree — once a subcall returns, its space is reclaimed and reused for the next branch. This is the essence of why space is "reusable" in a way time is not: you cannot reuse time once it has elapsed, but you can absolutely reuse tape cells.
Complexity & correctness
Space bound. As derived above, Savitch's algorithm uses space to simulate an -space nondeterministic machine, giving PSPACE = NPSPACE (taking polynomial keeps the square polynomial). More generally the same argument gives Savitch's Theorem in full: for any ,
Correctness of `CANREACH`. The proof is a clean induction on .
- Base cases () are checked directly by comparing configurations or testing the (polynomially many) legal one-step transitions, which requires no recursion.
- Inductive step: `CANREACH(c1, c2, t)` returns true if and only if there exists some configuration reachable from within steps, from which is reachable within further steps. This is exactly the definition of " reachable from within steps" split at the midpoint of the path — any path of length has some configuration at position , and conversely concatenating two shorter reachability witnesses gives a path of length . The correctness of the recursive calls follows by strong induction on , bottoming out at the base cases.
Since decides its language using space , and thus (as argued) halts within steps on every branch if it halts at all, setting and checking `CANREACH(c_start, c_accept, T)` for every valid accepting configuration correctly decides whether some accepting branch exists — which is precisely acceptance by a nondeterministic machine.
Time cost of the simulation. Savitch's construction is space-efficient but time-inefficient: the recursion tree has levels and branches into (up to) choices of midpoint at each level, giving a running time on the order of — quasi-polynomial blow-up compared to what a direct simulation might achieve if unlimited space were available. This is the fundamental time–space tradeoff: Savitch buys enormous space savings at the cost of time, which is acceptable in PSPACE since only space is bounded.
PSPACE and the other classes. The chain
holds for concrete, provable reasons:
- : any deterministic machine is trivially a (degenerate) nondeterministic one.
- : a nondeterministic polynomial-time machine uses at most polynomial space (it cannot write more cells than it has time steps), so by Savitch.
- : as noted, a machine using space runs for at most steps before it must repeat a configuration (else it loops forever, contradicting that it decides a language), so polynomial space implies at most exponential time.
By the <span class="wiki-link-missing">Time Hierarchy Theorem</span> applied at the top and bottom of this chain, it is known that (strictly), which forces at least one of the inclusions above to be strict. However, it remains a major open problem whether , whether , or whether individually — only the combined chain is provably non-collapsing somewhere.
Closure properties. PSPACE is closed under complement, union, intersection, concatenation, and Kleene star. Complementation is the easy and instructive case: given a machine deciding in space , swap its accept and reject states to decide the complement in the same space bound — there is no blow-up, unlike the open question of whether NP is closed under complement (co-NP vs NP). This asymmetry is itself a clue that space and time behave very differently as resources.
Honest tradeoffs. PSPACE algorithms can be devastatingly slow in practice — Savitch's simulation and typical PSPACE-complete algorithms (e.g., minimax game-tree search with limited memoization) may take exponential time even though they use only polynomial memory. PSPACE membership is a statement about memory-feasibility, not time-feasibility; a problem being "in PSPACE" is no guarantee of a practical algorithm.
Worked example
Consider a toy nondeterministic machine over a binary work tape of length (so configurations are tiny, for illustration), deciding whether some path leads from configuration `000` to configuration `111` using its guessed transitions, within steps. Suppose the transition possibilities (nondeterministic, from tape contents alone, ignoring head/state detail for simplicity) are:
| From | Can go to (one step) |
|---|---|
| `000` | `001`, `010` |
| `001` | `011` |
| `010` | `110` |
| `011` | `111` |
| `110` | `111` |
We trace `CANREACH(000, 111, 4)`:
| Call | t | Splits into | Result |
|---|---|---|---|
| `CANREACH(000,111,4)` | 4 | try mid = `001`: `CANREACH(000,001,2)` and `CANREACH(001,111,2)` | testing... |
| `CANREACH(000,001,2)` | 2 | try mid=`001`: `CANREACH(000,001,1)`✓ (direct edge) and `CANREACH(001,001,1)`✓ (t=1 allows staying via 0 or 1 steps, equality holds) | true |
| `CANREACH(001,111,2)` | 2 | try mid=`011`: `CANREACH(001,011,1)`✓ (direct edge) and `CANREACH(011,111,1)`✓ (direct edge) | true |
| `CANREACH(000,111,4)` | 4 | both halves true via mid=`001` (outer), inner mid=`011` | true — ACCEPT |
Notice the algorithm never needed to store the whole path `000 → 001 → 011 → 111`; at any moment it only remembers the current pair of endpoints and the trial midpoint, one triple per level of recursion — three small configurations, not an exponential fan-out of paths. Even though there were two "wrong" choices available at `000` (going to `010` instead) that would have wasted a recursive attempt before backtracking, that wasted branch is discarded and its space reused, costing extra time but never extra space. This is the tradeoff in miniature: the algorithm may try the `010` branch first, fail to find a length-4 path to `111` through it (`010`→`110`→`111` is only length 2, and reachability search would confirm or refute this within the same space budget), and then backtrack to try `001` — all using the same constant-size stack frames.
Common pitfalls & traps
| Pitfall | Why it's wrong |
|---|---|
| Thinking PSPACE bounds time as well as space | PSPACE only restricts memory; algorithms can (and often do) run in exponential time while using only polynomial space. |
| Assuming Savitch's Theorem is "free" | The quadratic space blow-up is real, and the time cost of the simulation is exponential — there is no time efficiency guarantee. |
| Confusing NPSPACE with "NP but more space" | NPSPACE is defined by nondeterministic machines with a space bound on every branch, not by branching factor of guesses; it collapses to PSPACE, unlike NP vs P. |
| Believing PSPACE = NPSPACE implies P = NP | Space and time behave completely differently; the collapse for space gives no information about the time-based P vs NP question. |
| Forgetting the halting/looping argument for space-bounded machines | A machine that uses space but doesn't explicitly halt could loop forever revisiting the same configurations; deciders must be built to detect or avoid this, e.g. via a step counter within the space bound or standard configuration-graph reachability arguments. |
| Treating configuration count as exactly | The correct bound also includes polynomial factors for head positions and states: , still but not literally . |
:::warning[The single most dangerous confusion is equating "polynomial space" with "polynomial time." A PSPACE algorithm (including Savitch's own simulation) can legitimately run in exponential time — PSPACE membership says nothing about practical runtime, and treating a PSPACE-complete problem as "efficiently solvable" because it's "just polynomial" is a serious conceptual error.]:::
Pioneers & history
Origins · 1 minWalter J. Savitch and how this was discovered
Walter Savitch proved the theorem bearing his name while studying the relative power of deterministic and nondeterministic space-bounded computation, building on earlier work formalizing space complexity by Hartmanis, Lewis, and Stearns. His 1970 result that remains one of the cleanest and most surprising simulation results in complexity theory — a stark contrast to the still-open analogous question for time.
Origins · 1 minhow this was discovered
Where this matters
PSPACE is the natural home for problems involving unbounded-depth game trees and quantified logical reasoning. Two-player perfect-information games with polynomially describable positions but unbounded game length — generalized versions of Geography, Hex, and Checkers on boards — are typically PSPACE-complete, meaning solving them optimally is believed to require essentially exhaustive game-tree search, bounded only by the memory needed to track the current line of play. This directly informs the design of AI game engines: the reason chess and Go engines rely on heuristic evaluation and pruning (like alpha-beta search or Monte Carlo tree search) rather than exact minimax to full depth is that exact solutions to generalized game problems are PSPACE-hard, and no known algorithm solves them in polynomial time. In formal verification and model checking, PSPACE captures the complexity of checking properties expressed in temporal and quantified logics over finite-state systems; tools that verify hardware or protocol correctness against specifications in linear temporal logic confront PSPACE-complete satisfiability problems as a core subroutine. In automated planning (as used in robotics and AI planning systems), determining whether a goal is reachable under a polynomially describable but combinatorially vast action space is frequently PSPACE-complete. The theoretical study of regular expressions with squaring and certain database query languages also lands squarely in PSPACE, connecting the class to practical questions in formal language theory and query optimization. Understanding PSPACE — and the looming shadow of Savitch's Theorem behind it — is essential background for the deeper study of PSPACE-Completeness and problems like the quantified Boolean formula problem that anchor the class.
Ask the tutor: Why does Savitch's Theorem not imply a similar collapse for time-bounded classes like P and NP?
Is PSPACE the same as EXPTIME?
They are not known to be equal, but PSPACE ⊆ EXPTIME is provable: any machine using polynomial space can run for at most steps before repeating a configuration, which is exponential time. Whether this inclusion is strict is open, though we do know by the time hierarchy theorem, which forces at least one inclusion in the chain P ⊆ NP ⊆ PSPACE ⊆ EXPTIME to be strict. Most researchers believe PSPACE is strictly smaller than EXPTIME, based on the intuition that unlimited time is a fundamentally stronger resource than polynomial-bounded memory, but no proof exists.
Does PSPACE = NPSPACE mean P = NP?
No — this is one of the most common confusions in the subject. Savitch's Theorem is a statement purely about space, showing that a nondeterministic space-bounded machine can be simulated deterministically with only a quadratic increase in memory. The P vs NP question is about time, where no analogous simulation is known; simulating a nondeterministic time-bounded machine deterministically seems to require exponentially more time (via brute-force branch enumeration), not merely a polynomial increase. Space and time are fundamentally different resources: space can be reused across branches of a computation, but time, once spent, cannot be "rewound," which is precisely why Savitch's trick works for space but has no time analogue.
What is a PSPACE-complete problem, informally?
A problem is PSPACE-complete if it is in PSPACE and every other PSPACE problem can be reduced to it in polynomial time — making it, in a precise sense, "as hard as anything in PSPACE." The canonical example is TQBF (True Quantified Boolean Formula), which asks whether a fully quantified Boolean formula with alternating and quantifiers is true. Many two-player game problems, when generalized to arbitrary board sizes, are also PSPACE-complete, because determining the winner requires reasoning through an unbounded-depth alternating "if I move here, then for all opponent responses..." structure — mirroring quantifier alternation. This connection is explored fully under PSPACE-completeness.
Can a PSPACE algorithm still be practically useful despite exponential time?
Sometimes, but with real caveats. Many PSPACE algorithms, including Savitch's simulation, exhibit exponential runtime, so "in PSPACE" is not a promise of practical efficiency — it is purely a promise about memory feasibility. In practice, PSPACE-complete problems like optimal game-tree evaluation are tackled with heuristics, pruning, bounded-depth search, or approximation rather than exact algorithms, precisely because exact PSPACE algorithms scale exponentially in time. The class is theoretically important for classifying difficulty and understanding what memory alone can achieve, but engineers rarely run textbook PSPACE algorithms directly on large inputs.
Why does space allow reuse in a way time does not?
A Turing machine's tape is a physical resource that can be overwritten: once a subroutine finishes using a block of tape cells, those cells can be repurposed for the next subroutine, exactly as a recursive function's stack frame is freed after it returns. Time has no such reuse — each step of computation happens once and is gone, so if you need to explore many branches, you must spend time proportional to the total work across all branches, not just the peak amount at any one moment. This asymmetry is exactly why Savitch's Theorem could collapse NPSPACE into PSPACE at only a quadratic memory cost, while the analogous question of collapsing NTIME into deterministic time (the P vs NP question) remains stubbornly open.
How does PSPACE relate to problems with quantifier alternation?
There is a deep and precise correspondence: PSPACE is exactly the class of languages expressible by formulas with a polynomial (but unbounded) number of alternating existential and universal quantifiers over polynomial-size objects, as formalized by the TQBF problem. Intuitively, each quantifier alternation corresponds to one more level of a game tree — "does there exist a move such that for all opponent responses, there exists a counter-move such that..." — and PSPACE captures exactly the resources needed to evaluate such alternating structures when the number of alternations can grow with input size (in contrast, NP captures only a fixed, constant number of alternations, i.e., a single ).
What role does Savitch's Theorem play in the broader space complexity hierarchy?
Savitch's Theorem is not limited to polynomial space — it holds for any space bound , giving in general. This means it also shows, for instance, that nondeterministic logarithmic space (NL) is contained in , a result used throughout the study of space complexity below the polynomial level. The theorem is one of the master tools relating deterministic and nondeterministic space classes at every scale, not just the PSPACE = NPSPACE identity, making it foundational for the entire space-complexity hierarchy leading up to and including PSPACE.