| 1 | module |
| 2 | |
| 3 | public import E424.Tools.T7Aux |
| 4 | |
| 5 | @[expose] public section |
| 6 | |
| 7 | /-! |
| 8 | # Erdős 424: helpers for tool T7 (counting blocks). |
| 9 | |
| 10 | `core_sum`: for increments `D i = y (i+1) - y i` that are monotone with `λ (j-i-1) ≤ D j - D i ≤ hλ (j-i+1)`, |
| 11 | `‖∑_{i<N} e(y i)‖ ≤ 7 h N √λ + 14/√λ`. Group the indices by `⌊D i - θ⌋` (`θ = √λ/2`); each group is a |
| 12 | Kusmin-Landau block `D i ∈ [k+θ, k+1-θ]` plus at most `2θ/λ+2` indices with `D i` near `k+1`. |
| 13 | -/ |
| 14 | |
| 15 | set_option linter.style.header false |
| 16 | |
| 17 | namespace E424 |
| 18 | |
| 19 | open Finset |
| 20 | |
| 21 | /-- At most `w/λ + 2` indices have `D i` in an open window of width `w`. -/ |
| 22 | lemma window_card (y : ℕ → ℝ) (N : ℕ) (lam : ℝ) (hlam : 0 < lam) |
| 23 | (hlow : ∀ i j, i ≤ j → j < N → lam * ((j : ℝ) - i - 1) ≤ (y (j + 1) - y j) - (y (i + 1) - y i)) |
| 24 | (c w : ℝ) (hw : 0 ≤ w) : |
| 25 | (((range N).filter (fun i => c < y (i + 1) - y i ∧ y (i + 1) - y i < c + w)).card : ℝ) |
| 26 | ≤ w / lam + 2 := by |
| 27 | set S := (range N).filter (fun i => c < y (i + 1) - y i ∧ y (i + 1) - y i < c + w) with hS |
| 28 | rcases S.eq_empty_or_nonempty with h0 | hne |
| 29 | · rw [h0]; simp only [card_empty, Nat.cast_zero]; positivity |
| 30 | have hmem : ∀ i, i ∈ S ↔ i < N ∧ (c < y (i + 1) - y i ∧ y (i + 1) - y i < c + w) := fun i => by |
| 31 | rw [hS, mem_filter, mem_range] |
| 32 | have hmM := S.min'_le _ (S.max'_mem hne) |
| 33 | have hm := (hmem _).mp (S.min'_mem hne) |
| 34 | have hM := (hmem _).mp (S.max'_mem hne) |
| 35 | have hsub : S ⊆ Icc (S.min' hne) (S.max' hne) := fun i hi => |
| 36 | mem_Icc.mpr ⟨S.min'_le i hi, S.le_max' i hi⟩ |
| 37 | have hc := card_le_card hsub |
| 38 | rw [Nat.card_Icc] at hc |
| 39 | have hcR : (S.card : ℝ) ≤ ((S.max' hne : ℕ) : ℝ) + 1 - (S.min' hne : ℕ) := by |
| 40 | have : ((S.max' hne + 1 - S.min' hne : ℕ) : ℝ) |
| 41 | = ((S.max' hne : ℕ) : ℝ) + 1 - (S.min' hne : ℕ) := by |
| 42 | rw [Nat.cast_sub (by omega)]; push_cast; ring |
| 43 | rw [← this]; exact_mod_cast hc |
| 44 | have h1 := hlow _ _ hmM hM.1 |
| 45 | have h2 : lam * (((S.max' hne : ℕ) : ℝ) - (S.min' hne : ℕ) - 1) < lam * (w / lam) := by |
| 46 | rw [mul_div_cancel₀ _ hlam.ne'] |
| 47 | linarith [hm.2.1, hm.2.2, hM.2.1, hM.2.2] |
| 48 | have h3 := lt_of_mul_lt_mul_left h2 hlam.le |
| 49 | linarith |
| 50 | |
| 51 | /-- A Kusmin-Landau block: indices with `D i ∈ [k+θ, k+1-θ]` form an interval. -/ |
| 52 | lemma kl_block (y : ℕ → ℝ) (N : ℕ) (k : ℤ) (θ : ℝ) (hθ : 0 < θ) (hθ2 : θ ≤ 1 / 2) |
| 53 | (hmono : ∀ i j, i ≤ j → j < N → y (i + 1) - y i ≤ y (j + 1) - y j) : |
| 54 | ‖∑ i ∈ (range N).filter (fun i => (k : ℝ) + θ ≤ y (i + 1) - y i ∧ |
| 55 | y (i + 1) - y i ≤ k + 1 - θ), ee (y i)‖ ≤ 2 / θ := by |
| 56 | set F := (range N).filter (fun i => (k : ℝ) + θ ≤ y (i + 1) - y i ∧ |
| 57 | y (i + 1) - y i ≤ k + 1 - θ) with hF |
| 58 | rcases F.eq_empty_or_nonempty with h0 | hne |
| 59 | · rw [h0]; simp only [sum_empty, norm_zero]; positivity |
| 60 | have hmem : ∀ i, i ∈ F ↔ i < N ∧ ((k : ℝ) + θ ≤ y (i + 1) - y i ∧ |
| 61 | y (i + 1) - y i ≤ k + 1 - θ) := fun i => by |
| 62 | rw [hF, mem_filter, mem_range] |
| 63 | have hm := (hmem _).mp (F.min'_mem hne) |
| 64 | have hM := (hmem _).mp (F.max'_mem hne) |
| 65 | have hin : ∀ i, F.min' hne ≤ i → i ≤ F.max' hne → i ∈ F := fun i h1 h2 => by |
| 66 | have hiN : i < N := by omega |
| 67 | rw [hmem] |
| 68 | refine ⟨hiN, ?_, ?_⟩ |
| 69 | · linarith [hmono _ _ h1 hiN, hm.2.1] |
| 70 | · linarith [hmono _ _ h2 hM.1, hM.2.2] |
| 71 | have hFeq : F = Ico (F.min' hne) (F.max' hne + 1) := by |
| 72 | ext i |
| 73 | simp only [mem_Ico] |
| 74 | constructor |
| 75 | · intro hi |
| 76 | exact ⟨F.min'_le i hi, Nat.lt_succ_of_le (F.le_max' i hi)⟩ |
| 77 | · rintro ⟨h1, h2⟩ |
| 78 | exact hin i h1 (Nat.lt_succ_iff.mp h2) |
| 79 | rw [hFeq, sum_Ico_eq_sum_range] |
| 80 | refine kl_sum_le (fun i => y (F.min' hne + i)) _ k θ hθ hθ2 ?_ ?_ |
| 81 | · intro i hi |
| 82 | have hmem' : F.min' hne + i ∈ F := hin _ (by omega) (by omega) |
| 83 | simpa [Nat.add_assoc] using ((hmem _).mp hmem').2 |
| 84 | · intro i hi j hj hij |
| 85 | have hmem' : F.min' hne + j ∈ F := hin _ (by omega) (by omega) |
| 86 | simpa [Nat.add_assoc] using hmono _ _ (Nat.add_le_add_left hij _) ((hmem _).mp hmem').1 |
| 87 | |
| 88 | /-- One fiber `{i : ⌊D i - θ⌋ = k}`: a Kusmin-Landau block plus indices with `D i` near `k+1`. -/ |
| 89 | lemma fiber_bound (y : ℕ → ℝ) (N : ℕ) (lam : ℝ) (hlam : 0 < lam) (hlam1 : lam ≤ 1) |
| 90 | (hmono : ∀ i j, i ≤ j → j < N → y (i + 1) - y i ≤ y (j + 1) - y j) |
| 91 | (hlow : ∀ i j, i ≤ j → j < N → lam * ((j : ℝ) - i - 1) ≤ (y (j + 1) - y j) - (y (i + 1) - y i)) |
| 92 | (k : ℤ) : |
| 93 | ‖∑ i ∈ (range N).filter (fun i => ⌊y (i + 1) - y i - Real.sqrt lam / 2⌋ = k), ee (y i)‖ |
| 94 | ≤ 7 / Real.sqrt lam := by |
| 95 | have hs : 0 < Real.sqrt lam := Real.sqrt_pos.mpr hlam |
| 96 | have hs1 : Real.sqrt lam ≤ 1 := by |
| 97 | rw [Real.sqrt_le_one]; exact hlam1 |
| 98 | have hss : Real.sqrt lam * Real.sqrt lam = lam := Real.mul_self_sqrt hlam.le |
| 99 | set θ := Real.sqrt lam / 2 with hθ |
| 100 | have hθ0 : 0 < θ := by positivity |
| 101 | have hθ2 : θ ≤ 1 / 2 := by rw [hθ]; linarith |
| 102 | set F1 := (range N).filter (fun i => (k : ℝ) + θ ≤ y (i + 1) - y i ∧ |
| 103 | y (i + 1) - y i ≤ k + 1 - θ) with hF1 |
| 104 | set F2 := (range N).filter (fun i => ((k : ℝ) + 1 - θ) < y (i + 1) - y i ∧ |
| 105 | y (i + 1) - y i < ((k : ℝ) + 1 - θ) + 2 * θ) with hF2 |
| 106 | have hunion : (range N).filter (fun i => ⌊y (i + 1) - y i - θ⌋ = k) = F1 ∪ F2 := by |
| 107 | ext i |
| 108 | simp only [hF1, hF2, mem_union, mem_filter, mem_range, Int.floor_eq_iff] |
| 109 | constructor |
| 110 | · rintro ⟨hi, h1, h2⟩ |
| 111 | by_cases hc : y (i + 1) - y i ≤ k + 1 - θ |
| 112 | · exact Or.inl ⟨hi, by linarith, hc⟩ |
| 113 | · exact Or.inr ⟨hi, by linarith, by linarith⟩ |
| 114 | · rintro (⟨hi, h1, h2⟩ | ⟨hi, h1, h2⟩) |
| 115 | · exact ⟨hi, by linarith, by linarith⟩ |
| 116 | · exact ⟨hi, by linarith, by linarith⟩ |
| 117 | have hdisj : Disjoint F1 F2 := by |
| 118 | rw [disjoint_left] |
| 119 | intro i h1 h2 |
| 120 | simp only [hF1, hF2, mem_filter] at h1 h2 |
| 121 | linarith [h1.2.2, h2.2.1] |
| 122 | rw [hunion, sum_union hdisj] |
| 123 | have hA := kl_block y N k θ hθ0 hθ2 hmono |
| 124 | have hB := window_card y N lam hlam hlow ((k : ℝ) + 1 - θ) (2 * θ) (by positivity) |
| 125 | have hnB : ‖∑ i ∈ F2, ee (y i)‖ ≤ (F2.card : ℝ) := by |
| 126 | refine (norm_sum_le _ _).trans ?_ |
| 127 | have : ∀ i ∈ F2, ‖ee (y i)‖ = 1 := fun i _ => by |
| 128 | unfold ee; exact Complex.norm_exp_ofReal_mul_I _ |
| 129 | rw [sum_congr rfl this]; simp |
| 130 | have e1 : 2 / θ = 4 / Real.sqrt lam := by rw [hθ]; field_simp; ring |
| 131 | have e2 : 2 * θ / lam = 1 / Real.sqrt lam := by |
| 132 | rw [hθ, div_eq_div_iff hlam.ne' hs.ne']; linear_combination hss |
| 133 | have e3 : 2 ≤ 2 / Real.sqrt lam := by rw [le_div_iff₀ hs]; linarith |
| 134 | have e4 : 7 / Real.sqrt lam = 4 / Real.sqrt lam + 1 / Real.sqrt lam + 2 / Real.sqrt lam := by ring |
| 135 | refine (norm_add_le _ _).trans ?_ |
| 136 | rw [e1] at hA |
| 137 | rw [e2] at hB |
| 138 | linarith |
| 139 | |
| 140 | /-- Counting blocks: `‖∑_{i<N} e(y i)‖ ≤ 7 h N √λ + 14/√λ`. -/ |
| 141 | theorem core_sum (y : ℕ → ℝ) (N : ℕ) (lam h : ℝ) (hlam : 0 < lam) (hlam1 : lam ≤ 1) (h1 : 1 ≤ h) |
| 142 | (hmono : ∀ i j, i ≤ j → j < N → y (i + 1) - y i ≤ y (j + 1) - y j) |
| 143 | (hlow : ∀ i j, i ≤ j → j < N → lam * ((j : ℝ) - i - 1) ≤ (y (j + 1) - y j) - (y (i + 1) - y i)) |
| 144 | (hup : ∀ i j, i ≤ j → j < N → (y (j + 1) - y j) - (y (i + 1) - y i) ≤ h * lam * ((j : ℝ) - i + 1)) : |
| 145 | ‖∑ i ∈ range N, ee (y i)‖ ≤ 7 * h * N * Real.sqrt lam + 14 / Real.sqrt lam := by |
| 146 | have hs : 0 < Real.sqrt lam := Real.sqrt_pos.mpr hlam |
| 147 | have hss : Real.sqrt lam * Real.sqrt lam = lam := Real.mul_self_sqrt hlam.le |
| 148 | rcases Nat.eq_zero_or_pos N with rfl | hN |
| 149 | · simp only [range_zero, sum_empty, norm_zero]; positivity |
| 150 | set g : ℕ → ℤ := fun i => ⌊y (i + 1) - y i - Real.sqrt lam / 2⌋ with hg |
| 151 | have hgmono : ∀ i j, i ≤ j → j < N → g i ≤ g j := fun i j hij hj => |
| 152 | Int.floor_le_floor (by linarith [hmono i j hij hj]) |
| 153 | have hmaps : ∀ i ∈ range N, g i ∈ Icc (g 0) (g (N - 1)) := fun i hi => by |
| 154 | have hi' := mem_range.mp hi |
| 155 | exact mem_Icc.mpr ⟨hgmono 0 i (Nat.zero_le _) hi', hgmono i (N - 1) (by omega) (by omega)⟩ |
| 156 | rw [← sum_fiberwise_of_maps_to hmaps] |
| 157 | refine (norm_sum_le _ _).trans ?_ |
| 158 | have hfib := fun k : ℤ => fiber_bound y N lam hlam hlam1 hmono hlow k |
| 159 | have hbd := sum_le_card_nsmul (Icc (g 0) (g (N - 1))) _ (7 / Real.sqrt lam) |
| 160 | (fun k _ => hfib k) |
| 161 | refine hbd.trans ?_ |
| 162 | rw [nsmul_eq_mul] |
| 163 | -- number of fibers |
| 164 | have hcard : ((Icc (g 0) (g (N - 1))).card : ℝ) ≤ h * lam * N + 2 := by |
| 165 | have h0 : g 0 ≤ g (N - 1) := hgmono 0 (N - 1) (Nat.zero_le _) (by omega) |
| 166 | have hc : ((Icc (g 0) (g (N - 1))).card : ℤ) = g (N - 1) + 1 - g 0 := by |
| 167 | rw [Int.card_Icc]; omega |
| 168 | have hcR : ((Icc (g 0) (g (N - 1))).card : ℝ) = (g (N - 1) : ℝ) + 1 - g 0 := by |
| 169 | exact_mod_cast hc |
| 170 | have hup' := hup 0 (N - 1) (Nat.zero_le _) (by omega) |
| 171 | have hN1 : ((N - 1 : ℕ) : ℝ) = (N : ℝ) - 1 := by |
| 172 | rw [Nat.cast_sub hN]; simp |
| 173 | have f1 : (g (N - 1) : ℝ) ≤ y (N - 1 + 1) - y (N - 1) - Real.sqrt lam / 2 := Int.floor_le _ |
| 174 | have f2 : y (0 + 1) - y 0 - Real.sqrt lam / 2 < (g 0 : ℝ) + 1 := Int.lt_floor_add_one _ |
| 175 | rw [hcR] |
| 176 | rw [hN1] at hup' |
| 177 | simp only [Nat.cast_zero] at hup' |
| 178 | nlinarith |
| 179 | have h7 : (0 : ℝ) ≤ 7 / Real.sqrt lam := by positivity |
| 180 | calc ((Icc (g 0) (g (N - 1))).card : ℝ) * (7 / Real.sqrt lam) |
| 181 | ≤ (h * lam * N + 2) * (7 / Real.sqrt lam) := mul_le_mul_of_nonneg_right hcard h7 |
| 182 | _ = 7 * h * N * (lam / Real.sqrt lam) + 14 / Real.sqrt lam := by ring |
| 183 | _ = 7 * h * N * Real.sqrt lam + 14 / Real.sqrt lam := by |
| 184 | rw [div_eq_of_eq_mul hs.ne' hss.symm] |
| 185 | |
| 186 | end E424 |
| 187 | |