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.ArithmeticFunction.Misc

71 declarations and 1 deprecated aliases. Mathlib docs · Source

Miscellaneous arithmetic Functions

This file defines some simple examples of arithmetic functions (functions ℕ → R vanishing at 0, considered as a ring under Dirichlet convolution). Note that the Von Mangoldt and Möbius functions are in separate files.

Main Definitions

  • σ k is the arithmetic function such that σ k x = ∑ y ∈ divisors x, y ^ k for 0 < x.
  • pow k is the arithmetic function such that pow k x = x ^ k for 0 < x.
  • id is the identity arithmetic function on ℕ.
  • ω n is the number of distinct prime factors of n.
  • Ω n is the number of prime factors of n counted with multiplicity.

Notation

The arithmetic functions σ, ω and Ω have Greek letter names. This notation is scoped to the separate locales ArithmeticFunction.sigma for σ, ArithmeticFunction.omega for ω and ArithmeticFunction.Omega for Ω, to allow for selective access.

Tags

arithmetic functions, dirichlet convolution, divisors

def ArithmeticFunction.prodPrimeFactors E1 #

{R : Type u_1} → [inst : CommMonoidWithZero R] → (ℕ → R) → ArithmeticFunction R

The map $n \mapsto \prod_{p \mid n} f(p)$ as an arithmetic function

def ArithmeticFunction.bigproddvd E1 #

Lean.ParserDescr

∏ᵖ p ∣ n, f p is custom notation for prodPrimeFactors f n

theorem ArithmeticFunction.prodPrimeFactors_apply E0 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] {f : ℕ → R} {n : ℕ},
  n ≠ 0 → (ArithmeticFunction.prodPrimeFactors fun p ↦ f p) n = ∏ p ∈ n.primeFactors, f p

theorem ArithmeticFunction.IsMultiplicative.prodPrimeFactors E1 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] (f : ℕ → R), (ArithmeticFunction.prodPrimeFactors f).IsMultiplicative

theorem ArithmeticFunction.IsMultiplicative.prodPrimeFactors_add_of_squarefree E1 #

∀ {R : Type u_1} [inst : CommSemiring R] {f g : ArithmeticFunction R},
  f.IsMultiplicative →
    g.IsMultiplicative → ∀ {n : ℕ}, Squarefree n → (ArithmeticFunction.prodPrimeFactors fun p ↦ (f + g) p) n = (f * g) n

def ArithmeticFunction.id E3 #

ArithmeticFunction ℕ

The identity on ℕ as an ArithmeticFunction.

theorem ArithmeticFunction.id_apply E0 #

∀ {x : ℕ}, ArithmeticFunction.id x = x

theorem ArithmeticFunction.isMultiplicative_id E1 #

ArithmeticFunction.id.IsMultiplicative

def ArithmeticFunction.pow E1 #

ℕ → ArithmeticFunction ℕ

pow k n = n ^ k, except pow 0 0 = 0.

theorem ArithmeticFunction.pow_apply E0 #

∀ {k n : ℕ}, (ArithmeticFunction.pow k) n = if k = 0 ∧ n = 0 then 0 else n ^ k

theorem ArithmeticFunction.pow_zero_eq_zeta E1 #

ArithmeticFunction.pow 0 = ArithmeticFunction.zeta

theorem ArithmeticFunction.pow_one_eq_id E1 #

ArithmeticFunction.pow 1 = ArithmeticFunction.id

theorem ArithmeticFunction.isMultiplicative_pow E1 #

∀ {k : ℕ}, (ArithmeticFunction.pow k).IsMultiplicative

def ArithmeticFunction.sigma E1 #

ℕ → ArithmeticFunction ℕ

σ k n is the sum of the kth powers of the divisors of n

def ArithmeticFunction.sigma.termσ E1 #

Lean.ParserDescr

σ k n is the sum of the kth powers of the divisors of n

theorem ArithmeticFunction.sigma_apply E0 #

∀ {k n : ℕ}, (ArithmeticFunction.sigma k) n = ∑ d ∈ n.divisors, d ^ k

theorem ArithmeticFunction.sigma_eq_zero E0 #

∀ {k n : ℕ}, (ArithmeticFunction.sigma k) n = 0 ↔ n = 0

theorem ArithmeticFunction.sigma_pos_iff E0 #

∀ {k n : ℕ}, 0 < (ArithmeticFunction.sigma k) n ↔ 0 < n

theorem ArithmeticFunction.sigma_apply_prime_pow E1 #

∀ {k p i : ℕ}, Nat.Prime p → (ArithmeticFunction.sigma k) (p ^ i) = ∑ j ∈ Finset.range (i + 1), p ^ (j * k)

theorem ArithmeticFunction.sigma_one_apply E0 #

∀ (n : ℕ), (ArithmeticFunction.sigma 1) n = ∑ d ∈ n.divisors, d

theorem ArithmeticFunction.sigma_one_apply_prime_pow E1 #

∀ {p i : ℕ}, Nat.Prime p → (ArithmeticFunction.sigma 1) (p ^ i) = ∑ k ∈ Finset.range (i + 1), p ^ k

theorem ArithmeticFunction.sigma_eq_sum_div E1 #

∀ (k n : ℕ), (ArithmeticFunction.sigma k) n = ∑ d ∈ n.divisors, (n / d) ^ k

theorem ArithmeticFunction.sigma_zero_apply E0 #

∀ (n : ℕ), (ArithmeticFunction.sigma 0) n = n.divisors.card

theorem ArithmeticFunction.sigma_zero_apply_prime_pow E1 #

∀ {p i : ℕ}, Nat.Prime p → (ArithmeticFunction.sigma 0) (p ^ i) = i + 1

theorem ArithmeticFunction.sigma_one E0 #

∀ (k : ℕ), (ArithmeticFunction.sigma k) 1 = 1

theorem ArithmeticFunction.sigma_pos E1 #

∀ (k n : ℕ), n ≠ 0 → 0 < (ArithmeticFunction.sigma k) n

theorem ArithmeticFunction.sigma_mono E1 #

