The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V12. Number theory

Mathlib.NumberTheory.Bernoulli

40 declarations. Mathlib docs · Source

Bernoulli numbers

The Bernoulli numbers are a sequence of rational numbers that frequently show up in number theory.

Mathematical overview

The Bernoulli numbers $(B_0, B_1, B_2, \ldots)=(1, -1/2, 1/6, 0, -1/30, \ldots)$ are a sequence of rational numbers. They show up in the formula for the sums of $k$th powers. They are related to the Taylor series expansions of $x/\tan(x)$ and of $\coth(x)$, and also show up in the values that the Riemann Zeta function takes both at both negative and positive integers (and hence in the theory of modular forms). For example, if $1 \leq n$ then

$$\zeta(2n)=\sum_{t\geq1}t^{-2n}=(-1)^{n+1}\frac{(2\pi)^{2n}B_{2n}}{2(2n)!}.$$

This result is formalised in Lean: riemannZeta_two_mul_nat.

The Bernoulli numbers can be formally defined using the power series

$$\sum B_n\frac{t^n}{n!}=\frac{t}{1-e^{-t}}$$

although that happens to not be the definition in mathlib (this is an implementation detail and need not concern the mathematician).

Note that $B_1=-1/2$, meaning that we are using the $B_n^-$ of from Wikipedia.

Implementation detail

The Bernoulli numbers are defined using well-founded induction, by the formula $$B_n=1-\sum_{k\lt n}\frac{\binom{n}{k}}{n-k+1}B_k.$$ This formula is true for all $n$ and in particular $B_0=1$. Note that this is the definition for positive Bernoulli numbers, which we call bernoulli'. The negative Bernoulli numbers are then defined as bernoulli := (-1)^n * bernoulli'.

The proof of von Staudt-Clausen's theorem follows Rado's JLMS 1934 paper "A New Proof of a Theorem of v. Staudt".

Main theorems

  • sum_bernoulli : ∑ k ∈ range n, (n.choose k : ℚ) * bernoulli k = if n = 1 then 1 else 0
  • Bernoulli.vonStaudt_clausen : bernoulli (2 * k) + ∑ p ∈ range (2 * k + 2) with p.Prime ∧ (p - 1) ∣ 2 * k, (1 : ℚ) / p ∈ Set.range Int.cast

References

  • https://en.wikipedia.org/wiki/Bernoulli_number
  • [R. Rado, A New Proof of a Theorem of v. Staudt][Rado1934]

Definitions

Examples

The von Staudt-Clausen Theorem

Here we formalize Rado's proof of von Staudt-Clausen's theorem, which states that for any $k \ge 0$, $$B_{2k} + \sum_{p \text{ prime}, (p - 1) \mid 2k} \frac{1}{p} \in \mathbb{Z}.$$ Rado's proof is based on Faulhaber's theorem and induction on $k$.

def bernoulli' E1 #

ℕ → ℚ

The Bernoulli numbers: the $n$-th Bernoulli number $B_n$ is defined recursively via $$B_n = 1 - \sum_{k < n} \binom{n}{k}\frac{B_k}{n+1-k}$$

theorem bernoulli'_def' E1 #

∀ (n : ℕ), bernoulli' n = 1 - ∑ k, ↑(n.choose ↑k) / (↑n - ↑↑k + 1) * bernoulli' ↑k

theorem bernoulli'_def E0 #

∀ (n : ℕ), bernoulli' n = 1 - ∑ k ∈ Finset.range n, ↑(n.choose k) / (↑n - ↑k + 1) * bernoulli' k

theorem bernoulli'_spec E1 #

∀ (n : ℕ), ∑ k ∈ Finset.range n.succ, ↑(n.choose (n - k)) / (↑n - ↑k + 1) * bernoulli' k = 1

theorem bernoulli'_spec' E1 #

∀ (n : ℕ), ∑ k ∈ Finset.HasAntidiagonal.antidiagonal n, ↑((k.1 + k.2).choose k.2) / (↑k.2 + 1) * bernoulli' k.1 = 1

theorem bernoulli'_zero E0 #

bernoulli' 0 = 1

theorem bernoulli'_one E0 #

bernoulli' 1 = 2⁻¹

theorem bernoulli'_two E0 #

bernoulli' 2 = 6⁻¹

theorem bernoulli'_three E0 #

bernoulli' 3 = 0

theorem bernoulli'_four E0 #

bernoulli' 4 = -30⁻¹

theorem bernoulli'_five E0 #

bernoulli' 5 = 0

theorem bernoulli'_six E0 #

bernoulli' 6 = 42⁻¹

theorem sum_bernoulli' E0 #

∀ (n : ℕ), ∑ k ∈ Finset.range n, ↑(n.choose k) * bernoulli' k = ↑n

def bernoulli'PowerSeries E1 #

(A : Type u_1) → [inst : CommRing A] → [Algebra ℚ A] → PowerSeries A

The exponential generating function for the Bernoulli numbers bernoulli' n.

theorem bernoulli'PowerSeries_mul_exp_sub_one E1 #

∀ (A : Type u_1) [inst : CommRing A] [inst_1 : Algebra ℚ A],
  bernoulli'PowerSeries A * (PowerSeries.exp A - 1) = PowerSeries.X * PowerSeries.exp A

theorem bernoulli'_eq_zero_of_odd E1 #

∀ {n : ℕ}, Odd n → 1 < n → bernoulli' n = 0

Odd Bernoulli numbers (greater than 1) are zero.

def bernoulli E3 #

ℕ → ℚ

The Bernoulli numbers are defined to be bernoulli' with a parity sign.

theorem bernoulli'_eq_bernoulli E1 #

∀ (n : ℕ), bernoulli' n = (-1) ^ n * bernoulli n

theorem neg_bernoulli'_succ_eq_bernoulli E1 #

∀ (n : ℕ), -bernoulli' (n + 1) = (-1) ^ n * bernoulli (n + 1)

theorem bernoulli_zero E0 #

bernoulli 0 = 1

theorem bernoulli_one E0 #

bernoulli 1 = -2⁻¹

theorem bernoulli_two E0 #

bernoulli 2 = 6⁻¹

theorem bernoulli_three E0 #

bernoulli 3 = 0

theorem bernoulli_four E0 #

bernoulli 4 = -30⁻¹

theorem bernoulli_five E0 #

bernoulli 5 = 0

theorem bernoulli_six E0 #

bernoulli 6 = 42⁻¹

theorem bernoulli_eq_zero_of_odd E0 #

∀ {n : ℕ}, Odd n → 1 < n → bernoulli n = 0

theorem bernoulli_eq_bernoulli'_of_ne_one E1 #

∀ {n : ℕ}, n ≠ 1 → bernoulli n = bernoulli' n

theorem sum_bernoulli E0 #

∀ (n : ℕ), ∑ k ∈ Finset.range n, ↑(n.choose k) * bernoulli k = if n = 1 then 1 else 0

theorem bernoulli_spec' E1 #

∀ (n : ℕ),
  ∑ k ∈ Finset.HasAntidiagonal.antidiagonal n, ↑((k.1 + k.2).choose k.2) / (↑k.2 + 1) * bernoulli k.1 =
    if n = 0 then 1 else 0

def bernoulliPowerSeries E1 #

(A : Type u_1) → [inst : CommRing A] → [Algebra ℚ A] → PowerSeries A

The exponential generating function for the Bernoulli numbers bernoulli n.

theorem bernoulliPowerSeries_mul_exp_sub_one E1 #

∀ (A : Type u_1) [inst : CommRing A] [inst_1 : Algebra ℚ A],
  bernoulliPowerSeries A * (PowerSeries.exp A - 1) = PowerSeries.X

theorem sum_range_pow E3 #

