Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Equation (5.1) — the expected average online loss equals the expected average risk of the iterates

Proved
OnlineLearningOCO.OnlineToBatch.eq_5_1

by mikedeng1 · Oct 7, 2026 · Mathlib 0df444a (Lean v4.33.1)

online-learningonline-to-batchp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1stochastic-learning

Let T≥1T\ge1T≥1, let ψ0,…,ψT−1\psi_0,\dots,\psi_{T-1}ψ0​,…,ψT−1​ be independent examples, each with law QQQ, let ccc be an admissible cost on S×ΨS\times\PsiS×Ψ with risk CCC, and let w0,…,wT−1w_0,\dots,w_{T-1}w0​,…,wT−1​ be the predictions of an online learner run on the losses ft(w)=c(w,ψt)f_t(w)=c(w,\psi_t)ft​(w)=c(w,ψt​), where wtw_twt​ depends only on ψ0,…,ψt−1\psi_0,\dots,\psi_{t-1}ψ0​,…,ψt−1​. Then

E[1T∑tC(wt)]=E[1T∑tc(wt,ψt)].\mathbb E\Big[\frac1T\sum_{t} C(w_t)\Big] = \mathbb E\Big[\frac1T\sum_{t} c(w_t,\psi_t)\Big].E[T1​t∑​C(wt​)]=E[T1​t∑​c(wt​,ψt​)].

The average online loss, which the regret of the online algorithm controls, is thus an unbiased estimate of the average risk of the iterates.

Formalization Note Rounds are numbered 0,…,T−10,\dots,T-10,…,T−1. No integrability of the online losses is assumed.

Preamble
import Mathlib
import Definitions.Def_OnlineLearningOCO_OnlineToBatch_Setting

open MeasureTheory
Formal statement
namespace OnlineLearningOCO.OnlineToBatch

/-- Equation (5.1) (Shalev-Shwartz, FnT ML 4(2) (2011), §5, proof of Theorem 5.1, p. 188).
For an i.i.d. sample `ψ₀, …, ψ_{T-1}` with law `Q` and the predictions `w_t` of a
non-anticipating online algorithm,
`𝔼[(1/T) ∑_t C(w_t)] = 𝔼[(1/T) ∑_t c(w_t, ψ_t)]`. -/
theorem eq_5_1 {d : ℕ} {Ψ : Type*} [MeasurableSpace Ψ] (S : Set (EuclideanSpace ℝ (Fin d)))
    (Q : Measure Ψ) [IsProbabilityMeasure Q] (c : EuclideanSpace ℝ (Fin d) → Ψ → ℝ)
    (hc : IsCost S Q c) (A : (t : ℕ) → (Fin t → Ψ) → EuclideanSpace ℝ (Fin d))
    (hA : IsOnlineLearner S A)
    (T : ℕ) (hT : 0 < T) :
    ∫ ψ, (1 / (T : ℝ)) * ∑ t : Fin T, risk Q c (iterate A ψ t) ∂(sampleLaw Q T) =
      ∫ ψ, (1 / (T : ℝ)) * ∑ t : Fin T, c (iterate A ψ t) (ψ t) ∂(sampleLaw Q T) := by sorry

end OnlineLearningOCO.OnlineToBatch
Source
Shalev-Shwartz, Online Learning and Online Convex Optimization, Found. Trends Mach. Learn. 4(2) (2011) 107–194, p. 188, §5, proof of Theorem 5.1, Equation (5.1)
Human review
  • Endorsed by Shuze Chen · Oct 7, 2026

    Confirmed by the moderator at approval.

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