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/Tools/T2Aux.lean

All files · 503 lines · source at the verified commit

1module
2
3public import Mathlib
4
5@[expose] public section
6
7/-!
8# Erdős 424: helpers for T2. Layered Brun-Hooley weights on subsets of a finite set.
9Weights are functions on finite sets of primes; `x p` plays the role of `1/p`.
10-/
11
12set_option linter.style.header false
13open Finset
14
15namespace E424.BH
16
17/-- Truncated Möbius function on sets. -/
18noncomputable def tr (b : ℕ) (B : Finset ℕ) : ℝ := if #B ≤ b then (-1) ^ #B else 0
19
20/-- `∑_{E ⊆ D ⊆ S} f(D) ∏_{p ∈ D} x_p`. -/
21noncomputable def cs (x : ℕ → ℝ) (S : Finset ℕ) (f : Finset ℕ → ℝ) (E : Finset ℕ) : ℝ :=
22 ∑ D ∈ S.powerset with E ⊆ D, f D * ∏ p ∈ D, x p
23
24lemma cs_empty (x : ℕ → ℝ) (S : Finset ℕ) (f : Finset ℕ → ℝ) :
25 cs x S f ∅ = ∑ D ∈ S.powerset, f D * ∏ p ∈ D, x p := by simp [cs]
26
27/-- Bonferroni with weights. -/
28lemma bonf (x : ℕ → ℝ) (T : Finset ℕ) (hx : ∀ p ∈ T, 0 ≤ x p ∧ x p ≤ 1) : ∀ b : ℕ,
29 0 ≤ (-1 : ℝ) ^ b * (∑ B ∈ T.powerset, tr b B * ∏ p ∈ B, x p - ∏ p ∈ T, (1 - x p)) := by
30 induction T using Finset.induction_on with
31 | empty => intro b; simp [tr]
32 | insert a s ha ih =>
33 have hs : ∀ p ∈ s, 0 ≤ x p ∧ x p ≤ 1 := fun p hp => hx p (mem_insert_of_mem hp)
34 have hxa := hx a (mem_insert_self a s)
35 have hV : 0 ≤ ∏ p ∈ s, (1 - x p) := prod_nonneg fun p hp => by linarith [(hs p hp).2]
36 intro b
37 rw [sum_powerset_insert ha, prod_insert ha]
38 rcases b with _ | b
39 · have h0 : ∑ t ∈ s.powerset, tr 0 (insert a t) * ∏ p ∈ insert a t, x p = 0 := by
40 refine sum_eq_zero fun t ht => ?_
41 have : a ∉ t := fun h => ha (mem_powerset.1 ht h)
42 simp [tr, card_insert_of_notMem this]
43 have := ih hs 0
44 rw [h0]
45 simp only [pow_zero, one_mul] at this ⊢
46 nlinarith
47 · have h1 : ∑ t ∈ s.powerset, tr (b + 1) (insert a t) * ∏ p ∈ insert a t, x p =
48 - x a * ∑ t ∈ s.powerset, tr b t * ∏ p ∈ t, x p := by
49 rw [mul_sum]
50 refine sum_congr rfl fun t ht => ?_
51 have hat : a ∉ t := fun h => ha (mem_powerset.1 ht h)
52 rw [prod_insert hat]
53 simp only [tr, card_insert_of_notMem hat, add_le_add_iff_right]
54 split_ifs <;> ring
55 have i1 := ih hs (b + 1)
56 have i2 := mul_nonneg hxa.1 (ih hs b)
57 rw [h1]
58 rw [pow_succ] at i1 ⊢
59 nlinarith
60
61/-- Elementary symmetric sums are at most `L^k/k!`. -/
62lemma esymm_le (x : ℕ → ℝ) (T : Finset ℕ) (hx : ∀ p ∈ T, 0 ≤ x p) : ∀ k : ℕ,
63 (∑ B ∈ T.powerset with #B = k, ∏ p ∈ B, x p) ≤ (∑ p ∈ T, x p) ^ k / (k.factorial : ℝ) := by
64 induction T using Finset.induction_on with
65 | empty =>
66 intro k
67 rcases k with _ | k
68 · simp [filter_singleton]
69 · simp [filter_singleton]
70 | insert a s ha ih =>
71 have hs : ∀ p ∈ s, 0 ≤ x p := fun p hp => hx p (mem_insert_of_mem hp)
72 have hxa := hx a (mem_insert_self a s)
73 have hL : 0 ≤ ∑ p ∈ s, x p := sum_nonneg hs
74 intro k
75 rw [sum_filter, sum_powerset_insert ha, sum_insert ha, ← sum_filter]
76 rcases k with _ | k
77 · have h0 : ∑ t ∈ s.powerset, (if #(insert a t) = 0 then ∏ p ∈ insert a t, x p else 0) = 0 := by
78 refine sum_eq_zero fun t ht => ?_
79 simp
80 have := ih hs 0
81 rw [h0]
82 simpa using this
83 · have h1 : ∑ t ∈ s.powerset, (if #(insert a t) = k + 1 then ∏ p ∈ insert a t, x p else 0) =
84 x a * ∑ t ∈ s.powerset with #t = k, ∏ p ∈ t, x p := by
85 rw [sum_filter, mul_sum]
86 refine sum_congr rfl fun t ht => ?_
87 have hat : a ∉ t := fun h => ha (mem_powerset.1 ht h)
88 rw [prod_insert hat, card_insert_of_notMem hat]
89 simp
90 rw [h1]
91 have i1 := ih hs (k + 1)
92 have i2 := mul_le_mul_of_nonneg_left (ih hs k) hxa
93 set L := ∑ p ∈ s, x p
94 have hb : L ^ (k + 1) + (k + 1) * x a * L ^ k ≤ (x a + L) ^ (k + 1) := by
95 clear i1 i2 h1
96 induction k with
97 | zero => simp; linarith
98 | succ k ihk =>
99 have hxL : 0 ≤ x a + L := by linarith
100 have := mul_le_mul_of_nonneg_left ihk hxL
101 have h3 : 0 ≤ (k + 1) * x a ^ 2 * L ^ k := by positivity
102 push_cast
103 calc _ ≤ (x a + L) * (L ^ (k + 1) + (k + 1) * x a * L ^ k) := by
104 ring_nf at h3 ⊢; linarith
105 _ ≤ _ := by rw [pow_succ' (x a + L) (k + 1)]; exact this
106 have hf : (0 : ℝ) < ((k + 1).factorial : ℝ) := by positivity
107 have hf' : (0 : ℝ) < (k.factorial : ℝ) := by positivity
108 have e : x a * (L ^ k / (k.factorial : ℝ)) =
109 ((k + 1) * x a * L ^ k) / ((k + 1).factorial : ℝ) := by
110 rw [Nat.factorial_succ]; push_cast; field_simp
111 calc _ ≤ L ^ (k + 1) / ((k + 1).factorial : ℝ) + x a * (L ^ k / (k.factorial : ℝ)) :=
112 add_le_add i1 i2
113 _ = (L ^ (k + 1) + (k + 1) * x a * L ^ k) / ((k + 1).factorial : ℝ) := by
114 rw [e, add_div]
115 _ ≤ _ := by gcongr
116
117/-- Sums over subsets of a disjoint union factor. -/
118lemma sum_split {S T R : Finset ℕ} (hd : Disjoint S T) (hR : R ⊆ S ∪ T) (f g : Finset ℕ → ℝ) :
119 ∑ D ∈ R.powerset, f (D ∩ S) * g (D ∩ T) =
120 (∑ A ∈ (R ∩ S).powerset, f A) * ∑ B ∈ (R ∩ T).powerset, g B := by
121 rw [sum_mul_sum, ← sum_product']
122 have hdd : ∀ a, a ∈ S → a ∉ T := fun a h => disjoint_left.1 hd h
123 refine sum_nbij' (fun D => (D ∩ S, D ∩ T)) (fun q => q.1 ∪ q.2) ?_ ?_ ?_ ?_ ?_
124 · intro D hD
125 simp only [mem_product, mem_powerset] at hD ⊢
126 exact ⟨inter_subset_inter_right hD, inter_subset_inter_right hD⟩
127 · rintro ⟨A, B⟩ h
128 simp only [mem_product, mem_powerset] at h ⊢
129 exact union_subset (h.1.trans inter_subset_left) (h.2.trans inter_subset_left)
130 · intro D hD
131 simp only [mem_powerset] at hD ⊢
132 rw [← inter_union_distrib_left, inter_eq_left]
133 exact hD.trans hR
134 · rintro ⟨A, B⟩ h
135 simp only [mem_product, mem_powerset] at h
136 have hA : ∀ a ∈ A, a ∈ S := fun a ha => (mem_inter.1 (h.1 ha)).2
137 have hB : ∀ a ∈ B, a ∈ T := fun a ha => (mem_inter.1 (h.2 ha)).2
138 ext a <;> grind
139 · intro D _; rfl
140
141lemma prod_split {S T D : Finset ℕ} (hd : Disjoint S T) (hD : D ⊆ S ∪ T) (x : ℕ → ℝ) :
142 ∏ p ∈ D, x p = (∏ p ∈ D ∩ S, x p) * ∏ p ∈ D ∩ T, x p := by
143 rw [← prod_union (hd.mono inter_subset_right inter_subset_right), ← inter_union_distrib_left,
144 inter_eq_left.2 hD]
145
146lemma cs_split {S T E : Finset ℕ} (hd : Disjoint S T) (hE : E ⊆ S ∪ T) (x : ℕ → ℝ)
147 (f g : Finset ℕ → ℝ) :
148 cs x (S ∪ T) (fun D => f (D ∩ S) * g (D ∩ T)) E = cs x S f (E ∩ S) * cs x T g (E ∩ T) := by
149 unfold cs
150 rw [sum_filter, sum_filter, sum_filter]
151 have h := sum_split hd (Subset.refl (S ∪ T))
152 (fun A => if E ∩ S ⊆ A then f A * ∏ p ∈ A, x p else 0)
153 (fun B => if E ∩ T ⊆ B then g B * ∏ p ∈ B, x p else 0)
154 rw [union_inter_cancel_left, union_inter_cancel_right] at h
155 rw [← h]
156 refine sum_congr rfl fun D hD => ?_
157 have hD' := mem_powerset.1 hD
158 rw [prod_split hd hD' x]
159 by_cases hED : E ⊆ D
160 · rw [if_pos hED, if_pos (inter_subset_inter_right hED), if_pos (inter_subset_inter_right hED)]
161 ring
162 · rw [if_neg hED]
163 by_cases h1 : E ∩ S ⊆ D ∩ S
164 · have h2 : ¬ E ∩ T ⊆ D ∩ T := by
165 intro h2
166 apply hED
167 intro a ha
168 rcases mem_union.1 (hE ha) with h | h
169 · exact (mem_inter.1 (h1 (mem_inter.2 ⟨ha, h⟩))).1
170 · exact (mem_inter.1 (h2 (mem_inter.2 ⟨ha, h⟩))).1
171 rw [if_neg h2, mul_zero]
172 · rw [if_neg h1, zero_mul]
173
174lemma cs_sub (x : ℕ → ℝ) (S : Finset ℕ) (f g : Finset ℕ → ℝ) (E : Finset ℕ) :
175 cs x S (fun D => f D - g D) E = cs x S f E - cs x S g E := by
176 unfold cs
177 rw [← sum_sub_distrib]
178 exact sum_congr rfl fun D _ => by ring
179
180/-- `∑_{F ⊆ B ⊆ T} |f(B)| x(B) ≤ x(F) ∏ (1 + x)` for `|f| ≤ 1`. -/
181lemma abs_cs_le (x : ℕ → ℝ) {T F : Finset ℕ} (hx : ∀ p ∈ T, 0 ≤ x p) (hF : F ⊆ T)
182 (f : Finset ℕ → ℝ) (hf : ∀ B, |f B| ≤ 1) :
183 |cs x T f F| ≤ (∏ p ∈ F, x p) * ∏ p ∈ T, (1 + x p) := by
184 have hw : ∀ B ⊆ T, 0 ≤ ∏ p ∈ B, x p := fun B hB => prod_nonneg fun p hp => hx p (hB hp)
185 have he : ∑ B ∈ T.powerset with F ⊆ B, ∏ p ∈ B, x p =
186 (∏ p ∈ F, x p) * ∏ p ∈ T \ F, (1 + x p) := by
187 rw [prod_one_add, mul_sum]
188 refine sum_nbij' (fun B => B \ F) (fun B => F ∪ B) ?_ ?_ ?_ ?_ ?_
189 · intro B hB
190 simp only [mem_filter, mem_powerset] at hB ⊢
191 exact sdiff_subset_sdiff hB.1 (Subset.refl _)
192 · intro B hB
193 simp only [mem_filter, mem_powerset] at hB ⊢
194 exact ⟨union_subset hF (hB.trans sdiff_subset), subset_union_left⟩
195 · intro B hB
196 simp only [mem_filter, mem_powerset] at hB
197 exact union_sdiff_of_subset hB.2
198 · intro B hB
199 simp only [mem_powerset] at hB
200 rw [union_sdiff_cancel_left]
201 exact (disjoint_sdiff).mono_right hB
202 · intro B hB
203 simp only [mem_filter, mem_powerset] at hB
204 rw [mul_comm, prod_sdiff hB.2]
205 calc |cs x T f F| ≤ ∑ B ∈ T.powerset with F ⊆ B, |f B * ∏ p ∈ B, x p| :=
206 abs_sum_le_sum_abs _ _
207 _ ≤ ∑ B ∈ T.powerset with F ⊆ B, ∏ p ∈ B, x p := by
208 refine sum_le_sum fun B hB => ?_
209 have := hw B (mem_powerset.1 (mem_filter.1 hB).1)
210 rw [abs_mul, abs_of_nonneg this]
211 exact mul_le_of_le_one_left this (hf B)
212 _ = (∏ p ∈ F, x p) * ∏ p ∈ T \ F, (1 + x p) := he
213 _ ≤ _ := by
214 refine mul_le_mul_of_nonneg_left ?_ (hw F hF)
215 rw [← prod_sdiff hF]
216 refine le_mul_of_one_le_right (prod_nonneg fun p hp => ?_) ?_
217 · linarith [hx p (mem_sdiff.1 hp).1]
218 · refine (prod_const_one (s := F)).symm.trans_le ?_
219 exact prod_le_prod₀ (fun _ _ => zero_le_one) fun p hp => by linarith [hx p (hF hp)]
220
221/-- Sieve weights `lp, lm` on the subsets of `S` with loss `t` and levels `Qp, Qm`. -/
222structure Sys (x : ℕ → ℝ) (S : Finset ℕ) (t Qp Qm : ℝ) (lp lm : Finset ℕ → ℝ) : Prop where
223 lo : ∀ R ⊆ S, ∑ D ∈ R.powerset, lm D ≤ if R = ∅ then 1 else 0
224 hi : ∀ R ⊆ S, (if R = ∅ then (1 : ℝ) else 0) ≤ ∑ D ∈ R.powerset, lp D
225 abs_lp : ∀ D, |lp D| ≤ 1
226 supp_p : ∀ D ⊆ S, lp D ≠ 0 → (∏ p ∈ D, (p : ℝ)) ≤ Qp
227 supp_m : ∀ D ⊆ S, lm D ≠ 0 → (∏ p ∈ D, (p : ℝ)) ≤ Qm
228 V_le : ∏ p ∈ S, (1 - x p) ≤ cs x S lp ∅
229 le_V : cs x S lm ∅ ≤ ∏ p ∈ S, (1 - x p)
230 ratio : (1 - t) * cs x S lp ∅ ≤ cs x S lm ∅
231 coef_p : ∀ E ⊆ S, |cs x S lp E| ≤ cs x S lp ∅ * (12 ^ #E * ∏ p ∈ E, x p)
232 coef_m : ∀ E ⊆ S, |cs x S lm E| ≤ (1 + t) * cs x S lp ∅ * (24 ^ #E * ∏ p ∈ E, x p)
233
234/-- The empty system. -/
235lemma sys_empty (x : ℕ → ℝ) {t Qp Qm : ℝ} (ht : 0 ≤ t) (hp : 1 ≤ Qp) (hm : 1 ≤ Qm) :
236 Sys x ∅ t Qp Qm (fun _ => 1) (fun _ => 1) := by
237 have h : cs x ∅ (fun _ => 1) ∅ = 1 := by simp [cs]
238 refine ⟨?_, ?_, by simp, ?_, ?_, by simp [h], by simp [h], by simp [h, ht], ?_, ?_⟩
239 · intro R hR; simp [subset_empty.1 hR]
240 · intro R hR; simp [subset_empty.1 hR]
241 · intro R hR; simpa [subset_empty.1 hR] using hp
242 · intro R hR; simpa [subset_empty.1 hR] using hm
243 · intro R hR; simp [subset_empty.1 hR, h]
244 · intro R hR; simp [subset_empty.1 hR, h, ht]
245
246/-- One layer `T` with truncation `b`, loss `ε`. -/
247structure Layer (x : ℕ → ℝ) (T : Finset ℕ) (ε w : ℝ) (b : ℕ) (yp ym : Finset ℕ → ℝ) : Prop where
248 lo : ∀ R ⊆ T, ∑ D ∈ R.powerset, ym D ≤ if R = ∅ then 1 else 0
249 hi : ∀ R ⊆ T, (if R = ∅ then (1 : ℝ) else 0) ≤ ∑ D ∈ R.powerset, yp D
250 abs_yp : ∀ D, |yp D| ≤ 1
251 supp_p : ∀ D ⊆ T, yp D ≠ 0 → (∏ p ∈ D, (p : ℝ)) ≤ w ^ b
252 supp_m : ∀ D ⊆ T, yp D - ym D ≠ 0 → (∏ p ∈ D, (p : ℝ)) ≤ w ^ (b + 1)
253 pos : 0 < cs x T yp ∅
254 V_le : ∏ p ∈ T, (1 - x p) ≤ cs x T yp ∅
255 le_V : cs x T ym ∅ ≤ ∏ p ∈ T, (1 - x p)
256 loss_nonneg : 0 ≤ cs x T yp ∅ - cs x T ym ∅
257 loss : cs x T yp ∅ - cs x T ym ∅ ≤ ε * cs x T yp ∅
258 coef_p : ∀ F ⊆ T, F ≠ ∅ → |cs x T yp F| ≤ cs x T yp ∅ * (12 ^ #F * ∏ p ∈ F, x p)
259 coef_m : ∀ F ⊆ T, F ≠ ∅ → |cs x T yp F - cs x T ym F| ≤ cs x T yp ∅ * (12 ^ #F * ∏ p ∈ F, x p)
260
261lemma sys_step {x : ℕ → ℝ} {S T : Finset ℕ} {t ε Qp Qm w : ℝ} {b : ℕ}
262 {lp lm yp ym : Finset ℕ → ℝ} (hd : Disjoint S T) (hx : ∀ p ∈ S ∪ T, 0 ≤ x p ∧ x p ≤ 1)
263 (ht : 0 ≤ t) (hε : 0 ≤ ε) (hQp : 0 ≤ Qp)
264 (hs : Sys x S t Qp Qm lp lm) (hl : Layer x T ε w b yp ym) {Qm' : ℝ}
265 (h1 : Qm * w ^ b ≤ Qm') (h2 : Qp * w ^ (b + 1) ≤ Qm') :
266 Sys x (S ∪ T) (t + ε) (Qp * w ^ b) Qm' (fun D => lp (D ∩ S) * yp (D ∩ T))
267 (fun D => lm (D ∩ S) * yp (D ∩ T) - lp (D ∩ S) * (yp (D ∩ T) - ym (D ∩ T))) := by
268 have hempS : ∀ f g : Finset ℕ → ℝ, cs x (S ∪ T) (fun D => f (D ∩ S) * g (D ∩ T)) ∅ =
269 cs x S f ∅ * cs x T g ∅ := fun f g => by
270 simpa using cs_split hd (empty_subset _) x f g
271 have hsplit : ∀ E ⊆ S ∪ T, cs x (S ∪ T)
272 (fun D => lm (D ∩ S) * yp (D ∩ T) - lp (D ∩ S) * (yp (D ∩ T) - ym (D ∩ T))) E =
273 cs x S lm (E ∩ S) * cs x T yp (E ∩ T) -
274 cs x S lp (E ∩ S) * (cs x T yp (E ∩ T) - cs x T ym (E ∩ T)) := fun E hE => by
275 rw [cs_sub, cs_split hd hE, cs_split hd hE x lp (fun D => yp D - ym D), cs_sub]
276 have hm0 := hsplit ∅ (empty_subset _)
277 simp only [empty_inter] at hm0
278 have hVS : 0 ≤ ∏ p ∈ S, (1 - x p) :=
279 prod_nonneg fun p hp => by linarith [(hx p (mem_union_left _ hp)).2]
280 have hVT : 0 ≤ ∏ p ∈ T, (1 - x p) :=
281 prod_nonneg fun p hp => by linarith [(hx p (mem_union_right _ hp)).2]
282 have hMp : 0 ≤ cs x S lp ∅ := hVS.trans hs.V_le
283 have hYp := hl.pos
284 have hcard : ∀ E ⊆ S ∪ T, #E = #(E ∩ S) + #(E ∩ T) := fun E hE => by
285 rw [← card_union_of_disjoint (hd.mono inter_subset_right inter_subset_right),
286 ← inter_union_distrib_left, inter_eq_left.2 hE]
287 have hxpos : ∀ E ⊆ S ∪ T, 0 ≤ ∏ p ∈ E, x p := fun E hE =>
288 prod_nonneg fun p hp => (hx p (hE hp)).1
289 have hcp : ∀ F ⊆ T, |cs x T yp F| ≤ cs x T yp ∅ * (12 ^ #F * ∏ p ∈ F, x p) := fun F hF => by
290 by_cases h : F = ∅
291 · simp [h, abs_of_pos hYp]
292 · exact hl.coef_p F hF h
293 refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
294 · intro R hR
295 rw [sum_sub_distrib, sum_split hd hR lm yp, sum_split hd hR lp (fun D => yp D - ym D),
296 sum_sub_distrib]
297 have a1 := hs.lo (R ∩ S) inter_subset_right
298 have a2 := hs.hi (R ∩ S) inter_subset_right
299 have b1 := hl.lo (R ∩ T) inter_subset_right
300 have b2 := hl.hi (R ∩ T) inter_subset_right
301 have hRe : R = ∅ ↔ R ∩ S = ∅ ∧ R ∩ T = ∅ := by
302 rw [← union_eq_empty, ← inter_union_distrib_left, inter_eq_left.2 hR]
303 simp only [hRe]
304 generalize ∑ D ∈ (R ∩ S).powerset, lm D = am at *
305 generalize ∑ D ∈ (R ∩ S).powerset, lp D = ap at *
306 generalize ∑ D ∈ (R ∩ T).powerset, ym D = bm at *
307 generalize ∑ D ∈ (R ∩ T).powerset, yp D = bp at *
308 by_cases c1 : R ∩ S = ∅ <;> by_cases c2 : R ∩ T = ∅ <;> simp [c1, c2] at * <;> nlinarith
309 · intro R hR
310 rw [sum_split hd hR lp yp]
311 have a2 := hs.hi (R ∩ S) inter_subset_right
312 have b2 := hl.hi (R ∩ T) inter_subset_right
313 have hRe : R = ∅ ↔ R ∩ S = ∅ ∧ R ∩ T = ∅ := by
314 rw [← union_eq_empty, ← inter_union_distrib_left, inter_eq_left.2 hR]
315 simp only [hRe]
316 by_cases c1 : R ∩ S = ∅ <;> by_cases c2 : R ∩ T = ∅ <;> simp [c1, c2] at * <;> nlinarith
317 · intro D
318 rw [abs_mul]
319 exact mul_le_one₀ (hs.abs_lp _) (abs_nonneg _) (hl.abs_yp _)
320 · intro D hD h
321 obtain ⟨n1, n2⟩ := mul_ne_zero_iff.1 h
322 rw [prod_split hd hD (fun p => (p : ℝ))]
323 exact mul_le_mul (hs.supp_p _ inter_subset_right n1) (hl.supp_p _ inter_subset_right n2)
324 (prod_nonneg fun _ _ => Nat.cast_nonneg _) hQp
325 · intro D hD h
326 rw [prod_split hd hD (fun p => (p : ℝ))]
327 have hn : ∀ B : Finset ℕ, 0 ≤ ∏ p ∈ B, (p : ℝ) :=
328 fun B => prod_nonneg fun _ _ => Nat.cast_nonneg _
329 by_cases c : lm (D ∩ S) * yp (D ∩ T) = 0
330 · have c2 : lp (D ∩ S) * (yp (D ∩ T) - ym (D ∩ T)) ≠ 0 := by
331 intro c2; exact h (by simp only [c, c2, sub_zero])
332 obtain ⟨n1, n2⟩ := mul_ne_zero_iff.1 c2
333 exact (mul_le_mul (hs.supp_p _ inter_subset_right n1) (hl.supp_m _ inter_subset_right n2)
334 (hn _) hQp).trans h2
335 · obtain ⟨n1, n2⟩ := mul_ne_zero_iff.1 c
336 exact (mul_le_mul (hs.supp_m _ inter_subset_right n1) (hl.supp_p _ inter_subset_right n2)
337 (hn _) ((hn _).trans (hs.supp_m _ inter_subset_right n1))).trans h1
338 · rw [prod_union hd, hempS]
339 exact mul_le_mul hs.V_le hl.V_le hVT hMp
340 · rw [prod_union hd, hm0]
341 have e1 := hs.V_le
342 have e2 := hs.le_V
343 have e3 := hl.V_le
344 have e4 := hl.le_V
345 nlinarith [mul_nonneg (sub_nonneg.2 (e2.trans e1)) (sub_nonneg.2 e3),
346 mul_nonneg hMp (sub_nonneg.2 e4), mul_nonneg hVT (sub_nonneg.2 e2)]
347 · rw [hm0, hempS]
348 have e1 := mul_le_mul_of_nonneg_right hs.ratio hYp.le
349 have e2 := mul_le_mul_of_nonneg_left hl.loss hMp
350 nlinarith
351 · intro E hE
352 rw [cs_split hd hE, hempS, abs_mul, hcard E hE, prod_split hd hE, pow_add]
353 calc _ ≤ _ := mul_le_mul (hs.coef_p _ inter_subset_right) (hcp _ inter_subset_right)
354 (abs_nonneg _) ((abs_nonneg _).trans (hs.coef_p _ inter_subset_right))
355 _ = _ := by ring
356 · intro E hE
357 rw [hsplit E hE, hempS, hcard E hE, prod_split hd hE, pow_add]
358 have c1 := hs.coef_m (E ∩ S) inter_subset_right
359 have c2 := hs.coef_p (E ∩ S) inter_subset_right
360 have c3 := hcp (E ∩ T) inter_subset_right
361 have wS := hxpos (E ∩ S) (inter_subset_left.trans hE)
362 have wT := hxpos (E ∩ T) (inter_subset_left.trans hE)
363 have hpow : (12 : ℝ) ^ #(E ∩ S) ≤ 24 ^ #(E ∩ S) := by gcongr; norm_num
364 have hMY := mul_nonneg hMp hYp.le
365 set mS := ∏ p ∈ E ∩ S, x p
366 set mT := ∏ p ∈ E ∩ T, x p
367 set a := cs x S lp ∅
368 set y := cs x T yp ∅
369 have c2' : |cs x S lp (E ∩ S)| ≤ a * (24 ^ #(E ∩ S) * mS) :=
370 c2.trans (by gcongr)
371 have k1 : |cs x S lm (E ∩ S) * cs x T yp (E ∩ T)| ≤
372 (1 + t) * a * (24 ^ #(E ∩ S) * mS) * (y * (12 ^ #(E ∩ T) * mT)) := by
373 rw [abs_mul]
374 exact mul_le_mul c1 c3 (abs_nonneg _) ((abs_nonneg _).trans c1)
375 have hZ : 0 ≤ a * y * (24 ^ #(E ∩ S) * mS) := by positivity
376 by_cases h : E ∩ T = ∅
377 · have hmT : mT = 1 := by simp [mT, h]
378 have k2 : |cs x S lp (E ∩ S) * (cs x T yp (E ∩ T) - cs x T ym (E ∩ T))| ≤
379 a * (24 ^ #(E ∩ S) * mS) * (ε * y) := by
380 rw [abs_mul, h, abs_of_nonneg hl.loss_nonneg]
381 exact mul_le_mul c2' hl.loss hl.loss_nonneg ((abs_nonneg _).trans c2')
382 refine (abs_sub _ _).trans ((add_le_add k1 k2).trans ?_)
383 rw [hmT, h]
384 simp only [card_empty, pow_zero]
385 nlinarith
386 · have k2 : |cs x S lp (E ∩ S) * (cs x T yp (E ∩ T) - cs x T ym (E ∩ T))| ≤
387 a * (24 ^ #(E ∩ S) * mS) * (y * (12 ^ #(E ∩ T) * mT)) := by
388 rw [abs_mul]
389 exact mul_le_mul c2' (hl.coef_m _ inter_subset_right h) (abs_nonneg _)
390 ((abs_nonneg _).trans c2')
391 refine (abs_sub _ _).trans ((add_le_add k1 k2).trans ?_)
392 have hc : #(E ∩ T) ≠ 0 := card_ne_zero.2 (nonempty_iff_ne_empty.2 h)
393 have h24 : (2 : ℝ) * 12 ^ #(E ∩ T) ≤ 24 ^ #(E ∩ T) := by
394 rw [show (24 : ℝ) = 2 * 12 by norm_num, mul_pow]
395 gcongr
396 exact le_self_pow₀ (by norm_num) hc
397 calc _ = a * y * (24 ^ #(E ∩ S) * mS) * mT * (2 + t) * 12 ^ #(E ∩ T) := by ring
398 _ ≤ a * y * (24 ^ #(E ∩ S) * mS) * mT * ((1 + (t + ε)) * 2) * 12 ^ #(E ∩ T) := by
399 gcongr; linarith
400 _ = a * y * (24 ^ #(E ∩ S) * mS) * mT * (1 + (t + ε)) * (2 * 12 ^ #(E ∩ T)) := by ring
401 _ ≤ a * y * (24 ^ #(E ∩ S) * mS) * mT * (1 + (t + ε)) * 24 ^ #(E ∩ T) := by
402 have : 0 ≤ a * y * (24 ^ #(E ∩ S) * mS) * mT * (1 + (t + ε)) := by positivity
403 exact mul_le_mul_of_nonneg_left h24 this
404 _ = _ := by ring
405
406lemma one_sub_sum_le (x : ℕ → ℝ) (T : Finset ℕ) (hx : ∀ p ∈ T, 0 ≤ x p ∧ x p ≤ 1) :
407 1 - ∑ p ∈ T, x p ≤ ∏ p ∈ T, (1 - x p) := by
408 induction T using Finset.induction_on with
409 | empty => simp
410 | insert a s ha ih =>
411 have hs : ∀ p ∈ s, 0 ≤ x p ∧ x p ≤ 1 := fun p hp => hx p (mem_insert_of_mem hp)
412 have hxa := hx a (mem_insert_self a s)
413 have hV : ∏ p ∈ s, (1 - x p) ≤ 1 :=
414 prod_le_one₀ (fun p hp => by linarith [(hs p hp).2]) fun p hp => by linarith [(hs p hp).1]
415 rw [sum_insert ha, prod_insert ha]
416 nlinarith [ih hs]
417
418/-- The truncated Möbius functions form a layer. -/
419lemma layer_tr (x : ℕ → ℝ) (T : Finset ℕ) (hx : ∀ p ∈ T, 0 ≤ x p ∧ x p ≤ 1)
420 (hL : ∑ p ∈ T, x p ≤ 3 / 4) {b : ℕ} (hb : Even b) {w ε : ℝ} (hw : 1 ≤ w)
421 (hTw : ∀ p ∈ T, (p : ℝ) ≤ w) (hε : 4 * ((3 / 4) ^ (b + 1) / ((b + 1).factorial : ℝ)) ≤ ε) :
422 Layer x T ε w b (tr b) (tr (b + 1)) := by
423 have hL0 : 0 ≤ ∑ p ∈ T, x p := sum_nonneg fun p hp => (hx p hp).1
424 have hV := one_sub_sum_le x T hx
425 have hb1 := bonf x T hx b
426 have hb2 := bonf x T hx (b + 1)
427 rw [pow_succ, hb.neg_one_pow] at hb2
428 rw [hb.neg_one_pow] at hb1
429 rw [← cs_empty] at hb1 hb2
430 have hR : ∀ (R : Finset ℕ) (c : ℕ), 0 ≤ (-1 : ℝ) ^ c * (∑ B ∈ R.powerset, tr c B -
431 if R = ∅ then 1 else 0) := fun R c => by
432 have := bonf (fun _ => 1) R (by simp) c
433 simpa [prod_const, zero_pow_eq] using this
434 have habs : ∀ c B, |tr c B| ≤ 1 := fun c B => by
435 unfold tr; split_ifs <;> simp
436 have hdiff : ∀ B, tr b B - tr (b + 1) B = if #B = b + 1 then 1 else 0 := fun B => by
437 unfold tr
438 rcases lt_trichotomy #B (b + 1) with h | h | h
439 · rw [if_pos (by omega), if_pos (by omega), if_neg (by omega), sub_self]
440 · rw [if_neg (by omega), if_pos (by omega), if_pos h, h, pow_succ, hb.neg_one_pow]; norm_num
441 · rw [if_neg (by omega), if_neg (by omega), if_neg (by omega), sub_self]
442 have hloss : cs x T (tr b) ∅ - cs x T (tr (b + 1)) ∅ =
443 ∑ B ∈ T.powerset with #B = b + 1, ∏ p ∈ B, x p := by
444 rw [← cs_sub, cs_empty, sum_filter]
445 exact sum_congr rfl fun B _ => by rw [hdiff]; split_ifs <;> simp
446 have hsupp : ∀ D ⊆ T, ∀ c, #D ≤ c → (∏ p ∈ D, (p : ℝ)) ≤ w ^ c := fun D hD c hc =>
447
448 calc (∏ p ∈ D, (p : ℝ)) ≤ ∏ _p ∈ D, w :=
449 prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) fun p hp => hTw p (hD hp)
450 _ = w ^ #D := prod_const w
451 _ ≤ w ^ c := pow_le_pow_right₀ hw hc
452 have hexp : ∏ p ∈ T, (1 + x p) ≤ 3 := by
453 calc ∏ p ∈ T, (1 + x p) ≤ ∏ p ∈ T, Real.exp (x p) :=
454 prod_le_prod₀ (fun p hp => by linarith [(hx p hp).1]) fun p _ => by
455 linarith [Real.add_one_le_exp (x p)]
456 _ = Real.exp (∑ p ∈ T, x p) := (Real.exp_sum _ _).symm
457 _ ≤ Real.exp 1 := Real.exp_le_exp.2 (by linarith)
458 _ ≤ 3 := by linarith [Real.exp_one_lt_d9]
459 have hcoef : ∀ f : Finset ℕ → ℝ, (∀ B, |f B| ≤ 1) → ∀ F ⊆ T, F ≠ ∅ →
460 |cs x T f F| ≤ cs x T (tr b) ∅ * (12 ^ #F * ∏ p ∈ F, x p) := fun f hf F hF hne => by
461 have h1 := abs_cs_le x (fun p hp => (hx p hp).1) hF f hf
462 have hwF : 0 ≤ ∏ p ∈ F, x p := prod_nonneg fun p hp => (hx p (hF hp)).1
463 have h12 : (12 : ℝ) ≤ 12 ^ #F :=
464 le_self_pow₀ (by norm_num) (card_ne_zero.2 (nonempty_iff_ne_empty.2 hne))
465 have hM : (1 : ℝ) / 4 ≤ cs x T (tr b) ∅ := by linarith
466 calc _ ≤ (∏ p ∈ F, x p) * 3 := h1.trans (by gcongr)
467 _ ≤ (∏ p ∈ F, x p) * (cs x T (tr b) ∅ * 12 ^ #F) := by
468 gcongr; nlinarith
469 _ = _ := by ring
470 refine ⟨?_, ?_, habs b, ?_, ?_, by linarith, by linarith, by linarith, ?_, ?_,
471 hcoef _ (habs b), ?_⟩
472 · intro R _
473 have := hR R (b + 1)
474 rw [pow_succ, hb.neg_one_pow] at this
475 linarith
476 · intro R _
477 have := hR R b
478 rw [hb.neg_one_pow] at this
479 linarith
480 · intro D hD h
481 refine hsupp D hD b ?_
482 by_contra hc
483 exact h (by simp [tr, hc])
484 · intro D hD h
485 refine hsupp D hD (b + 1) ?_
486 by_contra hc
487 exact h (by rw [hdiff, if_neg (by omega)])
488 · rw [hloss]
489 exact sum_nonneg fun B hB => prod_nonneg fun p hp =>
490 (hx p (mem_powerset.1 (mem_filter.1 hB).1 hp)).1
491 · rw [hloss]
492 have h1 := esymm_le x T (fun p hp => (hx p hp).1) (b + 1)
493 have h2 : (∑ p ∈ T, x p) ^ (b + 1) / ((b + 1).factorial : ℝ) ≤
494 (3 / 4) ^ (b + 1) / ((b + 1).factorial : ℝ) := by gcongr
495 have hM : (1 : ℝ) / 4 ≤ cs x T (tr b) ∅ := by linarith
496 have h0 : (0 : ℝ) ≤ (3 / 4) ^ (b + 1) / ((b + 1).factorial : ℝ) := by positivity
497 nlinarith
498 · intro F hF hne
499 rw [← cs_sub]
500 exact hcoef _ (fun B => by rw [hdiff]; split_ifs <;> simp) F hF hne
501
502end E424.BH
503