import PoincareLib.Geometry.Manifold.InverseFunction /-! # Smoothness of local left inverses A local left inverse of a smooth map with invertible derivative agrees near the image point with the inverse supplied by the Euclidean inverse function theorem in charts. No regularity of the given inverse is assumed. -/ set_option autoImplicit false open Set Filter open scoped Manifold ContDiff Topology namespace Poincare variable {n : โ„•} {M N : Type*} [TopologicalSpace M] [TopologicalSpace N] [ChartedSpace (EuclideanSpace โ„ (Fin n)) M] [ChartedSpace (EuclideanSpace โ„ (Fin n)) N] [IsManifold (๐“ก n) โˆž M] [IsManifold (๐“ก n) โˆž N] set_option backward.isDefEq.respectTransparency false in /-- A locally left-inverse function is smooth near a nonsingular smooth point. -/ theorem contMDiffAt_of_local_left_inverse {f : M โ†’ N} {g : N โ†’ M} {x : M} (hf : ContMDiffAt (๐“ก n) (๐“ก n) โˆž f x) (hbij : Function.Bijective (mfderiv (๐“ก n) (๐“ก n) f x)) (hleft : โˆ€แถ  z in ๐“ x, g (f z) = z) : ContMDiffAt (๐“ก n) (๐“ก n) โˆž g (f x) := by let c := extChartAt (๐“ก n) x let d := extChartAt (๐“ก n) (f x) let F := writtenInExtChartAt (๐“ก n) (๐“ก n) x f have hF : ContDiffAt โ„ โˆž F (c x) := by simpa [F, c, writtenInExtChartAt, contDiffWithinAt_univ] using (contMDiffAt_iff.mp hf).2 have hderiv : mfderiv (๐“ก n) (๐“ก n) f x = fderiv โ„ F (c x) := by rw [mfderiv, if_pos (hf.mdifferentiableAt (by simp))] simp [F, c] have hFbij : Function.Bijective (fderiv โ„ F (c x)) := by rwa [hderiv] at hbij let e := ContinuousLinearEquiv.ofBijective (fderiv โ„ F (c x)) (LinearMap.ker_eq_bot.mpr hFbij.1) (LinearMap.range_eq_top.mpr hFbij.2) have hdF : HasFDerivAt F (e : EuclideanSpace โ„ (Fin n) โ†’L[โ„] EuclideanSpace โ„ (Fin n)) (c x) := (hF.differentiableAt (by simp)).hasFDerivAt let i := hF.localInverse hdF (by simp) have hi : ContDiffAt โ„ โˆž i (F (c x)) := hF.to_localInverse hdF (by simp) have hix : i (F (c x)) = c x := hF.localInverse_apply_image hdF (by simp) have hFx : F (c x) = d (f x) := by simp [F, c, d, writtenInExtChartAt] have hil : โˆ€แถ  z in ๐“ (c x), i (F z) = z := (hF.hasStrictFDerivAt' hdF (by simp)).eventually_left_inverse have hc : ContinuousAt c x := continuousAt_extChartAt x have heq : g =แถ [๐“ (f x)] fun y => c.symm (i (d y)) := by rw [โ† map_nhds_eq_of_contMDiffAt_mfderiv_bijective hf hbij] change โˆ€แถ  z in ๐“ x, g (f z) = c.symm (i (d (f z))) filter_upwards [hleft, hc.tendsto.eventually hil, (isOpen_extChartAt_source (I := ๐“ก n) x).mem_nhds (mem_extChartAt_source x)] with z hz hzi hzc have hFz : F (c z) = d (f z) := by simp only [F, writtenInExtChartAt, Function.comp_apply] rw [c.left_inv hzc] rw [hz, โ† hFz, hzi, c.left_inv hzc] have hd : ContMDiffAt (๐“ก n) (๐“ก n) โˆž d (f x) := contMDiffAt_extChartAt have hi' : ContMDiffAt (๐“ก n) (๐“ก n) โˆž i (d (f x)) := by rw [โ† hFx] exact hi.contMDiffAt have hcs : ContMDiffAt (๐“ก n) (๐“ก n) โˆž c.symm (i (d (f x))) := by rw [โ† hFx, hix] exact (contMDiffOn_extChartAt_symm x).contMDiffAt ((isOpen_extChartAt_target (I := ๐“ก n) x).mem_nhds (mem_extChartAt_target x)) exact (hcs.comp (f x) (hi'.comp (f x) hd)).congr_of_eventuallyEq heq end Poincare