Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

A stale request is a fault with probability c/sc/sc/s

Proved
CompetitivePaging.Marking.stale_fault_prob

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 request iii start a phase and let t≥it \ge it≥i be an index such that no request with index in (i,t](i, t](i,t] starts a phase, so that request ttt belongs to the phase starting at iii. Let mki\mathrm{mk}_imki​ be the marked set just before the phase (the vertices requested in the previous phase, or VVV for the first phase) and R(i,t)R(i,t)R(i,t) the set of vertices requested at indices i,…,t−1i, \dots, t-1i,…,t−1. Suppose σ(t)\sigma(t)σ(t) is stale: σ(t)∈mki\sigma(t) \in \mathrm{mk}_iσ(t)∈mki​ and σ(t)∉R(i,t)\sigma(t) \notin R(i,t)σ(t)∈/R(i,t). Put

c=∣R(i,t)∖mki∣,s=∣mki∖R(i,t)∣,c = |R(i,t) \setminus \mathrm{mk}_i|, \qquad s = |\mathrm{mk}_i \setminus R(i,t)|,c=∣R(i,t)∖mki​∣,s=∣mki​∖R(i,t)∣,

the number of clean vertices requested in the phase so far and the current number of stale vertices. Then the probability that σ(t)\sigma(t)σ(t) is not covered just before it is served is

Pr⁡[σ(t)∉cov]=cs.\Pr[\sigma(t) \notin \mathrm{cov}] = \frac{c}{s}.Pr[σ(t)∈/cov]=sc​.

This is the expected cost of a request to a stale vertex, the key probabilistic input to the bound on the marking algorithm's cost in a phase.

Formalization Note. The probability is taken under the law of the algorithm's state after the first ttt requests and is stated in [0,∞][0,\infty][0,∞]; s≥1s \ge 1s≥1 because σ(t)\sigma(t)σ(t) itself is stale.

Preamble
import Mathlib
import Definitions.Def_KServer_model
import Definitions.Def_CompetitivePaging_Marking_markingAlgorithm

open scoped ENNReal
Formal statement
namespace CompetitivePaging.Marking

/-- §3, proof of Theorem 1 (p. 4): a request to a stale vertex (requested in the previous
phase, not yet in this phase) is a fault with probability `c/s`, where `c` is the number of
clean vertices requested in the phase so far and `s` the current number of stale vertices. -/
theorem stale_fault_prob {n k : ℕ} {M : Type*} [DecidableEq M]
    (e : Fin n ≃ M) (hk : 1 ≤ k) (hkn : k ≤ n) (σ : List M) (i t : ℕ) (ht : t < σ.length)
    (hi : IsPhaseStart k (initVertices e hkn) σ i) (hit : i ≤ t)
    (hno : ∀ u, i < u → u ≤ t → ¬ IsPhaseStart k (initVertices e hkn) σ u)
    (hstale : σ.get ⟨t, ht⟩ ∈ marksAt k (initVertices e hkn) σ i)
    (hnew : σ.get ⟨t, ht⟩ ∉ phaseRequested σ i t) :
    faultProb k (initVertices e hkn) (σ.take t) (σ.get ⟨t, ht⟩) =
      ((phaseRequested σ i t \ marksAt k (initVertices e hkn) σ i).card : ℝ≥0∞)
        / ((marksAt k (initVertices e hkn) σ i \ phaseRequested σ i t).card : ℝ≥0∞) := by sorry

end CompetitivePaging.Marking
Source
Fiat, Karp, Luby, McGeoch, Sleator, Young, Competitive Paging Algorithms, arXiv:cs/0205038v1, p. 4, §3, proof of Theorem 1
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, and i≤t<mi\le t<mi≤t<m.
  • Mk(u)\mathrm{Mk}(u)Mk(u) is the deterministic marked set just before request uuu, starting from V0V_0V0​ under the rule "insert the request; if exactly k+1k+1k+1 points are marked, keep only the request".
  • R[i,t)={σi,…,σt−1}R[i,t)=\{\sigma_i,\dots,\sigma_{t-1}\}R[i,t)={σi​,…,σt−1​}.

Hypotheses.

  1. iii is a phase start: ∣Mk(i)∪{σi}∣=k+1|\mathrm{Mk}(i)\cup\{\sigma_i\}|=k+1∣Mk(i)∪{σi​}∣=k+1.
  2. No uuu with i<u≤ti<u\le ti<u≤t is a phase start. In particular, ttt is not one unless t=it=it=i.
  3. σt∈Mk(i)\sigma_t\in\mathrm{Mk}(i)σt​∈Mk(i), the marked set just before request iii.
  4. σt∉R[i,t)\sigma_t\notin R[i,t)σt​∈/R[i,t).

Claim. Let ppp be the probability that σt\sigma_tσt​ is uncovered after σ0,…,σt−1\sigma_0,\dots,\sigma_{t-1}σ0​,…,σt−1​ are served. The randomized marking process starts from (covered, marked) =(V0,V0)=(V_0,V_0)=(V0​,V0​); an uncovered request replaces a uniformly random covered, unmarked point after the mark update, or changes nothing if there is none. Then

p=∣R[i,t)∖Mk(i)∣∣Mk(i)∖R[i,t)∣,p=\frac{\big|R[i,t)\setminus \mathrm{Mk}(i)\big|}{\big|\mathrm{Mk}(i)\setminus R[i,t)\big|},p=​Mk(i)∖R[i,t)​​R[i,t)∖Mk(i)​​,

with the division taken in [0,∞][0,\infty][0,∞].

Degenerate cases.

  • Hypotheses 3 and 4 put σt\sigma_tσt​ in the denominator set, so the denominator is at least 111. The junk values x/0x/0x/0 in [0,∞][0,\infty][0,∞] never arise.
  • When t=it=it=i, R[i,t)R[i,t)R[i,t) is empty and the right side is 0/∣Mk(i)∣=00/|\mathrm{Mk}(i)|=00/∣Mk(i)∣=0. In that case, hypotheses 1 and 3 together require ∣Mk(i)∣=k+1|\mathrm{Mk}(i)|=k+1∣Mk(i)∣=k+1.
  • 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