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.Generalized.ReducedGeometry.Regularity.Formulas.HarnackIntegrability |
| 2 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Paths.SquareRoot.Action.SquareRootAction |
| 3 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus |
| 4 | |
| 5 | /-! |
| 6 | # The actual integrated Harnack identity |
| 7 | |
| 8 | Square-time integration gives the actual action minus the two actual |
| 9 | boundary values. The initial boundary vanishes when the starting time |
| 10 | is zero. Morgan-Tian equation (6.2), p. 106, and Lemma 6.48, p. 130. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set |
| 16 | open scoped Manifold ContDiff Bundle intervalIntegral |
| 17 | |
| 18 | universe u |
| 19 | |
| 20 | namespace PoincareMT.M14 |
| 21 | |
| 22 | variable {n : ℕ} {X : Type u} [TopologicalSpace X] {time : X → ℝ} |
| 23 | {I : SpacetimeInterval} {G : GeneralizedLGeometryTransport n X time I} |
| 24 | {T τ₁ τ₂ : ℝ} {x y : G.Point} {p : M14BackwardPath G T τ₁ τ₂ x y} |
| 25 | |
| 26 | /-- The nonsingular square-time boundary primitive in Lemma 6.48, |
| 27 | p. 130, built from the actual square velocity. -/ |
| 28 | noncomputable def squareHarnackPrimitive (R : M14SquareRootPath G p) (s : ℝ) : ℝ := |
| 29 | s ^ 3 * horizontalScalarCurvature G.leafwise (R.curve s) + |
| 30 | s * G.spacetime.horizontalMetric.inner (R.curve s) |
| 31 | (R.horizontal_velocity s) (R.horizontal_velocity s) / 4 |
| 32 | |
| 33 | /-- The actual Harnack primitive is smooth on the full closed square |
| 34 | interval, including zero, Lemmas 6.47-6.48, p. 130. -/ |
| 35 | theorem squareHarnackPrimitive_contDiffOn |
| 36 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) (R : M14SquareRootPath G p) : |
| 37 | ContDiffOn ℝ ∞ (squareHarnackPrimitive R) (M14SqrtParameterInterval τ₁ τ₂) := |
| 38 | ((contDiffOn_id.pow 3).mul (squareRoot_scalar_contDiffOn hM12 R)).add |
| 39 | ((contDiffOn_id.mul (squareRoot_energy_contDiffOn R)).div_const 4) |
| 40 | |
| 41 | /-- The product derivative of the actual closed square primitive, |
| 42 | the calculation in Lemma 6.48, p. 130. -/ |
| 43 | theorem squareHarnackPrimitive_derivWithin |
| 44 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) (R : M14SquareRootPath G p) |
| 45 | {s : ℝ} (hs : s ∈ M14SqrtParameterInterval τ₁ τ₂) : |
| 46 | derivWithin (squareHarnackPrimitive R) (M14SqrtParameterInterval τ₁ τ₂) s = |
| 47 | 3 * s ^ 2 * horizontalScalarCurvature G.leafwise (R.curve s) + |
| 48 | s ^ 3 * derivWithin (fun r => horizontalScalarCurvature G.leafwise (R.curve r)) |
| 49 | (M14SqrtParameterInterval τ₁ τ₂) s + |
| 50 | (G.spacetime.horizontalMetric.inner (R.curve s) |
| 51 | (R.horizontal_velocity s) (R.horizontal_velocity s) + |
| 52 | s * derivWithin (fun r => G.spacetime.horizontalMetric.inner (R.curve r) |
| 53 | (R.horizontal_velocity r) (R.horizontal_velocity r)) |
| 54 | (M14SqrtParameterInterval τ₁ τ₂) s) / 4 := by |
| 55 | have hC := uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt) |
| 56 | have hSd := (squareRoot_scalar_contDiffOn hM12 R).differentiableOn (by simp) s hs |
| 57 | have hEd := (squareRoot_energy_contDiffOn R).differentiableOn (by simp) s hs |
| 58 | have hS := hSd.hasDerivWithinAt |
| 59 | have hE := hEd.hasDerivWithinAt |
| 60 | have h := (((hasDerivWithinAt_pow 3 s).mul hS).add |
| 61 | (((hasDerivWithinAt_id s _).mul hE).div_const 4)).derivWithin (hC s hs) |
| 62 | change derivWithin (fun r => r ^ 3 * horizontalScalarCurvature G.leafwise (R.curve r) + |
| 63 | r * G.spacetime.horizontalMetric.inner (R.curve r) |
| 64 | (R.horizontal_velocity r) (R.horizontal_velocity r) / 4) _ s = _ |
| 65 | simpa only [Pi.add_def, Pi.mul_def, Nat.cast_ofNat, Nat.reduceSub, one_mul, id_eq] using h |
| 66 | |
| 67 | /-- The actual generalized K integral equals half the action minus |
| 68 | the final square boundary plus the initial one, Lemma 6.48, p. 130. -/ |
| 69 | theorem squareRoot_harnackIntegral_eq |
| 70 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) (R : M14SquareRootPath G p) |
| 71 | (E : M14PullbackExtension G R.curve (M14SqrtParameterInterval τ₁ τ₂) |
| 72 | R.horizontal_velocity) |
| 73 | (hEuler : ∀ s ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂), |
| 74 | ∀ W, M14SquareRootEulerResidual G R E s W = 0) : |
| 75 | M14GeneralizedKIntegral G p |
| 76 | (fun t => M14BackwardTimeDerivative G (horizontalScalarCurvature G.leafwise) |
| 77 | (p.curve t)) = |
| 78 | M14BackwardLAction G p / 2 - squareHarnackPrimitive R (Real.sqrt τ₂) + |
| 79 | squareHarnackPrimitive R (Real.sqrt τ₁) := by |
| 80 | let C := M14SqrtParameterInterval τ₁ τ₂ |
| 81 | have hle : Real.sqrt τ₁ ≤ Real.sqrt τ₂ := Real.sqrt_le_sqrt p.tau_lt.le |
| 82 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt) |
| 83 | have hP := squareHarnackPrimitive_contDiffOn hM12 R |
| 84 | have hPi : IntervalIntegrable (derivWithin (squareHarnackPrimitive R) C) |
| 85 | MeasureTheory.volume (Real.sqrt τ₁) (Real.sqrt τ₂) := |
| 86 | ((hP.derivWithin hC (m := ∞) (by simp)).continuousOn).intervalIntegrable_of_Icc hle |
| 87 | have hFTC : (∫ s in Real.sqrt τ₁..Real.sqrt τ₂, |
| 88 | derivWithin (squareHarnackPrimitive R) C s) = |
| 89 | squareHarnackPrimitive R (Real.sqrt τ₂) - |
| 90 | squareHarnackPrimitive R (Real.sqrt τ₁) := by |
| 91 | apply intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hle hP.continuousOn _ hPi |
| 92 | intro s hs |
| 93 | have hd := (hP.differentiableOn (by simp) s (Ioo_subset_Icc_self hs)).hasDerivWithinAt |
| 94 | exact hd.hasDerivAt (Icc_mem_nhds hs.1 hs.2) |
| 95 | let H := M14GeneralizedHarnackDensity G p |
| 96 | (fun t => M14BackwardTimeDerivative G (horizontalScalarCurvature G.leafwise) (p.curve t)) |
| 97 | have hchange := intervalIntegral.integral_comp_mul_deriv_of_deriv_nonneg |
| 98 | (a := Real.sqrt τ₁) (b := Real.sqrt τ₂) |
| 99 | (f := fun s : ℝ => s ^ 2) (f' := fun s => 2 * s) |
| 100 | (g := fun t => t * Real.sqrt t * H t) (continuous_pow 2).continuousOn |
| 101 | (fun s _ => by simpa using hasDerivAt_pow 2 s) |
| 102 | (fun s hs => by |
| 103 | rw [min_eq_left hle, max_eq_right hle] at hs |
| 104 | exact mul_nonneg (by norm_num) ((Real.sqrt_nonneg τ₁).trans hs.1.le)) |
| 105 | rw [Real.sq_sqrt p.tau_nonneg, Real.sq_sqrt (p.tau_nonneg.trans p.tau_lt.le)] at hchange |
| 106 | change (∫ t in τ₁..τ₂, t * Real.sqrt t * H t) = _ |
| 107 | rw [← hchange] |
| 108 | calc |
| 109 | (∫ s in Real.sqrt τ₁..Real.sqrt τ₂, (s ^ 2 * Real.sqrt (s ^ 2) * H (s ^ 2)) * (2 * s)) = |
| 110 | ∫ s in Real.sqrt τ₁..Real.sqrt τ₂, |
| 111 | (squareRootLIntegrand R s / 2 - derivWithin (squareHarnackPrimitive R) C s) := by |
| 112 | apply intervalIntegral.integral_congr_Ioo_of_le hle |
| 113 | intro s hs |
| 114 | have hs0 : 0 < s := (Real.sqrt_nonneg τ₁).trans_lt hs.1 |
| 115 | dsimp only |
| 116 | rw [Real.sqrt_sq hs0.le, squareHarnackPrimitive_derivWithin hM12 R (Ioo_subset_Icc_self hs), |
| 117 | squareRoot_weightedHarnack_eq hM12 R E hs (hEuler s hs)] |
| 118 | unfold squareRootLIntegrand |
| 119 | ring |
| 120 | _ = M14BackwardLAction G p / 2 - squareHarnackPrimitive R (Real.sqrt τ₂) + |
| 121 | squareHarnackPrimitive R (Real.sqrt τ₁) := by |
| 122 | rw [intervalIntegral.integral_sub ((squareRootLIntegrand_intervalIntegrable R).div_const 2) |
| 123 | hPi, intervalIntegral.integral_div, integral_squareRootLIntegrand_eq_action R, hFTC] |
| 124 | ring |
| 125 | |
| 126 | /-- At initial time zero the genuine square boundary term vanishes, |
| 127 | yielding the zero-start K identity of Lemma 6.48, p. 130. -/ |
| 128 | theorem squareRoot_harnackIntegral_zero_start |
| 129 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) {p : M14BackwardPath G T 0 τ₂ x y} |
| 130 | (R : M14SquareRootPath G p) |
| 131 | (E : M14PullbackExtension G R.curve (M14SqrtParameterInterval 0 τ₂) |
| 132 | R.horizontal_velocity) |
| 133 | (hEuler : ∀ s ∈ Ioo 0 (Real.sqrt τ₂), |
| 134 | ∀ W, M14SquareRootEulerResidual G R E s W = 0) : |
| 135 | M14GeneralizedKIntegral G p |
| 136 | (fun t => M14BackwardTimeDerivative G (horizontalScalarCurvature G.leafwise) |
| 137 | (p.curve t)) = |
| 138 | M14BackwardLAction G p / 2 - squareHarnackPrimitive R (Real.sqrt τ₂) := by |
| 139 | have h := squareRoot_harnackIntegral_eq hM12 R E (by simpa only [Real.sqrt_zero] using hEuler) |
| 140 | simpa only [Real.sqrt_zero, squareHarnackPrimitive, zero_pow (by norm_num : 3 ≠ 0), |
| 141 | zero_mul, zero_div, add_zero] using h |
| 142 | |
| 143 | end PoincareMT.M14 |