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.Analysis.Calculus.SmoothCompactness |
| 2 | import PoincareLib.Analysis.Calculus.SmoothCompactness.FiniteDimensional |
| 3 | import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension |
| 4 | |
| 5 | /-! |
| 6 | # Smooth compactness for eventually smooth sequences |
| 7 | |
| 8 | Sequences defined on expanding domains need only be smooth near each compact |
| 9 | subset eventually. Smooth extensions on a compact exhaustion reduce this case |
| 10 | to the fixed-domain extraction theorem without changing any limiting jet. |
| 11 | The countable construction retains one subsequence across all coordinate |
| 12 | domains, including finite-dimensional spacetime products. It supports the |
| 13 | compactness argument of Morgan--Tian, Proposition 5.14, pp. 90--91. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Filter Set Function |
| 19 | open scoped ContDiff Topology |
| 20 | |
| 21 | namespace Poincare.Analysis.Calculus |
| 22 | |
| 23 | variable {d : ℕ} {E : Type*} |
| 24 | [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 25 | |
| 26 | /-- On each compact subset, all sufficiently late terms are smooth on some |
| 27 | open neighborhood. The neighborhood may depend on the term. -/ |
| 28 | def LocallyEventuallyContDiff |
| 29 | {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] |
| 30 | (Ω : Set X) (f : ℕ → X → E) : Prop := |
| 31 | ∀ K : Set X, IsCompact K → K ⊆ Ω → |
| 32 | ∀ᶠ j : ℕ in atTop, ∃ U : Set X, |
| 33 | IsOpen U ∧ K ⊆ U ∧ ContDiffOn ℝ ∞ (f j) U |
| 34 | |
| 35 | /-- Eventual smoothness on a fixed neighborhood of every point supplies |
| 36 | eventual smoothness near each compact subset. -/ |
| 37 | theorem locallyEventuallyContDiff_of_local |
| 38 | {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] |
| 39 | {Ω : Set X} {f : ℕ → X → E} |
| 40 | (hf : ∀ x ∈ Ω, ∃ U, IsOpen U ∧ x ∈ U ∧ |
| 41 | ∀ᶠ j in atTop, ContDiffOn ℝ ∞ (f j) U) : |
| 42 | LocallyEventuallyContDiff Ω f := by |
| 43 | intro K hK hKΩ |
| 44 | refine hK.induction_on (p := fun S => ∀ᶠ j in atTop, |
| 45 | ∃ U : Set X, IsOpen U ∧ S ⊆ U ∧ ContDiffOn ℝ ∞ (f j) U) ?_ ?_ ?_ ?_ |
| 46 | · exact Eventually.of_forall (fun _ => ⟨∅, isOpen_empty, subset_rfl, contDiffOn_empty⟩) |
| 47 | · intro S T hST hT |
| 48 | exact hT.mono fun _ ⟨U, hU, hTU, hfd⟩ => ⟨U, hU, hST.trans hTU, hfd⟩ |
| 49 | · intro S T hS hT |
| 50 | filter_upwards [hS, hT] with j ⟨U, hU, hSU, hfdU⟩ ⟨V, hV, hTV, hfdV⟩ |
| 51 | refine ⟨U ∪ V, hU.union hV, union_subset_union hSU hTV, fun x hx => ?_⟩ |
| 52 | rcases hx with hx | hx |
| 53 | · exact (hfdU.contDiffAt (hU.mem_nhds hx)).contDiffWithinAt |
| 54 | · exact (hfdV.contDiffAt (hV.mem_nhds hx)).contDiffWithinAt |
| 55 | · intro x hx |
| 56 | obtain ⟨U, hU, hxU, hfd⟩ := hf x (hKΩ hx) |
| 57 | exact ⟨U, mem_nhdsWithin_of_mem_nhds (hU.mem_nhds hxU), |
| 58 | hfd.mono fun _ h => ⟨U, hU, subset_rfl, h⟩⟩ |
| 59 | |
| 60 | private theorem exists_contDiff_extension_on_compact |
| 61 | {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] |
| 62 | [FiniteDimensional ℝ X] |
| 63 | {K U : Set X} (hK : IsCompact K) (hU : IsOpen U) (hKU : K ⊆ U) |
| 64 | (f : X → E) (hf : ContDiffOn ℝ ∞ f U) : |
| 65 | ∃ F : X → E, ContDiff ℝ ∞ F ∧ EqOn F f K := by |
| 66 | obtain ⟨V, hV, hKV, hVU⟩ := hK.exists_isOpen_closure_subset (hU.mem_nhdsSet.mpr hKU) |
| 67 | obtain ⟨a, ha, had, har⟩ := hV.exists_contDiff_support_eq (n := ⊤) |
| 68 | obtain ⟨b, hb, hbd, hbr⟩ := hK.isClosed.isOpen_compl.exists_contDiff_support_eq (n := ⊤) |
| 69 | have hab (x : X) : 0 < a x + b x := by |
| 70 | have hax := (har (mem_range_self x)).1 |
| 71 | have hbx := (hbr (mem_range_self x)).1 |
| 72 | by_cases hx : x ∈ K |
| 73 | · have hane : a x ≠ 0 := by |
| 74 | rw [← mem_support, ha] |
| 75 | exact hKV hx |
| 76 | exact add_pos_of_pos_of_nonneg (lt_of_le_of_ne hax hane.symm) hbx |
| 77 | · have hbne : b x ≠ 0 := by |
| 78 | rwa [← mem_support, hb] |
| 79 | exact add_pos_of_nonneg_of_pos hax (lt_of_le_of_ne hbx hbne.symm) |
| 80 | let c : X → ℝ := fun x => a x / (a x + b x) |
| 81 | have hc : ContDiff ℝ ∞ c := had.div (had.add hbd) (fun x => (hab x).ne') |
| 82 | have hcs : tsupport c ⊆ U := by |
| 83 | apply (closure_mono (show support c ⊆ V from ?_)).trans hVU |
| 84 | intro x hx |
| 85 | rw [← ha] |
| 86 | exact fun h => hx (by simp [c, h]) |
| 87 | have hcK : EqOn c (fun _ => 1) K := by |
| 88 | intro x hx |
| 89 | have hbx : b x = 0 := by |
| 90 | rw [← notMem_support, hb] |
| 91 | exact not_not_intro hx |
| 92 | simp only [c, hbx, add_zero] |
| 93 | exact div_self (by simpa [hbx] using (hab x).ne') |
| 94 | refine ⟨fun x => c x • f x, contDiff_iff_contDiffAt.mpr (fun x => ?_), ?_⟩ |
| 95 | · by_cases hx : x ∈ tsupport c |
| 96 | · exact hc.contDiffAt.smul ((hf x (hcs hx)).contDiffAt (hU.mem_nhds (hcs hx))) |
| 97 | · apply (contDiffAt_const (c := (0 : E))).congr_of_eventuallyEq |
| 98 | filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hx] with y hy |
| 99 | simp only [Pi.zero_apply] at hy |
| 100 | simp only [hy, zero_smul] |
| 101 | · intro x hx |
| 102 | simp only [hcK hx, one_smul] |
| 103 | |
| 104 | /-- Countably many sequences, smooth only eventually near compact subsets of |
| 105 | their finite-dimensional domains, admit one common smooth subsequence. -/ |
| 106 | theorem exists_common_smoothSubsequenceExtraction_finiteDimensional_of_locallyEventuallyContDiff |
| 107 | {X Y : ℕ → Type*} |
| 108 | [∀ i, NormedAddCommGroup (X i)] [∀ i, NormedSpace ℝ (X i)] |
| 109 | [∀ i, FiniteDimensional ℝ (X i)] |
| 110 | [∀ i, NormedAddCommGroup (Y i)] [∀ i, NormedSpace ℝ (Y i)] |
| 111 | [∀ i, FiniteDimensional ℝ (Y i)] |
| 112 | {Ω : ∀ i, Set (X i)} (hΩ : ∀ i, IsOpen (Ω i)) |
| 113 | (f : ∀ i, ℕ → X i → Y i) |
| 114 | (hf : ∀ i, LocallyEventuallyContDiff (Ω i) (f i)) |
| 115 | (hbound : ∀ i K, IsCompact K → K ⊆ Ω i → |
| 116 | ∀ m : ℕ, ∃ B : ℝ, ∀ᶠ k in atTop, ∀ x ∈ K, |
| 117 | ‖iteratedFDeriv ℝ m (f i k) x‖ ≤ B) : |
| 118 | ∃ σ : ℕ → ℕ, StrictMono σ ∧ ∃ f₀ : ∀ i, X i → Y i, |
| 119 | (∀ i, ContDiffOn ℝ ∞ (f₀ i) (Ω i)) ∧ |
| 120 | ∀ i m K, IsCompact K → K ⊆ Ω i → TendstoUniformlyOn |
| 121 | (fun k => iteratedFDeriv ℝ m (f i (σ k))) |
| 122 | (iteratedFDeriv ℝ m (f₀ i)) atTop K := by |
| 123 | classical |
| 124 | let : ∀ i, LocallyCompactSpace (Ω i) := fun i => (hΩ i).locallyCompactSpace |
| 125 | let A : ∀ i, CompactExhaustion (Ω i) := fun i => CompactExhaustion.choice (Ω i) |
| 126 | let K : ∀ i, ℕ → Set (X i) := fun i n => Subtype.val '' A i n |
| 127 | have hK (i n : ℕ) : IsCompact (K i n) := (A i |>.isCompact n).image continuous_subtype_val |
| 128 | have hKΩ (i n : ℕ) : K i n ⊆ Ω i := by |
| 129 | rintro _ ⟨x, _, rfl⟩ |
| 130 | exact x.property |
| 131 | have hKmono (i : ℕ) : Monotone (K i) := fun _ _ h => image_mono (A i |>.subset h) |
| 132 | have hKn (i n : ℕ) : K i n ⊆ interior (K i (n + 1)) := by |
| 133 | rintro _ ⟨x, hx, rfl⟩ |
| 134 | apply mem_interior.mpr |
| 135 | refine ⟨Subtype.val '' interior (A i (n + 1)), image_mono interior_subset, |
| 136 | (hΩ i).isOpenEmbedding_subtypeVal.isOpenMap _ isOpen_interior, ?_⟩ |
| 137 | exact ⟨x, (A i).subset_interior_succ n hx, rfl⟩ |
| 138 | have hcover (i : ℕ) {C : Set (X i)} (hC : IsCompact C) (hCΩ : C ⊆ Ω i) : |
| 139 | ∃ n, C ⊆ interior (K i n) := by |
| 140 | have hpre : IsCompact ((Subtype.val : Ω i → X i) ⁻¹' C) := by |
| 141 | apply Topology.IsEmbedding.subtypeVal.isCompact_iff.mpr |
| 142 | rwa [image_preimage_eq_of_subset (by simpa only [Subtype.range_coe] using hCΩ)] |
| 143 | obtain ⟨n, hn⟩ := (A i).exists_superset_of_isCompact hpre |
| 144 | refine ⟨n + 1, fun x hx => hKn i n ?_⟩ |
| 145 | exact ⟨⟨x, hCΩ hx⟩, hn hx, rfl⟩ |
| 146 | have hsmooth (n : ℕ) : ∀ᶠ k in atTop, ∀ i : Fin (n + 1), |
| 147 | ∃ U : Set (X i), IsOpen U ∧ K i n ⊆ U ∧ ContDiffOn ℝ ∞ (f i k) U := |
| 148 | eventually_all.mpr (fun i => hf i (K i n) (hK i n) (hKΩ i n)) |
| 149 | obtain ⟨τ, hτ, hτsmooth⟩ := Poincare.exists_strictMono_forall_le_of_eventually hsmooth |
| 150 | have hext (i n : ℕ) : ∃ F : X i → Y i, ContDiff ℝ ∞ F ∧ |
| 151 | (i ≤ n → EqOn F (f i (τ n)) (K i n)) := by |
| 152 | by_cases hi : i ≤ n |
| 153 | · obtain ⟨U, hU, hKU, hfd⟩ := hτsmooth n n le_rfl ⟨i, Nat.lt_succ_of_le hi⟩ |
| 154 | obtain ⟨F, hF, heq⟩ := exists_contDiff_extension_on_compact (hK i n) hU hKU |
| 155 | (f i (τ n)) hfd |
| 156 | exact ⟨F, hF, fun _ => heq⟩ |
| 157 | · exact ⟨fun _ => 0, contDiff_const, fun h => (hi h).elim⟩ |
| 158 | choose F hF hFeq using hext |
| 159 | have hjet (i : ℕ) (C : Set (X i)) (hC : IsCompact C) (hCΩ : C ⊆ Ω i) (m : ℕ) : |
| 160 | ∀ᶠ n in atTop, EqOn (iteratedFDeriv ℝ m (F i n)) |
| 161 | (iteratedFDeriv ℝ m (f i (τ n))) C := by |
| 162 | obtain ⟨N, hN⟩ := hcover i hC hCΩ |
| 163 | filter_upwards [eventually_ge_atTop N, eventually_ge_atTop i] with n hn hi x hx |
| 164 | have hlocal : F i n =ᶠ[𝓝 x] f i (τ n) := |
| 165 | Filter.eventuallyEq_of_mem (mem_interior_iff_mem_nhds.mp (hN hx)) |
| 166 | (fun y hy => hFeq i n hi (hKmono i hn hy)) |
| 167 | exact (hlocal.iteratedFDeriv ℝ m).self_of_nhds |
| 168 | have hFbound (i : ℕ) (C : Set (X i)) (hC : IsCompact C) (hCΩ : C ⊆ Ω i) (m : ℕ) : |
| 169 | ∃ B : ℝ, ∀ᶠ k in atTop, ∀ x ∈ C, ‖iteratedFDeriv ℝ m (F i k) x‖ ≤ B := by |
| 170 | obtain ⟨B, hB⟩ := hbound i C hC hCΩ m |
| 171 | refine ⟨B, ?_⟩ |
| 172 | filter_upwards [hjet i C hC hCΩ m, hτ.tendsto_atTop.eventually hB] with n hn hb x hx |
| 173 | rw [hn hx] |
| 174 | exact hb x hx |
| 175 | obtain ⟨σ, hσ, f₀, hf₀, hlim⟩ := exists_common_smoothSubsequenceExtraction_finiteDimensional |
| 176 | hΩ F (fun i n => (hF i n).contDiffOn) hFbound |
| 177 | refine ⟨τ ∘ σ, hτ.comp hσ, f₀, hf₀, fun i m C hC hCΩ => ?_⟩ |
| 178 | exact (hlim i m C hC hCΩ).congr (hσ.tendsto_atTop.eventually (hjet i C hC hCΩ m)) |
| 179 | |
| 180 | /-- Single-family smooth extraction on a finite-dimensional normed domain, |
| 181 | requiring only eventual smoothness near compact subsets. -/ |
| 182 | theorem exists_smoothSubsequenceExtraction_finiteDimensional_of_locallyEventuallyContDiff |
| 183 | {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] |
| 184 | [FiniteDimensional ℝ X] [FiniteDimensional ℝ E] |
| 185 | {Ω : Set X} (hΩ : IsOpen Ω) (f : ℕ → X → E) |
| 186 | (hf : LocallyEventuallyContDiff Ω f) |
| 187 | (hbound : ∀ K, IsCompact K → K ⊆ Ω → |
| 188 | ∀ m : ℕ, ∃ B : ℝ, ∀ᶠ k in atTop, ∀ x ∈ K, |
| 189 | ‖iteratedFDeriv ℝ m (f k) x‖ ≤ B) : |
| 190 | ∃ σ : ℕ → ℕ, StrictMono σ ∧ ∃ f₀ : X → E, |
| 191 | ContDiffOn ℝ ∞ f₀ Ω ∧ |
| 192 | ∀ m K, IsCompact K → K ⊆ Ω → TendstoUniformlyOn |
| 193 | (fun k => iteratedFDeriv ℝ m (f (σ k))) |
| 194 | (iteratedFDeriv ℝ m f₀) atTop K := by |
| 195 | obtain ⟨σ, hσ, f₀, hf₀, hlim⟩ := |
| 196 | exists_common_smoothSubsequenceExtraction_finiteDimensional_of_locallyEventuallyContDiff |
| 197 | (X := fun _ => X) (Y := fun _ => E) (fun _ => hΩ) (fun _ => f) |
| 198 | (fun _ => hf) (fun _ => hbound) |
| 199 | exact ⟨σ, hσ, f₀ 0, hf₀ 0, hlim 0⟩ |
| 200 | |
| 201 | /-- Smooth compactness remains valid when smoothness is only eventual near |
| 202 | each compact subset of the open Euclidean domain. -/ |
| 203 | theorem exists_smoothSubsequenceExtraction_of_locallyEventuallyContDiff |
| 204 | [FiniteDimensional ℝ E] |
| 205 | {Ω : Set (EuclideanSpace ℝ (Fin d))} |
| 206 | (hΩ : IsOpen Ω) |
| 207 | (f : ℕ → EuclideanSpace ℝ (Fin d) → E) |
| 208 | (hf : LocallyEventuallyContDiff Ω f) |
| 209 | (hbound : LocallyEventuallyBoundedDerivatives Ω f) : |
| 210 | Nonempty (SmoothSubsequenceExtraction Ω f) := by |
| 211 | obtain ⟨σ, hσ, f₀, hf₀, hlim⟩ := |
| 212 | exists_smoothSubsequenceExtraction_finiteDimensional_of_locallyEventuallyContDiff |
| 213 | hΩ f hf hbound |
| 214 | exact ⟨⟨σ, hσ, f₀, hf₀, hlim⟩⟩ |
| 215 | |
| 216 | end Poincare.Analysis.Calculus |