feat(Data/Nat): add prime divisibility for ascFactorial and choose#39366
feat(Data/Nat): add prime divisibility for ascFactorial and choose#39366akiezun wants to merge 1 commit into
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary e7eedc30e9Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
| lemma Prime.dvd_ascFactorial_iff {p k n : ℕ} (hp : p.Prime) : | ||
| p ∣ k.ascFactorial n ↔ ∃ i < n, p ∣ k + i := by | ||
| induction n with | ||
| | zero => simp [Nat.ascFactorial_zero, hp.ne_one] | ||
| | succ n ih => | ||
| rw [Nat.ascFactorial_succ, hp.dvd_mul, ih] | ||
| constructor | ||
| · rintro (h | ⟨i, hi, h⟩) | ||
| · exact ⟨n, lt_succ_self n, h⟩ | ||
| · exact ⟨i, lt_succ_of_lt hi, h⟩ | ||
| · rintro ⟨i, hi, h⟩ | ||
| rcases lt_or_eq_of_le (Nat.le_of_lt_succ hi) with hi | rfl | ||
| · exact Or.inr ⟨i, hi, h⟩ | ||
| · exact Or.inl h |
There was a problem hiding this comment.
| lemma Prime.dvd_ascFactorial_iff {p k n : ℕ} (hp : p.Prime) : | |
| p ∣ k.ascFactorial n ↔ ∃ i < n, p ∣ k + i := by | |
| induction n with | |
| | zero => simp [Nat.ascFactorial_zero, hp.ne_one] | |
| | succ n ih => | |
| rw [Nat.ascFactorial_succ, hp.dvd_mul, ih] | |
| constructor | |
| · rintro (h | ⟨i, hi, h⟩) | |
| · exact ⟨n, lt_succ_self n, h⟩ | |
| · exact ⟨i, lt_succ_of_lt hi, h⟩ | |
| · rintro ⟨i, hi, h⟩ | |
| rcases lt_or_eq_of_le (Nat.le_of_lt_succ hi) with hi | rfl | |
| · exact Or.inr ⟨i, hi, h⟩ | |
| · exact Or.inl h | |
| lemma Prime.dvd_ascFactorial_iff {p k n : ℕ} (hp : p.Prime) : | |
| p ∣ k.ascFactorial n ↔ ∃ i < n, p ∣ k + i := by | |
| simp [Nat.ascFactorial_eq_prod_range, hp.prime.dvd_finsetProd_iff] |
Not sure if this file has enough imports for this. If not, this can be moved to anywhere that imports Mathlib.Algebra.BigOperators.Associated and Mathlib.Data.Nat.Factorial.BigOperators
There was a problem hiding this comment.
It doesn't and AFAICT there's no file that imports these which is also a sensible place for such a theorem.
New file?
There was a problem hiding this comment.
It doesn't and AFAICT there's no file that imports these which is also a sensible place for such a theorem. New file?
Thanks. Suggestions for file name?
There was a problem hiding this comment.
Maybe Data/Nat/Factorial/Prime.lean, not sure
There was a problem hiding this comment.
It is going to be a bit confusing if we have both Mathlib/Data/Nat/Prime/Factorial.lean and Data/Nat/Factorial/Prime.lean... what about adding more imports here and eat the cost of large imports? (assuming it is not circular)
Adds two prime-divisibility lemmas for natural-number factorial/binomial APIs.
The first characterizes when a prime divides an ascending factorial:
Nat.Prime.dvd_ascFactorial_iff.The second applies this to binomial coefficients:
Nat.Prime.dvd_choose_add_sub_one_iff, usingNat.ascFactorial_eq_factorial_mul_choose'and cancellation of then!factorwhen
n < p.