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.ContDiff.Comp |
| 2 | import Mathlib.Topology.OpenPartialHomeomorph.Continuity |
| 3 | |
| 4 | /-! |
| 5 | # Supported changes of vector fields in smooth coordinates |
| 6 | |
| 7 | A compactly supported change of a constant field in a smooth coordinate |
| 8 | chart extends to a global change of the corresponding vector field. |
| 9 | -/ |
| 10 | |
| 11 | noncomputable section |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set Filter |
| 15 | open scoped ContDiff Topology |
| 16 | |
| 17 | namespace Poincare.ODE.LocalFlow |
| 18 | |
| 19 | /-- A smooth coordinate change transports a compactly supported, nowhere-zero |
| 20 | perturbation of a constant field to a global nowhere-zero vector field. -/ |
| 21 | theorem exists_supported_vectorField_change |
| 22 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 24 | (e : OpenPartialHomeomorph E F) |
| 25 | (he : ContDiffOn ℝ ∞ e e.source) |
| 26 | (hi : ContDiffOn ℝ ∞ e.symm e.target) |
| 27 | {V : F → F} (hV : ContDiff ℝ ∞ V) (hVne : ∀ x, V x ≠ 0) |
| 28 | {v : E} (hv : ∀ y ∈ e.source, fderiv ℝ e y v = V (e y)) |
| 29 | {K : Set E} (hK : IsCompact K) (hKs : K ⊆ e.source) |
| 30 | {W : E → E} (hW : ContDiff ℝ ∞ W) (hWne : ∀ y, W y ≠ 0) |
| 31 | (hWfix : ∀ y, y ∉ K → W y = v) : |
| 32 | ∃ Z : F → F, |
| 33 | ContDiff ℝ ∞ Z ∧ |
| 34 | (∀ x, Z x ≠ 0) ∧ |
| 35 | (∀ x, x ∉ e '' K → Z x = V x) ∧ |
| 36 | ∀ y ∈ e.source, Z (e y) = fderiv ℝ e y (W y) := by |
| 37 | classical |
| 38 | let Z : F → F := fun x => |
| 39 | if x ∈ e.target then fderiv ℝ e (e.symm x) (W (e.symm x)) else V x |
| 40 | have hZchart (y : E) (hy : y ∈ e.source) : |
| 41 | Z (e y) = fderiv ℝ e y (W y) := by |
| 42 | simp only [Z, if_pos (e.map_source hy), e.left_inv hy] |
| 43 | have hZfix (x : F) (hx : x ∉ e '' K) : Z x = V x := by |
| 44 | by_cases hxt : x ∈ e.target |
| 45 | · have hyK : e.symm x ∉ K := by |
| 46 | intro hy |
| 47 | exact hx ⟨e.symm x, hy, e.right_inv hxt⟩ |
| 48 | simp only [Z, if_pos hxt, hWfix _ hyK] |
| 49 | rw [hv _ (e.map_target hxt), e.right_inv hxt] |
| 50 | · simp only [Z, if_neg hxt] |
| 51 | have hKclosed : IsClosed (e '' K) := |
| 52 | (hK.image_of_continuousOn (he.continuousOn.mono hKs)).isClosed |
| 53 | refine ⟨Z, ?_, ?_, hZfix, hZchart⟩ |
| 54 | · apply contDiff_iff_contDiffAt.mpr |
| 55 | intro x |
| 56 | by_cases hx : x ∈ e.target |
| 57 | · have hye : ContDiffAt ℝ ∞ e (e.symm x) := |
| 58 | he.contDiffAt (e.open_source.mem_nhds (e.map_target hx)) |
| 59 | have hxi : ContDiffAt ℝ ∞ e.symm x := |
| 60 | hi.contDiffAt (e.open_target.mem_nhds hx) |
| 61 | have hs : ContDiffAt ℝ ∞ |
| 62 | (fun z => fderiv ℝ e (e.symm z) (W (e.symm z))) x := |
| 63 | ((hye.fderiv_right (by simp)).clm_apply hW.contDiffAt).comp x hxi |
| 64 | apply hs.congr_of_eventuallyEq |
| 65 | filter_upwards [e.open_target.mem_nhds hx] with z hz |
| 66 | exact if_pos hz |
| 67 | · have hxK : x ∉ e '' K := by |
| 68 | rintro ⟨y, hy, rfl⟩ |
| 69 | exact hx (e.map_source (hKs hy)) |
| 70 | apply hV.contDiffAt.congr_of_eventuallyEq |
| 71 | filter_upwards [hKclosed.isOpen_compl.mem_nhds hxK] with z hz |
| 72 | exact hZfix z hz |
| 73 | · intro x |
| 74 | by_cases hx : x ∈ e.target |
| 75 | · let y := e.symm x |
| 76 | have hy : y ∈ e.source := e.map_target hx |
| 77 | have hde := (he.contDiffAt (e.open_source.mem_nhds hy)).differentiableAt |
| 78 | (by simp) |
| 79 | have hdi := (hi.contDiffAt (e.open_target.mem_nhds (e.map_source hy))).differentiableAt |
| 80 | (by simp) |
| 81 | have hid : HasFDerivAt (fun z => e.symm (e z)) |
| 82 | (ContinuousLinearMap.id ℝ E) y := |
| 83 | (hasFDerivAt_id y).congr_of_eventuallyEq (e.eventually_left_inverse hy) |
| 84 | have hleft := (hdi.hasFDerivAt.comp y hde.hasFDerivAt).unique hid |
| 85 | intro hzero |
| 86 | have hpushed : fderiv ℝ e y (W y) = 0 := by |
| 87 | simpa only [Z, if_pos hx] using hzero |
| 88 | have hwy := congrArg (fun L : E →L[ℝ] E => L (W y)) hleft |
| 89 | simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.id_apply, |
| 90 | hpushed, map_zero] at hwy |
| 91 | exact hWne y hwy.symm |
| 92 | · simpa only [Z, if_neg hx] using hVne x |
| 93 | |
| 94 | end Poincare.ODE.LocalFlow |