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 PoincareLib.Analysis.Calculus.Extension.Local |
| 5 | |
| 6 | /-! |
| 7 | # Smooth extension near a compact interval |
| 8 | |
| 9 | A cutoff extends a smooth curve from an open set containing a closed interval, |
| 10 | preserving the curve on a neighborhood of that entire interval. |
| 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 curve smooth near a closed interval has a globally smooth representative |
| 22 | agreeing on a larger open interval. -/ |
| 23 | theorem exists_global_contDiff_near_interval {f : ℝ → E} {U : Set ℝ} |
| 24 | (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) {a b : ℝ} |
| 25 | (hab : a ≤ b) (hI : Icc a b ⊆ U) : |
| 26 | ∃ (g : ℝ → E) (l r : ℝ), ContDiff ℝ ∞ g ∧ |
| 27 | l < a ∧ b < r ∧ Ioo l r ⊆ U ∧ EqOn g f (Ioo l r) := by |
| 28 | obtain ⟨l₀, l', hl, hleft⟩ := mem_nhds_iff_exists_Ioo_subset.mp |
| 29 | (hU.mem_nhds (hI (left_mem_Icc.mpr hab))) |
| 30 | obtain ⟨r', r₀, hr, hright⟩ := mem_nhds_iff_exists_Ioo_subset.mp |
| 31 | (hU.mem_nhds (hI (right_mem_Icc.mpr hab))) |
| 32 | have hwide : Ioo l₀ r₀ ⊆ U := by |
| 33 | intro x hx |
| 34 | by_cases hxa : x < a |
| 35 | · exact hleft ⟨hx.1, hxa.trans hl.2⟩ |
| 36 | by_cases hbx : b < x |
| 37 | · exact hright ⟨hr.1.trans hbx, hx.2⟩ |
| 38 | exact hI ⟨le_of_not_gt hxa, le_of_not_gt hbx⟩ |
| 39 | let η := min (a - l₀) (r₀ - b) / 4 |
| 40 | have hη : 0 < η := div_pos (lt_min (sub_pos.mpr hl.1) (sub_pos.mpr hr.2)) (by norm_num) |
| 41 | have hηl : 4 * η ≤ a - l₀ := by dsimp [η]; linarith [min_le_left (a - l₀) (r₀ - b)] |
| 42 | have hηr : 4 * η ≤ r₀ - b := by dsimp [η]; linarith [min_le_right (a - l₀) (r₀ - b)] |
| 43 | let c := (a + b) / 2 |
| 44 | let χ : ContDiffBump c := { |
| 45 | rIn := (b - a) / 2 + η |
| 46 | rOut := (b - a) / 2 + 2 * η |
| 47 | rIn_pos := by linarith |
| 48 | rIn_lt_rOut := by linarith } |
| 49 | have hsupport : tsupport χ ⊆ U := by |
| 50 | rw [χ.tsupport_eq] |
| 51 | intro x hx |
| 52 | have hd : |x - c| ≤ (b - a) / 2 + 2 * η := by |
| 53 | simpa only [mem_closedBall, Real.dist_eq] using hx |
| 54 | obtain ⟨hxl, hxr⟩ := abs_le.mp hd |
| 55 | apply hwide |
| 56 | dsimp [c] at hxl hxr |
| 57 | constructor <;> linarith |
| 58 | refine ⟨fun x => χ x • f x, a - η, b + η, ?_, by linarith, by linarith, ?_, ?_⟩ |
| 59 | · rw [contDiff_iff_contDiffAt] |
| 60 | intro x |
| 61 | by_cases hx : x ∈ U |
| 62 | · exact χ.contDiffAt.smul ((hf x hx).contDiffAt (hU.mem_nhds hx)) |
| 63 | · have hn : x ∉ tsupport χ := fun hx' => hx (hsupport hx') |
| 64 | apply (contDiffAt_const (c := (0 : E))).congr_of_eventuallyEq |
| 65 | filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hn] with y hy |
| 66 | simp [hy] |
| 67 | · intro x hx |
| 68 | apply hwide |
| 69 | constructor <;> linarith [hx.1, hx.2] |
| 70 | · intro x hx |
| 71 | dsimp only |
| 72 | rw [χ.one_of_mem_closedBall, one_smul] |
| 73 | rw [mem_closedBall, Real.dist_eq] |
| 74 | change |x - c| ≤ (b - a) / 2 + η |
| 75 | rw [abs_le] |
| 76 | dsimp [c] |
| 77 | constructor <;> linarith [hx.1, hx.2] |
| 78 | |
| 79 | end Poincare.Analysis |