import PoincareLib.Geometry.RicciFlow.Compactness.GeometricLimit.Overlap.SourceTransition import PoincareLib.Geometry.Manifold.InverseFunction.SmoothInverse import Mathlib.Geometry.Manifold.LocalDiffeomorph /-! # Eventual smoothness of source chart transitions Compact confinement places the source chart image in the target chart image on a fixed neighborhood. The injective local diffeomorphism then supplies a smooth inverse on that image. -/ set_option autoImplicit false open Set Filter Metric open scoped Topology NNReal Manifold ContDiff namespace PoincareMT.ChartDistance theorem contMDiffOn_invFun_of_localDiffeomorph {n : β„•} {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [ChartedSpace (EuclideanSpace ℝ (Fin n)) X] [ChartedSpace (EuclideanSpace ℝ (Fin n)) Y] [IsManifold (𝓑 n) ∞ X] [IsManifold (𝓑 n) ∞ Y] [Nonempty X] {f : X β†’ Y} (hf : IsLocalDiffeomorph (𝓑 n) (𝓑 n) ∞ f) (hinj : Function.Injective f) : ContMDiffOn (𝓑 n) (𝓑 n) ∞ (Function.invFun f) (range f) := by rintro _ ⟨x, rfl⟩ apply ContMDiffAt.contMDiffWithinAt exact Poincare.contMDiffAt_of_local_left_inverse (hf.contMDiff x) (hf.mfderivToContinuousLinearEquiv (by simp) x).bijective (Eventually.of_forall (Function.leftInverse_invFun hinj)) variable {ΞΉ : Type*} {n : β„•} {X : ΞΉ β†’ Type*} [βˆ€ i, MetricSpace (X i)] [βˆ€ i, LocallyCompactSpace (X i)] [βˆ€ i, Nonempty (X i)] [βˆ€ i, ChartedSpace (EuclideanSpace ℝ (Fin n)) (X i)] [βˆ€ i, IsManifold (𝓑 n) ∞ (X i)] {M : β„• β†’ Type*} [βˆ€ k, MetricSpace (M k)] [βˆ€ k, ChartedSpace (EuclideanSpace ℝ (Fin n)) (M k)] [βˆ€ k, IsManifold (𝓑 n) ∞ (M k)] {e : βˆ€ k i, X i β†’ M k} {D : βˆ€ i j, X i Γ— X j β†’ ℝ} (hD : βˆ€ i j x y, Tendsto (fun k => dist (e k i x) (e k j y)) atTop (𝓝 (D i j (x, y)))) (L : ΞΉ β†’ ℝβ‰₯0) (he : βˆ€ k i, LipschitzWith (L i) (e k i)) (c : ΞΉ β†’ ℝ) (hc : βˆ€ i, 0 < c i) (hlower : βˆ€ k i x y, c i * dist x y ≀ dist (e k i x) (e k i y)) (hopen : βˆ€ k i, Topology.IsOpenEmbedding (e k i)) (hconn : βˆ€ k (p : M k) r, IsPreconnected (ball p r)) (hsmooth : βˆ€ k i, IsLocalDiffeomorph (𝓑 n) (𝓑 n) ∞ (e k i)) include hD he hc hlower hopen hconn hsmooth in theorem exists_eventually_smooth_source_transition {i j : ΞΉ} {x : X i} (hx : x ∈ overlap D i j) : βˆƒ U : Set (X i), IsOpen U ∧ x ∈ U ∧ U βŠ† overlap D i j ∧ βˆ€αΆ  k in atTop, ContMDiffOn (𝓑 n) (𝓑 n) ∞ (fun y => Function.invFun (e k j) (e k i y)) U := by obtain ⟨U, hU, hxU, K, _, hrep⟩ := exists_source_transition_neighborhood hD L he c hc hlower hopen hconn hx refine ⟨U ∩ overlap D i j, hU.inter (isOpen_overlap hD L he c hc hlower hopen hconn i j), ⟨hxU, hx⟩, inter_subset_right, ?_⟩ filter_upwards [hrep] with k hk exact (contMDiffOn_invFun_of_localDiffeomorph (hsmooth k j) (hopen k j).injective).comp (hsmooth k i).contMDiff.contMDiffOn (fun y hy => image_subset_range _ _ (hk y hy.1).1) end PoincareMT.ChartDistance