TExcelTAD
Home › Approximation Algorithms › Gap-Preserving Reductions

Gap-Preserving Reductions

The PCP theorem gives one hard gap problem: distinguishing satisfiable 3-CNF formulas from those in which every assignment violates an ε\varepsilon 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 Π1\Pi_1 be a maximization problem and Π2\Pi_2 a maximization or minimization problem. A gap-preserving reduction with parameters (c1,s1)(c_1, s_1) and (c2,s2)(c_2, s_2) is a polynomial-time map I↦I′I \mapsto I' with

OPT(I)≥c1  ⇒  OPT(I′)≥c2,OPT(I)<s1  ⇒  OPT(I′)<s2\text{OPT}(I) \ge c_1 \;\Rightarrow\; \text{OPT}(I') \ge c_2 , \qquad \text{OPT}(I) < s_1 \;\Rightarrow\; \text{OPT}(I') < s_2

(for a minimization Π2\Pi_2, the inequalities on the right are ≤c2\le c_2 and >s2> s_2). If Gap-Π1,c1,s1\text{Gap-}\Pi_{1,c_1,s_1} is NP-hard, so is Gap-Π2,c2,s2\text{Gap-}\Pi_{2,c_2,s_2}, and Π2\Pi_2 has no approximation ratio better than s2c2\frac{s_2}{c_2} (or c2s2\frac{c_2}{s_2} 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 OPT(I′)≤α OPT(I)\text{OPT}(I') \le \alpha\,\text{OPT}(I) and that solutions map back with the absolute error growing by at most a factor β\beta. 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 ϕ\phi with mm clauses, build a graph GϕG_\phi:

  • one vertex for each occurrence of a literal in a clause (at most 3m3m 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 (xix_i and xˉi\bar x_i) is joined by an edge (so the chosen literals are consistent).

Lemma. The maximum independent set of GϕG_\phi equals the maximum number of simultaneously satisfiable clauses of ϕ\phi.

Proof. Given an assignment satisfying kk 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 kk contains no complementary pair, so its literals can all be made true by one assignment (others arbitrary), which satisfies the kk clauses they come from. □\square

So the reduction maps Gap-MAX-3SAT1,1−ε\text{Gap-MAX-3SAT}_{1, 1-\varepsilon} (thresholds mm and (1−ε)m(1 - \varepsilon)m) exactly onto Gap-IS\text{Gap-IS} with thresholds mm and (1−ε)m(1 - \varepsilon)m: maximum independent set (and, in the complement graph, maximum clique) has no (1−ε)(1 - \varepsilon)-approximation unless P = NP.

Vertex cover. The complement of an independent set is a vertex cover, so on GϕG_\phi with NN vertices the optimum cover is N−mN - m for satisfiable ϕ\phi and more than N−(1−ε)mN - (1 - \varepsilon)m otherwise. With N≤3mN \le 3m the ratio is at least N−m+εmN−m≥1+ε2\frac{N - m + \varepsilon m}{N - m} \ge 1 + \frac{\varepsilon}{2}, so vertex cover is APX-hard and has no PTAS unless P = NP.

python · try it yourself
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 (484^8 choices).

cpp · try it yourself
#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 G[H]G[H] replaces every vertex of GG by a copy of HH: vertices are pairs (g,h)(g, h), and (g,h)(g, h) is adjacent to (g′,h′)(g', h') if gg′∈E(G)gg' \in E(G), or g=g′g = g' and hh′∈E(H)hh' \in E(H).

Lemma. α(G[H])=α(G)⋅α(H)\alpha(G[H]) = \alpha(G) \cdot \alpha(H).

Proof. If IGI_G and IHI_H are independent, so is IG×IHI_G \times I_H. Conversely, let SS be independent in G[H]G[H]. The set of gg with some (g,h)∈S(g, h) \in S is independent in GG, so it has at most α(G)\alpha(G) elements, and for each such gg, the hh with (g,h)∈S(g, h) \in S are independent in HH, at most α(H)\alpha(H) of them. □\square

So with Gk=G[G[⋯ ]]G^k = G[G[\cdots]], the gap αnoαyes≤1−ε\frac{\alpha_{\text{no}}}{\alpha_{\text{yes}}} \le 1 - \varepsilon becomes (1−ε)k(1 - \varepsilon)^k, for graphs of size NkN^k, which is polynomial for every constant kk.

Theorem. Unless P = NP, maximum independent set and maximum clique have no constant-factor approximation.

python · try it yourself
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 n1−εn^{1 - \varepsilon}-approximation unless NP = ZPP, and Zuckerman (2007) derandomized this to P ≠\ne NP: Tight Thresholds: MAX-3SAT, Clique and Set Cover.

A chain of reductions

Gap-preserving reductions compose, which is how hardness spreads:

  • MAX-3SAT →\to MAX-3SAT with each variable in at most 5 clauses (with expander graphs to replace repeated occurrences) →\to independent set and vertex cover in bounded-degree graphs.
  • Vertex cover →\to Steiner tree (Bern and Plassmann, 1989): Steiner tree with edge costs 1 and 2 is APX-hard.
  • MAX-3SAT →\to label cover →\to 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), kk-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?

  1. That every variable is true
  2. At most one literal per clause, and no two chosen literals that contradict each other
  3. That every clause is satisfied
  4. That the graph is bipartite

Why does the MAX-3SAT gap give a constant-factor hardness for vertex cover?

  1. Because vertex cover is the same as MAX-3SAT
  2. The cover is NN minus the independent set, with N≤3mN \le 3m, so the gap mm versus (1−ε)m(1 - \varepsilon)m becomes N−mN - m versus more than N−m+εmN - m + \varepsilon m, a ratio of at least 1+ε21 + \frac{\varepsilon}{2}
  3. Because of the integrality gap
  4. Because covers are larger than independent sets

What does the identity α(G[H])=α(G)α(H)\alpha(G[H]) = \alpha(G)\alpha(H) give for hardness of approximation?

  1. A polynomial algorithm for independent set
  2. Powering the graph raises a gap ratio 1−ε1 - \varepsilon to (1−ε)k(1 - \varepsilon)^k, so no constant factor is achievable unless P = NP
  3. That clique is in APX
  4. Nothing, products do not preserve gaps