| | @@ -0,0 +1,171 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap75.Cover |
| 2 | +import ErdosSwarm.Erdos530Gap75.FixedLevel |
| 3 | + |
| 4 | +/-! |
| 5 | +# The fixed-level cover of Erdős #530 at `m ≥ 2^256` from its three inputs |
| 6 | + |
| 7 | +Step 4 and Theorem 1 of `experiments/erdos530/upper-fixed-level/NOTES.md` (F2 and F5 of its |
| 8 | +§6). `few_outsiders_fixed` is `few_outsiders_of_inputs` of `Cover.lean` with the |
| 9 | +square-root-scale incidence lemma `incidence_sqrt` in place of `Erdos530Gap103.incidence`: |
| 10 | +on the live set of a level-`2^48` refinement of a container with at most `5m` points, an |
| 11 | +independent Sidon seed of size at least `(1 − τ − 90/2^48)m` has fewer than `(s + ε)τm` |
| 12 | +outsiders. The discard count is at most `2^62·m^(3/2)`, so the score error is |
| 13 | +`1024·W(0)·(1 + 2^63)/m^(1/2) < 2/1000` already at `m = 2^256`. |
| 14 | + |
| 15 | +`fixed_level_cover` combines this with `cover_of_outsider_bound48` and `fixed_count_le` of |
| 16 | +`FixedLevel.lean` and gives `Cover75At512` from the charging lemma, the missing-energy |
| 17 | +bound and the seed lower bound, which are **hypotheses** here; `Main512.lean` supplies them. |
| 18 | +-/ |
| 19 | + |
| 20 | +namespace ErdosSwarm.Erdos530Gap75.FixedLevel |
| 21 | + |
| 22 | +open Finset ErdosSwarm.Erdos530Gap |
| 23 | +open ErdosSwarm.Erdos530Gap103 (tau iso adjacentPairs edgeFreeQuadruples) |
| 24 | + |
| 25 | +set_option exponentiation.threshold 1024 |
| 26 | + |
| 27 | +open ErdosSwarm.Erdos530Gap103 (coord coord_iso coord_mem_Ioo isoR) |
| 28 | + |
| 29 | +noncomputable section |
| 30 | + |
| 31 | +/-- The upper bound in step 4 of the note, summed over the `b` tested outsiders. Write |
| 32 | +`m = r²` and `w = 32/m`. The discard loses at most `2^62·r³` terms of weight `W(0)`, and the |
| 33 | +diagonal of the seed energy costs at most `m·W(0)`; the error is |
| 34 | +`1024·W(0)·(1 + 2^63)/r ≤ 2/1000` for `r ≥ 2^128`. -/ |
| 35 | +private theorem score_sum_le {r n b E Q T D : ℝ} |
| 36 | + (hr : (2 : ℝ) ^ 128 ≤ r) (hn : n ≤ r ^ 2) (hb₀ : 0 ≤ b) |
| 37 | + (hb : sCoef ≤ b * (32 / r ^ 2)) (hD : D ≤ 2 ^ 62 * r ^ 3) |
| 38 | + (hbudget : 0 ≤ Q + kernel 0 * D) (hch : T ≤ Q + kernel 0 * D) |
| 39 | + (hen : 2 * Q + E ≤ (r ^ 2) ^ 2 / 32 + n * kernel 0) : |
| 40 | + b * ((32 / r ^ 2) ^ 2 * E) + 2 * sCoef * (32 / r ^ 2) * T ≤ |
| 41 | + b * (32 + 2 / 1000) := by |
| 42 | + let w := 32 / r ^ 2 |
| 43 | + have hr₁ : 1 ≤ r := le_trans (by norm_num) hr |
| 44 | + have hr₀ : 0 < r := zero_lt_one.trans_le hr₁ |
| 45 | + have hw : 0 ≤ w := by dsimp [w]; positivity |
| 46 | + have hs : 0 ≤ sCoef := by norm_num [sCoef] |
| 47 | + have hscale : w ^ 2 * ((r ^ 2) ^ 2 / 32) = 32 := by |
| 48 | + dsimp [w]; field_simp |
| 49 | + have herr : w ^ 2 * (n * kernel 0 + 2 * (kernel 0 * D)) ≤ 2 / 1000 := by |
| 50 | + have hn' : n ≤ r ^ 3 := hn.trans (pow_le_pow_right₀ hr₁ (by decide : 2 ≤ 3)) |
| 51 | + rw [kernel_zero] |
| 52 | + calc w ^ 2 * (n * (2929 / 700) + 2 * (2929 / 700 * D)) ≤ |
| 53 | + w ^ 2 * (r ^ 3 * (2929 / 700) + 2 * (2929 / 700 * (2 ^ 62 * r ^ 3))) := by gcongr |
| 54 | + _ = (1024 * (1 + 2 ^ 63) * (2929 / 700)) / r := by dsimp [w]; field_simp; ring |
| 55 | + _ ≤ (1024 * (1 + 2 ^ 63) * (2929 / 700)) / 2 ^ 128 := by gcongr |
| 56 | + _ ≤ _ := by norm_num |
| 57 | + have henergy : E + 2 * (Q + kernel 0 * D) ≤ |
| 58 | + (r ^ 2) ^ 2 / 32 + (n * kernel 0 + 2 * (kernel 0 * D)) := by linarith only [hen] |
| 59 | + calc b * (w ^ 2 * E) + 2 * sCoef * w * T ≤ |
| 60 | + b * (w ^ 2 * E) + 2 * sCoef * w * (Q + kernel 0 * D) := by gcongr |
| 61 | + _ ≤ b * (w ^ 2 * E) + 2 * (b * w) * w * (Q + kernel 0 * D) := by gcongr |
| 62 | + _ = b * (w ^ 2 * (E + 2 * (Q + kernel 0 * D))) := by ring |
| 63 | + _ ≤ b * (w ^ 2 * ((r ^ 2) ^ 2 / 32 + (n * kernel 0 + 2 * (kernel 0 * D)))) := by |
| 64 | + gcongr |
| 65 | + _ = b * (32 + w ^ 2 * (n * kernel 0 + 2 * (kernel 0 * D))) := by rw [mul_add, hscale] |
| 66 | + _ ≤ _ := by gcongr |
| 67 | + |
| 68 | +/-- **F2.** The outsider bound (NOTES §2 step 4): `few_outsiders_of_inputs` of `Cover.lean` |
| 69 | +with `incidence_sqrt` in place of `Erdos530Gap103.incidence`. On the live set of a |
| 70 | +level-`2^48` refinement, an independent Sidon seed of size at least `(1 − τ − 90/2^48)m` |
| 71 | +has fewer than `(s + ε)τm` outsiders. -/ |
| 72 | +theorem few_outsiders_fixed {A : Allocation} (hcharge : Charging A) (henergy : MissingEnergy) |
| 73 | + (hlow : SeedLower A) {M : ℕ} (hm : (2 : ℝ) ^ 256 ≤ Real.sqrt M) : |
| 74 | + OutsiderBound48 M ((sCoef + eps) * tau * Real.sqrt M) := by |
| 75 | + intro U S G hU hSU hsid hind hedges hquads hle hge |
| 76 | + classical |
| 77 | + by_contra! hmany |
| 78 | + have hm₀ : 0 < Real.sqrt M := lt_of_lt_of_le (by norm_num) hm |
| 79 | + have hM : 0 < M := by exact_mod_cast Real.sqrt_pos.mp hm₀ |
| 80 | + let r := Real.sqrt (Real.sqrt M) |
| 81 | + have hr2 : Real.sqrt M = r ^ 2 := (Real.sq_sqrt hm₀.le).symm |
| 82 | + have hr : (2 : ℝ) ^ 128 ≤ r := Real.le_sqrt_of_sq_le (le_trans (by norm_num) hm) |
| 83 | + have hr₀ : 0 < r := lt_of_lt_of_le (by norm_num) hr |
| 84 | + obtain ⟨B₀, hB₀, hcap, hsample⟩ := Erdos530Gap103.outsider_samples (s := sCoef) |
| 85 | + (le_trans (by norm_num) hm) (by norm_num [sCoef]) (by norm_num [sCoef]) hmany |
| 86 | + obtain ⟨Z, hZ, hZcard, hrest⟩ := incidence_sqrt hSU hsid hind hle hB₀ hcap |
| 87 | + obtain ⟨B, hBsub, hBcard⟩ := hsample Z hZ (hZcard.trans (by linarith only [hm₀])) |
| 88 | + obtain ⟨P, g, hP, hdisc, hD, hg⟩ := hrest B hBsub |
| 89 | + have hBU : B ⊆ U \ S := (hBsub.trans sdiff_subset).trans hB₀ |
| 90 | + have hB : B ⊆ host M \ S := fun x hx => |
| 91 | + mem_sdiff.mpr ⟨hU (mem_sdiff.mp (hBU hx)).1, (mem_sdiff.mp (hBU hx)).2⟩ |
| 92 | + have hS := hSU.trans hU |
| 93 | + |
| 94 | + -- Keep the supplied isometry at repeated distances and use the identity elsewhere. |
| 95 | + let paired (x : ℕ) : Prop := ∃ p ∈ P, p.1 = x ∧ ∃ p' ∈ P, p ≠ p' ∧ |
| 96 | + ((p.1 : ℤ) - p.2).natAbs = ((p'.1 : ℤ) - p'.2).natAbs |
| 97 | + let g' (x : ℕ) : Bool × ℤ := if paired x then g x else (false, 0) |
| 98 | + have hch := hcharge (g := g') hS hB hP hD (by |
| 99 | + intro p hp p' hp' hne he |
| 100 | + have h : paired p.1 := ⟨p, hp, rfl, p', hp', hne, he⟩ |
| 101 | + simpa only [g', if_pos h] using hg p hp p' hp' hne he) |
| 102 | + have hcenter (x : ℕ) (hx : x ∈ B) : coord M (iso (g' x) x) ∈ Set.Icc (0 : ℝ) 32 := by |
| 103 | + by_cases h : paired x |
| 104 | + · simp only [g', if_pos h] |
| 105 | + obtain ⟨p, hp, rfl, p', hp', hne, he⟩ := h |
| 106 | + rw [← (hg p hp p' hp' hne he).2] |
| 107 | + exact Set.Ioo_subset_Icc_self (coord_mem_Ioo (hS (mem_product.mp (hP hp')).2)) |
| 108 | + · simpa [g', h, iso] using |
| 109 | + Set.Ioo_subset_Icc_self (coord_mem_Ioo (mem_sdiff.mp (hB hx)).1) |
| 110 | + |
| 111 | + let w := 32 / Real.sqrt M |
| 112 | + have hw : 0 ≤ w := by dsimp [w]; positivity |
| 113 | + have hmass : 31 - 1 / 10 ^ 5 ≤ (S.card : ℝ) * w := by |
| 114 | + dsimp only [w] |
| 115 | + rw [← mul_div_assoc, le_div_iff₀ hm₀] |
| 116 | + norm_num [tau, Erdos530Gap103.tau] at hge |
| 117 | + linarith only [hge, hm₀] |
| 118 | + have hlower (x : ℕ) (hx : x ∈ B) : (32 + 2 / 1000 : ℝ) < |
| 119 | + w ^ 2 * (∑ a ∈ S, ∑ a' ∈ S, kernel (coord M a - coord M a')) + |
| 120 | + 2 * sCoef * w * ∑ a ∈ S, score A (coord M x) (coord M a) (g' x).1 |
| 121 | + (isoShift M (g' x)) := |
| 122 | + hlow S (fun a : ℕ => coord M a) hw (fun _ ha => coord_mem_Ioo (hS ha)) |
| 123 | + hmass (coord_mem_Ioo (mem_sdiff.mp (hB hx)).1) (g' x).1 (isoShift M (g' x)) |
| 124 | + (by unfold isoShift; rw [coord_iso]; exact hcenter x hx) |
| 125 | + have hBne : B.Nonempty := by |
| 126 | + apply card_pos.mp |
| 127 | + rw [hBcard] |
| 128 | + exact Nat.ceil_pos.mpr (mul_pos (by norm_num [sCoef, tau, Erdos530Gap103.tau]) hm₀) |
| 129 | + have hsum := sum_lt_sum_of_nonempty hBne hlower |
| 130 | + rw [sum_const, nsmul_eq_mul, sum_add_distrib, sum_const, nsmul_eq_mul, ← mul_sum] at hsum |
| 131 | + |
| 132 | + have hb : sCoef ≤ (B.card : ℝ) * w := by |
| 133 | + rw [hBcard, ← mul_div_assoc, le_div_iff₀ hm₀] |
| 134 | + have h := Nat.le_ceil (sCoef * tau * Real.sqrt M) |
| 135 | + simp only [tau, Erdos530Gap103.tau] at h ⊢ |
| 136 | + linarith only [h] |
| 137 | + -- The discard count: `D ≤ 2^62·r³` from the census of the level-`2^48` leaf. |
| 138 | + have hdisc' : (((B ×ˢ S) \ P).card : ℝ) ≤ 2 ^ 62 * r ^ 3 := by |
| 139 | + change _ ≤ (13 / 2 + 2000 * r) * _ + 48 * _ + 2 * (Real.sqrt M * r) + 2 / 3 * Real.sqrt M |
| 140 | + at hdisc |
| 141 | + rw [hr2] at hdisc hedges hquads |
| 142 | + have h1 : (13 / 2 + 2000 * r) * ((Erdos530Gap103.adjacentPairs G U).card : ℝ) ≤ |
| 143 | + (13 / 2 + 2000 * r) * (5 * 2 ^ 48 * r ^ 2) := by gcongr |
| 144 | + have h2 : r ^ 2 * 2 ^ 128 ≤ r ^ 3 := by |
| 145 | + calc r ^ 2 * 2 ^ 128 ≤ r ^ 2 * r := by gcongr |
| 146 | + _ = r ^ 3 := by ring |
| 147 | + linarith only [hdisc, h1, hquads, h2] |
| 148 | + have hen := henergy hM hS hsid |
| 149 | + rw [← Real.sq_sqrt (Nat.cast_nonneg M)] at hen |
| 150 | + have hW (z : ℝ) : 0 ≤ kernel z := kernel_nonneg z |
| 151 | + have hbudget : 0 ≤ missingWeight M S + kernel 0 * (((B ×ˢ S) \ P).card : ℝ) := |
| 152 | + add_nonneg (sum_nonneg fun d _ => hW _) (mul_nonneg (hW 0) (Nat.cast_nonneg _)) |
| 153 | + dsimp only [w] at hb hsum |
| 154 | + rw [hr2] at hb hsum hle hen |
| 155 | + exact hsum.not_ge (score_sum_le hr hle (Nat.cast_nonneg _) hb hdisc' hbudget hch hen) |
| 156 | + |
| 157 | +/-- **F5.** Theorem 1 of `experiments/erdos530/upper-fixed-level/NOTES.md`: the cover at |
| 158 | +`m ≥ 2^256` from the three inputs of the final pass, by one refinement at the level `2^48`. -/ |
| 159 | +theorem fixed_level_cover {P : Allocation} (hch : Charging P) (hen : MissingEnergy) |
| 160 | + (hlow : SeedLower P) : Cover75At512 := by |
| 161 | + intro M hm |
| 162 | + obtain ⟨𝒞, hcount, hsize, hcover⟩ := cover_of_outsider_bound48 |
| 163 | + (few_outsiders_fixed hch hen hlow hm) |
| 164 | + (width := (1 + K * tau) * Real.sqrt M) (by |
| 165 | + norm_num [K, sCoef, eps, tau, Erdos530Gap103.tau] |
| 166 | + linarith only [hm]) hm |
| 167 | + exact ⟨𝒞, hcount.trans (Real.exp_le_exp.mpr (fixed_count_le hm)), hsize, hcover⟩ |
| 168 | + |
| 169 | +end |
| 170 | + |
| 171 | +end ErdosSwarm.Erdos530Gap75.FixedLevel |