Skip to content

Commit

Permalink
feat(nat/choose): lemmas regarding binomial coefficients (#6362)
Browse files Browse the repository at this point in the history
  • Loading branch information
laughinggas committed Feb 22, 2021
1 parent 4daac66 commit 70d7114
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/data/nat/choose/dvd.lean
Expand Up @@ -5,6 +5,7 @@ Authors: Chris Hughes, Patrick Stevens
-/
import data.nat.choose.basic
import data.nat.prime
import data.rat.floor
/-!
# Divisibility properties of binomial coefficients
-/
Expand Down Expand Up @@ -34,5 +35,23 @@ begin
rwa r at e,
end

lemma choose_eq_factorial_div_factorial' {a b : ℕ}
(hab : a ≤ b) : (b.choose a : ℚ) = b! / (a! * (b - a)!) :=
begin
field_simp [mul_ne_zero, factorial_ne_zero], norm_cast,
rw ← choose_mul_factorial_mul_factorial hab, ring,
end

lemma choose_mul {n k s : ℕ} (hn : k ≤ n) (hs : s ≤ k) :
(n.choose k : ℚ) * k.choose s = n.choose s * (n - s).choose (k - s) :=
begin
rw [choose_eq_factorial_div_factorial' hn, choose_eq_factorial_div_factorial' hs,
choose_eq_factorial_div_factorial' (le_trans hs hn), choose_eq_factorial_div_factorial' ],
swap,
{ exact nat.sub_le_sub_right hn s, },
{ field_simp [mul_ne_zero, factorial_ne_zero],
rw sub_sub_sub_cancel_right hs, ring, },
end

end prime
end nat

0 comments on commit 70d7114

Please sign in to comment.