Safekipedia

P versus NP problem

Adventurer · ages 7–10Adapted from Wikipedia
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)

The P versus NP problem is a major unsolved problem in theoretical computer science. It asks a simple question: if the 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 quickly can also be solved quickly. 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 quickly, but their answers could be checked quickly.

The problem has been called the most important open problem in computer science. It is important to computational theory. A proof either way would have deep effects on many fields, including mathematics, cryptography, algorithm research, artificial intelligence, game theory, multimedia processing, philosophy, economics and others. 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

Think about this yes-or-no puzzle: is there at least one correct way to finish a Sudoku grid of size n2×n2? In a correct answer, every row, column, and n×n square holds the numbers 1 through n2. If someone gives a possible answer, it is easy to check whether it works by looking at the rows, columns, and squares. However, no one knows if there is a fast way to always get the right "yes" or "no" for every puzzle like this. So a big Sudoku can be checked quickly, but it may or may not be solved quickly.

This puzzle has to be a general version of Sudoku, because any Sudoku of one fixed size 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 first written down in 1971 by Stephen Cook in his important paper "The complexity of theorem proving procedures". Leonid Levin came up with it separately 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 simple model of a computer. This computer has only one possible next action, and 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. It asks whether P equals NP.

Is P equal to NP?

Since 2001, William Gasarch has run three polls of researchers. The polls asked 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 quickly, and their answers can still be checked quickly. NP-hard problems are at least as hard as NP problems, but their answers may not be easy to check. 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 be true.

After the Boolean satisfiability problem was shown to be NP-complete, a method called proof by reduction made it easier to show that many other problems are also NP-complete. One of these is the puzzle Sudoku. A quick way to solve Sudoku could be used to fill in Latin squares quickly. It could also help with splitting tri-partite graphs into triangles. Through a chain 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 be outside P. The class EXPTIME contains decision problems that a deterministic Turing machine can solve 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 can be turned into it using a polynomial-time many-one reduction. Many such problems are known. 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 take even longer. 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. 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 is not equal to NP, then some problems in NP 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 few NP problems that are not known to be in P or NP-complete.

The graph isomorphism problem asks whether two finite graphs are isomorphic. Scientists do not know which group it belongs to. It is believed not to be NP-complete. The best method 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 fast method for it is known. This problem is the basis of several modern secure systems, such as RSA. The best known quantum algorithm for it is Shor's algorithm. It runs in polynomial time. However, this does not show exactly where the problem fits 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).

This discussion has often 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, the problem of deciding whether one graph contains another as a minor can be solved quickly. However, the big O notation hides a very large number, which is written using Knuth's up-arrow notation.

Even when a problem is hard, useful methods can still exist. Many hard problems have methods that solve many real-world examples in a reasonable time. These include the knapsack problem, the traveling salesman problem, and the Boolean satisfiability problem. The average-case complexity of these methods can be surprisingly low. The simplex algorithm, used in linear programming, is one example. It can be very slow 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. These lead to classes such as BPP and BQP. The time complexity of an algorithm describes how its running time grows.

Reasons to believe P ≠ NP or P = NP

Cook restates the problem as "Does P = NP?" Polls show that most computer scientists believe P is not equal to NP. One big reason is that after many years 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 searching for these methods long before NP-completeness was even defined. Karp's 21 NP-complete problems, among the first ones found, were all well-known problems when they were shown to be NP-complete. If P = NP were true, many other surprising results that scientists think are false would also be true. For example, co-NP would equal NP, and PH would equal P. Some people also say that hard problems with answers that are easy to check fit what we see in the real world. Scott Aaronson of UT Austin explains it this way: if P = NP, the world would be very different, and "creative leaps" would not be especially valuable.

Some researchers, however, think it is too confident to believe P ≠ NP. They say scientists should also look for proofs that P = NP. Moshe Y. Vardi of Rice University said in 2002 that not finding fast methods is a weak argument. We are only at the beginning of exploring the many possible algorithms. He pointed out that the proof of Fermat's Last Theorem shows that very simple questions can need very deep theories to be answered. Anil Nerode of Cornell University, also in 2002, warned that strong assumptions have led famous mathematicians to be wrong, 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 fail for a very large number. 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 a lot of attention because either answer would move the study of computing forward. It could also have big effects in the real world. 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. 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. 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. It would guide future research by showing that many common problems cannot be solved efficiently. Researchers could then focus on partial solutions or other problems. Many people already believe P ≠ NP, so 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. A Princeton University workshop in 2009 studied them.

Results about difficulty of proof

The P = NP problem is still unsolved. Even with a prize of one million dollars and a lot of research, it has not been answered. Trying to solve it has still led to new ideas. Some of the most helpful research has shown that current proof methods are not enough to answer the question. This 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 answer 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. This would mean it cannot be proved or disproved using them. Even simpler starting rules based on the Peano axioms for whole number 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

Another way to ask whether P equals NP is to ask what different kinds of logic can say. This area is called descriptive complexity. It describes groups of problems using logic that works on finite structures. Fagin's theorem shows that NP is exactly the set of properties of finite structures that can be written in existential second-order logic. The Immerman–Vardi theorem shows that, for finite structures with a linear order, P is exactly the set of properties that can be written in first-order logic with a least fixed-point operator. So for these ordered structures, asking whether P equals NP is the same as asking whether the two logics can say the same things.

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. Some algorithms for these problems could run in polynomial time when the answer is "yes," but only if P = NP. These algorithms use such huge numbers that they are not practical. They also do not count as polynomial time, because they can run forever when the answer is "no." One example, from Levin, correctly solves the NP-complete problem SUBSET-SUM.

Even if P = NP, this kind of algorithm would only run quickly on "yes" answers, and it would still 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 a 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 find the correct answer in a number of steps that grows at a manageable rate as the input gets bigger, then the problem can be solved in "polynomial time." Problems like this belong to the class P.

NP is the class of problems where a "yes" answer can be checked quickly if someone gives a proof, called a certificate. The checking method does not have to be fast in general, 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 still considered unsolved. Still, many people, both amateurs and some professional researchers, have said they solved it. Gerhard J. Woeginger collected a list of many claimed proofs made over several decades. Some of these claimed that P = NP, some claimed that P ≠ NP, and a few proved other results.

Some of these attempts got a little attention in the news, but they have since been shown to be wrong.

The film Travelling Salesman, by director Timothy Lanzone, is about 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 wanders into the "third dimension." In the second episode of season 2 of Elementary, "Solve for X", Holmes and Watson look into why some mathematicians who were trying to solve P versus NP had died.

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, there is a small reference 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 researcher goes missing and claims to have solved P vs. NP. The novel "The Ruby Circuit" by Martin G. Ljungqvist is about mathematicians and the P vs. NP problem.

Similar problems

Some other problems are like P versus NP. One is the R vs. RE problem. R is like class P, and RE is like class NP. These two classes are not equal. Some problems cannot be fully solved by any computer method, even though their answers can still be checked. An example is Hilbert's tenth problem, which is RE-complete.

A similar problem appears in algebraic complexity: the VP vs. VNP problem. Like P versus NP, nobody knows its answer yet. Another similar problem is FPT vs. W[1], which is found in parameterized complexity.

Quiz time!

4 questions about P versus NP problem

Question 1 of 4

What 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.