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.Analysis.ODE.ParameterCurveSpace |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Basic |
| 3 | |
| 4 | /-! |
| 5 | # Superposition for parameter dependent ODEs |
| 6 | |
| 7 | Adapted from the corresponding DoCarmo analytic development at workspace |
| 8 | revision 1971ab2f. Supports Morgan--Tian (2007), equation (3.9) and |
| 9 | Claim 3.16, p. 42, through smooth dependence of local flows. |
| 10 | -/ |
| 11 | |
| 12 | open Filter Set |
| 13 | open scoped Topology ContDiff |
| 14 | |
| 15 | set_option linter.unusedSectionVars false |
| 16 | |
| 17 | noncomputable section |
| 18 | |
| 19 | namespace Poincare.ODE.Parameter |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 24 | variable {K : Type*} [TopologicalSpace K] [CompactSpace K] |
| 25 | |
| 26 | section GeneralTarget |
| 27 | |
| 28 | variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 29 | |
| 30 | open Classical in |
| 31 | |
| 32 | def superpositionGen (f : E → F) : C(K, E) → C(K, F) := fun α => |
| 33 | if h : Continuous (f ∘ α) then ⟨f ∘ α, h⟩ else 0 |
| 34 | |
| 35 | lemma superpositionGen_apply_of_continuousOn {f : E → F} {s : Set E} |
| 36 | (hf : ContinuousOn f s) (α : C(K, E)) (hα : ∀ t, α t ∈ s) (t : K) : |
| 37 | superpositionGen f α t = f (α t) := by |
| 38 | have h : Continuous (f ∘ α) := hf.comp_continuous α.continuous hα |
| 39 | simp only [superpositionGen] |
| 40 | rw [dif_pos h] |
| 41 | rfl |
| 42 | |
| 43 | lemma superpositionGen_apply {f : E → F} (hf : Continuous f) (α : C(K, E)) (t : K) : |
| 44 | superpositionGen f α t = f (α t) := |
| 45 | superpositionGen_apply_of_continuousOn hf.continuousOn α (fun _ => Set.mem_univ _) t |
| 46 | |
| 47 | lemma superpositionGen_eq_superposition (f : E → E) : |
| 48 | superpositionGen (K := K) f = superposition f := rfl |
| 49 | |
| 50 | theorem continuous_superpositionGen {f : E → F} (hf : Continuous f) : |
| 51 | Continuous (superpositionGen (K := K) f) := by |
| 52 | rw [Metric.continuous_iff] |
| 53 | intro α₀ ε hε |
| 54 | have hcomp : IsCompact (Set.range α₀) := isCompact_range α₀.continuous |
| 55 | obtain ⟨δ, hδ, H⟩ := |
| 56 | hcomp.exists_forall_dist_image_lt_of_continuousAt (fun x _ => hf.continuousAt) hε |
| 57 | refine ⟨δ, hδ, fun α hα => ?_⟩ |
| 58 | rw [ContinuousMap.dist_lt_iff hε] |
| 59 | intro t |
| 60 | rw [superpositionGen_apply hf, superpositionGen_apply hf, dist_comm] |
| 61 | refine H (α₀ t) (Set.mem_range_self t) (α t) ?_ |
| 62 | calc dist (α₀ t) (α t) ≤ dist α₀ α := ContinuousMap.dist_apply_le_dist t |
| 63 | _ = dist α α₀ := dist_comm _ _ |
| 64 | _ < δ := hα |
| 65 | |
| 66 | theorem hasStrictFDerivAt_superpositionGen |
| 67 | {f : E → F} {f' : E → E →L[ℝ] F} {u : Set E} (hu : IsOpen u) |
| 68 | (hd : ∀ x ∈ u, HasFDerivAt f (f' x) x) |
| 69 | {α₀ : C(K, E)} (hmem : ∀ t, α₀ t ∈ u) |
| 70 | (hc : ∀ t, ContinuousAt f' (α₀ t)) |
| 71 | {A₀ : C(K, E →L[ℝ] F)} (hA₀ : ∀ t, A₀ t = f' (α₀ t)) : |
| 72 | HasStrictFDerivAt (superpositionGen f) (postcompCurve A₀) α₀ := by |
| 73 | have hcont : ContinuousOn f u := fun y hy => (hd y hy).continuousAt.continuousWithinAt |
| 74 | have hrange : IsCompact (Set.range α₀) := isCompact_range α₀.continuous |
| 75 | have hrangeu : Set.range α₀ ⊆ u := Set.range_subset_iff.mpr hmem |
| 76 | obtain ⟨δ₁, hδ₁, hthick⟩ := hrange.exists_thickening_subset_open hu hrangeu |
| 77 | refine .of_isLittleO (Asymptotics.isLittleO_iff.mpr fun ε hε => ?_) |
| 78 | have hcrange : ∀ x ∈ Set.range α₀, ContinuousAt f' x := by |
| 79 | rintro x ⟨t, rfl⟩; exact hc t |
| 80 | obtain ⟨δ₂, hδ₂, hunif⟩ := |
| 81 | hrange.exists_forall_dist_image_lt_of_continuousAt hcrange (half_pos hε) |
| 82 | have hδpos : (0:ℝ) < min δ₁ δ₂ := lt_min hδ₁ hδ₂ |
| 83 | have hball : ∀ t, Metric.ball (α₀ t) (min δ₁ δ₂) ⊆ u := fun t y hy => |
| 84 | hthick (Metric.mem_thickening_iff.mpr ⟨α₀ t, Set.mem_range_self t, |
| 85 | (Metric.mem_ball.mp hy).trans_le (min_le_left _ _)⟩) |
| 86 | have key : ∀ t : K, ∀ a ∈ Metric.ball (α₀ t) (min δ₁ δ₂), |
| 87 | ∀ b ∈ Metric.ball (α₀ t) (min δ₁ δ₂), |
| 88 | ‖f a - f b - f' (α₀ t) (a - b)‖ ≤ ε * ‖a - b‖ := by |
| 89 | intro t a ha b hb |
| 90 | have hg : ∀ y ∈ Metric.ball (α₀ t) (min δ₁ δ₂), |
| 91 | HasFDerivWithinAt (fun z => f z - f' (α₀ t) z) (f' y - f' (α₀ t)) |
| 92 | (Metric.ball (α₀ t) (min δ₁ δ₂)) y := fun y hy => |
| 93 | ((hd y (hball t hy)).sub (f' (α₀ t)).hasFDerivAt).hasFDerivWithinAt |
| 94 | have hbound : ∀ y ∈ Metric.ball (α₀ t) (min δ₁ δ₂), ‖f' y - f' (α₀ t)‖ ≤ ε := |
| 95 | fun y hy => by |
| 96 | have h1 : dist (α₀ t) y < δ₂ := by |
| 97 | rw [dist_comm] |
| 98 | exact (Metric.mem_ball.mp hy).trans_le (min_le_right _ _) |
| 99 | have h2 := hunif (α₀ t) (Set.mem_range_self t) y h1 |
| 100 | rw [dist_eq_norm] at h2 |
| 101 | calc ‖f' y - f' (α₀ t)‖ = ‖f' (α₀ t) - f' y‖ := norm_sub_rev _ _ |
| 102 | _ ≤ ε := by linarith |
| 103 | have hmvt := (convex_ball (α₀ t) (min δ₁ δ₂)).norm_image_sub_le_of_norm_hasFDerivWithin_le |
| 104 | hg hbound hb ha |
| 105 | calc ‖f a - f b - f' (α₀ t) (a - b)‖ |
| 106 | = ‖(f a - f' (α₀ t) a) - (f b - f' (α₀ t) b)‖ := by rw [map_sub]; congr 1; abel |
| 107 | _ ≤ ε * ‖a - b‖ := hmvt |
| 108 | filter_upwards [prod_mem_nhds |
| 109 | (Metric.ball_mem_nhds α₀ hδpos) (Metric.ball_mem_nhds α₀ hδpos)] |
| 110 | rintro ⟨α, β⟩ ⟨hα, hβ⟩ |
| 111 | have hval : ∀ {γ : C(K, E)}, γ ∈ Metric.ball α₀ (min δ₁ δ₂) → |
| 112 | ∀ t, γ t ∈ Metric.ball (α₀ t) (min δ₁ δ₂) := by |
| 113 | intro γ hγ t |
| 114 | rw [Metric.mem_ball, dist_eq_norm] at hγ ⊢ |
| 115 | calc ‖γ t - α₀ t‖ = ‖(γ - α₀) t‖ := by rw [ContinuousMap.sub_apply] |
| 116 | _ ≤ ‖γ - α₀‖ := ContinuousMap.norm_coe_le_norm _ t |
| 117 | _ < min δ₁ δ₂ := hγ |
| 118 | have hαval : ∀ t, α t ∈ u := fun t => hball t (hval hα t) |
| 119 | have hβval : ∀ t, β t ∈ u := fun t => hball t (hval hβ t) |
| 120 | refine (ContinuousMap.norm_le _ (mul_nonneg hε.le (norm_nonneg _))).mpr fun t => ?_ |
| 121 | have hpt : (superpositionGen f α - superpositionGen f β - postcompCurve A₀ (α - β)) t |
| 122 | = f (α t) - f (β t) - f' (α₀ t) (α t - β t) := by |
| 123 | rw [ContinuousMap.sub_apply, ContinuousMap.sub_apply, postcompCurve_apply, |
| 124 | ContinuousMap.sub_apply, hA₀, |
| 125 | superpositionGen_apply_of_continuousOn hcont α hαval, |
| 126 | superpositionGen_apply_of_continuousOn hcont β hβval] |
| 127 | rw [hpt] |
| 128 | have h2 : ‖α t - β t‖ ≤ ‖α - β‖ := by |
| 129 | have h3 := ContinuousMap.norm_coe_le_norm (α - β) t |
| 130 | rwa [ContinuousMap.sub_apply] at h3 |
| 131 | exact (key t _ (hval hα t) _ (hval hβ t)).trans (mul_le_mul_of_nonneg_left h2 hε.le) |
| 132 | |
| 133 | end GeneralTarget |
| 134 | |
| 135 | section PostcompL |
| 136 | |
| 137 | variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 138 | |
| 139 | def postcompCurveLM : C(K, E →L[ℝ] F) →ₗ[ℝ] (C(K, E) →L[ℝ] C(K, F)) where |
| 140 | toFun A := postcompCurve A |
| 141 | map_add' A B := by |
| 142 | ext β t |
| 143 | simp only [postcompCurve_apply, add_apply, ContinuousMap.add_apply] |
| 144 | map_smul' c A := by |
| 145 | ext β t |
| 146 | simp only [postcompCurve_apply, smul_apply, ContinuousMap.smul_apply, |
| 147 | RingHom.id_apply] |
| 148 | |
| 149 | @[simp] lemma postcompCurveLM_apply (A : C(K, E →L[ℝ] F)) : |
| 150 | postcompCurveLM A = postcompCurve A := rfl |
| 151 | |
| 152 | def postcompCurveL : C(K, E →L[ℝ] F) →L[ℝ] (C(K, E) →L[ℝ] C(K, F)) := |
| 153 | postcompCurveLM.mkContinuous 1 |
| 154 | (fun (A : C(K, E →L[ℝ] F)) => by rw [one_mul]; exact norm_postcompCurve_le A) |
| 155 | |
| 156 | @[simp] lemma postcompCurveL_apply (A : C(K, E →L[ℝ] F)) : |
| 157 | postcompCurveL A = postcompCurve A := by |
| 158 | simp only [postcompCurveL, LinearMap.mkContinuous_apply, postcompCurveLM_apply] |
| 159 | |
| 160 | end PostcompL |
| 161 | |
| 162 | theorem contDiff_superpositionGen_nat (n : ℕ) : |
| 163 | ∀ {F : Type u} [NormedAddCommGroup F] [NormedSpace ℝ F] {f : E → F}, |
| 164 | ContDiff ℝ (n : WithTop ℕ∞) f → ContDiff ℝ (n : WithTop ℕ∞) (superpositionGen (K := K) f) := by |
| 165 | induction n with |
| 166 | | zero => |
| 167 | intro F _ _ f hf |
| 168 | rw [Nat.cast_zero, contDiff_zero] at hf ⊢ |
| 169 | exact continuous_superpositionGen hf |
| 170 | | succ k ih => |
| 171 | intro F _ _ f hf |
| 172 | rw [Nat.cast_succ] at hf ⊢ |
| 173 | obtain ⟨hf_diff, -, hf_fderiv⟩ := contDiff_succ_iff_fderiv.mp hf |
| 174 | have hf_cont_fderiv : Continuous (fderiv ℝ f) := |
| 175 | hf.continuous_fderiv (by exact_mod_cast Nat.succ_ne_zero k) |
| 176 | have hHas : ∀ α : C(K, E), |
| 177 | HasStrictFDerivAt (superpositionGen f) |
| 178 | (postcompCurve (superpositionGen (fderiv ℝ f) α)) α := by |
| 179 | intro α |
| 180 | refine hasStrictFDerivAt_superpositionGen (f' := fderiv ℝ f) (u := Set.univ) isOpen_univ |
| 181 | (fun x _ => hf_diff.differentiableAt.hasFDerivAt) (fun _ => Set.mem_univ _) |
| 182 | (fun _ => hf_cont_fderiv.continuousAt) ?_ |
| 183 | intro t |
| 184 | exact superpositionGen_apply hf_cont_fderiv α t |
| 185 | have hfderiv_eq : fderiv ℝ (superpositionGen f) |
| 186 | = fun (α : C(K, E)) => postcompCurveL (superpositionGen (fderiv ℝ f) α) := by |
| 187 | funext α |
| 188 | rw [(hHas α).hasFDerivAt.fderiv, postcompCurveL_apply] |
| 189 | rw [contDiff_succ_iff_fderiv] |
| 190 | refine ⟨fun α => (hHas α).hasFDerivAt.differentiableAt, fun h => absurd h (by simp), ?_⟩ |
| 191 | rw [hfderiv_eq] |
| 192 | exact ContDiff.continuousLinearMap_comp postcompCurveL (ih hf_fderiv) |
| 193 | |
| 194 | theorem contDiff_superpositionGen_infty {F : Type u} [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 195 | {f : E → F} (hf : ContDiff ℝ ∞ f) : |
| 196 | ContDiff ℝ ∞ (superpositionGen (K := K) f) := by |
| 197 | rw [contDiff_infty] |
| 198 | intro n |
| 199 | exact contDiff_superpositionGen_nat n (contDiff_infty.mp hf n) |
| 200 | |
| 201 | theorem contDiff_superposition_infty {f : E → E} (hf : ContDiff ℝ ∞ f) : |
| 202 | ContDiff ℝ ∞ (superposition (K := K) f) := by |
| 203 | rw [← superpositionGen_eq_superposition] |
| 204 | exact contDiff_superpositionGen_infty hf |
| 205 | |
| 206 | end Poincare.ODE.Parameter |
| 207 | |
| 208 | end |