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.LGeometry.Variation.FirstVariationIdentity |
| 2 | |
| 3 | /-! Adapted from Mapher `PoincareMT/Proofs/M08/FirstVariation.lean` at |
| 4 | `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. -/ |
| 5 | |
| 6 | |
| 7 | set_option autoImplicit false |
| 8 | |
| 9 | open Set Filter Topology MeasureTheory |
| 10 | open scoped Manifold ContDiff Bundle intervalIntegral |
| 11 | |
| 12 | universe u |
| 13 | |
| 14 | namespace PoincareMT.LGeometry |
| 15 | |
| 16 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 17 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 18 | |
| 19 | theorem hasDerivAt_firstVariation {J : Set ℝ} {F : RicciFlow n M J} |
| 20 | {T τmax τ₁ τ₂ : ℝ} (hM04 : RicciFlowCurvatureTheory.{u}) |
| 21 | (hwindow : Icc (T - τmax) T ⊆ J) (hτ₂ : τ₂ ≤ τmax) |
| 22 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) |
| 23 | (D : LVariationDerivativeData V) : |
| 24 | HasDerivAt (variationLLength V) |
| 25 | (firstVariationBoundaryTerm V + firstVariationResidualIntegral V D) 0 := by |
| 26 | let a := Real.sqrt τ₁ |
| 27 | let b := Real.sqrt τ₂ |
| 28 | let C := sqrtParameterInterval τ₁ τ₂ |
| 29 | let raw := fun s ↦ variationParameterDeriv C V.parameterDomain (variationActionDensity V) (s, 0) |
| 30 | let B := variationBoundaryPair V |
| 31 | let dB := derivWithin B C |
| 32 | let R := fun s ↦ regularizedEulerResidual F T V.baseSquareCurve C |
| 33 | D.velocity_extension s (squareVariationField V s) |
| 34 | have hab : a < b := Real.sqrt_lt_sqrt p.nonnegative p.ordered |
| 35 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc hab |
| 36 | have hzero : (0 : ℝ) ∈ V.parameterDomain := ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 37 | have hraw : ContinuousOn raw C := |
| 38 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo (variationActionDensity V) |
| 39 | (variationActionDensity_contDiffOn hM04 V)).continuousOn.comp |
| 40 | (continuousOn_id.prodMk continuousOn_const) (fun s hs ↦ ⟨hs, hzero⟩) |
| 41 | have hB : ContDiffOn ℝ ∞ B C := variationBoundaryPair_contDiffOn V |
| 42 | have hdB : ContinuousOn dB C := (hB.derivWithin hC (m := ∞) (by simp)).continuousOn |
| 43 | have hrawInt : IntervalIntegrable raw volume a b := hraw.intervalIntegrable_of_Icc hab.le |
| 44 | have hdBInt : IntervalIntegrable dB volume a b := hdB.intervalIntegrable_of_Icc hab.le |
| 45 | have hid (s : ℝ) (hs : s ∈ Ioo a b) : raw s = dB s - R s := |
| 46 | firstVariation_density_identity hM04 hwindow hτ₂ V D hs |
| 47 | have hRInt : IntervalIntegrable R volume a b := by |
| 48 | apply (hdBInt.sub hrawInt).congr_uIoo |
| 49 | intro s hs |
| 50 | rw [uIoo_of_le hab.le] at hs |
| 51 | have h := hid s hs |
| 52 | linarith |
| 53 | have hFTC : (∫ s in a..b, dB s) = B b - B a := |
| 54 | intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hab.le hB.continuousOn |
| 55 | (fun s hs ↦ (((hB s (Ioo_subset_Icc_self hs)).differentiableWithinAt |
| 56 | (by simp)).hasDerivWithinAt).hasDerivAt (Icc_mem_nhds hs.1 hs.2)) hdBInt |
| 57 | have hvalue : (∫ s in a..b, raw s) = |
| 58 | firstVariationBoundaryTerm V + firstVariationResidualIntegral V D := by |
| 59 | calc |
| 60 | (∫ s in a..b, raw s) = ∫ s in a..b, dB s + -R s := |
| 61 | intervalIntegral.integral_congr_Ioo_of_le hab.le (fun s hs ↦ by |
| 62 | simpa only [sub_eq_add_neg] using hid s hs) |
| 63 | _ = (∫ s in a..b, dB s) + ∫ s in a..b, -R s := |
| 64 | intervalIntegral.integral_add hdBInt hRInt.neg |
| 65 | _ = _ := by rw [hFTC]; rfl |
| 66 | have h := hasDerivAt_variationLLength_integral hM04 V hzero |
| 67 | change HasDerivAt (variationLLength V) (∫ s in a..b, raw s) 0 at h |
| 68 | rwa [hvalue] at h |
| 69 | |
| 70 | theorem exists_firstVariation {J : Set ℝ} {F : RicciFlow n M J} |
| 71 | {T τmax τ₁ τ₂ : ℝ} (hM04 : RicciFlowCurvatureTheory.{u}) |
| 72 | (hwindow : Icc (T - τmax) T ⊆ J) (hτ₂ : τ₂ ≤ τmax) |
| 73 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) : |
| 74 | ∃ D : LVariationDerivativeData V, |
| 75 | HasDerivAt (variationLLength V) |
| 76 | (firstVariationBoundaryTerm V + firstVariationResidualIntegral V D) 0 := by |
| 77 | obtain ⟨D⟩ := exists_variationDerivativeData V |
| 78 | exact ⟨D, hasDerivAt_firstVariation hM04 hwindow hτ₂ V D⟩ |
| 79 | |
| 80 | end PoincareMT.LGeometry |