import OAI.Probability.FreeIsing.Martingales.ContinuousMaximal namespace OAI noncomputable section open MeasureTheory Filter Set open scoped NNReal ENNReal Topology namespace Problem367.MartingaleSquareMaximal variable {Ω : Type*} [mΩ : MeasurableSpace Ω] {μ : Measure Ω} {M : ℕ → ℝ≥0 → Ω → ℝ} theorem ae_exists_continuous_limit_of_summable_crossings (hc : ∀ n, ∀ᵐ ω ∂μ, Continuous (fun t => M n t ω)) (T : ℝ≥0) (hsum : (∑' n : ℕ, μ {ω | ∃ t ≤ T, ((1 / 2 : ℝ) ^ n) < |M (n + 1) t ω - M n t ω|}) ≠ ∞) : ∀ᵐ ω ∂μ, ∃ f : C(Set.Iic T, ℝ), ∀ t : Set.Iic T, Tendsto (fun n => M n t ω) atTop (𝓝 (f t)) := by have hbc := ae_eventually_notMem hsum filter_upwards [ae_all_iff.mpr hc, hbc] with ω hcω hω have hcompact : IsCompact (Set.Iic T) := by convert (isCompact_Icc (a := (0 : ℝ≥0)) (b := T)) using 1 ext t simp only [Set.mem_Iic, Set.mem_Icc] exact ⟨fun ht => ⟨zero_le, ht⟩, And.right⟩ let : CompactSpace (Set.Iic T) := isCompact_iff_compactSpace.mp hcompact let f : ℕ → C(Set.Iic T, ℝ) := fun n => ⟨fun t => M n t ω, (hcω n).comp continuous_subtype_val⟩ have hgeom : Summable (fun n : ℕ => (1 / 2 : ℝ) ^ n) := summable_geometric_of_norm_lt_one (by norm_num) have hdist : Summable (fun n : ℕ => dist (f n) (f (n + 1))) := by apply hgeom.of_norm_bounded_eventually_nat filter_upwards [hω] with n hn rw [Real.norm_eq_abs, abs_of_nonneg dist_nonneg] apply (ContinuousMap.dist_le (by positivity : (0 : ℝ) ≤ (1 / 2 : ℝ) ^ n)).2 intro t have hv : |M (n + 1) t ω - M n t ω| ≤ (1 / 2 : ℝ) ^ n := by by_contra! h exact hn ⟨t, t.property, h⟩ simpa only [f, ContinuousMap.coe_mk, Real.dist_eq, abs_sub_comm] using hv obtain ⟨g, hg⟩ := cauchySeq_tendsto_of_complete (cauchySeq_of_summable_dist hdist) refine ⟨g, fun t => ?_⟩ exact ((continuous_eval_const t).tendsto g).comp hg theorem ae_exists_continuous_limit_of_summable_energy [IsFiniteMeasure μ] {F : Filtration ℝ≥0 mΩ} (hM : ∀ n, Martingale (M n) F μ) (h2 : ∀ n t, MemLp (M n t) 2 μ) (hc : ∀ n, ∀ᵐ ω ∂μ, Continuous (fun t => M n t ω)) (T : ℝ≥0) (hsum : (∑' n : ℕ, ENNReal.ofReal (∫ ω, (M (n + 1) T ω - M n T ω) ^ 2 ∂μ) / (((1 / 2 : ℝ≥0) ^ n : ℝ≥0) : ℝ≥0∞) ^ 2) ≠ ∞) : ∀ᵐ ω ∂μ, ∃ f : C(Set.Iic T, ℝ), ∀ t : Set.Iic T, Tendsto (fun n => M n t ω) atTop (𝓝 (f t)) := by apply ae_exists_continuous_limit_of_summable_crossings hc T apply ne_top_of_le_ne_top hsum apply ENNReal.tsum_le_tsum intro n have hcont : ∀ᵐ ω ∂μ, Continuous (fun t => (M (n + 1) - M n) t ω) := by filter_upwards [hc (n + 1), hc n] with ω ha hb exact ha.sub hb have hb := continuous_maximal_sq ((hM (n + 1)).sub (hM n)) (fun t => (h2 (n + 1) t).sub (h2 n t)) hcont ((1 / 2 : ℝ≥0) ^ n) T apply (ENNReal.le_div_iff_mul_le (Or.inl (by positivity)) (Or.inl (by simp))).2 simpa only [NNReal.coe_pow, NNReal.coe_div, NNReal.coe_one, NNReal.coe_ofNat, Pi.sub_apply, mul_comm] using hb end Problem367.MartingaleSquareMaximal end end OAI