Documentation

CslibFrontier.Foundations.Data.Nat.Choose.PrimePowerDvd

Divisibility by prime powers through binomial coefficients #

For a prime p, the base-p digits of c are read off modulo p by binomial coefficients: C(c, p ^ i) ≡ ⌊c / p ^ i⌋ (mod p) by Lucas's theorem. Hence p ^ e ∣ c exactly when p ∣ C(c, p ^ i) for every i < e (Nat.pow_dvd_iff_forall_dvd_choose), and c is not divisible by a positive m exactly when p ∤ C(c, p ^ i) for some prime p and some i with p ^ (i + 1) ∣ m (Nat.mod_ne_zero_iff_exists_not_dvd_choose). This is the reduction of a MOD_m gate to MOD_p tests of polynomials of degree below m [BeigelTarui1994, Lemma 2.1 and Fact 2.2].

Main results #

References #

theorem Nat.choose_pow_succ_modEq {p : ℕ} (hp : Prime p) (c i : ℕ) :
c.choose (p ^ (i + 1)) ≡ (c / p).choose (p ^ i) [MOD p]

C(c, p ^ (i + 1)) ≡ C(c / p, p ^ i) (mod p) for a prime p: one step of Lucas's theorem.

theorem Nat.pow_dvd_iff_forall_dvd_choose {p : ℕ} (hp : Prime p) (e c : ℕ) :
p ^ e ∣ c ↔ ∀ i < e, p ∣ c.choose (p ^ i)

Prime-power divisibility from binomial coefficients. For a prime p, p ^ e ∣ c exactly when p ∣ C(c, p ^ i) for every i < e: the binomial coefficient C(c, p ^ i) is the i-th base-p digit of c modulo p [BeigelTarui1994, Fact 2.2].

theorem Nat.mod_ne_zero_iff_exists_not_dvd_choose {m : ℕ} (hm : 0 < m) (c : ℕ) :
c % m ≠ 0 ↔ ∃ (p : ℕ) (i : ℕ), Prime p ∧ p ^ (i + 1) ∣ m ∧ ¬p ∣ c.choose (p ^ i)

Non-divisibility through prime-power binomial coefficients. For m > 0, c is not divisible by m exactly when some prime p and some i with p ^ (i + 1) ∣ m have p ∤ C(c, p ^ i). Such p and i satisfy p ≤ m and i < m.