Download data/lean/OAI/Probability/FreeIsing/Stochastic/RandomRiemannCompensator.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.2 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FreeIsing/Stochastic/RandomRiemannCompensator.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/FreeIsing/Stochastic/RandomRiemannCompensator.lean
-
curl -L -o RandomRiemannCompensator.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FreeIsing/Stochastic/RandomRiemannCompensator.lean
10.2 kB
| import OAI.Probability.FreeIsing.Energy.EnergyRiemannApproximation | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory Filter Set | |
| open scoped Topology ENNReal NNReal | |
| namespace Problem367.RandomRiemann | |
| def partitionSum (f : β β β) (Ο : β β β) (n : β) : β := | |
| β i β Finset.range n, (Ο (i + 1) - Ο i) * f (Ο i) | |
| theorem abs_partitionSum_le {f : β β β} {Ο : β β β} (hΟ : Monotone Ο) | |
| (n : β) {C : β} (hb : β i < n, |f (Ο i)| β€ C) : | |
| |partitionSum f Ο n| β€ C * (Ο n - Ο 0) := by | |
| calc | |
| _ β€ β i β Finset.range n, |(Ο (i + 1) - Ο i) * f (Ο i)| := | |
| Finset.abs_sum_le_sum_abs _ _ | |
| _ β€ β i β Finset.range n, C * (Ο (i + 1) - Ο i) := by | |
| apply Finset.sum_le_sum | |
| intro i hi | |
| rw [abs_mul, abs_of_nonneg (sub_nonneg.mpr (hΟ (Nat.le_succ i)))] | |
| nlinarith [mul_le_mul_of_nonneg_left (hb i (Finset.mem_range.mp hi)) | |
| (sub_nonneg.mpr (hΟ (Nat.le_succ i)))] | |
| _ = _ := by rw [β Finset.mul_sum, Finset.sum_range_sub] | |
| theorem partition_error_le {f : β β β} (hf : Continuous f) | |
| {Ο : β β β} (hΟ : Monotone Ο) (n : β) {Ξ΅ : β} | |
| (hmod : β i < n, β x β Icc (Ο i) (Ο (i + 1)), |f (Ο i) - f x| β€ Ξ΅) : | |
| |partitionSum f Ο n - β« x in Ο 0..Ο n, f x| β€ Ξ΅ * (Ο n - Ο 0) := by | |
| have hsplit := intervalIntegral.sum_integral_adjacent_intervals | |
| (ΞΌ := volume) (a := Ο) (n := n) (fun i _ => hf.intervalIntegrable _ _) | |
| have heq : partitionSum f Ο n - (β« x in Ο 0..Ο n, f x) = | |
| β i β Finset.range n, β« x in Ο i..Ο (i + 1), f (Ο i) - f x := by | |
| rw [partitionSum, β hsplit, β Finset.sum_sub_distrib] | |
| apply Finset.sum_congr rfl | |
| intro i hi | |
| rw [intervalIntegral.integral_sub intervalIntegrable_const (hf.intervalIntegrable _ _), | |
| intervalIntegral.integral_const, smul_eq_mul] | |
| rw [heq] | |
| calc | |
| _ β€ β i β Finset.range n, |β« x in Ο i..Ο (i + 1), f (Ο i) - f x| := | |
| Finset.abs_sum_le_sum_abs _ _ | |
| _ β€ β i β Finset.range n, Ξ΅ * (Ο (i + 1) - Ο i) := by | |
| apply Finset.sum_le_sum | |
| intro i hi | |
| have hle := hΟ (Nat.le_succ i) | |
| have h := intervalIntegral.norm_integral_le_of_norm_le_const | |
| (a := Ο i) (b := Ο (i + 1)) (C := Ξ΅) | |
| (f := fun x => f (Ο i) - f x) (fun x hx => ?_) | |
| Β· simpa only [Real.norm_eq_abs, abs_of_nonneg (sub_nonneg.mpr hle)] using h | |
| Β· rw [uIoc_of_le hle] at hx | |
| exact hmod i (Finset.mem_range.mp hi) x β¨hx.1.le, hx.2β© | |
| _ = _ := by rw [β Finset.mul_sum, Finset.sum_range_sub] | |
| def stoppedPoint (T t : β) (n i : β) : β := min t (EnergyRiemann.point T n i) | |
| def stoppedSum (f : β β β) (T t : β) (n : β) : β := | |
| β i β Finset.range n, | |
| (stoppedPoint T t n (i + 1) - stoppedPoint T t n i) * f (EnergyRiemann.point T n i) | |
| theorem stoppedPoint_mono {T : β} (hT : 0 β€ T) (t : β) (n : β) : | |
| Monotone (stoppedPoint T t n) := fun _ _ hij => | |
| min_le_min_left t (EnergyRiemann.point_mono hT n hij) | |
| theorem stoppedPoint_zero (T : β) {t : β} (ht : 0 β€ t) (n : β) : | |
| stoppedPoint T t n 0 = 0 := by simp [stoppedPoint, ht] | |
| theorem stoppedPoint_end (T t : β) {n : β} (hn : 0 < n) : | |
| stoppedPoint T t n n = min t T := by rw [stoppedPoint, EnergyRiemann.point_end T hn] | |
| theorem stoppedPoint_step_le {T : β} (hT : 0 β€ T) (t : β) (n i : β) : | |
| stoppedPoint T t n (i + 1) - stoppedPoint T t n i β€ T / n := by | |
| have hle := EnergyRiemann.point_mono hT n (Nat.le_succ i) | |
| have hstep := EnergyRiemann.point_step T n i | |
| unfold stoppedPoint | |
| by_cases hi : EnergyRiemann.point T n i β€ t | |
| Β· rw [min_eq_right hi] | |
| exact (sub_le_sub_right (min_le_right t _) _).trans_eq hstep | |
| Β· have ht : t β€ EnergyRiemann.point T n i := le_of_not_ge hi | |
| rw [min_eq_left ht, min_eq_left (ht.trans hle), sub_self] | |
| positivity | |
| theorem stoppedSum_eq_partitionSum {T : β} (hT : 0 β€ T) | |
| (f : β β β) (t : β) (n : β) : | |
| stoppedSum f T t n = partitionSum f (stoppedPoint T t n) n := by | |
| apply Finset.sum_congr rfl | |
| intro i hi | |
| by_cases hit : EnergyRiemann.point T n i β€ t | |
| Β· simp only [stoppedPoint, min_eq_right hit] | |
| Β· have ht : t β€ EnergyRiemann.point T n i := le_of_not_ge hit | |
| have ht' := ht.trans (EnergyRiemann.point_mono hT n (Nat.le_succ i)) | |
| simp only [stoppedPoint, min_eq_left ht, min_eq_left ht', sub_self, zero_mul] | |
| theorem abs_stoppedSum_le {T t C : β} (hT : 0 β€ T) (ht : 0 β€ t) | |
| {f : β β β} (hb : β x, |f x| β€ C) (n : β) : | |
| |stoppedSum f T t n| β€ C * min t T := by | |
| by_cases hn : n = 0 | |
| Β· subst n | |
| simp only [stoppedSum, Finset.range_zero, Finset.sum_empty, abs_zero] | |
| exact mul_nonneg ((abs_nonneg (f 0)).trans (hb 0)) (le_min ht hT) | |
| Β· rw [stoppedSum_eq_partitionSum hT] | |
| simpa only [stoppedPoint_zero T ht, stoppedPoint_end T t (Nat.pos_of_ne_zero hn), sub_zero] | |
| using abs_partitionSum_le (stoppedPoint_mono hT t n) n (fun i _ => hb _) | |
| theorem tendsto_stoppedSum {f : β β β} (hf : Continuous f) | |
| {T t : β} (hT : 0 β€ T) (ht : 0 β€ t) : | |
| Tendsto (stoppedSum f T t) atTop (π (β« x in (0 : β)..min t T, f x)) := by | |
| apply Metric.tendsto_atTop.mpr | |
| intro Ξ΅ hΞ΅ | |
| let Ξ· := Ξ΅ / (T + 1) | |
| have hΞ· : 0 < Ξ· := div_pos hΞ΅ (by linarith) | |
| have hUC := isCompact_Icc.uniformContinuousOn_of_continuous | |
| (s := Icc (0 : β) T) hf.continuousOn | |
| obtain β¨Ξ΄, hΞ΄, hΞ΄modβ© := Metric.uniformContinuousOn_iff.mp hUC Ξ· hΞ· | |
| have hwidth : Tendsto (fun n : β => T / (n : β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop | |
| have hev : βαΆ n : β in atTop, T / (n : β) < Ξ΄ := hwidth.eventually (gt_mem_nhds hΞ΄) | |
| obtain β¨N, hNβ© := (hev.and (eventually_ge_atTop 1)).exists_forall_of_atTop | |
| refine β¨N, ?_β© | |
| intro n hn | |
| obtain β¨hmesh, hnposβ© := hN n hn | |
| have hn' : 0 < n := hnpos | |
| have hmem (i : β) (hi : i β€ n) : stoppedPoint T t n i β Icc (0 : β) T := by | |
| constructor | |
| Β· rw [β stoppedPoint_zero T ht n] | |
| exact stoppedPoint_mono hT t n (Nat.zero_le i) | |
| Β· exact (stoppedPoint_mono hT t n hi).trans | |
| ((stoppedPoint_end T t hn').le.trans (min_le_right t T)) | |
| have he := partition_error_le hf (stoppedPoint_mono hT t n) n (Ξ΅ := Ξ·) ?_ | |
| Β· rw [stoppedPoint_zero T ht, stoppedPoint_end T t hn', | |
| β stoppedSum_eq_partitionSum hT] at he | |
| change |stoppedSum f T t n - β« x in (0 : β)..min t T, f x| < Ξ΅ | |
| calc | |
| _ β€ Ξ· * (min t T - 0) := he | |
| _ β€ Ξ· * T := by gcongr; simp | |
| _ < Ξ΅ := by | |
| dsimp [Ξ·] | |
| rw [div_mul_eq_mul_div] | |
| apply (div_lt_iffβ (by linarith : 0 < T + 1)).mpr | |
| nlinarith | |
| Β· intro i hi x hx | |
| have hleft := hmem i hi.le | |
| have hright := hmem (i + 1) (Nat.succ_le_of_lt hi) | |
| have hxT : x β Icc (0 : β) T := β¨hleft.1.trans hx.1, hx.2.trans hright.2β© | |
| have hdist : dist (stoppedPoint T t n i) x < Ξ΄ := by | |
| rw [Real.dist_eq, abs_of_nonpos (sub_nonpos.mpr hx.1)] | |
| have hstep := stoppedPoint_step_le hT t n i | |
| linarith [hx.2] | |
| exact (hΞ΄mod _ hleft x hxT hdist).le | |
| theorem tendsto_stoppedSum_L1 | |
| {Ξ© : Type*} [MeasurableSpace Ξ©] {ΞΌ : Measure Ξ©} [IsFiniteMeasure ΞΌ] | |
| {H : β β Ξ© β β} (hm : β t, AEStronglyMeasurable (H t) ΞΌ) | |
| (hc : βα΅ Ο βΞΌ, Continuous (fun t => H t Ο)) | |
| {C T t : β} (hb : βα΅ Ο βΞΌ, β s, |H s Ο| β€ C) | |
| (hT : 0 β€ T) (ht : 0 β€ t) : | |
| Tendsto (fun n => eLpNorm | |
| ((fun Ο => stoppedSum (fun s => H s Ο) T t n) - | |
| (fun Ο => β« s in (0 : β)..min t T, H s Ο)) 1 ΞΌ) atTop (π 0) := by | |
| have hmeas (n : β) : AEStronglyMeasurable | |
| (fun Ο => stoppedSum (fun s => H s Ο) T t n) ΞΌ := by | |
| unfold stoppedSum | |
| apply Finset.aestronglyMeasurable_fun_sum | |
| intro i hi | |
| exact (hm _).const_mul _ | |
| have hbound (n : β) : βα΅ Ο βΞΌ, | |
| βstoppedSum (fun s => H s Ο) T t nβ β€ C * min t T := by | |
| filter_upwards [hb] with Ο hΟ | |
| exact abs_stoppedSum_le hT ht hΟ n | |
| have hlim : βα΅ Ο βΞΌ, Tendsto (fun n => stoppedSum (fun s => H s Ο) T t n) | |
| atTop (π (β« s in (0 : β)..min t T, H s Ο)) := by | |
| filter_upwards [hc] with Ο hΟ | |
| exact tendsto_stoppedSum hΟ hT ht | |
| have h := tendsto_lintegral_norm_of_dominated_convergence hmeas | |
| (integrable_const (C * min t T)).hasFiniteIntegral hbound hlim | |
| have hlimitMeas := aestronglyMeasurable_of_tendsto_ae atTop hmeas hlim | |
| simpa only [eLpNorm_one_eq_lintegral_enorm ((hmeas _).sub hlimitMeas), | |
| Pi.sub_apply, β ofReal_norm] using h | |
| theorem tendsto_stoppedSquareSum_L1 | |
| {Ξ© : Type*} [MeasurableSpace Ξ©] {ΞΌ : Measure Ξ©} [IsFiniteMeasure ΞΌ] | |
| {H : β β Ξ© β β} (hm : β t, AEStronglyMeasurable (H t) ΞΌ) | |
| (hc : βα΅ Ο βΞΌ, Continuous (fun t => H t Ο)) | |
| {C T t : β} (hC : 0 β€ C) (hb : βα΅ Ο βΞΌ, β s, |H s Ο| β€ C) | |
| (hT : 0 β€ T) (ht : 0 β€ t) : | |
| Tendsto (fun n => eLpNorm | |
| ((fun Ο => stoppedSum (fun s => (H s Ο) ^ 2) T t n) - | |
| (fun Ο => β« s in (0 : β)..min t T, (H s Ο) ^ 2)) 1 ΞΌ) atTop (π 0) := by | |
| apply tendsto_stoppedSum_L1 (fun t => (hm t).pow 2) | |
| (hc.mono (fun Ο hΟ => hΟ.pow 2)) (C := C ^ 2) _ hT ht | |
| filter_upwards [hb] with Ο hΟ | |
| intro s | |
| simpa only [Pi.pow_apply, abs_sq, sq_abs] using | |
| (sq_le_sqβ (abs_nonneg (H s Ο)) hC).mpr (hΟ s) | |
| theorem tendsto_stoppedSquareSum_L1_nnreal | |
| {Ξ© : Type*} [MeasurableSpace Ξ©] {ΞΌ : Measure Ξ©} [IsFiniteMeasure ΞΌ] | |
| {H : ββ₯0 β Ξ© β β} (hm : β t, AEStronglyMeasurable (H t) ΞΌ) | |
| (hc : βα΅ Ο βΞΌ, Continuous (fun t => H t Ο)) | |
| {C : β} (hC : 0 β€ C) (hb : βα΅ Ο βΞΌ, β s, |H s Ο| β€ C) | |
| (T t : ββ₯0) : | |
| Tendsto (fun n => eLpNorm | |
| ((fun Ο => stoppedSum (fun s => (H s.toNNReal Ο) ^ 2) T t n) - | |
| (fun Ο => β« s in (0 : β)..min (t : β) T, (H s.toNNReal Ο) ^ 2)) 1 ΞΌ) | |
| atTop (π 0) := by | |
| apply tendsto_stoppedSquareSum_L1 (fun s => hm s.toNNReal) _ hC _ T.coe_nonneg t.coe_nonneg | |
| Β· filter_upwards [hc] with Ο hΟ | |
| exact hΟ.comp (by fun_prop) | |
| Β· filter_upwards [hb] with Ο hΟ | |
| exact fun s => hΟ s.toNNReal | |
| end Problem367.RandomRiemann | |
| end | |
| end OAI | |