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 PoincareLib.Analysis.ODE.LocalFlow.FlowBox |
| 2 | import PoincareLib.Analysis.ODE.Uniqueness.Open |
| 3 | import Mathlib.Topology.MetricSpace.ProperSpace |
| 4 | |
| 5 | /-! |
| 6 | # Transverse returns of bounded planar trajectories |
| 7 | |
| 8 | A bounded forward trajectory of a smooth nonvanishing planar field crosses |
| 9 | a local transverse section at arbitrarily late times. Compactness supplies |
| 10 | late visits to a flow box, and uniqueness moves each visit to its zero-time |
| 11 | section. This is a prerequisite for the nontrapping argument in Smale, |
| 12 | Diffeomorphisms of the 2-sphere (1959), Lemma 2, printed p. 622. |
| 13 | -/ |
| 14 | |
| 15 | noncomputable section |
| 16 | |
| 17 | namespace Poincare.ODE.LocalFlow |
| 18 | |
| 19 | open Set Filter Metric Bornology |
| 20 | open scoped ContDiff Topology |
| 21 | |
| 22 | private theorem transverse_eq_of_flowBox_visit |
| 23 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 24 | {V : E → E} (hV : ContDiff ℝ ∞ V) {γ : ℝ → E} |
| 25 | (hγ : ∀ t ≥ 0, HasDerivAt γ (V (γ t)) t) |
| 26 | (e : OpenPartialHomeomorph (ℝ × ℝ) E) |
| 27 | (he : ∀ s t, (s, t) ∈ e.source → |
| 28 | HasDerivAt (fun r => e (s, r)) (V (e (s, t))) t) |
| 29 | {ε : ℝ} (hε : 0 < ε) |
| 30 | (hbox : Ioo (-ε) ε ×ˢ Ioo (-ε) ε ⊆ e.source) |
| 31 | {n s u : ℝ} (hn : 2 * ε < n) (hs : s ∈ Ioo (-ε) ε) |
| 32 | (hu : u ∈ Ioo (-ε) ε) (hvisit : γ n = e (s, u)) : |
| 33 | γ (n - u) = e (s, 0) := by |
| 34 | let α : ℝ → E := fun t => γ (n + t - u) |
| 35 | have hα : ∀ t ∈ Ioo (-ε) ε, |
| 36 | α t ∈ (univ : Set E) ∧ HasDerivAt α (V (α t)) t := by |
| 37 | intro t ht |
| 38 | refine ⟨mem_univ _, ?_⟩ |
| 39 | have htime : 0 ≤ n + t - u := by linarith [ht.1, hu.2] |
| 40 | simpa only [α, Function.comp_def, one_smul, id_eq] using |
| 41 | (hγ (n + t - u) htime).scomp t (((hasDerivAt_id t).const_add n).sub_const u) |
| 42 | have hη : ∀ t ∈ Ioo (-ε) ε, |
| 43 | e (s, t) ∈ (univ : Set E) ∧ |
| 44 | HasDerivAt (fun r => e (s, r)) (V (e (s, t))) t := |
| 45 | fun t ht => ⟨mem_univ _, he s t (hbox ⟨hs, ht⟩)⟩ |
| 46 | have hinit : α u = e (s, u) := by simpa only [α, add_sub_cancel_right] using hvisit |
| 47 | have heq := Poincare.ODE.eqOn_of_hasDerivAt isOpen_univ hV.contDiffOn |
| 48 | isOpen_Ioo (convex_Ioo (-ε) ε).isPreconnected hα hη hu hinit |
| 49 | simpa only [α, add_zero] using heq (show (0 : ℝ) ∈ Ioo (-ε) ε from ⟨by linarith, hε⟩) |
| 50 | |
| 51 | /-- A bounded forward integral curve of a smooth nowhere-zero planar field |
| 52 | has arbitrarily late crossings of a transverse section through a cluster point. |
| 53 | The rectangle lies in a smooth flow box, and its second-coordinate curves |
| 54 | solve the original vector field. -/ |
| 55 | theorem exists_flowBox_transverse_returns |
| 56 | {V : EuclideanSpace ℝ (Fin 2) → EuclideanSpace ℝ (Fin 2)} |
| 57 | (hV : ContDiff ℝ ∞ V) (hne : ∀ p, V p ≠ 0) |
| 58 | {γ : ℝ → EuclideanSpace ℝ (Fin 2)} |
| 59 | (hγ : ∀ t ≥ 0, HasDerivAt γ (V (γ t)) t) |
| 60 | (hbounded : IsBounded (γ '' Ici 0)) : |
| 61 | ∃ (e : OpenPartialHomeomorph (ℝ × ℝ) (EuclideanSpace ℝ (Fin 2))) (ε : ℝ), |
| 62 | 0 < ε ∧ Ioo (-ε) ε ×ˢ Ioo (-ε) ε ⊆ e.source ∧ |
| 63 | MapClusterPt (e (0, 0)) atTop γ ∧ |
| 64 | ContDiffOn ℝ ∞ e e.source ∧ ContDiffOn ℝ ∞ e.symm e.target ∧ |
| 65 | (∀ s t, (s, t) ∈ e.source → |
| 66 | HasDerivAt (fun r => e (s, r)) (V (e (s, t))) t) ∧ |
| 67 | ∀ T : ℝ, ∃ t > T, ∃ s ∈ Ioo (-ε) ε, |
| 68 | (s, 0) ∈ e.source ∧ γ t = e (s, 0) := by |
| 69 | have hcompact : IsCompact (closure (γ '' Ici 0)) := hbounded.isCompact_closure |
| 70 | have hmem : ∀ᶠ t : ℝ in atTop, γ t ∈ closure (γ '' Ici 0) := by |
| 71 | filter_upwards [eventually_ge_atTop (0 : ℝ)] with t ht |
| 72 | exact subset_closure (mem_image_of_mem γ ht) |
| 73 | obtain ⟨p, _, hp⟩ := hcompact.exists_mapClusterPt_of_frequently hmem.frequently |
| 74 | obtain ⟨e, he0, hep, _, he, hei, hflow⟩ := |
| 75 | exists_smooth_planar_flowBox isOpen_univ hV.contDiffOn (mem_univ p) (hne p) |
| 76 | obtain ⟨ε, hε, hball⟩ := Metric.isOpen_iff.mp e.open_source (0, 0) he0 |
| 77 | have hbox : Ioo (-ε) ε ×ˢ Ioo (-ε) ε ⊆ e.source := by |
| 78 | rintro ⟨s, u⟩ ⟨hs, hu⟩ |
| 79 | apply hball |
| 80 | rw [mem_ball, Prod.dist_eq, Real.dist_eq, Real.dist_eq, sub_zero, sub_zero, |
| 81 | max_lt_iff] |
| 82 | exact ⟨abs_lt.mpr hs, abs_lt.mpr hu⟩ |
| 83 | let O : Set (EuclideanSpace ℝ (Fin 2)) := |
| 84 | e.target ∩ e.symm ⁻¹' (Ioo (-ε) ε ×ˢ Ioo (-ε) ε) |
| 85 | have hO : IsOpen O := |
| 86 | e.continuousOn_symm.isOpen_inter_preimage e.open_target (isOpen_Ioo.prod isOpen_Ioo) |
| 87 | have hpO : p ∈ O := by |
| 88 | have hzero : (0 : ℝ) ∈ Ioo (-ε) ε := ⟨by linarith, hε⟩ |
| 89 | rw [← hep] |
| 90 | refine ⟨e.map_source he0, ?_⟩ |
| 91 | change e.symm (e (0, 0)) ∈ Ioo (-ε) ε ×ˢ Ioo (-ε) ε |
| 92 | rw [e.left_inv he0] |
| 93 | exact ⟨hzero, hzero⟩ |
| 94 | refine ⟨e, ε, hε, hbox, hep.symm ▸ hp, he, hei, hflow, ?_⟩ |
| 95 | intro T |
| 96 | have hlate : ∃ᶠ n : ℝ in atTop, γ n ∈ O := |
| 97 | (mapClusterPt_iff_frequently.mp hp) O (hO.mem_nhds hpO) |
| 98 | obtain ⟨n, hnO, hn⟩ := |
| 99 | (hlate.and_eventually (eventually_gt_atTop (max T 0 + 3 * ε))).exists |
| 100 | let s : ℝ := (e.symm (γ n)).1 |
| 101 | let u : ℝ := (e.symm (γ n)).2 |
| 102 | have hs : s ∈ Ioo (-ε) ε := hnO.2.1 |
| 103 | have hu : u ∈ Ioo (-ε) ε := hnO.2.2 |
| 104 | have hvisit : γ n = e (s, u) := (e.right_inv hnO.1).symm |
| 105 | have hnε : 2 * ε < n := by linarith [le_max_right T 0] |
| 106 | have hreturn : γ (n - u) = e (s, 0) := |
| 107 | transverse_eq_of_flowBox_visit hV hγ e hflow hε hbox hnε hs hu hvisit |
| 108 | refine ⟨n - u, ?_, s, hs, hbox ⟨hs, ⟨by linarith, hε⟩⟩, hreturn⟩ |
| 109 | linarith [le_max_left T 0, hu.2] |
| 110 | |
| 111 | end Poincare.ODE.LocalFlow |