File size: 14,289 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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | import Mathlib
import OAI.Probability.LogConcave.Dynamics.Truncated
namespace OAI
section
section
noncomputable section
namespace LogConcaveSampling.GlobalODE
open Set Function Filter Metric
open scoped Topology NNReal
def variationalField {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
(f : E β E) (p : E Γ (E βL[β] E)) : E Γ (E βL[β] E) :=
(f p.1,(fderiv β f p.1).comp p.2)
lemma variationalField_smooth {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
{f : E β E} {n : β} (hf : ContDiff β ((n:WithTop ββ)+1) f) :
ContDiff β (n:WithTop ββ) (variationalField f) :=
((hf.of_le (by exact_mod_cast Nat.le_succ n)).comp contDiff_fst).prodMk
(((hf.fderiv_right le_rfl).comp contDiff_fst).clm_comp contDiff_snd)
lemma truncated_contDiff {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
[FiniteDimensional β E] {f : E β E} {k : β} (hf : ContDiff β (k:WithTop ββ) f) (n : β) :
ContDiff β (k:WithTop ββ) (LinearGrowthODE.truncated f n) :=
(((PoincareCutoff.bump (E:=E)).contDiff).comp (contDiff_id.const_smul _)).smul hf
theorem autonomous_flow_contDiff (n : β) :
β {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [FiniteDimensional β E]
{f : E β E} (hf : ContDiff β (n:WithTop ββ) f) {K : ββ₯0}
(hL : LipschitzWith K f) {a b : β} (hab : aβ€b) (t : Icc a b),
ContDiff β (n:WithTop ββ) (fun x => flow (fun _ _ => hL)
(hf.continuous.comp continuous_snd) β¨a,le_rfl,habβ© x t) := by
induction n with
| zero =>
intro E _ _ _ f hf K hL a b hab t
exact contDiff_zero.mpr (flow_lipschitz (fun _ _ => hL)
(hf.continuous.comp continuous_snd) β¨a,le_rfl,habβ© t).continuous
| succ n ih =>
intro E _ _ _ f hf K hL a b hab t
have hf1 : ContDiff β 1 f := hf.of_le (by exact_mod_cast Nat.succ_pos n)
let hc : Continuous (uncurry (fun (_ : β) => f)) := hf.continuous.comp continuous_snd
let hD : Continuous (uncurry (fun (_ : β) => fderiv β f)) :=
(hf1.continuous_fderiv (by norm_num)).comp continuous_snd
let hd : β (u : β) (z : E),HasFDerivAt f (fderiv β f z) z :=
fun _ z => (hf1.differentiable (by norm_num) z).hasFDerivAt
cases n with
| zero =>
exact flow_contDiff_one_left hab hc (fun _ _ => hL) hD hd t
| succ m =>
let J := flowLinearization hab hc (fun _ _ => hL) hD hd
let X := fun x => flow (fun _ _ => hL) hc β¨a,le_rfl,habβ© x
have hXd (x : E) : HasFDerivAt (fun z => X z t) (J x t) x :=
flow_hasFDerivAt_left hab hc (fun _ _ => hL) hD hd x t
change ContDiff β (((m+1:β):WithTop ββ)+1) (fun x => X x t)
apply contDiff_succ_iff_hasFDerivAt.mpr
refine β¨fun x => J x t,?_,hXdβ©
apply contDiff_iff_contDiffAt.mpr
intro xβ
let V := variationalField f
have hV : ContDiff β ((m+1:β):WithTop ββ) V := variationalField_smooth (by simpa using hf)
have hV1 : ContDiff β 1 V := hV.of_le (by exact_mod_cast Nat.succ_pos m)
obtain β¨A,hAβ© := isCompact_Icc.exists_bound_of_continuousOn
(flow_continuous (fun _ _ => hL) hc β¨a,le_rfl,habβ© (0:E)).continuousOn
let C := Real.exp ((K:β)*(b-a))
have hC : 0<C := Real.exp_pos _
obtain β¨N,hNβ© := exists_nat_gt (max (A+C*(βxββ+1)) C)
let W := LinearGrowthODE.truncated V N
have hW : ContDiff β ((m+1:β):WithTop ββ) W := truncated_contDiff hV N
obtain β¨L,hWLβ© := LinearGrowthODE.truncated_lipschitz hV1 N
have hWc : Continuous (uncurry (fun (_ : β) => W)) := hW.continuous.comp continuous_snd
let Z (p : E Γ (E βL[β] E)) := flow (fun _ _ => hWL) hWc β¨a,le_rfl,habβ© p t
have hZ : ContDiff β ((m+1:β):WithTop ββ) Z := ih hW hWL hab t
have hloc : (fun x => J x t) =αΆ [π xβ]
(fun x => (Z (x,ContinuousLinearMap.id β E)).2) := by
filter_upwards [Metric.ball_mem_nhds xβ zero_lt_one] with x hx
have hxn : βxββ€βxββ+1 := by
have hh := norm_le_norm_add_norm_sub xβ x
rw [βdist_eq_norm, dist_comm] at hh
linarith [Metric.mem_ball.mp hx]
have hb (u : Icc a b) : β(X x u,J x u)ββ€(N:β)+1 := by
have hu : |(u:β)-a|β€b-a := by
rw [abs_of_nonneg (sub_nonneg.mpr u.2.1)]; linarith [u.2.2]
have hex : Real.exp ((K:β)*|(u:β)-a|)β€C :=
Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hu K.coe_nonneg)
have hX : βX x uββ€A+C*(βxββ+1) := by
have hs := (flow_lipschitz (fun _ _ => hL) hc β¨a,le_rfl,habβ© u).dist_le_mul x 0
simp only [dist_zero_right] at hs
have hn : βX x uββ€βX 0 uβ+dist (X x u) (X 0 u) := by
simpa only [dist_eq_norm, norm_sub_rev] using
(norm_le_norm_add_norm_sub (X 0 u) (X x u))
exact hn.trans (add_le_add (hA u u.2) (hs.trans
(mul_le_mul hex hxn (norm_nonneg _) hC.le)))
have hJ : βJ x uββ€C :=
(fundamental_norm_bound β¨a,le_rfl,habβ©
(flowSpatialCoefficient_continuous hab hc (fun _ _ => hL) hD x)
(flowSpatialCoefficient_bound hab hc (fun _ _ => hL) hd x) u).trans hex
rw [Prod.norm_def]
exact (max_le_max hX hJ).trans (by linarith)
have he (u : β) (hu : uβIcc a b) : W (X x u,J x u)=V (X x u,J x u) :=
LinearGrowthODE.truncated_eq (hb β¨u,huβ©)
have hcP : Continuous (fun u => (X x u,J x u)) :=
(flow_continuous (fun _ _ => hL) hc _ x).prodMk
(fundamental_continuous β¨a,le_rfl,habβ©
(flowSpatialCoefficient_continuous hab hc (fun _ _ => hL) hD x)
(flowSpatialCoefficient_bound hab hc (fun _ _ => hL) hd x))
have hdP (u : β) (hu : uβIcc a b) :
HasDerivWithinAt (fun u => (X x u,J x u)) (W (X x u,J x u)) (Icc a b) u := by
rw [he u hu]
exact (flow_deriv (fun _ _ => hL) hc _ x u hu).prodMk
(fundamental_deriv β¨a,le_rfl,habβ©
(flowSpatialCoefficient_continuous hab hc (fun _ _ => hL) hD x)
(flowSpatialCoefficient_bound hab hc (fun _ _ => hL) hd x) u hu)
have hs := trajectory_dist (fun (_ : β) _ => hWL) hcP.continuousOn hdP
(flow_continuous (fun _ _ => hWL) hWc β¨a,le_rfl,habβ© (x,ContinuousLinearMap.id β E)).continuousOn
(flow_deriv (fun _ _ => hWL) hWc β¨a,le_rfl,habβ© (x,ContinuousLinearMap.id β E))
β¨a,le_rfl,habβ© t
have hi : (X x a,J x a)=(x,ContinuousLinearMap.id β E) := by
apply Prod.ext
Β· exact flow_initial (fun _ _ => hL) hc β¨a,le_rfl,habβ© x
Β· exact fundamental_initial β¨a,le_rfl,habβ©
(flowSpatialCoefficient_continuous hab hc (fun _ _ => hL) hD x)
(flowSpatialCoefficient_bound hab hc (fun _ _ => hL) hd x)
rw [show (β¨a,le_rfl,habβ© : Icc a b).val=a from rfl,hi,flow_initial,
dist_self,zero_mul,dist_le_zero] at hs
exact congrArg Prod.snd hs
exact (hZ.comp (contDiff_id.prodMk contDiff_const)).snd.contDiffAt.congr_of_eventuallyEq hloc
end LogConcaveSampling.GlobalODE
end
end
section
noncomputable section
namespace LogConcaveSampling.GlobalODE
open Set Function Filter Metric
open scoped Topology NNReal
theorem smooth_flow_left {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
[FiniteDimensional β E] {n : β} {f : β β E β E}
(hf : ContDiff β (n:WithTop ββ) (uncurry f)) {K : ββ₯0} {a b : β}
(hL : βtβIcc a b,LipschitzWith K (f t)) (hab : aβ€b) (t : Icc a b) :
ContDiff β (n:WithTop ββ) (fun x => flow hL hf.continuous β¨a,le_rfl,habβ© x t) := by
cases n with
| zero => exact contDiff_zero.mpr (flow_lipschitz hL hf.continuous _ t).continuous
| succ n =>
let V : β Γ E β β Γ E := fun p => (1,f p.1 p.2)
have hV : ContDiff β ((n+1:β):WithTop ββ) V := contDiff_const.prodMk hf
have hV1 : ContDiff β 1 V := hV.of_le (by exact_mod_cast Nat.succ_pos n)
let X := fun x => flow hL hf.continuous β¨a,le_rfl,habβ© x
apply contDiff_iff_contDiffAt.mpr
intro xβ
obtain β¨A,hAβ© := isCompact_Icc.exists_bound_of_continuousOn
((flow_continuous hL hf.continuous β¨a,le_rfl,habβ© (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 (max |a| |b|) (A+C*(βxββ+1)))
let W := LinearGrowthODE.truncated V N
have hW : ContDiff β ((n+1:β):WithTop ββ) W := truncated_contDiff hV N
obtain β¨L,hWLβ© := LinearGrowthODE.truncated_lipschitz hV1 N
have hWc : Continuous (uncurry (fun (_ : β) => W)) := hW.continuous.comp continuous_snd
let Z (p : β Γ E) := flow (fun _ _ => hWL) hWc β¨a,le_rfl,habβ© p t
have hZ : ContDiff β ((n+1:β):WithTop ββ) Z := autonomous_flow_contDiff _ hW hWL hab t
have he : (fun x => X x t) =αΆ [π xβ] (fun x => (Z (a,x)).2) := by
filter_upwards [ball_mem_nhds xβ zero_lt_one] with x hx
have hxn : βxββ€βxββ+1 := by
have hh := norm_le_norm_add_norm_sub xβ x
rw [βdist_eq_norm,dist_comm] at hh
linarith [mem_ball.mp hx]
have hb (u : Icc a b) : β((u:β),X x u)ββ€(N:β)+1 := by
have hu : |(u:β)-a|β€b-a := by
rw [abs_of_nonneg (sub_nonneg.mpr u.2.1)]; linarith [u.2.2]
have hex : Real.exp ((K:β)*|(u:β)-a|)β€C :=
Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hu K.coe_nonneg)
have hX : βX x uββ€A+C*(βxββ+1) := by
have hs := (flow_lipschitz hL hf.continuous β¨a,le_rfl,habβ© u).dist_le_mul x 0
simp only [dist_zero_right] at hs
have hn : βX x uββ€βX 0 uβ+dist (X x u) (X 0 u) := by
simpa only [dist_eq_norm,norm_sub_rev] using (norm_le_norm_add_norm_sub (X 0 u) (X x u))
exact hn.trans (add_le_add (hA u u.2) (hs.trans
(mul_le_mul hex hxn (norm_nonneg _) hC.le)))
have hau : |(u:β)| β€ max |a| |b| := by
rw [abs_le]
exact β¨by linarith [neg_abs_le a,le_max_left |a| |b|,u.2.1],
by linarith [le_abs_self b,le_max_right |a| |b|,u.2.2]β©
rw [Prod.norm_def,Real.norm_eq_abs]
exact (max_le_max hau hX).trans (by linarith)
have heW (u : β) (hu : uβIcc a b) : W (u,X x u)=V (u,X x u) :=
LinearGrowthODE.truncated_eq (hb β¨u,huβ©)
have hcP : Continuous (fun u => (u,X x u)) :=
continuous_id.prodMk (flow_continuous hL hf.continuous _ x)
have hdP (u : β) (hu : uβIcc a b) :
HasDerivWithinAt (fun u => (u,X x u)) (W (u,X x u)) (Icc a b) u := by
rw [heW u hu]
exact (hasDerivWithinAt_id u (Icc a b)).prodMk (flow_deriv hL hf.continuous _ x u hu)
have hs := trajectory_dist (fun (_ : β) _ => hWL) hcP.continuousOn hdP
(flow_continuous (fun _ _ => hWL) hWc β¨a,le_rfl,habβ© (a,x)).continuousOn
(flow_deriv (fun _ _ => hWL) hWc β¨a,le_rfl,habβ© (a,x)) β¨a,le_rfl,habβ© t
have hi : (a,X x a)=(a,x) := by rw [show X x a=x from flow_initial hL hf.continuous _ x]
rw [show (β¨a,le_rfl,habβ© : Icc a b).val=a from rfl,hi,flow_initial,
dist_self,zero_mul,dist_le_zero] at hs
exact congrArg Prod.snd hs
exact (hZ.comp (contDiff_const.prodMk contDiff_id)).snd.contDiffAt.congr_of_eventuallyEq he
lemma flow_congr {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E]
{a b : β} {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 a b,LipschitzWith L (g t))
(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 x t := by
have hd (u : β) (hu : uβIcc a b) := flow_deriv hJ hg s x u hu
have hh := trajectory_dist hL (flow_continuous hL hf s x).continuousOn
(flow_deriv hL hf s x) (flow_continuous hJ hg s x).continuousOn
(fun u hu => (he u hu _) βΈ flow_deriv hJ hg s x u hu) s t
simpa only [flow_initial,dist_self,zero_mul,dist_le_zero] using hh
end LogConcaveSampling.GlobalODE
namespace LogConcaveSampling.GlobalODE
open Set Function
open scoped Topology NNReal
theorem smooth_flow {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
[FiniteDimensional β E] {n : β} {f : β β E β E}
(hf : ContDiff β (n:WithTop ββ) (uncurry f)) {K : ββ₯0} {a b : β}
(hL : βtβIcc a b,LipschitzWith K (f t)) (hab : aβ€b) (s t : Icc a b) :
ContDiff β (n:WithTop ββ) (fun x => flow hL hf.continuous s x t) := by
cases n with
| zero => exact contDiff_zero.mpr (flow_lipschitz hL hf.continuous s t).continuous
| succ n =>
have hf1 : ContDiff β 1 (uncurry f) := hf.of_le (by exact_mod_cast Nat.succ_pos n)
let D : β β E β E βL[β] E := fun u x =>
(fderiv β (uncurry f) (u,x)).comp (ContinuousLinearMap.inr β β E)
have hD : Continuous (uncurry D) :=
(hf1.continuous_fderiv (by norm_num)).clm_comp continuous_const
have hd (u : β) (z : E) : HasFDerivAt (f u) (D u z) z := by
exact ((hf1.differentiable (by norm_num) (u,z)).hasFDerivAt).comp z
((hasFDerivAt_const u z).prodMk (hasFDerivAt_id z))
have hi (u : Icc a b) : ContDiff β ((n+1:β):WithTop ββ)
(fun x => flow hL hf.continuous u x a) := by
let H := flowHomeomorph hL hf.continuous β¨a,le_rfl,habβ© u
let J (x : E) := fundamentalEquiv
(flowSpatialCoefficient_continuous hab hf.continuous hL hD x)
(flowSpatialCoefficient_bound hab hf.continuous hL hd x) β¨a,le_rfl,habβ© u
have hJ (x : E) : HasFDerivAt H (J x : E βL[β] E) x :=
flow_hasFDerivAt_left hab hf.continuous hL hD hd x u
exact H.contDiff_symm hJ (smooth_flow_left hf hL hab u)
have hh := (smooth_flow_left hf hL hab t).comp (hi s)
convert! hh using 1
funext x
exact (flow_cocycle hL hf.continuous s β¨a,le_rfl,habβ© t x).symm
end LogConcaveSampling.GlobalODE
end
end
end
end OAI
|