/- Provenance and modification notice (recorded 2026-09-29). Source: https://github.com/qinz1yang/differential-geometry DifferentialGeometry/Analysis/ODE/Flow/HigherRegularity/ContDiffOnTop.lean Comparison revision: 1b535dd102b94cc42b107cca27059687888f08b3. Changes: Imports, module paths, and namespaces were adapted to the subject-organized PoincareLib library. License: Apache-2.0. Source licenses and notices are retained under PoincareConjecture/provenance/2026-09-29/licenses/. See PoincareConjecture/MODIFICATIONS.md for the reviewed source mapping. -/ /- Copyright (c) 2026 The DifferentialGeometry contributors. Released under Apache 2.0 license. Adapted from DifferentialGeometry/Analysis/ODE/Flow/HigherRegularity/ContDiffOnTop.lean at revision 1b535dd102b94cc42b107cca27059687888f08b3. Original SHA-256: 9887d7f3a261b26e634d3d8068770e64a212c57cc0da2813ee8761c291222afa Changes: library paths and namespaces. -/ import PoincareLib.Analysis.ODE.LocalFlow.ParametricLinearODE import Mathlib.Analysis.Calculus.ContDiff.FiniteDimension noncomputable section namespace Poincare.ODE.LocalFlow open Set Metric Function open scoped ContDiff NNReal theorem contDiffOn_top_of_forall_nat {π•œ E F : Type*} [NontriviallyNormedField π•œ] [NormedAddCommGroup E] [NormedSpace π•œ E] [NormedAddCommGroup F] [NormedSpace π•œ F] {f : E β†’ F} {S : Set E} (h : βˆ€ k : β„•, ContDiffOn π•œ (k : β„•βˆž) f S) : ContDiffOn π•œ (∞ : WithTop β„•βˆž) f S := contDiffOn_infty.mpr h section CoefficientRegularity variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] variable {f : ℝ β†’ E β†’ E} {tβ‚€ : ℝ} {xβ‚€ : E} {Ξ¦ : E Γ— ℝ β†’ E} omit [CompleteSpace E] in private theorem contDiffOn_variational_coeff_aux {n : β„•} {T : ℝ} {ρ : ℝβ‰₯0} (hf_succ : ContDiffOn ℝ ((n : β„•βˆž) + 1) (uncurry f) (univ : Set (ℝ Γ— E))) (hΞ¦_Cn : ContDiffOn ℝ (n : β„•βˆž) Ξ¦ ((ball xβ‚€ (ρ : ℝ)) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T))) : ContDiffOn ℝ (n : β„•βˆž) (fun q : E Γ— ℝ => fderiv ℝ (f q.2) (Ξ¦ q)) ((ball xβ‚€ (ρ : ℝ)) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T)) := by set pfD : ℝ Γ— E β†’ (E β†’L[ℝ] E) := fun p => fderiv ℝ (f p.1) p.2 set iM : E Γ— ℝ β†’ ℝ Γ— E := fun q => (q.2, Ξ¦ q) set U := (ball xβ‚€ (ρ : ℝ)) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T) suffices h : ContDiffOn ℝ (n : β„•βˆž) (pfD ∘ iM) U by exact h.congr (fun _ _ => rfl) have hpfd : ContDiffOn ℝ (n : β„•βˆž) pfD (univ : Set (ℝ Γ— E)) := contDiffOn_partial_fderiv_of_succ hf_succ have hiM : ContDiffOn ℝ (n : β„•βˆž) iM U := (contDiff_snd.contDiffOn : ContDiffOn ℝ (n : β„•βˆž) Prod.snd U).prodMk hΞ¦_Cn exact hpfd.comp hiM (fun _ _ => mem_univ _) end CoefficientRegularity section HartmanTheorem variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [FiniteDimensional ℝ E] variable {f : ℝ β†’ E β†’ E} {tβ‚€ : ℝ} {xβ‚€ : E} {r : ℝβ‰₯0} {tmin tmax : ℝ} {Ξ¦ : E Γ— ℝ β†’ E} theorem IsLocalFlow.contDiffOn_top (hΞ¦ : IsLocalFlow f tβ‚€ xβ‚€ r tmin tmax Ξ¦) (hf_top : ContDiff ℝ ∞ (uncurry f)) {T_out T_mid T M : ℝ} (hT : 0 < T) (hT_lt_mid : T < T_mid) (hT_mid_lt_out : T_mid < T_out) (hM : 0 ≀ M) (hMT_mid : M * T_mid < 1) (hsub : Icc (tβ‚€ - T_out) (tβ‚€ + T_out) βŠ† Icc tmin tmax) {ρ_out ρ_mid ρ : ℝβ‰₯0} {r' : ℝβ‰₯0} (hr' : 0 < r') (hρ_lt_mid : (ρ : ℝ) < (ρ_mid : ℝ)) (hρ_mid_lt_out : (ρ_mid : ℝ) < (ρ_out : ℝ)) (hρρ' : (ρ_mid : ℝ) + (r' : ℝ) ≀ (r : ℝ)) (hρ_out_le_r : (ρ_out : ℝ) ≀ (r : ℝ)) (hA_bd : βˆ€ x ∈ closedBall xβ‚€ (ρ_out : ℝ), βˆ€ Ο„ ∈ Icc (tβ‚€ - T_out) (tβ‚€ + T_out), β€–fderiv ℝ (f Ο„) (Ξ¦ ⟨x, Ο„βŸ©)β€– ≀ M) : ContDiffOn ℝ ∞ Ξ¦ ((ball xβ‚€ (ρ : ℝ)) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T)) := by apply contDiffOn_top_of_forall_nat intro n set U := (ball xβ‚€ (ρ : ℝ)) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T) have hf_Ck : βˆ€ k : β„•, ContDiffOn ℝ (k : β„•βˆž) (uncurry f) (univ : Set (ℝ Γ— E)) := fun k => (hf_top.contDiffOn : ContDiffOn ℝ ∞ (uncurry f) univ).of_le (by exact_mod_cast (le_top : (k : β„•βˆž) ≀ ⊀)) have hf_C1 : ContDiffOn ℝ 1 (uncurry f) (univ : Set (ℝ Γ— E)) := by simpa using hf_Ck 1 have hΞ¦_C1 : ContDiffOn ℝ 1 Ξ¦ U := contDiffOn_flow_of_isLocalFlow hΞ¦ hf_C1 hT hT_lt_mid hT_mid_lt_out hM hMT_mid hsub hr' hρ_lt_mid hρ_mid_lt_out hρρ' hρ_out_le_r hA_bd have hT_mid_pos : 0 < T_mid := lt_trans hT hT_lt_mid have hsub_mid_out : Icc (tβ‚€ - T_mid) (tβ‚€ + T_mid) βŠ† Icc (tβ‚€ - T_out) (tβ‚€ + T_out) := Icc_subset_Icc (by linarith) (by linarith) have hsub_mid : Icc (tβ‚€ - T_mid) (tβ‚€ + T_mid) βŠ† Icc tmin tmax := hsub_mid_out.trans hsub have hA_bd_mid : βˆ€ x ∈ closedBall xβ‚€ (ρ_mid : ℝ), βˆ€ Ο„ ∈ Icc (tβ‚€ - T_mid) (tβ‚€ + T_mid), β€–fderiv ℝ (f Ο„) (Ξ¦ ⟨x, Ο„βŸ©)β€– ≀ M := fun x hx Ο„ hΟ„ => hA_bd x (closedBall_subset_closedBall (le_of_lt hρ_mid_lt_out) hx) Ο„ (hsub_mid_out hΟ„) have hab : tβ‚€ - T < tβ‚€ + T := by linarith have htβ‚€_mem : tβ‚€ ∈ Ioo (tβ‚€ - T) (tβ‚€ + T) := ⟨by linarith, by linarith⟩ induction n with | zero => exact hΞ¦_C1.of_le (by decide) | succ n ih => have hf_Csucc : ContDiffOn ℝ ((n : β„•βˆž) + 1) (uncurry f) (univ : Set (ℝ Γ— E)) := by simpa using hf_Ck (n + 1) have hcoeff_Cn : ContDiffOn ℝ (n : β„•βˆž) (fun q : E Γ— ℝ => fderiv ℝ (f q.2) (Ξ¦ q)) U := contDiffOn_variational_coeff_aux hf_Csucc ih set A : E β†’ ℝ β†’ (E β†’L[ℝ] E) := fun x t => fderiv ℝ (f t) (Ξ¦ ⟨x, t⟩) have hlinear_Cn : βˆ€ Ξ΄ : E, ContDiffOn ℝ (n : β„•βˆž) (uncurry (linearODESolution A (tβ‚€ - T) (tβ‚€ + T) tβ‚€ (fun _ => Ξ΄))) (ball xβ‚€ (ρ : ℝ) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T)) := fun Ξ΄ => linearODESolution_contDiffOn htβ‚€_mem isOpen_ball n (hcoeff_Cn : ContDiffOn ℝ (n : β„•βˆž) (uncurry A) _) (contDiffOn_const : ContDiffOn ℝ (n : β„•βˆž) (fun (_ : E) => Ξ΄) (ball xβ‚€ (ρ : ℝ))) set Lsp : E Γ— ℝ β†’ E β†’L[ℝ] E := fun q => (fderiv ℝ Ξ¦ q).comp (ContinuousLinearMap.inl ℝ E ℝ) have hfderiv_coprod : βˆ€ q ∈ U, fderiv ℝ Ξ¦ q = (Lsp q).coprod (timePieceFn f Ξ¦ q) := by intro ⟨x, t⟩ ⟨hx, ht⟩ have hx' : dist x xβ‚€ < ↑ρ := mem_ball.mp hx have hx_cb_mid : x ∈ closedBall xβ‚€ (ρ_mid : ℝ) := mem_closedBall.mpr (le_of_lt (lt_trans hx' hρ_lt_mid)) have ht_mid : t ∈ Ioo (tβ‚€ - T_mid) (tβ‚€ + T_mid) := ⟨by linarith [ht.1], by linarith [ht.2]⟩ have hfd := hasFDerivAt_flow_jointly_at hΞ¦ hf_C1 hT_mid_pos hM hMT_mid hsub_mid hr' hρρ' hA_bd_mid hx_cb_mid ht_mid rw [hfd.fderiv] change (variationalLinearMapAt hT_mid_pos hM hMT_mid _ _ _).coprod ((ContinuousLinearMap.id ℝ ℝ).smulRight (f t (Ξ¦ (x, t)))) = (Lsp (x, t)).coprod (timePieceFn f Ξ¦ (x, t)) congr 1 Β· change _ = (fderiv ℝ Ξ¦ (x, t)).comp (ContinuousLinearMap.inl ℝ E ℝ) rw [hfd.fderiv] exact (ContinuousLinearMap.coprod_comp_inl _ _).symm have hLsp_Cn : ContDiffOn ℝ (n : β„•βˆž) Lsp U := by rw [contDiffOn_clm_apply] intro Ξ΄ refine (hlinear_Cn Ξ΄).congr (fun q hq => ?_) obtain ⟨hx_ball, ht_Ioo⟩ := hq have hx' : dist q.1 xβ‚€ < ↑ρ := mem_ball.mp hx_ball have hx_cb_mid : q.1 ∈ closedBall xβ‚€ (ρ_mid : ℝ) := mem_closedBall.mpr (le_of_lt (lt_trans hx' hρ_lt_mid)) have ht_mid : q.2 ∈ Ioo (tβ‚€ - T_mid) (tβ‚€ + T_mid) := ⟨by linarith [ht_Ioo.1], by linarith [ht_Ioo.2]⟩ have hΞ¦_restr := hΞ¦.restrict_center_of_norm_le (x₁ := q.1) (r' := r') (by rw [mem_closedBall] at hx_cb_mid; linarith) have hA_cont_x := ((hΞ¦_restr.continuousOn_fderiv_along_orbit hf_C1 q.1 (mem_closedBall_self (by exact_mod_cast (le_of_lt hr')))).mono hsub_mid) have hA_bd_x := fun Ο„ hΟ„ => hA_bd_mid q.1 hx_cb_mid Ο„ hΟ„ have ht_Icc : q.2 ∈ Icc (tβ‚€ - T_mid) (tβ‚€ + T_mid) := Ioo_subset_Icc_self ht_mid have hfd := hasFDerivAt_flow_jointly_at hΞ¦ hf_C1 hT_mid_pos hM hMT_mid hsub_mid hr' hρρ' hA_bd_mid hx_cb_mid ht_mid have hLsp_eq_vlm : Lsp q = variationalLinearMapAt hT_mid_pos hM hMT_mid hA_cont_x hA_bd_x ht_Icc := by change (fderiv ℝ Ξ¦ q).comp (ContinuousLinearMap.inl ℝ E ℝ) = _ conv_lhs => rw [show q = (q.1, q.2) from Prod.mk.eta.symm] rw [hfd.fderiv] exact ContinuousLinearMap.coprod_comp_inl _ _ have hvlm_eq := variationalLinearMapAt_apply hT_mid_pos hM hMT_mid hA_cont_x hA_bd_x ht_Icc Ξ΄ have hvsf := variationalSolutionFun_isSolution hT_mid_pos hM hMT_mid hA_cont_x hA_bd_x Ξ΄ have hA_cont_Ioo : ContinuousOn (A q.1) (Ioo (tβ‚€ - T) (tβ‚€ + T)) := hA_cont_x.mono (fun s hs => Ioo_subset_Icc_self (⟨by linarith [hs.1], by linarith [hs.2]⟩ : s ∈ Ioo (tβ‚€ - T_mid) (tβ‚€ + T_mid))) have hA_joint_cont : ContinuousOn (uncurry A) (ball xβ‚€ (ρ : ℝ) Γ—Λ’ Ioo (tβ‚€ - T) (tβ‚€ + T)) := hcoeff_Cn.continuousOn have h_exists : HasLinearODESolution A (tβ‚€ - T) (tβ‚€ + T) tβ‚€ (fun _ => Ξ΄) q.1 := hasLinearODESolution_of_continuousOn htβ‚€_mem hA_joint_cont (mem_ball.mpr hx') have h_uniq := linearODE_unique_on_Ioo (G := E) htβ‚€_mem hA_cont_Ioo (fun s hs => by have hs_mid : s ∈ Ioo (tβ‚€ - T_mid) (tβ‚€ + T_mid) := ⟨by linarith [hs.1], by linarith [hs.2]⟩ exact (hvsf.2 s (Ioo_subset_Icc_self hs_mid)).hasDerivAt (Icc_mem_nhds_iff.mpr hs_mid)) (fun s hs => linearODESolution_hasDerivAt_of_hasSolution A (tβ‚€ - T) (tβ‚€ + T) tβ‚€ (fun _ => Ξ΄) h_exists hs) (by rw [hvsf.1, linearODESolution_init]) simp only [hLsp_eq_vlm, hvlm_eq, uncurry] have h_eq := h_uniq ht_Ioo dsimp at h_eq exact h_eq exact contDiffOn_flow_succ_of_spatial_smooth hΞ¦ hT hT_lt_mid hT_mid_lt_out hM hMT_mid hsub hr' hρ_lt_mid hρ_mid_lt_out hρρ' hρ_out_le_r hA_bd (by simpa using hf_Ck (n + 1)) ih hLsp_Cn hfderiv_coprod end HartmanTheorem end Poincare.ODE.LocalFlow end