| | @@ -1,49 +1,86 @@ |
| 1 | 1 | import ErdosSwarm.Erdos30 |
| 2 | 2 | |
| 3 | 3 | /-! |
| 4 | | −# Erdős Problem 30: the Erdős–Turán bound `h N ≤ √N + 3 N^{1/4}` |
| 4 | +# Erdős Problem 30: the Erdős–Turán upper bound |
| 5 | 5 | -/ |
| 6 | 6 | |
| 7 | 7 | namespace ErdosSwarm.Erdos30 |
| 8 | 8 | |
| 9 | 9 | local notation "h" => _root_.Erdos30.h |
| 10 | 10 | |
| 11 | | −theorem h_le_sqrt_add (N : ℕ) (hN : 1 ≤ N) : |
| 12 | | − (h N : ℝ) ≤ Real.sqrt N + 3 * (N : ℝ) ^ (4⁻¹ : ℝ) := by |
| 13 | | − obtain ⟨F, hF, hS, hc⟩ := exists_eq_h N |
| 11 | +/-- The Erdős–Turán window bound with width rounded up from `N ^ (3/4)`. -/ |
| 12 | +theorem card_le_sqrt_add_quarter_of_pos {A : Finset ℕ} {N : ℕ} (hN : 1 ≤ N) |
| 13 | + (hA : A ⊆ Finset.Icc 1 N) (hS : IsSidon (A : Set ℕ)) : |
| 14 | + (A.card : ℝ) ≤ Real.sqrt N + (N : ℝ) ^ (4⁻¹ : ℝ) + 1 := by |
| 14 | 15 | set q : ℝ := (N : ℝ) ^ (4⁻¹ : ℝ) with hq |
| 15 | 16 | have hq4 : q ^ 4 = N := by |
| 16 | | − rw [hq, ← Real.rpow_natCast, ← Real.rpow_mul (Nat.cast_nonneg _)]; norm_num |
| 17 | + rw [hq, ← Real.rpow_natCast, ← Real.rpow_mul (Nat.cast_nonneg _)] |
| 18 | + norm_num |
| 17 | 19 | have hq1 : 1 ≤ q := Real.one_le_rpow (by exact_mod_cast hN) (by norm_num) |
| 18 | 20 | have hsqrt : Real.sqrt N = q ^ 2 := by |
| 19 | | − rw [← hq4, show q ^ 4 = (q ^ 2) ^ 2 by ring]; exact Real.sqrt_sq (by positivity) |
| 20 | | − rw [hsqrt] |
| 21 | | − set u : ℕ := ⌈q ^ 3⌉₊ with hu |
| 21 | + rw [← hq4, show q ^ 4 = (q ^ 2) ^ 2 by ring] |
| 22 | + exact Real.sqrt_sq (by positivity) |
| 23 | + set u : ℕ := ⌈q ^ 3⌉₊ |
| 22 | 24 | have hu1 : 1 ≤ u := Nat.ceil_pos.mpr (by positivity) |
| 23 | 25 | have hu_ge : q ^ 3 ≤ u := Nat.le_ceil _ |
| 24 | 26 | have hu_lt : (u : ℝ) < q ^ 3 + 1 := Nat.ceil_lt_add_one (by positivity) |
| 25 | | − have w := window_bound hS hF hu1 |
| 26 | | − rw [hc] at w |
| 27 | | − have w2 : h N ^ 2 * u ≤ (N + u) * (h N + u) := |
| 28 | | − w.trans (Nat.mul_le_mul (by omega) (by omega)) |
| 29 | | − have wr : ((h N : ℝ)) ^ 2 * u ≤ (q ^ 4 + u) * (h N + u) := by |
| 30 | | − rw [hq4]; exact_mod_cast w2 |
| 31 | | − set k : ℝ := (h N : ℝ) with hk |
| 32 | | − have hk0 : 0 ≤ k := Nat.cast_nonneg _ |
| 33 | | − have hu0 : (0 : ℝ) < u := by exact_mod_cast hu1 |
| 34 | | − have h4 : q ^ 4 ≤ q * u := by nlinarith [pow_pos (by linarith : (0:ℝ) < q) 3] |
| 35 | | − have h5 : k ^ 2 * u ≤ u * ((q + 1) * (k + u)) := by |
| 36 | | − refine wr.trans ?_ |
| 37 | | − have : (q ^ 4 + u) ≤ u * (q + 1) := by nlinarith |
| 38 | | − nlinarith |
| 39 | | − have h6 : k ^ 2 ≤ (q + 1) * (k + u) := by |
| 40 | | − have : u * k ^ 2 ≤ u * ((q + 1) * (k + u)) := by linarith |
| 41 | | − exact le_of_mul_le_mul_left this hu0 |
| 42 | | − have h7 : k ^ 2 ≤ (q + 1) * k + (q ^ 4 + q ^ 3 + q + 1) := by nlinarith |
| 43 | | − by_contra hlt |
| 44 | | − rw [not_le] at hlt |
| 45 | | − have hd : 0 < k - (q ^ 2 + 3 * q) := by linarith |
| 46 | | − have hs : 0 < k + (q ^ 2 + 3 * q) - (q + 1) := by nlinarith |
| 47 | | − nlinarith [mul_pos hd hs] |
| 27 | + have hu_pos : (0 : ℝ) < u := by exact_mod_cast hu1 |
| 28 | + set k : ℝ := (A.card : ℝ) |
| 29 | + have hk : 0 ≤ k := Nat.cast_nonneg _ |
| 30 | + have window := window_bound hS hA hu1 |
| 31 | + have hcast₁ : ((N + u - 1 : ℕ) : ℝ) = (N : ℝ) + u - 1 := by |
| 32 | + rw [Nat.cast_sub (by omega), Nat.cast_add, Nat.cast_one] |
| 33 | + have hcast₂ : ((A.card + u - 1 : ℕ) : ℝ) = k + u - 1 := by |
| 34 | + rw [Nat.cast_sub (by omega), Nat.cast_add, Nat.cast_one] |
| 35 | + have window_real := Nat.cast_le (α := ℝ).mpr window |
| 36 | + push_cast [hcast₁, hcast₂] at window_real |
| 37 | + change k ^ 2 * u ≤ ((N : ℝ) + u - 1) * (k + u - 1) at window_real |
| 38 | + have hwidth : (N : ℝ) + u - 1 ≤ u * (q + 1) := by |
| 39 | + have := mul_le_mul_of_nonneg_left hu_ge (by linarith : 0 ≤ q) |
| 40 | + rw [← hq4] |
| 41 | + nlinarith only [this] |
| 42 | + have hkwidth : 0 ≤ k + u - 1 := by |
| 43 | + have : (1 : ℝ) ≤ u := by exact_mod_cast hu1 |
| 44 | + linarith |
| 45 | + have hquadratic : k ^ 2 ≤ (q + 1) * (q ^ 3 + k) := by |
| 46 | + apply le_of_mul_le_mul_left _ hu_pos |
| 47 | + calc |
| 48 | + (u : ℝ) * k ^ 2 ≤ ((N : ℝ) + u - 1) * (k + u - 1) := by |
| 49 | + simpa only [mul_comm (u : ℝ) (k ^ 2)] using window_real |
| 50 | + _ ≤ (u * (q + 1)) * (k + u - 1) := |
| 51 | + mul_le_mul_of_nonneg_right hwidth hkwidth |
| 52 | + _ ≤ u * ((q + 1) * (q ^ 3 + k)) := by |
| 53 | + rw [mul_assoc] |
| 54 | + gcongr |
| 55 | + linarith |
| 56 | + rw [hsqrt] |
| 57 | + by_contra! hlt |
| 58 | + have hd : 0 < k - (q ^ 2 + q + 1) := by linarith |
| 59 | + have hs : 0 < k + (q ^ 2 + q + 1) - (q + 1) := by |
| 60 | + linarith [show 0 < q ^ 2 by positivity] |
| 61 | + nlinarith only [hquadratic, mul_pos hd hs, sq_nonneg q] |
| 62 | + |
| 63 | +/-- An eventual bound with coefficient one and additive constant one. -/ |
| 64 | +theorem card_le_sqrt_add_quarter : |
| 65 | + ∃ C : ℝ, ∀ᶠ N : ℕ in Filter.atTop, ∀ A : Finset ℕ, |
| 66 | + A ⊆ Finset.Icc 1 N → IsSidon (A : Set ℕ) → |
| 67 | + (A.card : ℝ) ≤ Real.sqrt N + (N : ℝ) ^ (4⁻¹ : ℝ) + C := by |
| 68 | + refine ⟨1, ?_⟩ |
| 69 | + filter_upwards [Filter.eventually_ge_atTop 1] with N hN A hA hS |
| 70 | + exact card_le_sqrt_add_quarter_of_pos hN hA hS |
| 71 | + |
| 72 | +theorem h_le_sqrt_add_two_mul (N : ℕ) (hN : 1 ≤ N) : |
| 73 | + (h N : ℝ) ≤ Real.sqrt N + 2 * (N : ℝ) ^ (4⁻¹ : ℝ) := by |
| 74 | + obtain ⟨A, hA, hS, hcard⟩ := exists_eq_h N |
| 75 | + have hbound := card_le_sqrt_add_quarter_of_pos hN hA hS |
| 76 | + rw [hcard] at hbound |
| 77 | + have hq : 1 ≤ (N : ℝ) ^ (4⁻¹ : ℝ) := |
| 78 | + Real.one_le_rpow (by exact_mod_cast hN) (by norm_num) |
| 79 | + linarith |
| 80 | + |
| 81 | +theorem h_le_sqrt_add (N : ℕ) (hN : 1 ≤ N) : |
| 82 | + (h N : ℝ) ≤ Real.sqrt N + 3 * (N : ℝ) ^ (4⁻¹ : ℝ) := by |
| 83 | + have hq : 0 ≤ (N : ℝ) ^ (4⁻¹ : ℝ) := by positivity |
| 84 | + linarith [h_le_sqrt_add_two_mul N hN] |
| 48 | 85 | |
| 49 | 86 | end ErdosSwarm.Erdos30 |