Lean / senamakel/li-criterion-rh / Main.lean
Lean readerLiCriterion/Main.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports LiCriterion.Zeros, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import LiCriterion.Zeros/-!# Li's criterion, forward direction: RH ⇒ `λₙ > 0` for every `n ≥ 1`Under RH every `ρ ∈ nontrivialPosZeros` has `Re ρ = 1/2`, so `w = 1 - 1/ρ` lies on the unitcircle (`|ρ - 1| = |ρ|`). For `‖v‖ = 1`, `2 Re (1 - v) = ‖1 - v‖²`; with `v = wⁿ` each summand of`lambda n` is `‖1 - wⁿ‖² ∈ [0, n² ‖ρ‖⁻²]` (`‖1 - wⁿ‖ ≤ n ‖1 - w‖ = n / ‖ρ‖`). The family istherefore summable by `summable_inv_sq_nontrivialPosZeros`. A zero with `‖ρ‖ > n`(`exists_nontrivialPosZeros_norm_gt`) has `‖1 - wⁿ‖ ≥ nδ - n²δ² > 0` for `δ = 1/‖ρ‖ < 1/n`, sothe sum is strictly positive.-/open Complexnamespace RiemannHypothesis/-- `‖1 - wⁿ‖ ≤ n ‖1 - w‖` for `‖w‖ ≤ 1`. -/lemma norm_one_sub_pow_le {w : ℂ} (hw : ‖w‖ ≤ 1) (n : ℕ) : ‖1 - w ^ n‖ ≤ n * ‖1 - w‖ := byinduction n with| zero => simp| succ n ih =>have e : 1 - w ^ (n + 1) = (1 - w ^ n) + w ^ n * (1 - w) := by ringhave h2 : ‖w ^ n * (1 - w)‖ ≤ 1 * ‖1 - w‖ := byrw [norm_mul, norm_pow]exact mul_le_mul_of_nonneg_right (pow_le_one₀ (norm_nonneg _) hw) (norm_nonneg _)rw [e]calc ‖(1 - w ^ n) + w ^ n * (1 - w)‖ ≤ ‖1 - w ^ n‖ + ‖w ^ n * (1 - w)‖ := norm_add_le _ __ ≤ n * ‖1 - w‖ + 1 * ‖1 - w‖ := add_le_add ih h2_ = ((n + 1 : ℕ) : ℝ) * ‖1 - w‖ := by push_cast; ring/-- Second order: `‖1 - wⁿ - n (1 - w)‖ ≤ n² ‖1 - w‖²` for `‖w‖ ≤ 1`. -/lemma norm_one_sub_pow_sub_le {w : ℂ} (hw : ‖w‖ ≤ 1) (n : ℕ) :‖1 - w ^ n - n * (1 - w)‖ ≤ (n : ℝ) ^ 2 * ‖1 - w‖ ^ 2 := byinduction n with| zero => simp| succ n ih =>have e : 1 - w ^ (n + 1) - ((n + 1 : ℕ) : ℂ) * (1 - w)= (1 - w ^ n - n * (1 - w)) + (1 - w) * (w ^ n - 1) := by push_cast; ringhave h2 : ‖(1 - w) * (w ^ n - 1)‖ ≤ ‖1 - w‖ * (n * ‖1 - w‖) := byrw [norm_mul, norm_sub_rev (w ^ n)]exact mul_le_mul_of_nonneg_left (norm_one_sub_pow_le hw n) (norm_nonneg _)rw [e]have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg nhave hδ : 0 ≤ ‖1 - w‖ ^ 2 := sq_nonneg _calc ‖(1 - w ^ n - n * (1 - w)) + (1 - w) * (w ^ n - 1)‖≤ ‖1 - w ^ n - n * (1 - w)‖ + ‖(1 - w) * (w ^ n - 1)‖ := norm_add_le _ __ ≤ (n : ℝ) ^ 2 * ‖1 - w‖ ^ 2 + ‖1 - w‖ * (n * ‖1 - w‖) := add_le_add ih h2_ ≤ ((n + 1 : ℕ) : ℝ) ^ 2 * ‖1 - w‖ ^ 2 := bypush_cast; nlinarith [mul_nonneg hn hδ]/-- On the unit circle, `2 Re (1 - v) = ‖1 - v‖²`. -/lemma two_mul_re_one_sub_eq {v : ℂ} (hv : ‖v‖ = 1) : 2 * (1 - v).re = ‖1 - v‖ ^ 2 := byhave h : v.re * v.re + v.im * v.im = 1 := byrw [← Complex.normSq_apply, ← Complex.sq_norm, hv, one_pow]rw [Complex.sq_norm, Complex.normSq_apply]simp only [sub_re, one_re, sub_im, one_im]linear_combination (-1 : ℝ) * h/-- On the critical line, `‖1 - 1/ρ‖ = 1`. -/lemma norm_one_sub_inv_eq_one {ρ : ℂ} (hre : ρ.re = 1 / 2) : ‖1 - 1 / ρ‖ = 1 := byhave hρ0 : ρ ≠ 0 := fun h => by rw [h] at hre; norm_num at hrehave hn : ‖ρ - 1‖ = ‖ρ‖ := byrw [Complex.norm_def, Complex.norm_def, Complex.normSq_apply, Complex.normSq_apply]congr 1simp only [sub_re, one_re, sub_im, one_im, hre]ringrw [show 1 - 1 / ρ = (ρ - 1) / ρ by field_simp, norm_div, hn,div_self (norm_ne_zero_iff.mpr hρ0)]/-- Every element of `nontrivialPosZeros` is a nontrivial zero in Mathlib's sense, so RH puts iton the critical line. -/lemma re_eq_half_of_RH (hRH : RiemannHypothesis) {ρ : ℂ} (hρ : ρ ∈ nontrivialPosZeros) :ρ.re = 1 / 2 := byobtain ⟨_, _, him, hζ⟩ := hρrefine hRH ρ hζ ?_ ?_· rintro ⟨k, rfl⟩simp at him· rintro rflsimp at him/-- The summand of `lambda n`, under RH: `2 Re (1 - wⁿ) = ‖1 - wⁿ‖²` with `w = 1 - 1/ρ`. -/lemma summand_eq_of_RH (hRH : RiemannHypothesis) (n : ℕ) (ρ : nontrivialPosZeros) :2 * (1 - (1 - 1 / ρ.1) ^ n).re = ‖1 - (1 - 1 / ρ.1) ^ n‖ ^ 2 :=two_mul_re_one_sub_eq (by rw [norm_pow, norm_one_sub_inv_eq_one (re_eq_half_of_RH hRH ρ.2),one_pow])lemma norm_one_sub_one_sub_inv (ρ : ℂ) : ‖1 - (1 - 1 / ρ)‖ = ‖ρ‖⁻¹ := byrw [sub_sub_cancel, norm_div, norm_one, one_div]/-- Under RH the summands of `lambda n` are summable. -/theorem summable_lambda_summand_of_RH (hRH : RiemannHypothesis) (n : ℕ) :Summable fun ρ : nontrivialPosZeros => 2 * (1 - (1 - 1 / ρ.1) ^ n).re := byrefine Summable.of_nonneg_of_le (fun ρ => ?_) (fun ρ => ?_)(summable_inv_sq_nontrivialPosZeros.mul_left ((n : ℝ) ^ 2))· rw [summand_eq_of_RH hRH]; positivity· rw [summand_eq_of_RH hRH, ← mul_pow, ← norm_one_sub_one_sub_inv]have hw : ‖1 - 1 / ρ.1‖ ≤ 1 := (norm_one_sub_inv_eq_one (re_eq_half_of_RH hRH ρ.2)).leexact pow_le_pow_left₀ (norm_nonneg _) (norm_one_sub_pow_le hw n) 2/-- A zero with `‖ρ‖ > n ≥ 1` contributes a strictly positive summand. -/lemma summand_pos_of_RH (hRH : RiemannHypothesis) {n : ℕ} (hn : 0 < n) (ρ : nontrivialPosZeros)(hρ : (n : ℝ) < ‖ρ.1‖) : 0 < 2 * (1 - (1 - 1 / ρ.1) ^ n).re := byrw [summand_eq_of_RH hRH]set w : ℂ := 1 - 1 / ρ.1have hw : ‖w‖ ≤ 1 := (norm_one_sub_inv_eq_one (re_eq_half_of_RH hRH ρ.2)).leset δ : ℝ := ‖1 - w‖have hnpos : (0 : ℝ) < n := by exact_mod_cast hnhave hρpos : 0 < ‖ρ.1‖ := hnpos.trans hρhave hδ : δ = ‖ρ.1‖⁻¹ := norm_one_sub_one_sub_inv _have hδpos : 0 < δ := by rw [hδ]; positivityhave hnδ : n * δ < 1 := byrw [hδ, ← div_eq_mul_inv, div_lt_one hρpos]; exact hρhave h2 := norm_one_sub_pow_sub_le hw n-- `n δ = ‖n (1 - w)‖ ≤ ‖1 - wⁿ‖ + ‖1 - wⁿ - n (1 - w)‖`have h3 : (n : ℝ) * δ ≤ ‖1 - w ^ n‖ + ‖1 - w ^ n - n * (1 - w)‖ := byhave e : (n : ℂ) * (1 - w) = (1 - w ^ n) - (1 - w ^ n - n * (1 - w)) := by ringhave := norm_sub_le (1 - w ^ n) (1 - w ^ n - n * (1 - w))rw [← e, norm_mul, Complex.norm_natCast] at thisexact thishave h4 : 0 < ‖1 - w ^ n‖ := byhave : 0 < (n : ℝ) * δ * (1 - n * δ) := mul_pos (mul_pos hnpos hδpos) (by linarith)nlinarithpositivity/-- **Li's criterion, RH ⇒ positivity** (Li 1997; Bombieri–Lagarias 1999): under the Riemannhypothesis, `lambda n > 0` for every `n > 0`. This is formal-conjectures' `li_criterion_rhs`with RH as a hypothesis. -/theorem li_criterion_rhs_of_RH (hRH : RiemannHypothesis) : LiCriterionRHS := byintro n hnobtain ⟨ρ, hρ, hR⟩ := exists_nontrivialPosZeros_norm_gt nexact (summable_lambda_summand_of_RH hRH n).tsum_pos(fun ρ => by rw [summand_eq_of_RH hRH]; positivity) ⟨ρ, hρ⟩(summand_pos_of_RH hRH hn ⟨ρ, hρ⟩ hR)/-- The forward direction of formal-conjectures' `li_criterion`. -/theorem li_criterion_forward : RiemannHypothesis → ∀ n > 0, 0 < lambda n :=fun hRH _ hn => li_criterion_rhs_of_RH hRH hnend RiemannHypothesis