Multiple knapsack problem
AbbreviationMultiple-knapsack instances#✓fully proved
A multiple-knapsack instance consists of a finite list of items, each a pair \((w, v)\) of natural numbers giving its weight \(w\) and value \(v\), a finite list of natural-number knapsack capacities, and a natural-number target value.
Used by 2
DefinitionFeasible multiple-knapsack instances#✓fully proved
Let a multiple-knapsack instance have items \((w_0, v_0), \dots, (w_{k-1}, v_{k-1})\) (weight, value), knapsack capacities \(c_0, \dots, c_{m-1}\) and target \(V\). The instance is feasible when there are \(a_0, \dots, a_{k-1} \in \{0, \dots, m\}\), where \(a_j = b < m\) puts item \(j\) in knapsack \(b\) and \(a_j = m\) leaves item \(j\) out, such that for every \(b < m\) the total weight \(\sum_{j : a_j = b} w_j\) is at most \(c_b\), and the total value \(\sum_{j : a_j < m} v_j\) is at least \(V\).
def MultipleKnapsackFeasible
(i : MultipleKnapsackInstance) : Prop :=
∃ assign : List ℕ, assign.length = i.1.length ∧
(∀ j < i.1.length, assign.getD j 0 ≤ i.2.1.length) ∧
(∀ b < i.2.1.length,
(Finset.range i.1.length).sum (fun j =>
if assign.getD j 0 = b then (i.1.getD j (0, 0)).1 else 0) ≤
i.2.1.getD b 0) ∧
i.2.2 ≤ (Finset.range i.1.length).sum (fun j =>
if assign.getD j 0 < i.2.1.length then (i.1.getD j (0, 0)).2 else 0)
abbrev MultipleKnapsackInstance := List (ℕ × ℕ) × List ℕ × ℕ
WantedExt/Complexity/NPComplete/MultipleKnapsackWanted.lean:47
Uses 1 · Used by 1
DefinitionMULTIPLE KNAPSACK as a decision problem#✓fully proved
The decision problem MULTIPLE KNAPSACK accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a feasible multiple-knapsack instance. Bitstrings that do not decode are rejected.
noncomputable def multipleKnapsackDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := MultipleKnapsackInstance) x with
| some i => decide (MultipleKnapsackFeasible i)
| none => false
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
abbrev MultipleKnapsackInstance := List (ℕ × ℕ) × List ℕ × ℕ
WantedExt/Complexity/NPComplete/MultipleKnapsackWanted.lean:47
def MultipleKnapsackFeasible
(i : MultipleKnapsackInstance) : Prop :=
∃ assign : List ℕ, assign.length = i.1.length ∧
(∀ j < i.1.length, assign.getD j 0 ≤ i.2.1.length) ∧
(∀ b < i.2.1.length,
(Finset.range i.1.length).sum (fun j =>
if assign.getD j 0 = b then (i.1.getD j (0, 0)).1 else 0) ≤
i.2.1.getD b 0) ∧
i.2.2 ≤ (Finset.range i.1.length).sum (fun j =>
if assign.getD j 0 < i.2.1.length then (i.1.getD j (0, 0)).2 else 0)
WantedExt/Complexity/NPComplete/MultipleKnapsackWanted.lean:50
Uses 11 · Used by 1
TheoremMULTIPLE KNAPSACK is NP-complete#●ready to prove
The decision problem MULTIPLE KNAPSACK belongs to NP, and every decision problem in NP has a polynomial-time many-one reduction to MULTIPLE KNAPSACK.
public theorem_wanted multipleKnapsack_npComplete :
multipleKnapsackDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L multipleKnapsackDec
noncomputable def multipleKnapsackDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := MultipleKnapsackInstance) x with
| some i => decide (MultipleKnapsackFeasible i)
| none => false
WantedExt/Complexity/NPComplete/MultipleKnapsackWanted.lean:63
def NP : DecisionComplexityClass :=
{ L | ∃ (p : Polynomial ℕ), ∃ R : (List Bool × List Bool) → Bool,
IsPolyTime R ∧
∀ x, L x ↔ ∃ w : List Bool, w.length ≤ p.eval x.length ∧ R (x, w) }
MathlibExt/Computability/Complexity.lean:200
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def PolyManyOneRed (L₁ L₂ : MetaMathlibExt.ComplexityTheory.DecisionProblem) : Prop :=
∃ reduce : List Bool → List Bool,
MetaMathlibExt.ComplexityTheory.IsPolyTime reduce ∧ ∀ x, L₁ x = L₂ (reduce x)
CSLibExt/Computability/CookLevin.lean:396
Sources
- M. R. Garey and D. S. Johnson, Computers and Intractability (1979), MULTIPLE KNAPSACK.
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.