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 | /- |
| 2 | Copyright (c) 2026 The PoincareLib contributors. |
| 3 | -/ |
| 4 | import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension |
| 5 | |
| 6 | /-! |
| 7 | # Extending a smooth curve near a point |
| 8 | |
| 9 | A smooth cutoff extends a curve from an open neighborhood to the entire real |
| 10 | line without changing it near the prescribed point. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | open Set Metric Filter |
| 15 | open scoped ContDiff Topology |
| 16 | |
| 17 | namespace Poincare.Analysis |
| 18 | |
| 19 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 20 | |
| 21 | /-- A smooth curve on an open set has a globally smooth representative of its |
| 22 | germ at each point of that set. -/ |
| 23 | theorem exists_global_contDiff_germ {f : ℝ → E} {U : Set ℝ} {a : ℝ} |
| 24 | (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) (ha : a ∈ U) : |
| 25 | ∃ g : ℝ → E, ContDiff ℝ ∞ g ∧ g =ᶠ[𝓝 a] f := by |
| 26 | obtain ⟨r, hr, hrU⟩ := Metric.mem_nhds_iff.mp (hU.mem_nhds ha) |
| 27 | let χ : ContDiffBump a := { |
| 28 | rIn := r / 4 |
| 29 | rOut := r / 2 |
| 30 | rIn_pos := by positivity |
| 31 | rIn_lt_rOut := by linarith } |
| 32 | have hsupport : tsupport χ ⊆ U := by |
| 33 | rw [χ.tsupport_eq] |
| 34 | exact (closedBall_subset_ball (by change r / 2 < r; linarith)).trans hrU |
| 35 | refine ⟨fun t => χ t • f t, ?_, ?_⟩ |
| 36 | · rw [contDiff_iff_contDiffAt] |
| 37 | intro t |
| 38 | by_cases ht : t ∈ U |
| 39 | · exact χ.contDiffAt.smul ((hf t ht).contDiffAt (hU.mem_nhds ht)) |
| 40 | · have hn : t ∉ tsupport χ := fun ht' => ht (hsupport ht') |
| 41 | have heq := notMem_tsupport_iff_eventuallyEq.mp hn |
| 42 | apply (contDiffAt_const (c := (0 : E))).congr_of_eventuallyEq |
| 43 | filter_upwards [heq] with s hs |
| 44 | simp [hs] |
| 45 | · filter_upwards [ball_mem_nhds a χ.rIn_pos] with t ht |
| 46 | rw [χ.one_of_mem_closedBall (ball_subset_closedBall ht), one_smul] |
| 47 | |
| 48 | end Poincare.Analysis |