P versus NP problem
A major unsolved problem in theoretical computer science.
The P versus NP problem is a major unsolved problem in theoretical computer science. It asks whether every decision problem for which a proposed positive answer can be quickly verified can also be quickly solved.
- field
- Theoretical computer science, computational complexity theory
- known_for
- Asking whether P equals NP, the most important open problem in computer science
- related_classes
- P (polynomial time solvable), NP (nondeterministic polynomial time verifiable)
Reader's Guide
The P versus NP problem is central to computational complexity theory, which studies the resources required during computation to solve a given problem. The class P consists of decision problems solvable on a deterministic sequential machine in polynomial time; the class NP consists of problems whose positive solutions are verifiable in polynomial time. An answer to the question would determine whether problems that can be verified in polynomial time can also be solved in polynomial time. If P ≠ NP, which is widely believed, it would mean there are problems in NP that are harder to compute than to verify. A proof either way would have profound implications for mathematics, cryptography, algorithm research, artificial intelligence, game theory, multimedia processing, philosophy, economics, and many other fields. The concept of NP-completeness is useful in attacking the question: NP-complete problems are those that any other NP problem can be reduced to in polynomial time, and if any NP-complete problem is in P, then P = NP. The Boolean satisfiability problem was the first natural problem proven to be NP-complete by the Cook–Levin theorem.
Did You Know?
- Generalized Sudoku is in NP (quickly verifiable) but may or may not be in P (quickly solvable).
Two Faces of the Same Class
NP can be understood through two equivalent lenses. One view frames it as the collection of decision problems a nondeterministic Turing machine can resolve within polynomial time—hence the name "nondeterministic polynomial time." The other, equally valid perspective describes NP as the set of problems where a "yes" answer comes with a proof that a deterministic machine can check in polynomial time. These two descriptions are not merely parallel; they are mathematically interchangeable. The reason lies in the structure of the underlying algorithm: it unfolds in two phases. First, a candidate solution is produced through a nondeterministic guess. Second, a deterministic procedure confirms whether that guess actually solves the instance. Because the guessing step can be reinterpreted as the existence of a suitable witness string, and the checking step is purely deterministic, the machine-based and verifier-based characterizations collapse into one another. This duality gives researchers flexibility: they can reason about NP either in terms of hypothetical parallel exploration or in terms of efficient certification, depending on which angle illuminates the problem at hand.
The Central Question and Its Stakes
The class P, encompassing every decision problem a deterministic machine can solve in polynomial time, sits neatly inside NP. The inclusion is straightforward: if you can solve a problem quickly, you can certainly verify a proposed answer quickly by simply re-solving it. Yet the reverse direction—whether every problem with efficiently checkable solutions also admits an efficient solver—remains one of the deepest open questions in mathematics. The prevailing intuition among complexity theorists is that P is a strict subset of NP, meaning some problems are fundamentally easier to check than to find. At the top of NP sit the NP-complete problems, a family so interconnected that a polynomial-time algorithm for any single member would immediately unlock polynomial-time solutions for every problem in NP. Thus, proving P equals NP would not merely settle one question; it would hand researchers efficient algorithms for an enormous landscape of search and optimization challenges that currently resist them.
A Concrete Window into Verification
The subset sum problem offers a vivid illustration of why NP feels so natural. Given a collection of integers, say {−7, −3, −2, 5, 8}, the question asks whether some subcollection adds to zero. Here the answer is affirmative: {−3, −2, 5} produces the sum zero. Finding such a subset by brute force requires enumerating every possible combination, a task whose cost balloons exponentially as the input grows. Yet if someone hands you a specific subset, confirming that its elements sum to zero is a matter of a single pass of addition—clearly polynomial time. That subset acts as a witness, sometimes called a certificate, and the addition routine serves as the verifier. This pattern generalizes: a decision problem belongs to NP whenever there exists a verifier that, given the problem instance paired with a witness string, returns "yes" in polynomial time when the witness is valid and "no" otherwise. The distinction between the exponential search and the polynomial check is precisely what separates P from NP in the minds of those who study these classes.
The Shadow Class co-NP
Alongside NP stands its mirror image, co-NP. While NP guarantees efficient verification of "yes" answers, co-NP is the class of problems where "no" answers carry efficiently checkable proofs. The subset sum example makes the contrast tangible: asking "does some subset sum to zero?" is an NP question, whereas asking "does every non-empty subset have a nonzero sum?" is its co-NP counterpart. The verifier-based definition of NP deliberately does not demand an efficient certificate for negative answers, which is exactly the gap that co-NP fills. Whether these two classes coincide—whether NP equals co-NP—is an open question that remains unresolved in complexity theory. It is a separate, though related, mystery from the P-versus-NP problem. Together, the unresolved status of P versus NP and NP versus co-NP frames two of the most fundamental boundaries in our understanding of what computation can and cannot do efficiently, and both continue to resist proof despite decades of intensive effort.
Frequently Asked Questions
What is the P versus NP problem?
It is the question of whether every problem whose "yes" answer can be checked in quick time can also be solved from scratch in quick time. It remains one of the most prominent unsolved questions in theoretical computer science.
What do the "P" and "NP" in the problem name actually mean?
P stands for problems a deterministic algorithm can solve within polynomial time, while NP stands for problems where a proposed solution can be verified within polynomial time. The core question is whether these two classes are truly the same set of problems.
Why is P versus NP considered so important to the field?
Cracking it would fundamentally reshape our understanding of what computation can and cannot achieve efficiently. It has direct implications for cryptography, optimization, and virtually any domain that relies on the gap between verifying an answer and discovering one.
More in Complexity Theory 1-24
Spotted an error? Know more?
This is a living reference — every entry is fact-audited, and reader corrections feed straight into our audit queue. Suggest an edit · See this site's audit record