∀ (n p : ℕ),
  ∑ k ∈ Finset.range n, ↑k ^ p =
    ∑ i ∈ Finset.range (p + 1), bernoulli i * ↑((p + 1).choose i) * ↑n ^ (p + 1 - i) / (↑p + 1)

Faulhaber's theorem relating the sum of p-th powers to the Bernoulli numbers: $$\sum_{k=0}^{n-1} k^p = \sum_{i=0}^p B_i\binom{p+1}{i}\frac{n^{p+1-i}}{p+1}.$$ See https://proofwiki.org/wiki/Faulhaber%27s_Formula and [orosi2018faulhaber] for the proof provided here.

theorem sum_Ico_pow E3 #

∀ (n p : ℕ),
  ∑ k ∈ Finset.Ico 1 (n + 1), ↑k ^ p =
    ∑ i ∈ Finset.range (p + 1), bernoulli' i * ↑((p + 1).choose i) * ↑n ^ (p + 1 - i) / (↑p + 1)

Alternate form of Faulhaber's theorem, relating the sum of p-th powers to the Bernoulli numbers: $$\sum_{k=1}^{n} k^p = \sum_{i=0}^p (-1)^iB_i\binom{p+1}{i}\frac{n^{p+1-i}}{p+1}.$$ Deduced from sum_range_pow.

theorem Bernoulli.vonStaudt_clausen E3 #

∀ (k : ℕ),
  bernoulli (2 * k) + ∑ p ∈ Finset.range (2 * k + 2) with Nat.Prime p ∧ p - 1 ∣ 2 * k, 1 / ↑p ∈ Set.range Int.cast

von Staudt-Clausen theorem: For any natural number $k$, the sum $$B_{2k} + \sum_{p - 1 \mid 2k} \frac{1}{p}$$ is an integer.

theorem Bernoulli.padicValuation_bernoulli E1 #

∀ {k p : ℕ} [inst : Fact (Nat.Prime p)],
  0 < k → p - 1 ∣ 2 * k → (Rat.padicValuation p) (bernoulli (2 * k)) = WithZero.exp 1

If p is prime, 0 < k, and p - 1 ∣ 2 * k, then the p-adic valuation of the Bernoulli number B₂ₖ is WithZero.exp 1, the valuation of 1 / p.

theorem Bernoulli.padicValRat_bernoulli E1 #

∀ {k p : ℕ} [Fact (Nat.Prime p)], 0 < k → p - 1 ∣ 2 * k → padicValRat p (bernoulli (2 * k)) = -1

If p is prime, 0 < k, and p - 1 ∣ 2 * k, then the p-adic valuation of the Bernoulli number B₂ₖ is -1.

theorem Bernoulli.dvd_den_bernoulli E1 #

∀ {k p : ℕ} [Fact (Nat.Prime p)], 0 < k → p - 1 ∣ 2 * k → p ∣ (bernoulli (2 * k)).den

If p is prime, 0 < k, and p - 1 ∣ 2 * k, then p divides the denominator of the Bernoulli number B₂ₖ.

theorem Bernoulli.not_dvd_num_bernoulli E1 #

∀ {k p : ℕ} [Fact (Nat.Prime p)], 0 < k → p - 1 ∣ 2 * k → ¬↑p ∣ (bernoulli (2 * k)).num

If p is prime, 0 < k, and p - 1 ∣ 2 * k, then p does not divide the numerator of the Bernoulli number B₂ₖ.

theorem Bernoulli.not_sq_dvd_den_bernoulli E1 #

∀ {k p : ℕ} [Fact (Nat.Prime p)], 0 < k → p - 1 ∣ 2 * k → ¬p ^ 2 ∣ (bernoulli (2 * k)).den

If p is prime, 0 < k, and p - 1 ∣ 2 * k, then p ^ 2 does not divide the denominator of the Bernoulli number B₂ₖ: each prime occurs in the denominator with multiplicity one.