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.BumpFunction.FiniteDimension |
| 2 | |
| 3 | /-! |
| 4 | # Smooth extension near a compact set |
| 5 | |
| 6 | A map smooth on an open neighborhood of a compact subset of a finite-dimensional |
| 7 | real normed space admits a globally smooth extension of its germ near that |
| 8 | compact set. Enlarging the compact set before choosing the cutoff preserves an |
| 9 | open neighborhood, hence all derivatives of the original map there. |
| 10 | -/ |
| 11 | |
| 12 | noncomputable section |
| 13 | set_option autoImplicit false |
| 14 | open Filter Set Function |
| 15 | open scoped ContDiff Topology |
| 16 | namespace Poincare.Analysis |
| 17 | |
| 18 | /-- A map smooth near a compact set has a globally smooth representative |
| 19 | agreeing on an open neighborhood of that entire compact set. -/ |
| 20 | theorem exists_contDiff_extension_near_compact |
| 21 | {X E : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] |
| 22 | [FiniteDimensional ℝ X] [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | {K U : Set X} (hK : IsCompact K) (hU : IsOpen U) (hKU : K ⊆ U) |
| 24 | (f : X → E) (hf : ContDiffOn ℝ ∞ f U) : |
| 25 | ∃ (F : X → E) (V : Set X), |
| 26 | ContDiff ℝ ∞ F ∧ IsOpen V ∧ K ⊆ V ∧ V ⊆ U ∧ EqOn F f V := by |
| 27 | obtain ⟨L, hL, hKL, hLU⟩ := exists_compact_between hK hU hKU |
| 28 | obtain ⟨V, hV, hLV, hVU⟩ := hL.exists_isOpen_closure_subset |
| 29 | (hU.mem_nhdsSet.mpr hLU) |
| 30 | obtain ⟨a, ha, had, har⟩ := hV.exists_contDiff_support_eq (n := ⊤) |
| 31 | obtain ⟨b, hb, hbd, hbr⟩ := hL.isClosed.isOpen_compl.exists_contDiff_support_eq (n := ⊤) |
| 32 | have hab (x : X) : 0 < a x + b x := by |
| 33 | have hax := (har (mem_range_self x)).1 |
| 34 | have hbx := (hbr (mem_range_self x)).1 |
| 35 | by_cases hx : x ∈ L |
| 36 | · have hane : a x ≠ 0 := by |
| 37 | rw [← mem_support, ha] |
| 38 | exact hLV hx |
| 39 | exact add_pos_of_pos_of_nonneg (lt_of_le_of_ne hax hane.symm) hbx |
| 40 | · have hbne : b x ≠ 0 := by |
| 41 | rwa [← mem_support, hb] |
| 42 | exact add_pos_of_nonneg_of_pos hax (lt_of_le_of_ne hbx hbne.symm) |
| 43 | let c : X → ℝ := fun x => a x / (a x + b x) |
| 44 | have hc : ContDiff ℝ ∞ c := had.div (had.add hbd) (fun x => (hab x).ne') |
| 45 | have hcs : tsupport c ⊆ U := by |
| 46 | apply (closure_mono (show support c ⊆ V from ?_)).trans hVU |
| 47 | intro x hx |
| 48 | rw [← ha] |
| 49 | exact fun h => hx (by simp [c, h]) |
| 50 | have hcL : EqOn c (fun _ => 1) L := by |
| 51 | intro x hx |
| 52 | have hbx : b x = 0 := by |
| 53 | rw [← notMem_support, hb] |
| 54 | exact not_not_intro hx |
| 55 | simp only [c, hbx, add_zero] |
| 56 | exact div_self (by simpa [hbx] using (hab x).ne') |
| 57 | refine ⟨fun x => c x • f x, interior L, ?_, isOpen_interior, hKL, |
| 58 | interior_subset.trans hLU, ?_⟩ |
| 59 | · apply contDiff_iff_contDiffAt.mpr |
| 60 | intro x |
| 61 | by_cases hx : x ∈ tsupport c |
| 62 | · exact hc.contDiffAt.smul ((hf x (hcs hx)).contDiffAt (hU.mem_nhds (hcs hx))) |
| 63 | · apply (contDiffAt_const (c := (0 : E))).congr_of_eventuallyEq |
| 64 | filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hx] with y hy |
| 65 | simp only [Pi.zero_apply] at hy |
| 66 | simp only [hy, zero_smul] |
| 67 | · intro x hx |
| 68 | simp only [hcL (interior_subset hx), one_smul] |
| 69 | |
| 70 | end Poincare.Analysis |