Gap-Preserving Reductions
The PCP theorem gives one hard gap problem: distinguishing satisfiable 3-CNF formulas from those in which every assignment violates an fraction of the clauses (The PCP Theorem). To prove hardness for other problems we need reductions that carry a gap along, in the same way ordinary reductions carry NP-hardness. This lesson defines them, derives constant-factor hardness for independent set and vertex cover from MAX-3SAT, and then amplifies the gap for independent set until no constant factor survives.
Definition
Let be a maximization problem and a maximization or minimization problem. A gap-preserving reduction with parameters and is a polynomial-time map with
(for a minimization , the inequalities on the right are and ). If is NP-hard, so is , and has no approximation ratio better than (or for minimization) unless P = NP. The thresholds may depend on the instance, for example on the number of clauses.
A related notion, the L-reduction of Papadimitriou and Yannakakis (1991), requires and that solutions map back with the absolute error growing by at most a factor . L-reductions preserve the existence of a PTAS, and they define the class MAX-SNP, whose complete problems (MAX-3SAT, vertex cover in bounded-degree graphs, metric TSP with distances 1 and 2, and others) became APX-hard once the PCP theorem was proved.
From MAX-3SAT to independent set
Given a 3-CNF formula with clauses, build a graph :
- one vertex for each occurrence of a literal in a clause (at most vertices);
- the vertices of each clause form a triangle (so an independent set picks at most one literal per clause);
- every pair of vertices with complementary literals ( and ) is joined by an edge (so the chosen literals are consistent).
Lemma. The maximum independent set of equals the maximum number of simultaneously satisfiable clauses of .
Proof. Given an assignment satisfying clauses, choose one true literal in each satisfied clause: no two are in the same triangle, and no two are complementary because all are true. Conversely, an independent set of size contains no complementary pair, so its literals can all be made true by one assignment (others arbitrary), which satisfies the clauses they come from.
So the reduction maps (thresholds and ) exactly onto with thresholds and : maximum independent set (and, in the complement graph, maximum clique) has no -approximation unless P = NP.
Vertex cover. The complement of an independent set is a vertex cover, so on with vertices the optimum cover is for satisfiable and more than otherwise. With the ratio is at least , so vertex cover is APX-hard and has no PTAS unless P = NP.
from itertools import product, combinations
def to_graph(clauses):
V = [(j, lit) for j, c in enumerate(clauses) for lit in c] # literal occurrences
E = set()
for a, b in combinations(range(len(V)), 2):
(ja, la), (jb, lb) = V[a], V[b]
if ja == jb or la == -lb:
E.add((a, b))
return V, E
def max_independent_set(n, E):
adj = [set() for _ in range(n)]
for a, b in E:
adj[a].add(b); adj[b].add(a)
def go(cand):
if not cand:
return 0
v = max(cand, key=lambda u: len(adj[u] & cand))
if not adj[v] & cand: # no edges left: take everything
return len(cand)
return max(go(cand - {v}), 1 + go(cand - {v} - adj[v]))
return go(frozenset(range(n)))
def max_sat(clauses, nvars):
return max(sum(any((lit > 0) == a[abs(lit) - 1] for lit in c) for c in clauses)
for a in product([False, True], repeat=nvars))
# literals: 3 means x3, -3 means not x3
formulas = {
"satisfiable": [[1, 2, -3], [-1, 3, 4], [2, -4, 5], [-2, -5, 1], [3, 5, -1], [-3, 4, 2]],
"all 8 sign patterns on x1, x2, x3": [[s1 * 1, s2 * 2, s3 * 3] for s1 in (1, -1) for s2 in (1, -1) for s3 in (1, -1)],
}
for name, clauses in formulas.items():
nvars = max(abs(l) for c in clauses for l in c)
V, E = to_graph(clauses)
print(f"{name}: m = {len(clauses)}, max satisfied {max_sat(clauses, nvars)}, "
f"graph with {len(V)} vertices and {len(E)} edges, max independent set {max_independent_set(len(V), E)}")satisfiable: m = 6, max satisfied 6, graph with 18 vertices and 33 edges, max independent set 6
all 8 sign patterns on x1, x2, x3: m = 8, max satisfied 7, graph with 24 vertices and 72 edges, max independent set 7
In C++
The same reduction for the eight-clause formula, with the independent set found by trying all subsets of the 24 vertices that take at most one vertex per triangle ( choices).
#include <cstdio>
#include <vector>
int main() {
std::vector<std::vector<int>> clauses;
for (int s1 : {1, -1}) for (int s2 : {1, -1}) for (int s3 : {1, -1}) clauses.push_back({s1 * 1, s2 * 2, s3 * 3});
int m = clauses.size(), best = 0;
long long total = 1;
for (int j = 0; j < m; j++) total *= 4; // per clause: skip it, or pick one of its 3 literals
for (long long code = 0; code < total; code++) {
std::vector<int> chosen;
long long c = code;
for (int j = 0; j < m; j++, c /= 4)
if (c % 4) chosen.push_back(clauses[j][c % 4 - 1]);
bool independent = true; // no complementary pair among the chosen literals
for (size_t a = 0; a < chosen.size() && independent; a++)
for (size_t b = a + 1; b < chosen.size(); b++)
if (chosen[a] == -chosen[b]) { independent = false; break; }
if (independent && (int)chosen.size() > best) best = chosen.size();
}
std::printf("%d clauses, maximum independent set %d, so at most %d of %d clauses are satisfiable\n", m, best, best, m);
}8 clauses, maximum independent set 7, so at most 7 of 8 clauses are satisfiable
Amplifying the gap: graph products
A constant-factor gap for independent set can be raised to any constant by a product construction. The lexicographic product replaces every vertex of by a copy of : vertices are pairs , and is adjacent to if , or and .
Lemma. .
Proof. If and are independent, so is . Conversely, let be independent in . The set of with some is independent in , so it has at most elements, and for each such , the with are independent in , at most of them.
So with , the gap becomes , for graphs of size , which is polynomial for every constant .
Theorem. Unless P = NP, maximum independent set and maximum clique have no constant-factor approximation.
def lex_product(G, H):
nG, EG = G
nH, EH = H
adjG = {(a, b) for a, b in EG} | {(b, a) for a, b in EG}
adjH = {(a, b) for a, b in EH} | {(b, a) for a, b in EH}
V = [(g, h) for g in range(nG) for h in range(nH)]
idx = {v: i for i, v in enumerate(V)}
E = [(idx[u], idx[v]) for u in V for v in V if idx[u] < idx[v]
and ((u[0], v[0]) in adjG or (u[0] == v[0] and (u[1], v[1]) in adjH))]
return len(V), E
def alpha(n, E):
adj = [set() for _ in range(n)]
for a, b in E:
adj[a].add(b); adj[b].add(a)
def go(cand):
if not cand:
return 0
v = max(cand, key=lambda u: len(adj[u] & cand))
if not adj[v] & cand:
return len(cand)
return max(go(cand - {v}), 1 + go(cand - {v} - adj[v]))
return go(frozenset(range(n)))
C5 = (5, [(i, (i + 1) % 5) for i in range(5)])
P3 = (3, [(0, 1), (1, 2)])
for name, G, H in [("C5[P3]", C5, P3), ("P3[C5]", P3, C5), ("C5[C5]", C5, C5)]:
n, E = lex_product(G, H)
print(f"{name}: {n} vertices, {len(E)} edges, alpha = {alpha(n, E)} = {alpha(*G)} * {alpha(*H)}")C5[P3]: 15 vertices, 55 edges, alpha = 4 = 2 * 2
P3[C5]: 15 vertices, 65 edges, alpha = 4 = 2 * 2
C5[C5]: 25 vertices, 150 edges, alpha = 4 = 2 * 2
The constant-factor version is only the beginning. Using the PCP theorem with stronger parameters (and randomized products or derandomized graph products), Håstad (1999) showed that clique has no -approximation unless NP = ZPP, and Zuckerman (2007) derandomized this to P NP: Tight Thresholds: MAX-3SAT, Clique and Set Cover.
A chain of reductions
Gap-preserving reductions compose, which is how hardness spreads:
- MAX-3SAT MAX-3SAT with each variable in at most 5 clauses (with expander graphs to replace repeated occurrences) independent set and vertex cover in bounded-degree graphs.
- Vertex cover Steiner tree (Bern and Plassmann, 1989): Steiner tree with edge costs 1 and 2 is APX-hard.
- MAX-3SAT label cover set cover (Lund and Yannakakis, 1994; Feige, 1998): the logarithmic hardness of set cover.
- Max-cut, metric TSP with costs 1 and 2 (Papadimitriou and Yannakakis, 1993), -median and many scheduling problems are APX-hard by such chains.
Test yourself
In the graph built from a 3-CNF formula, what do the triangles and the complementary edges enforce?
- That every variable is true
- At most one literal per clause, and no two chosen literals that contradict each other
- That every clause is satisfied
- That the graph is bipartite
Why does the MAX-3SAT gap give a constant-factor hardness for vertex cover?
- Because vertex cover is the same as MAX-3SAT
- The cover is minus the independent set, with , so the gap versus becomes versus more than , a ratio of at least
- Because of the integrality gap
- Because covers are larger than independent sets
What does the identity give for hardness of approximation?
- A polynomial algorithm for independent set
- Powering the graph raises a gap ratio to , so no constant factor is achievable unless P = NP
- That clique is in APX
- Nothing, products do not preserve gaps