AiTechWorlds
AiTechWorlds
Open your phone's Sudoku app. Tap a completed puzzle — the app instantly tells you whether it is correct. That check takes milliseconds. Now try solving a blank Sudoku from scratch. Depending on your skill, that might take minutes or hours. The same puzzle. The same logic. But checking a solution is trivially easy while finding one is genuinely hard. This asymmetry — easy to verify, hard to find — is not just a quirk of Sudoku. It appears throughout mathematics, cryptography, logistics, biology, and economics. Formalising this asymmetry is the P vs. NP problem, posed by Stephen Cook in 1971, still unsolved, and carrying a Clay Mathematics Institute prize of one million dollars.
P (Polynomial Time) is the class of decision problems solvable by a deterministic Turing machine in O(nᵏ) time for some fixed constant k, where n is the input size.
Polynomial time is the theoretical definition of "efficiently solvable." Problems in P include:
The choice of polynomial (rather than, say, O(2ⁿ)) is motivated by the Cobham-Edmonds thesis: polynomial-time algorithms are robust across reasonable machine models, while exponential-time algorithms are practically infeasible for large inputs.
NP has two equivalent definitions:
Definition 1 — Verifier: NP is the class of decision problems for which a proposed solution can be verified in polynomial time by a deterministic TM.
Definition 2 — Nondeterministic TM: NP is the class of problems solvable in polynomial time by a nondeterministic Turing machine (one that can "guess" the right answer and verify it).
Both definitions describe exactly the same class of problems. The name NP stands for Nondeterministic Polynomial — it does NOT mean "not polynomial" or "necessarily hard."
Examples of NP problems:
co-NP is the class of problems where NO-instances can be verified in polynomial time. If the answer to a problem is "no," and you can verify that efficiently, the problem is in co-NP.
NP ∩ co-NP contains problems where both YES and NO can be verified efficiently. Primality testing was long suspected to be in NP ∩ co-NP (now known to be in P).
If a problem is in P — solvable in polynomial time — then it is also in NP: to verify a solution, simply re-solve the problem from scratch in polynomial time, ignoring the proposed solution. Therefore P ⊆ NP.
The open question is whether this containment is strict: is P ⊊ NP (are there problems in NP that are not in P)? Or does P = NP (can every efficiently verifiable problem also be efficiently solved)?
Known relationships: P ⊆ NP ∩ co-NP ⊆ PSPACE ⊆ EXPTIME. Whether P = NP is open. Whether NP = co-NP is also open (widely believed false).
| Complexity Class | Definition | Examples | Relation to P | Real Impact |
|---|---|---|---|---|
| P | Decidable in poly time | Sorting, SP, Primality | P = P | Direct, efficient algorithms |
| NP | Verifiable in poly time | SAT, Sudoku, TSP | P ⊆ NP (= ? unclear) | Cryptography depends on P ≠ NP |
| co-NP | "No" verifiable in poly time | Tautology | P ⊆ co-NP | Proof systems |
| PSPACE | Decidable in poly space | QBF, game solving | NP ⊆ PSPACE | Planning, control |
| EXPTIME | Decidable in exp time | Chess optimal play | PSPACE ⊆ EXPTIME | Impractical exact algorithms |
If P = NP (virtually no one believes this, but the proof remains elusive):
If P ≠ NP (the consensus belief):
RSA encryption (Rivest, Shamir, Adleman, 1978) relies on the hardness of integer factorisation:
Integer factorisation is in NP (verify a factor by dividing), but it is not known to be NP-complete. If P = NP, factorisation is certainly polynomial. Even without P = NP, a polynomial factoring algorithm would break RSA. The Clay Prize winner who proves P = NP could theoretically decrypt any RSA-encrypted communication ever intercepted.
Stephen Cook introduced the notion of NP-completeness in his 1971 paper "The Complexity of Theorem-Proving Procedures." Richard Karp followed in 1972 by proving 21 classical problems are NP-complete. Cook won the ACM Turing Award in 1982. The Clay Mathematics Institute listed P vs. NP as one of the seven Millennium Prize Problems in 2000, each carrying a USD 1,000,000 prize.
As of 2026, P vs. NP remains unsolved. We lack both a polynomial algorithm for any NP-complete problem and a proof that no such algorithm can exist. Most complexity theorists believe P ≠ NP, based on decades of failed attempts to find polynomial algorithms for NP-complete problems — but mathematical belief is not a proof.
Sources: Cook, S. A. (1971). The complexity of theorem-proving procedures. Proceedings of the 3rd Annual ACM Symposium on Theory of Computing, 151–158. | Sipser, M. (2013). Introduction to the Theory of Computation (3rd ed.). Cengage. | Arora, S., & Barak, B. (2009). Computational Complexity: A Modern Approach. Cambridge University Press.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises