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.Straight.JoinGeometry |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.Analysis.Piecewise.FirstJet |
| 3 | |
| 4 | /-! |
| 5 | # The actual continuous graph at a regular straight join |
| 6 | |
| 7 | The two original smooth arcs have a common tangent-projection frame. Their |
| 8 | graph functions have matching values and zero first derivatives at the |
| 9 | join, giving one continuous graph with its actual derivative there. |
| 10 | Source: MT Claim 19.40, pp. 470-471; minimal-contact derivation, Section 9. |
| 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 |
| 19 | open Poincare.Topology.Plane.Curves |
| 20 | |
| 21 | namespace PoincareMT |
| 22 | |
| 23 | /-- Actual regular endpoint tangency produces a graph of both short arcs in one linear |
| 24 | frame. The joined graph is continuous and has derivative zero at the contact, with no |
| 25 | assertion about higher derivatives there. Source: |
| 26 | `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, Section 9. -/ |
| 27 | theorem m64Intrinsic_exists_straight_join_graph |
| 28 | {alpha beta : ℝ → AnnulusCoordinates} |
| 29 | (ha : ContDiff ℝ ∞ alpha) (hb : ContDiff ℝ ∞ beta) |
| 30 | {A B c eta : ℝ} (heta : 0 < eta) (hc : 0 < c) |
| 31 | (hend : alpha A = beta B) (hreg : deriv alpha A ≠ 0) |
| 32 | (htan : deriv beta B = c • deriv alpha A) : |
| 33 | ∃ epsilon > 0, epsilon < eta ∧ |
| 34 | ∃ (L : AnnulusCoordinates ≃L[ℝ] (ℝ × ℝ)) (X : Set ℝ) (h : ℝ → ℝ), |
| 35 | (∀ z, L z = (inner ℝ (deriv alpha A) z, |
| 36 | inner ℝ (quarterTurn (deriv alpha A)) z)) ∧ |
| 37 | IsOpen X ∧ ContinuousOn h X ∧ (L (alpha A)).1 ∈ X ∧ |
| 38 | HasDerivAt h 0 (L (alpha A)).1 ∧ |
| 39 | ∀ z : AnnulusCoordinates, (L z).1 ∈ X → |
| 40 | (z ∈ alpha '' Icc (A - epsilon) A ∪ beta '' Icc B (B + epsilon) ↔ |
| 41 | (L z).2 = h (L z).1) := by |
| 42 | classical |
| 43 | obtain ⟨epsilon, hepsilon, heeta, hleft, hright, _, _, _⟩ := |
| 44 | m64Intrinsic_straight_join_local_geometry ha hb heta hc hend hreg htan |
| 45 | have hAE : A - epsilon < A := sub_lt_self _ hepsilon |
| 46 | have hBE : B < B + epsilon := lt_add_of_pos_right _ hepsilon |
| 47 | obtain ⟨la, ua, G, L, f, hla, hua, hsource, hGval, hL, hm, hGs, |
| 48 | _, _, hf, hgraph, himage, htarget, _⟩ := |
| 49 | exists_graph_coordinates_of_positive_projection ha hAE.le |
| 50 | (fun t ht => (hleft t ht).1) |
| 51 | obtain ⟨lb, ub, H, R, g, hlb, hub, hsource', hHval, hR, hm', hHs, |
| 52 | _, _, hg, hgraph', himage', htarget', _⟩ := |
| 53 | exists_graph_coordinates_of_positive_projection hb hBE.le |
| 54 | (fun t ht => (hright t ht).1) |
| 55 | have hLR : L = R := by |
| 56 | apply ContinuousLinearEquiv.ext |
| 57 | funext z |
| 58 | exact (hL z).trans (hR z).symm |
| 59 | subst R |
| 60 | have hI : Icc (A - epsilon) A ⊆ G.source := by |
| 61 | rw [hsource] |
| 62 | exact fun t ht => ⟨hla.trans_le ht.1, ht.2.trans_lt hua⟩ |
| 63 | have hJ : Icc B (B + epsilon) ⊆ H.source := by |
| 64 | rw [hsource'] |
| 65 | exact fun t ht => ⟨hlb.trans_le ht.1, ht.2.trans_lt hub⟩ |
| 66 | have hG : StrictMonoOn G G.source := by |
| 67 | intro x hx y hy hxy |
| 68 | simpa only [hGval] using hm hx hy hxy |
| 69 | have hH : StrictMonoOn H H.source := by |
| 70 | intro x hx y hy hxy |
| 71 | simpa only [hHval] using hm' hx hy hxy |
| 72 | have hA := hI (right_mem_Icc.mpr hAE.le) |
| 73 | have hB := hJ (left_mem_Icc.mpr hBE.le) |
| 74 | have hbase : G A = H B := by rw [hGval, hHval, hend] |
| 75 | have hLpoint : (L (alpha A)).1 = G A := congrArg Prod.fst (hgraph A hA) |
| 76 | have hfg : f (G A) = g (G A) := by |
| 77 | have heq := congrArg L hend |
| 78 | rw [hgraph A hA, hgraph' B hB, ← hbase] at heq |
| 79 | exact congrArg Prod.snd heq |
| 80 | have hta := m64Intrinsic_graph_tangent ha L G hGs hf hgraph hA |
| 81 | have htb := m64Intrinsic_graph_tangent hb L H hHs hg hgraph' hB |
| 82 | have hGa : 0 < deriv G A := by |
| 83 | have hfirst := congrArg Prod.fst hta |
| 84 | simp only [Prod.smul_fst, smul_eq_mul, mul_one] at hfirst |
| 85 | rw [← hfirst, hL] |
| 86 | exact real_inner_self_pos.mpr hreg |
| 87 | have hHb : 0 < deriv H B := by |
| 88 | have hfirst := congrArg Prod.fst htb |
| 89 | simp only [Prod.smul_fst, smul_eq_mul, mul_one] at hfirst |
| 90 | rw [← hfirst, hL] |
| 91 | exact (hright B (left_mem_Icc.mpr hBE.le)).1 |
| 92 | have hz : (L (deriv alpha A)).2 = 0 := by |
| 93 | rw [hL] |
| 94 | exact (real_inner_comm _ _).trans (inner_quarterTurn_self _) |
| 95 | have hz' : (L (deriv beta B)).2 = 0 := by |
| 96 | rw [htan, map_smul, Prod.smul_snd, smul_eq_mul, hz, mul_zero] |
| 97 | have hfzero : deriv f (G A) = 0 := by |
| 98 | have hs := congrArg Prod.snd hta |
| 99 | simp only [Prod.smul_snd, smul_eq_mul, hz] at hs |
| 100 | exact (mul_eq_zero.mp hs.symm).resolve_left hGa.ne' |
| 101 | have hgzero : deriv g (G A) = 0 := by |
| 102 | have hs := congrArg Prod.snd htb |
| 103 | simp only [Prod.smul_snd, smul_eq_mul, hz'] at hs |
| 104 | rw [hbase] |
| 105 | exact (mul_eq_zero.mp hs.symm).resolve_left hHb.ne' |
| 106 | have hdf : HasDerivAt f 0 (G A) := by |
| 107 | rw [← hfzero] |
| 108 | exact ((hf.contDiffAt (G.open_target.mem_nhds (G.map_source hA))).differentiableAt |
| 109 | (by simp)).hasDerivAt |
| 110 | have hdg : HasDerivAt g 0 (G A) := by |
| 111 | rw [← hgzero] |
| 112 | exact ((hg.contDiffAt (H.open_target.mem_nhds (hbase ▸ H.map_source hB))).differentiableAt |
| 113 | (by simp)).hasDerivAt |
| 114 | let X := (G.target ∩ H.target) ∩ Ioo (G (A - epsilon)) (H (B + epsilon)) |
| 115 | let h : ℝ → ℝ := (Iic (G A)).piecewise f g |
| 116 | have hX : IsOpen X := (G.open_target.inter H.open_target).inter isOpen_Ioo |
| 117 | have hx : G A ∈ X := ⟨⟨G.map_source hA, hbase ▸ H.map_source hB⟩, |
| 118 | hG (hI (left_mem_Icc.mpr hAE.le)) hA hAE, |
| 119 | hbase ▸ hH hB (hJ (right_mem_Icc.mpr hBE.le)) hBE⟩ |
| 120 | have hfc : ContinuousOn f X := hf.continuousOn.mono (fun _ ht => ht.1.1) |
| 121 | have hgc : ContinuousOn g X := hg.continuousOn.mono (fun _ ht => ht.1.2) |
| 122 | have hh : ContinuousOn h X := by |
| 123 | apply ContinuousOn.if |
| 124 | · intro t ht |
| 125 | have ht0 : t = G A := by |
| 126 | have ht' := ht.2 |
| 127 | change t ∈ frontier (Iic (G A)) at ht' |
| 128 | simpa only [frontier_Iic, mem_singleton_iff] using ht' |
| 129 | simpa only [ht0] using hfg |
| 130 | · exact hfc.mono inter_subset_left |
| 131 | · exact hgc.mono inter_subset_left |
| 132 | have hd : HasDerivAt h 0 (G A) := |
| 133 | m64HasDerivAt_piecewise_of_same_jet hdf hdg hfg (Iic (G A)) |
| 134 | refine ⟨epsilon, hepsilon, heeta, L, X, h, hL, hX, hh, |
| 135 | hLpoint ▸ hx, hLpoint ▸ hd, ?_⟩ |
| 136 | intro z hzX |
| 137 | constructor |
| 138 | · rintro (⟨s, hs, rfl⟩ | ⟨t, ht, rfl⟩) |
| 139 | · have hle : G s ≤ G A := hG.monotoneOn (hI hs) hA hs.2 |
| 140 | rw [hgraph s (hI hs)] |
| 141 | exact (piecewise_eq_of_mem (Iic (G A)) f g hle).symm |
| 142 | · have hge : G A ≤ H t := hbase ▸ hH.monotoneOn hB (hJ ht) ht.1 |
| 143 | rw [hgraph' t (hJ ht)] |
| 144 | change g (H t) = (Iic (G A)).piecewise f g (H t) |
| 145 | by_cases hle : H t ≤ G A |
| 146 | · have ht0 := le_antisymm hle hge |
| 147 | rw [piecewise_eq_of_mem (Iic (G A)) f g hle, ht0, hfg] |
| 148 | · exact (piecewise_eq_of_notMem (Iic (G A)) f g hle).symm |
| 149 | · intro hz |
| 150 | by_cases hle : (L z).1 ≤ G A |
| 151 | · have hxI : (L z).1 ∈ Icc (G (A - epsilon)) (G A) := ⟨hzX.2.1.le, hle⟩ |
| 152 | obtain ⟨s, hs, hGsx⟩ := (himage ▸ hxI : (L z).1 ∈ G '' Icc (A - epsilon) A) |
| 153 | refine Or.inl ⟨s, hs, L.injective ?_⟩ |
| 154 | rw [hgraph s (hI hs), hGsx] |
| 155 | refine Prod.ext rfl ?_ |
| 156 | rw [hz] |
| 157 | exact (piecewise_eq_of_mem (Iic (G A)) f g hle).symm |
| 158 | · have hxI : (L z).1 ∈ Icc (H B) (H (B + epsilon)) := |
| 159 | ⟨hbase ▸ (le_of_not_ge hle), hzX.2.2.le⟩ |
| 160 | obtain ⟨t, ht, hHtx⟩ := (himage' ▸ hxI : (L z).1 ∈ H '' Icc B (B + epsilon)) |
| 161 | refine Or.inr ⟨t, ht, L.injective ?_⟩ |
| 162 | rw [hgraph' t (hJ ht), hHtx] |
| 163 | refine Prod.ext rfl ?_ |
| 164 | rw [hz] |
| 165 | exact (piecewise_eq_of_notMem (Iic (G A)) f g hle).symm |
| 166 | |
| 167 | end PoincareMT |