Tight Thresholds: MAX-3SAT, Clique and Set Cover
For a handful of central problems the story of this course has a perfect ending: a simple algorithm achieves some ratio, and for every doing better by is NP-hard. This lesson collects the three most famous examples, explains the reductions behind one of them in detail, and states the others with their exact assumptions. The underlying PCP constructions (Håstad's 3-bit PCP, label cover with parallel repetition, the Feige and Dinur-Steurer reductions) are far beyond a single lesson, so they are only sketched.
MAX-3SAT: the random assignment is optimal
For MAX-E3SAT (every clause has exactly 3 distinct variables) a uniformly random assignment satisfies each clause with probability , and the method of conditional expectations turns this into a deterministic algorithm satisfying at least clauses (Johnson, 1974; see The Method of Conditional Expectations). It even satisfies of the total, not just of OPT.
Theorem (Håstad, 2001). For every , it is NP-hard to distinguish satisfiable E3SAT formulas from those in which no assignment satisfies more than a fraction of the clauses. Hence MAX-E3SAT has no -approximation unless P = NP.
The algorithm uses no information about the formula at all, and still nothing polynomial does better. Håstad's proof goes through MAX-E3LIN2: equations . A random assignment satisfies half of them, and
Theorem (Håstad, 2001). For every , given a system of E3LIN2 equations, it is NP-hard to distinguish the case where a fraction can be satisfied from the case where at most can be.
(Completeness is essential here: whether all equations can be satisfied is decided by Gaussian elimination.) From E3LIN2 to E3SAT there is a short gadget reduction. The equation holds exactly when the assignment avoids the four patterns with an even number of ones; forbid each by a clause:
A satisfying assignment of the equation satisfies all four clauses; a violating one fails exactly one of them. (For , negate one variable.) So a fraction of satisfied equations becomes a fraction of satisfied clauses, and the gap becomes
The program checks the gadget on all 8 assignments, and then runs Johnson's algorithm on random E3SAT formulas.
import random
from itertools import product
gadget = [(1, 1, 1), (1, -1, -1), (-1, 1, -1), (-1, -1, 1)] # signs of x, y, z in the four clauses
print("x y z x+y+z clauses satisfied")
for a in product([0, 1], repeat=3):
sat = sum(any((s > 0) == bool(v) for s, v in zip(c, a)) for c in gadget)
print(f"{a[0]} {a[1]} {a[2]} {sum(a) % 2:5} {sat}")
def johnson(clauses, n):
"""Method of conditional expectations: fix x_1..x_n keeping E[#satisfied] from dropping."""
def expectation(assign):
total = 0.0
for c in clauses:
if any(abs(l) - 1 in assign and assign[abs(l) - 1] == (l > 0) for l in c):
total += 1
else:
free = sum(abs(l) - 1 not in assign for l in c)
total += 1 - 0.5 ** free if free else 0
return total
assign = {}
for i in range(n):
assign[i] = max([True, False], key=lambda b: expectation({**assign, i: b}))
return sum(any(assign[abs(l) - 1] == (l > 0) for l in c) for c in clauses)
rng = random.Random(42)
print("\n n m Johnson OPT 7/8 m")
for n, m in [(8, 30), (10, 45), (12, 60)]:
clauses = [[v * rng.choice([1, -1]) for v in rng.sample(range(1, n + 1), 3)] for _ in range(m)]
opt = max(sum(any(a[abs(l) - 1] == (l > 0) for l in c) for c in clauses) for a in product([False, True], repeat=n))
print(f"{n:2} {m:3} {johnson(clauses, n):7} {opt:4} {7 * m / 8:6.2f}")x y z x+y+z clauses satisfied
0 0 0 0 3
0 0 1 1 4
0 1 0 1 4
0 1 1 0 3
1 0 0 1 4
1 0 1 0 3
1 1 0 0 3
1 1 1 1 4
n m Johnson OPT 7/8 m
8 30 29 29 26.25
10 45 43 44 39.38
12 60 59 59 52.50
Every equation behaves as the gadget promises: four satisfied clauses when the parity is right, three when it is wrong. On random formulas Johnson's algorithm lands within a clause or two of the optimum, far above its promise of ; the theorem says that no polynomial algorithm can promise more on all formulas.
In C++
Johnson's algorithm with the conditional expectation computed exactly in integers (multiplied by 8, so every clause contributes ).
#include <cstdio>
#include <cstdlib>
#include <vector>
int main() {
std::vector<std::vector<int>> clauses = {{1, 2, 3}, {-1, 2, 4}, {-2, -3, 5}, {1, -4, -5}, {-1, -2, -3}, {3, 4, -5},
{-3, -4, 1}, {2, 5, -1}, {-2, 4, 5}, {1, 3, -5}, {-1, -4, 2}, {-3, -5, -2}};
int n = 5;
std::vector<int> val(n + 1, -1); // -1 = not yet fixed
auto expect8 = [&]() {
int total = 0;
for (auto& c : clauses) {
bool sat = false;
int fr = 0;
for (int l : c) {
int v = val[std::abs(l)];
if (v < 0) fr++;
else if ((v == 1) == (l > 0)) sat = true;
}
total += sat ? 8 : (fr ? 8 - (8 >> fr) : 0);
}
return total;
};
for (int i = 1; i <= n; i++) {
val[i] = 1;
int t = expect8();
val[i] = 0;
int f = expect8();
val[i] = t >= f ? 1 : 0;
std::printf("x%d = %d (8 * E = %d)\n", i, val[i], t >= f ? t : f);
}
std::printf("satisfied %d of %d clauses, 7/8 of them is %.1f\n", expect8() / 8, (int)clauses.size(), 7.0 * clauses.size() / 8);
}x1 = 1 (8 * E = 84)
x2 = 1 (8 * E = 85)
x3 = 0 (8 * E = 92)
x4 = 1 (8 * E = 96)
x5 = 1 (8 * E = 96)
satisfied 12 of 12 clauses, 7/8 of them is 10.5
Clique: nothing beats the trivial algorithm by much
A single vertex is a clique, so returning it is an -approximation. The best known polynomial algorithm improves this only to a ratio of (Feige, 2004), and that is nearly optimal:
Theorem (Håstad, 1999; Zuckerman, 2007). For every , maximum clique (and maximum independent set) has no -approximation unless P = NP. (Håstad proved it under NP ZPP; Zuckerman derandomized the construction.)
The route: the PCP theorem gives a constant gap; graph products amplify it to any constant (Gap-Preserving Reductions); and PCPs with very small amortized free bit complexity (Håstad) together with randomness-efficient products (expander walks, dispersers) push the gap to . The same bound holds for graph colouring (Feige and Kilian, 1998; Zuckerman, 2007).
Even random graphs resist. In the largest clique has about vertices, while greedy (repeatedly add the vertex adjacent to all chosen ones with the most such neighbours) finds about , and no polynomial algorithm is known to find a clique of size in such graphs (a question raised by Karp in 1976). The factor 2 is asymptotic: for small the lower-order terms dominate, and the program, comparing greedy with an exact branch-and-bound search, shows the gap only beginning to open.
import random
def random_graph(n, rng):
adj = [set() for _ in range(n)]
for u in range(n):
for v in range(u + 1, n):
if rng.random() < 0.5:
adj[u].add(v); adj[v].add(u)
return adj
def greedy_clique(adj):
cand, size = set(range(len(adj))), 0
while cand:
v = max(cand, key=lambda u: (len(adj[u] & cand), -u))
size += 1
cand &= adj[v]
return size
def max_clique(adj):
best = 0
def expand(size, cand):
nonlocal best
if not cand:
best = max(best, size)
return
for v in sorted(cand, key=lambda u: len(adj[u] & cand)):
if size + len(cand) <= best:
return
expand(size + 1, cand & adj[v])
cand = cand - {v}
expand(0, set(range(len(adj))))
return best
rng = random.Random(1)
print(" n greedy maximum log2 n")
for n in [16, 32, 64]:
adj = random_graph(n, rng)
print(f"{n:3} {greedy_clique(adj):7} {max_clique(adj):8} {n.bit_length() - 1:7}") n greedy maximum log2 n
16 4 4 4
32 6 6 5
64 8 9 6
Set cover: greedy is optimal up to lower-order terms
Greedy achieves (Greedy Set Cover).
Theorem (Dinur and Steurer, 2014). For every , set cover has no -approximation unless P = NP.
Sketch of the history. Lund and Yannakakis (1994) reduced label cover, a two-prover PCP, to set cover using a combinatorial gadget (set systems in which a cover must use complementary pairs) and obtained , under a quasi-polynomial assumption. Feige (1998) used multi-prover proof systems to reach the sharp constant under NP DTIME. Dinur and Steurer obtained the same threshold from P NP via an analytical approach to parallel repetition of label cover (Raz, 1998, proved that repeating a two-prover game times drives its soundness down exponentially in ; their version needs only a polynomial blow-up for the parameters required).
A table of thresholds
| Problem | Best algorithm | Hardness | Assumption |
|---|---|---|---|
| MAX-E3SAT | , random assignment | (Håstad, 2001) | P NP |
| MAX-E3LIN2 | , random assignment | (Håstad, 2001) | P NP |
| max clique / independent set | about | (Håstad, 1999; Zuckerman, 2007) | P NP |
| set cover | , greedy | (Dinur and Steurer, 2014) | P NP |
| metric -center | 2 | (Hsu and Nemhauser, 1979) | P NP |
| vertex cover | 2 | (Khot, Minzer and Safra, 2018); | P NP; UGC |
| max-cut | (Goemans and Williamson, 1995) | (Håstad, 2001; Trevisan, Sorkin, Sudan and Williamson, 2000); | P NP; UGC |
| metric TSP | (Karpinski, Lampis and Schmied, 2015) | P NP |
The first five rows are tight under P NP. For vertex cover and max-cut the gap between known algorithms and NP-hardness is closed only by the Unique Games Conjecture, the subject of the next lesson (The Unique Games Conjecture). Metric TSP remains wide open.
Test yourself
In the gadget from E3LIN2 to E3SAT, how many of the four clauses does an assignment that violates the equation satisfy?
- None
- Three: it matches exactly one forbidden pattern
- Two
- All four
Why does Håstad's E3LIN2 theorem need completeness instead of 1?
- Because the random assignment satisfies half of the equations
- Whether all equations can be satisfied is decidable in polynomial time by Gaussian elimination
- Because E3LIN2 is not in NP
- To make the gadget work
Which statement about maximum clique is proved under P NP?
- Clique has a 2-approximation
- For every there is no -approximation (Zuckerman, 2007, derandomizing Håstad)
- Clique is in APX
- Clique has a PTAS on all graphs
What is the threshold for set cover, and under which assumption?
- 2, under P NP
- , under P NP (Dinur and Steurer, 2014)
- , unconditionally
- , under the UGC