∀ (k k' n : ℕ), k ≤ k' → (ArithmeticFunction.sigma k) n ≤ (ArithmeticFunction.sigma k') n

theorem ArithmeticFunction.zeta_mul_pow_eq_sigma E1 #

∀ {k : ℕ}, ArithmeticFunction.zeta * ArithmeticFunction.pow k = ArithmeticFunction.sigma k

theorem ArithmeticFunction.isMultiplicative_sigma E1 #

∀ {k : ℕ}, (ArithmeticFunction.sigma k).IsMultiplicative

theorem ArithmeticFunction.sigma_eq_prod_primeFactors_sum_range_factorization_pow_mul E1 #

∀ {k n : ℕ},
  n ≠ 0 → (ArithmeticFunction.sigma k) n = ∏ p ∈ n.primeFactors, ∑ i ∈ Finset.range (n.factorization p + 1), p ^ (i * k)

theorem ArithmeticFunction.sigma_le_pow_succ E1 #

∀ (k n : ℕ), (ArithmeticFunction.sigma k) n ≤ n ^ (k + 1)

A crude upper bound: σ_k(n) ≤ n ^ (k + 1).

theorem Nat.card_divisors E1 #

∀ {n : ℕ}, n ≠ 0 → n.divisors.card = ∏ x ∈ n.primeFactors, (n.factorization x + 1)

theorem Nat.divisors_card_eq_one_iff E0 #

∀ (n : ℕ), n.divisors.card = 1 ↔ n = 1

theorem ArithmeticFunction.sigma_eq_one_iff E0 #

∀ (k n : ℕ), (ArithmeticFunction.sigma k) n = 1 ↔ n = 1

theorem Nat.sum_divisors E1 #

∀ {n : ℕ}, n ≠ 0 → ∑ d ∈ n.divisors, d = ∏ p ∈ n.primeFactors, ∑ k ∈ Finset.range (n.factorization p + 1), p ^ k

def ArithmeticFunction.cardFactors E1 #

ArithmeticFunction ℕ

Ω n is the number of prime factors of n.

def ArithmeticFunction.Omega.termΩ E1 #

Lean.ParserDescr

Ω n is the number of prime factors of n.

theorem ArithmeticFunction.cardFactors_apply E0 #

∀ {n : ℕ}, ArithmeticFunction.cardFactors n = n.primeFactorsList.length

theorem ArithmeticFunction.cardFactors_zero E1 #

ArithmeticFunction.cardFactors 0 = 0

theorem ArithmeticFunction.cardFactors_one E0 #

ArithmeticFunction.cardFactors 1 = 0

theorem ArithmeticFunction.cardFactors_eq_zero_iff_eq_zero_or_one E0 #

∀ {n : ℕ}, ArithmeticFunction.cardFactors n = 0 ↔ n = 0 ∨ n = 1

theorem ArithmeticFunction.cardFactors_pos_iff_one_lt E0 #

∀ {n : ℕ}, 0 < ArithmeticFunction.cardFactors n ↔ 1 < n

theorem ArithmeticFunction.cardFactors_eq_one_iff_prime E0 #

∀ {n : ℕ}, ArithmeticFunction.cardFactors n = 1 ↔ Nat.Prime n

theorem ArithmeticFunction.cardFactors_mul E1 #

∀ {m n : ℕ},
  m ≠ 0 →
    n ≠ 0 → ArithmeticFunction.cardFactors (m * n) = ArithmeticFunction.cardFactors m + ArithmeticFunction.cardFactors n

theorem ArithmeticFunction.cardFactors_multiset_prod E1 #

∀ {s : Multiset ℕ},
  s.prod ≠ 0 → ArithmeticFunction.cardFactors s.prod = (Multiset.map (⇑ArithmeticFunction.cardFactors) s).sum

theorem ArithmeticFunction.cardFactors_apply_prime E0 #

∀ {p : ℕ}, Nat.Prime p → ArithmeticFunction.cardFactors p = 1

theorem ArithmeticFunction.cardFactors_pow E1 #

∀ {m k : ℕ}, ArithmeticFunction.cardFactors (m ^ k) = k * ArithmeticFunction.cardFactors m

theorem ArithmeticFunction.cardFactors_apply_prime_pow E0 #

∀ {p k : ℕ}, Nat.Prime p → ArithmeticFunction.cardFactors (p ^ k) = k

theorem ArithmeticFunction.cardFactors_eq_sum_factorization E1 #

∀ {n : ℕ}, ArithmeticFunction.cardFactors n = n.factorization.sum fun x k ↦ k

def ArithmeticFunction.cardDistinctFactors E1 #

ArithmeticFunction ℕ

ω n is the number of distinct prime factors of n.

def ArithmeticFunction.omega.termω E1 #

Lean.ParserDescr

ω n is the number of distinct prime factors of n.

theorem ArithmeticFunction.cardDistinctFactors_zero E1 #

ArithmeticFunction.cardDistinctFactors 0 = 0

theorem ArithmeticFunction.cardDistinctFactors_one E0 #

ArithmeticFunction.cardDistinctFactors 1 = 0

theorem ArithmeticFunction.cardDistinctFactors_eq_length_dedup_primeFactorsList E1 #

∀ {n : ℕ}, ArithmeticFunction.cardDistinctFactors n = n.primeFactorsList.dedup.length

theorem ArithmeticFunction.cardDistinctFactors_eq_card_primeFactors E1 #

∀ {n : ℕ}, ArithmeticFunction.cardDistinctFactors n = n.primeFactors.card

theorem ArithmeticFunction.cardDistinctFactors_eq_zero E0 #

∀ {n : ℕ}, ArithmeticFunction.cardDistinctFactors n = 0 ↔ n ≤ 1

theorem ArithmeticFunction.cardDistinctFactors_pos E0 #

∀ {n : ℕ}, 0 < ArithmeticFunction.cardDistinctFactors n ↔ 1 < n

theorem ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree E1 #

∀ {n : ℕ}, n ≠ 0 → (ArithmeticFunction.cardDistinctFactors n = ArithmeticFunction.cardFactors n ↔ Squarefree n)

theorem ArithmeticFunction.cardDistinctFactors_eq_one_iff E0 #

∀ {n : ℕ}, ArithmeticFunction.cardDistinctFactors n = 1 ↔ IsPrimePow n

theorem ArithmeticFunction.cardDistinctFactors_apply_prime_pow E0 #

∀ {p k : ℕ}, Nat.Prime p → k ≠ 0 → ArithmeticFunction.cardDistinctFactors (p ^ k) = 1

theorem ArithmeticFunction.cardDistinctFactors_apply_prime E0 #

∀ {p : ℕ}, Nat.Prime p → ArithmeticFunction.cardDistinctFactors p = 1

theorem ArithmeticFunction.cardDistinctFactors_mul E1 #

∀ {m n : ℕ},
  m.Coprime n →
    ArithmeticFunction.cardDistinctFactors (m * n) =
      ArithmeticFunction.cardDistinctFactors m + ArithmeticFunction.cardDistinctFactors n

theorem ArithmeticFunction.cardDistinctFactors_prod E1 #

∀ {ι : Type u_2} {s : Finset ι} {f : ι → ℕ},
  (↑s).Pairwise (Function.onFun Nat.Coprime f) →
    ArithmeticFunction.cardDistinctFactors (∏ i ∈ s, f i) = ∑ i ∈ s, ArithmeticFunction.cardDistinctFactors (f i)

theorem ArithmeticFunction.sum_Ioc_zeta E1 #

∀ (N : ℕ), ∑ n ∈ Finset.Ioc 0 N, ArithmeticFunction.zeta n = N

theorem ArithmeticFunction.sum_Ioc_mul_eq_sum_prod_filter E1 #

∀ {R : Type u_2} [inst : Semiring R] (f g : ArithmeticFunction R) (N : ℕ),
  ∑ n ∈ Finset.Ioc 0 N, (f * g) n = ∑ x ∈ Finset.Ioc 0 N ×ˢ Finset.Ioc 0 N with x.1 * x.2 ≤ N, f x.1 * g x.2

theorem ArithmeticFunction.sum_Ioc_mul_eq_sum_sum E1 #

∀ {R : Type u_2} [inst : Semiring R] (f g : ArithmeticFunction R) (N : ℕ),
  ∑ n ∈ Finset.Ioc 0 N, (f * g) n = ∑ n ∈ Finset.Ioc 0 N, f n * ∑ m ∈ Finset.Ioc 0 (N / n), g m

theorem ArithmeticFunction.sum_Ioc_mul_zeta_eq_sum E1 #

∀ {R : Type u_2} [inst : Semiring R] (f : ArithmeticFunction R) (N : ℕ),
  ∑ n ∈ Finset.Ioc 0 N, (f * ↑ArithmeticFunction.zeta) n = ∑ n ∈ Finset.Ioc 0 N, f n * ↑(N / n)

theorem ArithmeticFunction.sum_Ioc_sigma0_eq_sum_div E1 #

∀ (N : ℕ), ∑ n ∈ Finset.Ioc 0 N, (ArithmeticFunction.sigma 0) n = ∑ n ∈ Finset.Ioc 0 N, N / n

An O(N) formula for the sum of the number of divisors function.

theorem Nat.Coprime.card_divisors_mul E1 #

∀ {m n : ℕ}, m.Coprime n → (m * n).divisors.card = m.divisors.card * n.divisors.card

theorem Nat.Coprime.sum_divisors_mul E1 #

∀ {m n : ℕ}, m.Coprime n → ∑ d ∈ (m * n).divisors, d = (∑ d ∈ m.divisors, d) * ∑ d ∈ n.divisors, d

def Mathlib.Meta.Positivity.evalArithmeticFunctionSigma E1 #

Mathlib.Meta.Positivity.PositivityExt

Extension for ArithmeticFunction.sigma.

Deprecated aliases

NameNew nameSince
ArithmeticFunction.cardDistinctFactors_applyArithmeticFunction.cardDistinctFactors_eq_length_dedup_primeFactorsList2026-10-20