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.Cone.TangentChord |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Local.ChordBounds |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Slope |
| 4 | |
| 5 | /-! |
| 6 | # Tangency of the outgoing leg at a constrained minimizing contact |
| 7 | |
| 8 | The actual coordinate chords force an existing outgoing derivative and |
| 9 | its opposite into the occupied cone. In a half-plane every supporting |
| 10 | linear functional therefore vanishes on that derivative. Only the |
| 11 | outgoing leg is differentiated. Source: MT Claim 19.40, pp. 470-471; |
| 12 | minimal-contact-regularity derivation, Section 3. |
| 13 | -/ |
| 14 | |
| 15 | noncomputable section |
| 16 | set_option autoImplicit false |
| 17 | set_option backward.isDefEq.respectTransparency false |
| 18 | |
| 19 | open Set Filter |
| 20 | open scoped Topology ENNReal NNReal Manifold ContDiff Bundle |
| 21 | |
| 22 | namespace PoincareMT |
| 23 | |
| 24 | attribute [local instance] normedAddCommGroupTangentSpaceVectorSpace |
| 25 | normedSpaceTangentSpaceVectorSpace |
| 26 | |
| 27 | /-- For a constrained minimizer in a smooth local cone chart, an actual right derivative |
| 28 | belongs to the cone together with its opposite. No left derivative or differentiability |
| 29 | across the contact is required. Source: MT Claim 19.40, pp. 470-471; |
| 30 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Section 3. -/ |
| 31 | theorem m64Intrinsic_constrained_minimizer_outgoing_tangent_mem |
| 32 | (G : RiemannianMetric 2 AnnulusCoordinates) {K : Set AnnulusCoordinates} |
| 33 | {gamma : ℝ → AnnulusCoordinates} {L : ℝ} |
| 34 | (hc : ContinuousOn gamma (Icc 0 L)) (hconf : MapsTo gamma (Icc 0 L) K) |
| 35 | (hlip : ∀ s ∈ Icc 0 L, ∀ t ∈ Icc 0 L, |
| 36 | G.edist (gamma s) (gamma t) ≤ ENNReal.ofReal |s - t|) |
| 37 | (hmin : ∀ a ∈ Icc 0 L, ∀ b ∈ Icc 0 L, a ≤ b → |
| 38 | ∀ tau : ℝ → AnnulusCoordinates, ContinuousOn tau (Icc 0 1) → |
| 39 | tau 0 = gamma a → tau 1 = gamma b → MapsTo tau (Icc 0 1) K → |
| 40 | ENNReal.ofReal (b - a) ≤ m64IntrinsicCurveVariation G tau 0 1) |
| 41 | (H : OpenPartialHomeomorph AnnulusCoordinates AnnulusCoordinates) |
| 42 | (h0 : (0 : AnnulusCoordinates) ∈ H.source) |
| 43 | (hH : ContMDiffOn (𝓡 2) (𝓡 2) ∞ H H.source) |
| 44 | (hHi : ContMDiffOn (𝓡 2) (𝓡 2) ∞ H.symm H.target) |
| 45 | (C : ConvexCone ℝ AnnulusCoordinates) (hC : IsClosed (C : Set AnnulusCoordinates)) |
| 46 | (hzero : (0 : AnnulusCoordinates) ∈ C) |
| 47 | (hregion : ∀ᶠ z in 𝓝 (0 : AnnulusCoordinates), H z ∈ K ↔ z ∈ C) |
| 48 | {u : ℝ} (hu : u ∈ Ioo 0 L) (hpoint : gamma u = H 0) |
| 49 | {v : AnnulusCoordinates} |
| 50 | (hderiv : HasDerivWithinAt (fun r : ℝ => H.symm (gamma (u + r))) v (Ioi 0) 0) : |
| 51 | v ∈ C ∧ -v ∈ C := by |
| 52 | have hD : H.MDifferentiable (𝓡 2) (𝓡 2) := |
| 53 | ⟨hH.mdifferentiableOn (by simp), hHi.mdifferentiableOn (by simp)⟩ |
| 54 | obtain ⟨A, hA, _⟩ := G.exists_frozenPullbackEquiv (hD.mfderiv h0).injective |
| 55 | let Q := C.map A.toLinearEquiv.toLinearMap |
| 56 | have hQ : IsClosed (Q : Set AnnulusCoordinates) := |
| 57 | A.toHomeomorph.isClosedMap _ hC |
| 58 | have hQzero : (0 : AnnulusCoordinates) ∈ Q := ⟨0, hzero, map_zero A⟩ |
| 59 | have hlimit : Tendsto (fun r : ℝ => r⁻¹ • H.symm (gamma (u + r))) |
| 60 | (𝓝[>] 0) (𝓝 v) := by |
| 61 | apply ((hasDerivWithinAt_iff_tendsto_slope' (notMem_Ioi.mpr le_rfl)).mp hderiv).congr' |
| 62 | filter_upwards [] with r |
| 63 | simp only [slope_def_module, sub_zero, add_zero, hpoint, H.left_inv h0] |
| 64 | have hAlimit : Tendsto (fun r : ℝ => r⁻¹ • A (H.symm (gamma (u + r)))) |
| 65 | (𝓝[>] 0) (𝓝 (A v)) := by |
| 66 | apply ((A.continuous.tendsto v).comp hlimit).congr' |
| 67 | filter_upwards [] with r |
| 68 | exact map_smul A r⁻¹ (H.symm (gamma (u + r))) |
| 69 | obtain ⟨hvQ, hnegQ⟩ := m64ClosedCone_tangent_mem_and_neg_mem_of_chord_bounds |
| 70 | Q hQ hQzero (x := fun r => A (H.symm (gamma (u - r)))) hAlimit (by |
| 71 | intro theta htheta |
| 72 | obtain ⟨epsilon, hepsilon, hbound⟩ := |
| 73 | m64Intrinsic_constrained_minimizer_local_chord_bounds G hc hconf hlip hmin |
| 74 | H h0 hH hHi C.convex hregion A hA hu hpoint htheta |
| 75 | refine ⟨epsilon, hepsilon, ?_⟩ |
| 76 | intro r hr he |
| 77 | obtain ⟨hx, hy, hxn, hyn, hlower⟩ := hbound r hr he |
| 78 | exact ⟨⟨_, hx, rfl⟩, ⟨_, hy, rfl⟩, hxn, hyn, by simpa only [map_sub] using hlower⟩) |
| 79 | constructor |
| 80 | · obtain ⟨z, hz, hzv⟩ := hvQ |
| 81 | exact A.injective hzv ▸ hz |
| 82 | · obtain ⟨z, hz, hzv⟩ := hnegQ |
| 83 | have hzeq : z = -v := A.injective (by rw [map_neg]; exact hzv) |
| 84 | exact hzeq ▸ hz |
| 85 | |
| 86 | end PoincareMT |