import Mathlib import OAI.Analysis.BiholderTransport.Geodesics.MinimizingSubinterval import OAI.Analysis.BiholderTransport.Geodesics.GlobalGauss namespace OAI noncomputable section open Set Filter Manifold Bundle Metric open scoped Topology ContDiff NNReal namespace WeakMTWTransport variable {n : β„•} {M : Type*} [MetricSpace M] [CompactSpace M] [ChartedSpace (Model n) M] [IsManifold π“˜(ℝ,Model n) ∞ M] [RiemannianBundle (fun x : M => TangentSpace π“˜(ℝ,Model n) x)] [IsContMDiffRiemannianBundle π“˜(ℝ,Model n) ∞ (Model n) (fun x : M => TangentSpace π“˜(ℝ,Model n) x)] attribute [local instance] normedAddCommGroupTangentSpaceVectorSpace normedSpaceTangentSpaceVectorSpace lemma chart_spray_hasDerivAt (a : M) (z : TangentBundle π“˜(ℝ,Model n) M) {t : ℝ} (ht : (sprayFlow t z).1∈(extChartAt π“˜(ℝ,Model n) a).source) : HasDerivAt (fun s => extChartAt π“˜(ℝ,Model n) a (sprayFlow s z).1) (mfderiv π“˜(ℝ,Model n) π“˜(ℝ,Model n) (extChartAt π“˜(ℝ,Model n) a) (sprayFlow t z).1 (sprayFlow t z).2) t := by have hsrc : (sprayFlow t z).1∈(chartAt (Model n) a).source := by simpa only [extChartAt_source] using ht have projectedDeriv := (ContinuousLinearMap.fst ℝ (Model n) (Model n)).hasFDerivAt.comp_hasDerivAt t (sprayFlow_chart_hasDerivAt (⟨a,0⟩ : TangentBundle π“˜(ℝ,Model n) M) z ht) change HasDerivAt (fun s => extChartAt π“˜(ℝ,Model n) a (sprayFlow s z).1) (tangentCoordChange π“˜(ℝ,Model n) (sprayFlow t z).1 a (sprayFlow t z).1 (sprayFlow t z).2) t at projectedDeriv apply projectedDeriv.congr_deriv symm change (mfderiv π“˜(ℝ,Model n) π“˜(ℝ,Model n) (chartAt (Model n) a) (sprayFlow t z).1) (sprayFlow t z).2 = _ rw [mfderiv_chartAt_eq_tangentCoordChange hsrc] rfl variable [IsRiemannianManifold π“˜(ℝ,Model n) M] lemma exists_lipschitzOn_chart (a : M) : βˆƒ C : ℝβ‰₯0, βˆƒ r>0, ball a rβŠ†(extChartAt π“˜(ℝ,Model n) a).source ∧ LipschitzOnWith C (extChartAt π“˜(ℝ,Model n) a) (ball a r) := by have : IsContinuousRiemannianBundle (Model n) (fun x : M => TangentSpace π“˜(ℝ,Model n) x) := continuousRiemannianBundle_of_smooth (IB := π“˜(ℝ,Model n)) obtain ⟨C,hC,H⟩ := eventually_norm_mfderiv_extChartAt_lt π“˜(ℝ,Model n) a obtain ⟨R,hR,hsub⟩ := Metric.mem_nhds_iff.mp (inter_mem (extChartAt_source_mem_nhds (I := π“˜(ℝ,Model n)) a) H) let Cnn : ℝβ‰₯0 := ⟨C,hC.le⟩ refine ⟨Cnn,R/3,by positivity,?_,?_⟩ Β· exact fun x hx => (hsub ((ball_subset_ball (by linarith : R/3≀R)) hx)).1 apply LipschitzOnWith.of_dist_le_mul intro x hx y hy obtain ⟨p,hp,he⟩ := exists_minimizing_vector (n := n) x y let z : TangentBundle π“˜(ℝ,Model n) M := ⟨x,p⟩ have hpN : β€–pβ€–=dist x y := by rw [←he]; exact hp.symm have hpath : βˆ€ t∈Icc (0:ℝ) 1, (sprayFlow t z).1∈ball a R := by intro t ht have hD := dist_sprayFlow_le z 0 t simp only [sprayFlow_zero,zero_sub,abs_neg,abs_of_nonneg ht.1] at hD change dist x (sprayFlow t z).1≀t*β€–pβ€– at hD have hD' : dist x (sprayFlow t z).1≀dist x y := hD.trans (by rw [←hpN]; exact mul_le_of_le_one_left (norm_nonneg _) ht.2) have hxy := dist_triangle x a y have hax : dist x a extChartAt π“˜(ℝ,Model n) a (sprayFlow t z).1 let dΞ³ : ℝ β†’ Model n := fun t => mfderiv π“˜(ℝ,Model n) π“˜(ℝ,Model n) (extChartAt π“˜(ℝ,Model n) a) (sprayFlow t z).1 (sprayFlow t z).2 have hd : βˆ€ t∈Icc (0:ℝ) 1, HasDerivWithinAt Ξ³ (dΞ³ t) (Icc 0 1) t := by intro t ht exact (chart_spray_hasDerivAt a z (hsub (hpath t ht)).1).hasDerivWithinAt have hb : βˆ€ t∈Icc (0:ℝ) 1, β€–dΞ³ t‖≀C*β€–pβ€– := by intro t ht apply (ContinuousLinearMap.le_opNorm _ _).trans rw [sprayFlow_speed] exact mul_le_mul_of_nonneg_right (hsub (hpath t ht)).2.le (norm_nonneg _) have hfin := norm_image_sub_le_of_norm_deriv_le_segment_01' hd (fun t ht => hb t ⟨ht.1,ht.2.le⟩) have he1 : (sprayFlow 1 z).1=y := by simpa only [z,←riemannianExp_eq_sprayFlow] using he have he0 : (sprayFlow 0 z).1=x := by rw [sprayFlow_zero] change dist (extChartAt π“˜(ℝ,Model n) a x) (extChartAt π“˜(ℝ,Model n) a y)≀C*dist x y simpa only [Ξ³,he1,he0,←dist_eq_norm,dist_comm,hpN] using hfin end WeakMTWTransport end end OAI