Documentation

Mathlib.NumberTheory.ArithmeticFunction

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 #

Main Results #

Notation #

The arithmetic functions ζ and σ have Greek letter names, which are localized notation in the namespace ArithmeticFunction.

Tags #

arithmetic functions, dirichlet convolution, divisors

def Nat.ArithmeticFunction (R : Type u_1) [Zero R] :
Type u_1

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
Instances For
    Equations
    @[simp]
    theorem Nat.ArithmeticFunction.toFun_eq {R : Type u_1} [Zero R] (f : Nat.ArithmeticFunction R) :
    f.toFun = f
    @[simp]
    theorem Nat.ArithmeticFunction.coe_mk {R : Type u_1} [Zero R] (f : R) (hf : f 0 = 0) :
    { toFun := f, map_zero' := hf } = f
    @[simp]
    theorem Nat.ArithmeticFunction.map_zero {R : Type u_1} [Zero R] {f : Nat.ArithmeticFunction R} :
    f 0 = 0
    @[simp]
    theorem Nat.ArithmeticFunction.zero_apply {R : Type u_1} [Zero R] {x : } :
    0 x = 0
    theorem Nat.ArithmeticFunction.ext {R : Type u_1} [Zero R] ⦃f : Nat.ArithmeticFunction R ⦃g : Nat.ArithmeticFunction R (h : ∀ (x : ), f x = g x) :
    f = g
    theorem Nat.ArithmeticFunction.ext_iff {R : Type u_1} [Zero R] {f : Nat.ArithmeticFunction R} {g : Nat.ArithmeticFunction R} :
    f = g ∀ (x : ), f x = g x
    Equations
    • One or more equations did not get rendered due to their size.
    theorem Nat.ArithmeticFunction.one_apply {R : Type u_1} [Zero R] [One R] {x : } :
    1 x = if x = 1 then 1 else 0
    @[simp]
    theorem Nat.ArithmeticFunction.one_one {R : Type u_1} [Zero R] [One R] :
    1 1 = 1
    @[simp]
    theorem Nat.ArithmeticFunction.one_apply_ne {R : Type u_1} [Zero R] [One R] {x : } (h : x 1) :
    1 x = 0

    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.

    Equations
    • f = { toFun := fun n => ↑(f n), map_zero' := (_ : ↑(f 0) = 0) }
    Instances For
      Equations
      • Nat.ArithmeticFunction.natCoe = { coe := Nat.ArithmeticFunction.natToArithmeticFunction }
      @[simp]
      theorem Nat.ArithmeticFunction.natCoe_apply {R : Type u_1} [AddMonoidWithOne R] {f : Nat.ArithmeticFunction } {x : } :
      f x = ↑(f x)

      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.

      Equations
      • f = { toFun := fun n => ↑(f n), map_zero' := (_ : ↑(f 0) = 0) }
      Instances For
        Equations
        • Nat.ArithmeticFunction.intCoe = { coe := Nat.ArithmeticFunction.ofInt }
        @[simp]
        theorem Nat.ArithmeticFunction.intCoe_apply {R : Type u_1} [AddGroupWithOne R] {f : Nat.ArithmeticFunction } {x : } :
        f x = ↑(f x)
        @[simp]
        @[simp]
        @[simp]
        Equations
        • Nat.ArithmeticFunction.add = { add := fun f g => { toFun := fun n => f n + g n, map_zero' := (_ : f 0 + g 0 = 0) } }
        @[simp]
        theorem Nat.ArithmeticFunction.add_apply {R : Type u_1} [AddMonoid R] {f : Nat.ArithmeticFunction R} {g : Nat.ArithmeticFunction R} {n : } :
        ↑(f + g) n = f n + g n
        Equations
        • One or more equations did not get rendered due to their size.
        Equations
        • Nat.ArithmeticFunction.instAddMonoidWithOne = let src := Nat.ArithmeticFunction.instAddMonoid; let src_1 := Nat.ArithmeticFunction.one; AddMonoidWithOne.mk
        Equations

        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.
        @[simp]
        theorem Nat.ArithmeticFunction.smul_apply {R : Type u_1} {M : Type u_2} [Zero R] [AddCommMonoid M] [SMul R M] {f : Nat.ArithmeticFunction R} {g : Nat.ArithmeticFunction M} {n : } :
        ↑(f g) n = Finset.sum (Nat.divisorsAntidiagonal n) fun x => f x.fst g x.snd

        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
        • Nat.ArithmeticFunction.instMulArithmeticFunctionToZeroToMonoidWithZero = { mul := fun x x_1 => x x_1 }
        @[simp]
        theorem Nat.ArithmeticFunction.mul_apply {R : Type u_1} [Semiring R] {f : Nat.ArithmeticFunction R} {g : Nat.ArithmeticFunction R} {n : } :
        ↑(f * g) n = Finset.sum (Nat.divisorsAntidiagonal n) fun x => f x.fst * g x.snd
        theorem Nat.ArithmeticFunction.mul_apply_one {R : Type u_1} [Semiring R] {f : Nat.ArithmeticFunction R} {g : Nat.ArithmeticFunction R} :
        ↑(f * g) 1 = f 1 * g 1
        @[simp]
        @[simp]
        theorem Nat.ArithmeticFunction.intCoe_mul {R : Type u_1} [Ring R] {f : Nat.ArithmeticFunction } {g : Nat.ArithmeticFunction } :
        ↑(f * g) = f * g
        Equations
        Equations
        • One or more equations did not get rendered due to their size.
        Equations
        • One or more equations did not get rendered due to their size.
        Equations
        • One or more equations did not get rendered due to their size.

        ζ 0 = 0, otherwise ζ x = 1. The Dirichlet Series is the Riemann ζ.

        Equations
        Instances For

          ζ 0 = 0, otherwise ζ x = 1. The Dirichlet Series is the Riemann ζ.

          Equations
          Instances For
            @[simp]
            theorem Nat.ArithmeticFunction.zeta_apply {x : } :
            Nat.ArithmeticFunction.zeta x = if x = 0 then 0 else 1

            This is the pointwise product of ArithmeticFunctions.

            Equations
            Instances For

              This is the pointwise power of ArithmeticFunctions.

              Equations
              Instances For
                @[simp]
                theorem Nat.ArithmeticFunction.ppow_apply {R : Type u_1} [Semiring R] {f : Nat.ArithmeticFunction R} {k : } {x : } (kpos : 0 < k) :
                ↑(Nat.ArithmeticFunction.ppow f k) x = f x ^ k

                This is the pointwise division of ArithmeticFunctions.

                Equations
                Instances For
                  @[simp]

                  This result only holds for DivisionSemirings instead of GroupWithZeros because zeta takes values in ℕ, and hence the coersion requires an AddMonoidWithOne. TODO: Generalise zeta

                  Multiplicative functions

                  Equations
                  Instances For
                    theorem Nat.ArithmeticFunction.IsMultiplicative.map_prod {R : Type u_1} {ι : Type u_2} [CommMonoidWithZero R] (g : ι) {f : Nat.ArithmeticFunction R} (hf : Nat.ArithmeticFunction.IsMultiplicative f) (s : Finset ι) (hs : Set.Pairwise (s) (Nat.Coprime on g)) :
                    f (Finset.prod s fun i => g i) = Finset.prod s fun i => f (g i)

                    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

                    theorem Nat.ArithmeticFunction.IsMultiplicative.iff_ne_zero {R : Type u_1} [MonoidWithZero R] {f : Nat.ArithmeticFunction R} :
                    Nat.ArithmeticFunction.IsMultiplicative f f 1 = 1 ∀ {m n : }, m 0n 0Nat.Coprime m nf (m * n) = f m * f 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

                    @[simp]
                    theorem Nat.ArithmeticFunction.pow_apply {k : } {n : } :
                    ↑(Nat.ArithmeticFunction.pow k) n = if k = 0 n = 0 then 0 else n ^ k

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

                    Equations
                    Instances For

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

                      Equations
                      Instances For

                        Ω n is the number of prime factors of n.

                        Equations
                        Instances For

                          Ω n is the number of prime factors of n.

                          Equations
                          Instances For

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

                            Equations
                            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
                              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
                                Instances For
                                  theorem Nat.ArithmeticFunction.moebius_apply_prime_pow {p : } {k : } (hp : Nat.Prime p) (hk : k 0) :
                                  Nat.ArithmeticFunction.moebius (p ^ k) = if k = 1 then -1 else 0

                                  A unit in ArithmeticFunction R that evaluates to ζ, with inverse μ.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    @[simp]
                                    theorem Nat.ArithmeticFunction.coe_zetaUnit {R : Type u_1} [CommRing R] :
                                    Nat.ArithmeticFunction.zetaUnit = Nat.ArithmeticFunction.zeta
                                    @[simp]
                                    theorem Nat.ArithmeticFunction.inv_zetaUnit {R : Type u_1} [CommRing R] :
                                    Nat.ArithmeticFunction.zetaUnit⁻¹ = Nat.ArithmeticFunction.moebius
                                    theorem Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq {R : Type u_1} [AddCommGroup R] {f : R} {g : R} :
                                    (∀ (n : ), n > 0(Finset.sum (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0(Finset.sum (Nat.divisorsAntidiagonal n) fun x => Nat.ArithmeticFunction.moebius x.fst g x.snd) = f n

                                    Möbius inversion for functions to an AddCommGroup.

                                    theorem Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq {R : Type u_1} [Ring R] {f : R} {g : R} :
                                    (∀ (n : ), n > 0(Finset.sum (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0(Finset.sum (Nat.divisorsAntidiagonal n) fun x => ↑(Nat.ArithmeticFunction.moebius x.fst) * g x.snd) = f n

                                    Möbius inversion for functions to a Ring.

                                    theorem Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq {R : Type u_1} [CommGroup R] {f : R} {g : R} :
                                    (∀ (n : ), n > 0(Finset.prod (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0(Finset.prod (Nat.divisorsAntidiagonal n) fun x => g x.snd ^ Nat.ArithmeticFunction.moebius x.fst) = f n

                                    Möbius inversion for functions to a CommGroup.

                                    theorem Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero {R : Type u_1} [CommGroupWithZero R] {f : R} {g : R} (hf : ∀ (n : ), 0 < nf n 0) (hg : ∀ (n : ), 0 < ng n 0) :
                                    (∀ (n : ), n > 0(Finset.prod (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0(Finset.prod (Nat.divisorsAntidiagonal n) fun x => g x.snd ^ Nat.ArithmeticFunction.moebius x.fst) = f n

                                    Möbius inversion for functions to a CommGroupWithZero.

                                    theorem Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq_on {R : Type u_1} [AddCommGroup R] {f : R} {g : R} (s : Set ) (hs : ∀ (m n : ), m nn sm s) :
                                    (∀ (n : ), n > 0n s(Finset.sum (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0n s(Finset.sum (Nat.divisorsAntidiagonal n) fun x => Nat.ArithmeticFunction.moebius x.fst g x.snd) = f n

                                    Möbius inversion for functions to an AddCommGroup, where the equalities only hold on a well-behaved set.

                                    theorem Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq_on' {R : Type u_1} [AddCommGroup R] {f : R} {g : R} (s : Set ) (hs : ∀ (m n : ), m nn sm s) (hs₀ : ¬0 s) :
                                    (∀ (n : ), n s(Finset.sum (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n s(Finset.sum (Nat.divisorsAntidiagonal n) fun x => Nat.ArithmeticFunction.moebius x.fst g x.snd) = f n
                                    theorem Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq_on {R : Type u_1} [Ring R] {f : R} {g : R} (s : Set ) (hs : ∀ (m n : ), m nn sm s) :
                                    (∀ (n : ), n > 0n s(Finset.sum (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0n s(Finset.sum (Nat.divisorsAntidiagonal n) fun x => ↑(Nat.ArithmeticFunction.moebius x.fst) * g x.snd) = f n

                                    Möbius inversion for functions to a Ring, where the equalities only hold on a well-behaved set.

                                    theorem Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_on {R : Type u_1} [CommGroup R] {f : R} {g : R} (s : Set ) (hs : ∀ (m n : ), m nn sm s) :
                                    (∀ (n : ), n > 0n s(Finset.prod (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0n s(Finset.prod (Nat.divisorsAntidiagonal n) fun x => g x.snd ^ Nat.ArithmeticFunction.moebius x.fst) = f n

                                    Möbius inversion for functions to a CommGroup, where the equalities only hold on a well-behaved set.

                                    theorem Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero {R : Type u_1} [CommGroupWithZero R] (s : Set ) (hs : ∀ (m n : ), m nn sm s) {f : R} {g : R} (hf : ∀ (n : ), n > 0f n 0) (hg : ∀ (n : ), n > 0g n 0) :
                                    (∀ (n : ), n > 0n s(Finset.prod (Nat.divisors n) fun i => f i) = g n) ∀ (n : ), n > 0n s(Finset.prod (Nat.divisorsAntidiagonal n) fun x => g x.snd ^ Nat.ArithmeticFunction.moebius x.fst) = f n

                                    Möbius inversion for functions to a CommGroupWithZero, where the equalities only hold on a well-behaved set.