NP-completeness proofs (3): set-related problems
In this article, we’ll explore three fundamental NP-completeness proofs involving set-based problems: set cover, partition, and subset sum. These proofs demonstrate elegant reductions between different computational problems and provide insights into the nature of NP-completeness. — At least, I hope it do provide insights to you. 😆
Have fun proving them by yourself!
P1: Set cover problem
Definition.
Set cover decision: Given a set of elements , a collection of subsets of , and an integer , does there exist a selection of or fewer sets from whose union equals ?
Proof by reduction from vertex cover.
Certificate: Verifying sets of elements would costs , which is in polytime. Thus the problem is NP.
Vertex cover decision: Given a graph and an integer , does there exist a subset of vertices such that and for each edge , at least or belongs to ?
Reduction: Let . For each vertex , put all edges connected to into a set .
Given an algorithm to find a set cover of size that covers , i.e. covers all edges in the graph, then we can pick either or for each edge to form a vertex cover of size .
The construction of set cover inputs costs since we are iterating through all edges connected to all vertices. This reduction is in polytime. In conclusion, the set cover decision problem is NP-complete.
P2: Partition problem
Definition.
Partition decision: Given a set of integers , can it be partitioned into two subsets and such that and ?
Proof by reduction from subset sum.
Certificate: Calculating and are both , so verification is in polytime. Thus, the problem is NP.
Subset sum decision: Given a set of integers and an integer , does there exist a subset such that ?
Reduction: Construct a set where and , which sums to .
Given an algorithm to partition into two subsets, and , they must be of equal sum . Each subset cannot contain both and due to ; one subset must contain , and then the rest of the integers in must sum to . This solves subset sum problem.
Calculating is , thus the reduction is in polytime. In conclusion, the partition decision problem is NP-complete.
P3: Subset sum problem
Definition.
Subset sum decision: Given a set of integers and an integer , does there exist a subset such that ?
Proof by reduction from 3-SAT.
Certificate: Calculating is , so verification is in polytime. Therefore, the problem is NP.
3-SAT: Given a 3-CNF formula of clauses, does there exist a set of values that makes the formula True?
Reduction: For each variable , create two base-2 integers , whose bits are:
- variable-slots: only the -th digit is marked 1, other digits are marked 0.
- clause-slots: for each clause :
- If exists in the clause , then ’s bit should be 1, otherwise 0.
- If exists in the clause , then ’s bit should be 1, otherwise 0.
For example, for a formula , we have 3 variables and 2 clauses, therefore 5 digits:
- : (being the 1st variable; appearing in )
- : (being the 1st variable; appearing in )
- : (being the 2nd variable; appearing in )
- : (being the 2nd variable; appearing in )
- : (being the 3rd variable; appearing in and )
- : (being the 3rd variable; not appearing at all)
Let the subset sum and in the example, . By finding a satisfying subset, e.g., , we have found the answer to the 3-SAT as well, since each variable-slot is satisfied exactly once, and each clause-slot is satisfied also exactly once.
The construction of the base-2 integers costs at least , which is in polytime. In conclusion, the subset sum problem is NP-complete.