Intractability/NP-Completeness

Lesson 12.21,388 words

NP-Completeness

Some problems in NP\mathsf{NP} are universally hardest: every other problem in NP\mathsf{NP} reduces to them. This lesson defines NP\mathsf{NP}-hard and NP\mathsf{NP}-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 NP\mathsf{NP}-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

-complete is the intersection of and -hard; some -hard problems lie outside .

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.
Transitivity bootstrap: every already reduces to the known-complete ; one new reduction extends the chain, so inherits hardness from the whole class.

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

Cook–Levin encodes a verifier's whole computation on as one formula , satisfiable iff some accepts.

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:

Reduction web of NP-complete problems branching out from SAT and 3-SAT.

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

Clause triangles with dashed conflict edges for the 3-SAT to Independent-Set reduction.

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.

Choosing — one vertex per triangle, no conflict edge between them — is a size- independent set, i.e. a satisfying assignment.

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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

  1. CLRS, Ch. 34 — NP-Completeness (§34.1): the definitions of -hard (a lower bound) and -complete (hard and in ).
  2. 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.
  3. Skiena, §11 — NP-Completeness: Karp's 1972 reductions and the web of -complete problems growing from satisfiability.
  4. Erickson, Ch. 12 — NP-Hardness: the gadget reduction (clause triangles plus conflict edges, ).
  5. CLRS, Ch. 34 — NP-Completeness (§34.4): the standard four-step recipe for proving a new problem -complete.
Practice

╌╌ END ╌╌