The Web of Reductions

Thousands of hard problems turn out to be one problem in disguise. Follow an instance through a chain of translations and carry its solution all the way back

The Web of Reductions

A reduction is a translator. It rewrites any instance of one problem as an instance of another, so that the two have the same answer. A year after Cook’s theorem, Richard Karp used reductions to show that twenty-one well-known problems from all over mathematics, about graphs, sets, schedules and sums, were the same problem wearing different clothes. This lesson runs the translations, in both directions.

A Chain of Translations

Press Solve and carry forward and watch one solution appear in three worlds. Then clear it and work backwards by ticking numbers until the sum hits the target, or try All eight clauses and see all three searches come back empty.

World A · 3-SAT
exhaustive search: 0 assignments…
(∨∨)
(∨∨)
(∨∨)

Tap a literal to change it. Tap C1, C2, … or a variable to light up its gadget in the graph and its digits in the table.

World B · Vertex Cover, size 9
exhaustive search: 0 partial covers…
x₁¬x₁x₂¬x₂x₃¬x₃x₁¬x₂x₃¬x₁x₂x₃x₁x₂¬x₃
World C · Subset Sum, 36 numbers of 22 base-4 digits
exhaustive search: 0 partial subsets…
gadgetcountvariablesC1C2C3
target9222222222222222222222
sum of chosen0000000000000000000000
x₁11·····1···········1··
¬x₁11···········1········
x₂1·1···········1·····1·
¬x₂1·1·····1·············
x₃1··1·····1·····1······
¬x₃1··1·················1
C1 corner x₁1···11·1··············
C1 corner ¬x₂1···1·1·1·············
C1 corner x₃1····11··1············
C2 corner ¬x₁1·········11·1········
C2 corner x₂1·········1·1·1·······
C2 corner x₃1··········11··1······
C3 corner x₁1···············11·1··
C3 corner x₂1···············1·1·1·
C3 corner ¬x₃1················11··1
slack e1·1····················
slack e2··1···················
slack e3···1··················
slack e4····1·················
slack e5·····1················
slack e6······1···············
slack e7·······1··············
slack e8········1·············
slack e9·········1············
slack e10··········1···········
slack e11···········1··········
slack e12············1·········
slack e13·············1········
slack e14··············1·······
slack e15···············1······
slack e16················1·····
slack e17·················1····
slack e18··················1···
slack e19···················1··
slack e20····················1·
slack e21·····················1

Read as one number in ordinary decimal, the target is 42,514,449,607,338.

3 · 3
formula: variables · clauses (n and m), 9 literals
15 · 21
graph: vertices · edges (2n + 3m and n + 6m); cover size n + 2m = 9
36 × 22
numbers × digits each: one number per vertex and per edge
searching…
exhaustive search in worlds A, B and C
Press Solve and carry forward, or work backwards: tick numbers in the table (or tap vertices in the graph) until every column of the sum matches the target.

Amber marks the chosen solution in every world; emerald edges and digits are satisfied, and indigo is the gadget you are pointing at. A vertex of the graph and its row of the table are the same choice: ticking one ticks the other. The first column counts chosen vertices; each later column belongs to one edge and holds a 1 for its two ends and for its slack number, so no column can exceed 3 and nothing carries in base 4. The three searches are honest but tiny: formulas here are capped at 4 variables and 8 clauses, and what happens at this size says nothing about large instances.

Go deeper:What a Reduction Is, and These Two in Particular

A polynomial-time many-one reduction from a problem A to a problem B, also called a Karp reduction, is a function f that can be computed in polynomial time and satisfies: x is a yes-instance of A exactly when f(x) is a yes-instance of B. Reductions compose, since running one polynomial-time translator after another is still polynomial time. Two consequences follow at once. If A reduces to B and B is in P, then A is in P: translate, then solve. And read the other way, if A is NP-hard then so is B. A problem is NP-complete if it is in NP and every problem in NP reduces to it.

3-SAT to Vertex Cover. For a formula with n variables and m clauses, draw an edge for each variable joining its two literals, a triangle for each clause, and an edge from each triangle corner to the literal it names. Any cover needs one end of each variable edge and two corners of each triangle, which is already n + 2m vertices. A cover of exactly that size has no vertex to spare, so in each triangle the one corner left out must have its link covered from the far end, by a literal the cover chose. Reading the chosen literals as “true” gives an assignment in which every clause has a true literal, and the argument runs equally well in reverse.

Vertex Cover to Subset Sum. Number the edges and give each a digit position. A vertex becomes a number with a leading 1 and a 1 in the position of each edge it touches; each edge also gets a slack number with a single 1. The target is k followed by all 2s. A column can collect at most three 1s, so in base 4 no column carries into its neighbour, and the sum can be read digit by digit: the leading digit counts vertices, and an edge’s digit reaches 2 exactly when at least one of its ends was chosen. Both constructions are the textbook ones, as found in Garey and Johnson (1979), Sipser, and Cormen, Leiserson, Rivest and Stein.

