Skip to content

Proposition D: the density of good slope primes

Route AP replaces the twenty-two-prime pattern by long arithmetic progressions of good slope primes. Szemerédi's theorem in the primes provides them once the good slope primes are known to have positive relative upper density in the primes; this chapter proves that density statement, Proposition D of the route AP note in its weak form, following the project's research note on it. No complex multiplication enters: the description of the good slope primes uses elementary character sums only, the main term uses Dirichlet's theorem in residue classes, and the one deep-ish step, a uniform bound for the primes removed at a medium prime \(\ell\), uses a two-dimensional Selberg sieve.

Notation: \(G\) is the set of good slope primes, \(\chi\) the quadratic character of \(\mathbb F_p\), \(\varphi_p(a)=\sum_{x\in\mathbb F_p}\chi(x^3+ax)\), \(\pi(N)\) the number of primes at most \(N\), and for a set \(S\) of natural numbers \(\theta_S(N)=\sum_{n\le N,\,n\in S}\log n\) and \(\Phi_S(x)=\sum_{n\in S}(\log n)/n^x\).

DefinitionThe density statement for good slope primes#✓

Let \(G\) be the set of good slope primes. The density statement is the assertion that \(G\) has positive relative upper density in the primes: there is \(c>0\) such that $\(\#\bigl(G\cap[0,N]\bigr)\ge c\,\pi(N)\qquad\text{for infinitely many }N,\)$ where \(\pi(N)\) is the number of primes at most \(N\).

This is the weak form of Proposition D of the route AP note; numerically the relative density of \(G\) is about \(0.106\). Together with Szemerédi's theorem in the primes it gives long arithmetic progressions of good slope primes. It is proved in this chapter (Proposition D).

def GoodPrimeDensity : Prop :=
  PrimesRelUpperDensityPos {p | GoodSlopePrime p}
Sources
Uses 2 · Used by 3
22 fully proved

Character sums and the description of good primes

The point counts of the two reductions of \(E\) at a split prime are expressed through \(\varphi_p\), and Jacobsthal's identity writes \(p=c_p^2+e_p^2\) with \(c_p=\varphi_p(1)/2\). For the primes in the class \(p\equiv1\pmod8\), \((p/7)=-1\), being a good slope prime becomes \(\gcd(c_p,p+1)=1\).

TheoremCharacter sums for the curves \(y^2=x^3+ax\)#✓

Let \(p\) be an odd prime, \(\chi\) the quadratic character of \(\mathbb F_p\), and for \(a\in\mathbb F_p\) put \(\varphi_p(a)=\sum_{x\in\mathbb F_p}\chi(x^3+ax)\). Let \(\#E_a(\mathbb F_p)\) be the number of solutions of \(y^2=x^3+ax\) over \(\mathbb F_p\) plus one (the point at infinity). Then:

  1. \(\#E_a(\mathbb F_p)=p+1+\varphi_p(a)\);
  2. \(\varphi_p(k^2a)=\chi(k)\,\varphi_p(a)\) for \(k\in\mathbb F_p^\times\), and \(\varphi_p(0)=0\);
  3. \(\sum_{t\in\mathbb F_p}\chi\bigl((t+\alpha)(t+\beta)\bigr)=-1\) for \(\alpha\ne\beta\), and \(=p-1\) for \(\alpha=\beta\).

Proof sketch. (1) The equation \(y^2=c\) has \(1+\chi(c)\) solutions; sum over \(x\) with \(c=x^3+ax\). (2) Substitute \(x=kX\): \((kX)^3+k^2a\,kX=k^3(X^3+aX)\) and \(\chi(k^3)=\chi(k)\); and \(\varphi_p(0)=\sum\chi(x)^3=\sum\chi(x)=0\). (3) For \(t\ne-\beta\) the summand is \(\chi\bigl((t+\alpha)/(t+\beta)\bigr)\), and \(t\mapsto(t+\alpha)/(t+\beta)\) is a bijection of \(\mathbb F_p\setminus\{-\beta\}\) onto \(\mathbb F_p\setminus\{1\}\), so the sum is \(\sum_{w\ne1}\chi(w)=-1\). The Lean proofs reuse the character sums of the Selmer chapter, since \(\varphi_p(a)\) is the cubic character sum at \(-a\).

theorem pointCount_eq (hp2 : p ≠ 2) (a : ZMod p) : (pointCount p a : ℤ) = p + 1 + jac a
noncomputable def jac (a : ZMod p) : ℤ :=
  ∑ x : ZMod p, quadraticChar (ZMod p) (x ^ 3 + a * x)
theorem jac_sq_mul {k : ZMod p} (hk : k ≠ 0) (a : ZMod p) :
    jac (k ^ 2 * a) = χ k * jac a
Sources
Used by 3

TheoremJacobsthal's identity#✓

Let \(p\) be an odd prime. Every \(\varphi_p(a)\) is even, and \(\sum_{a\in\mathbb F_p}\varphi_p(a)^2=p(p-1)(1+\chi(-1))\). If \(p\equiv1\pmod4\) and \(r\in\mathbb F_p\) is not a square, then $\(\varphi_p(1)^2+\varphi_p(r)^2=4p .\)$

Proof sketch. Evenness: for \(x\ne0\), \(\chi(x^3+ax)=\chi(x)\chi(x^2+a)\), and the involution \(x\mapsto-x\) pairs the summands (for \(p\equiv3\pmod 4\) they cancel, for \(p\equiv1\) they agree), its fixed point \(x=0\) contributing \(0\). Second moment: by the shifted product sums, \(\sum_a\varphi_p(a)^2=\sum_{x,y}\chi(x)\chi(y)\sum_a\chi\bigl((a+x^2)(a+y^2)\bigr)=p(p-1)(1+\chi(-1))\), which is \(2p(p-1)\) for \(p\equiv1\pmod4\). Square classes: \(\varphi_p(0)=0\) and, by scaling, \(\varphi_p(a)^2\) is \(\varphi_p(1)^2\) on the \((p-1)/2\) nonzero squares and \(\varphi_p(r)^2\) on the \((p-1)/2\) non-squares; so \(\tfrac{p-1}2\bigl(\varphi_p(1)^2+\varphi_p(r)^2\bigr)=2p(p-1)\).

theorem jacobsthal (hp4 : p % 4 = 1) {r : ZMod p} (hr : ¬ IsSquare r) :
    jac (1 : ZMod p) ^ 2 + jac r ^ 2 = 4 * p
theorem jac_even (hp2 : p ≠ 2) (a : ZMod p) : Even (jac a)
theorem sum_jac_sq (hp2 : p ≠ 2) :
    ∑ a : ZMod p, jac a ^ 2 = (p : ℤ) * (p - 1) * (1 + χ (-1))
Sources
Uses 1 · Used by 1

TheoremFour divides the point count of \(y^2=x^3-D^2x\)#✓

Let \(p\) be an odd prime and \(D\in\mathbb F_p^\times\). Then \(4\) divides the number of points, the point at infinity included, of \(y^2=x^3-D^2x\) over \(\mathbb F_p\).

The research note states this for \(p\equiv1\pmod4\); the proof needs only that \(p\) is odd.

Proof sketch. Put \(g(x)=x(x-D)(x+D)\), with three distinct roots. Counting row by row, the point count is \(1+3+2m\) with \(m=\#X\), \(X=\{x\in\mathbb F_p^\times: g(x)\text{ a nonzero square}\}\). The involution \(\tau(x)=-D^2/x\) of \(\mathbb F_p^\times\) satisfies \(g(\tau x)=(D^2/x^2)^2g(x)\), so \(\tau(X)=X\), and an involution has \(\#X\equiv\#\mathrm{Fix}(\tau|_X)\pmod 2\). The fixed points are the solutions of \(x^2=-D^2\): none for \(p\equiv3\pmod4\), and \(\pm iD\) for \(p\equiv1\pmod4\), which lie in \(X\) together or not at all because \(g\) is odd and \(\chi(-1)=1\). So \(m\) is even and \(4\mid4+2m\).

theorem four_dvd_pointCount (hp2 : p ≠ 2) {D : ZMod p} (hD : D ≠ 0) :
    4 ∣ pointCount p (-D ^ 2)
theorem four_dvd_pointCount_of_mod_four (hp4 : p % 4 = 1) {D : ZMod p} (hD : D ≠ 0) :
    4 ∣ pointCount p (-D ^ 2)
Sources
Uses 1 · Used by 1

TheoremThe description of the good slope primes#✓

Say that a prime \(p\) is in the class if \(p\equiv1\pmod8\) and \(p\bmod7\in\{3,5,6\}\) (that is, \((p/7)=-1\)), and put \(c_p=\varphi_p(1)/2\). Let \(p\) be a prime in the class. Then:

  1. \(c_p\) is odd, and \(p=c_p^2+e_p^2\) with \(e_p=\varphi_p(r_0)/2\) for any non-square \(r_0\);
  2. for every \(r\in\mathbb F_p\) with \(r^2=2\), the point counts of \(y^2=x^3-(75-53r)^2x\) and \(y^2=x^3-(75+53r)^2x\) over \(\mathbb F_p\) are \(p+1-2c_p\) and \(p+1+2c_p\), in some order;
  3. their greatest common divisor is \(4\gcd(c_p,p+1)\);
  4. \(p\) is a good slope prime if and only if \(\gcd(c_p,p+1)=1\); and an odd prime \(\ell\) dividing both \(c_p\) and \(p+1\) satisfies \(\ell\equiv1\pmod4\).

For example \(c_{17}=-1\), so \(17\) is a good slope prime.

Proof sketch. Since \(p\equiv1\pmod8\), \(2\) is a square, so some \(r\) has \(r^2=2\), and \(d=75-53r\), \(\bar d=75+53r\) satisfy \(d\bar d=7\); by quadratic reciprocity \(\chi(7)=(p/7)=-1\), so \(d\) and \(\bar d\) are nonzero and \(\chi(d)\chi(\bar d)=-1\). By scaling, \(\varphi_p(-d^2)=\chi(d)\varphi_p(-1)\) and \(\varphi_p(-1)=\chi(i)\varphi_p(1)=\varphi_p(1)\) for \(i^2=-1\), since \(i\) is a square when \(p\equiv1\pmod8\); with the point count formula this gives (2). Four divides both point counts, and \(p+1\equiv2\pmod 8\), so \(c_p\) is odd; Jacobsthal's identity gives \(p=c_p^2+e_p^2\). For \(c\) odd and \(n\equiv2\pmod4\), \(\gcd(n-2c,n+2c)=4\gcd(c,n)\), which is (3), and (4) follows from the definition of a good slope prime. If an odd \(\ell\) divides \(c_p\) and \(p+1\), then \(e_p^2=p-c_p^2\equiv-1\pmod\ell\), so \(\ell\equiv1\pmod 4\).

theorem goodSlopePrime_iff {p : ℕ} (hp : p.Prime) (hC : InClass p) :
    GoodSlopePrime p ↔ Int.gcd (cp p) (p + 1) = 1
def InClass (p : ℕ) : Prop := p % 8 = 1 ∧ (p % 7 = 3 ∨ p % 7 = 5 ∨ p % 7 = 6)
noncomputable def cp (p : ℕ) : ℤ :=
  if h : p.Prime then haveI : Fact p.Prime := ⟨h⟩; jac (1 : ZMod p) / 2 else 0
Uses 4 · Used by 4

The residue set and the main term

The congruence conditions modulo \(8\), \(7\) and the small primes \(\ell\equiv1\pmod4\) define a set \(C_L\) of primes of Dirichlet density \(\delta_L\ge3/(8(L-1))\); removing the primes \(T_L\) bad at some \(\ell>L\) leaves good slope primes only.

TheoremThe residue set \(A_L\) and the primes \(C_L\)#✓

For \(L\ge1\) let \(Q_L\) be the set of primes \(\ell\) with \(5\le\ell\le L\) and \(\ell\equiv1\pmod4\), and \(M_L=56\prod_{\ell\in Q_L}\ell\). Let \(A_L\subseteq\mathbb Z/M_L\) be the set of residues \(a\) with \(a\equiv1\pmod8\), \(a\bmod7\in\{3,5,6\}\) and \(a\not\equiv0,-1\pmod\ell\) for every \(\ell\in Q_L\), and \(C_L\) the set of primes \(p\) with \(p\bmod M_L\in A_L\). Then every element of \(A_L\) is a unit, $\(\#A_L=3\prod_{\ell\in Q_L}(\ell-2),\qquad\varphi(M_L)=24\prod_{\ell\in Q_L}(\ell-1),\qquad \delta_L:=\frac{\#A_L}{\varphi(M_L)}=\frac18\prod_{\ell\in Q_L}\frac{\ell-2}{\ell-1},\)$ and \(\delta_L\ge3/(8(L-1))\) for \(L\ge4\). Every prime \(p\in C_L\) is in the class (\(p\equiv1\pmod8\), \((p/7)=-1\)) and satisfies \(\ell\nmid p+1\) for every \(\ell\in Q_L\).

Proof sketch. The moduli \(8\), \(7\) and the \(\ell\in Q_L\) are pairwise coprime, so by the Chinese remainder theorem \(\mathbb Z/M_L\) is the product of the \(\mathbb Z/i\), and \(A_L\) is the product of the sets of allowed components, of sizes \(1\), \(3\) and \(\ell-2\); every allowed component is a unit. The totient is multiplicative. For the lower bound, every factor \((n-2)/(n-1)\) with \(5\le n\le L\) lies in \([0,1]\), so the product over \(Q_L\) is at least the product over all \(n\in[5,L]\), which telescopes to \(3/(L-1)\).

theorem deltaL_ge {L : ℕ} (hL : 4 ≤ L) : 3 / (8 * ((L : ℝ) - 1)) ≤ deltaL L
def QL (L : ℕ) : Finset ℕ := (Icc 5 L).filter (fun ℓ => ℓ.Prime ∧ ℓ % 4 = 1)
def modSet (L : ℕ) : Finset ℕ := insert 8 (insert 7 (QL L))
Sources
Uses 1 · Used by 3

TheoremThe main term: the Dirichlet series of \(C_L\)#✓

For a set \(S\) of natural numbers and real \(x>1\) put \(\Phi_S(x)=\sum_{n\in S}(\log n)/n^x\). For every \(L\) there is a constant \(K_L\) such that $\(\Phi_{C_L}(x)\ge\frac{\delta_L}{x-1}-K_L\qquad\text{for all }x\in(1,2].\)$

Proof sketch. This is Dirichlet's theorem in residue classes, in the form Mathlib proves it: for a unit \(a\) modulo \(M\), the series \(\sum_{n\equiv a}\Lambda(n)/n^x\) is at least \(\varphi(M)^{-1}/(x-1)-C_a\) on \((1,2]\). Sum over the \(\#A_L\) unit classes \(a\in A_L\); on primes \(\Lambda(p)=\log p\), and the contribution of proper prime powers is bounded on \((1,2]\) by its (convergent) value at exponent \(1\).

theorem phi_CL_lower (L : ℕ) :
    ∃ K : ℝ, ∀ x ∈ Set.Ioc (1 : ℝ) 2, deltaL L / (x - 1) - K ≤ PhiS (CL L) x
theorem summable_vonMangoldt_div_rpow {x : ℝ} (hx : 1 < x) :
    Summable (fun n : ℕ => vonMangoldt n / (n : ℝ) ^ x)
Sources
Uses 1 · Used by 1

TheoremA subset of good slope primes#✓

For a prime \(\ell\) let \(\mathrm{Bad}_\ell\) be the set of primes \(p\) in the class (\(p\equiv1\pmod8\), \((p/7)=-1\)) with \(\ell\mid c_p\) and \(\ell\mid p+1\), and for \(L\ge1\) let \(T_L\) be the union of the \(\mathrm{Bad}_\ell\) over the primes \(\ell>L\) with \(\ell\equiv1\pmod4\). Then every prime of \(G^*_L=C_L\setminus T_L\) is a good slope prime.

Proof sketch. Let \(p\in C_L\setminus T_L\); it is in the class. If \(\gcd(c_p,p+1)\ne1\), take a prime \(\ell\) dividing it. Then \(\ell\) is odd (since \(c_p\) is odd), so \(\ell\equiv1\pmod4\) and hence \(\ell\ge5\). If \(\ell\le L\) then \(\ell\in Q_L\), which is impossible since \(\ell\mid p+1\); so \(\ell>L\) and \(p\in\mathrm{Bad}_\ell\subseteq T_L\), a contradiction. Hence \(\gcd(c_p,p+1)=1\), and \(p\) is a good slope prime by the description.

theorem goodSlopePrime_of_mem_CL {L p : ℕ} (hC : p ∈ CL L) (hT : p ∉ TL L) :
    GoodSlopePrime p
def BadSet (ℓ : ℕ) : Set ℕ := {p | p.Prime ∧ InClass p ∧ (ℓ : ℤ) ∣ cp p ∧ ℓ ∣ p + 1}
def TL (L : ℕ) : Set ℕ := {p | ∃ ℓ : ℕ, ℓ.Prime ∧ L < ℓ ∧ ℓ % 4 = 1 ∧ p ∈ BadSet ℓ}
Sources
Uses 2 · Used by 4

The primes bad at a large \(\ell\)

TheoremThe primes bad at a large \(\ell\)#✓

For every prime \(\ell\) and every \(N\), $\(\#\bigl(\mathrm{Bad}_\ell\cap[0,N]\bigr)\le\frac{8N}{\ell^2}+\frac{4\sqrt N}{\ell},\)$ and the left side is \(0\) when \(\ell>\sqrt N\). Consequently, for \(N\ge1\) and every finite set \(F\) of primes \(\ell\) with \(\ell^4>N\), $\(\sum_{\ell\in F}\#\bigl(\mathrm{Bad}_\ell\cap[0,N]\bigr)\le20\,N^{3/4}.\)$

The Lean statement takes for \(c_p\) any function with \(p=c_p^2+e^2\) for some \(e\), for the primes in the class; the instance is \(c_p=\varphi_p(1)/2\).

Proof sketch. By the description, \(p=c_p^2+e_p^2\), so \(p\mapsto(c_p,e_p)\) embeds \(\mathrm{Bad}_\ell\cap[0,N]\) into the lattice points \((c,e)\in[-\sqrt N,\sqrt N]^2\) with \(c\ne0\), \(\ell\mid c\) and \(\ell\mid e^2+1\) (from \(\ell\mid p+1=c^2+e^2+1\)). There are at most \(2\sqrt N/\ell\) nonzero multiples of \(\ell\) in the interval (none if \(\ell>\sqrt N\)), and \(e\) lies in at most two residue classes modulo \(\ell\), each meeting the interval in at most \(2\sqrt N/\ell+1\) points. Summing \(8N/\ell^2+4\sqrt N/\ell\) over the primes \(\ell\in F\): the second term vanishes for \(\ell>\sqrt N\), and \(\sum_{\ell>N^{1/4}}\ell^{-2}\) and \(\sum_{N^{1/4}<\ell\le\sqrt N}\ell^{-1}\) are of order \(N^{-1/4}\) and \(N^{1/4}\), giving \(20N^{3/4}\).

theorem sum_card_badSet_large_le (c : ℕ → ℤ)
    (hrep : ∀ p : ℕ, p.Prime → InClass p → ∃ e : ℤ, (p : ℤ) = c p ^ 2 + e ^ 2) {N : ℕ}
    (hN : 1 ≤ N) (F : Finset ℕ) (hF : ∀ ℓ ∈ F, ℓ.Prime ∧ N < ℓ ^ 4) :
    ∑ ℓ ∈ F, (((range (N + 1)).filter (· ∈ BadSetOf c ℓ)).card : ℝ) ≤
      20 * (N : ℝ) ^ ((3 : ℝ) / 4)
def BadSetOf (c : ℕ → ℤ) (ℓ : ℕ) : Set ℕ :=
  {p | p.Prime ∧ InClass p ∧ (ℓ : ℤ) ∣ c p ∧ ℓ ∣ p + 1}
def latticePts (ℓ N : ℕ) : Finset (ℤ × ℤ) :=
  ((Icc (-(Nat.sqrt N : ℤ)) (Nat.sqrt N)) ×ˢ (Icc (-(Nat.sqrt N : ℤ)) (Nat.sqrt N))).filter
    (fun ce => ce.1 ≠ 0 ∧ (ℓ : ℤ) ∣ ce.1 ∧ (ℓ : ℤ) ∣ ce.2 ^ 2 + 1)
Sources
Uses 2 · Used by 1

The sieve bound for a medium \(\ell\)

A prime bad at \(\ell\) is a value of \((\ell U)^2+(b+\ell V)^2\) on a box, coprime to the small primes \(q\equiv1\pmod4\). The Selberg sieve, vendored from the PrimeNumberTheoremAnd project, bounds these values; the local densities, the box count and a lower bound for the Selberg sum by elementary divisor sums supply its inputs.

TheoremThe Selberg sieve bound#✓

Let \(\mathcal A\) be a finite set of natural numbers with nonnegative weights \(a_n\) and total mass \(X\), let \(P\) be a squarefree product of primes, let \(\nu\) be a multiplicative function with \(0<\nu(q)<1\) for the primes \(q\mid P\), and let \(y\ge1\) be the level. Put \(R_d=\sum_{n\in\mathcal A,\,d\mid n}a_n-\nu(d)X\), \(g(l)=\nu(l)\prod_{q\mid l}(1-\nu(q))^{-1}\) and \(S=\sum_{l\mid P,\ l^2\le y}g(l)\). Then \(S>0\) and $\(\sum_{\substack{n\in\mathcal A\ \gcd(n,P)=1}}a_n\;\le\;\frac XS+\sum_{\substack{d\mid P\ d\le y}}3^{\omega(d)}|R_d| .\)$

This is Selberg's upper bound sieve. The Lean proof is the one of the PrimeNumberTheoremAnd project (https://github.com/AlexKontorovich/PrimeNumberTheoremAnd, by Arend Mellendijk), vendored unchanged except for its import lines under the Apache License 2.0, and built on Mathlib's sieve structures.

Proof sketch. Choose the Selberg weights \(\lambda_d\) (\(d\mid P\), \(d^2\le y\), \(\lambda_1=1\)) that minimize the quadratic form of the main term; then \(\mu^+(d)=\sum_{[d_1,d_2]=d}\lambda_{d_1}\lambda_{d_2}\) is an upper bound sieve, the main term equals \(X/S\) after diagonalization, \(|\lambda_d|\le1\), and \(|\mu^+(d)|\le3^{\omega(d)}\), which bounds the error term.

theorem selberg_bound_simple :
    siftedSum (s := s.toBoundingSieve) ≤
      X / S +
        ∑ d ∈ divisors P, if (d : ℝ) ≤ y then (3:ℝ) ^ ω d * |R d| else 0
def selbergTerms : ArithmeticFunction ℝ :=
  s.nu.pmul (.prodPrimeFactors fun p =>  1 / (1 - ν p))
@[simp]
def selbergBoundingSum : ℝ :=
  ∑ l ∈ divisors P, if l ^ 2 ≤ y then g l else 0
Used by 2

TheoremLocal densities of \((\ell U)^2+(b+\ell V)^2\)#✓

Let \(\ell,b\) be integers and \(F(U,V)=(\ell U)^2+(b+\ell V)^2\). For a prime \(q\equiv1\pmod4\) with \(q\nmid\ell\), the equation \(F(U,V)=0\) has exactly \(2q-1\) solutions in \(\mathbb F_q^2\). Consequently, for a finite set \(t\) of such primes and \(d=\prod_{q\in t}q\), the congruence \(F(U,V)\equiv0\pmod d\) has exactly \(\prod_{q\in t}(2q-1)\) solutions in \((\mathbb Z/d)^2\).

Proof sketch. \((U,V)\mapsto(\ell U,b+\ell V)\) is a bijection of \(\mathbb F_q^2\) since \(\ell\) is invertible. With \(i^2=-1\) in \(\mathbb F_q\), \(x^2+y^2=(x-iy)(x+iy)\) vanishes exactly on two lines meeting only at \(0\): \(2q-1\) points. The Chinese remainder theorem makes the count multiplicative in \(d\).

theorem card_zset_prod (t : Finset ℕ) (ht : ∀ q ∈ t, q.Prime ∧ q % 4 = 1 ∧ ¬ (q : ℤ) ∣ ℓ)
    (b : ℤ) : Nat.card (ZSet (ZMod (∏ q ∈ t, q)) ℓ b) = ∏ q ∈ t, (2 * q - 1)
def ZSet (R : Type*) [CommRing R] (ℓ b : ℤ) : Set (R × R) :=
  {z | ((ℓ : R) * z.1) ^ 2 + ((b : R) + (ℓ : R) * z.2) ^ 2 = 0}
theorem card_zset_prime {q : ℕ} [hq : Fact q.Prime] (h4 : q % 4 = 1) {ℓ : ℤ}
    (hℓ : (ℓ : ZMod q) ≠ 0) (b : ℤ) :
    Nat.card (ZSet (ZMod q) ℓ b) = 2 * q - 1
Sources
Used by 1

TheoremCounting a box with a divisibility condition#✓

Let \(\ell,b\) be integers, \(F(U,V)=(\ell U)^2+(b+\ell V)^2\), \(d\ge1\), and let \(\rho(d)\) be the number of solutions of \(F\equiv0\pmod d\) in \((\mathbb Z/d)^2\). For a box \(\mathcal B=[a_1,a_1+M_1)\times[a_2,a_2+M_2)\) of integer points, $\(\Bigl|\#\{(U,V)\in\mathcal B: d\mid F(U,V)\}-\rho(d)\frac{M_1M_2}{d^2}\Bigr|\le\rho(d)\,(M_1+M_2+1).\)$

Proof sketch. An interval of \(M\) consecutive integers has \(M/d+\theta\) elements in each residue class modulo \(d\), with \(|\theta|\le1\). For each of the \(\rho(d)\) residue pairs the box contains \((M_1/d+\theta_1)(M_2/d+\theta_2)\) points of the pair, which differs from \(M_1M_2/d^2\) by at most \(M_1+M_2+1\) (as \(d\ge1\)); sum over the pairs.

theorem abs_card_box_dvd_sub_le (ℓ b a₁ a₂ : ℤ) (M₁ M₂ d : ℕ) (hd : 0 < d) :
    |((#{x ∈ box a₁ a₂ M₁ M₂ | (d : ℤ) ∣ gaussFZ ℓ b x} : ℕ) : ℝ) -
        (Nat.card (ZSet (ZMod d) ℓ b) : ℝ) * (M₁ * M₂ / (d : ℝ) ^ 2)| ≤
      (Nat.card (ZSet (ZMod d) ℓ b) : ℝ) * (M₁ + M₂ + 1)
def box (a₁ a₂ : ℤ) (M₁ M₂ : ℕ) : Finset (ℤ × ℤ) := Ico a₁ (a₁ + (M₁ : ℤ)) ×ˢ Ico a₂ (a₂ + (M₂ : ℤ))
def gaussFZ (ℓ b : ℤ) (x : ℤ × ℤ) : ℤ := (ℓ * x.1) ^ 2 + (b + ℓ * x.2) ^ 2
Sources
Used by 1

TheoremA lower bound for the Selberg sum#✓

Let a Selberg sieve have level \(w^2\) (\(w\ge1\)) and satisfy \(g(q)\ge(1-1/q)^{-2}-1\) at the primes \(q\mid P\). Then its Selberg sum satisfies $\(S\ge\sum_{\substack{m\le w\ \mathrm{rad}(m)\mid P}}\frac{\tau(m)}m,\)$ where \(\tau\) is the number of divisors. Moreover, with \(r(n)=\sum_{d\mid n}\chi_4(d)\) and \(h(n)=\tau(n)/n\) if every prime factor of \(n\) is \(\equiv1\pmod4\), \(h(n)=0\) otherwise:

  1. \(\sum_{n\le w}r(n)/n\ge\frac23\log w\);
  2. \(\log w\le6\sum_{n\le w}h(n)\);
  3. for a prime \(\ell\), removing the multiples of \(\ell\) keeps at least the fraction \(1-2/\ell\): \(\sum_{n\le w,\ \ell\nmid n}h(n)\ge(1-2/\ell)\sum_{n\le w}h(n)\).

Proof sketch. Expand \(g(q)\ge\sum_{k\ge1}(k+1)q^{-k}\) multiplicatively: for \(l\mid P\) with \(l\le w\), \(g(l)\) dominates the sum of \(\tau(m)/m\) over the \(m\le w\) with radical \(l\). (1) Write \(\sum_{n\le w}r(n)/n=\sum_d(\chi_4(d)/d)H(\lfloor w/d\rfloor)\) and pair the terms \(d\equiv1,3\pmod4\) in blocks; no Euler constant is needed. (2) \(r(n)/n\) is the Dirichlet convolution of \(h\) with a nonnegative function \(v\) supported on numbers without prime factors \(\equiv1\pmod4\), whose partial sums are at most \(4\); so \(\sum r(n)/n\le4\sum h(n)\). (3) \(h(\ell m)\le2h(m)/\ell\).

theorem selbergBoundingSum_ge_tau (s : SelbergSieve) (w : ℕ) (hw : 1 ≤ w)
    (hlevel : s.level = (w : ℝ) ^ 2)
    (hg : ∀ q, q.Prime → q ∣ s.prodPrimes →
      1 / (1 - 1 / (q : ℝ)) ^ 2 - 1 ≤ SelbergSieve.selbergTerms s.toBoundingSieve q) :
    ∑ m ∈ (Icc 1 w).filter (fun m => (∏ p ∈ m.primeFactors, p) ∣ s.prodPrimes), tauDiv m
      ≤ s.selbergBoundingSum
theorem prod_factors_sum_pow_mult (M : ℕ) (hM : M ≠ 0) (f : ArithmeticFunction ℝ)
    (hf : IsMultiplicative f) (d : ℕ) (hd : Squarefree d) :
    ∏ p ∈ d.primeFactors, ∑ n ∈ Finset.Icc 1 M, f (p^n)
    = ∑ m ∈ (d^M).divisors.filter (d ∣ ·), f m
def tauDiv : ArithmeticFunction ℝ := ⟨fun n => (n.divisors.card : ℝ) / n, by simp⟩
Sources
Uses 1 · Used by 1

TheoremThe sieve for the primes bad at \(\ell\)#✓

Let \(\ell\) be a prime, \(b\) an integer, \(K\ge0\) and \(w\ge1\). Sift the values of \(F(U,V)=(\ell U)^2+(b+\ell V)^2\) on the box \(\mathcal B=[-K,K]\times[-K-1,K]\), each counted with its multiplicity, by the primes \(q\le w\) with \(q\equiv1\pmod4\) and \(q\ne\ell\), with density \(\nu(q)=(2q-1)/q^2\) and level \(w^2\); the total mass is \(X=(2K+1)(2K+2)\). Then the number of points of \(\mathcal B\) whose value is coprime to all these primes is at most $\(\frac XS+w^8(4K+4),\)$ where \(S\) is the Selberg sum of the sieve, and \(S\ge(\log w)/10\) if \(\ell\ge5\).

Proof sketch. The Selberg sieve bound. By the local densities, \(\rho(d)=\nu(d)d^2\) for \(d\mid P\), so the box count bounds each remainder by \(|R_d|\le d^2(4K+4)\) for \(d\mid P\); with \(3^{\omega(d)}\le d\) (the prime factors of \(d\) are at least \(5\)) the error sum is at most \(\sum_{d\le w^2}d^3(4K+4)\le w^8(4K+4)\). At a sifting prime \(g(q)=(2q-1)/(q-1)^2=(1-1/q)^{-2}-1\), so the lower bound for the Selberg sum applies: \(S\ge\sum_{m\le w,\ \mathrm{rad}(m)\mid P}\tau(m)/m\), which is the sum of \(h\) over \(m\le w\) prime to \(\ell\), at least \((1-2/\ell)(\log w)/6\ge(\log w)/10\) for \(\ell\ge5\).

theorem siftedSum_le (hℓ : ℓ.Prime) :
    (gaussSieve ℓ b K w hw).siftedSum ≤
      ((2 * K + 1) * (2 * K + 2) : ℝ) / (gaussSieve ℓ b K w hw).selbergBoundingSum +
        (w : ℝ) ^ 8 * (4 * K + 4)
def gaussSieve (ℓ : ℕ) (b : ℤ) (K w : ℕ) (hw : 1 ≤ w) : SelbergSieve where
  support := (gsBox K).image (gsF ℓ b)
  prodPrimes := gsProd ℓ w
  prodPrimes_squarefree := gsProd_squarefree ℓ w
  weights n := (#((gsBox K).filter (fun x => gsF ℓ b x = n)) : ℝ)
  weights_nonneg _ := Nat.cast_nonneg _
  totalMass := (2 * K + 1) * (2 * K + 2)
  nu := gsNu
  nu_mult := IsMultiplicative.prodPrimeFactors _
  nu_pos_of_prime _ hp _ := gsNu_prime_pos hp
  nu_lt_one_of_prime _ hp _ := gsNu_prime_lt_one hp
  level := (w : ℝ) ^ 2
  one_le_level := one_le_pow₀ (by exact_mod_cast hw)
def gsPrimes (ℓ w : ℕ) : Finset ℕ := (range (w + 1)).filter (fun q => q.Prime ∧ q % 4 = 1 ∧ q ≠ ℓ)
Sources
Uses 4 · Used by 1

TheoremThe count of primes \(c^2+e^2\) with \(\ell\mid c\) and \(\ell\mid p+1\)#✓

For a prime \(\ell\) let \(\mathrm{GB}_\ell\) be the set of primes \(p=c^2+e^2\) (\(c,e\in\mathbb Z\)) with \(\ell\mid c\) and \(\ell\mid p+1\); by the description it contains \(\mathrm{Bad}_\ell\). Let \(\ell\ge5\), \(N\ge0\), \(w\ge2\) and \(K=\lfloor\lfloor\sqrt N\rfloor/\ell\rfloor\). Then $\(\#\bigl(\mathrm{GB}_\ell\cap[0,N]\bigr)\le(w+1)+2\Bigl(\frac{10(2K+1)(2K+2)}{\log w}+w^8(4K+4)\Bigr).\)$

Proof sketch. For \(p\in\mathrm{GB}_\ell\cap[0,N]\), \(c=\ell U\) and \(e^2\equiv-1\pmod\ell\), so \(e\equiv b\pmod\ell\) for one of the at most two roots \(b\) of \(b^2\equiv-1\), and \(e=b+\ell V\) (after choosing the sign of \(e\) and \(b\in[0,\ell)\)) with \((U,V)\) in the box \([-K,K]\times[-K-1,K]\); distinct primes give distinct points. A prime \(p>w\) is coprime to every sifting prime, so all but at most \(w+1\) of these primes are counted by the sifted sum of the sieve for the primes bad at \(\ell\); apply its bound, with \(S\ge(\log w)/10\), for each root \(b\).

theorem card_gaussBad_le {ℓ : ℕ} (hℓ : ℓ.Prime) (hℓ5 : 5 ≤ ℓ) (N w : ℕ) (hw : 2 ≤ w) :
    (#((range (N + 1)).filter (· ∈ GaussBad ℓ)) : ℝ) ≤
      (w + 1) + 2 * (10 * ((2 * (Nat.sqrt N / ℓ : ℕ) + 1) * (2 * (Nat.sqrt N / ℓ : ℕ) + 2) : ℝ) /
        Real.log w + (w : ℝ) ^ 8 * (4 * (Nat.sqrt N / ℓ : ℕ) + 4))
def GaussBad (ℓ : ℕ) : Set ℕ :=
  {p | p.Prime ∧ ∃ c e : ℤ, (p : ℤ) = c ^ 2 + e ^ 2 ∧ (ℓ : ℤ) ∣ c ∧ ℓ ∣ p + 1}
theorem mem_gaussBad_of_bad {ℓ p : ℕ} (hp : p.Prime) (hC : InClass p) (h1 : (ℓ : ℤ) ∣ cp p)
    (h2 : ℓ ∣ p + 1) : p ∈ GaussBad ℓ
Sources
Uses 3 · Used by 1

DefinitionThe uniform bound for the primes bad at a medium \(\ell\)#✓

The uniform bad-prime bound is the assertion that there are constants \(A>0\) and \(N_1\) such that for every \(N\ge N_1\) and every prime \(\ell\equiv1\pmod4\) with \(5\le\ell\) and \(\ell^4\le N\), $\(\#\bigl(\mathrm{Bad}_\ell\cap[0,N]\bigr)\le\frac{A\,N}{\ell^2\log N}.\)$

It is Proposition 4.2 of the research note, isolated as a statement so that Theorem D can be proved from it before the sieve; it is proved in the uniform bound holds.

def UniformBadBound : Prop :=
  ∃ A N₁ : ℝ, 0 < A ∧ ∀ N : ℕ, N₁ ≤ N → ∀ ℓ : ℕ, ℓ.Prime → ℓ % 4 = 1 → 5 ≤ ℓ →
    ((ℓ : ℝ) ^ 4 ≤ N) →
    (((Finset.range (N + 1)).filter (· ∈ BadSet ℓ)).card : ℝ) ≤ A * N / (ℓ ^ 2 * Real.log N)
Sources
Uses 1 · Used by 2

TheoremThe uniform bound holds#✓

The uniform bad-prime bound holds. More precisely, there is \(N_1\) such that for every \(N\ge N_1\) and every prime \(\ell\equiv1\pmod4\) with \(5\le\ell\) and \(\ell^4\le N\), $\(\#\bigl(\mathrm{GB}_\ell\cap[0,N]\bigr)\le\frac{14402\,N}{\ell^2\log N},\)$ and \(\mathrm{Bad}_\ell\subseteq\mathrm{GB}_\ell\).

The research note proves the bound with \(A_1=16003\) and \(N_1=e^{1920}\); the Lean proof has \(A=14402\) and a threshold \(N_1\) that is not explicit.

Proof sketch. Put \(u=N^{1/40}\) and \(w=\lfloor u\rfloor\), and apply the count of \(\mathrm{GB}_\ell\). Since \(\sqrt N=u^{20}\), \(K\le u^{20}/\ell\), and \(\ell^4\le N\) gives \(\ell\le u^{10}\). The main term \(20(2K+1)(2K+2)/\log w\) is then at most a constant times \(N/(\ell^2\log N)\) (as \(\log N=40\log u\) and \(\log w\ge\log(u-1)\)), while the error terms \(w+1\) and \(2w^8(4K+4)\) are of order \(u^{28}\), which is at most \(N/(\ell^2\log N)\) once \(400\log u\le u^2\) and \(u\ge4\). An elementary real inequality collects the constants into \(14402\).

theorem uniformBadBound_holds : UniformBadBound
theorem uniformBadBound :
    ∃ A N₁ : ℝ, 0 < A ∧ ∀ N : ℕ, N₁ ≤ N → ∀ ℓ : ℕ, ℓ.Prime → ℓ % 4 = 1 → 5 ≤ ℓ →
      ((ℓ : ℝ) ^ 4 ≤ N) →
      (((Finset.range (N + 1)).filter
          (· ∈ {p : ℕ | p.Prime ∧ InClass p ∧ (ℓ : ℤ) ∣ cp p ∧ ℓ ∣ p + 1})).card : ℝ) ≤
        A * N / (ℓ ^ 2 * Real.log N)
theorem uniformGaussBadBound :
    ∃ A N₁ : ℝ, 0 < A ∧ ∀ N : ℕ, N₁ ≤ N → ∀ ℓ : ℕ, ℓ.Prime → ℓ % 4 = 1 → 5 ≤ ℓ →
      ((ℓ : ℝ) ^ 4 ≤ N) →
      (((range (N + 1)).filter (· ∈ GaussBad ℓ)).card : ℝ) ≤ A * N / (ℓ ^ 2 * Real.log N)
Sources
Uses 2 · Used by 1

Assembly

The prime tail and Abel summation bound the Dirichlet series of \(T_L\), the main term bounds that of \(C_L\) from below, and a positive lower Dirichlet density gives a positive relative upper density.

TheoremThe prime tail \(\sum_{\ell>L}\ell^{-2}\)#✓

For \(L\ge2\) and every finite set \(F\) of primes greater than \(L\), $\(\sum_{\ell\in F}\frac1{\ell^2}\le\frac{3\log4}{L\log L};\)$ in particular \(\sum_{L<\ell\le M}\ell^{-2}\le4\log4/(L\log L)\) for every \(M\), the form of the research note.

Proof sketch. \(\ell^{-2}\le(\log\ell/\log L)\,\ell^{-2}\) for \(\ell>L\); Abel summation of \(\sum(\log\ell)\ell^{-2}\) against Chebyshev's bound \(\theta(m)\le m\log4\) gives the bound (the note uses a dyadic decomposition instead and gets the constant \(4\log 4\)).

theorem sum_inv_sq_le_of_primes_gt {L : ℕ} (hL : 2 ≤ L) (F : Finset ℕ)
    (hF : ∀ ℓ ∈ F, ℓ.Prime ∧ L < ℓ) :
    ∑ ℓ ∈ F, (1 : ℝ) / (ℓ : ℝ) ^ 2 ≤ 3 * Real.log 4 / (L * Real.log L)
theorem prime_tail {L : ℕ} (hL : 2 ≤ L) (M : ℕ) :
    ∑ ℓ ∈ (Ioc L M).filter Nat.Prime, (1 : ℝ) / (ℓ : ℝ) ^ 2 ≤
      4 * Real.log 4 / (L * Real.log L)
theorem sum_log_div_sq_le {L : ℕ} (hL : 1 ≤ L) (M : ℕ) :
    ∑ n ∈ range (M + 1), {n : ℕ | n.Prime ∧ L < n}.indicator (fun n : ℕ => Real.log n) n *
      (1 / (n : ℝ) ^ 2) ≤ 3 * Real.log 4 / L
Sources
Used by 1

TheoremAbel summation for \(\Phi_S\)#✓

For a set \(S\) of natural numbers put \(\theta_S(N)=\sum_{n\le N,\ n\in S}\log n\) and, for \(x>1\), \(\Phi_S(x)=\sum_{n\in S}(\log n)/n^x\). Let \(\kappa\ge0\) and \(B\) be reals with \(\theta_S(N)\le\kappa N+B\) for every \(N\). Then for every \(x\in(1,2]\) the series \(\Phi_S(x)\) converges and $\(\Phi_S(x)\le\kappa\,\frac x{x-1}+B .\)$

Proof sketch. Discrete partial summation writes \(\sum_{n\le M}\mathbf 1_S(n)\log n\cdot n^{-x}\) as \(\theta_S(M)M^{-x}+\sum_{n<M}\theta_S(n)\bigl(n^{-x}-(n+1)^{-x}\bigr)\). Insert the bound on \(\theta_S\); the constant \(B\) telescopes to at most \(B\), and \(\sum_n n\bigl(n^{-x}-(n+1)^{-x}\bigr)\) is at most \(\sum_{n\le M}n^{-x}\le x/(x-1)\), by Bernoulli's inequality. The partial sums are bounded and the terms nonnegative.

theorem abel_bound {S : Set ℕ} {κ B : ℝ} (hκ : 0 ≤ κ) (hθ : ∀ N : ℕ, thetaS S N ≤ κ * N + B)
    {x : ℝ} (hx1 : 1 < x) (hx2 : x ≤ 2) :
    Summable (phiTerm S x) ∧ PhiS S x ≤ κ * (x / (x - 1)) + B
noncomputable def thetaS (S : Set ℕ) (N : ℕ) : ℝ :=
  ∑ n ∈ range (N + 1), S.indicator (fun n : ℕ => Real.log n) n
noncomputable def phiTerm (S : Set ℕ) (x : ℝ) (n : ℕ) : ℝ :=
  S.indicator (fun n : ℕ => Real.log n) n / (n : ℝ) ^ x
Sources
Used by 2

TheoremDirichlet density gives relative upper density#✓

Let \(S\) be a set of natural numbers, and let \(\eta>0\) and \(K\) be reals with $\(\Phi_S(x)\ge\frac\eta{x-1}-K\qquad\text{for all }x\in(1,2].\)$ Then \(S\) has positive relative upper density in the primes: there is \(c>0\) with \(\#(S\cap[0,N])\ge c\,\pi(N)\) for infinitely many \(N\).

This is Proposition 5.3 of the research note (a positive lower Dirichlet density in the von Mangoldt normalisation gives a positive upper relative density).

Proof sketch. Suppose not. Then for every \(c>0\) eventually \(\#(S\cap[0,N])<c\,\pi(N)\), and with Chebyshev's bound \(\pi(N)\le(\log4+\varepsilon)N/\log N\) this gives \(\theta_S(N)\le\#(S\cap[0,N])\log N\le\kappa N\) for large \(N\) with \(\kappa\) as small as we like, hence \(\theta_S(N)\le\kappa N+B\) for all \(N\). Abel summation gives \(\Phi_S(x)\le\kappa x/(x-1)+B\), which contradicts the lower bound as \(x\to1^+\) once \(2\kappa<\eta\).

theorem primesRelUpperDensityPos_of_dirichlet {S : Set ℕ} {η K : ℝ}
    (hη : 0 < η) (h : ∀ x ∈ Set.Ioc (1 : ℝ) 2, η / (x - 1) - K ≤ PhiS S x) :
    PrimesRelUpperDensityPos S
Sources
Uses 2 · Used by 1

TheoremTheorem D: the density statement from the uniform bound#✓

Assume the uniform bad-prime bound. Then the good slope primes have positive relative upper density in the primes.

The proof goes through Theorem D of the research note: for a suitable \(L\), the set \(G^*_L=C_L\setminus T_L\) of good slope primes satisfies \(\Phi_{G^*_L}(x)\ge\eta_L/(x-1)-K\) on \((1,2]\) with \(\eta_L>0\), a positive lower Dirichlet density. The Lean proof applies this to the larger set of all good slope primes directly.

Proof sketch. Let \(A,N_1\) be the constants of the uniform bound and choose \(L\ge5\) with \(\log L\ge16A\log4\). For \(N\ge\max(N_1,2)\), the uniform bound for the primes \(L<\ell\le N^{1/4}\), summed with the prime tail, and the lattice count for the primes \(\ell>N^{1/4}\) give \(\#(T_L\cap[0,N])\le\alpha_LN/\log N+20N^{3/4}\) with \(\alpha_L=3A\log4/(L\log L)\le\delta_L/2\). With \(\varepsilon=\delta_L/4\), eventually \(\theta_{T_L}(N)\le(\alpha_L+\varepsilon)N\), so Abel summation gives \(\Phi_{T_L}(x)\le(\alpha_L+\varepsilon)x/(x-1)+B\). Since \(C_L\setminus T_L\) consists of good slope primes, \(\Phi_G\ge\Phi_{C_L}-\Phi_{T_L}\), and the main term gives \(\Phi_G(x)\ge(\delta_L-\alpha_L-\varepsilon)/(x-1)-K'\) with \(\delta_L-\alpha_L-\varepsilon\ge\delta_L/4>0\). Dirichlet density gives relative upper density.

theorem goodPrimeDensity_of_uniformBadBound (h : UniformBadBound) : GoodPrimeDensity
theorem card_TL_le {A N₁ : ℝ} (hA : 0 < A)
    (hU : ∀ N : ℕ, N₁ ≤ N → ∀ ℓ : ℕ, ℓ.Prime → ℓ % 4 = 1 → 5 ≤ ℓ → ((ℓ : ℝ) ^ 4 ≤ N) →
      (((Finset.range (N + 1)).filter (· ∈ BadSet ℓ)).card : ℝ) ≤ A * N / (ℓ ^ 2 * Real.log N))
    {L : ℕ} (hL : 5 ≤ L) {N : ℕ} (hN : N₁ ≤ N) (hN2 : 2 ≤ N) :
    (((range (N + 1)).filter (· ∈ TL L)).card : ℝ) ≤
      A * (3 * Real.log 4 / (L * Real.log L)) * N / Real.log N + 20 * (N : ℝ) ^ ((3 : ℝ) / 4)
theorem exists_L (A : ℝ) : ∃ L : ℕ, 5 ≤ L ∧ 16 * A * Real.log 4 ≤ Real.log L
Sources
Uses 9 · Used by 1

TheoremProposition D: the good slope primes have positive relative density#✓

The good slope primes have positive relative upper density in the primes: there is \(c>0\) such that \(\#(G\cap[0,N])\ge c\,\pi(N)\) for infinitely many \(N\), where \(G\) is the set of good slope primes.

This is the weak form of Proposition D, which the research note deduces from Theorem D through its Proposition 5.3 (Dirichlet density gives relative upper density). It discharges the density statement, the second input of the progressions of good slope primes.

Proof sketch. The uniform bad-prime bound holds, and Theorem D derives the density statement from it.

theorem goodPrimeDensity : GoodPrimeDensity
Sources
Uses 3 · Used by 4

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.