Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Fractional primal-dual ski rental: exact finite-BBB competitive ratio

Proved
PrimalDualOnline.SkiRental.fractional_competitive

by moutei · Sep 16, 2026 · Mathlib 0df444a (Lean v4.33.1)

competitive-analysislinear-programmingonline-algorithmsprimal-dualski-rental

Let B≥1B \ge 1B≥1 be the purchase price of a ski-rental instance and let k≥0k \ge 0k≥0 be the number of ski days, unknown to the algorithm. Run the fractional primal-dual algorithm with the rate

c∗(B)  =  (1+1B)B−1,c^{*}(B) \;=\; \left(1 + \frac{1}{B}\right)^{B} - 1 ,c∗(B)=(1+B1​)B−1,

and let xjx_jxj​ be its buy variable after jjj updates, zjz_jzj​ the rent variable of source day j+1j+1j+1, and ALG(B,k)=Bxk+∑j<kzj\mathrm{ALG}(B,k) = B x_k + \sum_{j<k} z_jALG(B,k)=Bxk​+∑j<k​zj​ the primal objective of the solution after kkk days. Then three things hold simultaneously.

1. The buy trajectory is nondecreasing. a≤b  ⟹  xa≤xba \le b \implies x_a \le x_ba≤b⟹xa​≤xb​ for all indices. This is the online requirement of the model: a fractional primal variable may never be decreased once raised.

2. The final solution is feasible for the canonical fractional primal program:

0≤xk≤1,0≤zj≤1,xk+zj≥1(0≤j<k).0 \le x_k \le 1, \qquad 0 \le z_j \le 1, \qquad x_k + z_j \ge 1 \qquad (0 \le j < k).0≤xk​≤1,0≤zj​≤1,xk​+zj​≥1(0≤j<k).

3. Its cost is bounded against the offline optimum min⁡(B,k)\min(B,k)min(B,k):

ALG(B,k)  ≤  (1+1(1+1B)B−1)⋅min⁡(B,k).\mathrm{ALG}(B,k) \;\le\; \left(1 + \frac{1}{\left(1 + \frac{1}{B}\right)^{B} - 1}\right) \cdot \min(B, k) .ALG(B,k)≤(1+(1+B1​)B−11​)⋅min(B,k).

All three are needed for the statement to mean what "online competitive algorithm" means. Component 3 alone bounds a number without certifying that the number is the cost of anything that solves the problem; component 2 supplies that. Component 2 alone would be satisfied by procedures the model forbids; component 1 rules out a procedure that lowers a commitment it has already made. With all three, the conclusion is a genuine competitive guarantee, and the coefficient depends only on the purchase price, not on kkk, so the bound is uniform over all request sequences.

The coefficient is left in exact closed form. Because (1+1/B)B\left(1 + 1/B\right)^{B}(1+1/B)B increases to eee, one has c∗(B)<e−1c^{*}(B) < e - 1c∗(B)<e−1 and the coefficient is strictly greater than e/(e−1)e/(e-1)e/(e−1) at every finite BBB; it converges to e/(e−1)e/(e-1)e/(e−1) only as B→∞B \to \inftyB→∞, which is a separate statement. A goal asserting e/(e−1)e/(e-1)e/(e−1)-competitiveness at finite BBB would be false.

Source correspondence.

  • What the thesis states (p. 18): "Using weak duality theorem (Theorem 2.1) we immediately conclude that the algorithm is (1+1/c)(1 + 1/c)(1+1/c)-competitive", with claim (i) asserting feasibility of the primal and dual solutions and the model requiring that primal variables not decrease.
  • What this Lean theorem states: the conjunction of monotonicity, box feasibility of the final solution, and the cost bound with the coefficient in closed form.
  • Introduced by the formalization: collecting the three into one conclusion is the formalization's choice — the source states competitiveness as the headline and feasibility as a separate claim (i), and treats non-decrease as a property of the model rather than a theorem. The exact closed-form coefficient in place of the source's informal "≈e/(e−1)\approx e/(e-1)≈e/(e−1) for B≫1B \gg 1B≫1" is also the formalization's.

