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.Basic |
| 2 | import Mathlib.Analysis.Normed.Module.FiniteDimension |
| 3 | import Mathlib.Topology.Order.IntermediateValue |
| 4 | import Mathlib.Tactic.Linarith |
| 5 | |
| 6 | /-! |
| 7 | # An even map has a singular derivative in odd dimension |
| 8 | |
| 9 | An eventual evenness identity makes the Jacobian determinants at two |
| 10 | antipodal points opposite. Continuity and preconnectedness force a |
| 11 | zero determinant between them. Only the given compact or connected |
| 12 | test set matters; the ambient open domain need not be connected. |
| 13 | Source: the RP2 product exclusion in Morgan-Tian Theorem 12.28, |
| 14 | pp. 323-324; M34 RP2 product exclusion derivation, section 6. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set Filter |
| 20 | open scoped Topology |
| 21 | |
| 22 | namespace PoincareMT.M34 |
| 23 | |
| 24 | /-- In odd real dimension, an eventual evenness identity at two points |
| 25 | of a preconnected set prevents everywhere injective derivatives. -/ |
| 26 | theorem exists_not_injective_fderiv_of_eventually_even |
| 27 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 28 | {f : E → E} {U K : Set E} (hU : IsOpen U) (hK : IsPreconnected K) |
| 29 | (hKU : K ⊆ U) {a : E} (ha : a ∈ K) (hna : -a ∈ K) |
| 30 | (hf : ContDiffOn ℝ 1 f U) (hdim : Odd (Module.finrank ℝ E)) |
| 31 | (heven : (fun x => f (-x)) =ᶠ[𝓝 a] f) : |
| 32 | ∃ x ∈ K, ¬ Function.Injective (fderiv ℝ f x) := by |
| 33 | classical |
| 34 | have hdf : DifferentiableAt ℝ f (-a) := |
| 35 | (hf.contDiffAt (hU.mem_nhds (hKU hna))).differentiableAt (by norm_num) |
| 36 | have hcomp := fderiv_comp a hdf (differentiableAt_id.neg : DifferentiableAt ℝ (fun x : E => -x) a) |
| 37 | have hsame := heven.fderiv_eq (𝕜 := ℝ) |
| 38 | change fderiv ℝ (f ∘ fun x : E => -x) a = fderiv ℝ f a at hsame |
| 39 | rw [hcomp] at hsame |
| 40 | have hneg : fderiv ℝ (fun x : E => -x) a = -ContinuousLinearMap.id ℝ E := |
| 41 | (hasFDerivAt_id a).neg.fderiv |
| 42 | have hderiv : fderiv ℝ f (-a) = -fderiv ℝ f a := by |
| 43 | ext v |
| 44 | have h := congrArg (fun L : E →L[ℝ] E => L v) hsame |
| 45 | simp only [ContinuousLinearMap.comp_apply, hneg, neg_apply, |
| 46 | ContinuousLinearMap.id_apply, map_neg] at h |
| 47 | exact neg_eq_iff_eq_neg.mp h |
| 48 | let D : E → ℝ := fun x => (fderiv ℝ f x).det |
| 49 | have hdet : D (-a) = -D a := by |
| 50 | dsimp [D] |
| 51 | rw [hderiv] |
| 52 | change LinearMap.det (-(fderiv ℝ f a).toLinearMap) = _ |
| 53 | rw [← neg_one_smul ℝ (fderiv ℝ f a).toLinearMap, LinearMap.det_smul, |
| 54 | hdim.neg_one_pow, neg_one_mul] |
| 55 | have hcontinuous : ContinuousOn D K := |
| 56 | (ContinuousLinearMap.continuous_det.comp_continuousOn |
| 57 | (hf.continuousOn_fderiv_of_isOpen hU (by norm_num))).mono hKU |
| 58 | by_contra! hinjective |
| 59 | have hnonzero (x : E) (hx : x ∈ K) : D x ≠ 0 := by |
| 60 | intro hz |
| 61 | exact (LinearMap.det_eq_zero_iff_ker_ne_bot.mp hz) |
| 62 | (LinearMap.ker_eq_bot.mpr (hinjective x hx)) |
| 63 | by_cases hsign : 0 ≤ D a |
| 64 | · obtain ⟨x, hx, hz⟩ := hK.intermediate_value hna ha hcontinuous |
| 65 | (show (0 : ℝ) ∈ Icc (D (-a)) (D a) from ⟨by rw [hdet]; linarith, hsign⟩) |
| 66 | exact hnonzero x hx hz |
| 67 | · obtain ⟨x, hx, hz⟩ := hK.intermediate_value ha hna hcontinuous |
| 68 | (show (0 : ℝ) ∈ Icc (D a) (D (-a)) from |
| 69 | ⟨(lt_of_not_ge hsign).le, by rw [hdet]; linarith⟩) |
| 70 | exact hnonzero x hx hz |
| 71 | |
| 72 | end PoincareMT.M34 |