| | @@ -0,0 +1,195 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap103.Data |
| 2 | + |
| 3 | +/-! |
| 4 | +# The energy bound of §3 for the 102/103 upper bound in Erdős #530 |
| 5 | + |
| 6 | +`missing_energy` is lemma 6 of the plan in `ErdosSwarm/Erdos530Gap103/Plan.lean` |
| 7 | +(§3 of `experiments/erdos530/upper-new-cover/NOTES.md`, row `R = 32`): for a Sidon set |
| 8 | +`S ⊆ [1, M]`, |
| 9 | + |
| 10 | +`2 Q + ∑_{a, a' ∈ S} W(u_a − u_a') ≤ M/32 + |S| W(0)`, |
| 11 | + |
| 12 | +where `Q` is the kernel weight of the positive integers up to `M` that are not differences |
| 13 | +of `S`. It is unconditional, but it is one input of the plan, not a bound on `ℓ(N)`. |
| 14 | + |
| 15 | +Proof. By Sidon uniqueness the ordered pairs `a' < a` of `S` correspond one to one to the |
| 16 | +differences of `S`, so the double sum is `|S| W(0)` plus twice the kernel weight of the |
| 17 | +differences, and the left side is `|S| W(0) + 2 ∑_{d = 1}^{M} W(32 d/M)`. Each of the two |
| 18 | +tents of `W` is `max(0, 1 − d t)` at `d`, and `∑_{d = 1}^{n} max(0, 1 − d t) ≤ 1/(2t)`: |
| 19 | +while `n t ≤ 1` the sum is `n − t n(n+1)/2`, and `1/(2t)` minus this is |
| 20 | +`((1 − n t)² + n t²)/(2t)`; later terms vanish. So `∑_{d = 1}^{M} W(32 d/M) ≤ M/64`. |
| 21 | +-/ |
| 22 | + |
| 23 | +namespace ErdosSwarm.Erdos530Gap103 |
| 24 | + |
| 25 | +open Finset ErdosSwarm.Erdos530Gap |
| 26 | + |
| 27 | +/-- The right-endpoint sum of a tent while its last term is nonnegative. -/ |
| 28 | +private theorem tent_sum_closed (t : ℝ) (ht : 0 ≤ t) (n : ℕ) (hn : (n : ℝ) * t ≤ 1) : |
| 29 | + ∑ d ∈ Icc 1 n, max 0 (1 - (d : ℝ) * t) = n - t * (n * (n + 1) / 2) := by |
| 30 | + induction n with |
| 31 | + | zero => simp |
| 32 | + | succ n ih => |
| 33 | + push_cast at hn |
| 34 | + have hn' : (n : ℝ) * t ≤ 1 := by nlinarith |
| 35 | + rw [sum_Icc_succ_top (by omega), ih hn', max_eq_right (by push_cast; linarith)] |
| 36 | + push_cast |
| 37 | + ring |
| 38 | + |
| 39 | +/-- The right-endpoint sum of the tent `max(0, 1 − y t)` is at most its integral `1/(2t)` |
| 40 | +over the positive axis. -/ |
| 41 | +private theorem tent_sum_le (t : ℝ) (ht : 0 < t) (n : ℕ) : |
| 42 | + ∑ d ∈ Icc 1 n, max 0 (1 - (d : ℝ) * t) ≤ 1 / (2 * t) := by |
| 43 | + induction n with |
| 44 | + | zero => simpa using ht.le |
| 45 | + | succ n ih => |
| 46 | + by_cases h : ((n + 1 : ℕ) : ℝ) * t ≤ 1 |
| 47 | + · rw [tent_sum_closed t ht.le (n + 1) h, le_div_iff₀ (by positivity)] |
| 48 | + push_cast |
| 49 | + have h0 : (0 : ℝ) ≤ n + 1 := by positivity |
| 50 | + nlinarith [sq_nonneg (1 - ((n : ℝ) + 1) * t), mul_nonneg h0 (sq_nonneg t)] |
| 51 | + · rw [sum_Icc_succ_top (by omega), max_eq_left (by linarith), add_zero] |
| 52 | + exact ih |
| 53 | + |
| 54 | +private theorem kernel_neg (y : ℝ) : kernel (-y) = kernel y := by |
| 55 | + unfold kernel |
| 56 | + rw [abs_neg] |
| 57 | + |
| 58 | +/-- The right-endpoint sum of the kernel at step `32/M` is at most `(M/32)·∫₀^∞ W = M/64`. -/ |
| 59 | +private theorem kernel_sum_le {M : ℕ} (hM : 0 < M) : |
| 60 | + ∑ d ∈ Icc 1 M, kernel (32 * (d : ℝ) / M) ≤ (M : ℝ) / 64 := by |
| 61 | + have hM' : (0 : ℝ) < M := by exact_mod_cast hM |
| 62 | + have h1 := tent_sum_le (32 / (7 * M)) (by positivity) M |
| 63 | + have h2 := tent_sum_le (768 / M) (by positivity) M |
| 64 | + have key : ∀ d ∈ Icc 1 M, kernel (32 * (d : ℝ) / M) = |
| 65 | + 17 / 175 * max 0 (1 - (d : ℝ) * (32 / (7 * M))) + |
| 66 | + 192 / 25 * max 0 (1 - (d : ℝ) * (768 / M)) := by |
| 67 | + intro d _ |
| 68 | + have habs : |32 * (d : ℝ) / M| = 32 * (d : ℝ) / M := abs_of_nonneg (by positivity) |
| 69 | + have e1 : 32 * (d : ℝ) / M / 7 = (d : ℝ) * (32 / (7 * M)) := by |
| 70 | + field_simp |
| 71 | + have e2 : 24 * (32 * (d : ℝ) / M) = (d : ℝ) * (768 / M) := by |
| 72 | + field_simp |
| 73 | + ring |
| 74 | + unfold kernel |
| 75 | + rw [habs, e1, e2] |
| 76 | + ring |
| 77 | + rw [sum_congr rfl key, sum_add_distrib, ← mul_sum, ← mul_sum] |
| 78 | + have e1 : 1 / (2 * (32 / (7 * (M : ℝ)))) = 7 * M / 64 := by |
| 79 | + field_simp |
| 80 | + ring |
| 81 | + have e2 : 1 / (2 * (768 / (M : ℝ))) = M / 1536 := by |
| 82 | + field_simp |
| 83 | + ring |
| 84 | + rw [e1] at h1 |
| 85 | + rw [e2] at h2 |
| 86 | + linarith |
| 87 | + |
| 88 | +/-- 6. §3 of the note, the energy bound `2Q/(τ²M) ≤ R − 𝓔_W(ν) + |S| W(0)/(τ²M)` multiplied |
| 89 | +by `τ²M = M/1024`. By Sidon uniqueness the double sum is `|S| W(0)` plus twice the kernel |
| 90 | +weight of the differences of `S`, and the right-endpoint sum of the decreasing kernel gives |
| 91 | +`∑_{d ≥ 1} W(32 d/M) ≤ (M/32)·∫₀^∞ W = M/64`. -/ |
| 92 | +theorem missing_energy {M : ℕ} {S : Finset ℕ} (hM : 0 < M) (hS : S ⊆ host M) |
| 93 | + (hsid : IsSidon (S : Set ℕ)) : |
| 94 | + 2 * missingWeight M S + ∑ a ∈ S, ∑ a' ∈ S, kernel (coord M a - coord M a') ≤ |
| 95 | + (M : ℝ) / 32 + S.card * kernel 0 := by |
| 96 | + have hM' : (0 : ℝ) < M := by exact_mod_cast hM |
| 97 | + set g : ℕ → ℝ := fun d => kernel (32 * (d : ℝ) / M) with hg |
| 98 | + set f : ℕ × ℕ → ℝ := fun p => kernel (coord M p.1 - coord M p.2) with hf |
| 99 | + -- the kernel at a coordinate difference, in either order |
| 100 | + have hval : ∀ a a' : ℕ, a' ≤ a → |
| 101 | + kernel (coord M a - coord M a') = g (a - a') ∧ |
| 102 | + kernel (coord M a' - coord M a) = g (a - a') := by |
| 103 | + intro a a' h |
| 104 | + have e : coord M (a : ℤ) - coord M (a' : ℤ) = 32 * ((a - a' : ℕ) : ℝ) / M := by |
| 105 | + unfold coord |
| 106 | + push_cast [Nat.cast_sub h] |
| 107 | + ring |
| 108 | + have e' : coord M (a' : ℤ) - coord M (a : ℤ) = -(32 * ((a - a' : ℕ) : ℝ) / M) := by |
| 109 | + rw [← e] |
| 110 | + ring |
| 111 | + exact ⟨by rw [e], by rw [e', kernel_neg]⟩ |
| 112 | + -- the differences of `S` and the ordered pairs `a' < a` |
| 113 | + have hpairs : ∑ p ∈ (S ×ˢ S).filter (fun p => p.2 < p.1), g (p.1 - p.2) = |
| 114 | + ∑ d ∈ (Icc 1 M).filter |
| 115 | + (fun d => ¬ ∀ a ∈ S, ∀ a' ∈ S, ((a : ℤ) - a').natAbs ≠ d), g d := by |
| 116 | + refine sum_nbij (fun p => p.1 - p.2) ?_ ?_ ?_ (fun _ _ => rfl) |
| 117 | + · intro p hp |
| 118 | + obtain ⟨hp, hlt⟩ := mem_filter.mp hp |
| 119 | + obtain ⟨h1, h2⟩ := mem_product.mp hp |
| 120 | + have hle := (mem_Icc.mp (hS h1)).2 |
| 121 | + refine mem_filter.mpr ⟨mem_Icc.mpr ⟨by omega, by omega⟩, fun h => ?_⟩ |
| 122 | + exact h p.1 h1 p.2 h2 (by omega) |
| 123 | + · intro p hp q hq hpq |
| 124 | + rw [mem_coe] at hp hq |
| 125 | + obtain ⟨hp, hlt⟩ := mem_filter.mp hp |
| 126 | + obtain ⟨hq, hlt'⟩ := mem_filter.mp hq |
| 127 | + obtain ⟨hp1, hp2⟩ := mem_product.mp hp |
| 128 | + obtain ⟨hq1, hq2⟩ := mem_product.mp hq |
| 129 | + have hpq' : p.1 - p.2 = q.1 - q.2 := hpq |
| 130 | + rcases hsid p.1 (mem_coe.mpr hp1) q.1 (mem_coe.mpr hq1) q.2 (mem_coe.mpr hq2) |
| 131 | + p.2 (mem_coe.mpr hp2) (by omega) with ⟨h1, h2⟩ | ⟨h1, h2⟩ |
| 132 | + · exact Prod.ext h1 h2.symm |
| 133 | + · omega |
| 134 | + · intro d hd |
| 135 | + rw [mem_coe] at hd |
| 136 | + obtain ⟨hd, hne⟩ := mem_filter.mp hd |
| 137 | + have hd1 := (mem_Icc.mp hd).1 |
| 138 | + push Not at hne |
| 139 | + obtain ⟨a, ha, a', ha', hdiff⟩ := hne |
| 140 | + rcases lt_or_ge a' a with h | h |
| 141 | + · exact ⟨(a, a'), mem_coe.mpr (mem_filter.mpr ⟨mem_product.mpr ⟨ha, ha'⟩, h⟩), |
| 142 | + by simp only; omega⟩ |
| 143 | + · exact ⟨(a', a), mem_coe.mpr (mem_filter.mpr ⟨mem_product.mpr ⟨ha', ha⟩, by omega⟩), |
| 144 | + by simp only; omega⟩ |
| 145 | + have hQ : missingWeight M S + ∑ d ∈ (Icc 1 M).filter |
| 146 | + (fun d => ¬ ∀ a ∈ S, ∀ a' ∈ S, ((a : ℤ) - a').natAbs ≠ d), g d = |
| 147 | + ∑ d ∈ Icc 1 M, g d := by |
| 148 | + unfold missingWeight |
| 149 | + exact sum_filter_add_sum_filter_not _ _ _ |
| 150 | + -- split the double sum into `a' < a`, `a < a'` and the diagonal |
| 151 | + have h1 := sum_filter_add_sum_filter_not (S ×ˢ S) (fun p : ℕ × ℕ => p.2 < p.1) f |
| 152 | + have h2 := sum_filter_add_sum_filter_not ((S ×ˢ S).filter (fun p : ℕ × ℕ => ¬ p.2 < p.1)) |
| 153 | + (fun p : ℕ × ℕ => p.1 < p.2) f |
| 154 | + have hA : ∑ p ∈ (S ×ˢ S).filter (fun p => p.2 < p.1), f p = |
| 155 | + ∑ p ∈ (S ×ˢ S).filter (fun p => p.2 < p.1), g (p.1 - p.2) := |
| 156 | + sum_congr rfl fun p hp => (hval p.1 p.2 (mem_filter.mp hp).2.le).1 |
| 157 | + have hB : ∑ p ∈ ((S ×ˢ S).filter (fun p : ℕ × ℕ => ¬ p.2 < p.1)).filter |
| 158 | + (fun p : ℕ × ℕ => p.1 < p.2), f p = |
| 159 | + ∑ p ∈ (S ×ˢ S).filter (fun p => p.2 < p.1), g (p.1 - p.2) := by |
| 160 | + refine sum_nbij' Prod.swap Prod.swap ?_ ?_ (fun _ _ => rfl) (fun _ _ => rfl) ?_ |
| 161 | + · intro p hp |
| 162 | + obtain ⟨hp, hlt⟩ := mem_filter.mp hp |
| 163 | + obtain ⟨h1, h2⟩ := mem_product.mp (mem_filter.mp hp).1 |
| 164 | + exact mem_filter.mpr ⟨mem_product.mpr ⟨h2, h1⟩, hlt⟩ |
| 165 | + · intro p hp |
| 166 | + obtain ⟨hp, hlt⟩ := mem_filter.mp hp |
| 167 | + obtain ⟨h1, h2⟩ := mem_product.mp hp |
| 168 | + exact mem_filter.mpr ⟨mem_filter.mpr ⟨mem_product.mpr ⟨h2, h1⟩, |
| 169 | + by simp only [Prod.fst_swap, Prod.snd_swap]; omega⟩, hlt⟩ |
| 170 | + · intro p hp |
| 171 | + exact (hval p.2 p.1 (mem_filter.mp hp).2.le).2 |
| 172 | + have hC : ∑ p ∈ ((S ×ˢ S).filter (fun p : ℕ × ℕ => ¬ p.2 < p.1)).filter |
| 173 | + (fun p : ℕ × ℕ => ¬ p.1 < p.2), f p = S.card * kernel 0 := by |
| 174 | + rw [← nsmul_eq_mul, ← sum_const] |
| 175 | + refine sum_nbij' (fun p => p.1) (fun a => (a, a)) ?_ ?_ ?_ (fun _ _ => rfl) ?_ |
| 176 | + · intro p hp |
| 177 | + exact (mem_product.mp (mem_filter.mp (mem_filter.mp hp).1).1).1 |
| 178 | + · intro a ha |
| 179 | + exact mem_filter.mpr ⟨mem_filter.mpr ⟨mem_product.mpr ⟨ha, ha⟩, lt_irrefl a⟩, |
| 180 | + lt_irrefl a⟩ |
| 181 | + · intro p hp |
| 182 | + obtain ⟨hp, hlt⟩ := mem_filter.mp hp |
| 183 | + have hlt' := (mem_filter.mp hp).2 |
| 184 | + exact Prod.ext rfl (by simp only; omega) |
| 185 | + · intro p hp |
| 186 | + obtain ⟨hp, hlt⟩ := mem_filter.mp hp |
| 187 | + have hlt' := (mem_filter.mp hp).2 |
| 188 | + have heq : p.1 = p.2 := by omega |
| 189 | + simp only [hf, heq, sub_self] |
| 190 | + have hsum := kernel_sum_le hM |
| 191 | + rw [← sum_product' S S fun a a' => kernel (coord M a - coord M a')] |
| 192 | + change 2 * missingWeight M S + ∑ p ∈ S ×ˢ S, f p ≤ _ |
| 193 | + linarith |
| 194 | + |
| 195 | +end ErdosSwarm.Erdos530Gap103 |