Safekipedia

P versus NP problem

Discoverer · ages 10+Adapted from Wikipedia
A graph showing how the running time of a knapsack algorithm grows as the problem gets bigger, based on measurements from experiments.

The P versus NP problem is a major unsolved problem in theoretical computer science. It asks a simple question: if a answer to a problem can be checked quickly, can the problem also be solved quickly?

Here, "quickly" means that an algorithm exists that solves the task in polynomial time, rather than exponential time. This means the time needed to finish the task is bounded above by a polynomial function of the size of the input. The group of questions that some algorithm can answer in polynomial time is called "P" or "class P". Other questions have no known way to be answered quickly, but if someone gives an answer, it can be checked quickly. These questions belong to "NP", which stands for "nondeterministic polynomial time."

An answer to the P versus NP question would show whether problems that can be checked in polynomial time can also be solved in polynomial time. Most people believe that P ≠ NP. If this is true, some problems in NP are harder to solve than to check. They could not be solved in polynomial time, but their answers could be checked in polynomial time.

The problem has been called the most important open problem in computer science. It is important to computational theory, and a proof either way would have deep effects on mathematics, cryptography, algorithm research, artificial intelligence, game theory, multimedia processing, philosophy, economics and many other fields. It is one of the seven Millennium Prize Problems chosen by the Clay Mathematics Institute, and each one offers a prize of US$1,000,000 for the first correct solution. Readers curious about other puzzles can explore More unsolved problems in computer science.

Example

Consider this yes-or-no puzzle: given an incomplete Sudoku grid of size n2×n2, is there at least one legal solution where every row, column, and n×n square contains the integers 1 through n2? If someone offers a possible answer, it is easy to check whether it works by looking at the rows, columns, and squares. However, it is not known whether there is a quick method that can correctly answer "yes" or "no" for every puzzle of this kind. So generalized Sudoku can be checked quickly, but it may or may not be solved quickly.

This puzzle has to be a generalized version of Sudoku, because any fixed-size Sudoku has only a limited number of possible grids. For a fixed-size Sudoku, the answer can be found quickly by looking it up in a table.

History

The exact statement of the P versus NP problem was introduced in 1971 by Stephen Cook in his important paper "The complexity of theorem proving procedures". Leonid Levin introduced it independently in 1973.

Even before 1971, people had noticed ideas behind the problem. In 1955, mathematician John Nash wrote a letter to the National Security Agency. He guessed that the time needed to crack a complex code would grow very fast as the key got longer. If this were proved, it would show what is now called P ≠ NP. In a 1956 letter to John von Neumann, Kurt Gödel asked whether theorem-proving, which is now known to be co-NP-complete, could be solved in quadratic or linear time. He suggested that if it could, the discovery of mathematical proofs could be automated.

Context

The relationship between the complexity classes P and NP is studied in computational complexity theory, which is part of the theory of computation. This field looks at how much time and memory a computer needs to solve a problem. To study time, scientists use a model of a computer that is deterministic (it has only one possible next action) and sequential (it does one action after another). The class P includes all decision problems (defined below) that can be solved in a time that is polynomial in the size of the input on such a computer. The class NP includes decision problems whose positive answers can be checked in polynomial time when given the right information. This is the same as saying they can be solved in polynomial time on a nondeterministic machine. Every problem in P is also in NP. The biggest open question in theoretical computer science is about how these two classes relate, and it asks whether P equals NP.

Is P equal to NP?

Since 2001, William Gasarch has run three polls of researchers about whether P is not equal to NP and related questions. The share of people who believed P is not equal to NP was 61% in 2001, 83% in 2011, and 88% in 2018. In 2018, 99% of the experts who answered believed P is not equal to NP. These polls do not show whether P equals NP. As Gasarch said: "This does not bring us any closer to solving P=?NP or to knowing when it will be solved, but it attempts to be an objective report on the subjective opinion of this era."

NP-completeness

Euler diagram for P, NP, NP-complete, and NP-hard set of problems (excluding the empty language and its complement, which belong to P but are not NP-complete)

Main article: NP-completeness

NP-complete problems are the hardest problems in NP. Any other NP problem can be changed into one of them in a quick way, and their answers can still be checked quickly. NP-hard problems are at least as hard as NP problems, but they do not need to have answers that can be checked quickly. The Boolean satisfiability problem is NP-complete, as shown by the Cook–Levin theorem. Many important problems are NP-complete, and no fast method is known for solving any of them. If any NP-complete problem could be solved quickly, then P = NP would follow.

