Definition
3-SAT to Subset Sum
There is a polynomial-time many-one reduction from the 3-SAT problem to the Subset Sum problem:
Construction
Let
be a 3-SAT formula over variables . Represent each constructed integer by decimal digits, divided into
For a predicate , write when is true and otherwise.
Assignment numbers
For every variable , create two numbers and . Their variable digits satisfy
Their clause digits record which clauses the corresponding assignment satisfies:
Selecting represents ; selecting represents .
The following table shows the construction for
Each pair has its in the same variable column. The clause columns differ according to which choice makes each clause true.
Fill-up numbers
For each clause , create two distinct copies and of the number whose only non-zero digit is a in clause position . These numbers can add zero, one, or two to that clause digit.
The target leaves exactly enough room to fill every positive contribution, but not a zero contribution:
Target
Set the target to
The resulting Subset Sum multiset is
No-carry Invariant
Decimal addition is digitwise
No selected subset can produce a carry. A variable digit receives at most two units, one from and one from . A clause digit receives at most three units from assignment numbers and two from its fill-up numbers. Every digit sum is therefore at most .
Consequently, equality with can be checked independently in every digit position.
Correctness
The formula is satisfiable if and only if some submultiset of sums exactly to .
Correctness
Forward
Suppose that an assignment satisfies . For each variable , select if and if . Every variable digit then sums to exactly .
In each clause digit, the selected assignment numbers contribute because the clause has at least one true literal. Select exactly of the clause’s two fill-up numbers. Every clause digit then reaches , so the selected numbers sum to .
Backward
Suppose that a submultiset of sums to . Since the variable digit for has target , the no-carry invariant forces the subset to contain exactly one of and . These choices define a truth assignment.
Consider a clause digit. Its two fill-up numbers can contribute at most , while its target is . At least one selected assignment number must therefore contribute to this digit. By construction, its chosen truth value satisfies a literal of the clause. Hence every clause is satisfied.
Running Time
The reduction creates integers, each with decimal digits. Its output contains
digits in total. Since an -digit decimal integer also has binary bits, the reduction runs in time polynomial in the size of the 3-SAT instance.
Numerical Magnitude
The constructed integers may have numerical value as large as . Their values are therefore exponential even though their binary encodings have polynomial length. This reduction proves NP-hardness but does not establish strong NP-hardness, consistently with Subset Sum being weakly NP-hard.
NP-completeness
Since 3-SAT is NP-hard, the reduction proves that Subset Sum is NP-hard. Together with membership in NP, this proves that Subset Sum is NP-complete.
Example
Two clauses
Consider
Use the digit order . The construction gives:
number digits satisfied clauses 100 10100 01010 11010 00none 001 01001 10000 10fill 000 01fill 111 33target Under the satisfying assignment , , and , select . Their sum is
111 22. Adding one fill-up number for each clause reaches111 33: