Documentation

Formalizations.Reusable.NumberTheory

Reusable layer: number theory #

Stable names for archive results in number theory. Each theorem re-exposes its archive proof.

Main results #

theorem Formalizations.Reusable.wolstenholme_choose_modEq (p : ℕ) (hp : Nat.Prime p) (h5 : 5 ≤ p) :
(2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3] ∧ (2 * p).choose p ≡ 2 [MOD p ^ 3]

Wolstenholme's theorem (1862). For a prime p ≥ 5, C(2p − 1, p − 1) ≡ 1 (mod p³) and, equivalently, C(2p, p) ≡ 2 (mod p³), with Mathlib's Nat.choose and Nat.ModEq. The proof shows that the harmonic sum Σ_{k<p} 1/k vanishes in ZMod (p²) and expands (p − 1)! · C(2p − 1, p − 1) = Π_{k<p} (p + k) in ZMod (p³).

theorem Formalizations.Reusable.touchard_bell_add_prime (p : ℕ) [Fact (Nat.Prime p)] (n : ℕ) :
↑(n + p).bell = ↑n.bell + ↑(n + 1).bell

Touchard's congruence (1933). For a prime p and every n, the Bell numbers (Mathlib's Nat.bell) satisfy B(n + p) = B(n) + B(n + 1) in ZMod p; in particular B(p) ≡ 2 (mod p). The proof uses the umbral functional L(Xⁿ) = B(n) on (ZMod p)[X], for which the falling factorial of order p is X^p − X.

theorem Formalizations.Reusable.ded_reciprocity {h k : ℕ} (hc : h.Coprime k) (hh : 0 < h) (hk : 0 < k) :
DedekindSum.ded (↑h) k + DedekindSum.ded (↑k) h = (↑h ^ 2 + ↑k ^ 2 + 1) / (12 * ↑h * ↑k) - 1 / 4

Dedekind reciprocity. For coprime positive integers h, k, the Dedekind sums s(h, k) = Σ_{r<k} ((r/k)) ((hr/k)), with the sawtooth ((x)) = x - ⌊x⌋ - 1/2 (and 0 at integers), satisfy s(h, k) + s(k, h) = (h² + k² + 1) / (12 h k) − 1/4.

The Dirichlet identity τ ∗ φ = σ. For every n, Σ_{d ∣ n} τ(d) φ(n/d) = σ(n), where τ(d) is the number of divisors of d, φ Euler's totient and σ(n) the sum of the divisors of n.

Cyclotomic reciprocity. For n ≥ 2, reversing the coefficients of the real cyclotomic polynomial Φₙ leaves it unchanged.

theorem Formalizations.Reusable.exists_fib_modEq_period (m : ℕ) (hm : 0 < m) :
∃ (period : ℕ), 0 < period ∧ ∀ (n : ℕ), Nat.fib (n + period) ≡ Nat.fib n [MOD m]

Existence of Pisano periods. For every positive modulus m, the Fibonacci sequence has a positive period modulo m, valid from index zero.

theorem Formalizations.Reusable.even_of_fib_modEq_period (m : ℕ) (hm : 2 < m) (period : ℕ) (hperiod : 0 < period) (hper : ∀ (n : ℕ), Nat.fib (n + period) ≡ Nat.fib n [MOD m]) :
Even period

Parity of Pisano periods. When m > 2, every positive period of the Fibonacci sequence modulo m is even.

Fibonacci numbers at primes. For every prime p, the Fibonacci number F_p equals the Legendre symbol (5/p) in ZMod p, including p = 2 and p = 5.

theorem Formalizations.Reusable.flynn_connolly :
(∀ (p n : ℕ), Nat.Prime p → p % 2 = 1 → p % 3 = 2 → p % 5 = 2 ∨ p % 5 = 3 → n = 2 * p ∨ n = 4 * p → Nat.fib n % 2 = 1 ∧ Nat.fib (Nat.fib n + 2) % Nat.fib n = 1) ∧ {k : ℕ | Odd k ∧ k ∣ ∑ i ∈ Finset.Icc 1 k, Nat.fib i}.Infinite

Flynn-Connolly's theorem. For each odd prime p with p ≡ 2 (mod 3) and p ≡ ±2 (mod 5), both F_(2p) and F_(4p) are odd and satisfy F_(k+2) ≡ 1 (mod k) when substituted for k. Infinitely many odd k divide F₁ + ⋯ + Fₖ.

theorem Formalizations.Reusable.amiot_interval {n k : ℕ} (hk1 : 1 < k) (hk2 : k < n - 1) (c₀ : ZMod n) (a : (ZMod n)ˣ) (ha1 : ↑a ≠ 1) (ha2 : ↑a ≠ -1) :
¬∀ (x : ZMod n), (x - c₀).val < k → (↑a * x - c₀).val < k

Amiot's interval lemma. For 1 < k < n − 1, some point of the cyclic interval of length k starting at c₀ leaves the interval when multiplied by any specified unit a ≠ ±1. Membership in this interval is expressed by (x - c₀).val < k.