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.Tensor.HarnackIntegrability |
| 2 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Action.ExponentialAction |
| 3 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus |
| 4 | |
| 5 | /-! |
| 6 | # The integrated Harnack identity |
| 7 | |
| 8 | Morgan-Tian's K identity follows from the actual square-time primitive. |
| 9 | Its initial boundary value vanishes because scalar curvature and square |
| 10 | energy are smooth through zero. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option maxSynthPendingDepth 3 |
| 15 | set_option maxHeartbeats 800000 |
| 16 | |
| 17 | open scoped Manifold ContDiff Bundle Topology intervalIntegral |
| 18 | |
| 19 | universe u |
| 20 | |
| 21 | namespace PoincareMT.ReducedLength |
| 22 | |
| 23 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 24 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] |
| 25 | [IsManifold (𝓡 n) ∞ M] |
| 26 | |
| 27 | set_option backward.isDefEq.respectTransparency false in |
| 28 | theorem lExponentialFamily_harnack_integral_square_eq {J : Set ℝ} {F : RicciFlow n M J} |
| 29 | (hM04 : RicciFlowCurvatureTheory.{u}) {T τmax : ℝ} |
| 30 | (hτmax : 0 < τmax) (hwindow : Set.Icc (T - τmax) T ⊆ J) |
| 31 | {p : M} (A : LExponentialFamily F T τmax p) |
| 32 | (Z : TangentSpace (𝓡 n) p) (b : ℝ) (hb : 0 < b) (hmax : b < τmax) : |
| 33 | reducedHarnackIntegral F T (A.gamma Z) (backwardScalarEvolutionAlong F T (A.gamma Z)) b = |
| 34 | A.action Z b / 2 - |
| 35 | ((Real.sqrt b) ^ 3 * |
| 36 | (F.connection (T - (Real.sqrt b) ^ 2)).scalarCurvature (A.squareFamily Z (Real.sqrt b)) + |
| 37 | Real.sqrt b * regularizedCurveEnergy F T (A.squareFamily Z) (Real.sqrt b) / 4) := by |
| 38 | let U := ((fun s : ℝ ↦ (Z, s)) ⁻¹' A.squareDomain) ∩ |
| 39 | Set.Ioo (-Real.sqrt τmax) (Real.sqrt τmax) |
| 40 | have hU : IsOpen U := (A.square_open.preimage |
| 41 | (continuous_const.prodMk continuous_id)).inter isOpen_Ioo |
| 42 | have hKU : Set.Icc 0 (Real.sqrt b) ⊆ U := by |
| 43 | intro s hs |
| 44 | have hsmax := hs.2.trans_lt (Real.sqrt_lt_sqrt hb.le hmax) |
| 45 | exact ⟨A.square_contains ⟨Set.mem_univ _, hs.1, hsmax⟩, |
| 46 | (neg_lt_zero.mpr (Real.sqrt_pos.mpr hτmax)).trans_le hs.1, hsmax⟩ |
| 47 | have hα := (lExponentialFamily_squareSlice_contMDiffOn A Z).mono |
| 48 | (show U ⊆ (fun s : ℝ ↦ (Z, s)) ⁻¹' A.squareDomain from Set.inter_subset_left) |
| 49 | let S : ℝ → ℝ := fun s ↦ (F.connection (T - s ^ 2)).scalarCurvature (A.squareFamily Z s) |
| 50 | let E := regularizedCurveEnergy F T (A.squareFamily Z) |
| 51 | have hS : ContDiffOn ℝ ∞ S U := |
| 52 | ((squareTime_scalar_smooth F hM04 T τmax hτmax hwindow).comp |
| 53 | (contMDiffOn_id.prodMk hα) (fun s hs ↦ ⟨hs.2, Set.mem_univ _⟩)).contDiffOn |
| 54 | have hE : ContDiffOn ℝ ∞ E U := regularizedCurveEnergy_contDiffOn F T τmax hτmax hwindow |
| 55 | (A.squareFamily Z) U hU hα Set.inter_subset_right |
| 56 | let P : ℝ → ℝ := fun s ↦ s ^ 3 * S s + s * E s / 4 |
| 57 | let D : ℝ → ℝ := fun s ↦ 2 * s ^ 2 * S s + (1 / 2 : ℝ) * E s |
| 58 | have hP : ContDiffOn ℝ ∞ P U := |
| 59 | ((contDiffOn_id.pow 3).mul hS).add ((contDiffOn_id.mul hE).div_const 4) |
| 60 | have hD : ContDiffOn ℝ ∞ D U := |
| 61 | ((contDiffOn_const.mul (contDiffOn_id.pow 2)).mul hS).add (contDiffOn_const.mul hE) |
| 62 | have hPi : IntervalIntegrable (deriv P) MeasureTheory.volume 0 (Real.sqrt b) := |
| 63 | ((hP.deriv_of_isOpen hU (m := ∞) (by simp)).continuousOn.mono hKU).intervalIntegrable_of_Icc |
| 64 | (Real.sqrt_nonneg b) |
| 65 | have hDi : IntervalIntegrable D MeasureTheory.volume 0 (Real.sqrt b) := |
| 66 | (hD.continuousOn.mono hKU).intervalIntegrable_of_Icc (Real.sqrt_nonneg b) |
| 67 | have hFTC : (∫ s in 0..Real.sqrt b, deriv P s) = P (Real.sqrt b) - P 0 := by |
| 68 | apply intervalIntegral.integral_eq_sub_of_hasDerivAt _ hPi |
| 69 | intro s hs |
| 70 | have hs' : s ∈ Set.Icc 0 (Real.sqrt b) := by |
| 71 | simpa only [Set.uIcc_of_le (Real.sqrt_nonneg b)] using hs |
| 72 | exact ((hP.contDiffAt (hU.mem_nhds (hKU hs'))).differentiableAt (by simp)).hasDerivAt |
| 73 | have hPder (s : ℝ) (hs : s ∈ Set.Ioo 0 (Real.sqrt b)) : |
| 74 | deriv P s = 3 * s ^ 2 * S s + s ^ 3 * deriv S s + |
| 75 | (E s + s * deriv E s) / 4 := by |
| 76 | have hSd := ((hS.contDiffAt (hU.mem_nhds (hKU (Set.Ioo_subset_Icc_self hs)))).differentiableAt |
| 77 | (by simp)).hasDerivAt |
| 78 | have hEd := ((hE.contDiffAt (hU.mem_nhds (hKU (Set.Ioo_subset_Icc_self hs)))).differentiableAt |
| 79 | (by simp)).hasDerivAt |
| 80 | convert! (((hasDerivAt_pow 3 s).mul hSd).add |
| 81 | (((hasDerivAt_id s).mul hEd).div_const 4)).deriv using 1 <;> |
| 82 | simp only [P, Nat.cast_ofNat, Nat.reduceSub, one_mul, id_eq] |
| 83 | have hsq : ∀ s ∈ Set.Ioo (min 0 (Real.sqrt b)) (max 0 (Real.sqrt b)), |
| 84 | HasDerivAt (fun r : ℝ ↦ r ^ 2) (2 * s) s := by |
| 85 | intro s _ |
| 86 | simpa using hasDerivAt_pow 2 s |
| 87 | have hpos : ∀ s ∈ Set.Ioo (min 0 (Real.sqrt b)) (max 0 (Real.sqrt b)), 0 ≤ 2 * s := by |
| 88 | intro s hs |
| 89 | have hs' : 0 < s := by simpa only [min_eq_left (Real.sqrt_nonneg b)] using hs.1 |
| 90 | positivity |
| 91 | let H := reducedHarnackDensity F T (A.gamma Z) (backwardScalarEvolutionAlong F T (A.gamma Z)) |
| 92 | have hchange := intervalIntegral.integral_comp_mul_deriv_of_deriv_nonneg |
| 93 | (f := fun s : ℝ ↦ s ^ 2) (f' := fun s ↦ 2 * s) (g := fun t ↦ t * Real.sqrt t * H t) |
| 94 | (continuous_pow 2).continuousOn hsq hpos |
| 95 | simp only [zero_pow two_ne_zero, Real.sq_sqrt hb.le] at hchange |
| 96 | have haction : (∫ s in 0..Real.sqrt b, D s) = A.action Z b := |
| 97 | (lExponentialFamily_action_square_eq A Z b hb hmax).symm |
| 98 | change (∫ t in 0..b, t * Real.sqrt t * H t) = A.action Z b / 2 - P (Real.sqrt b) |
| 99 | rw [← hchange] |
| 100 | calc |
| 101 | (∫ s in 0..Real.sqrt b, (s ^ 2 * Real.sqrt (s ^ 2) * H (s ^ 2)) * (2 * s)) = |
| 102 | ∫ s in 0..Real.sqrt b, (D s / 2 - deriv P s) := by |
| 103 | apply intervalIntegral.integral_congr_Ioo_of_le (Real.sqrt_nonneg b) |
| 104 | intro s hs |
| 105 | dsimp only |
| 106 | rw [Real.sqrt_sq hs.1.le, hPder s hs, |
| 107 | lExponentialFamily_weightedHarnack_square hM04 hτmax hwindow A Z b hb hmax s hs] |
| 108 | dsimp only [D, S, E] |
| 109 | ring |
| 110 | _ = A.action Z b / 2 - P (Real.sqrt b) := by |
| 111 | rw [intervalIntegral.integral_sub (hDi.div_const 2) hPi, |
| 112 | intervalIntegral.integral_div, haction, hFTC] |
| 113 | simp only [P, zero_pow (by norm_num : 3 ≠ 0), zero_mul, zero_div, add_zero, sub_zero] |
| 114 | |
| 115 | set_option backward.isDefEq.respectTransparency false in |
| 116 | theorem lExponentialFamily_harnack_integral_eq {J : Set ℝ} {F : RicciFlow n M J} |
| 117 | (hM04 : RicciFlowCurvatureTheory.{u}) {T τmax : ℝ} |
| 118 | (hτmax : 0 < τmax) (hwindow : Set.Icc (T - τmax) T ⊆ J) |
| 119 | {p : M} (A : LExponentialFamily F T τmax p) |
| 120 | (Z : TangentSpace (𝓡 n) p) (b : ℝ) (hb : 0 < b) (hmax : b < τmax) : |
| 121 | reducedHarnackIntegral F T (A.gamma Z) (backwardScalarEvolutionAlong F T (A.gamma Z)) b = |
| 122 | A.action Z b / 2 - b * Real.sqrt b * |
| 123 | ((F.connection (T - b)).scalarCurvature (A.gamma Z b) + |
| 124 | (F.metric (T - b)).inner (A.gamma Z b) |
| 125 | (curveVelocity (A.gamma Z) b) (curveVelocity (A.gamma Z) b)) := by |
| 126 | have hs : Real.sqrt b ∈ Set.Ioo 0 (Real.sqrt τmax) := |
| 127 | ⟨Real.sqrt_pos.mpr hb, Real.sqrt_lt_sqrt hb.le hmax⟩ |
| 128 | have hbase := A.square_agrees Z (Real.sqrt b) ⟨hs.1.le, hs.2⟩ |
| 129 | have hvel0 := lExponentialFamily_square_velocity_eq A Z (Real.sqrt b) hs |
| 130 | have hvsq := congrArg (fun t : ℝ ↦ |
| 131 | (curveVelocity (A.gamma Z) t : EuclideanSpace ℝ (Fin n))) (Real.sq_sqrt hb.le) |
| 132 | have hvel : (curveVelocity (A.squareFamily Z) (Real.sqrt b) : EuclideanSpace ℝ (Fin n)) = |
| 133 | (2 * Real.sqrt b) • curveVelocity (A.gamma Z) b := |
| 134 | hvel0.trans (congrArg (fun v : EuclideanSpace ℝ (Fin n) ↦ (2 * Real.sqrt b) • v) hvsq) |
| 135 | simp only [Real.sq_sqrt hb.le] at hbase |
| 136 | rw [lExponentialFamily_harnack_integral_square_eq hM04 hτmax hwindow A Z b hb hmax] |
| 137 | unfold regularizedCurveEnergy |
| 138 | rw [Real.sq_sqrt hb.le, hbase, hvel] |
| 139 | simp only [map_smul, smul_apply, smul_eq_mul] |
| 140 | have hcube : Real.sqrt b ^ 3 = b * Real.sqrt b := by rw [pow_succ, Real.sq_sqrt hb.le] |
| 141 | ring_nf |
| 142 | rw [hcube] |
| 143 | ring |
| 144 | |
| 145 | end PoincareMT.ReducedLength |