Out of scope. This is not the randomized e/(e−1)e/(e-1)e/(e−1)-competitive algorithm. Randomized threshold rounding of this fractional solution is the subject of the planned follow-up mission, Primal-Dual Online Algorithms II: Randomized Rounding for Ski Rental, and nothing here asserts anything about a distribution, an expectation, or an integral solution.

Formalization Note. The covering constraints use the final buy level xkx_kxk​, not the value current on day jjj; for a monotone online trajectory the solution required to be feasible is the one the algorithm ends with, and an early day's constraint is satisfied a fortiori. The benchmark min⁡(B,k)\min(B,k)min(B,k) is defined independently of the algorithm, and a separate statement certifies it is the least attained objective value of the canonical program. Component 1 does not mention kkk; for each kkk the theorem restates the same kkk-independent claim.

Preamble
import Definitions.Def_PrimalDualOnline_SkiRentalLP
import Definitions.Def_PrimalDualOnline_SkiRentalAlg
import Mathlib.Tactic

open PrimalDualOnline.SkiRental
Formal statement
theorem PrimalDualOnline.SkiRental.fractional_competitive
    (B : ℕ) (hB : 0 < B) (k : ℕ) :
    Monotone (algX B (cOpt B)) ∧
      PrimalFeasibleBox k (algX B (cOpt B) k) (fun j : Fin k => algZ B (cOpt B) (j : ℕ)) ∧
      algCost B (cOpt B) k ≤ (1 + 1 / cOpt B) * offlineOpt (B : ℝ) k := by sorry
Source
Niv Buchbinder, "Designing Competitive Online Algorithms via a Primal-Dual Approach", PhD thesis, Tel Aviv University, 2008, https://www.tau.ac.il/~nivb/download/phd-thsis.pdf, Chapter 3, p. 18 (PDF p. 34): the conclusion of the analysis ("Using weak duality theorem (Theorem 2.1) we immediately conclude that the algorithm is (1 + 1/c)-competitive"), with c fixed as on p. 19.
Read-back

What the Lean code literally says, in plain math · claude-opus-5

Setup and notation

The declaration takes two natural-number arguments, BBB and kkk, and one hypothesis 0<B0 < B0<B. There is no hypothesis relating kkk and BBB: kkk is an arbitrary natural number, including 000 and values far exceeding BBB. Throughout, BBB is silently coerced to a real number wherever it appears in arithmetic.

Fix the constant c:=c∗(B)=(1+1B)B−1c := c^{*}(B) = \bigl(1 + \tfrac{1}{B}\bigr)^{B} - 1c:=c∗(B)=(1+B1​)B−1. The theorem instantiates every occurrence of the algorithm's free parameter at this single value; nothing is asserted for any other parameter value.

Define the real sequence (xj)j∈N(x_j)_{j \in \mathbb{N}}(xj​)j∈N​ by