Notice how long the numbers are: one digit for every edge. That is essential. When the numbers are small, dynamic programming solves Subset Sum in time proportional to the count of numbers times the target, which is fast. Subset Sum is hard only when its numbers have many digits, a situation called weak NP-completeness. See also: P versus NP in the Computational Complexity module, which searches Subset Sum directly, and Reductions there, for three other translations out of 3-SAT.

Karp’s Twenty-One

Tap any problem to read what it asks and see the path of reductions that reaches it from Satisfiability. Problems marked with a dot come with a tiny instance, solved in front of you; press New instance for another.

21 problems, 1 question
● has a live instance
Partition

Given a list of whole numbers, can it be split into two groups with the same sum?

→→→→→
7239111717
A tiny instance, solved by trying everything

The amber numbers and the sky numbers both add up to 33.

21
problems in Karp’s 1972 paper
20
reductions drawn, each a polynomial-time translation
5
reductions from Satisfiability to Partition
12
problems with a live instance here
Follow the indigo path. Composing its 5 translations turns any formula into an instance of Partition with the same answer, so a fast algorithm for Partition would be a fast algorithm for Satisfiability, and through it for every problem in NP.

Arrows are the reductions Karp gave: an arrow from A to B means instances of A can be rewritten as instances of B. Since all 21 are NP-complete, a reduction exists between any two of them, in both directions; the tree only records the route Karp took. The live instances have about seven items and are solved by trying every candidate, which is exactly what stops working as they grow. What came after: Garey and Johnson’s 1979 book catalogued over 300 NP-complete problems, and thousands are known now, including generalised versions of puzzles and games such as Sudoku on n² × n² grids, Minesweeper consistency and Tetris.

Go deeper:Why This Paper Mattered as Much as Cook’s

Cook’s theorem (1971) showed that one problem from logic, Satisfiability, is as hard as anything in NP. On its own that could have been a curiosity. Richard Karp’s 1972 paper “Reducibility Among Combinatorial Problems” showed it was nothing of the kind. Starting from Satisfiability and reducing step by step, he proved the same of twenty more problems: finding cliques, covering and packing sets, colouring graphs, routing through every vertex, sequencing jobs, splitting numbers evenly. These were the problems people in operations research and computer science actually needed to solve, and had been failing to solve efficiently for years.

The tree shows the reductions Karp gave, but the conclusion is stronger than the tree. Each of the 21 is in NP, so by Cook’s theorem each reduces to Satisfiability; and Satisfiability reduces to each of them along the arrows. So any one of them reduces to any other. Either all of them have polynomial-time algorithms or none of them does, and nobody knows which. Most researchers believe none does, but that is a belief, not a theorem.

Two terms are worth keeping apart. A problem is NP-hard if every problem in NP reduces to it. It is NP-complete if, in addition, it is itself in NP. NP-complete problems are the hardest problems in NP; they are not the hardest problems there are, and they are not unsolvable. Each can be solved by exhaustive search in exponential time, and many instances met in practice are easy. Some names have also shifted since 1972: Karp’s Knapsack is what is now called Subset Sum, and his Hitting Set asks for a set meeting each given set in exactly one element.

Stephen Cook received the Turing Award in 1982 and Richard Karp in 1985. Michael Garey and David Johnson’s 1979 book Computers and Intractability catalogued more than 300 NP-complete problems, and the list has grown into the thousands since.

Finding from Deciding

Press Play and watch an assignment locked in one variable at a time, using only yes/no answers; then switch to the largest clique. Turn on Make the oracle lie once and see what the verifier catches and what it cannot.

