TExcelTAD
Home › Approximation Algorithms › Gap-Introducing Reductions

Gap-Introducing Reductions

The first half of this course proved upper bounds: an algorithm achieves ratio ρ\rho. The second kind of theorem says that no polynomial algorithm achieves ratio ρ\rho, unless P = NP. Ordinary NP-hardness proofs do not give such results: they show that finding the exact optimum is hard, and say nothing about getting close. The tool that does is a reduction that creates a gap: the instances it builds have an optimum either at most cc or at least ss, with nothing in between, so an algorithm with ratio below sc\frac{s}{c} can tell the two cases apart and solve an NP-complete problem. Several examples have already appeared in the course; this lesson makes the method explicit and proves its most dramatic instance, the inapproximability of TSP without the triangle inequality.

Gap problems

Definition. For a minimization problem Π\Pi and thresholds c<sc < s, the gap problem Gap-Πc,s\text{Gap-}\Pi_{c,s} is the promise problem: given an instance II with either OPT(I)≤c\text{OPT}(I) \le c or OPT(I)>s\text{OPT}(I) > s, decide which. (For maximization: OPT≥c\text{OPT} \ge c or OPT<s\text{OPT} < s with s<cs < c.)

Lemma. If Gap-Πc,s\text{Gap-}\Pi_{c,s} is NP-hard, then Π\Pi has no polynomial ρ\rho-approximation with ρ≤sc\rho \le \frac{s}{c} unless P = NP.

Proof. Run the approximation. If OPT≤c\text{OPT} \le c, it returns a value at most ρc≤s\rho c \le s; if OPT>s\text{OPT} > s, every solution has value above ss. Comparing the value with ss decides the gap problem. □\square

A gap-introducing reduction maps instances of an NP-complete decision problem to instances of Π\Pi so that yes-instances land at most at cc and no-instances above ss. The thresholds cc and ss may depend on the input size.

Problem Reduction from Gap Consequence (unless P = NP)
bin packing PARTITION 2 bins vs 3 bins no ratio below 32\frac{3}{2} (Bin Packing: First Fit and First-Fit Decreasing)
metric kk-center dominating set radius 1 vs 2 no ratio below 2 (k-Center and Farthest-First Traversal)
graph colouring 3-colourability of planar graphs 3 colours vs 4 no ratio below 43\frac{4}{3}
makespan on unrelated machines 3-dimensional matching makespan 2 vs 3 no ratio below 32\frac{3}{2} (Lenstra, Shmoys and Tardos, 1990)
general TSP Hamiltonian cycle nn vs more than αn\alpha n no ratio α\alpha at all, for any polynomial-time computable α(n)\alpha(n)

The colouring row works because every planar graph is 4-colourable (Appel and Haken, 1976), while deciding 3-colourability of planar graphs is NP-complete (Garey, Johnson and Stockmeyer, 1976): the optimum of a planar graph with an edge is 2, 3 or 4, and distinguishing 3 from 4 is the hard part. The program shows the gap on two small planar graphs, computing the chromatic number by brute force.

python · try it yourself
from itertools import product

def chromatic_number(n, edges):
    for k in range(1, n + 1):
        for colours in product(range(k), repeat=n):
            if colours[0] == 0 and all(colours[u] != colours[v] for u, v in edges):
                return k

wheel5 = [(i, (i + 1) % 5) for i in range(5)] + [(5, i) for i in range(5)]    # odd wheel: planar
octahedron = [(u, v) for u in range(6) for v in range(u + 1, 6) if v != u + 3 or u >= 3]
for name, n, E in [("octahedron", 6, octahedron), ("wheel with 5 spokes", 6, wheel5)]:
    print(f"{name}: {len(E)} edges, chromatic number {chromatic_number(n, E)}")
octahedron: 12 edges, chromatic number 3
wheel with 5 spokes: 10 edges, chromatic number 4

