JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

NP-Completeness and the Cook-Levin Theorem

If reductions let us compare two problems' hardness, can any single problem be hardest of all? Yes — and we meet the very first one. We assemble NP-hardness and NP-completeness from the pieces you already have, then watch the Cook-Levin theorem prove that satisfiability is a universal problem every other NP problem secretly reduces to.

From comparing hardness to a hardest problem

In the previous guide a polynomial-time reduction from problem A to problem B gave us a one-line slogan: if A reduces to B, then B is at least as hard as A, because any fast solver for B becomes a fast solver for A. That arrow points in a fixed direction — solving B would solve A — so it ranks the two problems. Now ask the bold question that ranking invites. Inside the class NP of problems whose yes-answers carry a short, checkable certificate, is there a single problem that sits at the very top — one that every other NP problem reduces to? If such a champion exists, it is in a real sense the hardest problem in NP: cracking it in polynomial time would crack everything in NP at once.

Two pieces of vocabulary pin this down. A problem B is NP-hard if every problem in NP reduces to it in polynomial time — B is at least as hard as everything in NP, whether or not B itself lives in NP. A problem is NP-complete if it is both NP-hard and a member of NP. So NP-complete means two things at once: hard enough that all of NP funnels into it, yet tame enough to have short certificates of its own. The NP-complete problems are exactly the hardest problems that still belong to NP, and a wonderful fact we will keep using is that they all stand or fall together.

Why one hard problem topples a thousand

Before meeting the first NP-complete problem, savor what the definition buys us, because it is the engine of this whole subject. Suppose B is NP-complete and someone finds a polynomial-time algorithm for B. Take any other problem A in NP. By NP-hardness of B, A reduces to B in polynomial time: transform A's input, run the fast B-solver, read off A's answer — all polynomial, so A is now in P. But A was an arbitrary NP problem. So a single polynomial algorithm for one NP-complete problem would prove P = NP and collapse the whole class. The dominoes are pre-arranged; knocking over any NP-complete one knocks them all.

The contrapositive is the version researchers actually rely on every day. If even one problem in NP is genuinely outside P — if P is not equal to NP, as almost everyone believes — then no NP-complete problem can have a polynomial algorithm, ever. That is why proving your problem NP-complete is such powerful news. It does not literally prove no fast algorithm exists, since P versus NP is unresolved; but it certifies your problem is exactly as hard as thousands of famous problems that an army of brilliant people has failed to speed up for over fifty years. In practice that is your license to stop hunting for an exact polynomial method and start designing approximations, heuristics, or exponential methods that are merely better than brute force.

The Cook-Levin theorem: a first hardest problem

There is a chicken-and-egg snag. To prove a new problem NP-complete by reduction, we reduce a known NP-complete problem to it — but that needs a first NP-complete problem already in hand, and there is nothing to reduce from yet. The Cook-Levin theorem breaks the circle from scratch. It proves that Boolean satisfiability — SAT, the decision problem 'given a Boolean formula over true/false variables, is there an assignment making it true?' — is NP-complete. This is the seed of the whole NP-complete zoo: the very first problem shown hardest-in-NP without any predecessor to lean on.

Showing SAT is in NP is the easy half: a satisfying assignment is a short certificate, and plugging it in and evaluating the formula is a quick check — exactly the verifier picture from earlier in this rung. The deep half is showing SAT is NP-hard: that every single problem in NP reduces to SAT. We cannot enumerate those problems one by one; there are infinitely many. So Cook and Levin reduce from the definition of NP itself. Every NP problem, by definition, has a polynomial-time verifier — a fixed mechanical procedure that, given the input plus a candidate certificate, runs for a polynomial number of steps and outputs yes or no.

The trick is to capture that verifier's entire run as a single giant Boolean formula. Picture the verifier's computation laid out as a grid: rows are time steps, columns are memory cells, and each grid square holds a symbol. Local rules say how one row follows from the previous — a small, fixed wiring repeated everywhere — and those rules, plus 'the input is fixed' and 'the final step says accept', translate into Boolean clauses over variables that describe each grid square. The constructed formula is satisfiable exactly when some certificate makes the verifier accept. So the original input is a yes-instance if and only if the formula is satisfiable, and the whole grid is only polynomially large, so the construction runs in polynomial time. That is a polynomial-time reduction from an arbitrary NP problem to SAT.

From SAT, the zoo grows by reduction

Once SAT is the anchor, the chicken-and-egg problem is gone forever, and the next guide will lean on this. To prove a brand-new problem X is NP-complete, you no longer reduce from all of NP — you do two finite jobs. First show X is in NP by exhibiting a short certificate and a fast verifier. Then pick any one problem already known NP-complete and reduce it to X in polynomial time. Because reductions chain — they are transitive — that single reduction silently inherits all of NP through the known problem, which inherited it through SAT.

  1. Cook-Levin proves SAT is NP-complete from first principles, by encoding any polynomial verifier as a Boolean formula.
  2. SAT reduces to 3-SAT (formulas with three literals per clause), so 3-SAT is NP-complete too — and its rigid shape makes it the favorite starting point for further reductions.
  3. 3-SAT reduces to graph problems, scheduling problems, packing problems, and on and on; each new reduction adds another problem to the NP-complete family, all inheriting SAT's hardness.

Thousands of natural problems have been swept into this family this way, and the next guide builds such a reduction in full. Each is NP-complete, so each is a valid new anchor for the next proof; the zoo is self-reinforcing. And every member shares the same destiny: a polynomial algorithm for any one of them puts every one of them in P, while a proof that any one needs super-polynomial time bars them all from P. That shared fate is what makes 'NP-complete' a single coherent verdict rather than a loose label.

Honest fine print, and what P vs NP really asks

Keep four cautions close. First, 'NP-complete' does not mean 'proven to have no polynomial algorithm.' It means none is known and finding one would collapse P versus NP — a famous open question, not a closed verdict. Second, NP-complete is about the worst case: a problem can be NP-complete yet have instances, even most instances, that solve fast; many real SAT formulas crack in milliseconds. Third, NP-hardness alone does not place a problem in NP, so always check membership before claiming completeness. Fourth, the reduction direction is unforgiving: to show your problem X is hard you must reduce a known-hard problem TO X, never the other way; reducing X to something easy proves nothing about X's hardness.

With NP-completeness in hand we can finally state the headline question precisely. P versus NP asks: is finding a solution as easy as checking one? P is the problems we can solve quickly; NP is the problems whose proposed solutions we can check quickly. Cook-Levin showed NP has a top floor — the NP-complete problems — and P = NP would mean that top floor is no higher than P, that every quickly-checkable problem is also quickly-solvable. Almost everyone bets P is not equal to NP, that some problems are genuinely easier to verify than to discover, but after fifty years no proof exists in either direction.

Notice the asymmetry SAT exposes, which the final guide on co-NP will sharpen. A yes-answer to SAT comes with a satisfying assignment you can check in a flash — a short certificate. But a no-answer means no assignment works at all, and there is no obvious short certificate for 'unsatisfiable'; you would seemingly have to rule out every assignment. That gap between cheap yes-proofs and apparently expensive no-proofs is the seam where NP and its mirror image co-NP part ways, and it is one more reason the P versus NP question is as deep as it is stubborn.