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 Mathlib.Analysis.Calculus.ContDiff.Operations |
| 2 | import Mathlib.Analysis.Calculus.FDeriv.OfCompLeft |
| 3 | |
| 4 | /-! |
| 5 | # Smoothness of an inverse within a set |
| 6 | |
| 7 | The inverse derivative formula bootstraps a continuous right inverse |
| 8 | to smoothness on its actual domain, which may have boundary. This is |
| 9 | the relative inverse step for Morgan-Tian Proposition 6.28, p. 117; |
| 10 | see tasks/M14/derivations/2026-09-21-relative-inverse.md. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped ContDiff Topology |
| 17 | |
| 18 | namespace PoincareMT.M14 |
| 19 | |
| 20 | variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] |
| 21 | {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [CompleteSpace E] |
| 22 | {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] |
| 23 | |
| 24 | /-- A continuous right inverse of a smooth map with invertible within |
| 25 | derivative is smooth on its domain, including boundary points. No |
| 26 | unique-differentiation assumption on the inverse domain is needed. |
| 27 | Relative inverse step for Proposition 6.28, p. 117; see the derivation |
| 28 | 2026-09-21-relative-inverse.md. -/ |
| 29 | theorem contDiffOn_inverse_of_leftInverse {f : E → F} {g : F → E} |
| 30 | {S : Set E} {T : Set F} (hS : UniqueDiffOn 𝕜 S) |
| 31 | (hf : ContDiffOn 𝕜 ∞ f S) (hg : ContinuousOn g T) |
| 32 | (hmap : MapsTo g T S) (hfg : ∀ y ∈ T, f (g y) = y) |
| 33 | (hinv : ∀ z ∈ S, (fderivWithin 𝕜 f S z).IsInvertible) : |
| 34 | ContDiffOn 𝕜 ∞ g T := by |
| 35 | let D : F → F →L[𝕜] E := fun y => |
| 36 | ContinuousLinearMap.inverse (fderivWithin 𝕜 f S (g y)) |
| 37 | have hD (y : F) (hy : y ∈ T) : HasFDerivWithinAt g (D y) T y := by |
| 38 | obtain ⟨e, he⟩ := hinv (g y) (hmap hy) |
| 39 | have hfe : HasFDerivWithinAt f (e : E →L[𝕜] F) S (g y) := by |
| 40 | rw [he] |
| 41 | exact (hf.differentiableOn (by simp) _ (hmap hy)).hasFDerivWithinAt |
| 42 | have hd := HasFDerivWithinAt.of_local_left_inverse |
| 43 | ((hg y hy).tendsto_nhdsWithin hmap) hfe hy |
| 44 | (eventually_nhdsWithin_of_forall hfg) |
| 45 | simpa only [D, ← he, ContinuousLinearMap.inverse_equiv] using hd |
| 46 | rw [contDiffOn_infty] |
| 47 | intro k |
| 48 | induction k with |
| 49 | | zero => exact contDiffOn_zero.mpr hg |
| 50 | | succ k ih => |
| 51 | have hf' : ContDiffOn 𝕜 k (fderivWithin 𝕜 f S) S := |
| 52 | hf.fderivWithin hS (by exact_mod_cast (le_top : (k + 1 : ℕ∞) ≤ ⊤)) |
| 53 | have hDs : ContDiffOn 𝕜 k D T := by |
| 54 | intro y hy |
| 55 | exact (hinv (g y) (hmap hy)).contDiffAt_map_inverse.comp_contDiffWithinAt y |
| 56 | ((hf' (g y) (hmap hy)).comp y (ih y hy) hmap) |
| 57 | rw [Nat.cast_succ] |
| 58 | apply (contDiffOn_succ_iff_hasFDerivWithinAt (by simp)).mpr |
| 59 | intro y hy |
| 60 | refine ⟨T, ?_, by simp, D, hD, hDs⟩ |
| 61 | simpa only [insert_eq_of_mem hy] using (self_mem_nhdsWithin : T ∈ 𝓝[T] y) |
| 62 | |
| 63 | end PoincareMT.M14 |