(**************************************************************)
(*   Copyright Dominique Larchey-Wendling [*]                 *)
(*                                                            *)
(*                             [*] Affiliation LORIA -- CNRS  *)
(**************************************************************)
(*      This file is distributed under the terms of the       *)
(*         CeCILL v2 FREE SOFTWARE LICENSE AGREEMENT          *)
(**************************************************************)
(** ** Binomial theorem *)
Set Implicit Arguments.
Section factorial.
Fixpoint fact n := match n with 0 => 1 | S n => (S n) * fact n end.
Fact fact_0 : fact 0 = 1.
End factorial.
Section binomial.
Infix "<d" := divides (at level 70, no associativity).
Hint Resolve divides_refl.
Let fact_neq_0 n : fact n <> 0.
Fact binomial_gt n : forall p, n < p -> binomial n p = 0.
Fact binomial_nn n : binomial n n = 1.

Theorem binomial_thm n p : p <= n -> fact n = binomial n p * fact p * fact (n-p).
Fact binomial_le n p : p <= n -> binomial n p = div (fact n) (fact p * fact (n-p)).