Lean Machine Learning

5.Β Stochastic Processes and MartingalesπŸ”—

5.1.Β Stochastic processes, filtrations, and martingalesπŸ”—

We define a measure space Ξ©, with a probability mesure P : Measure Ξ©.

variable {Ξ© : Type*} {mΞ© : MeasurableSpace Ξ©} {P : Measure Ξ©} [IsProbabilityMeasure P]

Let then X be a stochastic process indexed by β„•: a function β„• β†’ Ξ© β†’ E. Here E is a Banach space, a complete normed space (that's what the martingale property needs). We will often need a measurability condition on X in lemmas, but we don't add it yet.

variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {mE : MeasurableSpace E} {X : β„• β†’ Ξ© β†’ E}

A filtration is a monotone family of sub-Οƒ-algebras indexed by β„•.

variable {𝓕 : Filtration β„• mΞ©} example : βˆ€ n, 𝓕 n ≀ mΞ© := Filtration.le 𝓕 example {i j : β„•} (hij : i ≀ j) : 𝓕 i ≀ 𝓕 j := Filtration.mono 𝓕 hij

If X is a martingale, then it is adapted to the filtration, which means that for all n, X n is (strongly) measurable with respect to 𝓕 n.

example (hX : Martingale X 𝓕 P) : StronglyAdapted 𝓕 X := hX.stronglyAdapted example (hX : Martingale X 𝓕 P) (n : β„•) : StronglyMeasurable[𝓕 n] (X n) := hX.stronglyAdapted n example [BorelSpace E] (hX : Martingale X 𝓕 P) (n : β„•) : Measurable[𝓕 n] (X n) := (hX.stronglyAdapted n).measurable /-- A martingale satisfies the following equality: for all `i ≀ j`, the conditional expectation of `X j` with respect to `𝓕 i` is equal to `X i`. -/ example (hX : Martingale X 𝓕 P) {i j : β„•} (hij : i ≀ j) : P[X j | 𝓕 i] =ᡐ[P] X i := hX.condExp_ae_eq hij /-- For a submartingale, the conditional expectation of `Y j` with respect to `𝓕 i` is greater than or equal to `Y i`. -/ example {Y : β„• β†’ Ξ© β†’ ℝ} (hX : Submartingale Y 𝓕 P) {i j : β„•} (hij : i ≀ j) : Y i ≀ᡐ[P] P[Y j | 𝓕 i] := hX.ae_le_condExp hij

Almost everywhere martingale convergence theorem: An LΒΉ-bounded submartingale converges almost everywhere to a ⨆ n, β„± n-measurable function.

theorem ae_tendsto_limitProcess {Y : β„• β†’ Ξ© β†’ ℝ} (hY : Submartingale Y 𝓕 P) {R : ℝβ‰₯0} (hbdd : βˆ€ n, eLpNorm (Y n) 1 P ≀ R) : βˆ€α΅ Ο‰ βˆ‚P, Tendsto (Y Β· Ο‰) atTop (𝓝 (𝓕.limitProcess Y P Ο‰)) := Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑R⊒ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (Filtration.limitProcess Y 𝓕 P Ο‰)) classical suffices βˆƒ g, StronglyMeasurable[⨆ n, 𝓕 n] g ∧ βˆ€α΅ Ο‰ βˆ‚P, Tendsto (Y Β· Ο‰) atTop (𝓝 (g Ο‰)) Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rthis:βˆƒ g, StronglyMeasurable g ∧ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰))⊒ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (Filtration.limitProcess Y 𝓕 P Ο‰)) Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rthis:βˆƒ g, StronglyMeasurable g ∧ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰))⊒ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (Classical.choose this Ο‰)) All goals completed! πŸ™ Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0⊒ βˆƒ g, StronglyMeasurable g ∧ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰)) Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΩ⊒ βˆƒ g, StronglyMeasurable g ∧ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰)) have hg' : βˆ€α΅ Ο‰ βˆ‚P.trim hle, Tendsto (Y Β· Ο‰) atTop (𝓝 (g' Ο‰)) := Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑R⊒ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (Filtration.limitProcess Y 𝓕 P Ο‰)) filter_upwards [hY.exists_ae_trim_tendsto_of_bdd hbdd] with Ο‰ Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΩω:Ξ©hΟ‰:βˆƒ c, Tendsto (fun n => Y n Ο‰) atTop (𝓝 c)⊒ Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰)) simp_rw Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΩω:Ξ©hΟ‰:βˆƒ c, Tendsto (fun n => Y n Ο‰) atTop (𝓝 c)⊒ Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰))g', dif_pos hΟ‰] All goals completed! πŸ™ Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΞ©hg':βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P.trim hle, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰))hg'm:AEStronglyMeasurable g' (P.trim hle)⊒ βˆƒ g, StronglyMeasurable g ∧ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰)) Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΞ©hg':βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P.trim hle, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰))g:Ξ© β†’ ℝhgm:StronglyMeasurable ghae:g' =αΆ [ae (P.trim hle)] g⊒ βˆƒ g, StronglyMeasurable g ∧ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰)) have hg : βˆ€α΅ Ο‰ βˆ‚P.trim hle, Tendsto (Y Β· Ο‰) atTop (𝓝 (g Ο‰)) := Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑R⊒ βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (Filtration.limitProcess Y 𝓕 P Ο‰)) filter_upwards [hae, hg'] with Ο‰ Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΞ©hg':βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P.trim hle, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰))g:Ξ© β†’ ℝhgm:StronglyMeasurable ghae:g' =αΆ [ae (P.trim hle)] gΟ‰:Ξ©hΟ‰:g' Ο‰ = g Ο‰βŠ’ Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰)) β†’ Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰)) Ξ©:Type u_1mΞ©:MeasurableSpace Ξ©P:Measure Ξ©inst✝:IsProbabilityMeasure P𝓕:Filtration β„• mΞ©Y:β„• β†’ Ξ© β†’ ℝhY:Submartingale Y 𝓕 PR:ℝβ‰₯0hbdd:βˆ€ (n : β„•), eLpNorm (Y n) 1 P ≀ ↑Rg':Ξ© β†’ ℝ := fun Ο‰ => if h : βˆƒ c, Tendsto (fun x => Y x Ο‰) atTop (𝓝 c) then h.choose else 0hle:⨆ n, ↑𝓕 n ≀ mΞ©hg':βˆ€α΅ (Ο‰ : Ξ©) βˆ‚P.trim hle, Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰))g:Ξ© β†’ ℝhgm:StronglyMeasurable ghae:g' =αΆ [ae (P.trim hle)] gΟ‰:Ξ©hΟ‰:g' Ο‰ = g Ο‰hg'Ο‰:Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g' Ο‰))⊒ Tendsto (fun x => Y x Ο‰) atTop (𝓝 (g Ο‰)) using hΟ‰ β–Έ hg'Ο‰ All goals completed! πŸ™

5.2.Β Stopping timesπŸ”—

A stopping time with respect to a filtration indexed by β„• is a random time Ο„ : Ξ© β†’ β„•βˆž such that for all n, the set {Ο‰ | Ο„ Ο‰ ≀ n} is measurable with respect to 𝓕 n.

variable {Ο„ : Ξ© β†’ β„•βˆž} (hΟ„ : IsStoppingTime 𝓕 Ο„) example (i : β„•) : MeasurableSet[𝓕 i] {Ο‰ | Ο„ Ο‰ ≀ i} := hΟ„.measurableSet_le i

The optional stopping theorem (fair game theorem): an adapted integrable process Y is a submartingale if and only if for all bounded stopping times Ο„ and Ο€ such that Ο„ ≀ Ο€, the stopped value of Y at Ο„ has expectation smaller than its stopped value at Ο€.

theorem submartingale_iff_expected_stoppedValue_mono' {Y : β„• β†’ Ξ© β†’ ℝ} (hadp : StronglyAdapted 𝓕 Y) (hint : βˆ€ i, Integrable (Y i) P) : Submartingale Y 𝓕 P ↔ βˆ€ Ο„ Ο€ : Ξ© β†’ β„•βˆž, IsStoppingTime 𝓕 Ο„ β†’ IsStoppingTime 𝓕 Ο€ β†’ Ο„ ≀ Ο€ β†’ (βˆƒ N : β„•, βˆ€ x, Ο€ x ≀ N) β†’ P[stoppedValue Y Ο„] ≀ P[stoppedValue Y Ο€] := ⟨fun hf _ _ hΟ„ hΟ€ hle ⟨_, hN⟩ => hf.expected_stoppedValue_mono hΟ„ hΟ€ hle hN, submartingale_of_expected_stoppedValue_mono hadp hint⟩