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.ODE.Uniqueness.Open |
| 2 | |
| 3 | /-! # Joining smooth families of integral curves -/ |
| 4 | |
| 5 | noncomputable section |
| 6 | |
| 7 | namespace Poincare.ODE.LocalFlow |
| 8 | |
| 9 | open Set Filter |
| 10 | open scoped ContDiff Topology |
| 11 | |
| 12 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 13 | |
| 14 | /-- Smooth solution families with equal data at a common time glue smoothly |
| 15 | on overlapping convex time domains. -/ |
| 16 | theorem glue_smooth_solution_families |
| 17 | {F : E → E} {U V : Set E} (hU : IsOpen U) (hF : ContDiffOn ℝ ∞ F U) |
| 18 | (hV : IsOpen V) {J₁ J₂ : Set ℝ} |
| 19 | (hJ₁ : IsOpen J₁) (hJ₂ : IsOpen J₂) (hc₁ : Convex ℝ J₁) (hc₂ : Convex ℝ J₂) |
| 20 | {Φ₁ Φ₂ : E × ℝ → E} |
| 21 | (hs₁ : ContDiffOn ℝ ∞ Φ₁ (V ×ˢ J₁)) |
| 22 | (hs₂ : ContDiffOn ℝ ∞ Φ₂ (V ×ˢ J₂)) |
| 23 | (hd₁ : ∀ y ∈ V, ∀ t ∈ J₁, Φ₁ (y, t) ∈ U ∧ |
| 24 | HasDerivAt (fun s => Φ₁ (y, s)) (F (Φ₁ (y, t))) t) |
| 25 | (hd₂ : ∀ y ∈ V, ∀ t ∈ J₂, Φ₂ (y, t) ∈ U ∧ |
| 26 | HasDerivAt (fun s => Φ₂ (y, s)) (F (Φ₂ (y, t))) t) |
| 27 | {c : ℝ} (hc : c ∈ J₁ ∩ J₂) (hjoin : ∀ y ∈ V, Φ₁ (y, c) = Φ₂ (y, c)) : |
| 28 | ∃ Φ : E × ℝ → E, |
| 29 | ContDiffOn ℝ ∞ Φ (V ×ˢ (J₁ ∪ J₂)) ∧ |
| 30 | EqOn Φ Φ₁ (V ×ˢ J₁) ∧ EqOn Φ Φ₂ (V ×ˢ J₂) ∧ |
| 31 | ∀ y ∈ V, ∀ t ∈ J₁ ∪ J₂, Φ (y, t) ∈ U ∧ |
| 32 | HasDerivAt (fun s => Φ (y, s)) (F (Φ (y, t))) t := by |
| 33 | classical |
| 34 | have heq : ∀ y ∈ V, EqOn (fun t => Φ₁ (y, t)) (fun t => Φ₂ (y, t)) (J₁ ∩ J₂) := by |
| 35 | intro y hy |
| 36 | exact Poincare.ODE.eqOn_of_hasDerivAt hU hF (hJ₁.inter hJ₂) |
| 37 | (hc₁.inter hc₂).isPreconnected (fun t ht => hd₁ y hy t ht.1) |
| 38 | (fun t ht => hd₂ y hy t ht.2) hc (hjoin y hy) |
| 39 | let Φ : E × ℝ → E := fun p => if p.2 ∈ J₁ then Φ₁ p else Φ₂ p |
| 40 | have heq₁ : EqOn Φ Φ₁ (V ×ˢ J₁) := fun p hp => if_pos hp.2 |
| 41 | have heq₂ : EqOn Φ Φ₂ (V ×ˢ J₂) := by |
| 42 | rintro ⟨y, t⟩ ⟨hy, ht⟩ |
| 43 | by_cases ht₁ : t ∈ J₁ |
| 44 | · exact (if_pos ht₁).trans (heq y hy ⟨ht₁, ht⟩) |
| 45 | · exact if_neg ht₁ |
| 46 | have hgerm₁ {p : E × ℝ} (hp : p ∈ V ×ˢ J₁) : Φ =ᶠ[𝓝 p] Φ₁ := |
| 47 | Filter.Eventually.mono ((hV.prod hJ₁).mem_nhds hp) fun q hq => heq₁ hq |
| 48 | have hgerm₂ {p : E × ℝ} (hp : p ∈ V ×ˢ J₂) : Φ =ᶠ[𝓝 p] Φ₂ := |
| 49 | Filter.Eventually.mono ((hV.prod hJ₂).mem_nhds hp) fun q hq => heq₂ hq |
| 50 | refine ⟨Φ, ?_, heq₁, heq₂, ?_⟩ |
| 51 | · rintro ⟨y, t⟩ ⟨hy, ht | ht⟩ |
| 52 | · exact ((hs₁.contDiffAt ((hV.prod hJ₁).mem_nhds ⟨hy, ht⟩)).congr_of_eventuallyEq |
| 53 | (hgerm₁ ⟨hy, ht⟩)).contDiffWithinAt |
| 54 | · exact ((hs₂.contDiffAt ((hV.prod hJ₂).mem_nhds ⟨hy, ht⟩)).congr_of_eventuallyEq |
| 55 | (hgerm₂ ⟨hy, ht⟩)).contDiffWithinAt |
| 56 | · intro y hy t ht |
| 57 | rcases ht with ht | ht |
| 58 | · have he : (fun s => Φ (y, s)) =ᶠ[𝓝 t] (fun s => Φ₁ (y, s)) := |
| 59 | Filter.Eventually.mono (hJ₁.mem_nhds ht) fun s hs => heq₁ ⟨hy, hs⟩ |
| 60 | rw [heq₁ (show (y, t) ∈ V ×ˢ J₁ from ⟨hy, ht⟩)] |
| 61 | exact ⟨(hd₁ y hy t ht).1, (hd₁ y hy t ht).2.congr_of_eventuallyEq he⟩ |
| 62 | · have he : (fun s => Φ (y, s)) =ᶠ[𝓝 t] (fun s => Φ₂ (y, s)) := |
| 63 | Filter.Eventually.mono (hJ₂.mem_nhds ht) fun s hs => heq₂ ⟨hy, hs⟩ |
| 64 | rw [heq₂ (show (y, t) ∈ V ×ˢ J₂ from ⟨hy, ht⟩)] |
| 65 | exact ⟨(hd₂ y hy t ht).1, (hd₂ y hy t ht).2.congr_of_eventuallyEq he⟩ |
| 66 | |
| 67 | variable [FiniteDimensional ℝ E] |
| 68 | |
| 69 | /-- A compact family of initial points admits smooth local flows with a |
| 70 | single common existence time. Their spatial neighborhoods may vary. -/ |
| 71 | theorem exists_uniform_smooth_local_flows |
| 72 | {U K : Set E} (hU : IsOpen U) (hK : IsCompact K) (hKU : K ⊆ U) |
| 73 | {F : E → E} (hF : ContDiffOn ℝ ∞ F U) : |
| 74 | ∃ δ > 0, ∀ x ∈ K, ∃ (V : Set E) (Φ : E × ℝ → E), |
| 75 | IsOpen V ∧ x ∈ V ∧ ContDiffOn ℝ ∞ Φ (V ×ˢ Ioo (-δ) δ) ∧ |
| 76 | (∀ y ∈ V, Φ (y, 0) = y) ∧ |
| 77 | ∀ y ∈ V, ∀ t ∈ Ioo (-δ) δ, Φ (y, t) ∈ U ∧ |
| 78 | HasDerivAt (fun s => Φ (y, s)) (F (Φ (y, t))) t := by |
| 79 | let P : Set E → Prop := fun S => |
| 80 | ∃ δ > 0, ∀ x ∈ S, ∃ (V : Set E) (Φ : E × ℝ → E), |
| 81 | IsOpen V ∧ x ∈ V ∧ ContDiffOn ℝ ∞ Φ (V ×ˢ Ioo (-δ) δ) ∧ |
| 82 | (∀ y ∈ V, Φ (y, 0) = y) ∧ |
| 83 | ∀ y ∈ V, ∀ t ∈ Ioo (-δ) δ, Φ (y, t) ∈ U ∧ |
| 84 | HasDerivAt (fun s => Φ (y, s)) (F (Φ (y, t))) t |
| 85 | change P K |
| 86 | refine hK.induction_on (p := P) ?_ ?_ ?_ ?_ |
| 87 | · exact ⟨1, zero_lt_one, fun _ hx => False.elim hx⟩ |
| 88 | · rintro S T hST ⟨δ, hδ, h⟩ |
| 89 | exact ⟨δ, hδ, fun x hx => h x (hST hx)⟩ |
| 90 | · rintro S T ⟨δ, hδ, hS⟩ ⟨ε, hε, hT⟩ |
| 91 | have hleft : Ioo (-(min δ ε)) (min δ ε) ⊆ Ioo (-δ) δ := |
| 92 | Ioo_subset_Ioo (neg_le_neg (min_le_left _ _)) (min_le_left _ _) |
| 93 | have hright : Ioo (-(min δ ε)) (min δ ε) ⊆ Ioo (-ε) ε := |
| 94 | Ioo_subset_Ioo (neg_le_neg (min_le_right _ _)) (min_le_right _ _) |
| 95 | refine ⟨min δ ε, lt_min hδ hε, ?_⟩ |
| 96 | intro x hx |
| 97 | rcases hx with hx | hx |
| 98 | · obtain ⟨V, Φ, hV, hxV, hs, hi, hd⟩ := hS x hx |
| 99 | exact ⟨V, Φ, hV, hxV, hs.mono (prod_mono_right hleft), hi, |
| 100 | fun y hy t ht => hd y hy t (hleft ht)⟩ |
| 101 | · obtain ⟨V, Φ, hV, hxV, hs, hi, hd⟩ := hT x hx |
| 102 | exact ⟨V, Φ, hV, hxV, hs.mono (prod_mono_right hright), hi, |
| 103 | fun y hy t ht => hd y hy t (hright ht)⟩ |
| 104 | · intro x hx |
| 105 | obtain ⟨V, δ, Φ, hV, hxV, _, hδ, hs, hi, hm, hd⟩ := |
| 106 | exists_smooth_localFlow hU hF (hKU hx) |
| 107 | refine ⟨V, mem_nhdsWithin_of_mem_nhds (hV.mem_nhds hxV), δ, hδ, ?_⟩ |
| 108 | intro y hy |
| 109 | exact ⟨V, Φ, hV, hy, hs, hi, fun z hz t ht => ⟨hm z hz t ht, hd z hz t ht⟩⟩ |
| 110 | |
| 111 | /-- A smooth vector field has a jointly smooth family of solutions near any |
| 112 | given solution on a compact time interval. The family is constructed by a finite |
| 113 | chain of local flows, and uniqueness makes the overlap identifications smooth. -/ |
| 114 | theorem exists_smooth_flow_along_compact_interval |
| 115 | {F : E → E} {U : Set E} (hU : IsOpen U) (hF : ContDiffOn ℝ ∞ F U) |
| 116 | {γ : ℝ → E} {J : Set ℝ} (hJ : IsOpen J) (hcJ : Convex ℝ J) |
| 117 | (hγ : ∀ t ∈ J, γ t ∈ U ∧ HasDerivAt γ (F (γ t)) t) |
| 118 | {T : ℝ} (hT : 0 ≤ T) (hsub : Icc 0 T ⊆ J) : |
| 119 | ∃ (V : Set E) (ε : ℝ) (Φ : E × ℝ → E), IsOpen V ∧ γ 0 ∈ V ∧ 0 < ε ∧ |
| 120 | ContDiffOn ℝ ∞ Φ (V ×ˢ Ioo (-ε) (T + ε)) ∧ |
| 121 | (∀ y ∈ V, Φ (y, 0) = y) ∧ |
| 122 | ∀ y ∈ V, ∀ t ∈ Ioo (-ε) (T + ε), Φ (y, t) ∈ U ∧ |
| 123 | HasDerivAt (fun s => Φ (y, s)) (F (Φ (y, t))) t := by |
| 124 | have hcompact : IsCompact (γ '' Icc 0 T) := |
| 125 | isCompact_Icc.image_of_continuousOn |
| 126 | (fun t ht => (hγ t (hsub ht)).2.continuousAt.continuousWithinAt) |
| 127 | obtain ⟨δ, hδ, hlocal⟩ := exists_uniform_smooth_local_flows hU hcompact |
| 128 | (fun _ ⟨t, ht, he⟩ => he ▸ (hγ t (hsub ht)).1) hF |
| 129 | obtain ⟨N, hN⟩ := exists_nat_gt (T / δ) |
| 130 | have hNpos : (0 : ℝ) < N := lt_of_le_of_lt (div_nonneg hT hδ.le) hN |
| 131 | let d : ℝ := T / N |
| 132 | let s : ℕ → ℝ := fun i => i * d |
| 133 | have hd : 0 ≤ d := div_nonneg hT hNpos.le |
| 134 | have hsmall : d < δ := by |
| 135 | apply (div_lt_iff₀ hNpos).2 |
| 136 | have := (div_lt_iff₀ hδ).mp hN |
| 137 | nlinarith |
| 138 | have hs0 : s 0 = 0 := by simp [s] |
| 139 | have hsN : s N = T := by dsimp [s, d]; field_simp |
| 140 | have hsnonneg (i : ℕ) : 0 ≤ s i := mul_nonneg (Nat.cast_nonneg i) hd |
| 141 | have hsstep (i : ℕ) : s (i + 1) = s i + d := by dsimp [s]; push_cast; ring |
| 142 | have hsle (i : ℕ) (hi : i ≤ N) : s i ≤ T := by |
| 143 | rw [← hsN] |
| 144 | exact mul_le_mul_of_nonneg_right (by exact_mod_cast hi) hd |
| 145 | have aux : ∀ i, i ≤ N → ∃ (V : Set E) (ε : ℝ) (Φ : E × ℝ → E), |
| 146 | IsOpen V ∧ γ 0 ∈ V ∧ 0 < ε ∧ |
| 147 | ContDiffOn ℝ ∞ Φ (V ×ˢ Ioo (-ε) (s i + ε)) ∧ |
| 148 | (∀ y ∈ V, Φ (y, 0) = y) ∧ Φ (γ 0, s i) = γ (s i) ∧ |
| 149 | ∀ y ∈ V, ∀ t ∈ Ioo (-ε) (s i + ε), Φ (y, t) ∈ U ∧ |
| 150 | HasDerivAt (fun r => Φ (y, r)) (F (Φ (y, t))) t := by |
| 151 | intro i |
| 152 | induction i with |
| 153 | | zero => |
| 154 | intro _ |
| 155 | obtain ⟨V, Φ, hV, hxV, hs, hi, hflow⟩ := |
| 156 | hlocal (γ 0) (mem_image_of_mem γ ⟨le_rfl, hT⟩) |
| 157 | refine ⟨V, δ, Φ, hV, hxV, hδ, ?_, hi, ?_, ?_⟩ |
| 158 | · simpa only [hs0, zero_add] using hs |
| 159 | · simpa only [hs0] using hi (γ 0) hxV |
| 160 | · simpa only [hs0, zero_add] using hflow |
| 161 | | succ i ih => |
| 162 | intro hi |
| 163 | obtain ⟨V, ε, Φ, hV, hxV, hε, hsΦ, hinit, hend, hflow⟩ := |
| 164 | ih (Nat.le_of_succ_le hi) |
| 165 | have hiT : s i ∈ Icc 0 T := ⟨hsnonneg i, hsle i (Nat.le_of_succ_le hi)⟩ |
| 166 | have hnT : s (i + 1) ∈ Icc 0 T := ⟨hsnonneg _, hsle _ hi⟩ |
| 167 | obtain ⟨W, Ψ, hW, hxW, hsΨ, hinitΨ, hflowΨ⟩ := |
| 168 | hlocal (γ (s i)) (mem_image_of_mem γ hiT) |
| 169 | have hiold : s i ∈ Ioo (-ε) (s i + ε) := ⟨by linarith [hsnonneg i], by linarith⟩ |
| 170 | let B : E → E := fun y => Φ (y, s i) |
| 171 | have hsB : ContDiffOn ℝ ∞ B V := hsΦ.comp |
| 172 | (contDiff_id.prodMk contDiff_const).contDiffOn (fun y hy => ⟨hy, hiold⟩) |
| 173 | let V' : Set E := V ∩ B ⁻¹' W |
| 174 | have hV' : IsOpen V' := hsB.continuousOn.isOpen_inter_preimage hV hW |
| 175 | have hxV' : γ 0 ∈ V' := ⟨hxV, by |
| 176 | change Φ (γ 0, s i) ∈ W |
| 177 | rwa [hend]⟩ |
| 178 | let J₂ : Set ℝ := Ioo (s i - δ) (s i + δ) |
| 179 | let Ψ' : E × ℝ → E := fun p => Ψ (B p.1, p.2 - s i) |
| 180 | have htime (t : ℝ) (ht : t ∈ J₂) : t - s i ∈ Ioo (-δ) δ := |
| 181 | ⟨by linarith [ht.1], by linarith [ht.2]⟩ |
| 182 | have hsΨ' : ContDiffOn ℝ ∞ Ψ' (V' ×ˢ J₂) := by |
| 183 | apply hsΨ.comp |
| 184 | · exact ((hsB.mono inter_subset_left).comp contDiffOn_fst (fun _ hp => hp.1)).prodMk |
| 185 | (contDiffOn_snd.sub contDiffOn_const) |
| 186 | · intro p hp |
| 187 | exact ⟨hp.1.2, htime p.2 hp.2⟩ |
| 188 | have hflowΨ' : ∀ y ∈ V', ∀ t ∈ J₂, Ψ' (y, t) ∈ U ∧ |
| 189 | HasDerivAt (fun r => Ψ' (y, r)) (F (Ψ' (y, t))) t := by |
| 190 | intro y hy t ht |
| 191 | refine ⟨(hflowΨ (B y) hy.2 _ (htime t ht)).1, ?_⟩ |
| 192 | simpa [Ψ', Function.comp_def] using |
| 193 | (hflowΨ (B y) hy.2 _ (htime t ht)).2.scomp t ((hasDerivAt_id t).sub_const (s i)) |
| 194 | have hicommon : s i ∈ Ioo (-ε) (s i + ε) ∩ J₂ := |
| 195 | ⟨hiold, by constructor <;> linarith⟩ |
| 196 | obtain ⟨Ξ, hsΞ, heqΦ, heqΨ, hflowΞ⟩ := glue_smooth_solution_families hU hF hV' |
| 197 | isOpen_Ioo isOpen_Ioo (convex_Ioo _ _) (convex_Ioo _ _) |
| 198 | (hsΦ.mono (prod_mono_left inter_subset_left)) hsΨ' |
| 199 | (fun y hy => hflow y hy.1) hflowΨ' hicommon (fun y hy => by |
| 200 | simpa only [Ψ', sub_self, B] using (hinitΨ (B y) hy.2).symm) |
| 201 | let ε' : ℝ := min ε (δ - d) / 2 |
| 202 | have hε' : 0 < ε' := half_pos (lt_min hε (sub_pos.mpr hsmall)) |
| 203 | have hε'le : ε' ≤ ε := |
| 204 | (half_le_self (le_of_lt (lt_min hε (sub_pos.mpr hsmall)))).trans (min_le_left _ _) |
| 205 | have hε'd : d + ε' < δ := by |
| 206 | have := (half_lt_self (lt_min hε (sub_pos.mpr hsmall))).trans_le (min_le_right ε (δ - d)) |
| 207 | dsimp [ε'] |
| 208 | linarith |
| 209 | have hJsub : Ioo (-ε') (s (i + 1) + ε') ⊆ Ioo (-ε) (s i + ε) ∪ J₂ := by |
| 210 | intro t ht |
| 211 | by_cases hto : t < s i + ε |
| 212 | · exact Or.inl ⟨by linarith [ht.1], hto⟩ |
| 213 | · right |
| 214 | rw [hsstep] at ht |
| 215 | exact ⟨by linarith, by linarith [ht.2]⟩ |
| 216 | have h0old : (0 : ℝ) ∈ Ioo (-ε) (s i + ε) := |
| 217 | ⟨by linarith, by linarith [hsnonneg i]⟩ |
| 218 | have hnnew : s (i + 1) ∈ J₂ := by rw [hsstep]; constructor <;> linarith |
| 219 | have heqref : Ψ' (γ 0, s (i + 1)) = γ (s (i + 1)) := by |
| 220 | have he : EqOn (fun t => Ψ' (γ 0, t)) γ (J ∩ J₂) := |
| 221 | Poincare.ODE.eqOn_of_hasDerivAt hU hF (hJ.inter isOpen_Ioo) |
| 222 | (hcJ.inter (convex_Ioo _ _)).isPreconnected |
| 223 | (fun t ht => hflowΨ' (γ 0) hxV' t ht.2) (fun t ht => hγ t ht.1) |
| 224 | ⟨hsub hiT, hicommon.2⟩ (by |
| 225 | simpa only [Ψ', sub_self, B, hend] using hinitΨ (γ (s i)) hxW) |
| 226 | exact he ⟨hsub hnT, hnnew⟩ |
| 227 | refine ⟨V', ε', Ξ, hV', hxV', hε', hsΞ.mono (prod_mono_right hJsub), ?_, ?_, ?_⟩ |
| 228 | · intro y hy |
| 229 | exact (heqΦ (show (y, 0) ∈ V' ×ˢ Ioo (-ε) (s i + ε) from ⟨hy, h0old⟩)).trans |
| 230 | (hinit y hy.1) |
| 231 | · exact (heqΨ (show (γ 0, s (i + 1)) ∈ V' ×ˢ J₂ from ⟨hxV', hnnew⟩)).trans heqref |
| 232 | · exact fun y hy t ht => hflowΞ y hy t (hJsub ht) |
| 233 | obtain ⟨V, ε, Φ, hV, hxV, hε, hs, hi, _, hf⟩ := aux N le_rfl |
| 234 | rw [hsN] at hs hf |
| 235 | exact ⟨V, ε, Φ, hV, hxV, hε, hs, hi, hf⟩ |
| 236 | |
| 237 | end Poincare.ODE.LocalFlow |