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/T3.lean

All files · 144 lines · source at the verified commit

1module
2
3public import E424.Tools.T2
4public import E424.Tools.T10
5
6@[expose] public section
7
8/-!
9# Erdős 424: tool T3. Absolute existential constants; Mathlib only.
10-/
11
12set_option linter.style.header false
13open Finset
14
15namespace E424
16
17/-- Multiples of `d` in `(⌊x⌋, ⌊x+y⌋]`. -/
18lemma abs_card_multiples_le {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) {d : ℕ} (hd : 0 < d) :
19 |(#{n ∈ Ioc ⌊x⌋₊ ⌊x + y⌋₊ | d ∣ n} : ℝ) - y / d| ≤ 1 := by
20 have hab : ⌊x⌋₊ ≤ ⌊x + y⌋₊ := Nat.floor_le_floor (by linarith)
21 have hd' : (0 : ℝ) < d := by exact_mod_cast hd
22 have h1 : #{n ∈ Ioc 0 ⌊x + y⌋₊ | d ∣ n} =
23 #{n ∈ Ioc 0 ⌊x⌋₊ | d ∣ n} + #{n ∈ Ioc ⌊x⌋₊ ⌊x + y⌋₊ | d ∣ n} := by
24 rw [← card_union_of_disjoint, ← filter_union, Ioc_union_Ioc_eq_Ioc (Nat.zero_le _) hab]
25 exact disjoint_filter_filter (Ioc_disjoint_Ioc_of_le le_rfl)
26 rw [Nat.Ioc_filter_dvd_card_eq_div, Nat.Ioc_filter_dvd_card_eq_div, ← Nat.floor_div_natCast,
27 ← Nat.floor_div_natCast] at h1
28 have h2 : (⌊(x + y) / d⌋₊ : ℝ) =
29 ⌊x / d⌋₊ + (#{n ∈ Ioc ⌊x⌋₊ ⌊x + y⌋₊ | d ∣ n} : ℝ) := by exact_mod_cast h1
30 have a1 := Nat.floor_le (show 0 ≤ x / d by positivity)
31 have a2 := Nat.lt_floor_add_one (x / d)
32 have b1 := Nat.floor_le (show 0 ≤ (x + y) / d by positivity)
33 have b2 := Nat.lt_floor_add_one ((x + y) / d)
34 rw [add_div] at b1 b2
35 rw [← add_div] at b1 b2
36 have e : (x + y) / d = x / d + y / d := add_div _ _ _
37 rw [abs_le]
38 constructor <;> linarith
39
40/-- **T3**, rough numbers in intervals. -/
41theorem T3_rough_interval : ∃ C > 0, ∀ z y x : ℝ, 2 ≤ z → z ≤ y → 0 ≤ x →
42 ∀ s : Finset ℕ, (∀ n ∈ s, x < n ∧ (n : ℝ) ≤ x + y ∧ Rough z n) →
43 (s.card : ℝ) ≤ C * y / Real.log z := by
44 obtain ⟨c, C, K, -, hC, hK, hT2⟩ := T2_brun_hooley
45 obtain ⟨A, hA, hT10⟩ := T10_mertens_prod
46 have hK' : (2 : ℝ) ≤ K := by exact_mod_cast hK
47 have hlK : 0 < Real.log K := Real.log_pos (by linarith)
48 refine ⟨48 * Real.log K + 24 * C * A * Real.log K + 2, by positivity, ?_⟩
49 intro z y x hz hzy hx s hs
50 have hlz : 0 < Real.log z := Real.log_pos (by linarith)
51 have hy : 0 ≤ y := by linarith
52 set I := Ioc ⌊x⌋₊ ⌊x + y⌋₊ with hI
53 have hsI : s ⊆ I := fun n hn => by
54 obtain ⟨h1, h2, -⟩ := hs n hn
55 exact mem_Ioc.2 ⟨(Nat.floor_lt hx).2 h1, Nat.le_floor h2⟩
56 set w := z ^ ((1 : ℝ) / 24) with hw
57 have hw24 : w ^ 24 = z := by
58 rw [hw, ← Real.rpow_natCast, ← Real.rpow_mul (by linarith)]; norm_num
59 have hw1 : 1 ≤ w := Real.one_le_rpow (by linarith) (by norm_num)
60 have hlw : Real.log z = 24 * Real.log w := by
61 rw [← hw24, Real.log_pow]; norm_num
62 rw [le_div_iff₀ hlz]
63 rcases lt_or_ge w K with hwK | hwK
64 · have h1 : Real.log w ≤ Real.log K := Real.log_le_log (by linarith) hwK.le
65 have h2 : (#s : ℝ) ≤ 2 * y := by
66 have := abs_card_multiples_le hx hy one_pos
67 have h3 := (abs_le.1 this).2
68 simp only [one_dvd, filter_true, Nat.cast_one, div_one] at h3
69 have h4 : (#s : ℝ) ≤ #I := by exact_mod_cast card_le_card hsI
70 linarith
71 calc (#s : ℝ) * Real.log z ≤ 2 * y * (24 * Real.log K) := by
72 rw [hlw]; exact mul_le_mul h2 (by linarith) (by linarith) (by linarith)
73 _ = (48 * Real.log K) * y := by ring
74 _ ≤ _ := by
75 gcongr
76 have : 0 ≤ 24 * C * A * Real.log K := by positivity
77 linarith
78 · obtain ⟨lm, lp, hsupp, habs, hpt, -, hM, -⟩ := hT2 K w le_rfl hwK
79 set S := primesIoc K w with hSdef
80 set P := ∏ p ∈ S, p with hP
81 have hS : ∀ p ∈ S, p.Prime ∧ (p : ℝ) ≤ w := fun p hp => by
82 obtain ⟨h1, h2⟩ := mem_filter.1 hp
83 exact ⟨h2, (Nat.le_floor_iff (by linarith)).1 (mem_Ioc.1 h1).2⟩
84 have hlw0 : 0 < Real.log w := by linarith
85 have hV := (hT10 K w hK' hwK).2
86 set q := w ^ 12 with hq
87 have hqq : q * q = z := by rw [hq, ← hw24]; ring
88 have hwz : w ≤ z := by rw [← hw24]; exact le_self_pow₀ hw1 (by norm_num)
89 have hcop : ∀ n ∈ s, n.Coprime P := fun n hn => by
90 refine Nat.Coprime.prod_right fun p hp => ?_
91 rw [Nat.coprime_comm, (hS p hp).1.coprime_iff_not_dvd]
92 intro hpn
93 have := (hs n hn).2.2 p (hS p hp).1 hpn
94 linarith [(hS p hp).2]
95 have h1 : (#s : ℝ) ≤ ∑ n ∈ I, ∑ d ∈ P.divisors with d ∣ n, lp d := by
96 calc (#s : ℝ) = ∑ n ∈ s, if n.Coprime P then (1 : ℝ) else 0 := by
97 rw [sum_congr rfl fun n hn => if_pos (hcop n hn)]; simp
98 _ ≤ ∑ n ∈ I, if n.Coprime P then (1 : ℝ) else 0 :=
99 sum_le_sum_of_subset_of_nonneg hsI fun n _ _ => by split_ifs <;> norm_num
100 _ ≤ _ := sum_le_sum fun n _ => (hpt n).2
101 have h2 : ∑ n ∈ I, ∑ d ∈ P.divisors with d ∣ n, lp d =
102 ∑ d ∈ P.divisors, lp d * (#{n ∈ I | d ∣ n} : ℝ) := by
103 simp_rw [sum_filter]
104 rw [sum_comm]
105 refine sum_congr rfl fun d _ => ?_
106 rw [← sum_filter, sum_const, nsmul_eq_mul, mul_comm]
107 have h3 : ∑ d ∈ P.divisors, lp d * (#{n ∈ I | d ∣ n} : ℝ) ≤
108 y * (∑ d ∈ P.divisors, lp d / d) + ∑ d ∈ P.divisors, if (d : ℝ) ≤ q then 1 else 0 := by
109 rw [mul_sum, ← sum_add_distrib]
110 refine sum_le_sum fun d hd => ?_
111 split_ifs with hdq
112 · have e := abs_card_multiples_le hx hy (Nat.pos_of_mem_divisors hd)
113 have : lp d * ((#{n ∈ I | d ∣ n} : ℝ) - y / d) ≤ 1 := by
114 refine (le_abs_self _).trans ?_
115 rw [abs_mul]
116 exact mul_le_one₀ (habs d) (abs_nonneg _) e
117 calc _ = y * (lp d / d) + lp d * ((#{n ∈ I | d ∣ n} : ℝ) - y / d) := by ring
118 _ ≤ _ := by linarith
119 · rw [(hsupp d (not_le.1 hdq)).2]; simp
120 have hq0 : 0 < q := by positivity
121 have h4 : (∑ d ∈ P.divisors, if (d : ℝ) ≤ q then (1 : ℝ) else 0) ≤ q := by
122 rw [← sum_filter, sum_const, nsmul_eq_mul, mul_one]
123 have : #(P.divisors.filter fun d : ℕ => (d : ℝ) ≤ q) ≤ #(Ioc 0 ⌊q⌋₊) := card_le_card fun d hd => by
124 obtain ⟨a, b⟩ := mem_filter.1 hd
125 exact mem_Ioc.2 ⟨Nat.pos_of_mem_divisors a, Nat.le_floor b⟩
126 rw [Nat.card_Ioc, Nat.sub_zero] at this
127 exact (Nat.cast_le.2 this).trans (Nat.floor_le hq0.le)
128 have h5 : q * Real.log z ≤ 2 * y := by
129 have e1 : Real.log z = 2 * Real.log q := by
130 rw [← hqq, Real.log_mul hq0.ne' hq0.ne']; ring
131 have e2 := Real.log_le_sub_one_of_pos hq0
132 nlinarith
133 have h6 : (y * ∑ d ∈ P.divisors, lp d / d) * Real.log z ≤ 24 * C * A * Real.log K * y := by
134 calc _ ≤ (y * (C * (A * Real.log K / Real.log w))) * Real.log z := by
135 gcongr
136 exact hM.trans (by gcongr)
137 _ = _ := by rw [hlw]; field_simp
138 calc (#s : ℝ) * Real.log z ≤ (y * (∑ d ∈ P.divisors, lp d / d) + q) * Real.log z := by
139 gcongr; linarith
140 _ ≤ 24 * C * A * Real.log K * y + 2 * y := by rw [add_mul]; linarith
141 _ ≤ _ := by nlinarith [mul_nonneg hlK.le hy]
142
143end E424
144