Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.rod-cutting

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

AHoF Rod Cutting (dynamic programming): given a rod of integer length and a price for each possible piece length, cut it into pieces maximizing total revenue. The DP for length n takes the maximum over first-cut lengths i of price(i) + best-revenue(n - i); comparing the running best against a new cut's revenue is: cell current-best cut-revenue = max(current-best, cut-revenue) where cut-revenue = price(i) + revenue(n - i), over exact-rational revenues. Proved native and axiom-free: the DP cell as the decidable rational max (if current-best <= cut-revenue then cut-revenue else current-best); a worked cell taking a more profitable cut; a worked cell keeping the current best; and the certificates that the chosen revenue dominates BOTH options (native nnrat/at-most). The price table and the length sweep are executable; what is proved is the revenue-maximizing cut choice. Requires audit/decide-nnrat-at-most, logic/if-data, nnrat/at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 4 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.rod-cutting` prints this classification.

rod-cutting/cell

DefinitionSource, line 63

rod-cutting/cell :
  (x₁ x₂ : ℚ≥0)
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

rod-cutting/takes-better-cut

TheoremWorked exampleNo axiomsSource, line 75

rod-cutting/takes-better-cut :
  → knapsack/cell 5 8 = 8

= = equality/Eq

rod-cutting/keeps-best-cut

TheoremWorked exampleNo axiomsSource, line 82

rod-cutting/keeps-best-cut :
  → knapsack/cell 7 3 = 7

= = equality/Eq

rod-cutting/dominates-cut

TheoremWorked exampleNo axiomsSource, line 89

rod-cutting/dominates-cut :
  → 8 ≤ 8

≤ = nnrat/at-most

rod-cutting/dominates-previous

TheoremWorked exampleNo axiomsSource, line 95

rod-cutting/dominates-previous :
  → 5 ≤ 8

≤ = nnrat/at-most