one digit column per edge, no carrying

VC ≤p SUBSET-SUM

VC≤pSUBSET-SUM\mathrm{VC}\le_p\mathrm{SUBSET\text{-}SUM}, hence SUBSET-SUM\mathrm{SUBSET\text{-}SUM} is NP-complete.

The construction

The idea. Build numbers you can picture as rows of a table: one special column dd, plus one column per edge. A vertex row "reports" which edges it touches; an edge row is a unit vector. The target demands exactly 22 in every edge column and exactly KK in column dd. The trick: "exactly 22" is satisfiable iff at least one endpoint of the edge was chosen.

The algorithm. On input G=(V,E)G=(V,E) and K∈NK\in\mathbb N, write m=∣E∣m=|E| and E={e1,…,em}E=\{e_1,\dots,e_m\}:

  1. If K>∣V∣K>|V|, replace KK by ∣V∣|V|.
  2. For each v∈Vv\in V a number ava_v of m+1m+1 digits: the leftmost digit is 11, and digit j+1j+1 is 11 if v∈ejv\in e_j, else 00.
  3. For each e∈Ee\in E a number aea_e of m+1m+1 digits: the leftmost is 00, and digit j+1j+1 is 11 iff e=eje=e_j.
  4. A target SS: its leftmost digits encode KK, and every remaining digit is 22.
  5. Return the list {av}∪{ae}\{a_v\}\cup\{a_e\} and SS.

Algebraically: av=10m+∑j=1m[ v∈ej ]⋅10 m−j,aei=10 m−i,S=K⋅10m+∑j=1m2⋅10 m−j.a_v=10^{m}+\sum_{j=1}^{m}[\,v\in e_j\,]\cdot10^{\,m-j},\qquad a_{e_i}=10^{\,m-i},\qquad S=K\cdot10^{m}+\sum_{j=1}^{m}2\cdot10^{\,m-j}.

About step 0. VC\mathrm{VC} asks for a cover of size at most KK, while the construction forces exactly KK in column dd. The gap is harmless: (a) adding vertices to a cover keeps it a cover, so a cover of size ≤K\le K with K≤∣V∣K\le|V| can be padded to exactly KK; (b) if K>∣V∣K>|V| then (G,K)∈VC(G,K)\in\mathrm{VC} always, so the replacement does not change the answer.

Visualization

Guided construction

Vertex Cover → Subset Sum

Step 1 of 8
G = P₅: |V| = 5, m = |E| = 4K = 3
The input path beside a chart of the edge-column totalsOn the left a path of five vertices and four edges, each edge carrying a badge with how many of its endpoints were chosen. On the right one bar per edge column, split into the part contributed by chosen vertices and the part contributed by that edge's own number, against guide lines at the target 2, the maximum 3, and the carry threshold 10.G — the input graphEdge-column totals cⱼe₁e₂e₃e₄v₁v₂v₃v₄v₅02310e₁e₂e₃e₄
Vertex number a_v
One row per constructed number; one column for d and one for each edge; the last rows give the column totals and the target.
numberde₁e₂e₃e₄value
Step 0 — at most K becomes exactly KIf K > |V| replace K by |V|. A cover of size ≤ K always pads up to size exactly K, so forcing K in column d is harmless.

Correctness — both directions

VC ∈ ⟹ SUBSET-SUM ∈

Lemma 4.1 (no carrying) — the step without which nothing works. Let II be any subset of the constructed numbers, write U=I∩{av}U=I\cap\{a_v\} (identified with a vertex set) and for each jj cj=∣{v∈U:v∈ej}∣+[ aej∈I ].c_j=\bigl|\{v\in U:v\in e_j\}\bigr|+[\,a_{e_j}\in I\,]. Then (1) 0≤cj≤30\le c_j\le3; (2) ∑x∈Ix=∣U∣⋅10m+∑jcj10m−j\sum_{x\in I}x=|U|\cdot10^m+\sum_j c_j 10^{m-j}, and this is exactly the decimal representation — the addition carries in no edge column; (3) ∑jcj10m−j<10m\sum_j c_j10^{m-j}<10^m.

Proof. (1) The edge eje_j has exactly two endpoints, so at most two vertex numbers carry a 11 in column jj, plus exactly one edge number; the column total is ≤3\le3. (2) Expand and group by powers of 1010; each cj≤3≤9c_j\le3\le9 is a legal digit, so nothing carries left. (3) ∑j3⋅10m−j=10m−13<10m\sum_j 3\cdot10^{m-j}=\frac{10^m-1}{3}<10^m. □\square

Corollary 4.2 (the digit criterion). ∑x∈Ix=S\sum_{x\in I}x=S iff ∣U∣=K|U|=K and cj=2c_j=2 for every jj. Proof of ⇒\Rightarrow: write L=∑jcj10m−jL=\sum_j c_j10^{m-j} and L′=∑j2⋅10m−jL'=\sum_j2\cdot10^{m-j}, both in [0,10m)[0,10^m). The hypothesis gives (∣U∣−K)⋅10m=L′−L(|U|-K)\cdot10^m=L'-L, whose right side is smaller than 10m10^m in absolute value while the left is an integer multiple of 10m10^m — so both vanish. □\square

