mathlib documentation

data.nat.factorial.basic

Factorial and variants #

This file defines the factorial, along with the ascending and descending variants.

Main declarations #

@[simp]
def nat.factorial  :

nat.factorial n is the factorial of n.

Equations
@[simp]
theorem nat.factorial_zero  :
0! = 1
@[simp]
theorem nat.factorial_succ (n : ) :
(n.succ)! = (n + 1) * n!
@[simp]
theorem nat.factorial_one  :
1! = 1
@[simp]
theorem nat.factorial_two  :
2! = 2
theorem nat.mul_factorial_pred {n : } (hn : 0 < n) :
n * (n - 1)! = n!
theorem nat.factorial_pos (n : ) :
0 < n!
theorem nat.factorial_ne_zero (n : ) :
n! 0
theorem nat.factorial_dvd_factorial {m n : } (h : m n) :
m! n!
theorem nat.dvd_factorial {m n : } :
0 < mm nm n!
theorem nat.factorial_le {m n : } (h : m n) :
m! n!
theorem nat.factorial_mul_pow_le_factorial {m n : } :
m! * m.succ ^ n (m + n)!
theorem nat.factorial_lt {m n : } (hn : 0 < n) :
n! < m! n < m
theorem nat.one_lt_factorial {n : } :
1 < n! 1 < n
theorem nat.factorial_eq_one {n : } :
n! = 1 n 1
theorem nat.factorial_inj {m n : } (hn : 1 < n!) :
n! = m! n = m
theorem nat.self_le_factorial (n : ) :
n n!
theorem nat.lt_factorial_self {n : } (hi : 3 n) :
n < n!
theorem nat.add_factorial_succ_lt_factorial_add_succ {i : } (n : ) (hi : 2 i) :
i + (n + 1)! < (i + n + 1)!
theorem nat.add_factorial_lt_factorial_add {i n : } (hi : 2 i) (hn : 1 n) :
i + n! < (i + n)!
theorem nat.add_factorial_succ_le_factorial_add_succ (i n : ) :
i + (n + 1)! (i + (n + 1))!
theorem nat.add_factorial_le_factorial_add (i : ) {n : } (n1 : 1 n) :
i + n! (i + n)!
theorem nat.factorial_mul_pow_sub_le_factorial {n m : } (hnm : n m) :
n! * n ^ (m - n) m!

Ascending and descending factorials #

def nat.asc_factorial (n : ) :

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
@[simp]
theorem nat.asc_factorial_zero (n : ) :
@[simp]
theorem nat.zero_asc_factorial (k : ) :
theorem nat.asc_factorial_succ {n k : } :
theorem nat.succ_asc_factorial (n k : ) :
(n + 1) * n.succ.asc_factorial k = (n + k + 1) * n.asc_factorial k
theorem nat.factorial_mul_asc_factorial (n k : ) :
n! * n.asc_factorial k = (n + k)!

n.asc_factorial k = (n + k)! / n! but without ℕ-division. See nat.asc_factorial_eq_div for the version with ℕ-division.

theorem nat.asc_factorial_eq_div (n k : ) :
n.asc_factorial k = (n + k)! / n!

Avoid in favor of nat.factorial_mul_asc_factorial if you can. ℕ-division isn't worth it.

theorem nat.asc_factorial_of_sub {n k : } (h : k < n) :
(n - k) * (n - k).asc_factorial k = (n - (k + 1)).asc_factorial (k + 1)
theorem nat.pow_succ_le_asc_factorial (n k : ) :
(n + 1) ^ k n.asc_factorial k
theorem nat.pow_lt_asc_factorial' (n k : ) :
(n + 1) ^ (k + 2) < n.asc_factorial (k + 2)
theorem nat.pow_lt_asc_factorial (n : ) {k : } :
2 k(n + 1) ^ k < n.asc_factorial k
theorem nat.asc_factorial_le_pow_add (n k : ) :
n.asc_factorial k (n + k) ^ k
theorem nat.asc_factorial_lt_pow_add (n : ) {k : } :
2 kn.asc_factorial k < (n + k) ^ k
theorem nat.asc_factorial_pos (n k : ) :
def nat.desc_factorial (n : ) :

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
@[simp]
theorem nat.desc_factorial_zero (n : ) :
@[simp]
theorem nat.desc_factorial_succ (n k : ) :
@[simp]
theorem nat.desc_factorial_one (n : ) :
@[simp]
theorem nat.succ_desc_factorial_succ (n k : ) :
(n + 1).desc_factorial (k + 1) = (n + 1) * n.desc_factorial k
theorem nat.succ_desc_factorial (n k : ) :
(n + 1 - k) * (n + 1).desc_factorial k = (n + 1) * n.desc_factorial k
@[simp]
theorem nat.factorial_mul_desc_factorial {n k : } :
k n(n - k)! * n.desc_factorial k = n!

n.desc_factorial k = n! / (n - k)! but without ℕ-division. See nat.desc_factorial_eq_div for the version using ℕ-division.

theorem nat.desc_factorial_eq_div {n k : } (h : k n) :
n.desc_factorial k = n! / (n - k)!

Avoid in favor of nat.factorial_mul_desc_factorial if you can. ℕ-division isn't worth it.

theorem nat.pow_sub_le_desc_factorial (n k : ) :
(n + 1 - k) ^ k n.desc_factorial k
theorem nat.pow_sub_lt_desc_factorial' {n k : } :
k + 2 n(n - (k + 1)) ^ (k + 2) < n.desc_factorial (k + 2)
theorem nat.pow_sub_lt_desc_factorial {n k : } :
2 kk n(n + 1 - k) ^ k < n.desc_factorial k
theorem nat.desc_factorial_lt_pow {n : } (hn : 1 n) {k : } :
2 kn.desc_factorial k < n ^ k