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.Modulus.EnergyDensity |
| 2 | import PoincareLib.Geometry.Riemannian.MinimalSurface.Sphere.Analysis.Compact.SupportIntegralDerivative |
| 3 | |
| 4 | /-! |
| 5 | # Differentiating actual supported modulus-energy variations |
| 6 | |
| 7 | The genuine weighted-density difference is smooth and supported in the |
| 8 | same compact set as the variation. Actual differentiation under the |
| 9 | integral therefore applies at every fixed modulus, including rank-zero |
| 10 | points of the central map. |
| 11 | |
| 12 | Morgan--Tian context: Lemma 19.15 and its annular area-to-energy construction, printed pp. |
| 13 | 447-449. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | set_option backward.isDefEq.respectTransparency false |
| 18 | |
| 19 | open Set Filter MeasureTheory |
| 20 | open scoped Manifold ContDiff Topology |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 27 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 28 | |
| 29 | /-- The integral of the actual modulus-weighted density has its genuine first derivative for |
| 30 | every supported smooth variation. Source: Morgan--Tian (2007), Lemma 19.15 and Corollary |
| 31 | 19.16, pp. 447-449; project derivation |
| 32 | `proof-work/tasks/M64/reports/2026-09-27-annulus-energy-and-finite-variation-derivation.md`. -/ |
| 33 | theorem m64ModulusEnergy_hasDerivAt_of_supported_variation |
| 34 | (g : RiemannianMetric n M) (r : ℝ) {v : ℝ × LoopPlane → M} |
| 35 | {epsilon : ℝ} (hepsilon : 0 < epsilon) |
| 36 | {O K : Set LoopPlane} (hO : IsOpen O) (hK : IsCompact K) |
| 37 | (hKO : K ⊆ O) (hKdomain : K ⊆ m64AnnulusDomain) |
| 38 | (hv : ContMDiffOn 𝓘(ℝ, ℝ × LoopPlane) (𝓡 n) ∞ v |
| 39 | (Ioo (-epsilon) epsilon ×ˢ O)) |
| 40 | (hfix : ∀ s ∈ Ioo (-epsilon) epsilon, ∀ z ∉ K, |
| 41 | v (s, z) = v (0, z)) |
| 42 | (hint : ∀ s ∈ Ioo (-epsilon) epsilon, |
| 43 | IntegrableOn (m64ModulusEnergyDensity g r (fun z => v (s, z))) |
| 44 | m64AnnulusDomain volume) : |
| 45 | let D := fun q : ℝ × LoopPlane => |
| 46 | m64ModulusEnergyDensity g r (fun z => v (q.1, z)) q.2 - |
| 47 | m64ModulusEnergyDensity g r (fun z => v (0, z)) q.2 |
| 48 | Integrable (fun z => fderiv ℝ D (0, z) (1, 0)) volume ∧ |
| 49 | HasDerivAt |
| 50 | (fun s => ∫ z in m64AnnulusDomain, |
| 51 | m64ModulusEnergyDensity g r (fun y => v (s, y)) z) |
| 52 | (∫ z, fderiv ℝ D (0, z) (1, 0)) 0 := by |
| 53 | let E := fun q : ℝ × LoopPlane => m64ModulusEnergyDensity g r (fun z => v (q.1, z)) q.2 |
| 54 | let D := fun q : ℝ × LoopPlane => E q - E (0, q.2) |
| 55 | let G := fun s z => fderiv ℝ D (s, z) (1, 0) |
| 56 | have hzero : (0 : ℝ) ∈ Ioo (-epsilon) epsilon := ⟨by linarith, hepsilon⟩ |
| 57 | have hopen : IsOpen (Ioo (-epsilon) epsilon ×ˢ (univ : Set LoopPlane)) := |
| 58 | isOpen_Ioo.prod isOpen_univ |
| 59 | have hDzero (s : ℝ) (hs : s ∈ Ioo (-epsilon) epsilon) |
| 60 | (z : LoopPlane) (hz : z ∉ K) : D (s, z) = 0 := by |
| 61 | apply sub_eq_zero.mpr |
| 62 | apply m64ModulusEnergyDensity_congr_of_eventuallyEq g r |
| 63 | filter_upwards [hK.isClosed.isOpen_compl.mem_nhds hz] with y hy |
| 64 | exact hfix s hs y hy |
| 65 | have hD : ContDiffOn ℝ ∞ D (Ioo (-epsilon) epsilon ×ˢ univ) := by |
| 66 | intro q hq |
| 67 | by_cases hqO : q.2 ∈ O |
| 68 | · have hEq : ContDiffAt ℝ ∞ E q := m64ModulusEnergyDensity_family_contDiffAt g r |
| 69 | (hv.contMDiffAt ((isOpen_Ioo.prod hO).mem_nhds ⟨hq.1, hqO⟩)) |
| 70 | have hEzero : ContDiffAt ℝ ∞ E (0, q.2) := m64ModulusEnergyDensity_family_contDiffAt g r |
| 71 | (hv.contMDiffAt ((isOpen_Ioo.prod hO).mem_nhds ⟨hzero, hqO⟩)) |
| 72 | exact (hEq.sub (hEzero.comp q |
| 73 | (contDiffAt_const.prodMk contDiffAt_snd))).contDiffWithinAt |
| 74 | · have hqK : q.2 ∉ K := fun h => hqO (hKO h) |
| 75 | have hconst : ContDiffAt ℝ ∞ D q := |
| 76 | (contDiffAt_const (c := (0 : ℝ))).congr_of_eventuallyEq (by |
| 77 | filter_upwards [(isOpen_Ioo.prod hK.isClosed.isOpen_compl).mem_nhds |
| 78 | ⟨hq.1, hqK⟩] with p hp |
| 79 | exact hDzero p.1 hp.1 p.2 hp.2) |
| 80 | exact hconst.contDiffWithinAt |
| 81 | have hDs (s : ℝ) (hs : s ∈ Ioo (-epsilon) epsilon) : |
| 82 | Continuous (fun z => D (s, z)) := |
| 83 | hD.continuousOn.comp_continuous (continuous_const.prodMk continuous_id) |
| 84 | (fun z => ⟨hs, mem_univ z⟩) |
| 85 | have hG : ContinuousOn (Function.uncurry G) |
| 86 | (Ioo (-epsilon) epsilon ×ˢ univ) := |
| 87 | ((hD.fderiv_of_isOpen hopen (m := ∞) (by simp)).clm_apply |
| 88 | contDiffOn_const).continuousOn |
| 89 | have hder (s : ℝ) (hs : s ∈ Ioo (-epsilon) epsilon) (z : LoopPlane) : |
| 90 | HasDerivAt (fun t => D (t, z)) (G s z) s := by |
| 91 | have hDp : ContDiffAt ℝ ∞ D (s, z) := |
| 92 | hD.contDiffAt (hopen.mem_nhds ⟨hs, mem_univ z⟩) |
| 93 | exact (hDp.differentiableAt (by simp)).hasFDerivAt.comp_hasDerivAt s |
| 94 | ((hasDerivAt_id s).prodMk (hasDerivAt_const s z)) |
| 95 | obtain ⟨hGint, hderiv⟩ := M60.hasDerivAt_integral_of_common_compact_support |
| 96 | (μ := volume) (F := fun s z => D (s, z)) (F' := G) hK hepsilon |
| 97 | hDs hG hder hDzero |
| 98 | refine ⟨hGint, ?_⟩ |
| 99 | have hfull (s : ℝ) (hs : s ∈ Ioo (-epsilon) epsilon) : |
| 100 | (∫ z, D (s, z)) = |
| 101 | (∫ z in m64AnnulusDomain, E (s, z)) - |
| 102 | ∫ z in m64AnnulusDomain, E (0, z) := by |
| 103 | rw [← setIntegral_eq_integral_of_forall_compl_eq_zero] |
| 104 | · exact integral_sub (hint s hs) (hint 0 hzero) |
| 105 | · intro z hz |
| 106 | exact hDzero s hs z (fun h => hz (hKdomain h)) |
| 107 | apply (hderiv.add_const (∫ z in m64AnnulusDomain, E (0, z))).congr_of_eventuallyEq |
| 108 | filter_upwards [isOpen_Ioo.mem_nhds hzero] with s hs |
| 109 | rw [hfull s hs] |
| 110 | change (∫ z in m64AnnulusDomain, E (s, z)) = |
| 111 | (∫ z in m64AnnulusDomain, E (s, z)) - |
| 112 | (∫ z in m64AnnulusDomain, E (0, z)) + ∫ z in m64AnnulusDomain, E (0, z) |
| 113 | ring |
| 114 | |
| 115 | end PoincareMT |