import Mathlib import OAI.Analysis.BiholderTransport.Contact.CoordinateScalarSupport import OAI.Analysis.BiholderTransport.Regularity.CenterFullPullback namespace OAI section noncomputable section open Set Filter Manifold Bundle open scoped Topology ContDiff namespace WeakMTWTransport section ModelTangentJet variable {n : β„•} {M : Type*} [MetricSpace M] [CompactSpace M] [Nonempty 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)] [IsRiemannianManifold π“˜(ℝ,Model n) M] omit [CompactSpace M] [Nonempty M] [RiemannianBundle (fun x : M => TangentSpace π“˜(ℝ,Model n) x)] [IsContMDiffRiemannianBundle π“˜(ℝ,Model n) ∞ (Model n) (fun x : M => TangentSpace π“˜(ℝ,Model n) x)] [IsRiemannianManifold π“˜(ℝ,Model n) M] in lemma center_frame_identity (a : M) (d : Model n) : (trivializationAt (Model n) (TangentSpace π“˜(ℝ,Model n)) a).symmL ℝ a d=d := by rw [TangentBundle.symmL_trivializationAt_eq_core (mem_chart_source (Model n) a)] exact tangentCoordChange_self (I := π“˜(ℝ,Model n)) (mem_extChartAt_source a) omit [CompactSpace M] [Nonempty M] [IsContMDiffRiemannianBundle π“˜(ℝ,Model n) ∞ (Model n) (fun x : M => TangentSpace π“˜(ℝ,Model n) x)] [IsRiemannianManifold π“˜(ℝ,Model n) M] in lemma model_tangent_second_fderiv {a : M} {f : TangentSpace π“˜(ℝ,Model n) a β†’ ℝ} {q : Model n} (hf : ContDiffAt ℝ 2 f q) (d e : Model n) : fderiv ℝ (fderiv ℝ (fun r : Model n=>f r)) q d e= fderiv ℝ (fderiv ℝ f) q d e := by let A := (trivializationAt (Model n) (TangentSpace π“˜(ℝ,Model n)) a).symmL ℝ a have hA (r : Model n) : A r=r := center_frame_identity a r have hz (r : Model n) : (0 : TangentSpace π“˜(ℝ,Model n) a)+A r=r := (zero_add (A r)).trans (hA r) have H := second_fderiv_comp_affine (E := Model n) (F := TangentSpace π“˜(ℝ,Model n) a) (f := f) A 0 q (by simpa only [hz] using hf) d e have he : (fun h : Model n => f ((0 : TangentSpace π“˜(ℝ,Model n) a)+A h))= (fun h : Model n => f h) := by funext h; rw [hz h] rw [he,hz q,hA d,hA e] at H exact H omit [Nonempty M] in lemma scalarCostSupport_endpoint_contDiffAt {a c : M} {q : TangentSpace π“˜(ℝ,Model n) a} {r : TangentSpace π“˜(ℝ,Model n) c} {v s : ℝ} {Ο† : ℝ β†’ ℝ} (hr : s β€’ r∈injectivityDomain c) (he : riemannianExp a q=c) (hΟ† : ContDiffAt ℝ 2 Ο† v) : ContDiffAt ℝ 2 (fun w=>scalarCostSupport Ο† v c r s (riemannianExp a w)) q := by have hC := cost_contMDiffAt_of_injectivityDomain (⟨c,s β€’ r⟩ : TangentBundle π“˜(ℝ,Model n) M) hr have hC' : ContMDiffAt (π“˜(ℝ,Model n).prod π“˜(ℝ,Model n)) π“˜(ℝ,ℝ) ∞ (fun z:MΓ—M=>cost z.1 z.2) (riemannianExp a q,riemannianExp c (s β€’ r)) := by rwa [he] have hpair : ContMDiffAt π“˜(ℝ,TangentSpace π“˜(ℝ,Model n) a) (π“˜(ℝ,Model n).prod π“˜(ℝ,Model n)) ∞ (fun w : TangentSpace π“˜(ℝ,Model n) a => (riemannianExp a w,riemannianExp c (s β€’ r))) q := (contMDiff_riemannianExp_fiber a q).prodMk contMDiffAt_const have hcost : ContDiffAt ℝ ∞ (fun w : TangentSpace π“˜(ℝ,Model n) a => cost (riemannianExp a w) (riemannianExp c (s β€’ r))) q := (hC'.comp (g := fun z:MΓ—M=>cost z.1 z.2) q hpair).contDiffAt have hf : ContDiffAt ℝ ∞ (fun w=>v+cost c (riemannianExp c (s β€’ r))/s- cost (riemannianExp a w) (riemannianExp c (s β€’ r))/s) q := contDiffAt_const.sub (hcost.div_const s) have hval : v+cost c (riemannianExp c (s β€’ r))/s-cost (riemannianExp a q) (riemannianExp c (s β€’ r))/s=v := by rw [he,add_sub_cancel_right] exact (hval.symm β–Έ hΟ†).comp q (hf.of_le (ENat.natCast_le_of_coe_top_le_withTop le_rfl 2)) omit [Nonempty M] in lemma model_riemannianExp_continuous (a : M) : Continuous (fun w : Model n=>riemannianExp a w) := by let A := (trivializationAt (Model n) (TangentSpace π“˜(ℝ,Model n)) a).symmL ℝ a have H := (continuous_riemannianExp a).comp A.continuous have he : riemannianExp a ∘ A=(fun w : Model n=>riemannianExp a w) := by funext w exact congrArg (riemannianExp a) (center_frame_identity a w) rwa [he] at H omit [CompactSpace M] [Nonempty M] [IsContMDiffRiemannianBundle π“˜(ℝ,Model n) ∞ (Model n) (fun x : M => TangentSpace π“˜(ℝ,Model n) x)] [IsRiemannianManifold π“˜(ℝ,Model n) M] in lemma coordinateScalarSupport_center_value (c : M) (v s : ℝ) (Ο† : ℝ β†’ ℝ) (r z : Model n) : coordinateScalarSupport c Ο† (((v,s),(extChartAt π“˜(ℝ,Model n) c c,r)),z)= scalarCostSupport Ο† v c r s ((extChartAt π“˜(ℝ,Model n) c).symm z) := by have hx := (extChartAt π“˜(ℝ,Model n) c).map_source (mem_extChartAt_source c) have hb := (extChartAt π“˜(ℝ,Model n) c).left_inv (mem_extChartAt_source c) rw [coordinateScalarSupport_eq hx,hb,center_frame_identity] omit [Nonempty M] in lemma coordinate_support_endpoint_germ {a c : M} {q r : Model n} (v s : ℝ) (Ο† : ℝ β†’ ℝ) (he : riemannianExp a q=c) : (fun w : Model n=>coordinateScalarSupport c Ο† (((v,s),(extChartAt π“˜(ℝ,Model n) c c,r)),extChartAt π“˜(ℝ,Model n) c (riemannianExp a w)))=αΆ [𝓝 q] (fun w : Model n=>scalarCostSupport Ο† v c r s (riemannianExp a w)) := by have hx := (extChartAt π“˜(ℝ,Model n) c).map_source (mem_extChartAt_source c) have hb := (extChartAt π“˜(ℝ,Model n) c).left_inv (mem_extChartAt_source c) have hExp := (model_riemannianExp_continuous a).continuousAt (x := q) have hqc : riemannianExp a q∈(extChartAt π“˜(ℝ,Model n) c).source := by rw [he] exact mem_extChartAt_source c have hsource := hExp.eventually ((isOpen_extChartAt_source c).mem_nhds hqc) filter_upwards [hsource] with w hw rw [coordinateScalarSupport_center_value,(extChartAt π“˜(ℝ,Model n) c).left_inv hw] omit [Nonempty M] in lemma coordinate_support_endpoint_hessian {a c : M} {q r : Model n} {v s : ℝ} {Ο† : ℝ β†’ ℝ} (hr : s β€’ (show TangentSpace π“˜(ℝ,Model n) c from r)∈injectivityDomain c) (he : riemannianExp a q=c) (hΟ† : ContDiffAt ℝ 2 Ο† v) (d e : Model n) : fderiv ℝ (fderiv ℝ (fun w : Model n=>coordinateScalarSupport c Ο† (((v,s),(extChartAt π“˜(ℝ,Model n) c c,r)),extChartAt π“˜(ℝ,Model n) c (riemannianExp a w)))) q d e= fderiv ℝ (fderiv ℝ (fun w : TangentSpace π“˜(ℝ,Model n) a=> scalarCostSupport Ο† v c r s (riemannianExp a w))) q d e := by rw [(coordinate_support_endpoint_germ v s Ο† he).fderiv.fderiv_eq] exact model_tangent_second_fderiv (scalarCostSupport_endpoint_contDiffAt hr he hΟ†) d e omit [Nonempty M] in lemma exists_uniform_coordinate_center_full_pullback : βˆƒ c0>0,βˆ€αΆ  l : ℝ in 𝓝 1, 0coordinateScalarSupport c Ο† (((v,(1+l)/2),(extChartAt π“˜(ℝ,Model n) c c,r)), extChartAt π“˜(ℝ,Model n) c (riemannianExp a w)))) q d d := by obtain ⟨c0,hc0,H⟩ := exists_uniform_center_full_pullback (n := n) (M := M) refine ⟨c0,hc0,?_⟩ filter_upwards [H] with l hl intro hl0 hl1 a c r q hr hq hac hca Ο† v hΟ† hd d rw [coordinate_support_endpoint_hessian (contracted_minimizer_mem_injectivityDomain hr (by linarith) (by linarith)) hca hΟ†, real_inner_self_eq_norm_sq] exact hl hl0 hl1 c a r q hr hq hac hca Ο† v hΟ† hd d end ModelTangentJet end WeakMTWTransport end end end OAI