import PoincareLib.Geometry.RicciFlow.Curvature.Calculus import PoincareLib.Geometry.RicciFlow.Harnack.Noncompact.CurvatureControl.MetricMonotonicity import PoincareLib.Geometry.RicciFlow.Harnack.Noncompact.DirectionEvaluation import PoincareLib.Geometry.RicciFlow.MetricComparison import PoincareLib.Geometry.Riemannian.Distance.Basic import PoincareLib.Geometry.Riemannian.Distance.CompleteBalls import PoincareLib.Geometry.Riemannian.Curvature.IntrinsicCalculus /-! # Joint continuity of distance under nonnegative Ricci curvature Earlier metric balls lie in a compact ball of a complete terminal slice. Compactness bounds the Ricci quadratic form there, so the local metric comparison gives a two-sided distance estimate and joint continuity. -/ set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set Filter Bundle open scoped Manifold ContDiff Bundle Topology ENNReal universe u namespace PoincareMT.RicciFlow variable {n : β„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] {J : Set ℝ} private theorem continuousAt_ricci_tangent_evaluation (F : RicciFlow n M J) (hTensor : βˆ€ t, (F.connection t).CurvatureTensorCalculus) (q : ℝ Γ— TangentBundle (𝓑 n) M) (hq : q.1 ∈ interior J) : ContinuousAt (fun z : ℝ Γ— TangentBundle (𝓑 n) M => (F.connection z.1).ricci z.2.1 z.2.2 z.2.2) q := by apply Poincare.RicciFlow.Harnack.continuousAt_tensor_family_evaluation (q := q) (t := Prod.fst) (x := fun z => z.2.1) (T := fun t => (F.connection t).ricciEvaluation) (fun t => (hTensor t).2.1) (X := fun z (_ : Fin 2) => z.2.2) Β· intro O hO hx X hX exact (F.contMDiffAt_ricci_fields hq ((hX 0).contMDiffAt (hO.mem_nhds hx)) ((hX 1).contMDiffAt (hO.mem_nhds hx))).continuousAt Β· exact continuousAt_fst Β· exact (FiberBundle.continuous_proj (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓑 n))).continuousAt.comp continuousAt_snd Β· intro i exact continuousAt_snd private theorem exists_ricci_bound_on_compact_relative [T3Space M] (F : RicciFlow n M J) (hTensor : βˆ€ t, (F.connection t).CurvatureTensorCalculus) (g : RiemannianMetric n M) {a b : ℝ} (hJ : Icc a b βŠ† interior J) {K : Set M} (hK : IsCompact K) : βˆƒ C : ℝ, 0 ≀ C ∧ βˆ€ t ∈ Icc a b, βˆ€ x ∈ K, βˆ€ v : TangentSpace (𝓑 n) x, |(F.connection t).ricci x v v| ≀ C * g.inner x v v := by let : Bundle.RiemannianBundle (TangentSpace (𝓑 n) : M β†’ Type _) := ⟨g.toRiemannianMetric⟩ let : IsContinuousRiemannianBundle (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓑 n) : M β†’ Type _) := ⟨⟨g.inner, g.toContinuousRiemannianMetric.continuous, fun _ _ _ => rfl⟩⟩ let : LocallyCompactSpace M := ChartedSpace.locallyCompactSpace (EuclideanSpace ℝ (Fin n)) M let S : Set (TangentBundle (𝓑 n) M) := {q | q.1 ∈ K ∧ β€–q.2β€– = 1} have hS : IsCompact S := Poincare.VectorBundle.isCompact_sphere_over hK 1 have hcont : ContinuousOn (fun z : ℝ Γ— TangentBundle (𝓑 n) M => (F.connection z.1).ricci z.2.1 z.2.2 z.2.2) (Icc a b Γ—Λ’ S) := fun q hq => (continuousAt_ricci_tangent_evaluation F hTensor q (hJ hq.1)).continuousWithinAt obtain ⟨C, hCbound⟩ := (isCompact_Icc.prod hS).exists_bound_of_continuousOn hcont refine ⟨max C 0, le_max_right _ _, ?_⟩ intro t ht x hx v obtain ⟨R, hR⟩ := (hTensor t).2.1.1 x have hscale (c : ℝ) (w : TangentSpace (𝓑 n) x) : (F.connection t).ricci x (c β€’ w) (c β€’ w) = c ^ 2 * (F.connection t).ricci x w w := by have h := R.map_smul_univ (fun _ : Fin 2 => c) (fun _ => w) simp_rw [← hR] at h simpa [LeviCivitaData.ricciEvaluation, Fin.prod_univ_two, pow_two] using h by_cases hv : v = 0 Β· subst v have hz := hscale 0 (0 : TangentSpace (𝓑 n) x) simpa using hz have hn : β€–vβ€– β‰  0 := norm_ne_zero_iff.mpr hv let w := β€–v‖⁻¹ β€’ v have hw : β€–wβ€– = 1 := by simp [w, norm_smul, norm_inv, inv_mul_cancelβ‚€ hn] have hbound := hCbound (t, ⟨x, w⟩) ⟨ht, hx, hw⟩ have hbound' : |(F.connection t).ricci x w w| ≀ C := by simpa only [Real.norm_eq_abs] using hbound have hvw : v = β€–vβ€– β€’ w := by simp [w, smul_smul, mul_inv_cancelβ‚€ hn] have hnorm : β€–vβ€– ^ 2 = g.inner x v v := (real_inner_self_eq_norm_sq v).symm calc |(F.connection t).ricci x v v| = β€–vβ€– ^ 2 * |(F.connection t).ricci x w w| := by conv_lhs => rw [hvw, hscale] rw [abs_mul, abs_of_nonneg (sq_nonneg _)] _ ≀ β€–vβ€– ^ 2 * max C 0 := mul_le_mul_of_nonneg_left (hbound'.trans (le_max_left C 0)) (sq_nonneg _) _ = max C 0 * g.inner x v v := by rw [hnorm]; ring private theorem exists_local_distance_exp_comparison [T3Space M] [PreconnectedSpace M] (F : RicciFlow n M J) (hTensor : βˆ€ t, (F.connection t).CurvatureTensorCalculus) {a b : ℝ} (hJ : Icc a b βŠ† interior J) (hcomplete : MetricComplete (F.metric b)) (hRic : βˆ€ t ∈ Icc a b, βˆ€ x : M, βˆ€ v : TangentSpace (𝓑 n) x, 0 ≀ (F.connection t).ricci x v v) (O : M) {r : ℝ} (hr : 0 < r) : βˆƒ C : ℝ, 0 ≀ C ∧ βˆ€ s ∈ Icc a b, βˆ€ t ∈ Icc a b, βˆ€ y ∈ (F.metric a).ball O r, ((F.metric t).edist O y).toReal ≀ Real.exp (C * |t - s|) * ((F.metric s).edist O y).toReal := by obtain ⟨C, hCnonneg, hbound⟩ := exists_ricci_bound_on_compact_relative F hTensor (F.metric b) hJ ((F.metric b).isCompact_closedBall_of_metricComplete hcomplete O (3 * r)) refine ⟨C, hCnonneg, ?_⟩ intro s hs t ht y hy have hab : a ≀ b := hs.1.trans hs.2 have ha : a ∈ Icc a b := ⟨le_rfl, hab⟩ have hb : b ∈ Icc a b := ⟨hab, le_rfl⟩ have hy' : y ∈ (F.metric s).ball O r := F.ball_subset_ball_of_ricci_nonneg hJ O r ha hs hs.1 (fun Ο„ hΟ„ z _ v => hRic Ο„ hΟ„ z v) hy have hO : O ∈ (F.metric s).ball O r := by simpa only [RiemannianMetric.ball, mem_ofPred_eq, RiemannianMetric.edist, Manifold.riemannianEDist_self] using ENNReal.ofReal_pos.mpr hr have hdist := F.edist_le_exp_mul_of_ricci_bound (convex_Icc a b) (hJ.trans interior_subset) O r C hr hs ht (fun Ο„ hΟ„ z hz v => by have hz' : (F.metric b).edist O z ≀ ENNReal.ofReal (3 * r) := (F.ball_subset_ball_of_ricci_nonneg hJ O (3 * r) hs hb hs.2 (fun q hq w _ u => hRic q hq w u) hz).le exact (hbound Ο„ hΟ„ z hz' v).trans (mul_le_mul_of_nonneg_left (F.antitoneOn_metric_inner_self_of_ricci_nonneg hJ z v (fun q hq => hRic q hq z v) hΟ„ hb hΟ„.2) hCnonneg)) hO hy' have hfinite : ENNReal.ofReal (Real.exp (C * |t - s|)) * (F.metric s).edist O y β‰  ⊀ := ENNReal.mul_ne_top ENNReal.ofReal_ne_top ((F.metric s).edist_ne_top O y) simpa only [ENNReal.toReal_mul, ENNReal.toReal_ofReal (Real.exp_nonneg _)] using ENNReal.toReal_mono hfinite hdist /-- Distances are jointly continuous on a compact interior time interval under nonnegative Ricci curvature. Only the terminal metric must be complete. -/ private theorem continuousOn_toReal_edist_of_ricci_nonneg_aux [T3Space M] [PreconnectedSpace M] (F : RicciFlow n M J) (hTensor : βˆ€ t, (F.connection t).CurvatureTensorCalculus) {a b : ℝ} (hJ : Icc a b βŠ† interior J) (hcomplete : MetricComplete (F.metric b)) (hRic : βˆ€ t ∈ Icc a b, βˆ€ x : M, βˆ€ v : TangentSpace (𝓑 n) x, 0 ≀ (F.connection t).ricci x v v) (O : M) : ContinuousOn (fun p : ℝ Γ— M => ((F.metric p.1).edist O p.2).toReal) (Icc a b Γ—Λ’ univ) := by intro p hp let r := ((F.metric a).edist O p.2).toReal + 1 have hr : 0 < r := by dsimp only [r]; positivity have hpball : ((F.metric a).edist O p.2).toReal < r := lt_add_one _ obtain ⟨C, _, hcompare⟩ := exists_local_distance_exp_comparison F hTensor hJ hcomplete hRic O hr have hnear : βˆ€αΆ  q : ℝ Γ— M in 𝓝 p, q.2 ∈ (F.metric a).ball O r := by have hh := (((F.metric a).continuous_toReal_edist O).comp continuous_snd).continuousAt |>.eventually_lt_const hpball filter_upwards [hh] with q hq change (F.metric a).edist O q.2 < ENNReal.ofReal r rw [← ENNReal.ofReal_toReal ((F.metric a).edist_ne_top O q.2)] exact (ENNReal.ofReal_lt_ofReal_iff hr).mpr hq let D : ℝ Γ— M β†’ ℝ := fun q => ((F.metric p.1).edist O q.2).toReal let E : ℝ Γ— M β†’ ℝ := fun q => Real.exp (C * |q.1 - p.1|) have hD : Continuous D := ((F.metric p.1).continuous_toReal_edist O).comp continuous_snd have hE : Continuous E := by dsimp only [E]; fun_prop have hupper : Tendsto (fun q => E q * D q) (𝓝[Icc a b Γ—Λ’ univ] p) (𝓝 (((F.metric p.1).edist O p.2).toReal)) := by convert ((hE.mul hD).continuousAt (x := p)).tendsto.mono_left (nhdsWithin_le_nhds : 𝓝[Icc a b Γ—Λ’ univ] p ≀ 𝓝 p) using 1 <;> first | rfl | simp [E, D] have hlower : Tendsto (fun q => (E q)⁻¹ * D q) (𝓝[Icc a b Γ—Λ’ univ] p) (𝓝 (((F.metric p.1).edist O p.2).toReal)) := by convert ((hE.continuousAt.invβ‚€ (Real.exp_ne_zero _)).mul hD.continuousAt).tendsto.mono_left (nhdsWithin_le_nhds : 𝓝[Icc a b Γ—Λ’ univ] p ≀ 𝓝 p) using 1 <;> first | rfl | simp [E, D] apply tendsto_of_tendsto_of_tendsto_of_le_of_le' hlower hupper Β· filter_upwards [self_mem_nhdsWithin, hnear.filter_mono nhdsWithin_le_nhds] with q hq hqy apply (inv_mul_le_iffβ‚€ (Real.exp_pos _)).mpr simpa only [E, D, abs_sub_comm p.1 q.1] using hcompare q.1 hq.1 p.1 hp.1 q.2 hqy Β· filter_upwards [self_mem_nhdsWithin, hnear.filter_mono nhdsWithin_le_nhds] with q hq hqy exact hcompare p.1 hp.1 q.1 hq.1 q.2 hqy /-- Joint continuity of distance from a fixed point under nonnegative Ricci curvature, using the supplied curvature theory. -/ theorem continuousOn_toReal_edist_of_ricci_nonneg [T3Space M] [PreconnectedSpace M] (hC : RicciFlowCurvatureCalculus.{u}) (F : RicciFlow n M J) {a b : ℝ} (hJ : Icc a b βŠ† interior J) (hcomplete : MetricComplete (F.metric b)) (hRic : βˆ€ t ∈ Icc a b, βˆ€ x : M, βˆ€ v : TangentSpace (𝓑 n) x, 0 ≀ (F.connection t).ricci x v v) (O : M) : ContinuousOn (fun p : ℝ Γ— M => ((F.metric p.1).edist O p.2).toReal) (Icc a b Γ—Λ’ univ) := continuousOn_toReal_edist_of_ricci_nonneg_aux F (fun t => hC.tensor_calculus n M (F.metric t) (F.connection t)) hJ hcomplete hRic O /-- The intrinsic tensor calculus gives distance continuity without a separate curvature-theory service. -/ theorem continuousOn_toReal_edist_of_ricci_nonneg_intrinsic [T3Space M] [PreconnectedSpace M] (F : RicciFlow n M J) {a b : ℝ} (hJ : Icc a b βŠ† interior J) (hcomplete : MetricComplete (F.metric b)) (hRic : βˆ€ t ∈ Icc a b, βˆ€ x : M, βˆ€ v : TangentSpace (𝓑 n) x, 0 ≀ (F.connection t).ricci x v v) (O : M) : ContinuousOn (fun p : ℝ Γ— M => ((F.metric p.1).edist O p.2).toReal) (Icc a b Γ—Λ’ univ) := continuousOn_toReal_edist_of_ricci_nonneg_aux F (fun t => (F.connection t).intrinsicCurvatureTensorCalculus) hJ hcomplete hRic O end PoincareMT.RicciFlow