| 1 | module |
| 2 | |
| 3 | public import E424.ToolDefs |
| 4 | public import E424.Tools.T7Aux3 |
| 5 | |
| 6 | @[expose] public section |
| 7 | |
| 8 | /-! |
| 9 | # Erdős 424: tool T7. Absolute existential constants; Mathlib only. |
| 10 | -/ |
| 11 | |
| 12 | set_option linter.style.header false |
| 13 | open Finset |
| 14 | |
| 15 | namespace E424 |
| 16 | |
| 17 | /-- **T7**, second derivative test for sums. `λ ≤ 1` is needed (v2 omits it): for `λ > 1` and a short |
| 18 | interval around one integer the bound fails. -/ |
| 19 | theorem T7_second_derivative_sum : ∃ C > 0, ∀ (a b lam h G0 G1 : ℝ) (φ φ' φ'' G G' : ℝ → ℝ), |
| 20 | 0 ≤ a → a ≤ b → 0 < lam → lam ≤ 1 → 1 ≤ h → 0 ≤ G0 → 0 ≤ G1 → |
| 21 | (∀ x ∈ Set.Icc a b, HasDerivAt φ (φ' x) x ∧ HasDerivAt φ' (φ'' x) x ∧ |
| 22 | lam ≤ φ'' x ∧ φ'' x ≤ h * lam) → |
| 23 | (∀ x ∈ Set.Icc a b, HasDerivAt G (G' x) x ∧ |G x| ≤ G0 ∧ |G' x| ≤ G1) → |
| 24 | ‖∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, (G n : ℂ) * ee (φ n)‖ ≤ |
| 25 | C * h * (G0 + G1 * (b - a)) * ((b - a) * Real.sqrt lam + 1 / Real.sqrt lam) := by |
| 26 | refine ⟨15, by norm_num, ?_⟩ |
| 27 | intro a b lam h G0 G1 φ φ' φ'' G G' ha hab hlam hlam1 hh hG0 hG1 hφ hG |
| 28 | have hs : 0 < Real.sqrt lam := Real.sqrt_pos.mpr hlam |
| 29 | have hs1 : Real.sqrt lam ≤ 1 := by rw [Real.sqrt_le_one]; exact hlam1 |
| 30 | have hba : 0 ≤ b - a := by linarith |
| 31 | set s := Real.sqrt lam with hsdef |
| 32 | set Bd := (b - a) * s + 1 / s with hBd |
| 33 | have hBd0 : 0 < Bd := by positivity |
| 34 | have hGsum : 0 ≤ G0 + G1 * (b - a) := by positivity |
| 35 | have hrhs : 0 ≤ 15 * h * (G0 + G1 * (b - a)) * Bd := by |
| 36 | have : 0 ≤ h := by linarith |
| 37 | positivity |
| 38 | set m := ⌊a⌋₊ with hm |
| 39 | set M := ⌊b⌋₊ with hM |
| 40 | have hma : (m : ℝ) ≤ a := Nat.floor_le ha |
| 41 | have ham : a < m + 1 := Nat.lt_floor_add_one a |
| 42 | have hMb : (M : ℝ) ≤ b := Nat.floor_le (by linarith) |
| 43 | rcases le_or_gt M m with hMm | hMm |
| 44 | · rw [Ioc_eq_empty (by omega)] |
| 45 | simp only [sum_empty, norm_zero] |
| 46 | exact hrhs |
| 47 | -- reindex |
| 48 | obtain ⟨N, hN⟩ : ∃ N, N = M - m := ⟨_, rfl⟩ |
| 49 | have hNpos : 1 ≤ N := by omega |
| 50 | have hNb : (N : ℝ) < b - a + 1 := by |
| 51 | have : (N : ℝ) = M - m := by rw [hN, Nat.cast_sub hMm.le] |
| 52 | linarith |
| 53 | have hIoc : ∑ n ∈ Ioc m M, (G n : ℂ) * ee (φ n) |
| 54 | = ∑ i ∈ range N, (G ((m + 1 + i : ℕ) : ℝ) : ℂ) * ee (φ ((m + 1 + i : ℕ) : ℝ)) := by |
| 55 | rw [← Ico_add_one_add_one_eq_Ioc, sum_Ico_eq_sum_range] |
| 56 | have : M + 1 - (m + 1) = N := by omega |
| 57 | rw [this] |
| 58 | rw [hIoc] |
| 59 | set y : ℕ → ℝ := fun i => φ ((m + 1 + i : ℕ) : ℝ) with hy |
| 60 | set E : ℕ → ℂ := fun i => ee (y i) with hE |
| 61 | set g : ℕ → ℂ := fun i => (G ((m + 1 + i : ℕ) : ℝ) : ℂ) with hg |
| 62 | have hEn : ∀ i, ‖E i‖ = 1 := fun i => by |
| 63 | simp only [hE, ee]; exact Complex.norm_exp_ofReal_mul_I _ |
| 64 | -- partial sums |
| 65 | set B := 7 * h * (b - a) * s + 15 / s with hB |
| 66 | have hB0 : 0 ≤ B := by |
| 67 | have : 0 ≤ h := by linarith |
| 68 | positivity |
| 69 | have hpart : ∀ r, r ≤ N → ‖∑ i ∈ range r, E i‖ ≤ B := by |
| 70 | intro r hr |
| 71 | rcases r with _ | q |
| 72 | · simpa using hB0 |
| 73 | have hq : (q : ℝ) < b - a := by |
| 74 | have : ((q + 1 : ℕ) : ℝ) ≤ N := by exact_mod_cast hr |
| 75 | push_cast at this |
| 76 | linarith |
| 77 | have hcast : ∀ j : ℕ, y (j + 1) = φ (((m + 1 + j : ℕ) : ℝ) + 1) := fun j => by |
| 78 | simp only [hy]; congr 1; push_cast; ring |
| 79 | have hbnd : ∀ i j, i ≤ j → j < q → (φ (((m + 1 + i : ℕ) : ℝ) + 1) - φ ((m + 1 + i : ℕ) : ℝ) |
| 80 | ≤ φ (((m + 1 + j : ℕ) : ℝ) + 1) - φ ((m + 1 + j : ℕ) : ℝ)) ∧ |
| 81 | lam * ((j : ℝ) - i - 1) ≤ (φ (((m + 1 + j : ℕ) : ℝ) + 1) - φ ((m + 1 + j : ℕ) : ℝ)) |
| 82 | - (φ (((m + 1 + i : ℕ) : ℝ) + 1) - φ ((m + 1 + i : ℕ) : ℝ)) ∧ |
| 83 | (φ (((m + 1 + j : ℕ) : ℝ) + 1) - φ ((m + 1 + j : ℕ) : ℝ)) |
| 84 | - (φ (((m + 1 + i : ℕ) : ℝ) + 1) - φ ((m + 1 + i : ℕ) : ℝ)) ≤ h * lam * ((j : ℝ) - i + 1) := by |
| 85 | intro i j hij hj |
| 86 | have := incr_bounds hlam hφ (n := m + 1 + i) (n' := m + 1 + j) (by omega) |
| 87 | (by push_cast; linarith) |
| 88 | (by |
| 89 | have : ((m + 1 + j + 1 : ℕ) : ℝ) ≤ M := by exact_mod_cast (by omega : m + 1 + j + 1 ≤ M) |
| 90 | push_cast at this ⊢; linarith) |
| 91 | push_cast at this ⊢ |
| 92 | convert this using 3 <;> ring |
| 93 | have hcore := core_sum y q lam h hlam hlam1 hh |
| 94 | (fun i j hij hj => by |
| 95 | rw [hcast, hcast]; exact (hbnd i j hij hj).1) |
| 96 | (fun i j hij hj => by |
| 97 | rw [hcast, hcast]; exact (hbnd i j hij hj).2.1) |
| 98 | (fun i j hij hj => by |
| 99 | rw [hcast, hcast]; exact (hbnd i j hij hj).2.2) |
| 100 | rw [sum_range_succ] |
| 101 | refine (norm_add_le _ _).trans ?_ |
| 102 | rw [hEn] |
| 103 | have h1s : 1 ≤ 1 / s := by rw [le_div_iff₀ hs]; linarith |
| 104 | have hh0 : 0 ≤ h := by linarith |
| 105 | have : 7 * h * q * s ≤ 7 * h * (b - a) * s := by gcongr |
| 106 | have h15 : 14 / s + 1 ≤ 15 / s := by |
| 107 | have : 14 / s + 1 / s = 15 / s := by ring |
| 108 | linarith |
| 109 | simp only [hE] |
| 110 | linarith |
| 111 | -- Abel summation |
| 112 | have habel := sum_range_by_parts g E N |
| 113 | simp only [smul_eq_mul] at habel |
| 114 | have hterm : ∀ i, g i * E i = (G ((m + 1 + i : ℕ) : ℝ) : ℂ) * ee (φ ((m + 1 + i : ℕ) : ℝ)) := |
| 115 | fun i => rfl |
| 116 | have hfinal : ‖∑ i ∈ range N, g i * E i‖ ≤ G0 * B + ((N : ℝ) - 1) * (G1 * B) := by |
| 117 | rw [habel] |
| 118 | refine (norm_sub_le _ _).trans ?_ |
| 119 | have hN1 : ((N - 1 : ℕ) : ℝ) = (N : ℝ) - 1 := by rw [Nat.cast_sub hNpos]; simp |
| 120 | have hlast : ‖g (N - 1)‖ ≤ G0 := by |
| 121 | simp only [hg, Complex.norm_real, Real.norm_eq_abs] |
| 122 | refine (hG _ ⟨?_, ?_⟩).2.1 |
| 123 | · push_cast; linarith |
| 124 | · have : ((m + 1 + (N - 1) : ℕ) : ℝ) ≤ M := by |
| 125 | exact_mod_cast (by omega : m + 1 + (N - 1) ≤ M) |
| 126 | linarith |
| 127 | have h1 : ‖g (N - 1) * ∑ i ∈ range N, E i‖ ≤ G0 * B := by |
| 128 | rw [norm_mul] |
| 129 | exact mul_le_mul hlast (hpart N le_rfl) (norm_nonneg _) hG0 |
| 130 | have h2 : ‖∑ i ∈ range (N - 1), (g (i + 1) - g i) * ∑ j ∈ range (i + 1), E j‖ |
| 131 | ≤ ((N - 1 : ℕ) : ℝ) * (G1 * B) := by |
| 132 | refine (norm_sum_le _ _).trans ?_ |
| 133 | have : ∀ i ∈ range (N - 1), ‖(g (i + 1) - g i) * ∑ j ∈ range (i + 1), E j‖ ≤ G1 * B := by |
| 134 | intro i hi |
| 135 | have hi' := mem_range.mp hi |
| 136 | rw [norm_mul] |
| 137 | have hd : ‖g (i + 1) - g i‖ ≤ G1 := by |
| 138 | have hx : ((m + 1 + (i + 1) : ℕ) : ℝ) = ((m + 1 + i : ℕ) : ℝ) + 1 := by push_cast; ring |
| 139 | simp only [hg] |
| 140 | rw [hx, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] |
| 141 | refine unit_incr_le (fun x hx => ⟨(hG x hx).1, (hG x hx).2.2⟩) (by push_cast; linarith) ?_ |
| 142 | have : ((m + 1 + i + 1 : ℕ) : ℝ) ≤ M := by |
| 143 | exact_mod_cast (by omega : m + 1 + i + 1 ≤ M) |
| 144 | push_cast at this ⊢; linarith |
| 145 | exact mul_le_mul hd (hpart (i + 1) (by omega)) (norm_nonneg _) hG1 |
| 146 | refine (sum_le_card_nsmul _ _ _ this).trans ?_ |
| 147 | simp |
| 148 | rw [hN1] at h2 |
| 149 | linarith |
| 150 | have hNm : (N : ℝ) - 1 ≤ b - a := by linarith |
| 151 | have hBle : B ≤ 15 * h * Bd := by |
| 152 | have hh0 : 0 ≤ h := by linarith |
| 153 | have e1 : 7 * h * (b - a) * s ≤ 15 * h * ((b - a) * s) := by |
| 154 | have : 0 ≤ h * ((b - a) * s) := by positivity |
| 155 | linarith |
| 156 | have e2 : 15 / s ≤ 15 * h * (1 / s) := by |
| 157 | have : 15 / s * 1 ≤ 15 / s * h := mul_le_mul_of_nonneg_left hh (by positivity) |
| 158 | calc 15 / s = 15 / s * 1 := by ring |
| 159 | _ ≤ 15 / s * h := this |
| 160 | _ = 15 * h * (1 / s) := by ring |
| 161 | simp only [hB, hBd] |
| 162 | linarith |
| 163 | have hG1B : 0 ≤ G1 * B := by positivity |
| 164 | calc _ ≤ G0 * B + ((N : ℝ) - 1) * (G1 * B) := hfinal |
| 165 | _ ≤ G0 * B + (b - a) * (G1 * B) := by gcongr |
| 166 | _ = (G0 + G1 * (b - a)) * B := by ring |
| 167 | _ ≤ (G0 + G1 * (b - a)) * (15 * h * Bd) := mul_le_mul_of_nonneg_left hBle hGsum |
| 168 | _ = 15 * h * (G0 + G1 * (b - a)) * Bd := by ring |
| 169 | |
| 170 | end E424 |
| 171 | |