| | @@ -0,0 +1,101 @@ |
| 1 | +import Mathlib.NumberTheory.ArithmeticFunction.Misc |
| 2 | +import Mathlib.NumberTheory.Chebyshev |
| 3 | + |
| 4 | +/-! |
| 5 | +# Chebyshev's factorial ratio for Erdős Problem 30 |
| 6 | + |
| 7 | +The logarithm of `(30n)! n! / ((15n)! (10n)! (6n)!)` counts the von Mangoldt |
| 8 | +weight of a subset of the integers up to `30n`. This subset includes every |
| 9 | +integer in `(5n, 30n]`. The bounds give a finite input to the prime-power |
| 10 | +interval argument for the Sidon lower bound. |
| 11 | +-/ |
| 12 | + |
| 13 | +namespace ErdosSwarm.Erdos30 |
| 14 | + |
| 15 | +open Finset ArithmeticFunction |
| 16 | + |
| 17 | +/-- The logarithm of Chebyshev's factorial ratio at the scale `30n`. -/ |
| 18 | +noncomputable def chebyshevLogRatio (n : ℕ) : ℝ := |
| 19 | + Real.log ((30 * n).factorial : ℝ) + Real.log (n.factorial : ℝ) - |
| 20 | + Real.log ((15 * n).factorial : ℝ) - Real.log ((10 * n).factorial : ℝ) - |
| 21 | + Real.log ((6 * n).factorial : ℝ) |
| 22 | + |
| 23 | +/-- Expand a log factorial on any common summation interval ending at or above `m`. -/ |
| 24 | +private theorem log_factorial_eq_sum {m M : ℕ} (hm : m ≤ M) : |
| 25 | + Real.log (m.factorial : ℝ) = ∑ d ∈ Ioc 0 M, Λ d * (↑(m / d) : ℝ) := by |
| 26 | + calc |
| 27 | + Real.log (m.factorial : ℝ) = ∑ i ∈ Ioc 0 m, Real.log (i : ℝ) := by |
| 28 | + rw [← Real.log_prod (fun i hi => Nat.cast_ne_zero.mpr (mem_Ioc.mp hi).1.ne'), |
| 29 | + ← Nat.cast_prod, ← Ico_add_one_add_one_eq_Ioc, zero_add, prod_Ico_id_eq_factorial] |
| 30 | + _ = ∑ d ∈ Ioc 0 m, Λ d * (↑(m / d) : ℝ) := by |
| 31 | + simpa only [vonMangoldt_mul_zeta, log_apply] using sum_Ioc_mul_zeta_eq_sum Λ m |
| 32 | + _ = ∑ d ∈ Ioc 0 M, Λ d * (↑(m / d) : ℝ) := by |
| 33 | + refine sum_subset (Ioc_subset_Ioc_right hm) fun d hd hdm => ?_ |
| 34 | + have hlt : m < d := by |
| 35 | + exact lt_of_not_ge fun h => hdm (mem_Ioc.mpr ⟨(mem_Ioc.mp hd).1, h⟩) |
| 36 | + simp [Nat.div_eq_of_lt hlt] |
| 37 | + |
| 38 | +/-- The coefficient of `Λ d` when `k = 30n / d` is an integer quotient. -/ |
| 39 | +private def weight (k : ℕ) : ℤ := |
| 40 | + (k : ℤ) + ↑(k / 30) - ↑(k / 2) - ↑(k / 3) - ↑(k / 5) |
| 41 | + |
| 42 | +private theorem weight_bounds (k : ℕ) : 0 ≤ weight k ∧ weight k ≤ 1 := by |
| 43 | + have periodic (r q : ℕ) : weight (r + 30 * q) = weight r := by |
| 44 | + unfold weight |
| 45 | + omega |
| 46 | + have reduce := periodic (k % 30) (k / 30) |
| 47 | + rw [Nat.mod_add_div] at reduce |
| 48 | + rw [reduce] |
| 49 | + exact (show ∀ r : Fin 30, 0 ≤ weight r.val ∧ weight r.val ≤ 1 by decide) |
| 50 | + ⟨k % 30, Nat.mod_lt _ (by decide)⟩ |
| 51 | + |
| 52 | +private theorem weight_eq_one {k : ℕ} (hpos : 0 < k) (hlt : k < 6) : weight k = 1 := |
| 53 | + (show ∀ r : Fin 6, 0 < r.val → weight r.val = 1 by decide) ⟨k, hlt⟩ hpos |
| 54 | + |
| 55 | +private theorem chebyshevLogRatio_eq_sum (n : ℕ) : |
| 56 | + chebyshevLogRatio n = ∑ d ∈ Ioc 0 (30 * n), Λ d * (weight (30 * n / d) : ℝ) := by |
| 57 | + unfold chebyshevLogRatio |
| 58 | + rw [log_factorial_eq_sum (le_refl (30 * n)), |
| 59 | + log_factorial_eq_sum (show n ≤ 30 * n by omega), |
| 60 | + log_factorial_eq_sum (show 15 * n ≤ 30 * n by omega), |
| 61 | + log_factorial_eq_sum (show 10 * n ≤ 30 * n by omega), |
| 62 | + log_factorial_eq_sum (show 6 * n ≤ 30 * n by omega), |
| 63 | + ← sum_add_distrib, ← sum_sub_distrib, ← sum_sub_distrib, ← sum_sub_distrib] |
| 64 | + refine sum_congr rfl fun d _ => ?_ |
| 65 | + simp only [weight, Int.cast_sub, Int.cast_add, Int.cast_natCast, |
| 66 | + Nat.div_right_comm (30 * n) d, show 30 * n / 30 = n by omega, |
| 67 | + show 30 * n / 2 = 15 * n by omega, show 30 * n / 3 = 10 * n by omega, |
| 68 | + show 30 * n / 5 = 6 * n by omega] |
| 69 | + ring |
| 70 | + |
| 71 | +/-- All von Mangoldt weight in `(5n, 30n]` occurs in the log factorial ratio. -/ |
| 72 | +theorem psi_sub_le_chebyshevLogRatio (n : ℕ) : |
| 73 | + Chebyshev.psi (30 * (n : ℝ)) - Chebyshev.psi (5 * (n : ℝ)) ≤ chebyshevLogRatio n := by |
| 74 | + have hle : 5 * n ≤ 30 * n := by omega |
| 75 | + calc |
| 76 | + _ = ∑ d ∈ Ioc (5 * n) (30 * n), Λ d := by |
| 77 | + norm_cast |
| 78 | + simp only [Chebyshev.psi, Nat.floor_natCast] |
| 79 | + rw [← sum_Ioc_consecutive (fun d => Λ d) (Nat.zero_le _) hle, add_sub_cancel_left] |
| 80 | + _ = ∑ d ∈ Ioc (5 * n) (30 * n), Λ d * (weight (30 * n / d) : ℝ) := by |
| 81 | + refine sum_congr rfl fun d hd => ?_ |
| 82 | + obtain ⟨hsmall, hlarge⟩ := mem_Ioc.mp hd |
| 83 | + have hdpos : 0 < d := by omega |
| 84 | + have hpos := Nat.div_pos hlarge hdpos |
| 85 | + have hlt : 30 * n / d < 6 := (Nat.div_lt_iff_lt_mul hdpos).mpr (by omega) |
| 86 | + simp [weight_eq_one hpos hlt] |
| 87 | + _ ≤ ∑ d ∈ Ioc 0 (30 * n), Λ d * (weight (30 * n / d) : ℝ) := by |
| 88 | + refine sum_le_sum_of_subset_of_nonneg (Ioc_subset_Ioc_left (Nat.zero_le _)) fun d _ _ => ?_ |
| 89 | + exact mul_nonneg vonMangoldt_nonneg (by exact_mod_cast (weight_bounds (30 * n / d)).1) |
| 90 | + _ = _ := (chebyshevLogRatio_eq_sum n).symm |
| 91 | + |
| 92 | +/-- Each von Mangoldt weight up to `30n` occurs at most once in the log factorial ratio. -/ |
| 93 | +theorem chebyshevLogRatio_le_psi (n : ℕ) : |
| 94 | + chebyshevLogRatio n ≤ Chebyshev.psi (30 * (n : ℝ)) := by |
| 95 | + norm_cast |
| 96 | + rw [chebyshevLogRatio_eq_sum, Chebyshev.psi, Nat.floor_natCast] |
| 97 | + refine sum_le_sum fun d _ => ?_ |
| 98 | + have h : (weight (30 * n / d) : ℝ) ≤ 1 := by exact_mod_cast (weight_bounds _).2 |
| 99 | + simpa only [mul_one] using mul_le_mul_of_nonneg_left h (vonMangoldt_nonneg (n := d)) |
| 100 | + |
| 101 | +end ErdosSwarm.Erdos30 |