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.CurveShortening.Comparison.IntrinsicComparison.Triangle.RegularFans |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Normal.CornerFans |
| 3 | |
| 4 | /-! The exact defect sum for the original normal-collision triangle. |
| 5 | Source: MT Claim 19.40; normal-collision-transversality derivation, |
| 6 | Section 9. Both base fans are derived from actual annular confinement. -/ |
| 7 | |
| 8 | noncomputable section |
| 9 | set_option autoImplicit false |
| 10 | set_option backward.isDefEq.respectTransparency false |
| 11 | |
| 12 | open Set |
| 13 | open scoped Topology ContDiff Manifold Matrix |
| 14 | open PoincareMT.Topology.Surface |
| 15 | |
| 16 | namespace PoincareMT |
| 17 | |
| 18 | open Classical in |
| 19 | /-- Two actual normal base corners give defect sum `2*pi-theta`, where `theta` is the |
| 20 | canonical angle at the original collision vertex. Source: MT Claim 19.40; |
| 21 | normal-collision-transversality derivation, Section 9. Project construction: |
| 22 | `proof-work/tasks/M64/derivations/2026-09-27-normal-collision-transversality.md`, Section 9. -/ |
| 23 | theorem m64Intrinsic_triangle_region_fan_defects |
| 24 | {U V : Set AnnulusCoordinates} (R : M64IntrinsicCoordinateTriangulation (closure U)) |
| 25 | (g : RiemannianMetric 2 AnnulusCoordinates) |
| 26 | {base alpha beta : ℝ → AnnulusCoordinates} {D A B : ℝ} |
| 27 | (hc : ContDiff ℝ ∞ base) (ha : ContDiff ℝ ∞ alpha) (hb : ContDiff ℝ ∞ beta) |
| 28 | (hD : 0 < D) (hA : 0 < A) (hB : 0 < B) |
| 29 | (hci : InjOn base (Icc 0 D)) (hai : InjOn alpha (Icc 0 A)) |
| 30 | (hbi : InjOn beta (Icc 0 B)) |
| 31 | (hcreg : ∀ t ∈ Ioo 0 D, deriv base t ≠ 0) |
| 32 | (hareg : ∀ t ∈ Ioo 0 A, deriv alpha t ≠ 0) |
| 33 | (hbreg : ∀ t ∈ Ioo 0 B, deriv beta t ≠ 0) |
| 34 | (hstartA : base 0 = alpha 0) (hstartB : base D = beta 0) |
| 35 | (hmeet : alpha A = beta B) |
| 36 | (hbaseA : ∀ s ∈ Icc 0 D, ∀ t ∈ Icc 0 A, base s = alpha t → s = 0 ∧ t = 0) |
| 37 | (hbaseB : ∀ s ∈ Icc 0 D, ∀ t ∈ Icc 0 B, base s = beta t → s = D ∧ t = 0) |
| 38 | (hsides : ∀ s ∈ Icc 0 A, ∀ t ∈ Icc 0 B, alpha s = beta t → s = A ∧ t = B) |
| 39 | (hreg0 : deriv base 0 ≠ 0) (hreg1 : deriv base D ≠ 0) |
| 40 | (horth0 : g.inner (base 0) (deriv base 0) (deriv alpha 0) = 0) |
| 41 | (horth1 : g.inner (base D) (deriv base D) (deriv beta 0) = 0) |
| 42 | (hU : IsOpen U) (hV : IsOpen V) (hUV : Disjoint U V) |
| 43 | (hfront : frontier U = base '' Icc 0 D ∪ (alpha '' Icc 0 A ∪ beta '' Icc 0 B)) |
| 44 | (hfV : frontier V = frontier U) |
| 45 | (hnorm0 : ‖base 0‖ = 1) (hnorm1 : ‖base D‖ = 1) |
| 46 | (hinward0 : 0 < inner ℝ (base 0) (deriv alpha 0)) |
| 47 | (hinward1 : 0 < inner ℝ (base D) (deriv beta 0)) |
| 48 | (hsub : closure U ⊆ standardAnnulusDomain) |
| 49 | (v0 v1 vT : Euler.CoordinateVertex R.coordinates R.basis) |
| 50 | (hv0 : v0.1 = base 0) (hv1 : v1.1 = base D) (hvT : vT.1 = alpha A) : |
| 51 | let _ := Fintype.ofFinite (Euler.CoordinateVertex R.coordinates R.basis) |
| 52 | (∑ v : Euler.CoordinateVertex R.coordinates R.basis, |
| 53 | ((if v.1 ∈ frontier U then Real.pi else 2 * Real.pi) - |
| 54 | coordinateVertexAngleContribution g R.coordinates R.basis v.1)) = |
| 55 | 2 * Real.pi - coordinateVertexAngleContribution g R.coordinates R.basis vT.1 := by |
| 56 | classical |
| 57 | let _ := Fintype.ofFinite (Euler.CoordinateVertex R.coordinates R.basis) |
| 58 | let defect (v : Euler.CoordinateVertex R.coordinates R.basis) := |
| 59 | (if v.1 ∈ frontier U then Real.pi else 2 * Real.pi) - |
| 60 | coordinateVertexAngleContribution g R.coordinates R.basis v.1 |
| 61 | change (∑ v, defect v) = _ |
| 62 | have hzero (v : Euler.CoordinateVertex R.coordinates R.basis) |
| 63 | (h0 : v.1 ≠ base 0) (h1 : v.1 ≠ base D) (hT : v.1 ≠ alpha A) : defect v = 0 := by |
| 64 | have hf := m64Intrinsic_triangle_region_regular_vertex_fan R g hc ha hb hci hai hbi |
| 65 | hcreg hareg hbreg hstartA hstartB hmeet hbaseA hbaseB hsides hU hV hUV hfront hfV |
| 66 | v h0 h1 hT |
| 67 | simp only [defect, hf, sub_self] |
| 68 | have hp0 : base 0 ∉ beta '' Icc 0 B := by |
| 69 | rintro ⟨t, ht, he⟩ |
| 70 | exact hD.ne (hbaseB 0 ⟨le_rfl, hD.le⟩ t ht he.symm).1 |
| 71 | have hfan0 := m64Intrinsic_annular_normal_corner_fan R.face R.coordinates R.basis |
| 72 | R.smooth R.inverse_smooth R.source R.carrier R.boundary R.boundary_injective |
| 73 | R.intersections R.intersection_frontier g hc ha hD hA hci hai hstartA.symm hreg0 |
| 74 | horth0 (isCompact_Icc.image hb.continuous) hp0 hU hV hUV |
| 75 | (hfront.trans (by ac_rfl)) hfV hnorm0 hinward0 hsub R.cover v0 hv0 |
| 76 | have hri : InjOn (fun s => base (D - s)) (Icc 0 D) := by |
| 77 | intro s hs t ht he |
| 78 | have h := hci ⟨by linarith [hs.2], by linarith [hs.1]⟩ |
| 79 | ⟨by linarith [ht.2], by linarith [ht.1]⟩ he |
| 80 | linarith |
| 81 | have hrimage : (fun s => base (D - s)) '' Icc 0 D = base '' Icc 0 D := by |
| 82 | change (base ∘ fun s => D - s) '' Icc 0 D = _ |
| 83 | rw [image_comp, image_const_sub_Icc] |
| 84 | simp only [sub_self, sub_zero] |
| 85 | have hp1 : base (D - 0) ∉ alpha '' Icc 0 A := by |
| 86 | rw [sub_zero] |
| 87 | rintro ⟨t, ht, he⟩ |
| 88 | exact hD.ne' (hbaseA D ⟨hD.le, le_rfl⟩ t ht he.symm).1 |
| 89 | have hrd : deriv (fun s => base (D - s)) 0 = -deriv base D := by |
| 90 | rw [deriv_comp_const_sub, sub_zero] |
| 91 | have hrreg : deriv (fun s => base (D - s)) 0 ≠ 0 := by |
| 92 | rw [hrd] |
| 93 | exact neg_ne_zero.mpr hreg1 |
| 94 | have hrorth : g.inner (base (D - 0)) |
| 95 | (deriv (fun s => base (D - s)) 0 : AnnulusCoordinates) |
| 96 | (deriv beta 0 : AnnulusCoordinates) = 0 := by |
| 97 | rw [sub_zero, hrd, map_neg, neg_apply, horth1, neg_zero] |
| 98 | have hrfront : frontier U = (fun s => base (D - s)) '' Icc 0 D ∪ |
| 99 | beta '' Icc 0 B ∪ alpha '' Icc 0 A := by |
| 100 | rw [hrimage] |
| 101 | exact hfront.trans (by ac_rfl) |
| 102 | have hrc : ContDiff ℝ ∞ (fun s => base (D - s)) := |
| 103 | hc.comp (contDiff_const.sub contDiff_id) |
| 104 | have hfan1 := m64Intrinsic_annular_normal_corner_fan R.face R.coordinates R.basis |
| 105 | R.smooth R.inverse_smooth R.source R.carrier R.boundary R.boundary_injective |
| 106 | R.intersections R.intersection_frontier g |
| 107 | hrc hb hD hB hri hbi |
| 108 | (by simpa only [sub_zero] using hstartB.symm) hrreg hrorth |
| 109 | (isCompact_Icc.image ha.continuous) hp1 hU hV hUV hrfront hfV |
| 110 | (by simpa only [sub_zero] using hnorm1) (by simpa only [sub_zero] using hinward1) |
| 111 | hsub R.cover v1 (by simpa only [sub_zero] using hv1) |
| 112 | have hmem0 : v0.1 ∈ frontier U := by |
| 113 | rw [hfront] |
| 114 | exact Or.inl ⟨0, ⟨le_rfl, hD.le⟩, hv0.symm⟩ |
| 115 | have hmem1 : v1.1 ∈ frontier U := by |
| 116 | rw [hfront] |
| 117 | exact Or.inl ⟨D, ⟨hD.le, le_rfl⟩, hv1.symm⟩ |
| 118 | have hmemT : vT.1 ∈ frontier U := by |
| 119 | rw [hfront] |
| 120 | exact Or.inr (Or.inl ⟨A, ⟨hA.le, le_rfl⟩, hvT.symm⟩) |
| 121 | have hd0 : defect v0 = Real.pi / 2 := by |
| 122 | dsimp only [defect] |
| 123 | rw [if_pos hmem0, hfan0] |
| 124 | ring |
| 125 | have hd1 : defect v1 = Real.pi / 2 := by |
| 126 | dsimp only [defect] |
| 127 | rw [if_pos hmem1, hfan1] |
| 128 | ring |
| 129 | have hdT : defect vT = Real.pi - |
| 130 | coordinateVertexAngleContribution g R.coordinates R.basis vT.1 := by |
| 131 | simp only [defect, if_pos hmemT] |
| 132 | have hne01 : v0 ≠ v1 := by |
| 133 | intro he |
| 134 | have h := hci ⟨le_rfl, hD.le⟩ ⟨hD.le, le_rfl⟩ |
| 135 | (hv0.symm.trans ((congrArg Subtype.val he).trans hv1)) |
| 136 | exact hD.ne h |
| 137 | have hne0T : v0 ≠ vT := by |
| 138 | intro he |
| 139 | have h := hbaseA 0 ⟨le_rfl, hD.le⟩ A ⟨hA.le, le_rfl⟩ |
| 140 | (hv0.symm.trans ((congrArg Subtype.val he).trans hvT)) |
| 141 | exact hA.ne' h.2 |
| 142 | have hne1T : v1 ≠ vT := by |
| 143 | intro he |
| 144 | have h := hbaseA D ⟨hD.le, le_rfl⟩ A ⟨hA.le, le_rfl⟩ |
| 145 | (hv1.symm.trans ((congrArg Subtype.val he).trans hvT)) |
| 146 | exact hD.ne' h.1 |
| 147 | have hsum : (∑ v, defect v) = ∑ v ∈ ({v0, v1, vT} : Finset _), defect v := by |
| 148 | symm |
| 149 | apply Finset.sum_subset (Finset.subset_univ _) |
| 150 | intro v _ hv |
| 151 | apply hzero |
| 152 | · intro h |
| 153 | exact hv (by simp only [Finset.mem_insert, Finset.mem_singleton] |
| 154 | exact Or.inl (Subtype.ext (h.trans hv0.symm))) |
| 155 | · intro h |
| 156 | exact hv (by simp only [Finset.mem_insert, Finset.mem_singleton] |
| 157 | exact Or.inr (Or.inl (Subtype.ext (h.trans hv1.symm)))) |
| 158 | · intro h |
| 159 | exact hv (by simp only [Finset.mem_insert, Finset.mem_singleton] |
| 160 | exact Or.inr (Or.inr (Subtype.ext (h.trans hvT.symm)))) |
| 161 | rw [hsum, Finset.sum_insert (by simp [hne01, hne0T]), Finset.sum_pair hne1T, |
| 162 | hd0, hd1, hdT] |
| 163 | ring |
| 164 | |
| 165 | end PoincareMT |