After the Boolean satisfiability problem was proved to be NP-complete, a method called proof by reduction made it easier to show that many other problems are also NP-complete, including the puzzle Sudoku. A quick way to solve Sudoku could be used to complete Latin squares quickly, and that could help solve the problem of splitting tri-partite graphs into triangles. Through a series of changes like these, a quick solution to one of these problems leads to a quick solution to all of them. This means many different problems can be changed into one another and are, in a sense, "the same problem."

Harder problems

See also: Complexity class

Even though no one knows whether P = NP, some problems are known to lie outside P. The class EXPTIME contains all decision problems that can be solved by a deterministic Turing machine in O(2p(n)) time, where p(n) is a polynomial function of n. A problem is EXPTIME-complete if it is in EXPTIME and every problem in EXPTIME has a polynomial-time many-one reduction to it. Many such problems are known, and since P ≠ EXPTIME, they need more than polynomial time. By the time hierarchy theorem, they cannot be solved in much less than exponential time. One example is finding a perfect strategy for chess positions on an N × N board, along with similar problems for other board games.

Some problems need even more time. Deciding whether a statement in Presburger arithmetic is true takes longer than exponential time, as Fischer and Rabin proved in 1974. Other problems, called undecidable problems such as the halting problem, cannot be completely solved by any algorithm. Some questions ask how many solutions exist instead of whether any exist. These counting problems form the class #P, and many of them are #P-complete, which makes them among the hardest problems in #P.

Problems in NP not known to be in P or NP-complete

Main article: NP-intermediate

In 1975, Richard E. Ladner showed that if P ≠ NP, then there are problems in NP that are neither in P nor NP-complete. These are called NP-intermediate problems. The graph isomorphism problem, the discrete logarithm problem, and the integer factorization problem are believed to be NP-intermediate. They are some of the very few NP problems not known to be in P or NP-complete.

The graph isomorphism problem asks whether two finite graphs are isomorphic. It is not known whether it is in P, NP-complete, or NP-intermediate, but it is believed not to be NP-complete. The best algorithm for it, by László Babai, runs in quasi-polynomial time. The integer factorization problem asks for the prime factorization of a given number. No efficient algorithm for it is known, and this is the basis of several modern secure systems, such as RSA. The best known quantum algorithm for it, Shor's algorithm, runs in polynomial time, although this does not show where the problem lies compared with other quantum complexity classes.

Comparison of P with "easy" problems

The graph shows the running time vs. problem size for a knapsack problem of a state-of-the-art, specialized algorithm. The quadratic fit suggests that the algorithmic complexity of the problem is O((log(n))2).

Much of this discussion has assumed that P means "easy" and that problems not in P are "difficult." This idea is called Cobham's thesis. It is a common idea in complexity theory, but it has some limits. A method that is fast in theory may still be impractical. For example, a problem of deciding whether one graph contains another as a minor can be solved quickly, but the big O notation hides a very large constant, which is written using Knuth's up-arrow notation.

Even when a problem is hard, useful methods can still exist. Many hard problems, such as the knapsack problem, the traveling salesman problem, and the Boolean satisfiability problem, have methods that solve many real-world examples in a reasonable time. The average-case complexity of these methods can be surprisingly low. The simplex algorithm used in linear programming is one example. It has a very slow time complexity in the worst case, but it works very well in practice. Other approaches, such as randomized algorithms and quantum computation, use different kinds of machines, leading to classes such as BPP and BQP.

Reasons to believe P ≠ NP or P = NP

Cook restates the problem as "Does P = NP?" According to polls, most computer scientists believe that P is not equal to NP. One key reason is that after decades of study, no one has found a fast method for any of the more than 3,000 important known NP-complete problems (see List of NP-complete problems). People were looking for these methods long before NP-completeness was even defined. Karp's 21 NP-complete problems, among the first found, were all well-known problems when they were shown to be NP-complete. If P = NP were true, many other surprising results that are believed to be false would also be true, such as co-NP being equal to NP and PH being equal to P. Some people also argue that hard problems with answers that are easy to check match what we see in the real world. Scott Aaronson of UT Austin puts it this way: if P = NP, the world would be very different, with no special value in "creative leaps."

