The 0-1 knapsack problem #
Knapsack is the decision version of the 0-1 knapsack problem: given items, each with a weight
and a value, a capacity and a goal, some sub-multiset of the items has total weight at most the
capacity and total value at least the goal [GJ79]. All numbers are encoded in binary
(encNat); the verifier compares the sums in binary (ComputableTidilyInPolyTime.binary_le).
Giving every number of a subset sum instance equal weight and value, and taking the target as
both capacity and goal, reduces SubsetSum to Knapsack. Karp's KNAPSACK [Kar72] is the
subset sum form of the problem.
Main definitions #
Cslib.Complexity.Knapsack,Cslib.Complexity.encKnapsack.Cslib.Complexity.Knapsack.verifier.Cslib.Complexity.SubsetSum.toKnapsack.
Main results #
Cslib.Complexity.mem_Knapsack_iff_sublist: solutions are subsequences of the items.Cslib.Complexity.Knapsack.mem_NP:Knapsack ∈ NP encKnapsack.Cslib.Complexity.SubsetSum.toKnapsack_mem_iff: correctness of the reduction.Cslib.Complexity.polyTimeReducible_SubsetSum_Knapsack,Cslib.Complexity.Knapsack_npHard,Cslib.Complexity.Knapsack_npComplete:KnapsackisNP-complete.
References #
Knapsack.verifier verifies Knapsack with certificates as long as the encoded instance.
The Knapsack verifier is polynomial-time: the sums and comparisons are in binary.
The reduction to Knapsack is polynomial-time.
SubsetSum reduces to Knapsack in polynomial time.
The 0-1 knapsack problem is NP-complete, with all numbers in binary Garey and Johnson.