NP-Completeness
Some problems in are universally hardest: every other problem in reduces to them. This lesson defines -hard and -complete, states the Cook–Levin theorem that anchors the theory on SAT, walks the web of reductions that grows from it, and gives the four-step recipe for proving a brand-new problem -complete.
╌╌╌╌
The previous lesson left us with a claim: inside there are problems that are universally hardest, and they decide the versus question. This lesson makes that claim precise. We define what it means to be hardest, identify the first such problem (SAT, via the Cook–Levin theorem), and then show how a single starting problem yields many more equally hard problems through reductions. Finally we state the four-step recipe for proving a new problem -complete.
NP-hard and NP-complete
Recall that means is no harder than .
Now imagine a
problem that every problem in is no harder than. Such a
is at least as hard as everything in , a ceiling on the whole
class.
The distinction matters. -hardness is a pure lower bound: is as hard as anything in , but need not itself be in ; it could be far harder, even undecidable. -complete problems are the ones that are hardest and still belong to : they sit exactly at the frontier. They are the hardest problems whose solutions we can still efficiently check.1
Two consequences follow.
- All -complete problems stand or fall together. Suppose is -complete and someone finds a polynomial-time algorithm for . Then for any we have , so is solvable in polynomial time too, every at once. Hence Conversely, proving any single -complete problem requires super-polynomial time would prove . In this sense the thousands of known -complete problems are a single problem in many guises.
- Transitivity bootstraps the class. If is -complete and we show for some , then is -complete too: every satisfies , and composes. This is how one-complete problem yields many.
Transitivity spreads -completeness from one problem to the next, but it presupposes we already have a first -complete problem to start from. Where does the first one come from?
The first one: Cook–Levin
The breakthrough, proved independently by Stephen Cook (1971) and Leonid Levin, is that a natural problem is -complete from scratch, without reducing from anything, by reasoning directly about computation itself.
The problem is boolean satisfiability, or SAT.
With one -complete problem in hand, transitivity takes over.
The reduction web
Karp's 1972 paper reduced SAT to twenty-one other problems, showing them all -complete and launching the field.3 A convenient intermediate is 3-SAT, the special case of SAT in which the formula is in conjunctive normal form with exactly three literals per clause, a big AND of small ORs such as . One can show , so 3-SAT is itself -complete, and its rigid structure makes it the favorite starting point for further reductions.
The reduction is a small gadget worth seeing,
because it shows how a clause of the wrong width is padded or split to exactly
three literals using fresh variables. A clause with one literal becomes
with new variables : the four clauses together force true regardless
of . A long clause is
chained with fresh variables into
:
a satisfying assignment of the original picks some true , and the can be
set to carry the still unsatisfied
signal down the chain until that
discharges it. Each new clause has exactly three literals, the blow-up is linear,
and satisfiability is preserved in both directions — a clean polynomial reduction.
From 3-SAT the web branches out. A small portion:
Every arrow is a reduction ; following arrows back to SAT certifies each box as -complete. (The arrows above record one route to each result, not the only one; many of these problems also reduce to each other directly, as we saw with and Clique last lesson.)
A worked reduction: 3-SAT to Independent-Set
Let us actually build one arrow, the classic . We are given a 3-CNF formula with clauses and must produce a graph and integer such that has an independent set of size exactly when is satisfiable.
The construction. For each clause, create a triangle of three vertices, one per literal. So clause becomes three mutually-connected vertices labeled , , . Then add a conflict edge between any two vertices in different triangles that hold contradictory literals: one labeled and another labeled . Finally set , the number of clauses. This is clearly polynomial: vertices and at most edges. The construction is correct in both directions.
Solid edges are the per-clause triangles; dashed edges connect contradictory literals ( vs. , and vs. ). Picking one non-conflicting vertex per triangle amounts to a consistent satisfying choice.
A fully worked instance. Take the concrete formula It has clauses, so the construction builds vertices in two triangles and sets . The conflict edges join (clause 1) to (clause 2), and (clause 1) to (clause 2) — the two variable/negation collisions across the triangles. Now find a size- independent set: pick from the first triangle and from the second. These two are not joined by a conflict edge (the conflicts are – and –, neither of which is the pair ), and they sit in different triangles, so the two vertices are non-adjacent — an independent set of size . Reading the chosen literals back as an assignment gives , (and free): the first clause is satisfied by , the second by , so is satisfiable. The reduction turned a logic question into a graph question and back, exactly as the correctness proof requires.
The recipe: proving a new problem NP-complete
Once a stockpile of -complete problems exists, classifying a new problem follows a fixed procedure. To prove is -complete, carry out four steps.
- Show . Describe a polynomial-size certificate for yes-instances and argue it can be checked in polynomial time. This is usually the easy step, but skipping it is a real error: an -hard problem outside is hard but not complete.
- Choose a known -complete problem to reduce from. Pick one whose structure resembles — 3-SAT for logical or gadget-style constraints, or for graph selection, or for numeric targets, for routing.
- Give a polynomial-time reduction . Construct, from an arbitrary instance of , an instance of . This is the creative step of the proof. Mind the direction: you transform 's instance into 's, so that solving would solve . Reducing the wrong way () proves nothing about 's hardness.
- Prove the reduction correct. Establish the if and only if, which is exactly the completeness and soundness of the map. Completeness: a yes-instance of maps to a yes-instance of (no true case lost). Soundness: conversely every yes-instance of comes only from a yes-instance of (no false yes invented). Both directions are mandatory; dropping completeness lets false negatives slip through, dropping soundness lets false positives.
Steps 1 and 2 are bookkeeping; steps 3 and 4 are the substance.5 The worked reduction above is this recipe applied with and : the triangles-and-conflicts gadget is step 3, and the two-direction argument is step 4.
The tractability boundary and what hard
costs
The reduction web draws a line, and the sharpest way to see where it falls is a pair of problems that look nearly identical yet land on opposite sides. 2-SAT, the restriction of SAT to two literals per clause, is solvable in linear time: build the implication graph (each clause becomes and ), and the formula is satisfiable exactly when no variable and its negation share a strongly connected component — one pass of the SCC algorithm, worked out in full in the 2-SAT lesson. Add one literal per clause and 3-SAT becomes -complete. The jump from to is the whole story, and it is not an accident: Schaefer's dichotomy theorem (1978) proves that every boolean constraint-satisfaction problem is either in or -complete, with nothing in between, and it names the exact conditions that put a problem in .6
Trace the linear-time test on . Each clause contributes both implications and , giving six directed edges: from the first clause, and ; from the second, and ; from the third, and . Every path in this graph forces truth values: following the edges out of , we reach then , and no path ever leads from a literal to its own negation, so no variable shares an SCC with its complement. The formula is satisfiable — indeed works. Had we instead added the clauses , the graph would route , collapsing and into one SCC and certifying unsatisfiability — all detected by a single SCC pass, never any search.
Two deeper results sharpen how hard.
The Exponential Time Hypothesis (ETH),
conjectured by Impagliazzo and Paturi, says 3-SAT cannot be solved in
time — not merely that it is not polynomial, but that even sub-exponential time is
out of reach.7 ETH is now the standard tool for proving that specific
problems need or time, giving fine-grained lower
bounds far below the crude -versus- divide. And the PCP
theorem (Arora–Safra and Arora–Lund–Motwani–Sudan–Szegedy, 1998) recharacterizes
so strongly that it makes approximation itself hard: for many
problems, even finding a solution within some constant factor of optimal is
-complete.8 That result leads to the
approximation lesson, where
we ask not can we solve it exactly
but how close can we provably get.
Takeaways
- is -hard if every problem in reduces to it (a lower bound); it is -complete if it is also in, hardest among the efficiently-checkable problems.
- All -complete problems share one fate: a polynomial-time algorithm for any of them would prove and solve them all.
- Cook–Levin anchors the theory: SAT is -complete, proved directly by encoding any verifier's computation as a boolean formula. From it, 3-SAT and a vast reduction web follow by transitivity.
- The reduction (a triangle per clause plus conflict edges, with ) is the model gadget reduction.
- To prove a new problem -complete: (1) show membership in , (2) pick a known -complete , (3) reduce in polynomial time, (4) prove the equivalence both ways, always reducing from the hard problem.
Footnotes
- CLRS, Ch. 34 — NP-Completeness (§34.1): the definitions of -hard (a lower bound) and -complete (hard and in ). ↩
- CLRS, Ch. 34 — NP-Completeness (§34.3): the Cook–Levin theorem that SAT is -complete, proved by encoding a verifier's computation as a boolean formula. ↩
- Skiena, §11 — NP-Completeness: Karp's 1972 reductions and the web of -complete problems growing from satisfiability. ↩
- Erickson, Ch. 12 — NP-Hardness: the gadget reduction (clause triangles plus conflict edges, ). ↩
- CLRS, Ch. 34 — NP-Completeness (§34.4): the standard four-step recipe for proving a new problem -complete. ↩
- Thomas J. Schaefer,
The Complexity of Satisfiability Problems,
STOC 1978 — every boolean CSP is either in or -complete, with the exact tractable cases characterized (2-SAT, Horn-SAT, affine, and duals). ↩ - Russell Impagliazzo and Ramamohan Paturi,
On the Complexity of -SAT,
Journal of Computer and System Sciences 62(2), 2001 — the Exponential Time Hypothesis, that 3-SAT has no algorithm. ↩ - Sanjeev Arora and Shmuel Safra,
Probabilistic Checking of Proofs,
and Arora, Lund, Motwani, Sudan, Szegedy,Proof Verification and the Hardness of Approximation Problems,
Journal of the ACM, 1998 — the PCP theorem and inapproximability. ↩
╌╌ END ╌╌