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.CompactTime |
| 2 | |
| 3 | /-! |
| 4 | # Existence from compact confinement |
| 5 | |
| 6 | An a priori compact confinement estimate on finite solution intervals gives |
| 7 | existence on the whole prescribed interval. A uniform local existence time |
| 8 | on the compact set reduces continuation to finitely many joins. |
| 9 | -/ |
| 10 | |
| 11 | noncomputable section |
| 12 | |
| 13 | namespace Poincare.ODE |
| 14 | |
| 15 | open Set |
| 16 | open scoped ContDiff |
| 17 | |
| 18 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 19 | [FiniteDimensional ℝ E] |
| 20 | |
| 21 | /-- Compact confinement of every partial solution implies existence up to |
| 22 | the prescribed time. The confinement estimate is needed only at endpoints. -/ |
| 23 | theorem exists_solution_of_compact_confinement |
| 24 | {U K : Set E} (hU : IsOpen U) (hK : IsCompact K) (hKU : K ⊆ U) |
| 25 | {F : E → E} (hF : ContDiffOn ℝ ∞ F U) {x : E} (hx : x ∈ K) |
| 26 | {T : ℝ} (hT : 0 ≤ T) |
| 27 | (hconf : ∀ t ∈ Icc 0 T, ∀ γ : ℝ → E, γ 0 = x → |
| 28 | (∀ r ∈ Icc 0 t, γ r ∈ U ∧ |
| 29 | HasDerivWithinAt γ (F (γ r)) (Icc 0 t) r) → γ t ∈ K) : |
| 30 | ∃ γ : ℝ → E, γ 0 = x ∧ |
| 31 | ∀ t ∈ Icc 0 T, γ t ∈ U ∧ HasDerivWithinAt γ (F (γ t)) (Icc 0 T) t := by |
| 32 | obtain ⟨δ, hδ, hlocal⟩ := exists_uniform_local_solutions hU hK hKU hF |
| 33 | obtain ⟨N, hN⟩ := exists_nat_gt (T / δ) |
| 34 | have hNpos : (0 : ℝ) < N := lt_of_le_of_lt (div_nonneg hT hδ.le) hN |
| 35 | let d : ℝ := T / N |
| 36 | let s : ℕ → ℝ := fun i => i * d |
| 37 | have hd : 0 ≤ d := div_nonneg hT hNpos.le |
| 38 | have hsmall : d < δ := by |
| 39 | apply (div_lt_iff₀ hNpos).2 |
| 40 | have := (div_lt_iff₀ hδ).mp hN |
| 41 | nlinarith |
| 42 | have hs0 : s 0 = 0 := by simp [s] |
| 43 | have hsN : s N = T := by dsimp [s, d]; field_simp |
| 44 | have hsnonneg (i : ℕ) : 0 ≤ s i := mul_nonneg (Nat.cast_nonneg i) hd |
| 45 | have hsstep (i : ℕ) : s (i + 1) = s i + d := by dsimp [s]; push_cast; ring |
| 46 | have hsmono (i : ℕ) : s i ≤ s (i + 1) := by rw [hsstep]; linarith |
| 47 | have hsle (i : ℕ) (hi : i ≤ N) : s i ≤ T := by |
| 48 | rw [← hsN] |
| 49 | exact mul_le_mul_of_nonneg_right (by exact_mod_cast hi) hd |
| 50 | have hinterval : Icc 0 d ⊆ Ioo (-δ) δ := |
| 51 | fun t ht => ⟨by linarith [ht.1], ht.2.trans_lt hsmall⟩ |
| 52 | have aux : ∀ i, i ≤ N → ∃ γ : ℝ → E, γ 0 = x ∧ |
| 53 | ∀ t ∈ Icc 0 (s i), γ t ∈ U ∧ |
| 54 | HasDerivWithinAt γ (F (γ t)) (Icc 0 (s i)) t := by |
| 55 | intro i |
| 56 | induction i with |
| 57 | | zero => |
| 58 | intro _ |
| 59 | obtain ⟨γ, hinit, hγ⟩ := hlocal x hx |
| 60 | refine ⟨γ, hinit, ?_⟩ |
| 61 | intro t ht |
| 62 | have ht0 : t = 0 := by rw [hs0] at ht; exact le_antisymm ht.2 ht.1 |
| 63 | subst t |
| 64 | exact ⟨by simpa only [hinit] using hKU hx, |
| 65 | (hγ 0 ⟨by linarith, hδ⟩).2.hasDerivWithinAt⟩ |
| 66 | | succ i ih => |
| 67 | intro hi |
| 68 | obtain ⟨γ₁, hinit, hγ₁⟩ := ih (Nat.le_of_succ_le hi) |
| 69 | have hjoinK := hconf (s i) ⟨hsnonneg i, hsle i (Nat.le_of_succ_le hi)⟩ |
| 70 | γ₁ hinit hγ₁ |
| 71 | obtain ⟨β, hβ0, hβ⟩ := hlocal (γ₁ (s i)) hjoinK |
| 72 | let γ₂ : ℝ → E := fun t => β (t - s i) |
| 73 | have hjoin : γ₂ (s i) = γ₁ (s i) := by simp only [γ₂, sub_self, hβ0] |
| 74 | have hγ₂ : ∀ t ∈ Icc (s i) (s (i + 1)), γ₂ t ∈ U ∧ |
| 75 | HasDerivAt γ₂ (F (γ₂ t)) t := by |
| 76 | intro t ht |
| 77 | have hr : t - s i ∈ Icc 0 d := by |
| 78 | rw [hsstep] at ht |
| 79 | constructor <;> linarith [ht.1, ht.2] |
| 80 | refine ⟨(hβ _ (hinterval hr)).1, ?_⟩ |
| 81 | simpa only [γ₂, one_smul, Function.comp_def, id_eq] using |
| 82 | (hβ _ (hinterval hr)).2.scomp t ((hasDerivAt_id t).sub_const (s i)) |
| 83 | let γ : ℝ → E := fun t => if t ≤ s i then γ₁ t else γ₂ t |
| 84 | have hγd := hasDerivWithinAt_glue (hsnonneg i) (hsmono i) |
| 85 | (fun t ht => (hγ₁ t ht).2) |
| 86 | (fun t ht => (hγ₂ t ht).2.hasDerivWithinAt) hjoin |
| 87 | refine ⟨γ, by simpa only [γ, if_pos (hsnonneg i)] using hinit, ?_⟩ |
| 88 | intro t ht |
| 89 | refine ⟨?_, hγd t ht⟩ |
| 90 | by_cases hti : t ≤ s i |
| 91 | · simpa only [γ, if_pos hti] using (hγ₁ t ⟨ht.1, hti⟩).1 |
| 92 | · simpa only [γ, if_neg hti] using (hγ₂ t ⟨le_of_not_ge hti, ht.2⟩).1 |
| 93 | simpa only [hsN] using aux N le_rfl |
| 94 | |
| 95 | end Poincare.ODE |