Skip to content

Lean formalization of the Riemann Hypothesis (Alpöge, 2026-11-20) being cleaned up by members of the Lean community.

Python
5.0 KB
Raw Blame
module

public import Mathlib.LinearAlgebra.Lagrange
public import Lib.Speed

/-!
# Sums of residues at simple poles

This file computes sums of residues of rational functions whose denominator has simple roots over a
field. Let `p = nodal univ x` be the monic polynomial with the distinct roots `x i`. The residue of
`F / p` at `x i` is `F (x i) / p' (x i)`. Over a strictly ordered ring, this file also determines
the sign of `p' (x i)` when the roots are ordered.

## Main definitions and results

* `New.DiscreteSeries.sum_eval_div_eval_derivative_nodal` and
  `sum_eval_div_sub_mul_eval_derivative_nodal`: two sums of residues at simple poles.
* `New.DiscreteSeries.eval_derivative_nodal`: the derivative of `nodal univ x`, the monic
  polynomial with roots `x j`, at the root `x i` is the product of the `x i - x j` over `j ≠ i`.

## Relation to the literature

The residue sums rest on Lagrange interpolation.
-/

@[expose] public section

noncomputable section

section LagrangeWeights

open Finset Polynomial Lagrange

namespace New.DiscreteSeries

section Residues

variable {ι R K : Type*} [Fintype ι] [DecidableEq ι]

/-- The derivative of `nodal univ x`, the monic polynomial with roots `x j`, at the root `x i` is
the product of the `x i - x j` over `j ≠ i`. -/
lemma eval_derivative_nodal [CommRing R] (x : ι → R) (i : ι) :
    (derivative (nodal univ x)).eval (x i) = ∏ j ∈ univ.erase i, (x i - x j) := by
  rw [eval_nodal_derivative_eval_node_eq (mem_univ i), eval_nodal]

variable [Field K] {x : ι → K} {F : K[X]}

/-- Let `p = nodal univ x` be the monic polynomial with the distinct roots `x i` and let `F` be
monic of smaller degree. The residues `F (x i) / p' (x i)` of `F / p` add up to `1` if
`deg F + 1 = deg p` and to `0` otherwise. -/
theorem sum_eval_div_eval_derivative_nodal (hx : Function.Injective x) (hF : F.Monic)
    (h_degree : F.natDegree < Fintype.card ι) :
    ∑ i : ι, F.eval (x i) / (derivative (nodal univ x)).eval (x i) =
      if F.natDegree + 1 = Fintype.card ι then 1 else 0 := by
  -- By Lagrange's formula the sum is the coefficient of `F` in degree `deg p - 1`.
  simp_rw [eval_derivative_nodal]
  rw [← coeff_eq_sum hx.injOn (degree_le_natDegree.trans_lt (Nat.cast_lt.2 h_degree)), card_univ]
  split_ifs with h_top
  · rw [← h_top, Nat.add_sub_cancel, hF.coeff_natDegree]
  · exact coeff_eq_zero_of_natDegree_lt (by lia)

/-- Let `p = nodal univ x` have the distinct roots `x i`, let `deg F < deg p` and let `c` not be a
root. The residues of `F / ((t - c) p)` at the roots of `p` add up to minus the residue
`F (c) / p (c)` at the only other pole. -/
theorem sum_eval_div_sub_mul_eval_derivative_nodal (hx : Function.Injective x) {c : K}
    (hc : ∀ i : ι, c ≠ x i) (h_degree : F.natDegree < Fintype.card ι) :
    ∑ i : ι, F.eval (x i) / ((x i - c) * (derivative (nodal univ x)).eval (x i)) =
      -(F.eval c / (nodal univ x).eval c) := by
  -- This is the barycentric form of Lagrange's formula for `F (c)`.
  have h_value : F.eval c = (nodal univ x).eval c *
      ∑ i : ι, nodalWeight univ x i * (c - x i)⁻¹ * F.eval (x i) := by
    rw [← eval_interpolate_not_at_node _ fun i _ ↦ hc i,
      ← eq_interpolate hx.injOn (degree_le_natDegree.trans_lt (Nat.cast_lt.2 h_degree))]
  rw [h_value, mul_div_cancel_left₀ _ (eval_nodal_not_at_node fun i _ ↦ hc i), ← sum_neg_distrib]
  refine sum_congr rfl fun i _ ↦ ?_
  grind [nodalWeight_eq_eval_derivative_nodal (mem_univ i)]

end Residues

section Signs

variable {M : ℕ} {R : Type*} [CommRing R] [LinearOrder R] [IsStrictOrderedRing R] {x : Fin M → R}

/-- For decreasing roots `x 0 > x 1 > …` of `p = nodal univ x` the number `p' (x i)` has the sign
`(-1) ^ i`. -/
lemma derivative_nodal_sign_of_strictAnti (hx : StrictAnti x) (i : Fin M) :
    0 < (-1) ^ (i : ℕ) * (derivative (nodal univ x)).eval (x i) := by
  -- The factors `x i - x j` with `j < i` are negative, and those with `j > i` are positive.
  have h_split : (-1) ^ (i : ℕ) * ∏ j ∈ univ.erase i, (x i - x j) =
      (∏ j ∈ Ioi i, (x i - x j)) * ∏ j ∈ Iio i, (x j - x i) := by
    rw [← compl_singleton, ← Ioi_disjUnion_Iio, prod_disjUnion (disjoint_Ioi_Iio i),
      ← Fin.card_Iio, mul_left_comm, ← prod_neg]
    simp_rw [neg_sub]
  rw [eval_derivative_nodal, h_split]
  exact mul_pos (prod_pos fun j hj ↦ sub_pos.2 (hx (mem_Ioi.1 hj)))
    (prod_pos fun j hj ↦ sub_pos.2 (hx (mem_Iio.1 hj)))

/-- For increasing roots `x 0 < … < x (M - 1)` of `p = nodal univ x` the number `p' (x i)` has the
sign `(-1) ^ (M - 1 - i)`. -/
lemma derivative_nodal_sign_of_strictMono (hx : StrictMono x) (i : Fin M) :
    0 < (-1) ^ (M - 1 - (i : ℕ)) * (derivative (nodal univ x)).eval (x i) := by
  have h_nodal : nodal univ (x ∘ Fin.rev) = nodal univ x :=
    (EquivLike.bijective (Fin.revPerm (n := M))).prod_comp (fun j ↦ (X : R[X]) - C (x j))
  rw [Nat.sub_sub, Nat.add_comm 1]
  simpa only [Function.comp_apply, Fin.rev_rev, Fin.val_rev, h_nodal] using
    derivative_nodal_sign_of_strictAnti (hx.comp_strictAnti Fin.rev_strictAnti) i.rev

end Signs

end New.DiscreteSeries

end LagrangeWeights

end