Documentation

Complexity.Computability.Complexity.Problems.Knapsack

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 #

Main results #

References #

Instances (items, capacity, goal) of the 0-1 knapsack problem, items given as (weight, value): some sub-multiset of the items has total weight at most the capacity and total value at least the goal Garey and Johnson.

Instances For
    @[reducible, inline]

    Knapsack instances, with all numbers in binary.

    Instances For

      Knapsack asks for a subsequence of the items.

      The verifier for Knapsack: the items selected by the certificate mask fit the capacity and reach the goal.

      Instances For

        The reduction from SubsetSum to Knapsack: each number becomes an item with equal weight and value, and the target becomes both the capacity and the goal.

        Instances For

          The 0-1 knapsack problem is NP-complete, with all numbers in binary Garey and Johnson.