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 | /- Adapted from Mapher `PoincareMT/Proofs/M03/ConnectionDifference.lean` at |
| 2 | f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See |
| 3 | `references/ricci-flow/mapher/local-theory/port.json`. -/ |
| 4 | |
| 5 | import PoincareLib.Geometry.RicciFlow.Local.Connection.Family |
| 6 | |
| 7 | /-! |
| 8 | # The actual difference of two Levi-Civita connections |
| 9 | |
| 10 | Mathlib's difference map takes the section value first and the direction |
| 11 | second. Local frame evaluations give its joint regularity for two smooth |
| 12 | metric families; Koszul uniqueness makes it zero for a common metric. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option maxHeartbeats 1800000 |
| 17 | |
| 18 | open scoped Manifold ContDiff Bundle Topology |
| 19 | open Bundle Manifold Set |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace PoincareMT.RicciFlow.Local |
| 24 | |
| 25 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 26 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 27 | |
| 28 | theorem connection_difference_eq_zero {g : RiemannianMetric n M} |
| 29 | (D D' : LeviCivitaData g) (x : M) : |
| 30 | CovariantDerivative.difference D.connection D'.connection x = 0 := by |
| 31 | apply ContinuousLinearMap.ext |
| 32 | intro v |
| 33 | have hv := FiberBundle.mdifferentiableAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) v |
| 34 | have hdiff := IsCovariantDerivativeOn.difference_apply |
| 35 | D.connection.isCovariantDerivativeOnUniv D'.connection.isCovariantDerivativeOnUniv |
| 36 | (Set.mem_univ x) hv |
| 37 | rw [FiberBundle.extend_apply_self] at hdiff |
| 38 | change CovariantDerivative.difference D.connection D'.connection x v = |
| 39 | D.connection (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x - |
| 40 | D'.connection (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x at hdiff |
| 41 | change CovariantDerivative.difference D.connection D'.connection x v = 0 |
| 42 | rw [hdiff, D.connection_eq_at D' _ hv, sub_self] |
| 43 | |
| 44 | theorem contMDiffOn_connection_family_difference |
| 45 | {g g' : ℝ → RiemannianMetric n M} {J : Set ℝ} |
| 46 | (hg : RiemannianMetric.IsSmoothFamilyOn g J) |
| 47 | (hg' : RiemannianMetric.IsSmoothFamilyOn g' J) |
| 48 | (D : (t : ℝ) → LeviCivitaData (g t)) |
| 49 | (D' : (t : ℝ) → LeviCivitaData (g' t)) : |
| 50 | ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 51 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 52 | EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n))) ∞ |
| 53 | (fun p : ℝ × M => Bundle.TotalSpace.mk' |
| 54 | (EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 55 | EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n)) |
| 56 | (E := fun x : M => TangentSpace (𝓡 n) x →L[ℝ] |
| 57 | TangentSpace (𝓡 n) x →L[ℝ] TangentSpace (𝓡 n) x) |
| 58 | p.2 (CovariantDerivative.difference |
| 59 | (D p.1).connection (D' p.1).connection p.2)) (J ×ˢ Set.univ) := by |
| 60 | intro p hp |
| 61 | let e := trivializationAt (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓡 n)) p.2 |
| 62 | have hep : p.2 ∈ e.baseSet := FiberBundle.mem_baseSet_trivializationAt' p.2 |
| 63 | let frame (a : EuclideanSpace ℝ (Fin n)) (x : M) : TangentSpace (𝓡 n) x := |
| 64 | e.symmL ℝ x a |
| 65 | have hframe (a : EuclideanSpace ℝ (Fin n)) : ContMDiffOn (𝓡 n) |
| 66 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% (frame a)) e.baseSet := by |
| 67 | rw [e.contMDiffOn_section_baseSet_iff (IB := (𝓡 n)) (n := ∞)] |
| 68 | refine (contMDiffOn_const (c := a)).congr ?_ |
| 69 | intro x hx |
| 70 | simpa [frame, Trivialization.symmL_apply _ hx] using |
| 71 | congrArg Prod.snd (e.apply_mk_symm hx a) |
| 72 | let C (q : ℝ × M) : EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 73 | EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n) := |
| 74 | ContinuousLinearMap.inCoordinates (EuclideanSpace ℝ (Fin n)) |
| 75 | (TangentSpace (𝓡 n)) (EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n)) |
| 76 | (fun x => TangentSpace (𝓡 n) x →L[ℝ] TangentSpace (𝓡 n) x) |
| 77 | p.2 q.2 p.2 q.2 |
| 78 | (CovariantDerivative.difference (D q.1).connection (D' q.1).connection q.2) |
| 79 | have hbase : ∀ᶠ q in 𝓝[J ×ˢ (Set.univ : Set M)] p, q.2 ∈ e.baseSet := |
| 80 | Filter.Eventually.filter_mono nhdsWithin_le_nhds |
| 81 | (continuous_snd.continuousAt.preimage_mem_nhds (e.open_baseSet.mem_nhds hep)) |
| 82 | have hsmall : J ×ˢ e.baseSet ∈ 𝓝[J ×ˢ (Set.univ : Set M)] p := by |
| 83 | filter_upwards [self_mem_nhdsWithin, hbase] with q hq hqe |
| 84 | exact ⟨hq.1, hqe⟩ |
| 85 | have hC : ContMDiffWithinAt (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 86 | 𝓘(ℝ, EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 87 | EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n)) ∞ |
| 88 | C (J ×ˢ Set.univ) p := by |
| 89 | apply contMDiffWithinAt_clm_apply_iff.mpr |
| 90 | intro a |
| 91 | apply contMDiffWithinAt_clm_apply_iff.mpr |
| 92 | intro b |
| 93 | have hs₁ := contMDiffOn_connection_family_apply hg D e.open_baseSet |
| 94 | (frame a) (frame b) (hframe a) (hframe b) |
| 95 | have hs₂ := contMDiffOn_connection_family_apply hg' D' e.open_baseSet |
| 96 | (frame a) (frame b) (hframe a) (hframe b) |
| 97 | have hc₁ := (Bundle.contMDiffWithinAt_totalSpace.mp |
| 98 | ((hs₁ p ⟨hp.1, hep⟩).mono_of_mem_nhdsWithin hsmall)).2 |
| 99 | have hc₂ := (Bundle.contMDiffWithinAt_totalSpace.mp |
| 100 | ((hs₂ p ⟨hp.1, hep⟩).mono_of_mem_nhdsWithin hsmall)).2 |
| 101 | apply (hc₁.sub hc₂).congr_of_eventuallyEq_of_mem _ hp |
| 102 | filter_upwards [hbase] with q hq |
| 103 | dsimp [C] |
| 104 | rw [inCoordinates_apply_eq₂ |
| 105 | (F₁ := EuclideanSpace ℝ (Fin n)) (F₂ := EuclideanSpace ℝ (Fin n)) |
| 106 | (F₃ := EuclideanSpace ℝ (Fin n)) |
| 107 | (E₁ := TangentSpace (𝓡 n)) (E₂ := TangentSpace (𝓡 n)) |
| 108 | (E₃ := TangentSpace (𝓡 n)) hq hq hq] |
| 109 | rw [← Trivialization.symmL_apply (R := ℝ) e hq a, |
| 110 | ← Trivialization.symmL_apply (R := ℝ) e hq b] |
| 111 | have ha := ((hframe a).contMDiffAt |
| 112 | (e.open_baseSet.mem_nhds hq)).mdifferentiableAt (by simp) |
| 113 | have hdiff := IsCovariantDerivativeOn.difference_apply |
| 114 | (D q.1).connection.isCovariantDerivativeOnUniv |
| 115 | (D' q.1).connection.isCovariantDerivativeOnUniv (Set.mem_univ q.2) ha |
| 116 | change CovariantDerivative.difference (D q.1).connection (D' q.1).connection q.2 |
| 117 | (frame a q.2) = (D q.1).connection (frame a) q.2 - |
| 118 | (D' q.1).connection (frame a) q.2 at hdiff |
| 119 | change e.linearMapAt ℝ q.2 |
| 120 | (CovariantDerivative.difference (D q.1).connection (D' q.1).connection q.2 |
| 121 | (frame a q.2) (frame b q.2)) = _ |
| 122 | rw [hdiff, sub_apply, map_sub] |
| 123 | simp only [Trivialization.linearMapAt_apply, if_pos hq] |
| 124 | rfl |
| 125 | let F : ℝ × M → TotalSpace (EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 126 | EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n)) |
| 127 | (fun x => TangentSpace (𝓡 n) x →L[ℝ] |
| 128 | TangentSpace (𝓡 n) x →L[ℝ] TangentSpace (𝓡 n) x) := |
| 129 | fun q => TotalSpace.mk' (EuclideanSpace ℝ (Fin n) →L[ℝ] |
| 130 | EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n)) q.2 |
| 131 | (CovariantDerivative.difference (D q.1).connection (D' q.1).connection q.2) |
| 132 | exact (contMDiffWithinAt_hom_bundle F (s := J ×ˢ Set.univ) (x₀ := p)).mpr |
| 133 | ⟨contMDiffWithinAt_snd, hC⟩ |
| 134 | |
| 135 | end PoincareMT.RicciFlow.Local |