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.Variation.Fields.SquareTimeFields |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 3 | |
| 4 | /-! |
| 5 | # The metric derivative in the regularized equation |
| 6 | |
| 7 | The term `4s Ric` is the ordinary derivative of the square-time metric. |
| 8 | The chain rule applies also at zero because the signed neighborhood maps |
| 9 | into the given flow interval. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open scoped Manifold ContDiff Bundle Topology |
| 15 | open Filter |
| 16 | |
| 17 | universe u |
| 18 | |
| 19 | namespace PoincareMT.ReducedLength |
| 20 | |
| 21 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 22 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] |
| 23 | [IsManifold (𝓡 n) ∞ M] |
| 24 | |
| 25 | set_option backward.isDefEq.respectTransparency false in |
| 26 | theorem squareTime_metric_hasDerivAt {J : Set ℝ} (F : RicciFlow n M J) |
| 27 | (T b : ℝ) (hb : 0 < b) (hwindow : Set.Icc (T - b) T ⊆ J) |
| 28 | (s : ℝ) (hs : s ∈ Set.Ioo (-Real.sqrt b) (Real.sqrt b)) |
| 29 | (x : M) (u v : TangentSpace (𝓡 n) x) : |
| 30 | HasDerivAt (fun r ↦ (F.metric (T - r ^ 2)).inner x u v) |
| 31 | (4 * s * (F.connection (T - s ^ 2)).ricci x u v) s := by |
| 32 | have hclock : HasDerivAt (fun r : ℝ ↦ T - r ^ 2) (-2 * s) s := by |
| 33 | simpa only [id_eq, Nat.reduceSub, Nat.cast_ofNat, pow_one, mul_one, neg_mul] using |
| 34 | (hasDerivAt_pow 2 s).const_sub T |
| 35 | have hnear : ∀ᶠ r in 𝓝 s, T - r ^ 2 ∈ J := by |
| 36 | filter_upwards [Ioo_mem_nhds hs.1 hs.2] with r hr |
| 37 | exact hwindow (squareTime_mem_window T hb hr) |
| 38 | have h := (F.equation (T - s ^ 2) |
| 39 | (hwindow (squareTime_mem_window T hb hs)) x u v).comp_hasDerivAt s hclock hnear |
| 40 | convert! h using 1 <;> first | rfl | ring |
| 41 | |
| 42 | end PoincareMT.ReducedLength |