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.Deriv.Prod |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 3 | |
| 4 | /-! |
| 5 | # Ambient derivative witnesses determined on a closed interval |
| 6 | |
| 7 | Unique within derivatives identify ambient derivatives without requiring |
| 8 | the two functions to agree outside the set. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | namespace PoincareMT.ReducedLength |
| 14 | |
| 15 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 16 | |
| 17 | theorem deriv_eq_of_eqOn {f g : ℝ → E} {K : Set ℝ} {s : ℝ} |
| 18 | (heq : Set.EqOn f g K) (hs : s ∈ K) (hK : UniqueDiffWithinAt ℝ K s) |
| 19 | (hf : DifferentiableAt ℝ f s) (hg : DifferentiableAt ℝ g s) : |
| 20 | deriv f s = deriv g s := by |
| 21 | rw [← hf.derivWithin hK, ← hg.derivWithin hK] |
| 22 | exact derivWithin_congr heq (heq hs) |
| 23 | |
| 24 | theorem hasDerivAt_congr_of_eqOn {f g : ℝ → E} {K : Set ℝ} {s : ℝ} {v : E} |
| 25 | (heq : Set.EqOn f g K) (hs : s ∈ K) (hK : UniqueDiffWithinAt ℝ K s) |
| 26 | (hf : HasDerivAt f v s) (hg : DifferentiableAt ℝ g s) : |
| 27 | HasDerivAt g v s := |
| 28 | hg.hasDerivAt.congr_deriv |
| 29 | ((deriv_eq_of_eqOn heq hs hK hf.differentiableAt hg).symm.trans hf.deriv) |
| 30 | |
| 31 | theorem hasDerivAt_phase_congr_of_eqOn {f g : ℝ → E} {K : Set ℝ} {s : ℝ} {v : E × E} |
| 32 | (heq : Set.EqOn f g K) (hs : s ∈ K) (hK : UniqueDiffOn ℝ K) |
| 33 | (hf : ∀ r ∈ K, DifferentiableAt ℝ f r) |
| 34 | (hg : ∀ r ∈ K, DifferentiableAt ℝ g r) |
| 35 | (hdg : DifferentiableAt ℝ (deriv g) s) |
| 36 | (hphase : HasDerivAt (fun r ↦ (f r, deriv f r)) v s) : |
| 37 | HasDerivAt (fun r ↦ (g r, deriv g r)) v s := by |
| 38 | apply hasDerivAt_congr_of_eqOn (K := K) (s := s) ?_ hs (hK s hs) hphase |
| 39 | ((hg s hs).prodMk hdg) |
| 40 | intro r hr |
| 41 | exact Prod.ext (heq hr) (deriv_eq_of_eqOn heq hr (hK r hr) (hf r hr) (hg r hr)) |
| 42 | |
| 43 | end PoincareMT.ReducedLength |