(* (c) Copyright 2006-2016 Microsoft Corporation and Inria.                  *)
(* Distributed under the terms of CeCILL-B.                                  *)
From mathcomp
From mathcomp
(******************************************************************************)
(* This files contains the definition of:                                     *)
(*   'C(n, m) == the binomial coeficient n choose m.                          *)
(*     n ^_ m == the falling (or lower) factorial of n with m terms, i.e.,    *)
(*               the product n * (n - 1) * ... * (n - m + 1).                 *)
(*               Note that n ^_ m = 0 if m > n, and 'C(n, m) = n ^_ m %/ m/!. *)
(*                                                                            *)
(* In additions to the properties of these functions, we prove a few seminal  *)
(* results such as triangular_sum, Wilson and Pascal; their proofs are good   *)
(* examples of how to manipulate expressions with bigops.                     *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
(** More properties of the factorial **)

(* Specifications: *)
Lemma fact_smonotone m n : 0 < m -> m < n -> m`! < n`!.
Lemma fact_prod n : n`! = \prod_(1 <= i < n.+1) i.
Lemma logn_fact p n : prime p -> logn p n`! = \sum_(1 <= k < n.+1) n %/ p ^ k.
Theorem Wilson p : p > 1 -> prime p = (p %| ((p.-1)`!).+1).
Fixpoint ffact_rec n m := if m is m'.+1 then n * ffact_rec n.-1 m' else 1.