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.Analysis.SpecialFunctions.SmoothTransition |
| 2 | import Mathlib.Analysis.Calculus.MeanValue |
| 3 | import Mathlib.Analysis.Calculus.ContDiff.Operations |
| 4 | import Mathlib.Topology.Order.Compact |
| 5 | |
| 6 | /-! |
| 7 | # Smooth interpolation near a curve join |
| 8 | |
| 9 | Equal positions at the join cancel the inverse transition width in the |
| 10 | derivative estimate. The bound therefore holds uniformly as the width shrinks. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped ContDiff |
| 16 | |
| 17 | namespace PoincareMT.ReducedLength |
| 18 | |
| 19 | noncomputable def smoothJoinCutoff (s : ℝ) : ℝ := |
| 20 | Real.smoothTransition ((s + 1) / 2) |
| 21 | |
| 22 | theorem smoothJoinCutoff_contDiff : ContDiff ℝ ∞ smoothJoinCutoff := |
| 23 | Real.smoothTransition.contDiff.comp ((contDiff_id.add contDiff_const).div_const 2) |
| 24 | |
| 25 | theorem smoothJoinCutoff_mem (s : ℝ) : smoothJoinCutoff s ∈ Set.Icc (0 : ℝ) 1 := |
| 26 | ⟨Real.smoothTransition.nonneg _, Real.smoothTransition.le_one _⟩ |
| 27 | |
| 28 | theorem smoothJoinCutoff_zero {s : ℝ} (hs : s ≤ -1) : smoothJoinCutoff s = 0 := |
| 29 | Real.smoothTransition.zero_of_nonpos (by linarith) |
| 30 | |
| 31 | theorem smoothJoinCutoff_one {s : ℝ} (hs : 1 ≤ s) : smoothJoinCutoff s = 1 := |
| 32 | Real.smoothTransition.one_of_one_le (by linarith) |
| 33 | |
| 34 | theorem smoothJoinCutoff_hasDerivAt (c d s : ℝ) : |
| 35 | HasDerivAt (fun t ↦ smoothJoinCutoff ((t - c) / d)) |
| 36 | (deriv smoothJoinCutoff ((s - c) / d) / d) s := by |
| 37 | have h : HasDerivAt smoothJoinCutoff (deriv smoothJoinCutoff ((s - c) / d)) |
| 38 | ((s - c) / d) := (smoothJoinCutoff_contDiff.differentiable (by simp)).differentiableAt.hasDerivAt |
| 39 | simpa only [Function.comp_def, id_eq, one_div, div_eq_mul_inv, one_mul] using |
| 40 | h.comp s (((hasDerivAt_id s).sub_const c).div_const d) |
| 41 | |
| 42 | theorem exists_smoothJoinCutoff_deriv_bound : |
| 43 | ∃ C : ℝ, 0 ≤ C ∧ ∀ s ∈ Set.Icc (-1 : ℝ) 1, ‖deriv smoothJoinCutoff s‖ ≤ C := by |
| 44 | obtain ⟨C, hC⟩ := isCompact_Icc.exists_bound_of_continuousOn |
| 45 | (smoothJoinCutoff_contDiff.continuous_deriv (by simp)).continuousOn |
| 46 | exact ⟨max C 0, le_max_right _ _, fun s hs ↦ (hC s hs).trans (le_max_left _ _)⟩ |
| 47 | |
| 48 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 49 | |
| 50 | noncomputable def smoothJoinBlend (f g : ℝ → E) (c d s : ℝ) : E := |
| 51 | f s + smoothJoinCutoff ((s - c) / d) • (g s - f s) |
| 52 | |
| 53 | theorem smoothJoinBlend_eq_left (f g : ℝ → E) (c : ℝ) {d s : ℝ} |
| 54 | (hd : 0 < d) (hs : s ≤ c - d) : smoothJoinBlend f g c d s = f s := by |
| 55 | have h : (s - c) / d ≤ -1 := (div_le_iff₀ hd).mpr (by linarith) |
| 56 | simp only [smoothJoinBlend, smoothJoinCutoff_zero h, zero_smul, add_zero] |
| 57 | |
| 58 | theorem smoothJoinBlend_eq_right (f g : ℝ → E) (c : ℝ) {d s : ℝ} |
| 59 | (hd : 0 < d) (hs : c + d ≤ s) : smoothJoinBlend f g c d s = g s := by |
| 60 | have h : 1 ≤ (s - c) / d := (le_div_iff₀ hd).mpr (by linarith) |
| 61 | simp only [smoothJoinBlend, smoothJoinCutoff_one h, one_smul, add_sub_cancel] |
| 62 | |
| 63 | theorem smoothJoinBlend_mem_convex (f g : ℝ → E) (c d s : ℝ) |
| 64 | (K : Set E) (hK : Convex ℝ K) (hf : f s ∈ K) (hg : g s ∈ K) : |
| 65 | smoothJoinBlend f g c d s ∈ K := by |
| 66 | apply hK.add_smul_mem hf (by simpa only [add_sub_cancel] using hg) |
| 67 | exact smoothJoinCutoff_mem _ |
| 68 | |
| 69 | theorem smoothJoinBlend_contDiffOn (f g : ℝ → E) (c d : ℝ) (U : Set ℝ) |
| 70 | (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g U) : |
| 71 | ContDiffOn ℝ ∞ (smoothJoinBlend f g c d) U := |
| 72 | hf.add ((smoothJoinCutoff_contDiff.comp |
| 73 | ((contDiff_id.sub contDiff_const).div_const d)).contDiffOn.smul (hg.sub hf)) |
| 74 | |
| 75 | theorem smoothJoinBlend_hasDerivAt (f g : ℝ → E) (c d s : ℝ) |
| 76 | (hf : DifferentiableAt ℝ f s) (hg : DifferentiableAt ℝ g s) : |
| 77 | HasDerivAt (smoothJoinBlend f g c d) |
| 78 | (deriv f s + (deriv smoothJoinCutoff ((s - c) / d) / d) • (g s - f s) + |
| 79 | smoothJoinCutoff ((s - c) / d) • (deriv g s - deriv f s)) s := by |
| 80 | convert! hf.hasDerivAt.add ((smoothJoinCutoff_hasDerivAt c d s).smul |
| 81 | (hg.hasDerivAt.sub hf.hasDerivAt)) using 1 <;> |
| 82 | simp only [smoothJoinBlend, Pi.sub_apply, add_assoc, add_comm, add_left_comm] |
| 83 | |
| 84 | theorem exists_smoothJoinBlend_uniform_deriv_bound (f g : ℝ → E) |
| 85 | (U : Set ℝ) (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g U) |
| 86 | (c r : ℝ) (hr : 0 < r) (hI : Set.Icc (c - r) (c + r) ⊆ U) (heq : f c = g c) : |
| 87 | ∃ C : ℝ, 0 ≤ C ∧ ∀ d, 0 < d → d ≤ r → ∀ s ∈ Set.Icc (c - d) (c + d), |
| 88 | ‖deriv (smoothJoinBlend f g c d) s‖ ≤ C := by |
| 89 | obtain ⟨Cf, hCf⟩ := isCompact_Icc.exists_bound_of_continuousOn |
| 90 | (((hf.deriv_of_isOpen hU (m := ∞) (by simp)).continuousOn).mono hI) |
| 91 | obtain ⟨Cg, hCg⟩ := isCompact_Icc.exists_bound_of_continuousOn |
| 92 | (((hg.deriv_of_isOpen hU (m := ∞) (by simp)).continuousOn).mono hI) |
| 93 | let C := max (max Cf Cg) 0 |
| 94 | have hC : 0 ≤ C := le_max_right _ _ |
| 95 | have hfC (s : ℝ) (hs : s ∈ Set.Icc (c - r) (c + r)) : ‖deriv f s‖ ≤ C := |
| 96 | (hCf s hs).trans ((le_max_left _ _).trans (le_max_left _ _)) |
| 97 | have hgC (s : ℝ) (hs : s ∈ Set.Icc (c - r) (c + r)) : ‖deriv g s‖ ≤ C := |
| 98 | (hCg s hs).trans ((le_max_right _ _).trans (le_max_left _ _)) |
| 99 | have hfd (s : ℝ) (hs : s ∈ Set.Icc (c - r) (c + r)) : DifferentiableAt ℝ f s := |
| 100 | (hf.contDiffAt (hU.mem_nhds (hI hs))).differentiableAt (by simp) |
| 101 | have hgd (s : ℝ) (hs : s ∈ Set.Icc (c - r) (c + r)) : DifferentiableAt ℝ g s := |
| 102 | (hg.contDiffAt (hU.mem_nhds (hI hs))).differentiableAt (by simp) |
| 103 | obtain ⟨K, hK, hKb⟩ := exists_smoothJoinCutoff_deriv_bound |
| 104 | refine ⟨3 * C + K * (2 * C), by positivity, ?_⟩ |
| 105 | intro d hd hdr s hs |
| 106 | have hsI : s ∈ Set.Icc (c - r) (c + r) := ⟨by linarith [hs.1], by linarith [hs.2]⟩ |
| 107 | have hcI : c ∈ Set.Icc (c - r) (c + r) := ⟨by linarith, by linarith⟩ |
| 108 | have habs : ‖s - c‖ ≤ d := by rw [Real.norm_eq_abs, abs_le]; constructor <;> linarith [hs.1, hs.2] |
| 109 | have hcoord : (s - c) / d ∈ Set.Icc (-1 : ℝ) 1 := |
| 110 | ⟨(le_div_iff₀ hd).mpr (by linarith [hs.1]), |
| 111 | (div_le_iff₀ hd).mpr (by linarith [hs.2])⟩ |
| 112 | have hfg : ‖g s - f s‖ ≤ 2 * C * d := by |
| 113 | have hfL := (convex_Icc (c - r) (c + r)).norm_image_sub_le_of_norm_deriv_le |
| 114 | hfd hfC hcI hsI |
| 115 | have hgL := (convex_Icc (c - r) (c + r)).norm_image_sub_le_of_norm_deriv_le |
| 116 | hgd hgC hcI hsI |
| 117 | have he : g s - f s = (g s - g c) - (f s - f c) := by rw [heq]; abel |
| 118 | rw [he] |
| 119 | exact (norm_sub_le _ _).trans (by nlinarith [hfL, hgL, mul_le_mul_of_nonneg_left habs hC]) |
| 120 | have hchi : ‖smoothJoinCutoff ((s - c) / d)‖ ≤ 1 := by |
| 121 | rw [Real.norm_eq_abs, abs_of_nonneg (smoothJoinCutoff_mem _).1] |
| 122 | exact (smoothJoinCutoff_mem _).2 |
| 123 | have hKD : ‖deriv smoothJoinCutoff ((s - c) / d) / d‖ ≤ K / d := by |
| 124 | rw [norm_div, Real.norm_of_nonneg hd.le] |
| 125 | exact div_le_div_of_nonneg_right (hKb _ hcoord) hd.le |
| 126 | have hterm : ‖(deriv smoothJoinCutoff ((s - c) / d) / d) • (g s - f s)‖ ≤ K * (2 * C) := by |
| 127 | rw [norm_smul] |
| 128 | calc |
| 129 | _ ≤ (K / d) * (2 * C * d) := mul_le_mul hKD hfg (norm_nonneg _) (div_nonneg hK hd.le) |
| 130 | _ = K * (2 * C) := by field_simp [hd.ne'] |
| 131 | have hlast : ‖smoothJoinCutoff ((s - c) / d) • (deriv g s - deriv f s)‖ ≤ 2 * C := by |
| 132 | rw [norm_smul] |
| 133 | calc |
| 134 | _ ≤ 1 * (‖deriv g s‖ + ‖deriv f s‖) := |
| 135 | mul_le_mul hchi (norm_sub_le _ _) (norm_nonneg _) zero_le_one |
| 136 | _ ≤ 2 * C := by linarith [hfC s hsI, hgC s hsI] |
| 137 | rw [(smoothJoinBlend_hasDerivAt f g c d s (hfd s hsI) (hgd s hsI)).deriv] |
| 138 | exact (norm_add_le _ _).trans (by |
| 139 | have hsum := norm_add_le (deriv f s) |
| 140 | ((deriv smoothJoinCutoff ((s - c) / d) / d) • (g s - f s)) |
| 141 | linarith [hfC s hsI, hterm, hlast]) |
| 142 | |
| 143 | end PoincareMT.ReducedLength |