Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Optional Stopping Theorem

Proved
MarkovMixing.optional_stopping

by Shuze Chen · Aug 22, 2026 · Mathlib 0df444a (Lean v4.33.1)

markov-chainsmixing-timesprobability

Let PPP be a Markov chain on a finite state space VVV. A martingale adapted to the chain is a family MtM_tMt​ of real-valued functions of the trajectory up to time ttt whose one-step conditional expectation is neutral: ∑yP(ωt,y) Mt+1(ω,y)=Mt(ω)\sum_yP(\omega_t,y)\,M_{t+1}(\omega,y)=M_t(\omega)∑y​P(ωt​,y)Mt+1​(ω,y)=Mt​(ω) for every trajectory ω\omegaω, where (ω,y)(\omega,y)(ω,y) extends ω\omegaω by one step. A stopping time τ\tauτ is a {0,1}\{0,1\}{0,1}-valued stopping rule: whether to stop at time ttt is determined by the trajectory up to ttt. Fix a starting state xxx; τ\tauτ is almost surely finite when the total probability of ever stopping equals one, and the stopped expectation Ex(Mτ)\mathbb E_x(M_\tau)Ex​(Mτ​) is the sum over all times ttt and trajectories from xxx of (trajectory weight) × (probability of stopping exactly at ttt) × MtM_tMt​.

The theorem (the Optional Stopping Theorem, Corollary 17.7 of Levin–Peres–Wilmer) asserts: if MMM is uniformly bounded — ∣Mt(ω)∣≤K|M_t(\omega)|\le K∣Mt​(ω)∣≤K for some constant KKK and all t,ωt,\omegat,ω — and τ\tauτ is almost surely finite, then

Ex(Mτ)  =  M0(x):\mathbb E_x\bigl(M_{\tau}\bigr)\;=\;M_0(x):Ex​(Mτ​)=M0​(x):

stopping a fair game at a fair time wins nothing. This identity is the workhorse of discrete probability — the gambler's ruin probabilities and hitting-time identities of Missions I and VI are all instances — and in this mission it feeds the analysis of the evolving-set process.

Preamble
import Definitions.Def_mm_martingale
Formal statement
namespace MarkovMixing

/-- **Corollary 17.7, the Optional Stopping Theorem** (LPW): if `M` is a
bounded martingale with respect to the chain and `τ` is an almost surely
finite stopping time, then `E_x(M_τ) = M_0(x)`. -/
theorem optional_stopping {V : Type*} [Fintype V] [DecidableEq V]
    (P : Matrix V V ℝ) (hP : IsStochastic P)
    (M : ∀ t : ℕ, (Fin (t + 1) → V) → ℝ) (hM : IsChainMartingale P M)
    (s : ∀ t : ℕ, (Fin (t + 1) → V) → ℝ)
    (hs01 : ∀ (t : ℕ) (ω : Fin (t + 1) → V), s t ω = 0 ∨ s t ω = 1)
    (x : V) (hfin : (∑' t : ℕ, ∑ y, stopAtProb P x s t y) = 1)
    (K : ℝ) (hK : ∀ (t : ℕ) (ω : Fin (t + 1) → V), |M t ω| ≤ K) :
    stoppedExp P x s M = M 0 (fun _ => x) := by
  sorry

end MarkovMixing
Source
D. A. Levin, Y. Peres, E. L. Wilmer, Markov Chains and Mixing Times, AMS 2009, https://documents.epfl.ch/groups/i/ip/ipg/www/2013-2014/Random_Walks/markovmixing.pdf, Section 17.2, Corollary 17.7 (Optional Stopping Theorem, Version 2), p. 232

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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me