RiemannA guide by Principia Superintelligence

Part II, chapter 11

The table, and the main inequality

A second quadratic character picks out the inert primes; a cyclotomic field with 2n2n places sorts prime powers into the cells of a table with two rows and nn columns; one cell per translate carries the weight bb. The prime sum PP over the table minus its expected value MM is what the chain of lifts bounds. This is inequality (M), stated exactly and computed on a table small enough to print.

draft, under review26 minfirst published in v0.1.0, 2026-11-22

Only inert primes: use a character

Let dd be a prime with d≡3 mod 4d \equiv 3 \bmod 4 and let χd(r)=(r/d)\chi_d(r) = (r/d) be the Legendre symbol. The primes inert in Q(−d)\mathbb Q(\sqrt{-d}) are those with χd(p)=−1\chi_d(p) = -1. A sum over odd powers of inert primes is a sum over all prime powers with the coefficient 1−χd(r)1 - \chi_d(r):

1−χd(ph)  =  {2,p inert, h odd,0,all other prime powers with p≠d.1 - \chi_d(p^h) \;=\; \begin{cases} 2, & p \text{ inert},\ h \text{ odd},\\ 0, & \text{all other prime powers with } p \ne d. \end{cases}

The coefficient 22 matches the factor 22 in 2elog⁡p2e\log p of chapter 10. So the divisibility side is ∑rΛ(r)(1−χd(r))(⋯ )\sum_r \Lambda(r)(1 - \chi_d(r))(\cdots): the sum for ζ\zeta minus the sum for L(s,χd)L(s, \chi_d). To isolate ζ\zeta one must know that the χd\chi_d-sum is small. This is arranged by choosing dd well (chapter 12), and it is not circular. Defect (D2) of chapter 8 has become a design choice.

Many places: a table

By chapter 10 the weight met by a prime power r=phr = p^h depends on the place to which the Frobenius of rr leads. The field used in the proof is

E  =  Q(ζN+ζN−1, −q, −d ),ζN=e2πi/N,N=4n,E \;=\; \mathbb Q\big(\zeta_N + \zeta_N^{-1},\ \sqrt{-q},\ \sqrt{-d}\,\big), \qquad \zeta_N = e^{2\pi i/N},\quad N = 4n,

with nn a large power of 22 and q≡3 mod 4q \equiv 3 \bmod 4 a second auxiliary prime. Starting from the fixed place, the place reached by rr is determined by two things: the residue class of rr modulo NN up to sign (the Frobenius sends ζN+ζN−1\zeta_N + \zeta_N^{-1} to ζNr+ζN−r\zeta_N^r + \zeta_N^{-r}), and the quadratic symbol χq(r)\chi_q(r) (the Frobenius multiplies −q\sqrt{-q} by χq(r)\chi_q(r); the conjugation that enters for odd powers of inert primes changes its sign, which only interchanges the names of the two rows). So the places can be arranged in a table with two rows (the value of χq\chi_q) and nn columns (the residue class), and each prime power is assigned to a cell:

row v(r)=12(1+χq(r)),column [r]={r,−r} mod N.\text{row } v(r) = \tfrac12\big(1 + \chi_q(r)\big), \qquad \text{column } [r] = \{r, -r\} \bmod N .

The nn pairs of odd residues form a group HH under multiplication; its elements label the columns, and a fixed label t∈Ht \in H puts rr in column t[r]t[r].

The archive encodes the places as pairs of a two-bit label and an element of HH: one bit for complex conjugation, one for the row, and the column.

Formalism.D5.E0abbrevThickAverageLoss/PartnersToFactorsAt.lean:13E0=Z/2×Z/2E_0 = \mathbb Z/2 \times \mathbb Z/2: the two bits attached to a place.
abbrev E0

E0=Z/2×Z/2E_0 = \mathbb Z/2 \times \mathbb Z/2: the two bits attached to a place.

Formalism.D5.InPhidefThickAverageLoss/PartnersToFactorsAt.lean:20A place is in the chosen half (the CM type) when its first bit is 00.
def InPhi (g : E0 × H) : Prop

A place is in the chosen half (the CM type) when its first bit is 00.

Formalism.D5.PhiSetdefThickAverageLoss/PartnersToFactorsAt.lean:29Φ\Phi: the 2n2n chosen places.
def PhiSet : Finset (E0 × H)

Φ\Phi: the 2n2n chosen places.

Formalism.D5.topPldefThickAverageLoss/PartnersToFactorsAt.lean:26The place (0,0,t)(0, 0, t) in row 11 at column tt: a *top* place, one that can carry the weight bb.
def topPl (t : H) : E0 × H

The place (0,0,t)(0, 0, t) in row 11 at column tt: a *top* place, one that can carry the weight bb.

Formalism.D5.thickPldefThickAverageLoss/PartnersToFactorsAt.lean:27The place (0,1,t)(0, 1, t) in row 00 at column tt.
def thickPl (t : H) : E0 × H

The place (0,1,t)(0, 1, t) in row 00 at column tt.

Formalism.LFunctionChainParameters.characterSumData.partnerdefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:19The place linked to gg at the label tt: gˉ+(0,0,t)\bar g + (0,0,t), conjugation composed with the translation by tt. This is the Frobenius-then-conjugate rule of chapter 10.
def partner (t : H) (g : E0 × H) : E0 × H

The place linked to gg at the label tt: gˉ+(0,0,t)\bar g + (0,0,t), conjugation composed with the translation by tt. This is the Frobenius-then-conjugate rule of chapter 10.

The table for q=3q = 3, d=23d = 23, N=16N = 16: the primes up to 61 drop into their cells; a weight b=10b = 10 lands on one cell and 0.050.05 on the others; the prime sum PP and its main term MM for the four translates; then the inequality (M).

The data and the weights

Fix a small ε>0\varepsilon > 0 and a scale xx. Let q≡3 mod 8q \equiv 3 \bmod 8 and d≡7 mod 16d \equiv 7 \bmod 16 be primes with q∣d+1q \mid d + 1 (how they are chosen: chapter 12). They are very large: if xx lies in [Y,Y3/2][Y, Y^{3/2}], then log⁡q\log q is about Yε/5Y^{\varepsilon/5} and log⁡d\log d about Yε/5(log⁡Y)2Y^{\varepsilon/5}(\log Y)^2. Let nn be a power of 22 with x2+8ε≤n≤2x2+8εx^{2+8\varepsilon} \le n \le 2x^{2+8\varepsilon}, and N=4nN = 4n. Let b=exp⁡(xε)b = \exp(x^\varepsilon).

The construction supplies nonempty subsets T,T2T, T_2 of HH, an integer at>0a_t > 0 for each t∈Tt \in T with ∣at/b−x∣≤1|a_t/b - x| \le 1, and mm maps of initial rank kk (the chain of chapter 9). Write δ=∣T2∣/n\delta = |T_2|/n. For each translate u∈Hu \in H and map 1≤j≤m1 \le j \le m there are 2n2n positive weights wu,j(v,s)w_{u,j}(v, s); in the construction they are integers. The distinguished cells are (1,s)(1, s) with s∈uT2s \in uT_2. Their weights satisfy b≤wu,j(1,s)≤b+O(b/(nx2))b \le w_{u,j}(1, s) \le b + O(b/(nx^2)). At every other cell the ratio at/wu,j(v,s)a_t/w_{u,j}(v, s) is at least exp⁡(xε/3)/3\exp(x^{\varepsilon/3})/3. Thus the same table tests primes at two markedly different scales.

The archive’s arithmetic record for a host carries exactly the two auxiliary primes, the inertia subgroups and the Frobenius map into the places, with the facts that make the two labels work:

Formalism.LFunctionChainParameters.characterSumData.ArithDatastructureSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:38The record: q1q_1 (our qq), dd, an inertia subgroup of E0×HE_0 \times H for each prime, and the Frobenius frob ⁣:N→E0×H\mathrm{frob}\colon \mathbb N \to E_0 \times H.
structure ArithData (H : Type) [AddCommGroup H] [Fintype H] [DecidableEq H]

The record: q1q_1 (our qq), dd, an inertia subgroup of E0×HE_0 \times H for each prime, and the Frobenius frob ⁣:N→E0×H\mathrm{frob}\colon \mathbb N \to E_0 \times H.

Full declaration with proof
structure ArithData (H : Type) [AddCommGroup H] [Fintype H] [DecidableEq H] where
  q1 : ℕ
  d : ℕ
  inertia : ℕ → AddSubgroup (E0 × H)
  frob : ℕ → E0 × H
Formalism.LFunctionChainParameters.characterSumData.HostFactsstructureSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:47q1q_1 and dd are odd primes, distinct; every other odd prime is unramified; 22 and q1q_1 have inertia and Frobenius inside the chosen half; the inertia at dd is {0,sgc0}\{0, \mathrm{sgc}_0\} (the ramified prime has half weight).
structure HostFacts (D : ArithData H) : Prop

q1q_1 and dd are odd primes, distinct; every other odd prime is unramified; 22 and q1q_1 have inertia and Frobenius inside the chosen half; the inertia at dd is {0,sgc0}\{0, \mathrm{sgc}_0\} (the ramified prime has half weight).

Full declaration with proof
structure HostFacts (D : ArithData H) : Prop where
  first_prime_prime : D.q1.Prime
  d_prime : D.d.Prime
  first_prime_ne_two : D.q1 ≠ 2
  d_ne_two : D.d ≠ 2
  firstPrime_ne_secondPrime : D.q1 ≠ D.d

  unram : ∀ p : ℕ, p.Prime → p ≠ 2 → p ≠ D.q1 → p ≠ D.d → D.inertia p = ⊥

  split_inertia : ∀ p : ℕ, (p = 2 ∨ p = D.q1) → ∀ x ∈ D.inertia p, InPhi x
  split_frob : ∀ p : ℕ, (p = 2 ∨ p = D.q1) → InPhi (D.frob p)

  inertia_d : ∀ x, x ∈ D.inertia D.d ↔ x = 0 ∨ x = sgc0
Formalism.LFunctionChainParameters.characterSumData.IsInertdefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:72An inert prime: odd, different from q1q_1 and dd, whose Frobenius lands outside the chosen half.
def IsInert (D : ArithData H) (p : ℕ) : Prop

An inert prime: odd, different from q1q_1 and dd, whose Frobenius lands outside the chosen half.

Full declaration with proof
def IsInert (D : ArithData H) (p : ℕ) : Prop :=
  p.Prime ∧ p ≠ 2 ∧ p ≠ D.q1 ∧ p ≠ D.d ∧ ¬ InPhi (D.frob p)

The prime sum and its main term

Fix u,t,ju, t, j, write a=ata = a_t and w=wu,jw = w_{u,j}. Each prime power in cell i=(v,s)i = (v, s) contributes c(r) (a/r−wi)+=c(r) wi (a/(rwi)−1)+c(r)\,(a/r - w_i)_+ = c(r)\,w_i\,(a/(r w_i) - 1)_+, and the contribution ends at r=a/wir = a/w_i. Adding all cells gives the finite sum

Pu,t,j  =  ∑p odd primep≠q ∑h≥1(1−χd(ph))log⁡p (atph−wu,j(v(ph), t[ph]))+.P_{u,t,j} \;=\; \sum_{\substack{p \text{ odd prime}\\ p \ne q}}\ \sum_{h \ge 1} \big(1 - \chi_d(p^h)\big)\log p\,\Big(\frac{a_t}{p^h} - w_{u,j}\big(v(p^h),\ t[p^h]\big)\Big)_+ .

The primes 22 and qq can be omitted without changing anything: d≡7 mod 8d \equiv 7 \bmod 8 gives χd(2)=1\chi_d(2) = 1, and q∣d+1q \mid d + 1 gives χd(q)=1\chi_d(q) = 1 by quadratic reciprocity (indeed q,d≡3 mod 4q, d \equiv 3 \bmod 4 and d≡−1 mod qd \equiv -1 \bmod q give (q/d)=−(d/q)=−(−1/q)=1(q/d) = -(d/q) = -(-1/q) = 1). This is what the congruence conditions on qq and dd are for. The powers of dd do occur, with coefficient log⁡d\log d, but only at the large scale, since d>xd > x.

The quantity to subtract is the value PP would have if primes were perfectly distributed among the cells (chapter 12 derives it):

Mu,t,j  =  at(log⁡at−1−γ+L′L(1,χd)−⟨log⁡w⟩),⟨log⁡w⟩=12n∑ilog⁡wi.M_{u,t,j} \;=\; a_t\Big(\log a_t - 1 - \gamma + \frac{L'}{L}(1, \chi_d) - \langle \log w\rangle\Big), \qquad \langle\log w\rangle = \frac{1}{2n}\sum_i \log w_i .

So P−MP - M measures the irregularity of primes in the cells of the table, at the scales a/wia/w_i. The archive’s definitions follow this to the letter.

Formalism.LFunctionChainParameters.characterSumData.askPdefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:75The contribution of one inert prime pp: the sum over i≤Ni \le N with frob(p)i\mathrm{frob}(p)^i outside the chosen half of (a/pi−w(partner t (i⋅frob p)))+(a/p^i - w(\mathrm{partner}\,t\,(i\cdot\mathrm{frob}\,p)))_+. Odd powers only, at the linked place.
def askP (D : ArithData H) (N : ℕ) (a : ℝ) (t : H) (w : E0 × H → ℝ) (p : ℕ) : ℝ

The contribution of one inert prime pp: the sum over i≤Ni \le N with frob(p)i\mathrm{frob}(p)^i outside the chosen half of (a/pi−w(partner t (i⋅frob p)))+(a/p^i - w(\mathrm{partner}\,t\,(i\cdot\mathrm{frob}\,p)))_+. Odd powers only, at the linked place.

Full declaration with proof
def askP (D : ArithData H) (N : ℕ) (a : ℝ) (t : H) (w : E0 × H → ℝ) (p : ℕ) : ℝ :=
  ∑ i ∈ (Icc 1 N).filter (fun i => ¬ InPhi (i • D.frob p)),
    max (a / (p : ℝ) ^ i - w (partner t (i • D.frob p))) 0
Formalism.LFunctionChainParameters.characterSumData.ASKdefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:84The prime sum: ∑p inert2log⁡p⋅askP(p)+log⁡d⋅askD\sum_{p \text{ inert}} 2\log p\cdot\mathrm{askP}(p) + \log d\cdot\mathrm{askD}, the ramified prime with half weight. This is Pu,t,jP_{u,t,j}.
def ASK (D : ArithData H) (N : ℕ) (a : ℝ) (t : H) (w : E0 × H → ℝ) : ℝ

The prime sum: ∑p inert2log⁡p⋅askP(p)+log⁡d⋅askD\sum_{p \text{ inert}} 2\log p\cdot\mathrm{askP}(p) + \log d\cdot\mathrm{askD}, the ramified prime with half weight. This is Pu,t,jP_{u,t,j}.

Full declaration with proof
def ASK (D : ArithData H) (N : ℕ) (a : ℝ) (t : H) (w : E0 × H → ℝ) : ℝ := by
  classical
  exact (∑ p ∈ (range (N + 1)).filter (IsInert D), 2 * Real.log p * askP D N a t w p)
    + Real.log D.d * askD D N a t w
Formalism.LFunctionChainParameters.characterSumData.MAINdefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:89a(log⁡a−1−γ+ℓ(χC)−1∣Φ∣∑ρ∈Φlog⁡wρ)a\big(\log a - 1 - \gamma + \ell(\chi_C) - \tfrac{1}{|\Phi|}\sum_{\rho\in\Phi}\log w_\rho\big), where ℓ\ell assigns to each character of the table the constant L′/L(1,⋅)L'/L(1, \cdot) of its primitive version and χC\chi_C is the character χd\chi_d. This is Mu,t,jM_{u,t,j}.
def MAIN (ell : AddChar (E0 × H) ℂ → ℂ) (a : ℝ) (w : E0 × H → ℝ) : ℂ

a(log⁡a−1−γ+ℓ(χC)−1∣Φ∣∑ρ∈Φlog⁡wρ)a\big(\log a - 1 - \gamma + \ell(\chi_C) - \tfrac{1}{|\Phi|}\sum_{\rho\in\Phi}\log w_\rho\big), where ℓ\ell assigns to each character of the table the constant L′/L(1,⋅)L'/L(1, \cdot) of its primitive version and χC\chi_C is the character χd\chi_d. This is Mu,t,jM_{u,t,j}.

Full declaration with proof
def MAIN (ell : AddChar (E0 × H) ℂ → ℂ) (a : ℝ) (w : E0 × H → ℝ) : ℂ :=
  (a : ℂ) * (((Real.log a - 1 - Real.eulerMascheroniConstant : ℝ) : ℂ) + ell chC
    - (((1 / ((PhiSet (H := H)).card : ℝ)) * ∑ ρ ∈ PhiSet (H := H), Real.log (w ρ) : ℝ) : ℂ))

The inequality (M)

On the selected intervals the archive constructs the data above with δ≥x−ε\delta \ge x^{-\varepsilon}, ∣T∣/n≥x−ε/8/2|T|/n \ge x^{-\varepsilon/8}/2, and an upper error E≥0E \ge 0. With B=12∣T∣ m b δB = \tfrac12|T|\,m\,b\,\delta it proves

1n∑u∈H∑t∈T∑j=1m(Pu,t,j−Mu,t,j)  ≤  E,EB  ≤  xCε(xm+xmk+m+kn2).(M)\frac1n\sum_{u \in H}\sum_{t \in T}\sum_{j=1}^m \big(P_{u,t,j} - M_{u,t,j}\big) \;\le\; E, \qquad \frac EB \;\le\; x^{C\varepsilon}\Big(\frac xm + \frac{xm}{k} + m + \frac{k}{n^2}\Big). \tag{M}

Here CC is absolute, and the inequality is asserted for x≥x0(ε)x \ge x_0(\varepsilon). In words: on average over translates, the primes are not more numerous than expected in the table, up to the four errors shown. It is an upper bound, as every instance of the one-line inequality of chapter 7 is. The first inequality compares integral divisibility with complex size; the second is a computation with the sizes of the construction: m=x1/2+O(ε)m = x^{1/2 + O(\varepsilon)}, k=x9/2+O(ε)k = x^{9/2 + O(\varepsilon)}, n=x2+O(ε)n = x^{2 + O(\varepsilon)} (chapter 15 explains the balance).

The unnormalised error. The archive’s error bracket before division by BB is, with h=∣T∣h = |T|, h2=∣T2∣h_2 = |T_2| and an aggregate scale aE≤2xba_E \le 2xb,

E  ≤  xCε(h aE(1+m2k)+m(2nmb xε+h2 k b xεn (nx−ε))).E \;\le\; x^{C\varepsilon}\Big(h\,a_E\big(1 + \tfrac{m^2}{k}\big) + m\Big(2nmb\,x^\varepsilon + \frac{h_2\,k\,b\,x^\varepsilon}{n\,(n x^{-\varepsilon})}\Big)\Big).

Division by B=hmbδ/2B = hmb\delta/2 bounds the three bracketed contributions respectively by 4δ(xm+xmk)\tfrac4\delta(\tfrac xm + \tfrac{xm}{k}), 4nhδmxε\tfrac{4n}{h\delta}m x^\varepsilon and 2nhkn2x2ε\tfrac{2n}{h}\tfrac{k}{n^2}x^{2\varepsilon}; with h2=nδh_2 = n\delta and the bounds on n/hn/h and 1/δ1/\delta this gives (M). This computation explains why multiplicity matters: a cost incurred once yields x/mx/m after division, while the lattice comparison incurs a cost of order mm after division. Their balance occurs at x\sqrt x.

Formalism.LFunctionChainParameters.LErr.errorBracketSizeWindowsdefSizeWindowBrackets/ErrorFormsWeakWindowsFalse.lean:133The bracket above, as a function of x,ε,n,∣T∣,∣T2∣,m,b,k,aEx, \varepsilon, n, |T|, |T_2|, m, b, k, a_E.
def errorBracketSizeWindows (x ε : ℝ) (n nT nT2 m : ℕ) (b k aE : ℝ) : ℝ

The bracket above, as a function of x,ε,n,∣T∣,∣T2∣,m,b,k,aEx, \varepsilon, n, |T|, |T_2|, m, b, k, a_E.

Full declaration with proof
def errorBracketSizeWindows (x ε : ℝ) (n nT nT2 m : ℕ) (b k aE : ℝ) : ℝ :=
  (nT : ℝ) * aE * (1 + (m : ℝ) ^ 2 / k)
    + m * ((2 * n) * m * b * x ^ ε + nT2 * k * b * x ^ ε / (n * (n * x ^ (-ε))))
Deduction.CH.gapAdefDedekindLFunctions/SplitInertia.lean:50∑t∈T∑j(ASK−Re⁡MAIN)\sum_{t \in T}\sum_{j}(\mathrm{ASK} - \operatorname{Re}\mathrm{MAIN}) at a translate: the left side of (M) before averaging over uu.
def gapA (D : ArithData H) (N : ℕ) (ell : AddChar (E0 × H) ℂ → ℂ) {m : ℕ} (TT : Finset H) (a : H → ℝ)
    (w : H → Fin m → E0 × H → ℝ) (u0 : H) : ℝ

∑t∈T∑j(ASK−Re⁡MAIN)\sum_{t \in T}\sum_{j}(\mathrm{ASK} - \operatorname{Re}\mathrm{MAIN}) at a translate: the left side of (M) before averaging over uu.

Full declaration with proof
def gapA (D : ArithData H) (N : ℕ) (ell : AddChar (E0 × H) ℂ → ℂ) {m : ℕ} (TT : Finset H) (a : H → ℝ)
    (w : H → Fin m → E0 × H → ℝ) (u0 : H) : ℝ :=
  ∑ t ∈ TT, ∑ j : Fin m, (ASK D N (a t) t (w u0 j) - (MAIN ell (a t) (w u0 j)).re)
Deduction.ch_toptheoremLandauTheorems/ChTop.lean:37At each translate, the gap is at most xCεx^{C\varepsilon} times the error bracket, given the identification of the table data with the chain's data, the size-window hypotheses, the error windows, the bounds on T2T_2, and xx large. The route from this theorem to the window criterion of chapter 6 passes through `core_gm` (chapter 12).
theorem ch_top {H : Type} [AddCommGroup H] [Fintype H] [DecidableEq H] {U0 : Type} [Fintype U0] {W : U0 → Type} [∀ u0, Fintype (W u0)] [∀ u0, Nonempty (W u0)]
    {Top : Type} [Fintype Top] {m f : ℕ} (Dd : Data U0 W Top m f) (tr : U0 → H) (C : Consts) (Xpp eK K : ℝ)
    (D : ArithData H) (ell : AddChar (E0 × H) ℂ → ℂ) (N : ℕ) (TT T2 : Finset H) (a : H → ℝ)
    (w : H → Fin m → E0 × H → ℝ) (eT : Top ≃ TT) (eP : Fin f ≃ PhiSet (H

At each translate, the gap is at most xCεx^{C\varepsilon} times the error bracket, given the identification of the table data with the chain's data, the size-window hypotheses, the error windows, the bounds on T2T_2, and xx large. The route from this theorem to the window criterion of chapter 6 passes through `core_gm` (chapter 12).

Full declaration with proof
theorem ch_top {H : Type} [AddCommGroup H] [Fintype H] [DecidableEq H] {U0 : Type} [Fintype U0] {W : U0 → Type} [∀ u0, Fintype (W u0)] [∀ u0, Nonempty (W u0)]
    {Top : Type} [Fintype Top] {m f : ℕ} (Dd : Data U0 W Top m f) (tr : U0 → H) (C : Consts) (Xpp eK K : ℝ)
    (D : ArithData H) (ell : AddChar (E0 × H) ℂ → ℂ) (N : ℕ) (TT T2 : Finset H) (a : H → ℝ)
    (w : H → Fin m → E0 × H → ℝ) (eT : Top ≃ TT) (eP : Fin f ≃ PhiSet (H := H))
    (h1 : IdentU Dd tr D N ell TT a w eT eP) (h2 : SizeData₂ Dd C Xpp) (h3 : ErrWindows Dd C Xpp eK K) (h4 : BNBoundsU Dd T2)
    (h5 : LargeX Dd.x Dd.ε K C.cHH eK) (u : U0) :
    gapA D N ell TT a w (tr u) ≤
      Dd.x ^ (CErr C * Dd.ε) * errorBracketSizeWindows Dd.x Dd.ε (Fintype.card H) TT.card T2.card m Dd.b Dd.k Dd.a := by
  have hmain := ch_top_main_eq Dd tr D N ell TT a w eT eP h1 u
  have hask := h1.2.2.2.2 u
  have hgap : gapA D N ell TT a w (tr u) = Dd.ASK u - Dd.Main u := by
    rw [hask, hmain]
    unfold gapA
    rw [← Finset.sum_sub_distrib]
    refine Finset.sum_congr rfl fun t _ => ?_
    rw [← Finset.sum_sub_distrib]
  obtain ⟨s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11⟩ := h2
  have hle := each_unit_bound_statement Dd C Xpp s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 u
  have herr := errX5at_le Dd C Xpp eK K h3 h5 u
  have hnT : Dd.nT = (TT.card : ℝ) := by
    unfold Data.nT
    have := Fintype.card_congr eT
    rw [Fintype.card_coe] at this
    exact_mod_cast this
  have htext : ErrText Dd ≤ errorBracketSizeWindows Dd.x Dd.ε (Fintype.card H) TT.card T2.card m Dd.b Dd.k Dd.a := by
    unfold ErrText errorBracketSizeWindows
    rw [hnT]
    have hm : (0 : ℝ) ≤ m := Nat.cast_nonneg m
    gcongr
    · exact h4.1
    · exact h4.2
  have hpow : 0 ≤ Dd.x ^ (CErr C * Dd.ε) := Real.rpow_nonneg s1.1.le _
  rw [hgap]
  calc Dd.ASK u - Dd.Main u ≤ _ := by linarith
    _ ≤ _ := herr
    _ ≤ _ := mul_le_mul_of_nonneg_left htext hpow

The hypotheses of the bound are collected in a record whose fields are the quantities named in this chapter and the next four: the scale, the weights, the slopes and heights of the lattices, the losses, and the small numbers δ,η,e\delta, \eta, e of the rank argument.

Formalism.RankGapBounds.WeightedMeanData.DatastructureRankGapBounds/MeanBoundSecondForm.lean:37The record of the comparison, indexed by translates U0U_0, words WW and labels Top\mathrm{Top}: x,ε,a,b,b′,kx, \varepsilon, a, b, b', k, the constants γ\gamma and L′/LL'/L, the period data vv, the weights ww, the slopes μ\mu and heights hh of the lattices, the prime sum `ASK`, the losses `IO`, `HH`, and δ,η,e\delta, \eta, e with their bounds.
structure Data (U0 : Type) (W : U0 → Type) (Top : Type) (m f : ℕ)

The record of the comparison, indexed by translates U0U_0, words WW and labels Top\mathrm{Top}: x,ε,a,b,b′,kx, \varepsilon, a, b, b', k, the constants γ\gamma and L′/LL'/L, the period data vv, the weights ww, the slopes μ\mu and heights hh of the lattices, the prime sum `ASK`, the losses `IO`, `HH`, and δ,η,e\delta, \eta, e with their bounds.

Full declaration with proof
structure Data (U0 : Type) (W : U0 → Type) (Top : Type) (m f : ℕ) where
  x : ℝ
  ε : ℝ
  a : ℝ
  b : ℝ
  b' : ℝ
  k : ℝ
  L : ℝ
  La : ℝ
  B0 : ℝ
  Nc : ℝ
  gam : ℝ
  LpL : ℝ
  v : ℝ
  lg : ℝ
  logGam : ℝ
  aT : Top → ℝ
  w : U0 → Fin m → Fin f → ℝ
  d : (u0 : U0) → W u0 → ℝ
  T : (u0 : U0) → W u0 → ℝ
  muN : (u0 : U0) → W u0 → ℝ
  muMaxN : (u0 : U0) → W u0 → ℝ
  h : (u0 : U0) → W u0 → ℝ
  muM : (u0 : U0) → W u0 → ℝ
  muMaxM : (u0 : U0) → W u0 → ℝ
  EeJ : (u0 : U0) → W u0 → Fin m → ℝ
  muCC : U0 → ℝ
  muMinCC : U0 → ℝ
  Fo : U0 → ℝ
  Ga : U0 → ℝ
  Ta : U0 → ℝ
  ASK : U0 → ℝ
  IO : U0 → ℝ
  HH : U0 → ℝ
  del : U0 → ℝ
  η : U0 → ℝ
  e : U0 → ℝ
  delBar : ℝ
  etaBar : ℝ
  eBar : ℝ
Formalism.RankGapBounds.WeightedMeanData.Data.MaindefRankGapBounds/MeanBoundSecondForm.lean:107∑j∑tat(log⁡at−1−γ+L′/L−1f∑ρlog⁡wu,j,ρ)\sum_j\sum_t a_t\big(\log a_t - 1 - \gamma + L'/L - \tfrac1f\sum_\rho\log w_{u,j,\rho}\big): the sum of the Mu,t,jM_{u,t,j} at a translate.
def Main (u0 : U0) : ℝ

∑j∑tat(log⁡at−1−γ+L′/L−1f∑ρlog⁡wu,j,ρ)\sum_j\sum_t a_t\big(\log a_t - 1 - \gamma + L'/L - \tfrac1f\sum_\rho\log w_{u,j,\rho}\big): the sum of the Mu,t,jM_{u,t,j} at a translate.

Full declaration with proof
def Main (u0 : U0) : ℝ :=
  ∑ j : Fin m, ∑ t, D.aT t * (Real.log (D.aT t) - 1 - D.gam + D.LpL
    - (1 / (f : ℝ)) * ∑ ρ : Fin f, Real.log (D.w u0 j ρ))
Formalism.LFunctionChainParameters.WeightedSlopeBounds.each_unit_bound_statementtheoremChainSlopeWindows/LevelOfCongruence.lean:175The bound for each translate, from the hypotheses of the record. The exposition's dependency check lists this per-translate statement among those the final theorem uses, and the averaged form below among those it does not.
theorem each_unit_bound_statement {U0 : Type} [Fintype U0] {W : U0 → Type}
    [∀ u0, Fintype (W u0)] [∀ u0, Nonempty (W u0)] {Top : Type} [Fintype Top] {m f : ℕ}
    (D : Data U0 W Top m f) (C : Consts) (Xpp : ℝ) : PointwiseBoundVariant D C Xpp

The bound for each translate, from the hypotheses of the record. The exposition's dependency check lists this per-translate statement among those the final theorem uses, and the averaged form below among those it does not.

Full declaration with proof
theorem each_unit_bound_statement {U0 : Type} [Fintype U0] {W : U0 → Type}
    [∀ u0, Fintype (W u0)] [∀ u0, Nonempty (W u0)] {Top : Type} [Fintype Top] {m f : ℕ}
    (D : Data U0 W Top m f) (C : Consts) (Xpp : ℝ) : PointwiseBoundVariant D C Xpp := by
  intro hS hDIV hE hH hCount hSl hSN hLoss hSI hHH hFP u0
  have hx : 0 < D.x := hS.1
  have hdelBar : D.delBar < 1 := hS.2.2.2.2.2.2.2.2.2.2.2.2.2.1
  have hcSl1 : 0 ≤ C.cSl1 := hS.2.2.2.2.2.2.2.2.2.2.2.2.1
  have hinv0 : 0 ≤ (1 - D.delBar)⁻¹ := inv_nonneg.mpr (by linarith)
  have hX : 0 < D.x ^ C.cHH := Real.rpow_pos_of_pos hx _
  have hLX : 0 ≤ Real.log (1 + D.x ^ C.cHH) := Real.log_nonneg (by linarith)
  have hc4 : 0 ≤ (1 - D.delBar)⁻¹ * (4 * Real.log (1 + D.x ^ C.cHH)) :=
    mul_nonneg hinv0 (mul_nonneg (by norm_num) hLX)
  have h1 := Ga_bound5 D C Xpp hS hDIV hE hH hCount hSl hSN hSI hHH hFP u0
  have h2 := weighted_mean_lower_bound_le D C Xpp hS hCount u0
  have hIO := mul_le_mul_of_nonneg_left (hLoss u0).2 hcSl1
  have hML : wmean (D.d u0) (Lo5 D C Xpp u0) ≤ MLo5 D C Xpp := by
    unfold MLo5; unfold K7v5 at h2; linarith
  have h3 := mul_le_mul_of_nonneg_left hML hc4
  have h4 := (hLoss u0).1
  unfold Data.K3 at h1
  unfold K0v5 Data.EDiv at h1
  unfold ErrX5at UBar5
  linarith
Formalism.RankGapBounds.WeightedMeanData.Data.MeanBoundSecondFormdefRankGapBounds/MeanBoundSecondForm.lean:187The averaged form: under the twelve hypotheses, the mean of `ASK` over translates is at most the mean of `Main` plus the explicit error `ErrX`.
def MeanBoundSecondForm : Prop

The averaged form: under the twelve hypotheses, the mean of `ASK` over translates is at most the mean of `Main` plus the explicit error `ErrX`.

Full declaration with proof
def MeanBoundSecondForm : Prop :=
  Nonempty U0 → D.HidaSetting C → D.DIV C → D.EComp C → D.HComp C → D.Count C → D.Slopes C → D.SlopesN C →
    D.Losses C → D.SlopeIneq → D.HHBound C → D.FParams →
    umean D.ASK ≤ umean D.Main + D.ErrX C
Formalism.RankGapBounds.WeightedMeanData.Data.ErrXdefRankGapBounds/MeanBoundSecondForm.lean:176The explicit error: the sum of the loss terms, the slope spreads, the rank and count costs, and the layer-cake error of chapter 15.
def ErrX : ℝ

The explicit error: the sum of the loss terms, the slope spreads, the rank and count costs, and the layer-cake error of chapter 15.

Full declaration with proof
def ErrX : ℝ :=
  D.sumA * (C.cCount * (D.L + (m : ℝ) ^ 2 * D.L / D.k) + 2 * D.logGam / ((f : ℝ) * D.k))
    + (C.cDiv * D.nT * D.a * D.La + C.cDiv * (m : ℝ) * (D.B0 + D.Nc) * D.x ^ (C.eDiv * D.ε))
    + (m : ℝ) * C.cE * D.B0
    + C.cSlope * D.nT * D.a * D.La * (1 + (m : ℝ) / D.k)
    + umean (fun u0 => Real.log (Fintype.card (W u0) : ℝ))
    + D.LoP C
    + D.MLo C
    + (1 - D.delBar)⁻¹ * (4 * Real.log (1 + D.x ^ C.cHH) * (D.UBar C + D.b)
        + (D.etaBar + 4 * Real.sqrt D.eBar) * (D.x ^ C.cHH * D.b))

A table small enough to write out

Take q=3q = 3, d=23d = 23, N=16N = 16, so n=4n = 4 and H={[1],[3],[5],[7]}H = \{[1], [3], [5], [7]\}. The nonzero squares modulo 2323 are 1,2,3,4,6,8,9,12,13,16,181, 2, 3, 4, 6, 8, 9, 12, 13, 16, 18. The prime 77 is a square modulo 33 and 7≡7 mod 167 \equiv 7 \bmod 16: it goes in row 11, column [7][7], with coefficient 2log⁡72\log 7 because 77 is a non-square modulo 2323. Its square disappears because χ23(72)=1\chi_{23}(7^2) = 1; its cube has the same row and column as 77. To place 1111, observe that 11≡2 mod 311 \equiv 2 \bmod 3 and [11]=[5][11] = [5]. At the exceptional prime 2323, its first power lands in (0,[7])(0, [7]), its square in (1,[1])(1, [1]), and each has coefficient log⁡23\log 23. The primes up to 6161 with nonzero coefficient fall as follows, and below them are the per-cell constants and sums of the next section.

row \ column[1][3][5][7]
v = 0: χ3(r) = −117–5, 11, 5323
v = 1: χ3(r) = +1–19, 6137, 437
cell iCiSi(1000)Si(200000)Ri(1000)Ri(200000)
(0, [1])-0.372219523.602230456.69932.352-251.387
(0, [3])-0.631093224.352178879.838-8.025-53.464
(0, [5])0.5659671441.249418604.45111.813259.312
(0, [7])-0.406444417.613224057.714-39.412194.742
(1, [1])-0.575353291.947190566.1233.831484.900
(1, [3])-0.202447694.308264017.19433.286-645.209
(1, [5])-0.272849578.281250761.014-12.339179.021
(1, [7])-0.104899737.266284065.998-21.305-106.090
sum of the Ci-1.999336613= −1 − γ + L′/L(1, χ23) = -1.999336613

With weight 10 on the cell (1, [1]) and 0.05 on the other seven: P = 95461.6156, M = 95444.4636, excess 17.1520; the other three translates give 368.2081, -129.2546, -204.6531, and the mean is 12.8631. The same mean computed from the R columns splits as 8.679631 from the distinguished cells and 4.183488 from the rest.

With x=1000x = 1000, b=10b = 10, a=104a = 10^4, weight 1010 in cell (1,[1])(1, [1]) and 0.050.05 elsewhere, the cutoffs are a/w=1000a/w = 1000 in the distinguished cell and 200000200000 in the others. Summing over the prime powers gives P=95461.6156P = 95461.6156 and M=95444.4636M = 95444.4636: the excess is 17.152017.1520 against a main term of nearly 10510^5. Moving the distinguished cell to the other three columns gives excesses 368.2081368.2081, −129.2546-129.2546, −204.6531-204.6531; the mean of the four is 12.863112.8631. (The example ignores one feature of the construction, that the weights are integers, and its parameters do not satisfy the conditions of (M). The identities it illustrates hold for any positive weights.) Try other scales and weights:

cell[1][3][5][7]
row 0 (χ₃ = −1)
w = 0.050, cutoff 200,000
w·S = 11522.8
w = 0.050, cutoff 200,000
w·S = 8944.0
w = 0.050, cutoff 200,000
w·S = 20930.2
w = 0.050, cutoff 200,000
w·S = 11202.9
row 1 (χ₃ = +1)
w = 10, cutoff 1,000
w·S = 2919.5
w = 0.050, cutoff 200,000
w·S = 13200.9
w = 0.050, cutoff 200,000
w·S = 12538.1
w = 0.050, cutoff 200,000
w·S = 14203.3
translate uPMP − M
[1]95461.615695444.463617.1520
[3]95812.671895444.4636368.2081
[5]95315.209095444.4636-129.2546
[7]95239.810695444.4636-204.6531
mean over the four translates12.8631

a = x·b = 10,000. At x = 1000, b = 10, small weights 0.05 and column [1] this reproduces the exposition's 95461.6156 − 95444.4636 = 17.1520, and the mean 12.8631. The identity P − M = Σ_i w_i R_i(a/w_i) holds for any positive weights; the conditions of (M) on b, δ and the scales are not met by a table this small.

The exact identity behind P−MP - M

Keep tt fixed. For a cell ii write Si(y)=∑r∈ic(r)(y/r−1)+S_i(y) = \sum_{r \in i} c(r)(y/r - 1)_+ and Ψi(z)=∑r∈i, r≤zc(r)\Psi_i(z) = \sum_{r \in i,\ r \le z} c(r). Integrating each step of Ψi\Psi_i gives Si(y)/y=∫1yΨi(z) dz/z2S_i(y)/y = \int_1^y \Psi_i(z)\,dz/z^2, and term by term Pu,t,j=∑iwiSi(a/wi)P_{u,t,j} = \sum_i w_i S_i(a/w_i). For fixed moduli, among primes not dividing 2qd2qd the fraction contributing to a given cell is 1/(4n)1/(4n), and the coefficient 2log⁡p2\log p doubles this density, so Ψi(z)\Psi_i(z) has main term μz\mu z with μ=1/(2n)\mu = 1/(2n). Put Ci=∫1∞(Ψi(z)−μz) dz/z2C_i = \int_1^\infty (\Psi_i(z) - \mu z)\,dz/z^2. Then exactly

Si(y)  =  μ ylog⁡y+Ci y+Ri(y),Ri(y)=−y∫y∞(Ψi(z)−μz)dzz2,S_i(y) \;=\; \mu\,y\log y + C_i\,y + R_i(y), \qquad R_i(y) = -y\int_y^\infty \big(\Psi_i(z) - \mu z\big)\frac{dz}{z^2},

and summing the cells, ∑iSi(y)=S1(y)−Sχd(y)\sum_i S_i(y) = S_1(y) - S_{\chi_d}(y), whose constants are −1−γ-1 - \gamma and +L′/L(1,χd)+L'/L(1, \chi_d). Hence

∑iCi  =  −1−γ+L′L(1,χd),Pu,t,j−Mu,t,j  =  ∑iwi Ri(awi).\sum_i C_i \;=\; -1 - \gamma + \frac{L'}{L}(1, \chi_d), \qquad P_{u,t,j} - M_{u,t,j} \;=\; \sum_i w_i\,R_i\Big(\frac{a}{w_i}\Big).

In the example the eight constants sum to −1.999336613…-1.999336613\ldots, and doing the weighting in the RR columns of the table above gives 17.152017.1520 again. The archive proves this balance as an identity between its prime sum, its main term and a character-expanded remainder.

Formalism.LFunctionChainParameters.characterSumData.GPsidefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:68Gψ(y)G_\psi(y) for a character ψ\psi of E0×HE_0 \times H: the smoothed sum ∑n≤yΛ(n) ψ(frob n) (y/n−1)\sum_{n \le y}\Lambda(n)\,\psi(\mathrm{frob}\,n)\,(y/n - 1) plus y ℓ(ψ)y\,\ell(\psi); for the trivial character, the GG of chapter 2.
def GPsi (D : ArithData H) (ell : AddChar (E0 × H) ℂ → ℂ) (ψ : AddChar (E0 × H) ℂ) (y : ℝ) : ℂ

Gψ(y)G_\psi(y) for a character ψ\psi of E0×HE_0 \times H: the smoothed sum ∑n≤yΛ(n) ψ(frob n) (y/n−1)\sum_{n \le y}\Lambda(n)\,\psi(\mathrm{frob}\,n)\,(y/n - 1) plus y ℓ(ψ)y\,\ell(\psi); for the trivial character, the GG of chapter 2.

Full declaration with proof
def GPsi (D : ArithData H) (ell : AddChar (E0 × H) ℂ → ℂ) (ψ : AddChar (E0 × H) ℂ) (y : ℝ) : ℂ :=
  if ψ = 0 then ((Gz y : ℝ) : ℂ) else
    (∑ n ∈ Icc 1 ⌊y⌋₊, (Λ n : ℂ) * primVal D ψ n * ((y / n - 1 : ℝ) : ℂ)) + (y : ℂ) * ell ψ
Formalism.LFunctionChainParameters.characterSumData.DedefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:93The remainder: 1∣Φ∣∑g∉Φ∑ψψ(g)‾ wg Gψ(a/wg)\tfrac{1}{|\Phi|}\sum_{g \notin \Phi}\sum_\psi \overline{\psi(g)}\,w_g\,G_\psi(a/w_g) with wgw_g the weight at the partner place of gg; the character expansion of ∑iwiRi(a/wi)\sum_i w_i R_i(a/w_i).
def De (D : ArithData H) (ell : AddChar (E0 × H) ℂ → ℂ) (a : ℝ) (t : H) (w : E0 × H → ℝ) : ℂ

The remainder: 1∣Φ∣∑g∉Φ∑ψψ(g)‾ wg Gψ(a/wg)\tfrac{1}{|\Phi|}\sum_{g \notin \Phi}\sum_\psi \overline{\psi(g)}\,w_g\,G_\psi(a/w_g) with wgw_g the weight at the partner place of gg; the character expansion of ∑iwiRi(a/wi)\sum_i w_i R_i(a/w_i).

Full declaration with proof
def De (D : ArithData H) (ell : AddChar (E0 × H) ℂ → ℂ) (a : ℝ) (t : H) (w : E0 × H → ℝ) : ℂ :=
  (1 / ((PhiSet (H := H)).card : ℂ)) * ∑ g ∈ univ.filter (fun g : E0 × H => ¬ InPhi g),
    ∑ ψ : AddChar (E0 × H) ℂ, starRingEnd ℂ (ψ g) * ((w (partner t g) : ℝ) : ℂ)
      * GPsi D ell ψ (a / w (partner t g))
Formalism.LFunctionChainParameters.characterSumData.AskMainBalancedefSizeWindowBrackets/FirstPrimeNeSecondPrime.lean:98For a host with the facts above, positive aa and weights, and NN at least every cutoff a/wa/w: ASK−MAIN=De\mathrm{ASK} - \mathrm{MAIN} = \mathrm{De}. The identity P−M=∑iwiRi(a/wi)P - M = \sum_i w_i R_i(a/w_i), in the archive.
def AskMainBalance : Prop

For a host with the facts above, positive aa and weights, and NN at least every cutoff a/wa/w: ASK−MAIN=De\mathrm{ASK} - \mathrm{MAIN} = \mathrm{De}. The identity P−M=∑iwiRi(a/wi)P - M = \sum_i w_i R_i(a/w_i), in the archive.

Full declaration with proof
def AskMainBalance : Prop :=
  ∀ (D : ArithData H), HostFacts D → ∀ (ell : AddChar (E0 × H) ℂ → ℂ) (a : ℝ) (t : H) (w : E0 × H → ℝ),
    0 < a → (∀ ρ, InPhi ρ → 0 < w ρ) → ∀ N : ℕ, (∀ ρ, InPhi ρ → a / w ρ ≤ N) →
      (ASK D N a t w : ℂ) - MAIN ell a w = De D ell a t w
How the constants $C_i$ were computed

For this table let ξ\xi be the character of the pairs modulo 1616 of order four with ξ([3])=i\xi([3]) = i, and for a cell i=(v,s)i = (v, s) put β=2v−1\beta = 2v - 1. The coefficient of the cell, divided by Λ\Lambda, has the finite character expansion 18∑j,l=01∑k=03βj(−1)l ξ(s)‾k (χ3jχ23lξk)prim(r)\tfrac18\sum_{j, l = 0}^{1}\sum_{k = 0}^{3}\beta^j(-1)^l\,\overline{\xi(s)}^k\,(\chi_3^j\chi_{23}^l\xi^k)_{\mathrm{prim}}(r), where the subscript takes the primitive character inducing the product. The sign sums are each 22 when the signs agree and zero otherwise, and the four powers of ξ\xi sum to 44 precisely in column ss: coefficient 22. At 2323 the terms with l=1l = 1 vanish, giving 11 in the prescribed cell; at 22 and 33 the χ23\chi_{23} factor sums to zero. Substituting −L′/L(1,χ)-L'/L(1, \chi) for each nontrivial character and −1−γ-1 - \gamma for the trivial one gives the CiC_i in the table. We evaluate L′/L(1,χ)L'/L(1,\chi) from the Laurent expansion of the Hurwitz zeta function, L(1,χ)=−1q∑aχ(a)ψ(a/q)L(1, \chi) = -\tfrac1q\sum_a\chi(a)\psi(a/q) and L′(1,χ)=−(log⁡q)L(1,χ)−1q∑aχ(a)γ1(a/q)L'(1, \chi) = -(\log q)L(1,\chi) - \tfrac1q\sum_a\chi(a)\gamma_1(a/q) with γ1\gamma_1 the first generalised Stieltjes constant; the three real constants are L′/L(1,χ3)=0.368282L'/L(1,\chi_3) = 0.368282, L′/L(1,χ23)=−0.422120948038L'/L(1,\chi_{23}) = -0.422120948038 and L′/L(1,χ3χ23)=0.056523L'/L(1,\chi_3\chi_{23}) = 0.056523, matching the exposition’s to the digits it prints. Every value on this page is regenerated by make numerics.