Arithmetic Functions and Dirichlet Convolution #
This file defines arithmetic functions, which are functions from ℕ
to a specified type that map 0
to 0. In the literature, they are often instead defined as functions from ℕ+
. These arithmetic
functions are endowed with a multiplication, given by Dirichlet convolution, and pointwise addition,
to form the Dirichlet ring.
Main Definitions #
ArithmeticFunction R
consists of functionsf : ℕ → R
such thatf 0 = 0
.- An arithmetic function
f
IsMultiplicative
whenx.coprime y → f (x * y) = f x * f y
. - The pointwise operations
pmul
andppow
differ from the multiplication and power instances onArithmeticFunction R
, which use Dirichlet multiplication. ζ
is the arithmetic function such thatζ x = 1
for0 < x
.σ k
is the arithmetic function such thatσ k x = ∑ y ∈ divisors x, y ^ k
for0 < x
.pow k
is the arithmetic function such thatpow k x = x ^ k
for0 < x
.id
is the identity arithmetic function onℕ
.ω n
is the number of distinct prime factors ofn
.Ω n
is the number of prime factors ofn
counted with multiplicity.μ
is the Möbius function (spelledmoebius
in code).
Main Results #
- Several forms of Möbius inversion:
sum_eq_iff_sum_mul_moebius_eq
for functions to aCommRing
sum_eq_iff_sum_smul_moebius_eq
for functions to anAddCommGroup
prod_eq_iff_prod_pow_moebius_eq
for functions to aCommGroup
prod_eq_iff_prod_pow_moebius_eq_of_nonzero
for functions to aCommGroupWithZero
- And variants that apply when the equalities only hold on a set
S : Set ℕ
such thatm ∣ n → n ∈ S → m ∈ S
: sum_eq_iff_sum_mul_moebius_eq_on
for functions to aCommRing
sum_eq_iff_sum_smul_moebius_eq_on
for functions to anAddCommGroup
prod_eq_iff_prod_pow_moebius_eq_on
for functions to aCommGroup
prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero
for functions to aCommGroupWithZero
Notation #
All notation is localized in the namespace ArithmeticFunction
.
The arithmetic functions ζ
, σ
, ω
, Ω
and μ
have Greek letter names.
In addition, there are separate locales ArithmeticFunction.zeta
for ζ
,
ArithmeticFunction.sigma
for σ
, ArithmeticFunction.omega
for ω
,
ArithmeticFunction.Omega
for Ω
, and ArithmeticFunction.Moebius
for μ
,
to allow for selective access to these notations.
The arithmetic function $$n \mapsto \prod_{p \mid n} f(p)$$ is given custom notation
∏ᵖ p ∣ n, f p
when applied to n
.
Tags #
arithmetic functions, dirichlet convolution, divisors
An arithmetic function is a function from ℕ
that maps 0 to 0. In the literature, they are
often instead defined as functions from ℕ+
. Multiplication on ArithmeticFunctions
is by
Dirichlet convolution.
Equations
- ArithmeticFunction R = ZeroHom ℕ R
Instances For
Equations
- ArithmeticFunction.zero R = inferInstanceAs (Zero (ZeroHom ℕ R))
Equations
Coerce an arithmetic function with values in ℕ
to one with values in R
. We cannot inline
this in natCoe
because it gets unfolded too much.
Instances For
Equations
- ArithmeticFunction.natCoe = { coe := ArithmeticFunction.natToArithmeticFunction }
Coerce an arithmetic function with values in ℤ
to one with values in R
. We cannot inline
this in intCoe
because it gets unfolded too much.
Instances For
Equations
- ArithmeticFunction.intCoe = { coe := ArithmeticFunction.ofInt }
Equations
- ArithmeticFunction.add = { add := fun (f g : ArithmeticFunction R) => { toFun := fun (n : ℕ) => f n + g n, map_zero' := ⋯ } }
Equations
- ArithmeticFunction.instAddMonoid = AddMonoid.mk ⋯ ⋯ nsmulRec ⋯ ⋯
Equations
- ArithmeticFunction.instAddMonoidWithOne = AddMonoidWithOne.mk ⋯ ⋯
Equations
- ArithmeticFunction.instAddCommMonoid = AddCommMonoid.mk ⋯
Equations
- ArithmeticFunction.instNeg = { neg := fun (f : ArithmeticFunction R) => { toFun := fun (n : ℕ) => -f n, map_zero' := ⋯ } }
Equations
- ArithmeticFunction.instAddGroup = AddGroup.mk ⋯
Equations
- ArithmeticFunction.instAddCommGroup = AddCommGroup.mk ⋯
The Dirichlet convolution of two arithmetic functions f
and g
is another arithmetic function
such that (f * g) n
is the sum of f x * g y
over all (x,y)
such that x * y = n
.
Equations
- One or more equations did not get rendered due to their size.
The Dirichlet convolution of two arithmetic functions f
and g
is another arithmetic function
such that (f * g) n
is the sum of f x * g y
over all (x,y)
such that x * y = n
.
Equations
- ArithmeticFunction.instMul = { mul := fun (x1 x2 : ArithmeticFunction R) => x1 • x2 }
Equations
- ArithmeticFunction.instSemiring = Semiring.mk ⋯ ⋯ ⋯ ⋯ Monoid.npow ⋯ ⋯
Equations
- ArithmeticFunction.instCommSemiring = CommSemiring.mk ⋯
Equations
- ArithmeticFunction.instCommRing = CommRing.mk ⋯
ζ 0 = 0
, otherwise ζ x = 1
. The Dirichlet Series is the Riemann ζ
.
Equations
- ArithmeticFunction.zeta = { toFun := fun (x : ℕ) => if x = 0 then 0 else 1, map_zero' := ArithmeticFunction.zeta.proof_1 }
Instances For
ζ 0 = 0
, otherwise ζ x = 1
. The Dirichlet Series is the Riemann ζ
.
Equations
- ArithmeticFunction.termζ = Lean.ParserDescr.node `ArithmeticFunction.termζ 1024 (Lean.ParserDescr.symbol "ζ")
Instances For
ζ 0 = 0
, otherwise ζ x = 1
. The Dirichlet Series is the Riemann ζ
.
Equations
- ArithmeticFunction.zeta.termζ = Lean.ParserDescr.node `ArithmeticFunction.zeta.termζ 1024 (Lean.ParserDescr.symbol "ζ")
Instances For
This is the pointwise product of ArithmeticFunction
s.
Instances For
This is the pointwise power of ArithmeticFunction
s.
Equations
- f.ppow k = if h0 : k = 0 then ↑ArithmeticFunction.zeta else { toFun := fun (x : ℕ) => f x ^ k, map_zero' := ⋯ }
Instances For
This is the pointwise division of ArithmeticFunction
s.
Instances For
This result only holds for DivisionSemiring
s instead of GroupWithZero
s because zeta takes
values in ℕ, and hence the coercion requires an AddMonoidWithOne
. TODO: Generalise zeta
The map $n \mapsto \prod_{p \mid n} f(p)$ as an arithmetic function
Equations
- ArithmeticFunction.prodPrimeFactors f = { toFun := fun (d : ℕ) => if d = 0 then 0 else ∏ p ∈ d.primeFactors, f p, map_zero' := ⋯ }
Instances For
∏ᵖ p ∣ n, f p
is custom notation for prodPrimeFactors f n
Equations
- One or more equations did not get rendered due to their size.
Instances For
Multiplicative functions
Instances For
For any multiplicative function f
and any n > 0
,
we can evaluate f n
by evaluating f
at p ^ k
over the factorization of n
A recapitulation of the definition of multiplicative that is simpler for proofs
Two multiplicative functions f
and g
are equal if and only if
they agree on prime powers
The identity on ℕ
as an ArithmeticFunction
.
Equations
- ArithmeticFunction.id = { toFun := id, map_zero' := ArithmeticFunction.id.proof_1 }
Instances For
pow k n = n ^ k
, except pow 0 0 = 0
.
Equations
- ArithmeticFunction.pow k = ArithmeticFunction.id.ppow k
Instances For
σ k n
is the sum of the k
th powers of the divisors of n
Equations
- ArithmeticFunction.sigma k = { toFun := fun (n : ℕ) => ∑ d ∈ n.divisors, d ^ k, map_zero' := ⋯ }
Instances For
σ k n
is the sum of the k
th powers of the divisors of n
Equations
- ArithmeticFunction.termσ = Lean.ParserDescr.node `ArithmeticFunction.termσ 1024 (Lean.ParserDescr.symbol "σ")
Instances For
σ k n
is the sum of the k
th powers of the divisors of n
Equations
- ArithmeticFunction.sigma.termσ = Lean.ParserDescr.node `ArithmeticFunction.sigma.termσ 1024 (Lean.ParserDescr.symbol "σ")
Instances For
Ω n
is the number of prime factors of n
.
Equations
- ArithmeticFunction.cardFactors = { toFun := fun (n : ℕ) => n.primeFactorsList.length, map_zero' := ArithmeticFunction.cardFactors.proof_1 }
Instances For
Ω n
is the number of prime factors of n
.
Equations
- ArithmeticFunction.termΩ = Lean.ParserDescr.node `ArithmeticFunction.termΩ 1024 (Lean.ParserDescr.symbol "Ω")
Instances For
Ω n
is the number of prime factors of n
.
Equations
- ArithmeticFunction.Omega.termΩ = Lean.ParserDescr.node `ArithmeticFunction.Omega.termΩ 1024 (Lean.ParserDescr.symbol "Ω")
Instances For
ω n
is the number of distinct prime factors of n
.
Equations
- ArithmeticFunction.cardDistinctFactors = { toFun := fun (n : ℕ) => n.primeFactorsList.dedup.length, map_zero' := ArithmeticFunction.cardDistinctFactors.proof_1 }
Instances For
ω n
is the number of distinct prime factors of n
.
Equations
- ArithmeticFunction.termω = Lean.ParserDescr.node `ArithmeticFunction.termω 1024 (Lean.ParserDescr.symbol "ω")
Instances For
ω n
is the number of distinct prime factors of n
.
Equations
- ArithmeticFunction.omega.termω = Lean.ParserDescr.node `ArithmeticFunction.omega.termω 1024 (Lean.ParserDescr.symbol "ω")
Instances For
μ
is the Möbius function. If n
is squarefree with an even number of distinct prime factors,
μ n = 1
. If n
is squarefree with an odd number of distinct prime factors, μ n = -1
.
If n
is not squarefree, μ n = 0
.
Equations
- ArithmeticFunction.moebius = { toFun := fun (n : ℕ) => if Squarefree n then (-1) ^ ArithmeticFunction.cardFactors n else 0, map_zero' := ArithmeticFunction.moebius.proof_1 }
Instances For
μ
is the Möbius function. If n
is squarefree with an even number of distinct prime factors,
μ n = 1
. If n
is squarefree with an odd number of distinct prime factors, μ n = -1
.
If n
is not squarefree, μ n = 0
.
Equations
- ArithmeticFunction.termμ = Lean.ParserDescr.node `ArithmeticFunction.termμ 1024 (Lean.ParserDescr.symbol "μ")
Instances For
μ
is the Möbius function. If n
is squarefree with an even number of distinct prime factors,
μ n = 1
. If n
is squarefree with an odd number of distinct prime factors, μ n = -1
.
If n
is not squarefree, μ n = 0
.
Equations
- ArithmeticFunction.Moebius.termμ = Lean.ParserDescr.node `ArithmeticFunction.Moebius.termμ 1024 (Lean.ParserDescr.symbol "μ")
Instances For
Equations
- ArithmeticFunction.instInvertibleNatToArithmeticFunctionZeta = { invOf := ↑ArithmeticFunction.moebius, invOf_mul_self := ⋯, mul_invOf_self := ⋯ }
A unit in ArithmeticFunction R
that evaluates to ζ
, with inverse μ
.
Equations
- ArithmeticFunction.zetaUnit = { val := ↑ArithmeticFunction.zeta, inv := ↑ArithmeticFunction.moebius, val_inv := ⋯, inv_val := ⋯ }
Instances For
Möbius inversion for functions to an AddCommGroup
.
Möbius inversion for functions to a CommGroupWithZero
.
Möbius inversion for functions to an AddCommGroup
, where the equalities only hold on a
well-behaved set.
Möbius inversion for functions to a CommGroupWithZero
, where the equalities only hold on
a well-behaved set.