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 | # Extending a continuous derivative to an initial time boundary |
| 5 | |
| 6 | On a half-open time slab, continuous values and a continuous candidate |
| 7 | derivative extend an interior derivative to the included endpoint. This |
| 8 | is the boundary calculus used in Morgan-Tian Theorem 12.5, p. 297. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open Set Filter |
| 14 | open scoped Topology |
| 15 | |
| 16 | /-- A continuous derivative on an initial slab that is the actual |
| 17 | derivative in the interior is the within derivative at time zero too |
| 18 | (Theorem 12.5, p. 297, endpoint calculus). -/ |
| 19 | theorem hasFDerivWithinAt_Ico_prod_of_continuousOn |
| 20 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 21 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 22 | {f : ℝ × E → F} {D : ℝ × E → ℝ × E →L[ℝ] F} {T : ℝ} |
| 23 | (hf : ContinuousOn f (Ico 0 T ×ˢ univ)) |
| 24 | (hD : ContinuousOn D (Ico 0 T ×ˢ univ)) |
| 25 | (hd : ∀ p ∈ Ioo 0 T ×ˢ univ, HasFDerivAt f (D p) p) |
| 26 | {p : ℝ × E} (hp : p ∈ Ico 0 T ×ˢ univ) : |
| 27 | HasFDerivWithinAt f (D p) (Ico 0 T ×ˢ univ) p := by |
| 28 | rcases p with ⟨t, x⟩ |
| 29 | by_cases ht : t = 0 |
| 30 | · subst t |
| 31 | have hT : 0 < T := hp.1.2 |
| 32 | have hb : 0 < T / 2 := half_pos hT |
| 33 | have hbT : T / 2 < T := half_lt_self hT |
| 34 | let U : Set (ℝ × E) := Ioo 0 (T / 2) ×ˢ univ |
| 35 | have hsub : U ⊆ Ico 0 T ×ˢ univ := by |
| 36 | rintro ⟨s, y⟩ ⟨hs, hy⟩ |
| 37 | exact ⟨⟨hs.1.le, hs.2.trans hbT⟩, hy⟩ |
| 38 | have hinside : U ⊆ Ioo 0 T ×ˢ univ := by |
| 39 | rintro ⟨s, y⟩ ⟨hs, hy⟩ |
| 40 | exact ⟨⟨hs.1, hs.2.trans hbT⟩, hy⟩ |
| 41 | have hclosure : closure U = Icc 0 (T / 2) ×ˢ (univ : Set E) := by |
| 42 | simp only [U, closure_prod_eq, closure_Ioo hb.ne, closure_univ] |
| 43 | have hclosedsub : closure U ⊆ Ico 0 T ×ˢ univ := by |
| 44 | rw [hclosure] |
| 45 | rintro ⟨s, y⟩ ⟨hs, hy⟩ |
| 46 | exact ⟨⟨hs.1, hs.2.trans_lt hbT⟩, hy⟩ |
| 47 | have hlim : Tendsto (fderiv ℝ f) (𝓝[U] (0, x)) (𝓝 (D (0, x))) := by |
| 48 | apply ((hD (0, x) hp).mono hsub).congr' |
| 49 | filter_upwards [self_mem_nhdsWithin] with q hq |
| 50 | exact (hd q (hinside hq)).fderiv.symm |
| 51 | have hderiv : HasFDerivWithinAt f (D (0, x)) (closure U) (0, x) := |
| 52 | hasFDerivWithinAt_closure_of_tendsto_fderiv |
| 53 | (fun q hq => (hd q (hinside hq)).differentiableAt.differentiableWithinAt) |
| 54 | ((convex_Ioo 0 (T / 2)).prod convex_univ) (isOpen_Ioo.prod isOpen_univ) |
| 55 | (fun q hq => (hf q (hclosedsub hq)).mono hsub) hlim |
| 56 | apply hderiv.mono_of_mem_nhdsWithin |
| 57 | rw [hclosure] |
| 58 | filter_upwards [self_mem_nhdsWithin, |
| 59 | mem_nhdsWithin_of_mem_nhds |
| 60 | ((isOpen_Iio.preimage continuous_fst).mem_nhds hb)] with q hq hqb |
| 61 | exact ⟨⟨hq.1.1, hqb.le⟩, mem_univ q.2⟩ |
| 62 | · exact (hd (t, x) ⟨⟨lt_of_le_of_ne hp.1.1 (Ne.symm ht), hp.1.2⟩, |
| 63 | hp.2⟩).hasFDerivWithinAt |