| | @@ -0,0 +1,226 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap78.Data |
| 2 | +import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic |
| 3 | + |
| 4 | +/-! |
| 5 | +# Shared definitions for the 74/75 upper-bound plan in Erdős #530 |
| 6 | + |
| 7 | +The kernel, allocation table and scores come from §§1–3 of |
| 8 | +`experiments/erdos530/upper-smaller-k3/NOTES.md`. The cover and tail statements |
| 9 | +give the inputs for the bounds at `N ≥ 2^720` and `N ≥ 2^512`. |
| 10 | +-/ |
| 11 | + |
| 12 | +namespace ErdosSwarm.Erdos530Gap75 |
| 13 | + |
| 14 | +open Finset MeasureTheory ErdosSwarm.Erdos530Gap |
| 15 | +open ErdosSwarm.Erdos530Gap103 (tau recordLog coord iso isoR) |
| 16 | +open ErdosSwarm.Erdos530Gap78 (refinedLog tilt) |
| 17 | + |
| 18 | +noncomputable section |
| 19 | + |
| 20 | +set_option exponentiation.threshold 1024 |
| 21 | + |
| 22 | +/- ## Constants, kernel and grid (note §1, §2) -/ |
| 23 | + |
| 24 | +/-- The covering coefficient of Theorem 1 of the note. -/ |
| 25 | +def K : ℝ := 2999 / 500 |
| 26 | + |
| 27 | +/-- The exceptional coefficient `s = 6997/1000` of §1. -/ |
| 28 | +def sCoef : ℝ := 6997 / 1000 |
| 29 | + |
| 30 | +/-- The allowance `ε = 1/1250` of §1. -/ |
| 31 | +def eps : ℝ := 1 / 1250 |
| 32 | + |
| 33 | +/-- The unit-integral tent `T_h(d) = (1 − |d|/h)₊ / h`. -/ |
| 34 | +def tent (h y : ℝ) : ℝ := max 0 (1 - |y| / h) / h |
| 35 | + |
| 36 | +/-- The kernel (1): `W = T_{1/16}/4 + (4T₁ + 2T₂ + 7T₃ + 10T₄ + 5T₅ + 37T₆ + 10T₇)/100`. |
| 37 | +`W(0) = 2929/700`. -/ |
| 38 | +def kernel (y : ℝ) : ℝ := |
| 39 | + tent (1 / 16) y / 4 + |
| 40 | + (4 * tent 1 y + 2 * tent 2 y + 7 * tent 3 y + 10 * tent 4 y + 5 * tent 5 y + |
| 41 | + 37 * tent 6 y + 10 * tent 7 y) / 100 |
| 42 | + |
| 43 | +theorem kernel_zero : kernel 0 = 2929 / 700 := by |
| 44 | + norm_num [kernel, tent] |
| 45 | + |
| 46 | +theorem kernel_neg (y : ℝ) : kernel (-y) = kernel y := by |
| 47 | + simp [kernel, tent] |
| 48 | + |
| 49 | +theorem kernel_nonneg (y : ℝ) : 0 ≤ kernel y := by |
| 50 | + unfold kernel tent |
| 51 | + positivity |
| 52 | + |
| 53 | +/-- `Q_W` of §1: the kernel weight of the positive integers that are not differences of |
| 54 | +`S`. -/ |
| 55 | +def missingWeight (M : ℕ) (S : Finset ℕ) : ℝ := |
| 56 | + ∑ d ∈ (Icc 1 M).filter (fun d => ∀ a ∈ S, ∀ a' ∈ S, ((a : ℤ) - a').natAbs ≠ d), |
| 57 | + kernel (32 * (d : ℝ) / M) |
| 58 | + |
| 59 | +/-- The kernel on the mesh `1/16`: `w_d = W(d/16)`. The grid nodes are `0, …, 512`. -/ |
| 60 | +def gridWeight (n : ℤ) : ℝ := kernel ((n : ℝ) / 16) |
| 61 | + |
| 62 | +/-- An allocation table: a height `P_l(i, d) ∈ [0, 1]` for each overlap `l`, outsider node |
| 63 | +`i` and signed displacement `d` (§2). The charging identity holds for every table; only the |
| 64 | +grid inequality depends on the published one. -/ |
| 65 | +structure Allocation where |
| 66 | + /-- The height `P_l(i, d)`. -/ |
| 67 | + height : ℕ → ℤ → ℤ → ℝ |
| 68 | + mem : ∀ l i d, height l i d ∈ Set.Icc (0 : ℝ) 1 |
| 69 | + |
| 70 | +/-- `l = |I| − 1` for `I = J ∩ T⁻¹(J)`, `J = [0, 512]`, `T = iso g`. -/ |
| 71 | +def overlap (g : Bool × ℤ) : ℤ := |
| 72 | + if g.1 then (if g.2 ≤ 512 then g.2 else 1024 - g.2) else 512 - |g.2| |
| 73 | + |
| 74 | +/-- Whether the overlap `I` sits at the right end of `J` (then nodes are numbered from |
| 75 | +`512` downwards, so that `I = [0, l]` in the numbering). -/ |
| 76 | +def flipped (g : Bool × ℤ) : Prop := if g.1 then 512 < g.2 else g.2 < 0 |
| 77 | + |
| 78 | +instance (g : Bool × ℤ) : Decidable (flipped g) := by unfold flipped; infer_instance |
| 79 | + |
| 80 | +/-- The numbering of the physical host that starts at its endpoint in the overlap. -/ |
| 81 | +def num (g : Bool × ℤ) (j : ℤ) : ℤ := if flipped g then 512 - j else j |
| 82 | + |
| 83 | +/-- The share (5) in numbered coordinates: full credit outside the overlap, and |
| 84 | +`[1 + P_l(i, d) − P_l(l − j, d)]/2` with `d = j − i` inside. -/ |
| 85 | +def shareNum (P : Allocation) (l i j : ℤ) : ℝ := |
| 86 | + if l < j then 1 |
| 87 | + else (1 + P.height l.toNat i (j - i) - P.height l.toNat (l - j) (j - i)) / 2 |
| 88 | + |
| 89 | +/-- The share `H` of the incidence (outsider node `i`, seed node `j`) for the integer |
| 90 | +isometry `g`; at full overlap the average over the two numberings. -/ |
| 91 | +def share (P : Allocation) (g : Bool × ℤ) (i j : ℤ) : ℝ := |
| 92 | + if overlap g = 512 then (shareNum P 512 i j + shareNum P 512 (512 - i) (512 - j)) / 2 |
| 93 | + else shareNum P (overlap g) (num g i) (num g j) |
| 94 | + |
| 95 | +/-- The rounded score `w_d · H` of §2. -/ |
| 96 | +def nodeScore (P : Allocation) (i : ℤ) (g : Bool × ℤ) (j : ℤ) : ℝ := |
| 97 | + gridWeight (j - i) * share P g i j |
| 98 | + |
| 99 | +/-- The integer isometry (4) induced by `y ↦ ±y + r` and the shift `v`: |
| 100 | +`T(j) = σj − ⌊σv − 16r⌋ − 1_{σ = −1}`. -/ |
| 101 | +def gridIso (neg : Bool) (r v : ℝ) : Bool × ℤ := |
| 102 | + (neg, -⌊(if neg then -v else v) - 16 * r⌋ - if neg then 1 else 0) |
| 103 | + |
| 104 | +/-- The rounded score at shift `v`, with `r_v(y) = ⌊16y + v⌋`. -/ |
| 105 | +def roundedScore (P : Allocation) (t y : ℝ) (neg : Bool) (r v : ℝ) : ℝ := |
| 106 | + nodeScore P ⌊16 * t + v⌋ (gridIso neg r v) ⌊16 * y + v⌋ |
| 107 | + |
| 108 | +/-- The score `L(t, y; g)` of §2: the expectation of the rounded score over the shift. -/ |
| 109 | +def score (P : Allocation) (t y : ℝ) (neg : Bool) (r : ℝ) : ℝ := |
| 110 | + ∫ v in (0 : ℝ)..1, roundedScore P t y neg r v |
| 111 | + |
| 112 | +/-- The real translation part of the integer isometry `g` in the coordinates `coord M` |
| 113 | +(`Erdos530Gap103.coord_iso`). -/ |
| 114 | +def isoShift (M : ℕ) (g : Bool × ℤ) : ℝ := |
| 115 | + if g.1 then 32 * ((g.2 : ℝ) - 1) / M else 32 * (g.2 : ℝ) / M |
| 116 | + |
| 117 | +/- ## Stage 1: the cover with `K = 5.998` -/ |
| 118 | + |
| 119 | +/-- The statement of the charging lemma: property 1 of §1 summed over the retained |
| 120 | +incidences, as `Erdos530Gap78.second_occurrence` with the coupled-shift score. -/ |
| 121 | +def Charging (P : Allocation) : Prop := |
| 122 | + ∀ {M : ℕ} {S B : Finset ℕ} {Pr : Finset (ℕ × ℕ)} {g : ℕ → Bool × ℤ} |
| 123 | + (_hS : S ⊆ host M) (_hB : B ⊆ host M \ S) (_hP : Pr ⊆ B ×ˢ S) |
| 124 | + (_hD : ∀ p ∈ Pr, ∀ a ∈ S, ∀ a' ∈ S, |
| 125 | + ((a : ℤ) - a').natAbs ≠ ((p.1 : ℤ) - p.2).natAbs) |
| 126 | + (_hg : ∀ p ∈ Pr, ∀ p' ∈ Pr, p ≠ p' → |
| 127 | + ((p.1 : ℤ) - p.2).natAbs = ((p'.1 : ℤ) - p'.2).natAbs → |
| 128 | + (p'.1 : ℤ) = iso (g p.1) p.2 ∧ (p'.2 : ℤ) = iso (g p.1) p.1), |
| 129 | + ∑ x ∈ B, ∑ a ∈ S, score P (coord M x) (coord M a) (g x).1 (isoShift M (g x)) ≤ |
| 130 | + missingWeight M S + kernel 0 * ((B ×ˢ S) \ Pr).card |
| 131 | + |
| 132 | +/-- The statement of the missing-energy lemma for the kernel (1). -/ |
| 133 | +def MissingEnergy : Prop := |
| 134 | + ∀ {M : ℕ} {S : Finset ℕ} (_hM : 0 < M) (_hS : S ⊆ host M) (_hsid : IsSidon (S : Set ℕ)), |
| 135 | + 2 * missingWeight M S + ∑ a ∈ S, ∑ a' ∈ S, kernel (coord M a - coord M a') ≤ |
| 136 | + (M : ℝ) / 32 + S.card * kernel 0 |
| 137 | + |
| 138 | +/-- The grid inequality (6) for the table `P`: every nonnegative node mass of total at |
| 139 | +least `31 − 10⁻⁵`, every outsider node `i` and every integer isometry `g` with `g(i)` in the |
| 140 | +host. The note certifies `32 + 1/250`; the cover needs only `32 + 2/1000` (its error is |
| 141 | +`1024·W(0)·367/2^30 < 0.001465`). The exhaustive replay `verify_k3_all32.log` finds the |
| 142 | +least certified value `32.025136`, so a compact certificate has a slack of `0.023`. -/ |
| 143 | +def GridLower (P : Allocation) : Prop := |
| 144 | + ∀ (u : ℤ → ℝ), (∀ j ∈ Icc (0 : ℤ) 512, 0 ≤ u j) → |
| 145 | + 31 - 1 / 10 ^ 5 ≤ ∑ j ∈ Icc (0 : ℤ) 512, u j → |
| 146 | + ∀ i ∈ Icc (0 : ℤ) 512, ∀ g : Bool × ℤ, iso g i ∈ Icc (0 : ℤ) 512 → |
| 147 | + 32 + 2 / 1000 < |
| 148 | + ∑ j ∈ Icc (0 : ℤ) 512, ∑ j' ∈ Icc (0 : ℤ) 512, u j * u j' * gridWeight (j - j') + |
| 149 | + 2 * sCoef * ∑ j ∈ Icc (0 : ℤ) 512, u j * nodeScore P i g j |
| 150 | + |
| 151 | +/-- The statement of the seed lower bound (2), with `1/250` weakened to `2/1000`. -/ |
| 152 | +def SeedLower (P : Allocation) : Prop := |
| 153 | + ∀ {ι : Type} (S : Finset ι) (y : ι → ℝ) {w : ℝ} (_hw : 0 ≤ w) |
| 154 | + (_hy : ∀ a ∈ S, y a ∈ Set.Ioo (0 : ℝ) 32) (_hmass : 31 - 1 / 10 ^ 5 ≤ S.card * w) |
| 155 | + {t : ℝ} (_ht : t ∈ Set.Ioo (0 : ℝ) 32) (neg : Bool) (r : ℝ) |
| 156 | + (_hgt : isoR neg r t ∈ Set.Icc (0 : ℝ) 32), |
| 157 | + 32 + 2 / 1000 < |
| 158 | + w ^ 2 * ∑ a ∈ S, ∑ a' ∈ S, kernel (y a - y a') + |
| 159 | + 2 * sCoef * w * ∑ a ∈ S, score P t (y a) neg r |
| 160 | + |
| 161 | +/-- The conclusion of Theorem 1 of the note at `R = 32`: the two-stage cover with members |
| 162 | +of size at most `(1 + Kτ)m`, `K = 5.998`, and the count of the 102/103 cover. -/ |
| 163 | +def Cover75 : Prop := |
| 164 | + ∀ {M : ℕ}, (2 : ℝ) ^ 240 ≤ Real.sqrt M → |
| 165 | + ∃ 𝒞 : Finset (Finset ℕ), |
| 166 | + (𝒞.card : ℝ) ≤ Real.exp (coverLog M tau + recordLog (Real.sqrt M)) ∧ |
| 167 | + (∀ C ∈ 𝒞, C ⊆ host M ∧ (C.card : ℝ) ≤ (1 + K * tau) * Real.sqrt M) ∧ |
| 168 | + ∀ S ⊆ host M, IsSidon (S : Set ℕ) → seedSize M tau ≤ S.card → ∃ C ∈ 𝒞, S ⊆ C |
| 169 | + |
| 170 | +/- ## Stage 2: `74/75` for `N ≥ 2^720` -/ |
| 171 | + |
| 172 | +/-- `δ = 0.03596`. -/ |
| 173 | +def delta : unitInterval := ⟨3596 / 10 ^ 5, by constructor <;> norm_num⟩ |
| 174 | + |
| 175 | +/-- `η = 10⁻⁹`: the slack of the host size. -/ |
| 176 | +def eta : ℝ := 1 / 10 ^ 9 |
| 177 | + |
| 178 | +/-- The statement of the pair tail: `Erdos530Gap78.PairTail78` with the width `1 + Kτ`, |
| 179 | +`K = 5.998`, and `δ = 0.03596`. -/ |
| 180 | +def PairTail75 : Prop := |
| 181 | + ∀ {M : ℕ} (_hm : (2 : ℝ) ^ 360 ≤ Real.sqrt M) {α n : ℕ} |
| 182 | + (_hα : (α : ℝ) ≤ (1 + 52 * Real.sqrt M ^ (-(1 / 8 : ℝ))) * Real.sqrt M) |
| 183 | + (_hn : (n : ℝ) ≤ (1 + K * tau) * Real.sqrt M) |
| 184 | + (_hsize : ∀ lam : ℝ, 4 / 10 ^ 6 ≤ lam → lam ≤ 1 / 100 → |
| 185 | + (1 - lam) * Real.sqrt M ≤ α → (n : ℝ) < (1 + 96 * lam) * Real.sqrt M), |
| 186 | + let q := 1 - (delta : ℝ) |
| 187 | + let A := 1 - q + q * tilt |
| 188 | + let B := (1 - q) ^ 2 + (1 - (1 - q) ^ 2) * tilt |
| 189 | + Real.exp (coverLog M tau + recordLog (Real.sqrt M) + refinedLog (Real.sqrt M)) * |
| 190 | + (tilt ^ (-((seedSize M tau : ℝ) - 64 * Real.sqrt M ^ (27 / 32 : ℝ))) * |
| 191 | + (A ^ 2 / B) ^ α * (B / A) ^ n) < 1 / 4 |
| 192 | + |
| 193 | +/- ## Stage 3: the threshold `2^512` -/ |
| 194 | + |
| 195 | +/-- The normalised log count allowed for the three-pass outer cover at `m ≥ 2^256` |
| 196 | +(`upper-smaller-k3/NOTES.md` §4 bounds the outer transcripts together with the refined pairs |
| 197 | +and the factor `M + 1` by `1.4012·10⁻⁹`). -/ |
| 198 | +def outerRate : ℝ := 14012 / 10 ^ 13 |
| 199 | + |
| 200 | +/-- The conclusion of the three-pass cover of `upper-threshold-k7/NOTES.md` §1 with the last |
| 201 | +pass tested at `t = s/32`, `s = 6.997` (`upper-smaller-k3/NOTES.md` §4): members of size at |
| 202 | +most `a·m`, `a < 1.187406386 < 1 + Kτ`. -/ |
| 203 | +def Cover75At512 : Prop := |
| 204 | + ∀ {M : ℕ}, (2 : ℝ) ^ 256 ≤ Real.sqrt M → |
| 205 | + ∃ 𝒞 : Finset (Finset ℕ), |
| 206 | + (𝒞.card : ℝ) ≤ Real.exp (outerRate * Real.sqrt M) ∧ |
| 207 | + (∀ C ∈ 𝒞, C ⊆ host M ∧ (C.card : ℝ) ≤ (1 + K * tau) * Real.sqrt M) ∧ |
| 208 | + ∀ S ⊆ host M, IsSidon (S : Set ℕ) → seedSize M tau ≤ S.card → ∃ C ∈ 𝒞, S ⊆ C |
| 209 | + |
| 210 | +/-- The statement of the pair tail at `m ≥ 2^256` for the three-pass count. -/ |
| 211 | +def PairTail75At512 : Prop := |
| 212 | + ∀ {M : ℕ} (_hm : (2 : ℝ) ^ 256 ≤ Real.sqrt M) {α n : ℕ} |
| 213 | + (_hα : (α : ℝ) ≤ (1 + 52 * Real.sqrt M ^ (-(1 / 8 : ℝ))) * Real.sqrt M) |
| 214 | + (_hn : (n : ℝ) ≤ (1 + K * tau) * Real.sqrt M) |
| 215 | + (_hsize : ∀ lam : ℝ, 4 / 10 ^ 6 ≤ lam → lam ≤ 1 / 100 → |
| 216 | + (1 - lam) * Real.sqrt M ≤ α → (n : ℝ) < (1 + 96 * lam) * Real.sqrt M), |
| 217 | + let q := 1 - (delta : ℝ) |
| 218 | + let A := 1 - q + q * tilt |
| 219 | + let B := (1 - q) ^ 2 + (1 - (1 - q) ^ 2) * tilt |
| 220 | + Real.exp (outerRate * Real.sqrt M + refinedLog (Real.sqrt M)) * |
| 221 | + (tilt ^ (-((seedSize M tau : ℝ) - 64 * Real.sqrt M ^ (27 / 32 : ℝ))) * |
| 222 | + (A ^ 2 / B) ^ α * (B / A) ^ n) < 1 / 4 |
| 223 | + |
| 224 | +end |
| 225 | + |
| 226 | +end ErdosSwarm.Erdos530Gap75 |