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.RicciFlow.Surgery.Induction.Noncollapse.Assembly.FiniteEventInduction |
| 2 | import Mathlib.Analysis.Calculus.Deriv.MeanValue |
| 3 | |
| 4 | /-! |
| 5 | # Scalar comparison with finitely many retained event times |
| 6 | |
| 7 | Morgan--Tian Lemma 11.2, pp. 268-269, used on p. 393. |
| 8 | An ordinary derivative bound integrates across finitely many exceptional |
| 9 | times when the actual scalar is continuous there. The fixed global |
| 10 | clock prevents the scalar ceiling from being reset at each surgery. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped Topology |
| 17 | |
| 18 | namespace PoincareMT.Proofs.M46 |
| 19 | |
| 20 | /-- The actual scalar increment bound is unaffected by finitely many |
| 21 | retained surgery times where only continuity is used, p. 393. -/ |
| 22 | theorem image_sub_le_mul_sub_of_finite_deriv_exceptions |
| 23 | {f f' : ℝ → ℝ} {a b C : ℝ} {events : Set ℝ} |
| 24 | (hab : a ≤ b) (hfinite : (events ∩ Ioc a b).Finite) |
| 25 | (hcont : ContinuousOn f (Icc a b)) |
| 26 | (hderiv : ∀ t ∈ Ioo a b, t ∉ events → HasDerivAt f (f' t) t) |
| 27 | (hbound : ∀ t ∈ Ioo a b, t ∉ events → f' t ≤ C) : |
| 28 | f b - f a ≤ C * (b - a) := by |
| 29 | let Q (t : ℝ) : Prop := f t - f a ≤ C * (t - a) |
| 30 | apply finite_event_forward_induction hab hfinite Q |
| 31 | (by simp only [Q, sub_self, mul_zero, le_refl]) |
| 32 | · intro s hs t ht hst hfree hQs |
| 33 | have hinternal (z : ℝ) (hz : z ∈ Ioo s t) : z ∈ Ioo a b := |
| 34 | ⟨hs.1.trans_lt hz.1, hz.2.trans_le ht.2⟩ |
| 35 | have hnot (z : ℝ) (hz : z ∈ Ioo s t) : z ∉ events := |
| 36 | fun he => Set.disjoint_left.mp hfree he ⟨hz.1, hz.2.le⟩ |
| 37 | have hdiff : DifferentiableOn ℝ f (interior (Icc s t)) := by |
| 38 | rw [interior_Icc] |
| 39 | intro z hz |
| 40 | exact (hderiv z (hinternal z hz) (hnot z hz)).differentiableAt.differentiableWithinAt |
| 41 | have hrate : ∀ z ∈ interior (Icc s t), deriv f z ≤ C := by |
| 42 | rw [interior_Icc] |
| 43 | intro z hz |
| 44 | rw [(hderiv z (hinternal z hz) (hnot z hz)).deriv] |
| 45 | exact hbound z (hinternal z hz) (hnot z hz) |
| 46 | have hinc := (convex_Icc s t).image_sub_le_mul_sub_of_deriv_le |
| 47 | (hcont.mono (Icc_subset_Icc hs.1 ht.2)) hdiff hrate |
| 48 | s ⟨le_rfl, hst⟩ t ⟨hst, le_rfl⟩ hst |
| 49 | dsimp only [Q] at hQs ⊢ |
| 50 | nlinarith |
| 51 | · intro t ht hbefore |
| 52 | have hleft : ContinuousWithinAt f (Iio t) t := by |
| 53 | apply (hcont t ⟨ht.2.1.le, ht.2.2⟩).mono_of_mem_nhdsWithin |
| 54 | exact Filter.mem_of_superset (Ico_mem_nhdsLT ht.2.1) |
| 55 | (fun s hs => ⟨hs.1, hs.2.le.trans ht.2.2⟩) |
| 56 | have hclock : Tendsto (fun s : ℝ => C * (s - a)) (𝓝[<] t) (𝓝 (C * (t - a))) := by |
| 57 | have hc : Continuous (fun s : ℝ => C * (s - a)) := by fun_prop |
| 58 | exact hc.continuousAt.mono_left nhdsWithin_le_nhds |
| 59 | apply le_of_tendsto_of_tendsto (hleft.sub_const (f a)) hclock |
| 60 | filter_upwards [Ico_mem_nhdsLT ht.2.1] with s hs |
| 61 | exact hbefore s hs |
| 62 | |
| 63 | /-- One threshold-band comparison bounds the whole backward line, |
| 64 | independently of the number of retained surgeries, pp. 392-393. |
| 65 | Only the derivative above the canonical threshold is bounded. -/ |
| 66 | theorem scalar_le_four_inv_sq_of_finite_events |
| 67 | {f f' : ℝ → ℝ} {duration B r : ℝ} {events : Set ℝ} |
| 68 | (hB : 0 < B) (hr : 0 < r) |
| 69 | (hfinite : (events ∩ Ioc 0 duration).Finite) |
| 70 | (hcont : ContinuousOn f (Icc 0 duration)) |
| 71 | (hderiv : ∀ t ∈ Ioo 0 duration, t ∉ events → HasDerivAt f (f' t) t) |
| 72 | (hinitial : f 0 ≤ 2 * r⁻¹ ^ 2) |
| 73 | (hrate : ∀ t ∈ Ioo 0 duration, t ∉ events → |
| 74 | r⁻¹ ^ 2 ≤ f t → f' t ≤ B * f t ^ 2) |
| 75 | (hshort : 64 * B * r⁻¹ ^ 2 * duration ≤ 1) : |
| 76 | ∀ t ∈ Icc 0 duration, f t ≤ 4 * r⁻¹ ^ 2 := by |
| 77 | intro t ht |
| 78 | by_contra hbad |
| 79 | have hhigh : 4 * r⁻¹ ^ 2 < f t := lt_of_not_ge hbad |
| 80 | have hq : 0 < r⁻¹ ^ 2 := sq_pos_of_pos (inv_pos.mpr hr) |
| 81 | have hct : ContinuousOn f (Icc 0 t) := hcont.mono (Icc_subset_Icc_right ht.2) |
| 82 | have hupperClosed : IsClosed (Icc (0 : ℝ) t ∩ f ⁻¹' Ici (4 * r⁻¹ ^ 2)) := |
| 83 | hct.preimage_isClosed_of_isClosed isClosed_Icc isClosed_Ici |
| 84 | obtain ⟨b, hb, hfirst⟩ := |
| 85 | (isCompact_Icc.of_isClosed_subset hupperClosed inter_subset_left).exists_isLeast |
| 86 | ⟨t, ⟨⟨ht.1, le_rfl⟩, hhigh.le⟩⟩ |
| 87 | have hbpos : 0 < b := by |
| 88 | apply lt_of_le_of_ne hb.1.1 |
| 89 | intro heq |
| 90 | have h : 4 * r⁻¹ ^ 2 ≤ f b := hb.2 |
| 91 | rw [← heq] at h |
| 92 | linarith |
| 93 | have hbvalue : f b = 4 * r⁻¹ ^ 2 := by |
| 94 | obtain ⟨s, hs, hfs⟩ := intermediate_value_Icc hbpos.le |
| 95 | (hct.mono (Icc_subset_Icc_right hb.1.2)) |
| 96 | ⟨hinitial.trans (by linarith), hb.2⟩ |
| 97 | have hbs : b ≤ s := hfirst ⟨⟨hs.1, hs.2.trans hb.1.2⟩, hfs.ge⟩ |
| 98 | simpa only [le_antisymm hbs hs.2] using hfs |
| 99 | have hlowerClosed : IsClosed (Icc (0 : ℝ) b ∩ f ⁻¹' Iic (2 * r⁻¹ ^ 2)) := |
| 100 | (hct.mono (Icc_subset_Icc_right hb.1.2)).preimage_isClosed_of_isClosed |
| 101 | isClosed_Icc isClosed_Iic |
| 102 | obtain ⟨a, ha, hlast⟩ := |
| 103 | (isCompact_Icc.of_isClosed_subset hlowerClosed inter_subset_left).exists_isGreatest |
| 104 | ⟨0, ⟨⟨le_rfl, hbpos.le⟩, hinitial⟩⟩ |
| 105 | have hab : a < b := by |
| 106 | apply lt_of_le_of_ne ha.1.2 |
| 107 | intro heq |
| 108 | have h : f a ≤ 2 * r⁻¹ ^ 2 := ha.2 |
| 109 | rw [heq, hbvalue] at h |
| 110 | linarith |
| 111 | have havalue : f a = 2 * r⁻¹ ^ 2 := by |
| 112 | obtain ⟨s, hs, hfs⟩ := intermediate_value_Icc hab.le |
| 113 | (hct.mono (Icc_subset_Icc ha.1.1 hb.1.2)) |
| 114 | ⟨ha.2, by rw [hbvalue]; linarith⟩ |
| 115 | have hsa : s ≤ a := hlast ⟨⟨ha.1.1.trans hs.1, hs.2⟩, hfs.le⟩ |
| 116 | simpa only [le_antisymm hsa hs.1] using hfs |
| 117 | have hband (s : ℝ) (hs : s ∈ Ioo a b) : |
| 118 | 2 * r⁻¹ ^ 2 ≤ f s ∧ f s ≤ 4 * r⁻¹ ^ 2 := by |
| 119 | constructor |
| 120 | · by_contra hlo |
| 121 | exact not_le_of_gt hs.1 |
| 122 | (hlast ⟨⟨ha.1.1.trans hs.1.le, hs.2.le⟩, (lt_of_not_ge hlo).le⟩) |
| 123 | · by_contra hhi |
| 124 | exact not_le_of_gt hs.2 |
| 125 | (hfirst ⟨⟨ha.1.1.trans hs.1.le, hs.2.le.trans hb.1.2⟩, |
| 126 | (lt_of_not_ge hhi).le⟩) |
| 127 | have hwindow (s : ℝ) (hs : s ∈ Ioo a b) : s ∈ Ioo 0 duration := |
| 128 | ⟨ha.1.1.trans_lt hs.1, hs.2.trans_le (hb.1.2.trans ht.2)⟩ |
| 129 | have hrateBand (s : ℝ) (hs : s ∈ Ioo a b) (hne : s ∉ events) : |
| 130 | f' s ≤ 16 * B * r⁻¹ ^ 4 := by |
| 131 | obtain ⟨hlo, hhi⟩ := hband s hs |
| 132 | have hsquare : f s ^ 2 ≤ 16 * r⁻¹ ^ 4 := by nlinarith |
| 133 | have h := (hrate s (hwindow s hs) hne (by linarith)).trans |
| 134 | (mul_le_mul_of_nonneg_left hsquare hB.le) |
| 135 | nlinarith |
| 136 | have hinc := image_sub_le_mul_sub_of_finite_deriv_exceptions hab.le |
| 137 | (hfinite.subset (fun s hs => |
| 138 | ⟨hs.1, ha.1.1.trans_lt hs.2.1, hs.2.2.trans (hb.1.2.trans ht.2)⟩)) |
| 139 | (hcont.mono (Icc_subset_Icc ha.1.1 (hb.1.2.trans ht.2))) |
| 140 | (fun s hs hne => hderiv s (hwindow s hs) hne) hrateBand |
| 141 | rw [havalue, hbvalue] at hinc |
| 142 | have hlength : b - a ≤ duration := by linarith [ha.1.1, hb.1.2, ht.2] |
| 143 | have hlong := mul_le_mul_of_nonneg_left hlength |
| 144 | (by positivity : 0 ≤ 16 * B * r⁻¹ ^ 4) |
| 145 | have hscaled := mul_le_mul_of_nonneg_right hshort (by positivity : 0 ≤ r⁻¹ ^ 2) |
| 146 | nlinarith |
| 147 | |
| 148 | end PoincareMT.Proofs.M46 |