Function of #cas
BernoulliB
Bernoulli numbers and Bernoulli polynomials for , with theorems about Mathlib’s bernoulli and Polynomial.bernoulli.
#cas (BernoulliB n)bernoulli n = v in ℚ for the printed value v.#cas (BernoulliB n x)#cas (BernoulliB n q)#cas [N d] (BernoulliB n q)BernoulliB gives you the Bernoulli numbers and the Bernoulli polynomials. Call it with one argument and you get the number . Call it with two and you get the polynomial , whose constant term is the number . The sign of is a convention, and here it is Mathlib’s, , because the theorems are about Mathlib’s bernoulli and Polynomial.bernoulli. I want the printed number to agree with the definition your proof will use.
Examples (11)#
Basic Examples (2)
A Bernoulli number, in lowest terms:
#cas (BernoulliB 10)
Bernoulli number
5/66- Domain
ℚ (Mathlib's bernoulli, B₁ = -1/2)- Input (natural number)
10
Checked by Lean’s kernel: Bernoulli number from the kernel-evaluated numerators
bernoulli 10 = 5 / 66
The certificate: 1 checked step
Bernoulli number from the kernel-evaluated numerators
bernoulli 10 = 5 / 66
A Bernoulli polynomial, with the theorem at every real :
#cas (BernoulliB 4 x)
polynomial with exact rational coefficients
x^4 - 2*x^3 + x^2 - 1/30- Domain
Polynomial.bernoulli 4, x ∈ ℝ- Input (polynomial in x)
BernoulliB 4 x
Checked by Lean’s kernel: Monomial expansion of BernoulliB 4
∀ (x : ℝ), (Polynomial.aeval x) (Polynomial.bernoulli 4) = x ^ 4 - 2 * x ^ 3 + x ^ 2 - 1 / 30
The certificate: 1 checked step
Monomial expansion of BernoulliB 4
∀ (x : ℝ), (Polynomial.aeval x) (Polynomial.bernoulli 4) = x ^ 4 - 2 * x ^ 3 + x ^ 2 - 1 / 30
Scope (3)
follows Mathlib’s convention :
#cas (BernoulliB 1)
Bernoulli number
-1/2- Domain
ℚ (Mathlib's bernoulli, B₁ = -1/2)- Input (natural number)
1
Checked by Lean’s kernel: Bernoulli number from the kernel-evaluated numerators
bernoulli 1 = -(1 / 2)
The certificate: 1 checked step
Bernoulli number from the kernel-evaluated numerators
bernoulli 1 = -(1 / 2)
The variable need not be x, and expand prints the same polynomial:
#cas [expand] (BernoulliB 2 y)
polynomial with exact rational coefficients
y^2 - y + 1/6- Domain
Polynomial.bernoulli 2, y ∈ ℝ- Input (polynomial in y)
BernoulliB 2 y
Checked by Lean’s kernel: Monomial expansion of BernoulliB 2
∀ (y : ℝ), (Polynomial.aeval y) (Polynomial.bernoulli 2) = y ^ 2 - y + 1 / 6
The certificate: 1 checked step
Monomial expansion of BernoulliB 2
∀ (y : ℝ), (Polynomial.aeval y) (Polynomial.bernoulli 2) = y ^ 2 - y + 1 / 6
At a rational point, [N d] gives the exact value with its first digits:
#cas [N 10] (BernoulliB 2 (1/2))
exact rational value and its first 10 significant digits, truncated
-1/12 ≈ -0.08333333333- Domain
BernoulliB polynomial at a rational point
Checked by Lean’s kernel: Exact value and digits of BernoulliB 2
(Polynomial.aeval (1 / 2)) (Polynomial.bernoulli 2) = -(1 / 12) ∧ -(8333333333 + 1) / 10 ^ 11 < (Polynomial.aeval (1 / 2)) (Polynomial.bernoulli 2) ∧ (Polynomial.aeval (1 / 2)) (Polynomial.bernoulli 2) ≤ -8333333333 / 10 ^ 11
The certificate: 1 checked step
Exact value and digits of BernoulliB 2
(Polynomial.aeval (1 / 2)) (Polynomial.bernoulli 2) = -(1 / 12) ∧ -(8333333333 + 1) / 10 ^ 11 < (Polynomial.aeval (1 / 2)) (Polynomial.bernoulli 2) ∧ (Polynomial.aeval (1 / 2)) (Polynomial.bernoulli 2) ≤ -8333333333 / 10 ^ 11
Applications (2)
A proof can take the printed theorem as a hypothesis and specialize it, here at :
theorem bernoulliB_four_at_half (h : ∀ x : ℝ, Polynomial.aeval x (Polynomial.bernoulli 4) = x ^ 4 - 2 * x ^ 3 + x ^ 2 - 1 / 30) : Polynomial.aeval (1 / 2 : ℝ) (Polynomial.bernoulli 4) = 7 / 240 := by rw [h] norm_num #print axioms bernoulliB_four_at_half
bernoulliB_four_at_half depends on the axioms propext, Classical.choice, Quot.sound.
The tactic cas does not evaluate bernoulli, so a proof repeats the two steps of the command, the rewrite and the kernel’s evaluation:
theorem bernoulli_ten : bernoulli 10 = 5 / 66 := by rw [CAS.Analysis.SpecialFunctions.bernoulli_eq_numerators] decide +kernel #print axioms bernoulli_ten
bernoulli_ten depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (2)
The constant term of is the Bernoulli number :
#cas (BernoulliB 4)
Bernoulli number
-1/30- Domain
ℚ (Mathlib's bernoulli, B₁ = -1/2)- Input (natural number)
4
Checked by Lean’s kernel: Bernoulli number from the kernel-evaluated numerators
bernoulli 4 = -(1 / 30)
The certificate: 1 checked step
Bernoulli number from the kernel-evaluated numerators
bernoulli 4 = -(1 / 30)
The values of zeta at the nonpositive integers come from Bernoulli numbers, such as :
#cas (zeta (-1))
exact value of ζ
-1/12- Domain
ℂ (Mathlib's riemannZeta)- Input (nonpositive integer)
s = -1
Checked by Lean’s kernel: ζ(-k) by Bernoulli numbers (riemannZeta_neg_nat_eq_bernoulli)
riemannZeta (-1) = -(1 / 12)
The certificate: 1 checked step
ζ(-k) by Bernoulli numbers (riemannZeta_neg_nat_eq_bernoulli)
riemannZeta (-1) = -(1 / 12)
Possible Issues (2)
Both forms stop at , the cutoff of the command, although bernoulli_eq_numerators holds at every and Polynomial.bernoulli_def gives the coefficients at every degree in a proof:
#cas (BernoulliB 61)
Error
BernoulliB computes Bₙ for n ≤ 60
#cas (BernoulliB 61 x)
Error
BernoulliB accepts degrees up to 60
The index is an integer:
#cas (BernoulliB (1/2))
Error
BernoulliB takes integer arguments; `1/2` is not an integer
