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.SourceNames.LGeometry |
| 2 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Variation.Action.FirstVariation |
| 3 | |
| 4 | /-! |
| 5 | # The paired square-root Euler residual |
| 6 | |
| 7 | Morgan-Tian Lemma 6.4 and Definition 6.7, pp. 107-108. The actual |
| 8 | residual is linear in its test vector and independent of the extension |
| 9 | witness. First variation supplies a continuous scalar representative |
| 10 | of its pairing with an actual variation field on the interior. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped Manifold ContDiff Bundle Topology |
| 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 | {R : M14SquareRootPath G p} |
| 26 | |
| 27 | /-- M12's actual Ricci tensor is linear in the test-vector slot, |
| 28 | as used in the Euler equation after Lemma 6.4, pp. 107-108. -/ |
| 29 | theorem horizontalRicci_smul_right (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 30 | (q : G.Point) (v w : G.Horizontal q) (c : ℝ) : |
| 31 | horizontalRicci G.leafwise q v (c • w) = c * horizontalRicci G.leafwise q v w := by |
| 32 | have H := (hM12.leafwise_calculus X time I G.spacetime G.slices |
| 33 | G.timeIntervals G.gaugeCover).2 G.leafwise |
| 34 | obtain ⟨A, hA⟩ := H.ricci_tensor.1 q |
| 35 | have heval (v w : G.Horizontal q) : horizontalRicci G.leafwise q v w = A ![v, w] := by |
| 36 | simpa only [Matrix.cons_val_zero, Matrix.cons_val_one] using hA ![v, w] |
| 37 | rw [H.ricci_symmetric q v, heval, H.ricci_symmetric q v w, heval] |
| 38 | simpa only [smul_eq_mul, Matrix.vecCons] using A.cons_smul ![v] c w |
| 39 | |
| 40 | /-- The square-root Euler residual is linear under scalar multiplication |
| 41 | of its test vector, Definition 6.7, p. 108. -/ |
| 42 | theorem squareRootEulerResidual_smul (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 43 | (E : M14PullbackExtension G R.curve (M14SqrtParameterInterval τ₁ τ₂) |
| 44 | R.horizontal_velocity) (s c : ℝ) (W : G.Horizontal (R.curve s)) : |
| 45 | M14SquareRootEulerResidual G R E s (c • W) = c * M14SquareRootEulerResidual G R E s W := by |
| 46 | simp only [M14SquareRootEulerResidual, map_smul, Submodule.coe_smul, |
| 47 | horizontalRicci_smul_right hM12, smul_eq_mul] |
| 48 | ring |
| 49 | |
| 50 | /-- Every actual extension of the base velocity gives the same paired |
| 51 | Euler residual on the closed square interval, Definition 6.7 and |
| 52 | Lemma 6.8, pp. 108-109. -/ |
| 53 | theorem squareRootEulerResidual_extension_independent |
| 54 | (E₁ E₂ : M14PullbackExtension G R.curve (M14SqrtParameterInterval τ₁ τ₂) |
| 55 | R.horizontal_velocity) {s : ℝ} (hs : s ∈ M14SqrtParameterInterval τ₁ τ₂) |
| 56 | (W : G.Horizontal (R.curve s)) : |
| 57 | M14SquareRootEulerResidual G R E₁ s W = M14SquareRootEulerResidual G R E₂ s W := by |
| 58 | have hd := horizontalCovariantDerivative_extension_independent E₁ E₂ hs |
| 59 | (uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt) s hs) |
| 60 | ((R.smooth.mono R.interval_subset s hs).mdifferentiableWithinAt (by simp)) |
| 61 | simp only [M14SquareRootEulerResidual, hd] |
| 62 | |
| 63 | /-- The difference of the actual boundary-pair derivative and the |
| 64 | actual density partial in Lemma 6.4, pp. 107-108. It represents the |
| 65 | geometric residual on the strict interior. -/ |
| 66 | noncomputable def variationEulerDensity (V : M14LVariationData G p R) (s : ℝ) : ℝ := |
| 67 | derivWithin (variationBoundaryPair V) (M14SqrtParameterInterval τ₁ τ₂) s - |
| 68 | M08.variationParameterDeriv (M14SqrtParameterInterval τ₁ τ₂) V.parameterDomain |
| 69 | (variationActionDensity V) (s, 0) |
| 70 | |
| 71 | /-- The scalar representative of the first-variation residual is smooth |
| 72 | on the closed square interval, Lemma 6.4, pp. 107-108. -/ |
| 73 | theorem variationEulerDensity_contDiffOn (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 74 | (V : M14LVariationData G p R) : |
| 75 | ContDiffOn ℝ ∞ (variationEulerDensity V) (M14SqrtParameterInterval τ₁ τ₂) := by |
| 76 | have hC : UniqueDiffOn ℝ (M14SqrtParameterInterval τ₁ τ₂) := |
| 77 | uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt) |
| 78 | have hP : IsOpen V.parameterDomain := V.parameterDomain_eq ▸ isOpen_Ioo |
| 79 | have hzero : (0 : ℝ) ∈ V.parameterDomain := by |
| 80 | rw [V.parameterDomain_eq] |
| 81 | exact ⟨neg_lt_zero.mpr V.radius_pos, V.radius_pos⟩ |
| 82 | have hraw := (M08.variationParameterDeriv_contDiffOn hC hP (variationActionDensity V) |
| 83 | (variationActionDensity_contDiffOn hM12 V)).comp |
| 84 | (contDiffOn_id.prodMk contDiffOn_const) (fun _ hs => ⟨hs, hzero⟩) |
| 85 | exact ((variationBoundaryPair_contDiffOn V).derivWithin hC (m := ∞) (by simp)).sub hraw |
| 86 | |
| 87 | /-- The smooth scalar representative equals the frozen paired residual |
| 88 | against the actual variation field on the interior, for any base |
| 89 | extension witness, Lemma 6.4, pp. 107-108. -/ |
| 90 | theorem variationEulerDensity_eq_residual (hCoordinates : M12MetricPredecessors.{0} n) |
| 91 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) (V : M14LVariationData G p R) |
| 92 | (E : M14PullbackExtension G R.curve (M14SqrtParameterInterval τ₁ τ₂) |
| 93 | R.horizontal_velocity) {s : ℝ} (hs : s ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂)) : |
| 94 | variationEulerDensity V s = M14SquareRootEulerResidual G R E s (M14VariationField V s) := by |
| 95 | obtain ⟨D⟩ := exists_variationDerivativeData V |
| 96 | have hid := firstVariation_density_identity hCoordinates hM12 V D hs |
| 97 | rw [squareRootEulerResidual_extension_independent D.base_extension E |
| 98 | (Ioo_subset_Icc_self hs)] at hid |
| 99 | unfold variationEulerDensity |
| 100 | linarith |
| 101 | |
| 102 | end PoincareMT.M14 |