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.CurveShortening.Comparison.Analysis.Continuous.GraphShear |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Loop.RegionChart |
| 3 | |
| 4 | /-! |
| 5 | # A regular defining function from a continuous boundary graph |
| 6 | |
| 7 | The graph needs an actual derivative only at the distinguished point. |
| 8 | Its continuous shear chart and the Jordan pair determine the occupied |
| 9 | side. This treats the straight join in MT Claim 19.40 without assuming |
| 10 | that its two smooth boundary pieces have matching higher derivatives. |
| 11 | -/ |
| 12 | |
| 13 | noncomputable section |
| 14 | set_option autoImplicit false |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | |
| 17 | open Set Filter |
| 18 | open scoped Topology ContDiff |
| 19 | |
| 20 | namespace PoincareMT |
| 21 | |
| 22 | /-- A continuous graph of the actual Jordan frontier, differentiable at the selected point, |
| 23 | constructs a nondegenerate defining function there. This is the first-derivative input of |
| 24 | the metric half-plane fan theorem. Source: |
| 25 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Section 9. -/ |
| 26 | theorem m64Intrinsic_continuous_graph_defining_function |
| 27 | (L : AnnulusCoordinates ≃L[ℝ] (ℝ × ℝ)) |
| 28 | {h : ℝ → ℝ} {X : Set ℝ} (hX : IsOpen X) (hh : ContinuousOn h X) |
| 29 | {p : AnnulusCoordinates} {d : ℝ} (hdh : HasDerivAt h d (L p).1) |
| 30 | {U V W : Set AnnulusCoordinates} (hU : IsOpen U) (hV : IsOpen V) |
| 31 | (hdisj : Disjoint U V) (hfV : frontier V = frontier U) |
| 32 | (hW : IsOpen W) (hpW : p ∈ W) (hpfront : p ∈ frontier U) |
| 33 | (hgraph : ∀ z ∈ W, (L z).1 ∈ X ∧ (z ∈ frontier U ↔ (L z).2 = h (L z).1)) : |
| 34 | ∃ (phi : AnnulusCoordinates → ℝ) (ell : AnnulusCoordinates →L[ℝ] ℝ), |
| 35 | HasFDerivAt phi ell p ∧ phi p = 0 ∧ ell ≠ 0 ∧ |
| 36 | (∀ᶠ z in 𝓝 p, z ∈ closure U ↔ 0 ≤ phi z) := by |
| 37 | let H := (m64ContinuousGraphShear hX hh).trans L.symm.toHomeomorph.toOpenPartialHomeomorph |
| 38 | have hsource : H.source = X ×ˢ univ := by |
| 39 | ext q |
| 40 | simp [H, m64ContinuousGraphShear] |
| 41 | have hformula (q : ℝ × ℝ) : H q = L.symm (q.1, h q.1 + q.2) := rfl |
| 42 | let x := (L p).1 |
| 43 | have hxX : x ∈ X := (hgraph p hpW).1 |
| 44 | have hpgraph : (L p).2 = h x := (hgraph p hpW).2.mp hpfront |
| 45 | have hcoord : L p = (x, h x) := Prod.ext rfl hpgraph |
| 46 | have hx : (x, (0 : ℝ)) ∈ H.source := by rw [hsource]; exact ⟨hxX, mem_univ _⟩ |
| 47 | have hbase : H (x, 0) = p := by rw [hformula, add_zero, ← hcoord, L.symm_apply_apply] |
| 48 | have hpre : ∀ᶠ z in 𝓝 (x, (0 : ℝ)), H z ∈ W := |
| 49 | (H.continuousAt hx).preimage_mem_nhds (by simpa only [hbase] using hW.mem_nhds hpW) |
| 50 | have hline : ∀ᶠ z in 𝓝 (x, (0 : ℝ)), H z ∈ frontier U ↔ z.2 = 0 := by |
| 51 | filter_upwards [hpre] with z hz |
| 52 | rw [(hgraph (H z) hz).2, hformula, L.apply_symm_apply] |
| 53 | simp only [add_eq_left] |
| 54 | have hside := m64Intrinsic_jordan_product_line_germ hU hV hdisj hfV.symm H hx |
| 55 | (by rw [hbase]; exact hpfront) hline |
| 56 | let X0 : AnnulusCoordinates →L[ℝ] ℝ := |
| 57 | (ContinuousLinearMap.fst ℝ ℝ ℝ).comp L.toContinuousLinearMap |
| 58 | let Y0 : AnnulusCoordinates →L[ℝ] ℝ := |
| 59 | (ContinuousLinearMap.snd ℝ ℝ ℝ).comp L.toContinuousLinearMap |
| 60 | let phi := fun z => Y0 z - h (X0 z) |
| 61 | let ell : AnnulusCoordinates →L[ℝ] ℝ := Y0 - d • X0 |
| 62 | have hd : HasFDerivAt phi ell p := |
| 63 | Y0.hasFDerivAt.sub (hdh.comp_hasFDerivAt_of_eq p X0.hasFDerivAt rfl) |
| 64 | have hzero : phi p = 0 := sub_eq_zero.mpr hpgraph |
| 65 | have hv : ell (L.symm (0, 1)) = 1 := by |
| 66 | change (L (L.symm (0, 1))).2 - d * (L (L.symm (0, 1))).1 = 1 |
| 67 | rw [L.apply_symm_apply] |
| 68 | simp |
| 69 | have hell : ell ≠ 0 := by |
| 70 | intro heq |
| 71 | have hz : ell (L.symm (0, 1)) = 0 := by rw [heq]; rfl |
| 72 | linarith |
| 73 | let psi := fun z : AnnulusCoordinates => ((L z).1, (L z).2 - h (L z).1) |
| 74 | have hshift : ContinuousAt psi p := |
| 75 | L.continuous.fst.continuousAt.prodMk (L.continuous.snd.continuousAt.sub |
| 76 | (hdh.continuousAt.comp_of_eq L.continuous.fst.continuousAt rfl)) |
| 77 | have ht : Tendsto psi (𝓝 p) (𝓝 (x, (0 : ℝ))) := by |
| 78 | simpa only [psi, hcoord, sub_self] using hshift.tendsto |
| 79 | have hcancel (z : AnnulusCoordinates) : H (psi z) = z := by |
| 80 | rw [hformula] |
| 81 | simp only [psi, add_sub_cancel, L.symm_apply_apply] |
| 82 | rcases hside with hs | hs |
| 83 | · refine ⟨phi, ell, hd, hzero, hell, ?_⟩ |
| 84 | filter_upwards [ht.eventually hs] with z hz |
| 85 | rw [hcancel] at hz |
| 86 | exact hz |
| 87 | · refine ⟨fun z => -phi z, -ell, hd.neg, by simp only [hzero, neg_zero], |
| 88 | neg_ne_zero.mpr hell, ?_⟩ |
| 89 | filter_upwards [ht.eventually hs] with z hz |
| 90 | rw [hcancel] at hz |
| 91 | exact hz.trans neg_nonneg.symm |
| 92 | |
| 93 | end PoincareMT |