| | @@ -0,0 +1,103 @@ |
| 1 | +import ErdosSwarm.Erdos30CyclicGap |
| 2 | +import ErdosSwarm.Erdos30Lower |
| 3 | + |
| 4 | +/-! |
| 5 | +# A strict subsequence lower bound for the Sidon extremal function |
| 6 | + |
| 7 | +Cutting Ruzsa's cyclic Sidon set at its largest gap gives a Sidon subset of |
| 8 | +`[1, k² - k/2]` of size `k = p - 1` for every prime `p`. Along the odd primes, |
| 9 | +these lengths witness `h N > √N + 1/4`. |
| 10 | +The construction is Ruzsa's Theorem 4.4 in *Solving a linear equation in a set of |
| 11 | +integers I*, formalized in `ErdosSwarm.Erdos530.exists_ruzsa_sidon`. |
| 12 | +-/ |
| 13 | + |
| 14 | +namespace ErdosSwarm.Erdos30 |
| 15 | + |
| 16 | +open Finset Filter ErdosSwarm.Erdos530 |
| 17 | + |
| 18 | +local notation "h" => _root_.Erdos30.h |
| 19 | + |
| 20 | +/-- Lift a translated cyclic Sidon set with representatives below `L` into `[1, L]`. -/ |
| 21 | +private theorem card_le_h_of_translate_val_lt {m L : ℕ} [NeZero m] (S : Finset (ZMod m)) |
| 22 | + (hS : IsSidon (S : Set (ZMod m))) (t : ZMod m) (hval : ∀ x ∈ S, (x + t).val < L) : |
| 23 | + S.card ≤ h L := by |
| 24 | + classical |
| 25 | + let U := S.image (fun x => t + 1 + x) |
| 26 | + let repr (x : ZMod m) : ℕ := (x - 1).val + 1 |
| 27 | + have hsection (x : ZMod m) : (repr x : ZMod m) = x := by simp [repr] |
| 28 | + have hU : IsSidon (U : Set (ZMod m)) := by |
| 29 | + simp only [U, coe_image] |
| 30 | + exact isSidon_image_add_left (t + 1) hS |
| 31 | + have hsidon : IsSidon (U.image repr : Set ℕ) := by |
| 32 | + rw [coe_image] |
| 33 | + exact isSidon_image_of_section (Nat.castAddMonoidHom (ZMod m)) repr |
| 34 | + (fun x _ => hsection x) hU |
| 35 | + have hinterval : U.image repr ⊆ Icc 1 L := by |
| 36 | + intro y hy |
| 37 | + obtain ⟨u, hu, rfl⟩ := mem_image.mp hy |
| 38 | + obtain ⟨x, hx, rfl⟩ := mem_image.mp hu |
| 39 | + have heq : t + 1 + x - 1 = x + t := by abel |
| 40 | + simpa only [mem_Icc, repr, heq] using |
| 41 | + And.intro (Nat.le_add_left 1 (x + t).val) (Nat.succ_le_of_lt (hval x hx)) |
| 42 | + simpa only [U, card_image_of_injective _ (Function.LeftInverse.injective hsection), |
| 43 | + card_image_of_injective _ (add_right_injective (t + 1))] using card_le_h hsidon hinterval |
| 44 | + |
| 45 | +/-- A prime `p` gives `p - 1` Sidon points in an interval of length |
| 46 | +`(p - 1)² - (p - 1)/2` by cutting Ruzsa's set at its largest cyclic gap. -/ |
| 47 | +theorem pred_prime_le_h_sq_sub_half (p : ℕ) (hp : p.Prime) : |
| 48 | + p - 1 ≤ h ((p - 1) ^ 2 - (p - 1) / 2) := by |
| 49 | + by_cases hp2 : p = 2 |
| 50 | + · subst p |
| 51 | + change 1 ≤ h 1 |
| 52 | + rw [h_one] |
| 53 | + set k := p - 1 with hk |
| 54 | + have hk2 : 2 ≤ k := by |
| 55 | + have := hp.two_le |
| 56 | + omega |
| 57 | + have hkpos : 0 < k := by omega |
| 58 | + have hpk : p = k + 1 := by omega |
| 59 | + have : Fact p.Prime := ⟨hp⟩ |
| 60 | + have : NeZero (p * k) := ⟨(Nat.mul_pos hp.pos hkpos).ne'⟩ |
| 61 | + obtain ⟨S, hcard, hS⟩ := exists_ruzsa_sidon (p := p) |
| 62 | + change S.card = k at hcard |
| 63 | + obtain ⟨t, L, hLm, hval, hgap⟩ := |
| 64 | + exists_translate_val_lt_of_isSidon (m := p * k) S hS (by rwa [hcard]) |
| 65 | + rw [hcard] at hgap |
| 66 | + -- Cancel the set size from the gap estimate, then round up to an integer gap. |
| 67 | + have htwice : 2 * p + (k - 1) ≤ 2 * (p * k + 1 - L) := by |
| 68 | + apply Nat.le_of_mul_le_mul_right _ hkpos |
| 69 | + simpa only [add_mul, mul_add, mul_comm, mul_left_comm, mul_assoc] using hgap |
| 70 | + have hround : p + k / 2 ≤ p * k + 1 - L := by omega |
| 71 | + have hm : p * k = k ^ 2 + k := by |
| 72 | + rw [hpk] |
| 73 | + ring |
| 74 | + have hL : L ≤ k ^ 2 - k / 2 := by omega |
| 75 | + calc |
| 76 | + k = S.card := hcard.symm |
| 77 | + _ ≤ h L := card_le_h_of_translate_val_lt S hS t hval |
| 78 | + _ ≤ _ := h_mono hL |
| 79 | + |
| 80 | +/-- For infinitely many interval lengths, the largest Sidon subset has size strictly |
| 81 | +greater than `√N + 1/4`. Take `N = k² - k/2` with `k = p - 1` even. -/ |
| 82 | +theorem frequently_sqrt_add_quarter_lt_h : |
| 83 | + ∃ᶠ N : ℕ in atTop, Real.sqrt N + 1 / 4 < (h N : ℝ) := by |
| 84 | + rw [frequently_atTop] |
| 85 | + intro M |
| 86 | + obtain ⟨p, hMp, hp⟩ := Nat.exists_infinite_primes (M + 3) |
| 87 | + set k := p - 1 with hk |
| 88 | + have hk2 : 2 ≤ k := by omega |
| 89 | + have hsq : 2 * k ≤ k ^ 2 := by simpa only [sq] using Nat.mul_le_mul_right k hk2 |
| 90 | + refine ⟨k ^ 2 - k / 2, by omega, ?_⟩ |
| 91 | + have hbound : (k : ℝ) ≤ h (k ^ 2 - k / 2) := by |
| 92 | + exact_mod_cast pred_prime_le_h_sq_sub_half p hp |
| 93 | + apply lt_of_lt_of_le _ hbound |
| 94 | + rw [← lt_sub_iff_add_lt] |
| 95 | + have hkreal : (2 : ℝ) ≤ k := by exact_mod_cast hk2 |
| 96 | + apply (Real.sqrt_lt' (by linarith : 0 < (k : ℝ) - 1 / 4)).2 |
| 97 | + obtain ⟨q, hq⟩ := hp.even_sub_one (by omega) |
| 98 | + have hhalf : (k / 2 : ℕ) * 2 = k := by omega |
| 99 | + have hhalfReal : ((k / 2 : ℕ) : ℝ) * 2 = k := by exact_mod_cast hhalf |
| 100 | + rw [Nat.cast_sub (by omega), Nat.cast_pow] |
| 101 | + nlinarith only [hhalfReal] |
| 102 | + |
| 103 | +end ErdosSwarm.Erdos30 |