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 whole edifice 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 hold the key to 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 seed problem sprouts an entire forest of equally hard problems through reductions. Finally we distill the whole enterprise into a four-step recipe you can apply to a problem you have never seen before.
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 make these definitions powerful.
- 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 the engine that turns one-complete problem into many.
But the engine needs a spark. Transitivity spreads -completeness from one problem to the next, yet 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.
That SAT is in is easy: a satisfying assignment is a
certificate, and evaluating on it takes linear time. The deep half is
-hardness: showing that every reduces to
SAT. The idea, which we sketch rather than prove, is to encode computation
as logic. Any has a polynomial-time verifier . For an
input , the question does some certificate make accept ?
is exactly
the question is 's answer yes?
Cook and Levin build, in polynomial
time, a boolean formula whose variables describe the verifier's
entire step-by-step execution, with clauses that force the variables to obey
the machine's rules. Then is satisfiable if and only if some
certificate makes accept, so deciding SAT on decides
on . Because this works for an arbitrary problem in , SAT
is -hard.2
With one -complete problem in hand, the transitivity engine takes over.
The reduction web
Karp's celebrated 1972 paper reduced SAT to twenty-one other problems, showing them all -complete and launching the field.3 A convenient waystation 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.
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.
Why it works. An independent set may pick at most one vertex from each triangle (the three are mutually adjacent), so an independent set of size must pick exactly one literal from every clause. The conflict edges forbid choosing both and anywhere, so the chosen literals are mutually consistent — they describe a partial truth assignment. Setting each chosen literal true satisfies one literal in every clause, hence satisfies . Run the argument backward: a satisfying assignment picks, from each clause, one true literal; those vertices form an independent set, since two true literals can never be a variable and its negation. Therefore which is exactly what a valid reduction requires.4
Solid edges are the per-clause triangles; dashed edges connect contradictory literals ( vs. , and vs. ). Picking one non-conflicting vertex per triangle is exactly a consistent satisfying choice.
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 heart 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: a yes-instance of maps to a yes-instance of , and conversely every yes-instance of comes only from a yes-instance of . Both directions are mandatory; a one-way implication leaves a hole through which false positives or negatives can slip.
Steps 1 and 2 are bookkeeping; steps 3 and 4 are where insight lives.5 The worked reduction above is exactly this recipe applied with and : the triangles-and-conflicts gadget is step 3, and the two-direction argument is step 4.
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. ↩
╌╌ END ╌╌