x0=0,xj+1  =  {xj(1+1B)+1c B,if xj<1(strict),xj,if xj≥1.x_0 = 0, \qquad x_{j+1} \;=\; \begin{cases} x_j\bigl(1 + \tfrac{1}{B}\bigr) + \dfrac{1}{c\,B}, & \text{if } x_j < 1 \quad (\textbf{strict}),\\[2mm] x_j, & \text{if } x_j \ge 1 .\end{cases}x0​=0,xj+1​=⎩⎨⎧​xj​(1+B1​)+cB1​,xj​,​if xj​<1(strict),if xj​≥1.​

The "else" branch freezes the value at whatever xjx_jxj​ happens to be; it does not clip it to 111. Define the companion sequence zj=1−xjz_j = 1 - x_jzj​=1−xj​ if xj<1x_j < 1xj​<1, and zj=0z_j = 0zj​=0 if xj≥1x_j \ge 1xj​≥1; in particular z0=1z_0 = 1z0​=1 always. Two further definitions are used verbatim: primalCostB(x,z)=Bx+∑j<kzj\mathrm{primalCost}_B(x, z) = B x + \sum_{j<k} z_jprimalCostB​(x,z)=Bx+∑j<k​zj​, and offlineOpt(B,k)=min⁡{B,k}\mathrm{offlineOpt}(B,k) = \min\{B, k\}offlineOpt(B,k)=min{B,k} — a definition, not characterized as any optimum. So the algorithm's cost is literally ALG(k)=Bxk+∑j=0k−1zj\mathrm{ALG}(k) = B x_k + \sum_{j=0}^{k-1} z_jALG(k)=Bxk​+∑j=0k−1​zj​: the final value xkx_kxk​ multiplied by BBB, plus the zzz-values at indices 0,…,k−10,\dots,k-10,…,k−1.

The conclusion is a conjunction of exactly three claims, all under the single hypothesis 0<B0 < B0<B.

Component 1 — Monotonicity of the xxx-sequence

Asserts, with N\mathbb{N}N and R\mathbb{R}R carrying their usual orders:

∀ a,b∈N,a≤b  ⟹  xa≤xb.\forall\, a, b \in \mathbb{N}, \quad a \le b \;\Longrightarrow\; x_a \le x_b .∀a,b∈N,a≤b⟹xa​≤xb​.

This is a non-strict inequality (equality is permitted, and the frozen branch produces equalities). This component quantifies over all pairs of natural indices — the whole infinite sequence — and does not mention kkk at all; for each kkk the theorem simply restates the same kkk-independent claim.

Component 2 — Box feasibility at index kkk

Unfolds to the conjunction of three parts:

  1. 0≤xk0 \le x_k0≤xk​ and xk≤1x_k \le 1xk​≤1 — the single final iterate lies in the closed unit interval (both non-strict; note this is the same xkx_kxk​ whose defining recursion only guards on xj<1x_j < 1xj​<1).
  2. For every index jjj with 0≤j≤k−10 \le j \le k-10≤j≤k−1: 0≤zj0 \le z_j0≤zj​ and zj≤1z_j \le 1zj​≤1.
  3. For every index jjj with 0≤j≤k−10 \le j \le k-10≤j≤k−1: 1≤xk+zj1 \le x_k + z_j1≤xk​+zj​.

Part 3 pairs zjz_jzj​ with xkx_kxk​, the last iterate, and not with the contemporaneous xjx_jxj​. All three parts are stated with non-strict inequalities. This component depends on kkk, both in the value xkx_kxk​ and in the range of the quantifiers.

Component 3 — The cost inequality

B xk  +  ∑j=0k−1zj    ≤    (1+1(1+1B)B−1)min⁡{B, k}  =  (1+1B)B(1+1B)B−1  min⁡{B, k}.B\,x_k \;+\; \sum_{j=0}^{k-1} z_j \;\;\le\;\; \left(1 + \frac{1}{\bigl(1+\tfrac1B\bigr)^{B} - 1}\right)\min\{B,\,k\} \;=\; \frac{\bigl(1+\tfrac1B\bigr)^{B}}{\bigl(1+\tfrac1B\bigr)^{B} - 1}\;\min\{B,\,k\}.Bxk​+j=0∑k−1​zj​≤(1+(1+B1​)B−11​)min{B,k}=(1+B1​)B−1(1+B1​)B​min{B,k}.

The multiplicative factor depends only on BBB and not on kkk. The inequality is non-strict, oriented with the algorithm's cost on the left.

kkk-dependence summary

Component 1 is independent of kkk (a statement about the entire sequence over N\mathbb{N}N). Components 2 and 3 depend on kkk. The competitive factor itself is independent of kkk and depends on BBB only.

Degenerate and edge cases

  • k=0k = 0k=0. Both universally quantified parts of Component 2 are vacuous; Component 2 reduces to 0≤x0≤10 \le x_0 \le 10≤x0​≤1 with x0=0x_0 = 0x0​=0. The sum in ALG(0)\mathrm{ALG}(0)ALG(0) is empty, so Component 3 reads 0≤(1+1/c∗(B))⋅min⁡{B,0}0 \le \bigl(1 + 1/c^{*}(B)\bigr)\cdot\min\{B,0\}0≤(1+1/c∗(B))⋅min{B,0}, and since B≥1B \ge 1B≥1 the right side is 000; the assertion at k=0k=0k=0 is 0≤00 \le 00≤0.
  • k=Bk = Bk=B. min⁡{B,k}=B\min\{B,k\} = Bmin{B,k}=B, so the bound becomes B(1+1/c∗(B))B\bigl(1 + 1/c^{*}(B)\bigr)B(1+1/c∗(B)); the left side is BxB+∑j<BzjB x_B + \sum_{j<B} z_jBxB​+∑j<B​zj​.
  • k≫Bk \gg Bk≫B. min⁡{B,k}=B\min\{B,k\} = Bmin{B,k}=B, so the right-hand side is constant in kkk, while the left-hand sum formally ranges over kkk terms (each term with xj≥1x_j \ge 1xj​≥1 being 000). No hypothesis excludes this regime.
  • B=1B = 1B=1. c∗(1)=1c^{*}(1) = 1c∗(1)=1, the factor is exactly 222, the bound is 2min⁡{1,k}2\min\{1,k\}2min{1,k}, and the recursion gives x1=1x_1 = 1x1​=1 so the guard fails from index 111 onward.
  • B=0B = 0B=0 is excluded by the hypothesis; consequently the reciprocals 1/B1/B1/B, 1/(cB)1/(cB)1/(cB) are ordinary divisions rather than the 1/0=01/0 = 01/0=0 junk value. For B≥1B \ge 1B≥1, (1+1B)B≥2\bigl(1+\tfrac1B\bigr)^{B} \ge 2(1+B1​)B≥2, so c∗(B)≥1c^{*}(B) \ge 1c∗(B)≥1.
  • Strictness of the guard. Every branch tests xj<1x_j < 1xj​<1 strictly; at exactly xj=1x_j = 1xj​=1 the "else" branches apply.
  • Index coercion. The zzz-indices are 0,…,k−10,\dots,k-10,…,k−1; index kkk never appears among the zzz-terms, while the xxx-value used in Components 2 and 3 is exactly xkx_kxk​.

What is not asserted

  • No optimality or lower bound. Nothing says the factor is best possible, and no lower bound is proved against any algorithm, class of algorithms, or adversary.
  • No duality content. No dual variables, no dual feasibility, no weak- or strong-duality statement, and no claim that min⁡{B,k}\min\{B,k\}min{B,k} is the optimum of any linear program — offlineOpt\mathrm{offlineOpt}offlineOpt is only the definition min⁡{B,k}\min\{B,k\}min{B,k}.
  • No online information-constraint formalization. There is no formal model of an adversary or an input sequence, and no restriction stated that decisions at index jjj depend only on the prefix; the "algorithm" is only the explicit recursion above.
  • No claim about the sequence beyond the stated bounds: not that xB=1x_B = 1xB​=1, not that xjx_jxj​ reaches 111 at any particular index, not that xj<1x_j < 1xj​<1 for j<Bj < Bj<B, not that zj=0z_j = 0zj​=0 for j≥Bj \ge Bj≥B, and no closed form.
  • No per-time feasibility. Feasibility is asserted only for the pair (xk,zj)(x_k, z_j)(xk​,zj​); no claim is made about xj+zj≥1x_j + z_j \ge 1xj​+zj​≥1 at intermediate times.
  • No integrality or randomization. Only box-relaxed quantities appear; no integral solution, no rounding, no distribution, no expected-cost claim.
  • No asymptotics. Nothing about c∗(B)→e−1c^{*}(B) \to e - 1c∗(B)→e−1 or 1+1/c∗(B)→e/(e−1)1 + 1/c^{*}(B) \to e/(e-1)1+1/c∗(B)→e/(e−1), nothing about monotonicity of the factor in BBB, not even the positivity c∗(B)>0c^{*}(B) > 0c∗(B)>0.
  • No statement for B=0B = 0B=0, and no claim for parameter values other than c=c∗(B)c = c^{*}(B)c=c∗(B).
  • No tightness, uniqueness, or minimality of the cost, and no claim that ALG(k)\mathrm{ALG}(k)ALG(k) is the minimum of primalCost\mathrm{primalCost}primalCost over feasible points.
Human review
  • Endorsed by Shuze Chen · Sep 16, 2026

  • Endorsed by moutei · Sep 16, 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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me