An algorithm with ratio below 43\frac{4}{3} would have to answer 3 on the octahedron and could only answer 4 on the odd wheel, so it would decide planar 3-colourability.

TSP without the triangle inequality

Theorem (Sahni and Gonzalez, 1976). Let α(n)≥1\alpha(n) \ge 1 be computable in polynomial time. Unless P = NP, there is no polynomial-time α(n)\alpha(n)-approximation for TSP with arbitrary non-negative costs.

Proof. Reduce from HAMILTONIAN CYCLE, which is NP-complete (Hamiltonian Cycles and the Travelling Salesman). Given a graph G=(V,E)G = (V, E) with nn vertices, build the complete graph on VV with costs

c(u,v)={1if uv∈E,α(n)⋅n+1otherwise.c(u, v) = \begin{cases} 1 & \text{if } uv \in E, \\ \alpha(n) \cdot n + 1 & \text{otherwise.} \end{cases}

The costs have polynomially many bits because α(n)\alpha(n) is computable in polynomial time. If GG has a Hamiltonian cycle, that cycle is a tour of cost nn. If not, every tour uses at least one non-edge and costs at least (n−1)+α(n)n+1>α(n)⋅n(n - 1) + \alpha(n) n + 1 > \alpha(n) \cdot n. An α(n)\alpha(n)-approximation returns a tour of cost at most α(n)n\alpha(n) n in the first case and necessarily more in the second, so it decides HAMILTONIAN CYCLE. □\square

The constructed costs badly violate the triangle inequality: two edges of cost 1 may span a non-edge of huge cost. With the triangle inequality, the same reduction (non-edges of cost 2, which is metric) gives only that metric TSP is NP-hard, and the gap nn versus n+1n + 1 is too small to rule out any constant ratio.

The program applies the reduction to a cycle with chords (Hamiltonian) and to the Petersen graph (famously not Hamiltonian), and solves the TSP instances exactly.

python · try it yourself
from math import inf

def held_karp(c):
    n = len(c)
    D = [[inf] * n for _ in range(1 << n)]
    D[1][0] = 0
    for S in range(1, 1 << n, 2):
        for j in range(n):
            if D[S][j] < inf:
                for k in range(1, n):
                    if not S >> k & 1:
                        D[S | 1 << k][k] = min(D[S | 1 << k][k], D[S][j] + c[j][k])
    return min(D[-1][j] + c[j][0] for j in range(1, n))

def reduction(n, edges, alpha):
    E = {frozenset(e) for e in edges}
    return [[0 if u == v else 1 if frozenset((u, v)) in E else alpha * n + 1 for v in range(n)] for u in range(n)]

petersen = [(i, (i + 1) % 5) for i in range(5)] + [(5 + i, 5 + (i + 2) % 5) for i in range(5)] + [(i, i + 5) for i in range(5)]
prism = [(i, (i + 1) % 5) for i in range(5)] + [(5 + i, 5 + (i + 1) % 5) for i in range(5)] + [(i, i + 5) for i in range(5)]
alpha = 3
for name, E in [("pentagonal prism", prism), ("Petersen graph", petersen)]:
    opt = held_karp(reduction(10, E, alpha))
    verdict = "Hamiltonian" if opt == 10 else "not Hamiltonian"
    print(f"{name}: optimal tour {opt:3}; an alpha = {alpha} approximation returns <= {alpha * 10} iff the graph is Hamiltonian -> {verdict}")
pentagonal prism: optimal tour  10; an alpha = 3 approximation returns <= 30 iff the graph is Hamiltonian -> Hamiltonian
Petersen graph: optimal tour  40; an alpha = 3 approximation returns <= 30 iff the graph is Hamiltonian -> not Hamiltonian

Both graphs are 3-regular with 10 vertices and 15 edges, and they look alike locally, yet the optimal tour jumps from 10 to 40 (nine graph edges and one non-edge of cost 31, since the Petersen graph has a Hamiltonian path): the reduction turned a yes/no question into a factor-4 gap.

In C++

The same reduction on the Petersen graph, with a larger α\alpha; the gap grows with it while the yes-instances stay at cost nn.

cpp · try it yourself
#include <algorithm>
#include <cstdio>
#include <vector>

int main() {
    const int n = 10;
    int edges[15][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 0}, {5, 7}, {7, 9}, {9, 6}, {6, 8}, {8, 5},
                        {0, 5}, {1, 6}, {2, 7}, {3, 8}, {4, 9}};
    for (long long alpha : {2LL, 10LL, 1000LL}) {
        std::vector<std::vector<long long>> c(n, std::vector<long long>(n, alpha * n + 1));
        for (auto& e : edges) c[e[0]][e[1]] = c[e[1]][e[0]] = 1;
        const long long INF = 1LL << 60;
        std::vector<std::vector<long long>> D(1 << n, std::vector<long long>(n, INF));
        D[1][0] = 0;
        for (int S = 1; S < (1 << n); S += 2)
            for (int j = 0; j < n; j++)
                if (D[S][j] < INF)
                    for (int k = 1; k < n; k++)
                        if (!(S >> k & 1)) D[S | 1 << k][k] = std::min(D[S | 1 << k][k], D[S][j] + c[j][k]);
        long long best = INF;
        for (int j = 1; j < n; j++) best = std::min(best, D[(1 << n) - 1][j] + c[j][0]);
        std::printf("alpha = %4lld: Petersen tour %lld > alpha * n = %lld\n", alpha, best, alpha * n);
    }
}
alpha =    2: Petersen tour 30 > alpha * n = 20
alpha =   10: Petersen tour 110 > alpha * n = 100
alpha = 1000: Petersen tour 10010 > alpha * n = 10000

