| | @@ -1,5 +1,6 @@ |
| 1 | 1 | import ErdosSwarm.Erdos530BoxOccupancy |
| 2 | 2 | import ErdosSwarm.Erdos530DigitLevel |
| 3 | +import ErdosSwarm.Erdos530ParabolaConcentration |
| 3 | 4 | import ErdosSwarm.Erdos530PrimeWindowOccupancy |
| 4 | 5 | |
| 5 | 6 | /-! |
| | @@ -10,7 +11,9 @@ of size greater than `(63/100) √N` for all sufficiently large dimensions. |
| 10 | 11 | Here `N` counts the level together with the two progressions at scale `4 ^ r`. |
| 11 | 12 | The dimension threshold works for every choice among tied levels. This is |
| 12 | 13 | Theorem 2 of `experiments/erdos530/lower-middle-energy2/box-occupancy/POISSON.md`. |
| 13 | | −The triple-span bound also gives the coefficient `11/20`. |
| 14 | +Uniform sampling of the plane map, slope and intercept attains the same strict |
| 15 | +bound with probability tending to one. The triple-span bound also gives the |
| 16 | +coefficient `11/20`. |
| 14 | 17 | -/ |
| 15 | 18 | |
| 16 | 19 | namespace ErdosSwarm.Erdos530DigitLevel |
| | @@ -196,4 +199,157 @@ theorem eventually_exists_sidon_subset_of_max_digitLevel_63_div_100 : |
| 196 | 199 | exact ⟨S, hS, hsid, |
| 197 | 200 | (sqrt_lt_of_augmentation hn hN (by norm_num) (by norm_num) (by norm_num)).trans hlevel⟩ |
| 198 | 201 | |
| 202 | +open Erdos530ParabolaConcentration Erdos530ParabolaSlice |
| 203 | + |
| 204 | +/-- Read the base-16 digits of an integer, reduce them modulo the prime and |
| 205 | +apply the sampled linear map. -/ |
| 206 | +def projectLevelDigits {r p : ℕ} [Fact p.Prime] |
| 207 | + (L : (Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p) (n : ℕ) : ZMod p × ZMod p := |
| 208 | + L fun i => ((n / 16 ^ (i : ℕ) % 16 : ℕ) : ZMod p) |
| 209 | + |
| 210 | +private theorem digit_at_encoding {r : ℕ} (v : Fin r → ℕ) (hv : ∀ i, v i < 16) (i : Fin r) : |
| 211 | + Behrend.map 16 v / 16 ^ (i : ℕ) % 16 = v i := by |
| 212 | + induction r with |
| 213 | + | zero => exact Fin.elim0 i |
| 214 | + | succ r ih => |
| 215 | + refine Fin.cases ?_ (fun j => ?_) i |
| 216 | + · simp only [Fin.val_zero, pow_zero, Nat.div_one, Behrend.map_mod, Nat.mod_eq_of_lt (hv 0)] |
| 217 | + · have hdiv : Behrend.map 16 v / 16 = Behrend.map 16 (v ∘ Fin.succ) := by |
| 218 | + rw [Behrend.map_succ', Nat.add_mul_div_right _ _ (by decide), Nat.div_eq_of_lt (hv 0), |
| 219 | + Nat.zero_add] |
| 220 | + rw [Fin.val_succ, pow_succ', ← Nat.div_div_eq_div_mul, hdiv] |
| 221 | + exact ih (v ∘ Fin.succ) (fun j => hv j.succ) j |
| 222 | + |
| 223 | +private theorem projectLevelDigits_encode {r p : ℕ} [Fact p.Prime] |
| 224 | + (L : (Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p) {v : Fin r → ℕ} |
| 225 | + (hv : v ∈ Behrend.box r 8) : |
| 226 | + projectLevelDigits L (Behrend.map 16 v) = L (fun i => (v i : ZMod p)) := by |
| 227 | + unfold projectLevelDigits |
| 228 | + apply congrArg L |
| 229 | + funext i |
| 230 | + rw [digit_at_encoding v (fun j => (Behrend.mem_box.mp hv j).trans (by decide)) i] |
| 231 | + |
| 232 | +/-- Every sample in odd characteristic has Sidon representatives in the |
| 233 | +integer level, with a bijection onto precisely the slice of that sample. -/ |
| 234 | +theorem exists_sidon_representatives_digitLevel {r t p : ℕ} [Fact p.Prime] (hp : p ≠ 2) |
| 235 | + (u : ParabolaSample r p) : |
| 236 | + ∃ S ⊆ digitLevel r t, IsSidon (S : Set ℕ) ∧ |
| 237 | + Set.BijOn (projectLevelDigits u.1) (S : Set ℕ) (projectedSlice (levelRows r t) u) ∧ |
| 238 | + S.card = (projectedSlice (levelRows r t) u).card := by |
| 239 | + let g := projectLevelDigits u.1 |
| 240 | + have hg {v : Fin r → ℕ} (hv : v ∈ Behrend.sphere r 8 t) : |
| 241 | + g (Behrend.map 16 v) = u.1 (fun i => (v i : ZMod p)) := |
| 242 | + projectLevelDigits_encode u.1 (Behrend.sphere_subset_box hv) |
| 243 | + have himage : (digitLevel r t).image g = ((levelRows r t).image (modRow p)).image u.1 := by |
| 244 | + rw [digitLevel, image_image, image_image] |
| 245 | + ext y |
| 246 | + constructor |
| 247 | + · rintro hy |
| 248 | + obtain ⟨v, hv, rfl⟩ := mem_image.mp hy |
| 249 | + let row (i) : Fin 8 := ⟨v i, Behrend.mem_box.mp (Behrend.sphere_subset_box hv) i⟩ |
| 250 | + exact mem_image.mpr ⟨row, mem_filter.mpr ⟨mem_univ _, (mem_filter.mp hv).2⟩, (hg hv).symm⟩ |
| 251 | + · rintro hy |
| 252 | + obtain ⟨row, hrow, rfl⟩ := mem_image.mp hy |
| 253 | + have hv : (fun i => (row i).val) ∈ Behrend.sphere r 8 t := mem_filter.mpr |
| 254 | + ⟨Behrend.mem_box.mpr fun i => (row i).isLt, (mem_filter.mp hrow).2⟩ |
| 255 | + exact mem_image.mpr ⟨_, hv, hg hv⟩ |
| 256 | + have hadd : ∀ a ∈ digitLevel r t, ∀ b ∈ digitLevel r t, ∀ c ∈ digitLevel r t, |
| 257 | + ∀ d ∈ digitLevel r t, a + b = c + d → g a + g b = g c + g d := by |
| 258 | + intro a ha b hb c hc d hd heq |
| 259 | + simp only [digitLevel, mem_image] at ha hb hc hd |
| 260 | + obtain ⟨v, hv, rfl⟩ := ha |
| 261 | + obtain ⟨w, hw, rfl⟩ := hb |
| 262 | + obtain ⟨x, hx, rfl⟩ := hc |
| 263 | + obtain ⟨y, hy, rfl⟩ := hd |
| 264 | + have h := digit_sums_eq (Behrend.sphere_subset_box hv) (Behrend.sphere_subset_box hw) |
| 265 | + (Behrend.sphere_subset_box hx) (Behrend.sphere_subset_box hy) heq |
| 266 | + rw [hg hv, hg hw, hg hx, hg hy, ← map_add, ← map_add] |
| 267 | + apply congrArg u.1 |
| 268 | + funext i |
| 269 | + simpa only [Pi.add_apply, Nat.cast_add] using congrArg (Nat.cast (R := ZMod p)) (congrFun h i) |
| 270 | + obtain ⟨S, hS, hsid, himg, hinj, hcard⟩ := |
| 271 | + exists_sidon_representatives_parabolaSlice (Erdos530PrimeField.two_ne_zero_zmod hp) |
| 272 | + (digitLevel r t) g hadd u.2 |
| 273 | + rw [himage] at himg hcard |
| 274 | + refine ⟨S, hS, hsid, ?_, hcard⟩ |
| 275 | + have himg' : S.image g = projectedSlice (levelRows r t) u := himg |
| 276 | + rw [← himg', coe_image] |
| 277 | + exact hinj.bijOn_image |
| 278 | + |
| 279 | +/-- Samples whose particular parabola slice has a Sidon lift exceeding |
| 280 | +`(63/100) √N`, with `N` counting the augmented level. -/ |
| 281 | +noncomputable def successfulLevelSamples (r t p : ℕ) [Fact p.Prime] |
| 282 | + [Fintype ((Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p)] : Finset (ParabolaSample r p) := by |
| 283 | + classical |
| 284 | + exact univ.filter fun u => ∃ S ⊆ digitLevel r t, IsSidon (S : Set ℕ) ∧ |
| 285 | + Set.BijOn (projectLevelDigits u.1) (S : Set ℕ) (projectedSlice (levelRows r t) u) ∧ |
| 286 | + (63 / 100 : ℝ) * Real.sqrt (augmentedDigitLevel r t).card < S.card |
| 287 | + |
| 288 | +private theorem large_slice_of_close {n p H : ℕ} {M a : ℝ} (hp : 0 < (p : ℝ)) |
| 289 | + (hhi : (p : ℝ) ≤ 15 / 16 * Real.sqrt n) (hmean : (253 / 400 : ℝ) * p * Real.sqrt n < M) |
| 290 | + (hM : |M / (p : ℝ) ^ 2 - a| < 1 / 2000) (hH : |(H : ℝ) / p - a| < 1 / 2000) : |
| 291 | + (1263 / 2000 : ℝ) * Real.sqrt n < H := by |
| 292 | + have hlower : 253 / 400 * Real.sqrt n < M / p := |
| 293 | + (lt_div_iff₀ hp).2 (by linarith only [hmean]) |
| 294 | + have herr : M / (p : ℝ) ^ 2 - 1 / 1000 < (H : ℝ) / p := by |
| 295 | + linarith only [(abs_lt.mp hM).2, (abs_lt.mp hH).1] |
| 296 | + have hshift := mul_lt_mul_of_pos_right herr hp |
| 297 | + rw [sub_mul, show M / (p : ℝ) ^ 2 * p = M / p by field_simp, div_mul_cancel₀ _ hp.ne'] at hshift |
| 298 | + linarith only [hlower, hshift, hhi, Real.sqrt_nonneg (n : ℝ)] |
| 299 | + |
| 300 | +/-- With probability tending to one, the sampled slice lifts bijectively to |
| 301 | +a Sidon subset of size strictly greater than `(63/100) √N`. One dimension |
| 302 | +threshold works for all maximizing levels and all primes in the closed window. -/ |
| 303 | +theorem eventually_fraction_successfulLevelSamples_gt {ε : ℝ} (hε : 0 < ε) : |
| 304 | + ∀ᶠ r : ℕ in atTop, ∀ t : ℕ, (∀ s, (digitLevel r s).card ≤ (digitLevel r t).card) → |
| 305 | + ∀ (p : ℕ) [Fact p.Prime] [Fintype ((Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p)], |
| 306 | + (17 / 20 : ℝ) * Real.sqrt (digitLevel r t).card ≤ p → |
| 307 | + (p : ℝ) ≤ 15 / 16 * Real.sqrt (digitLevel r t).card → |
| 308 | + 1 - ε < ((successfulLevelSamples r t p).card : ℝ) / Fintype.card (ParabolaSample r p) := by |
| 309 | + classical |
| 310 | + have hB : (0 : ℝ) < 2 := by norm_num |
| 311 | + have hδ : (0 : ℝ) < 1 / 2000 := by norm_num |
| 312 | + filter_upwards [eventually_ge_atTop 19, Erdos530DigitMoments.eventually_lt_prime 2 hB, |
| 313 | + eventually_lt_meanImageSize, Erdos530PoissonOccupancy.eventually_meanImageSize_div_close hB hδ, |
| 314 | + eventually_sliceFraction_concentration hB hε hδ] with r hr hprime hmean happrox hconc |
| 315 | + intro t hmax p hp maps hlo hhi |
| 316 | + let X := levelRows r t |
| 317 | + have hcard : X.card = (digitLevel r t).card := card_levelRows r t |
| 318 | + have hdense := pow_eight_le_of_max hmax |
| 319 | + rw [← hcard] at hdense hlo hhi |
| 320 | + have hp' : (0 : ℝ) < p := by exact_mod_cast hp.out.pos |
| 321 | + have hρ : (X.card : ℝ) / (p : ℝ) ^ 2 ≤ 2 := by |
| 322 | + apply (div_le_iff₀ (sq_pos_of_pos hp')).2 |
| 323 | + have hsq := pow_le_pow_left₀ (mul_nonneg (by norm_num) (Real.sqrt_nonneg _)) hlo 2 |
| 324 | + rw [mul_pow, Real.sq_sqrt (Nat.cast_nonneg _)] at hsq |
| 325 | + linarith only [hsq, Nat.cast_nonneg (α := ℝ) X.card] |
| 326 | + have hodd : p ≠ 2 := (hprime p X hdense hρ).ne' |
| 327 | + obtain ⟨hsize, hN⟩ := card_bounds_of_max hr hmax |
| 328 | + rw [← hcard] at hsize hN |
| 329 | + have hn := (pow_pos (by decide : 0 < (4 : ℕ)) r).trans_le hsize |
| 330 | + have hgap : (63 / 100 : ℝ) * Real.sqrt (augmentedDigitLevel r t).card < |
| 331 | + (1263 / 2000 : ℝ) * Real.sqrt X.card := |
| 332 | + sqrt_lt_of_augmentation hn hN (by norm_num) (by norm_num) (by norm_num) |
| 333 | + let a := 1 - Real.exp (-((X.card : ℝ) / (p : ℝ) ^ 2)) |
| 334 | + let bad := univ.filter fun u : ParabolaSample r p => 1 / 2000 ≤ |sliceFraction X u - a| |
| 335 | + let good := successfulLevelSamples r t p |
| 336 | + have hbad : (bad.card : ℝ) / Fintype.card (ParabolaSample r p) < ε := (hconc p X hdense hρ).2 |
| 337 | + have hcover : goodᶜ ⊆ bad := by |
| 338 | + intro u hu |
| 339 | + by_contra h |
| 340 | + have hclose : |sliceFraction X u - a| < 1 / 2000 := by simpa [bad] using h |
| 341 | + have hlarge := large_slice_of_close hp' hhi (hmean p X hdense hlo hhi) |
| 342 | + (happrox p X hdense hρ) (H := (projectedSlice X u).card) hclose |
| 343 | + obtain ⟨S, hS, hsid, hbij, hc⟩ := exists_sidon_representatives_digitLevel (t := t) hodd u |
| 344 | + apply (mem_compl.mp hu) |
| 345 | + exact mem_filter.mpr ⟨mem_univ _, S, hS, hsid, hbij, by rw [hc]; exact hgap.trans hlarge⟩ |
| 346 | + have htotal : (0 : ℝ) < Fintype.card (ParabolaSample r p) := by exact_mod_cast Fintype.card_pos |
| 347 | + have hcount : Fintype.card (ParabolaSample r p) ≤ good.card + bad.card := |
| 348 | + (card_add_card_compl good).symm.le.trans (Nat.add_le_add_left (card_le_card hcover) _) |
| 349 | + apply (lt_div_iff₀ htotal).2 |
| 350 | + have hcount' : (Fintype.card (ParabolaSample r p) : ℝ) ≤ good.card + (bad.card : ℝ) := by |
| 351 | + exact_mod_cast hcount |
| 352 | + change (1 - ε) * Fintype.card (ParabolaSample r p) < (good.card : ℝ) |
| 353 | + linarith only [hcount', (div_lt_iff₀ htotal).mp hbad] |
| 354 | + |
| 199 | 355 | end ErdosSwarm.Erdos530DigitLevel |