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.IntrinsicComparison.Base.CornerAvoidance |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Geodesic.SideAvoidance |
| 3 | |
| 4 | /-! |
| 5 | # Side avoidance from the actual three collision-boundary arcs |
| 6 | |
| 7 | The actual base and normal sides construct both base-corner exclusions. |
| 8 | Their incidence properties then discharge every separation and endpoint |
| 9 | input of the checked geodesic-side avoidance theorem. |
| 10 | Source: MT Claim 19.40, pp. 470-471; minimal-contact derivation, Section 8. |
| 11 | -/ |
| 12 | |
| 13 | noncomputable section |
| 14 | set_option autoImplicit false |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | |
| 17 | open Set |
| 18 | open scoped Topology ContDiff Manifold Matrix ENNReal Bundle |
| 19 | |
| 20 | namespace PoincareMT |
| 21 | |
| 22 | attribute [local instance] normedAddCommGroupTangentSpaceVectorSpace |
| 23 | normedSpaceTangentSpaceVectorSpace |
| 24 | |
| 25 | /-- A minimizer from an interior base point to the collision vertex avoids both closed |
| 26 | geodesic sides before its terminal time. Both corner exclusions are constructed from the |
| 27 | original three boundary arcs. Source: MT Claim 19.40, pp. 470-471; |
| 28 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Section 8. -/ |
| 29 | theorem m64Intrinsic_constrained_minimizer_avoids_collision_sides |
| 30 | (G : RiemannianMetric 2 AnnulusCoordinates) |
| 31 | {base alpha beta : ℝ → AnnulusCoordinates} |
| 32 | (hb : ContDiff ℝ ∞ base) (ha : ContDiff ℝ ∞ alpha) (hc : ContDiff ℝ ∞ beta) |
| 33 | {D A B p : ℝ} (hD : 0 < D) (hA : 0 < A) (hB : 0 < B) (hp : p ∈ Ioo 0 D) |
| 34 | (hbi : InjOn base (Icc 0 D)) (hai : InjOn alpha (Icc 0 A)) |
| 35 | (hci : InjOn beta (Icc 0 B)) |
| 36 | (hstartA : base 0 = alpha 0) (hstartB : base D = beta 0) |
| 37 | (hmeet : alpha A = beta B) |
| 38 | (hbaseA : ∀ s ∈ Icc 0 D, ∀ t ∈ Icc 0 A, base s = alpha t → s = 0 ∧ t = 0) |
| 39 | (hbaseB : ∀ s ∈ Icc 0 D, ∀ t ∈ Icc 0 B, base s = beta t → s = D ∧ t = 0) |
| 40 | (hsides : ∀ s ∈ Icc 0 A, ∀ t ∈ Icc 0 B, alpha s = beta t → s = A ∧ t = B) |
| 41 | (hregA : ∀ t ∈ Ioo 0 A, deriv alpha t ≠ 0) |
| 42 | (hregB : ∀ t ∈ Ioo 0 B, deriv beta t ≠ 0) |
| 43 | (hgeoA : G.IsGeodesicOn alpha (Ioo 0 A)) (hgeoB : G.IsGeodesicOn beta (Ioo 0 B)) |
| 44 | (hindA : LinearIndependent ℝ (![deriv base 0, deriv alpha 0] : Fin 2 → AnnulusCoordinates)) |
| 45 | (hindB : LinearIndependent ℝ (![-deriv base D, deriv beta 0] : Fin 2 → AnnulusCoordinates)) |
| 46 | (hnormA : ‖base 0‖ = 1) (hnormB : ‖base D‖ = 1) |
| 47 | (hinwardA : 0 < inner ℝ (base 0) (deriv alpha 0)) |
| 48 | (hinwardB : 0 < inner ℝ (base D) (deriv beta 0)) |
| 49 | {U V : Set AnnulusCoordinates} (hU : IsOpen U) (hV : IsOpen V) |
| 50 | (hdisj : Disjoint U V) |
| 51 | (hfU : frontier U = base '' Icc 0 D ∪ (alpha '' Icc 0 A ∪ beta '' Icc 0 B)) |
| 52 | (hfV : frontier V = frontier U) (hK : IsCompact (closure U)) |
| 53 | (hsub : closure U ⊆ standardAnnulusDomain) |
| 54 | {gamma : ℝ → AnnulusCoordinates} {L : ℝ} |
| 55 | (hgamma : ContinuousOn gamma (Icc 0 L)) (hginj : InjOn gamma (Icc 0 L)) |
| 56 | (hg0 : gamma 0 = base p) (hgL : gamma L = alpha A) |
| 57 | (hconf : MapsTo gamma (Icc 0 L) (closure U)) |
| 58 | (hlip : ∀ s ∈ Icc 0 L, ∀ t ∈ Icc 0 L, |
| 59 | G.edist (gamma s) (gamma t) ≤ ENNReal.ofReal |s - t|) |
| 60 | (hmin : ∀ s ∈ Icc 0 L, ∀ t ∈ Icc 0 L, s ≤ t → |
| 61 | ∀ tau : ℝ → AnnulusCoordinates, ContinuousOn tau (Icc 0 1) → |
| 62 | tau 0 = gamma s → tau 1 = gamma t → MapsTo tau (Icc 0 1) (closure U) → |
| 63 | ENNReal.ofReal (t - s) ≤ m64IntrinsicCurveVariation G tau 0 1) : |
| 64 | ∀ u ∈ Ioo 0 L, gamma u ∉ alpha '' Icc 0 A ∪ beta '' Icc 0 B := by |
| 65 | have hcompactBase : IsCompact (base '' Icc 0 D) := isCompact_Icc.image hb.continuous |
| 66 | have hcompactA : IsCompact (alpha '' Icc 0 A) := isCompact_Icc.image ha.continuous |
| 67 | have hcompactB : IsCompact (beta '' Icc 0 B) := isCompact_Icc.image hc.continuous |
| 68 | have hzeroB : base 0 ∉ beta '' Icc 0 B := by |
| 69 | rintro ⟨t, ht, heq⟩ |
| 70 | exact hD.ne (hbaseB 0 ⟨le_rfl, hD.le⟩ t ht heq.symm).1 |
| 71 | have hendA : base D ∉ alpha '' Icc 0 A := by |
| 72 | rintro ⟨t, ht, heq⟩ |
| 73 | exact hD.ne' (hbaseA D ⟨hD.le, le_rfl⟩ t ht heq.symm).1 |
| 74 | have hcornerA (u : ℝ) (hu : u ∈ Ioo 0 L) : gamma u ≠ alpha 0 := by |
| 75 | rw [← hstartA] |
| 76 | apply m64Intrinsic_constrained_minimizer_avoids_annular_base_corner G hb ha hD hA |
| 77 | hbi hai hstartA.symm hindA hcompactB hzeroB hU hV hdisj |
| 78 | (by simpa only [union_assoc] using hfU) hfV hnormA hinwardA hsub |
| 79 | hgamma hconf hlip hmin hu |
| 80 | let reverseBase := fun t : ℝ => base (D - t) |
| 81 | have hr : ContDiff ℝ ∞ reverseBase := hb.comp (contDiff_const.sub contDiff_id) |
| 82 | have hri : InjOn reverseBase (Icc 0 D) := by |
| 83 | intro s hs t ht heq |
| 84 | have hh := hbi (show D - s ∈ Icc 0 D from ⟨by linarith [hs.2], by linarith [hs.1]⟩) |
| 85 | (show D - t ∈ Icc 0 D from ⟨by linarith [ht.2], by linarith [ht.1]⟩) heq |
| 86 | linarith |
| 87 | have hrimage : reverseBase '' Icc 0 D = base '' Icc 0 D := by |
| 88 | change (base ∘ fun t => D - t) '' Icc 0 D = _ |
| 89 | rw [image_comp, image_const_sub_Icc] |
| 90 | simp only [sub_self, sub_zero] |
| 91 | have hrzero : reverseBase 0 = base D := by simp only [reverseBase, sub_zero] |
| 92 | have hrderiv : deriv reverseBase 0 = -deriv base D := by |
| 93 | have hd : HasDerivAt base (deriv base D) (D - 0) := by |
| 94 | simpa only [sub_zero] using (hb.differentiable (by simp) D).hasDerivAt |
| 95 | have hh := hd.scomp 0 ((hasDerivAt_id (0 : ℝ)).const_sub D) |
| 96 | simpa only [reverseBase, Function.comp_def, id_eq, neg_one_smul] using hh.deriv |
| 97 | have hcornerB (u : ℝ) (hu : u ∈ Ioo 0 L) : gamma u ≠ beta 0 := by |
| 98 | rw [← hstartB, ← hrzero] |
| 99 | apply m64Intrinsic_constrained_minimizer_avoids_annular_base_corner G hr hc hD hB |
| 100 | hri hci (by rw [hrzero]; exact hstartB.symm) |
| 101 | (by simpa only [hrderiv] using hindB) hcompactA |
| 102 | (by simpa only [hrzero] using hendA) hU hV hdisj |
| 103 | (by simpa only [hrimage, union_assoc, union_left_comm, union_comm] using hfU) |
| 104 | hfV (by simpa only [hrzero] using hnormB) |
| 105 | (by simpa only [hrzero] using hinwardB) hsub hgamma hconf hlip hmin hu |
| 106 | have havoidA : ∀ u ∈ Ioo 0 L, gamma u ∉ alpha '' Icc 0 A := by |
| 107 | apply m64Intrinsic_constrained_minimizer_avoids_geodesic_side G ha hai hregA hgeoA |
| 108 | (hcompactBase.union hcompactB) _ hU hV hdisj |
| 109 | (by simpa only [union_assoc, union_left_comm, union_comm] using hfU) hfV |
| 110 | hK hgamma hginj hconf hlip hmin _ hgL hcornerA |
| 111 | · intro t ht hmem |
| 112 | rcases hmem with ⟨s, hs, heq⟩ | ⟨s, hs, heq⟩ |
| 113 | · exact ht.1.ne' (hbaseA s hs t (Ioo_subset_Icc_self ht) heq).2 |
| 114 | · exact ht.2.ne (hsides t (Ioo_subset_Icc_self ht) s hs heq.symm).1 |
| 115 | · rintro ⟨t, ht, heq⟩ |
| 116 | exact hp.1.ne' (hbaseA p (Ioo_subset_Icc_self hp) t ht (hg0.symm.trans heq.symm)).1 |
| 117 | have havoidB : ∀ u ∈ Ioo 0 L, gamma u ∉ beta '' Icc 0 B := by |
| 118 | apply m64Intrinsic_constrained_minimizer_avoids_geodesic_side G hc hci hregB hgeoB |
| 119 | (hcompactBase.union hcompactA) _ hU hV hdisj |
| 120 | (by simpa only [union_assoc, union_left_comm, union_comm] using hfU) hfV |
| 121 | hK hgamma hginj hconf hlip hmin _ (hgL.trans hmeet) hcornerB |
| 122 | · intro t ht hmem |
| 123 | rcases hmem with ⟨s, hs, heq⟩ | ⟨s, hs, heq⟩ |
| 124 | · exact ht.1.ne' (hbaseB s hs t (Ioo_subset_Icc_self ht) heq).2 |
| 125 | · exact ht.2.ne (hsides s hs t (Ioo_subset_Icc_self ht) heq).2 |
| 126 | · rintro ⟨t, ht, heq⟩ |
| 127 | exact hp.2.ne (hbaseB p (Ioo_subset_Icc_self hp) t ht (hg0.symm.trans heq.symm)).1 |
| 128 | intro u hu hmem |
| 129 | exact hmem.elim (havoidA u hu) (havoidB u hu) |
| 130 | |
| 131 | end PoincareMT |