Hardness of Approximation

If the best answer is out of reach, how close can you get? Sometimes arbitrarily close, sometimes not one percent better than guessing. The PCP theorem says why

Hardness of Approximation

If finding the best answer is NP-hard, settle for a good one. For some problems a polynomial-time algorithm can get within one percent of the optimum. For others it provably cannot get within a factor of a million, unless P = NP. The line between the two is drawn by one of the deepest theorems in computer science.

Good Enough

Pick a problem and compare a fast algorithm’s answer with the true optimum. Drag the cities, press Play to watch the tour being built, and try “Worst case” on each tab to push the algorithm towards its bound.

Step 26 of 26. Short-cut: skip every city already visited. Straight lines are never longer than detours, so the tour is no longer than the walk.

0%
of the subsets searched
245
spanning tree: a lower bound on the optimum
415 = …
doubled-tree tour (guarantee 2 ×)
407 = …
Christofides tour (guarantee 1.5 ×)
Tree plus matching is 415: less than the optimum for the tree, and at most half the optimum for the matching. The short-cut tour, 407, is therefore within 1.5 × of a number the algorithm never computes.

Drag a city to move it; tap empty space to add one (up to 12, the cap that keeps the exact search instant). Rose dots: the optimal tour, found by exponential search. White: spanning tree. Amber: matching on the odd cities. Indigo arrows: the Euler walk. Sky: the tour the algorithm returns. Lengths are in hundredths of the picture’s height. “Worst case” is a zigzag tuned by search to be bad for both algorithms; the bounds 2 and 1.5 are only approached with many more cities. The matching is found here by exhaustive dynamic programming; the real algorithm uses Edmonds’ polynomial-time matching.

Go deeper:Approximation Algorithms and Their Guarantees

An α-approximation algorithm runs in polynomial time and, on every input, returns a solution within a factor α of the optimum. The difficulty is that the algorithm cannot compute the optimum it is being compared with. Every proof therefore rests on a lower bound for the optimum that the algorithm can see. For the travelling salesman it is the minimum spanning tree: delete one leg of the best tour and a spanning tree remains, so the tree is shorter. Walking round the tree costs twice the tree, and short-cuts never lengthen a walk when distances obey the triangle inequality, which gives a factor 2.

Nicos Christofides (1976), and independently Anatoliy Serdyukov, replaced the doubling by a minimum-weight perfect matching on the tree’s odd-degree vertices. The best tour, short-cut to those vertices, splits into two matchings, so the cheaper one costs at most half the optimum, and the total is at most 3/2. For vertex cover the visible lower bound is a matching: no vertex can cover two of its edges, so taking both ends of a maximal matching is within a factor 2.

For MAX-3SAT a clause on three different variables fails a uniformly random assignment with probability 1/8, so the expected number of satisfied clauses is 7/8 of all of them, and the optimum is at most all of them. David Johnson (1974) removed the coins by the method of conditional expectations: fix one variable at a time, always to the value that keeps the expected count from falling. For set cover the greedy algorithm is within a factor H(k) = 1 + 1/2 + … + 1/k, about ln k, where k is the size of the largest set; here the ratio is not a constant, and the worst-case tab shows it growing.

The demos compare each algorithm with an optimum found by exponential search on a dozen or so items. That checks the guarantees on small cases; the guarantees themselves are theorems, true at every size. See also: The Web of Reductions, where these problems are shown to be one problem in disguise as far as exact solution goes. As the next demo shows, approximation tells them apart.

The Thresholds

Tap a bar to see who proved what. Then slide ε to buy accuracy with time on a knapsack, and switch to arbitrary distances to see a claimed ratio turn into a test for Hamiltonian cycles.

← a trivial answerthe exact optimum →

Travelling salesman, any metric

Minimisation · Constant factor

A wide unexplained gap: nobody knows where between about 1.008 and 1.5 the truth lies.

Achieved in polynomial time: 3/2 (minus a tiny constant)
Nicos Christofides, 1976, and independently Anatoliy Serdyukov: 3/2. Anna Karlin, Nathan Klein and Shayan Oveis Gharan, 2020: slightly below 3/2, by a constant of about 10−36.
NP-hard to do better than: 123/122
Marek Karpinski, Michael Lampis and Richard Schmied, 2013.

