Unit 5

Reductions and Completeness

Polynomial many-one reductions and the logic of hardness and completeness proofs.

Goals

  • Construct polynomial many-one reductions with the correct direction, totality, and encoding analysis.
  • Use transitivity and downward closure to transfer algorithms and class membership.
  • Distinguish NP-hardness from NP-completeness and derive the P=NP\mathrm P=\mathrm{NP} consequence correctly.
  • Understand Cook–Levin as an explicit polynomial-size tableau construction.
  • Prove both directions of the standard reduction 3SAT≤mpIS\mathrm{3SAT}\le_m^p\mathrm{IS}.

1. A reduction is an instance compiler

For languages A,B⊆{0,1}∗A,B\subseteq\{0,1\}^*,

A≤mpBA\le_m^p B

means that a total, polynomial-time computable function ff satisfies

x∈A  ⟺  f(x)∈Bx\in A\iff f(x)\in B

for every string xx. The same output instance must preserve both yes and no answers; this is why the biconditional is indispensable.

Suppose a polynomial algorithm DBD_B decides BB. Then DA(x)=DB(f(x))D_A(x)=D_B(f(x)) decides AA. The arrow therefore points from the problem whose difficulty we already understand to the problem whose hardness we want to establish:

known-hard A⟶new target B.\text{known-hard }A\longrightarrow\text{new target }B.

Reducing BB to AA only shows that access to an AA solver helps with BB; it gives no evidence that BB is hard.

Guided construction

NP-complete reduction chain

Step 1 of 5
Known-hard Asource instance x
f(x)total polynomial compiler
Target B solverhypothetical fast algorithm
The solver's yes/no answer decides A

Totality and malformed inputs

The definition quantifies over strings, not only well-formed formulas or graphs. A clean construction first tests whether xx encodes a legal source instance. On malformed input it emits one fixed legal no-instance of BB. This convention must agree with the source language’s malformed-input convention.

A polynomial-time transducer can print only polynomially many symbols, so its output length is polynomially bounded. Nevertheless, a proof should state the bound explicitly, especially when numbers are binary encoded.

2. Transitivity, closure, and algorithm transfer

Transitivity. If A≤mpBA\le_m^p B via ff and B≤mpCB\le_m^p C via gg, then A≤mpCA\le_m^p C via h=g∘fh=g\circ f.

Correctness.

x∈A  ⟺  f(x)∈B  ⟺  g(f(x))∈C.x\in A\iff f(x)\in B\iff g(f(x))\in C.

Complexity. Suppose ff runs in time p(n)p(n) and gg in time q(m)q(m). Then ∣f(x)∣≤p(∣x∣)|f(x)|\le p(|x|) up to a harmless constant, because writing output costs time. Hence

Th(n)≤p(n)+q(p(n)),T_h(n)\le p(n)+q(p(n)),

a polynomial. Saying merely “a composition of polynomial algorithms is polynomial” hides this essential output-length bridge.

Downward closure. If A≤mpBA\le_m^p B and B∈PB\in\mathrm P, then A∈PA\in\mathrm P. The same statement holds with NP or coNP in place of P.

For NP, let VB(y,w)V_B(y,w) verify BB. Verify AA by computing f(x)f(x) and running VB(f(x),w)V_B(f(x),w). The certificate bound remains polynomial because ∣f(x)∣|f(x)| is polynomial in ∣x∣|x|. For coNP, apply the same argument to complements: the biconditional gives

x∈A‾  ⟺  f(x)∈B‾.x\in\overline A\iff f(x)\in\overline B.

This closure fact explains why a single reduction can move an upper bound backward along its arrow.

3. Hardness, completeness, and the P=NP consequence

A language BB is NP-hard if

∀A∈NP,A≤mpB.\forall A\in\mathrm{NP},\quad A\le_m^p B.

