| | @@ -2,7 +2,7 @@ import FormalConjectures.ErdosProblems.«30» |
| 2 | 2 | import ErdosSwarm.Erdos329 |
| 3 | 3 | |
| 4 | 4 | /-! |
| 5 | | −# Erdős Problem 30: basic facts about `h N`, the largest Sidon subset size of `[1, N]` |
| 5 | +# Erdős Problem 30: bounds about `h N`, the largest Sidon subset size of `[1, N]` |
| 6 | 6 | -/ |
| 7 | 7 | |
| 8 | 8 | namespace ErdosSwarm.Erdos30 |
| | @@ -42,3 +42,86 @@ theorem h_le_two_sqrt (N : ℕ) : (h N : ℝ) ≤ 2 * Real.sqrt N := by |
| 42 | 42 | by_contra hlt |
| 43 | 43 | rw [not_le] at hlt |
| 44 | 44 | nlinarith |
| 45 | + |
| 46 | +open ErdosSwarm.Erdos329 in |
| 47 | +/-- The Erdős–Turán set `{2pk + (k² mod p) : k < p}` is Sidon for an odd prime `p`. -/ |
| 48 | +theorem isSidon_erdosTuran (p : ℕ) (hp : p.Prime) (hp2 : p ≠ 2) : |
| 49 | + IsSidon (((Finset.range p).image fun k => 2 * p * k + k ^ 2 % p : Finset ℕ) : Set ℕ) := by |
| 50 | + intro x₁ hx₁ y₁ hy₁ x₂ hx₂ y₂ hy₂ hsum |
| 51 | + simp only [Finset.coe_image, Finset.coe_range, Set.mem_image, Set.mem_Iio] at hx₁ hy₁ hx₂ hy₂ |
| 52 | + obtain ⟨a, ha, rfl⟩ := hx₁ |
| 53 | + obtain ⟨c, hc, rfl⟩ := hy₁ |
| 54 | + obtain ⟨b, hb, rfl⟩ := hx₂ |
| 55 | + obtain ⟨d, hd, rfl⟩ := hy₂ |
| 56 | + rcases et_sidon hp hp2 ha hb hc hd hsum with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ |
| 57 | + · exact .inl ⟨rfl, rfl⟩ |
| 58 | + · exact .inr ⟨rfl, rfl⟩ |
| 59 | + |
| 60 | +open ErdosSwarm.Erdos329 in |
| 61 | +/-- `h (2p²) ≥ p` for an odd prime `p`. -/ |
| 62 | +theorem le_h_two_mul_sq (p : ℕ) (hp : p.Prime) (hp2 : p ≠ 2) : p ≤ h (2 * p ^ 2) := by |
| 63 | + classical |
| 64 | + have hp0 : 0 < p := hp.pos |
| 65 | + set S : Finset ℕ := (Finset.range p).image fun k => 2 * p * k + k ^ 2 % p with hS |
| 66 | + have hinj : Function.Injective (fun k => 2 * p * k + k ^ 2 % p) := (et_strictMono hp0).injective |
| 67 | + have hcard : S.card = p := by |
| 68 | + rw [hS, Finset.card_image_of_injective _ hinj, Finset.card_range] |
| 69 | + set T : Finset ℕ := S.image (· + 1) with hT |
| 70 | + have hTcard : T.card = p := by |
| 71 | + rw [hT, Finset.card_image_of_injective _ (add_left_injective 1), hcard] |
| 72 | + have hTsub : T ⊆ Finset.Icc 1 (2 * p ^ 2) := by |
| 73 | + intro x hx |
| 74 | + simp only [hT, hS, Finset.mem_image, Finset.mem_range] at hx |
| 75 | + obtain ⟨y, ⟨k, hk, rfl⟩, rfl⟩ := hx |
| 76 | + have := et_lt hp0 hk |
| 77 | + unfold et at this |
| 78 | + simp only [Finset.mem_Icc] |
| 79 | + constructor |
| 80 | + · omega |
| 81 | + · have e : 2 * p ^ 2 = 2 * p * p := by ring |
| 82 | + omega |
| 83 | + have hTS : IsSidon (T : Set ℕ) := by |
| 84 | + have hs := isSidon_erdosTuran p hp hp2 |
| 85 | + intro x₁ hx₁ y₁ hy₁ x₂ hx₂ y₂ hy₂ hsum |
| 86 | + simp only [hT, Finset.coe_image, Set.mem_image] at hx₁ hy₁ hx₂ hy₂ |
| 87 | + obtain ⟨a, ha, rfl⟩ := hx₁ |
| 88 | + obtain ⟨c, hc, rfl⟩ := hy₁ |
| 89 | + obtain ⟨b, hb, rfl⟩ := hx₂ |
| 90 | + obtain ⟨d, hd, rfl⟩ := hy₂ |
| 91 | + rcases hs a ha c hc b hb d hd (by omega) with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ |
| 92 | + · exact .inl ⟨rfl, rfl⟩ |
| 93 | + · exact .inr ⟨rfl, rfl⟩ |
| 94 | + calc p = T.card := hTcard.symm |
| 95 | + _ ≤ h (2 * p ^ 2) := card_le_h hTS hTsub |
| 96 | + |
| 97 | +/-- `h N > ⌊√(N/8)⌋` for every `N ≥ 32`. -/ |
| 98 | +theorem sqrt_div_eight_lt_h (N : ℕ) (hN : 32 ≤ N) : Nat.sqrt (N / 8) < h N := by |
| 99 | + set n := Nat.sqrt (N / 8) with hn |
| 100 | + have hn2 : 2 ≤ n := by |
| 101 | + rw [hn, Nat.le_sqrt]; omega |
| 102 | + obtain ⟨p, hp, hnp, hp2n⟩ := Nat.exists_prime_lt_and_le_two_mul n (by omega) |
| 103 | + have hp2 : p ≠ 2 := by omega |
| 104 | + have hsq : n * n ≤ N / 8 := Nat.sqrt_le (N / 8) |
| 105 | + have h8 : 8 * (N / 8) ≤ N := Nat.mul_div_le N 8 |
| 106 | + have hpp : p * p ≤ 4 * (n * n) := by nlinarith |
| 107 | + have hle : 2 * p ^ 2 ≤ N := by rw [sq]; omega |
| 108 | + calc n < p := hnp |
| 109 | + _ ≤ h (2 * p ^ 2) := le_h_two_mul_sq p hp hp2 |
| 110 | + _ ≤ h N := h_mono hle |
| 111 | + |
| 112 | +/-- The largest Sidon subset has size at least a positive constant times `√N` |
| 113 | +for all sufficiently large `N`. -/ |
| 114 | +theorem h_ge_sqrt : ∃ c : ℝ, 0 < c ∧ ∀ᶠ N : ℕ in Filter.atTop, c * Real.sqrt N ≤ h N := by |
| 115 | + refine ⟨1 / 4, by norm_num, ?_⟩ |
| 116 | + filter_upwards [Filter.eventually_ge_atTop (32 : ℕ)] with N hN |
| 117 | + have hfloor := sqrt_div_eight_lt_h N hN |
| 118 | + have hsq : N / 8 < h N ^ 2 := |
| 119 | + (Nat.lt_succ_sqrt' (N / 8)).trans_le (Nat.pow_le_pow_left hfloor 2) |
| 120 | + have hNlt : N < 8 * h N ^ 2 := by omega |
| 121 | + have hreal : (N : ℝ) < 8 * (h N : ℝ) ^ 2 := by exact_mod_cast hNlt |
| 122 | + have hroot : Real.sqrt N ≤ 4 * (h N : ℝ) := by |
| 123 | + apply (Real.sqrt_le_left (by positivity)).2 |
| 124 | + nlinarith [sq_nonneg (h N : ℝ)] |
| 125 | + linarith |
| 126 | + |
| 127 | +end ErdosSwarm.Erdos30 |