Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.bin-packing

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/bin_packing.clj1 definitions, 3 theorems

AHoF Bin Packing (First-Fit approximation): pack items of given sizes into the fewest unit-capacity bins. The First-Fit heuristic places each item into the first bin with enough remaining capacity, opening a new bin only if none fits; it is known to use at most about 1.7x the optimal number of bins (not proved here). An item fits a bin exactly when its size does not exceed the bin's remaining capacity: fits? item-size remaining = decide (item-size <= remaining) over exact-rational sizes. Proved native and axiom-free: the fit test; worked instances on concrete sizes -- an item of size 1/2 fits a bin with 3/4 remaining; the certificate 1/2 <= 3/4 as a native nnrat/at-most; and an item of size 3/4 does not fit a bin with 1/2 remaining (a new bin must open). The bin list and remaining-capacity bookkeeping are executable; what is proved is the first-fit placement decision at these instances. Requires nnrat/at-most, audit/decide-nnrat-at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.bin-packing` prints this classification.

bin-packing/fits?

DefinitionSource, line 60

bin-packing/fits? :
  (x₁ x₂ : ℚ≥0)
  → data/Bool

ℚ≥0 = nnrat/NonnegativeRational

bin-packing/item-fits

TheoremWorked exampleNo axiomsSource, line 71

bin-packing/item-fits :
  → bin-packing/fits? 1/2 3/4 = data/true

= = equality/Eq

bin-packing/placement-respects-capacity

TheoremWorked exampleNo axiomsSource, line 79

bin-packing/placement-respects-capacity :
  → 1/2 ≤ 3/4

≤ = nnrat/at-most

bin-packing/oversized-opens-new-bin

TheoremWorked exampleNo axiomsSource, line 85

bin-packing/oversized-opens-new-bin :
  → bin-packing/fits? 3/4 1/2 = data/false

= = equality/Eq