| | @@ -0,0 +1,44 @@ |
| 1 | +import FormalConjectures.ErdosProblems.«30» |
| 2 | +import ErdosSwarm.Erdos329 |
| 3 | + |
| 4 | +/-! |
| 5 | +# Erdős Problem 30: basic facts about `h N`, the largest Sidon subset size of `[1, N]` |
| 6 | +-/ |
| 7 | + |
| 8 | +namespace ErdosSwarm.Erdos30 |
| 9 | + |
| 10 | +local notation "h" => _root_.Erdos30.h |
| 11 | + |
| 12 | +theorem card_le_h {F : Finset ℕ} {N : ℕ} (hS : IsSidon (F : Set ℕ)) (hF : F ⊆ Finset.Icc 1 N) : |
| 13 | + F.card ≤ h N := by |
| 14 | + classical |
| 15 | + unfold _root_.Erdos30.h Finset.maxSidonSubsetCard |
| 16 | + exact Finset.le_sup (f := Finset.card) |
| 17 | + (Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hF, hS⟩) |
| 18 | + |
| 19 | +theorem exists_eq_h (N : ℕ) : ∃ F ⊆ Finset.Icc 1 N, IsSidon (F : Set ℕ) ∧ F.card = h N := by |
| 20 | + classical |
| 21 | + unfold _root_.Erdos30.h Finset.maxSidonSubsetCard |
| 22 | + have hne : ((Finset.Icc 1 N).powerset.filter fun B : Finset ℕ => IsSidon (B : Set ℕ)).Nonempty := |
| 23 | + ⟨∅, Finset.mem_filter.mpr ⟨Finset.empty_mem_powerset _, by simp [IsSidon]⟩⟩ |
| 24 | + obtain ⟨F, hF, hc⟩ := Finset.exists_mem_eq_sup _ hne Finset.card |
| 25 | + obtain ⟨h1, h2⟩ := Finset.mem_filter.mp hF |
| 26 | + exact ⟨F, Finset.mem_powerset.mp h1, h2, hc.symm⟩ |
| 27 | + |
| 28 | +theorem h_mono : Monotone h := by |
| 29 | + intro M N hMN |
| 30 | + obtain ⟨F, hF, hS, hc⟩ := exists_eq_h M |
| 31 | + rw [← hc] |
| 32 | + exact card_le_h hS (hF.trans (Finset.Icc_subset_Icc_right hMN)) |
| 33 | + |
| 34 | +theorem h_le_two_sqrt (N : ℕ) : (h N : ℝ) ≤ 2 * Real.sqrt N := by |
| 35 | + obtain ⟨F, hF, hS, hc⟩ := exists_eq_h N |
| 36 | + have hsq := ErdosSwarm.Erdos329.sidon_card_sq hS (fun x hx => hF hx) |
| 37 | + rw [← hc] |
| 38 | + have hk : (F.card : ℝ) * F.card ≤ 4 * N := by exact_mod_cast (by omega : F.card * F.card ≤ 4 * N) |
| 39 | + have hs := Real.sq_sqrt (Nat.cast_nonneg N : (0:ℝ) ≤ N) |
| 40 | + have hs0 := Real.sqrt_nonneg (N : ℝ) |
| 41 | + have hk0 : (0:ℝ) ≤ F.card := Nat.cast_nonneg _ |
| 42 | + by_contra hlt |
| 43 | + rw [not_le] at hlt |
| 44 | + nlinarith |