variable columns and clause columns, with slack digits

3SAT ≤p SUBSET-SUM

3SAT≤pSUBSET-SUM\mathrm{3SAT}\le_p\mathrm{SUBSET\text{-}SUM} — the classical form of the reduction, encoding the choice of assignment and the satisfaction of clauses in carry-free digit columns.

The construction

On a 3CNF formula φ\varphi with variables x1,…,xnx_1,\dots,x_n and clauses C1,…,CmC_1,\dots,C_m. All numbers are written in base 1010 with n+mn+m digits: nn variable columns followed by mm clause columns.

  1. Two numbers per variable. For each ii define yiy_i (for xi=Truex_i=\mathrm{True}) and ziz_i (for xi=Falsex_i=\mathrm{False}):
    • in variable column ii — digit 11 in both; in every other variable column — 00.
    • in clause column jj — in yiy_i, digit 11 if the literal xix_i occurs in CjC_j, else 00; in ziz_i, digit 11 if xi‾\overline{x_i} occurs in CjC_j, else 00.
  2. Two slack numbers per clause. For each jj define gjg_j and hjh_j, both with digit 11 in clause column jj and 00 everywhere else.
  3. The target SS: digit 11 in every variable column and digit 33 in every clause column.
  4. Return all the numbers together with SS.

What each column enforces. A variable column demands exactly 11, and only yiy_i and ziz_i carry a 11 there — so exactly one of them is chosen, i.e. the assignment is well defined. A clause column demands 33, and the two slack numbers together supply at most 22; so at least one variable number contributing to that column must be chosen — i.e. the clause is satisfied.

Visualization

Guided construction

3SAT → Subset Sum

Step 1 of 6
φ = (x₁ ∨ ¬x₂) ∧ (¬x₁ ∨ x₂)
number
x₁
x₂
C₁
C₂

Correctness — both directions

3SAT ∈ ⟹ SUBSET-SUM ∈

Suppose vv satisfies φ\varphi. Choose the numbers:

  • for each ii: if v(xi)=1v(x_i)=1 take yiy_i, otherwise ziz_i.
  • for each jj: let sj∈{1,2,3}s_j\in\{1,2,3\} be the number of literals of CjC_j that vv satisfies (at least 11, since vv satisfies CjC_j, and at most 33). Take 3−sj3-s_j of the slack numbers of CjC_j — that is 22, 11, or 00 of them. This is possible since 3−sj∈{0,1,2}3-s_j\in\{0,1,2\} and there are two slack numbers.

Variable columns. In column ii exactly one number (yiy_i or ziz_i) contributed digit 11; the slack numbers contribute 00 there, and other variables' numbers contribute 00 in column ii. The total is 11 — as required.

Clause columns. In column jj the chosen variable numbers contribute exactly sjs_j (the number of satisfied literals of CjC_j), and the chosen slack numbers contribute 3−sj3-s_j. The total is sj+(3−sj)=3s_j+(3-s_j)=3 — as required.

Column totals are bounded: at most 22 in a variable column and at most 3+2=53+2=5 in a clause column, so nothing carries and digits may be read one by one. The overall sum is exactly SS.

SUBSET-SUM ∈ ⟹ 3SAT ∈

Suppose some subset II sums to SS. Since every column total is bounded by 5<105<10 (at most 22 in a variable column; at most 33 from variable numbers plus 22 from slack in a clause column), nothing carries, so equal sums force equality column by column.

Variable columns. Column ii demands total 11. Only yiy_i and ziz_i carry a non-zero digit there, and both carry 11. So exactly one of them lies in II. Define the assignment: v(xi)=1v(x_i)=1 if yi∈Iy_i\in I, and v(xi)=0v(x_i)=0 if zi∈Iz_i\in I. This is well defined and total.

Clause columns. Column jj demands total 33. The contributors are the slack numbers gj,hjg_j,h_j — at most 22 together — and chosen variable numbers whose literal occurs in CjC_j. So the variable numbers contribute at least 3−2=13-2=1, i.e. there exists a chosen variable number contributing 11 to column jj.

Take such a number. If it is yiy_i, then by construction the literal xix_i occurs in CjC_j, and by definition v(xi)=1v(x_i)=1 — the literal is satisfied. If it is ziz_i, then xi‾\overline{x_i} occurs in CjC_j and v(xi)=0v(x_i)=0 — again satisfied. Either way CjC_j is satisfied.

As jj was arbitrary, vv satisfies φ\varphi, i.e. φ∈3SAT\varphi\in\mathrm{3SAT}.

Cost of the reduction

TimeO((n+m)²)
SpaceO((n+m)²)
Output size(2n + 2m + 1) numbers of n+m digits each

The output holds 2n2n numbers (two per variable) plus 2m2m (two per clause), each of n+mn+m digits. The total digit count is (2n+2m)(n+m)+(n+m)=O((n+m)2)(2n+2m)(n+m)+(n+m)=O((n+m)^2) — exactly the count the exam papers asked for. Time is proportional to output size.

As in VC≤pSUBSET-SUM\mathrm{VC}\le_p\mathrm{SUBSET\text{-}SUM}: the value of each number is exponential in the input size while its written length is polynomial — and that is what makes the reduction legal.

What it buys

SUBSET-SUM\mathrm{SUBSET\text{-}SUM} is NP-hard, by a route that does not pass through VC\mathrm{VC}.

Pitfalls

  • Two slack numbers per clause are needed, not one. A clause can be satisfied by 11, 22, or 33 literals, so the shortfall to 33 is 22, 11, or 00 — and two slack numbers cover exactly those three cases. With one slack number, a clause satisfied by a single literal could not reach 33.

  • The clause-column target is 33, not 11. Were it 11, a slack number alone would satisfy the column with no variable number at all — and the backward direction would collapse.

The chain

Where this was read from

  • 2025 '1 מועד 1"What is the total number of digits across all output numbers, for a 3CNF formula with nn variables and mm clauses?"
  • 2024 '1 מועד 1"In class we saw a reduction from 3-SAT to Subset Sum" — tracing the match between a satisfying assignment and a subset.
  • 2024 '1 מועד 2The same construction, on a concrete formula.
  • 2023 '2 מועד 2A description of the reduction function into Subset-Sum, and whether it is legitimate.
  • An important mapping note: the 2026B lessons do not teach this reduction — lesson 11 proves SUBSET-SUM\mathrm{SUBSET\text{-}SUM} hard through VC\mathrm{VC}, by a completely different construction (a column per edge). The 3SAT reduction is the one the 2023–2025 papers call "the one we saw in the lecture", i.e. it was taught in earlier years. Both constructions are correct and both are in the corpus; they must not be conflated — they differ in input, in columns, and in target.

  • Since this reduction has no lesson source in the corpus, the construction details above are the standard form consistent with what the papers do state (the digit count, the assignment↔subset correspondence). Minor differences of phrasing from the version given in class those years are possible.