Lean / Reader
Lean reader

Erdos824Fibers.lean

59 lines2 declarationsno sorryimports Mathlib.Algebra.Order.Chebyshev Mathlib.NumberTheory.ArithmeticFunction.Misc Mathlib.Tactic
  1. import Mathlib.Algebra.Order.Chebyshev
  2. import Mathlib.NumberTheory.ArithmeticFunction.Misc
  3. import Mathlib.Tactic
  4. namespace Erdos824Fibers
  5. open ArithmeticFunction
  6. /-- A prime complementary shift gives a squarefree semiprime at a prescribed
  7. common divisor sum. The exact deficit also locates the preimage. -/
  8. theorem complementary_shift {q p c M n : ℕ} (hq : q.Prime) (hp : p.Prime) (hqp : q<p)
  9. (hM : (q+1)*c=M) (hpv : p+1=c*n) :
  10. sigma 1 (q*p)=M*n ∧ Squarefree (q*p) ∧ M*n-q*p=q+p+1 := by
  11. have hc := (Nat.coprime_primes hq hp).mpr hqp.ne
  12. have prime_sigma : ∀ {l : ℕ}, l.Prime → sigma 1 l=l+1 := by
  13. intro l hl
  14. simpa [Finset.sum_range_succ,add_comm] using sigma_one_apply_prime_pow (i:=1) hl
  15. have hprod : (q+1)*(p+1)=M*n := by rw [hpv,←Nat.mul_assoc,hM]
  16. refine ⟨?_,(Nat.squarefree_mul hc).mpr ⟨hq.squarefree,hp.squarefree⟩,?_⟩
  17. · simpa only [isMultiplicative_sigma.map_mul_of_coprime hc,prime_sigma hq,prime_sigma hp] using hprod
  18. · have hh : M*n=q*p+(q+p+1) := by rw [←hprod]; ring
  19. omega
  20. /-- If the mean degree is at least twice the threshold, large fibers carry
  21. enough mass that a second moment bounds their number from below. -/
  22. theorem many_heavy_fibers {ι : Type*} (S : Finset ι) (f : ι → ℕ) (H : ℕ)
  23. (hmean : 2*(S.card:ℝ)*H ≤ ∑ i ∈ S, (f i:ℝ)) :
  24. (∑ i ∈ S, (f i:ℝ))^2 ≤
  25. 4*((S.filter (fun i ↦ H≤f i)).card:ℝ)*(∑ i ∈ S, (f i:ℝ)^2) := by
  26. classical
  27. let G := S.filter (fun i ↦ H≤f i)
  28. let B := S.filter (fun i ↦ ¬ H≤f i)
  29. have hsplit : (∑ i ∈ G, (f i:ℝ))+(∑ i ∈ B,(f i:ℝ))=∑ i ∈ S,(f i:ℝ) :=
  30. Finset.sum_filter_add_sum_filter_not _ _ _
  31. have blo : (∑ i ∈ B,(f i:ℝ)) ≤ (S.card:ℝ)*H := by
  32. calc
  33. _ ≤ ∑ _i ∈ B,(H:ℝ) := by
  34. apply Finset.sum_le_sum
  35. intro i hi
  36. have h := (Finset.mem_filter.mp hi).2
  37. exact_mod_cast (show f i≤H by omega)
  38. _ = (B.card:ℝ)*H := by simp
  39. _ ≤ _ := by
  40. exact mul_le_mul_of_nonneg_right (by exact_mod_cast Finset.card_le_card (Finset.filter_subset _ S)) (by positivity)
  41. have hh : (∑ i ∈ S, (f i:ℝ)) ≤ 2*(∑ i ∈ G, (f i:ℝ)) := by linarith
  42. have hsq := sq_sum_le_card_mul_sum_sq (s:=G) (f:=fun i ↦ (f i:ℝ))
  43. have hsub : (∑ i ∈ G,(f i:ℝ)^2) ≤ ∑ i ∈ S,(f i:ℝ)^2 :=
  44. Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ S) (by intros; positivity)
  45. change _ ≤ 4*(G.card:ℝ)*_
  46. calc
  47. _ ≤ (2*(∑ i ∈ G,(f i:ℝ)))^2 := pow_le_pow_left₀ (by positivity) hh 2
  48. _ = 4*(∑ i ∈ G,(f i:ℝ))^2 := by ring
  49. _ ≤ 4*((G.card:ℝ)*∑ i ∈ G,(f i:ℝ)^2) := by linarith
  50. _ ≤ _ := by
  51. convert mul_le_mul_of_nonneg_left hsub (by positivity : 0≤4*(G.card:ℝ)) using 1 <;> ring
  52. #print axioms complementary_shift
  53. #print axioms many_heavy_fibers
  54. end Erdos824Fibers