import PoincareLib.Geometry.CurveShortening.Ramp.Analysis.Spatial.PartialDerivative import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.Ambient.CurveCoefficients import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.C2.GaugeWitnesses import PoincareLib.Geometry.RicciFlow.CurveShortening.Evolution.Speed import Mathlib.Analysis.Calculus.Deriv.Shift /-! # Actual normal-label velocity The spatial derivative of the principal coefficient is the exact speed-cubed coefficient in the normal-label equation. Its closed regularity comes from actual ambient jets. MT2007 Claim 19.1, p. 437 and Lemma 19.6, pp. 441-442; `2026-09-22-ambient-label-velocity.md`, statements 2-3. -/ set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set open scoped Manifold ContDiff universe u v namespace PoincareMT.M63 variable {n : โ„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace โ„ (Fin n)) M] [IsManifold (๐“ก n) โˆž M] {ฮน : Type v} [Fintype ฮน] {a b : โ„} local notation "W" => EuclideanSpace โ„ ฮน /-- The literal label velocity is smooth on the closed initial slab and retains the spatial period. MT2007 Claim 19.1, p. 437; ambient label-velocity derivation, statement 2. -/ theorem ambientCurve_labelVelocity_regular (F : RicciFlow n M (Icc a b)) {U : Set W} (hU : IsOpen U) {ฯ : W โ†’ M} (hฯ : ContMDiffOn ๐“˜(โ„, W) (๐“ก n) โˆž ฯ U) {T L : โ„} (hT : 0 < T) (hTb : a + T โ‰ค b) {q : โ„ โ†’ โ„ โ†’ W} (hq : ContDiffOn โ„ โˆž (Function.uncurry q) (Icc 0 T ร—หข univ)) (hper : โˆ€ t โˆˆ Icc 0 T, Function.Periodic (q t) L) (hguard : โˆ€ t โˆˆ Icc 0 T, โˆ€ x, q t x โˆˆ U โˆง mfderiv ๐“˜(โ„, W) (๐“ก n) ฯ (q t x) (deriv (q t) x) โ‰  0) : let A := fun t x => ambientCurvePrincipal F ฯ (a + t) (q t x) (deriv (q t) x) let w := fun t x => deriv (A t) x / 2 ContDiffOn โ„ โˆž (Function.uncurry w) (Icc 0 T ร—หข univ) โˆง โˆ€ t โˆˆ Icc 0 T, Function.Periodic (w t) L := by let A := fun t x => ambientCurvePrincipal F ฯ (a + t) (q t x) (deriv (q t) x) have hqx := contDiffOn_spatial_deriv_of_uniqueDiffOn (uniqueDiffOn_Icc hT) (m := โˆž) (by simp) hq have hparam : ContDiffOn โ„ โˆž (fun z : โ„ ร— โ„ => ((a + z.1, q z.1 z.2), deriv (q z.1) z.2)) (Icc 0 T ร—หข univ) := ((contDiffOn_const.add contDiffOn_fst).prodMk hq).prodMk hqx have hmap : MapsTo (fun z : โ„ ร— โ„ => ((a + z.1, q z.1 z.2), deriv (q z.1) z.2)) (Icc 0 T ร—หข univ) {z : (โ„ ร— W) ร— W | z.1.1 โˆˆ Icc a b โˆง z.1.2 โˆˆ U โˆง mfderiv ๐“˜(โ„, W) (๐“ก n) ฯ z.1.2 z.2 โ‰  0} := by intro z hz exact โŸจโŸจby linarith [hz.1.1], by linarith [hz.1.2]โŸฉ, hguard z.1 hz.1 z.2โŸฉ have hA : ContDiffOn โ„ โˆž (Function.uncurry A) (Icc 0 T ร—หข univ) := (ambientCurveCoefficients_contDiffOn F (e := fun _ => 0) contMDiff_const hU hฯ).1.comp hparam hmap have hAx := contDiffOn_spatial_deriv_of_uniqueDiffOn (uniqueDiffOn_Icc hT) (m := โˆž) (by simp) hA refine โŸจhAx.div_const 2, ?_โŸฉ intro t ht x have hqxper : Function.Periodic (deriv (q t)) L := by intro y rw [โ† deriv_comp_add_const, show (fun z => q t (z + L)) = q t from funext (hper t ht)] have hAper : Function.Periodic (A t) L := by intro y dsimp only [A] rw [hper t ht y, hqxper y] change deriv (A t) (x + L) / 2 = deriv (A t) x / 2 rw [โ† deriv_comp_add_const, show (fun y => A t (y + L)) = A t from funext hAper] /-- The actual principal derivative is the geometric coefficient that cancels tangential velocity, for any C2 immersed projected slice. MT2007 Lemma 19.6, pp. 441-442; label-velocity derivation, statement 3. -/ theorem ambientCurve_labelVelocity_eq (F : RicciFlow n M (Icc a b)) {U : Set W} (hU : IsOpen U) {ฯ : W โ†’ M} (hฯ : ContMDiffOn ๐“˜(โ„, W) (๐“ก n) โˆž ฯ U) (t : โ„) {f : โ„ โ†’ W} (hf : ContDiff โ„ 2 f) (hguard : โˆ€ x, f x โˆˆ U โˆง mfderiv ๐“˜(โ„, W) (๐“ก n) ฯ (f x) (deriv f x) โ‰  0) : let c := fun y (_ : โ„) => ฯ (f y) let A := fun x => ambientCurvePrincipal F ฯ t (f x) (deriv f x) let v := curveSpeed F c t โˆ€ x, deriv A x / 2 = -(deriv v x / v x ^ 3) := by let c := fun y (_ : โ„) => ฯ (f y) let A := fun x => ambientCurvePrincipal F ฯ t (f x) (deriv f x) let v := curveSpeed F c t change โˆ€ x, deriv A x / 2 = -(deriv v x / v x ^ 3) have hspace : ContMDiff ๐“˜(โ„, โ„) (๐“ก n) 2 (fun y => c y t) := (hฯ.of_le (ENat.natCast_le_of_coe_top_le_withTop le_rfl 2)).comp_contMDiff hf.contMDiff (fun x => (hguard x).1) have hvel (x : โ„) : curveVelocity (n := n) (fun y => c y t) x = mfderiv ๐“˜(โ„, W) (๐“ก n) ฯ (f x) (deriv f x) := by change (mfderiv ๐“˜(โ„, โ„) (๐“ก n) (ฯ โˆ˜ f) x) 1 = _ erw [mfderiv_comp x ((hฯ.contMDiffAt (hU.mem_nhds (hguard x).1)).mdifferentiableAt (by simp)) ((hf.contMDiff x).mdifferentiableAt (by norm_num)), ContinuousLinearMap.comp_apply, mfderiv_eq_fderiv] rfl have himm (x : โ„) : curveVelocity (n := n) (fun y => c y t) x โ‰  0 := by rw [hvel] exact (hguard x).2 have hv : ContDiff โ„ 1 v := speed_contDiff_of_c2 F c hspace himm have hvpos (x : โ„) : 0 < v x := Real.sqrt_pos.mpr ((F.metric t).pos _ _ (himm x)) have hA : A = fun y => (v y ^ 2)โปยน := by funext y dsimp only [A, ambientCurvePrincipal] rw [โ† hvel y] exact congrArg (fun z : โ„ => zโปยน) (M62.speed_sq F c t y).symm intro x have hne : v x โ‰  0 := (hvpos x).ne' have hd : HasDerivAt A (-2 * deriv v x / v x ^ 3) x := by rw [hA] convert! (((hv.differentiable (by simp) x).hasDerivAt.pow 2).inv (pow_ne_zero 2 (hvpos x).ne')) using 1 simp only [Pi.pow_apply] field_simp [hne] ring change deriv A x / 2 = -(deriv v x / v x ^ 3) rw [hd.deriv] ring end PoincareMT.M63