Poincaré conjecture: the Lean proof, cleaned up together
The 2026 Lean proof of the Poincaré conjecture after Morgan and Tian, 3 million lines, cleaned up together: smaller, faster to build, more readable, the theorems unchanged

| 1 | import PoincareLib.Geometry.Manifold.InverseFunction |
| 2 | |
| 3 | /-! |
| 4 | # Smoothness of local left inverses |
| 5 | |
| 6 | A local left inverse of a smooth map with invertible derivative agrees near |
| 7 | the image point with the inverse supplied by the Euclidean inverse function |
| 8 | theorem in charts. No regularity of the given inverse is assumed. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open Set Filter |
| 14 | open scoped Manifold ContDiff Topology |
| 15 | |
| 16 | namespace Poincare |
| 17 | |
| 18 | variable {n : ℕ} {M N : Type*} [TopologicalSpace M] [TopologicalSpace N] |
| 19 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] |
| 20 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) N] |
| 21 | [IsManifold (𝓡 n) ∞ M] [IsManifold (𝓡 n) ∞ N] |
| 22 | |
| 23 | set_option backward.isDefEq.respectTransparency false in |
| 24 | /-- A locally left-inverse function is smooth near a nonsingular smooth point. -/ |
| 25 | theorem contMDiffAt_of_local_left_inverse {f : M → N} {g : N → M} {x : M} |
| 26 | (hf : ContMDiffAt (𝓡 n) (𝓡 n) ∞ f x) |
| 27 | (hbij : Function.Bijective (mfderiv (𝓡 n) (𝓡 n) f x)) |
| 28 | (hleft : ∀ᶠ z in 𝓝 x, g (f z) = z) : |
| 29 | ContMDiffAt (𝓡 n) (𝓡 n) ∞ g (f x) := by |
| 30 | let c := extChartAt (𝓡 n) x |
| 31 | let d := extChartAt (𝓡 n) (f x) |
| 32 | let F := writtenInExtChartAt (𝓡 n) (𝓡 n) x f |
| 33 | have hF : ContDiffAt ℝ ∞ F (c x) := by |
| 34 | simpa [F, c, writtenInExtChartAt, contDiffWithinAt_univ] using |
| 35 | (contMDiffAt_iff.mp hf).2 |
| 36 | have hderiv : mfderiv (𝓡 n) (𝓡 n) f x = fderiv ℝ F (c x) := by |
| 37 | rw [mfderiv, if_pos (hf.mdifferentiableAt (by simp))] |
| 38 | simp [F, c] |
| 39 | have hFbij : Function.Bijective (fderiv ℝ F (c x)) := by |
| 40 | rwa [hderiv] at hbij |
| 41 | let e := ContinuousLinearEquiv.ofBijective (fderiv ℝ F (c x)) |
| 42 | (LinearMap.ker_eq_bot.mpr hFbij.1) (LinearMap.range_eq_top.mpr hFbij.2) |
| 43 | have hdF : HasFDerivAt F (e : EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 44 | EuclideanSpace ℝ (Fin n)) (c x) := |
| 45 | (hF.differentiableAt (by simp)).hasFDerivAt |
| 46 | let i := hF.localInverse hdF (by simp) |
| 47 | have hi : ContDiffAt ℝ ∞ i (F (c x)) := hF.to_localInverse hdF (by simp) |
| 48 | have hix : i (F (c x)) = c x := hF.localInverse_apply_image hdF (by simp) |
| 49 | have hFx : F (c x) = d (f x) := by simp [F, c, d, writtenInExtChartAt] |
| 50 | have hil : ∀ᶠ z in 𝓝 (c x), i (F z) = z := |
| 51 | (hF.hasStrictFDerivAt' hdF (by simp)).eventually_left_inverse |
| 52 | have hc : ContinuousAt c x := continuousAt_extChartAt x |
| 53 | have heq : g =ᶠ[𝓝 (f x)] fun y => c.symm (i (d y)) := by |
| 54 | rw [← map_nhds_eq_of_contMDiffAt_mfderiv_bijective hf hbij] |
| 55 | change ∀ᶠ z in 𝓝 x, g (f z) = c.symm (i (d (f z))) |
| 56 | filter_upwards [hleft, hc.tendsto.eventually hil, |
| 57 | (isOpen_extChartAt_source (I := 𝓡 n) x).mem_nhds (mem_extChartAt_source x)] |
| 58 | with z hz hzi hzc |
| 59 | have hFz : F (c z) = d (f z) := by |
| 60 | simp only [F, writtenInExtChartAt, Function.comp_apply] |
| 61 | rw [c.left_inv hzc] |
| 62 | rw [hz, ← hFz, hzi, c.left_inv hzc] |
| 63 | have hd : ContMDiffAt (𝓡 n) (𝓡 n) ∞ d (f x) := contMDiffAt_extChartAt |
| 64 | have hi' : ContMDiffAt (𝓡 n) (𝓡 n) ∞ i (d (f x)) := by |
| 65 | rw [← hFx] |
| 66 | exact hi.contMDiffAt |
| 67 | have hcs : ContMDiffAt (𝓡 n) (𝓡 n) ∞ c.symm (i (d (f x))) := by |
| 68 | rw [← hFx, hix] |
| 69 | exact (contMDiffOn_extChartAt_symm x).contMDiffAt |
| 70 | ((isOpen_extChartAt_target (I := 𝓡 n) x).mem_nhds (mem_extChartAt_target x)) |
| 71 | exact (hcs.comp (f x) (hi'.comp (f x) hd)).congr_of_eventuallyEq heq |
| 72 | |
| 73 | end Poincare |