Martingale Definition

lean4-proofprobabilityvisualization
E[Mn+1Fn]=Mn a.s.E[M_{n+1} \mid \mathcal{F}_n] = M_n \text{ a.s.}

Statement

A stochastic process (Mn)n0(M_n)_{n \geq 0} adapted to a filtration (Fn)n0(\mathcal{F}_n)_{n \geq 0} is a martingale with respect to measure PP if:

  1. MnM_n is integrable for all nn, and
  2. For all iji \leq j: E[MjFi]=MiE[M_j \mid \mathcal{F}_i] = M_i a.s.

Equivalently (in the Mathlib formulation): MM is strongly adapted to F\mathcal{F} and the conditional expectation property P[MjFi]=a.e.MiP[M_j \mid \mathcal{F}_i] =^{\mathrm{a.e.}} M_i holds for all iji \leq j.

Visualization

Symmetric random walk. Let X1,X2,X_1, X_2, \ldots be i.i.d. with P(Xk=+1)=P(Xk=1)=1/2P(X_k = +1) = P(X_k = -1) = 1/2, and set Mn=X1++XnM_n = X_1 + \cdots + X_n, M0=0M_0 = 0.

nnPossible values of MnM_nE[Mn+1Mn=m]E[M_{n+1} \mid M_n = m]
000001=00 \cdot 1 = 0
11±1\pm 112(m+1)+12(m1)=m\frac{1}{2}(m+1) + \frac{1}{2}(m-1) = m
220,±20, \pm 2mm (same computation)
nn{n,n+2,,n}\{-n, -n+2, \ldots, n\}mm for any mm

The next step always goes ±1\pm 1 with equal probability, so the expected value of Mn+1M_{n+1} given Mn=mM_n = m is exactly mm. The walk is "fair": no drift.

     +2  *
         |
   +1    *   *
         |   |
    0  * | * | *
         |   |
   -1    *   *
         |
     -2  *
   n: 0  1  2  3

Each level is equally likely to go up or down, keeping the expected future value equal to the present.

Proof Sketch

Verification for the random walk:

  1. Adaptedness. Mn=X1++XnM_n = X_1 + \cdots + X_n is Fn\mathcal{F}_n-measurable by definition.
  2. Integrability. E[Mn]k=1nE[Xk]=n<E[|M_n|] \leq \sum_{k=1}^n E[|X_k|] = n < \infty.
  3. Martingale property. E[Mn+1Fn]=E[Mn+Xn+1Fn]E[M_{n+1} \mid \mathcal{F}_n] = E[M_n + X_{n+1} \mid \mathcal{F}_n].
    • By Linearity of Conditional ExpectationLinearity of Conditional ExpectationE[aX+bYG]=aE[XG]+bE[YG]E[aX + bY \mid \mathcal{G}] = a\,E[X \mid \mathcal{G}] + b\,E[Y \mid \mathcal{G}]Conditional expectation is linear: E[aX+bY|G] = aE[X|G] + bE[Y|G] almost surelyRead more →: =E[MnFn]+E[Xn+1Fn]= E[M_n \mid \mathcal{F}_n] + E[X_{n+1} \mid \mathcal{F}_n].
    • Since MnM_n is Fn\mathcal{F}_n-measurable: E[MnFn]=MnE[M_n \mid \mathcal{F}_n] = M_n a.s.
    • Since Xn+1X_{n+1} is independent of Fn\mathcal{F}_n: E[Xn+1Fn]=E[Xn+1]=0E[X_{n+1} \mid \mathcal{F}_n] = E[X_{n+1}] = 0.
    • Conclusion: E[Mn+1Fn]=MnE[M_{n+1} \mid \mathcal{F}_n] = M_n a.s.

Connections

The martingale definition builds on Linearity of Conditional ExpectationLinearity of Conditional ExpectationE[aX+bYG]=aE[XG]+bE[YG]E[aX + bY \mid \mathcal{G}] = a\,E[X \mid \mathcal{G}] + b\,E[Y \mid \mathcal{G}]Conditional expectation is linear: E[aX+bY|G] = aE[X|G] + bE[Y|G] almost surelyRead more → (step 3 above) and Law of Total ExpectationLaw of Total ExpectationE[X]=E[E[XY]]E[X] = E[E[X \mid Y]]The expectation of X equals the expectation of its conditional expectation: E[X] = E[E[X|Y]]Read more → (taking unconditional expectations of both sides gives E[Mj]=E[Mi]E[M_j] = E[M_i] for all iji \leq j — martingales have constant mean). The Borel-Cantelli LemmaBorel-Cantelli Lemman=1P(An)<P(An i.o.)=0\sum_{n=1}^\infty P(A_n) < \infty \Rightarrow P(A_n \text{ i.o.}) = 0If the sum of event probabilities is finite, almost surely only finitely many events occurRead more → is proved using a martingale-based argument in the second BC lemma (Mathlib's ProbabilityTheory.measure_limsup_eq_one).

Lean4 Proof

Mathlib defines MeasureTheory.Martingale in Mathlib.Probability.Martingale.Basic. The symmetric random walk is a martingale via martingale_condExp.

martingale_condExp is proved in Mathlib using condExp_condExp_of_le (tower property) to verify P[P[fFj]Fi]=a.e.P[fFi]P[P[f \mid \mathcal{F}_j] \mid \mathcal{F}_i] =^{\mathrm{a.e.}} P[f \mid \mathcal{F}_i] for iji \leq j.

Lean4 Proof

import Mathlib.Probability.Martingale.Basic

namespace MoonMath

open MeasureTheory

/-- The process `fun i => μ[f | ℱ i]` (the tower of conditional expectations of `f`) is
    always a martingale. This establishes the pattern: martingales arise whenever you take
    conditional expectations of an integrable target. -/
theorem condExp_martingale {Ω E : Type*} [NormedAddCommGroup E] [NormedSpace  E]
    [CompleteSpace E] {m0 : MeasurableSpace Ω} (μ : Measure Ω) {ι : Type*} [Preorder ι]
    ( : Filtration ι m0) (f : Ω  E) :
    Martingale (fun i => μ[f |  i])  μ :=
  martingale_condExp f  μ

/-- Martingales have constant mean: for i ≤ j, E[M_j] = E[M_i]. -/
theorem martingale_const_mean {Ω E : Type*} [NormedAddCommGroup E] [NormedSpace  E]
    [CompleteSpace E] {m0 : MeasurableSpace Ω} {μ : Measure Ω} {ι : Type*} [Preorder ι]
    { : Filtration ι m0} {f : ι  Ω  E} (hf : Martingale f  μ)
    {i j : ι} (hij : i  j) [SigmaFiniteFiltration μ ] :
    ∫ ω, f j ω ∂μ = ∫ ω, f i ω ∂μ :=
  hf.setIntegral_eq hij MeasurableSet.univ

end MoonMath