import PoincareLib.Geometry.Manifold.Flow.HittingTime /-! # Smooth dependence of a unique scalar root The parameter implicit-function theorem identifies any uniquely selected root with a smooth local implicit function. This is the root argument used in `Geometry.Manifold.Flow.HittingTime`, exposed for regular-level graphs. -/ noncomputable section set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set Filter open scoped Manifold ContDiff Bundle Topology namespace Poincare.Manifold /-- A unique root with nonzero time derivative depends smoothly on the manifold parameter, without assuming continuity of the selected root. -/ theorem contMDiffAt_of_unique_zero {n : β„•} {M : Type*} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] {F : ℝ Γ— M β†’ ℝ} {Οƒ : M β†’ ℝ} {I : Set ℝ} {V : Set M} (hI : IsOpen I) (hV : IsOpen V) (hF : ContMDiffOn (π“˜(ℝ, ℝ).prod (𝓑 n)) π“˜(ℝ, ℝ) ∞ F (I Γ—Λ’ V)) (hroot : βˆ€ y ∈ V, Οƒ y ∈ I ∧ F (Οƒ y, y) = 0) (hunique : βˆ€ y ∈ V, βˆ€ s ∈ I, F (s, y) = 0 β†’ s = Οƒ y) {y : M} (hy : y ∈ V) {v : ℝ} (hv : v β‰  0) (hder : HasDerivAt (fun s ↦ F (s, y)) v (Οƒ y)) : ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ Οƒ y := by let e := extChartAt (𝓑 n) y have he := (contMDiffWithinAt_extChartAt_symm_target (n := ∞) y (mem_extChartAt_target y)).contMDiffAt (extChartAt_target_mem_nhds' (I := 𝓑 n) (mem_extChartAt_target y)) let G : EuclideanSpace ℝ (Fin n) Γ— ℝ β†’ ℝ := fun q ↦ F (q.2, e.symm q.1) let qβ‚€ : EuclideanSpace ℝ (Fin n) Γ— ℝ := (e y, Οƒ y) have hG : ContDiffAt ℝ ∞ G qβ‚€ := by have he' : ContMDiffAt π“˜(ℝ, EuclideanSpace ℝ (Fin n) Γ— ℝ) (𝓑 n) ∞ (fun q ↦ e.symm q.1) qβ‚€ := he.comp qβ‚€ contDiffAt_fst.contMDiffAt have hpair : ContMDiffAt π“˜(ℝ, EuclideanSpace ℝ (Fin n) Γ— ℝ) (π“˜(ℝ, ℝ).prod (𝓑 n)) ∞ (fun q ↦ (q.2, e.symm q.1)) qβ‚€ := contDiffAt_snd.contMDiffAt.prodMk he' have hF' := hF.contMDiffAt ((hI.prod hV).mem_nhds (show (Οƒ y, y) ∈ I Γ—Λ’ V from ⟨(hroot y hy).1, hy⟩)) have hsame : (qβ‚€.2, e.symm qβ‚€.1) = (Οƒ y, y) := by simp only [qβ‚€, e.left_inv (mem_extChartAt_source y)] rw [← hsame] at hF' exact (hF'.comp qβ‚€ hpair).contDiffAt have hGder : HasDerivAt (fun s ↦ G (qβ‚€.1, s)) v (Οƒ y) := by simpa only [G, qβ‚€, e.left_inv (mem_extChartAt_source y)] using hder have hpart : (fderiv ℝ G qβ‚€).comp (ContinuousLinearMap.inr ℝ (EuclideanSpace ℝ (Fin n)) ℝ) = v β€’ (ContinuousLinearMap.id ℝ ℝ) := by have hd := (hG.differentiableAt (by simp)).hasFDerivAt have hcomp := hd.comp (Οƒ y) ((hasFDerivAt_const qβ‚€.1 (Οƒ y)).prodMk (hasFDerivAt_id (Οƒ y))) have heq := hcomp.unique hGder.hasFDerivAt apply ContinuousLinearMap.ext intro z have hz := congrArg (fun L : ℝ β†’L[ℝ] ℝ ↦ L z) heq change fderiv ℝ G qβ‚€ (0, z) = z * v at hz change fderiv ℝ G qβ‚€ (0, z) = v * z simpa only [mul_comm] using hz have hinv : ((fderiv ℝ G qβ‚€).comp (ContinuousLinearMap.inr ℝ (EuclideanSpace ℝ (Fin n)) ℝ)).IsInvertible := by rw [hpart] refine ⟨(LinearEquiv.smulOfNeZero ℝ ℝ v hv).toContinuousLinearEquiv, ?_⟩ apply ContinuousLinearMap.ext intro z rfl let ψ := hG.implicitFunction (by simp) hinv have hψ : ContDiffAt ℝ ∞ ψ (e y) := hG.contDiffAt_implicitFunction (by simp) hinv have hψzero : ψ (e y) = Οƒ y := hG.implicitFunction_apply_self (by simp) hinv have hψeq : βˆ€αΆ  z in 𝓝 (e y), G (z, ψ z) = G qβ‚€ := hG.eventually_apply_implicitFunction (by simp) hinv have hψI : βˆ€αΆ  z in 𝓝 (e y), ψ z ∈ I := by apply hψ.continuousAt.preimage_mem_nhds rw [hψzero] exact hI.mem_nhds (hroot y hy).1 have hechart : ContMDiffAt (𝓑 n) (𝓑 n) ∞ e y := contMDiffAt_extChartAt have hcomp : ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ (fun z ↦ ψ (e z)) y := hψ.contMDiffAt.comp y hechart apply hcomp.congr_of_eventuallyEq filter_upwards [hechart.continuousAt hψeq, hechart.continuousAt hψI, hV.mem_nhds hy, extChartAt_source_mem_nhds' (I := 𝓑 n) (mem_extChartAt_source y)] with z heq hIz hz hchartz apply (hunique z hz (ψ (e z)) hIz ?_).symm have hback : e.symm (e z) = z := e.left_inv hchartz change F (ψ (e z), z) = 0 conv_lhs => arg 1; arg 2; rw [← hback] change G (e z, ψ (e z)) = 0 rw [heq] simpa only [G, qβ‚€, e.left_inv (mem_extChartAt_source y)] using (hroot y hy).2 /-- Timewise injectivity supplies the root uniqueness needed for smooth dependence on the manifold parameter. -/ theorem contMDiffAt_of_unique_time_root {n : β„•} {M : Type*} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] {F : ℝ Γ— M β†’ ℝ} {Οƒ : M β†’ ℝ} {I : Set ℝ} {V : Set M} (hI : IsOpen I) (hV : IsOpen V) (hF : ContMDiffOn (π“˜(ℝ, ℝ).prod (𝓑 n)) π“˜(ℝ, ℝ) ∞ F (I Γ—Λ’ V)) (hroot : βˆ€ y ∈ V, Οƒ y ∈ I ∧ F (Οƒ y, y) = 0) (hinj : βˆ€ y ∈ V, InjOn (fun s ↦ F (s, y)) I) {y : M} (hy : y ∈ V) {v : ℝ} (hv : v β‰  0) (hder : HasDerivAt (fun s ↦ F (s, y)) v (Οƒ y)) : ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ Οƒ y := by apply contMDiffAt_of_unique_zero hI hV hF hroot ?_ hy hv hder intro z hz s hs hzero exact hinj z hz hs (hroot z hz).1 (hzero.trans (hroot z hz).2.symm) end Poincare.Manifold