Unbounded knapsack problem
AbbreviationUnbounded knapsack instances#✓fully proved
An instance of the unbounded knapsack problem is a triple \((I, C, K)\) of a finite list \(I = ((s_1, v_1), \dots, (s_m, v_m))\) of items, where item \(j\) has weight \(s_j \in \mathbb{N}\) and value \(v_j \in \mathbb{N}\), a capacity \(C \in \mathbb{N}\) and a target value \(K \in \mathbb{N}\).
abbrev UnboundedKnapsackInstance := List (ℕ × ℕ) × ℕ × ℕ
Used by 2
DefinitionFeasible unbounded knapsack instances#✓fully proved
An unbounded knapsack instance with items \((s_1, v_1), \dots, (s_m, v_m)\), capacity \(C\) and target value \(K\) is feasible when there are multiplicities \(c_1, \dots, c_m \in \mathbb{N}\) with \(\sum_{j=1}^{m} c_j s_j \le C\) and \(\sum_{j=1}^{m} c_j v_j \ge K\).
def UnboundedKnapsackFeasible
(i : UnboundedKnapsackInstance) : Prop :=
∃ mult : List ℕ, mult.length = i.1.length ∧
(Finset.range i.1.length).sum
(fun j => mult.getD j 0 * (i.1.getD j (0, 0)).1) ≤ i.2.1 ∧
i.2.2 ≤ (Finset.range i.1.length).sum
(fun j => mult.getD j 0 * (i.1.getD j (0, 0)).2)
abbrev UnboundedKnapsackInstance := List (ℕ × ℕ) × ℕ × ℕ
WantedExt/Complexity/NPComplete/UnboundedKnapsackWanted.lean:45
Uses 1 · Used by 1
DefinitionUnbounded knapsack as a decision problem#✓fully proved
The unbounded knapsack problem is the decision problem that accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of unbounded knapsack instances, to a feasible instance. Bitstrings that fail to decode are rejected.
noncomputable def unboundedKnapsackDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := UnboundedKnapsackInstance) x with
| some i => decide (UnboundedKnapsackFeasible 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 UnboundedKnapsackInstance := List (ℕ × ℕ) × ℕ × ℕ
WantedExt/Complexity/NPComplete/UnboundedKnapsackWanted.lean:45
def UnboundedKnapsackFeasible
(i : UnboundedKnapsackInstance) : Prop :=
∃ mult : List ℕ, mult.length = i.1.length ∧
(Finset.range i.1.length).sum
(fun j => mult.getD j 0 * (i.1.getD j (0, 0)).1) ≤ i.2.1 ∧
i.2.2 ≤ (Finset.range i.1.length).sum
(fun j => mult.getD j 0 * (i.1.getD j (0, 0)).2)
WantedExt/Complexity/NPComplete/UnboundedKnapsackWanted.lean:48
Uses 11 · Used by 1
TheoremUNBOUNDED KNAPSACK is NP-complete#●ready to prove
The unbounded knapsack decision problem belongs to NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted unboundedKnapsack_npComplete :
unboundedKnapsackDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L unboundedKnapsackDec
noncomputable def unboundedKnapsackDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := UnboundedKnapsackInstance) x with
| some i => decide (UnboundedKnapsackFeasible i)
| none => false
WantedExt/Complexity/NPComplete/UnboundedKnapsackWanted.lean:58
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), UNBOUNDED KNAPSACK.
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.