AiTechWorlds
AiTechWorlds
In 1972, Richard Karp published a paper listing 21 combinatorial problems. He proved they were all, in a precise mathematical sense, the same problem. Solve one efficiently, and you can solve all 21 efficiently. Fail to solve one, and you fail them all. These are the NP-complete problems — the hardest problems within NP, the ones that every other NP problem reduces to. Today, thousands of NP-complete problems are known across mathematics, biology, logistics, economics, and engineering. Understanding reductions — how one problem transforms into another — is the toolkit for recognising and handling this class of problems in practice.
A polynomial-time reduction (Karp reduction) from problem L₁ to problem L₂, written L₁ ≤_p L₂, is a function f computable in polynomial time such that:
x ∈ L₁ ⟺ f(x) ∈ L₂
In other words: transform any instance of L₁ into an instance of L₂ in polynomial time, such that YES maps to YES and NO maps to NO. If L₁ ≤_p L₂:
Reductions are transitive: if L₁ ≤_p L₂ and L₂ ≤_p L₃, then L₁ ≤_p L₃.
Theorem (Cook, 1971; Levin, 1973): 3-SAT is NP-complete.
3-SAT: Given a Boolean formula in 3-CNF (3-conjunctive normal form — an AND of clauses, each clause being an OR of exactly 3 literals), does there exist a truth assignment to the variables that makes the formula true?
Example: Is (x₁ ∨ ¬x₂ ∨ x₃) ∧ (¬x₁ ∨ x₂ ∨ x₄) ∧ (x₂ ∨ ¬x₃ ∨ ¬x₄) satisfiable? A verifier checks any proposed assignment in O(n) time — 3-SAT is in NP. Cook proved it is NP-hard by showing that any NP problem can be encoded as a 3-SAT instance: the computation of a nondeterministic TM's accepting run becomes a Boolean formula. This was the first NP-completeness proof. Stephen Cook received the ACM Turing Award in 1982; Leonid Levin independently proved the equivalent result in the Soviet Union.
Richard Karp's landmark paper "Reducibility Among Combinatorial Problems" established 21 problems as NP-complete by reduction chains:
| Problem | NP-Complete? | Reduction From | Approximation | Applications |
|---|---|---|---|---|
| 3-SAT | Yes (first) | Any NP problem | None (no known PTAS) | Hardware verification, planning |
| Clique | Yes | 3-SAT | O(n / log²n) | Social network analysis |
| Vertex Cover | Yes | Clique (complement) | 2-approximation | Network security, bioinformatics |
| Hamiltonian Path | Yes | 3-SAT | None | Genome sequencing, routing |
| Travelling Salesman | Yes | Hamiltonian Path | 1.5× (Christofides) | Logistics, chip design |
| Graph 3-Coloring | Yes | 3-SAT | 4-coloring in P | Register allocation, scheduling |
| Subset Sum | Yes | 3-SAT | FPTAS exists | Cryptography, bin packing |
| Knapsack | Yes | Subset Sum | FPTAS exists | Resource allocation |
| Integer Linear Programming | Yes | Vertex Cover | Depends on structure | Operations research |
| Bin Packing | Yes | Subset Sum | (1+ε)-approx | Cloud resource scheduling |
Clique: Given a graph G and integer k, does G contain a clique (complete subgraph) of size k?
Reduction (Sipser, 2013, Theorem 7.32): Given a 3-CNF formula φ with k clauses, construct a graph G as follows:
(a ∨ b ∨ c), create three nodes labelled by the literals: (a,i), (b,i), (c,i) where i is the clause number.(x,i) and (y,j) (i ≠ j) if the literals x and y are not complementary (x ≠ ¬y).Why it works: A satisfying assignment makes at least one literal true in each clause. Pick one true literal per clause — these k nodes form a clique (no two can be contradictory, since the same assignment satisfies both; and they're in different clauses, so all edges between them exist). Conversely, any k-clique selects one literal from each clause; assigning those literals true is consistent (no edge means no contradiction) and satisfies all k clauses.
This reduction runs in O(n²) time — clearly polynomial. Therefore: if Clique could be solved in polynomial time, 3-SAT could too — and since 3-SAT is NP-hard, so is Clique.
Knowing a problem is NP-complete does not mean giving up. Four strategies exist:
1. Approximation algorithms: Find solutions guaranteed within a factor of optimal.
2. Exact exponential algorithms with good average case: SAT solvers.
3. Heuristics: No worst-case guarantee but fast in practice.
4. Fixed-parameter tractable (FPT) algorithms: Exponential only in a small parameter k, polynomial in input size n.
NP-completeness is the practitioner's red flag. When you can show that your optimisation problem is NP-complete — by reducing a known NP-complete problem to it in polynomial time — you know three things immediately: (1) no one has found a polynomial algorithm in 50+ years of trying; (2) you should look for approximation or heuristic approaches rather than exact polynomial solutions; (3) if you DO find a polynomial algorithm, you have solved P vs. NP and won $1,000,000.
The ability to recognise NP-complete structure in real problems — logistics, scheduling, genome assembly, circuit layout, network design — and to apply the right approximate or heuristic strategy, is one of the most practically valuable skills that comes from studying theoretical computer science.
Sources: Cook, S. A. (1971). The complexity of theorem-proving procedures. Proceedings of the 3rd Annual ACM Symposium on Theory of Computing, 151–158. | Karp, R. M. (1972). Reducibility among combinatorial problems. In R. E. Miller & J. W. Thatcher (Eds.), Complexity of Computer Computations (pp. 85–103). Plenum Press. | Sipser, M. (2013). Introduction to the Theory of Computation (3rd ed.). Cengage. | Christofides, N. (1976). Worst-case analysis of a new heuristic for the travelling salesman problem. Carnegie Mellon University Technical Report.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises