import OAI.Probability.FreeIsing.Martingales.ContinuousSelection namespace OAI noncomputable section open MeasureTheory Filter Set open scoped NNReal Topology namespace Problem367.MartingaleSquareMaximal variable {Ω : Type*} [mΩ : MeasurableSpace Ω] {μ : Measure Ω} [IsFiniteMeasure μ] omit [IsFiniteMeasure μ] in theorem dist_toLp_sq {f g : Ω → ℝ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ) : dist (hf.toLp f) (hg.toLp g) ^ 2 = ∫ ω, (f ω - g ω) ^ 2 ∂μ := by rw [dist_eq_norm, ← real_inner_self_eq_norm_sq, L2.inner_def] simp only [real_inner_self_eq_norm_sq, Real.norm_eq_abs, sq_abs] apply integral_congr_ae filter_upwards [Lp.coeFn_sub (hf.toLp f) (hg.toLp g), hf.coeFn_toLp, hg.coeFn_toLp] with ω hsub ha hb simp only [Pi.sub_apply] at hsub rw [hsub, ha, hb] theorem dist_toLp_le_of_le {F : Filtration ℝ≥0 mΩ} {M N : ℝ≥0 → Ω → ℝ} (hM : Martingale M F μ) (hN : Martingale N F μ) (hM2 : ∀ t, MemLp (M t) 2 μ) (hN2 : ∀ t, MemLp (N t) 2 μ) {s t : ℝ≥0} (hst : s ≤ t) : dist ((hM2 s).toLp (M s)) ((hN2 s).toLp (N s)) ≤ dist ((hM2 t).toLp (M t)) ((hN2 t).toLp (N t)) := by have hsq := integral_sq_le (hM.sub hN) (fun r => (hM2 r).sub (hN2 r)) hst simp only [Pi.sub_apply] at hsq rw [← dist_toLp_sq (hM2 s) (hN2 s), ← dist_toLp_sq (hM2 t) (hN2 t)] at hsq exact (sq_le_sq₀ dist_nonneg dist_nonneg).mp hsq theorem L2_cauchy_of_le {F : Filtration ℝ≥0 mΩ} {M : ℕ → ℝ≥0 → Ω → ℝ} (hM : ∀ n, Martingale (M n) F μ) (h2 : ∀ n t, MemLp (M n t) 2 μ) {s T : ℝ≥0} (hs : s ≤ T) (hC : CauchySeq (fun n => (h2 n T).toLp (M n T))) : CauchySeq (fun n => (h2 n s).toLp (M n s)) := by apply Metric.cauchySeq_iff.mpr intro ε hε obtain ⟨N, hN⟩ := Metric.cauchySeq_iff.mp hC ε hε refine ⟨N, fun n hn m hm => ?_⟩ exact (dist_toLp_le_of_le (hM n) (hM m) (h2 n) (h2 m) hs).trans_lt (hN n hn m hm) theorem memLp_tendsto_of_cauchy_of_ae_subsequence {X : ℕ → Ω → ℝ} (h2 : ∀ n, MemLp (X n) 2 μ) {L : Ω → ℝ} (hC : CauchySeq (fun n => (h2 n).toLp (X n))) {v : ℕ → ℕ} (hv : Tendsto v atTop atTop) (hL : ∀ᵐ ω ∂μ, Tendsto (fun n => X (v n) ω) atTop (𝓝 (L ω))) : ∃ hL2 : MemLp L 2 μ, Tendsto (fun n => (h2 n).toLp (X n)) atTop (𝓝 (hL2.toLp L)) := by obtain ⟨I, hI⟩ := cauchySeq_tendsto_of_complete hC have hraw : TendstoInMeasure μ X atTop I := (tendstoInMeasure_of_tendsto_Lp hI).congr_left (fun n => (h2 n).coeFn_toLp) have heq : L =ᵐ[μ] I := tendstoInMeasure_ae_unique (tendstoInMeasure_of_tendsto_ae (fun n => (h2 (v n)).aestronglyMeasurable) hL) (hraw.comp hv) have hL2 : MemLp L 2 μ := (Lp.memLp I).ae_eq heq.symm refine ⟨hL2, ?_⟩ have hclass : hL2.toLp L = I := (hL2.toLp_congr (Lp.memLp I) heq).trans (Lp.toLp_coeFn I (Lp.memLp I)) rw [hclass] exact hI theorem exists_predictable_continuous_L2_limit {F : Filtration ℝ≥0 mΩ} {M : ℕ → ℝ≥0 → Ω → ℝ} (hM : ∀ n, Martingale (M n) F μ) (h2 : ∀ n t, MemLp (M n t) 2 μ) (hc : ∀ n, ∀ᵐ ω ∂μ, Continuous (fun t => M n t ω)) (T : ℝ≥0) (hC : CauchySeq (fun n => (h2 n T).toLp (M n T))) : ∃ L : ℝ≥0 → Ω → ℝ, IsStronglyPredictable F L ∧ (∀ᵐ ω ∂μ, ContinuousOn (fun t => L t ω) (Iic T)) ∧ ∀ t ≤ T, ∃ hL2 : MemLp (L t) 2 μ, Tendsto (fun n => (h2 n t).toLp (M n t)) atTop (𝓝 (hL2.toLp (L t))) := by obtain ⟨v, L, hv, hpred, hcont, hlim⟩ := exists_predictable_continuous_subsequence_of_terminal_L2_cauchy hM h2 hc T hC refine ⟨L, hpred, hcont, fun t ht => ?_⟩ apply memLp_tendsto_of_cauchy_of_ae_subsequence (fun n => h2 n t) (L2_cauchy_of_le hM h2 ht hC) hv.tendsto_atTop filter_upwards [hlim] with ω hω exact hω t ht end Problem367.MartingaleSquareMaximal end end OAI