You are on page 1of 5

+ CS466 Lecture Notes, Spring 1995.

Lecture 25

SUBSET-SUM is NP-complete. Reference: Section 36.5.3 of CLR.

De nition. The SUBSET-SUM problem is the following: you are given a set of positive integers and a \target" . Question:
S t

Is there a subset 0 of such that the sum of the elements of 0 is equal to ?


S S S t

Theorem. The SUBSET-SUM problem is NPcomplete.


To prove this, we follow the \ ve-steps".
S

1. SUBSET-SUM is in NP. To prove this, observe that if someone gives us the set 0, we can in polynomial time determine the sum of the elements in 0, and see if that is equal to . + 1
S t

2. We will show VERTEX-COVER p SUBSET-SUM. 3. We need to show how to transform an instance of VERTEX-COVER to an instance of SUBSET-SUM. A VERTEX-COVER instance is a pair . Our construction will be based on the incidence matrix of the graph = ( ). The incidence matrix ij is a j j j j matrix that is de ned as follows:
< G; k > G V; E M V E M

ij

1 if edge j = 0 otherwise.is incident on vertex


e :

(1)

See Figure 36.14, page 952 of CLR. Notice that each row of the incidence matrix corresponds to the edges touching a given vertex. We now construct a set of numbers and a target such that there is a solution to the subset-sum problem i the original graph has a vertex-cover of size .
S t < S; t > k G

+
We do this as follows: =f 0 jV j 1g f where jE j 1 jE j + X i=4
S x ;:::;x x

y0 ; : : : ; y

jE j

for 0 for 0

i <

j j and
V

j =0

ij

4j

j <

j j and
E t

= 4j
jE j 1 X
j =0

4jEj + 2

4j

Proof. Suppose the original graph0 has a vertex cover of size . Then there is a subset such that each edge of touches a vertex in 0, and j 0j = . Then for my subset 0 I pick 0 = f i : i 2 0 g f j : edge j touches exactly one vertex in 0g
G k V G V V k S S x v V y e V :

4. Claim: there is a solution 0 to the subsetsum problem i the original graph has a vertex-cover 0 of size .
S < S; t > V G k

+
S t

We claim this subset 0 sums to . To prove this, convince yourself that we can check this claim on each digit of the elements of . (The carries do not interfere since at most 3 elements of have a 1 in digit position , for all less than j j.) Since the original graph has a vertex cover of size , the most signi cant digit(s) of the sums are , and this matches the target. Since since 0 is a vertex cover, each edge (i.e. column) has at least one vertex in 0 (i.e. row sum) that touches it (i.e. has a 1 in that digit position). It might have two, in which case none of the j 's 0 in 0 have a 1 in that position, by our de nition of . If it is has only one 1, then another 1 is added by the appropriate j . Thus for all digit positions except the most signi cant one(s), the column sum is 2. This matches the target. To prove the other direction, assume that there is a subset 0 that matches the target. De ne 0 = f i : number i 2 0 g Then 0 is a vertex cover. Since the target has a \ " in the most signi cant digit, this corresponds to picking exactly of the i. Thus 0 has exactly elements. To see that 0 is a vertex cover, let j be an edge in . Then there is a 2 in every other digit position of the target except the most signi cant one(s). Since there are only three elements of that have a 1 in digit position (namely, r and s, where j = ( ), and j ), at least 1 of the total contribution of 2 must come from an i 2 0. Hence j touches i, and i is in 0 . This completes the proof that 0 is a vertex cover.
S S j j E G k k V V y S S y S V v x S : V k k x V k V e G S j x x e r; s y x S e v v

5. Convince yourself that this transformation (from an instance of VERTEX-COVER to an instance of SUBSET-SUM) can be done in polynomial time. 2 Thus, SUBSET-SUM is NP-complete. This is rather remarkable, when one considers that the subset-sum problem deals with sums of numbers, and is quite far away from our original NP-complete problem of circuit satis ability!

You might also like