Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Knapsack Method, Steps (2) and (7), pp. 867–868 — the greedy completion is the lexicographically largest feasible extension

Proved
CuttingStock63.Knapsack.greedy_lex_largest

by mikedeng1 · Oct 6, 2026 · Mathlib 0df444a (Lean v4.33.1)

greedyknapsacklexicographic-orderp2o-batch-pfp2ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let l1,…,lm>0l_1,\dots,l_m>0l1​,…,lm​>0, let LLL be a capacity, and let (α)s(\alpha)_s(α)s​ be a prefix (0≤s≤m0\le s\le m0≤s≤m) with λ⋅(α)s≤L\lambda\cdot(\alpha)_s\le Lλ⋅(α)s​≤L. Let (γ)m(\gamma)_m(γ)m​ be the greedy completion of Steps (2) and (7): γi=ai\gamma_i=a_iγi​=ai​ for i≤si\le si≤s and

γi=[L−(λ⋅(α)s+ls+1γs+1+⋯+li−1γi−1)li],i=s+1,…,m.\gamma_i=\Big[\frac{L-(\lambda\cdot(\alpha)_s+l_{s+1}\gamma_{s+1}+\dots+l_{i-1}\gamma_{i-1})}{l_i}\Big],\qquad i=s+1,\dots,m.γi​=[li​L−(λ⋅(α)s​+ls+1​γs+1​+⋯+li−1​γi−1​)​],i=s+1,…,m.

Then (γ)m(\gamma)_m(γ)m​ is an extension of (α)s(\alpha)_s(α)s​, it satisfies L≥λ⋅(γ)mL\ge\lambda\cdot(\gamma)_mL≥λ⋅(γ)m​, and every extension (α′)m(\alpha')_m(α′)m​ of (α)s(\alpha)_s(α)s​ with L≥λ⋅(α′)mL\ge\lambda\cdot(\alpha')_mL≥λ⋅(α′)m​ is lexicographically at most (γ)m(\gamma)_m(γ)m​.

With s=0s=0s=0 this is the first claim of Step (2): the first vector of the method is the lexicographically largest mmm-vector satisfying L1≥λ⋅(α)mL_1\ge\lambda\cdot(\alpha)_mL1​≥λ⋅(α)m​. With s≥1s\ge1s≥1 it is the claim behind Step (7).

Formalization Note The page writes "which satisfies Lt≥λ⋅(α)sL_t\ge\lambda\cdot(\alpha)_sLt​≥λ⋅(α)s​" in Step (7); the prefix already satisfies that, and the intended condition is on the extension, Lt≥λ⋅(α)mL_t\ge\lambda\cdot(\alpha)_mLt​≥λ⋅(α)m​, which is what is stated. The lexicographic order is Mathlib's Pi.Lex (toLex). Positive lengths are the paper's standing setting (demanded lengths).

Preamble
import Mathlib
import Definitions.Def_CuttingStock63_Knapsack_Problem
import Definitions.Def_CuttingStock63_Knapsack_Method
Formal statement
namespace CuttingStock63.Knapsack

/-- Steps (2) and (7), pp. 867–868: if the prefix (α)_s satisfies cap ≥ λ·(α)_s, the greedy
completion of Steps (2)/(7) is the lexicographically largest extension (α)_m of (α)_s that
satisfies cap ≥ λ·(α)_m. With `s = 0` this is Step (2)'s "lexicographically largest m-vector". -/
theorem greedy_lex_largest {m : ℕ} (l : Fin m → ℝ) (hl : ∀ i, 0 < l i) (cap : ℝ)
    (a : Fin m → ℕ) (s : ℕ) (hs : s ≤ m) (hfit : lam l a s ≤ cap) :
    IsExtension a (greedyFill l cap a s) s ∧ Fits l cap (greedyFill l cap a s) ∧
      ∀ a' : Fin m → ℕ, IsExtension a a' s → Fits l cap a' →
        toLex a' ≤ toLex (greedyFill l cap a s) := by sorry

end CuttingStock63.Knapsack
Source
Gilmore & Gomory, A linear programming approach to the cutting stock problem—Part II, Opns. Res. 11 (1963), pp. 867–868, Knapsack Method, Step (2) and the paragraph before Step (5) (Step (7))
Human review
  • Endorsed by Shuze Chen · Oct 6, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 6, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me