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.Surgery.Metric.Distance.MetricPathLength |
| 2 | import PoincareLib.Geometry.RicciFlow.CanonicalNeighborhood.Neck |
| 3 | |
| 4 | /-! |
| 5 | # Intrinsic distance under a smooth metric identification |
| 6 | |
| 7 | Lengths are compared on the actual admissible C1 paths in the frozen |
| 8 | intrinsic distance. The subsets may be closed: smoothness is required |
| 9 | at their points in the ambient manifolds. This includes the retained |
| 10 | central sphere of Morgan--Tian's surgery, p.340. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped Manifold ContDiff Bundle ENNReal Topology |
| 16 | open MeasureTheory |
| 17 | |
| 18 | universe u v |
| 19 | |
| 20 | namespace PoincareMT.MetricSurgery |
| 21 | |
| 22 | theorem pathELength_eq_lintegral_speed_Ioo |
| 23 | {n : ℕ} {X : Type u} [TopologicalSpace X] |
| 24 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) X] [IsManifold (𝓡 n) ∞ X] |
| 25 | (g : RiemannianMetric n X) (gamma : ℝ → X) (a b : ℝ) : |
| 26 | g.pathELength gamma a b = |
| 27 | ∫⁻ t in Set.Ioo a b, ENNReal.ofReal (metricPathSpeed g gamma t) := by |
| 28 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : X → Type _) := |
| 29 | ⟨g.toRiemannianMetric⟩ |
| 30 | change Manifold.pathELength (𝓡 n) gamma a b = _ |
| 31 | rw [Manifold.pathELength_eq_lintegral_mfderiv_Ioo] |
| 32 | apply setLIntegral_congr_fun measurableSet_Ioo |
| 33 | intro t _ |
| 34 | dsimp only |
| 35 | erw [← ofReal_norm, norm_eq_sqrt_real_inner] |
| 36 | rfl |
| 37 | |
| 38 | variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] |
| 39 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) X] |
| 40 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) Y] |
| 41 | [IsManifold (𝓡 3) ∞ X] [IsManifold (𝓡 3) ∞ Y] |
| 42 | |
| 43 | omit [IsManifold (𝓡 3) ∞ X] [IsManifold (𝓡 3) ∞ Y] in |
| 44 | theorem path_contMDiffOn_comp_at {f : X → Y} {U : Set X} |
| 45 | (hf : ∀ x ∈ U, ContMDiffAt (𝓡 3) (𝓡 3) ∞ f x) |
| 46 | {gamma : ℝ → X} |
| 47 | (hgamma : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 3) 1 gamma (Set.Icc (0 : ℝ) 1)) |
| 48 | (hU : gamma '' Set.Icc (0 : ℝ) 1 ⊆ U) : |
| 49 | ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 3) 1 (f ∘ gamma) (Set.Icc (0 : ℝ) 1) := by |
| 50 | intro t ht |
| 51 | exact ((hf (gamma t) (hU ⟨t, ht, rfl⟩)).of_le (by simp)).comp_contMDiffWithinAt t |
| 52 | (hgamma t ht) |
| 53 | |
| 54 | set_option backward.isDefEq.respectTransparency false in |
| 55 | theorem pathELength_comp_eq_of_pullback (g : RiemannianMetric 3 X) |
| 56 | (h : RiemannianMetric 3 Y) {f : X → Y} {U : Set X} |
| 57 | (hf : ∀ x ∈ U, ContMDiffAt (𝓡 3) (𝓡 3) ∞ f x) |
| 58 | (hmetric : ∀ x ∈ U, ∀ v w : TangentSpace (𝓡 3) x, |
| 59 | h.inner (f x) (mfderiv (𝓡 3) (𝓡 3) f x v) (mfderiv (𝓡 3) (𝓡 3) f x w) = |
| 60 | g.inner x v w) |
| 61 | {gamma : ℝ → X} |
| 62 | (hgamma : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 3) 1 gamma (Set.Icc (0 : ℝ) 1)) |
| 63 | (hU : gamma '' Set.Icc (0 : ℝ) 1 ⊆ U) : |
| 64 | h.pathELength (f ∘ gamma) 0 1 = g.pathELength gamma 0 1 := by |
| 65 | rw [pathELength_eq_lintegral_speed_Ioo, pathELength_eq_lintegral_speed_Ioo] |
| 66 | apply setLIntegral_congr_fun measurableSet_Ioo |
| 67 | intro t ht |
| 68 | have ht' : t ∈ Set.Icc (0 : ℝ) 1 := ⟨ht.1.le, ht.2.le⟩ |
| 69 | have hgammaAt := ((hgamma t ht').contMDiffAt (Icc_mem_nhds ht.1 ht.2)).mdifferentiableAt |
| 70 | (by simp) |
| 71 | have hfAt := (hf (gamma t) (hU ⟨t, ht', rfl⟩)).mdifferentiableAt (by simp) |
| 72 | change ENNReal.ofReal (h.tangentNorm (f (gamma t)) |
| 73 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 3) (f ∘ gamma) t 1)) = |
| 74 | ENNReal.ofReal (g.tangentNorm (gamma t) (mfderiv 𝓘(ℝ, ℝ) (𝓡 3) gamma t 1)) |
| 75 | rw [mfderiv_comp t hfAt hgammaAt] |
| 76 | simp only [ContinuousLinearMap.comp_apply, Function.comp_apply, RiemannianMetric.tangentNorm, |
| 77 | hmetric (gamma t) (hU ⟨t, ht', rfl⟩)] |
| 78 | |
| 79 | theorem intrinsicEDist_image_le_of_pullback (g : RiemannianMetric 3 X) |
| 80 | (h : RiemannianMetric 3 Y) {f : X → Y} {U : Set X} |
| 81 | (hf : ∀ x ∈ U, ContMDiffAt (𝓡 3) (𝓡 3) ∞ f x) |
| 82 | (hmetric : ∀ x ∈ U, ∀ v w : TangentSpace (𝓡 3) x, |
| 83 | h.inner (f x) (mfderiv (𝓡 3) (𝓡 3) f x v) (mfderiv (𝓡 3) (𝓡 3) f x w) = |
| 84 | g.inner x v w) |
| 85 | (x y : X) : |
| 86 | intrinsicEDist h (f '' U) (f x) (f y) ≤ intrinsicEDist g U x y := by |
| 87 | apply le_sInf |
| 88 | rintro L ⟨gamma, hgamma, hzero, hone, hU, rfl⟩ |
| 89 | apply sInf_le |
| 90 | refine ⟨f ∘ gamma, path_contMDiffOn_comp_at hf hgamma hU, ?_, ?_, ?_, ?_⟩ |
| 91 | · simp only [Function.comp_apply, hzero] |
| 92 | · simp only [Function.comp_apply, hone] |
| 93 | · rintro _ ⟨t, ht, rfl⟩ |
| 94 | exact ⟨gamma t, hU ⟨t, ht, rfl⟩, rfl⟩ |
| 95 | · exact (pathELength_comp_eq_of_pullback g h hf hmetric hgamma hU).symm |
| 96 | |
| 97 | theorem intrinsicEDist_image_eq_of_inverse_pullbacks (g : RiemannianMetric 3 X) |
| 98 | (h : RiemannianMetric 3 Y) {f : X → Y} {k : Y → X} {U : Set X} |
| 99 | (hf : ∀ x ∈ U, ContMDiffAt (𝓡 3) (𝓡 3) ∞ f x) |
| 100 | (hk : ∀ y ∈ f '' U, ContMDiffAt (𝓡 3) (𝓡 3) ∞ k y) |
| 101 | (hinv : Set.LeftInvOn k f U) |
| 102 | (hmetric : ∀ x ∈ U, ∀ v w : TangentSpace (𝓡 3) x, |
| 103 | h.inner (f x) (mfderiv (𝓡 3) (𝓡 3) f x v) (mfderiv (𝓡 3) (𝓡 3) f x w) = |
| 104 | g.inner x v w) |
| 105 | (hmetricInv : ∀ y ∈ f '' U, ∀ v w : TangentSpace (𝓡 3) y, |
| 106 | g.inner (k y) (mfderiv (𝓡 3) (𝓡 3) k y v) (mfderiv (𝓡 3) (𝓡 3) k y w) = |
| 107 | h.inner y v w) |
| 108 | {x y : X} (hx : x ∈ U) (hy : y ∈ U) : |
| 109 | intrinsicEDist h (f '' U) (f x) (f y) = intrinsicEDist g U x y := by |
| 110 | apply le_antisymm (intrinsicEDist_image_le_of_pullback g h hf hmetric x y) |
| 111 | have himage : k '' (f '' U) = U := by |
| 112 | ext z |
| 113 | constructor |
| 114 | · rintro ⟨_, ⟨w, hw, rfl⟩, rfl⟩ |
| 115 | simpa only [hinv hw] using hw |
| 116 | · intro hz |
| 117 | exact ⟨f z, ⟨z, hz, rfl⟩, hinv hz⟩ |
| 118 | have hle := intrinsicEDist_image_le_of_pullback h g hk hmetricInv (f x) (f y) |
| 119 | simpa only [himage, hinv hx, hinv hy] using hle |
| 120 | |
| 121 | end PoincareMT.MetricSurgery |