import PoincareLib.Analysis.Calculus.SmoothCompactness.EventualUniqueness import Mathlib.Geometry.Manifold.ContMDiff.Atlas import Mathlib.Geometry.Manifold.ContMDiff.NormedSpace import Mathlib.Geometry.Manifold.Instances.Real /-! # Smooth compactness of functions on a manifold A countable chart cover provides a common smooth subsequence. Uniqueness of pointwise limits glues the coordinate limits and then upgrades convergence to compact-uniform convergence of every jet in every chart. -/ set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set Filter open scoped ContDiff Manifold Topology namespace Poincare.Manifold open Poincare.Analysis.Calculus /-- Local eventual smoothness and bounds for all derivatives in charts give a global smooth subsequential limit, with compact convergence of every jet in every extended chart. -/ theorem exists_smooth_subsequence_of_locallyEventuallyBounded_chart_derivatives {n : β„•} {M : Type*} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] [SecondCountableTopology M] (f : β„• β†’ M β†’ ℝ) (hsmooth : βˆ€ a : M, LocallyEventuallyContDiff (extChartAt (𝓑 n) a).target (fun k => f k ∘ (extChartAt (𝓑 n) a).symm)) (hbound : βˆ€ a : M, LocallyEventuallyBoundedDerivatives (extChartAt (𝓑 n) a).target (fun k => f k ∘ (extChartAt (𝓑 n) a).symm)) : βˆƒ Οƒ : β„• β†’ β„•, StrictMono Οƒ ∧ βˆƒ b : M β†’ ℝ, ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ b ∧ (βˆ€ x, Tendsto (fun k => f (Οƒ k) x) atTop (𝓝 (b x))) ∧ βˆ€ (a : M) (m : β„•) (K : Set (EuclideanSpace ℝ (Fin n))), IsCompact K β†’ K βŠ† (extChartAt (𝓑 n) a).target β†’ TendstoUniformlyOn (fun k => iteratedFDeriv ℝ m (f (Οƒ k) ∘ (extChartAt (𝓑 n) a).symm)) (iteratedFDeriv ℝ m (b ∘ (extChartAt (𝓑 n) a).symm)) atTop K := by classical rcases isEmpty_or_nonempty M with hM | hM Β· exact ⟨id, strictMono_id, fun _ => 0, contMDiff_const, fun x => isEmptyElim x, fun a => isEmptyElim a⟩ obtain ⟨S, hS, hcover⟩ := TopologicalSpace.countable_cover_nhds (fun x : M => extChartAt_source_mem_nhds (I := 𝓑 n) x) obtain ⟨a, ha⟩ := countable_iff_exists_subset_range.mp hS have hcover' (x : M) : βˆƒ i, x ∈ (extChartAt (𝓑 n) (a i)).source := by have hx : x ∈ ⋃ y ∈ S, (extChartAt (𝓑 n) y).source := hcover.symm β–Έ mem_univ x obtain ⟨y, hy, hxy⟩ := mem_iUnionβ‚‚.mp hx obtain ⟨i, rfl⟩ := ha hy exact ⟨i, hxy⟩ let c := fun i : β„• => extChartAt (𝓑 n) (a i) obtain βŸ¨Οƒ, hΟƒ, u, hu, hjet⟩ := exists_common_smoothSubsequenceExtraction_finiteDimensional_of_locallyEventuallyContDiff (X := fun _ => EuclideanSpace ℝ (Fin n)) (Y := fun _ => ℝ) (fun i => isOpen_extChartAt_target (a i)) (fun i k => f k ∘ (c i).symm) (fun i => hsmooth (a i)) (fun i => hbound (a i)) have hp (i : β„•) (z : EuclideanSpace ℝ (Fin n)) (hz : z ∈ (c i).target) : Tendsto (fun k => f (Οƒ k) ((c i).symm z)) atTop (𝓝 (u i z)) := by have he := (ContinuousMultilinearMap.uniformContinuous_eval_const (0 : Fin 0 β†’ EuclideanSpace ℝ (Fin n))).comp_tendstoUniformlyOn (hjet i 0 {z} isCompact_singleton (singleton_subset_iff.mpr hz)) simpa only [Function.comp_def, iteratedFDeriv_zero_apply] using he.tendsto_at (mem_singleton z) choose j hj using hcover' let b : M β†’ ℝ := fun x => u (j x) (c (j x) x) have hbpoint (x : M) : Tendsto (fun k => f (Οƒ k) x) atTop (𝓝 (b x)) := by have he := hp (j x) (c (j x) x) ((c (j x)).map_source (hj x)) simpa only [(c (j x)).left_inv (hj x), b] using he have hbeq (i : β„•) (x : M) (hx : x ∈ (c i).source) : b x = u i (c i x) := by have he := hp i (c i x) ((c i).map_source hx) rw [(c i).left_inv hx] at he exact tendsto_nhds_unique (hbpoint x) he have hbsmooth : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ b := by intro x have hx : x ∈ (c (j x)).source := hj x have hc : ContMDiffAt (𝓑 n) (𝓑 n) ∞ (c (j x)) x := by apply (contMDiffOn_extChartAt (I := 𝓑 n) (x := a (j x))).contMDiffAt simpa only [extChartAt_source] using extChartAt_source_mem_nhds' hx have huat : ContDiffAt ℝ ∞ (u (j x)) (c (j x) x) := (hu (j x)).contDiffAt (extChartAt_target_mem_nhds' ((c (j x)).map_source hx)) apply (huat.contMDiffAt.comp x hc).congr_of_eventuallyEq filter_upwards [extChartAt_source_mem_nhds' hx] with y hy exact hbeq (j x) y hy refine βŸ¨Οƒ, hΟƒ, b, hbsmooth, hbpoint, ?_⟩ intro p m K hK hKp apply tendstoUniformlyOn_iteratedFDeriv_of_locallyEventuallyContDiff (isOpen_extChartAt_target p) (fun z _ => hbpoint ((extChartAt (𝓑 n) p).symm z)) (fun A hA hAp => hΟƒ.tendsto_atTop.eventually (hsmooth p A hA hAp)) (fun A hA hAp l => ?_) m hK hKp obtain ⟨B, hB⟩ := hbound p A hA hAp l exact ⟨B, hΟƒ.tendsto_atTop.eventually hB⟩ end Poincare.Manifold