In 1972, Richard Karp published a paper titled "Reducibility Among Combinatorial Problems," in which he demonstrated that 21 decision problems were NP-complete. What is fascinating is that, until this date, no one has conclusively proven whether these problems can be solved using a polynomial-time algorithm. In layman's terms: if one can find a polynomial-time solution to any of these problems, like the Boolean Satisfiability Problem (SAT), then a domino effect ensues, and all NP problems would collapse to being polynomial-time solvable. Conversely, disproving the polynomial-time solvability for one inherently disproves it for all.
Post Script - pretty much, this blog series is my proving exercises before my final exam for the postgraduate course that I took, DDA6050: Analysis of Algorithms, draws near. Through this series, I attempt to prove the NP-completeness of Karp's problems from the ground up without relying much on established proofs.
Challenge Progress
Knapsack (simplified)
Given:
- an integer
KaTeX can only parse string typed expression
n
- a set of non-negative integers
KaTeX can only parse string typed expression
S={a1,…,an}
- an integer
KaTeX can only parse string typed expression
K
Task:
- Decide whether there is a subset
KaTeX can only parse string typed expression
P⊆S such that KaTeX can only parse string typed expression
∑ai∈P=K
Partition
Given:
- an integer
KaTeX can only parse string typed expression
n
- a set of non-negative integers
KaTeX can only parse string typed expression
{a1,…,an}
Task:
- Decide whether there is a subset
KaTeX can only parse string typed expression
P⊆[1,n] such that KaTeX can only parse string typed expression
∑i∈Pai=∑i∈/Pai
Partition is NP
The question of whether the Partition problem lies within NP can be addressed by examining the verification process for a potential solution, which we'll call a certificate. For the Partition problem, this certificate is a subset KaTeX can only parse string typed expression
P drawn from the indices KaTeX can only parse string typed expression
[1,n] of the given set of integers.
To verify the certificate's correctness, we start by computing the sum of the integers that are indexed by KaTeX can only parse string typed expression
P, which we denote as KaTeX can only parse string typed expression
∑i∈Pai. In parallel, we also determine the sum of the integers that aren't indexed by KaTeX can only parse string typed expression
P, represented by KaTeX can only parse string typed expression
∑i∈/Pai. Our main criterion for correctness then hinges on a straightforward comparison: are these two sums equal? If they are, our algorithm acknowledges the validity of the Partition and returns yes
. If not, it simply returns no
.
In terms of computational efficiency, this verification process is quite tractable. Calculating both summations takes linear time, specifically KaTeX can only parse string typed expression
O(n), and comparing them is a constant-time operation. Because the entire verification process is polynomial in KaTeX can only parse string typed expression
n, we can confidently state that the Partition problem is NP.
Partition is NP-hard by Knapsack
Let's consider a known NP-hard problem, Knapsack.
Given an instance of the simplified version of Knapsack problem with items KaTeX can only parse string typed expression
S={a1,…,an} and an integer KaTeX can only parse string typed expression
K, we then construct an instance of the Partition problem as follows:
- Compute
KaTeX can only parse string typed expression
H, which is half of the sum of the items in KaTeX can only parse string typed expression
S, i.e., KaTeX can only parse string typed expression
H=21∑ai∈Sai.
- Form a new set
KaTeX can only parse string typed expression
S˜=S∪{2H+2K,4H}.
The result of this transformation is KaTeX can only parse string typed expression
S˜, the goal is to find a subset of KaTeX can only parse string typed expression
S˜ that sums to KaTeX can only parse string typed expression
2(2H+(2H+2K)+4H)=4H+K.
(KaTeX can only parse string typed expression
⇒) Suppose there is a solution to the Knapsack problem where a subset KaTeX can only parse string typed expression
P⊆S that sums up to KaTeX can only parse string typed expression
K. Then, a solution to the Partition problem must also exist, as we can assign KaTeX can only parse string typed expression
4H into KaTeX can only parse string typed expression
P and KaTeX can only parse string typed expression
2H+2K to the other subset KaTeX can only parse string typed expression
S∖P. This is confirmed as KaTeX can only parse string typed expression
∑ai∈P+4H=4H+K=(2H−K)+(2H+2K)=∑ai∈S∖P+(2H+2K).
(KaTeX can only parse string typed expression
⇐) Conversely, if there is a subset of KaTeX can only parse string typed expression
S˜ that sums up to KaTeX can only parse string typed expression
4H+K, say KaTeX can only parse string typed expression
Q, we may conclude that both KaTeX can only parse string typed expression
2H+2K and KaTeX can only parse string typed expression
4H elements are not in the same subset as KaTeX can only parse string typed expression
6H+2K>4H+K. If the element KaTeX can only parse string typed expression
4H∈Q; then, KaTeX can only parse string typed expression
∑ai∈Q∖4H=K, we found KaTeX can only parse string typed expression
Q∖4H as our answer to the Knapsack problem. Otherwise, the element KaTeX can only parse string typed expression
2H+2K∈Q; then, KaTeX can only parse string typed expression
∑ai∈Q∖2H+2K=2H−K, which is the complement subset of the answer to the Knapsack problem.
This proves that KaTeX can only parse string typed expression
x∈Knapsack iff KaTeX can only parse string typed expression
f(x)∈Partition,∀x∈{0,1}∗.
The transformation involves adding two numbers to KaTeX can only parse string typed expression
S, which can be done in a constant time. Additionally, calculating KaTeX can only parse string typed expression
H requires summing over KaTeX can only parse string typed expression
S, which is done in KaTeX can only parse string typed expression
O(n). Hence, KaTeX can only parse string typed expression
f is a polynomial time transformation, which proves that the Partition problem is NP-hard.
Partition is NP-complete
Since the Partition problem is both in NP and NP-hard, we conclude that the Partition problem is NP-complete; hence, shown.