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 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 4 | import Mathlib.Analysis.SpecialFunctions.SmoothTransition |
| 5 | |
| 6 | /-! |
| 7 | # Smooth connectors in a planar flow box |
| 8 | |
| 9 | A compactly supported horizontal perturbation of the vertical unit field |
| 10 | joins any two vertical lines in a prescribed rectangle. The vertical |
| 11 | component remains one, so the modified field never vanishes. |
| 12 | -/ |
| 13 | |
| 14 | noncomputable section |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open Set Filter Metric |
| 19 | open scoped ContDiff Topology |
| 20 | |
| 21 | namespace Poincare.ODE.LocalFlow |
| 22 | |
| 23 | /-- A nowhere-zero field, equal to the vertical unit field outside a |
| 24 | rectangle, has an integral curve joining two prescribed vertical lines. -/ |
| 25 | theorem exists_vertical_field_connector |
| 26 | {r R h a b : ℝ} (hr : 0 < r) (hrR : r < R) (hh : 0 < h) |
| 27 | (ha : |a| ≤ r) (hb : |b| ≤ r) : |
| 28 | ∃ (W : ℝ × ℝ → ℝ × ℝ) (γ : ℝ → ℝ × ℝ), |
| 29 | ContDiff ℝ ∞ W ∧ ContDiff ℝ ∞ γ ∧ |
| 30 | (∀ z, (W z).2 = 1) ∧ |
| 31 | (∀ z, R ≤ |z.1| ∨ h ≤ |z.2| → W z = (0, 1)) ∧ |
| 32 | (∀ t, HasDerivAt γ (W (γ t)) t) ∧ |
| 33 | (∀ t, (γ t).2 = t ∧ |(γ t).1| ≤ r) ∧ |
| 34 | (∀ t, t ≤ -h → γ t = (b, t)) ∧ |
| 35 | (∀ t, h ≤ t → γ t = (a, t)) := by |
| 36 | let θ : ℝ → ℝ := fun t => Real.smoothTransition (t / h + 1 / 2) |
| 37 | have hθ : ContDiff ℝ ∞ θ := Real.smoothTransition.contDiff.comp |
| 38 | ((contDiff_id.div_const h).add contDiff_const) |
| 39 | have hθlo (t : ℝ) (ht : t < -h / 2) : θ t = 0 := by |
| 40 | apply Real.smoothTransition.zero_of_nonpos |
| 41 | have : t / h < -(1 / 2 : ℝ) := (div_lt_iff₀ hh).mpr (by linarith) |
| 42 | linarith |
| 43 | have hθhi (t : ℝ) (ht : h / 2 < t) : θ t = 1 := by |
| 44 | apply Real.smoothTransition.one_of_one_le |
| 45 | have : (1 / 2 : ℝ) < t / h := (lt_div_iff₀ hh).mpr (by linarith) |
| 46 | linarith |
| 47 | let u : ℝ → ℝ := fun t => b + (a - b) * θ t |
| 48 | have hu : ContDiff ℝ ∞ u := contDiff_const.add (contDiff_const.mul hθ) |
| 49 | have hubound (t : ℝ) : |u t| ≤ r := by |
| 50 | have ht0 : 0 ≤ θ t := Real.smoothTransition.nonneg _ |
| 51 | have ht1 : θ t ≤ 1 := Real.smoothTransition.le_one _ |
| 52 | obtain ⟨ha0, ha1⟩ := abs_le.mp ha |
| 53 | obtain ⟨hb0, hb1⟩ := abs_le.mp hb |
| 54 | dsimp only [u] |
| 55 | rw [abs_le] |
| 56 | constructor <;> nlinarith |
| 57 | have hulo (t : ℝ) (ht : t < -h / 2) : u t = b := by simp [u, hθlo t ht] |
| 58 | have huhi (t : ℝ) (ht : h / 2 < t) : u t = a := by simp [u, hθhi t ht] |
| 59 | have hduzero (t : ℝ) (ht : h ≤ |t|) : deriv u t = 0 := by |
| 60 | rcases le_abs.mp ht with ht | ht |
| 61 | · have hlt : h / 2 < t := by linarith |
| 62 | have heq : u =ᶠ[𝓝 t] fun _ => a := by |
| 63 | filter_upwards [eventually_gt_nhds hlt] with s hs |
| 64 | exact huhi s hs |
| 65 | exact heq.deriv_eq.trans (deriv_const t a) |
| 66 | · have hlt : t < -h / 2 := by linarith |
| 67 | have heq : u =ᶠ[𝓝 t] fun _ => b := by |
| 68 | filter_upwards [eventually_lt_nhds hlt] with s hs |
| 69 | exact hulo s hs |
| 70 | exact heq.deriv_eq.trans (deriv_const t b) |
| 71 | let χ : ContDiffBump (0 : ℝ) := ⟨r, R, hr, hrR⟩ |
| 72 | have hχu (t : ℝ) : χ (u t) = 1 := χ.one_of_mem_closedBall |
| 73 | (by simpa only [mem_closedBall, dist_zero_right, Real.norm_eq_abs] using hubound t) |
| 74 | let W : ℝ × ℝ → ℝ × ℝ := fun z => (χ z.1 * deriv u z.2, 1) |
| 75 | let γ : ℝ → ℝ × ℝ := fun t => (u t, t) |
| 76 | refine ⟨W, γ, ?_, hu.prodMk contDiff_id, fun _ => rfl, ?_, ?_, |
| 77 | fun t => ⟨rfl, hubound t⟩, ?_, ?_⟩ |
| 78 | · exact ((χ.contDiff.comp contDiff_fst).mul |
| 79 | ((contDiff_infty_iff_deriv.mp hu).2.comp contDiff_snd)).prodMk contDiff_const |
| 80 | · intro z hz |
| 81 | rcases hz with hz | hz |
| 82 | · have hc : χ z.1 = 0 := χ.zero_of_le_dist (by simpa [Real.dist_eq] using hz) |
| 83 | simp [W, hc] |
| 84 | · simp [W, hduzero z.2 hz] |
| 85 | · intro t |
| 86 | simpa only [W, γ, hχu, one_mul, id_eq] using |
| 87 | ((hu.differentiable (by simp) t).hasDerivAt.prodMk (hasDerivAt_id t)) |
| 88 | · intro t ht |
| 89 | exact Prod.ext (hulo t (by linarith)) rfl |
| 90 | · intro t ht |
| 91 | exact Prod.ext (huhi t (by linarith)) rfl |
| 92 | |
| 93 | end Poincare.ODE.LocalFlow |