| | @@ -0,0 +1,176 @@ |
| 1 | +import ErdosSwarm.Erdos30FactorialWeights |
| 2 | +import Mathlib.Analysis.SpecialFunctions.Log.Basic |
| 3 | +import Mathlib.Data.Finset.NatDivisors |
| 4 | +import Mathlib.Tactic.Linarith |
| 5 | +import Mathlib.Tactic.NormNum |
| 6 | + |
| 7 | +/-! |
| 8 | +# The two factorial rows for the 457/500 interval |
| 9 | + |
| 10 | +The table reproduces the two columns in the |
| 11 | +[coefficient file](../experiments/erdos30/factorial-interval/coefficients.csv). |
| 12 | +For each column, the weighted sum at 27720 is zero. Factoring each scale into primes reduces the strict slope comparison |
| 13 | +to four integer power bounds for the logarithms of 3, 5, 7 and 11 relative to log 2. |
| 14 | +-/ |
| 15 | + |
| 16 | +namespace ErdosSwarm.Erdos30.FactorialInterval |
| 17 | + |
| 18 | +/-- Divisors of 27720 with their coefficients in rows A and B of the interval certificate. -/ |
| 19 | +def rows : List (ℕ × ℤ × ℤ) := |
| 20 | + [(1, 15, 58), (2, -15, -58), (3, -15, -58), (4, 0, 0), |
| 21 | + (5, -15, -58), (6, 15, 58), (7, -15, -58), (8, 0, 0), |
| 22 | + (9, 0, 0), (10, 15, 58), (11, -15, -58), (12, -15, 0), |
| 23 | + (14, 15, 0), (15, 0, 58), (18, -15, -58), (20, 0, -58), |
| 24 | + (21, 15, 58), (22, 0, 58), (24, 15, -58), (28, -15, 58), |
| 25 | + (30, -15, -116), (33, 15, 0), (35, 15, 58), (36, 15, 58), |
| 26 | + (40, -15, 0), (42, -30, -58), (44, 15, -58), (45, -15, 0), |
| 27 | + (55, 25, 58), (56, 5, 0), (60, 15, 58), (63, -10, -58), |
| 28 | + (66, -5, 0), (70, -30, -58), (72, -15, 0), (77, 15, 0), |
| 29 | + (84, 45, -58), (88, -15, 58), (90, 30, 58), (99, -30, 116), |
| 30 | + (105, -15, -174), (110, -15, -174), (120, 10, 58), (126, 15, 174), |
| 31 | + (132, 5, -58), (140, 30, 0), (154, 0, 58), (165, -25, -58), |
| 32 | + (168, -35, 58), (180, -35, -116), (198, 50, -174), (210, 75, 290), |
| 33 | + (220, -25, 232), (231, -30, -116), (252, -20, -216), (264, -25, 100), |
| 34 | + (280, -20, 26), (308, 30, -142), (315, 25, 58), (330, 35, 232), |
| 35 | + (360, 30, -58), (385, -31, -121), (396, -29, 63), (420, -90, -58), |
| 36 | + (440, 35, -116), (462, 20, 106), (495, 35, 116), (504, 40, 100), |
| 37 | + (616, -50, -32), (630, -60, -232), (660, 5, -74), (693, 55, 174), |
| 38 | + (770, 21, 121), (792, 24, -47), (840, 45, -84), (924, -27, 36), |
| 39 | + (990, -123, -174), (1155, 91, 48), (1260, 48, 274), (1320, -10, -116), |
| 40 | + (1386, -44, -100), (1540, -45, -106), (1848, 63, 48), (1980, 82, -10), |
| 41 | + (2310, -101, -328), (2520, -33, 74), (2772, 1, 103), (3080, 50, 77), |
| 42 | + (3465, -68, -159), (3960, 17, -11), (4620, 77, 160), (5544, -31, -120), |
| 43 | + (6930, 151, 199), (9240, -13, -57), (13860, 2, -554), (27720, 86, -278)] |
| 44 | + |
| 45 | +/-- Row A supplies the lower bound for the Chebyshev slope. -/ |
| 46 | +def lowerRow (d : ℕ) : ℤ := ((rows.lookup d).getD (0, 0)).1 |
| 47 | + |
| 48 | +/-- Row B supplies the upper bound for the Chebyshev slope. -/ |
| 49 | +def upperRow (d : ℕ) : ℤ := ((rows.lookup d).getD (0, 0)).2 |
| 50 | + |
| 51 | +/-- Factoring 27720 as 8 · 9 · 5 · 7 · 11 gives exactly the divisors in the table. -/ |
| 52 | +theorem divisors_eq_keys : (27720 : ℕ).divisors = (rows.map Prod.fst).toFinset := by |
| 53 | + rw [show (27720 : ℕ) = 8 * 9 * 5 * 7 * 11 by decide] |
| 54 | + simp only [Nat.divisors_mul] |
| 55 | + decide +kernel |
| 56 | + |
| 57 | +/-- Both coefficients vanish away from the divisors of the period. -/ |
| 58 | +theorem rows_zero_of_not_dvd {d : ℕ} (hd : ¬d ∣ 27720) : |
| 59 | + lowerRow d = 0 ∧ upperRow d = 0 := by |
| 60 | + have hlookup : rows.lookup d = none := by |
| 61 | + refine List.lookup_eq_none_iff.mpr fun row hrow => ?_ |
| 62 | + simp only [bne_iff_ne] |
| 63 | + intro heq |
| 64 | + apply hd |
| 65 | + apply Nat.dvd_of_mem_divisors |
| 66 | + rw [divisors_eq_keys] |
| 67 | + exact List.mem_toFinset.mpr (List.mem_map.mpr ⟨row, hrow, heq.symm⟩) |
| 68 | + simp [lowerRow, upperRow, hlookup] |
| 69 | + |
| 70 | +/-- Row A satisfies the balance hypothesis for the periodic divisor weight. -/ |
| 71 | +theorem lowerRow_balance : factorialWeight 27720 lowerRow 27720 = 0 := by |
| 72 | + rw [factorialWeight, divisors_eq_keys] |
| 73 | + decide +kernel |
| 74 | + |
| 75 | +/-- Row B satisfies the balance hypothesis for the periodic divisor weight. -/ |
| 76 | +theorem upperRow_balance : factorialWeight 27720 upperRow 27720 = 0 := by |
| 77 | + rw [factorialWeight, divisors_eq_keys] |
| 78 | + decide +kernel |
| 79 | + |
| 80 | +/-- The Stirling limit for a balanced row at scale 27720. -/ |
| 81 | +noncomputable def logSlope (c : ℕ → ℤ) : ℝ := |
| 82 | + ∑ d ∈ (27720 : ℕ).divisors, (c d : ℝ) * (27720 / d : ℕ) * Real.log (27720 / d : ℕ) |
| 83 | + |
| 84 | +private def primes : Finset ℕ := {2, 3, 5, 7, 11} |
| 85 | + |
| 86 | +/-- The largest prime exponent in 27720 is three. Count the powers through the cube |
| 87 | +that divide a given scale. Their product is verified in `factor_scales`. -/ |
| 88 | +private def exponent (n p : ℕ) : ℕ := |
| 89 | + ((Finset.Icc 1 3).filter fun j => p ^ j ∣ n).card |
| 90 | + |
| 91 | +private theorem factor_scales : ∀ d ∈ (27720 : ℕ).divisors, |
| 92 | + ∏ p ∈ primes, p ^ exponent (27720 / d) p = 27720 / d := by |
| 93 | + rw [divisors_eq_keys] |
| 94 | + decide +kernel |
| 95 | + |
| 96 | +private def logCoefficient (c : ℕ → ℤ) (p : ℕ) : ℤ := |
| 97 | + ∑ d ∈ (27720 : ℕ).divisors, |
| 98 | + c d * (↑(27720 / d) : ℤ) * (↑(exponent (27720 / d) p) : ℤ) |
| 99 | + |
| 100 | +private theorem logSlope_eq_sum (c : ℕ → ℤ) : |
| 101 | + logSlope c = ∑ p ∈ primes, (logCoefficient c p : ℝ) * Real.log p := by |
| 102 | + have hlog (d : ℕ) (hd : d ∈ (27720 : ℕ).divisors) : |
| 103 | + Real.log (27720 / d : ℕ) = ∑ p ∈ primes, (exponent (27720 / d) p : ℝ) * Real.log p := by |
| 104 | + calc Real.log (27720 / d : ℕ) = |
| 105 | + Real.log (∏ p ∈ primes, (p : ℝ) ^ exponent (27720 / d) p) := by |
| 106 | + exact congrArg Real.log (by exact_mod_cast (factor_scales d hd).symm) |
| 107 | + _ = _ := by |
| 108 | + rw [Real.log_prod (fun p hp => pow_ne_zero _ (by |
| 109 | + simp [primes] at hp |
| 110 | + rcases hp with rfl | rfl | rfl | rfl | rfl <;> norm_num))] |
| 111 | + simp only [Real.log_pow] |
| 112 | + unfold logSlope |
| 113 | + calc _ = ∑ d ∈ (27720 : ℕ).divisors, ∑ p ∈ primes, |
| 114 | + (c d : ℝ) * (27720 / d : ℕ) * (exponent (27720 / d) p : ℝ) * Real.log p := by |
| 115 | + refine Finset.sum_congr rfl fun d hd => ?_ |
| 116 | + rw [hlog d hd, Finset.mul_sum] |
| 117 | + exact Finset.sum_congr rfl fun _ _ => (mul_assoc _ _ _).symm |
| 118 | + _ = _ := by |
| 119 | + rw [Finset.sum_comm] |
| 120 | + simp only [logCoefficient, Int.cast_sum, Int.cast_mul, Int.cast_natCast, Finset.sum_mul] |
| 121 | + |
| 122 | +private theorem logSlope_eq_of_coefficients (c : ℕ → ℤ) (e₂ e₃ e₅ e₇ e₁₁ : ℕ) |
| 123 | + (h : [logCoefficient c 2, logCoefficient c 3, logCoefficient c 5, |
| 124 | + logCoefficient c 7, logCoefficient c 11] = |
| 125 | + [(e₂ : ℤ), e₃, e₅, e₇, e₁₁]) : |
| 126 | + logSlope c = e₂ * Real.log 2 + e₃ * Real.log 3 + e₅ * Real.log 5 + |
| 127 | + e₇ * Real.log 7 + e₁₁ * Real.log 11 := by |
| 128 | + simp only [List.cons.injEq, and_true] at h |
| 129 | + obtain ⟨h₂, h₃, h₅, h₇, h₁₁⟩ := h |
| 130 | + rw [logSlope_eq_sum] |
| 131 | + simp [primes, h₂, h₃, h₅, h₇, h₁₁, add_assoc] |
| 132 | + |
| 133 | +/-- The coefficients of the five prime logarithms in the lower row's Stirling limit. -/ |
| 134 | +theorem logSlope_lowerRow : |
| 135 | + logSlope lowerRow = 148642 * Real.log 2 + 119358 * Real.log 3 + 47870 * Real.log 5 + |
| 136 | + 23933 * Real.log 7 + 15873 * Real.log 11 := by |
| 137 | + simpa only [Nat.cast_ofNat] using logSlope_eq_of_coefficients lowerRow |
| 138 | + 148642 119358 47870 23933 15873 (by |
| 139 | + unfold logCoefficient |
| 140 | + rw [divisors_eq_keys] |
| 141 | + decide +kernel) |
| 142 | + |
| 143 | +/-- The coefficients of the five prime logarithms in the upper row's Stirling limit. -/ |
| 144 | +theorem logSlope_upperRow : |
| 145 | + logSlope upperRow = 673864 * Real.log 2 + 359673 * Real.log 3 + 188925 * Real.log 5 + |
| 146 | + 149604 * Real.log 7 + 82808 * Real.log 11 := by |
| 147 | + simpa only [Nat.cast_ofNat] using logSlope_eq_of_coefficients upperRow |
| 148 | + 673864 359673 188925 149604 82808 (by |
| 149 | + unfold logCoefficient |
| 150 | + rw [divisors_eq_keys] |
| 151 | + decide +kernel) |
| 152 | + |
| 153 | +private theorem log_product_bound {p q a b : ℕ} (hp : 0 < p) (h : p ^ a ≤ q ^ b) : |
| 154 | + (a : ℝ) * Real.log p ≤ (b : ℝ) * Real.log q := by |
| 155 | + have hreal : (p : ℝ) ^ a ≤ (q : ℝ) ^ b := by exact_mod_cast h |
| 156 | + simpa only [Real.log_pow] using Real.log_le_log (pow_pos (Nat.cast_pos.mpr hp) a) hreal |
| 157 | + |
| 158 | +set_option exponentiation.threshold 113359 in |
| 159 | +/-- After clearing the slope denominators, the lower row exceeds 457/500 times the upper row. |
| 160 | +The power bounds enclose each needed logarithm in units of `log 2 / 32768`. -/ |
| 161 | +theorem slope_margin : |
| 162 | + 457 * 15 * 90 * logSlope upperRow < 500 * 58 * 89 * logSlope lowerRow := by |
| 163 | + rw [logSlope_lowerRow, logSlope_upperRow] |
| 164 | + have h₃ := log_product_bound (p := 2) (q := 3) (a := 51936) (b := 32768) |
| 165 | + (by decide) (by decide) |
| 166 | + have h₅ := log_product_bound (p := 2) (q := 5) (a := 76084) (b := 32768) |
| 167 | + (by decide) (by decide) |
| 168 | + have h₇ := log_product_bound (p := 7) (q := 2) (a := 32768) (b := 91992) |
| 169 | + (by decide) (by decide) |
| 170 | + have h₁₁ := log_product_bound (p := 11) (q := 2) (a := 32768) (b := 113359) |
| 171 | + (by decide) (by decide) |
| 172 | + have h₂ : 0 < Real.log 2 := Real.log_pos (by norm_num) |
| 173 | + push_cast at h₃ h₅ h₇ h₁₁ |
| 174 | + linarith only [h₂, h₃, h₅, h₇, h₁₁] |
| 175 | + |
| 176 | +end ErdosSwarm.Erdos30.FactorialInterval |