Riemann hypothesis: the Lean proof, cleaned up together
The 2026 Lean proof of the Riemann hypothesis and GRH, machine-checked by others, not refereed, no word from Clay; cleaned up together: more readable, faster to build, the theorems unchanged

| 1 | module |
| 2 | |
| 3 | public import Mathlib.LinearAlgebra.Lagrange |
| 4 | public import Lib.Speed |
| 5 | |
| 6 | /-! |
| 7 | # Sums of residues at simple poles |
| 8 | |
| 9 | This file computes sums of residues of rational functions whose denominator has simple roots over a |
| 10 | field. Let `p = nodal univ x` be the monic polynomial with the distinct roots `x i`. The residue of |
| 11 | `F / p` at `x i` is `F (x i) / p' (x i)`. Over a strictly ordered ring, this file also determines |
| 12 | the sign of `p' (x i)` when the roots are ordered. |
| 13 | |
| 14 | ## Main definitions and results |
| 15 | |
| 16 | * `New.DiscreteSeries.sum_eval_div_eval_derivative_nodal` and |
| 17 | `sum_eval_div_sub_mul_eval_derivative_nodal`: two sums of residues at simple poles. |
| 18 | * `New.DiscreteSeries.eval_derivative_nodal`: the derivative of `nodal univ x`, the monic |
| 19 | polynomial with roots `x j`, at the root `x i` is the product of the `x i - x j` over `j ≠ i`. |
| 20 | |
| 21 | ## Relation to the literature |
| 22 | |
| 23 | The residue sums rest on Lagrange interpolation. |
| 24 | -/ |
| 25 | |
| 26 | @[expose] public section |
| 27 | |
| 28 | noncomputable section |
| 29 | |
| 30 | section LagrangeWeights |
| 31 | |
| 32 | open Finset Polynomial Lagrange |
| 33 | |
| 34 | namespace New.DiscreteSeries |
| 35 | |
| 36 | section Residues |
| 37 | |
| 38 | variable {ι R K : Type*} [Fintype ι] [DecidableEq ι] |
| 39 | |
| 40 | /-- The derivative of `nodal univ x`, the monic polynomial with roots `x j`, at the root `x i` is |
| 41 | the product of the `x i - x j` over `j ≠ i`. -/ |
| 42 | lemma eval_derivative_nodal [CommRing R] (x : ι → R) (i : ι) : |
| 43 | (derivative (nodal univ x)).eval (x i) = ∏ j ∈ univ.erase i, (x i - x j) := by |
| 44 | rw [eval_nodal_derivative_eval_node_eq (mem_univ i), eval_nodal] |
| 45 | |
| 46 | variable [Field K] {x : ι → K} {F : K[X]} |
| 47 | |
| 48 | /-- Let `p = nodal univ x` be the monic polynomial with the distinct roots `x i` and let `F` be |
| 49 | monic of smaller degree. The residues `F (x i) / p' (x i)` of `F / p` add up to `1` if |
| 50 | `deg F + 1 = deg p` and to `0` otherwise. -/ |
| 51 | theorem sum_eval_div_eval_derivative_nodal (hx : Function.Injective x) (hF : F.Monic) |
| 52 | (h_degree : F.natDegree < Fintype.card ι) : |
| 53 | ∑ i : ι, F.eval (x i) / (derivative (nodal univ x)).eval (x i) = |
| 54 | if F.natDegree + 1 = Fintype.card ι then 1 else 0 := by |
| 55 | -- By Lagrange's formula the sum is the coefficient of `F` in degree `deg p - 1`. |
| 56 | simp_rw [eval_derivative_nodal] |
| 57 | rw [← coeff_eq_sum hx.injOn (degree_le_natDegree.trans_lt (Nat.cast_lt.2 h_degree)), card_univ] |
| 58 | split_ifs with h_top |
| 59 | · rw [← h_top, Nat.add_sub_cancel, hF.coeff_natDegree] |
| 60 | · exact coeff_eq_zero_of_natDegree_lt (by lia) |
| 61 | |
| 62 | /-- Let `p = nodal univ x` have the distinct roots `x i`, let `deg F < deg p` and let `c` not be a |
| 63 | root. The residues of `F / ((t - c) p)` at the roots of `p` add up to minus the residue |
| 64 | `F (c) / p (c)` at the only other pole. -/ |
| 65 | theorem sum_eval_div_sub_mul_eval_derivative_nodal (hx : Function.Injective x) {c : K} |
| 66 | (hc : ∀ i : ι, c ≠ x i) (h_degree : F.natDegree < Fintype.card ι) : |
| 67 | ∑ i : ι, F.eval (x i) / ((x i - c) * (derivative (nodal univ x)).eval (x i)) = |
| 68 | -(F.eval c / (nodal univ x).eval c) := by |
| 69 | -- This is the barycentric form of Lagrange's formula for `F (c)`. |
| 70 | have h_value : F.eval c = (nodal univ x).eval c * |
| 71 | ∑ i : ι, nodalWeight univ x i * (c - x i)⁻¹ * F.eval (x i) := by |
| 72 | rw [← eval_interpolate_not_at_node _ fun i _ ↦ hc i, |
| 73 | ← eq_interpolate hx.injOn (degree_le_natDegree.trans_lt (Nat.cast_lt.2 h_degree))] |
| 74 | rw [h_value, mul_div_cancel_left₀ _ (eval_nodal_not_at_node fun i _ ↦ hc i), ← sum_neg_distrib] |
| 75 | refine sum_congr rfl fun i _ ↦ ?_ |
| 76 | grind [nodalWeight_eq_eval_derivative_nodal (mem_univ i)] |
| 77 | |
| 78 | end Residues |
| 79 | |
| 80 | section Signs |
| 81 | |
| 82 | variable {M : ℕ} {R : Type*} [CommRing R] [LinearOrder R] [IsStrictOrderedRing R] {x : Fin M → R} |
| 83 | |
| 84 | /-- For decreasing roots `x 0 > x 1 > …` of `p = nodal univ x` the number `p' (x i)` has the sign |
| 85 | `(-1) ^ i`. -/ |
| 86 | lemma derivative_nodal_sign_of_strictAnti (hx : StrictAnti x) (i : Fin M) : |
| 87 | 0 < (-1) ^ (i : ℕ) * (derivative (nodal univ x)).eval (x i) := by |
| 88 | -- The factors `x i - x j` with `j < i` are negative, and those with `j > i` are positive. |
| 89 | have h_split : (-1) ^ (i : ℕ) * ∏ j ∈ univ.erase i, (x i - x j) = |
| 90 | (∏ j ∈ Ioi i, (x i - x j)) * ∏ j ∈ Iio i, (x j - x i) := by |
| 91 | rw [← compl_singleton, ← Ioi_disjUnion_Iio, prod_disjUnion (disjoint_Ioi_Iio i), |
| 92 | ← Fin.card_Iio, mul_left_comm, ← prod_neg] |
| 93 | simp_rw [neg_sub] |
| 94 | rw [eval_derivative_nodal, h_split] |
| 95 | exact mul_pos (prod_pos fun j hj ↦ sub_pos.2 (hx (mem_Ioi.1 hj))) |
| 96 | (prod_pos fun j hj ↦ sub_pos.2 (hx (mem_Iio.1 hj))) |
| 97 | |
| 98 | /-- For increasing roots `x 0 < … < x (M - 1)` of `p = nodal univ x` the number `p' (x i)` has the |
| 99 | sign `(-1) ^ (M - 1 - i)`. -/ |
| 100 | lemma derivative_nodal_sign_of_strictMono (hx : StrictMono x) (i : Fin M) : |
| 101 | 0 < (-1) ^ (M - 1 - (i : ℕ)) * (derivative (nodal univ x)).eval (x i) := by |
| 102 | have h_nodal : nodal univ (x ∘ Fin.rev) = nodal univ x := |
| 103 | (EquivLike.bijective (Fin.revPerm (n := M))).prod_comp (fun j ↦ (X : R[X]) - C (x j)) |
| 104 | rw [Nat.sub_sub, Nat.add_comm 1] |
| 105 | simpa only [Function.comp_apply, Fin.rev_rev, Fin.val_rev, h_nodal] using |
| 106 | derivative_nodal_sign_of_strictAnti (hx.comp_strictAnti Fin.rev_strictAnti) i.rev |
| 107 | |
| 108 | end Signs |
| 109 | |
| 110 | end New.DiscreteSeries |
| 111 | |
| 112 | end LagrangeWeights |
| 113 | |
| 114 | end |