On Jan 17 I asked the following question on cs.stackexchange.com:
What is the complexity of the following variant of the SUBSET-SUM decision problem?
2-BIT SUBSET SUM: Given an integer m≥0, and a set of nonnegative integers A={x1,x2,…,xn} such that every xi has at most k=2 bits set to 1 (xi=2bi1+2bi2,bi1,bi2≥0); is there a subset A′⊆A such that the sum of its elements is equal to m ?
(see the original question and answer on cs.stackexchange)
The problem is trivially solvable in polynomial time if k=1 and I quickly found a reduction from monotone X-SAT if k=3; but Tom van der Zanden found an easy reduction from SUBSET-SUM even if k=2. Here it is a sketch of the polynomial time reduction.
The main idea is that an integer x of the original SUBSET-SUM problem having k>2 bits set to 1, can be converted to k 2-bit integers (here "2-bit integer" means having at most 2 bits equal to 1) y1,…,yk such that y1+y2+…+yk=2(k−1)+t+x where t is a large enough integer that will be used to keep the sum of the high bits of the ys distinct
Suppose that b1,b2,…,bk are the positions of the bits that are set to 1 in the integer x, then we set y1=2b1+2t, y2=2b2+2t and for 2<j≤k: yj=2bj+2t+j−2. For example if x=53=1101012:
...t...543210 << bit position x: ...110101 (k = 4) y1: 1...000001 y2: 1...000100 y3: 10...010000 y4: 100...100000 sum: 1000...110101 = 2^{(k-1)+t} + x
Now if we add an extra integer z=2(k−1)+t and we modify the target of the original subset sum problem: m′=m+2(k−1)+t then a valid solution in the corresponding 2-BIT SUBSET SUM problem must contain z or (exclusive) all the yj:
x: ...110101 (k = 4) y1: 1...000001 y2: 1...000100 y3: 10...010000 y4: 100...100000 sum: 01000...110101 = 2^{(k-1)+t} + x z: 01000...000000 = 2^{(k-1)+t} m': 01000...[ m ] = 2^{(k-1)+t} + m ^ this new bit in the target sum force a valid solution to contain z or (exclusive) ALL the y1...y4 above
The whole reduction from SUBSET SUM problem to 2-BIT SUBSET SUM problem can be done in the following way:
given an instance of the SUBSET SUM problem, i.e. an integer m≥0 and a set of n nonnegative integers A=x1,...,xn (all in binary format); start with t equal to ⌈log2(∑ixi)⌉+1, A′=∅, m′=m. For each xi∈A: if xi has k=2 or fewer bits equal to 1 add it to A′, otherwise if it has more than 2 bits equal to 1, calulate the corresponding integers yj and z and set A′=A′∪{y1,...,yk}∪{z} and m′=m′+2(k−1)+y, finally increase t=t+k+1.
The resulting 2-BIT SUBSET SUM problem with target sum m′ and the set of 2-bit integers A′ has a solution if and only if the original SUBSET SUM problem has a solution.
Conclusion: the SUBSET SUM problem remains NP-complete even if we restrict the integers of the given set to have at most 2 bits equal to 1.
Is a similar claim true for subset product problem?
Nice question. I don’t see a quick similar proof; I’ll think about it.
Could you show your reduction from X-SAT if k=3?