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.FootpointQuantitative |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Shift |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Mul |
| 4 | |
| 5 | /-! |
| 6 | # The selected normal footpoint |
| 7 | |
| 8 | Quantitative uniqueness identifies the literal selected root with a smooth |
| 9 | implicit-function germ at every admissible point-label pair. MT2007 |
| 10 | Claim 19.1, p. 437; `2026-09-22-uniqueness-selected-footpoint.md`. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Filter Set |
| 16 | open scoped ContDiff Topology RealInnerProductSpace |
| 17 | |
| 18 | namespace PoincareMT.M63 |
| 19 | |
| 20 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] |
| 21 | |
| 22 | /-- Choose a normal root in the strict label window when the point is |
| 23 | close to its anchor; otherwise return the anchor. MT2007 Claim 19.1, |
| 24 | p. 437; selected-footpoint derivation, definition 1. -/ |
| 25 | noncomputable def selectedCurveFootpoint (r : ℝ → E) (rho eps : ℝ) |
| 26 | (p : ℝ × E) : ℝ := by |
| 27 | classical |
| 28 | exact if h : ‖p.2 - r p.1‖ < eps ∧ |
| 29 | ∃ y, |y - p.1| < rho ∧ curveFootpointResidual r (p.2, y) = 0 |
| 30 | then Classical.choose h.2 else p.1 |
| 31 | |
| 32 | /-- The selected footpoint solves the actual normal constraint, fixes |
| 33 | reference labels and respects every positive reference period globally. |
| 34 | MT2007 Claim 19.1, p. 437; selected-footpoint derivation, statement 2. -/ |
| 35 | theorem selectedCurveFootpoint_spec {r : ℝ → E} (hr : ContDiff ℝ ∞ r) |
| 36 | {m M B rho eps : ℝ} |
| 37 | (hm : 0 < m) (hM : 0 < M) (hB : 0 ≤ B) (hrho : 0 < rho) (heps : 0 < eps) |
| 38 | (hlower : ∀ s, m ≤ ‖deriv r s‖) (hupper : ∀ s, ‖deriv r s‖ ≤ M) |
| 39 | (hsecond : ∀ s, ‖deriv (deriv r) s‖ ≤ B) |
| 40 | (hsmall : 2 * B * (eps + M * rho) ≤ m ^ 2) |
| 41 | (hmargin : 4 * eps * M ≤ m ^ 2 * rho) : |
| 42 | (∀ p : ℝ × E, ‖p.2 - r p.1‖ < eps → |
| 43 | |selectedCurveFootpoint r rho eps p - p.1| < rho ∧ |
| 44 | curveFootpointResidual r (p.2, selectedCurveFootpoint r rho eps p) = 0) ∧ |
| 45 | (∀ x, selectedCurveFootpoint r rho eps (x, r x) = x) ∧ |
| 46 | (∀ P : ℝ, 0 < P → Function.Periodic r P → ∀ x z, |
| 47 | selectedCurveFootpoint r rho eps (x + P, z) = |
| 48 | selectedCurveFootpoint r rho eps (x, z) + P) := by |
| 49 | classical |
| 50 | have hroot (p : ℝ × E) (hp : ‖p.2 - r p.1‖ < eps) : |
| 51 | |selectedCurveFootpoint r rho eps p - p.1| < rho ∧ |
| 52 | curveFootpointResidual r (p.2, selectedCurveFootpoint r rho eps p) = 0 := by |
| 53 | have hunique := existsUnique_curveFootpoint_near hr hm hM hB hrho heps |
| 54 | hlower hupper hsecond hsmall hmargin hp |
| 55 | have hex := hunique.exists |
| 56 | rw [selectedCurveFootpoint, dif_pos ⟨hp, hex⟩] |
| 57 | exact Classical.choose_spec hex |
| 58 | refine ⟨hroot, ?_, ?_⟩ |
| 59 | · intro x |
| 60 | have hp : ‖r x - r x‖ < eps := by simpa using heps |
| 61 | have hunique := existsUnique_curveFootpoint_near hr hm hM hB hrho heps |
| 62 | hlower hupper hsecond hsmall hmargin hp |
| 63 | exact hunique.unique (hroot (x, r x) hp) |
| 64 | ⟨by simpa using hrho, by simp [curveFootpointResidual]⟩ |
| 65 | · intro P _hP hperiod x z |
| 66 | have hderiv_period (y : ℝ) : deriv r (y + P) = deriv r y := by |
| 67 | have hshift := ((hr.differentiable (by simp) (y + P)).hasDerivAt).comp_add_const y P |
| 68 | have hshift' : HasDerivAt r (deriv r (y + P)) y := by |
| 69 | exact hshift.congr_of_eventuallyEq (Eventually.of_forall fun s => (hperiod s).symm) |
| 70 | exact hshift'.unique (hr.differentiable (by simp) y).hasDerivAt |
| 71 | have hresidual (y : ℝ) : |
| 72 | curveFootpointResidual r (z, y + P) = curveFootpointResidual r (z, y) := by |
| 73 | simp only [curveFootpointResidual, hperiod y, hderiv_period] |
| 74 | by_cases hp : ‖z - r x‖ < eps |
| 75 | · have htranslated : ‖z - r (x + P)‖ < eps := by simpa only [hperiod x] using hp |
| 76 | have hunique := existsUnique_curveFootpoint_near hr hm hM hB hrho heps |
| 77 | hlower hupper hsecond hsmall hmargin htranslated |
| 78 | apply hunique.unique (hroot (x + P, z) htranslated) |
| 79 | refine ⟨?_, ?_⟩ |
| 80 | · simpa only [add_sub_add_right_eq_sub] using (hroot (x, z) hp).1 |
| 81 | · rw [hresidual] |
| 82 | exact (hroot (x, z) hp).2 |
| 83 | · have htranslated : ¬‖z - r (x + P)‖ < eps := by simpa only [hperiod x] using hp |
| 84 | simp only [selectedCurveFootpoint, hp, htranslated, false_and, dite_false] |
| 85 | |
| 86 | /-- At every admissible point-label pair the literal selected footpoint |
| 87 | is smooth and its derivative is the actual normal-constraint quotient. |
| 88 | MT2007 Claim 19.1, p. 437; selected-footpoint derivation, statement 3. |
| 89 | The denominator is derived positive from the quantitative guards. -/ |
| 90 | theorem selectedCurveFootpoint_contDiffAt [CompleteSpace E] |
| 91 | {r : ℝ → E} (hr : ContDiff ℝ ∞ r) {m M B rho eps : ℝ} |
| 92 | (hm : 0 < m) (hM : 0 < M) (hB : 0 ≤ B) (hrho : 0 < rho) (heps : 0 < eps) |
| 93 | (hlower : ∀ s, m ≤ ‖deriv r s‖) (hupper : ∀ s, ‖deriv r s‖ ≤ M) |
| 94 | (hsecond : ∀ s, ‖deriv (deriv r) s‖ ≤ B) |
| 95 | (hsmall : 2 * B * (eps + M * rho) ≤ m ^ 2) |
| 96 | (hmargin : 4 * eps * M ≤ m ^ 2 * rho) |
| 97 | (p : ℝ × E) (hp : ‖p.2 - r p.1‖ < eps) : |
| 98 | ContDiffAt ℝ ∞ (selectedCurveFootpoint r rho eps) p ∧ |
| 99 | ∀ v : ℝ × E, fderiv ℝ (selectedCurveFootpoint r rho eps) p v = |
| 100 | ⟪v.2, deriv r (selectedCurveFootpoint r rho eps p)⟫ / |
| 101 | (‖deriv r (selectedCurveFootpoint r rho eps p)‖ ^ 2 - |
| 102 | ⟪p.2 - r (selectedCurveFootpoint r rho eps p), |
| 103 | deriv (deriv r) (selectedCurveFootpoint r rho eps p)⟫) := by |
| 104 | let pi := selectedCurveFootpoint r rho eps |
| 105 | let y := pi p |
| 106 | let D := ‖deriv r y‖ ^ 2 - ⟪p.2 - r y, deriv (deriv r) y⟫ |
| 107 | have hspec := (selectedCurveFootpoint_spec hr hm hM hB hrho heps |
| 108 | hlower hupper hsecond hsmall hmargin).1 |
| 109 | have hy := hspec p hp |
| 110 | have hwindow : y ∈ Icc (p.1 - rho) (p.1 + rho) := by |
| 111 | have habs := abs_lt.mp hy.1 |
| 112 | exact ⟨by dsimp [y, pi]; linarith [habs.1], by dsimp [y, pi]; linarith [habs.2]⟩ |
| 113 | have hDlower : m ^ 2 / 2 ≤ D := curveFootpoint_denominator_lower hr hm hM hB |
| 114 | hrho heps hlower hupper hsecond hsmall hp hwindow |
| 115 | have hD : 0 < D := lt_of_lt_of_le (by positivity) hDlower |
| 116 | have hH := (curveFootpointResidual_contDiff hr).contDiffAt (x := (p.2, y)) |
| 117 | have hc : -D ≠ 0 := neg_ne_zero.mpr hD.ne' |
| 118 | have hinv : ((fderiv ℝ (curveFootpointResidual r) (p.2, y)).comp |
| 119 | (ContinuousLinearMap.inr ℝ E ℝ)).IsInvertible := by |
| 120 | rw [curveFootpointResidual_partial_at hr] |
| 121 | have hscalar : -‖deriv r y‖ ^ 2 + ⟪p.2 - r y, deriv (deriv r) y⟫ = -D := by |
| 122 | dsimp [D] |
| 123 | ring |
| 124 | rw [hscalar] |
| 125 | apply ContinuousLinearMap.IsInvertible.of_inverse |
| 126 | (g := (-D)⁻¹ • ContinuousLinearMap.id ℝ ℝ) |
| 127 | · apply ContinuousLinearMap.ext |
| 128 | intro s |
| 129 | simp only [ContinuousLinearMap.comp_apply, smul_apply, |
| 130 | ContinuousLinearMap.id_apply, smul_smul, mul_inv_cancel₀ hc, one_smul] |
| 131 | · apply ContinuousLinearMap.ext |
| 132 | intro s |
| 133 | simp only [ContinuousLinearMap.comp_apply, smul_apply, |
| 134 | ContinuousLinearMap.id_apply, smul_smul, inv_mul_cancel₀ hc, one_smul] |
| 135 | let q := hH.implicitFunction (by simp) hinv |
| 136 | have hqcenter : q p.2 = y := hH.implicitFunction_apply_self (by simp) hinv |
| 137 | have hqsmooth : ContDiffAt ℝ ∞ q p.2 := hH.contDiffAt_implicitFunction (by simp) hinv |
| 138 | have hH0 : curveFootpointResidual r (p.2, y) = 0 := hy.2 |
| 139 | have hqzero : ∀ᶠ z in 𝓝 p.2, curveFootpointResidual r (z, q z) = 0 := by |
| 140 | simpa only [hH0] using hH.eventually_apply_implicitFunction (by simp) hinv |
| 141 | have hdom : ∀ᶠ p' : ℝ × E in 𝓝 p, ‖p'.2 - r p'.1‖ < eps := |
| 142 | (continuousAt_snd.sub (hr.continuous.continuousAt.comp continuousAt_fst)).norm.eventually_lt |
| 143 | continuousAt_const hp |
| 144 | have hqwindow : ∀ᶠ p' : ℝ × E in 𝓝 p, |q p'.2 - p'.1| < rho := |
| 145 | ((hqsmooth.continuousAt.comp continuousAt_snd).sub continuousAt_fst).abs.eventually_lt |
| 146 | continuousAt_const (by change |q p.2 - p.1| < rho; rw [hqcenter]; exact hy.1) |
| 147 | have hagree : pi =ᶠ[𝓝 p] fun p' => q p'.2 := by |
| 148 | filter_upwards [hdom, hqwindow, continuousAt_snd.eventually hqzero] with p' hp' hw hz |
| 149 | exact (existsUnique_curveFootpoint_near hr hm hM hB hrho heps hlower hupper |
| 150 | hsecond hsmall hmargin hp').unique (hspec p' hp') ⟨hw, hz⟩ |
| 151 | have hpis : ContDiffAt ℝ ∞ pi p := |
| 152 | (hqsmooth.comp p contDiffAt_snd).congr_of_eventuallyEq hagree |
| 153 | refine ⟨hpis, ?_⟩ |
| 154 | intro v |
| 155 | let l : ℝ → ℝ × E := fun s => p + s • v |
| 156 | let d := fderiv ℝ pi p v |
| 157 | have hl : HasDerivAt l v 0 := by |
| 158 | simpa only [l, id_eq, one_smul] using ((hasDerivAt_id (0 : ℝ)).smul_const v).const_add p |
| 159 | have hpi_line : HasDerivAt (fun s => pi (l s)) d 0 := by |
| 160 | have hf := (hpis.differentiableAt (by simp)).hasFDerivAt |
| 161 | have hf' : HasFDerivAt pi (fderiv ℝ pi p) (l 0) := by |
| 162 | simpa only [l, zero_smul, add_zero] using hf |
| 163 | exact hf'.comp_hasDerivAt 0 hl |
| 164 | have hz_line : HasDerivAt (fun s => (l s).2) v.2 0 := by |
| 165 | change HasDerivAt (fun s => p.2 + s • v.2) v.2 0 |
| 166 | simpa only [id_eq, one_smul] using ((hasDerivAt_id (0 : ℝ)).smul_const v.2).const_add p.2 |
| 167 | have hr₁ := (contDiff_infty_iff_deriv.mp hr).1 |
| 168 | have hr₂ := (contDiff_infty_iff_deriv.mp (contDiff_infty_iff_deriv.mp hr).2).1 |
| 169 | have hr_line : HasDerivAt (fun s => r (pi (l s))) (d • deriv r y) 0 := by |
| 170 | have hf : HasDerivAt r (deriv r y) (pi (l 0)) := by |
| 171 | simpa only [l, zero_smul, add_zero] using (hr₁ y).hasDerivAt |
| 172 | exact hf.scomp (𝕜 := ℝ) 0 hpi_line |
| 173 | have hr₂_line : HasDerivAt (fun s => deriv r (pi (l s))) (d • deriv (deriv r) y) 0 := by |
| 174 | have hf : HasDerivAt (deriv r) (deriv (deriv r) y) (pi (l 0)) := by |
| 175 | simpa only [l, zero_smul, add_zero] using (hr₂ y).hasDerivAt |
| 176 | exact hf.scomp (𝕜 := ℝ) 0 hpi_line |
| 177 | have hres : HasDerivAt (fun s => curveFootpointResidual r ((l s).2, pi (l s))) |
| 178 | (⟪v.2 - d • deriv r y, deriv r y⟫ + |
| 179 | ⟪p.2 - r y, d • deriv (deriv r) y⟫) 0 := by |
| 180 | simpa only [curveFootpointResidual, Pi.sub_apply, l, zero_smul, add_zero, add_comm] using |
| 181 | (hz_line.sub hr_line).inner ℝ hr₂_line |
| 182 | have hldom : ∀ᶠ s in 𝓝 (0 : ℝ), ‖(l s).2 - r (l s).1‖ < eps := by |
| 183 | have hlim : Tendsto l (𝓝 0) (𝓝 p) := by |
| 184 | have hcenter : l 0 = p := by simp only [l, zero_smul, add_zero] |
| 185 | exact hcenter ▸ hl.continuousAt.tendsto |
| 186 | exact hlim.eventually hdom |
| 187 | have hzero : (fun s => curveFootpointResidual r ((l s).2, pi (l s))) =ᶠ[𝓝 0] |
| 188 | fun _ => (0 : ℝ) := by |
| 189 | filter_upwards [hldom] with s hs |
| 190 | exact (hspec (l s) hs).2 |
| 191 | have heq := hres.unique ((hasDerivAt_const (0 : ℝ) (0 : ℝ)).congr_of_eventuallyEq hzero) |
| 192 | have halgebra : ⟪v.2 - d • deriv r y, deriv r y⟫ + |
| 193 | ⟪p.2 - r y, d • deriv (deriv r) y⟫ = ⟪v.2, deriv r y⟫ - d * D := by |
| 194 | dsimp [D] |
| 195 | simp only [inner_sub_left, real_inner_smul_left, real_inner_smul_right, |
| 196 | real_inner_self_eq_norm_sq] |
| 197 | ring |
| 198 | change d = ⟪v.2, deriv r y⟫ / D |
| 199 | apply (eq_div_iff hD.ne').2 |
| 200 | rw [halgebra] at heq |
| 201 | linarith |
| 202 | |
| 203 | end PoincareMT.M63 |