File size: 9,417 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | import Mathlib
import OAI.Probability.LogConcave.Dynamics.VariationalField
namespace OAI
section
section
noncomputable section
namespace LogConcaveSampling.GlobalODE
open Set Function Filter Metric
open scoped Topology NNReal
theorem smooth_flow_joint {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
[FiniteDimensional β E] {f : β β E β E}
(hf : ContDiff β (β€:ββ) (uncurry f)) {K : ββ₯0} {a b : β}
(hL : βtβIcc a b,LipschitzWith K (f t)) (s : Icc a b)
(pβ : β Γ E) (hpβ : pβ.1βIoo a b) :
ContDiffAt β (β€:ββ) (fun p : β Γ E => flow hL hf.continuous s p.2 p.1) pβ := by
apply contDiffAt_infty.mpr
intro n
let V : β Γ (β Γ E) β β Γ (β Γ E) := fun p => (0,(p.1,p.1 β’ f p.2.1 p.2.2))
have hV : ContDiff β (β€:ββ) V :=
contDiff_const.prodMk (contDiff_fst.prodMk (contDiff_fst.smul (hf.comp contDiff_snd)))
let X := fun x => flow hL hf.continuous s x
obtain β¨A,hAβ© := isCompact_Icc.exists_bound_of_continuousOn
((flow_continuous hL hf.continuous s (0:E)).continuousOn : ContinuousOn (X 0) (Icc a b))
let C := Real.exp ((K:β)*(b-a))
have hC : 0<C := Real.exp_pos _
obtain β¨N,hNβ© := exists_nat_gt (max (b-a) (max (max |a| |b|) (A+C*(βpβ.2β+1))))
let W := LinearGrowthODE.truncated V N
have hW : ContDiff β (n:WithTop ββ) W := truncated_contDiff (hV.of_le (WithTop.coe_le_coe.mpr le_top)) N
obtain β¨L,hWLβ© := LinearGrowthODE.truncated_lipschitz (hV.of_le (by norm_num)) N
have hWc : Continuous (uncurry (fun (_ : β) => W)) := hW.continuous.comp continuous_snd
let Z (p : β Γ (β Γ E)) := flow (fun _ _ => hWL) hWc (β¨0,le_rfl,by norm_numβ© : Icc (0:β) 1) p 1
have hZ : ContDiff β (n:WithTop ββ) Z := autonomous_flow_contDiff _ hW hWL (by norm_num) β¨1,by norm_num,le_rflβ©
have he : (fun p : β Γ E => X p.2 p.1) =αΆ [π pβ]
(fun p => (Z (p.1-s,((s:β),p.2))).2.2) := by
have hn : Ioo a b ΓΛ’ ball pβ.2 1 β π pβ :=
(isOpen_Ioo.prod isOpen_ball).mem_nhds β¨hpβ,mem_ball_self zero_lt_oneβ©
filter_upwards [hn] with p hp
have hpt : p.1βIcc a b := β¨hp.1.1.le,hp.1.2.leβ©
have hxn : βp.2ββ€βpβ.2β+1 := by
have hh := norm_le_norm_add_norm_sub pβ.2 p.2
rw [βdist_eq_norm,dist_comm] at hh
linarith [mem_ball.mp hp.2]
let q : β β β := fun u => (s:β)+(p.1-s)*u
have hq (u : β) (hu : uβIcc (0:β) 1) : q uβIcc a b := by
have hc := (convex_Icc a b) s.2 hpt (show 0β€1-u by linarith [hu.2]) hu.1 (show 1-u+u=1 by ring)
convert! hc using 1
dsimp [q]
ring
have hqb (u : β) (hu : uβIcc (0:β) 1) : β(p.1-s,(q u,X p.2 (q u)))ββ€(N:β)+1 := by
have htime (v : Icc a b) : |(v:β)-s|β€b-a := by
rw [abs_le]; constructor <;> linarith [v.2.1,v.2.2,s.2.1,s.2.2]
have hex : Real.exp ((K:β)*|q u-s|)β€C :=
Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (htime β¨q u,hq u huβ©) K.coe_nonneg)
have hX : βX p.2 (q u)ββ€A+C*(βpβ.2β+1) := by
have hs := (flow_lipschitz hL hf.continuous s β¨q u,hq u huβ©).dist_le_mul p.2 0
simp only [dist_zero_right] at hs
have hh : βX p.2 (q u)ββ€βX 0 (q u)β+dist (X p.2 (q u)) (X 0 (q u)) := by
simpa only [dist_eq_norm,norm_sub_rev] using (norm_le_norm_add_norm_sub (X 0 (q u)) (X p.2 (q u)))
exact hh.trans (add_le_add (hA (q u) (hq u hu))
(hs.trans (mul_le_mul hex hxn (norm_nonneg _) hC.le)))
have hqt : |q u| β€ max |a| |b| := by
rw [abs_le]
constructor <;> linarith [(hq u hu).1,(hq u hu).2,
neg_abs_le a,le_abs_self b,le_max_left |a| |b|,le_max_right |a| |b|]
simp only [Prod.norm_def,Real.norm_eq_abs]
exact (max_le_max (htime β¨p.1,hptβ©) (max_le_max hqt hX)).trans (by linarith)
let P : β β β Γ (β Γ E) := fun u => (p.1-s,(q u,X p.2 (q u)))
have hqc : Continuous q := by dsimp [q]; fun_prop
have hPc : Continuous P := continuous_const.prodMk
(hqc.prodMk ((flow_continuous hL hf.continuous s p.2).comp hqc))
have hPd (u : β) (hu : uβIcc (0:β) 1) :
HasDerivWithinAt P (W (P u)) (Icc (0:β) 1) u := by
have heW : W (P u)=V (P u) := LinearGrowthODE.truncated_eq (hqb u hu)
rw [heW]
have hdq : HasDerivWithinAt q (p.1-s) (Icc (0:β) 1) u := by
convert! (hasDerivWithinAt_const u (Icc (0:β) 1) (s:β)).add
((hasDerivWithinAt_id u (Icc (0:β) 1)).const_mul (p.1-s)) using 1
simp
have hdX := (flow_deriv hL hf.continuous s p.2 (q u) (hq u hu)).scomp u hdq hq
exact (hasDerivWithinAt_const u (Icc (0:β) 1) (p.1-s)).prodMk (hdq.prodMk hdX)
have h0 : P 0=(p.1-s,((s:β),p.2)) := by
dsimp [P,q]
simp only [mul_zero,add_zero]
rw [show X p.2 s=p.2 from flow_initial hL hf.continuous s p.2]
have h1 : P 1=(p.1-s,(p.1,X p.2 p.1)) := by
dsimp [P]
rw [show q 1=p.1 by dsimp [q]; ring]
have hs := trajectory_dist (fun (_ : β) _ => hWL) hPc.continuousOn hPd
(flow_continuous (fun _ _ => hWL) hWc (β¨0,le_rfl,by norm_numβ© : Icc (0:β) 1) (p.1-s,((s:β),p.2))).continuousOn
(flow_deriv (fun _ _ => hWL) hWc (β¨0,le_rfl,by norm_numβ© : Icc (0:β) 1) (p.1-s,((s:β),p.2)))
(β¨0,le_rfl,by norm_numβ© : Icc (0:β) 1) (β¨1,by norm_num,le_rflβ© : Icc (0:β) 1)
change dist (P 1) (Z (p.1-s,((s:β),p.2)))β€dist (P 0) _ * _ at hs
rw [h0,flow_initial,dist_self,zero_mul,dist_le_zero,h1] at hs
exact congrArg (fun z => z.2.2) hs
exact ((hZ.comp ((contDiff_fst.sub contDiff_const).prodMk
(contDiff_const.prodMk contDiff_snd))).snd.snd).contDiffAt.congr_of_eventuallyEq he
end LogConcaveSampling.GlobalODE
end
end
section
noncomputable section
namespace LogConcaveSampling.GlobalODE
open Set Function Filter
open scoped Topology NNReal
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
[FiniteDimensional β E] {f : β β E β E}
(hf : ContDiff β (β€:ββ) (uncurry f)) {K : ββ₯0} {a b : β}
(hab : aβ€b) (hL : βtβIcc a b,LipschitzWith K (f t))
lemma spaceTimeForward_smooth (p : β Γ E) (hp : p.1βIoo a b) :
ContDiffAt β (β€:ββ) (spaceTimeForward hab hf.continuous hL) p := by
have hh := contDiffAt_fst.prodMk (smooth_flow_joint hf hL β¨a,le_rfl,habβ© p hp)
apply hh.congr_of_eventuallyEq
filter_upwards [continuous_fst.continuousAt.preimage_mem_nhds (Icc_mem_nhds hp.1 hp.2)] with q hq
simp only [spaceTimeForward,projIcc_of_mem _ hq]
lemma spaceTimeBackward_smooth (p : β Γ E) (hp : p.1βIoo a b) :
ContDiffAt β (β€:ββ) (spaceTimeBackward hab hf.continuous hL) p := by
let D := fun t => fderiv β (f t)
have hD : Continuous (uncurry D) := by
have hh := hf.continuous_fderiv (by norm_num)
have he : uncurry D=fun p : β Γ E => (fderiv β (uncurry f) p).comp (ContinuousLinearMap.inr β β E) := by
funext p
have hg : HasFDerivAt (fun z : E => (p.1,z)) (ContinuousLinearMap.inr β β E) p.2 := by
convert! (hasFDerivAt_const (π:=β) p.1 p.2).prodMk (hasFDerivAt_id (π:=β) p.2) using 1
exact ((hf.differentiable (by norm_num) p).hasFDerivAt.comp p.2 hg).fderiv
rw [he]
exact hh.clm_comp continuous_const
have hd (t : β) (z : E) : HasFDerivAt (f t) (D t z) z :=
((hf.comp (contDiff_const.prodMk contDiff_id)).differentiable (by norm_num) z).hasFDerivAt
let H := spaceTimeHomeomorph hab hf.continuous hL
have hp' : (H.symm p).1βIoo a b := hp
exact H.toOpenPartialHomeomorph.contDiffAt_symm (Set.mem_univ p)
(spaceTimeForward_hasFDerivAt hab hf.continuous hL hD hd (H.symm p) hp')
(spaceTimeForward_smooth hf hab hL (H.symm p) hp')
lemma backward_flow_smooth (T : Icc a b) (p : β Γ E) (hp : p.1βIoo a b) :
ContDiffAt β (β€:ββ)
(fun p : β Γ E => flow hL hf.continuous (projIcc a b hab p.1) p.2 T) p := by
have hA : ContDiff β (β€:ββ)
(fun y => flow hL hf.continuous β¨a,le_rfl,habβ© y T) := by
apply contDiff_infty.mpr
intro n
exact smooth_flow (hf.of_le (WithTop.coe_le_coe.mpr le_top)) hL hab _ T
have hh := hA.contDiffAt.comp p ((spaceTimeBackward_smooth hf hab hL p hp).snd)
convert! hh using 1
funext q
exact (flow_cocycle hL hf.continuous (projIcc a b hab q.1) β¨a,le_rfl,habβ© T q.2).symm
end LogConcaveSampling.GlobalODE
end
end
section
noncomputable section
namespace LogConcaveSampling.GlobalODE
open Set Function
open scoped Topology NNReal
lemma flow_restrict {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E]
{a b c d : β} {f g : β β E β E} {K L : ββ₯0}
(hf : Continuous (uncurry f)) (hg : Continuous (uncurry g))
(hL : βtβIcc a b,LipschitzWith K (f t))
(hJ : βtβIcc c d,LipschitzWith L (g t)) (hsub : Icc a b β Icc c d)
(he : βtβIcc a b,βx,f t x=g t x) (s t : Icc a b) (x : E) :
flow hL hf s x t=flow hJ hg β¨s,hsub s.2β© x t := by
have hh := trajectory_dist hL (flow_continuous hL hf s x).continuousOn
(flow_deriv hL hf s x) (flow_continuous hJ hg β¨s,hsub s.2β© x).continuousOn
(fun u hu => (he u hu _) βΈ (flow_deriv hJ hg β¨s,hsub s.2β© x u (hsub hu)).mono hsub) s t
simpa only [flow_initial,dist_self,zero_mul,dist_le_zero] using hh
end LogConcaveSampling.GlobalODE
end
end
end
end OAI
|