We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Subset-Sum NP Complete
Summary
We prove that the Subset-Sum problem is NP-Complete by reducing from 3SAT to SS.
Contents
Subset Sum
Input: positive integers
Output: Subet of numbers S that add up to t
If there is an O(nt) algorithm, this problem is NOT in P since its not polynomial in the SIZE of the input. It would need to be O(n log(t)).
SS is in NP
Given inputs and S, check that , takes time O(n log(t))
Reduce 3SAT to Subset-Sum
Input to subset-sum problem will be 2n + 2m + 1 numbers
All are digits long
Variables
Need to ensure exactly one of
In ith digit of put a 1, all other numbers put a 0
Example
1 | |||||||
1 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
0 | |||||||
1 |
This corresponds to only including since the sum has to equal the target of 1. Then digit n+j corresponds to clause
if put a 1 in digit n+j for
1 | 0 | 0 | 0 | ||||
1 | 0 | 0 | 1 | ||||
0 | 1 | 0 | 0 | ||||
0 | 1 | 0 | 1 | ||||
0 | 0 | 1 | 0 | ||||
0 | 0 | 1 | 1 | ||||
0 | 0 | 0 | 1 | ||||
0 | 0 | 0 | 1 | ||||
0 | 0 | 0 | 0 | ||||
0 | 0 | 0 | 0 | ||||
0 | 0 | 0 | 0 | ||||
0 | 0 | 0 | 0 | ||||
0 | 0 | 0 | 0 | ||||
0 | 0 | 0 | 0 | ||||
1 | 1 | 1 | 3 |
This corresponds to only letting us pick 3 in the column of . If all three are satisfied, we pick one of the variables. If one is not, we skip it and include one of the s variables (buffer). Since we only have 2 buffers but need a sum of 3, we have to have at least on literal be satisfied.
1 | 0 | 0 | 0 | 0 | 1 | 1 | |
1 | 0 | 0 | 1 | 1 | 0 | 0 | |
0 | 1 | 0 | 0 | 0 | 0 | 1 | |
0 | 1 | 0 | 1 | 1 | 1 | 0 | |
0 | 0 | 1 | 0 | 1 | 1 | 0 | |
0 | 0 | 1 | 1 | 0 | 0 | 0 | |
0 | 0 | 0 | 1 | 0 | 0 | 0 | |
0 | 0 | 0 | 1 | 0 | 0 | 0 | |
0 | 0 | 0 | 0 | 1 | 0 | 0 | |
0 | 0 | 0 | 0 | 1 | 0 | 0 | |
0 | 0 | 0 | 0 | 0 | 1 | 0 | |
0 | 0 | 0 | 0 | 0 | 1 | 0 | |
0 | 0 | 0 | 0 | 0 | 0 | 1 | |
0 | 0 | 0 | 0 | 0 | 0 | 1 | |
1 | 1 | 1 | 3 | 3 | 3 | 3 |
Correctness
SS has a solution 3SAT is satisfiable
Forward Claim
Take solution S to subset-sum
for digit i where :
- to get a 1 in digit i, include but not both
This gives us an assignment.
For digits n+j where :
- to get a sum of 3 in digit n+j, need to include literal of
This proves our assignment is satisfying.
Reverse Claim
Take a satisfying assignment for f:
-
- ith digit of t is correct
- for clauses literals is satisfied
- gets up to a sum of 3 in digit n+j, when using s buffers