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.ReducedGeometry.ReducedLength.ODE.OpenODEUniqueness |
| 2 | import Mathlib.Topology.Order.IntermediateValue |
| 3 | |
| 4 | /-! |
| 5 | # ODE uniqueness up to endpoints of a geometric interval |
| 6 | |
| 7 | The equation is required only within the interval. Local Lipschitz bounds |
| 8 | and the two one-sided uniqueness theorems compare every short segment. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open scoped Topology |
| 14 | |
| 15 | namespace PoincareMT.ReducedLength |
| 16 | |
| 17 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 18 | |
| 19 | theorem openODE_eventuallyEqWithin (S : Set (ℝ × E)) (hS : IsOpen S) |
| 20 | (V : ℝ × E → E) (hV : ContDiffOn ℝ 1 V S) |
| 21 | (I : Set ℝ) (hI : Set.OrdConnected I) (f g : ℝ → E) |
| 22 | (t0 : ℝ) (ht0 : t0 ∈ I) (h0 : (t0, f t0) ∈ S) (heq : f t0 = g t0) |
| 23 | (hfc : ContinuousWithinAt f I t0) (hgc : ContinuousWithinAt g I t0) |
| 24 | (hf : ∀ᶠ t in 𝓝[I] t0, (t, f t) ∈ S ∧ HasDerivAt f (V (t, f t)) t) |
| 25 | (hg : ∀ᶠ t in 𝓝[I] t0, (t, g t) ∈ S ∧ HasDerivAt g (V (t, g t)) t) : |
| 26 | f =ᶠ[𝓝[I] t0] g := by |
| 27 | obtain ⟨K, Q, hQ, hL⟩ := (hV.contDiffAt (hS.mem_nhds h0)).exists_lipschitzOnWith |
| 28 | have hLip : ∀ t : ℝ, LipschitzOnWith K (fun x ↦ V (t, x)) {x | (t, x) ∈ Q} := by |
| 29 | intro t x hx y hy |
| 30 | simpa only [Prod.edist_eq, edist_self, |
| 31 | max_eq_right (show 0 ≤ edist x y from bot_le)] using hL hx hy |
| 32 | have hfQ : ∀ᶠ t in 𝓝[I] t0, (t, f t) ∈ Q := |
| 33 | (continuousWithinAt_id.prodMk hfc).preimage_mem_nhdsWithin hQ |
| 34 | have hgQ : ∀ᶠ t in 𝓝[I] t0, (t, g t) ∈ Q := by |
| 35 | apply (continuousWithinAt_id.prodMk hgc).preimage_mem_nhdsWithin |
| 36 | simpa only [heq, Function.id_def] using hQ |
| 37 | obtain ⟨ε, hε, hdata⟩ := Metric.mem_nhdsWithin_iff.mp (hf.and (hg.and (hfQ.and hgQ))) |
| 38 | rw [Real.ball_eq_Ioo] at hdata |
| 39 | apply eventually_nhdsWithin_iff.mpr |
| 40 | filter_upwards [Metric.ball_mem_nhds t0 hε] with t ht htI |
| 41 | rw [Real.ball_eq_Ioo] at ht |
| 42 | by_cases horder : t0 ≤ t |
| 43 | · have hsegment : Set.Icc t0 t ⊆ Set.Ioo (t0 - ε) (t0 + ε) ∩ I := by |
| 44 | intro r hr |
| 45 | exact ⟨⟨by linarith [hr.1], hr.2.trans_lt ht.2⟩, hI.out ht0 htI hr⟩ |
| 46 | have hd := fun r (hr : r ∈ Set.Icc t0 t) ↦ hdata (hsegment hr) |
| 47 | exact ODE_solution_unique_of_mem_Icc_right (fun r _ ↦ hLip r) |
| 48 | (fun r hr ↦ (hd r hr).1.2.continuousAt.continuousWithinAt) |
| 49 | (fun r hr ↦ (hd r (Set.Ico_subset_Icc_self hr)).1.2.hasDerivWithinAt) |
| 50 | (fun r hr ↦ (hd r (Set.Ico_subset_Icc_self hr)).2.2.1) |
| 51 | (fun r hr ↦ (hd r hr).2.1.2.continuousAt.continuousWithinAt) |
| 52 | (fun r hr ↦ (hd r (Set.Ico_subset_Icc_self hr)).2.1.2.hasDerivWithinAt) |
| 53 | (fun r hr ↦ (hd r (Set.Ico_subset_Icc_self hr)).2.2.2) |
| 54 | heq ⟨horder, le_rfl⟩ |
| 55 | · have hle : t ≤ t0 := (lt_of_not_ge horder).le |
| 56 | have hsegment : Set.Icc t t0 ⊆ Set.Ioo (t0 - ε) (t0 + ε) ∩ I := by |
| 57 | intro r hr |
| 58 | exact ⟨⟨ht.1.trans_le hr.1, by linarith [hr.2]⟩, hI.out htI ht0 hr⟩ |
| 59 | have hd := fun r (hr : r ∈ Set.Icc t t0) ↦ hdata (hsegment hr) |
| 60 | exact ODE_solution_unique_of_mem_Icc_left (fun r _ ↦ hLip r) |
| 61 | (fun r hr ↦ (hd r hr).1.2.continuousAt.continuousWithinAt) |
| 62 | (fun r hr ↦ (hd r (Set.Ioc_subset_Icc_self hr)).1.2.hasDerivWithinAt) |
| 63 | (fun r hr ↦ (hd r (Set.Ioc_subset_Icc_self hr)).2.2.1) |
| 64 | (fun r hr ↦ (hd r hr).2.1.2.continuousAt.continuousWithinAt) |
| 65 | (fun r hr ↦ (hd r (Set.Ioc_subset_Icc_self hr)).2.1.2.hasDerivWithinAt) |
| 66 | (fun r hr ↦ (hd r (Set.Ioc_subset_Icc_self hr)).2.2.2) |
| 67 | heq ⟨le_rfl, hle⟩ |
| 68 | |
| 69 | theorem openODE_eqOn_preconnected (S : Set (ℝ × E)) (hS : IsOpen S) |
| 70 | (V : ℝ × E → E) (hV : ContDiffOn ℝ 1 V S) |
| 71 | (I : Set ℝ) (hI : IsPreconnected I) (f g : ℝ → E) |
| 72 | (hfc : ContinuousOn f I) (hgc : ContinuousOn g I) |
| 73 | (t0 : ℝ) (ht0 : t0 ∈ I) (heq : f t0 = g t0) |
| 74 | (hf : ∀ t ∈ I, (t, f t) ∈ S ∧ HasDerivAt f (V (t, f t)) t) |
| 75 | (hg : ∀ t ∈ I, (t, g t) ∈ S ∧ HasDerivAt g (V (t, g t)) t) : |
| 76 | Set.EqOn f g I := by |
| 77 | let : PreconnectedSpace I := isPreconnected_iff_preconnectedSpace.mp hI |
| 78 | let A : Set I := {t | f t = g t} |
| 79 | have hclosed : IsClosed A := isClosed_eq hfc.domRestrict hgc.domRestrict |
| 80 | have hopen : IsOpen A := by |
| 81 | apply isOpen_iff_mem_nhds.mpr |
| 82 | intro t ht |
| 83 | have hlocal := openODE_eventuallyEqWithin S hS V hV I hI.ordConnected f g |
| 84 | t t.property (hf t t.property).1 ht (hfc t t.property) (hgc t t.property) |
| 85 | (eventually_nhdsWithin_of_forall hf) (eventually_nhdsWithin_of_forall hg) |
| 86 | exact (eventually_nhds_subtype_iff I t (fun r ↦ f r = g r)).mpr hlocal |
| 87 | have hAll : A = Set.univ := IsClopen.eq_univ ⟨hclosed, hopen⟩ ⟨⟨t0, ht0⟩, heq⟩ |
| 88 | intro t ht |
| 89 | have hm : (⟨t, ht⟩ : I) ∈ A := by rw [hAll]; trivial |
| 90 | exact hm |
| 91 | |
| 92 | end PoincareMT.ReducedLength |