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 Mathlib.Geometry.Manifold.IntegralCurve.ExistUnique |
| 2 | import Mathlib.Geometry.Manifold.Instances.Real |
| 3 | |
| 4 | /-! |
| 5 | # A local flow transports its own vector field |
| 6 | |
| 7 | Uniqueness gives the local time-shift composition identity. Differentiating |
| 8 | that identity at shift zero yields transport by the actual time-map |
| 9 | differential. No flow composition law is assumed. |
| 10 | -/ |
| 11 | |
| 12 | noncomputable section |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open Set Filter |
| 17 | open scoped Manifold ContDiff Bundle Topology |
| 18 | |
| 19 | universe u |
| 20 | |
| 21 | namespace Poincare.Manifold |
| 22 | |
| 23 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] [T2Space M] |
| 24 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 25 | |
| 26 | private theorem integralCurve_eqOn_Ioo_of_contMDiffOn |
| 27 | {X : (x : M) → TangentSpace (𝓡 n) x} {U : Set M} (hU : IsOpen U) |
| 28 | (hX : ContMDiffOn (𝓡 n) ((𝓡 n).prod (𝓡 n)) 1 (T% X) U) |
| 29 | {α β : ℝ → M} {a b t₀ : ℝ} (ht₀ : t₀ ∈ Ioo a b) |
| 30 | (hαU : ∀ t ∈ Ioo a b, α t ∈ U) |
| 31 | (hα : IsMIntegralCurveOn (I := 𝓡 n) α X (Ioo a b)) |
| 32 | (hβ : IsMIntegralCurveOn (I := 𝓡 n) β X (Ioo a b)) |
| 33 | (hinit : α t₀ = β t₀) : EqOn α β (Ioo a b) := by |
| 34 | let S := {t | α t = β t} ∩ Ioo a b |
| 35 | suffices hsub : Ioo a b ⊆ S from fun t ht => (hsub ht).1 |
| 36 | apply isPreconnected_Ioo.subset_of_closure_inter_subset (s := Ioo a b) (u := S) _ |
| 37 | ⟨t₀, ⟨ht₀, ⟨hinit, ht₀⟩⟩⟩ |
| 38 | · dsimp only [S] |
| 39 | rw [inter_comm, ← Subtype.image_preimage_val, inter_comm, ← Subtype.image_preimage_val, |
| 40 | image_subset_image_iff Subtype.val_injective, preimage_ofPred_eq] |
| 41 | intro t ht |
| 42 | rw [mem_preimage, ← closure_subtype] at ht |
| 43 | revert ht t |
| 44 | apply IsClosed.closure_subset (isClosed_eq _ _) |
| 45 | · rw [continuous_iff_continuousAt] |
| 46 | rintro ⟨t, ht⟩ |
| 47 | apply ContinuousAt.comp _ continuousAt_subtype_val |
| 48 | exact (hα.continuousWithinAt ht).continuousAt (Ioo_mem_nhds ht.1 ht.2) |
| 49 | · rw [continuous_iff_continuousAt] |
| 50 | rintro ⟨t, ht⟩ |
| 51 | apply ContinuousAt.comp _ continuousAt_subtype_val |
| 52 | exact (hβ.continuousWithinAt ht).continuousAt (Ioo_mem_nhds ht.1 ht.2) |
| 53 | · rw [isOpen_iff_mem_nhds] |
| 54 | intro t ht |
| 55 | have hmem := Ioo_mem_nhds ht.2.1 ht.2.2 |
| 56 | have heq := isMIntegralCurveAt_eventuallyEq_of_contMDiffAt_boundaryless |
| 57 | (hX.contMDiffAt (hU.mem_nhds (hαU t ht.2))) |
| 58 | (hα.isMIntegralCurveAt hmem) (hβ.isMIntegralCurveAt hmem) ht.1 |
| 59 | exact (heq.and hmem).mono (fun _ hs => hs) |
| 60 | |
| 61 | private theorem localFlow_comp_eventuallyEq |
| 62 | {X : (x : M) → TangentSpace (𝓡 n) x} |
| 63 | {U V : Set M} (hU : IsOpen U) (hV : IsOpen V) |
| 64 | (hX : ContMDiffOn (𝓡 n) ((𝓡 n).prod (𝓡 n)) 1 (T% X) U) |
| 65 | {a b : ℝ} (ha : a < 0) (hb : 0 < b) |
| 66 | {Φ : ℝ × M → M} |
| 67 | (hinit : ∀ y ∈ V, Φ (0, y) = y) |
| 68 | (hstays : ∀ y ∈ V, ∀ t ∈ Ioo a b, Φ (t, y) ∈ U) |
| 69 | (horbit : ∀ y ∈ V, IsMIntegralCurveOn (I := 𝓡 n) |
| 70 | (fun t => Φ (t, y)) X (Ioo a b)) |
| 71 | {y : M} (hy : y ∈ V) {t : ℝ} (ht : t ∈ Ioo a b) : |
| 72 | (fun s => Φ (t, Φ (s, y))) =ᶠ[𝓝 0] (fun s => Φ (s + t, y)) := by |
| 73 | obtain ⟨a', haa', ha'min⟩ := exists_between (lt_min ha ht.1) |
| 74 | obtain ⟨b', hmaxb', hb'b⟩ := exists_between (max_lt hb ht.2) |
| 75 | have ha'0 : a' < 0 := ha'min.trans_le (min_le_left _ _) |
| 76 | have ha't : a' < t := ha'min.trans_le (min_le_right _ _) |
| 77 | have hb'0 : 0 < b' := (le_max_left _ _).trans_lt hmaxb' |
| 78 | have htb' : t < b' := (le_max_right _ _).trans_lt hmaxb' |
| 79 | have hsub : Ioo a' b' ⊆ Ioo a b := Ioo_subset_Ioo haa'.le hb'b.le |
| 80 | have hcont := (horbit y hy).isMIntegralCurveAt (Ioo_mem_nhds ha hb) |>.continuousAt |
| 81 | have hnear : ∀ᶠ s in 𝓝 0, Φ (s, y) ∈ V := by |
| 82 | apply hcont.preimage_mem_nhds |
| 83 | rw [hinit y hy] |
| 84 | exact hV.mem_nhds hy |
| 85 | have hshifts : Ioo (a - a') (b - b') ∈ 𝓝 (0 : ℝ) := |
| 86 | Ioo_mem_nhds (sub_neg.mpr haa') (sub_pos.mpr hb'b) |
| 87 | filter_upwards [hnear, hshifts] with s hs hsinterval |
| 88 | have hshift : ∀ r ∈ Ioo a' b', r + s ∈ Ioo a b := by |
| 89 | intro r hr |
| 90 | constructor <;> linarith [hr.1, hr.2, hsinterval.1, hsinterval.2] |
| 91 | have hα := (horbit (Φ (s, y)) hs).mono hsub |
| 92 | have hβ : IsMIntegralCurveOn (I := 𝓡 n) (fun r => Φ (r + s, y)) X (Ioo a' b') := |
| 93 | ((horbit y hy).comp_add s).mono hshift |
| 94 | have heq := integralCurve_eqOn_Ioo_of_contMDiffOn hU hX ⟨ha'0, hb'0⟩ |
| 95 | (fun r hr => hstays (Φ (s, y)) hs r (hsub hr)) hα hβ |
| 96 | (by simpa using hinit (Φ (s, y)) hs) |
| 97 | simpa only [add_comm] using heq ⟨ha't, htb'⟩ |
| 98 | |
| 99 | /-- The differential of an actual local time map transports the generating |
| 100 | vector field; the time-shift identity follows from integral-curve uniqueness. -/ |
| 101 | theorem mfderiv_localFlow_vectorField |
| 102 | {n : ℕ} {M : Type u} [TopologicalSpace M] [T2Space M] |
| 103 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 104 | {X : (x : M) → TangentSpace (𝓡 n) x} |
| 105 | {U V : Set M} (hU : IsOpen U) (hV : IsOpen V) |
| 106 | (hX : ContMDiffOn (𝓡 n) ((𝓡 n).prod (𝓡 n)) 1 (T% X) U) |
| 107 | {a b : ℝ} (ha : a < 0) (hb : 0 < b) |
| 108 | {Φ : ℝ × M → M} |
| 109 | (hΦ : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) (𝓡 n) 1 Φ (Ioo a b ×ˢ V)) |
| 110 | (hinit : ∀ y ∈ V, Φ (0, y) = y) |
| 111 | (hstays : ∀ y ∈ V, ∀ t ∈ Ioo a b, Φ (t, y) ∈ U) |
| 112 | (horbit : ∀ y ∈ V, IsMIntegralCurveOn (I := 𝓡 n) |
| 113 | (fun t => Φ (t, y)) X (Ioo a b)) |
| 114 | {y : M} (hy : y ∈ V) {t : ℝ} (ht : t ∈ Ioo a b) : |
| 115 | mfderiv (𝓡 n) (𝓡 n) (fun z => Φ (t, z)) y (X y) = |
| 116 | X (Φ (t, y)) := by |
| 117 | have hcomp := localFlow_comp_eventuallyEq hU hV hX ha hb hinit hstays horbit hy ht |
| 118 | have hzero := (horbit y hy).isMIntegralCurveAt (Ioo_mem_nhds ha hb) |
| 119 | have htime := (horbit y hy).isMIntegralCurveAt (Ioo_mem_nhds ht.1 ht.2) |
| 120 | have hspatial : MDifferentiableAt (𝓡 n) (𝓡 n) (fun z => Φ (t, z)) y := |
| 121 | ((hΦ.contMDiffAt ((isOpen_Ioo.prod hV).mem_nhds ⟨ht, hy⟩)).comp y |
| 122 | (contMDiffAt_const.prodMk contMDiffAt_id)).mdifferentiableAt (by simp) |
| 123 | have hspatial' : MDifferentiableAt (𝓡 n) (𝓡 n) |
| 124 | (fun z => Φ (t, z)) (Φ (0, y)) := by |
| 125 | simpa only [hinit y hy] using hspatial |
| 126 | have hleft := hspatial'.hasMFDerivAt.comp 0 hzero.hasMFDerivAt |
| 127 | have hright : IsMIntegralCurveAt (I := 𝓡 n) (fun s => Φ (s + t, y)) X 0 := by |
| 128 | simpa only [sub_self, Function.comp_def] using htime.comp_add t |
| 129 | have heq := (hleft.congr_of_eventuallyEq hcomp.symm).mfderiv.symm.trans |
| 130 | hright.hasMFDerivAt.mfderiv |
| 131 | have heval := congrArg (fun A => A (1 : ℝ)) heq |
| 132 | change (mfderiv (𝓡 n) (𝓡 n) (fun z => Φ (t, z)) (Φ (0, y))) |
| 133 | ((1 : ℝ) • X (Φ (0, y))) = (1 : ℝ) • X (Φ (0 + t, y)) at heval |
| 134 | simp only [one_smul] at heval |
| 135 | rw [zero_add, hinit y hy] at heval |
| 136 | exact heval |
| 137 | |
| 138 | end Poincare.Manifold |