Sub topic 3
Building Gadgets: Reducing 3-SAT to Independent Set
This chapter assumes you know many-one reductions, NP-completeness, and basic Python.
The Gadget Construction
A gadget is a small piece of the target instance that encodes one piece of the source instance. Each 3-SAT clause becomes a triangle, and only one vertex of a triangle can be chosen. Conflict edges join every literal x to every literal ¬x, so no contradictory choice survives. The formula is satisfiable exactly when the graph has an independent set of size m, where m is the number of clauses.
from itertools import combinations
def three_sat_to_independent_set(clauses):
vertices, edges = [], []
for i, clause in enumerate(clauses):
nodes = [(i, j, lit) for j, lit in enumerate(clause)]
vertices.extend(nodes)
edges.extend(combinations(nodes, 2)) # clause triangle
for a, b in combinations(vertices, 2):
if a[2] == -b[2]:
edges.append((a, b)) # conflict edge
return vertices, edges, len(clauses)
v, e, k = three_sat_to_independent_set([(1, -2, 3), (-1, 2, 3)])
print(len(v), len(e), k) # 6 7 2Turing Reductions and Oracles
A Turing reduction solves A using a subroutine (an oracle) for B. It may call the oracle many times and can post-process the answers, for example by negating them. Many-one reductions are needed to separate NP from coNP. Turing reductions are enough to prove that a problem is decidable or undecidable, and to turn a decision procedure into a search procedure.
Undecidability via Halting
Given a machine M and an input w, build a machine M′ that ignores its own input, runs M on w, and then accepts. M′ accepts every string exactly when M halts on w. So a decider for "does M′ accept everything?" would decide the halting problem, which is impossible.
From Yes/No to Solutions
Self-reducibility means you can find a solution by asking yes/no questions. First check that an independent set of size k exists. Then try deleting each vertex in turn, and keep the deletion whenever the oracle still answers yes. This takes at most |V| + 1 oracle calls.
Reductions in Practice
| Task | Reduce to |
|---|---|
| Scheduling, configuration, verification | SAT solver |
| Resource allocation | Linear programming |
| Bipartite matching, image segmentation | Max flow |
Common Mistakes
- Reducing in the wrong direction. To show that B is hard, reduce a known hard problem to B.
- Proving only "yes maps to yes" and skipping "yes in the target implies yes in the source".
- Building an output of exponential size.
- Letting the reduction solve the source problem along the way.
Further Directions
Approximation-preserving reductions, such as L-reductions, carry approximation ratios from one problem to another. Fine-grained reductions start from conjectures such as SETH or 3SUM and give exact polynomial lower bounds, for example that a problem has no O(n^(2−ε)) algorithm.
Exercise
In the 3-SAT reduction, why must the independent set size be exactly the number of clauses rather than smaller?
Show answer
Each triangle holds at most one chosen vertex, so size m forces one true literal per clause. A smaller target would allow some clauses to go unsatisfied.