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/Existence/ConjugatorWithinDerivativeNative.lean` at |
| 2 | f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See |
| 3 | `references/ricci-flow/mapher/local-theory/port.json`. -/ |
| 4 | |
| 5 | import PoincareLib.Geometry.RicciFlow.Local.Gauge.Flow.ConjugatorLieDerivative |
| 6 | import Mathlib.Analysis.Calculus.TangentCone.Prod |
| 7 | import Mathlib.Analysis.Calculus.TangentCone.Real |
| 8 | |
| 9 | /-! |
| 10 | # The variational equation at the initial endpoint |
| 11 | |
| 12 | Second derivatives within a product domain are symmetric at points accumulated |
| 13 | by its interior. This proves the flow variational equation with exactly the |
| 14 | within-set regularity of the short-time metric and conjugator. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | set_option maxHeartbeats 2000000 |
| 19 | |
| 20 | noncomputable section |
| 21 | |
| 22 | open scoped ContDiff Topology |
| 23 | |
| 24 | namespace PoincareMT.ConjugatorLieDerivativeNative |
| 25 | |
| 26 | variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 27 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 28 | |
| 29 | theorem mem_closure_interior_Ico_prod {U : Set E} (hU : IsOpen U) |
| 30 | {T t : ℝ} (hT : 0 < T) (ht : t ∈ Set.Ico 0 T) {x : E} (hx : x ∈ U) : |
| 31 | (t, x) ∈ closure (interior (Set.Ico 0 T ×ˢ U)) := by |
| 32 | rw [interior_prod_eq, interior_Ico, hU.interior_eq, closure_prod_eq, |
| 33 | closure_Ioo (ne_of_lt hT)] |
| 34 | exact ⟨⟨ht.1, ht.2.le⟩, subset_closure hx⟩ |
| 35 | |
| 36 | private theorem spatial_fderiv_eq_within {f : ℝ × E → F} |
| 37 | {J : Set ℝ} {U : Set E} {t : ℝ} {x : E} |
| 38 | (hU : IsOpen U) (ht : t ∈ J) (hx : x ∈ U) |
| 39 | (hf : DifferentiableWithinAt ℝ f (J ×ˢ U) (t, x)) : |
| 40 | fderiv ℝ (fun z => f (t, z)) x = |
| 41 | (fderivWithin ℝ f (J ×ˢ U) (t, x)).comp |
| 42 | (ContinuousLinearMap.inr ℝ ℝ E) := by |
| 43 | have hmaps : ∀ᶠ z in 𝓝 x, (t, z) ∈ J ×ˢ U := by |
| 44 | filter_upwards [hU.mem_nhds hx] with z hz using ⟨ht, hz⟩ |
| 45 | exact (hf.hasFDerivWithinAt.comp_hasFDerivAt x |
| 46 | (hasFDerivAt_prodMk_right t x) hmaps).fderiv |
| 47 | |
| 48 | theorem hasDerivWithinAt_spatial_fderiv_of_orbit |
| 49 | {f : ℝ × E → F} {V : F → F} {J : Set ℝ} {U : Set E} {t : ℝ} {x : E} |
| 50 | (hU : IsOpen U) (hJ : UniqueDiffOn ℝ J) (ht : t ∈ J) (hx : x ∈ U) |
| 51 | (hinterior : (t, x) ∈ closure (interior (J ×ˢ U))) |
| 52 | (hf : ContDiffWithinAt ℝ 2 f (J ×ˢ U) (t, x)) |
| 53 | (hV : DifferentiableAt ℝ V (f (t, x))) |
| 54 | (horbit : ∀ᶠ z in 𝓝 x, |
| 55 | HasDerivWithinAt (fun s => f (s, z)) (V (f (t, z))) J t) |
| 56 | (u : E) : |
| 57 | HasDerivWithinAt (fun s => fderiv ℝ (fun z => f (s, z)) x u) |
| 58 | (fderiv ℝ V (f (t, x)) (fderiv ℝ (fun z => f (t, z)) x u)) J t := by |
| 59 | let S := J ×ˢ U |
| 60 | have hS : UniqueDiffOn ℝ S := hJ.prod hU.uniqueDiffOn |
| 61 | have hmem : (t, x) ∈ S := ⟨ht, hx⟩ |
| 62 | have hfd : DifferentiableWithinAt ℝ (fderivWithin ℝ f S) S (t, x) := |
| 63 | (hf.fderivWithin_right hS (m := 1) (by norm_num) hmem).differentiableWithinAt one_ne_zero |
| 64 | have hlocal : ∀ᶠ q in 𝓝[S] (t, x), DifferentiableWithinAt ℝ f S q := by |
| 65 | have h := hf.eventually (by norm_num) |
| 66 | rw [Set.insert_eq_of_mem hmem] at h |
| 67 | exact h.mono fun _ hq => hq.differentiableWithinAt two_ne_zero |
| 68 | have hmapsTime : Set.MapsTo (fun s : ℝ => (s, x)) J S := fun _ hs => ⟨hs, hx⟩ |
| 69 | have htx : Filter.Tendsto (fun s : ℝ => (s, x)) (𝓝[J] t) (𝓝[S] (t, x)) := |
| 70 | (show ContinuousWithinAt (fun s : ℝ => (s, x)) J t from by fun_prop).tendsto_nhdsWithin hmapsTime |
| 71 | have hspaceMem : ∀ᶠ z in 𝓝 x, (t, z) ∈ S := by |
| 72 | filter_upwards [hU.mem_nhds hx] with z hz using ⟨ht, hz⟩ |
| 73 | have htz : Filter.Tendsto (fun z : E => (t, z)) (𝓝 x) (𝓝[S] (t, x)) := |
| 74 | tendsto_nhdsWithin_iff.mpr |
| 75 | ⟨(continuous_const.prodMk continuous_id).continuousAt, hspaceMem⟩ |
| 76 | have htime : (fun z => fderivWithin ℝ f S (t, z) (1, 0)) =ᶠ[𝓝 x] |
| 77 | (fun z => V (f (t, z))) := by |
| 78 | filter_upwards [htz hlocal, horbit, hU.mem_nhds hx] with z hz hode hzU |
| 79 | have hline : HasDerivWithinAt (fun s : ℝ => (s, z)) (1, 0) J t := by |
| 80 | simpa using HasDerivWithinAt.prodMk (hasDerivWithinAt_id t J) |
| 81 | (hasDerivWithinAt_const t J z) |
| 82 | have hcurve := HasFDerivWithinAt.comp_hasDerivWithinAt t |
| 83 | (f := fun s : ℝ => (s, z)) hz.hasFDerivWithinAt hline |
| 84 | (fun _ hs => ⟨hs, hzU⟩) |
| 85 | exact (hJ t ht).eq_deriv _ hcurve hode |
| 86 | have hline : HasDerivWithinAt (fun s : ℝ => (s, x)) (1, 0) J t := by |
| 87 | simpa using HasDerivWithinAt.prodMk (hasDerivWithinAt_id t J) |
| 88 | (hasDerivWithinAt_const t J x) |
| 89 | have hDtime := (HasFDerivWithinAt.comp_hasDerivWithinAt t |
| 90 | (f := fun s : ℝ => (s, x)) hfd.hasFDerivWithinAt hline hmapsTime).clm_apply |
| 91 | (hasDerivWithinAt_const t J ((0, u) : ℝ × E)) |
| 92 | have hspatial : |
| 93 | (fun s => fderiv ℝ (fun z => f (s, z)) x u) =ᶠ[𝓝[J] t] |
| 94 | (fun s => fderivWithin ℝ f S (s, x) (0, u)) := by |
| 95 | filter_upwards [htx hlocal, self_mem_nhdsWithin] with s hs hsJ |
| 96 | rw [spatial_fderiv_eq_within hU hsJ hx hs] |
| 97 | rfl |
| 98 | have hspush : HasDerivWithinAt (fun s => fderiv ℝ (fun z => f (s, z)) x u) |
| 99 | (fderivWithin ℝ (fderivWithin ℝ f S) S (t, x) (1, 0) (0, u)) J t := by |
| 100 | have hval : fderiv ℝ (fun z => f (t, z)) x u = |
| 101 | fderivWithin ℝ f S (t, x) (0, u) := by |
| 102 | rw [spatial_fderiv_eq_within hU ht hx (hf.differentiableWithinAt two_ne_zero)] |
| 103 | rfl |
| 104 | apply HasDerivWithinAt.congr_of_eventuallyEq _ hspatial hval |
| 105 | simpa only [map_zero, add_zero, Function.comp_apply] using hDtime |
| 106 | have hspaceTime : HasFDerivAt (fun z => fderivWithin ℝ f S (t, z) (1, 0)) |
| 107 | (((fderivWithin ℝ (fderivWithin ℝ f S) S (t, x)).comp |
| 108 | (ContinuousLinearMap.inr ℝ ℝ E)).flip (1, 0)) x := by |
| 109 | have h := (hfd.hasFDerivWithinAt.comp_hasFDerivAt x |
| 110 | (hasFDerivAt_prodMk_right t x) hspaceMem).clm_apply |
| 111 | (hasFDerivAt_const ((1, 0) : ℝ × E) x) |
| 112 | simpa using h |
| 113 | have hslice : DifferentiableAt ℝ (fun z => f (t, z)) x := |
| 114 | ((hf.differentiableWithinAt two_ne_zero).hasFDerivWithinAt.comp_hasFDerivAt x |
| 115 | (hasFDerivAt_prodMk_right t x) hspaceMem).differentiableAt |
| 116 | have hcomp : HasFDerivAt (fun z => V (f (t, z))) |
| 117 | ((fderiv ℝ V (f (t, x))).comp (fderiv ℝ (fun z => f (t, z)) x)) x := |
| 118 | hV.hasFDerivAt.comp x hslice.hasFDerivAt |
| 119 | have hderivs := (hspaceTime.congr_of_eventuallyEq htime.symm).unique hcomp |
| 120 | have hmixed := hf.isSymmSndFDerivWithinAt (by |
| 121 | rw [minSmoothness_of_isRCLikeNormedField]) hS hinterior hmem |
| 122 | apply hspush.congr_deriv |
| 123 | calc |
| 124 | fderivWithin ℝ (fderivWithin ℝ f S) S (t, x) (1, 0) (0, u) = |
| 125 | fderivWithin ℝ (fderivWithin ℝ f S) S (t, x) (0, u) (1, 0) := |
| 126 | hmixed.eq (1, 0) (0, u) |
| 127 | _ = _ := congrArg (fun A : E →L[ℝ] F => A u) hderivs |
| 128 | |
| 129 | theorem hasDerivWithinAt_pullback_coefficient_of_contDiffWithinAt |
| 130 | {f : ℝ × E → F} {V : F → F} |
| 131 | {G : F → F →L[ℝ] F →L[ℝ] ℝ} {J : Set ℝ} {U : Set E} {t : ℝ} {x : E} |
| 132 | (hU : IsOpen U) (hJ : UniqueDiffOn ℝ J) (ht : t ∈ J) (hx : x ∈ U) |
| 133 | (hinterior : (t, x) ∈ closure (interior (J ×ˢ U))) |
| 134 | (hf : ContDiffWithinAt ℝ 2 f (J ×ˢ U) (t, x)) |
| 135 | (hV : DifferentiableAt ℝ V (f (t, x))) |
| 136 | (hG : DifferentiableAt ℝ G (f (t, x))) |
| 137 | (horbit : ∀ᶠ z in 𝓝 x, |
| 138 | HasDerivWithinAt (fun s => f (s, z)) (V (f (t, z))) J t) |
| 139 | (u v : E) : |
| 140 | HasDerivWithinAt |
| 141 | (fun s => G (f (s, x)) |
| 142 | (fderiv ℝ (fun z => f (s, z)) x u) |
| 143 | (fderiv ℝ (fun z => f (s, z)) x v)) |
| 144 | (coordinateLieMetric G V (f (t, x)) |
| 145 | (fderiv ℝ (fun z => f (t, z)) x u) |
| 146 | (fderiv ℝ (fun z => f (t, z)) x v)) J t := by |
| 147 | have hbase : HasDerivWithinAt (fun s => G (f (s, x))) |
| 148 | (fderiv ℝ G (f (t, x)) (V (f (t, x)))) J t := |
| 149 | HasFDerivAt.comp_hasDerivWithinAt t (l := G) |
| 150 | (f := fun s : ℝ => f (s, x)) hG.hasFDerivAt horbit.self_of_nhds |
| 151 | have hu := hasDerivWithinAt_spatial_fderiv_of_orbit hU hJ ht hx hinterior hf hV horbit u |
| 152 | have hv := hasDerivWithinAt_spatial_fderiv_of_orbit hU hJ ht hx hinterior hf hV horbit v |
| 153 | simpa only [coordinateLieMetric, ContinuousLinearMap.add_apply, Function.comp_apply] |
| 154 | using (hbase.clm_apply hu).clm_apply hv |
| 155 | |
| 156 | end PoincareMT.ConjugatorLieDerivativeNative |
| 157 | |
| 158 | end |