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.Elliptic.Regularity.Iteration.TestCalculus |
| 2 | |
| 3 | /-! # Differentiating divergence-form weak equations -/ |
| 4 | |
| 5 | noncomputable section |
| 6 | |
| 7 | open Set MeasureTheory Function Filter Topology |
| 8 | open scoped ENNReal ContDiff |
| 9 | |
| 10 | namespace Poincare.Analysis.Elliptic.Iteration |
| 11 | |
| 12 | variable {n : ℕ} |
| 13 | |
| 14 | local notation "E" => EuclideanSpace ℝ (Fin n) |
| 15 | |
| 16 | /-- The weak divergence equation `-div F = f`. -/ |
| 17 | def WeakEquation (O : Set E) (F : Fin n → E → ℝ) (f : E → ℝ) : Prop := |
| 18 | ∀ φ : E → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → tsupport φ ⊆ O → |
| 19 | (∫ x in O, ∑ i, F i x * partialDeriv i φ x) = ∫ x in O, f x * φ x |
| 20 | |
| 21 | theorem WeakEquation.restrict {O V : Set E} (hVO : V ⊆ O) |
| 22 | {F : Fin n → E → ℝ} {f : E → ℝ} (heq : WeakEquation O F f) : |
| 23 | WeakEquation V F f := by |
| 24 | intro φ hφ hφc hφV |
| 25 | have hderivzero : ∀ i x, x ∉ V → partialDeriv i φ x = 0 := by |
| 26 | intro i x hx |
| 27 | exact image_eq_zero_of_notMem_tsupport |
| 28 | (fun h => hx (hφV (tsupport_partial_subset i φ h))) |
| 29 | have hφzero : ∀ x, x ∉ V → φ x = 0 := |
| 30 | fun x hx => image_eq_zero_of_notMem_tsupport (fun h => hx (hφV h)) |
| 31 | have hraw := heq φ hφ hφc (hφV.trans hVO) |
| 32 | rw [setIntegral_eq_integral_of_forall_compl_eq_zero |
| 33 | (fun x hx => by simp [hderivzero _ x (fun hv => hx (hVO hv))]), |
| 34 | setIntegral_eq_integral_of_forall_compl_eq_zero |
| 35 | (fun x hx => by simp [hφzero x (fun hv => hx (hVO hv))])] at hraw |
| 36 | rw [setIntegral_eq_integral_of_forall_compl_eq_zero |
| 37 | (fun x hx => by simp [hderivzero _ x hx]), |
| 38 | setIntegral_eq_integral_of_forall_compl_eq_zero |
| 39 | (fun x hx => by simp [hφzero x hx])] |
| 40 | exact hraw |
| 41 | |
| 42 | theorem WeakEquation.congr_flux {O : Set E} |
| 43 | {F G : Fin n → E → ℝ} {f : E → ℝ} |
| 44 | (heq : WeakEquation O F f) |
| 45 | (hFG : ∀ i, F i =ᵐ[volume.restrict O] G i) : |
| 46 | WeakEquation O G f := by |
| 47 | intro φ hφ hφc hφO |
| 48 | rw [← heq φ hφ hφc hφO] |
| 49 | apply integral_congr_ae |
| 50 | filter_upwards [ae_all_iff.mpr hFG] with x hx |
| 51 | exact Finset.sum_congr rfl (fun i _ => by rw [hx i]) |
| 52 | |
| 53 | theorem locallyIntegrable_finset_sum {ι : Type*} (s : Finset ι) {O : Set E} |
| 54 | {f : ι → E → ℝ} (hf : ∀ i ∈ s, LocallyIntegrable (f i) (volume.restrict O)) : |
| 55 | LocallyIntegrable (fun x => ∑ i ∈ s, f i x) (volume.restrict O) := by |
| 56 | classical |
| 57 | induction s using Finset.induction_on with |
| 58 | | empty => simpa using (locallyIntegrable_zero : LocallyIntegrable |
| 59 | (fun _ : E => (0 : ℝ)) (volume.restrict O)) |
| 60 | | @insert a s ha ih => |
| 61 | simp only [Finset.sum_insert ha] |
| 62 | exact (hf a (Finset.mem_insert_self _ _)).add |
| 63 | (ih (fun i hi => hf i (Finset.mem_insert_of_mem hi))) |
| 64 | |
| 65 | theorem weakPartial_finset_sum {ι : Type*} (s : Finset ι) {O : Set E} |
| 66 | {u g : ι → E → ℝ} {k : Fin n} |
| 67 | (hu : ∀ i ∈ s, LocallyIntegrable (u i) (volume.restrict O)) |
| 68 | (hg : ∀ i ∈ s, LocallyIntegrable (g i) (volume.restrict O)) |
| 69 | (hweak : ∀ i ∈ s, Sobolev.Weak.HasWeakPartialDeriv k (g i) (u i) O) : |
| 70 | Sobolev.Weak.HasWeakPartialDeriv k (fun x => ∑ i ∈ s, g i x) |
| 71 | (fun x => ∑ i ∈ s, u i x) O := by |
| 72 | intro φ hφ hφc hφO |
| 73 | change (∫ x in O, (∑ i ∈ s, u i x) * partialDeriv k φ x) = |
| 74 | -(∫ x in O, (∑ i ∈ s, g i x) * φ x) |
| 75 | simp_rw [Finset.sum_mul] |
| 76 | rw [integral_finsetSum s (fun i hi => integrable_mul_partial_test (hu i hi) hφ hφc k), |
| 77 | integral_finsetSum s (fun i hi => integrable_mul_test (hg i hi) hφ hφc)] |
| 78 | rw [← Finset.sum_neg_distrib] |
| 79 | exact Finset.sum_congr rfl (fun i hi => hweak i hi φ hφ hφc hφO) |
| 80 | |
| 81 | theorem WeakEquation.differentiate |
| 82 | {O : Set E} {F G : Fin n → E → ℝ} {f g : E → ℝ} {k : Fin n} |
| 83 | (heq : WeakEquation O F f) |
| 84 | (hF : ∀ i, LocallyIntegrable (F i) (volume.restrict O)) |
| 85 | (hG : ∀ i, LocallyIntegrable (G i) (volume.restrict O)) |
| 86 | (hFG : ∀ i, Sobolev.Weak.HasWeakPartialDeriv k (G i) (F i) O) |
| 87 | (hfg : Sobolev.Weak.HasWeakPartialDeriv k g f O) : |
| 88 | WeakEquation O G g := by |
| 89 | intro φ hφ hφc hφO |
| 90 | have hDφ := contDiff_partial hφ k |
| 91 | have hDφc := hasCompactSupport_partial hφc k |
| 92 | have hDφO := (tsupport_partial_subset k φ).trans hφO |
| 93 | have hbase := heq (partialDeriv k φ) hDφ hDφc hDφO |
| 94 | have hrhs := hfg φ hφ hφc hφO |
| 95 | change (∫ x in O, f x * partialDeriv k φ x) = -(∫ x in O, g x * φ x) at hrhs |
| 96 | rw [integral_finsetSum Finset.univ |
| 97 | (fun i _ => integrable_mul_partial_test (hF i) hDφ hDφc i)] at hbase |
| 98 | have hterm : ∀ i, (∫ x in O, F i x * partialDeriv i (partialDeriv k φ) x) = |
| 99 | -(∫ x in O, G i x * partialDeriv i φ x) := by |
| 100 | intro i |
| 101 | rw [partial_comm hφ i k] |
| 102 | exact hFG i (partialDeriv i φ) (contDiff_partial hφ i) |
| 103 | (hasCompactSupport_partial hφc i) ((tsupport_partial_subset i φ).trans hφO) |
| 104 | simp_rw [hterm] at hbase |
| 105 | rw [Finset.sum_neg_distrib, hrhs] at hbase |
| 106 | rw [integral_finsetSum Finset.univ |
| 107 | (fun i _ => integrable_mul_partial_test (hG i) hφ hφc i)] |
| 108 | exact neg_injective hbase |
| 109 | |
| 110 | /-- A divergence correction can be moved into the scalar source. -/ |
| 111 | theorem WeakEquation.remove_flux |
| 112 | {O : Set E} {F H S : Fin n → E → ℝ} {f : E → ℝ} |
| 113 | (heq : WeakEquation O (fun i x => F i x + H i x) f) |
| 114 | (hF : ∀ i, LocallyIntegrable (F i) (volume.restrict O)) |
| 115 | (hH : ∀ i, LocallyIntegrable (H i) (volume.restrict O)) |
| 116 | (hS : ∀ i, LocallyIntegrable (S i) (volume.restrict O)) |
| 117 | (hf : LocallyIntegrable f (volume.restrict O)) |
| 118 | (hHS : ∀ i, Sobolev.Weak.HasWeakPartialDeriv i (S i) (H i) O) : |
| 119 | WeakEquation O F (fun x => f x + ∑ i, S i x) := by |
| 120 | intro φ hφ hφc hφO |
| 121 | have hbase := heq φ hφ hφc hφO |
| 122 | have hFφ i := integrable_mul_partial_test (hF i) hφ hφc i |
| 123 | have hHφ i := integrable_mul_partial_test (hH i) hφ hφc i |
| 124 | have hSφ i := integrable_mul_test (hS i) hφ hφc |
| 125 | have hHSeq i := hHS i φ hφ hφc hφO |
| 126 | change ∀ i, (∫ x in O, H i x * partialDeriv i φ x) = |
| 127 | -(∫ x in O, S i x * φ x) at hHSeq |
| 128 | simp_rw [add_mul, Finset.sum_add_distrib] at hbase |
| 129 | rw [integral_add (integrable_finsetSum _ (fun i _ => hFφ i)) |
| 130 | (integrable_finsetSum _ (fun i _ => hHφ i)), |
| 131 | integral_finsetSum Finset.univ (fun i _ => hHφ i)] at hbase |
| 132 | simp_rw [hHSeq] at hbase |
| 133 | rw [Finset.sum_neg_distrib] at hbase |
| 134 | simp_rw [add_mul, Finset.sum_mul] |
| 135 | rw [integral_add (integrable_mul_test hf hφ hφc) |
| 136 | (integrable_finsetSum _ (fun i _ => hSφ i)), |
| 137 | integral_finsetSum Finset.univ (fun i _ => hSφ i)] |
| 138 | linarith |
| 139 | |
| 140 | end Poincare.Analysis.Elliptic.Iteration |