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.Three.ArcStraightFan |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Normal.CornerFans |
| 3 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Arc.BoundaryFans |
| 4 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Regional.InteriorFans |
| 5 | |
| 6 | /-! Actual vertex defects of the three-arc normal-contact region. |
| 7 | Source: MT Claim 19.40, pp. 470-471; combined-boundary-collar derivation, |
| 8 | Section 11. All fans refer to one actual coordinate triangulation. -/ |
| 9 | |
| 10 | noncomputable section |
| 11 | set_option autoImplicit false |
| 12 | set_option backward.isDefEq.respectTransparency false |
| 13 | |
| 14 | open Set |
| 15 | open scoped Topology ContDiff Manifold Matrix |
| 16 | open PoincareMT.Topology.Surface |
| 17 | |
| 18 | namespace PoincareMT |
| 19 | |
| 20 | private theorem vertex_angle_nonneg |
| 21 | {I : Type*} [Fintype I] (g : RiemannianMetric 2 AnnulusCoordinates) |
| 22 | (F : I → OpenPartialHomeomorph AnnulusCoordinates AnnulusCoordinates) |
| 23 | (b : I → AffineBasis (Fin 3) ℝ AnnulusCoordinates) (q : AnnulusCoordinates) : |
| 24 | 0 ≤ coordinateVertexAngleContribution g F b q := by |
| 25 | unfold coordinateVertexAngleContribution |
| 26 | apply Finset.sum_nonneg |
| 27 | intro i _ |
| 28 | apply Finset.sum_nonneg |
| 29 | intro k _ |
| 30 | split_ifs |
| 31 | · exact Real.arccos_nonneg _ |
| 32 | · exact le_rfl |
| 33 | |
| 34 | open Classical in |
| 35 | /-- An actual normal initial corner, straight middle join, and arbitrary terminal corner |
| 36 | give total canonical defect at most `3*pi/2`. Source: MT Claim 19.40; |
| 37 | combined-boundary-collar derivation, Section 11. Construction: |
| 38 | proof-work/tasks/M64/derivations/2026-09-27-combined-boundary-collar.md, Section 11. -/ |
| 39 | theorem m64Intrinsic_three_arc_region_fan_defects_le |
| 40 | {U V : Set AnnulusCoordinates} (R : M64IntrinsicCoordinateTriangulation (closure U)) |
| 41 | (g : RiemannianMetric 2 AnnulusCoordinates) |
| 42 | (gamma : Bool → ℝ → AnnulusCoordinates) (sigma : ℝ → AnnulusCoordinates) |
| 43 | (T : Bool → ℝ) {S speed : ℝ} (hg : ∀ e, ContDiff ℝ ∞ (gamma e)) |
| 44 | (hs : ContDiff ℝ ∞ sigma) (hT : ∀ e, 0 < T e) (hS : 0 < S) (hspeed : 0 < speed) |
| 45 | (hinj : ∀ e, InjOn (gamma e) (Icc 0 (T e))) (hsi : InjOn sigma (Icc 0 S)) |
| 46 | (hstart : sigma 0 = gamma false 0) (hend : sigma S = gamma true (T true)) |
| 47 | (hjoin : gamma false (T false) = gamma true 0) |
| 48 | (hreg : deriv (gamma false) (T false) ≠ 0) |
| 49 | (htan : deriv (gamma true) 0 = speed • deriv (gamma false) (T false)) |
| 50 | (hab : ∀ x ∈ Icc 0 (T false), ∀ y ∈ Icc 0 (T true), |
| 51 | gamma false x = gamma true y → x = T false ∧ y = 0) |
| 52 | (has : ∀ x ∈ Icc 0 (T false), ∀ y ∈ Icc 0 S, |
| 53 | gamma false x = sigma y → x = 0 ∧ y = 0) |
| 54 | (hbs : ∀ x ∈ Icc 0 (T true), ∀ y ∈ Icc 0 S, |
| 55 | gamma true x = sigma y → x = T true ∧ y = S) |
| 56 | (hregular : ∀ e, ∀ t ∈ Ioo (0 : ℝ) (T e), deriv (gamma e) t ≠ 0) |
| 57 | (hsreg : ∀ t ∈ Ioo (0 : ℝ) S, deriv sigma t ≠ 0) |
| 58 | (hreg0 : deriv (gamma false) 0 ≠ 0) |
| 59 | (horth : g.inner (gamma false 0) (deriv (gamma false) 0) (deriv sigma 0) = 0) |
| 60 | (hU : IsOpen U) (hV : IsOpen V) (hUV : Disjoint U V) |
| 61 | (hfU : frontier U = gamma false '' Icc 0 (T false) ∪ |
| 62 | gamma true '' Icc 0 (T true) ∪ sigma '' Icc 0 S) |
| 63 | (hfV : frontier V = frontier U) (hnorm : ‖gamma false 0‖ = 1) |
| 64 | (hinward : 0 < inner ℝ (gamma false 0) (deriv sigma 0)) |
| 65 | (hsub : closure U ⊆ standardAnnulusDomain) |
| 66 | (v0 v1 : Euler.CoordinateVertex R.coordinates R.basis) |
| 67 | (hv0 : v0.1 = gamma false 0) (hv1 : v1.1 = gamma true (T true)) : |
| 68 | let _ := Fintype.ofFinite (Euler.CoordinateVertex R.coordinates R.basis) |
| 69 | (∑ v : Euler.CoordinateVertex R.coordinates R.basis, |
| 70 | ((if v.1 ∈ frontier U then Real.pi else 2 * Real.pi) - |
| 71 | coordinateVertexAngleContribution g R.coordinates R.basis v.1)) ≤ |
| 72 | 3 * Real.pi / 2 := by |
| 73 | classical |
| 74 | let _ := Fintype.ofFinite (Euler.CoordinateVertex R.coordinates R.basis) |
| 75 | let defect (v : Euler.CoordinateVertex R.coordinates R.basis) := |
| 76 | (if v.1 ∈ frontier U then Real.pi else 2 * Real.pi) - |
| 77 | coordinateVertexAngleContribution g R.coordinates R.basis v.1 |
| 78 | change (∑ v, defect v) ≤ _ |
| 79 | have htrace : frontier (⋃ i, (R.face i).carrier) = frontier U := by |
| 80 | rw [R.cover, (m64Intrinsic_jordan_interior_closure hU hV hUV hfV.symm).2] |
| 81 | have hregular_fan {eta : ℝ → AnnulusCoordinates} {a b p : ℝ} |
| 82 | (he : ContDiff ℝ ∞ eta) (hei : InjOn eta (Icc a b)) (hp : p ∈ Ioo a b) |
| 83 | (hr : deriv eta p ≠ 0) {K : Set AnnulusCoordinates} (hK : IsCompact K) |
| 84 | (hpK : eta p ∉ K) (hf : frontier U = eta '' Icc a b ∪ K) |
| 85 | (v : Euler.CoordinateVertex R.coordinates R.basis) (hv : v.1 = eta p) : |
| 86 | coordinateVertexAngleContribution g R.coordinates R.basis v.1 = Real.pi := |
| 87 | m64Intrinsic_region_arc_boundary_fan R.face R.coordinates R.basis R.smooth |
| 88 | R.inverse_smooth R.source R.carrier R.boundary R.boundary_injective |
| 89 | R.intersections R.intersection_frontier g he hei hp hr hK hpK |
| 90 | hU hV hUV hf hfV R.cover v hv |
| 91 | have hzero (v : Euler.CoordinateVertex R.coordinates R.basis) |
| 92 | (hvstart : v.1 ≠ gamma false 0) (hvend : v.1 ≠ gamma true (T true)) : defect v = 0 := by |
| 93 | by_cases hvboundary : v.1 ∈ frontier U |
| 94 | · have hfan : coordinateVertexAngleContribution g R.coordinates R.basis v.1 = |
| 95 | Real.pi := by |
| 96 | by_cases hvjoin : v.1 = gamma false (T false) |
| 97 | · have hpK : gamma false (T false) ∉ sigma '' Icc 0 S := by |
| 98 | rintro ⟨t, ht, he⟩ |
| 99 | exact (hT false).ne' |
| 100 | (has (T false) ⟨(hT false).le, le_rfl⟩ t ht he.symm).1 |
| 101 | exact m64Intrinsic_straight_join_region_vertex_fan R.face R.coordinates R.basis |
| 102 | R.smooth R.inverse_smooth R.source R.carrier R.boundary R.boundary_injective |
| 103 | R.intersections R.intersection_frontier g v (hg false) (hg true) |
| 104 | (hT false) (hT true) hspeed (hinj false) (hinj true) hjoin hreg htan |
| 105 | (isCompact_Icc.image hs.continuous) hpK hU hV hUV hfU hfV R.cover hvjoin |
| 106 | · rw [hfU] at hvboundary |
| 107 | rcases hvboundary with (hva | hvb) | hvs |
| 108 | · obtain ⟨p, hp, hpv⟩ := hva |
| 109 | have hp0 : 0 < p := lt_of_le_of_ne hp.1 (fun h => |
| 110 | hvstart (hpv.symm.trans (congrArg (gamma false) h.symm))) |
| 111 | have hpT : p < T false := lt_of_le_of_ne hp.2 (fun h => |
| 112 | hvjoin (hpv.symm.trans (congrArg (gamma false) h))) |
| 113 | have hpK : gamma false p ∉ gamma true '' Icc 0 (T true) ∪ sigma '' Icc 0 S := by |
| 114 | rintro (⟨t, ht, he⟩ | ⟨t, ht, he⟩) |
| 115 | · exact hpT.ne (hab p hp t ht he.symm).1 |
| 116 | · exact hp0.ne' (has p hp t ht he.symm).1 |
| 117 | exact hregular_fan (hg false) (hinj false) ⟨hp0, hpT⟩ |
| 118 | (hregular false p ⟨hp0, hpT⟩) |
| 119 | ((isCompact_Icc.image (hg true).continuous).union |
| 120 | (isCompact_Icc.image hs.continuous)) hpK |
| 121 | (hfU.trans (union_assoc _ _ _)) v hpv.symm |
| 122 | · obtain ⟨p, hp, hpv⟩ := hvb |
| 123 | have hp0 : 0 < p := lt_of_le_of_ne hp.1 (fun h => |
| 124 | hvjoin (hpv.symm.trans ((congrArg (gamma true) h.symm).trans hjoin.symm))) |
| 125 | have hpT : p < T true := lt_of_le_of_ne hp.2 (fun h => |
| 126 | hvend (hpv.symm.trans (congrArg (gamma true) h))) |
| 127 | have hpK : gamma true p ∉ gamma false '' Icc 0 (T false) ∪ sigma '' Icc 0 S := by |
| 128 | rintro (⟨t, ht, he⟩ | ⟨t, ht, he⟩) |
| 129 | · exact hp0.ne' (hab t ht p hp he).2 |
| 130 | · exact hpT.ne (hbs p hp t ht he.symm).1 |
| 131 | exact hregular_fan (hg true) (hinj true) ⟨hp0, hpT⟩ |
| 132 | (hregular true p ⟨hp0, hpT⟩) |
| 133 | ((isCompact_Icc.image (hg false).continuous).union |
| 134 | (isCompact_Icc.image hs.continuous)) hpK (hfU.trans (by ac_rfl)) v hpv.symm |
| 135 | · obtain ⟨p, hp, hpv⟩ := hvs |
| 136 | have hp0 : 0 < p := lt_of_le_of_ne hp.1 (fun h => |
| 137 | hvstart (hpv.symm.trans ((congrArg sigma h.symm).trans hstart))) |
| 138 | have hpS : p < S := lt_of_le_of_ne hp.2 (fun h => |
| 139 | hvend (hpv.symm.trans ((congrArg sigma h).trans hend))) |
| 140 | have hpK : sigma p ∉ |
| 141 | gamma false '' Icc 0 (T false) ∪ gamma true '' Icc 0 (T true) := by |
| 142 | rintro (⟨t, ht, he⟩ | ⟨t, ht, he⟩) |
| 143 | · exact hp0.ne' (has t ht p hp he).2 |
| 144 | · exact hpS.ne (hbs t ht p hp he).2 |
| 145 | exact hregular_fan hs hsi ⟨hp0, hpS⟩ (hsreg p ⟨hp0, hpS⟩) |
| 146 | ((isCompact_Icc.image (hg false).continuous).union |
| 147 | (isCompact_Icc.image (hg true).continuous)) hpK |
| 148 | (hfU.trans (union_comm _ _)) v hpv.symm |
| 149 | simp only [defect, if_pos hvboundary, hfan, sub_self] |
| 150 | · have hvregion : v.1 ∈ ⋃ i, (R.face i).carrier := by |
| 151 | obtain ⟨⟨i, k⟩, hik⟩ := v.2 |
| 152 | apply mem_iUnion.mpr |
| 153 | refine ⟨i, ?_⟩ |
| 154 | rw [R.carrier] |
| 155 | exact ⟨R.basis i k, subset_convexHull ℝ _ (mem_range_self k), hik⟩ |
| 156 | have hvint : v.1 ∈ interior (⋃ i, (R.face i).carrier) := by |
| 157 | by_contra h |
| 158 | exact hvboundary (htrace ▸ ⟨subset_closure hvregion, h⟩) |
| 159 | have hfan := m64Intrinsic_regional_interior_vertex_fan R.face R.coordinates R.basis |
| 160 | R.smooth R.inverse_smooth R.source R.carrier R.boundary R.boundary_injective |
| 161 | R.intersections R.intersection_frontier g v hvint |
| 162 | simp only [defect, if_neg hvboundary, hfan, sub_self] |
| 163 | have hpW : gamma false 0 ∉ gamma true '' Icc 0 (T true) := by |
| 164 | rintro ⟨t, ht, he⟩ |
| 165 | exact (hT false).ne (hab 0 ⟨le_rfl, (hT false).le⟩ t ht he.symm).1 |
| 166 | have hfan0 := m64Intrinsic_annular_normal_corner_fan R.face R.coordinates R.basis |
| 167 | R.smooth R.inverse_smooth R.source R.carrier R.boundary R.boundary_injective |
| 168 | R.intersections R.intersection_frontier g (hg false) hs (hT false) hS |
| 169 | (hinj false) hsi hstart hreg0 horth (isCompact_Icc.image (hg true).continuous) |
| 170 | hpW hU hV hUV (hfU.trans (by ac_rfl)) hfV hnorm hinward hsub R.cover v0 hv0 |
| 171 | have hmem0 : v0.1 ∈ frontier U := by |
| 172 | rw [hfU] |
| 173 | exact Or.inl (Or.inl ⟨0, ⟨le_rfl, (hT false).le⟩, hv0.symm⟩) |
| 174 | have hmem1 : v1.1 ∈ frontier U := by |
| 175 | rw [hfU] |
| 176 | exact Or.inl (Or.inr ⟨T true, ⟨(hT true).le, le_rfl⟩, hv1.symm⟩) |
| 177 | have hdefect0 : defect v0 = Real.pi / 2 := by |
| 178 | dsimp only [defect] |
| 179 | rw [if_pos hmem0, hfan0] |
| 180 | ring |
| 181 | have hdefect1 : defect v1 ≤ Real.pi := by |
| 182 | dsimp only [defect] |
| 183 | rw [if_pos hmem1] |
| 184 | exact sub_le_self _ (vertex_angle_nonneg g R.coordinates R.basis v1.1) |
| 185 | have hne : v0 ≠ v1 := by |
| 186 | intro h |
| 187 | have he : sigma 0 = sigma S := hstart.trans (hv0.symm.trans |
| 188 | ((congrArg Subtype.val h).trans (hv1.trans hend.symm))) |
| 189 | exact hS.ne (hsi ⟨le_rfl, hS.le⟩ ⟨hS.le, le_rfl⟩ he) |
| 190 | have hsum : (∑ v, defect v) = ∑ v ∈ ({v0, v1} : Finset _), defect v := by |
| 191 | symm |
| 192 | apply Finset.sum_subset (Finset.subset_univ _) |
| 193 | intro v _ hv |
| 194 | apply hzero |
| 195 | · intro h |
| 196 | exact hv (Finset.mem_insert.mpr (Or.inl (Subtype.ext (h.trans hv0.symm)))) |
| 197 | · intro h |
| 198 | exact hv (Finset.mem_insert.mpr (Or.inr |
| 199 | (Finset.mem_singleton.mpr (Subtype.ext (h.trans hv1.symm))))) |
| 200 | rw [hsum, Finset.sum_pair hne, hdefect0] |
| 201 | linarith |
| 202 | |
| 203 | end PoincareMT |