← Student tools · Problem 29 · Lecture 12 · Round 2 (30 pts)

3SAT → SUBSET-SUM · the digit-position trick

Build numbers whose digits encode variables and clauses; a subset sums to target iff formula is satisfiable.

CLO-4R2·30 ptsL12
🔊 Listen

SUBSET-SUM = {⟨S, t⟩ : S has a subset summing to t}. We prove SUBSET-SUM NP-complete by reducing 3SAT to it (Sipser §7.5). The trick is one of the most beautiful in the chain: each digit position in a base-10 number encodes a separate constraint, so summing numbers digit-by-digit checks all constraints simultaneously.

Construction · f(⟨φ⟩) = ⟨S, t⟩

For a 3CNF φ with n variables and m clauses:

  1. Layout: each number has n + m digits — n variable positions, m clause positions.
  2. For each variable xi: two numbers, one for xi = true, one for xi = false. The variable position i has digit 1; clause positions get a 1 in each clause this literal satisfies.
  3. Slack numbers: for each clause, two slacks of value 1 and 2 in its position (or four slacks of value 1, depending on the variant). They absorb the difference between "clause has 1 true literal" and "clause has 3."
  4. Target t: digit 1 in each variable position (exactly one of the two variable-numbers chosen), digit 3 in each clause position (clause covered, plus slack).

Two key invariants make this work:

🔊 Listen
Tiny instance · 2 vars, 2 clauses Auto-plays
🔊 Listen
🔊 Listen
🔊 Listen

Sipser: Theorem 7.56 (3SAT ≤p SUBSET-SUM). Lecture notes: Module 5 slide 5. Companion problems: P27 (3SAT → CLIQUE), P28 (CLIQUE → VC), P30 (HAMPATH reduction).