| | @@ -0,0 +1,98 @@ |
| 1 | +import ErdosSwarm.Erdos30FactorialPrimeInterval |
| 2 | +import ErdosSwarm.Erdos530BonferroniInterval |
| 3 | +import ErdosSwarm.Erdos530PoissonOccupancy |
| 4 | +import Mathlib.Algebra.Order.BigOperators.Expect |
| 5 | + |
| 6 | +/-! |
| 7 | +# Mean image size in the prime window for Erdős problem 530 |
| 8 | + |
| 9 | +For every sufficiently dense sample of the eight-digit box in large dimension, |
| 10 | +each prime between `(17/20) √n` and `(15/16) √n` gives mean image size greater |
| 11 | +than `(253/400) p √n`. Here `n` is the sample size and the mean is over all |
| 12 | +linear maps to the plane. This is the occupancy estimate used in §3 of |
| 13 | +`experiments/erdos530/lower-middle-energy2/box-occupancy/POISSON.md`. |
| 14 | +-/ |
| 15 | + |
| 16 | +namespace ErdosSwarm.Erdos530PrimeWindowOccupancy |
| 17 | + |
| 18 | +open Filter Finset Erdos530Bonferroni Erdos530DigitMoments Erdos530DigitTuple |
| 19 | + Erdos530PoissonOccupancy |
| 20 | + |
| 21 | +/-- Every sufficiently large cardinality admits a prime in the window above any fixed cutoff. -/ |
| 22 | +theorem eventually_exists_prime_in_window (cutoff : ℕ) : |
| 23 | + ∀ᶠ n : ℕ in atTop, ∃ p : ℕ, p.Prime ∧ cutoff < p ∧ |
| 24 | + (17 / 20 : ℝ) * Real.sqrt n ≤ p ∧ (p : ℝ) ≤ 15 / 16 * Real.sqrt n := by |
| 25 | + have hs : Tendsto (fun n : ℕ => Real.sqrt n) atTop atTop := |
| 26 | + Real.tendsto_sqrt_atTop.comp tendsto_natCast_atTop_atTop |
| 27 | + have hy := hs.const_mul_atTop (by norm_num : (0 : ℝ) < 15 / 16) |
| 28 | + filter_upwards [hy.eventually Erdos30.eventually_exists_prime_457_div_500, |
| 29 | + hs.eventually_ge_atTop (2 * (cutoff : ℝ) + 1)] with n ⟨p, hp, hlo, hhi⟩ hcut |
| 30 | + change 457 / 500 * (15 / 16 * Real.sqrt n) < (p : ℝ) at hlo |
| 31 | + change 2 * (cutoff : ℝ) + 1 ≤ Real.sqrt n at hcut |
| 32 | + refine ⟨p, hp, ?_, ?_, hhi⟩ |
| 33 | + · exact_mod_cast (show (cutoff : ℝ) < p by linarith [Nat.cast_nonneg (α := ℝ) cutoff]) |
| 34 | + · linarith [Real.sqrt_nonneg (n : ℝ)] |
| 35 | + |
| 36 | +/-- One dimension threshold gives the strict lower bound on the mean image size |
| 37 | +for every dense sample and every prime in the closed window. -/ |
| 38 | +theorem eventually_lt_meanImageSize : |
| 39 | + ∀ᶠ r : ℕ in atTop, ∀ (p : ℕ) [Fact p.Prime] |
| 40 | + [Fintype ((Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p)] (X : Finset (Fin r → Fin 8)), |
| 41 | + 8 ^ r ≤ (49 * r + 1) * X.card → |
| 42 | + (17 / 20 : ℝ) * Real.sqrt X.card ≤ p → (p : ℝ) ≤ 15 / 16 * Real.sqrt X.card → |
| 43 | + (253 / 400 : ℝ) * p * Real.sqrt X.card < |
| 44 | + meanImageSize (ZMod p) (ZMod p × ZMod p) (X.image (modRow p)) := by |
| 45 | + filter_upwards [eventually_bonferroniSum_close 6 (by norm_num : (0 : ℝ) < 2) |
| 46 | + (by norm_num : (0 : ℝ) < 1 / 400)] with r herr p hp maps X hX hlo hhi |
| 47 | + let s := Real.sqrt X.card |
| 48 | + let x := (p : ℝ) / s |
| 49 | + let ρ := (X.card : ℝ) / (p : ℝ) ^ 2 |
| 50 | + let M := meanImageSize (ZMod p) (ZMod p × ZMod p) (X.image (modRow p)) |
| 51 | + have hp' : (0 : ℝ) < p := by exact_mod_cast hp.out.pos |
| 52 | + have hs : 0 < s := by dsimp [s]; linarith only [hp', hhi] |
| 53 | + have hx : 0 < x := div_pos hp' hs |
| 54 | + have hxlo : 17 / 20 ≤ x := (le_div_iff₀ hs).2 hlo |
| 55 | + have hxhi : x ≤ 15 / 16 := (div_le_iff₀ hs).2 hhi |
| 56 | + have hρ : ρ = 1 / x ^ 2 := by |
| 57 | + dsimp [ρ, x, s] |
| 58 | + rw [div_pow, div_div_eq_mul_div, one_mul, Real.sq_sqrt (Nat.cast_nonneg _)] |
| 59 | + have hρle : ρ ≤ 2 := by |
| 60 | + rw [hρ, div_le_iff₀ (sq_pos_of_pos hx)] |
| 61 | + nlinarith only [sq_nonneg (x - 17 / 20), hxlo] |
| 62 | + have hcert := lt_mul_bonferroniSum_six hxlo hxhi |
| 63 | + rw [← hρ] at hcert |
| 64 | + have happrox := (abs_lt.mp (herr p X hX hρle)).1 |
| 65 | + have hlower : bonferroniSum 6 (normalizedMoment p X) ≤ M / (p : ℝ) ^ 2 := by |
| 66 | + rw [bonferroniSum_normalizedMoment (maps := maps)] |
| 67 | + exact div_le_div_of_nonneg_right |
| 68 | + (bonferroniSum_even_le_meanImageSize (ZMod p) (ZMod p × ZMod p) _ 3) (sq_nonneg _) |
| 69 | + have hscaled : 253 / 400 < x * (M / (p : ℝ) ^ 2) := calc |
| 70 | + (253 / 400 : ℝ) ≤ 127 / 200 - x * (1 / 400) := by linarith only [hxhi] |
| 71 | + _ < x * bonferroniSum 6 (fun j => ρ ^ j / j.factorial) - x * (1 / 400) := |
| 72 | + sub_lt_sub_right hcert _ |
| 73 | + _ = x * (bonferroniSum 6 (fun j => ρ ^ j / j.factorial) - 1 / 400) := by ring |
| 74 | + _ ≤ x * (M / (p : ℝ) ^ 2) := by |
| 75 | + apply mul_le_mul_of_nonneg_left _ hx.le |
| 76 | + linarith only [happrox, hlower] |
| 77 | + have hid : x * (M / (p : ℝ) ^ 2) = M / ((p : ℝ) * s) := by |
| 78 | + dsimp [x] |
| 79 | + field_simp |
| 80 | + rw [hid] at hscaled |
| 81 | + simpa only [mul_assoc] using (lt_div_iff₀ (mul_pos hp' hs)).mp hscaled |
| 82 | + |
| 83 | +/-- Some plane map has image size strictly above the same threshold as the mean. -/ |
| 84 | +theorem eventually_exists_large_image : |
| 85 | + ∀ᶠ r : ℕ in atTop, ∀ (p : ℕ) [Fact p.Prime] (X : Finset (Fin r → Fin 8)), |
| 86 | + 8 ^ r ≤ (49 * r + 1) * X.card → |
| 87 | + (17 / 20 : ℝ) * Real.sqrt X.card ≤ p → (p : ℝ) ≤ 15 / 16 * Real.sqrt X.card → |
| 88 | + ∃ L : (Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p, |
| 89 | + (253 / 400 : ℝ) * p * Real.sqrt X.card < ((X.image (modRow p)).image L).card := by |
| 90 | + classical |
| 91 | + filter_upwards [eventually_lt_meanImageSize] with r hr p hp X hX hlo hhi |
| 92 | + let := FunLike.fintype ((Fin r → ZMod p) →ₗ[ZMod p] ZMod p × ZMod p) |
| 93 | + have hmean := hr p X hX hlo hhi |
| 94 | + rw [meanImageSize, ← Fintype.expect_eq_sum_div_card] at hmean |
| 95 | + obtain ⟨L, _, hL⟩ := Finset.exists_lt_of_lt_expect univ_nonempty hmean |
| 96 | + exact ⟨L, hL⟩ |
| 97 | + |
| 98 | +end ErdosSwarm.Erdos530PrimeWindowOccupancy |