If P ≠ NP there are problems that are neither easy nor complete. Graph isomorphism and factoring live in that twilight, and above NP a tower of harder classes rises
“Easy” and “NP-complete” are not the only possibilities. If P ≠ NP, there must be problems in NP that are neither, and two famous candidates, graph isomorphism and factoring, have resisted classification for fifty years. And NP itself is only the first floor of a much taller building, whose floors nobody has managed to prove are different.
Are these two graphs the same graph drawn differently? Press Replay to recolour them round by round, then try the hexagon against two triangles, where the recolouring sees nothing and a search has to take over.
A vertex’s fill is its current colour class; an indigo ring marks a vertex the search has individualised. In the histogram each colour has two bars, left graph then right, with the two counts underneath. Drag vertices to untangle a drawing by hand. Graphs here have at most 10 vertices, so everything finishes instantly; that is evidence about small graphs only. Refinement alone settles almost every large random graph (ties are commoner at this size: press New instance a few times on the first preset), and the pairs that defeat it are rare and highly symmetric.
Graph Isomorphism is in NP: the certificate is the matching of vertices, and checking it means looking up each edge once. But in half a century nobody has shown it to be in P, and nobody has shown it to be NP-complete. There is evidence against the second: if Graph Isomorphism were NP-complete, the polynomial hierarchy would collapse to its second level (Boppana, Håstad and Zachos, 1987; Schöning), which most researchers believe does not happen. On the other side, László Babai announced in 2015 an algorithm running in quasi-polynomial time, exp((log n)c) for a constant c, the first improvement on the general problem in over thirty years. In 2017 Harald Helfgott found an error in the analysis; Babai repaired it within days. Quasi-polynomial is far below the exponential times believed necessary for NP-complete problems, and still above polynomial.
The recolouring in this demo is colour refinement, the one-dimensional Weisfeiler–Leman algorithm (1968). It never looks at vertex names, so isomorphic graphs always produce equal histograms, and unequal histograms are a proof of non-isomorphism. Babai, Erdős and Selkow (1980) showed that it gives almost every graph a colouring in which all vertices differ, so for random graphs the problem is easy. Its blindness on regular graphs is real, and the fallback shown here, individualise a vertex, refine, and backtrack, is the skeleton of the practical isomorphism programs in use today. Their worst cases are rare, highly symmetric graphs.
That there is a twilight zone at all, assuming P ≠ NP, is a theorem. Ladner (1975) proved that if P ≠ NP then NP contains problems that are neither in P nor NP-complete. The problems his proof builds are artificial, stitched together to dodge every polynomial-time algorithm and every reduction in turn. The interest of Graph Isomorphism and of integer factoring is that they are natural problems that might live there. Nothing is proved either way: either could still turn out to be in P. See also: Secrets and One-Way Functions, for factoring.
Pick a side and play: ∃ wants every clause true, ∀ wants one false. Then press Play the search and compare its two counters, and drag the alternations slider down to zero to land back in NP.
Violet is ∃, teal is ∀. In the tree an ∃ level is an OR of its two children and a ∀ level an AND; a node is emerald once it is known to be true and rose once false; the sky path is the stack; the dashed amber path is the game you are playing. The class shown is for this shape of prefix around an arbitrary formula: with only a fixed number of alternations the question sits in the polynomial hierarchy, and with as many as there are variables it is PSPACE-complete. This toy has at most 6 variables and writes φ as clauses, which makes a final ∀ block easy to remove (just delete its literals), so the hard cases end in ∃. With early stopping off the search visits all 2n+1 − 1 nodes; either way, counts on trees this small show the shape of the growth and prove nothing about large n.
A sentence ∃x1 ∀x2 ∃x3 … φ is true exactly when the ∃-player has a winning strategy in the game above. Deciding that is the problem TQBF, true quantified Boolean formulas, and it is PSPACE-complete (Stockmeyer and Meyer, 1973). PSPACE is the class of problems solvable with a polynomial amount of memory and no limit on time. The depth-first search in the demo shows why TQBF is in it: the search visits up to 2n+1 − 1 nodes, but at any moment it remembers only the path from the root, one value per variable. When it backs out of a branch it reuses that memory for the next one. Space can be reused; time cannot.
Restricting the number of alternations gives the polynomial hierarchy (Meyer and Stockmeyer, 1972). With only ∃ the question is satisfiability, in NP. With only ∀ it is a co-NP question. One alternation, ∃∀, is the second level Σ2, and ∀∃ is Π2; k blocks give level k. “Does White have a move such that for every reply there is a move such that …” is the hierarchy’s natural language. These statements are about a prefix around an arbitrary Boolean formula. The demo writes φ as clauses, and then a final ∀ block can be eliminated by deleting its literals, so the genuinely hard sentences in clause form end with ∃.
What is proved: P ⊆ NP ⊆ PH ⊆ PSPACE ⊆ EXP, and P ≠ EXP by the time hierarchy theorem. So at least one of those inclusions is strict, and nobody can say which. Savitch’s theorem (1970) shows that nondeterminism adds nothing to polynomial space: a guessing machine with polynomial memory can be simulated by an ordinary one with only the square of that memory, the opposite of what is believed about time.
Games are where these classes show up in the wild. A generalised board game whose length is bounded by a polynomial in the board size is typically PSPACE-complete; Generalised Geography is the standard example (Schaefer, 1978). When play can go on for exponentially many moves the game is typically EXP-complete, as generalised chess on an n × n board is (Fraenkel and Lichtenstein, 1981). Since P ≠ EXP, that last problem provably has no polynomial-time algorithm, a statement nobody can yet make about any problem in NP.
Tap a class to see what lives there, and a rose chip to see one of the few separations anyone has proved. Then switch on P = NP and watch what it drags down with it.
Problems whose yes answers have certificates checkable in polynomial time.
Lives here: 3-SAT, which is NP-complete: a satisfying assignment is the certificate.
Known: NP ≠ NEXP by the nondeterministic time hierarchy theorem. NP versus P, co-NP, PSPACE and EXP: all open.
P ≠ EXP by the time hierarchy theorem (Hartmanis and Stearns, 1965): more time solves strictly more problems. So on every route up the rose lines at least one inclusion is strict. For no single line is it known to be that one.
Smaller classes are lower; a grey line means the lower class is contained in the upper one, and every such line is a theorem. Rose marks a proved separation and the lines it must run through. Dashed indigo is a hypothesis, dotted indigo an inclusion derived from it, and a coloured band joins classes that the hypotheses force to be equal. The engine knows the 22 inclusions, complementation, the 4 separations and 5 conditional theorems (two collapse theorems, Karp–Lipton with Adleman, Ko, and padding). It computes consequences from those alone, so classes it leaves apart are not thereby shown to differ, and it may miss consequences that other theorems would give.
Every line in the diagram is a theorem, and most are easy. What is hard is showing that any line is strict. The only separations known come from the hierarchy theorems of the 1960s and 1970s, which say that substantially more of the same resource solves more problems: more time (Hartmanis and Stearns, 1965), more space (Stearns, Hartmanis and Lewis, 1965), more nondeterministic time (Cook, 1972). They separate P from EXP, NL from PSPACE, and NP from NEXP. They compare a resource with itself, and say nothing about time against space or guessing against computing. Between P and PSPACE not a single separation is known.
A handful of surprising equalities are known too: nondeterministic space is no stronger than deterministic space up to squaring (Savitch, 1970); NL is closed under complement (Immerman and Szelepcsényi, independently, 1987); interactive proofs capture exactly PSPACE (Shamir, 1990; see also Proofs as Conversations); and the whole polynomial hierarchy is contained in polynomial time with a counting oracle, P#P (Toda, 1991).
In place of proofs, the field uses a yardstick: the belief that the polynomial hierarchy has infinitely many distinct levels. “X would collapse the hierarchy” is how a complexity theorist says “X is probably false”. The engine in the demo derives such collapses from a few theorems: if NP = co-NP every level falls to NP; if P = NP every level falls to P, and by padding EXP = NEXP as well; if NP ⊆ BPP the hierarchy falls to its second level (Karp and Lipton, 1980, with Adleman, 1978) and NP = RP (Ko, 1982). None of these consequences is a contradiction. They are reasons for disbelief, not proofs.
Two classes sit awkwardly. BPP, randomised polynomial time, is inside Σ2 ∩ Π2 (Sipser, Gács and Lautemann, 1983) and is widely conjectured to equal P, yet its relation to NP is unknown in both directions. BQP, quantum polynomial time, contains BPP and sits inside PSPACE (Bernstein and Vazirani, 1993); it is not known to contain NP, and is not believed to, and it is not known to be contained in NP or anywhere in the hierarchy either. See also: Does Randomness Help? and Would a Quantum Computer Help?
Spot a mistake or have an idea?