Trivial second-moment lemma for max coprime errors
Provedgpy_sum_maxCoprimeErr_sq_le_of_sum_boundnumber-theory
If the first moment of the max coprime-residue errors over moduli up to Q is at most B (with B nonnegative), then the second moment is at most B squared. This is the trivial second moment: each error is at most the whole first moment. It is a pure lemma with no analytic input, stated with all local definitions unfolded into Mathlib terms.
Preamble
import Mathlib open Classical
Formal statement
theorem gpy_sum_maxCoprimeErr_sq_le_of_sum_bound (M : ℕ → ℕ → ℝ) (Y' Q : ℕ) {B : ℝ}
(hBnn : 0 ≤ B)
(hsum : ∑ L ∈ Finset.range (Q + 1), (if h : (((Finset.range L).filter (fun r => Nat.Coprime r L)).image
(fun r => abs ((((Finset.range (Y' + 1)).filter (fun p => Nat.Prime p ∧ p ≡ r [MOD L])).card : ℝ) - M Y' L))).Nonempty then
(((Finset.range L).filter (fun r => Nat.Coprime r L)).image
(fun r => abs ((((Finset.range (Y' + 1)).filter (fun p => Nat.Prime p ∧ p ≡ r [MOD L])).card : ℝ) - M Y' L))).max' h
else 0) ≤ B) :
∑ L ∈ Finset.range (Q + 1), ((if h : (((Finset.range L).filter (fun r => Nat.Coprime r L)).image
(fun r => abs ((((Finset.range (Y' + 1)).filter (fun p => Nat.Prime p ∧ p ≡ r [MOD L])).card : ℝ) - M Y' L))).Nonempty then
(((Finset.range L).filter (fun r => Nat.Coprime r L)).image
(fun r => abs ((((Finset.range (Y' + 1)).filter (fun p => Nat.Prime p ∧ p ≡ r [MOD L])).card : ℝ) - M Y' L))).max' h
else 0)) ^ 2 ≤ B ^ 2 := by sorrySource
GPY BDH-partial bounds (trivial second moment plus Cauchy-Schwarz with the tau-fourth bound), conditional on a plain BV sum bound; formalized from Mathlib (no local definitions in statements)