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.Riemannian.Metric.LocalExtension |
| 2 | import Mathlib.Geometry.Manifold.PartitionOfUnity |
| 3 | |
| 4 | /-! Positive metric extension preserving all germs along a closed set. |
| 5 | Source: MT Lemma 19.31, pp. 464-466; trimmed-intrinsic-transport derivation, |
| 6 | Section 3. Mathlib smooth separation extends the actual positive field. -/ |
| 7 | |
| 8 | noncomputable section |
| 9 | set_option autoImplicit false |
| 10 | set_option maxSynthPendingDepth 8 |
| 11 | set_option backward.isDefEq.respectTransparency false |
| 12 | |
| 13 | open Set Filter |
| 14 | open scoped Topology ContDiff Manifold |
| 15 | |
| 16 | namespace PoincareMT |
| 17 | |
| 18 | /-- Smooth positive symmetric coefficients on an open neighborhood of a |
| 19 | closed set have a global metric realization preserving every germ there. |
| 20 | Source: MT Lemma 19.31, pp. 464-466; trimmed-intrinsic-transport, Section 3. |
| 21 | No assumptions are made about the totalized coefficients outside U. -/ |
| 22 | theorem m64_exists_metric_eq_nhds_of_isClosed |
| 23 | {n : ℕ} {S U : Set (EuclideanSpace ℝ (Fin n))} |
| 24 | (hS : IsClosed S) (hU : IsOpen U) (hSU : S ⊆ U) |
| 25 | (B : EuclideanSpace ℝ (Fin n) → EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 26 | EuclideanSpace ℝ (Fin n) →L[ℝ] ℝ) |
| 27 | (hB : ContDiffOn ℝ ∞ B U) |
| 28 | (hsymm : ∀ x ∈ U, ∀ v w, B x v w = B x w v) |
| 29 | (hpos : ∀ x ∈ U, ∀ v, v ≠ 0 → 0 < B x v v) : |
| 30 | ∃ (g : RiemannianMetric n (EuclideanSpace ℝ (Fin n))) (_D : LeviCivitaData g), |
| 31 | ∀ x ∈ S, g.euclideanCoefficients =ᶠ[𝓝 x] B := by |
| 32 | obtain ⟨chi, hzero, hone, hchi⟩ := |
| 33 | exists_contMDiffMap_zero_one_nhds_of_isClosed (𝓡 n) hU.isClosed_compl hS |
| 34 | (show Disjoint Uᶜ S from disjoint_left.mpr (fun _ hx hs => hx (hSU hs))) |
| 35 | (n := ⊤) |
| 36 | let delta : EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n) →L[ℝ] ℝ := innerSL ℝ |
| 37 | let C : EuclideanSpace ℝ (Fin n) → EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 38 | EuclideanSpace ℝ (Fin n) →L[ℝ] ℝ := |
| 39 | fun x => chi x • B x + (1 - chi x) • delta |
| 40 | have hCa (x v w : EuclideanSpace ℝ (Fin n)) : |
| 41 | C x v w = chi x * B x v w + (1 - chi x) * inner ℝ v w := rfl |
| 42 | have hchiSmooth : ContDiff ℝ ∞ (fun x => chi x) := chi.contMDiff.contDiff |
| 43 | have hC : ContDiff ℝ ∞ C := by |
| 44 | rw [contDiff_iff_contDiffAt] |
| 45 | intro x |
| 46 | have hfirst : ContDiffAt ℝ ∞ (fun y => chi y • B y) x := by |
| 47 | by_cases hx : x ∈ U |
| 48 | · exact hchiSmooth.contDiffAt.smul (hB.contDiffAt (hU.mem_nhds hx)) |
| 49 | · have hz : ∀ᶠ y in 𝓝 x, chi y = 0 := hzero.filter_mono (nhds_le_nhdsSet hx) |
| 50 | apply (contDiffAt_const (c := (0 : EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 51 | EuclideanSpace ℝ (Fin n) →L[ℝ] ℝ))).congr_of_eventuallyEq |
| 52 | filter_upwards [hz] with y hy |
| 53 | simp only [hy, zero_smul] |
| 54 | exact hfirst.add ((contDiffAt_const.sub hchiSmooth.contDiffAt).smul contDiffAt_const) |
| 55 | have hzeroAt (x : EuclideanSpace ℝ (Fin n)) (hx : x ∉ U) : chi x = 0 := |
| 56 | hzero.self_of_nhdsSet x hx |
| 57 | have hCs : ∀ x v w, C x v w = C x w v := by |
| 58 | intro x v w |
| 59 | rw [hCa, hCa] |
| 60 | by_cases hx : x ∈ U |
| 61 | · rw [hsymm x hx v w, real_inner_comm v w] |
| 62 | · simp only [hzeroAt x hx, zero_mul, zero_add, sub_zero, one_mul, real_inner_comm] |
| 63 | have hCp : ∀ x v, v ≠ 0 → 0 < C x v v := by |
| 64 | intro x v hv |
| 65 | rw [hCa] |
| 66 | by_cases hc : chi x = 0 |
| 67 | · simpa only [hc, zero_mul, zero_add, sub_zero, one_mul] using real_inner_self_pos.mpr hv |
| 68 | · have hx : x ∈ U := by |
| 69 | by_contra hn |
| 70 | exact hc (hzeroAt x hn) |
| 71 | exact add_pos_of_pos_of_nonneg |
| 72 | (mul_pos (lt_of_le_of_ne (hchi x).1 (Ne.symm hc)) (hpos x hx v hv)) |
| 73 | (mul_nonneg (sub_nonneg.mpr (hchi x).2) real_inner_self_nonneg) |
| 74 | let g := RiemannianMetric.ofEuclideanCoefficients C hC hCs hCp |
| 75 | refine ⟨g, g.euclideanLeviCivitaData, ?_⟩ |
| 76 | intro x hx |
| 77 | have ho : ∀ᶠ y in 𝓝 x, chi y = 1 := hone.filter_mono (nhds_le_nhdsSet hx) |
| 78 | filter_upwards [ho] with y hy |
| 79 | change C y = B y |
| 80 | simp only [C, hy, one_smul, sub_self, zero_smul, add_zero] |
| 81 | |
| 82 | end PoincareMT |