Lean / Reader
Lean reader

RecordDivisors.lean

63 lines5 declarationsno sorryimports PrimeSignatures

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

  1. import PrimeSignatures
  2. namespace ReciprocalRecords
  3. def bandPower (m n p : ℕ) : ℕ :=
  4. (if n < 2*p then 4 else 1) + (if m < p then 2 else 0) +
  5. (if 2*p ≤ n ∧ m < 2*p then 1 else 0)
  6. private theorem two_labels : ∀ a : Fin 5 → Fin 4,
  7. (∀ i, (a i).val < 2) → 4 ≤ equalEdges a := by decide +kernel
  8. private theorem four_zero : ∀ a : Fin 5 → Fin 4,
  9. (∀ i : Fin 4, a i.castSucc = 0) → 6 ≤ equalEdges a := by decide +kernel
  10. /-- The extra weights from (M,N] and (M/2,N/2] count only the additional pairs. -/
  11. theorem five_band_count {p L m n : ℕ} (hp : p.Prime) (hpL : p ∣ L)
  12. (hband : n < 3*p) (hgap : 2*n ≤ 3*m)
  13. (z : Fin 5 → ℤ) (A : Fin 5 → Finset ℕ)
  14. (hA : ∀ i d, d ∈ A i → 0 < d ∧ d ≤ n ∧ d ∣ L)
  15. (hold : ∀ (i : Fin 4) d, d ∈ A i.castSucc → d ≤ m)
  16. (hrep : ∀ i, z i ≡ scaledTotal L (A i) [ZMOD (p : ℤ)]) :
  17. bandPower m n p ≤ (taggedEdges p z).card := by
  18. let a := fun i => label p (A i)
  19. have hc : equalEdges a ≤ (taggedEdges p z).card := by
  20. apply labelled_collisions
  21. intro i j heq
  22. have rr (i) := local_signature hp hpL (A i) (fun d hd =>
  23. ⟨(hA i d hd).1, lt_of_le_of_lt (hA i d hd).2.1 hband, (hA i d hd).2.2⟩)
  24. have h := (hrep i).trans (rr i)
  25. rw [local_of_label (L := L) heq] at h
  26. exact h.trans ((hrep j).trans (rr j)).symm
  27. apply le_trans _ hc
  28. by_cases hn : n < 2*p
  29. · have hb (i) : (a i).val < 2 := label_binary (fun h => (Nat.not_le_of_lt hn) (hA i _ h).2.1)
  30. by_cases hm : m < p
  31. · have hzero (i : Fin 4) : a i.castSucc = 0 := label_zero
  32. (fun h => (Nat.not_le_of_lt hm) (hold i _ h))
  33. (fun h => (Nat.not_le_of_lt hn) (hA _ _ h).2.1)
  34. simpa [bandPower, hn, hm, Nat.not_le_of_lt hn] using four_zero a hzero
  35. · simpa [bandPower, hn, hm, Nat.not_le_of_lt hn] using two_labels a hb
  36. · have hm : ¬ m < p := by omega
  37. by_cases h : m < 2*p
  38. · have hb (i : Fin 4) : (a i.castSucc).val < 2 := label_binary
  39. (fun hh => (Nat.not_le_of_lt h) (hold i _ hh))
  40. simpa [bandPower, hn, hm, Nat.le_of_not_gt hn, h] using four_old_binary a hb
  41. · simpa [bandPower, hn, hm, h] using five_four a
  42. /-- Finite product form of the four-record prime-band inequality.
  43. Set L to lcm(1,...,n) and S to the primes p in (n/3,n]. -/
  44. theorem four_record_divisibility {L m n : ℕ} (S : Finset ℕ) (hgap : 2*n ≤ 3*m)
  45. (hs : ∀ p ∈ S, Nat.Prime p ∧ p ∣ L ∧ n < 3*p)
  46. (z : Fin 5 → ℤ) (A : Fin 5 → Finset ℕ)
  47. (hA : ∀ i d, d ∈ A i → 0 < d ∧ d ≤ n ∧ d ∣ L)
  48. (hold : ∀ (i : Fin 4) d, d ∈ A i.castSucc → d ≤ m)
  49. (hrep : ∀ p ∈ S, ∀ i, z i ≡ scaledTotal L (A i) [ZMOD (p : ℤ)]) :
  50. (∏ p ∈ S, p ^ bandPower m n p) ∣ (detProduct z).natAbs := by
  51. apply combined_divisor z S _ (fun p h => (hs p h).1)
  52. intro p h
  53. obtain ⟨hp, hpL, hband⟩ := hs p h
  54. exact five_band_count hp hpL hband hgap _ _ hA hold (hrep p h)
  55. end ReciprocalRecords