Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The marking algorithm's expected cost in a phase is at most l(Hk−Hl+1)≤lHkl(H_k - H_l + 1) \le l H_kl(Hk​−Hl​+1)≤lHk​

Proved
CompetitivePaging.Marking.phase_expected_cost_le

by mikedeng1 · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

online-algorithmsp2o-batch-p100bp2o-gran-per-chapterp2o-plan-paperp2o-v1pagingrandomized-algorithms

Let MMM be a set of nnn vertices enumerated as e(0),…,e(n−1)e(0), \dots, e(n-1)e(0),…,e(n−1), let 1≤k≤n1 \le k \le n1≤k≤n, and run the marking algorithm with kkk servers from V={e(0),…,e(k−1)}V = \{e(0), \dots, e(k-1)\}V={e(0),…,e(k−1)} on a request sequence σ\sigmaσ. Let requests i,…,i′−1i, \dots, i'-1i,…,i′−1 form a complete phase, let l=∣R(i,i′)∖mki∣l = |R(i,i') \setminus \mathrm{mk}_i|l=∣R(i,i′)∖mki​∣ be the number of requests to clean vertices in the phase, and let CM(i,i′)C_M(i,i')CM​(i,i′) be the expected cost of the marking algorithm on the requests of the phase (the sum of their fault probabilities). With Hm=1+12+⋯+1mH_m = 1 + \frac12 + \dots + \frac1mHm​=1+21​+⋯+m1​ the mmm-th harmonic number,

CM(i,i′)≤l (Hk−Hl+1)≤l Hk.C_M(i,i') \le l\,(H_k - H_l + 1) \le l\,H_k.CM​(i,i′)≤l(Hk​−Hl​+1)≤lHk​.

Together with the adversary's amortized cost of at least l/2l/2l/2 per phase, this gives the competitive factor 2Hk2H_k2Hk​ of Theorem 1.

Preamble
import Mathlib
import Definitions.Def_KServer_model
import Definitions.Def_CompetitivePaging_Marking_markingAlgorithm
Formal statement
namespace CompetitivePaging.Marking

/-- §3, proof of Theorem 1 (pp. 4–5): in a complete phase with `l` requests to clean vertices,
the expected cost of the marking algorithm is at most `l (H_k - H_l + 1) ≤ l H_k`. -/
theorem phase_expected_cost_le {n k : ℕ} {M : Type*} [DecidableEq M]
    (e : Fin n ≃ M) (hk : 1 ≤ k) (hkn : k ≤ n) (σ : List M) (i i' : ℕ)
    (hphase : IsCompletePhase k (initVertices e hkn) σ i i') :
    markingPhaseCost k (initVertices e hkn) σ i i'
        ≤ ((phaseRequested σ i i' \ marksAt k (initVertices e hkn) σ i).card : ℝ)
          * ((harmonic k : ℝ)
            - (harmonic (phaseRequested σ i i' \ marksAt k (initVertices e hkn) σ i).card : ℝ)
            + 1) ∧
      ((phaseRequested σ i i' \ marksAt k (initVertices e hkn) σ i).card : ℝ)
          * ((harmonic k : ℝ)
            - (harmonic (phaseRequested σ i i' \ marksAt k (initVertices e hkn) σ i).card : ℝ)
            + 1)
        ≤ ((phaseRequested σ i i' \ marksAt k (initVertices e hkn) σ i).card : ℝ)
          * (harmonic k : ℝ) := by sorry

end CompetitivePaging.Marking
Source
Fiat, Karp, Luby, McGeoch, Sleator, Young, Competitive Paging Algorithms, arXiv:cs/0205038v1, p. 5, §3, proof of Theorem 1 (displayed bound)
Read-back

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

Setting.

  • e:{0,…,n−1}→Me:\{0,\dots,n-1\}\to Me:{0,…,n−1}→M is a bijection onto a type MMM with decidable equality, and 1≤k≤n1\le k\le n1≤k≤n.
  • V0={e(0),…,e(k−1)}V_0=\{e(0),\dots,e(k-1)\}V0​={e(0),…,e(k−1)}.
  • σ=(σ0,…,σm−1)\sigma=(\sigma_0,\dots,\sigma_{m-1})σ=(σ0​,…,σm−1​) is a request sequence.
  • (i,i′)(i,i')(i,i′) is a complete phase: i<i′i<i'i<i′ are both phase starts, so i′<mi'<mi′<m, with none strictly between. Here Mk(u)\mathrm{Mk}(u)Mk(u) is the deterministic marked set just before request uuu (started at V0V_0V0​, rule "insert the request; if exactly k+1k+1k+1 marked, keep only the request"), and u<mu<mu<m is a phase start iff ∣Mk(u)∪{σu}∣=k+1|\mathrm{Mk}(u)\cup\{\sigma_u\}|=k+1∣Mk(u)∪{σu​}∣=k+1.

Quantities.

  • ℓ=∣{σi,…,σi′−1}∖Mk(i)∣\ell=|\{\sigma_i,\dots,\sigma_{i'-1}\}\setminus\mathrm{Mk}(i)|ℓ=∣{σi​,…,σi′−1​}∖Mk(i)∣.
  • Hj=∑r=1j1/rH_j=\sum_{r=1}^{j}1/rHj​=∑r=1j​1/r, with H0=0H_0=0H0​=0.
  • PCost\mathrm{PCost}PCost is the sum, over i≤t<i′i\le t<i'i≤t<i′, of the probability that σt\sigma_tσt​ is uncovered just before it is served. The randomized marking process starts from (covered, marked) =(V0,V0)=(V_0,V_0)=(V0​,V0​) at the beginning of σ\sigmaσ, not at index iii.

Claim.

PCost≤ℓ (Hk−Hℓ+1)andℓ (Hk−Hℓ+1)≤ℓ Hk.\mathrm{PCost}\le \ell\,(H_k-H_\ell+1)\qquad\text{and}\qquad \ell\,(H_k-H_\ell+1)\le \ell\,H_k.PCost≤ℓ(Hk​−Hℓ​+1)andℓ(Hk​−Hℓ​+1)≤ℓHk​.

The second inequality is equivalent to ℓ(1−Hℓ)≤0\ell(1-H_\ell)\le0ℓ(1−Hℓ​)≤0, which holds for every natural number ℓ\ellℓ.

Degenerate cases.

  • If ℓ=0\ell=0ℓ=0, both bounds are 000, so the claim says PCost=0\mathrm{PCost}=0PCost=0 (it is a sum of nonnegative terms).
  • ℓ\ellℓ is not required to be at most kkk, so Hk−HℓH_k-H_\ellHk​−Hℓ​ may be negative.
  • When k=nk=nk=n, no phase start exists and the statement is vacuous.
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 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