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 |
| 2 | import PoincareLib.Analysis.ODE.Endpoint |
| 3 | |
| 4 | /-! |
| 5 | # Fixed diagonalization for the three-dimensional reaction |
| 6 | |
| 7 | Coordinate reflections commute with the reaction. Uniqueness therefore |
| 8 | preserves every initially vanishing off-diagonal entry. |
| 9 | |
| 10 | Reference: Morgan--Tian, Lemma 4.13, pp. 68--69. |
| 11 | -/ |
| 12 | |
| 13 | namespace Poincare.HamiltonIvey |
| 14 | |
| 15 | open Set |
| 16 | open scoped BigOperators |
| 17 | |
| 18 | noncomputable section |
| 19 | |
| 20 | abbrev ThreeMatrix := Matrix (Fin 3) (Fin 3) ℝ |
| 21 | |
| 22 | local instance : NormedAddCommGroup ThreeMatrix := Matrix.normedAddCommGroup |
| 23 | local instance : NormedSpace ℝ ThreeMatrix := Matrix.normedSpace |
| 24 | |
| 25 | /-- The sectional-curvature normalization of the operator reaction. -/ |
| 26 | def operatorReaction (A : ThreeMatrix) : ThreeMatrix := |
| 27 | 2 • (A * A + Matrix.adjugate A) |
| 28 | |
| 29 | theorem operatorReaction_eq_trace_polynomial (A : ThreeMatrix) : |
| 30 | operatorReaction A = |
| 31 | (4 : ℝ) • (A * A) - (2 * A.trace) • A + |
| 32 | (A.trace ^ 2 - (A * A).trace) • (1 : ThreeMatrix) := by |
| 33 | ext i j |
| 34 | fin_cases i <;> fin_cases j <;> |
| 35 | simp [operatorReaction, Matrix.adjugate_fin_three, Matrix.mul_apply, |
| 36 | Matrix.trace, Fin.sum_univ_succ] <;> ring |
| 37 | |
| 38 | theorem operatorReaction_diagonal_entries (d : Fin 3 → ℝ) : |
| 39 | operatorReaction (Matrix.diagonal d) = Matrix.diagonal |
| 40 | ![2 * (d 0 ^ 2 + d 1 * d 2), 2 * (d 1 ^ 2 + d 0 * d 2), |
| 41 | 2 * (d 2 ^ 2 + d 0 * d 1)] := by |
| 42 | rw [operatorReaction_eq_trace_polynomial] |
| 43 | ext i j |
| 44 | fin_cases i <;> fin_cases j <;> |
| 45 | simp [Matrix.trace, Fin.sum_univ_succ] <;> ring |
| 46 | |
| 47 | private def reflect (k : Fin 3) (A : ThreeMatrix) : ThreeMatrix := |
| 48 | fun i j => (if i = k then -1 else 1) * A i j * (if j = k then -1 else 1) |
| 49 | |
| 50 | private theorem reflect_reaction (k : Fin 3) (A : ThreeMatrix) : |
| 51 | reflect k (operatorReaction A) = operatorReaction (reflect k A) := by |
| 52 | ext i j |
| 53 | fin_cases k <;> fin_cases i <;> fin_cases j <;> |
| 54 | simp [reflect, operatorReaction, Matrix.adjugate_fin_three, |
| 55 | Matrix.mul_apply, Fin.sum_univ_succ] <;> ring |
| 56 | |
| 57 | private theorem contDiff_operatorReaction : ContDiff ℝ 1 operatorReaction := by |
| 58 | apply contDiff_pi.mpr |
| 59 | intro i |
| 60 | apply contDiff_pi.mpr |
| 61 | intro j |
| 62 | fin_cases i <;> fin_cases j <;> |
| 63 | simp [operatorReaction, Matrix.adjugate_fin_three, Matrix.mul_apply, |
| 64 | Fin.sum_univ_succ] <;> fun_prop |
| 65 | |
| 66 | private theorem reflect_continuous (k : Fin 3) : Continuous (reflect k) := by |
| 67 | unfold reflect |
| 68 | fun_prop |
| 69 | |
| 70 | private theorem reflect_deriv (k : Fin 3) {A : ℝ → ThreeMatrix} {D : ThreeMatrix} |
| 71 | {t : ℝ} (hA : HasDerivAt A D t) : |
| 72 | HasDerivAt (fun s => reflect k (A s)) (reflect k D) t := by |
| 73 | apply hasDerivAt_pi.mpr |
| 74 | intro i |
| 75 | apply hasDerivAt_pi.mpr |
| 76 | intro j |
| 77 | exact ((hasDerivAt_pi.mp (hasDerivAt_pi.mp hA i) j).const_mul _).mul_const _ |
| 78 | |
| 79 | /-- An initially diagonal solution remains diagonal in the same coordinates. -/ |
| 80 | theorem operator_reaction_stays_diagonal |
| 81 | {a b : ℝ} {A : ℝ → ThreeMatrix} |
| 82 | (hA : ContinuousOn A (Icc a b)) |
| 83 | (hd : ∀ t ∈ Ioo a b, HasDerivAt A (operatorReaction (A t)) t) |
| 84 | (hinit : ∀ i j, i ≠ j → A a i j = 0) : |
| 85 | ∀ t ∈ Icc a b, ∀ i j, i ≠ j → A t i j = 0 := by |
| 86 | have hdright := Poincare.hasDerivWithinAt_Ici_of_continuousOn hA |
| 87 | (contDiff_operatorReaction.continuous.comp_continuousOn hA) hd |
| 88 | have hreflect (k : Fin 3) : EqOn (fun t => reflect k (A t)) A (Icc a b) := by |
| 89 | have hRc := (reflect_continuous k).comp_continuousOn hA |
| 90 | have hRd := Poincare.hasDerivWithinAt_Ici_of_continuousOn hRc |
| 91 | (contDiff_operatorReaction.continuous.comp_continuousOn hRc) |
| 92 | (fun t ht => show HasDerivAt (reflect k ∘ A) |
| 93 | (operatorReaction (reflect k (A t))) t from by |
| 94 | simpa only [Function.comp_def, reflect_reaction] using reflect_deriv k (hd t ht)) |
| 95 | let S := A '' Icc a b ∪ (fun t => reflect k (A t)) '' Icc a b |
| 96 | have hS : IsCompact S := |
| 97 | (isCompact_Icc.image_of_continuousOn hA).union |
| 98 | (isCompact_Icc.image_of_continuousOn ((reflect_continuous k).comp_continuousOn hA)) |
| 99 | obtain ⟨K, hK⟩ := LocallyLipschitzOn.exists_lipschitzOnWith_of_compact hS |
| 100 | contDiff_operatorReaction.locallyLipschitz.locallyLipschitzOn |
| 101 | apply ODE_solution_unique_of_mem_Icc_right |
| 102 | (v := fun _ => operatorReaction) (s := fun _ => S) (fun _ _ => hK) |
| 103 | ((reflect_continuous k).comp_continuousOn hA) |
| 104 | hRd (fun t ht => Or.inr ⟨t, Ico_subset_Icc_self ht, rfl⟩) |
| 105 | hA hdright |
| 106 | (fun t ht => Or.inl ⟨t, Ico_subset_Icc_self ht, rfl⟩) |
| 107 | · ext i j |
| 108 | by_cases hij : i = j |
| 109 | · subst j |
| 110 | by_cases hi : i = k <;> simp [reflect, hi] |
| 111 | · simp [reflect, hinit i j hij] |
| 112 | intro t ht i j hij |
| 113 | have h := congrFun (congrFun (hreflect i ht) i) j |
| 114 | simp [reflect, hij.symm] at h |
| 115 | linarith |
| 116 | |
| 117 | end |
| 118 | |
| 119 | end Poincare.HamiltonIvey |