| | @@ -1,3 +1,4 @@ |
| 1 | +import Mathlib.Data.Nat.Cast.Field |
| 1 | 2 | import Mathlib.Data.Nat.Factorial.Basic |
| 2 | 3 | import Mathlib.NumberTheory.ArithmeticFunction.Misc |
| 3 | 4 | import Mathlib.Analysis.SpecialFunctions.Exponential |
| | @@ -79,4 +80,62 @@ theorem summable_sigma_div_factorial (k : ℕ) : |
| 79 | 80 | gcongr |
| 80 | 81 | exact_mod_cast sigma_le_pow k n |
| 81 | 82 | |
| 83 | +/-- `σ₁(n) ≤ n (n + 1) / 2`: the divisors of `n` lie in `[1, n]`. -/ |
| 84 | +theorem two_mul_sigma_one_le (n : ℕ) : 2 * σ 1 n ≤ n * (n + 1) := by |
| 85 | + rw [ArithmeticFunction.sigma_one_apply] |
| 86 | + have hsub : n.divisors ⊆ Finset.range (n + 1) := fun d hd => |
| 87 | + Finset.mem_range.mpr (Nat.lt_succ_of_le (Nat.divisor_le hd)) |
| 88 | + have h1 : ∑ d ∈ n.divisors, d ≤ ∑ d ∈ Finset.range (n + 1), d := |
| 89 | + Finset.sum_le_sum_of_subset hsub |
| 90 | + have h2 := Finset.sum_range_id_mul_two (n + 1) |
| 91 | + simp only [Nat.add_sub_cancel] at h2 |
| 92 | + nlinarith [h1, h2] |
| 93 | + |
| 94 | +/-- `∑_{d ≤ N} 1 / d² ≤ 7 / 4`: `1 + 1/4 + ∑_{d ≥ 3} 1 / (d (d - 1))`. -/ |
| 95 | +theorem sum_inv_sq_le (N : ℕ) : ∑ d ∈ Finset.Icc 1 N, (1 : ℝ) / (d : ℝ) ^ 2 ≤ 7 / 4 := by |
| 96 | + have key : ∀ N : ℕ, 2 ≤ N → |
| 97 | + ∑ d ∈ Finset.Icc 1 N, (1 : ℝ) / (d : ℝ) ^ 2 ≤ 7 / 4 - 1 / (N : ℝ) := by |
| 98 | + intro N hN |
| 99 | + induction N, hN using Nat.le_induction with |
| 100 | + | base => norm_num [Finset.sum_Icc_succ_top] |
| 101 | + | succ N hN ih => |
| 102 | + rw [Finset.sum_Icc_succ_top (by omega)] |
| 103 | + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) |
| 104 | + have hstep : (1 : ℝ) / ((N : ℝ) + 1) ^ 2 ≤ 1 / (N : ℝ) - 1 / ((N : ℝ) + 1) := by |
| 105 | + rw [div_sub_div _ _ hN0.ne' (by positivity), div_le_div_iff₀ (by positivity) (by positivity)] |
| 106 | + nlinarith |
| 107 | + push_cast |
| 108 | + linarith |
| 109 | + rcases N with _ | _ | N |
| 110 | + · norm_num |
| 111 | + · norm_num |
| 112 | + · have := key (N + 2) (by omega) |
| 113 | + have h0 : (0 : ℝ) ≤ 1 / ((N + 2 : ℕ) : ℝ) := by positivity |
| 114 | + linarith |
| 115 | + |
| 116 | +/-- `σ₂(n) ≤ 7 n² / 4`: `σ₂(n) = ∑_{d ∣ n} (n / d)² = n² ∑_{d ∣ n} 1 / d²`. -/ |
| 117 | +theorem sigma_two_le (n : ℕ) : (σ 2 n : ℝ) ≤ 7 / 4 * (n : ℝ) ^ 2 := by |
| 118 | + rcases Nat.eq_zero_or_pos n with rfl | hn |
| 119 | + · simp |
| 120 | + have hsig : (σ 2 n : ℝ) = ∑ d ∈ n.divisors, ((n / d : ℕ) : ℝ) ^ 2 := by |
| 121 | + rw [ArithmeticFunction.sigma_apply] |
| 122 | + push_cast |
| 123 | + exact (Nat.sum_div_divisors n (fun d : ℕ => (d : ℝ) ^ 2)).symm |
| 124 | + have hterm : ∀ d ∈ n.divisors, |
| 125 | + ((n / d : ℕ) : ℝ) ^ 2 = (n : ℝ) ^ 2 * (1 / (d : ℝ) ^ 2) := by |
| 126 | + intro d hd |
| 127 | + have hdn : d ∣ n := Nat.dvd_of_mem_divisors hd |
| 128 | + have hd0 : (d : ℝ) ≠ 0 := by exact_mod_cast (Nat.pos_of_mem_divisors hd).ne' |
| 129 | + rw [Nat.cast_div hdn hd0] |
| 130 | + field_simp |
| 131 | + have hsub : n.divisors ⊆ Finset.Icc 1 n := fun d hd => |
| 132 | + Finset.mem_Icc.mpr ⟨Nat.pos_of_mem_divisors hd, Nat.divisor_le hd⟩ |
| 133 | + rw [hsig, Finset.sum_congr rfl hterm, ← Finset.mul_sum] |
| 134 | + calc (n : ℝ) ^ 2 * ∑ d ∈ n.divisors, (1 : ℝ) / (d : ℝ) ^ 2 |
| 135 | + ≤ (n : ℝ) ^ 2 * ∑ d ∈ Finset.Icc 1 n, (1 : ℝ) / (d : ℝ) ^ 2 := |
| 136 | + mul_le_mul_of_nonneg_left |
| 137 | + (Finset.sum_le_sum_of_subset_of_nonneg hsub fun _ _ _ => by positivity) (by positivity) |
| 138 | + _ ≤ (n : ℝ) ^ 2 * (7 / 4) := mul_le_mul_of_nonneg_left (sum_inv_sq_le n) (by positivity) |
| 139 | + _ = 7 / 4 * (n : ℝ) ^ 2 := by ring |
| 140 | + |
| 82 | 141 | end ErdosSwarm.Erdos252 |