It is NP-complete if additionally B∈NPB\in\mathrm{NP}. The membership proof is usually a verifier; the hardness proof usually starts from an already NP-complete problem. An NP-hard language need not even be decidable, so hardness alone never establishes completeness.

Theorem. If an NP-complete language BB belongs to P, then P=NP\mathrm P=\mathrm{NP}.

Proof. Let A∈NPA\in\mathrm{NP}. Hardness gives A≤mpBA\le_m^p B. Since B∈PB\in\mathrm P, downward closure gives A∈PA\in\mathrm P. Therefore NP⊆P\mathrm{NP}\subseteq\mathrm P. The reverse containment is standard, so equality follows. □\square

The contrapositive is also useful but conditional: if P≠NP\mathrm P\ne\mathrm{NP}, then no NP-complete language is in P. We do not currently know the premise.

4. Cook–Levin: computation becomes a formula

Cook–Levin proves SAT NP-complete. SAT is in NP because an assignment can be evaluated in polynomial time. Hardness is the deeper part: for every L∈NPL\in\mathrm{NP} and input xx, construct a Boolean formula ΦN,x\Phi_{N,x} satisfiable exactly when an NTM NN has an accepting computation on xx.

Assume every branch of N(x)N(x) halts within T=p(∣x∣)T=p(|x|) steps. During that time the head can visit only O(T)O(T) tape cells. Pad shorter accepting runs with a self-looping accept state, so every relevant history has exactly TT rows. A tableau is a T×ST\times S grid, S=O(T)S=O(T), whose row tt is the complete configuration at time tt.

Guided construction

Cook–Levin tableau

Step 1 of 7
Input x = 10 · time bound T = 3 · tableau width S = 5
t=0
⊢
[q0,1]
0
□
□

Tableau variables

Let the finite alphabet

Γ′=Γ∪(Q×Γ)\Gamma'=\Gamma\cup(Q\times\Gamma)

contain ordinary tape symbols and marked symbols (q,a)(q,a) meaning “the head is here, the state is qq, and the scanned symbol is aa.” Introduce

Xt,i,sX_{t,i,s}

for 0≤t<T0\le t<T, 0≤i<S0\le i<S, and s∈Γ′s\in\Gamma'. Its intended meaning is that cell ii of row tt contains symbol ss.

