Lean / Reader
Lean readerRecordDivisors.lean
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.
import PrimeSignaturesnamespace ReciprocalRecordsdef bandPower (m n p : ℕ) : ℕ :=(if n < 2*p then 4 else 1) + (if m < p then 2 else 0) +(if 2*p ≤ n ∧ m < 2*p then 1 else 0)private theorem two_labels : ∀ a : Fin 5 → Fin 4,(∀ i, (a i).val < 2) → 4 ≤ equalEdges a := by decide +kernelprivate theorem four_zero : ∀ a : Fin 5 → Fin 4,(∀ i : Fin 4, a i.castSucc = 0) → 6 ≤ equalEdges a := by decide +kernel/-- The extra weights from (M,N] and (M/2,N/2] count only the additional pairs. -/theorem five_band_count {p L m n : ℕ} (hp : p.Prime) (hpL : p ∣ L)(hband : n < 3*p) (hgap : 2*n ≤ 3*m)(z : Fin 5 → ℤ) (A : Fin 5 → Finset ℕ)(hA : ∀ i d, d ∈ A i → 0 < d ∧ d ≤ n ∧ d ∣ L)(hold : ∀ (i : Fin 4) d, d ∈ A i.castSucc → d ≤ m)(hrep : ∀ i, z i ≡ scaledTotal L (A i) [ZMOD (p : ℤ)]) :bandPower m n p ≤ (taggedEdges p z).card := bylet a := fun i => label p (A i)have hc : equalEdges a ≤ (taggedEdges p z).card := byapply labelled_collisionsintro i j heqhave rr (i) := local_signature hp hpL (A i) (fun d hd =>⟨(hA i d hd).1, lt_of_le_of_lt (hA i d hd).2.1 hband, (hA i d hd).2.2⟩)have h := (hrep i).trans (rr i)rw [local_of_label (L := L) heq] at hexact h.trans ((hrep j).trans (rr j)).symmapply le_trans _ hcby_cases hn : n < 2*p· have hb (i) : (a i).val < 2 := label_binary (fun h => (Nat.not_le_of_lt hn) (hA i _ h).2.1)by_cases hm : m < p· have hzero (i : Fin 4) : a i.castSucc = 0 := label_zero(fun h => (Nat.not_le_of_lt hm) (hold i _ h))(fun h => (Nat.not_le_of_lt hn) (hA _ _ h).2.1)simpa [bandPower, hn, hm, Nat.not_le_of_lt hn] using four_zero a hzero· simpa [bandPower, hn, hm, Nat.not_le_of_lt hn] using two_labels a hb· have hm : ¬ m < p := by omegaby_cases h : m < 2*p· have hb (i : Fin 4) : (a i.castSucc).val < 2 := label_binary(fun hh => (Nat.not_le_of_lt h) (hold i _ hh))simpa [bandPower, hn, hm, Nat.le_of_not_gt hn, h] using four_old_binary a hb· simpa [bandPower, hn, hm, h] using five_four a/-- Finite product form of the four-record prime-band inequality.Set L to lcm(1,...,n) and S to the primes p in (n/3,n]. -/theorem four_record_divisibility {L m n : ℕ} (S : Finset ℕ) (hgap : 2*n ≤ 3*m)(hs : ∀ p ∈ S, Nat.Prime p ∧ p ∣ L ∧ n < 3*p)(z : Fin 5 → ℤ) (A : Fin 5 → Finset ℕ)(hA : ∀ i d, d ∈ A i → 0 < d ∧ d ≤ n ∧ d ∣ L)(hold : ∀ (i : Fin 4) d, d ∈ A i.castSucc → d ≤ m)(hrep : ∀ p ∈ S, ∀ i, z i ≡ scaledTotal L (A i) [ZMOD (p : ℤ)]) :(∏ p ∈ S, p ^ bandPower m n p) ∣ (detProduct z).natAbs := byapply combined_divisor z S _ (fun p h => (hs p h).1)intro p hobtain ⟨hp, hpL, hband⟩ := hs p hexact five_band_count hp hpL hband hgap _ _ hA hold (hrep p h)end ReciprocalRecords