Space and Parallel Complexity §
Where Computability and Complexity Classes asks how much time a computation needs, this page asks two related questions: how much memory does a computation need (space complexity), and how much can be parallelized (circuit depth)? The two are linked: a machine using little space has few configurations, so its computation can be laid out as a shallow circuit.
Authoritative sources
Space complexity classes §
A language is in SPACE() if a deterministic Turing machine decides it using at most tape cells on inputs of length ; NSPACE() is the nondeterministic analogue. The canonical classes are:
- L: deterministic space. Example: deciding whether a number is even, or comparing two positions in a list — only bits are needed to count.
- NL: nondeterministic space. Example: ST-CONNECTIVITY (is reachable from in a graph?) — a nondeterministic machine just guesses the path vertex by vertex, storing one vertex index ( bits) at a time. The Immerman–Szelepcsényi theorem (1987) shows : nondeterministic log-space can also certify unreachability.
- PSPACE: deterministic polynomial space. It contains NP and PH, since a polynomial-space machine can enumerate all certificates one at a time, reusing the same tape region. Canonical complete problem: TQBF (truth of quantified Boolean formulas).
- EXPSPACE: exponential space. By the space hierarchy theorem (below), it strictly contains PSPACE.
Details
The key counting fact: a machine with tape cells over a fixed alphabet, states, and one head has at most configurations. If it never repeats a configuration it must halt within that many steps, so a decider using space runs in at most time. This is why and why polynomial space is so powerful relative to polynomial time: space is reusable, time is not.
Space hierarchy theorem: for space-constructible (e.g. asymptotically), . The proof is a diagonalization: enumerate all -space machines, and on input simulate machine on input , doing the opposite — the extra space pays for the bookkeeping. Unlike the time hierarchy, this gives unconditional separations: L ⊊ PSPACE, for instance, is proven, whereas P ⊊ EXPTIME is the best unconditional time separation.
Example problem: show that ST-CONNECTIVITY is in NL.
Solution
A nondeterministic machine stores only the current vertex (initialized to ), using bits. At each step it nondeterministically guesses a neighbor of (scanning the adjacency list with an -bit counter), overwrites with , and repeats for at most steps (another -bit counter). It accepts if ever occurs. Every accepting branch traces a genuine path from to , and if a path exists some branch guesses it — so the language is decided in nondeterministic space, i.e. ST-CONNECTIVITY ∈ NL. (Savitch’s theorem further shows , so it is even in DSPACE().)
Circuit complexity and parallelism §
A Boolean circuit is a DAG of AND, OR, and NOT gates whose inputs are the input bits; its size is its gate count and its depth is the length of its longest path. Depth measures how much the computation can be parallelized: each layer of a depth- circuit is one parallel step.
- NC: languages decidable by poly-size, -depth circuits. NC = is the class of problems with fast (polylogarithmic-time) parallel algorithms on polynomially many processors.
- AC: constant-depth circuits with unbounded-fan-in AND/OR gates. The parity function is not in AC (Furst–Saxe–Sipser; Håstad’s switching lemma, 1987) — the first major unconditional lower bound.
- The NC hierarchy: . Whether NC = P (the “P = NC?” question) is the parallel-computation analogue of P vs NP: it asks whether every polynomial-time problem is efficiently parallelizable.
Details
Examples of NC computations: addition of two -bit numbers (carry-lookahead: each output bit is a function of inputs, computable by a tree of gates of depth ), and Boolean formula evaluation. Examples of NC: matrix multiplication ( depth with processors via associative reduction), determinant, and graph reachability. Problems believed not to be in NC include linear programming and circuit value evaluation (they are P-complete under log-space reductions: if any P-complete problem were in NC, then NC = P).
Example problem: show that computing the AND of bits is in NC.
Solution
Build a balanced binary tree of 2-input AND gates: gates, depth . Layer computes the AND of disjoint blocks of input bits; all gates in a layer are independent and can be evaluated in parallel. Size is (polynomial) and depth is , so the language (and generally the AND of the input bits) is in NC. The same tree pattern with OR gates, or with a comparator network, gives parallel OR, MAX, and sorting networks — the fundamental templates of parallel algorithms.
Quizz §
Quizz
Problem: Show that : every log-space decider runs in polynomial time.
Solution
A log-space machine on inputs of length has tape cells, states, and one head position among cells, so its number of distinct configurations is at most , which is polynomial in . A decider must halt on every input, and a machine that halts never repeats a configuration (otherwise it would loop forever); hence it halts within polynomially many steps. Since it also uses only space — and — the same machine witnesses membership in P.