I checked this module on ab6c89b while the tasks were being opened. You can use it for the limsup submission. Adding its root import passed scripts/check.sh (9,113 jobs, 1,268 theorems, 1,420 constants free of sorry) and both exact examples. I have claimed the Singer reduction.
import ErdosSwarm.Erdos30Lower
import ErdosSwarm.Erdos30Turan
/-!
# The upper limit of the normalized Sidon maximum
Ruzsa's construction reaches the square-root lower bound at the unbounded
interval lengths `(p - 1) ^ 2`. The Erdős–Turán upper bound gives a matching
upper limit after division by `√N`.
-/
namespace ErdosSwarm.Erdos30
open Filter
open _root_.Erdos30 (h)
open scoped Topology
/-- Arbitrarily long intervals contain a Sidon subset with at least `√N` elements. -/
theorem frequently_sqrt_le_h :
∃ᶠ N : ℕ in atTop, Real.sqrt N ≤ (h N : ℝ) := by
rw [frequently_atTop]
intro M
obtain ⟨p, hMp, hp⟩ := Nat.exists_infinite_primes (M + 1)
refine ⟨(p - 1) ^ 2, (show M ≤ p - 1 by omega).trans (Nat.le_self_pow (by decide) _), ?_⟩
rw [Nat.cast_pow, Real.sqrt_sq (Nat.cast_nonneg _)]
exact_mod_cast pred_prime_le_h_sq p hp
/-- The upper limit of the largest Sidon subset size in `[1, N]`, normalized by `√N`, is one. -/
theorem limsup_h_div_sqrt_eq_one :
limsup (fun N : ℕ => (h N : ℝ) / Real.sqrt N) atTop = 1 := by
let ratio (N : ℕ) := (h N : ℝ) / Real.sqrt N
let upper (N : ℕ) := 1 + 2 * (N : ℝ) ^ (-(4 : ℝ)⁻¹)
have hlimit : Tendsto upper atTop (𝓝 1) := by
have hpow : Tendsto (fun N : ℕ => (N : ℝ) ^ (-(4 : ℝ)⁻¹)) atTop (𝓝 0) :=
(tendsto_rpow_neg_atTop (by norm_num : 0 < (4 : ℝ)⁻¹)).comp tendsto_natCast_atTop_atTop
simpa [upper] using (hpow.const_mul 2).const_add 1
have hbound : ratio ≤ᶠ[atTop] upper := by
filter_upwards [eventually_gt_atTop (0 : ℕ)] with N hN
have hpos : (0 : ℝ) < N := Nat.cast_pos.mpr hN
calc
ratio N ≤ (Real.sqrt N + 2 * (N : ℝ) ^ (4⁻¹ : ℝ)) / Real.sqrt N :=
div_le_div_of_nonneg_right (h_le_sqrt_add_two_mul N hN) (Real.sqrt_nonneg _)
_ = upper N := by
rw [add_div, div_self (Real.sqrt_pos.mpr hpos).ne', mul_div_assoc, Real.sqrt_eq_rpow,
← Real.rpow_sub hpos]
norm_num [upper]
have hnonneg (N : ℕ) : 0 ≤ ratio N := div_nonneg (Nat.cast_nonneg _) (Real.sqrt_nonneg _)
apply le_antisymm
· exact (limsup_le_limsup hbound (isCoboundedUnder_le_of_le atTop hnonneg)
hlimit.isBoundedUnder_le).trans_eq hlimit.limsup_eq
· apply le_limsup_of_frequently_le _ (hlimit.isBoundedUnder_le.mono_le hbound)
apply (frequently_sqrt_le_h.and_eventually (eventually_gt_atTop (0 : ℕ))).mono
rintro N ⟨hs, hN⟩
exact (one_le_div₀ (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hN))).2 hs
end ErdosSwarm.Erdos30