Download data/lean/OAI/Probability/FKMaps/ExcursionKernel.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 27.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FKMaps/ExcursionKernel.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/FKMaps/ExcursionKernel.lean
-
curl -L -o ExcursionKernel.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FKMaps/ExcursionKernel.lean
27.1 kB
| import OAI.Probability.FKMaps.SimpleWalk | |
| namespace OAI | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.Histogram | |
| variable {ΞΉ : Type*} [Fintype ΞΉ] | |
| def cube (Ξ΄ : β) (a : ΞΉ β β) : Set (ΞΉ β β) := pi univ (fun i => Ico (a i) (a i+Ξ΄)) | |
| lemma measurableSet_cube (Ξ΄ : β) (a : ΞΉ β β) : MeasurableSet (cube Ξ΄ a) := | |
| MeasurableSet.pi (Set.to_countable _) (fun _ _ => measurableSet_Ico) | |
| lemma volume_cube (Ξ΄ : β) (a : ΞΉ β β) : | |
| volume (cube Ξ΄ a)=ENNReal.ofReal Ξ΄ ^ Fintype.card ΞΉ := by | |
| rw [cube,volume_pi,Measure.pi_pi] | |
| simp | |
| lemma mem_cube_dist {Ξ΄ : β} {a x : ΞΉ β β} (hΞ΄ : 0β€Ξ΄) (hx : xβcube Ξ΄ a) : dist x aβ€Ξ΄ := by | |
| apply (dist_pi_le_iff hΞ΄).mpr | |
| intro i | |
| have hi := hx i (mem_univ i) | |
| rw [Real.dist_eq] | |
| exact abs_le.mpr β¨by linarith [hi.1],by linarith [hi.2]β© | |
| def boxLaw (Ξ΄ : β) (a : ΞΉ β β) : Measure (ΞΉ β β) := | |
| (ENNReal.ofReal Ξ΄ ^ Fintype.card ΞΉ)β»ΒΉ β’ volume.restrict (cube Ξ΄ a) | |
| lemma boxLaw_probability {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) (a : ΞΉ β β) : | |
| IsProbabilityMeasure (boxLaw Ξ΄ a) := by | |
| constructor | |
| simp only [boxLaw,Measure.smul_apply,Measure.restrict_apply_univ,smul_eq_mul,volume_cube] | |
| exact ENNReal.inv_mul_cancel (pow_ne_zero _ (ne_of_gt (ENNReal.ofReal_pos.mpr hΞ΄))) | |
| (ENNReal.pow_ne_top ENNReal.ofReal_ne_top) | |
| lemma boxLaw_dist {Ξ΄ : β} (hΞ΄ : 0β€Ξ΄) (a : ΞΉ β β) : | |
| βα΅ x βboxLaw Ξ΄ a, dist x aβ€Ξ΄ := by | |
| apply Measure.ae_smul_measure | |
| filter_upwards [ae_restrict_mem (measurableSet_cube Ξ΄ a)] with x hx | |
| exact mem_cube_dist hΞ΄ hx | |
| lemma boxLaw_withDensity (Ξ΄ : β) (a : ΞΉ β β) : | |
| boxLaw Ξ΄ a=volume.withDensity ((cube Ξ΄ a).indicator | |
| (fun _ => (ENNReal.ofReal Ξ΄ ^ Fintype.card ΞΉ)β»ΒΉ)) := by | |
| rw [withDensity_indicator (measurableSet_cube Ξ΄ a),withDensity_const] | |
| rfl | |
| end FKCRT.Histogram | |
| end | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.Histogram | |
| variable {ΞΉ Ξ© : Type*} [Fintype ΞΉ] [Fintype Ξ©] [MeasurableSpace Ξ©] | |
| [MeasurableSingletonClass Ξ©] | |
| def mixture (ΞΌ : Measure Ξ©) (Ο : Ξ© β ΞΉ β β) (Ξ΄ : β) : Measure (ΞΉ β β) := | |
| β Ο, ΞΌ {Ο} β’ boxLaw Ξ΄ (Ο Ο) | |
| lemma mixture_probability (ΞΌ : Measure Ξ©) [IsProbabilityMeasure ΞΌ] | |
| (Ο : Ξ© β ΞΉ β β) {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) : | |
| IsProbabilityMeasure (mixture ΞΌ Ο Ξ΄) := by | |
| have (Ο : Ξ©) : IsProbabilityMeasure (boxLaw Ξ΄ (Ο Ο)) := boxLaw_probability hΞ΄ (Ο Ο) | |
| constructor | |
| simp only [mixture,Measure.finsetSum_apply,Measure.smul_apply,smul_eq_mul, | |
| measure_univ,mul_one] | |
| rw [sum_measure_singleton,Finset.coe_univ,measure_univ] | |
| def density (ΞΌ : Measure Ξ©) (Ο : Ξ© β ΞΉ β β) (Ξ΄ : β) (x : ΞΉ β β) : ββ₯0β := | |
| β Ο,ΞΌ {Ο} * (cube Ξ΄ (Ο Ο)).indicator | |
| (fun _ => (ENNReal.ofReal Ξ΄ ^ Fintype.card ΞΉ)β»ΒΉ) x | |
| omit [MeasurableSingletonClass Ξ©] in | |
| lemma measurable_density (ΞΌ : Measure Ξ©) (Ο : Ξ© β ΞΉ β β) (Ξ΄ : β) : | |
| Measurable (density ΞΌ Ο Ξ΄) := by | |
| apply Finset.measurable_sum | |
| intro Ο hΟ | |
| exact measurable_const.mul (measurable_const.indicator (measurableSet_cube Ξ΄ (Ο Ο))) | |
| omit [MeasurableSingletonClass Ξ©] in | |
| lemma mixture_withDensity (ΞΌ : Measure Ξ©) (Ο : Ξ© β ΞΉ β β) (Ξ΄ : β) : | |
| mixture ΞΌ Ο Ξ΄=volume.withDensity (density ΞΌ Ο Ξ΄) := by | |
| ext s hs | |
| rw [withDensity_apply _ hs] | |
| simp only [mixture,Measure.finsetSum_apply,density] | |
| have hm (Ο : Ξ©) : Measurable (fun x : ΞΉ β β => ΞΌ {Ο} * (cube Ξ΄ (Ο Ο)).indicator | |
| (fun _ => (ENNReal.ofReal Ξ΄ ^ Fintype.card ΞΉ)β»ΒΉ) x) := | |
| measurable_const.mul (measurable_const.indicator (measurableSet_cube Ξ΄ (Ο Ο))) | |
| rw [lintegral_finsetSum _ (fun Ο _ => hm Ο)] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| rw [Measure.smul_apply,smul_eq_mul,boxLaw_withDensity, | |
| withDensity_apply _ hs,lintegral_const_mul _ | |
| (measurable_const.indicator (measurableSet_cube Ξ΄ (Ο Ο)))] | |
| omit [MeasurableSingletonClass Ξ©] in | |
| lemma integral_mixture (ΞΌ : Measure Ξ©) [IsProbabilityMeasure ΞΌ] | |
| (Ο : Ξ© β ΞΉ β β) {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) (F : BoundedContinuousFunction (ΞΉ β β) β) : | |
| (β« x,F x βmixture ΞΌ Ο Ξ΄)=β Ο,(ΞΌ {Ο}).toReal * β« x,F x βboxLaw Ξ΄ (Ο Ο) := by | |
| have (Ο : Ξ©) : IsProbabilityMeasure (boxLaw Ξ΄ (Ο Ο)) := boxLaw_probability hΞ΄ (Ο Ο) | |
| have hi (Ο : Ξ©) : Integrable F (ΞΌ {Ο} β’ boxLaw Ξ΄ (Ο Ο)) := by | |
| exact (F.integrable (boxLaw Ξ΄ (Ο Ο))).smul_measure (measure_ne_top _ _) | |
| rw [mixture,integral_finsetSum_measure (fun Ο _ => hi Ο)] | |
| simp only [integral_smul_measure,smul_eq_mul] | |
| lemma box_integral_lipschitz {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) (a : ΞΉ β β) | |
| (F : BoundedContinuousFunction (ΞΉ β β) β) {L : ββ₯0} (hF : LipschitzWith L F) : | |
| |(β« x,F x βboxLaw Ξ΄ a)-F a|β€L*Ξ΄ := by | |
| have := boxLaw_probability hΞ΄ a | |
| have hconst : (β« x,F a βboxLaw Ξ΄ a)=F a := by simp | |
| rw [β hconst,β integral_sub (F.integrable _) (integrable_const _)] | |
| apply abs_integral_le_integral_abs.trans | |
| calc | |
| (β« x,|F x-F a| βboxLaw Ξ΄ a) β€ β« x,(L:β)*Ξ΄ βboxLaw Ξ΄ a := by | |
| apply integral_mono_ae ((F.integrable _).sub (integrable_const _)).abs (integrable_const _) | |
| filter_upwards [boxLaw_dist hΞ΄.le a] with x hx | |
| exact (hF.dist_le_mul x a).trans (mul_le_mul_of_nonneg_left hx L.coe_nonneg) | |
| _ = _ := by simp | |
| lemma integral_mixture_close (ΞΌ : Measure Ξ©) [IsProbabilityMeasure ΞΌ] | |
| (Ο : Ξ© β ΞΉ β β) {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) | |
| (F : BoundedContinuousFunction (ΞΉ β β) β) {L : ββ₯0} (hF : LipschitzWith L F) : | |
| |(β« x,F x βmixture ΞΌ Ο Ξ΄)-(β« Ο,F (Ο Ο) βΞΌ)|β€L*Ξ΄ := by | |
| have hi : Integrable (fun Ο => F (Ο Ο)) ΞΌ := Integrable.of_finite | |
| rw [integral_mixture ΞΌ Ο hΞ΄ F,integral_fintype hi,β Finset.sum_sub_distrib] | |
| calc | |
| _ β€ β Ο,|(ΞΌ {Ο}).toReal * (β« x,F x βboxLaw Ξ΄ (Ο Ο)) - ΞΌ.real {Ο} β’ F (Ο Ο)| := | |
| Finset.abs_sum_le_sum_abs _ _ | |
| _ β€ β Ο,(ΞΌ {Ο}).toReal*((L:β)*Ξ΄) := by | |
| apply Finset.sum_le_sum | |
| intro Ο _ | |
| rw [smul_eq_mul,measureReal_def,β mul_sub,abs_mul,abs_of_nonneg ENNReal.toReal_nonneg] | |
| exact mul_le_mul_of_nonneg_left (box_integral_lipschitz hΞ΄ (Ο Ο) F hF) ENNReal.toReal_nonneg | |
| _ = _ := by | |
| rw [β Finset.sum_mul,β ENNReal.toReal_sum (fun _ _ => measure_ne_top _ _), | |
| sum_measure_singleton,Finset.coe_univ,measure_univ,ENNReal.toReal_one,one_mul] | |
| end FKCRT.Histogram | |
| end | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.Histogram | |
| variable {ΞΉ Ξ© : Type*} [Fintype ΞΉ] [Fintype Ξ©] [MeasurableSpace Ξ©] | |
| [MeasurableSingletonClass Ξ©] | |
| omit [Fintype ΞΉ] in | |
| lemma mem_lattice_cube {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) (a : ΞΉ β β) {x : ΞΉ β β} | |
| (hx : β i,0β€x i) : xβcube Ξ΄ (fun i => Ξ΄*(a i:β))βa=fun i => βx i/Ξ΄ββ := by | |
| constructor | |
| Β· intro h | |
| apply funext | |
| intro i | |
| have hi := h i (mem_univ i) | |
| symm | |
| apply (Nat.floor_eq_iff (div_nonneg (hx i) hΞ΄.le)).mpr | |
| constructor | |
| Β· exact (le_div_iffβ hΞ΄).mpr (by simpa only [mul_comm] using hi.1) | |
| Β· apply (div_lt_iffβ hΞ΄).mpr | |
| simpa only [add_mul,mul_add,one_mul,mul_one,mul_comm] using hi.2 | |
| Β· rintro rfl | |
| intro i _ | |
| have hfloor := (Nat.floor_eq_iff (div_nonneg (hx i) hΞ΄.le)).mp (rfl : βx i/Ξ΄ββ=βx i/Ξ΄ββ) | |
| constructor | |
| Β· simpa only [mul_comm] using (le_div_iffβ hΞ΄).mp hfloor.1 | |
| Β· simpa only [add_mul,mul_add,one_mul,mul_one,mul_comm] using (div_lt_iffβ hΞ΄).mp hfloor.2 | |
| lemma density_lattice (ΞΌ : Measure Ξ©) (a : Ξ© β ΞΉ β β) {Ξ΄ : β} (hΞ΄ : 0<Ξ΄) | |
| {x : ΞΉ β β} (hx : β i,0β€x i) : | |
| density ΞΌ (fun Ο i => Ξ΄*(a Ο i:β)) Ξ΄ x= | |
| ΞΌ {Ο | a Ο=fun i => βx i/Ξ΄ββ}*(ENNReal.ofReal Ξ΄ ^ Fintype.card ΞΉ)β»ΒΉ := by | |
| classical | |
| let s : Finset Ξ© := Finset.univ.filter (fun Ο => a Ο=fun i => βx i/Ξ΄ββ) | |
| have hset : (s : Set Ξ©)={Ο | a Ο=fun i => βx i/Ξ΄ββ} := by ext Ο; simp [s] | |
| rw [density,β hset,β sum_measure_singleton,Finset.sum_mul] | |
| simp only [s,Finset.sum_filter] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| by_cases h : a Ο=fun i => βx i/Ξ΄ββ | |
| Β· rw [ite_eq_left h,indicator_of_mem ((mem_lattice_cube hΞ΄ _ hx).mpr h)] | |
| Β· rw [ite_eq_right h,indicator_of_notMem (mt (mem_lattice_cube hΞ΄ _ hx).mp h),mul_zero] | |
| omit [MeasurableSingletonClass Ξ©] in | |
| lemma density_lattice_negative (ΞΌ : Measure Ξ©) (a : Ξ© β ΞΉ β β) {Ξ΄ : β} | |
| (hΞ΄ : 0β€Ξ΄) {x : ΞΉ β β} (hx : β i,x i<0) : | |
| density ΞΌ (fun Ο i => Ξ΄*(a Ο i:β)) Ξ΄ x=0 := by | |
| obtain β¨i,hiβ© := hx | |
| apply Finset.sum_eq_zero | |
| intro Ο _ | |
| have hn : xβcube Ξ΄ (fun i => Ξ΄*(a Ο i:β)) := by | |
| intro h | |
| have hh := (h i (mem_univ i)).1 | |
| have hz : 0β€Ξ΄*(a Ο i:β) := mul_nonneg hΞ΄ (Nat.cast_nonneg _) | |
| linarith | |
| rw [indicator_of_notMem hn,mul_zero] | |
| lemma floor_mesh_tendsto {Ξ΄ : β β β} (hΞ΄ : β n,0<Ξ΄ n) | |
| (hlim : Tendsto Ξ΄ atTop (π 0)) {x : β} (hx : 0β€x) : | |
| Tendsto (fun n => Ξ΄ n*(βx/Ξ΄ nββ:β)) atTop (π x) := by | |
| have hl (n : β) := Nat.floor_le (div_nonneg hx (hΞ΄ n).le) | |
| have hu (n : β) := Nat.lt_floor_add_one (x/Ξ΄ n) | |
| have hlow : Tendsto (fun n => x-Ξ΄ n) atTop (π x) := by | |
| simpa only [sub_zero] using tendsto_const_nhds.sub hlim | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le hlow tendsto_const_nhds | |
| Β· intro n | |
| have h := (div_lt_iffβ (hΞ΄ n)).mp (hu n) | |
| nlinarith | |
| Β· intro n | |
| simpa only [mul_comm] using (le_div_iffβ (hΞ΄ n)).mp (hl n) | |
| end FKCRT.Histogram | |
| end | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.SimpleWalk | |
| attribute [local instance] Classical.propDecidable | |
| def located : List (βΓβ) β List (βΓβ) | |
| | [] => [] | |
| | x::xs => x::(located xs).map (fun y => (x.1+y.1,y.2)) | |
| def observed {N : β} (a : β) (xs : List (βΓβ)) (d : Path N) : Prop := | |
| β xβlocated xs,(a:β€)+pathSum d x.1=x.2 | |
| lemma tracePoints_observed (a R : β) (xs : List (βΓβ)) (d : Path (traceSize R xs)) : | |
| tracePoints a R xs dβobserved a xs d := by | |
| induction xs generalizing a with | |
| | nil => simp [tracePoints,observed,located] | |
| | cons x xs ih => | |
| obtain β¨β¨d,eβ©,rflβ© := (splitPathAt x.1 (traceSize R xs)).symm.surjective d | |
| simp only [tracePoints,Equiv.apply_symm_apply,ih,observed,located,List.mem_cons, | |
| List.mem_map,forall_eq_or_imp,forall_exists_index,and_imp,forall_apply_eq_imp_iffβ] | |
| change ((a:β€)+pathSum d x.1=x.2 β§ | |
| β yβlocated xs,(x.2:β€)+pathSum e y.1=y.2)β | |
| ((a:β€)+pathSum (Fin.append d e) x.1=x.2 β§ | |
| β yβlocated xs,(a:β€)+pathSum (Fin.append d e) (x.1+y.1)=y.2) | |
| simp only [pathSum_append_left d e le_rfl,pathSum_append_right] | |
| constructor <;> rintro β¨hx,hxsβ© <;> refine β¨hx,?_β© <;> intro y hy | |
| Β· have h := hxs y hy; linarith | |
| Β· have h := hxs y hy; linarith | |
| lemma pathMass_firstHit_observed (a R : β) (xs : List (βΓβ)) : | |
| pathMass (traceSize R xs) (fun d => firstHit a d β§ observed a xs d)= | |
| traceKilledWeight a R xs := by | |
| rw [β pathMass_traceExcursion] | |
| apply pathMass_congr | |
| intro d | |
| rw [traceExcursion_iff,tracePoints_observed] | |
| lemma traceSize_eq_sum (R : β) (xs : List (βΓβ)) : | |
| traceSize R xs=(xs.map Prod.fst).sum+R := by | |
| induction xs with | |
| | nil => simp [traceSize] | |
| | cons x xs ih => simp [traceSize,ih,Nat.add_assoc] | |
| lemma pathSum_cast {N M : β} (h : N=M) (d : Path N) (k : β) : | |
| pathSum (fun i : Fin M => d (Fin.cast h.symm i)) k=pathSum d k := by | |
| subst M | |
| rfl | |
| lemma pathMass_cast {N M : β} (h : N=M) (P : Path M β Prop) : | |
| pathMass N (fun d => P (fun i : Fin M => d (Fin.cast h.symm i)))=pathMass M P := by | |
| subst M | |
| rfl | |
| end FKCRT.SimpleWalk | |
| end | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.SimpleWalk | |
| /-- Even grid time immediately below t, for the odd duration 2n+1. -/ | |
| def evenGrid (n : β) (t : β) : β := 2*β((2*n+1:β):β)*t/2ββ | |
| lemma even_evenGrid (n : β) (t : β) : Even (evenGrid n t) := even_two_mul _ | |
| lemma evenGrid_mono (n : β) {s t : β} (h : sβ€t) : evenGrid n sβ€evenGrid n t := by | |
| unfold evenGrid | |
| exact Nat.mul_le_mul_left _ (Nat.floor_mono (div_le_div_of_nonneg_right | |
| (mul_le_mul_of_nonneg_left h (Nat.cast_nonneg _)) (by norm_num))) | |
| @[simp] lemma evenGrid_zero (n : β) : evenGrid n 0=0 := by simp [evenGrid] | |
| lemma evenGrid_le (n : β) {t : β} (ht : tβ€1) : evenGrid n tβ€2*n := by | |
| have h : ((2*n+1:β):β)*t/2<(n:β)+1 := by | |
| have he := mul_le_mul_of_nonneg_left ht (Nat.cast_nonneg (2*n+1) : (0:β)β€(2*n+1:β)) | |
| push_cast at he β’ | |
| linarith | |
| have hh : β((2*n+1:β):β)*t/2βββ€n := (Nat.floor_lt' (by omega : n+1β 0)).mpr | |
| (by exact_mod_cast h) |> Nat.le_of_lt_succ | |
| exact Nat.mul_le_mul_left 2 hh | |
| lemma evenGrid_error (n : β) {t : β} (ht : 0β€t) : | |
| 0β€((2*n+1:β):β)*t-(evenGrid n t:β) β§ | |
| ((2*n+1:β):β)*t-(evenGrid n t:β)<2 := by | |
| have hnonneg : 0β€((2*n+1:β):β)*t/2 := by positivity | |
| have hl := Nat.floor_le hnonneg | |
| have hu := Nat.lt_floor_add_one (((2*n+1:β):β)*t/2) | |
| unfold evenGrid | |
| push_cast at hl hu β’ | |
| constructor <;> linarith | |
| lemma evenGrid_ratio (t : β) (ht : 0β€t) : | |
| Tendsto (fun n => (evenGrid n t:β)/((2*n+1:β):β)) atTop (π t) := by | |
| have hN : Tendsto (fun n : β => ((2*n+1:β):β)) atTop atTop := | |
| tendsto_natCast_atTop_atTop.comp (tendsto_atTop_mono (fun n => by show nβ€2*n+1; omega) tendsto_id) | |
| have hzero : Tendsto (fun n => (2:β)/((2*n+1:β):β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop hN | |
| have hl : Tendsto (fun n => t-2/((2*n+1:β):β)) atTop (π t) := by | |
| simpa using tendsto_const_nhds.sub hzero | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le hl tendsto_const_nhds | |
| Β· intro n | |
| have hpos : 0<((2*n+1:β):β) := by positivity | |
| have he := (evenGrid_error n ht).2 | |
| apply (le_div_iffβ hpos).mpr | |
| rw [sub_mul,div_mul_cancelβ _ hpos.ne'] | |
| linarith | |
| Β· intro n | |
| exact (div_le_iffβ (by positivity : 0<((2*n+1:β):β))).mpr | |
| (by have h := (evenGrid_error n ht).1; linarith) | |
| /-- Successive durations at a deterministic increasing list of observation times. -/ | |
| def gridDurations {m : β} (u : Fin (m+1) β unitInterval) (n : β) (i : Fin m) : β := | |
| evenGrid n (u i.succ)-evenGrid n (u i.castSucc) | |
| def gridRemainder {m : β} (u : Fin (m+1) β unitInterval) (n : β) : β := | |
| 2*n-evenGrid n (u (Fin.last m)) | |
| lemma gridDurations_even {m : β} (u : Fin (m+1) β unitInterval) (hu : Monotone u) | |
| (n : β) (i : Fin m) : Even (gridDurations u n i) := by | |
| exact (Nat.even_sub (evenGrid_mono n (hu i.castSucc_lt_succ.le))).mpr | |
| (iff_of_true (even_evenGrid n _) (even_evenGrid n _)) | |
| lemma gridRemainder_even {m : β} (u : Fin (m+1) β unitInterval) (n : β) : | |
| Even (gridRemainder u n) := | |
| (Nat.even_sub (evenGrid_le n (u (Fin.last m)).property.2)).mpr | |
| (iff_of_true (even_two_mul n) (even_evenGrid n _)) | |
| lemma gridDurations_ratio {m : β} (u : Fin (m+1) β unitInterval) (hu : Monotone u) | |
| (i : Fin m) : | |
| Tendsto (fun n => (gridDurations u n i:β)/((2*n+1:β):β)) atTop | |
| (π ((u i.succ:β)-(u i.castSucc:β))) := by | |
| have h := (evenGrid_ratio (u i.succ) (u i.succ).property.1).sub | |
| (evenGrid_ratio (u i.castSucc) (u i.castSucc).property.1) | |
| apply h.congr' | |
| exact Filter.Eventually.of_forall (fun n => by | |
| dsimp only [gridDurations] | |
| rw [Nat.cast_sub (evenGrid_mono n (hu i.castSucc_lt_succ.le)),sub_div]) | |
| end FKCRT.SimpleWalk | |
| end | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.SimpleWalk | |
| open TreeCoding | |
| /-- The heat density for one-dimensional standard Brownian motion. -/ | |
| def heat (t x : β) : β := Real.exp (-x^2/(2*t))/Real.sqrt (2*Real.pi*t) | |
| lemma heat_pos {t : β} (ht : 0<t) (x : β) : 0<heat t x := by | |
| exact div_pos (Real.exp_pos _) (Real.sqrt_pos.mpr (by positivity)) | |
| lemma heat_continuousOn : ContinuousOn (fun tx : βΓβ => heat tx.1 tx.2) {tx | 0<tx.1} := by | |
| intro tx htx | |
| change 0<tx.1 at htx | |
| unfold heat | |
| have h1 : 2*tx.1β 0 := by positivity | |
| have h2 : Real.sqrt (2*Real.pi*tx.1)β 0 := by positivity | |
| apply ContinuousAt.continuousWithinAt | |
| fun_prop (disch := assumption) | |
| /-- Full span-two uniform local limit, now for the explicitly reflected simple kernel. -/ | |
| theorem kernel_uniform_local_limit : | |
| β E : β β β, (β n,0β€E n) β§ Tendsto E atTop (π 0) β§ | |
| β (N : β), 0<N β β z : β€, Even ((N:β€)+z) β | |
| |Real.sqrt N*kernel N z-(Real.sqrt (2*Real.pi)/Real.pi)* | |
| Real.exp (-((z:β)/Real.sqrt N)^2/2)|β€E N := by | |
| obtain β¨E,hE,hEt,hβ© := binaryOffspring.uniform_local_limit | |
| have hsub : Tendsto (fun n : β => n-1) atTop atTop := by | |
| apply tendsto_atTop.mpr | |
| intro b | |
| exact eventually_atTop.mpr β¨b+1,fun n hn => by omegaβ© | |
| refine β¨fun N => E (N-1),fun N => hE _,hEt.comp hsub,?_β© | |
| intro N hN z hz | |
| have hn : N-1+1=N := by omega | |
| have hnR : ((N-1:β):β)+1=(N:β) := by exact_mod_cast hn | |
| simpa only [hn,hnR,binary_kernel,binaryOffspring_sigma,one_mul] using h (N-1) z (by simpa only [hn] using hz) | |
| lemma kernel_local_limit {N : β β β} {z : β β β€} {x : β} | |
| (hN : Tendsto N atTop atTop) | |
| (hz : βαΆ n in atTop,Even ((N n:β€)+z n)) | |
| (hx : Tendsto (fun n => (z n:β)/Real.sqrt (N n:β)) atTop (π x)) : | |
| Tendsto (fun n => Real.sqrt (N n:β)*kernel (N n) (z n)) atTop | |
| (π ((Real.sqrt (2*Real.pi)/Real.pi)*Real.exp (-x^2/2))) := by | |
| obtain β¨E,_hE,hEt,hEβ© := kernel_uniform_local_limit | |
| have hmodel := ((Real.continuous_exp.tendsto (-x^2/2)).comp ((hx.pow 2).neg.div_const 2)).const_mul | |
| (Real.sqrt (2*Real.pi)/Real.pi) | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le' | |
| (show Tendsto (fun n => (Real.sqrt (2*Real.pi)/Real.pi)* | |
| Real.exp (-((z n:β)/Real.sqrt (N n:β))^2/2)-E (N n)) atTop _ by | |
| simpa using hmodel.sub (hEt.comp hN)) | |
| (show Tendsto (fun n => (Real.sqrt (2*Real.pi)/Real.pi)* | |
| Real.exp (-((z n:β)/Real.sqrt (N n:β))^2/2)+E (N n)) atTop _ by | |
| simpa using hmodel.add (hEt.comp hN)) | |
| Β· filter_upwards [hz,hN.eventually (eventually_gt_atTop 0)] with n hn hnn | |
| have hh := (abs_le.mp (hE (N n) hnn (z n) hn)).1 | |
| linarith | |
| Β· filter_upwards [hz,hN.eventually (eventually_gt_atTop 0)] with n hn hnn | |
| have hh := (abs_le.mp (hE (N n) hnn (z n) hn)).2 | |
| linarith | |
| lemma sqrt_ratio_tendsto {N T : β β β} {t : β} | |
| (hr : Tendsto (fun n => (N n:β)/(T n:β)) atTop (π t)) : | |
| Tendsto (fun n => Real.sqrt (N n:β)/Real.sqrt (T n:β)) atTop (π (Real.sqrt t)) := by | |
| simpa only [Function.comp_def,Real.sqrt_div (Nat.cast_nonneg _)] using Real.continuous_sqrt.tendsto t |>.comp hr | |
| /-- Kernel limit at arbitrary macroscopic times and spatial lattice sites. -/ | |
| theorem kernel_scaled_limit {N T : β β β} {z : β β β€} {t x : β} | |
| (ht : 0<t) (hN : Tendsto N atTop atTop) (hT : Tendsto T atTop atTop) | |
| (hr : Tendsto (fun n => (N n:β)/(T n:β)) atTop (π t)) | |
| (hz : βαΆ n in atTop,Even ((N n:β€)+z n)) | |
| (hx : Tendsto (fun n => (z n:β)/Real.sqrt (T n:β)) atTop (π x)) : | |
| Tendsto (fun n => Real.sqrt (T n:β)*kernel (N n) (z n)) atTop (π (2*heat t x)) := by | |
| have hs := sqrt_ratio_tendsto hr | |
| have ht' : 0<Real.sqrt t := Real.sqrt_pos.mpr ht | |
| have hz' : Tendsto (fun n => (z n:β)/Real.sqrt (N n:β)) atTop (π (x/Real.sqrt t)) := by | |
| apply (hx.div hs (ne_of_gt ht')).congr' | |
| filter_upwards [hT.eventually (eventually_gt_atTop 0),hN.eventually (eventually_gt_atTop 0)] with n hn hnn | |
| have htp : Real.sqrt (T n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hn)) | |
| have hnp : Real.sqrt (N n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hnn)) | |
| dsimp only [Pi.div_apply] | |
| field_simp | |
| have hc := (kernel_local_limit hN hz hz').div hs (ne_of_gt ht') | |
| have hm : ((Real.sqrt (2*Real.pi)/Real.pi)*Real.exp (-(x/Real.sqrt t)^2/2))/Real.sqrt t=2*heat t x := by | |
| rw [heat,div_pow,Real.sq_sqrt ht.le,Real.sqrt_mul (by positivity : 0β€2*Real.pi)] | |
| have hpi : Real.sqrt (2*Real.pi)^2=2*Real.pi := Real.sq_sqrt (by positivity) | |
| have hpis : Real.sqrt (2*Real.pi)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by positivity)) | |
| have harg : -(x^2/t)/2= -x^2/(2*t) := by ring | |
| rw [harg] | |
| field_simp | |
| nlinarith | |
| rw [hm] at hc | |
| apply hc.congr' | |
| filter_upwards [hN.eventually (eventually_gt_atTop 0),hT.eventually (eventually_gt_atTop 0)] with n hn hnt | |
| have hnp : Real.sqrt (N n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hn)) | |
| have htp : Real.sqrt (T n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hnt)) | |
| dsimp only [Pi.div_apply] | |
| field_simp | |
| end FKCRT.SimpleWalk | |
| end | |
| noncomputable section | |
| open Set Filter MeasureTheory ProbabilityTheory | |
| open scoped Topology BigOperators ENNReal NNReal | |
| namespace FKCRT.SimpleWalk | |
| lemma cast_div_sqrt_tendsto_zero {T : β β β} (hT : Tendsto T atTop atTop) (c : β) : | |
| Tendsto (fun n => c/Real.sqrt (T n:β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop (Real.tendsto_sqrt_atTop.comp (tendsto_natCast_atTop_atTop.comp hT)) | |
| /-- The killed heat kernel obtained from the proved discrete reflection principle. -/ | |
| def killedHeat (t x y : β) : β := heat t (y-x)-heat t (y+x) | |
| lemma killed_scaled_limit {N T a b : β β β} {t x y : β} | |
| (ht : 0<t) (hN : Tendsto N atTop atTop) (hT : Tendsto T atTop atTop) | |
| (hr : Tendsto (fun n => (N n:β)/(T n:β)) atTop (π t)) | |
| (hz : βαΆ n in atTop,Even ((N n:β€)+(b n:β€)-a n)) | |
| (hx : Tendsto (fun n => (a n:β)/Real.sqrt (T n:β)) atTop (π x)) | |
| (hy : Tendsto (fun n => (b n:β)/Real.sqrt (T n:β)) atTop (π y)) : | |
| Tendsto (fun n => Real.sqrt (T n:β)*killed (N n) (a n) (b n)) atTop | |
| (π (2*killedHeat t x y)) := by | |
| have hm : Tendsto (fun n => (((b n:β€)-a n:β€):β)/Real.sqrt (T n:β)) atTop (π (y-x)) := by | |
| simpa only [Int.cast_sub,Int.cast_natCast,sub_div] using hy.sub hx | |
| have hp : Tendsto (fun n => (((b n:β€)+a n+2:β€):β)/Real.sqrt (T n:β)) atTop (π (y+x)) := by | |
| simpa only [Int.cast_add,Int.cast_ofNat,Int.cast_natCast,add_div,add_zero] using | |
| (hy.add hx).add (cast_div_sqrt_tendsto_zero hT 2) | |
| have hz1 : βαΆ n in atTop, Even ((N n:β€)+((b n:β€)-a n)) := by | |
| filter_upwards [hz] with n hn; convert hn using 1; ring | |
| have hz2 : βαΆ n in atTop, Even ((N n:β€)+((b n:β€)+a n+2)) := by | |
| filter_upwards [hz] with n hn | |
| have he : (N n:β€)+((b n:β€)+a n+2)=((N n:β€)+b n-a n)+2*((a n:β€)+1) := by ring | |
| rw [he] | |
| exact hn.add (even_two_mul ((a n:β€)+1)) | |
| have h := (kernel_scaled_limit ht hN hT hr hz1 hm).sub (kernel_scaled_limit ht hN hT hr hz2 hp) | |
| simpa only [killed_reflection,mul_sub,killedHeat] using h | |
| lemma sqrt_div_nat_tendsto_zero {T : β β β} (hT : Tendsto T atTop atTop) : | |
| Tendsto (fun n => Real.sqrt (T n:β)/(T n:β)) atTop (π 0) := by | |
| apply (cast_div_sqrt_tendsto_zero hT 1).congr' | |
| filter_upwards [hT.eventually (eventually_gt_atTop 0)] with n hn | |
| have htp : 0<(T n:β) := by exact_mod_cast hn | |
| have hsp : Real.sqrt (T n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr htp) | |
| have hs := Real.sq_sqrt htp.le | |
| field_simp | |
| nlinarith | |
| lemma entrance_scaled_limit {N T b : β β β} {t y : β} | |
| (ht : 0<t) (hN : Tendsto N atTop atTop) (hT : Tendsto T atTop atTop) | |
| (hr : Tendsto (fun n => (N n:β)/(T n:β)) atTop (π t)) | |
| (hz : βαΆ n in atTop,Even ((N n:β€)+b n)) | |
| (hy : Tendsto (fun n => (b n:β)/Real.sqrt (T n:β)) atTop (π y)) : | |
| Tendsto (fun n => (T n:β)*killed (N n) 0 (b n)) atTop (π (4*y/t*heat t y)) := by | |
| have hsmall : Tendsto (fun n => (b n:β)/(T n:β)) atTop (π 0) := by | |
| have h := hy.mul (sqrt_div_nat_tendsto_zero hT) | |
| simp only [mul_zero] at h | |
| apply h.congr' | |
| filter_upwards [hT.eventually (eventually_gt_atTop 0)] with n hn | |
| have hs : Real.sqrt (T n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hn)) | |
| field_simp | |
| have hnum : Tendsto (fun n => 2*((b n:β)+1)/Real.sqrt (T n:β)) atTop (π (2*y)) := by | |
| simpa only [add_zero,mul_div_assoc,add_div] using (hy.add (cast_div_sqrt_tendsto_zero hT 1)).const_mul 2 | |
| have hden : Tendsto (fun n => ((N n:β)+b n+2)/(T n:β)) atTop (π t) := by | |
| simpa only [add_div,add_zero] using (hr.add hsmall).add | |
| (tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop.comp hT) : | |
| Tendsto (fun n => (2:β)/(T n:β)) atTop (π 0)) | |
| have hk := kernel_scaled_limit ht hN hT hr hz (by simpa only [Int.cast_natCast] using hy) | |
| have h := (hnum.div hden (ne_of_gt ht)).mul hk | |
| have hi : 2*y/t*(2*heat t y)=4*y/t*heat t y := by ring | |
| rw [hi] at h | |
| apply h.congr' | |
| filter_upwards [hT.eventually (eventually_gt_atTop 0)] with n hn | |
| have htp : (T n:β)β 0 := by exact_mod_cast (Nat.ne_of_gt hn) | |
| have hs : Real.sqrt (T n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hn)) | |
| have hd : (N n:β)+b n+2β 0 := by positivity | |
| rw [killed_entrance] | |
| dsimp only [Pi.mul_apply,Pi.div_apply] | |
| field_simp | |
| /-- Terminal first-hitting density at macroscopic time. -/ | |
| lemma firstHit_scaled_limit {N T b : β β β} {t y : β} | |
| (ht : 0<t) (hN : Tendsto N atTop atTop) (hT : Tendsto T atTop atTop) | |
| (hr : Tendsto (fun n => ((N n:β)+1)/(T n:β)) atTop (π t)) | |
| (hz : βαΆ n in atTop,Even (((N n+1:β):β€)+((b n:β€)+1))) | |
| (hy : Tendsto (fun n => (b n:β)/Real.sqrt (T n:β)) atTop (π y)) : | |
| Tendsto (fun n => (T n:β)*pathMass (N n+1) (firstHit (b n))) atTop | |
| (π (2*y/t*heat t y)) := by | |
| have hN' : Tendsto (fun n => N n+1) atTop atTop := tendsto_atTop_mono (fun n => by omega) hN | |
| have hy' : Tendsto (fun n => (((b n:β€)+1:β€):β)/Real.sqrt (T n:β)) atTop (π y) := by | |
| simpa only [Int.cast_add,Int.cast_one,Int.cast_natCast,add_div,add_zero] using | |
| hy.add (cast_div_sqrt_tendsto_zero hT 1) | |
| have hk := kernel_scaled_limit ht hN' hT (by simpa only [Nat.cast_add,Nat.cast_one] using hr) hz hy' | |
| have hnum : Tendsto (fun n => ((b n:β)+1)/Real.sqrt (T n:β)) atTop (π y) := by | |
| simpa only [Int.cast_add,Int.cast_one,Int.cast_natCast] using hy' | |
| have h := (hnum.div hr (ne_of_gt ht)).mul hk | |
| have hi : y/t*(2*heat t y)=2*y/t*heat t y := by ring | |
| rw [hi] at h | |
| apply h.congr' | |
| filter_upwards [hT.eventually (eventually_gt_atTop 0)] with n hn | |
| have htp : (T n:β)β 0 := by exact_mod_cast (Nat.ne_of_gt hn) | |
| have hs : Real.sqrt (T n:β)β 0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hn)) | |
| have hd : (N n:β)+1β 0 := by positivity | |
| rw [firstHit_formula] | |
| dsimp only [Pi.mul_apply,Pi.div_apply] | |
| field_simp | |
| end FKCRT.SimpleWalk | |
| end | |
| end OAI | |