Some researchers, however, think it is overconfident to believe P ≠ NP and say that researchers should also look for proofs that P = NP. Moshe Y. Vardi of Rice University said in 2002 that the lack of progress in exhaustive search is a weak argument, since we are only at the beginning of exploring the space of algorithms. He noted that the proof of Fermat's Last Theorem shows that very simple questions may need very deep theories to be settled. Anil Nerode of Cornell University, also in 2002, warned that prejudice has caused famous mathematicians to fail, so one should always try both directions. Donald Knuth of Stanford University said in 2014 that it is really hard to believe that all the possible algorithms for a very large number fail. A related pair of groups, DLIN and NLIN, comes from changing "polynomial time" to "linear time" in the definitions. It is known that these two groups are not equal.

Consequences of solution

The problem gets so much attention because either answer would move the study of computing forward a great deal and could have big real-world effects. If P = NP, a proof could lead to fast ways of solving important problems, such as 3-SAT, and many fields could benefit. Problems in operations research, like integer programming and the travelling salesman problem, and in protein structure prediction could become easier to solve. But codes would also be at risk. Public-key cryptography, symmetric ciphers such as AES or 3DES, and cryptographic hashing, which supports blockchain cryptocurrencies such as Bitcoin, would need to be changed or replaced with information-theoretically secure methods. A proof might not give practical methods, though, since it might not show how to find a solution or the method might be too slow to use. Even so, it would encourage research into better methods. Stephen Cook said that a practical method could help computers find proofs for many famous problems, such as the CMI prize problems, and Fermat's Last Theorem took over three centuries to prove. Donald Knuth was doubtful that a proof would be helpful.

Diagram of complexity classes provided that P ≠ NP. The existence of problems within NP but outside both P and NP-complete, under that assumption, was established by Ladner's theorem.

A proof that P ≠ NP would not give the practical benefits of a proof that P = NP. It would still be a great advance in the study of computing and would guide future research by showing that many common problems cannot be solved efficiently. Researchers could then focus on partial solutions or other problems, and because many people already believe P ≠ NP, much of this focusing has already happened. Even so, the average-case complexity of hard problems is still open. Russell Impagliazzo described five hypothetical "worlds" that could result from different answers, and a Princeton University workshop in 2009 studied them.

Results about difficulty of proof

Even though the P = NP problem is still unsolved, despite a prize of one million dollars and a great deal of research, trying to solve it has led to new techniques. Some of the most useful research has shown that existing proof methods are not enough to answer the question, which suggests that new approaches are needed. Nearly all known proof methods in computational complexity theory fall into one of the following groups, and none of them can prove that P ≠ NP:

These barriers also explain why NP-complete problems are useful. If someone finds a fast algorithm for an NP-complete problem, that would solve the P = NP question in a way the above results do not rule out. Some computer scientists suggest the problem may be independent of standard axiom systems like ZFC, meaning it cannot be proved or disproved within them. Even weaker assumions based on the Peano axioms for integer arithmetic might not settle it.

ClassificationDefinition
Relativizing proofsImagine a world where every algorithm is allowed to make queries to some fixed subroutine called an oracle (which can answer a fixed set of questions in constant time, such as an oracle that solves any traveling salesman problem in 1 step), and the running time of the oracle is not counted against the running time of the algorithm. Most proofs (especially classical ones) apply uniformly in a world with oracles regardless of what the oracle does. These proofs are called relativizing. In 1975, Baker, Gill, and Solovay showed that P = NP with respect to some oracles, while P ≠ NP for other oracles. As relativizing proofs can only prove statements that are true for all possible oracles, these techniques cannot resolve P = NP.
Natural proofsIn 1993, Alexander Razborov and Steven Rudich defined a general class of proof techniques for circuit complexity lower bounds, called natural proofs. At the time, all previously known circuit lower bounds were natural, and circuit complexity was considered a very promising approach for resolving P = NP. However, Razborov and Rudich showed that if one-way functions exist, P and NP are indistinguishable to natural proof methods. Although the existence of one-way functions is unproven, most mathematicians believe that they exist, and a proof of their existence would be a much stronger statement than P ≠ NP. Thus, it is unlikely that natural proofs alone can resolve P = NP.
Algebrizing proofsAfter the Baker–Gill–Solovay result, new non-relativizing proof techniques were successfully used to prove that IP = PSPACE. However, in 2008, Scott Aaronson and Avi Wigderson showed that the main technical tool used in the IP = PSPACE proof, known as arithmetization, was also insufficient to resolve P = NP. Arithmetization converts the operations of an algorithm to algebraic and basic arithmetic symbols and then uses those to analyze the workings. In the IP = PSPACE proof, they convert the black box and the Boolean circuits to an algebraic problem. As mentioned previously, it has been proven that this method is not viable to solve P = NP and other time complexity problems.

