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.Parabolic.WeakRegularity.ForwardEquation |
| 2 | |
| 3 | /-! # Divergence form of the canonical forward equation -/ |
| 4 | |
| 5 | noncomputable section |
| 6 | set_option autoImplicit false |
| 7 | set_option backward.isDefEq.respectTransparency false |
| 8 | |
| 9 | open Set Filter |
| 10 | open scoped ContDiff Topology |
| 11 | |
| 12 | namespace Poincare.Analysis.Parabolic.WeakRegularity.Canonical |
| 13 | |
| 14 | variable {n : ℕ} {U : Set (Spacetime n)} |
| 15 | |
| 16 | private theorem sd_smooth (hU : IsOpen U) {f : Spacetime n → ℝ} |
| 17 | (hf : ContDiffOn ℝ ∞ f U) (i : Fin n) : |
| 18 | ContDiffOn ℝ ∞ (spatialDeriv i f) U := |
| 19 | (hf.fderiv_of_isOpen hU (by simp)).clm_apply contDiffOn_const |
| 20 | |
| 21 | private theorem sd_mul (hU : IsOpen U) {f g : Spacetime n → ℝ} |
| 22 | (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g U) |
| 23 | {z : Spacetime n} (hz : z ∈ U) (i : Fin n) : |
| 24 | spatialDeriv i (fun y => f y * g y) z = |
| 25 | spatialDeriv i f z * g z + f z * spatialDeriv i g z := by |
| 26 | rw [spatialDeriv, fderiv_fun_mul |
| 27 | ((hf.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp)) |
| 28 | ((hg.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp))] |
| 29 | simp only [add_apply, smul_apply, smul_eq_mul, spatialDeriv] |
| 30 | ring |
| 31 | |
| 32 | private theorem sd_sum (hU : IsOpen U) {f : Fin n → Spacetime n → ℝ} |
| 33 | (hf : ∀ j, ContDiffOn ℝ ∞ (f j) U) {z : Spacetime n} |
| 34 | (hz : z ∈ U) (i : Fin n) : |
| 35 | spatialDeriv i (fun y => ∑ j, f j y) z = ∑ j, spatialDeriv i (f j) z := by |
| 36 | rw [spatialDeriv, fderiv_fun_sum (fun j _ => |
| 37 | ((hf j).contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp))] |
| 38 | simp only [ContinuousLinearMap.sum_apply, spatialDeriv] |
| 39 | |
| 40 | private theorem sd_sub (hU : IsOpen U) {f g : Spacetime n → ℝ} |
| 41 | (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g U) |
| 42 | {z : Spacetime n} (hz : z ∈ U) (i : Fin n) : |
| 43 | spatialDeriv i (fun y => f y - g y) z = |
| 44 | spatialDeriv i f z - spatialDeriv i g z := by |
| 45 | rw [spatialDeriv, fderiv_fun_sub |
| 46 | ((hf.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp)) |
| 47 | ((hg.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp))] |
| 48 | rfl |
| 49 | |
| 50 | private theorem sd_add (hU : IsOpen U) {f g : Spacetime n → ℝ} |
| 51 | (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g U) |
| 52 | {z : Spacetime n} (hz : z ∈ U) (i : Fin n) : |
| 53 | spatialDeriv i (fun y => f y + g y) z = |
| 54 | spatialDeriv i f z + spatialDeriv i g z := by |
| 55 | rw [spatialDeriv, fderiv_fun_add |
| 56 | ((hf.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp)) |
| 57 | ((hg.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp))] |
| 58 | rfl |
| 59 | |
| 60 | private theorem sd_mul_second (hU : IsOpen U) {f g : Spacetime n → ℝ} |
| 61 | (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g U) |
| 62 | {z : Spacetime n} (hz : z ∈ U) (i j : Fin n) : |
| 63 | spatialDeriv i (spatialDeriv j (fun y => f y * g y)) z = |
| 64 | spatialDeriv i (spatialDeriv j f) z * g z + |
| 65 | spatialDeriv j f z * spatialDeriv i g z + |
| 66 | spatialDeriv i f z * spatialDeriv j g z + |
| 67 | f z * spatialDeriv i (spatialDeriv j g) z := by |
| 68 | have heq : spatialDeriv j (fun y => f y * g y) =ᶠ[𝓝 z] |
| 69 | (fun y => spatialDeriv j f y * g y + f y * spatialDeriv j g y) := by |
| 70 | filter_upwards [hU.mem_nhds hz] with y hy |
| 71 | exact sd_mul hU hf hg hy j |
| 72 | change fderiv ℝ _ z _ = _ |
| 73 | rw [heq.fderiv_eq] |
| 74 | change spatialDeriv i (fun y => spatialDeriv j f y * g y + |
| 75 | f y * spatialDeriv j g y) z = _ |
| 76 | rw [sd_add hU ((sd_smooth hU hf j).mul hg) (hf.mul (sd_smooth hU hg j)) hz, |
| 77 | sd_mul hU (sd_smooth hU hf j) hg hz, |
| 78 | sd_mul hU hf (sd_smooth hU hg j) hz] |
| 79 | ring |
| 80 | |
| 81 | /-- The forward equation is the divergence of its genuine first-order flux. -/ |
| 82 | theorem forwardCoefficients_operator_eq_divergence (hU : IsOpen U) |
| 83 | {a : Fin n → Fin n → Spacetime n → ℝ} {b : Fin n → Spacetime n → ℝ} |
| 84 | (ha : ∀ i j, ContDiffOn ℝ ∞ (a i j) U) |
| 85 | (hb : ∀ i, ContDiffOn ℝ ∞ (b i) U) |
| 86 | {w : Spacetime n → ℝ} (hw : ContDiffOn ℝ ∞ w U) |
| 87 | {z : Spacetime n} (hz : z ∈ U) : |
| 88 | (forwardCoefficients a b).operator w z = timeDeriv w z + |
| 89 | ∑ i, spatialDeriv i (fun y => b i y * w y - |
| 90 | ∑ j, spatialDeriv j (fun v => a i j v * w v) y) z := by |
| 91 | have hsum (i : Fin n) : ContDiffOn ℝ ∞ |
| 92 | (fun y => ∑ j, spatialDeriv j (fun v => a i j v * w v) y) U := |
| 93 | ContDiffOn.sum (fun j _ => sd_smooth hU ((ha i j).mul hw) j) |
| 94 | have hflux (i) := sd_sub hU ((hb i).mul hw) (hsum i) hz i |
| 95 | have hds (i) := sd_sum hU (fun j => sd_smooth hU ((ha i j).mul hw) j) hz i |
| 96 | have hd (i) := sd_sub hU (hb i) |
| 97 | (ContDiffOn.sum (s := Finset.univ) (fun j _ => |
| 98 | (sd_smooth hU (ha i j) j).add (sd_smooth hU (ha j i) j))) hz i |
| 99 | have hdd (i) := sd_sum hU (fun j => |
| 100 | (sd_smooth hU (ha i j) j).add (sd_smooth hU (ha j i) j)) hz i |
| 101 | have hcross : (∑ i, ∑ j, spatialDeriv i (a i j) z * spatialDeriv j w z) = |
| 102 | ∑ i, ∑ j, spatialDeriv j (a j i) z * spatialDeriv i w z := |
| 103 | Finset.sum_comm |
| 104 | have hsecond : (∑ i, ∑ j, spatialDeriv i (spatialDeriv j (a j i)) z) = |
| 105 | ∑ i, ∑ j, spatialDeriv j (spatialDeriv i (a i j)) z := |
| 106 | Finset.sum_comm |
| 107 | have hsecondw := congrArg (fun r : ℝ => r * w z) hsecond |
| 108 | simp only [Finset.sum_mul] at hsecondw |
| 109 | simp only [Coefficients.operator, forwardCoefficients, hflux, hds, hd, hdd, |
| 110 | sd_add hU (sd_smooth hU (ha _ _) _) (sd_smooth hU (ha _ _) _) hz, |
| 111 | sd_mul hU (hb _) hw hz, sd_mul_second hU (ha _ _) hw hz] |
| 112 | simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, Finset.sum_mul, sub_mul, add_mul] |
| 113 | rw [hcross, hsecondw] |
| 114 | ring |
| 115 | |
| 116 | /-- A stationary density balance converts the forward flux into the weighted |
| 117 | gradient flux. The balance is an identity of the supplied coefficients. -/ |
| 118 | theorem forwardCoefficients_operator_weighted (hU : IsOpen U) |
| 119 | {a : Fin n → Fin n → Spacetime n → ℝ} {b : Fin n → Spacetime n → ℝ} |
| 120 | (ha : ∀ i j, ContDiffOn ℝ ∞ (a i j) U) |
| 121 | (hb : ∀ i, ContDiffOn ℝ ∞ (b i) U) |
| 122 | {ρ u : Spacetime n → ℝ} (hρ : ContDiffOn ℝ ∞ ρ U) |
| 123 | (hu : ContDiffOn ℝ ∞ u U) |
| 124 | (hbalance : ∀ z ∈ U, ∀ i, |
| 125 | b i z * ρ z = ∑ j, spatialDeriv j (fun y => a i j y * ρ y) z) |
| 126 | {z : Spacetime n} (hz : z ∈ U) : |
| 127 | (forwardCoefficients a b).operator (fun y => ρ y * u y) z = |
| 128 | timeDeriv (fun y => ρ y * u y) z - |
| 129 | ∑ i, spatialDeriv i (fun y => ∑ j, ρ y * a i j y * spatialDeriv j u y) z := by |
| 130 | rw [forwardCoefficients_operator_eq_divergence hU ha hb (hρ.mul hu) hz] |
| 131 | have hflux (i) : (fun y => b i y * (ρ y * u y) - |
| 132 | ∑ j, spatialDeriv j (fun v => a i j v * (ρ v * u v)) y) =ᶠ[𝓝 z] |
| 133 | (fun y => -(∑ j, ρ y * a i j y * spatialDeriv j u y)) := by |
| 134 | filter_upwards [hU.mem_nhds hz] with y hy |
| 135 | have hprod (j) : spatialDeriv j (fun v => a i j v * (ρ v * u v)) y = |
| 136 | spatialDeriv j (fun v => a i j v * ρ v) y * u y + |
| 137 | ρ y * a i j y * spatialDeriv j u y := by |
| 138 | simp_rw [← mul_assoc] |
| 139 | rw [sd_mul hU ((ha i j).mul hρ) hu hy] |
| 140 | ring |
| 141 | simp only [hprod] |
| 142 | rw [Finset.sum_add_distrib, ← Finset.sum_mul, ← hbalance y hy i] |
| 143 | ring |
| 144 | have hd (i) : spatialDeriv i (fun y => b i y * (ρ y * u y) - |
| 145 | ∑ j, spatialDeriv j (fun v => a i j v * (ρ v * u v)) y) z = |
| 146 | -spatialDeriv i (fun y => ∑ j, ρ y * a i j y * spatialDeriv j u y) z := by |
| 147 | change fderiv ℝ _ z _ = _ |
| 148 | rw [(hflux i).fderiv_eq, fderiv_fun_neg] |
| 149 | rfl |
| 150 | simp only [hd] |
| 151 | simp only [Finset.sum_neg_distrib, sub_eq_add_neg] |
| 152 | |
| 153 | end Poincare.Analysis.Parabolic.WeakRegularity.Canonical |