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.Calculus.FDeriv.Extend |
| 2 | |
| 3 | /-! |
| 4 | # Joining a continuous derivative across one time slice |
| 5 | |
| 6 | Convex derivative extension on two closed slabs gives the same joint |
| 7 | derivative on their union. This is the calculus used to join the actual |
| 8 | past and forward Ricci evolutions in Morgan-Tian Theorem 12.5, |
| 9 | pp. 296-297; see flow-joining-implementation.md. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set Filter |
| 15 | open scoped Topology |
| 16 | |
| 17 | /-- A continuous derivative field on a nondegenerate closed slab agrees |
| 18 | with the actual within derivative also at its endpoints |
| 19 | (Theorem 12.5, pp. 296-297, endpoint calculus). -/ |
| 20 | theorem hasFDerivWithinAt_Icc_prod_of_continuousOn |
| 21 | {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 22 | [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 23 | {f : ℝ × E → V} {D : ℝ × E → ℝ × E →L[ℝ] V} {a b : ℝ} |
| 24 | (hab : a < b) (hf : ContinuousOn f (Icc a b ×ˢ univ)) |
| 25 | (hD : ContinuousOn D (Icc a b ×ˢ univ)) |
| 26 | (hd : ∀ p ∈ Ioo a b ×ˢ univ, HasFDerivAt f (D p) p) |
| 27 | {p : ℝ × E} (hp : p ∈ Icc a b ×ˢ univ) : |
| 28 | HasFDerivWithinAt f (D p) (Icc a b ×ˢ univ) p := by |
| 29 | have hsub : Ioo a b ×ˢ (univ : Set E) ⊆ Icc a b ×ˢ univ := |
| 30 | fun _ h => ⟨Ioo_subset_Icc_self h.1, h.2⟩ |
| 31 | have hclosure : closure (Ioo a b ×ˢ (univ : Set E)) = Icc a b ×ˢ univ := by |
| 32 | simp only [closure_prod_eq, closure_Ioo hab.ne, closure_univ] |
| 33 | have hlim : Tendsto (fderiv ℝ f) (𝓝[Ioo a b ×ˢ univ] p) (𝓝 (D p)) := by |
| 34 | apply ((hD p hp).mono hsub).congr' |
| 35 | filter_upwards [self_mem_nhdsWithin] with q hq |
| 36 | exact (hd q hq).fderiv.symm |
| 37 | rw [← hclosure] |
| 38 | apply hasFDerivWithinAt_closure_of_tendsto_fderiv |
| 39 | (fun q hq => (hd q hq).differentiableAt.differentiableWithinAt) |
| 40 | ((convex_Ioo a b).prod convex_univ) (isOpen_Ioo.prod isOpen_univ) _ hlim |
| 41 | intro q hq |
| 42 | rw [hclosure] at hq |
| 43 | exact (hf q hq).mono hsub |
| 44 | |
| 45 | /-- A continuous joint derivative known off one time slice extends |
| 46 | across that slice on the open slab (Theorem 12.5, pp. 296-297). -/ |
| 47 | theorem hasFDerivAt_prod_of_continuousOn_off_time |
| 48 | {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 49 | [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 50 | {f : ℝ × E → V} {D : ℝ × E → ℝ × E →L[ℝ] V} {a b c : ℝ} |
| 51 | (hf : ContinuousOn f (Ioo a b ×ˢ univ)) |
| 52 | (hD : ContinuousOn D (Ioo a b ×ˢ univ)) |
| 53 | (hd : ∀ p ∈ Ioo a b ×ˢ univ, p.1 ≠ c → HasFDerivAt f (D p) p) |
| 54 | {p : ℝ × E} (hp : p ∈ Ioo a b ×ˢ univ) : HasFDerivAt f (D p) p := by |
| 55 | by_cases hc : p.1 = c |
| 56 | · have hac : a < c := by simpa only [hc] using hp.1.1 |
| 57 | have hcb : c < b := by simpa only [hc] using hp.1.2 |
| 58 | let l := (a + c) / 2 |
| 59 | let r := (c + b) / 2 |
| 60 | have hl : a < l ∧ l < c := by dsimp [l]; constructor <;> linarith |
| 61 | have hr : c < r ∧ r < b := by dsimp [r]; constructor <;> linarith |
| 62 | have hleft : Icc l c ×ˢ (univ : Set E) ⊆ Ioo a b ×ˢ univ := by |
| 63 | intro q hq |
| 64 | exact ⟨⟨hl.1.trans_le hq.1.1, hq.1.2.trans_lt hcb⟩, hq.2⟩ |
| 65 | have hright : Icc c r ×ˢ (univ : Set E) ⊆ Ioo a b ×ˢ univ := by |
| 66 | intro q hq |
| 67 | exact ⟨⟨hac.trans_le hq.1.1, hq.1.2.trans_lt hr.2⟩, hq.2⟩ |
| 68 | have hdl : HasFDerivWithinAt f (D p) (Icc l c ×ˢ univ) p := by |
| 69 | apply hasFDerivWithinAt_Icc_prod_of_continuousOn hl.2 |
| 70 | (hf.mono hleft) (hD.mono hleft) _ |
| 71 | ⟨by simpa only [hc] using (show c ∈ Icc l c from ⟨hl.2.le, le_rfl⟩), hp.2⟩ |
| 72 | intro q hq |
| 73 | exact hd q (hleft ⟨Ioo_subset_Icc_self hq.1, hq.2⟩) hq.1.2.ne |
| 74 | have hdr : HasFDerivWithinAt f (D p) (Icc c r ×ˢ univ) p := by |
| 75 | apply hasFDerivWithinAt_Icc_prod_of_continuousOn hr.1 |
| 76 | (hf.mono hright) (hD.mono hright) _ |
| 77 | ⟨by simpa only [hc] using (show c ∈ Icc c r from ⟨le_rfl, hr.1.le⟩), hp.2⟩ |
| 78 | intro q hq |
| 79 | exact hd q (hright ⟨Ioo_subset_Icc_self hq.1, hq.2⟩) hq.1.1.ne' |
| 80 | apply (hdl.union hdr).hasFDerivAt |
| 81 | have hnear : Ioo l r ×ˢ (univ : Set E) ∈ 𝓝 p := |
| 82 | (isOpen_Ioo.prod isOpen_univ).mem_nhds |
| 83 | ⟨by simpa only [hc] using (show c ∈ Ioo l r from ⟨hl.2, hr.1⟩), hp.2⟩ |
| 84 | filter_upwards [hnear] with q hq |
| 85 | by_cases hqc : q.1 ≤ c |
| 86 | · exact Or.inl ⟨⟨hq.1.1.le, hqc⟩, hq.2⟩ |
| 87 | · exact Or.inr ⟨⟨(not_le.mp hqc).le, hq.1.2.le⟩, hq.2⟩ |
| 88 | · exact hd p hp hc |