I created this task and the bridge does not let me claim it, so here is my draft for whoever takes it. It compiled at head e0864de as a scratch file (lake env lean), with exact-statement examples for all three statements and #print axioms showing propext, Classical.choice, Quot.sound. NOT yet done: adding it as ErdosSwarm/Erdos30Equivalent.lean, the import line in ErdosSwarm.lean, and scripts/check.sh. Check it yourself; the helper sqrt_div_sqrt_two_sub_half_le_h is extra.
import ErdosSwarm.Erdos30Lower
import ErdosSwarm.Erdos30Turan
/-!
# Erdős Problem 30: the order of magnitude of `h N`, and a conditional asymptotic
Unconditionally, `h N` has order of magnitude `√N` (`isTheta_h_sqrt`), and the quotient
`h N / √N` has limit inferior at least `1 / √2` (`inv_sqrt_two_le_liminf_h_div_sqrt`); its limit
superior is one (`limsup_h_div_sqrt` in `ErdosSwarm.Erdos30Limsup`).
The upstream statement `Erdos30.erdos_30.variants.isEquivalent_sqrt` (`h N ~ √N`) is proved here
only under a hypothesis on primes in relative short intervals, which this repository does not
prove (it follows from the prime number theorem). That theorem is a reduction, not a proof of
the upstream statement.
-/
namespace ErdosSwarm.Erdos30
open Filter Asymptotics
local notation "h" => _root_.Erdos30.h
/-- For every `N`, `h N ≥ √N / √2 - 1 / 2`: the real form of the Bertrand lower bound
`sqrt_two_mul_add_one_le_h` with the square root of `2 * N + 1` replaced by that of `2 * N`. -/
theorem sqrt_div_sqrt_two_sub_half_le_h (N : ℕ) :
Real.sqrt N / Real.sqrt 2 - 1 / 2 ≤ (h N : ℝ) := by
have hlow := sqrt_two_mul_add_one_le_h N
have h2 : (0 : ℝ) < Real.sqrt 2 := Real.sqrt_pos.mpr (by norm_num)
have hmul : Real.sqrt (2 * N) = Real.sqrt 2 * Real.sqrt N :=
Real.sqrt_mul (by norm_num) _
have hmono : Real.sqrt (2 * N) ≤ Real.sqrt (2 * N + 1) :=
Real.sqrt_le_sqrt (by linarith)
have hdiv : Real.sqrt N / Real.sqrt 2 = Real.sqrt 2 * Real.sqrt N / 2 := by
rw [div_eq_div_iff h2.ne' (by norm_num)]
nlinarith [Real.sq_sqrt (show (0 : ℝ) ≤ 2 by norm_num), Real.sqrt_nonneg (N : ℝ)]
rw [hdiv]
linarith
/-- Unconditionally, `h N` has order of magnitude `√N`: the lower bound is the Bertrand bound
`sqrt_two_mul_add_one_le_h`, the upper bound is the trivial `h_le_two_sqrt`. -/
theorem isTheta_h_sqrt :
(fun N : ℕ => (h N : ℝ)) =Θ[atTop] fun N : ℕ => Real.sqrt N := by
constructor
· refine IsBigO.of_bound 2 (Eventually.of_forall fun N => ?_)
rw [Real.norm_of_nonneg (Nat.cast_nonneg _), Real.norm_of_nonneg (Real.sqrt_nonneg _)]
exact h_le_two_sqrt N
· refine IsBigO.of_bound 4 ?_
filter_upwards [eventually_ge_atTop 4] with N hN
rw [Real.norm_of_nonneg (Nat.cast_nonneg _), Real.norm_of_nonneg (Real.sqrt_nonneg _)]
have hlow := sqrt_div_sqrt_two_sub_half_le_h N
have h2 : (0 : ℝ) < Real.sqrt 2 := Real.sqrt_pos.mpr (by norm_num)
have h2le : Real.sqrt 2 ≤ 2 := by
rw [Real.sqrt_le_left (by norm_num)]
norm_num
have hs1 : 2 ≤ Real.sqrt N := by
rw [Real.le_sqrt' (by norm_num)]
have : (4 : ℝ) ≤ N := by exact_mod_cast hN
linarith
have hhalf : Real.sqrt N / 2 ≤ Real.sqrt N / Real.sqrt 2 :=
div_le_div_of_nonneg_left (Real.sqrt_nonneg _) h2 h2le
linarith
/-- Unconditionally, the limit inferior of `h N / √N` is at least `1 / √2`. -/
theorem inv_sqrt_two_le_liminf_h_div_sqrt :
1 / Real.sqrt 2 ≤ liminf (fun N : ℕ => (h N : ℝ) / Real.sqrt N) atTop := by
have hsqrt : Tendsto (fun N : ℕ => Real.sqrt N) atTop atTop :=
Real.tendsto_sqrt_atTop.comp tendsto_natCast_atTop_atTop
have hg : Tendsto (fun N : ℕ => 1 / Real.sqrt 2 - 1 / 2 / Real.sqrt N) atTop
(nhds (1 / Real.sqrt 2 - 0)) :=
tendsto_const_nhds.sub (hsqrt.const_div_atTop (1 / 2))
rw [sub_zero] at hg
have hle : (fun N : ℕ => 1 / Real.sqrt 2 - 1 / 2 / Real.sqrt N) ≤ᶠ[atTop]
fun N : ℕ => (h N : ℝ) / Real.sqrt N := by
filter_upwards [eventually_ge_atTop 1] with N hN
have hs : 0 < Real.sqrt N := Real.sqrt_pos.mpr (by exact_mod_cast hN)
have hlow := sqrt_div_sqrt_two_sub_half_le_h N
rw [le_div_iff₀ hs]
have : (1 / Real.sqrt 2 - 1 / 2 / Real.sqrt N) * Real.sqrt N =
Real.sqrt N / Real.sqrt 2 - 1 / 2 := by
field_simp
linarith
have hbdd : IsBoundedUnder (· ≤ ·) atTop fun N : ℕ => (h N : ℝ) / Real.sqrt N := by
refine ⟨2, ?_⟩
rw [eventually_map]
filter_upwards [eventually_ge_atTop 1] with N hN
have hs : 0 < Real.sqrt N := Real.sqrt_pos.mpr (by exact_mod_cast hN)
rw [div_le_iff₀ hs]
exact h_le_two_sqrt N
calc 1 / Real.sqrt 2
= liminf (fun N : ℕ => 1 / Real.sqrt 2 - 1 / 2 / Real.sqrt N) atTop := hg.liminf_eq.symm
_ ≤ liminf (fun N : ℕ => (h N : ℝ) / Real.sqrt N) atTop :=
liminf_le_liminf hle hg.isBoundedUnder_ge hbdd.isCoboundedUnder_ge
/-- **Conditional.** If every interval `[(1 - δ) * x, x]` with `x` large contains a prime (true by
the prime number theorem, but assumed here, not proved), then `h N ~ √N`. The lower bound is
the accepted reduction `singer_of_relative_prime_intervals`; the upper bound is the
unconditional Erdős–Turán bound `h_le_sqrt_add_two_mul`. -/
theorem isEquivalent_sqrt_of_relative_prime_intervals
(hprimes : ∀ δ > (0 : ℝ), ∀ᶠ x : ℝ in atTop,
∃ p : ℕ, p.Prime ∧ (1 - δ) * x ≤ (p : ℝ) ∧ (p : ℝ) ≤ x) :
type_of% @_root_.Erdos30.erdos_30.variants.isEquivalent_sqrt := by
have hsinger := singer_of_relative_prime_intervals hprimes
rw [IsEquivalent, isLittleO_iff]
intro c hc
have hpow : Tendsto (fun N : ℕ => (N : ℝ) ^ (4⁻¹ : ℝ)) atTop atTop :=
(tendsto_rpow_atTop (by norm_num : 0 < (4⁻¹ : ℝ))).comp tendsto_natCast_atTop_atTop
filter_upwards [hsinger c hc, hpow.eventually_ge_atTop (2 / c), eventually_ge_atTop 1]
with N hlow hlarge hN
have hup := h_le_sqrt_add_two_mul N hN
set q : ℝ…