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.AnnularEvolution.Moving.MapVariation |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.AnnularEvolution.Moving.AnnulusCurrent |
| 3 | import PoincareLib.Geometry.CurveShortening.Comparison.AnnularEvolution.Domain.Boundary |
| 4 | import PoincareLib.Geometry.CurveShortening.Comparison.PolygonApproximation.Metric.LipschitzBridge |
| 5 | import Mathlib.Analysis.Calculus.ContDiff.Operations |
| 6 | |
| 7 | /-! |
| 8 | # Energy variation smooth on the closed rectangle |
| 9 | |
| 10 | Within-derivatives give a smooth energy representative up to the four faces. |
| 11 | Its integral equals the actual energy because those faces have zero volume. |
| 12 | This permits differentiation for precisely the variations in the annular |
| 13 | stationarity predicate, without requiring an extension outside the rectangle. |
| 14 | |
| 15 | Morgan--Tian context: Lemma 19.15 and its annular area-to-energy construction, printed pp. |
| 16 | 447-449. |
| 17 | -/ |
| 18 | |
| 19 | set_option autoImplicit false |
| 20 | set_option backward.isDefEq.respectTransparency false |
| 21 | |
| 22 | open Set Filter MeasureTheory Bundle |
| 23 | open scoped Manifold ContDiff Topology |
| 24 | |
| 25 | universe u |
| 26 | |
| 27 | namespace PoincareMT |
| 28 | |
| 29 | private theorem annulusInterior_subset : m64AnnulusInterior ⊆ m64AnnulusDomain := by |
| 30 | intro p hp |
| 31 | simp only [m64AnnulusInterior, mem_preimage, Set.mem_pi, mem_univ, mem_Ioo] at hp |
| 32 | have h0 := hp 0 trivial |
| 33 | have h1 := hp 1 trivial |
| 34 | exact ⟨h0.1.le, h0.2.le, h1.1.le, h1.2.le⟩ |
| 35 | |
| 36 | /-- Every face of the closed annular rectangle has a unique within-derivative. Source: |
| 37 | Morgan--Tian (2007), Lemma 19.15 and Corollary 19.16, pp. 447-449; project derivation |
| 38 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 39 | theorem m64AnnulusDomain_uniqueDiffOn : UniqueDiffOn ℝ m64AnnulusDomain := by |
| 40 | apply uniqueDiffOn_convex m64AnnulusDomain_convex |
| 41 | refine ⟨annulusPoint (curvePeriod / 2) (1 / 2), ?_⟩ |
| 42 | apply (interior_maximal annulusInterior_subset isOpen_m64AnnulusInterior) |
| 43 | simp only [m64AnnulusInterior, mem_preimage, Set.mem_pi, mem_univ, mem_Ioo] |
| 44 | intro i _ |
| 45 | fin_cases i <;> norm_num [annulusPoint, curvePeriod, Real.pi_pos] |
| 46 | |
| 47 | /-- Integrating a scalar function smooth on the closed rectangle preserves differentiability |
| 48 | in the open time variable. Source: Morgan--Tian (2007), Lemma 19.15 and Corollary 19.16, pp. |
| 49 | 447-449; project derivation |
| 50 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 51 | theorem m64AnnulusIntegral_differentiableAt_of_contDiffOn |
| 52 | {E : ℝ × LoopPlane → ℝ} {epsilon : ℝ} (hepsilon : 0 < epsilon) |
| 53 | (hE : ContDiffOn ℝ ∞ E (Ioo (-epsilon) epsilon ×ˢ m64AnnulusDomain)) : |
| 54 | DifferentiableAt ℝ (fun s => ∫ p in m64AnnulusDomain, E (s, p)) 0 := by |
| 55 | let Q := Ioo (-epsilon) epsilon ×ˢ m64AnnulusDomain |
| 56 | have hQ : UniqueDiffOn ℝ Q := |
| 57 | isOpen_Ioo.uniqueDiffOn.prod m64AnnulusDomain_uniqueDiffOn |
| 58 | apply (m64AnnulusIntegral_hasDerivAt_of_local_continuous_derivative |
| 59 | (F := fun s p => E (s, p)) |
| 60 | (F' := fun s p => fderivWithin ℝ E Q (s, p) (1, 0)) hepsilon ?_ ?_ ?_).2.differentiableAt |
| 61 | · intro s hs |
| 62 | exact hE.continuousOn.comp (continuous_const.prodMk continuous_id).continuousOn |
| 63 | (fun p hp => ⟨hs, hp⟩) |
| 64 | · exact ((hE.fderivWithin hQ (m := ∞) (by simp)).clm_apply |
| 65 | (contDiffOn_const (c := (1, (0 : LoopPlane))))).continuousOn |
| 66 | · intro s hs p hp |
| 67 | exact ((hE.differentiableOn (by simp)) (s, p) ⟨hs, hp⟩).hasFDerivWithinAt |
| 68 | |>.comp_hasDerivAt (l := E) (f := fun s : ℝ => (s, p)) s |
| 69 | ((hasDerivAt_id s).prodMk (hasDerivAt_const s p)) |
| 70 | (by filter_upwards [isOpen_Ioo.mem_nhds hs] with t ht; exact ⟨ht, hp⟩) |
| 71 | |
| 72 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 73 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] |
| 74 | [IsManifold (𝓡 n) ∞ M] |
| 75 | |
| 76 | private theorem within_energy_contDiffOn |
| 77 | (g : RiemannianMetric n M) (w : Fin 2 → ℝ) |
| 78 | {v : ℝ × LoopPlane → M} {Q : Set (ℝ × LoopPlane)} |
| 79 | (hQ : UniqueDiffOn ℝ Q) |
| 80 | (hv : ContMDiffOn 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) ∞ v Q) : |
| 81 | ContDiffOn ℝ ∞ (fun q => (1 / 2 : ℝ) * ∑ i : Fin 2, |
| 82 | w i * g.inner (v q) |
| 83 | (mfderivWithin 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) v Q q |
| 84 | (0, EuclideanSpace.basisFun (Fin 2) ℝ i)) |
| 85 | (mfderivWithin 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) v Q q |
| 86 | (0, EuclideanSpace.basisFun (Fin 2) ℝ i))) Q := by |
| 87 | intro q hq |
| 88 | let u (i : Fin 2) (w : ℝ × LoopPlane) := |
| 89 | mfderivWithin 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) v Q w |
| 90 | (0, EuclideanSpace.basisFun (Fin 2) ℝ i) |
| 91 | have hpush (i : Fin 2) : |
| 92 | ContMDiffWithinAt 𝓘(ℝ, ℝ × LoopPlane) ((𝓡 n).prod (𝓡 n)) ∞ |
| 93 | (fun w => (⟨v w, u i w⟩ : TangentBundle (𝓡 n) M)) Q q := by |
| 94 | have hd : ContMDiffWithinAt 𝓘(ℝ, ℝ × LoopPlane) |
| 95 | ((𝓘(ℝ, ℝ × LoopPlane)).prod 𝓘(ℝ, ℝ × LoopPlane)) ∞ |
| 96 | (fun w : ℝ × LoopPlane => |
| 97 | (⟨w, (0, EuclideanSpace.basisFun (Fin 2) ℝ i)⟩ : |
| 98 | TangentBundle 𝓘(ℝ, ℝ × LoopPlane) (ℝ × LoopPlane))) Q q := by |
| 99 | rw [contMDiffWithinAt_totalSpace] |
| 100 | refine ⟨contMDiffWithinAt_id, ?_⟩ |
| 101 | simpa using contMDiffWithinAt_const |
| 102 | (c := ((0 : ℝ), EuclideanSpace.basisFun (Fin 2) ℝ i)) |
| 103 | have hderiv := (hv q hq).mfderivWithin_const (m := ∞) (by simp) hq hQ.uniqueMDiffOn |
| 104 | exact hderiv.clm_apply_of_inCoordinates hd (hv q hq) |
| 105 | have hmetric := g.contMDiff.contMDiffAt.comp_contMDiffWithinAt q (hv q hq) |
| 106 | have hscalar (i : Fin 2) : ContDiffWithinAt ℝ ∞ |
| 107 | (fun w => g.inner (v w) (u i w) (u i w)) Q q := by |
| 108 | have h := hmetric.clm_bundle_apply₂ (F₃ := ℝ) (E₃ := Bundle.Trivial M ℝ) |
| 109 | (hpush i) (hpush i) |
| 110 | exact contMDiffWithinAt_iff_contDiffWithinAt.mp |
| 111 | (Bundle.contMDiffWithinAt_totalSpace.mp h).2 |
| 112 | exact contDiffWithinAt_const.mul |
| 113 | (ContDiffWithinAt.sum fun i _ => contDiffWithinAt_const.mul (hscalar i)) |
| 114 | |
| 115 | /-- Every fixed linear combination of the two diagonal Gram integrals is differentiable for |
| 116 | a variation smooth on the closed source rectangle. Source: Morgan--Tian (2007), Lemma 19.15 |
| 117 | and Corollary 19.16, pp. 447-449; project derivation |
| 118 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 119 | theorem m64AnnulusGramEnergy_differentiableAt_of_closed_smooth_variation |
| 120 | (g : RiemannianMetric n M) (w : Fin 2 → ℝ) {v : ℝ × LoopPlane → M} |
| 121 | {epsilon : ℝ} (hepsilon : 0 < epsilon) |
| 122 | (hv : ContMDiffOn 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) ∞ v |
| 123 | (Ioo (-epsilon) epsilon ×ˢ m64AnnulusDomain)) : |
| 124 | DifferentiableAt ℝ (fun s => ∫ p in m64AnnulusDomain, |
| 125 | (1 / 2 : ℝ) * ∑ i : Fin 2, w i * m60AreaGram g (fun z => v (s, z)) p i i) 0 := by |
| 126 | let Q := Ioo (-epsilon) epsilon ×ˢ m64AnnulusDomain |
| 127 | let E := fun q : ℝ × LoopPlane => (1 / 2 : ℝ) * ∑ i : Fin 2, |
| 128 | w i * g.inner (v q) |
| 129 | (mfderivWithin 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) v Q q |
| 130 | (0, EuclideanSpace.basisFun (Fin 2) ℝ i)) |
| 131 | (mfderivWithin 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) v Q q |
| 132 | (0, EuclideanSpace.basisFun (Fin 2) ℝ i)) |
| 133 | have hQ : UniqueDiffOn ℝ Q := |
| 134 | isOpen_Ioo.uniqueDiffOn.prod m64AnnulusDomain_uniqueDiffOn |
| 135 | have hE : ContDiffOn ℝ ∞ E Q := within_energy_contDiffOn g w hQ hv |
| 136 | have hdiff := m64AnnulusIntegral_differentiableAt_of_contDiffOn hepsilon hE |
| 137 | apply hdiff.congr_of_eventuallyEq |
| 138 | have hzero : (0 : ℝ) ∈ Ioo (-epsilon) epsilon := ⟨by linarith, hepsilon⟩ |
| 139 | filter_upwards [isOpen_Ioo.mem_nhds hzero] with s hs |
| 140 | apply integral_congr_ae |
| 141 | have hnull : ∀ᵐ p ∂volume, p ∉ m64AnnulusDomain \ interior m64AnnulusDomain := |
| 142 | ae_iff.mpr (by simpa only [not_not, Set.ofPred_mem_eq] using m64AnnulusDomain_boundary_null) |
| 143 | filter_upwards [ae_restrict_mem m64AnnulusDomain_measurableSet, |
| 144 | ae_restrict_of_ae hnull] with p hp hint |
| 145 | have hpint : p ∈ interior m64AnnulusDomain := by |
| 146 | by_contra h |
| 147 | exact hint ⟨hp, h⟩ |
| 148 | have hnhds : Q ∈ 𝓝 (s, p) := |
| 149 | prod_mem_nhds (isOpen_Ioo.mem_nhds hs) (mem_interior_iff_mem_nhds.mp hpint) |
| 150 | have hmd := (hv.contMDiffAt hnhds).mdifferentiableAt (by simp) |
| 151 | simp only [E, mfderivWithin_of_mem_nhds hnhds, |
| 152 | m60AreaGram, m64MovingAnnulus_spatial_differential hmd] |
| 153 | |
| 154 | /-- The actual annular energy is differentiable for a variation smooth only on the closed |
| 155 | source rectangle and an open interval of times. Source: Morgan--Tian (2007), Lemma 19.15 and |
| 156 | Corollary 19.16, pp. 447-449; project derivation |
| 157 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 158 | theorem m64AnnulusEnergy_differentiableAt_of_closed_smooth_variation |
| 159 | (g : RiemannianMetric n M) {v : ℝ × LoopPlane → M} |
| 160 | {epsilon : ℝ} (hepsilon : 0 < epsilon) |
| 161 | (hv : ContMDiffOn 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) ∞ v |
| 162 | (Ioo (-epsilon) epsilon ×ˢ m64AnnulusDomain)) : |
| 163 | DifferentiableAt ℝ (fun s => ∫ p in m64AnnulusDomain, |
| 164 | m60EnergyDensity g (fun z => v (s, z)) p) 0 := by |
| 165 | simpa only [m60EnergyDensity, Matrix.trace, Matrix.diag, one_mul] using |
| 166 | m64AnnulusGramEnergy_differentiableAt_of_closed_smooth_variation g |
| 167 | (fun _ => 1) hepsilon hv |
| 168 | |
| 169 | end PoincareMT |