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.Geometry.Riemannian.Coordinates.Exponential.InitialData |
| 2 | import PoincareLib.Geometry.Riemannian.Distance.ExponentialRays |
| 3 | import PoincareLib.Geometry.Riemannian.Comparison.Injectivity.OrbitConvexity |
| 4 | import PoincareLib.Geometry.CurveShortening.Comparison.Geometry |
| 5 | import Mathlib.Analysis.Calculus.TangentCone.Real |
| 6 | |
| 7 | /-! |
| 8 | # Extending the actual outgoing geodesic to a boundary contact |
| 9 | |
| 10 | Compact position confinement and conserved energy allow coordinate ODE |
| 11 | continuation. Time reversal gives an extension through a finite left |
| 12 | endpoint, and continuity identifies its endpoint with the original curve. |
| 13 | Source: MT Claim 19.40, pp. 470-471; minimal-contact-regularity derivation. |
| 14 | No completeness of the ambient plane metric is assumed. |
| 15 | -/ |
| 16 | |
| 17 | noncomputable section |
| 18 | set_option autoImplicit false |
| 19 | set_option backward.isDefEq.respectTransparency false |
| 20 | |
| 21 | open Set Filter |
| 22 | open scoped Topology Manifold ContDiff Bundle |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | attribute [local instance] normedAddCommGroupTangentSpaceVectorSpace |
| 27 | normedSpaceTangentSpaceVectorSpace |
| 28 | |
| 29 | /-- A geodesic confined to any actual compact planar region extends past its finite right |
| 30 | endpoint, with terminal position in that region. Source: MT Claim 19.40, pp. 470-471; |
| 31 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Sections 3 and |
| 32 | 10. -/ |
| 33 | theorem m64Intrinsic_compact_geodesic_right_extension |
| 34 | (G : RiemannianMetric 2 AnnulusCoordinates) {K : Set AnnulusCoordinates} |
| 35 | (hK : IsCompact K) {a b : ℝ} (hab : a < b) {q : ℝ → AnnulusCoordinates} |
| 36 | (hgeo : G.IsGeodesicOn q (Ioo a b)) (hmap : MapsTo q (Ioo a b) K) : |
| 37 | ∃ epsilon : ℝ, 0 < epsilon ∧ ∃ eta : ℝ → AnnulusCoordinates, |
| 38 | EqOn eta q (Ioo a b) ∧ eta b ∈ K ∧ G.IsGeodesicOn eta (Ioo a (b + epsilon)) := by |
| 39 | let p : AnnulusCoordinates := 0 |
| 40 | have hfixed := hgeo.hasDerivAt_in_chart isOpen_Ioo p (fun _ _ => by simp) |
| 41 | have hq (t : ℝ) (ht : t ∈ Ioo a b) : HasDerivAt q (deriv q t) t := by |
| 42 | simpa only [extChartAt_model_space_eq_id, PartialEquiv.refl_coe, id_eq] using |
| 43 | (hfixed t ht).1 |
| 44 | have hw (t : ℝ) (ht : t ∈ Ioo a b) : HasDerivAt (deriv q) |
| 45 | (-coordinateChristoffel (G.pullbackCoefficients (extChartAt (𝓡 2) p).symm) |
| 46 | (q t) (deriv q t) (deriv q t)) t := by |
| 47 | simpa only [extChartAt_model_space_eq_id, PartialEquiv.refl_coe, id_eq] using |
| 48 | (hfixed t ht).2 |
| 49 | obtain ⟨epsilon, hepsilon, eta, v, heq, _, hend, hflow⟩ := |
| 50 | G.exists_chart_geodesic_continuation p hK (fun _ _ => by simp) hab |
| 51 | (fun t ht => hmap ht) hq hw |
| 52 | refine ⟨epsilon, hepsilon, eta, heq, hend, ?_⟩ |
| 53 | simpa only [extChartAt_model_space_eq_id, PartialEquiv.refl_symm, |
| 54 | PartialEquiv.refl_coe, id_eq] using! |
| 55 | G.isGeodesicOn_chart_curve p isOpen_Ioo hflow |
| 56 | |
| 57 | /-- Compact confinement extends a geodesic through its left endpoint. The original right |
| 58 | continuity identifies the extension there, so the agreement includes the endpoint and |
| 59 | supplies a genuine right derivative. Source: MT Claim 19.40, pp. 470-471; |
| 60 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Sections 3 and |
| 61 | 10. -/ |
| 62 | theorem m64Intrinsic_compact_geodesic_left_extension |
| 63 | (G : RiemannianMetric 2 AnnulusCoordinates) {K : Set AnnulusCoordinates} |
| 64 | (hK : IsCompact K) {a b : ℝ} (hab : a < b) {q : ℝ → AnnulusCoordinates} |
| 65 | (hgeo : G.IsGeodesicOn q (Ioo a b)) (hmap : MapsTo q (Ioo a b) K) |
| 66 | (hc : ContinuousWithinAt q (Ici a) a) : |
| 67 | ∃ epsilon : ℝ, 0 < epsilon ∧ ∃ eta : ℝ → AnnulusCoordinates, |
| 68 | EqOn eta q (Ico a b) ∧ G.IsGeodesicOn eta (Ioo (a - epsilon) b) := by |
| 69 | have hrev : G.IsGeodesicOn (fun t => q (-t)) (Ioo (-b) (-a)) := by |
| 70 | have hh := hgeo.comp_affine (-1) 0 |
| 71 | simp only [neg_one_mul, add_zero] at hh |
| 72 | intro t ht |
| 73 | exact hh t ⟨by linarith [ht.2], by linarith [ht.1]⟩ |
| 74 | obtain ⟨epsilon, hepsilon, eta, heq, _, heta⟩ := |
| 75 | m64Intrinsic_compact_geodesic_right_extension G hK (neg_lt_neg hab) hrev |
| 76 | (fun t ht => hmap ⟨by linarith [ht.2], by linarith [ht.1]⟩) |
| 77 | let zeta := fun t => eta (-t) |
| 78 | have hzeta : G.IsGeodesicOn zeta (Ioo (a - epsilon) b) := by |
| 79 | have hh := heta.comp_affine (-1) 0 |
| 80 | simp only [neg_one_mul, add_zero] at hh |
| 81 | intro t ht |
| 82 | exact hh t ⟨by linarith [ht.2], by linarith [ht.1]⟩ |
| 83 | have hza : ContinuousAt zeta a := |
| 84 | (hzeta.contMDiffAt (show a ∈ Ioo (a - epsilon) b from ⟨by linarith, hab⟩)).continuousAt |
| 85 | have hnear : zeta =ᶠ[𝓝[>] a] q := by |
| 86 | filter_upwards [Ioo_mem_nhdsGT hab] with t ht |
| 87 | have h := heq (show -t ∈ Ioo (-b) (-a) from ⟨by linarith [ht.2], by linarith [ht.1]⟩) |
| 88 | simpa only [zeta, neg_neg] using h |
| 89 | have hpoint : zeta a = q a := |
| 90 | tendsto_nhds_unique ((hza.tendsto.mono_left nhdsWithin_le_nhds).congr' hnear) |
| 91 | (hc.mono Ioi_subset_Ici_self) |
| 92 | refine ⟨epsilon, hepsilon, zeta, ?_, hzeta⟩ |
| 93 | intro t ht |
| 94 | rcases ht.1.eq_or_lt with h | h |
| 95 | · simpa only [← h] using hpoint |
| 96 | · have hh := heq (show -t ∈ Ioo (-b) (-a) from ⟨by linarith [ht.2], by linarith⟩) |
| 97 | simpa only [zeta, neg_neg] using hh |
| 98 | |
| 99 | /-- The actual compact outgoing geodesic has a right derivative at its continuous boundary |
| 100 | endpoint. This supplies the derivative input of the local constrained-minimizer tangency |
| 101 | theorem. Source: MT Claim 19.40, pp. 470-471; |
| 102 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Sections 3 and |
| 103 | 10. -/ |
| 104 | theorem m64Intrinsic_compact_geodesic_has_right_derivative |
| 105 | (G : RiemannianMetric 2 AnnulusCoordinates) {K : Set AnnulusCoordinates} |
| 106 | (hK : IsCompact K) {a b : ℝ} (hab : a < b) {q : ℝ → AnnulusCoordinates} |
| 107 | (hgeo : G.IsGeodesicOn q (Ioo a b)) (hmap : MapsTo q (Ioo a b) K) |
| 108 | (hc : ContinuousWithinAt q (Ici a) a) : |
| 109 | ∃ v : AnnulusCoordinates, HasDerivWithinAt q v (Ioi a) a := by |
| 110 | obtain ⟨epsilon, hepsilon, eta, heq, heta⟩ := |
| 111 | m64Intrinsic_compact_geodesic_left_extension G hK hab hgeo hmap hc |
| 112 | have hd : HasDerivAt eta (deriv eta a) a := |
| 113 | (contMDiffAt_iff_contDiffAt.mp (heta.contMDiffAt |
| 114 | (show a ∈ Ioo (a - epsilon) b from ⟨by linarith, hab⟩))).differentiableAt |
| 115 | (by simp) |>.hasDerivAt |
| 116 | refine ⟨deriv eta a, hd.hasDerivWithinAt.congr_of_eventuallyEq ?_ ?_⟩ |
| 117 | · filter_upwards [Ioo_mem_nhdsGT hab] with t ht |
| 118 | exact (heq ⟨ht.1.le, ht.2⟩).symm |
| 119 | · exact (heq ⟨le_rfl, hab⟩).symm |
| 120 | |
| 121 | /-- A distinct later point forces the actual outgoing endpoint derivative to be nonzero. The |
| 122 | extension includes the endpoint, so M07's constant-speed argument applies on a genuine |
| 123 | closed subinterval through that point. Source: MT Claim 19.40, pp. 470-471; |
| 124 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Sections 3 and |
| 125 | 10. -/ |
| 126 | theorem m64Intrinsic_compact_geodesic_right_derivative_ne_zero |
| 127 | (G : RiemannianMetric 2 AnnulusCoordinates) {K : Set AnnulusCoordinates} |
| 128 | (hK : IsCompact K) {a b : ℝ} (hab : a < b) {q : ℝ → AnnulusCoordinates} |
| 129 | (hgeo : G.IsGeodesicOn q (Ioo a b)) (hmap : MapsTo q (Ioo a b) K) |
| 130 | (hc : ContinuousWithinAt q (Ici a) a) {c : ℝ} (hcab : c ∈ Ioo a b) |
| 131 | (hne : q a ≠ q c) {v : AnnulusCoordinates} |
| 132 | (hv : HasDerivWithinAt q v (Ioi a) a) : v ≠ 0 := by |
| 133 | obtain ⟨epsilon, hepsilon, eta, heq, heta⟩ := |
| 134 | m64Intrinsic_compact_geodesic_left_extension G hK hab hgeo hmap hc |
| 135 | have hd : HasDerivAt eta (deriv eta a) a := |
| 136 | (contMDiffAt_iff_contDiffAt.mp (heta.contMDiffAt |
| 137 | (show a ∈ Ioo (a - epsilon) b from ⟨by linarith, hab⟩))).differentiableAt |
| 138 | (by simp) |>.hasDerivAt |
| 139 | have hdq : HasDerivWithinAt q (deriv eta a) (Ioi a) a := by |
| 140 | apply hd.hasDerivWithinAt.congr_of_eventuallyEq |
| 141 | · filter_upwards [Ioo_mem_nhdsGT hab] with t ht |
| 142 | exact (heq ⟨ht.1.le, ht.2⟩).symm |
| 143 | · exact (heq ⟨le_rfl, hab⟩).symm |
| 144 | have hveq : v = deriv eta a := |
| 145 | (hv.derivWithin (uniqueDiffWithinAt_Ioi a)).symm.trans |
| 146 | (hdq.derivWithin (uniqueDiffWithinAt_Ioi a)) |
| 147 | rw [hveq] |
| 148 | apply heta.deriv_ne_zero_of_endpoints_ne isOpen_Ioo hcab.1.le |
| 149 | (show Icc a c ⊆ Ioo (a - epsilon) b from fun t ht => |
| 150 | ⟨by linarith [ht.1], ht.2.trans_lt hcab.2⟩) |
| 151 | (show eta a ≠ eta c from by rw [heq ⟨le_rfl, hab⟩, heq ⟨hcab.1.le, hcab.2⟩]; exact hne) |
| 152 | exact ⟨le_rfl, hcab.1.le⟩ |
| 153 | |
| 154 | end PoincareMT |