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.Analysis.ODE.ExistUnique |
| 2 | import Mathlib.Analysis.Calculus.MeanValue |
| 3 | import Mathlib.Topology.Order.IntermediateValue |
| 4 | |
| 5 | /-! |
| 6 | # Uniqueness for ODEs on an actual closed time interval |
| 7 | |
| 8 | The ODE uniqueness used in Morgan-Tian Lemma 6.18, pp. 113-114, |
| 9 | is here stated with coefficients smooth within the closed time domain |
| 10 | and genuine within derivatives of the solutions. Mathlib's convex |
| 11 | local Lipschitz theorem and one-sided Gronwall inequalities apply at |
| 12 | both endpoints. The comparison follows M08 LinearIntervalODE and |
| 13 | M09 WithinODEUniqueness without an ambient derivative assumption. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Set Filter Metric |
| 19 | open scoped Topology ContDiff |
| 20 | |
| 21 | namespace PoincareMT.M14 |
| 22 | |
| 23 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 24 | |
| 25 | /-- Solutions of a smooth closed-time ODE that meet at one point |
| 26 | agree on a relative neighborhood, including either closed endpoint. |
| 27 | This is the local uniqueness input of Lemma 6.18, pp. 113-114. -/ |
| 28 | theorem closedODE_eventuallyEqWithin {a b t₀ : ℝ} (hab : a < b) |
| 29 | {U : Set E} (hU : IsOpen U) (V : ℝ × E → E) |
| 30 | (hV : ContDiffOn ℝ ∞ V (Icc a b ×ˢ U)) |
| 31 | {f g : ℝ → E} (ht₀ : t₀ ∈ Icc a b) (hf₀ : f t₀ ∈ U) |
| 32 | (hf : ∀ t ∈ Icc a b, HasDerivWithinAt f (V (t, f t)) (Icc a b) t) |
| 33 | (hg : ∀ t ∈ Icc a b, HasDerivWithinAt g (V (t, g t)) (Icc a b) t) |
| 34 | (heq : f t₀ = g t₀) : f =ᶠ[𝓝[Icc a b] t₀] g := by |
| 35 | obtain ⟨r, hr, hball⟩ := Metric.isOpen_iff.mp hU (f t₀) hf₀ |
| 36 | let S := Icc a b ×ˢ ball (f t₀) r |
| 37 | have hS : Convex ℝ S := (convex_Icc a b).prod (convex_ball _ _) |
| 38 | have hSdiff : UniqueDiffOn ℝ S := (uniqueDiffOn_Icc hab).prod isOpen_ball.uniqueDiffOn |
| 39 | have hVS : ContDiffOn ℝ ∞ V S := hV.mono (prod_mono Subset.rfl hball) |
| 40 | have h₀S : (t₀, f t₀) ∈ S := ⟨ht₀, mem_ball_self hr⟩ |
| 41 | obtain ⟨K, Q, hQ, hLip⟩ := hS.exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt |
| 42 | (eventually_nhdsWithin_of_forall (fun z hz => |
| 43 | ((hVS z hz).differentiableWithinAt (by simp)).hasFDerivWithinAt)) |
| 44 | ((hVS.fderivWithin hSdiff (m := ∞) (by simp)).continuousOn _ h₀S) |
| 45 | have hslice (t : ℝ) : LipschitzOnWith K (fun z => V (t, z)) {z | (t, z) ∈ Q} := by |
| 46 | intro z hz w hw |
| 47 | simpa only [Prod.edist_eq, edist_self, |
| 48 | max_eq_right (show 0 ≤ edist z w from bot_le)] using hLip hz hw |
| 49 | obtain ⟨ε, hε, hQsub⟩ := Metric.mem_nhdsWithin_iff.mp hQ |
| 50 | have hfc : ContinuousOn f (Icc a b) := HasDerivWithinAt.continuousOn hf |
| 51 | have hgc : ContinuousOn g (Icc a b) := HasDerivWithinAt.continuousOn hg |
| 52 | have hfQ : ∀ᶠ t in 𝓝[Icc a b] t₀, (t, f t) ∈ Q := by |
| 53 | filter_upwards [self_mem_nhdsWithin, |
| 54 | (continuousWithinAt_id.prodMk (hfc t₀ ht₀)).preimage_mem_nhdsWithin |
| 55 | (ball_mem_nhds (t₀, f t₀) hε), |
| 56 | (hfc t₀ ht₀).preimage_mem_nhdsWithin (ball_mem_nhds (f t₀) hr)] with t ht htf hfr |
| 57 | exact hQsub ⟨htf, ht, hfr⟩ |
| 58 | have hgQ : ∀ᶠ t in 𝓝[Icc a b] t₀, (t, g t) ∈ Q := by |
| 59 | have hp : ball (t₀, f t₀) ε ∈ 𝓝 (t₀, g t₀) := by |
| 60 | rw [← heq] |
| 61 | exact ball_mem_nhds _ hε |
| 62 | have hb : ball (f t₀) r ∈ 𝓝 (g t₀) := by |
| 63 | rw [← heq] |
| 64 | exact ball_mem_nhds _ hr |
| 65 | filter_upwards [self_mem_nhdsWithin, |
| 66 | (continuousWithinAt_id.prodMk (hgc t₀ ht₀)).preimage_mem_nhdsWithin hp, |
| 67 | (hgc t₀ ht₀).preimage_mem_nhdsWithin hb] with t ht htg hgr |
| 68 | exact hQsub ⟨htg, ht, hgr⟩ |
| 69 | obtain ⟨δ, hδ, hdata⟩ := Metric.mem_nhdsWithin_iff.mp (hfQ.and hgQ) |
| 70 | rw [Real.ball_eq_Ioo] at hdata |
| 71 | apply eventually_nhdsWithin_iff.mpr |
| 72 | filter_upwards [Metric.ball_mem_nhds t₀ hδ] with t ht htI |
| 73 | rw [Real.ball_eq_Ioo] at ht |
| 74 | by_cases horder : t₀ ≤ t |
| 75 | · have hsegment : Icc t₀ t ⊆ Ioo (t₀ - δ) (t₀ + δ) ∩ Icc a b := by |
| 76 | intro r hr |
| 77 | exact ⟨⟨by linarith [hr.1], hr.2.trans_lt ht.2⟩, |
| 78 | ht₀.1.trans hr.1, hr.2.trans htI.2⟩ |
| 79 | have hsub : Icc t₀ t ⊆ Icc a b := fun r hr => (hsegment hr).2 |
| 80 | exact ODE_solution_unique_of_mem_Icc_right (fun r _ => hslice r) |
| 81 | (hfc.mono hsub) |
| 82 | (fun r hr => (hf r (hsub (Ico_subset_Icc_self hr))).mono_of_mem_nhdsWithin |
| 83 | (Icc_mem_nhdsGE_of_mem ⟨ht₀.1.trans hr.1, hr.2.trans_le htI.2⟩)) |
| 84 | (fun r hr => (hdata (hsegment (Ico_subset_Icc_self hr))).1) |
| 85 | (hgc.mono hsub) |
| 86 | (fun r hr => (hg r (hsub (Ico_subset_Icc_self hr))).mono_of_mem_nhdsWithin |
| 87 | (Icc_mem_nhdsGE_of_mem ⟨ht₀.1.trans hr.1, hr.2.trans_le htI.2⟩)) |
| 88 | (fun r hr => (hdata (hsegment (Ico_subset_Icc_self hr))).2) heq ⟨horder, le_rfl⟩ |
| 89 | · have hle : t ≤ t₀ := (lt_of_not_ge horder).le |
| 90 | have hsegment : Icc t t₀ ⊆ Ioo (t₀ - δ) (t₀ + δ) ∩ Icc a b := by |
| 91 | intro r hr |
| 92 | exact ⟨⟨ht.1.trans_le hr.1, by linarith [hr.2]⟩, |
| 93 | htI.1.trans hr.1, hr.2.trans ht₀.2⟩ |
| 94 | have hsub : Icc t t₀ ⊆ Icc a b := fun r hr => (hsegment hr).2 |
| 95 | exact ODE_solution_unique_of_mem_Icc_left (fun r _ => hslice r) |
| 96 | (hfc.mono hsub) |
| 97 | (fun r hr => (hf r (hsub (Ioc_subset_Icc_self hr))).mono_of_mem_nhdsWithin |
| 98 | (Icc_mem_nhdsLE_of_mem ⟨htI.1.trans_lt hr.1, hr.2.trans ht₀.2⟩)) |
| 99 | (fun r hr => (hdata (hsegment (Ioc_subset_Icc_self hr))).1) |
| 100 | (hgc.mono hsub) |
| 101 | (fun r hr => (hg r (hsub (Ioc_subset_Icc_self hr))).mono_of_mem_nhdsWithin |
| 102 | (Icc_mem_nhdsLE_of_mem ⟨htI.1.trans_lt hr.1, hr.2.trans ht₀.2⟩)) |
| 103 | (fun r hr => (hdata (hsegment (Ioc_subset_Icc_self hr))).2) heq ⟨le_rfl, hle⟩ |
| 104 | |
| 105 | /-- Initial equality determines a solution throughout its actual |
| 106 | closed interval when the reference solution stays in the smooth |
| 107 | state domain, the uniqueness part of Lemma 6.18, pp. 113-114. -/ |
| 108 | theorem closedODE_interval_solution_unique {a b t₀ : ℝ} (hab : a < b) |
| 109 | {U : Set E} (hU : IsOpen U) (V : ℝ × E → E) |
| 110 | (hV : ContDiffOn ℝ ∞ V (Icc a b ×ˢ U)) |
| 111 | {f g : ℝ → E} (hsrc : MapsTo f (Icc a b) U) |
| 112 | (hf : ∀ t ∈ Icc a b, HasDerivWithinAt f (V (t, f t)) (Icc a b) t) |
| 113 | (hg : ∀ t ∈ Icc a b, HasDerivWithinAt g (V (t, g t)) (Icc a b) t) |
| 114 | (ht₀ : t₀ ∈ Icc a b) (heq : f t₀ = g t₀) : EqOn f g (Icc a b) := by |
| 115 | let : PreconnectedSpace (Icc a b) := |
| 116 | isPreconnected_iff_preconnectedSpace.mp isPreconnected_Icc |
| 117 | let A : Set (Icc a b) := {t | f t = g t} |
| 118 | have hfc : ContinuousOn f (Icc a b) := HasDerivWithinAt.continuousOn hf |
| 119 | have hgc : ContinuousOn g (Icc a b) := HasDerivWithinAt.continuousOn hg |
| 120 | have hclosed : IsClosed A := isClosed_eq hfc.domRestrict hgc.domRestrict |
| 121 | have hopen : IsOpen A := by |
| 122 | apply isOpen_iff_mem_nhds.mpr |
| 123 | intro t ht |
| 124 | have hlocal := closedODE_eventuallyEqWithin hab hU V hV t.property |
| 125 | (hsrc t.property) hf hg ht |
| 126 | exact (eventually_nhds_subtype_iff (Icc a b) t (fun r => f r = g r)).mpr hlocal |
| 127 | have hAll : A = univ := IsClopen.eq_univ ⟨hclosed, hopen⟩ ⟨⟨t₀, ht₀⟩, heq⟩ |
| 128 | intro t ht |
| 129 | have hm : (⟨t, ht⟩ : Icc a b) ∈ A := by rw [hAll]; trivial |
| 130 | exact hm |
| 131 | |
| 132 | end PoincareMT.M14 |