The assignment being built
x₁
·
x₂
·
x₃
·
x₄
·
x₅
·
x₆
·
x₇
·
x₈
·
x₉
·
x₁₀
·
φ = (x₆ ∨ x₇ ∨ x₈) (¬x₂ ∨ x₅ ∨ ¬x₇) (x₂ ∨ x₅ ∨ ¬x₉) (x₁ ∨ x₃ ∨ x₉) (¬x₂ ∨ ¬x₃ ∨ ¬x₄) (¬x₅ ∨ ¬x₈ ∨ ¬x₉) (¬x₁ ∨ x₃ ∨ ¬x₅) (¬x₅ ∨ x₆ ∨ ¬x₈) (¬x₂ ∨ ¬x₄ ∨ x₇) (x₅ ∨ ¬x₇ ∨ x₁₀) (¬x₁ ∨ x₅ ∨ ¬x₁₀) (x₅ ∨ x₉ ∨ x₁₀) (x₃ ∨ x₄ ∨ x₁₀) (x₅ ∨ ¬x₆ ∨ x₉) (x₁ ∨ x₂ ∨ x₉) (x₁ ∨ x₈ ∨ ¬x₉) (x₁ ∨ ¬x₇ ∨ ¬x₈) (¬x₁ ∨ x₂ ∨ x₅) (x₄ ∨ x₅ ∨ x₁₀) (x₂ ∨ x₆ ∨ x₇) (x₁ ∨ x₆ ∨ ¬x₁₀) (x₂ ∨ ¬x₇ ∨ ¬x₉) (¬x₁ ∨ ¬x₂ ∨ x₄) (¬x₁ ∨ x₈ ∨ ¬x₁₀) (x₂ ∨ x₆ ∨ x₉) (x₂ ∨ x₅ ∨ ¬x₉) (¬x₂ ∨ ¬x₃ ∨ x₅) (¬x₅ ∨ ¬x₇ ∨ x₁₀) (x₃ ∨ ¬x₄ ∨ x₅) (¬x₂ ∨ ¬x₈ ∨ x₉) (x₅ ∨ x₇ ∨ ¬x₈) (¬x₃ ∨ ¬x₇ ∨ x₈) (¬x₂ ∨ x₅ ∨ ¬x₇) (¬x₄ ∨ x₈ ∨ ¬x₁₀) (x₁ ∨ ¬x₃ ∨ x₁₀) (¬x₅ ∨ ¬x₆ ∨ ¬x₉) (¬x₅ ∨ ¬x₉ ∨ ¬x₁₀) (x₁ ∨ ¬x₄ ∨ x₉) (¬x₁ ∨ ¬x₂ ∨ x₈) (¬x₁ ∨ ¬x₃ ∨ x₇) (¬x₃ ∨ ¬x₇ ∨ x₁₀) (¬x₂ ∨ ¬x₆ ∨ ¬x₈) (¬x₅ ∨ ¬x₇ ∨ ¬x₉) (¬x₃ ∨ x₆ ∨ x₁₀) (¬x₅ ∨ ¬x₆ ∨ x₇) (¬x₃ ∨ ¬x₄ ∨ ¬x₆) (x₃ ∨ ¬x₅ ∨ ¬x₈) (¬x₁ ∨ x₃ ∨ x₆) (x₁ ∨ ¬x₈ ∨ x₁₀) (¬x₂ ∨ x₃ ∨ x₉) (¬x₃ ∨ x₈ ∨ ¬x₉) (¬x₅ ∨ x₈ ∨ ¬x₉) (¬x₁ ∨ x₅ ∨ x₆) (¬x₂ ∨ ¬x₃ ∨ x₁₀) (¬x₃ ∨ x₅ ∨ ¬x₉) (x₆ ∨ x₈ ∨ ¬x₉) (x₃ ∨ x₈ ∨ x₁₀) (x₁ ∨ ¬x₆ ∨ x₁₀) (¬x₂ ∨ ¬x₅ ∨ ¬x₇) (¬x₂ ∨ x₃ ∨ x₁₀)
Questions to the oracle0 asked
  1. Nothing asked yet. Press Play or Step.
0 / 11
oracle questions asked
n + 1 = 11
questions an honest run needs
702
assignments exhaustive search tries before one works
210 = 1,024
candidates in the worst case
The oracle says only yes or no. First ask whether φ is satisfiable at all; then, for each variable in turn, ask whether it still is with that variable set to true.

The chart’s scale is logarithmic: each gridline is four times the one before. Sky counts questions, rose counts candidates examined by exhaustive search on the same instance (for assignments it stops at the first that works, so its length is partly luck; the dashed outline is every assignment there is). The comparison is about how many questions are needed, not about total work: inside the box the oracle here is an ordinary exponential-time solver. If the yes/no problem had a polynomial-time algorithm, each question would be cheap and so would the whole search. Instances are capped at 14 variables and 12 vertices so that exhaustive search finishes at once.

Go deeper:Self-Reducibility: Why a Yes/No Question Is Enough

P versus NP is stated for decision problems, questions with a yes or no answer. That can look like a cheat: who wants to know that a schedule exists without being handed one? The demo shows why nothing is lost. A satisfying assignment can be extracted with n + 1 calls to a procedure that only decides satisfiability, because fixing a variable in a formula gives another formula. The size of the largest clique comes from a binary search with about log2 n questions of the form “is there a clique of size at least k?”, and the clique itself from n more.

This property is called self-reducibility, and every NP-complete problem has a form of it: its search version, and where there is one its optimisation version, are polynomial-time equivalent to its decision version. So P = NP really would mean that solutions and optima could be found in polynomial time, not merely shown to exist. Whether that is so is the open question; and a polynomial-time algorithm need not be a practical one.

The same is not known for every problem in NP. For factoring, for instance, the natural task is a search and the yes/no version has to be set up with some care, and under plausible but unproved assumptions there are NP problems whose search version is harder than their decision version.

These procedures use a different kind of reduction from the first demo. A Karp reduction translates one instance into one instance and passes the answer straight through. Here the algorithm calls the oracle many times and thinks in between; that is a Turing reduction, also called a Cook reduction. When the oracle lies, the difference between yes and no shows again: a wrong solution is caught by checking it, but a false “no”, or a clique that is valid and merely not the largest, leaves nothing to check.

Key Takeaways

  • A reduction translates instances of A into instances of B with the same answer, in polynomial time; a fast algorithm for B then gives one for A.
  • Gadgets do the translating: variables become edges, clauses become triangles, edges become digits, and solutions travel both ways.
  • Karp (1972) showed 21 problems NP-complete; thousands are known now, and either all are in P or none is, which is open.
  • For NP-complete problems a yes/no oracle is enough to find solutions and optima, with polynomially many questions.

Spot a mistake or have an idea?

Search