This journal is in preparation. Submissions are open as a pilot and the editorial board is being formed. Articles marked Demonstration show the format only.
Journal of Machine-Verified MathematicsPeer-reviewed mathematics with machine-checked proofs, for the age of AI

E424/RoughElements/L8Aux.lean

All files · 310 lines · source at the verified commit

1module
2
3public import E424.Tools.T1
4
5@[expose] public section
6
7/-!
8# Auxiliary lemmas for Lemma 8: additive characters, reduced fractions, the two large sieve sums
9-/
10
11set_option linter.style.header false
12open Finset
13
14namespace E424.LS
15
16theorem ee_eq_one {x : ℝ} (h : ee x = 1) : ∃ k : ℤ, x = k := by
17 unfold ee at h
18 obtain ⟨k, hk⟩ := Complex.exp_eq_one_iff.mp h
19 refine ⟨k, ?_⟩
20 have h1 : (((2 * Real.pi * x : ℝ) : ℂ)) = ((2 * Real.pi * k : ℝ) : ℂ) := by
21 refine mul_right_cancel₀ Complex.I_ne_zero (hk.trans ?_)
22 push_cast
23 ring
24 have h2 : 2 * Real.pi * x = 2 * Real.pi * k := by exact_mod_cast h1
25 exact mul_left_cancel₀ (by positivity) h2
26
27theorem ee_zero : ee 0 = 1 := by simpa using ee_int 0
28
29theorem ee_nat_mul (n : ℕ) (x : ℝ) : ee (n * x) = ee x ^ n := by
30 induction n with
31 | zero => simp [ee_zero]
32 | succ n ih =>
33 rw [pow_succ, ← ih, ← ee_add]
34 congr 1
35 push_cast
36 ring
37
38/-- Orthogonality of additive characters. -/
39theorem sum_ee_range {d : ℕ} (hd : 0 < d) (s : ℤ) :
40 ∑ ξ ∈ range d, ee ((ξ : ℝ) / d * s) = if (d : ℤ) ∣ s then (d : ℂ) else 0 := by
41 have hd' : (d : ℝ) ≠ 0 := by positivity
42 have hterm : ∀ ξ : ℕ, ee ((ξ : ℝ) / d * s) = ee ((s : ℝ) / d) ^ ξ := by
43 intro ξ
44 rw [← ee_nat_mul]
45 congr 1
46 ring
47 simp_rw [hterm]
48 split_ifs with h
49 · obtain ⟨t, rfl⟩ := h
50 have : (((d : ℤ) * t : ℤ) : ℝ) / d = (t : ℤ) := by push_cast; field_simp
51 rw [this, ee_int]
52 simp
53 · have hne : ee ((s : ℝ) / d) ≠ 1 := by
54 intro h1
55 obtain ⟨k, hk⟩ := ee_eq_one h1
56 rw [div_eq_iff hd'] at hk
57 exact h ⟨k, by rw [mul_comm]; exact_mod_cast hk⟩
58 rw [geom_sum_eq hne, ← ee_nat_mul, mul_div_cancel₀ _ hd', ee_int, sub_self, zero_div]
59
60/-- Grouping the fractions `ξ / d` by reduced denominator. -/
61theorem sum_range_eq_sum_reduced {d : ℕ} (hd : 0 < d) (G : ℝ → ℂ) :
62 ∑ ξ ∈ range d, G ((ξ : ℝ) / d) =
63 ∑ e ∈ d.divisors, ∑ ξ ∈ range e with ξ.Coprime e, G ((ξ : ℝ) / e) := by
64 have hmaps : ∀ ξ ∈ range d, d / ξ.gcd d ∈ d.divisors := fun ξ _ =>
65 Nat.mem_divisors.mpr ⟨Nat.div_dvd_of_dvd (Nat.gcd_dvd_right _ _), hd.ne'⟩
66 rw [← sum_fiberwise_of_maps_to hmaps]
67 refine sum_congr rfl fun e he => ?_
68 obtain ⟨⟨t, rfl⟩, -⟩ := Nat.mem_divisors.mp he
69 have he0 : 0 < e := Nat.pos_of_mul_pos_right hd
70 have ht0 : 0 < t := Nat.pos_of_mul_pos_left hd
71 have hfib : ∀ ξ ∈ (range (e * t)).filter (fun ξ => e * t / ξ.gcd (e * t) = e),
72 ∃ η, ξ = η * t ∧ η < e ∧ η.Coprime e := by
73 intro ξ hξ
74 rw [mem_filter, mem_range] at hξ
75 have hg0 : 0 < ξ.gcd (e * t) := Nat.gcd_pos_of_pos_right _ hd
76 have hg : ξ.gcd (e * t) = t := by
77 have := Nat.eq_mul_of_div_eq_left (Nat.gcd_dvd_right ξ (e * t)) hξ.2
78 exact (Nat.eq_of_mul_eq_mul_left he0 this).symm
79 obtain ⟨η, hη⟩ : t ∣ ξ := hg ▸ Nat.gcd_dvd_left ξ (e * t)
80 rw [mul_comm] at hη
81 subst hη
82 refine ⟨η, rfl, Nat.lt_of_mul_lt_mul_right hξ.1, ?_⟩
83 rw [Nat.gcd_mul_right] at hg
84 exact Nat.eq_of_mul_eq_mul_right ht0 (by rw [hg, one_mul])
85 refine sum_nbij' (fun ξ => ξ / t) (fun η => η * t) ?_ ?_ ?_ ?_ ?_
86 · intro ξ hξ
87 obtain ⟨η, rfl, h1, h2⟩ := hfib ξ hξ
88 rw [Nat.mul_div_cancel _ ht0, mem_filter, mem_range]
89 exact ⟨h1, h2⟩
90 · intro η hη
91 rw [mem_filter, mem_range] at hη ⊢
92 refine ⟨Nat.mul_lt_mul_of_pos_right hη.1 ht0, ?_⟩
93 rw [Nat.gcd_mul_right, hη.2.gcd_eq_one, one_mul, Nat.mul_div_cancel _ ht0]
94 · intro ξ hξ
95 obtain ⟨η, rfl, -, -⟩ := hfib ξ hξ
96 rw [Nat.mul_div_cancel _ ht0]
97 · intro η _
98 exact Nat.mul_div_cancel _ ht0
99 · intro ξ hξ
100 obtain ⟨η, rfl, -, -⟩ := hfib ξ hξ
101 rw [Nat.mul_div_cancel _ ht0]
102 congr 1
103 have : (t : ℝ) ≠ 0 := by positivity
104 push_cast
105 exact mul_div_mul_right _ _ this
106
107/-- `∑_{z ∈ S} e(zγ)`. -/
108noncomputable def hat (S : Finset ℕ) (γ : ℝ) : ℂ := ∑ z ∈ S, ee (z * γ)
109
110/-- A weight depending on `x mod P` costs only a sum over the characters mod `P`. -/
111theorem bilinear_le {P : ℕ} (hP : 0 < P) (φ : ℕ → ℂ) (hφ : ∀ i, ‖φ i‖ ≤ 1) (β : ℝ)
112 (Q : ℕ) (𝒵 𝒞 : Finset ℕ) (hQ : ∀ z ∈ 𝒵, ∀ c ∈ 𝒞, c ≤ Q * z) :
113 ‖∑ p ∈ 𝒵 ×ˢ 𝒞, φ ((Q * p.1 - p.2) % P) * ee (β * (Q * p.1 - p.2 : ℕ))‖ ≤
114 ∑ a ∈ range P, ‖hat 𝒵 (Q * (β + a / P))‖ * ‖hat 𝒞 (β + a / P)‖ := by
115 have hP' : (P : ℂ) ≠ 0 := by exact_mod_cast hP.ne'
116 set φh : ℕ → ℂ := fun a => 1 / P * ∑ i ∈ range P, φ i * ee ((a : ℝ) / P * (-i : ℤ)) with hφh
117 have hφh1 : ∀ a, ‖φh a‖ ≤ 1 := by
118 intro a
119 rw [hφh, norm_mul, norm_div, norm_one, Complex.norm_natCast, one_div,
120 inv_mul_le_iff₀ (by exact_mod_cast hP), mul_one]
121 refine (norm_sum_le _ _).trans ((sum_le_card_nsmul _ _ 1 fun i _ => ?_).trans ?_)
122 · rw [norm_mul, norm_ee, mul_one]; exact hφ i
123 · simp
124 have hexp : ∀ x : ℕ, φ (x % P) = ∑ a ∈ range P, φh a * ee ((a : ℝ) / P * x) := by
125 intro x
126 have h1 : ∀ a ∈ range P, φh a * ee ((a : ℝ) / P * x) =
127 1 / P * ∑ i ∈ range P, φ i * ee ((a : ℝ) / P * (x - i : ℤ)) := by
128 intro a _
129 rw [hφh, mul_assoc, sum_mul]
130 congr 1
131 refine sum_congr rfl fun i _ => ?_
132 rw [mul_assoc, ← ee_add]
133 congr 2
134 push_cast
135 ring
136 rw [sum_congr rfl h1, ← mul_sum, sum_comm]
137 simp_rw [← mul_sum, sum_ee_range hP]
138 rw [sum_eq_single (x % P)]
139 · rw [if_pos]
140 · field_simp
141 · exact (Nat.modEq_iff_dvd.mp (Nat.mod_modEq x P))
142 · intro i hi hne
143 rw [if_neg, mul_zero]
144 intro hdvd
145 refine hne ?_
146 have : i % P = x % P := Nat.modEq_iff_dvd.mpr hdvd
147 rwa [Nat.mod_eq_of_lt (mem_range.mp hi)] at this
148 · intro h
149 exact absurd (mem_range.mpr (Nat.mod_lt _ hP)) h
150 have hmain : ∑ p ∈ 𝒵 ×ˢ 𝒞, φ ((Q * p.1 - p.2) % P) * ee (β * (Q * p.1 - p.2 : ℕ)) =
151 ∑ a ∈ range P, φh a * (hat 𝒵 (Q * (β + a / P)) * starRingEnd ℂ (hat 𝒞 (β + a / P))) := by
152 simp_rw [hexp, sum_mul]
153 rw [sum_comm]
154 refine sum_congr rfl fun a _ => ?_
155 rw [hat, hat, map_sum, sum_mul_sum, ← sum_product', mul_sum]
156 refine sum_congr rfl fun p hp => ?_
157 rw [mem_product] at hp
158 rw [conj_ee, mul_assoc, ← ee_add, ← ee_add, Nat.cast_sub (hQ _ hp.1 _ hp.2)]
159 congr 2
160 push_cast
161 ring
162 rw [hmain]
163 refine (norm_sum_le _ _).trans (sum_le_sum fun a _ => ?_)
164 rw [norm_mul (φh a), norm_mul (hat _ _), Complex.norm_conj]
165 exact mul_le_of_le_one_left (by positivity) (hφh1 a)
166
167/-- Spacing of the points `uξ/e + va/R`. -/
168theorem points_sep {E R u v e e' ξ ξ' a a' : ℕ} (he0 : 0 < e) (he0' : 0 < e') (hR : 0 < R)
169 (he : e ≤ 2 * E) (he' : e' ≤ 2 * E) (heR : e.Coprime R) (heR' : e'.Coprime R)
170 (hu : u.Coprime e) (hu' : u.Coprime e') (hv : v.Coprime R) (hξ : ξ < e) (hξ' : ξ' < e')
171 (hξe : ξ.Coprime e) (hξe' : ξ'.Coprime e') (ha : a < R) (ha' : a' < R)
172 (hne : ¬ (e = e' ∧ ξ = ξ' ∧ a = a')) (k : ℤ) :
173 1 / (4 * (E : ℝ) ^ 2 * R) ≤
174 |((u : ℝ) * ξ / e + (v : ℝ) * a / R) - ((u : ℝ) * ξ' / e' + (v : ℝ) * a' / R) - k| := by
175 set num : ℤ := u * ξ * e' * R + v * a * e * e' - u * ξ' * e * R - v * a' * e * e' - k * e * e' * R
176 with hnum
177 have hnum0 : num ≠ 0 := by
178 intro h0
179 have key : ∀ {e e' ξ : ℕ}, e.Coprime R → u.Coprime e → ξ.Coprime e →
180 (e : ℤ) ∣ u * ξ * e' * R → e ∣ e' := by
181 intro e e' ξ h1 h2 h3 h4
182 have h5 : e ∣ (u * ξ * R) * e' := by
183 have : (e : ℤ) ∣ ((u * ξ * R * e' : ℕ) : ℤ) := by
184 push_cast; convert h4 using 1; ring
185 exact_mod_cast this
186 exact (Nat.Coprime.mul_right (Nat.Coprime.mul_right h2.symm h3.symm) h1).dvd_of_dvd_mul_left h5
187 have h1 : e ∣ e' := key heR hu hξe ⟨u * ξ' * R + v * a' * e' + k * e' * R - v * a * e', by
188 linear_combination h0⟩
189 have h2 : e' ∣ e := key heR' hu' hξe' ⟨u * ξ * R + v * a * e - v * a' * e - k * e * R, by
190 linear_combination -h0⟩
191 obtain rfl := Nat.dvd_antisymm h1 h2
192 have he0z : (e : ℤ) ≠ 0 := by exact_mod_cast he0.ne'
193 have h3 : (u : ℤ) * R * (ξ - ξ') = e * (k * R - v * (a - a')) := by
194 refine mul_left_cancel₀ he0z ?_
195 linear_combination h0
196 have h4 : (e : ℤ) ∣ ξ - ξ' := by
197 refine IsCoprime.dvd_of_dvd_mul_left (x := (e : ℤ)) (y := (u : ℤ) * R) ?_ ⟨_, h3⟩
198 exact IsCoprime.mul_right (Nat.isCoprime_iff_coprime.mpr hu.symm)
199 (Nat.isCoprime_iff_coprime.mpr heR)
200 have h5 : ξ' = ξ := by
201 have := Nat.modEq_iff_dvd.mpr h4
202 exact Nat.ModEq.eq_of_lt_of_lt this hξ' hξ
203 subst h5
204 have h6 : (v : ℤ) * (a - a') = R * k := by
205 rw [sub_self, mul_zero] at h3
206 have := (mul_eq_zero.mp h3.symm).resolve_left he0z
207 linear_combination -this
208 have h7 : (R : ℤ) ∣ a - a' :=
209 IsCoprime.dvd_of_dvd_mul_left (x := (R : ℤ)) (y := (v : ℤ))
210 (Nat.isCoprime_iff_coprime.mpr hv.symm) ⟨_, h6⟩
211 have h8 : a' = a := Nat.ModEq.eq_of_lt_of_lt (Nat.modEq_iff_dvd.mpr h7) ha' ha
212 exact hne ⟨rfl, rfl, h8.symm⟩
213 have hepos : (0 : ℝ) < e := by exact_mod_cast he0
214 have hepos' : (0 : ℝ) < e' := by exact_mod_cast he0'
215 have hRpos : (0 : ℝ) < R := by exact_mod_cast hR
216 have heq : ((u : ℝ) * ξ / e + (v : ℝ) * a / R) - ((u : ℝ) * ξ' / e' + (v : ℝ) * a' / R) - k =
217 (num : ℝ) / (e * e' * R) := by
218 rw [hnum]
219 push_cast
220 field_simp
221 ring
222 rw [heq, abs_div, abs_of_pos (by positivity : (0 : ℝ) < e * e' * R)]
223 have hone : (1 : ℝ) ≤ |(num : ℝ)| := by exact_mod_cast Int.one_le_abs hnum0
224 have hle : (e : ℝ) * e' * R ≤ 4 * (E : ℝ) ^ 2 * R := by
225 have h1 : (e : ℝ) ≤ 2 * E := by exact_mod_cast he
226 have h2 : (e' : ℝ) ≤ 2 * E := by exact_mod_cast he'
227 refine mul_le_mul_of_nonneg_right ?_ hRpos.le
228 nlinarith
229 exact div_le_div₀ (abs_nonneg _) hone (by positivity) hle
230
231/-- The index set of reduced fractions with denominator in `(E, 2E]`, coprime to `6P`. -/
232def fracs (E P : ℕ) : Finset (Σ _ : ℕ, ℕ) :=
233 ((Ioc E (2 * E)).filter fun e => e.Coprime (6 * P)).sigma fun e =>
234 (range e).filter fun ξ => ξ.Coprime e
235
236/-- The large sieve for the points `uξ/e + va/R`, `R ∣ P`. -/
237theorem sieve_sum {C1 : ℝ} (hT1 : ∀ (ι : Type) (s : Finset ι) (γ : ι → ℝ) (δ : ℝ), 0 < δ →
238 (∀ i ∈ s, ∀ j ∈ s, i ≠ j → ∀ k : ℤ, δ ≤ |γ i - γ j - k|) →
239 ∀ (M : ℤ) (N : ℕ) (a : ℤ → ℂ),
240 ∑ i ∈ s, ‖∑ n ∈ Ico M (M + N), a n * ee (n * γ i)‖ ^ 2 ≤
241 C1 * (N + 1 / δ) * ∑ n ∈ Ico M (M + N), ‖a n‖ ^ 2)
242 {E P R u v : ℕ} (hE : 1 ≤ E) (hR : 0 < R) (hRP : R ∣ P) (hv : v.Coprime R)
243 (hu : ∀ e, e.Coprime (6 * P) → u.Coprime e) (S : Finset ℕ) (L : ℕ) (hS : ∀ z ∈ S, z < L) :
244 ∑ i ∈ fracs E P, ∑ a ∈ range R, ‖hat S ((u : ℝ) * i.2 / i.1 + (v : ℝ) * a / R)‖ ^ 2 ≤
245 C1 * (L + 4 * (E : ℝ) ^ 2 * R) * S.card := by
246 classical
247 have hE' : (0 : ℝ) < E := by exact_mod_cast hE
248 have hR' : (0 : ℝ) < R := by exact_mod_cast hR
249 have h := hT1 ((Σ _ : ℕ, ℕ) × ℕ) (fracs E P ×ˢ range R)
250 (fun p => (u : ℝ) * p.1.2 / p.1.1 + (v : ℝ) * p.2 / R) (1 / (4 * (E : ℝ) ^ 2 * R))
251 (by positivity) ?_ 0 L (fun n => if n.toNat ∈ S then 1 else 0)
252 · have hconv : ∀ γ : ℝ, ∑ n ∈ Ico (0 : ℤ) (0 + L),
253 (if n.toNat ∈ S then (1 : ℂ) else 0) * ee (n * γ) = hat S γ := by
254 intro γ
255 simp_rw [ite_mul, one_mul, zero_mul]
256 rw [← sum_filter, hat]
257 refine sum_nbij' (fun n => n.toNat) (fun z => (z : ℤ)) ?_ ?_ ?_ ?_ ?_
258 · intro n hn; exact (mem_filter.mp hn).2
259 · intro z hz
260 have := hS z hz
261 rw [mem_filter, mem_Ico]
262 refine ⟨by omega, by simpa using hz⟩
263 · intro n hn
264 have := (mem_Ico.mp (mem_filter.mp hn).1).1
265 exact Int.toNat_of_nonneg this
266 · intro z _; simp
267 · intro n hn
268 have := (mem_Ico.mp (mem_filter.mp hn).1).1
269 have h2 : ((n.toNat : ℤ) : ℝ) = n := by rw [Int.toNat_of_nonneg this]
270 rw [← h2]
271 norm_cast
272 have hcard : ∑ n ∈ Ico (0 : ℤ) (0 + L), ‖(if n.toNat ∈ S then (1 : ℂ) else 0)‖ ^ 2 =
273 S.card := by
274 have h1 : ∀ n : ℤ, ‖(if n.toNat ∈ S then (1 : ℂ) else 0)‖ ^ 2 =
275 if n.toNat ∈ S then (1 : ℝ) else 0 := fun n => by split_ifs <;> simp
276 have h2 := hconv 0
277 simp only [mul_zero, ee_zero, mul_one, hat, sum_const, nsmul_eq_mul] at h2
278 have h3 : ((∑ n ∈ Ico (0 : ℤ) (0 + L), (if n.toNat ∈ S then (1 : ℝ) else 0) : ℝ) : ℂ) =
279 ((S.card : ℝ) : ℂ) := by
280 push_cast
281 rw [← h2]
282 refine sum_congr rfl fun n _ => ?_
283 split_ifs <;> simp
284 rw [sum_congr rfl fun n _ => h1 n]
285 exact_mod_cast h3
286 simp_rw [hconv] at h
287 rw [hcard, one_div_one_div, sum_product] at h
288 exact h
289 · rintro ⟨⟨e, ξ⟩, a⟩ hp ⟨⟨e', ξ'⟩, a'⟩ hp' hne k
290 simp only [fracs, mem_product, mem_sigma, mem_filter, mem_Ioc, mem_range] at hp hp'
291 obtain ⟨⟨⟨⟨h1, h2⟩, h3⟩, h4, h5⟩, h6⟩ := hp
292 obtain ⟨⟨⟨⟨h1', h2'⟩, h3'⟩, h4', h5'⟩, h6'⟩ := hp'
293 have hc : ∀ {e : ℕ}, e.Coprime (6 * P) → e.Coprime R := fun h =>
294 h.coprime_dvd_right (hRP.mul_left 6)
295 refine points_sep (by omega) (by omega) hR h2 h2' (hc h3) (hc h3') (hu _ h3) (hu _ h3') hv h4 h4'
296 h5 h5' h6 h6' ?_ k
297 rintro ⟨rfl, rfl, rfl⟩
298 exact hne rfl
299
300theorem sum_range_periodic (g : ℕ → ℝ) (R : ℕ) (hg : ∀ m x, g (m * R + x) = g x) (m : ℕ) :
301 ∑ a ∈ range (m * R), g a = m * ∑ a ∈ range R, g a := by
302 induction m with
303 | zero => simp
304 | succ m ih =>
305 rw [Nat.succ_mul, sum_range_add, ih, sum_congr rfl fun x _ => hg m x]
306 push_cast
307 ring
308
309end E424.LS
310