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.Region.Frontier |
| 2 | import PoincareLib.Geometry.Riemannian.Surface.GaussBonnet.VertexContributions |
| 3 | |
| 4 | /-! |
| 5 | # Regional Gauss-Bonnet with the actual Euler count |
| 6 | |
| 7 | Every geometric one-face edge contributes its two distinct endpoints. |
| 8 | Regrouping the corner angles and this boundary incidence gives the exact |
| 9 | Euler expression. No disk Euler constant or complete vertex fan is assumed. |
| 10 | |
| 11 | Morgan--Tian context: Proposition 19.35, printed pp. 467-481, especially Claim 19.40, pp. |
| 12 | 470-471. The explicit coordinate-mesh and regional Gauss--Bonnet constructions are project |
| 13 | derivations. |
| 14 | -/ |
| 15 | |
| 16 | noncomputable section |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open Set MeasureTheory |
| 21 | open scoped Topology ContDiff Manifold Bundle |
| 22 | open PoincareMT.Topology.Surface |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | private theorem sum_endpoint_degree |
| 27 | {V E : Type*} [Fintype V] [Fintype E] (ends : E → V × V) |
| 28 | (hdistinct : ∀ e, (ends e).1 ≠ (ends e).2) : |
| 29 | (∑ v : V, (Nat.card {e : E // (ends e).1 = v ∨ (ends e).2 = v} : ℝ)) = |
| 30 | 2 * Fintype.card E := by |
| 31 | classical |
| 32 | have hdegree (v : V) : |
| 33 | (Nat.card {e : E // (ends e).1 = v ∨ (ends e).2 = v} : ℝ) = |
| 34 | ∑ e : E, ((if (ends e).1 = v then (1 : ℝ) else 0) + |
| 35 | if (ends e).2 = v then 1 else 0) := by |
| 36 | rw [Nat.card_eq_fintype_card, Fintype.card_subtype] |
| 37 | rw [← Finset.sum_boole] |
| 38 | apply Finset.sum_congr rfl |
| 39 | intro e _ |
| 40 | by_cases hleft : (ends e).1 = v |
| 41 | · have hright : (ends e).2 ≠ v := fun h => hdistinct e (hleft.trans h.symm) |
| 42 | simp only [hleft, hright, true_or, if_true, if_false, add_zero] |
| 43 | · by_cases hright : (ends e).2 = v <;> simp only [hleft, hright, false_or, |
| 44 | if_true, if_false, zero_add] |
| 45 | simp_rw [hdegree] |
| 46 | rw [Finset.sum_comm] |
| 47 | simp only [Finset.sum_add_distrib, Finset.sum_ite_eq, Finset.mem_univ, if_true, |
| 48 | Finset.sum_const, Finset.card_univ, nsmul_eq_mul] |
| 49 | ring |
| 50 | |
| 51 | /-- The actual one-face edges contribute twice their cardinality to the sum of boundary |
| 52 | degrees at the canonical geometric vertices. Source: Morgan--Tian Proposition 19.35, printed |
| 53 | pp. 467-481, including the Gauss--Bonnet argument in Lemma 19.45, p. 474; the explicit |
| 54 | regional construction is reviewed in |
| 55 | `proof-work/tasks/M64/reviews/2026-09-27-round1-intrinsic-euler-turning.md`, Mathematical |
| 56 | Checks. -/ |
| 57 | theorem m64Intrinsic_region_boundary_degree_sum |
| 58 | {I : Type*} [Finite I] (face : I → SmoothFace AnnulusCoordinates) |
| 59 | (F : I → OpenPartialHomeomorph AnnulusCoordinates AnnulusCoordinates) |
| 60 | (b : I → AffineBasis (Fin 3) ℝ AnnulusCoordinates) |
| 61 | (hsource : ∀ i, convexHull ℝ (range (b i)) ⊆ (F i).source) : |
| 62 | let _ := Fintype.ofFinite (Euler.CoordinateVertex F b) |
| 63 | (∑ v : Euler.CoordinateVertex F b, (Nat.card {e : |
| 64 | {e : FaceBoundaryEdge face // Nat.card {p : I × Fin 3 // |
| 65 | faceBoundaryIndex face p.1 p.2 = e} = 1} // |
| 66 | (Euler.coordinateEdgeEnds face F b e.1).1 = v ∨ |
| 67 | (Euler.coordinateEdgeEnds face F b e.1).2 = v} : ℝ)) = |
| 68 | 2 * Nat.card {e : FaceBoundaryEdge face // Nat.card {p : I × Fin 3 // |
| 69 | faceBoundaryIndex face p.1 p.2 = e} = 1} := by |
| 70 | classical |
| 71 | let _ := Fintype.ofFinite (Euler.CoordinateVertex F b) |
| 72 | let E := {e : FaceBoundaryEdge face // Nat.card {p : I × Fin 3 // |
| 73 | faceBoundaryIndex face p.1 p.2 = e} = 1} |
| 74 | let _ := Fintype.ofFinite E |
| 75 | simpa only [Nat.card_eq_fintype_card] using sum_endpoint_degree |
| 76 | (fun e : E => Euler.coordinateEdgeEnds face F b e.1) |
| 77 | (fun e => Euler.coordinateEdgeEnds_distinct face F b hsource e.1) |
| 78 | |
| 79 | open Classical in |
| 80 | /-- The signed turning and actual metric corner defects give the Euler count of the finite |
| 81 | coordinate region. At a manifold boundary vertex the degree is two, so its displayed corner |
| 82 | term is `pi - angle`; the formula also retains the correct incidence at vertices not yet |
| 83 | classified. Source: Morgan--Tian Proposition 19.35, printed pp. 467-481, including the |
| 84 | Gauss--Bonnet argument in Lemma 19.45, p. 474; the explicit regional construction is |
| 85 | reviewed in `proof-work/tasks/M64/reviews/2026-09-27-round1-intrinsic-euler-turning.md`, |
| 86 | Mathematical Checks. -/ |
| 87 | theorem m64Intrinsic_region_gaussBonnet_euler |
| 88 | {I : Type*} [Fintype I] (face : I → SmoothFace AnnulusCoordinates) |
| 89 | (F : I → OpenPartialHomeomorph AnnulusCoordinates AnnulusCoordinates) |
| 90 | (b : I → AffineBasis (Fin 3) ℝ AnnulusCoordinates) |
| 91 | (hF : ∀ i, ContMDiffOn (𝓡 2) (𝓡 2) ∞ (F i) (F i).source) |
| 92 | (hFi : ∀ i, ContMDiffOn (𝓡 2) (𝓡 2) ∞ (F i).symm (F i).target) |
| 93 | (hsource : ∀ i, convexHull ℝ (range (b i)) ⊆ (F i).source) |
| 94 | (hcarrier : ∀ i, (face i).carrier = F i '' convexHull ℝ (range (b i))) |
| 95 | (hboundary : ∀ i k, ((face i).boundary k).map = F i ∘ |
| 96 | affineChartSegment (b i (k.succAbove 0)) (b i (k.succAbove 1))) |
| 97 | (hfront : ∀ i j, i ≠ j → (face i).carrier ∩ (face j).carrier ⊆ frontier (face i).carrier) |
| 98 | {g : RiemannianMetric 2 AnnulusCoordinates} (D : LeviCivitaData g) |
| 99 | (Q : ∀ i, RiemannianMetric.AlignedChartFrame g (coordinateTriangleChart (F i) (b i))) : |
| 100 | let _ := Fintype.ofFinite (Euler.CoordinateVertex F b) |
| 101 | (∫ x in ⋃ i, (face i).carrier, D.scalarCurvature x ∂g.volumeMeasure) + |
| 102 | 2 * (∑ p : I × Fin 3, if ∀ q : I × Fin 3, |
| 103 | faceBoundaryIndex face q.1 q.2 = faceBoundaryIndex face p.1 p.2 → q = p then |
| 104 | coordinateTriangleTurningIntegral D (F p.1) (b p.1) (Q p.1) (p.2 + 1) ((p.2 + 1) + 1) |
| 105 | else 0) + |
| 106 | 2 * (∑ v : Euler.CoordinateVertex F b, |
| 107 | ((2 - (Nat.card {e : {e : FaceBoundaryEdge face // |
| 108 | Nat.card {p : I × Fin 3 // faceBoundaryIndex face p.1 p.2 = e} = 1} // |
| 109 | (Euler.coordinateEdgeEnds face F b e.1).1 = v ∨ |
| 110 | (Euler.coordinateEdgeEnds face F b e.1).2 = v} : ℝ) / 2) * Real.pi - |
| 111 | coordinateVertexAngleContribution g F b v.1)) = |
| 112 | 4 * Real.pi * ((Nat.card (Euler.CoordinateVertex F b) : ℝ) - |
| 113 | Nat.card (FaceBoundaryEdge face) + Nat.card I) := by |
| 114 | classical |
| 115 | let _ := Fintype.ofFinite (Euler.CoordinateVertex F b) |
| 116 | let E := {e : FaceBoundaryEdge face // Nat.card {p : I × Fin 3 // |
| 117 | faceBoundaryIndex face p.1 p.2 = e} = 1} |
| 118 | let degree (v : Euler.CoordinateVertex F b) : ℝ := Nat.card {e : E // |
| 119 | (Euler.coordinateEdgeEnds face F b e.1).1 = v ∨ |
| 120 | (Euler.coordinateEdgeEnds face F b e.1).2 = v} |
| 121 | have hdegrees : (∑ v, degree v) = 2 * Nat.card E := |
| 122 | m64Intrinsic_region_boundary_degree_sum face F b hsource |
| 123 | have hslots : 3 * (Nat.card I : ℝ) + Nat.card E = |
| 124 | 2 * Nat.card (FaceBoundaryEdge face) := by |
| 125 | exact_mod_cast m64Intrinsic_region_edge_slot_count face F b hsource hcarrier hboundary hfront |
| 126 | have hangles := sum_coordinateVertexAngleContribution g F b |
| 127 | have hcorners : (∑ i, ∑ k : Fin 3, (Real.pi - coordinateTriangleAngle g (F i) (b i) k)) = |
| 128 | 3 * Real.pi * Nat.card I - ∑ i, ∑ k : Fin 3, coordinateTriangleAngle g (F i) (b i) k := by |
| 129 | simp only [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, |
| 130 | Fintype.card_fin, nsmul_eq_mul, Nat.card_eq_fintype_card] |
| 131 | ring |
| 132 | have hdefects : (∑ v : Euler.CoordinateVertex F b, |
| 133 | ((2 - degree v / 2) * Real.pi - coordinateVertexAngleContribution g F b v.1)) = |
| 134 | 2 * Real.pi * Nat.card (Euler.CoordinateVertex F b) - Real.pi * Nat.card E - |
| 135 | ∑ i, ∑ k : Fin 3, coordinateTriangleAngle g (F i) (b i) k := by |
| 136 | rw [Finset.sum_sub_distrib, ← Finset.sum_mul, Finset.sum_sub_distrib, |
| 137 | ← Finset.sum_div, hdegrees, hangles] |
| 138 | simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Nat.card_eq_fintype_card] |
| 139 | ring |
| 140 | have hgb := m64Intrinsic_region_gaussBonnet_unpaired face F b hF hFi hsource |
| 141 | hcarrier hboundary hfront D Q |
| 142 | rw [hcorners] at hgb |
| 143 | change _ + 2 * (∑ v : Euler.CoordinateVertex F b, |
| 144 | ((2 - degree v / 2) * Real.pi - coordinateVertexAngleContribution g F b v.1)) = _ |
| 145 | rw [hdefects] |
| 146 | have hcard : (Fintype.card I : ℝ) = Nat.card I := by rw [Nat.card_eq_fintype_card] |
| 147 | rw [hcard] at hgb |
| 148 | nlinarith [congrArg (fun x : ℝ => Real.pi * x) hslots] |
| 149 | |
| 150 | end PoincareMT |