Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 7.1 (upper bound) — an expected 2H(n)2H(n)2H(n)-competitive randomized algorithm for the uniform task system

Proved
MetricalTaskSystem.Randomized.uniform_expCompetitive_two_harmonic

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

competitive-analysisonline-algorithmsp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1randomized-algorithms

Let (S,d)(S,d)(S,d) be the uniform task system on nnn states (every transition costs 111) and let

H(n)=1+12+13+⋯+1n.H(n)=1+\frac12+\frac13+\cdots+\frac1n .H(n)=1+21​+31​+⋯+n1​.

There is a randomized on-line algorithm RRR and a constant KKK such that, for every initial state s0s_0s0​ and every finite sequence T\mathbf TT of nonnegative tasks,

cˉR(T)≤2H(n) c0(T)+K.\bar c_R(\mathbf T)\le 2H(n)\,c_0(\mathbf T)+K .cˉR​(T)≤2H(n)c0​(T)+K.

This is the upper half of Theorem 7.1: it shows wˉ(S,d)≤2H(n)\bar w(S,d)\le 2H(n)wˉ(S,d)≤2H(n), a logarithmic ratio, whereas every deterministic on-line algorithm has competitive ratio at least 2n−12n-12n−1.

Formalization Note The statement is the existence of an expected 2H(n)2H(n)2H(n)-competitive algorithm, not the inequality wˉ(S,d)≤2H(n)\bar w(S,d)\le 2H(n)wˉ(S,d)≤2H(n) alone, which would hold trivially if no algorithm were competitive (the real infimum of the empty set is 000). Tasks are finite and nonnegative.

Preamble
import Mathlib
import Definitions.Def_MetricalTaskSystem_Randomized_Model
import Definitions.Def_MetricalTaskSystem_Randomized_RandomizedAlgorithm
Formal statement
namespace MetricalTaskSystem.Randomized

/-- **Theorem 7.1, upper bound** (Borodin–Linial–Saks 1992, p. 759). On the uniform task system
with `n = |S|` states there is a randomized on-line algorithm that is expected
`2H(n)`-competitive, where `H(n) = 1 + 1/2 + ⋯ + 1/n`. -/
theorem uniform_expCompetitive_two_harmonic {S : Type} [Fintype S] [DecidableEq S]
    [Nonempty S] :
    ∃ R : RandomizedOnlineAlgorithm S,
      IsExpCompetitive (uniformD (S := S)) R (2 * (harmonic (Fintype.card S) : ℝ)) := by sorry

end MetricalTaskSystem.Randomized
Source
Borodin, Linial, Saks, An Optimal On-Line Algorithm for Metrical Task System, J. ACM 39(4) (1992), p. 759, Theorem 7.1 and Proof of the Upper Bound
Read-back

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

Let SSS be a finite, nonempty type with decidable equality and n=∣S∣≥1n = |S| \ge 1n=∣S∣≥1. Let H(n)=1+12+⋯+1nH(n) = 1 + \tfrac12 + \dots + \tfrac1nH(n)=1+21​+⋯+n1​.

The statement asserts that there exists a randomized on-line algorithm RRR that is expected 2H(n)2H(n)2H(n)-competitive for the uniform cost dunif(i,j)=[ i≠j ]d_{\mathrm{unif}}(i,j) = [\,i \ne j\,]dunif​(i,j)=[i=j]. Here RRR maps an initial state, the tasks seen so far and the states visited so far to a probability distribution on SSS.

Unfolded, this means 2H(n)>02H(n) > 02H(n)>0, and there exist RRR and a real constant KKK such that, for every initial state s0∈Ss_0 \in Ss0​∈S, every m∈Nm \in \mathbb{N}m∈N and every task sequence T1,…,Tm:S→[0,∞)T_1,\dots,T_m : S \to [0,\infty)T1​,…,Tm​:S→[0,∞):

∑σ∈Sm+1Pr⁡R(σ∣T) c(T;σ)  ≤  2H(n)⋅min⁡σ0=s0c(T;σ)+K.\sum_{\sigma \in S^{m+1}} \Pr_R(\sigma\mid T)\, c(T;\sigma) \;\le\; 2H(n)\cdot \min_{\sigma_0 = s_0} c(T;\sigma) + K.σ∈Sm+1∑​RPr​(σ∣T)c(T;σ)≤2H(n)⋅σ0​=s0​min​c(T;σ)+K.

In this inequality:

  • c(T;σ)=∑i=1m([σi−1≠σi]+Ti(σi))c(T;\sigma) = \sum_{i=1}^m \big([\sigma_{i-1}\neq\sigma_i] + T_i(\sigma_i)\big)c(T;σ)=∑i=1m​([σi−1​=σi​]+Ti​(σi​));
  • Pr⁡R(σ∣T)\Pr_R(\sigma \mid T)PrR​(σ∣T) is 000 unless σ0=s0\sigma_0 = s_0σ0​=s0​, and otherwise is the product over i=1,…,mi = 1,\dots,mi=1,…,m of the probability that RRR, given s0s_0s0​, (T1,…,Ti)(T_1,\dots,T_i)(T1​,…,Ti​) and (σ0,…,σi−1)(\sigma_0,\dots,\sigma_{i-1})(σ0​,…,σi−1​), picks σi\sigma_iσi​.

Degenerate cases.

  • 2H(n)>02H(n) > 02H(n)>0: this is automatic, because n≥1n \ge 1n≥1 gives 2H(n)≥22H(n) \ge 22H(n)≥2.
  • m=0m = 0m=0: both sides reduce to 0≤K0 \le K0≤K.
  • n=1n = 1n=1: every schedule is constant. The expected cost and the off-line minimum both equal ∑iTi(s)\sum_i T_i(s)∑i​Ti​(s), which is ≥0\ge 0≥0. The claim then holds with any RRR and K=0K = 0K=0.
  • Algorithm and constant: no restriction is placed on how RRR is constructed; it need only exist. The constant KKK is not specified.
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