import PoincareLib.Geometry.RicciFlow.ReducedGeometry.LGeometry.Basic import Mathlib.Geometry.Manifold.MFDeriv.NormedSpace import Mathlib.Geometry.Manifold.MFDeriv.SpecificFunctions import Mathlib.Analysis.Calculus.Deriv.Comp /-! # Differentiating a parametric function along a manifold curve The product chain rule separates the explicit parameter derivative from the spatial derivative. The conclusion retains an actual derivative witness. -/ set_option autoImplicit false open scoped Manifold ContDiff namespace PoincareMT.ReducedLength variable {n : โ„•} {M : Type*} [TopologicalSpace M] [ChartedSpace (EuclideanSpace โ„ (Fin n)) M] [IsManifold (๐“ก n) โˆž M] {W : Type*} [NormedAddCommGroup W] [NormedSpace โ„ W] set_option backward.isDefEq.respectTransparency false in theorem hasDerivAt_parametric_curve (f : โ„ ร— M โ†’ W) (ฮณ : โ„ โ†’ M) (s : โ„) (hf : MDifferentiableAt ((๐“˜(โ„, โ„)).prod (๐“ก n)) (๐“˜(โ„, W)) f (s, ฮณ s)) (hฮณ : MDifferentiableAt (๐“˜(โ„, โ„)) (๐“ก n) ฮณ s) : HasDerivAt (fun t โ†ฆ f (t, ฮณ t)) (deriv (fun t โ†ฆ f (t, ฮณ s)) s + mvfderiv (๐“ก n) (fun x โ†ฆ f (s, x)) (ฮณ s) (curveVelocity ฮณ s)) s := by have hgraph := (hasMFDerivAt_id (I := ๐“˜(โ„, โ„)) s).prodMk hฮณ.hasMFDerivAt have hcomp := (hf.hasMFDerivAt.comp s hgraph).hasFDerivAt.hasDerivAt have hsplit := mfderiv_prod_eq_add_apply (I := ๐“˜(โ„, โ„)) (I' := ๐“ก n) (I'' := ๐“˜(โ„, W)) (v := (1, curveVelocity ฮณ s)) hf have htime : mfderiv (๐“˜(โ„, โ„)) (๐“˜(โ„, W)) (fun t โ†ฆ f (t, ฮณ s)) s 1 = deriv (fun t โ†ฆ f (t, ฮณ s)) s := by exact (congrArg (fun L : โ„ โ†’L[โ„] W โ†ฆ L 1) (mfderiv_eq_fderiv (f := fun t โ†ฆ f (t, ฮณ s)) (x := s))).trans fderiv_apply_one_eq_deriv have hvalue : mfderiv ((๐“˜(โ„, โ„)).prod (๐“ก n)) (๐“˜(โ„, W)) f (s, ฮณ s) (1, curveVelocity ฮณ s) = deriv (fun t โ†ฆ f (t, ฮณ s)) s + mvfderiv (๐“ก n) (fun x โ†ฆ f (s, x)) (ฮณ s) (curveVelocity ฮณ s) := by exact hsplit.trans (congrArg (ยท + mvfderiv (๐“ก n) (fun x โ†ฆ f (s, x)) (ฮณ s) (curveVelocity ฮณ s)) htime) convert! hcomp using 1 exact hvalue.symm end PoincareMT.ReducedLength