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.Defs

84 declarations and 4 deprecated aliases. Mathlib docs · Source

def ArithmeticFunction E3 #

(R : Type u_1) → [Zero R] → Type (max 0 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.

instance ArithmeticFunction.zero E0 #

(R : Type u_1) → [inst : Zero R] → Zero (ArithmeticFunction R)

instance instInhabitedArithmeticFunction E0 #

(R : Type u_1) → [inst : Zero R] → Inhabited (ArithmeticFunction R)

instance ArithmeticFunction.instFunLikeNat E0 #

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

theorem ArithmeticFunction.toFun_eq E0 #

∀ {R : Type u_1} [inst : Zero R] (f : ArithmeticFunction R), f.toFun = ⇑f

theorem ArithmeticFunction.coe_mk E0 #

∀ {R : Type u_1} [inst : Zero R] (f : ℕ → R) (hf : f 0 = 0), ⇑{ toFun := f, map_zero' := hf } = f

theorem ArithmeticFunction.map_zero E0 #

∀ {R : Type u_1} [inst : Zero R] {f : ArithmeticFunction R}, f 0 = 0

theorem ArithmeticFunction.coe_inj E0 #

∀ {R : Type u_1} [inst : Zero R] {f g : ArithmeticFunction R}, ⇑f = ⇑g ↔ f = g

theorem ArithmeticFunction.range_coe E0 #

∀ {R : Type u_1} [inst : Zero R], Set.range DFunLike.coe = {f | f 0 = 0}

instance ArithmeticFunction.instIsZeroApplyNat E0 #

∀ {R : Type u_1} [inst : Zero R], IsZeroApply (ArithmeticFunction R)

theorem ArithmeticFunction.ext E1 #

∀ {R : Type u_1} [inst : Zero R] ⦃f g : ArithmeticFunction R⦄, (∀ (x : ℕ), f x = g x) → f = g

theorem ArithmeticFunction.ext_iff E0 #

∀ {R : Type u_1} [inst : Zero R] {f g : ArithmeticFunction R}, f = g ↔ ∀ (x : ℕ), f x = g x

instance ArithmeticFunction.one E0 #

{R : Type u_1} → [inst : Zero R] → [One R] → One (ArithmeticFunction R)

theorem ArithmeticFunction.one_apply E0 #

∀ {R : Type u_1} [inst : Zero R] [inst_1 : One R] {x : ℕ}, 1 x = if x = 1 then 1 else 0

theorem ArithmeticFunction.one_one E0 #

∀ {R : Type u_1} [inst : Zero R] [inst_1 : One R], 1 1 = 1

theorem ArithmeticFunction.one_apply_ne E0 #

∀ {R : Type u_1} [inst : Zero R] [inst_1 : One R] {x : ℕ}, x ≠ 1 → 1 x = 0

def ArithmeticFunction.natToArithmeticFunction E1 #

{R : Type u_1} → [inst : AddMonoidWithOne R] → ArithmeticFunction ℕ → ArithmeticFunction R

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.

instance ArithmeticFunction.natCoe E0 #

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

theorem ArithmeticFunction.natCoe_nat E0 #

∀ (f : ArithmeticFunction ℕ), ↑f = f

theorem ArithmeticFunction.natCoe_apply E0 #

∀ {R : Type u_1} [inst : AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ}, ↑f x = ↑(f x)

def ArithmeticFunction.ofInt E1 #

{R : Type u_1} → [inst : AddGroupWithOne R] → ArithmeticFunction ℤ → ArithmeticFunction R

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.

instance ArithmeticFunction.intCoe E0 #

{R : Type u_1} → [inst : AddGroupWithOne R] → Coe (ArithmeticFunction ℤ) (ArithmeticFunction R)

theorem ArithmeticFunction.intCoe_int E0 #

∀ (f : ArithmeticFunction ℤ), ↑f = f

theorem ArithmeticFunction.intCoe_apply E0 #

∀ {R : Type u_1} [inst : AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ}, ↑f x = ↑(f x)

theorem ArithmeticFunction.coe_coe E0 #

∀ {R : Type u_1} [inst : AddGroupWithOne R] {f : ArithmeticFunction ℕ}, ↑↑f = ↑f

theorem ArithmeticFunction.natCoe_one E0 #

∀ {R : Type u_1} [inst : AddMonoidWithOne R], ↑1 = 1

theorem ArithmeticFunction.intCoe_one E0 #

∀ {R : Type u_1} [inst : AddGroupWithOne R], ↑1 = 1

instance ArithmeticFunction.instSMul E0 #

{R : Type u_1} → {S : Type u_2} → [inst : Zero R] → [SMulZeroClass S R] → SMul S (ArithmeticFunction R)

instance ArithmeticFunction.instIsSMulApplyNat E0 #

∀ {R : Type u_1} {S : Type u_2} [inst : Zero R] [inst_1 : SMulZeroClass S R], IsSMulApply S (ArithmeticFunction R)

instance ArithmeticFunction.add E0 #

{R : Type u_1} → [inst : AddMonoid R] → Add (ArithmeticFunction R)

instance ArithmeticFunction.instIsAddApplyNat E0 #

∀ {R : Type u_1} [inst : AddMonoid R], IsAddApply (ArithmeticFunction R)

instance ArithmeticFunction.instAddMonoid E0 #

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

instance ArithmeticFunction.instAddMonoidWithOne E0 #

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

instance ArithmeticFunction.instAddCommMonoid E0 #

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

instance ArithmeticFunction.instNeg E0 #

{R : Type u_1} → [inst : NegZeroClass R] → Neg (ArithmeticFunction R)

instance ArithmeticFunction.instIsNegApplyNat E0 #

∀ {R : Type u_1} [inst : NegZeroClass R], IsNegApply (ArithmeticFunction R)

instance ArithmeticFunction.instSub E0 #

{R : Type u_1} → [inst : SubNegZeroMonoid R] → Sub (ArithmeticFunction R)

instance ArithmeticFunction.instIsSubApplyNat E0 #

∀ {R : Type u_1} [inst : SubNegZeroMonoid R], IsSubApply (ArithmeticFunction R)

instance ArithmeticFunction.instAddGroup E0 #

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

instance ArithmeticFunction.instAddCommGroup E0 #

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

instance ArithmeticFunction.instSMul_1 E0 #

{R : Type u_1} →
  {M : Type u_2} →
    [inst : Zero R] → [inst_1 : AddCommMonoid M] → [SMul R M] → SMul (ArithmeticFunction R) (ArithmeticFunction M)

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.

theorem ArithmeticFunction.smul_apply E0 #

∀ {R : Type u_1} {M : Type u_2} [inst : Zero R] [inst_1 : AddCommMonoid M] [inst_2 : SMul R M]
  {f : ArithmeticFunction R} {g : ArithmeticFunction M} {n : ℕ}, (f • g) n = ∑ x ∈ n.divisorsAntidiagonal, f x.1 • g x.2

instance ArithmeticFunction.instMul E0 #

{R : Type u_1} → [inst : Semiring R] → Mul (ArithmeticFunction R)

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.

theorem ArithmeticFunction.mul_apply E0 #

∀ {R : Type u_1} [inst : Semiring R] {f g : ArithmeticFunction R} {n : ℕ},
  (f * g) n = ∑ x ∈ n.divisorsAntidiagonal, f x.1 * g x.2

theorem ArithmeticFunction.mul_apply_one E1 #

∀ {R : Type u_1} [inst : Semiring R] {f g : ArithmeticFunction R}, (f * g) 1 = f 1 * g 1

theorem ArithmeticFunction.natCoe_mul E0 #

∀ {R : Type u_1} [inst : Semiring R] {f g : ArithmeticFunction ℕ}, ↑(f * g) = ↑f * ↑g

theorem ArithmeticFunction.intCoe_mul E0 #

∀ {R : Type u_1} [inst : Ring R] {f g : ArithmeticFunction ℤ}, ↑(f * g) = ↑f * ↑g

theorem ArithmeticFunction.mul_smul' E1 #

∀ {R : Type u_1} {M : Type u_2} [inst : Semiring R] [inst_1 : AddCommMonoid M] [inst_2 : Module R M]
  (f g : ArithmeticFunction R) (h : ArithmeticFunction M), (f * g) • h = f • g • h

theorem ArithmeticFunction.one_smul' E1 #

∀ {R : Type u_1} {M : Type u_2} [inst : Semiring R] [inst_1 : AddCommMonoid M] [inst_2 : Module R M]
  (b : ArithmeticFunction M), 1 • b = b

instance ArithmeticFunction.instMonoid E0 #

{R : Type u_1} → [inst : Semiring R] → Monoid (ArithmeticFunction R)

instance ArithmeticFunction.instSemiring E0 #

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

instance ArithmeticFunction.instCommSemiring E0 #

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

instance ArithmeticFunction.instCommRing E0 #

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

instance ArithmeticFunction.instModule E0 #

{R : Type u_1} →
  {S : Type u_2} → [inst : Semiring R] → [inst_1 : AddCommMonoid S] → [Module R S] → Module R (ArithmeticFunction S)

instance ArithmeticFunction.instAlgebra E0 #

{R : Type u_1} →
  {S : Type u_2} → [inst : CommSemiring R] → [inst_1 : Semiring S] → [Algebra R S] → Algebra R (ArithmeticFunction S)

theorem ArithmeticFunction.algebraMap_apply_one E0 #

∀ {R : Type u_1} {S : Type u_2} [inst : CommSemiring R] [inst_1 : Semiring S] [inst_2 : Algebra R S] (x : R),
  ((algebraMap R (ArithmeticFunction S)) x) 1 = (algebraMap R S) x

instance ArithmeticFunction.instModule_1 E0 #

{R : Type u_1} →
  {M : Type u_2} →
    [inst : Semiring R] →
      [inst_1 : AddCommMonoid M] → [Module R M] → Module (ArithmeticFunction R) (ArithmeticFunction M)

def ArithmeticFunction.dirichletInverseFun E1 #

{R : Type u_1} → [inst : Ring R] → (f : ℕ → R) → Invertible (f 1) → ℕ → R

Given an inverse of f 1, construct the Dirichlet inverse of f. We use Invertible to make this definition computable when f is computable.

theorem ArithmeticFunction.dirichletInverseFun_apply_zero E0 #

∀ {R : Type u_1} [inst : Ring R] (f : ℕ → R) (hf : Invertible (f 1)), ArithmeticFunction.dirichletInverseFun f hf 0 = 0

theorem ArithmeticFunction.dirichletInverseFun_apply_one E0 #

∀ {R : Type u_1} [inst : Ring R] (f : ℕ → R) (hf : Invertible (f 1)),
  ArithmeticFunction.dirichletInverseFun f hf 1 = ⅟(f 1)

theorem ArithmeticFunction.dirichletInverseFun_apply_ne E0 #

∀ {R : Type u_1} [inst : Ring R] (f : ℕ → R) (hf : Invertible (f 1)) {n : ℕ},
  n ≠ 0 →
    n ≠ 1 →
      ArithmeticFunction.dirichletInverseFun f hf n =
        -⅟(f 1) * ∑ d ∈ n.properDivisors, f (n / d) * ArithmeticFunction.dirichletInverseFun f hf d

def ArithmeticFunction.dirichletInverse E1 #

{R : Type u_1} → [inst : Ring R] → (f : ℕ → R) → Invertible (f 1) → ArithmeticFunction R

Given an inverse of f 1, construct the Dirichlet inverse of f.

theorem ArithmeticFunction.self_mul_dirichletInverse E1 #

∀ {R : Type u_1} [inst : Ring R] (f : ArithmeticFunction R) (hf : Invertible (f 1)),
  f * ArithmeticFunction.dirichletInverse (⇑f) hf = 1

theorem ArithmeticFunction.dirichletInverse_mul_self E1 #

∀ {R : Type u_1} [inst : CommRing R] (f : ArithmeticFunction R) (hf : Invertible (f 1)),
  ArithmeticFunction.dirichletInverse (⇑f) hf * f = 1

theorem ArithmeticFunction.isUnit_iff_isUnit_apply_one E1 #

∀ {R : Type u_1} [inst : CommRing R] {f : ArithmeticFunction R}, IsUnit f ↔ IsUnit (f 1)

def ArithmeticFunction.IsMultiplicative E1 #

{R : Type u_1} → [inst : MonoidWithZero R] → ArithmeticFunction R → Prop

Multiplicative functions

theorem ArithmeticFunction.IsMultiplicative.map_one E0 #

∀ {R : Type u_1} [inst : MonoidWithZero R] {f : ArithmeticFunction R}, f.IsMultiplicative → f 1 = 1

theorem ArithmeticFunction.IsMultiplicative.map_mul_of_coprime E0 #

∀ {R : Type u_1} [inst : MonoidWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {m n : ℕ}, m.gcd n = 1 → f (m * n) = f m * f n

theorem ArithmeticFunction.IsMultiplicative.map_prod E0 #

∀ {R : Type u_1} {ι : Type u_2} [inst : CommMonoidWithZero R] (g : ι → ℕ) {f : ArithmeticFunction R},
  f.IsMultiplicative →
    ∀ (s : Finset ι), (↑s).Pairwise (Function.onFun Nat.Coprime g) → f (∏ i ∈ s, g i) = ∏ i ∈ s, f (g i)

theorem ArithmeticFunction.IsMultiplicative.map_prod_of_prime E0 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ (t : Finset ℕ), (∀ p ∈ t, Nat.Prime p) → f (∏ a ∈ t, a) = ∏ a ∈ t, f a

theorem ArithmeticFunction.IsMultiplicative.map_prod_of_subset_primeFactors E0 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ (l : ℕ), ∀ t ⊆ l.primeFactors, f (∏ a ∈ t, a) = ∏ a ∈ t, f a

theorem ArithmeticFunction.IsMultiplicative.prod_primeFactors E1 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {l : ℕ}, Squarefree l → ∏ a ∈ l.primeFactors, f a = f l

theorem ArithmeticFunction.IsMultiplicative.map_div_of_coprime E0 #

∀ {R : Type u_1} [inst : GroupWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {l d : ℕ}, d ∣ l → (l / d).Coprime d → f d ≠ 0 → f (l / d) = f l / f d

theorem ArithmeticFunction.IsMultiplicative.natCast E1 #

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

theorem ArithmeticFunction.IsMultiplicative.intCast E1 #

∀ {R : Type u_1} {f : ArithmeticFunction ℤ} [inst : Ring R], f.IsMultiplicative → (↑f).IsMultiplicative

theorem ArithmeticFunction.IsMultiplicative.mul E1 #

∀ {R : Type u_1} [inst : CommSemiring R] {f g : ArithmeticFunction R},
  f.IsMultiplicative → g.IsMultiplicative → (f * g).IsMultiplicative

theorem ArithmeticFunction.IsMultiplicative.multiplicative_factorization E1 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] (f : ArithmeticFunction R),
  f.IsMultiplicative → ∀ {n : ℕ}, n ≠ 0 → f n = n.factorization.prod fun p k ↦ f (p ^ k)

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 ArithmeticFunction.IsMultiplicative.iff_ne_zero E1 #

∀ {R : Type u_1} [inst : MonoidWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative ↔ f 1 = 1 ∧ ∀ {m n : ℕ}, m ≠ 0 → n ≠ 0 → m.Coprime n → f (m * n) = f m * f n

A recapitulation of the definition of multiplicative that is simpler for proofs

theorem ArithmeticFunction.IsMultiplicative.lcm_apply_mul_gcd_apply E0 #

∀ {R : Type u_1} [inst : CommMonoidWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {x y : ℕ}, f (x.lcm y) * f (x.gcd y) = f x * f y

theorem ArithmeticFunction.IsMultiplicative.map_gcd E0 #

∀ {R : Type u_1} [inst : CommGroupWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {x y : ℕ}, f (x.lcm y) ≠ 0 → f (x.gcd y) = f x * f y / f (x.lcm y)

theorem ArithmeticFunction.IsMultiplicative.map_lcm E0 #

∀ {R : Type u_1} [inst : CommGroupWithZero R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {x y : ℕ}, f (x.gcd y) ≠ 0 → f (x.lcm y) = f x * f y / f (x.gcd y)

theorem ArithmeticFunction.isMultiplicative_one E0 #

∀ {R : Type u_1} [inst : MonoidWithZero R], ArithmeticFunction.IsMultiplicative 1

theorem ArithmeticFunction.isMultiplicative_finsetProd E1 #

∀ {R : Type u_1} [inst : CommSemiring R] {ι : Type u_2} (f : ι → ArithmeticFunction R) (s : Finset ι),
  (∀ i ∈ s, (f i).IsMultiplicative) → (∏ i ∈ s, f i).IsMultiplicative

theorem ArithmeticFunction.IsMultiplicative.pow E1 #

∀ {R : Type u_1} [inst : CommSemiring R] {f : ArithmeticFunction R},
  f.IsMultiplicative → ∀ {k : ℕ}, (f ^ k).IsMultiplicative

Deprecated aliases

NameNew nameSince
ArithmeticFunction.add_applyadd_apply2026-10-27
ArithmeticFunction.neg_applyneg_apply2026-10-27
ArithmeticFunction.smul_mapsmul_apply2026-10-29
ArithmeticFunction.zero_applyzero_apply2026-10-27