Logical characterizations

The question of whether P equals NP can also be asked in another way, as a question about what different kinds of logic can express. This area is called descriptive complexity. It describes complexity classes using logics that work on finite structures. Fagin's theorem shows that NP is exactly the set of properties of finite structures that can be expressed in existential second-order logic. The Immerman–Vardi theorem shows that, on finite structures with a linear order, P is exactly the set of properties that can be expressed in first-order logic with a least fixed-point operator. So on these ordered structures, asking whether P equals NP is the same as asking whether the two logics can express the same properties.

The levels of the polynomial hierarchy match different numbers of changes between types of second-order quantifiers. P equals NP exactly when P equals the whole polynomial hierarchy.

Polynomial-time algorithms

No known algorithm solves an NP-complete problem in polynomial time. There are algorithms for these problems that, if P = NP, run in polynomial time when the answer is "yes," but they use such huge numbers that they are impractical. They also do not count as polynomial time, because they can run forever when the answer is "no." One example, due to Levin, correctly accepts the NP-complete problem SUBSET-SUM.

This kind of algorithm only runs quickly on "yes" answers if P = NP, and even then it would be far too slow to use. If the shortest program that could solve SUBSET-SUM in polynomial time is b bits long, the algorithm would first try at least 2b − 1 other programs.

Formal definitions

A decision problem is a problem that takes some string of letters as input and answers "yes" or "no." If an algorithm, such as a Turing machine or a computer program with unlimited memory, can always give the correct answer within a number of steps that grows at a manageable rate with the size of the input, then the problem can be solved in "polynomial time," and it belongs to the class P. NP is the class of problems where a "yes" answer can be checked quickly if someone provides a proof, called a certificate. Not every checking method has to be fast, but for a problem to be in NP, there must be a fast way to check the certificate.

Some problems in NP are called NP-complete. A problem is NP-complete if it is in NP and every other problem in NP can be quickly changed into it. Because of this, if someone finds a fast way to solve one NP-complete problem, they can use it to solve every problem in NP quickly.

Claimed solutions

The P versus NP problem is generally considered unsolved, but many amateur researchers and some professional researchers have claimed to have solved it. Gerhard J. Woeginger made a list of 116 claimed proofs from 1986 to 2016. Of these, 61 claimed that P = NP, 49 claimed that P ≠ NP, and 6 proved other results, such as that the problem is undecidable.

Some of these attempts received brief media attention, but they have since been refuted.

The film Travelling Salesman, by director Timothy Lanzone, tells the story of four mathematicians hired by the US government to solve the P versus NP problem. In the sixth episode of The Simpsons' seventh season, "Treehouse of Horror VI", the equation P = NP appears shortly after Homer accidentally stumbles into the "third dimension." In the second episode of season 2 of Elementary, "Solve for X", Holmes and Watson investigate the deaths of mathematicians who were trying to solve P versus NP.

The problem also appears in other stories. In the episode "Put Your Head on My Shoulders" from the second season of the animated series Futurama, a small reference sits in the background. During a scene where Fry and Amy Wong talk privately in a supply closet, two books of the same size can be seen on a shelf. One is marked "P" and the other "NP." In the graphic novel "The Phantom Researcher" by Robin Cousin, a missing researcher claims to have solved P vs. NP. The novel "The Ruby Circuit" by Martin G. Ljungqvist centers on mathematicians and the P vs. NP problem.

Similar problems

Some other problems are similar to P versus NP. One is the R vs. RE problem, where R is like class P and RE is like class NP. These two classes are not equal, because there are problems that no computer method can fully solve, even though their answers can still be checked. An example is Hilbert's tenth problem, which is RE-complete.

A similar problem exists in algebraic complexity: the VP vs. VNP problem. Like P versus NP, its answer is currently unknown. Another analogous problem is FPT vs. W[1], found in parameterized complexity.

Quiz time!

5 questions about P versus NP problem

Question 1 of 5

What question does the P versus NP problem ask?

Keep exploring

This article is a child-friendly adaptation of the Wikipedia article on P versus NP problem, available under CC BY-SA 4.0.

Images from Wikimedia Commons. Tap any image to view credits and license.