Download data/lean/OAI/Probability/LogConcave/Dynamics/TriangularEquiv.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Dynamics/TriangularEquiv.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Dynamics/TriangularEquiv.lean
-
curl -L -o TriangularEquiv.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Dynamics/TriangularEquiv.lean
14.3 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.Model | |
| import OAI.Probability.LogConcave.Dynamics.SpaceTimeForward | |
| import OAI.Probability.LogConcave.Sampling.FDerivTimePartial | |
| namespace OAI | |
| section | |
| section | |
| noncomputable section | |
| open MeasureTheory Filter | |
| open scoped ENNReal NNReal Topology | |
| section UpperProof | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped ENNReal NNReal RealInnerProductSpace Topology | |
| open Function MeasureTheory Set Filter | |
| open scoped Topology NNReal | |
| namespace LogConcaveSampling.GlobalODE | |
| open Set Function Filter | |
| open scoped Topology | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] | |
| def triangularEquiv (v : E) (J : E βL[β] E) : (β Γ E) βL[β] (β Γ E) where | |
| toLinearEquiv := | |
| { toFun := fun p => (p.1,p.1 β’v+J p.2) | |
| invFun := fun p => (p.1,J.symm (p.2-p.1 β’v)) | |
| left_inv := fun p => by simp | |
| right_inv := fun p => by simp | |
| map_add' := fun p q => by simp [add_smul]; abel | |
| map_smul' := fun c p => by simp [smul_add,smul_smul] } | |
| continuous_toFun := continuous_fst.prodMk | |
| ((continuous_fst.smul continuous_const).add (J.continuous.comp continuous_snd)) | |
| continuous_invFun := continuous_fst.prodMk | |
| (J.symm.continuous.comp (continuous_snd.sub (continuous_fst.smul continuous_const))) | |
| variable [CompleteSpace E] [ProperSpace E] | |
| {a b : β} (hab : aβ€b) {f : β β E β E} (hc : Continuous (uncurry f)) | |
| {K : ββ₯0} (hL : β tβIcc a b,LipschitzWith K (f t)) | |
| {D : β β E β E βL[β] E} (hD : Continuous (uncurry D)) | |
| (hf : β t z,HasFDerivAt (f t) (D t z) z) | |
| omit [ProperSpace E] in | |
| lemma spaceTimeForward_time_deriv (p : β Γ E) (hp : p.1βIoo a b) : | |
| HasDerivAt (fun t => (spaceTimeForward hab hc hL (t,p.2)).2) | |
| (f p.1 (spaceTimeForward hab hc hL p).2) p.1 := by | |
| have hpi : p.1βIcc a b := β¨hp.1.le,hp.2.leβ© | |
| have hh := (flow_deriv hL hc β¨a,le_rfl,habβ© p.2 p.1 hpi).hasDerivAt | |
| (Icc_mem_nhds hp.1 hp.2) | |
| have he : (spaceTimeForward hab hc hL p).2=flow hL hc β¨a,le_rfl,habβ© p.2 p.1 := by | |
| simp [spaceTimeForward,projIcc_of_mem _ hpi] | |
| rw [he] | |
| apply hh.congr_of_eventuallyEq | |
| filter_upwards [Icc_mem_nhds hp.1 hp.2] with t ht | |
| simp [spaceTimeForward,projIcc_of_mem _ ht] | |
| theorem spaceTimeForward_hasFDerivAt (p : β Γ E) (hp : p.1βIoo a b) : | |
| HasFDerivAt (spaceTimeForward hab hc hL) | |
| (triangularEquiv (f p.1 (spaceTimeForward hab hc hL p).2) | |
| (fundamentalEquiv (flowSpatialCoefficient_continuous hab hc hL hD p.2) | |
| (flowSpatialCoefficient_bound hab hc hL hf p.2) β¨a,le_rfl,habβ© | |
| β¨p.1,hp.1.le,hp.2.leβ©) : (β Γ E) βL[β] (β Γ E)) p := by | |
| let J := flowLinearization hab hc hL hD hf p.2 p.1 | |
| have hsp : HasFDerivAt (fun z => (spaceTimeForward hab hc hL (p.1,z)).2) J p.2 := by | |
| simpa [spaceTimeForward,projIcc_of_mem _ β¨hp.1.le,hp.2.leβ©] using | |
| flow_hasFDerivAt_left hab hc hL hD hf p.2 β¨p.1,hp.1.le,hp.2.leβ© | |
| have hg : Continuous (fun q : β Γ E => f q.1 (spaceTimeForward hab hc hL q).2) := | |
| hc.comp (continuous_fst.prodMk (spaceTimeForward_continuous hab hc hL).snd) | |
| have hh := LogConcaveSampling.hasFDerivAt_of_time_partial | |
| (f:=fun t z => (spaceTimeForward hab hc hL (t,z)).2) | |
| (g:=fun t z => f t (spaceTimeForward hab hc hL (t,z)).2) | |
| (isOpen_Ioo.prod isOpen_univ) (show pβIoo a b ΓΛ’ (univ:Set E) from β¨hp,mem_univ _β©) | |
| hg.continuousAt (fun q hq => spaceTimeForward_time_deriv hab hc hL q hq.1) hsp | |
| convert! hasFDerivAt_fst.prodMk hh using 1 | |
| include hD hf in | |
| theorem spaceTimeBackward_differentiableAt (p : β Γ E) (hp : p.1βIoo a b) : | |
| DifferentiableAt β (spaceTimeBackward hab hc hL) p := by | |
| have hh := spaceTimeForward_hasFDerivAt hab hc hL hD hf | |
| (spaceTimeBackward hab hc hL p) hp | |
| exact (hh.of_local_left_inverse (spaceTimeBackward_continuous hab hc hL).continuousAt | |
| (Filter.Eventually.of_forall (spaceTime_right_inverse hab hc hL))).differentiableAt | |
| end LogConcaveSampling.GlobalODE | |
| namespace LogConcaveSampling.GlobalODE | |
| open Set Function Filter | |
| open scoped Topology | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E] | |
| {a b : β} (hab : aβ€b) {f : β β E β E} (hc : Continuous (uncurry f)) | |
| {K : ββ₯0} (hL : β tβIcc a b,LipschitzWith K (f t)) | |
| def backwardTest (T : Icc a b) (Ο : E β β) (p : β Γ E) : β := | |
| Ο (flow hL hc β¨a,le_rfl,habβ© (spaceTimeBackward hab hc hL p).2 T) | |
| lemma backwardTest_eq (T : Icc a b) (Ο : E β β) (p : β Γ E) : | |
| backwardTest hab hc hL T Ο p=Ο (flow hL hc (projIcc a b hab p.1) p.2 T) := by | |
| unfold backwardTest spaceTimeBackward | |
| rw [flow_cocycle hL hc (projIcc a b hab p.1) β¨a,le_rfl,habβ© T] | |
| lemma backwardTest_continuous (T : Icc a b) {Ο : E β β} (hΟ : Continuous Ο) : | |
| Continuous (backwardTest hab hc hL T Ο) := | |
| hΟ.comp ((flow_lipschitz hL hc β¨a,le_rfl,habβ© T).continuous.comp | |
| (spaceTimeBackward_continuous hab hc hL).snd) | |
| lemma backwardTest_lipschitz (T : Icc a b) {Ο : E β β} {L : ββ₯0} | |
| (hΟ : LipschitzWith L Ο) (t : β) : | |
| LipschitzWith (L*β¨Real.exp ((K:β)*(b-a)),(Real.exp_pos _).leβ©) | |
| (fun z => backwardTest hab hc hL T Ο (t,z)) := by | |
| simp only [backwardTest_eq] | |
| apply hΟ.comp | |
| apply (flow_lipschitz hL hc (projIcc a b hab t) T).weaken | |
| change Real.exp _β€Real.exp _ | |
| apply Real.exp_le_exp.mpr | |
| apply mul_le_mul_of_nonneg_left _ K.coe_nonneg | |
| rw [abs_le] | |
| constructor <;> linarith [T.2.1,T.2.2,(projIcc a b hab t).2.1,(projIcc a b hab t).2.2] | |
| variable [ProperSpace E] {D : β β E β E βL[β] E} (hD : Continuous (uncurry D)) | |
| (hf : β t z,HasFDerivAt (f t) (D t z) z) | |
| include hD hf in | |
| lemma backwardTest_differentiableAt (T : Icc a b) {Ο : E β β} | |
| (hΟ : Differentiable β Ο) (p : β Γ E) (hp : p.1βIoo a b) : | |
| DifferentiableAt β (backwardTest hab hc hL T Ο) p := | |
| (hΟ _).comp p (((flow_contDiff_one_left hab hc hL hD hf T).differentiable (by norm_num) _).comp p | |
| (spaceTimeBackward_differentiableAt hab hc hL hD hf p hp).snd) | |
| include hD hf in | |
| theorem backwardTest_material_zero (T : Icc a b) {Ο : E β β} | |
| (hΟ : Differentiable β Ο) (p : β Γ E) (hp : p.1βIoo a b) : | |
| fderiv β (backwardTest hab hc hL T Ο) p (1,f p.1 p.2)=0 := by | |
| let B := spaceTimeBackward hab hc hL | |
| let G := fun z => Ο (flow hL hc β¨a,le_rfl,habβ© z T) | |
| have hG : Differentiable β G := hΟ.comp | |
| ((flow_contDiff_one_left hab hc hL hD hf T).differentiable (by norm_num)) | |
| have hv : f (B p).1 (spaceTimeForward hab hc hL (B p)).2=f p.1 p.2 := by | |
| rw [spaceTime_right_inverse hab hc hL p] | |
| rfl | |
| have hB := (spaceTimeForward_hasFDerivAt hab hc hL hD hf (B p) hp).of_local_left_inverse | |
| (spaceTimeBackward_continuous hab hc hL).continuousAt | |
| (Filter.Eventually.of_forall (spaceTime_right_inverse hab hc hL)) | |
| have hcomp := (hG (B p).2).hasFDerivAt.comp p hB.snd | |
| change (fderiv β (G β fun x => (spaceTimeBackward hab hc hL x).2) p) (1,f p.1 p.2)=0 | |
| rw [hcomp.fderiv] | |
| change (fderiv β G (B p).2) _=0 | |
| have he : (((triangularEquiv (f (B p).1 (spaceTimeForward hab hc hL (B p)).2) | |
| (fundamentalEquiv (flowSpatialCoefficient_continuous hab hc hL hD (B p).2) | |
| (flowSpatialCoefficient_bound hab hc hL hf (B p).2) β¨a,le_rfl,habβ© | |
| β¨(B p).1,hp.1.le,hp.2.leβ©)).symm : (β Γ E) βL[β] (β Γ E)) (1,f p.1 p.2)).2=0 := by | |
| change (fundamentalEquiv _ _ _ _).symm (f p.1 p.2-1 β’ _)=0 | |
| rw [hv,one_smul,sub_self,map_zero] | |
| convert! (congrArg (fderiv β G (B p).2) he).trans (map_zero _) using 1 | |
| end LogConcaveSampling.GlobalODE | |
| namespace LogConcaveSampling.GlobalODE | |
| open Set Function Filter | |
| open scoped Topology | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E] | |
| [ProperSpace E] {a b : β} (hab : aβ€b) {f : β β E β E} | |
| (hc : Continuous (uncurry f)) {K : ββ₯0} (hL : β tβIcc a b,LipschitzWith K (f t)) | |
| {D : β β E β E βL[β] E} (hD : Continuous (uncurry D)) | |
| (hf : β t z,HasFDerivAt (f t) (D t z) z) | |
| include hD hf in | |
| theorem backwardTest_chain (T : Icc a b) {Ο : E β β} | |
| (hΟ : Differentiable β Ο) {Ξ³ : β β E} {Ξ³' : E} {t : β} | |
| (ht : tβIoo a b) (hΞ³ : HasDerivAt Ξ³ Ξ³' t) : | |
| HasDerivAt (fun s => backwardTest hab hc hL T Ο (s,Ξ³ s)) | |
| (fderiv β (fun z => backwardTest hab hc hL T Ο (t,z)) (Ξ³ t) (Ξ³'-f t (Ξ³ t))) t := by | |
| let A := fderiv β (backwardTest hab hc hL T Ο) (t,Ξ³ t) | |
| have hd := (backwardTest_differentiableAt hab hc hL hD hf T hΟ (t,Ξ³ t) ht).hasFDerivAt | |
| have hsp := hd.comp (Ξ³ t) ((hasFDerivAt_const (π:=β) t (Ξ³ t)).prodMk (hasFDerivAt_id _)) | |
| have hchain := hd.comp_hasDerivAt t ((hasDerivAt_id t).prodMk hΞ³) | |
| have hzero : A (1,f t (Ξ³ t))=0 := backwardTest_material_zero hab hc hL hD hf T hΟ _ ht | |
| have he : A (1,Ξ³')=A (0,Ξ³'-f t (Ξ³ t)) := by | |
| have hp : ((1:β),Ξ³')=(1,f t (Ξ³ t))+(0,Ξ³'-f t (Ξ³ t)) := by ext <;> simp | |
| rw [hp,map_add,hzero,zero_add] | |
| convert! hchain using 1 | |
| change (fderiv β (backwardTest hab hc hL T Ο β Prod.mk t) (Ξ³ t)) (Ξ³'-f t (Ξ³ t))=A (1,Ξ³') | |
| rw [hsp.fderiv] | |
| change A (0,Ξ³'-f t (Ξ³ t))=A (1,Ξ³') | |
| exact he.symm | |
| omit [ProperSpace E] in | |
| lemma backwardTest_spatial_derivative_bound (T : Icc a b) {Ο : E β β} {L : ββ₯0} | |
| (hΟ : LipschitzWith L Ο) (t : β) (z v : E) : | |
| βfderiv β (fun z => backwardTest hab hc hL T Ο (t,z)) z vββ€ | |
| ((L:β)*Real.exp ((K:β)*(b-a)))*βvβ := by | |
| apply ((fderiv β (fun z => backwardTest hab hc hL T Ο (t,z)) z).le_opNorm v).trans | |
| apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) | |
| exact norm_fderiv_le_of_lipschitz β (backwardTest_lipschitz hab hc hL T hΟ t) | |
| end LogConcaveSampling.GlobalODE | |
| namespace LogConcaveSampling.GlobalODE | |
| open Set Function Filter MeasureTheory | |
| open scoped Topology | |
| theorem transport_expectation_of_flux {d : β} {Ξ© : Type*} [MeasurableSpace Ξ©] | |
| {ΞΌ : Measure Ξ©} [IsFiniteMeasure ΞΌ] {a b : β} (hab : a<b) | |
| {f : β β Point d β Point d} (hc : Continuous (uncurry f)) {K : ββ₯0} | |
| (hL : β tβIcc a b,LipschitzWith K (f t)) | |
| {D : β β Point d β Point d βL[β] Point d} (hD : Continuous (uncurry D)) | |
| (hf : β t z,HasFDerivAt (f t) (D t z) z) | |
| {X X' : β β Ξ© β Point d} | |
| (hXm : β t,Measurable (X t)) (hXc : β Ο,Continuous (fun t => X t Ο)) | |
| (hXp : β tβIoo a b,β Ο,HasDerivAt (fun t => X t Ο) (X' t Ο) t) | |
| (hX'm : β t,Measurable (X' t)) | |
| {g : Ξ© β β} (hg : Integrable g ΞΌ) | |
| (hgb : β tβIoo a b,β Ο,βX' t Ο-f t (X t Ο)ββ€g Ο) | |
| (hflux : β tβIoo a b,β S : Point d β Point d βL[β] β,Measurable S β | |
| (β C : β,β y,βS yββ€C) β (β« Ο,S (X t Ο) (X' t Ο-f t (X t Ο)) βΞΌ)=0) | |
| {Ο : Point d β β} (hΟ : Differentiable β Ο) {L : ββ₯0} (hΟL : LipschitzWith L Ο) | |
| {B : β} (hΟB : β z,βΟ zββ€B) : | |
| (β« Ο,Ο (X b Ο) βΞΌ) = | |
| β« Ο,Ο (flow hL hc β¨a,le_rfl,hab.leβ© (X a Ο) b) βΞΌ := by | |
| let T : Icc a b := β¨b,hab.le,le_rflβ© | |
| let Ο := backwardTest hab.le hc hL T Ο | |
| let S := fun t => fderiv β (fun z => Ο (t,z)) | |
| let U := fun t Ο => Ο (t,X t Ο) | |
| let U' := fun t Ο => S t (X t Ο) (X' t Ο-f t (X t Ο)) | |
| let C : β := (L:β)*Real.exp ((K:β)*(b-a)) | |
| have hC : 0β€C := by dsimp [C]; positivity | |
| have hSm : β t,Measurable (S t) := fun t => measurable_fderiv β _ | |
| have hSb : β t y,βS t yββ€C := by | |
| intro t y | |
| exact norm_fderiv_le_of_lipschitz β (backwardTest_lipschitz hab.le hc hL T hΟL t) | |
| have hΟ : Continuous Ο := backwardTest_continuous hab.le hc hL T hΟ.continuous | |
| have hUm : β t,Measurable (U t) := fun t => hΟ.measurable.comp (measurable_const.prodMk (hXm t)) | |
| have hUb : β t Ο,βU t Οββ€B := by intro t Ο; exact hΟB _ | |
| have hU'm : β t,Measurable (U' t) := by | |
| intro t | |
| exact (continuous_fst.clm_apply continuous_snd).measurable.comp | |
| (((hSm t).comp (hXm t)).prodMk ((hX'm t).sub | |
| (hc.measurable.comp (measurable_const.prodMk (hXm t))))) | |
| have hUi : β t,Integrable (U t) ΞΌ := fun t => | |
| (integrable_const B).mono' (hUm t).aestronglyMeasurable (Eventually.of_forall (hUb t)) | |
| have hU'b : β tβIoo a b,β Ο,βU' t Οββ€C*g Ο := by | |
| intro t ht Ο | |
| exact ((S t (X t Ο)).le_opNorm _).trans | |
| ((mul_le_mul_of_nonneg_right (hSb t _) (norm_nonneg _)).trans | |
| (mul_le_mul_of_nonneg_left (hgb t ht Ο) hC)) | |
| have hUd : β tβIoo a b,β Ο,HasDerivAt (fun t => U t Ο) (U' t Ο) t := by | |
| intro t ht Ο | |
| exact backwardTest_chain hab.le hc hL hD hf T hΟ ht (hXp t ht Ο) | |
| have hQd : β tβIoo a b,HasDerivAt (fun t => β« Ο,U t Ο βΞΌ) 0 t := by | |
| intro t ht | |
| have hh := hasDerivAt_integral_of_dominated_loc_of_deriv_le (F:=U) (F':=U') | |
| (Ioo_mem_nhds ht.1 ht.2) (Eventually.of_forall fun s => (hUm s).aestronglyMeasurable) | |
| (hUi t) (hU'm t).aestronglyMeasurable | |
| (Eventually.of_forall fun Ο s hs => hU'b s hs Ο) (hg.const_mul C) | |
| (Eventually.of_forall fun Ο s hs => hUd s hs Ο) | |
| have hz := hflux t ht (S t) (hSm t) β¨C,hSb tβ© | |
| change (β« Ο,U' t Ο βΞΌ)=0 at hz | |
| rw [hz] at hh | |
| exact hh.2 | |
| have hQc : Continuous (fun t => β« Ο,U t Ο βΞΌ) := | |
| continuous_of_dominated (fun t => (hUm t).aestronglyMeasurable) | |
| (fun t => Eventually.of_forall (hUb t)) (integrable_const B) | |
| (Eventually.of_forall fun Ο => hΟ.comp (continuous_id.prodMk (hXc Ο))) | |
| obtain β¨t,ht,heβ© := exists_deriv_eq_slope (fun t => β« Ο,U t Ο βΞΌ) hab hQc.continuousOn | |
| (fun t ht => (hQd t ht).differentiableAt.differentiableWithinAt) | |
| rw [(hQd t ht).deriv] at he | |
| have heq : (β« Ο,U b Ο βΞΌ)=(β« Ο,U a Ο βΞΌ) := | |
| sub_eq_zero.mp ((div_eq_zero_iff).mp he.symm |>.resolve_right (sub_ne_zero.mpr hab.ne')) | |
| convert! heq using 1 <;> apply integral_congr_ae <;> filter_upwards [] with Ο | |
| Β· simp only [U,Ο,backwardTest_eq] | |
| rw [projIcc_of_mem _ (show bβIcc a b from β¨hab.le,le_rflβ©)] | |
| exact (congrArg Ο (flow_initial hL hc β¨b,hab.le,le_rflβ© (X b Ο))).symm | |
| Β· simp only [U,Ο,backwardTest_eq] | |
| rw [projIcc_of_mem _ (show aβIcc a b from β¨le_rfl,hab.leβ©)] | |
| end LogConcaveSampling.GlobalODE | |
| end UpperProof | |
| end | |
| end | |
| end | |
| end OAI | |