Function of #cas
binomial
The binomial coefficient of natural numbers and , with a theorem about Mathlib’s Nat.choose.
#cas (binomial n k)Nat.choose n k = c.binomial computes a binomial coefficient . It is a small thing, but the value comes with a theorem about Mathlib’s Nat.choose, so a proof can use the number the report prints instead of a number copied over by hand.
Examples (9)#
Basic Examples (1)
The number of ways to choose 3 of 10 things, with the theorem that the kernel checked:
#cas (binomial 10 3)
binomial
120- Domain
ℕ- Input (natural numbers)
(10, 3)
Checked by Lean’s kernel: binomial
Nat.choose 10 3 = 120
The certificate: 1 checked step
binomial
Nat.choose 10 3 = 120
Scope (2)
The largest coefficient for , with 30 digits:
#cas (binomial 100 50)
binomial
100891344545564193334812497256- Domain
ℕ- Input (natural numbers)
(100, 50)
Checked by Lean’s kernel: binomial
Nat.choose 100 50 = 100891344545564193334812497256
The certificate: 1 checked step
binomial
Nat.choose 100 50 = 100891344545564193334812497256
For the coefficient is 0:
#cas (binomial 3 10)
binomial
0- Domain
ℕ- Input (natural numbers)
(3, 10)
Checked by Lean’s kernel: binomial
Nat.choose 3 10 = 0
The certificate: 1 checked step
binomial
Nat.choose 3 10 = 0
Applications (1)
Properties and Relations (1)
Possible Issues (4)
Mathlib’s Ring.choose extends to negative , and the call evaluates Nat.choose, so a negative argument is refused:
#cas (binomial (-3) 2)
Error
binomial takes a natural number as its first argument; `-3` is negative
The arguments are numbers, not variables:
#cas (binomial x 2)
Error
binomial takes integer arguments; `x` is a variable
The call takes two arguments:
#cas (binomial 10)
Error
binomial takes 2 arguments, as in `binomial n k`; the call has 1
The value has at most 10000 digits, and has 30101:
#cas (binomial 100000 50000)
Error
binomial: the value has more than 10000 digits, the most that a call computes
See Also
factorial · gamma · integerDigits · cas