The direction. Suppose (G,K)∈VC(G,K)\in\mathrm{VC}; after step 0, K≤∣V∣K\le|V|, so there is a cover U⊆VU\subseteq V with ∣U∣=K|U|=K exactly. Put I1={au∣u∈U}I_1=\{a_u\mid u\in U\}.

In column dd each contributes 11, and exactly KK vertices were chosen — contribution KK, exactly as in SS.

Fix jj. As UU is a cover, at least one endpoint of eje_j lies in UU; and as there are only two endpoints, at most two. So the column total is 11 or 22.

Define I2I_2: for every jj whose column came to 11, add aeja_{e_j}. That number adds 11 to column jj alone and 00 everywhere else (including dd), so it "repairs" 11 to 22 without disturbing anything. It cannot repair 00 to 22 — and that is exactly right: the value 00 cannot occur here, precisely because UU is a cover.

So cj=2c_j=2 for every jj and ∣U∣=K|U|=K, and by Corollary 4.2 the numbers in I1∪I2I_1\cup I_2 sum to exactly SS.

SUBSET-SUM ∈ ⟹ VC ∈

Suppose some subset II of the constructed numbers sums to exactly SS. As in Lemma 4.1, write U=I∩{av}U=I\cap\{a_v\} (identified with a vertex set). By Corollary 4.2, ∣U∣=K,cj=∣{v∈U:v∈ej}∣+[ aej∈I ]=2for every 1≤j≤m.|U|=K,\qquad c_j=\bigl|\{v\in U:v\in e_j\}\bigr|+[\,a_{e_j}\in I\,]=2\quad\text{for every }1\le j\le m .

Fix jj. The term [ aej∈I ][\,a_{e_j}\in I\,] is at most 11, since there is exactly one number for the edge eje_j and it can be picked at most once. Hence ∣{v∈U:v∈ej}∣=2−[ aej∈I ]  ≥  1.\bigl|\{v\in U:v\in e_j\}\bigr|=2-[\,a_{e_j}\in I\,]\;\ge\;1 .

So every edge eje_j has at least one endpoint in UU, i.e. UU is a vertex cover of GG. Its size is ∣U∣=K≤K|U|=K\le K, so (G,K)∈VC(G,K)\in\mathrm{VC}.

Cost of the reduction

TimeO(|x|²)
SpaceO((|V| + m)·m)
Output sizeO((|V| + m)·m + log K) digits

One loop over the vertices and one over the edges, writing an (m+1)(m+1)-digit number for each, plus SS. Testing "v∈ejv\in e_j" is O(1)O(1) with adjacency lists, so computation time is proportional to output size.

A remark made only in passing, and the heart of the lesson: the value of every constructed number is of order 10m10^{m} — exponential in the input size. This is not a problem, because the reduction must run in polynomial time and writing such a number costs only m+1m+1 digits. The reduction is legal precisely because it may produce numbers of enormous value with a modest encoding length — the same value-versus-length distinction, seen from its other side.

What it buys

SUBSET-SUM\mathrm{SUBSET\text{-}SUM} is NP-complete. From here the numeric chain continues: SUBSET-SUM≤pPARTITION≤pBIN-PACKING\mathrm{SUBSET\text{-}SUM}\le_p\mathrm{PARTITION}\le_p\mathrm{BIN\text{-}PACKING}.

Pitfalls

  • Without the no-carry lemma there is no proof. Had any column total reached 1010, it would carry a 11 leftward, and a correct-looking total could arise from an entirely wrong combination of columns — ten 11s in one column "impersonating" a 11 in its neighbour. The whole argument rests on equal sums forcing equality digit by digit. (Any base ≥4\ge4 would do; base 1010 is chosen purely for legibility.)

  • KK is written as a block of digits, not one digit. The number of chosen vertices ∣U∣|U| may be 1010 or more, and then the leftmost "digit" is not a digit. The argument in Corollary 4.2 assumes nothing about ∣U∣|U| — it only exploits that anything below 10m10^m stays below 10m10^m.

  • The reduction builds numbers from the graph and KK alone and never looks for a cover. The same "grave sin" rejected in 3COL≤p4COL\mathrm{3COL}\le_p\mathrm{4COL} recurs here: the construction must never be phrased in terms of the solution.

The chain

Where this was read from

  • Lesson 11משפט 4 (לב השיעור): VC≤pSUBSET-SUM\mathrm{VC} \le_p \mathrm{SUBSET\text{-}SUM}
  • Guided exercisesubset-sum-encoding
  • The ⇐\Leftarrow direction is absent from the written summary and was given orally in the lecture with the remark "if you really want to feel you understand this — write it out". The write-up here is that completion.