Theory of Computation: Lecture 8
Polynomial-time mapping reductions, NP-completeness, Cook-Levin, the 3SAT reduction, and the SAT-to-INDSET construction.
Polynomial-Time Reductions
NP membership says that yes-instances have short certificates that can be checked quickly. NP-completeness needs a second idea: translate one decision problem into another without losing the yes/no answer and without spending more than polynomial time.
Polynomial-time computable function. A function is polynomial-time computable if some polynomial-time Turing machine halts on every input with exactly on its tape.
The function must be total. It must produce an output for every input, even when the input is a no-instance.
Polynomial-time mapping reduction. A language is polynomial-time mapping reducible to a language , written , if there is a polynomial-time computable function such that, for every string ,
- Computability. The instance can be constructed in polynomial time.
- Correctness. The translation preserves membership exactly.
- Surjectivity. Not required. Some instances of may never be produced by .
The direction means: a fast solver for would give a fast solver for . So is at least as hard as .
Theorem. If and , then .
Proof. Let be a polynomial-time reduction from to , and let be a polynomial-time decider for . Build a decider for :
- On input , compute .
- Run on .
- Output whatever outputs.
The machine decides because
Cost rule. If runs in time and runs in time, then because the reduction cannot write more symbols than its running time allows. The composed decider runs in
for fixed constants .
Corollary. If and , then .
This is a hardness transfer. For NP problems, however, we usually do not know that a natural language is outside . NP-completeness replaces that missing knowledge with reductions from all of .
Transitivity of polynomial-time reductions. If and , then .
If runs in time and runs in time, the composed map is polynomial-time computable. Correctness follows by chaining the two equivalences:
NP-Complete Languages
NP-hard language. A language is NP-hard if every language in polynomial-time reduces to it:
NP-complete language. A language is NP-complete if it is both in and NP-hard.
- Membership. , so yes-instances of have short certificates.
- Hardness. Every problem in can be translated to in polynomial time.
If any NP-complete language has a polynomial-time decider, then : for every , use and the theorem above to get .
Cook-Levin theorem. is NP-complete.
Thus is the first complete problem: it is in , and every language in reduces to it in polynomial time.
Recipe: proving that is NP-complete.
- NP membership. Give a polynomial-time verifier for .
- NP-hardness. Reduce a known NP-complete language to .
- Conclusion. Since the known complete problem represents all of , transitivity gives every a reduction to .
At the start, the known NP-complete language is . Later, any already proven NP-complete language may be used.
The 3SAT Reduction
SAT. The language of satisfiable CNF formulas in which every clause contains at most literals.
With this convention, SAT allows clauses of size , , or .
Theorem. is NP-complete.
Membership in is inherited from : a certificate is a truth assignment, and the verifier checks every clause.
For hardness, reduce to . Let be a clause with more than three literals:
Introduce a fresh variable and replace by two clauses:
This preserves satisfiability.
If is satisfiable and one of is true, set . Then is true because of the original true literal, and is true because of . If a true literal appears only among , set .
Conversely, if all original literals are false, then forces while forces , impossible. So any satisfying assignment for makes at least one original literal true.
Repeat this replacement until every clause has at most three literals. Each step shortens one long clause by one literal, introduces one fresh variable, and increases the formula size only linearly. Therefore the whole transformation is polynomial time, and the resulting formula is satisfiable exactly when the original formula is satisfiable.
The same idea does not give a SAT-to-2SAT reduction: binary clauses cannot carry the remaining tail of a long disjunction in the same satisfiability-preserving way.
INDSET Is NP-Complete
Independent set language. The language
Membership in is immediate: a certificate is a set , and the verifier checks that and that no pair of vertices in is connected by an edge.
Theorem. is NP-complete.
It remains to prove NP-hardness by showing .
Reduction from SAT to INDSET. Given a CNF formula with clauses , build a graph as follows:
- Create one vertex for each literal occurrence in each clause.
- Add edges between every pair of vertices from the same clause.
- Add edges between every pair of conflicting literals, such as and .
- Output .
Each clause becomes a clique, so an independent set can select at most one literal per clause. Conflict edges prevent it from selecting inconsistent literals.
For example, for
the selected vertices correspond to the satisfying assignment .
Correctness: satisfiable formula gives independent set. Suppose has a satisfying assignment. In each clause, choose one literal that is true. The chosen vertices form an independent set of size : there is one chosen vertex per clause, so no same-clause edge is used, and two true literals under one assignment cannot be conflicting.
Correctness: independent set gives satisfying assignment. Suppose has an independent set of size . Since each clause group is a clique, contains at most one vertex from each clause. There are clauses and , so it contains exactly one vertex from every clause. Since has no conflict edge, the selected literals are mutually consistent. Set each selected literal to true and assign the remaining variables arbitrarily. Every clause has a selected true literal, so is satisfiable.
The graph has one vertex per literal occurrence and at most quadratically many edges in the formula size, so the construction is polynomial time. Therefore , and since , the language is NP-complete.