The hatched stretch is open: no polynomial-time algorithm is known there, and no proof that none exists.

Tap a problem for its sources. Position along a bar is the guaranteed fraction of the optimum (for a minimisation problem, optimum ÷ guaranteed cost). Sky: reached by a known polynomial-time algorithm. Rose: proved NP-hard to reach, so out of reach unless P = NP. Hatched: unknown. With the conjecture switched on, the paler rose with a dashed edge shows what would also be hard; those stretches are conditional.

Knapsack: buy accuracy with time

Pack the most value into a bag of limited weight. Slide ε down and watch the answer close in on the optimum while the table grows.

24,193
value packed by the scheme (93.6% of optimal)
25,850
true optimum
882
table cells the scheme filled
769
rounding unit K: values are counted in multiples of this
Promised: at least 50.0% of the optimum. Delivered: 93.6%. Halving ε roughly doubles the table. The promise holds for every instance, and the cost is polynomial in both the number of items and 1/ε, which is what “fully polynomial approximation scheme” means.

14 items; bar height shows value (on a square-root scale, so that small items stay visible), weights are roughly proportional to value, and the number beneath is the rounded value the scheme works with: an item rounded to 0 is invisible to it. Sky: packed by the scheme. Dashed rose outline: in an optimal packing. The exact method is the same dynamic programme on unrounded values; its table grows with the size of the numbers themselves, which is exponential in their number of digits, so it is only affordable here because the values are below 20,000. The scheme’s table has at most n³/ε cells whatever the values are.

Go deeper:Classes of Approximability and the Unique Games Conjecture

NP-complete problems are all equally hard to solve exactly, in the sense that each reduces to every other. Those reductions do not preserve how good an approximate answer is, and the optimisation versions fall into very different classes. Some have an approximation scheme: for every ε > 0 a polynomial-time algorithm within a factor 1 + ε. Knapsack has a fully polynomial one, with time polynomial in 1/ε as well (Oscar Ibarra and Chul Kim, 1975); points in the plane have a scheme for the travelling salesman (Sanjeev Arora, 1996, and independently Joseph Mitchell). Some problems have a constant factor and provably nothing better than some other constant. Set cover has a logarithmic factor and no constant. Clique has essentially nothing.

A hardness threshold is a theorem of the form “achieving ratio r in polynomial time would imply P = NP”. The oldest is the one run in the demo: Sartaj Sahni and Teofilo Gonzalez (1976) observed that for the travelling salesman with arbitrary distances any constant ratio at all would decide Hamiltonian cycle. Thresholds for problems such as MAX-3SAT, vertex cover and clique were out of reach until the PCP theorem of the next demo. With it, Johan Håstad proved in 2001 that beating 7/8 for MAX-3SAT by any constant is NP-hard, so the coin-flipping algorithm is the best possible unless P = NP.

Several bars still have a gap. The Unique Games Conjecture, proposed by Subhash Khot in 2002, asserts that a particular constraint-satisfaction problem is NP-hard to approximate. If it is true, many gaps close exactly: factor 2 is optimal for vertex cover (Khot and Oded Regev, 2008), and the Goemans–Williamson constant 0.878… is optimal for Max Cut (Khot, Guy Kindler, Elchanan Mossel and Ryan O’Donnell). The conjecture is open, and researchers are divided about it. Every statement that depends on it is conditional, and the demo marks those separately from the theorems.

Three Queries

The grid is a proof, and the verifier reads only three of its cells: flip some cells, run the test, and watch the chance of being caught track how wrong the table is. Then slide an approximation ratio into the gap below.

The proof: a table of f on all 64 six-bit inputs. Row = first three bits, column = last three.
000001010011100101110111000001010011100101110111
No test run yet on this table. The verifier will read three of the 64 cells.
Start from the linear function f(x) = x1 ⊕ x3 ⊕ x4. Choose which input bits it adds up:
6/64 = 9.4%
δ: cells that differ from the nearest linear function
22.9%
exact chance one test rejects, over all 4,096 pairs (x, y)
—
tests rejected so far
7.5%
chance this table survives 10 tests
The nearest linear function is x1 ⊕ x3 ⊕ x4, and 6 cells (rose dots) disagree with it: δ = 9.4%. One test of three cells rejects with probability 22.9%, which is at least δ, as the theorem promises. After 10 tests the table survives with probability 7.5%.

