Lean / Reader
Lean reader

Erdos824Primitive.lean

579 lines33 declarations1 × sorry / admit / native_decideimports Mathlib.NumberTheory.ArithmeticFunction.Misc Mathlib.NumberTheory.Harmonic.Bounds Mathlib.Analysis.SpecialFunctions.Log.Summable Mathlib.Analysis.SpecialFunctions.Pow.NNReal Mathlib.Analysis.Normed.Ring.InfiniteSum Mathlib.Analysis.PSeries +1
  1. import Mathlib.NumberTheory.ArithmeticFunction.Misc
  2. import Mathlib.NumberTheory.Harmonic.Bounds
  3. import Mathlib.Analysis.SpecialFunctions.Log.Summable
  4. import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
  5. import Mathlib.Analysis.Normed.Ring.InfiniteSum
  6. import Mathlib.Analysis.PSeries
  7. import Mathlib.Tactic
  8. /-!
  9. # Unitary-primitive pairs with equal divisor sums
  10. The maximum-coordinate counting exponent for all coprime equal-divisor-sum
  11. pairs equals that for pairs admitting no nontrivial unitary divisor collision.
  12. Theorem `upper_exponents_equal` compares the upper counting exponents.
  13. Theorem `eventually_superpolylog_primitive` gives a uniform lower bound under
  14. a uniform near-quadratic hypothesis. Both work in any divisor-closed class of
  15. integers, including squarefree integers.
  16. -/
  17. namespace Erdos824Primitive
  18. open ArithmeticFunction
  19. def EqualPair (a b : ℕ) : Prop :=
  20. 1 < a ∧ 1 < b ∧ a.Coprime b ∧ sigma 1 a = sigma 1 b
  21. /-- A nontrivial unitary divisor in each coordinate, with equal divisor sums. -/
  22. def Splits (a b : ℕ) : Prop :=
  23. ∃ u v c d : ℕ, 1 < u ∧ 1 < v ∧ 1 < c ∧ 1 < d ∧ a = u*c ∧ b = v*d ∧
  24. u.Coprime c ∧ v.Coprime d ∧ sigma 1 u = sigma 1 v
  25. theorem splits_iff_unitary_divisors (a b : ℕ) :
  26. Splits a b ↔ ∃ u v : ℕ, 1 < u ∧ u < a ∧ u ∣ a ∧ 1 < v ∧ v < b ∧ v ∣ b ∧
  27. u.Coprime (a/u) ∧ v.Coprime (b/v) ∧ sigma 1 u = sigma 1 v := by
  28. constructor
  29. · rintro ⟨u, v, c, d, hu, hv, hc, hd, rfl, rfl, huc, hvd, hsig⟩
  30. refine ⟨u, v, hu, by nlinarith, dvd_mul_right _ _, hv, by nlinarith,
  31. dvd_mul_right _ _, ?_, ?_, hsig⟩
  32. · simpa [Nat.mul_div_cancel_left _ (by omega : 0 < u)] using huc
  33. · simpa [Nat.mul_div_cancel_left _ (by omega : 0 < v)] using hvd
  34. · rintro ⟨u, v, hu, hua, ⟨c, rfl⟩, hv, hvb, ⟨d, rfl⟩, huc, hvd, hsig⟩
  35. have hc : 1 < c := by by_contra! h; interval_cases c <;> simp_all
  36. have hd : 1 < d := by by_contra! h; interval_cases d <;> simp_all
  37. refine ⟨u, v, c, d, hu, hv, hc, hd, rfl, rfl, ?_, ?_, hsig⟩
  38. · simpa [Nat.mul_div_cancel_left _ (by omega : 0 < u)] using huc
  39. · simpa [Nat.mul_div_cancel_left _ (by omega : 0 < v)] using hvd
  40. def Primitive (p : ℕ × ℕ) : Prop :=
  41. EqualPair p.1 p.2 ∧ ¬ Splits p.1 p.2
  42. abbrev AtomFamily (A : ℕ → Prop) :=
  43. {p : ℕ × ℕ // Primitive p ∧ A p.1 ∧ A p.2}
  44. abbrev PairFamily (A : ℕ → Prop) :=
  45. {p : ℕ × ℕ // EqualPair p.1 p.2 ∧ A p.1 ∧ A p.2}
  46. theorem factorization (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u)
  47. (a b : ℕ) (hit : EqualPair a b) (ha : A a) (hb : A b) :
  48. ∃ S : Finset (AtomFamily A), (∏ p ∈ S, p.val.1) = a ∧ (∏ p ∈ S, p.val.2) = b := by
  49. classical
  50. induction a using Nat.strong_induction_on generalizing b with
  51. | h a ih =>
  52. by_cases hs : Splits a b
  53. · obtain ⟨u, v, c, d, hu, hv, hc, hd, rfl, rfl, huc, hvd, huv⟩ := hs
  54. obtain ⟨_, _, hcop, heq⟩ := hit
  55. have hcu : 0 < sigma 1 u := sigma_pos_iff.mpr (by omega)
  56. rw [isMultiplicative_sigma.map_mul_of_coprime huc,
  57. isMultiplicative_sigma.map_mul_of_coprime hvd, ← huv] at heq
  58. have hcd : sigma 1 c = sigma 1 d := Nat.eq_of_mul_eq_mul_left hcu heq
  59. have hu_lt : u < u*c := by nlinarith
  60. have hc_lt : c < u*c := by nlinarith
  61. have hu_dvd : u ∣ u*c := dvd_mul_right _ _
  62. have hv_dvd : v ∣ v*d := dvd_mul_right _ _
  63. have hc_dvd : c ∣ u*c := dvd_mul_left _ _
  64. have hd_dvd : d ∣ v*d := dvd_mul_left _ _
  65. obtain ⟨L, hL, hLp⟩ := ih u hu_lt v
  66. ⟨hu, hv, Nat.Coprime.of_dvd hu_dvd hv_dvd hcop, huv⟩
  67. (closed hu_dvd ha) (closed hv_dvd hb)
  68. obtain ⟨R, hR, hRp⟩ := ih c hc_lt d
  69. ⟨hc, hd, Nat.Coprime.of_dvd hc_dvd hd_dvd hcop, hcd⟩
  70. (closed hc_dvd ha) (closed hd_dvd hb)
  71. have hdis : Disjoint L R := by
  72. apply Finset.disjoint_left.mpr
  73. intro p hpL hpR
  74. have hpu := Finset.dvd_prod_of_mem (fun q : AtomFamily A ↦ q.val.1) hpL
  75. have hpc := Finset.dvd_prod_of_mem (fun q : AtomFamily A ↦ q.val.1) hpR
  76. rw [hL] at hpu
  77. rw [hR] at hpc
  78. exact p.property.1.1.1.ne' (Nat.eq_one_of_dvd_coprimes huc hpu hpc)
  79. exact ⟨L ∪ R, by rw [Finset.prod_union hdis, hL, hR],
  80. by rw [Finset.prod_union hdis, hLp, hRp]⟩
  81. · let q : AtomFamily A := ⟨(a,b), ⟨hit, hs⟩, ha, hb⟩
  82. exact ⟨{q}, by simp [q], by simp [q]⟩
  83. /-- The positive Dirichlet weight at exponent s, using the product of the two coordinates. -/
  84. noncomputable def weight (s : ℝ) (p : ℕ × ℕ) : ℝ := ((p.1 * p.2 : ℕ) : ℝ) ^ (-s)
  85. private theorem weight_prod (A : ℕ → Prop) (s : ℝ) (S : Finset (AtomFamily A)) :
  86. (∏ p ∈ S, weight s p.val) = weight s ((∏ p ∈ S, p.val.1), (∏ p ∈ S, p.val.2)) := by
  87. classical
  88. induction S using Finset.induction_on with
  89. | empty => simp [weight]
  90. | insert p S hp ih =>
  91. simp only [Finset.prod_insert hp]
  92. rw [ih]
  93. simp only [weight, Nat.cast_mul]
  94. rw [← Real.mul_rpow (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))
  95. (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))]
  96. congr 1
  97. ring
  98. private theorem representations (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u) :
  99. ∃ rep : PairFamily A → Finset (AtomFamily A), Function.Injective rep ∧
  100. (∀ p, (∏ q ∈ rep p, q.val.1) = p.val.1) ∧ (∀ p, (∏ q ∈ rep p, q.val.2) = p.val.2) := by
  101. classical
  102. have reps (p : PairFamily A) := factorization A closed p.val.1 p.val.2
  103. p.property.1 p.property.2.1 p.property.2.2
  104. choose rep hfst hsnd using reps
  105. have hinj : Function.Injective rep := by
  106. intro p q hpq
  107. apply Subtype.ext
  108. apply Prod.ext
  109. · rw [← hfst p, hpq, hfst q]
  110. · rw [← hsnd p, hpq, hsnd q]
  111. exact ⟨rep, hinj, hfst, hsnd⟩
  112. set_option maxHeartbeats 600000 in
  113. /-- Primitive pairs and all admissible pairs have the same Dirichlet convergence set. -/
  114. theorem summable_iff_primitive (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u) (s : ℝ) :
  115. Summable (fun p : PairFamily A ↦ weight s p.val) ↔
  116. Summable (fun p : AtomFamily A ↦ weight s p.val) := by
  117. classical
  118. constructor
  119. · intro hs
  120. let incl : AtomFamily A → PairFamily A := fun p ↦ ⟨p.val, p.property.1.1, p.property.2⟩
  121. have hi : Function.Injective incl := fun _ _ h ↦
  122. Subtype.ext (congrArg (fun q : PairFamily A ↦ q.val) h)
  123. have hiSum := hs.comp_injective hi
  124. exact hiSum
  125. · intro hs
  126. obtain ⟨rep, hinj, hfst, hsnd⟩ := representations A closed
  127. have hn (p : AtomFamily A) : 0 ≤ weight s p.val := by unfold weight; positivity
  128. have hh := (summable_finsetProd_of_summable_nonneg hn hs).comp_injective hinj
  129. apply hh.congr
  130. intro p
  131. change (∏ q ∈ rep p, weight s q.val) = weight s p.val
  132. rw [weight_prod, hfst, hsnd]
  133. private theorem sigma_le (n : ℕ) :
  134. (sigma 1 n : ℝ) ≤ n * (1 + Real.log n) := by
  135. calc
  136. (sigma 1 n : ℝ) = ∑ d ∈ n.divisors, (↑(n / d) : ℝ) := by
  137. simp only [sigma_eq_sum_div, pow_one, Nat.cast_sum]
  138. _ = ∑ d ∈ n.divisors, (n : ℝ) * (d : ℝ)⁻¹ := by
  139. apply Finset.sum_congr rfl
  140. intro d hd
  141. rw [Nat.cast_div (Nat.mem_divisors.mp hd).1 (by exact_mod_cast (Nat.pos_of_mem_divisors hd).ne'), div_eq_mul_inv]
  142. _ = n * (∑ d ∈ n.divisors, (d : ℝ)⁻¹) := (Finset.mul_sum ..).symm
  143. _ ≤ n * (harmonic n : ℝ) := by
  144. apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg n)
  145. simp only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast]
  146. apply Finset.sum_le_sum_of_subset_of_nonneg _ (by intros; positivity)
  147. intro d hd
  148. exact Finset.mem_Icc.mpr ⟨Nat.pos_of_mem_divisors hd,
  149. Nat.le_of_dvd (Nat.pos_of_ne_zero (Nat.mem_divisors.mp hd).2) (Nat.mem_divisors.mp hd).1⟩
  150. _ ≤ n * (1 + Real.log n) := mul_le_mul_of_nonneg_left (harmonic_le_one_add_log n) (Nat.cast_nonneg _)
  151. private theorem self_le_sigma (n : ℕ) (hn : 0 < n) : n ≤ sigma 1 n := by
  152. rw [sigma_one_apply]
  153. exact Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) (Nat.mem_divisors_self n hn.ne')
  154. /-- Converting between the maximum-coordinate and product cutoffs costs only a logarithm. -/
  155. theorem height_bound (a b : ℕ) (hit : EqualPair a b) :
  156. (max (a : ℝ) b)^2 ≤ (a*b : ℕ) * (1 + Real.log (max (a : ℝ) b)) := by
  157. obtain ⟨ha, hb, _, hsig⟩ := hit
  158. have aux (u v : ℕ) (hv : 0 < v) (hu : 0 < u) (huv : u ≤ v) (hσ : sigma 1 u = sigma 1 v) :
  159. (v : ℝ)^2 ≤ ((u*v : ℕ) : ℝ) * (1 + Real.log v) := by
  160. have hlog := Real.log_le_log (by exact_mod_cast hu) (by exact_mod_cast huv : (u : ℝ) ≤ v)
  161. have h1 : (v : ℝ) ≤ (u : ℝ) * (1 + Real.log v) := by
  162. calc (v : ℝ) ≤ sigma 1 v := by exact_mod_cast self_le_sigma v hv
  163. _ = (sigma 1 u : ℝ) := by rw [hσ]
  164. _ ≤ _ := (sigma_le u).trans (mul_le_mul_of_nonneg_left (by linarith) (Nat.cast_nonneg u))
  165. push_cast
  166. nlinarith [mul_le_mul_of_nonneg_left h1 (Nat.cast_nonneg v)]
  167. rcases le_total a b with hab | hba
  168. · rw [max_eq_right (by exact_mod_cast hab)]
  169. exact aux a b (by omega) (by omega) hab hsig
  170. · rw [max_eq_left (by exact_mod_cast hba), Nat.mul_comm a b]
  171. exact aux b a (by omega) (by omega) hba hsig.symm
  172. noncomputable def high (p : ℕ × ℕ) : ℝ := max (p.1 : ℝ) p.2
  173. private theorem high_weight_le (t : ℝ) (ht : 0 ≤ t) (p : ℕ × ℕ) (hp : EqualPair p.1 p.2) :
  174. high p ^ (-(2*t)) ≤ weight t p := by
  175. let m := high p
  176. have hm : 0 < m := lt_of_lt_of_le (by exact_mod_cast (show 0 < p.1 by have := hp.1; omega))
  177. (le_max_left _ _)
  178. have hw : 0 < ((p.1*p.2 : ℕ) : ℝ) := by
  179. have := hp.1; have := hp.2.1; exact_mod_cast Nat.mul_pos (by omega) (by omega)
  180. have hwm : ((p.1*p.2 : ℕ) : ℝ) ≤ m^2 := by
  181. rw [Nat.cast_mul, sq]; exact mul_le_mul (le_max_left _ _) (le_max_right _ _) (Nat.cast_nonneg _) hm.le
  182. change m ^ (-(2*t)) ≤ _
  183. rw [show -(2*t) = 2 * (-t) by ring, Real.rpow_mul hm.le]
  184. simpa only [Real.rpow_two, weight] using Real.rpow_le_rpow_of_nonpos hw hwm (neg_nonpos.mpr ht)
  185. private theorem weight_domination (t r : ℝ) (ht : 0 < t) (hr : r < 2*t) :
  186. ∃ C : ℝ, 0 < C ∧ ∀ p : ℕ × ℕ, EqualPair p.1 p.2 →
  187. weight t p ≤ C * high p ^ (-r) := by
  188. let δ := (2*t-r)/t
  189. have hδ : 0 < δ := div_pos (sub_pos.mpr hr) ht
  190. let K := 1 + 1/δ
  191. have hK : 0 < K := by dsimp [K]; positivity
  192. refine ⟨K^t, Real.rpow_pos_of_pos hK _, ?_⟩
  193. intro p hp
  194. let m := high p
  195. let w : ℝ := (p.1*p.2 : ℕ)
  196. have hm1 : 1 ≤ m := le_trans (by exact_mod_cast hp.1.le) (le_max_left _ _)
  197. have hm : 0 < m := zero_lt_one.trans_le hm1
  198. have hw : 0 < w := by
  199. dsimp [w]
  200. have := hp.1; have := hp.2.1; exact_mod_cast Nat.mul_pos (by omega) (by omega)
  201. have hδm : 1 ≤ m^δ := Real.one_le_rpow hm1 hδ.le
  202. have hlog : 1 + Real.log m ≤ K * m^δ := by
  203. calc 1 + Real.log m ≤ m^δ + m^δ / δ := add_le_add hδm (Real.log_le_rpow_div hm.le hδ)
  204. _ = K * m^δ := by dsimp [K]; ring
  205. have hbound : m^(2-δ) ≤ w*K := by
  206. apply (mul_le_mul_iff_left₀ (Real.rpow_pos_of_pos hm δ)).mp
  207. calc m^(2-δ) * m^δ = m^2 := by rw [← Real.rpow_add hm, sub_add_cancel, Real.rpow_two]
  208. _ ≤ w * (1 + Real.log m) := height_bound _ _ hp
  209. _ ≤ w * (K * m^δ) := mul_le_mul_of_nonneg_left hlog hw.le
  210. _ = _ := by ring
  211. have hexp : (2-δ)*t = r := by dsimp [δ]; field_simp; ring
  212. have hkey := Real.rpow_le_rpow (Real.rpow_nonneg hm.le _) hbound ht.le
  213. rw [← Real.rpow_mul hm.le, hexp, Real.mul_rpow hw.le hK.le] at hkey
  214. change w^(-t) ≤ K^t * m^(-r)
  215. rw [Real.rpow_neg hw.le, Real.rpow_neg hm.le, ← div_eq_mul_inv, le_div_iff₀ (Real.rpow_pos_of_pos hm _)]
  216. rw [inv_mul_eq_div, div_le_iff₀ (Real.rpow_pos_of_pos hw _)]
  217. linarith only [hkey, mul_comm (w^t) (K^t)]
  218. /-- Convergence at one maximum-coordinate exponent for primitive pairs implies
  219. convergence at every larger positive exponent for all pairs. -/
  220. theorem high_summable_transfer (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u)
  221. {r s : ℝ} (hs : 0 < s) (hrs : r < s)
  222. (h : Summable (fun p : AtomFamily A ↦ high p.val ^ (-r))) :
  223. Summable (fun p : PairFamily A ↦ high p.val ^ (-s)) := by
  224. let t := s/2
  225. have ht : 0 < t := half_pos hs
  226. have htwo : 2*t = s := by dsimp [t]; ring
  227. obtain ⟨C, _, hC⟩ := weight_domination t r ht (by simpa only [htwo] using hrs)
  228. have hatom : Summable (fun p : AtomFamily A ↦ weight t p.val) :=
  229. (h.mul_left C).of_nonneg_of_le (by intro p; unfold weight; positivity)
  230. (fun p ↦ hC p.val p.property.1.1)
  231. have hall := (summable_iff_primitive A closed t).mpr hatom
  232. apply hall.of_nonneg_of_le
  233. · intro p; apply Real.rpow_nonneg; exact (Nat.cast_nonneg p.val.1).trans (le_max_left _ _)
  234. · intro p; simpa only [htwo] using high_weight_le t ht.le p.val p.property.1
  235. /-- Uniform polynomial bound on all finite subsets of a height cutoff. -/
  236. def PowerBound {ι : Type*} (M : ι → ℕ) (r : ℝ) : Prop :=
  237. ∃ C : ℝ, 0 < C ∧ ∀ X : ℕ, 0 < X → ∀ T : Finset ι,
  238. (∀ p ∈ T, M p ≤ X) → (T.card : ℝ) ≤ C * (X : ℝ)^r
  239. theorem powerBound_of_summable {ι : Type*} (M : ι → ℕ) (pos : ∀ p, 0 < M p)
  240. {s : ℝ} (hs : 0 ≤ s) (h : Summable (fun p ↦ (M p : ℝ)^(-s))) : PowerBound M s := by
  241. let C := max 1 (∑' p, (M p : ℝ)^(-s))
  242. refine ⟨C, zero_lt_one.trans_le (le_max_left _ _), ?_⟩
  243. intro X hX T hT
  244. have hx : 0 < (X : ℝ) := by exact_mod_cast hX
  245. have bound : (T.card : ℝ) * (X : ℝ)^(-s) ≤ C := by
  246. calc _ = ∑ _p ∈ T, (X : ℝ)^(-s) := by simp
  247. _ ≤ ∑ p ∈ T, (M p : ℝ)^(-s) := by
  248. apply Finset.sum_le_sum
  249. intro p hp
  250. exact Real.rpow_le_rpow_of_nonpos (by exact_mod_cast pos p) (by exact_mod_cast hT p hp) (by linarith)
  251. _ ≤ _ := (h.sum_le_tsum T (by intro i _; positivity)).trans (le_max_right _ _)
  252. rw [Real.rpow_neg hx.le, ← div_eq_mul_inv] at bound
  253. exact (div_le_iff₀ (Real.rpow_pos_of_pos hx _)).mp bound
  254. private lemma dyadic_rpow (k : ℕ) (r : ℝ) : ((2 : ℝ)^k)^r = ((2 : ℝ)^r)^k := by
  255. rw [← Real.rpow_natCast_mul (by norm_num), mul_comm, Real.rpow_mul_natCast (by norm_num)]
  256. theorem summable_of_powerBound {ι : Type*} (M : ι → ℕ) (pos : ∀ p, 0 < M p)
  257. {r t : ℝ} (hr : 0 ≤ r) (hrt : r < t) (h : PowerBound M r) :
  258. Summable (fun p ↦ (M p : ℝ)^(-t)) := by
  259. classical
  260. obtain ⟨C, hC, hcount⟩ := h
  261. let band (p : ι) := Nat.log 2 (M p)
  262. let q := (2 : ℝ)^(r-t)
  263. have hq : 0 < q := Real.rpow_pos_of_pos (by norm_num) _
  264. have hq1 : q < 1 := Real.rpow_lt_one_of_one_lt_of_neg (by norm_num) (sub_neg.mpr hrt)
  265. have hseries : Summable (fun k : ℕ ↦ (C * (2 : ℝ)^r) * q^k) :=
  266. (summable_geometric_of_lt_one hq.le hq1).mul_left _
  267. apply summable_of_sum_le (c := ∑' k : ℕ, (C * (2 : ℝ)^r)*q^k) (by intro p; positivity)
  268. intro S
  269. calc ∑ p ∈ S, (M p : ℝ)^(-t)
  270. = ∑ k ∈ S.image band, ∑ p ∈ S.filter (fun p ↦ band p = k), (M p : ℝ)^(-t) :=
  271. (Finset.sum_fiberwise_of_maps_to (fun p hp ↦ Finset.mem_image_of_mem band hp) _).symm
  272. _ ≤ ∑ k ∈ S.image band, (C * (2 : ℝ)^r)*q^k := by
  273. apply Finset.sum_le_sum
  274. intro k _
  275. let V := S.filter (fun p ↦ band p = k)
  276. have hk (p : ι) (hp : p ∈ V) : Nat.log 2 (M p) = k := (Finset.mem_filter.mp hp).2
  277. have hN := hcount (2^(k+1)) (by positivity) V (fun p hp ↦ by
  278. have hlt := Nat.lt_pow_succ_log_self (by decide : 1 < 2) (M p)
  279. rw [hk p hp] at hlt
  280. exact hlt.le)
  281. change ∑ p ∈ V, (M p : ℝ)^(-t) ≤ _
  282. calc ∑ p ∈ V, (M p : ℝ)^(-t) ≤ ∑ _p ∈ V, ((2 : ℝ)^k)^(-t) := by
  283. apply Finset.sum_le_sum
  284. intro p hp
  285. have hlow := Nat.pow_log_le_self 2 (pos p).ne'
  286. rw [hk p hp] at hlow
  287. exact Real.rpow_le_rpow_of_nonpos (by positivity) (by exact_mod_cast hlow) (by linarith)
  288. _ = (V.card : ℝ) * ((2 : ℝ)^k)^(-t) := by simp
  289. _ ≤ (C * ((2 : ℝ)^(k+1))^r) * ((2 : ℝ)^k)^(-t) :=
  290. mul_le_mul_of_nonneg_right (by exact_mod_cast hN) (by positivity)
  291. _ = _ := by
  292. rw [dyadic_rpow (k+1) r, dyadic_rpow k (-t), pow_succ]
  293. dsimp [q]
  294. rw [sub_eq_add_neg, Real.rpow_add (by norm_num : (0 : ℝ) < 2), mul_pow]
  295. ring
  296. _ ≤ _ := hseries.sum_le_tsum _ (by intro k _; positivity)
  297. def maxCoordinate (p : ℕ × ℕ) : ℕ := max p.1 p.2
  298. private theorem cast_maxCoordinate (p : ℕ × ℕ) : (maxCoordinate p : ℝ) = high p :=
  299. Nat.cast_max _ _
  300. private theorem maxCoordinate_pos {p : ℕ × ℕ} (h : EqualPair p.1 p.2) : 0 < maxCoordinate p :=
  301. (zero_lt_one.trans h.1).trans_le (le_max_left _ _)
  302. /-- A polynomial bound for primitive pairs gives every strictly weaker polynomial
  303. bound for all pairs. The cutoff is the maximum of the two coordinates. -/
  304. theorem powerBound_transfer (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u)
  305. {r s : ℝ} (hr : 0 ≤ r) (hrs : r < s)
  306. (h : PowerBound (fun p : AtomFamily A ↦ maxCoordinate p.val) r) :
  307. PowerBound (fun p : PairFamily A ↦ maxCoordinate p.val) s := by
  308. let t := (r+s)/2
  309. have hrt : r < t := by dsimp [t]; linarith
  310. have hts : t < s := by dsimp [t]; linarith
  311. have hA := summable_of_powerBound _ (fun p ↦ maxCoordinate_pos p.property.1.1) hr hrt h
  312. simp only [cast_maxCoordinate] at hA
  313. have hP := high_summable_transfer A closed (hr.trans_lt hrs) hts hA
  314. apply powerBound_of_summable _ (fun p ↦ maxCoordinate_pos p.property.1) (hr.trans hrs.le)
  315. simpa only [cast_maxCoordinate] using hP
  316. /-- The nonnegative upper counting exponents, expressed by uniform polynomial
  317. bounds at every strictly larger exponent, agree for primitive and all pairs. -/
  318. theorem upper_exponents_equal (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u) :
  319. {r : ℝ | 0 ≤ r ∧ ∀ s, r < s → PowerBound (fun p : PairFamily A ↦ maxCoordinate p.val) s} =
  320. {r : ℝ | 0 ≤ r ∧ ∀ s, r < s → PowerBound (fun p : AtomFamily A ↦ maxCoordinate p.val) s} := by
  321. classical
  322. ext r
  323. constructor
  324. · rintro ⟨hr, h⟩
  325. refine ⟨hr, fun s hs ↦ ?_⟩
  326. obtain ⟨C, hC, hc⟩ := h s hs
  327. let incl : AtomFamily A → PairFamily A := fun p ↦ ⟨p.val, p.property.1.1, p.property.2⟩
  328. have hi : Function.Injective incl := fun _ _ he ↦ Subtype.ext (congrArg (fun q : PairFamily A ↦ q.val) he)
  329. refine ⟨C, hC, ?_⟩
  330. intro X hX T hT
  331. have hinc (p : PairFamily A) (hp : p ∈ T.image incl) : maxCoordinate p.val ≤ X := by
  332. obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hp
  333. exact hT a ha
  334. simpa only [Finset.card_image_of_injective _ hi] using hc X hX (T.image incl) hinc
  335. · rintro ⟨hr, h⟩
  336. refine ⟨hr, fun s hs ↦ ?_⟩
  337. let t := (r+s)/2
  338. have hrt : r < t := by dsimp [t]; linarith
  339. have hts : t < s := by dsimp [t]; linarith
  340. exact powerBound_transfer A closed (hr.trans hrt.le) hts (h t hrt)
  341. /-- For either orientation there are at most (X+1)^2 pairs below a cutoff. -/
  342. private theorem cutoff_bound (A : ℕ → Prop) (T : Finset (AtomFamily A)) (X : ℕ)
  343. (hX : ∀ p ∈ T, maxCoordinate p.val ≤ X) : T.card ≤ (X+1)^2 := by
  344. classical
  345. have hh : T.image Subtype.val ⊆ (Finset.range (X+1)) ×ˢ (Finset.range (X+1)) := by
  346. intro p hp
  347. obtain ⟨q, hq, rfl⟩ := Finset.mem_image.mp hp
  348. have hu := le_max_left q.val.1 q.val.2
  349. have hv := le_max_right q.val.1 q.val.2
  350. have h := hX q hq
  351. change max q.val.1 q.val.2 ≤ X at h
  352. exact Finset.mem_product.mpr ⟨Finset.mem_range.mpr (by omega), Finset.mem_range.mpr (by omega)⟩
  353. simpa only [Finset.card_image_of_injective _ Subtype.coe_injective, Finset.card_product,
  354. Finset.card_range, sq] using Finset.card_le_card hh
  355. /-- If all coprime equal-divisor-sum pairs have no uniform polynomial bound at
  356. exponent s, then arbitrarily large maximum-coordinate cutoffs admit more than
  357. X^r primitive pairs for each nonnegative r strictly below s. Both orientations
  358. are counted. The result also applies inside any divisor-closed class A. -/
  359. theorem frequently_many_primitive (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u)
  360. {r s : ℝ} (hr : 0 ≤ r) (hrs : r < s)
  361. (large : ¬ PowerBound (fun p : PairFamily A ↦ maxCoordinate p.val) s) (N : ℕ) :
  362. ∃ X : ℕ, N ≤ X ∧ ∃ T : Finset (AtomFamily A),
  363. (∀ p ∈ T, maxCoordinate p.val ≤ X) ∧ (X : ℝ)^r < T.card := by
  364. classical
  365. by_contra! h
  366. apply large
  367. apply powerBound_transfer A closed hr hrs
  368. let C : ℝ := ((N+1 : ℕ) : ℝ)^2
  369. have hc : 1 ≤ C := by dsimp [C]; push_cast; nlinarith [Nat.cast_nonneg (α := ℝ) N, sq_nonneg (N : ℝ)]
  370. refine ⟨C, zero_lt_one.trans_le hc, ?_⟩
  371. intro X hX T hT
  372. have hx : 1 ≤ (X : ℝ)^r := Real.one_le_rpow (by exact_mod_cast hX) hr
  373. by_cases hn : N ≤ X
  374. · exact (h X hn T hT).trans (le_mul_of_one_le_left (zero_le_one.trans hx) hc)
  375. · have hh : (T.card : ℝ) ≤ C := by
  376. dsimp [C]
  377. exact_mod_cast (cutoff_bound A T X hT).trans (Nat.pow_le_pow_left (by omega : X+1 ≤ N+1) 2)
  378. exact hh.trans (le_mul_of_one_le_right (zero_le_one.trans hc) hx)
  379. private theorem primitive_high_series (A : ℕ → Prop) {t : ℝ} (ht : 1 < t) :
  380. Summable (fun p : AtomFamily A ↦ weight t p.val) := by
  381. have hn := Real.summable_nat_rpow.mpr (by linarith : -t < -1)
  382. have hp := hn.mul_of_nonneg hn (fun i ↦ Real.rpow_nonneg (Nat.cast_nonneg i) _)
  383. (fun i ↦ Real.rpow_nonneg (Nat.cast_nonneg i) _)
  384. have hu := hp.comp_injective (Subtype.coe_injective (p := fun p : ℕ × ℕ ↦ Primitive p ∧ A p.1 ∧ A p.2))
  385. apply hu.congr
  386. intro p
  387. simp only [Function.comp_apply, weight, Nat.cast_mul, Real.mul_rpow (Nat.cast_nonneg _) (Nat.cast_nonneg _)]
  388. private theorem finite_weight_bound (A : ℕ → Prop) {s t : ℝ} (hs : 0 < s) (hst : s < t) (ht : 1 < t) :
  389. ∃ C : ℝ, 0 < C ∧ ∀ S : Finset (AtomFamily A),
  390. ∑ a ∈ S, weight s a.val ≤ C * (S.card : ℝ)^(t-s) := by
  391. classical
  392. have hsum := primitive_high_series A ht
  393. let Z := ∑' a : AtomFamily A, weight t a.val
  394. have hz : 0 ≤ Z := tsum_nonneg (fun a ↦ Real.rpow_nonneg (Nat.cast_nonneg _) _)
  395. refine ⟨Z+1, by linarith, ?_⟩
  396. intro S
  397. by_cases hempty : S = ∅
  398. · subst S; simp [show t-s ≠ 0 by linarith]
  399. let n : ℝ := S.card
  400. have hn1 : 1 ≤ n := by
  401. dsimp [n]; exact_mod_cast (show 1 ≤ S.card from Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hempty))
  402. have hn : 0 < n := zero_lt_one.trans_le hn1
  403. have point (p : AtomFamily A) : weight s p.val ≤ n^(t-s)*weight t p.val + n^(-s) := by
  404. let w : ℝ := (p.val.1 * p.val.2 : ℕ)
  405. have hw : 0 < w := by
  406. dsimp [w]; have h1 := p.property.1.1.1; have h2 := p.property.1.1.2.1
  407. exact_mod_cast Nat.mul_pos (by omega) (by omega)
  408. change w^(-s) ≤ n^(t-s) * w^(-t) + n^(-s)
  409. by_cases h : w ≤ n
  410. · have hfac : w^(-s) = w^(t-s)*w^(-t) := by rw [← Real.rpow_add hw]; congr 1; ring
  411. rw [hfac]
  412. apply le_trans (mul_le_mul_of_nonneg_right (Real.rpow_le_rpow hw.le h (by linarith)) (Real.rpow_nonneg hw.le _))
  413. exact le_add_of_nonneg_right (Real.rpow_nonneg hn.le _)
  414. · apply (Real.rpow_le_rpow_of_nonpos hn (le_of_not_ge h) (neg_nonpos.mpr hs.le)).trans
  415. exact le_add_of_nonneg_left (mul_nonneg (Real.rpow_nonneg hn.le _) (Real.rpow_nonneg hw.le _))
  416. calc ∑ a ∈ S, weight s a.val ≤ ∑ a ∈ S, (n^(t-s)*weight t a.val + n^(-s)) :=
  417. Finset.sum_le_sum (fun a _ ↦ point a)
  418. _ = n^(t-s)*(∑ a ∈ S, weight t a.val) + n*n^(-s) := by
  419. simp [Finset.sum_add_distrib, Finset.mul_sum, n]
  420. _ ≤ n^(t-s)*Z + n^(1-s) := by
  421. apply add_le_add
  422. · exact mul_le_mul_of_nonneg_left (hsum.sum_le_tsum _ (by intro a _; unfold weight; positivity)) (Real.rpow_nonneg hn.le _)
  423. · rw [sub_eq_add_neg, Real.rpow_add hn, Real.rpow_one]
  424. _ ≤ n^(t-s)*Z + n^(t-s) := add_le_add le_rfl (Real.rpow_le_rpow_of_exponent_le hn1 (show 1-s ≤ t-s by linarith))
  425. _ = _ := by change _ = (Z+1)*n^(t-s); ring
  426. /-- At each cutoff a sufficiently large collection of equal-sum pairs forces
  427. many primitive pairs at the very same cutoff. -/
  428. theorem finite_count_bound (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u)
  429. {s t : ℝ} (hs : 0 < s) (hst : s < t) (ht : 1 < t) :
  430. ∃ C : ℝ, 0 < C ∧ ∀ X : ℕ, 0 < X → ∀ T : Finset (PairFamily A),
  431. (∀ p ∈ T, maxCoordinate p.val ≤ X) → ∃ S : Finset (AtomFamily A),
  432. (∀ p ∈ S, maxCoordinate p.val ≤ X) ∧
  433. (T.card : ℝ) ≤ (X : ℝ)^(2*s) * Real.exp (C * (S.card : ℝ)^(t-s)) := by
  434. classical
  435. obtain ⟨C, hC, hsum⟩ := finite_weight_bound A hs hst ht
  436. obtain ⟨rep, hinj, hfst, hsnd⟩ := representations A closed
  437. refine ⟨C, hC, ?_⟩
  438. intro X hX T hT
  439. let S := T.biUnion rep
  440. have hx : 0 < (X : ℝ) := by exact_mod_cast hX
  441. have hn (p : AtomFamily A) : 0 ≤ weight s p.val := Real.rpow_nonneg (Nat.cast_nonneg _) _
  442. refine ⟨S, ?_, ?_⟩
  443. · intro p hp
  444. obtain ⟨q, hq, hpq⟩ := Finset.mem_biUnion.mp hp
  445. have hu := Finset.dvd_prod_of_mem (fun a : AtomFamily A ↦ a.val.1) hpq
  446. have hv := Finset.dvd_prod_of_mem (fun a : AtomFamily A ↦ a.val.2) hpq
  447. rw [hfst] at hu
  448. rw [hsnd] at hv
  449. have h1 := q.property.1.1; have h2 := q.property.1.2.1
  450. exact (max_le_max (Nat.le_of_dvd (by omega) hu) (Nat.le_of_dvd (by omega) hv)).trans (hT q hq)
  451. · have hEuler : (T.card : ℝ) * (X : ℝ)^(-(2*s)) ≤ Real.exp (C*(S.card : ℝ)^(t-s)) := by
  452. calc _ = ∑ _p ∈ T, (X : ℝ)^(-(2*s)) := by simp
  453. _ ≤ ∑ p ∈ T, weight s p.val := by
  454. apply Finset.sum_le_sum
  455. intro p hp
  456. have hm := maxCoordinate_pos p.property.1
  457. have hmR : 0 < high p.val := by rw [← cast_maxCoordinate]; exact_mod_cast hm
  458. apply (Real.rpow_le_rpow_of_nonpos hmR _ (by linarith : -(2*s) ≤ 0)).trans
  459. (high_weight_le s hs.le p.val p.property.1)
  460. rw [← cast_maxCoordinate]; exact_mod_cast hT p hp
  461. _ = ∑ R ∈ T.image rep, ∏ a ∈ R, weight s a.val := by
  462. rw [Finset.sum_image (fun _ _ _ _ h ↦ hinj h)]
  463. apply Finset.sum_congr rfl
  464. intro p _
  465. rw [weight_prod, hfst, hsnd]
  466. _ ≤ ∑ R ∈ S.powerset, ∏ a ∈ R, weight s a.val := by
  467. apply Finset.sum_le_sum_of_subset_of_nonneg _ (by intro R _ _; exact Finset.prod_nonneg (fun a _ ↦ hn a))
  468. intro R hR
  469. obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hR
  470. exact Finset.mem_powerset.mpr (Finset.subset_biUnion_of_mem rep hp)
  471. _ = ∏ a ∈ S, (1 + weight s a.val) := (Finset.prod_one_add _).symm
  472. _ ≤ Real.exp (∑ a ∈ S, weight s a.val) := Real.prod_one_add_le_exp_sum _ hn
  473. _ ≤ _ := Real.exp_le_exp.mpr (hsum S)
  474. rw [Real.rpow_neg hx.le, ← div_eq_mul_inv, div_le_iff₀ (Real.rpow_pos_of_pos hx _)] at hEuler
  475. simpa only [mul_comm] using hEuler
  476. open Filter in
  477. /-- A near-quadratic lower bound at every large cutoff for all pairs gives
  478. more than every fixed power of the logarithm in primitive pairs at every
  479. large cutoff. The hypothesis and conclusion use the same height. -/
  480. theorem eventually_superpolylog_primitive (A : ℕ → Prop) (closed : ∀ ⦃u n⦄, u ∣ n → A n → A u)
  481. (dense : ∀ ε : ℝ, 0 < ε → ∀ᶠ X : ℕ in atTop, ∃ T : Finset (PairFamily A),
  482. (∀ p ∈ T, maxCoordinate p.val ≤ X) ∧ (X : ℝ)^(2-ε) < T.card)
  483. (K : ℝ) (hK : 0 ≤ K) :
  484. ∀ᶠ X : ℕ in atTop, ∃ S : Finset (AtomFamily A),
  485. (∀ p ∈ S, maxCoordinate p.val ≤ X) ∧ (Real.log X)^K < S.card := by
  486. let δ := 1 / (4*(K+1))
  487. have hd : 0 < δ := by dsimp [δ]; positivity
  488. have hd1 : δ < 1 := by
  489. dsimp [δ]; rw [div_lt_one (by positivity)]; linarith
  490. let s := 1-δ
  491. let t := 1+δ
  492. have hs : 0 < s := by dsimp [s]; linarith
  493. have hst : s < t := by dsimp [s,t]; linarith
  494. have ht : 1 < t := by dsimp [t]; linarith
  495. have hex : K*(t-s) ≤ 1/2 := by
  496. dsimp [s,t,δ]
  497. field_simp
  498. linarith
  499. obtain ⟨C,hC,hbound⟩ := finite_count_bound A closed hs hst ht
  500. have hlarge : Tendsto (fun X : ℕ ↦ Real.log (X : ℝ)) atTop atTop :=
  501. Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop
  502. filter_upwards [dense δ hd, hlarge.eventually_ge_atTop (max 1 ((C/δ)^2+1)), eventually_ge_atTop 1] with X hT hL hX
  503. obtain ⟨T, hm, hcard⟩ := hT
  504. obtain ⟨S, hS, hCS⟩ := hbound X hX T hm
  505. refine ⟨S,hS,?_⟩
  506. let L := Real.log (X : ℝ)
  507. have hL1 : 1 ≤ L := (le_max_left _ _).trans hL
  508. have hLpos : 0 < L := zero_lt_one.trans_le hL1
  509. have hLbig : (C/δ)^2 < L := by
  510. have := (le_max_right _ _).trans hL
  511. dsimp [L]; linarith
  512. have hsqrt := (Real.lt_sqrt (div_nonneg hC.le hd.le)).mpr hLbig
  513. have hroot : C < Real.sqrt L * δ := (div_lt_iff₀ hd).mp hsqrt
  514. have hsqrtpos := Real.sqrt_pos.mpr hLpos
  515. have hstrict : C * Real.sqrt L < δ*L := by
  516. have h := mul_lt_mul_of_pos_right hroot hsqrtpos
  517. nlinarith [Real.sq_sqrt hLpos.le]
  518. have hx : 0 < (X : ℝ) := by exact_mod_cast hX
  519. have hlogs := Real.log_lt_log (Real.rpow_pos_of_pos hx _) (hcard.trans_le hCS)
  520. rw [Real.log_mul (Real.rpow_pos_of_pos hx _).ne' (Real.exp_pos _).ne',
  521. Real.log_rpow hx, Real.log_rpow hx, Real.log_exp] at hlogs
  522. have hgain : δ*L < C*(S.card : ℝ)^(t-s) := by
  523. dsimp [s,L] at hlogs ⊢
  524. linarith
  525. by_contra! hsmall
  526. have hsml : (S.card : ℝ)^(t-s) ≤ Real.sqrt L := by
  527. calc _ ≤ (L^K)^(t-s) := Real.rpow_le_rpow (Nat.cast_nonneg _) hsmall (sub_pos.mpr hst).le
  528. _ = L^(K*(t-s)) := (Real.rpow_mul hLpos.le _ _).symm
  529. _ ≤ L^(1/2 : ℝ) := Real.rpow_le_rpow_of_exponent_le hL1 hex
  530. _ = _ := (Real.sqrt_eq_rpow L).symm
  531. linarith [mul_le_mul_of_nonneg_left hsml hC.le]
  532. #print axioms eventually_superpolylog_primitive
  533. #print axioms finite_count_bound
  534. #print axioms frequently_many_primitive
  535. #print axioms upper_exponents_equal
  536. end Erdos824Primitive