TExcelTAD
Home › Approximation Algorithms › Tight Thresholds: MAX-3SAT, Clique and Set Cover

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 ε>0\varepsilon > 0 doing better by ε\varepsilon 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 78\frac{7}{8}, and the method of conditional expectations turns this into a deterministic algorithm satisfying at least 78m\frac{7}{8}m clauses (Johnson, 1974; see The Method of Conditional Expectations). It even satisfies 78\frac{7}{8} of the total, not just of OPT.

Theorem (Håstad, 2001). For every ε>0\varepsilon > 0, it is NP-hard to distinguish satisfiable E3SAT formulas from those in which no assignment satisfies more than a 78+ε\frac{7}{8} + \varepsilon fraction of the clauses. Hence MAX-E3SAT has no (78+ε)(\frac{7}{8} + \varepsilon)-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 xi+xj+xk=b(mod2)x_i + x_j + x_k = b \pmod 2. A random assignment satisfies half of them, and

Theorem (Håstad, 2001). For every ε>0\varepsilon > 0, given a system of E3LIN2 equations, it is NP-hard to distinguish the case where a 1−ε1 - \varepsilon fraction can be satisfied from the case where at most 12+ε\frac{1}{2} + \varepsilon can be.

(Completeness 1−ε1 - \varepsilon 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 x+y+z=1x + y + z = 1 holds exactly when the assignment avoids the four patterns with an even number of ones; forbid each by a clause:

(x∨y∨z)∧(x∨yˉ∨zˉ)∧(xˉ∨y∨zˉ)∧(xˉ∨yˉ∨z).(x \vee y \vee z) \wedge (x \vee \bar y \vee \bar z) \wedge (\bar x \vee y \vee \bar z) \wedge (\bar x \vee \bar y \vee z) .

A satisfying assignment of the equation satisfies all four clauses; a violating one fails exactly one of them. (For b=0b = 0, negate one variable.) So a fraction ff of satisfied equations becomes a fraction f+(1−f)34f + (1 - f)\frac{3}{4} of satisfied clauses, and the gap (1−ε, 12+ε)(1 - \varepsilon,\ \frac{1}{2} + \varepsilon) becomes

(1−ε4,  78+ε4).\left(1 - \frac{\varepsilon}{4},\ \ \frac{7}{8} + \frac{\varepsilon}{4}\right) .

The program checks the gadget on all 8 assignments, and then runs Johnson's algorithm on random E3SAT formulas.

python · try it yourself
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 78m\frac{7}{8}m; 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 8(1−2−r)8(1 - 2^{-r})).

cpp · try it yourself
#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 1n\frac{1}{n}-approximation. The best known polynomial algorithm improves this only to a ratio of O(n(log⁡log⁡n)2(log⁡n)3)O\big(\frac{n (\log \log n)^2}{(\log n)^3}\big) (Feige, 2004), and that is nearly optimal:

Theorem (Håstad, 1999; Zuckerman, 2007). For every ε>0\varepsilon > 0, maximum clique (and maximum independent set) has no n1−εn^{1 - \varepsilon}-approximation unless P = NP. (Håstad proved it under NP ≠\ne 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 n1−εn^{1 - \varepsilon}. The same bound holds for graph colouring (Feige and Kilian, 1998; Zuckerman, 2007).

Even random graphs resist. In G(n,12)G(n, \frac{1}{2}) the largest clique has about 2log⁡2n2\log_2 n vertices, while greedy (repeatedly add the vertex adjacent to all chosen ones with the most such neighbours) finds about log⁡2n\log_2 n, and no polynomial algorithm is known to find a clique of size (1+ε)log⁡2n(1 + \varepsilon)\log_2 n in such graphs (a question raised by Karp in 1976). The factor 2 is asymptotic: for small nn the lower-order terms dominate, and the program, comparing greedy with an exact branch-and-bound search, shows the gap only beginning to open.

python · try it yourself
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 Hn≤ln⁡n+1H_n \le \ln n + 1 (Greedy Set Cover).

Theorem (Dinur and Steurer, 2014). For every ε>0\varepsilon > 0, set cover has no (1−ε)ln⁡n(1 - \varepsilon)\ln n-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 14log⁡2n\frac{1}{4}\log_2 n, under a quasi-polynomial assumption. Feige (1998) used multi-prover proof systems to reach the sharp constant (1−ε)ln⁡n(1 - \varepsilon)\ln n under NP ⊈\not\subseteq DTIME(nO(log⁡log⁡n))(n^{O(\log \log n)}). Dinur and Steurer obtained the same threshold from P ≠\ne NP via an analytical approach to parallel repetition of label cover (Raz, 1998, proved that repeating a two-prover game kk times drives its soundness down exponentially in kk; their version needs only a polynomial blow-up for the parameters required).

A table of thresholds

Problem Best algorithm Hardness Assumption
MAX-E3SAT 78\frac{7}{8}, random assignment 78+ε\frac{7}{8} + \varepsilon (Håstad, 2001) P ≠\ne NP
MAX-E3LIN2 12\frac{1}{2}, random assignment 12+ε\frac{1}{2} + \varepsilon (Håstad, 2001) P ≠\ne NP
max clique / independent set about 1n\frac{1}{n} n−(1−ε)n^{-(1 - \varepsilon)} (Håstad, 1999; Zuckerman, 2007) P ≠\ne NP
set cover HnH_n, greedy (1−ε)ln⁡n(1 - \varepsilon)\ln n (Dinur and Steurer, 2014) P ≠\ne NP
metric kk-center 2 2−ε2 - \varepsilon (Hsu and Nemhauser, 1979) P ≠\ne NP
vertex cover 2 2−ε\sqrt{2} - \varepsilon (Khot, Minzer and Safra, 2018); 2−ε2 - \varepsilon P ≠\ne NP; UGC
max-cut 0.8780.878 (Goemans and Williamson, 1995) 1617+ε\frac{16}{17} + \varepsilon (Håstad, 2001; Trevisan, Sorkin, Sudan and Williamson, 2000); 0.878+ε0.878 + \varepsilon P ≠\ne NP; UGC
metric TSP 32−10−36\frac{3}{2} - 10^{-36} 123122\frac{123}{122} (Karpinski, Lampis and Schmied, 2015) P ≠\ne NP

The first five rows are tight under P ≠\ne 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?

  1. None
  2. Three: it matches exactly one forbidden pattern
  3. Two
  4. All four

Why does Håstad's E3LIN2 theorem need completeness 1−ε1 - \varepsilon instead of 1?

  1. Because the random assignment satisfies half of the equations
  2. Whether all equations can be satisfied is decidable in polynomial time by Gaussian elimination
  3. Because E3LIN2 is not in NP
  4. To make the gadget work

Which statement about maximum clique is proved under P ≠\ne NP?

  1. Clique has a 2-approximation
  2. For every ε>0\varepsilon > 0 there is no n1−εn^{1 - \varepsilon}-approximation (Zuckerman, 2007, derandomizing Håstad)
  3. Clique is in APX
  4. Clique has a PTAS on all graphs

What is the threshold for set cover, and under which assumption?

  1. 2, under P ≠\ne NP
  2. (1−ε)ln⁡n(1 - \varepsilon)\ln n, under P ≠\ne NP (Dinur and Steurer, 2014)
  3. log⁡2n\log_2 n, unconditionally
  4. HnH_n, under the UGC