What gap-introducing reductions cannot do directly

Every reduction above starts from a problem whose yes/no answer already creates a large multiplicative difference in a tiny optimum (2 vs 3 bins, radius 1 vs 2) or from a construction where the cost function can be chosen freely (TSP). For problems such as MAX-3SAT, vertex cover or set cover, the natural reductions from SAT create only an additive gap of one clause or one vertex, which says nothing about ratios. A satisfiable formula has all mm clauses satisfiable; an unsatisfiable one might still have m−1m - 1. To get a constant-factor gap for these problems one needs the PCP theorem (The PCP Theorem), which produces formulas where unsatisfiable means "far from satisfiable". From there, gap-preserving reductions carry the gap to other problems (Gap-Preserving Reductions).

Test yourself

If Gap-Πc,s\text{Gap-}\Pi_{c,s} is NP-hard for a minimization problem, what follows?

  1. Π\Pi has no polynomial algorithm at all
  2. No polynomial ρ\rho-approximation with ρ≤sc\rho \le \frac{s}{c} exists unless P = NP
  3. Π\Pi has a PTAS
  4. OPT is always between cc and ss

In the reduction from Hamiltonian cycle to TSP, why must non-edges cost more than about αn\alpha n?

  1. To keep the costs metric
  2. So that any tour using a non-edge costs more than α\alpha times the cost nn of a Hamiltonian cycle
  3. Because α\alpha must be an integer
  4. To make the instance sparse

Why does the same reduction with non-edges of cost 2 not rule out constant factors for metric TSP?

  1. Because cost 2 is not metric
  2. It only creates the gap nn versus n+1n + 1, a ratio that tends to 1
  3. Because Christofides solves it exactly
  4. Because Hamiltonian cycle is easy on such graphs

Why does the planar 3-colourability reduction give a gap for graph colouring?

  1. Planar graphs are 3-colourable
  2. Every planar graph is 4-colourable, so the optimum is 3 for yes-instances and 4 for no-instances, a ratio of 43\frac{4}{3}
  3. Because colouring is in P
  4. Because of the PCP theorem