Computational Complexity Theory
This document collects the basic definitions of computational complexity theory: models of computation, decision problems, asymptotic notation, the standard time and space complexity classes, reductions, and the elementary completeness and hierarchy results. It is a self-contained reference; for a real treatment see Sipser, Introduction to the Theory of Computation; Arora & Barak, Computational Complexity: A Modern Approach; Papadimitriou, Computational Complexity.
Unlike the other math notes in this folder, complexity theory is independent of the topology / group-theory / Clifford-algebra chain — it can be read on its own.
1. Models of Computation
1.1 Turing machines
A (deterministic, one-tape) Turing machine is a tuple where
- is a finite set of states,
- is the input alphabet, the tape alphabet (with blank ),
- is the transition function,
- is the start state, and are the accepting / rejecting halt states.
On input , starts in state with written on the tape and the head at the leftmost cell. At each step it reads the current cell, writes a new symbol, moves the head left or right, and transitions to a new state according to . halts when it enters (accepts) or (rejects). The running time is the number of steps before halting; the space is the number of distinct tape cells visited.
Variants — multi-tape machines, two-way tapes, RAM machines, -calculus, etc. — all simulate one another with at most polynomial overhead, so the class of polynomial-time problems is robust under choice of model. This is the invariance thesis (a stronger, machine-relative form of the Church–Turing thesis).
1.2 Nondeterministic Turing machines
A nondeterministic Turing machine (NTM) replaces with a relation : from a given configuration there may be several legal next moves. An NTM accepts if some sequence of nondeterministic choices leads to . The running time is the length of the shortest accepting computation (or, on rejection, the maximum over all branches).
Equivalent formulations:
- a deterministic verifier that checks a certificate (witness) of length polynomial in ,
- a deterministic machine equipped with a "guess" oracle.
Nondeterminism is not a physical model — no known device computes faster by branching exponentially — but it is the cleanest mathematical handle on search problems.
1.3 Other models
- Boolean circuits: families of acyclic directed graphs over with input wires; gives non-uniform complexity (one circuit per input length). See § 8.
- Randomized Turing machines: has access to fair coin flips; the machine accepts with some probability. See § 7.
- Quantum Turing machines / quantum circuits: unitary evolution on a Hilbert space of qubits, with measurement at the end. The associated class is — see the qcfront project for hands-on quantum computing.
2. Decision Problems, Languages, and Promise Problems
A language is a subset of strings over a finite alphabet (typically ). A decision problem is the question "given , is ?" Examples:
- ,
- ,
- .
A Turing machine decides if halts on every input and accepts exactly the strings in .
Function problems ("compute ") and search problems ("find a witness") are reducible to and from decision problems for the natural classes; we work with decision problems for cleanliness. A promise problem is a pair of disjoint sets, with the machine's behavior on unconstrained — useful for -style classes.
3. Asymptotic Notation
Let . Then
| Notation | Meaning | Intuition |
|---|---|---|
| such that for | grows no faster than | |
| such that for | grows at least as fast as | |
| and | and grow at the same rate | |
| grows strictly slower than | ||
| grows strictly faster than |
The "" in "" is conventional abuse of notation; it really means (a set).
Polynomial / exponential growth. " is polynomial" means for some constant . " is exponential" usually means for some ; "polylogarithmic" means . The catch-all denotes any polynomial in .
4. Time and Space Complexity Classes
For a function , define
For space, the input is on a read-only tape and only the work tape is counted (this is what makes sublinear-space classes meaningful).
4.1 The standard classes
| Class | Definition | Informal |
|---|---|---|
| logarithmic-space | ||
| nondet. log-space | ||
| tractable — solvable in polynomial time | ||
| poly-time verifiable | ||
| poly-time refutable | ||
| polynomial space (= , by Savitch) | ||
| exponential time | ||
| nondet. exponential time | ||
| exponential space | ||
| decidable by some TM | the decidable (recursive) languages | |
| accepted (but not necessarily decided) by some TM | recursively enumerable |
The Cobham–Edmonds thesis identifies with the feasibly computable problems — a reasonable working hypothesis, although large constants and exponents can defeat polynomial running times in practice.
4.2 NP via verifiers
Equivalent definition of : iff there exist a deterministic polynomial-time machine (the verifier) and a polynomial such that
The witness is a certificate for . This is the operational definition usually used in practice: showing amounts to exhibiting a short, efficiently-checkable proof of membership.
5. Inclusions and Separations
The following inclusions are unconditional:
Known to be proper: , , , (all follow from the hierarchy theorems, § 9). It is therefore known that at least one of the inclusions is strict — we just don't know which one(s).
Open (the headliners):
- — the central open problem of theoretical CS; a Clay Millennium Prize Problem.
- .
- , .
- .
Two structural theorems worth remembering:
- Savitch's theorem (1970): for . Consequence: , — nondeterminism gives at most a quadratic space saving.
- Immerman–Szelepcsényi theorem (1987–88): for . In particular — nondeterministic space classes are closed under complement, in striking contrast to the conjectured .
6. Reductions and Completeness
To compare difficulty across problems we use reductions.
6.1 Polynomial-time many-one (Karp) reductions
iff there exists a polynomial-time computable function such that
In words: instances are translated to equivalent instances. If and , then . is reflexive and transitive.
6.2 Polynomial-time Turing (Cook) reductions
iff is decidable in polynomial time by a Turing machine with oracle access to (a constant-time membership query for ). Cook reductions are at least as powerful as Karp reductions (every Karp reduction is a one-query Cook reduction). The distinction matters for asymmetric classes like vs — Karp reductions preserve "yes-instances of " while Cook reductions need not.
6.3 Completeness
For a class and a reduction ,
- is -hard (under ) if every satisfies .
- is -complete if it is -hard and .
A -complete problem is "the hardest problem in ": placing it in any sub-class (closed under the reduction) would collapse .
6.4 The Cook–Levin theorem and NP-completeness
Cook–Levin theorem (1971, independently Levin): is -complete under polynomial-time many-one reductions. The proof encodes the computation tableau of an arbitrary polynomial-time NTM as a Boolean formula whose satisfying assignments correspond to accepting computations.
Karp (1972) used this as a seed to show -completeness of 21 natural problems, and the list has since grown to thousands. A small sampler:
| Problem | What it asks |
|---|---|
| / | satisfiability of Boolean (3-CNF) formulas |
| does contain a -clique? | |
| does have a vertex cover of size ? | |
| does have an independent set of size ? | |
| , | Hamiltonian path / travelling salesman (decision) |
| does some subset of sum to ? | |
| can be properly 3-colored? | |
| feasibility of over |
Practical upshot: if you can reduce one of these to your problem, your problem is at least as hard as , and (assuming ) admits no polynomial-time algorithm.
6.5 Completeness for other classes
| Class | A canonical complete problem | Under |
|---|---|---|
| (directed - connectivity) | log-space reductions | |
| log-space reductions | ||
| (Boolean tautologies) | Karp reductions | |
| (true quantified Boolean formulas) | Karp reductions | |
| "does this NTM accept in steps?" | Karp reductions |
7. The Polynomial Hierarchy
Generalize (one existential quantifier over a poly-bounded witness) and (one universal) by allowing alternations:
where denotes class with oracle access to . Equivalently, iff there exists a poly-time predicate and a polynomial such that
with and for odd, for even. The union
is the polynomial hierarchy. We have ; whether the hierarchy is infinite or collapses at some level is open. Collapses propagate upward: if for any , then . In particular would collapse the entire hierarchy to .
8. Randomized and Non-Uniform Classes
8.1 Randomized polynomial time
A probabilistic Turing machine runs in polynomial time and has access to random bits.
| Class | Acceptance criterion |
|---|---|
| ; | |
| ; | |
| on every input (two-sided error) | |
| expected polynomial time, always correct | |
| (unbounded error) |
The probability gap is amplified by repetition: a polynomial number of independent trials drives the error to (Chernoff bound). Inclusions: ; also (Sipser–Gács–Lautemann). It is widely conjectured (and supported by derandomization results based on circuit lower bounds) that .
8.2 Boolean circuits and
A circuit family decides if has inputs and for all . The complexity of a family is measured by size (gate count) and depth (longest input-to-output path).
- : languages decided by polynomial-size circuit families (no uniformity required). , and (Adleman). But contains undecidable languages — non-uniformity is genuinely more powerful.
- : poly-size, depth , unbounded-fan-in gates.
- : poly-size, depth , bounded-fan-in gates. is "efficiently parallelizable".
- Chain: .
The conjecture would imply , and is the basis for the circuit-lower-bound approach to separation. (Karp–Lipton: if , then .)
8.3 Quantum polynomial time
is the class of languages decided with bounded error by a polynomial-size family of uniform quantum circuits. Known: ; relationship of to is open. Shor's factoring algorithm places in ; this is conjectured to be outside but not known to be -complete. See misc/quantum-complexity-theory.md for the full quantum-complexity story (models of quantum computation, / / , oracle separations, local Hamiltonian completeness) and qcfront for hands-on quantum-computing code.
9. Hierarchy Theorems
The hierarchy theorems formalize "more resource = more power". A function is time-constructible if some TM, given input , outputs in time ; space-constructible is the analogous notion for space. All "reasonable" functions (, , , …) are constructible.
Time hierarchy theorem (Hartmanis–Stearns, 1965). If are time-constructible and , then
Space hierarchy theorem. If are space-constructible and (with ), then
Both proofs go via diagonalization: build a machine that, given , simulates on for steps (or cells) and flips the answer. Corollaries already used in § 5: , , .
These are essentially the only general-purpose tools known for proving lower bounds on uniform machines. Pure diagonalization cannot resolve — the relativization barrier (Baker–Gill–Solovay, 1975) shows that there exist oracles with and , so any proof technique that relativizes (as diagonalization does) cannot decide the question. Subsequent barriers — natural proofs (Razborov–Rudich, 1994) and algebrization (Aaronson–Wigderson, 2008) — rule out further large classes of techniques.
10. Beyond the Basics (Pointers)
A non-exhaustive map of where complexity theory goes from here:
- Approximation and hardness of approximation. Many -hard optimization problems admit good polynomial-time approximation algorithms; the PCP theorem (Arora–Lund–Motwani–Sudan–Szegedy, 1992–98) characterizes via probabilistically checkable proofs and gives tight inapproximability results.
- Interactive proofs. — languages decidable by a polynomial-time verifier interacting with an all-powerful prover — equals (Shamir, 1992). Multi-prover variants: .
- Average-case complexity (Levin, 1986): hardness against random instances, foundational for cryptography.
- Communication complexity, query complexity, proof complexity, fine-grained complexity (e.g. SETH-based lower bounds within ), descriptive complexity (Fagin's theorem: existential second-order logic).
- Cryptographic assumptions (one-way functions, trapdoor permutations, LWE) sit above in strength — they encode worst-case-to-average-case structure that is conjectured but unproved.
See Arora & Barak, Computational Complexity: A Modern Approach, for systematic treatments of all of the above.