
(* :Title: Combinatorial Simplification *)

(* :Author: Roman Maeder *)

(* :Summary: combinatorial simplifications useful for summation *)

(* :Context: DiscreteMath`CombinatorialSimplification` *)

(* :Package Version: 1.1 *)

(* :Copyright: Copyright 1988, Wolfram Research Inc. *)

(* :History: *)

(* :Keywords: *)

(* :Source: none *)

(* :Warning: redefines Factorial, Binomial, and Product. *)

(* :Mathematica Version: 2.0 *)

(* :Limitation:  *)

(* :Discussion: *)


BeginPackage["DiscreteMath`CombinatorialSimplification`"]

Begin["Private`"]

protection = Unprotect[Factorial, Binomial, Product]

Factorial/:
  (n_)!/(m_)! := Product[i, {i, m+1, n}]	/; n - m > 0 && IntegerQ[n-m]
Factorial/:
  (n_)!/(m_)! := 1/Product[i, {i, n+1, m}]	/; m - n > 0 && IntegerQ[m-n]

Binomial/:
  Binomial[n_, k_]/Binomial[n_, k1_] := (n-k+1)/k /; k1 == k-1
Binomial/:
  Binomial[n_, k1_]/Binomial[n_, k_] := k/(n-k+1) /; k1 == k-1

Product/:
  Product[t_, {x_, a_, n_, 1}]/Product[t_, {x_, a_, n1_, 1}] :=
    (t /. x-> n)					/; n1 == n-1
Product/:
  Product[t_, {x_, a_, n1_, 1}]/Product[t_, {x_, a_, n_, 1}] :=
    1/(t /. x-> n)					/; n1 == n-1

Factorial/:
  (k_)! k1_ := (k1)!		/; k1 - k == 1

Protect[Evaluate[protection]]

End[]

EndPackage[]

Null
