Bin packing
AbbreviationBin packing instances#✓fully proved
An instance of BIN PACKING is a triple \((s, B, K)\) of a finite list \(s\) of natural numbers (the item sizes), a natural number \(B\) (the bin capacity) and a natural number \(K\) (the number of bins).
abbrev BinPackingInstance := List ℕ × ℕ × ℕ
Used by 2
DefinitionFeasible bin packing instances#✓fully proved
An instance \((s, B, K)\) of BIN PACKING is feasible when there is a list of exactly \(K\) bins, each a finite list of natural numbers with sum at most \(B\), such that the concatenation of the bins is a permutation of \(s\).
Since bins may be empty, this says that the items fit into at most \(K\) bins of capacity \(B\).
def BinPackingFeasible
(i : BinPackingInstance) : Prop :=
∃ bins : List (List ℕ), bins.length = i.2.2 ∧ bins.flatten.Perm i.1 ∧
∀ bin ∈ bins, bin.sum ≤ i.2.1
abbrev BinPackingInstance := List ℕ × ℕ × ℕ
WantedExt/Complexity/NPComplete/BinPackingWanted.lean:46
Uses 1 · Used by 1
DefinitionThe bin packing decision problem#✓fully proved
BIN PACKING is the decision problem that accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of bin packing instances, to a feasible instance; it rejects every bitstring that fails to decode.
noncomputable def binPackingDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := BinPackingInstance) x with
| some i => decide (BinPackingFeasible 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 BinPackingInstance := List ℕ × ℕ × ℕ
WantedExt/Complexity/NPComplete/BinPackingWanted.lean:46
def BinPackingFeasible
(i : BinPackingInstance) : Prop :=
∃ bins : List (List ℕ), bins.length = i.2.2 ∧ bins.flatten.Perm i.1 ∧
∀ bin ∈ bins, bin.sum ≤ i.2.1
WantedExt/Complexity/NPComplete/BinPackingWanted.lean:49
Uses 11 · Used by 1
TheoremBIN PACKING is NP-complete#●ready to prove
The bin packing decision problem belongs to NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted binPacking_npComplete :
binPackingDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L binPackingDec
noncomputable def binPackingDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := BinPackingInstance) x with
| some i => decide (BinPackingFeasible i)
| none => false
WantedExt/Complexity/NPComplete/BinPackingWanted.lean:56
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), BIN PACKING; D. S. Johnson, "Fast algorithms for bin packing" (1974).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.