Factorial and variants #
This file defines the factorial, along with the ascending and descending variants.
Main declarations #
nat.factorial
: The factorial.nat.asc_factorial
: The ascending factorial. Note that it runs fromn + 1
ton + k
and not fromn
ton + k - 1
. We might want to change that in the future.nat.desc_factorial
: The descending factorial. It runs fromn - k
ton
.
Ascending and descending factorials #
n.asc_factorial k = (n + k)! / n!
(as seen in nat.asc_factorial_eq_div
), but implemented
recursively to allow for "quick" computation when using norm_num
. This is closely related to
pochhammer
, but much less general.
Equations
- n.asc_factorial (k + 1) = (n + k + 1) * n.asc_factorial k
- n.asc_factorial 0 = 1
n.asc_factorial k = (n + k)! / n!
but without ℕ-division. See nat.asc_factorial_eq_div
for
the version with ℕ-division.
Avoid in favor of nat.factorial_mul_asc_factorial
if you can. ℕ-division isn't worth it.
n.desc_factorial k = n! / (n - k)!
(as seen in nat.desc_factorial_eq_div
), but
implemented recursively to allow for "quick" computation when using norm_num
. This is closely
related to pochhammer
, but much less general.
Equations
- n.desc_factorial (k + 1) = (n - k) * n.desc_factorial k
- n.desc_factorial 0 = 1
Alias of nat.desc_factorial_eq_zero_iff_lt
.
n.desc_factorial k = n! / (n - k)!
but without ℕ-division. See nat.desc_factorial_eq_div
for the version using ℕ-division.
Avoid in favor of nat.factorial_mul_desc_factorial
if you can. ℕ-division isn't worth it.