← Student tools · Problem 34 · Lecture 13 · Round 3 (40 pts)

Savitch's theorem · the recursion tree

A nondeterministic f(n)-space machine can be simulated in O(f(n)²) deterministic space. The reason: an exponential tree with logarithmic depth.

CLO-4 · Mapping reduction Round 3 · 40 pts Lecture 13
🔊 Listen

Savitch's theorem (1970) is the single most surprising result in space complexity: nondeterminism is essentially free in polynomial space. The space classes P and NP have a long-standing gap (we believe P ≠ NP), but the space classes PSPACE and NPSPACE are equal.

This is the inverse of what one would expect. For TIME, a single nondeterministic step can replace exponentially many deterministic steps (that is exactly the P vs NP question). For SPACE, a clever recursion can simulate any nondeterministic choice with only a quadratic blowup.

Savitch's theorem (1970)

For any function f(n) ≥ log n: NSPACE(f(n)) ⊆ SPACE(f(n)2).

Consequence: PSPACE = NPSPACE. Nondeterminism saves no space (up to a polynomial).

🔊 Listen

A nondeterministic Turing machine N using f(n) space has at most 2O(f(n)) distinct configurations (state × tape contents × head position). So if N halts at all, it does so within that many steps.

The naive simulation — BFS over configurations — uses linear space in the number of reachable configurations, which is exponential. That breaks the bound. We need a smarter way.

Reformulate as reachability

CANYIELD(A, B, t) = "can config A reach config B in ≤ t steps?"

N accepts x ⇔ CANYIELD(Cstart(x), Caccept, 2O(f)) returns yes.

Now we have a clean recursive question. The trick is to recurse cleverly.

🔊 Listen

Savitch's insight: cut t in half by guessing a midpoint configuration M.

CANYIELD recursion

CANYIELD(A, B, t):
  if t = 1: return whether A = B or A → B in one step;
  for each candidate midpoint M (try all 2O(f) of them):
    if CANYIELD(A, M, t/2) AND CANYIELD(M, B, t/2): return yes;
  return no.

Critically, the two recursive calls run in sequence, not in parallel, reusing the same memory. The for-loop also reuses memory: the M slot holds one config at a time.

Resource Per recursion level Total
Recursion depthlog t = O(f)
Bits stored on stackO(f) (one config)O(f²)
Time (sequential)2 children × 2O(f) Ms(2O(f))log t = 2O(f²)

Space O(f²), Time 2O(f²). Wildly slow but space-efficient. The recursion tree below has exponentially many nodes, yet at any instant only a single root-to-leaf path sits on the stack.

🔊 Listen
Savitch's recursion · tree expansion Auto-plays
🔊 Listen

Suppose N uses n bits of tape. Then:

For n = 100: deterministic simulation uses roughly 10 000 bits of memory — but might run for 210 000 steps. Space matters, time does not (for this theorem).

🔊 Listen
🔊 Listen
  1. "Just try every config." That uses exponential space (the list of seen configs). The midpoint trick is what avoids it.
  2. "The tree has 2log t leaves, so it uses that much space." No — the tree has that many leaves, but only one path lives on the stack at a time.
  3. Confusing log t with t. log t = O(f), not O(2f). Logs of exponentials are linear.
  4. "Why doesn't this work for TIME?" Because both children must actually execute; their times add. log t × 2 child evaluations × loop over M = exponential time. Space, by contrast, gets reused.
  5. Forgetting the floor of log t. If t is not a power of 2, round t/2 to ⌈t/2⌉ for the first half and ⌊t/2⌋ for the second. Doesn't affect asymptotics.
🔊 Listen
🔊 Listen

Total time: 12 minutes.