Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 6.4 — 2∑s≠skfk(s)+fk(sk)=Ck−1+∑i=1kd(si,si−1)2\sum_{s\ne s_k}f_k(s)+f_k(s_k)=C_{k-1}+\sum_{i=1}^k d(s_i,s_{i-1})2∑s=sk​​fk​(s)+fk​(sk​)=Ck−1​+∑i=1k​d(si​,si−1​)

Proved
MetricalTaskSystem.Deterministic.astar_potential_eq

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

competitive-analysismetrical-task-systemsonline-algorithmsp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let (S,d)(S,d)(S,d) be a task system with at least two states and let sks_ksk​, fkf_kfk​ and ckc_kck​ be the states, functions and budgets of the algorithm Ad∗A^*_dAd∗​ started at s0s_0s0​. Put

Fk=2∑s≠skfk(s)+fk(sk),Ck−1=∑i=0k−1ci.F_k=2\sum_{s\neq s_k}f_k(s)+f_k(s_k),\qquad C_{k-1}=\sum_{i=0}^{k-1}c_i .Fk​=2s=sk​∑​fk​(s)+fk​(sk​),Ck−1​=i=0∑k−1​ci​.

Then for every k≥0k\ge0k≥0

Fk=Ck−1+∑i=1kd(si,si−1).F_k=C_{k-1}+\sum_{i=1}^k d(s_i,s_{i-1}) .Fk​=Ck−1​+i=1∑k​d(si​,si−1​).

The identity relates the potential FkF_kFk​ to the on-line algorithm's cost, and is one of the three lemmas behind Theorem 6.1.

Formalization Note Ck−1C_{k-1}Ck−1​ is written as ∑i<kci\sum_{i<k}c_i∑i<k​ci​ to avoid natural-number subtraction; at k=0k=0k=0 both sides are 000.

Preamble
import Mathlib
import Definitions.Def_MetricalTaskSystem_Deterministic_Model
import Definitions.Def_MetricalTaskSystem_Deterministic_AstarD
Formal statement
namespace MetricalTaskSystem.Deterministic

/-- **Lemma 6.4** (Borodin–Linial–Saks 1992, p. 756). Let `F_k = 2 Σ_{x ≠ s_k} f_k(x) + f_k(s_k)`.
Then `F_k = C_{k−1} + Σ_{i=1}^k d(s_i, s_{i−1})`, where `C_{k−1} = Σ_{i=0}^{k−1} c_i`
(for `k = 0` both sides are `0`). -/
theorem astar_potential_eq {S : Type} [Fintype S] [DecidableEq S] [Nontrivial S]
    (d : S → S → ℝ) (hd : IsTaskSystem d) (s₀ : S) (s : ℕ → S) (hs : IsAstarSeq d s₀ s)
    (k : ℕ) :
    2 * ∑ x ∈ Finset.univ.erase (s k), fSeq d s k x + fSeq d s k (s k) =
      ∑ i ∈ Finset.range k, cSeq d s i + ∑ i ∈ Finset.range k, d (s (i + 1)) (s i) := by sorry

end MetricalTaskSystem.Deterministic
Source
Borodin, Linial, Saks, An Optimal On-Line Algorithm for Metrical Task System, J. ACM 39(4) (1992), p. 756, Lemma 6.4 (C_k defined on p. 756)
Read-back

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

Setting. Let SSS be a finite set with at least two elements, and let ddd be a task system:

  • d(i,i)=0d(i,i) = 0d(i,i)=0;
  • d(i,j)>0d(i,j) > 0d(i,j)>0 for i≠ji \ne ji=j;
  • d(i,k)≤d(i,j)+d(j,k)d(i,k) \le d(i,j) + d(j,k)d(i,k)≤d(i,j)+d(j,k).

Let s0∈Ss_0 \in Ss0​∈S and let s0,s1,…s_0, s_1, \dotss0​,s1​,… be a sequence of states.

The functions fkf_kfk​. Define f0≡0f_0 \equiv 0f0​≡0 and

fk+1(x)=fk(sk+1)+d(sk+1,sk)  if x=sk,fk+1(x)=fk(x)  otherwise.f_{k+1}(x) = f_k(s_{k+1}) + d(s_{k+1}, s_k) \ \text{ if } x = s_k, \qquad f_{k+1}(x) = f_k(x) \ \text{ otherwise}.fk+1​(x)=fk​(sk+1​)+d(sk+1​,sk​)  if x=sk​,fk+1​(x)=fk​(x)  otherwise.

Hypothesis. The sequence starts at s0s_0s0​, and for every kkk:

  • sk+1≠sks_{k+1} \ne s_ksk+1​=sk​;
  • sk+1s_{k+1}sk+1​ minimizes fk(x)+d(x,sk)f_k(x) + d(x, s_k)fk​(x)+d(x,sk​) over all x≠skx \ne s_kx=sk​.

Budgets. Let ci=fi+1(si)−fi(si)c_i = f_{i+1}(s_i) - f_i(s_i)ci​=fi+1​(si​)−fi​(si​).

Conclusion. For every k≥0k \ge 0k≥0,

2∑x≠skfk(x)+fk(sk)=∑i=0k−1ci+∑i=0k−1d(si+1,si).2 \sum_{x \ne s_k} f_k(x) + f_k(s_k) = \sum_{i=0}^{k-1} c_i + \sum_{i=0}^{k-1} d(s_{i+1}, s_i).2x=sk​∑​fk​(x)+fk​(sk​)=i=0∑k−1​ci​+i=0∑k−1​d(si+1​,si​).

Degenerate cases.

  • k=0k = 0k=0. Both sides are 000.
  • Excluded cases. One-element or empty SSS is excluded.
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