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.RicciFlow.ReducedGeometry.ReducedLength.Minimum.Variational.WeakEnergy |
| 2 | import Mathlib.MeasureTheory.Function.L2Space |
| 3 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus |
| 4 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.LebesgueDifferentiationThm |
| 5 | import Mathlib.MeasureTheory.Measure.SeparableMeasure |
| 6 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 7 | |
| 8 | /-! |
| 9 | # Identifying paths from weak velocity limits |
| 10 | |
| 11 | Interval-indicator tests show that pointwise limits of paths and weak limits |
| 12 | of their L2 velocities satisfy the same primitive formula. The resulting |
| 13 | path has the weak velocity as its ordinary derivative almost everywhere. |
| 14 | Smooth primitives can also be chosen with two prescribed endpoint values. |
| 15 | |
| 16 | Adapted from Mapher `Proofs/M08/ChartPrimitive.lean`, commit |
| 17 | `49331b7d7ecad38f53e4300c3b35d6a84b2cc648`. |
| 18 | -/ |
| 19 | |
| 20 | set_option autoImplicit false |
| 21 | |
| 22 | open MeasureTheory Set Filter Topology |
| 23 | open scoped intervalIntegral ContDiff |
| 24 | |
| 25 | namespace PoincareMT.ReducedLengthMinimum.Variational |
| 26 | |
| 27 | variable {E : Type*} [NormedAddCommGroup E] |
| 28 | |
| 29 | section SmoothPrimitive |
| 30 | |
| 31 | variable [NormedSpace ℝ E] [CompleteSpace E] |
| 32 | |
| 33 | /-- Correcting the derivative by a constant gives a smooth primitive with |
| 34 | both endpoint values prescribed. -/ |
| 35 | theorem smooth_primitive_fixed_endpoints {a b : ℝ} (hab : a < b) |
| 36 | (u₀ u₁ : E) (q : ℝ → E) (hq : ContDiff ℝ ∞ q) : |
| 37 | ∃ f : ℝ → E, ContDiff ℝ ∞ f ∧ f a = u₀ ∧ f b = u₁ ∧ |
| 38 | ∀ s, HasDerivAt f |
| 39 | (q s + (b - a)⁻¹ • (u₁ - u₀ - ∫ r in a..b, q r)) s := by |
| 40 | let c : E := (b - a)⁻¹ • (u₁ - u₀ - ∫ r in a..b, q r) |
| 41 | let d : ℝ → E := fun s => q s + c |
| 42 | let f : ℝ → E := fun s => u₀ + ∫ r in a..s, d r |
| 43 | have hd : ContDiff ℝ ∞ d := hq.add contDiff_const |
| 44 | have hdint : ∀ s t : ℝ, IntervalIntegrable d volume s t := by |
| 45 | intro s t |
| 46 | exact (hd.continuous.intervalIntegrable s t) |
| 47 | have hfderiv (s : ℝ) : HasDerivAt f (d s) s := by |
| 48 | dsimp only [f] |
| 49 | exact (intervalIntegral.integral_hasDerivAt_right (hdint a s) |
| 50 | hd.continuous.aestronglyMeasurable.stronglyMeasurableAtFilter |
| 51 | hd.continuous.continuousAt).const_add u₀ |
| 52 | have hf : ContDiff ℝ ∞ f := by |
| 53 | rw [contDiff_infty_iff_deriv] |
| 54 | refine ⟨fun s => (hfderiv s).differentiableAt, ?_⟩ |
| 55 | rw [show deriv f = d by |
| 56 | funext s |
| 57 | exact (hfderiv s).deriv] |
| 58 | exact hd |
| 59 | have hfa : f a = u₀ := by |
| 60 | simp only [f, intervalIntegral.integral_same, add_zero] |
| 61 | have hfb : f b = u₁ := by |
| 62 | dsimp only [f, d, c] |
| 63 | rw [intervalIntegral.integral_add (hq.continuous.intervalIntegrable a b) |
| 64 | (continuous_const.intervalIntegrable a b), intervalIntegral.integral_const, |
| 65 | smul_inv_smul₀ (ne_of_gt (sub_pos.mpr hab))] |
| 66 | abel |
| 67 | refine ⟨f, hf, hfa, hfb, ?_⟩ |
| 68 | intro s |
| 69 | simpa only [d, c] using hfderiv s |
| 70 | |
| 71 | end SmoothPrimitive |
| 72 | |
| 73 | variable [InnerProductSpace ℝ E] [CompleteSpace E] |
| 74 | |
| 75 | /-- L2 velocities on a closed real interval. -/ |
| 76 | noncomputable abbrev IntervalL2 (E : Type*) [NormedAddCommGroup E] (a b : ℝ) := |
| 77 | Lp E 2 (volume.restrict (Icc a b)) |
| 78 | |
| 79 | omit [InnerProductSpace ℝ E] [CompleteSpace E] in |
| 80 | theorem intervalL2_intervalIntegrable {a b : ℝ} (hab : a ≤ b) (v : IntervalL2 E a b) : |
| 81 | IntervalIntegrable v volume a b := by |
| 82 | apply (intervalIntegrable_iff_integrableOn_Icc_of_le hab).mpr |
| 83 | exact MemLp.integrable (by norm_num) (Lp.memLp v) |
| 84 | |
| 85 | /-- The classical derivative and the L2 representative give the same primitive. -/ |
| 86 | theorem primitive_of_deriv {a b : ℝ} {u d : ℝ → E} |
| 87 | (hu : ContinuousOn u (Icc a b)) |
| 88 | (hd : ∀ t ∈ Ioo a b, HasDerivAt u (d t) t) |
| 89 | (hLp : MemLp d 2 (volume.restrict (Icc a b))) {t : ℝ} (ht : t ∈ Icc a b) : |
| 90 | u t = u a + ∫ s in a..t, (hLp.toLp d) s := by |
| 91 | have hint : IntervalIntegrable d volume a t := by |
| 92 | apply (intervalIntegrable_iff_integrableOn_Icc_of_le ht.1).mpr |
| 93 | exact IntegrableOn.mono_set (MemLp.integrable (by norm_num) hLp) |
| 94 | (Icc_subset_Icc_right ht.2) |
| 95 | have hFTC := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le ht.1 |
| 96 | (hu.mono (Icc_subset_Icc_right ht.2)) |
| 97 | (fun s hs => hd s ⟨hs.1, hs.2.trans_le ht.2⟩) hint |
| 98 | have heq : (∫ s in a..t, (hLp.toLp d) s) = ∫ s in a..t, d s := by |
| 99 | apply intervalIntegral.integral_congr_ae_restrict |
| 100 | rw [uIoc_of_le ht.1] |
| 101 | exact ae_mono (Measure.restrict_mono |
| 102 | (Ioc_subset_Icc_self.trans (Icc_subset_Icc_right ht.2)) le_rfl) hLp.coeFn_toLp |
| 103 | rw [heq, hFTC, add_comm, sub_add_cancel] |
| 104 | |
| 105 | omit [CompleteSpace E] in |
| 106 | private theorem integral_as_setIntegral {a b t : ℝ} (ht : t ∈ Icc a b) |
| 107 | (v : IntervalL2 E a b) : |
| 108 | (∫ s in Icc a t, v s ∂volume.restrict (Icc a b)) = ∫ s in a..t, v s := by |
| 109 | rw [Measure.restrict_restrict_of_subset (Icc_subset_Icc_right ht.2), |
| 110 | integral_Icc_eq_integral_Ioc, intervalIntegral.integral_of_le ht.1] |
| 111 | |
| 112 | /-- Weak velocities identify the pointwise limit of their primitives, including |
| 113 | the original endpoint values. -/ |
| 114 | theorem primitive_of_weak_limit {a b : ℝ} |
| 115 | (u : ℕ → ℝ → E) (g : ℝ → E) (v : ℕ → IntervalL2 E a b) (w : IntervalL2 E a b) |
| 116 | (hprimitive : ∀ k t, t ∈ Icc a b → u k t = u k a + ∫ s in a..t, v k s) |
| 117 | (hpoint : ∀ t ∈ Icc a b, Tendsto (fun k => u k t) atTop (𝓝 (g t))) |
| 118 | (hweak : ∀ l : IntervalL2 E a b →L[ℝ] ℝ, |
| 119 | Tendsto (fun k => l (v k)) atTop (𝓝 (l w))) {t : ℝ} (ht : t ∈ Icc a b) : |
| 120 | g t = g a + ∫ s in a..t, w s := by |
| 121 | apply ext_inner_left ℝ |
| 122 | intro z |
| 123 | let test : IntervalL2 E a b := |
| 124 | indicatorConstLp 2 (s := Icc a t) measurableSet_Icc (measure_ne_top _ _) z |
| 125 | have htest (q : IntervalL2 E a b) : |
| 126 | inner ℝ test q = inner ℝ z (∫ s in a..t, q s) := by |
| 127 | dsimp only [test] |
| 128 | rw [L2.inner_indicatorConstLp_eq_inner_setIntegral ℝ] |
| 129 | rw [integral_as_setIntegral ht q] |
| 130 | have hw := hweak (innerSL ℝ test) |
| 131 | change Tendsto (fun k => inner ℝ test (v k)) atTop (𝓝 (inner ℝ test w)) at hw |
| 132 | simp only [htest] at hw |
| 133 | have ha : a ∈ Icc a b := ⟨le_rfl, ht.1.trans ht.2⟩ |
| 134 | have hsum := (Filter.Tendsto.inner (𝕜 := ℝ) |
| 135 | (tendsto_const_nhds (x := z)) (hpoint a ha)).add hw |
| 136 | have hsum' : Tendsto (fun k => inner ℝ z (u k t)) atTop |
| 137 | (𝓝 (inner ℝ z (g a + ∫ s in a..t, w s))) := by |
| 138 | simpa only [inner_add_right, hprimitive _ _ ht] using hsum |
| 139 | exact tendsto_nhds_unique |
| 140 | (Filter.Tendsto.inner (𝕜 := ℝ) tendsto_const_nhds (hpoint t ht)) hsum' |
| 141 | |
| 142 | /-- The identified primitive has its L2 velocity as an ordinary derivative |
| 143 | almost everywhere. -/ |
| 144 | theorem primitive_ae_hasDerivAt {a b : ℝ} (hab : a ≤ b) |
| 145 | (u : ℝ → E) (w : IntervalL2 E a b) |
| 146 | (hprimitive : ∀ s ∈ Icc a b, u s = u a + ∫ r in a..s, w r) : |
| 147 | ∀ᵐ s ∂volume.restrict (Icc a b), HasDerivAt u (w s) s := by |
| 148 | have hFTC := (intervalL2_intervalIntegrable hab w).ae_hasDerivAt_integral |
| 149 | rw [uIcc_of_le hab] at hFTC |
| 150 | have hmem : ∀ᵐ s ∂volume.restrict (Icc a b), s ∈ Ioo a b := by |
| 151 | rw [← restrict_Ioo_eq_restrict_Icc] |
| 152 | exact ae_restrict_mem measurableSet_Ioo |
| 153 | filter_upwards [ae_restrict_of_ae hFTC, hmem] with s hs hsI |
| 154 | have hd := (hs (Ioo_subset_Icc_self hsI) a ⟨le_rfl, hab⟩).const_add (u a) |
| 155 | apply hd.congr_of_eventuallyEq |
| 156 | exact eventually_of_mem (Ioo_mem_nhds hsI.1 hsI.2) |
| 157 | (fun r hr => hprimitive r (Ioo_subset_Icc_self hr)) |
| 158 | |
| 159 | end PoincareMT.ReducedLengthMinimum.Variational |