import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Coordinates.ConnectionFrame import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Mul /-! # Coefficients of a parametric section in a fixed local frame The coefficients are the actual localFrameCoeff functions. Their local trivialization expression yields differentiability in parameter and position. -/ set_option autoImplicit false open scoped Manifold ContDiff Bundle Topology BigOperators open Filter namespace PoincareMT.ReducedLength variable {n : β„•} {M : Type*} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] local notation "V" => EuclideanSpace ℝ (Fin n) set_option backward.isDefEq.respectTransparency false in theorem mdifferentiableAt_parametric_frameCoeff {ΞΉ : Type*} (b : Module.Basis ΞΉ ℝ V) (p q : M) (s : ℝ) (H : ℝ β†’ (x : M) β†’ TangentSpace (𝓑 n) x) (hq : q ∈ (trivializationAt V (TangentSpace (𝓑 n) : M β†’ Type _) p).baseSet) (hH : MDifferentiableAt ((π“˜(ℝ, ℝ)).prod (𝓑 n)) ((𝓑 n).prod (𝓑 n)) (fun z : ℝ Γ— M ↦ Bundle.TotalSpace.mk' V z.2 (H z.1 z.2)) (s, q)) (i : ΞΉ) : let e := trivializationAt V (TangentSpace (𝓑 n) : M β†’ Type _) p MDifferentiableAt ((π“˜(ℝ, ℝ)).prod (𝓑 n)) (π“˜(ℝ, ℝ)) (fun z : ℝ Γ— M ↦ e.localFrameCoeff (𝓑 n) b i z.2 (H z.1 z.2)) (s, q) := by let e := trivializationAt V (TangentSpace (𝓑 n) : M β†’ Type _) p let B : ℝ Γ— M β†’ TangentBundle (𝓑 n) M := fun z ↦ Bundle.TotalSpace.mk' V z.2 (H z.1 z.2) have hB : MDifferentiableAt ((π“˜(ℝ, ℝ)).prod (𝓑 n)) (𝓑 n) (fun z ↦ (e (B z)).2) (s, q) := ((e.mdifferentiableAt_totalSpace_iff (𝓑 n) B (e.mem_source.mpr hq)).mp hH).2 let c : V β†’L[ℝ] ℝ := (b.coord i).toContinuousLinearMap have hc := c.mdifferentiableAt.comp (s, q) hB apply hc.congr_of_eventuallyEq filter_upwards [continuous_snd.continuousAt.preimage_mem_nhds (e.open_baseSet.mem_nhds hq)] with z hz exact e.localFrameCoeff_eq_coeff (I := 𝓑 n) (b := b) (s := H z.1) hz set_option backward.isDefEq.respectTransparency false in theorem parametric_frame_time_derivative {ΞΉ : Type*} [Fintype ΞΉ] (g : RiemannianMetric n M) (b : Module.Basis ΞΉ ℝ V) (p q : M) (s : ℝ) (H : ℝ β†’ (x : M) β†’ TangentSpace (𝓑 n) x) (hq : q ∈ (trivializationAt V (TangentSpace (𝓑 n) : M β†’ Type _) p).baseSet) (hH : MDifferentiableAt ((π“˜(ℝ, ℝ)).prod (𝓑 n)) ((𝓑 n).prod (𝓑 n)) (fun z : ℝ Γ— M ↦ Bundle.TotalSpace.mk' V z.2 (H z.1 z.2)) (s, q)) : let e := trivializationAt V (TangentSpace (𝓑 n) : M β†’ Type _) p HasDerivAt (fun t ↦ H t q) (βˆ‘ i, deriv (fun t ↦ e.localFrameCoeff (𝓑 n) b i q (H t q)) s β€’ e.localFrame b i q) s := by let : Bundle.RiemannianBundle (TangentSpace (𝓑 n) : M β†’ Type _) := ⟨g.toRiemannianMetric⟩ let e := trivializationAt V (TangentSpace (𝓑 n) : M β†’ Type _) p have hc (i : ΞΉ) : DifferentiableAt ℝ (fun t ↦ e.localFrameCoeff (𝓑 n) b i q (H t q)) s := ((mdifferentiableAt_parametric_frameCoeff b p q s H hq hH i).comp s (mdifferentiableAt_id.prodMk mdifferentiableAt_const)).differentiableAt have hsum := HasDerivAt.fun_sum (u := Finset.univ) (fun i _ ↦ (hc i).hasDerivAt.smul_const (e.localFrame b i q)) convert! hsum using 1 funext t exact e.eq_sum_localFrameCoeff_smul (s := H t) (b := b) hq end PoincareMT.ReducedLength