import PoincareLib.Geometry.CurveShortening.Comparison.Compatibility.SourceNames import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.Embedding.HessianVector import PoincareLib.Geometry.CurveShortening.Ramp.LocalEstimates.Curve.TensorLeibniz import Mathlib.Analysis.Calculus.Deriv.Prod /-! # Witnessed product rules for embedded curvature The actual selected connection and scalar Hessian identify derivatives in the fixed Euclidean target. MT2007 Claim 19.1, p. 437; MT2015Correction Lemmas 0.1--0.2, pp. 3--6. See `2026-09-22-c2-embedded-product-rules.md`, statements 2--3. -/ set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set Bundle Manifold open scoped Manifold ContDiff Bundle BigOperators universe u v namespace PoincareMT.M63 variable {n : β„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] {ΞΉ : Type v} [Fintype ΞΉ] local notation "W" => EuclideanSpace ℝ ΞΉ /-- Differentiate the actual differential applied to a moving tangent field, with the literal coordinate Hessian and selected pullback connection. MT2007 Claim 19.1, p. 437; embedded-product derivation, statement 2. No injectivity of the smooth map is required. -/ theorem hasDerivAt_embedding_pushforward {g : RiemannianMetric n M} (D : LeviCivitaData g) {e : M β†’ W} (he : ContMDiff (𝓑 n) π“˜(ℝ, W) ∞ e) {gamma : ℝ β†’ M} {x : ℝ} (hgamma : ContMDiffAt π“˜(ℝ, ℝ) (𝓑 n) ∞ gamma x) (Y : (s : ℝ) β†’ TangentSpace (𝓑 n) (gamma s)) (hY : MDifferentiableAt π“˜(ℝ, ℝ) (𝓑 n).tangent (fun s => (⟨gamma s, Y s⟩ : TangentBundle (𝓑 n) M)) x) : HasDerivAt (fun s => (mfderiv (𝓑 n) π“˜(ℝ, W) e (gamma s) (Y s) : W)) (HAdd.hAdd (Ξ± := W) (Ξ² := W) (Ξ³ := W) (coordinateHessian D e (gamma x) (curveVelocity gamma x) (Y x)) (mfderiv (𝓑 n) π“˜(ℝ, W) e (gamma x) (rampHorizontalCovariantDerivative D gamma Y x))) x := by classical have hcoord (i : ΞΉ) : HasDerivAt (fun s => EuclideanSpace.proj i (mfderiv (𝓑 n) π“˜(ℝ, W) e (gamma s) (Y s))) (EuclideanSpace.proj i (HAdd.hAdd (Ξ± := W) (Ξ² := W) (Ξ³ := W) (coordinateHessian D e (gamma x) (curveVelocity gamma x) (Y x)) (mfderiv (𝓑 n) π“˜(ℝ, W) e (gamma x) (rampHorizontalCovariantDerivative D gamma Y x)))) x := by let f : M β†’ ℝ := fun p => e p i have hf : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ f := (EuclideanSpace.proj i).contDiff.contMDiff.comp he let T0 : CovariantTensorEvaluation n M 0 := fun p _ => f p have hT0 : IsSmoothCovariantTensor T0 := by constructor Β· intro p exact ⟨MultilinearMap.constOfIsEmpty ℝ (fun _ : Fin 0 => TangentSpace (𝓑 n) p) (f p), fun _ => rfl⟩ Β· intro U hU Z hZ exact hf.contMDiffOn let T1 := D.covariantTensorDerivative T0 have hT1 : IsSmoothCovariantTensor T1 := M04.isSmoothCovariantTensor_covariantTensorDerivative D hT0 have hdf (p : M) (w : Fin 1 β†’ TangentSpace (𝓑 n) p) : T1 p w = mvfderiv (𝓑 n) f p (w 0) := by simp [T1, T0, LeviCivitaData.covariantTensorDerivative] have hHessian (p : M) (w : Fin 2 β†’ TangentSpace (𝓑 n) p) : D.covariantTensorDerivative T1 p w = D.hessian f p (w 0) (w 1) := by have h01 : (Fin.succ 0 : Fin 2) = 1 := by decide rw [LeviCivitaData.covariantTensorDerivative] simp only [hdf, Fin.sum_univ_succ, Fin.sum_univ_zero, Function.update_self, LeviCivitaData.hessian, LeviCivitaData.hessianOnFields, FiberBundle.extend_apply_self, add_zero, h01] have hproj (p : M) (V : TangentSpace (𝓑 n) p) : mvfderiv (𝓑 n) f p V = EuclideanSpace.proj i (mfderiv (𝓑 n) π“˜(ℝ, W) e p V) := by let L : W β†’L[ℝ] ℝ := EuclideanSpace.proj i change mvfderiv (𝓑 n) (L ∘ e) p V = _ rw [mvfderiv_comp_apply p L.differentiableAt.mdifferentiableAt (he.mdifferentiable (by simp) p) V] simpa only [mvfderiv, mfderiv_eq_fderiv, ContinuousLinearMap.comp_apply] using! congrArg (fun K : W β†’L[ℝ] ℝ => K (mfderiv (𝓑 n) π“˜(ℝ, W) e p V)) (L.fderiv (x := e p)) have hscalar := m63HasDerivAt_tensor_pullback D T1 hT1 hgamma (fun (_ : Fin 1) s => Y s) (fun _ => hY) simpa [hdf, hHessian, hproj, Fin.sum_univ_succ, coordinateHessian, f] using hscalar let L : (ΞΉ β†’ ℝ) ≃L[ℝ] W := (PiLp.continuousLinearEquiv 2 ℝ (fun _ : ΞΉ => ℝ)).symm have hpi := hasDerivAt_pi.mpr hcoord have h := L.toContinuousLinearMap.hasFDerivAt.comp_hasDerivAt x hpi convert! h using 1 /-- The actual coordinate Hessian differentiates its leading tensor and both moving arguments. Its covariant derivative inserts the actual velocity in the first slot. MT2007 Claim 19.1, p. 437; embedded-product derivation, statement 3. -/ theorem hasDerivAt_coordinateHessian_pullback {g : RiemannianMetric n M} (D : LeviCivitaData g) {e : M β†’ W} (he : ContMDiff (𝓑 n) π“˜(ℝ, W) ∞ e) {gamma : ℝ β†’ M} {x : ℝ} (hgamma : ContMDiffAt π“˜(ℝ, ℝ) (𝓑 n) ∞ gamma x) (Y Z : (s : ℝ) β†’ TangentSpace (𝓑 n) (gamma s)) (hY : MDifferentiableAt π“˜(ℝ, ℝ) (𝓑 n).tangent (fun s => (⟨gamma s, Y s⟩ : TangentBundle (𝓑 n) M)) x) (hZ : MDifferentiableAt π“˜(ℝ, ℝ) (𝓑 n).tangent (fun s => (⟨gamma s, Z s⟩ : TangentBundle (𝓑 n) M)) x) : let T : ΞΉ β†’ CovariantTensorEvaluation n M 2 := fun i p w => D.hessian (fun q => e q i) p (w 0) (w 1) HasDerivAt (fun s => coordinateHessian D e (gamma s) (Y s) (Z s)) (WithLp.toLp 2 (fun i => D.covariantTensorDerivative (T i) (gamma x) ![curveVelocity gamma x, Y x, Z x]) + coordinateHessian D e (gamma x) (rampHorizontalCovariantDerivative D gamma Y x) (Z x) + coordinateHessian D e (gamma x) (Y x) (rampHorizontalCovariantDerivative D gamma Z x)) x := by classical dsimp only let T : ΞΉ β†’ CovariantTensorEvaluation n M 2 := fun i p w => D.hessian (fun q => e q i) p (w 0) (w 1) have hcoord (i : ΞΉ) : HasDerivAt (fun s => (coordinateHessian D e (gamma s) (Y s) (Z s)) i) ((WithLp.toLp 2 (fun j => D.covariantTensorDerivative (T j) (gamma x) ![curveVelocity gamma x, Y x, Z x]) + coordinateHessian D e (gamma x) (rampHorizontalCovariantDerivative D gamma Y x) (Z x) + coordinateHessian D e (gamma x) (Y x) (rampHorizontalCovariantDerivative D gamma Z x)) i) x := by have hf : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ (fun p => e p i) := (EuclideanSpace.proj i).contDiff.contMDiff.comp he have hT : IsSmoothCovariantTensor (T i) := M04.isSmoothCovariantTensor_hessian D hf have hfields : βˆ€ j : Fin 2, MDifferentiableAt π“˜(ℝ, ℝ) (𝓑 n).tangent (fun s => (⟨gamma s, ![Y, Z] j s⟩ : TangentBundle (𝓑 n) M)) x := by intro j fin_cases j Β· exact hY Β· exact hZ have hscalar := m63HasDerivAt_tensor_pullback D (T i) hT hgamma ![Y, Z] hfields have htuple : (fun j : Fin 2 => ![Y, Z] j x) = ![Y x, Z x] := by funext j fin_cases j <;> rfl rw [htuple] at hscalar simpa [T, Fin.sum_univ_succ, coordinateHessian, add_assoc] using hscalar let L : (ΞΉ β†’ ℝ) ≃L[ℝ] W := (PiLp.continuousLinearEquiv 2 ℝ (fun _ : ΞΉ => ℝ)).symm have hpi := hasDerivAt_pi.mpr hcoord have h := L.toContinuousLinearMap.hasFDerivAt.comp_hasDerivAt x hpi convert! h using 1 end PoincareMT.M63