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.CurveShortening.Ramp.LocalFlow.Uniqueness.SelectedFootpoint |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Operations |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Inverse |
| 4 | import Mathlib.Topology.Order.MonotoneContinuity |
| 5 | |
| 6 | /-! |
| 7 | # The actual periodic normal graph of a nearby C2 curve |
| 8 | |
| 9 | The literal selected footpoint gives a positive C2 label map, its C2 |
| 10 | order inverse and the actual periodic normal graph. MT2007 Claim 19.1, |
| 11 | p. 437; `2026-09-22-uniqueness-normal-graph-isomorphism.md`. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Filter Set |
| 17 | open scoped ContDiff Topology RealInnerProductSpace |
| 18 | |
| 19 | namespace PoincareMT.M63 |
| 20 | |
| 21 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E] |
| 22 | |
| 23 | /-- The actual nearby-curve label has its witnessed normal-constraint |
| 24 | derivative, and that derivative is positive. MT2007 Claim 19.1, p. 437; |
| 25 | normal-graph-isomorphism derivation, statement 1. -/ |
| 26 | theorem selectedCurveLabel_hasDerivAt {r : ℝ → E} (hr : ContDiff ℝ ∞ r) |
| 27 | {m M B rho eps : ℝ} |
| 28 | (hm : 0 < m) (hM : 0 < M) (hB : 0 ≤ B) (hrho : 0 < rho) (heps : 0 < eps) |
| 29 | (hlower : ∀ s, m ≤ ‖deriv r s‖) (hupper : ∀ s, ‖deriv r s‖ ≤ M) |
| 30 | (hsecond : ∀ s, ‖deriv (deriv r) s‖ ≤ B) |
| 31 | (hsmall : 2 * B * (eps + M * rho) ≤ m ^ 2) |
| 32 | (hmargin : 4 * eps * M ≤ m ^ 2 * rho) |
| 33 | {c : ℝ → E} (hc : ContDiff ℝ 2 c) {eta : ℝ} (heta : 0 ≤ eta) |
| 34 | (htrans : 2 * M * (eta + B * rho) ≤ m ^ 2) |
| 35 | (hclose : ∀ x, ‖c x - r x‖ < eps) |
| 36 | (hfirst : ∀ x, ‖deriv c x - deriv r x‖ ≤ eta) (x : ℝ) : |
| 37 | let f : ℝ → ℝ := fun s => selectedCurveFootpoint r rho eps (s, c s) |
| 38 | let y := f x |
| 39 | HasDerivAt f (⟪deriv c x, deriv r y⟫ / |
| 40 | (‖deriv r y‖ ^ 2 - ⟪c x - r y, deriv (deriv r) y⟫)) x ∧ 0 < deriv f x := by |
| 41 | let pi := selectedCurveFootpoint r rho eps |
| 42 | let f : ℝ → ℝ := fun s => pi (s, c s) |
| 43 | let y := f x |
| 44 | let D := ‖deriv r y‖ ^ 2 - ⟪c x - r y, deriv (deriv r) y⟫ |
| 45 | obtain ⟨hpi, hpid⟩ := selectedCurveFootpoint_contDiffAt hr hm hM hB hrho heps |
| 46 | hlower hupper hsecond hsmall hmargin (x, c x) (hclose x) |
| 47 | have hpair : HasDerivAt (fun s => (s, c s)) (1, deriv c x) x := |
| 48 | (hasDerivAt_id x).prodMk (hc.differentiable (by norm_num) x).hasDerivAt |
| 49 | have hdf : HasDerivAt f (⟪deriv c x, deriv r y⟫ / D) x := by |
| 50 | have hd := (hpi.differentiableAt (by simp)).hasFDerivAt.comp_hasDerivAt x hpair |
| 51 | rw [hpid (1, deriv c x)] at hd |
| 52 | exact hd |
| 53 | have hy := (selectedCurveFootpoint_spec hr hm hM hB hrho heps |
| 54 | hlower hupper hsecond hsmall hmargin).1 (x, c x) (hclose x) |
| 55 | have hwindow : y ∈ Icc (x - rho) (x + rho) := by |
| 56 | have habs : |y - x| < rho := hy.1 |
| 57 | exact ⟨by linarith [(abs_lt.mp habs).1], by linarith [(abs_lt.mp habs).2]⟩ |
| 58 | have hD : 0 < D := lt_of_lt_of_le (by positivity) |
| 59 | (curveFootpoint_denominator_lower hr hm hM hB hrho heps hlower hupper |
| 60 | hsecond hsmall (hclose x) hwindow) |
| 61 | have hLip : ‖deriv r y - deriv r x‖ ≤ B * |y - x| := by |
| 62 | simpa only [Real.norm_eq_abs] using |
| 63 | (convex_univ : Convex ℝ (univ : Set ℝ)).norm_image_sub_le_of_norm_deriv_le |
| 64 | (fun s _ => ((contDiff_infty_iff_deriv.mp hr).2.differentiable (by simp) s)) |
| 65 | (fun s _ => hsecond s) (mem_univ x) (mem_univ y) |
| 66 | have hdist : ‖deriv c x - deriv r y‖ ≤ eta + B * rho := calc |
| 67 | _ ≤ ‖deriv c x - deriv r x‖ + ‖deriv r x - deriv r y‖ := by |
| 68 | simpa only [dist_eq_norm] using dist_triangle (deriv c x) (deriv r x) (deriv r y) |
| 69 | _ = ‖deriv c x - deriv r x‖ + ‖deriv r y - deriv r x‖ := by |
| 70 | rw [norm_sub_rev (deriv r x) (deriv r y)] |
| 71 | _ ≤ eta + B * rho := add_le_add (hfirst x) |
| 72 | (hLip.trans (mul_le_mul_of_nonneg_left (show |y - x| ≤ rho from hy.1.le) hB)) |
| 73 | have hinner : |⟪deriv c x - deriv r y, deriv r y⟫| ≤ (eta + B * rho) * M := |
| 74 | (abs_real_inner_le_norm _ _).trans |
| 75 | (mul_le_mul hdist (hupper y) (norm_nonneg _) (by positivity)) |
| 76 | have hsquare : m ^ 2 ≤ ‖deriv r y‖ ^ 2 := by |
| 77 | nlinarith [hlower y, norm_nonneg (deriv r y)] |
| 78 | have hnum : 0 < ⟪deriv c x, deriv r y⟫ := by |
| 79 | have hlo := (abs_le.mp hinner).1 |
| 80 | rw [inner_sub_left, real_inner_self_eq_norm_sq] at hlo |
| 81 | nlinarith [sq_pos_of_pos hm] |
| 82 | exact ⟨hdf, hdf.deriv.symm ▸ div_pos hnum hD⟩ |
| 83 | |
| 84 | /-- The literal normal label is a C2 order isomorphism with positive |
| 85 | C2 inverse, and its inverse constructs the actual periodic normal |
| 86 | graph. MT2007 Claim 19.1, p. 437; normal-graph-isomorphism derivation, |
| 87 | statement 2. No injectivity of either curve image is assumed. -/ |
| 88 | theorem exists_curveNormalGraph_orderIso {r : ℝ → E} (hr : ContDiff ℝ ∞ r) |
| 89 | {m M B rho eps : ℝ} |
| 90 | (hm : 0 < m) (hM : 0 < M) (hB : 0 ≤ B) (hrho : 0 < rho) (heps : 0 < eps) |
| 91 | (hlower : ∀ s, m ≤ ‖deriv r s‖) (hupper : ∀ s, ‖deriv r s‖ ≤ M) |
| 92 | (hsecond : ∀ s, ‖deriv (deriv r) s‖ ≤ B) |
| 93 | (hsmall : 2 * B * (eps + M * rho) ≤ m ^ 2) |
| 94 | (hmargin : 4 * eps * M ≤ m ^ 2 * rho) |
| 95 | {c : ℝ → E} (hc : ContDiff ℝ 2 c) {eta : ℝ} (heta : 0 ≤ eta) |
| 96 | (htrans : 2 * M * (eta + B * rho) ≤ m ^ 2) |
| 97 | (hclose : ∀ x, ‖c x - r x‖ < eps) |
| 98 | (hfirst : ∀ x, ‖deriv c x - deriv r x‖ ≤ eta) |
| 99 | {P : ℝ} (hP : 0 < P) (hrper : Function.Periodic r P) |
| 100 | (hcper : Function.Periodic c P) : |
| 101 | ∃ phi : ℝ ≃o ℝ, |
| 102 | (∀ x, phi x = selectedCurveFootpoint r rho eps (x, c x)) ∧ |
| 103 | ContDiff ℝ 2 (phi : ℝ → ℝ) ∧ ContDiff ℝ 2 (phi.symm : ℝ → ℝ) ∧ |
| 104 | (∀ x, |phi x - x| < rho) ∧ (∀ x, 0 < deriv phi x) ∧ |
| 105 | (∀ y, HasDerivAt phi.symm ((deriv phi (phi.symm y))⁻¹) y ∧ |
| 106 | 0 < deriv phi.symm y) ∧ |
| 107 | (∀ x, phi (x + P) = phi x + P) ∧ |
| 108 | (∀ y, phi.symm (y + P) = phi.symm y + P) ∧ |
| 109 | let U : ℝ → E := fun y => c (phi.symm y) - r y |
| 110 | ContDiff ℝ 2 U ∧ Function.Periodic U P ∧ |
| 111 | (∀ y, ⟪U y, deriv r y⟫ = 0) ∧ ∀ x, c x = r (phi x) + U (phi x) := by |
| 112 | let f : ℝ → ℝ := fun x => selectedCurveFootpoint r rho eps (x, c x) |
| 113 | have hspec := selectedCurveFootpoint_spec hr hm hM hB hrho heps |
| 114 | hlower hupper hsecond hsmall hmargin |
| 115 | have hwindow (x : ℝ) : |f x - x| < rho := (hspec.1 (x, c x) (hclose x)).1 |
| 116 | have hf : ContDiff ℝ 2 f := contDiff_iff_contDiffAt.mpr fun x => by |
| 117 | have hpi := (selectedCurveFootpoint_contDiffAt hr hm hM hB hrho heps |
| 118 | hlower hupper hsecond hsmall hmargin (x, c x) (hclose x)).1 |
| 119 | exact (hpi.of_le (ENat.natCast_le_of_coe_top_le_withTop le_rfl 2)).comp x |
| 120 | (contDiffAt_id.prodMk hc.contDiffAt) |
| 121 | have hd (x : ℝ) : HasDerivAt f (deriv f x) x := |
| 122 | (hf.differentiable (by norm_num) x).hasDerivAt |
| 123 | have hpos (x : ℝ) : 0 < deriv f x := |
| 124 | (selectedCurveLabel_hasDerivAt hr hm hM hB hrho heps hlower hupper hsecond hsmall |
| 125 | hmargin hc heta htrans hclose hfirst x).2 |
| 126 | have hmono : StrictMono f := strictMono_of_hasDerivAt_pos hd hpos |
| 127 | have hsurj : Function.Surjective f := by |
| 128 | intro z |
| 129 | have hl := (abs_lt.mp (hwindow (z - rho - 1))).2 |
| 130 | have hu := (abs_lt.mp (hwindow (z + rho + 1))).1 |
| 131 | obtain ⟨x, _hx, heq⟩ := intermediate_value_Icc |
| 132 | (show z - rho - 1 ≤ z + rho + 1 by linarith) hf.continuous.continuousOn |
| 133 | (show z ∈ Icc (f (z - rho - 1)) (f (z + rho + 1)) from |
| 134 | ⟨by linarith, by linarith⟩) |
| 135 | exact ⟨x, heq⟩ |
| 136 | let phi : ℝ ≃o ℝ := StrictMono.orderIsoOfSurjective f hmono hsurj |
| 137 | have hinvSmooth : ContDiff ℝ 2 (phi.symm : ℝ → ℝ) := |
| 138 | phi.toHomeomorph.contDiff_symm_deriv (fun x => (hpos x).ne') hd hf |
| 139 | have hinv (y : ℝ) : HasDerivAt phi.symm ((deriv phi (phi.symm y))⁻¹) y := |
| 140 | (hd (phi.symm y)).of_local_left_inverse phi.symm.toHomeomorph.continuous.continuousAt |
| 141 | (hpos _).ne' (Eventually.of_forall phi.apply_symm_apply) |
| 142 | have hshift (x : ℝ) : phi (x + P) = phi x + P := by |
| 143 | change selectedCurveFootpoint r rho eps (x + P, c (x + P)) = |
| 144 | selectedCurveFootpoint r rho eps (x, c x) + P |
| 145 | rw [hcper x] |
| 146 | exact hspec.2.2 P hP hrper x (c x) |
| 147 | have hinvShift (y : ℝ) : phi.symm (y + P) = phi.symm y + P := by |
| 148 | apply phi.injective |
| 149 | rw [phi.apply_symm_apply, hshift, phi.apply_symm_apply] |
| 150 | refine ⟨phi, fun _ => rfl, hf, hinvSmooth, hwindow, hpos, ?_, hshift, hinvShift, ?_⟩ |
| 151 | · intro y |
| 152 | exact ⟨hinv y, (hinv y).deriv.symm ▸ inv_pos.mpr (hpos (phi.symm y))⟩ |
| 153 | · refine ⟨(hc.comp hinvSmooth).sub |
| 154 | (hr.of_le (ENat.natCast_le_of_coe_top_le_withTop le_rfl 2)), ?_, ?_, ?_⟩ |
| 155 | · intro y |
| 156 | simp only [hinvShift, hcper (phi.symm y), hrper y] |
| 157 | · intro y |
| 158 | have hroot := (hspec.1 (phi.symm y, c (phi.symm y)) (hclose (phi.symm y))).2 |
| 159 | change ⟪c (phi.symm y) - r (phi (phi.symm y)), deriv r (phi (phi.symm y))⟫ = 0 at hroot |
| 160 | simpa only [phi.apply_symm_apply] using hroot |
| 161 | · intro x |
| 162 | change c x = r (phi x) + (c (phi.symm (phi x)) - r (phi x)) |
| 163 | rw [phi.symm_apply_apply] |
| 164 | abel |
| 165 | |
| 166 | end PoincareMT.M63 |