import PoincareLib.Geometry.RicciFlow.CurveShortening.Evolution.Speed import PoincareLib.Geometry.RicciFlow.CurveShortening.Connection.Pullback import Mathlib.Geometry.Manifold.ContMDiffMFDeriv import Mathlib.Analysis.SpecialFunctions.Sqrt /-! # Spatial regularity and curvature orthogonality The primitive C2 slices give C1 velocity, speed and unit tangent, including at the closed time endpoints. Metric compatibility then gives the actual identity `g(H,S) = 0`. This follows Morgan--Tian Lemma 19.6, pp. 441-442, and the 2015 correction, Lemma 0.1, p. 3. See the checked derivation in `references/ricci-flow/mapher/curve-evolution/derivations/2026-09-19-spatial-orthogonality.md`. -/ set_option autoImplicit false set_option maxSynthPendingDepth 3 set_option backward.isDefEq.respectTransparency false open scoped Manifold ContDiff Bundle Topology open Filter universe u namespace PoincareMT.M62 variable {n : โ„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace โ„ (Fin n)) M] [IsManifold (๐“ก n) โˆž M] {a b : โ„} (F : RicciFlow n M (Set.Icc a b)) (c : โ„ โ†’ โ„ โ†’ M) /-- C2 spatial slices have C1 actual velocity; MT2007 Lemma 19.6, p. 441. -/ theorem spatial_velocity_contMDiff (hc : M62ShrinkingCurve F c) {t : โ„} (ht : t โˆˆ Set.Icc a b) : ContMDiff (๐“˜(โ„, โ„)) ((๐“ก n).prod (๐“ก n)) 1 (fun x โ†ฆ (โŸจc x t, curveVelocity (fun y โ†ฆ c y t) xโŸฉ : TangentBundle (๐“ก n) M)) := by have hone : ContMDiff (๐“˜(โ„, โ„)) (๐“˜(โ„, โ„)).tangent 1 (fun x : โ„ โ†ฆ (โŸจx, 1โŸฉ : TangentBundle (๐“˜(โ„, โ„)) โ„)) := by apply contMDiff_vectorSpace_iff_contDiff.mpr exact contDiff_const exact ((hc.spatial_regular t ht).contMDiff_tangentMap (m := 1) (by norm_num)).comp hone /-- Immersion makes the actual speed C1 on every included slice; MT2007 p. 441. -/ theorem speed_contDiff (hc : M62ShrinkingCurve F c) {t : โ„} (ht : t โˆˆ Set.Icc a b) : ContDiff โ„ 1 (curveSpeed F c t) := by have hX := spatial_velocity_contMDiff F c hc ht have hฮณ : ContMDiff (๐“˜(โ„, โ„)) (๐“ก n) 1 (fun x โ†ฆ c x t) := (hc.spatial_regular t ht).of_le (by norm_num) have hpair : ContMDiff (๐“˜(โ„, โ„)) ((๐“ก n).prod (๐“˜(โ„, โ„))) 1 (fun x โ†ฆ Bundle.TotalSpace.mk' โ„ (E := Bundle.Trivial M โ„) (c x t) ((F.metric t).inner (c x t) (curveVelocity (fun y โ†ฆ c y t) x) (curveVelocity (fun y โ†ฆ c y t) x))) := (((F.metric t).contMDiff.of_le (show (1 : WithTop โ„•โˆž) โ‰ค โˆž by simp)).comp hฮณ).clm_bundle_applyโ‚‚ hX hX have hsq : ContMDiff (๐“˜(โ„, โ„)) (๐“˜(โ„, โ„)) 1 (fun x โ†ฆ (F.metric t).inner (c x t) (curveVelocity (fun y โ†ฆ c y t) x) (curveVelocity (fun y โ†ฆ c y t) x)) := by intro x exact (Bundle.contMDiffAt_totalSpace.mp (hpair x)).2 exact hsq.contDiff.sqrt fun x โ†ฆ ((F.metric t).pos _ _ (hc.immersed t ht x)).ne' /-- The actual unit tangent is C1 on each C2 immersed slice; MT2007 p. 441. -/ theorem unitTangent_contMDiff (hc : M62ShrinkingCurve F c) {t : โ„} (ht : t โˆˆ Set.Icc a b) : ContMDiff (๐“˜(โ„, โ„)) ((๐“ก n).prod (๐“ก n)) 1 (fun x โ†ฆ (โŸจc x t, spatialUnitTangent F c t xโŸฉ : TangentBundle (๐“ก n) M)) := by have hX := spatial_velocity_contMDiff F c hc ht have hv : ContMDiff (๐“˜(โ„, โ„)) (๐“˜(โ„, โ„)) 1 (fun x โ†ฆ (curveSpeed F c t x)โปยน) := ((speed_contDiff F c hc ht).inv (fun x โ†ฆ (speed_pos F c hc ht x).ne')).contMDiff intro x rw [Bundle.contMDiffAt_totalSpace] refine โŸจ((hc.spatial_regular t ht).of_le (by norm_num) x), ?_โŸฉ have hcoord := (hv x).smul (Bundle.contMDiffAt_totalSpace.mp (hX x)).2 apply hcoord.congr_of_eventuallyEq let e := trivializationAt (EuclideanSpace โ„ (Fin n)) (TangentSpace (๐“ก n)) (c x t) have hnear : โˆ€แถ  y in ๐“ x, c y t โˆˆ e.baseSet := (hc.spatial_regular t ht).continuous.continuousAt (e.open_baseSet.mem_nhds (FiberBundle.mem_baseSet_trivializationAt' (c x t))) filter_upwards [hnear] with y hy change (e โŸจc y t, (curveSpeed F c t y)โปยน โ€ข curveVelocity (fun z โ†ฆ c z t) yโŸฉ).2 = (curveSpeed F c t y)โปยน โ€ข (e โŸจc y t, curveVelocity (fun z โ†ฆ c z t) yโŸฉ).2 simpa only [e.continuousLinearMapAt_apply_of_mem โ„ hy] using (e.continuousLinearMapAt โ„ (c y t)).map_smul (curveSpeed F c t y)โปยน (curveVelocity (fun z โ†ฆ c z t) y) /-- The curvature vector is orthogonal to the unit tangent, including on endpoint slices; MT2007 Lemma 19.6, pp. 441-442, and correction Lemma 0.1, p. 3. -/ theorem curvature_unitTangent_inner_zero (hc : M62ShrinkingCurve F c) {t : โ„} (ht : t โˆˆ Set.Icc a b) (x : โ„) : (F.metric t).inner (c x t) (m62CurvatureVector F c t x) (spatialUnitTangent F c t x) = 0 := by have hS := (unitTangent_contMDiff F c hc ht x).mdifferentiableAt (by simp) have hpair := hasDerivAt_metric_pairing (F.connection t) ((hc.spatial_regular t ht x).mdifferentiableAt (by norm_num)) hS hS have hconst : (fun y โ†ฆ (F.metric t).inner (c y t) (spatialUnitTangent F c t y) (spatialUnitTangent F c t y)) = fun _ : โ„ โ†ฆ (1 : โ„) := funext (unitTangent_inner_self F c hc ht) rw [hconst] at hpair have heq := hpair.unique (hasDerivAt_const x (1 : โ„)) have hz : (F.metric t).inner (c x t) (rampHorizontalCovariantDerivative (F.connection t) (fun y โ†ฆ c y t) (spatialUnitTangent F c t) x) (spatialUnitTangent F c t x) = 0 := by rw [(F.metric t).symm (c x t) (spatialUnitTangent F c t x)] at heq linarith simp only [m62CurvatureVector, m62SpatialDerivative, map_smul, smul_apply, smul_eq_mul, hz, mul_zero] end PoincareMT.M62