Tap any cell to flip it. Lime rings: the two cells chosen by coin flips. Teal ring: the third cell, x ⊕ y, which the first two determine. Rose dots: cells where the table differs from the nearest linear function, found by comparing with all 64 of them. On the chart, lime dots are random corruptions of random linear functions, the indigo ring is your table, and the short lime bar is your measured rejection rate. This is the linearity test only, on a 64-cell table. It is not a PCP: a real one encodes a whole NP witness in such tables (exponentially long ones, in the simplest textbook construction) and adds further tests to check that the encoded witness is valid.

From checking proofs to hardness of approximation

A proof checked by a few random queries is a formula with a gap: either every local check can pass, or a constant fraction must fail. Slide the approximation ratio into the gap.

False statements map to formulas with at most
The ratio is inside the gap. Run the algorithm on the reduction’s output: if it satisfies more than 88.5% of the clauses the original statement was true, and otherwise it was false. That decides an NP-complete problem in polynomial time, so an algorithm this good exists only if P = NP.

This panel is a diagram of the argument, not a computation: the rose shape only marks where false statements can land: at most 7/8 + ε (Håstad, 2001; drawn with ε = 0.01). Emerald: formulas from true statements. Sky: the algorithm’s guarantee. Hatched: the gap. Producing a gap at all is the content of the PCP theorem; without it a false statement could map to a formula with all clauses but one satisfiable, and no approximation algorithm would notice.

Go deeper:The PCP Theorem

The PCP theorem says that every proof of an NP statement can be rewritten in a form that a randomised verifier checks by reading only a constant number of its bits: a correct proof is always accepted, and for a false statement every purported proof is rejected with constant probability. In symbols, NP = PCP(log n, O(1)): logarithmically many random bits, constantly many queries. It was proved in 1992 by Sanjeev Arora and Shmuel Safra and by Arora, Carsten Lund, Rajeev Motwani, Madhu Sudan and Mario Szegedy, building on the theory of interactive proofs. Irit Dinur gave a combinatorial proof by gap amplification in 2006. See also: Proofs as Conversations.

The demo runs one ingredient only, and is not a PCP. The linearity test of Manuel Blum, Michael Luby and Ronitt Rubinfeld (1990) reads f(x), f(y) and f(x ⊕ y) for random x and y. If f is at distance δ from the nearest linear function, the test rejects with probability at least δ. Writing f̂(S) for the correlation of f with the linear function of the subset S, the rejection probability is exactly ½ − ½ Σ f̂(S)3, and the bound follows because the squares of the f̂(S) add up to 1. In the algebraic proof of the theorem the prover writes the witness in an error-correcting code built from linear functions, so that any lie is smeared across many positions, and tests like this one are how the verifier confirms that the table it is reading is a codeword at all.

The link to approximation was found by Uriel Feige, Shafi Goldwasser, László Lovász, Shmuel Safra and Mario Szegedy in 1991, for Clique. In the form used here: the verifier’s possible checks, one for each outcome of its coins, are constraints on the bits of the proof. For a true statement some proof satisfies all of them; for a false one every proof violates a constant fraction. So the PCP theorem is equivalent to a statement about approximation: there is a constant ρ < 1 such that telling satisfiable 3-CNF formulas from those in which at most a ρ fraction of the clauses can be satisfied is NP-hard. An approximation algorithm with ratio better than ρ would tell them apart.

All of these hardness results are conditional on P ≠ NP, which is unproved. What is proved is the implication: an algorithm beating the threshold would give P = NP.

Key Takeaways

  • An approximation algorithm is proved good by comparing it with a lower bound it can see, such as a spanning tree or a matching, never with the optimum itself.
  • Problems that are equally hard to solve exactly differ enormously in approximation: knapsack to any accuracy, vertex cover within 2, set cover within ln n, clique hardly at all.
  • Three random queries catch a table that is far from linear with probability at least its distance, and repeating the test drives the error down geometrically.
  • The PCP theorem (1992) turns proof checking into a gap, and with it thresholds such as Håstad’s 7/8 for MAX-3SAT are known exactly, assuming P ≠ NP.

Spot a mistake or have an idea?

Search