There are O(TS∣Γ′∣)=O(T2)O(TS|\Gamma'|)=O(T^2) variables because NN is fixed and ∣Γ′∣|\Gamma'| is constant.

Uniqueness constraints

Every tableau location contains exactly one symbol:

⋁s∈Γ′Xt,i,s\bigvee_{s\in\Gamma'}X_{t,i,s}

enforces at least one, while for every s≠rs\ne r,

(¬Xt,i,s∨¬Xt,i,r)(\neg X_{t,i,s}\lor\neg X_{t,i,r})

enforces at most one. Across TSTS cells this contributes O(T2)O(T^2) clauses for a fixed machine alphabet. Exactly one marked state/head symbol per row can be imposed similarly, or derived from a carefully chosen local-rule system plus the valid start row.

Start constraints

Unit clauses fix row 00 to the initial configuration: state q0q_0 scans the first input symbol, the remaining input symbols occupy their cells, and all unused cells contain blanks. Because xx is known while constructing the formula, these are literal constants encoded by unit clauses.

Acceptance constraints

Require an accepting marked symbol somewhere:

⋁t,i,aXt,i,(qacc,a).\bigvee_{t,i,a}X_{t,i,(q_{\mathrm{acc}},a)}.

With the padded accepting self-loop, one may instead require qaccq_{\mathrm{acc}} in the final row. Either convention works, but the transition constraints and boundary treatment must match it.

Local transition constraints

A Turing transition changes only the scanned cell, the state marker, and possibly a neighboring cell receiving the head. Therefore whether a small window in row t+1t+1 legally follows row tt depends on a constant-size window—commonly a 2×32\times3 or 2×42\times4 neighborhood.

For each position and each forbidden local pattern π\pi, add a clause forbidding all its literals simultaneously:

⋁(u,j,s)∈π¬Xt+u,i+j,s.\bigvee_{(u,j,s)\in\pi}\neg X_{t+u,i+j,s}.

The window size and alphabet are constants, so there are only constantly many pattern types per (t,i)(t,i). Boundary cells use endmarkers or separate fixed rules. These clauses enforce that unchanged distant cells stay unchanged and that the head/state update follows one legal nondeterministic transition.

Correctness: the two directions

If NN accepts xx, choose an accepting branch, write its configurations as a padded tableau, and assign each Xt,i,sX_{t,i,s} according to the grid. Every uniqueness, start, acceptance, and local-transition clause is then true.

Conversely, if ΦN,x\Phi_{N,x} is satisfiable, uniqueness decodes one symbol per location. Start clauses make row 00 the real initial configuration. Local clauses ensure each next row is a legal successor, not merely a visually plausible row. Acceptance clauses ensure the decoded branch accepts. Therefore

x∈L  ⟺  ΦN,x∈SAT.x\in L\iff \Phi_{N,x}\in\mathrm{SAT}.

Polynomial size and construction time

There are O(T2)O(T^2) cells. Each receives constantly many uniqueness clauses; each space-time position receives constantly many local clauses; start and accept portions are at most polynomial. Thus ∣ΦN,x∣=O(T2)|\Phi_{N,x}|=O(T^2) under the fixed-machine encoding, or another fixed polynomial under alternative encodings. Enumerating the clauses takes polynomial time. This size argument is what turns the tableau idea into a reduction rather than a handwave.

The usual final step converts a general formula to CNF and then to 3CNF with auxiliary variables while preserving satisfiability and polynomial size.

What a local window actually checks

Suppose the upper row contains

⋯ , b, (q,a), c, ⋯\cdots,\ b,\ (q,a),\ c,\ \cdots

and δ(q,a)\delta(q,a) permits the move “write dd, move right, enter state q′q'.” The corresponding lower-row neighborhood must be

⋯ , b, d, (q′,c), ⋯ .\cdots,\ b,\ d,\ (q',c),\ \cdots.

For a left move, the state marker moves onto the left symbol instead. If the head lies outside a window, the lower middle symbol must equal the upper middle symbol. The finite list of allowed windows contains these cases for every transition in δ\delta, together with ordinary copy windows.

To encode “this window is one of the allowed ones” in CNF, it is convenient to enumerate every forbidden assignment to its constant number of positions. If a forbidden assignment sets literals L1,…,LrL_1,\ldots,L_r true, the clause

(¬L1∨⋯∨¬Lr)(\neg L_1\lor\cdots\lor\neg L_r)

excludes precisely that assignment. Here rr is a machine-dependent constant. Overlapping windows are crucial: agreement on their shared cells stitches local legality into one globally legal successor configuration. Without overlap, unrelated legal fragments could be combined into an impossible row.

For explicit accounting, write g=∣Γ′∣g=|\Gamma'|. Location constraints use TSTS clauses of width gg for “at least one” and TS(g2)TS\binom g2 binary clauses for “at most one.” Start constraints use SS unit clauses. A final-row acceptance condition has width at most S∣Γ∣S|\Gamma|. If FF is the constant number of forbidden window patterns, transitions use at most F(T−1)(S−2)F(T-1)(S-2) constant-width clauses. Since g,Fg,F depend on NN, not on xx, the total symbol count is O(TS)=O(T2)O(TS)=O(T^2), apart from the acceptance clause’s still-polynomial width. Converting a width-rr clause to 3CNF introduces only O(r)O(r) variables and clauses, so polynomial size survives.

5. Full reduction: 3SAT to Independent Set

Let

φ=C1∧⋯∧Cm\varphi=C_1\land\cdots\land C_m

be a 3CNF formula, allowing repeated literals if the chosen 3SAT definition does. Build a graph GφG_\varphi:

  1. Create one vertex vi,jv_{i,j} for each literal occurrence ℓi,j\ell_{i,j} in clause CiC_i.
  2. Connect every pair of vertices belonging to the same clause. Each clause gadget is a triangle (or a clique for clauses represented with fewer distinct occurrences).
  3. Connect two vertices from different clauses whenever their literals are complementary, xx and ¬x\neg x.
  4. Output (Gφ,k=m)(G_\varphi,k=m).

The graph has 3m3m vertices and at most 3m+9(m2)=O(m2)3m+9\binom m2=O(m^2) edges, so it is polynomial to construct.

Guided construction

3SAT → Independent Set

Step 1 of 7
φ =(x ∨ y ∨ z)∧(¬x ∨ y ∨ w)∧(¬y ∨ z ∨ w)
3SAT to Independent Set constructionThree clause panels become triangle gadgets. Solid edges join literals in one clause, dashed edges join complementary literals, and the final step selects x, y, and z as an independent set of size three.C1x ∨ y ∨ zsource clauseC2¬x ∨ y ∨ wsource clauseC3¬y ∨ z ∨ wsource clause
Same-clause edgeComplement conflict

Forward direction

Assume φ\varphi is satisfiable under assignment α\alpha. In each clause choose one occurrence made true by α\alpha, and put its vertex in SS. Exactly one is chosen from each clause, hence ∣S∣=m|S|=m. No two chosen vertices lie in one clause, so no clause edge joins them. Nor can two chosen literals be complementary: one assignment cannot make both xx and ¬x\neg x true. Therefore SS is independent.

Reverse direction

Assume GφG_\varphi has an independent set SS of size mm. Since every clause gadget is a clique, SS contains at most one vertex from each clause. There are exactly mm clauses and mm selected vertices, so it contains exactly one from every clause.

No selected pair is connected by a conflict edge, so the selected literals contain no complementary pair. Define a partial assignment making each selected literal true. It is consistent: no variable is forced both ways. Extend arbitrarily to unmentioned variables. Each clause contains its selected true literal, so every clause—and therefore φ\varphi—is satisfied.

Thus

φ∈3SAT  ⟺  (Gφ,m)∈IS.\varphi\in\mathrm{3SAT}\iff(G_\varphi,m)\in\mathrm{IS}.

IS is in NP: list kk distinct vertices and test every pair for nonadjacency. Since 3SAT is NP-hard, this proves IS NP-complete.

Mini-example

For

(x∨y∨z)∧(¬x∨y∨w)∧(¬y∨z∨w),(x\lor y\lor z)\land(\neg x\lor y\lor w)\land(\neg y\lor z\lor w),

create three triangles, one per clause, and set k=3k=3. Add conflict edges between the first occurrence of xx and the second occurrence of ¬x\neg x; between every yy occurrence and the third clause’s ¬y\neg y; and any other complementary pair that appears. Repeated positive occurrences such as zz are not conflicts with one another.

The assignment x=1,y=1,z=1,w=0x=1,y=1,z=1,w=0 satisfies the formula. One resulting independent set chooses xx from C1C_1, yy from C2C_2, and zz from C3C_3. These vertices lie in different triangles and no selected literals are complementary.

Now start from an arbitrary independent set of size three. It cannot choose two vertices from one triangle. Because there are three triangles, it chooses one per clause. It cannot, for example, choose yy from C1C_1 and ¬y\neg y from C3C_3, because those vertices have a conflict edge. Thus its three chosen literals form a consistent partial assignment and certify all three clauses simultaneously.

This example also shows why selecting merely two nonconflicting vertices would not suffice: two clauses could be represented while the third remained unsatisfied. The threshold is part of the reduction’s logic, not a cosmetic parameter.

6. A reduction-proof checklist

Before declaring a reduction complete, verify five separate obligations:

  1. Input and output. State the exact decision-language encodings and parameters.
  2. Construction. Describe f(x)f(x) on legal and malformed source strings.
  3. Forward implication. Transform every source witness into a target witness.
  4. Reverse implication. Decode every target solution meeting the threshold into a source solution.
  5. Resources. Bound output objects, bit lengths, and construction time in the encoded source length.

For 3SAT→IS, these become: 3m3m occurrence vertices; clause and conflict edges; one true occurrence per clause in the forward direction; one consistent occurrence per clause in the reverse direction; and O(m2)O(m^2) output size. Keeping the obligations separate prevents a persuasive gadget drawing from replacing the formal proof.

7. Direction tested with a hypothetical solver

A reliable direction test is to write the algorithm that would follow from the reduction. Suppose the goal is to show a new problem BB is hard and SAT is the known-hard source. Given a SAT formula φ\varphi, compute f(φ)f(\varphi), call a hypothetical solver for BB once, and return that answer. This algorithm exists precisely when

φ∈SAT  ⟺  f(φ)∈B.\varphi\in\mathrm{SAT}\iff f(\varphi)\in B.

Thus the required statement is SAT≤mpB\mathrm{SAT}\le_m^pB. If the construction instead starts from a BB instance and calls a SAT solver, it proves B≤mpSATB\le_m^p\mathrm{SAT}—an upper-bound style result that every NP language already has after Cook–Levin.

Reductions also compose into a network. From

SAT≤mp3SATand3SAT≤mpIS,\mathrm{SAT}\le_m^p\mathrm{3SAT} \quad\text{and}\quad \mathrm{3SAT}\le_m^p\mathrm{IS},

transitivity gives SAT≤mpIS\mathrm{SAT}\le_m^p\mathrm{IS}. There is no need to rebuild the Cook–Levin tableau inside the graph reduction. This modularity is the practical value of completeness: after one universal source is established, later proofs can begin from whichever complete problem best matches the target structure.

Finally, a reduction does not compare the running times of the best algorithms in both directions. From A≤mpBA\le_m^pB, a fast BB algorithm gives a fast AA algorithm up to polynomial overhead. A fast AA algorithm says nothing about BB, and the reduction alone does not prove that BB is strictly harder.

Common mistakes

  1. Reversing the hardness arrow.
  2. Proving only “yes maps to yes” rather than an iff.
  3. Ignoring malformed strings or claiming a partial mapping.
  4. Measuring numeric runtime in value rather than binary length.
  5. Declaring NP-completeness after hardness without proving membership.
  6. Saying “Cook–Levin records a computation” without variables, constraints, correctness, and size.
  7. In 3SAT→IS, forgetting clause edges or complementary-literal edges.
  8. In the reverse proof, failing to explain why size mm forces one choice per clause.

Exercises

Exercise 1 — Direction of hardness

Let A≤pBA\le_p B. Prove: if B∈PB\in\mathrm P then A∈PA\in\mathrm P. Explain what flows backward and what flows forward along the reduction arrow.

Solution

If x∈A  ⟺  f(x)∈Bx\in A\iff f(x)\in B with ff polynomial-time, a decider for BB yields one for AA by composition. Algorithms/membership in downward-closed classes flow from BB to AA (backward along hardness). Hardness flows from AA to BB (forward): if AA is hard and A≤pBA\le_p B then BB is at least as hard as AA.

Exercise 2 — Two obligations for completeness

Define NP-completeness. Prove why NP membership alone or hardness alone is insufficient.

Solution

AA is NP-complete if (1) A∈NPA\in\mathrm{NP} and (2) for every L∈NPL\in\mathrm{NP}, L≤pAL\le_p A. Without (1), AA might be hard outside NP\mathrm{NP}. Without (2), membership does not equate it to the whole class.

Exercise 3 — Local windows in Cook–Levin

Explain why local-window constraints on the computation tableau suffice to enforce a legal TM computation.

Solution

A deterministic step changes only an O(1)O(1)-size neighborhood around the head. Consistency of all overlapping windows across time forces legal transitions from the input to an accepting configuration. Variable/clause counts are polynomial in the tableau size.

Exercise 4 — k=mk=m in 3SAT→IS

In the standard reduction from 3SAT to Independent Set with parameter k=mk=m (number of clauses), prove why choosing k<mk<m breaks equivalence.

Solution

The construction places a group per clause with conflict edges between opposite literals. k=mk=m forces selecting a vertex from every clause — matching a satisfying assignment. If k<mk<m, one may pick vertices from fewer clauses and ignore an unsatisfied clause, breaking the equivalence.

Exercise 5 — Transitivity and output size

Prove ≤p\le_p is transitive, emphasizing why ∣f(x)∣|f(x)| must be polynomial.

Solution

If ff reduces AA to BB and gg reduces BB to CC in polynomial time, then g∘fg\circ f is polynomial-time because ∣f(x)∣=poly(∣x∣)|f(x)|=\mathrm{poly}(|x|), so g(f(x))g(f(x)) runs in poly(poly(∣x∣))\mathrm{poly}(\mathrm{poly}(|x|)). Without an output-size bound, composition may leave polynomial time.

Summary

A reduction is an instance compiler with a direction. Completeness needs membership and hardness; direction and size mistakes are classic exam traps.

Guided practice

Task 1 — Refute a wrong direction

A student “proves” BB is hard via a reduction B≤pAB\le_p A where AA is easy. What is wrong?

Solution

B≤pAB\le_p A with A∈PA\in\mathrm P implies B∈PB\in\mathrm P — so BB is easy, not hard. To transfer hardness from AA to BB one needs A≤pBA\le_p B.

Task 2 — Partial reduction writeup

In a graph reduction only “if the formula is satisfiable then an independent set exists” is proved. Which parts are missing?

Solution

Missing: the converse (IS ⇒\Rightarrow satisfiable formula), malformed-input handling, time/size bounds for ff, and target NP membership if completeness is claimed.

Task 3 — From Cook–Levin to 3SAT-completeness

Outline how one passes from SAT to 3SAT while preserving NP-completeness (gadget idea, not a full proof).

Solution

Long clauses are split into 3-literal clauses with helper variables so satisfiability is preserved. The reduction is polynomial; with SAT∈NP\mathrm{SAT}\in\mathrm{NP} and SAT-hardness one obtains 3SAT-completeness.

Sources

Course evidence

  • Current Semester A transcript 9: polynomial many-one reductions, direction, transitivity, and closure.
  • Current Semester A transcript 10: NP-hardness, NP-completeness, and the consequences of a polynomial algorithm for a complete problem.
  • Current Semester A transcripts 12–13: the Cook–Levin computation tableau, local consistency, acceptance, and polynomial-size accounting.
  • Current Semester A transcript 14: SAT/3SAT graph gadgets, including the independent-set construction.
  • Merged course summary, pp. 43–49: polynomial reductions and completeness; pp. 50–54: Cook–Levin only; pp. 55–57, 64–66, and 72–75: the graph-problem family and graph reductions. No broader topic coverage is attributed to these ranges.

Textbook verification

  • Sipser, Introduction to the Theory of Computation, 3rd ed., §§7.4–7.5, pp. 300–325: polynomial reducibility, Cook–Levin, and 3SAT.
  • Arora–Barak, Computational Complexity: A Modern Approach (draft), §2.3, pp. 45–58: universality of tableau/Cook–Levin encodings and NP-completeness.
  • Papadimitriou, Computational Complexity, Chs. 8–9: reductions, NP-completeness, and the tableau proof. Textbooks verify the standard theorem; notation and teaching order here follow the course.