Function of #cas

BernoulliB

Bernoulli numbers Bn and Bernoulli polynomials Bn(x) for n≤60, with theorems about Mathlib’s bernoulli and Polynomial.bernoulli.

#cas (BernoulliB n)
gives the Bernoulli number Bn for n ≤ 60, with B1=−12, and proves bernoulli n = v in ℚ for the printed value v.
#cas (BernoulliB n x)
gives the Bernoulli polynomial Bn in the variable x, in monomials with exact rational coefficients, and proves the expansion at every real x.
#cas (BernoulliB n q)
gives the exact value of Bn at the rational number q and proves it.
#cas [N d] (BernoulliB n q)
gives the exact value of Bn at q with its first d significant digits, truncated toward zero, and proves their decimal bounds.

BernoulliB gives you the Bernoulli numbers and the Bernoulli polynomials. Call it with one argument and you get the number Bn. Call it with two and you get the polynomial Bn(x), whose constant term is the number Bn. The sign of B1 is a convention, and here it is Mathlib’s, B1=−12, 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.

Details and Options

  • n is a natural number with n≤60, a literal or a closed integer expression.
  • For the number the theorem is bernoulli n = v in ℚ, for the printed value v. Mathlib’s bernoulli' has B1′=12 instead. The proof rewrites with CAS.Analysis.SpecialFunctions.bernoulli_eq_numerators, which holds at every n and writes Bn as entry n of the integer recurrence bernoulliNumerators n over (n+1)!, and the kernel evaluates the recurrence and decides the equation (decide +kernel).
  • B0=1, and Bn=0 for odd n≥3.
  • For the polynomial the theorem is ∀ x : ℝ, Polynomial.aeval x (Polynomial.bernoulli n) = p for the printed p, from Polynomial.coeff_bernoulli and integer Bernoulli numerators that the kernel evaluates (CAS.Analysis.SpecialFunctions.bernoulli_eq_intPoly).
  • The second argument is a variable, which the polynomial is written in, or a rational number. At a rational q the call proves the exact value of Bn(q), and [N d] adds its first d significant digits, truncated toward zero, with their decimal bounds in the theorem. The report prints v = digits when the digits are exact and v ≈ digits otherwise.
  • #cas [expand] (BernoulliB n x) prints the same polynomial as #cas (BernoulliB n x).
  • The tactic cas does not evaluate bernoulli. A proof repeats the two steps of the command, as in the Applications below.
  • There are no options.

Examples (11)#

Basic Examples (2)

A Bernoulli number, in lowest terms:

In[1]:=
#cas (BernoulliB 10)
Out[1]=

Bernoulli number

566
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
  1. Bernoulli number from the kernel-evaluated numerators

    bernoulli 10 = 5 / 66

    Checked by Lean’s kernel


A Bernoulli polynomial, with the theorem at every real x:

In[2]:=
#cas (BernoulliB 4 x)
Out[2]=

polynomial with exact rational coefficients

x4−2x3+x2−130
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
  1. Monomial expansion of BernoulliB 4

    ∀ (x : ℝ), (Polynomial.aeval x) (Polynomial.bernoulli 4) = x ^ 4 - 2 * x ^ 3 + x ^ 2 - 1 / 30

    Checked by Lean’s kernel

Scope (3)

B1 follows Mathlib’s convention B1=−12:

In[3]:=
#cas (BernoulliB 1)
Out[3]=

Bernoulli number

−12
-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
  1. Bernoulli number from the kernel-evaluated numerators

    bernoulli 1 = -(1 / 2)

    Checked by Lean’s kernel


The variable need not be x, and expand prints the same polynomial:

In[4]:=
#cas [expand] (BernoulliB 2 y)
Out[4]=

polynomial with exact rational coefficients

y2−y+16
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
  1. Monomial expansion of BernoulliB 2

    ∀ (y : ℝ), (Polynomial.aeval y) (Polynomial.bernoulli 2) = y ^ 2 - y + 1 / 6

    Checked by Lean’s kernel


At a rational point, [N d] gives the exact value with its first digits:

In[5]:=
#cas [N 10] (BernoulliB 2 (1/2))
Out[5]=

exact rational value and its first 10 significant digits, truncated

−112≈−0.08333333333
-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
  1. 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

    Checked by Lean’s kernel

Applications (2)

A proof can take the printed theorem as a hypothesis and specialize it, here at x=12:

In[6]:=
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
Out[6]=

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:

In[7]:=
theorem bernoulli_ten : bernoulli 10 = 5 / 66 := by
  rw [CAS.Analysis.SpecialFunctions.bernoulli_eq_numerators]
  decide +kernel

#print axioms bernoulli_ten
Out[7]=

bernoulli_ten depends on the axioms propext, Classical.choice, Quot.sound.

Properties and Relations (2)

The constant term of B4(x)=x4−2x3+x2−130 is the Bernoulli number B4:

In[8]:=
#cas (BernoulliB 4)
Out[8]=

Bernoulli number

−130
-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
  1. Bernoulli number from the kernel-evaluated numerators

    bernoulli 4 = -(1 / 30)

    Checked by Lean’s kernel


The values of zeta at the nonpositive integers come from Bernoulli numbers, such as ζ(−1)=−B2/2=−112:

In[9]:=
#cas (zeta (-1))
Out[9]=

exact value of ζ

−112
-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
  1. ζ(-k) by Bernoulli numbers (riemannZeta_neg_nat_eq_bernoulli)

    riemannZeta (-1) = -(1 / 12)

    Checked by Lean’s kernel

Possible Issues (2)

Both forms stop at n=60, the cutoff of the command, although bernoulli_eq_numerators holds at every n and Polynomial.bernoulli_def gives the coefficients at every degree in a proof:

In[10]:=
#cas (BernoulliB 61)
Out[10]=

Error

BernoulliB computes Bₙ for n ≤ 60
In[11]:=
#cas (BernoulliB 61 x)
Out[11]=

Error

BernoulliB accepts degrees up to 60

The index is an integer:

In[12]:=
#cas (BernoulliB (1/2))
Out[12]=

Error

BernoulliB takes integer arguments; `1/2` is not an integer

See Also

zeta · sum · LegendreP · expand · N