Visual walkthrough — PSPACE — Quantified Boolean Formula
We assume you know only what a Boolean value is: a wire that is either 0 (false) or 1 (true). Everything else is built below.
Step 1 — Two symbols, two players
WHAT. We meet the only two "quantifier" symbols we ever need. is read "there exists a value of "; is read "for all values of ". A variable can only be or , so "all values" means the two-element set .
WHY these two and nothing else. Ordinary SAT only has the first one: "does some assignment work?" That is a single player hunting for one lucky choice. To model a contest, we need an opponent who is forced on us — a value we do not get to choose. is exactly that: whatever it picks, we must still win. So and are the minimal pair that turns a search into a two-player game.
PICTURE. Two boxes, one bit flowing out of each. The Prover's box has a happy "I only need one" tag; the Spoiler's has "I attack all of them".
Step 2 — A quantifier prefix is a sequence of moves
WHAT. Write the quantifiers in a row, then a plain Boolean formula at the end: Term by term: means Prover fixes first; means Spoiler then fixes knowing ; means Prover then fixes knowing both. is the referee — after all bits are set, it outputs one truth value.
WHY read left-to-right as time. Order encodes information. A later player has already seen the earlier picks. This is why and differ (Step 8): who-moves-first decides who-can-react.
WHY no free variables. Every is claimed by some quantifier, so nothing is left dangling. With no inputs, the whole thing collapses to a single true/false — there is nothing to plug in.
PICTURE. A turn-order timeline: alternating Prover/Spoiler tokens placed left to right, an arrow labelled "time / information", and the referee at the far right reading all the placed bits.
Step 3 — Unfold the moves into a game tree
WHAT. Each quantifier is a variable with two possible values, so it becomes a node with two children (the -branch and the -branch). Stacking the quantifiers stacks the levels. For variables we get a binary tree of depth with leaves; each leaf is one complete assignment, and stamps it or .
WHY a tree and not a list. The Spoiler's choice branches the future: after there are two possible worlds for , and we must survive both. A list can't hold "both futures at once"; a tree can. The tree is the space of all plays.
PICTURE. A depth-3 tree: level-1 an -node (blue), level-2 two -nodes (orange), level-3 four -nodes, and eight leaves each carrying a / from .
Step 4 — How each node combines its two children
WHAT. Give every node a value by folding its two children with one Boolean operation: Symbol by symbol: (OR) is if at least one input is — that is the Prover, who needs only one good branch. (AND) is only if both inputs are — that is the Spoiler, whom you must beat everywhere.
WHY OR for , AND for . Match the players' win-conditions from Step 1. "There exists a good child" is literally "child OR child". "Good for all children" is literally "child AND child". The logic connective is the quantifier, once the domain is .
PICTURE. One -node showing next to one -node showing , arrows pointing from children up into the parent with the operation labelled on the merge.
Step 5 — Walk a true formula:
WHAT. Evaluate leaves first, then fold upward. The referee is .
- subtree (): leaf ; leaf . Fold with : .
- subtree (): leaf ; leaf . Fold with : .
- Root is : fold with : . TRUE.
WHY it's true. The Prover ignores the losing world and commits to ; there the Spoiler is helpless because is already regardless of . One winning branch is all demands.
PICTURE. The depth-2 tree fully coloured: the subtree glows red (value ), the subtree green (value ), the root green with the winning edge thick.
Step 6 — Walk a false formula:
WHAT. Referee .
- subtree (): leaf ; leaf . Fold with : .
- The root is , an . As soon as one child is , we can stop: . FALSE.
WHY we stop early. = AND, and AND dies on a single . The Spoiler already found the killer move : no matter what the Prover then picks, . We never even expand the subtree — a first taste of not needing the whole tree in view.
PICTURE. Same tree; the subtree evaluated to red , the root stamped red , and the entire subtree drawn faded/greyed with a "not expanded — already lost" tag.
Step 7 — The key trick: reuse the same memory for both branches
WHAT. To fold a node we need two child values. But we don't need them simultaneously. Do the left branch fully; it returns a single bit; record that one bit; then erase the left branch's entire workspace and reuse it to compute the right branch; finally combine the two bits with or .
Here denotes the ==length of the formula == — how many symbols it takes to write down (variables, quantifiers, connectives). One stack frame stores the current variable, its quantifier, and a pointer into , all bounded by .
WHY this is the whole PSPACE result. The tree has leaves (Step 3) — that's the time. But memory only ever holds one root-to-current-node path plus a handful of returned bits. The path is length . So space grows one level at a time, not one leaf at a time: Term by term: = space to evaluate a formula with quantifiers; is the space its child (one fewer quantifier) needs; we add just one stack frame for the current variable; the recursion bottoms out at the referee , also . No factor of ever appears because the two subtrees share the same reused memory. Result: polynomial space, exponential time.
PICTURE. Left: the full tree faded, with a single bold path from root to a leaf highlighted (the "active memory"). A left subtree greyed with a small saved chip "bit = 1", the right subtree currently active. Caption: memory = one path, not one tree.
Step 8 — Degenerate & edge cases you must see
WHAT. Corner situations that could break intuition:
- All (this is SAT). Every node is an ; the whole tree is one giant OR over leaves — "does some assignment satisfy ?" Confirms .
- All . Every node is an ; the tree is one giant AND — "is a tautology?" (true on all inputs).
- Order matters. Compare with the swapped , still over . In the Prover picks after seeing , so it can copy () and win every time → TRUE. Swap to : now is fixed first; the Spoiler then picks the worst . No single satisfies for both and (try : gives ) → FALSE. The binary tree has the same branching shape both ways; only which player owns which level — i.e. the OR/AND labels on the nodes — flips, and that alone flips the verdict.
- Empty prefix. No quantifiers, constant. Depth-0 tree = a single leaf; just reads . Base case, cost .
WHY include these. They show the machinery is complete: pure-, pure-, mixed-and-order-sensitive, and the zero-variable base all fall out of the same fold-the-tree rule with no special casing.
PICTURE. Four mini-trees side by side: (a) all-blue OR-tree "SAT", (b) all-orange AND-tree "tautology", (c) two identically-shaped trees with swapped OR/AND labels and opposite truth values, (d) a lone leaf "empty prefix".
The one-picture summary
WHAT. One diagram compresses the derivation: prefix → tree → fold with OR/AND → one reused path → verdict. Time is the leaf-fan; space is the thin -long spine.
Recall Feynman retelling — say it back in plain words
Two players take turns setting bits: the Prover () who wants "true" and only needs one lucky line of play, and the Spoiler () who wants "false" and must be beaten on every line. Line them up left to right — that order is time, so a later mover has seen the earlier bits. Unfold all possible plays into a binary tree: each Prover node is an OR (one good child suffices), each Spoiler node is an AND (all children must be good). Evaluate the leaves with the referee formula, then fold upward. The formula is true exactly when the Prover has a winning strategy — a green root. The tree has leaves, so brute time is exponential — but to fold any node you only need its two children one at a time: compute the left, keep just its one-bit answer, wipe the workspace, compute the right in the same memory, combine. Memory therefore only ever holds a single root-to-leaf path of length , giving space. That single reused spine, riding under an exponential fan of leaves, is the whole reason .
Recall Self-test
folds children with which operation, and why? ::: OR — the Prover needs only one good branch. folds children with which operation, and why? ::: AND — the Spoiler must be beaten on every branch. Why is the space only despite leaves? ::: The two subtrees are computed one after another in the same reused memory, so depth (), not leaf count, sets the space. Does swapping the outer two quantifiers change the tree's shape? ::: No — same binary shape; only the OR/AND labels on the levels flip, which can flip the verdict. In over , is it true or false, and the swap? ::: True (Prover sets after seeing ); the swap is false.
Related: SAT and NP-completeness · Savitch's Theorem · PSPACE and Polynomial Space · Two-Player Games and Game Trees · NP vs PSPACE · Polynomial Hierarchy