If P Equals NP

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?

If P Equals NP

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.

The Proof Finder

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.

The checker: given a proof, redo each steptheorem: MUUI
  1. axiomMI

Waiting for the searcher to hand over a proof…

The searcher: given only the theorem, try every proof
Theorem to prove:
…
steps in the shortest proof
0
rule applications the searcher tried
—
rule applications the checker redid
—
searching cost ÷ checking cost
“Is there a proof of this statement at most n symbols long?” is an NP problem for any reasonable formal system: the proof itself is the certificate, and checking it is mechanical. So if P = NP, that question would have a polynomial-time algorithm, for this toy system and equally for the systems in which real mathematics is written. That is the dashed curve. Nobody has such an algorithm, and most researchers believe none exists.

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.

Go deeper:Gödel’s Letter, and the Problem about All the Others

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.

Universal Search and Galactic Algorithms

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.

0
steps given to all programs together
…
steps the winner needed for itself, T
…
slowdown from running everything at once
0
printed answers the verifier checked
No program is trusted. Each is run a little at a time, the program in place i getting a share 2−i of the steps, and anything a program prints is handed to the verifier. The first answer that passes ends the search.

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.

Exponential algorithm:
trying every assignment
996
crossover n*: beyond it the polynomial wins
10²⁸³ years
running time at the crossover, at 10⁹ operations a second
n = 1
largest input the polynomial algorithm finishes in the age of the universe
n = 88
largest input the exponential algorithm finishes in that time
Below n ≈ 996 the exponential algorithm is faster. At the crossover both need about 10³⁰⁰ operations, which is 10²⁸³ years: 10²⁷³ times the age of the universe. The polynomial algorithm wins only on inputs that neither could ever finish. In the time since the Big Bang it would get through n = 1, and the exponential one through n = 88.

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.

Go deeper:The Fastest Algorithm We Cannot Use

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.

The Smallest Explanation

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.

Tap an input to see its label, or to hide it again
Smallest formula that fits every label
Finding the smallest formula of every function… 10 of 65,536
…
AND/OR gates in it
2,048
functions that fit the labels
…
of them equally small
—
unseen inputs it gets right

Hidden rule:
Occam’s razor as an algorithm: of everything consistent with the evidence, take the shortest. When the hidden rule has a small formula, the choice snaps to it long before all 16 inputs have been seen, while a function picked at random among the consistent ones is right about an unseen input half the time however many examples it has had.
Here the search runs over all 65,536 functions of 4 inputs, and it was done by listing them. For n inputs there are 2 to the power 2n functions: about 10³⁰⁸ of them at n = 10. But “is there a circuit with at most s gates that agrees with these examples?” is an NP question, because the circuit is a certificate that is easy to check. It is a version of the minimum circuit size problem. If P = NP it could be answered efficiently, and the simplest theory fitting any set of data could be computed. That is a statement about a hypothetical, not a forecast.
If P = NP were proved: a consequences board
  • Would follow
    The polynomial hierarchy collapses to P
    A theorem: if P = NP then every level of the tower built on NP, co-NP included, equals P.
  • Only with a practical algorithm
    Public-key cryptography becomes impossible
    In theory one-way functions would not exist, so every such scheme could be broken in polynomial time. Keys in use are at risk only if that polynomial is small.
  • Only with a practical algorithm
    Optimal schedules, routes and designs
    Each reduces to questions in NP, so a polynomial algorithm would exist. Whether it beats today’s solvers on real instances depends on its exponent and constant.
  • Only with a practical algorithm
    Shortest proofs found mechanically
    Only proofs short enough to write down, and only if the search is cheaper than the mathematicians.
  • Only with a practical algorithm
    The smallest circuit or simplest model for any data
    The question above this board would be in P. At n to the hundredth power it would stay out of reach.
  • Would not follow
    The halting problem becomes solvable
    Undecidable problems have no algorithm at all, fast or slow. P = NP says nothing about them.
  • Would not follow
    Problems complete for exponential time become easy
    The time hierarchy theorem proves that exponential time is strictly larger than P, whatever happens to NP.

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.

Go deeper:Occam’s Razor, Circuit Minimisation, and What Researchers Believe

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.

200261%
201283%
201988%
Share of respondents who answered “P ≠ NP” in Gasarch’s polls. A record of opinion, not evidence.

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.

Key Takeaways

  • If P = NP, any proof short enough to check could be found in polynomial time, as Gödel saw in 1956.
  • Levin’s universal search is optimal up to a constant factor for every problem with checkable answers, and the constant makes it useless.
  • Polynomial does not mean fast: n100 beats 2n only beyond n ≈ 996, where neither can ever finish.
  • Finding the simplest rule that fits the data is an NP search, so P = NP with a practical algorithm would automate much of learning.

Spot a mistake or have an idea?

Search