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.ReducedGeometry.LGeometry.Minimization.Charts.WeakVelocity |
| 2 | |
| 3 | /-! Adapted from Mapher `PoincareMT/Proofs/M08/EndpointMomentum.lean` at |
| 4 | `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. -/ |
| 5 | |
| 6 | |
| 7 | /-! |
| 8 | # Endpoint velocity from finite action and the Euler momentum equation |
| 9 | |
| 10 | The endpoint momentum is defined by an integrable primitive. No value of |
| 11 | the original derivative at either endpoint is used. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | |
| 17 | noncomputable section |
| 18 | |
| 19 | open Set Filter MeasureTheory |
| 20 | open scoped Topology ContDiff intervalIntegral |
| 21 | |
| 22 | namespace PoincareMT.LGeometry |
| 23 | |
| 24 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E] |
| 25 | |
| 26 | theorem exists_continuous_endpoint_momentum {a b : ℝ} (hab : a < b) |
| 27 | (P Q : ℝ → E) (hQ : IntervalIntegrable Q volume a b) |
| 28 | (hP : ∀ s ∈ Ioo a b, HasDerivAt P (Q s) s) : |
| 29 | ∃ c : E, ∀ s ∈ Ioo a b, P s = c + ∫ r in a..s, Q r := by |
| 30 | let d := (a + b) / 2 |
| 31 | have hd : d ∈ Ioo a b := ⟨by dsimp only [d]; linarith, by dsimp only [d]; linarith⟩ |
| 32 | have hQsub {r s : ℝ} (hr : r ∈ Icc a b) (hs : s ∈ Icc a b) : |
| 33 | IntervalIntegrable Q volume r s := hQ.mono_set (by |
| 34 | rw [uIcc_of_le hab.le] |
| 35 | exact uIcc_subset_Icc hr hs) |
| 36 | refine ⟨P d - ∫ r in a..d, Q r, ?_⟩ |
| 37 | intro s hs |
| 38 | have hsub : uIcc d s ⊆ Ioo a b := by |
| 39 | intro r hr |
| 40 | exact ⟨lt_of_lt_of_le (lt_min hd.1 hs.1) hr.1, |
| 41 | lt_of_le_of_lt hr.2 (max_lt hd.2 hs.2)⟩ |
| 42 | have hFTC := intervalIntegral.integral_eq_sub_of_hasDerivAt |
| 43 | (fun r hr ↦ hP r (hsub hr)) (hQsub (Ioo_subset_Icc_self hd) (Ioo_subset_Icc_self hs)) |
| 44 | have hadd := intervalIntegral.integral_add_adjacent_intervals |
| 45 | (hQsub ⟨le_rfl, hab.le⟩ (Ioo_subset_Icc_self hd)) |
| 46 | (hQsub (Ioo_subset_Icc_self hd) (Ioo_subset_Icc_self hs)) |
| 47 | rw [hFTC] at hadd |
| 48 | rw [← hadd] |
| 49 | abel |
| 50 | |
| 51 | /-- An interior Euler momentum with integrable force recovers both endpoint velocities. -/ |
| 52 | theorem endpoint_velocity_of_momentum {a b : ℝ} (hab : a < b) |
| 53 | (u d P Q : ℝ → E) |
| 54 | (hu : ContinuousOn u (Icc a b)) |
| 55 | (hud : ∀ s ∈ Ioo a b, HasDerivAt u (d s) s) |
| 56 | (hd : MemLp d 2 (volume.restrict (Icc a b))) |
| 57 | (A B : ℝ → E →L[ℝ] E) |
| 58 | (hB : ContinuousOn B (Icc a b)) |
| 59 | (hinv : ∀ s ∈ Icc a b, ∀ v : E, B s (A s v) = v) |
| 60 | (hPdef : ∀ s ∈ Ioo a b, P s = A s (d s)) |
| 61 | (hQ : IntervalIntegrable Q volume a b) |
| 62 | (hPd : ∀ s ∈ Ioo a b, HasDerivAt P (Q s) s) : |
| 63 | ∃ (c : E) (q Pbar : ℝ → E), |
| 64 | (∀ s, Pbar s = c + ∫ r in a..s, Q r) ∧ |
| 65 | (∀ s, q s = B s (Pbar s)) ∧ |
| 66 | ContinuousOn Pbar (Icc a b) ∧ ContinuousOn q (Icc a b) ∧ |
| 67 | EqOn Pbar P (Ioo a b) ∧ EqOn q d (Ioo a b) ∧ |
| 68 | (∀ s ∈ Icc a b, u s = u a + ∫ r in a..s, q r) ∧ |
| 69 | (∀ s ∈ Icc a b, HasDerivWithinAt u (q s) (Icc a b) s) ∧ |
| 70 | ContDiffOn ℝ 1 u (Icc a b) := by |
| 71 | obtain ⟨c, hc⟩ := exists_continuous_endpoint_momentum hab P Q hQ hPd |
| 72 | let Pbar : ℝ → E := fun s ↦ c + ∫ r in a..s, Q r |
| 73 | let q : ℝ → E := fun s ↦ B s (Pbar s) |
| 74 | have hPc : ContinuousOn Pbar (Icc a b) := by |
| 75 | have h := intervalIntegral.continuousOn_primitive_interval' hQ left_mem_uIcc |
| 76 | rw [uIcc_of_le hab.le] at h |
| 77 | exact continuousOn_const.add h |
| 78 | have hqc : ContinuousOn q (Icc a b) := hB.clm_apply hPc |
| 79 | have hqeq : EqOn q d (Ioo a b) := by |
| 80 | intro s hs |
| 81 | dsimp only [q, Pbar] |
| 82 | rw [← hc s hs, hPdef s hs, hinv s (Ioo_subset_Icc_self hs)] |
| 83 | have hdq : d =ᵐ[volume.restrict (Icc a b)] q := by |
| 84 | rw [← restrict_Ioo_eq_restrict_Icc] |
| 85 | filter_upwards [ae_restrict_mem measurableSet_Ioo] with s hs |
| 86 | exact (hqeq hs).symm |
| 87 | have hprimitive (s : ℝ) (hs : s ∈ Icc a b) : |
| 88 | u s = u a + ∫ r in a..s, q r := by |
| 89 | rw [chart_primitive_of_deriv hu hud hd hs] |
| 90 | congr 1 |
| 91 | apply intervalIntegral.integral_congr_ae_restrict |
| 92 | rw [uIoc_of_le hs.1] |
| 93 | exact ae_mono (Measure.restrict_mono |
| 94 | (Ioc_subset_Icc_self.trans (Icc_subset_Icc_right hs.2)) le_rfl) |
| 95 | (hd.coeFn_toLp.trans hdq) |
| 96 | obtain ⟨hderiv, hsmooth⟩ := continuous_primitive_regular hab u q hqc hprimitive |
| 97 | exact ⟨c, q, Pbar, fun _ ↦ rfl, fun _ ↦ rfl, hPc, hqc, |
| 98 | fun s hs ↦ (hc s hs).symm, hqeq, hprimitive, hderiv, hsmooth⟩ |
| 99 | |
| 100 | theorem endpoint_momentum_derivative_of_continuous_force {a b : ℝ} (hab : a < b) |
| 101 | (c : E) (Q Qbar : ℝ → E) |
| 102 | (heq : EqOn Qbar Q (Ioo a b)) (hQbar : ContinuousOn Qbar (Icc a b)) : |
| 103 | ∀ s ∈ Icc a b, HasDerivWithinAt |
| 104 | (fun t ↦ c + ∫ r in a..t, Q r) (Qbar s) (Icc a b) s := by |
| 105 | let Pbar : ℝ → E := fun t ↦ c + ∫ r in a..t, Q r |
| 106 | have heqint (s : ℝ) (hs : s ∈ Icc a b) : |
| 107 | (∫ r in a..s, Q r) = ∫ r in a..s, Qbar r := by |
| 108 | apply intervalIntegral.integral_congr_Ioo_of_le hs.1 |
| 109 | intro r hr |
| 110 | exact (heq ⟨hr.1, hr.2.trans_le hs.2⟩).symm |
| 111 | have hprimitive (s : ℝ) (hs : s ∈ Icc a b) : |
| 112 | Pbar s = Pbar a + ∫ r in a..s, Qbar r := by |
| 113 | simp only [Pbar, intervalIntegral.integral_same, add_zero, heqint s hs] |
| 114 | exact (continuous_primitive_regular hab Pbar Qbar hQbar hprimitive).1 |
| 115 | |
| 116 | end PoincareMT.LGeometry |