Suppose it were true. Finding a proof would be as easy as checking one, and every optimisation problem would yield. Or would it — at n to the hundredth power?
Suppose someone proved P = NP tomorrow, with an algorithm you could run. What would actually change? Perhaps everything: any proof that can be checked could be found. Or perhaps nothing you would notice, because “polynomial” is not the same as “fast”. Most researchers believe P ≠ NP, so everything on this page is a hypothetical, not a prediction.
Pick a theorem and watch the searcher try every proof until one works, then watch the checker verify it line by line. Tap a symbol in the proof to corrupt it and see where the checker stops.
Waiting for the searcher to hand over a proof…
The system is the MIU puzzle from Douglas Hofstadter’s Gödel, Escher, Bach: one axiom, MI, and four rules (rule 1: xI → xIU; rule 2: Mx → Mxx; rule 3: xIIIy → xUy; rule 4: xUUy → xy). To keep the search finite a line may be at most 24 symbols long, and the searcher stops at 12 steps. Tap any I or U in the proof to change it and the sky ticks stop at the line that no longer follows. Each row of the tree holds the lines first reached by proofs of that length (rose; a sample when there are too many to draw); the amber path is the proof found, and the faint rose curve on the chart is the same search carried to 12 steps. A dozen steps of a toy system show a trend and prove nothing about large n.
In a formal system a proof is a list of lines, each following from earlier ones by a fixed rule. Checking one takes no insight: redo each step and compare. Finding one is the part mathematicians are for. The question “does this statement have a proof at most n symbols long?” is in NP for any reasonable system, because a proof that short is a certificate that can be checked in time polynomial in n. If P = NP, that question has a polynomial-time algorithm, and with it a way to construct the proof.
Kurt Gödel asked exactly this in a letter to John von Neumann dated 20 March 1956, fifteen years before the question was formally posed. He asked how many steps a machine needs to decide whether a formula has a proof of length n, and remarked that if the number grew only like n or n2, then, in a common English translation, “the mental work of a mathematician concerning Yes-or-No questions could be completely replaced by a machine”. Von Neumann was dying and the letter went unanswered. It became widely known only in the late 1980s.
This is the sense in which P versus NP is sometimes called the problem about all the others. The Clay Mathematics Institute lists it beside six other Millennium problems, and each of those is a statement whose proof, if it has one short enough to write down, could in principle be found by such an algorithm.
Two caveats carry most of the weight. The algorithm finds only proofs of feasible length; a theorem whose shortest proof is astronomically long stays out of reach. And it helps only if it is practical, which a proof of P = NP need not deliver. The next demo is about that. The demo above is a toy on purpose: a puzzle system with four rules, a page 24 symbols wide and proofs of at most 12 steps. Its exponential curve is what one search strategy does on small cases, not a theorem about proof search.
Slide the backtracking solver later in the list and watch the cost of running every program at once double with each place. Then set the exponent of a polynomial and see where it finally beats an exponential.
The formula is a random 3-SAT instance with 40 variables and 160 clauses, built round a hidden solution so that it is satisfiable. A step is one variable set, one flip or one printed guess. Thick bars are steps given to each program on a log scale, so equal drops from lane to lane are equal halvings; indigo bars are the programs that genuinely search, grey ones only fill the list, and the thin teal line counts the answers each program printed, all of them checked. The lower chart collects the total for every place you have tried (emerald dots, amber for the current one) against the guarantee in rose. A dozen hand-picked strategies stand in for the list of all programs; the real list is infinite and almost all of it is rubbish.
Sky is the polynomial c·nk, rose the exponential; both axes are logarithmic, so the polynomial is a straight line of slope k. The rose band is where the exponential algorithm is the faster of the two. Times assume a billion operations a second and take the universe to be 13.8 billion years old. An algorithm that is polynomial on paper and useless at every feasible size is sometimes called galactic.
Leonid Levin’s 1973 paper, the one that introduced NP-completeness independently of Stephen Cook, also contained universal search. List every program. Run them all, giving the i-th a share 2−i of the time, and check whatever any of them prints. If some program finds satisfying assignments in time T, this procedure finds them in about 2i · T plus the cost of checking. So it is optimal, up to a constant factor, for any problem whose solutions can be checked quickly, and in particular: if P = NP, then universal search already finds satisfying assignments in polynomial time whenever one exists. We may possess the fastest algorithm without knowing how fast it is. It is also useless, because the constant is 2 to the length of the best program.
A proof of P = NP could disappoint in other ways. It might be non-constructive, showing that an algorithm exists without exhibiting it. There is a precedent: the theory of graph minors developed by Neil Robertson and Paul Seymour proves that polynomial-time algorithms exist for certain graph problems without always saying what they are. Or the proof might give an algorithm whose exponent is in the hundreds. Donald Knuth has said that he suspects P = NP for this sort of reason, and that it would have no practical consequence.
The reverse also holds. A proof of P ≠ NP would not make hard instances common. Modern SAT solvers routinely dispatch industrial formulas with millions of variables, even though satisfiability is NP-complete, because the instances that arise in practice are far from the worst case. The asymptotic question and the practical question are different questions.
The list of twelve strategies in the demo is a stand-in. A real enumeration runs through every program text in order of length, almost all of them rubbish, and a useful solver appears only after about 2 to the power of its length in bits. See also: Searching Smarter in the Computational Complexity module for the solvers themselves.
Tap inputs to reveal their labels and watch the smallest formula that fits them change. Draw examples one at a time until it snaps to the hidden rule, then try parity.
Each cell is one input, written x₁x₂x₃x₄. Emerald and rose cells are labelled examples (1 and 0); dashed amber cells are unseen, showing what the smallest formula predicts. Size is the number of two-input AND and OR gates in a formula, with NOT free; when several consistent functions tie for smallest, the one the census reached first is used. Majority of 4 means at least 3 of 4. The curve averages 300 random orders of the 16 examples. Four inputs is a toy: real learning problems have far too many functions to list, which is the whole point.
That short explanations generalise is a theorem as well as a habit. Anselm Blumer, Andrzej Ehrenfeucht, David Haussler and Manfred Warmuth proved in 1987 that a hypothesis which is consistent with enough random examples, and which is short compared with the number of examples, is probably close to the truth on new ones. Finding a short consistent hypothesis is a search problem in NP. So if P = NP, anything learnable at all in this sense would be learnable efficiently.
The question behind the demo, whether a given truth table has a circuit of at most s gates, is the minimum circuit size problem. It is in NP, since a small circuit can be checked against the table. Whether it is NP-complete has been open for decades, and it sits at the centre of current research on meta-complexity, the complexity of questions about complexity. See also: The State of Play.
What do researchers expect? William Gasarch polled theorists three times. The share answering that P ≠ NP was 61% in 2002, 83% in 2012 and 88% in 2019.
A poll measures belief, and none of these numbers is evidence about the answer. The board in the demo sorts the usual claims about P = NP by what they need: a few are theorems, most depend on the algorithm being practical, and some would not follow at all.
Spot a mistake or have an idea?