Factorial and variants #
This file defines the factorial, along with the ascending and descending variants.
Main declarations #
Nat.factorial
: The factorial.Nat.ascFactorial
: 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.descFactorial
: The descending factorial. It runs fromn - k
ton
.
Nat.factorial n
is the factorial of n
.
Equations
- Nat.factorial 0 = 1
- Nat.factorial (Nat.succ n) = Nat.succ n * Nat.factorial n
Instances For
factorial notation n!
Equations
- Nat.term_! = Lean.ParserDescr.trailingNode `Nat.term_! 10000 0 (Lean.ParserDescr.symbol "!")
Instances For
Ascending and descending factorials #
n.ascFactorial k = (n + k)! / n!
(as seen in Nat.ascFactorial_eq_div
), but implemented
recursively to allow for "quick" computation when using norm_num
. This is closely related to
ascPochhammer
, but much less general.
Equations
- Nat.ascFactorial n 0 = 1
- Nat.ascFactorial n (Nat.succ n_1) = (n + n_1 + 1) * Nat.ascFactorial n n_1
Instances For
n.ascFactorial k = (n + k)! / n!
but without ℕ-division. See Nat.ascFactorial_eq_div
for
the version with ℕ-division.
Avoid in favor of Nat.factorial_mul_ascFactorial
if you can. ℕ-division isn't worth it.
n.descFactorial k = n! / (n - k)!
(as seen in Nat.descFactorial_eq_div
), but
implemented recursively to allow for "quick" computation when using norm_num
. This is closely
related to ascPochhammer
, but much less general.
Equations
- Nat.descFactorial n 0 = 1
- Nat.descFactorial n (Nat.succ n_1) = (n - n_1) * Nat.descFactorial n n_1
Instances For
Alias of the reverse direction of Nat.descFactorial_eq_zero_iff_lt
.
n.descFactorial k = n! / (n - k)!
but without ℕ-division. See Nat.descFactorial_eq_div
for the version using ℕ-division.
Avoid in favor of Nat.factorial_mul_descFactorial
if you can. ℕ-division isn't worth it.