Lean / Reader
Lean reader

PrimeSignatures.lean

72 lines11 declarationsno sorryimports PrimeCollisions Mathlib.Algebra.BigOperators.ModEq

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports PrimeCollisions, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import PrimeCollisions
  2. import Mathlib.Algebra.BigOperators.ModEq
  3. namespace ReciprocalRecords
  4. def w (L d : ℕ) : ℤ := (L / d : ℕ)
  5. def scaledTotal (L : ℕ) (A : Finset ℕ) : ℤ := ∑ d ∈ A, w L d
  6. /-- Only denominators divisible by p contribute to a scaled reciprocal sum modulo p. -/
  7. theorem zero_off_multiples {L d p : ℕ} (hp : p.Prime) (hpL : p ∣ L)
  8. (hd : d ∣ L) (hpd : ¬p ∣ d) : w L d ≡ 0 [ZMOD (p : ℤ)] := by
  9. have hh : p ∣ L / d * d := by rwa [Nat.div_mul_cancel hd]
  10. have h := (hp.dvd_mul.mp hh).resolve_right hpd
  11. apply Int.modEq_zero_iff_dvd.mpr
  12. unfold w
  13. exact_mod_cast h
  14. /-- Below 3p no positive multiples other than p and 2p occur. -/
  15. theorem other_denominator {p d : ℕ} (hd : 0 < d)
  16. (hu : d < 3*p) (h1 : d ≠ p) (h2 : d ≠ 2*p) : ¬p ∣ d := by
  17. rintro ⟨k, rfl⟩
  18. have hk : k < 3 := by nlinarith
  19. interval_cases k <;> simp_all [mul_comm]
  20. def localTotal (L p : ℕ) (A : Finset ℕ) : ℤ :=
  21. (if p ∈ A then w L p else 0) + (if 2*p ∈ A then w L (2*p) else 0)
  22. theorem local_signature {L p : ℕ} (hp : p.Prime) (hpL : p ∣ L)
  23. (A : Finset ℕ) (hA : ∀ d ∈ A, 0 < d ∧ d < 3*p ∧ d ∣ L) :
  24. scaledTotal L A ≡ localTotal L p A [ZMOD (p : ℤ)] := by
  25. let f (d : ℕ) : ℤ := (if p = d then w L p else 0) + (if 2*p = d then w L (2*p) else 0)
  26. have he (d) (hd : d ∈ A) : w L d ≡ f d [ZMOD (p : ℤ)] := by
  27. obtain ⟨hpos, hu, hdiv⟩ := hA d hd
  28. have hne : 2*p ≠ p := by have := hp.pos; omega
  29. by_cases h : p = d
  30. · subst d; simp [f, hne]
  31. by_cases h' : 2*p = d
  32. · subst d; simp [f, hne.symm]
  33. simpa [f, h, h'] using zero_off_multiples hp hpL hdiv
  34. (other_denominator hpos hu (Ne.symm h) (Ne.symm h'))
  35. simpa [scaledTotal, f, localTotal, Finset.sum_add_distrib] using Int.ModEq.sum he
  36. /-- The order on labels is used when the older witnesses cannot use 2p. -/
  37. def label (p : ℕ) (A : Finset ℕ) : Fin 4 :=
  38. if 2*p ∈ A then (if p ∈ A then 3 else 2) else (if p ∈ A then 1 else 0)
  39. theorem local_of_label {p L : ℕ} {A B : Finset ℕ} (he : label p A = label p B) :
  40. localTotal L p A = localTotal L p B := by
  41. unfold label at he
  42. unfold localTotal
  43. split_ifs at * <;> simp_all
  44. theorem label_binary {p : ℕ} {A : Finset ℕ} (h : 2*p ∉ A) : (label p A).val < 2 := by
  45. simp only [label, h, if_false]
  46. split <;> decide
  47. theorem label_zero {p : ℕ} {A : Finset ℕ} (h : p ∉ A) (h' : 2*p ∉ A) :
  48. label p A = 0 := by simp [label, h, h']
  49. theorem labelled_totals {n p L : ℕ} (hp : p.Prime) (hpL : p ∣ L)
  50. (A : Fin n → Finset ℕ) (hA : ∀ i d, d ∈ A i → 0 < d ∧ d < 3*p ∧ d ∣ L) :
  51. equalEdges (fun i => label p (A i)) ≤
  52. (taggedEdges p (fun i => scaledTotal L (A i))).card := by
  53. apply labelled_collisions
  54. intro i j h
  55. have hi := local_signature hp hpL (A i) (hA i)
  56. have hj := local_signature hp hpL (A j) (hA j)
  57. rw [local_of_label (L := L) h] at hi
  58. exact hi.trans hj.symm
  59. end ReciprocalRecords