Quelle Defs.lean
Sprache: Lean
|
|
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
module
public import Mathlib.Algebra.Algebra.Defs
public import Mathlib.Algebra.Module.FunLike
public import Mathlib.Data.Nat.Factorization.Induction
public import Mathlib.Data.Nat.GCD.BigOperators
public import Mathlib.Data.Nat.Squarefree
public import Mathlib.Tactic.ArithMult
import Mathlib.Algebra.Module.BigOperators
/-!
# 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 functions `f : ℕ → R` such that `f 0 = 0`.
* An arithmetic function `f` `IsMultiplicative` when `x.Coprime y → f (x * y) = f x * f y`.
* Multiplication and power instances on `ArithmeticFunction R`, are defined using Dirichlet
convolution.
Further examples of arithmetic functions, such as the Möbius function `μ`, are available in
other files in the `Mathlib.NumberTheory.ArithmeticFunction` directory.
## Tags
arithmetic functions, dirichlet convolution, divisors
-/
@[expose] public section
open Finset
open Nat
variable (R : Type*)
/-- 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. -/
def ArithmeticFunction [Zero R] :=
ZeroHom ℕ R
instance ArithmeticFunction.zero [Zero R] : Zero (ArithmeticFunction R) :=
inferInstanceAs (Zero (ZeroHom ℕ R))
instance [Zero R] : Inhabited (ArithmeticFunction R) := inferInstanceAs (Inhabited (ZeroHom ℕ R))
variable {R}
namespace ArithmeticFunction
section Zero
variable [Zero R]
@[macro_inline]
instance : FunLike (ArithmeticFunction R) ℕ R :=
inferInstanceAs (FunLike (ZeroHom ℕ R) ℕ R)
@[simp]
theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f := rfl
@[simp]
theorem coe_mk (f : ℕ → R) (hf) : @DFunLike.coe (ArithmeticFunction R) _ _ _
(ZeroHom.mk f hf) = f := rfl
@[simp]
theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
ZeroHom.map_zero' f
theorem coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g :=
DFunLike.coe_fn_eq
theorem range_coe : Set.range ((↑) : ArithmeticFunction R → (ℕ → R)) = {f | f 0 = 0} := by
ext f
exact ⟨by rintro ⟨f, rfl⟩; simp, fun hf ↦ ⟨⟨f, hf⟩, rfl⟩⟩
instance : IsZeroApply (ArithmeticFunction R) where
@[deprecated zero_apply +typeChanged (since := "2026-10-27")]
protected theorem zero_apply {x : ℕ} : (0 : ArithmeticFunction R) x = 0 :=
rfl
@[ext]
theorem ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g :=
ZeroHom.ext h
section One
variable [One R]
instance one : One (ArithmeticFunction R) :=
⟨⟨fun x => ite (x = 1) 1 0, rfl⟩⟩
protected theorem one_apply {x : ℕ} : (1 : ArithmeticFunction R) x = ite (x = 1) 1 0 :=
rfl
@[simp]
theorem one_one : (1 : ArithmeticFunction R) 1 = 1 :=
rfl
@[simp]
theorem one_apply_ne {x : ℕ} (h : x ≠ 1) : (1 : ArithmeticFunction R) x = 0 :=
ite_eq_right h
end One
end Zero
/-- 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. -/
@[coe]
def natToArithmeticFunction [AddMonoidWithOne R] :
(ArithmeticFunction ℕ) → (ArithmeticFunction R) :=
fun f => ⟨fun n => ↑(f n), by simp⟩
instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
⟨natToArithmeticFunction⟩
@[simp]
theorem natCoe_nat (f : ArithmeticFunction ℕ) : natToArithmeticFunction f = f :=
ext fun _ => cast_id _
@[simp]
theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x :=
rfl
/-- 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. -/
@[coe]
def ofInt [AddGroupWithOne R] :
(ArithmeticFunction ℤ) → (ArithmeticFunction R) :=
fun f => ⟨fun n => ↑(f n), by simp⟩
instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
⟨ofInt⟩
@[simp]
theorem intCoe_int (f : ArithmeticFunction ℤ) : ofInt f = f :=
ext fun _ => Int.cast_id
@[simp]
theorem intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x := rfl
@[simp]
theorem coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} :
((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = (f : ArithmeticFunction R) := by
ext
simp
@[simp]
theorem natCoe_one [AddMonoidWithOne R] :
((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 := by
ext n
simp [ArithmeticFunction.one_apply]
@[simp]
theorem intCoe_one [AddGroupWithOne R] : ((1 : ArithmeticFunction ℤ) :
ArithmeticFunction R) = 1 := by
ext n
simp [ArithmeticFunction.one_apply]
section SMul
variable {S : Type*} [Zero R] [SMulZeroClass S R]
instance : SMul S (ArithmeticFunction R) where
smul n f := ⟨n • f, by simp⟩
instance : IsSMulApply S (ArithmeticFunction R) where
end SMul
section AddMonoid
variable [AddMonoid R]
instance add : Add (ArithmeticFunction R) where
add f g := ⟨f + g, by simp⟩
instance : IsAddApply (ArithmeticFunction R) where
@[deprecated add_apply +typeChanged (since := "2026-10-27")]
protected theorem add_apply {f g : ArithmeticFunction R} {n : ℕ} : (f + g) n = f n + g n :=
rfl
instance instAddMonoid : AddMonoid (ArithmeticFunction R) := fast_instance% FunLike.addMonoid
end AddMonoid
set_option backward.isDefEq.respectTransparency false in
instance instAddMonoidWithOne [AddMonoidWithOne R] : AddMonoidWithOne (ArithmeticFunction R) where
natCast n := ⟨fun x ↦ if x = 1 then (n : R) else 0, by simp⟩
natCast_zero := by ext; simp
natCast_succ n := by ext x; by_cases h : x = 1 <;> simp [h]
instance instAddCommMonoid [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) :=
fast_instance% FunLike.addCommMonoid
instance [NegZeroClass R] : Neg (ArithmeticFunction R) where
neg f := ⟨-f, by simp⟩
instance [NegZeroClass R] : IsNegApply (ArithmeticFunction R) where
@[deprecated neg_apply +typeChanged (since := "2026-10-27")]
protected theorem neg_apply [NegZeroClass R] {f : ArithmeticFunction R} {n : ℕ} :
(-f) n = -f n := rfl
instance [SubNegZeroMonoid R] : Sub (ArithmeticFunction R) where
sub f g := ⟨f - g, by simp⟩
instance [SubNegZeroMonoid R] : IsSubApply (ArithmeticFunction R) where
instance [AddGroup R] : AddGroup (ArithmeticFunction R) := fast_instance% FunLike.addGroup
instance [AddCommGroup R] : AddCommGroup (ArithmeticFunction R) :=
fast_instance% FunLike.addCommGroup
section SMul
variable {M : Type*} [Zero R] [AddCommMonoid M] [SMul R 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`. -/
instance : SMul (ArithmeticFunction R) (ArithmeticFunction M) where
smul f g := ⟨fun n ↦ ∑ x ∈ divisorsAntidiagonal n, f x.fst • g x.snd, by simp⟩
@[simp]
protected theorem smul_apply {f : ArithmeticFunction R} {g : ArithmeticFunction M} {n : ℕ} :
(f • g) n = ∑ x ∈ divisorsAntidiagonal n, f x.fst • g x.snd :=
rfl
end SMul
/-- 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`. -/
instance [Semiring R] : Mul (ArithmeticFunction R) where
mul f g := f • g
@[simp]
protected theorem mul_apply [Semiring R] {f g : ArithmeticFunction R} {n : ℕ} :
(f * g) n = ∑ x ∈ divisorsAntidiagonal n, f x.fst * g x.snd :=
rfl
theorem mul_apply_one [Semiring R] {f g : ArithmeticFunction R} : (f * g) 1 = f 1 * g 1 := by simp
@[simp, norm_cast]
theorem natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} :
(↑(f * g) : ArithmeticFunction R) = f * g := by
ext n
simp
@[simp, norm_cast]
theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
(↑(f * g) : ArithmeticFunction R) = ↑f * g := by
ext n
simp
section Module
variable {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M]
theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
(f * g) • h = f • g • h := by
ext n
simp only [ArithmeticFunction.smul_apply, ArithmeticFunction.mul_apply, sum_smul, mul_smul,
sum_sigma', smul_sum]
apply sum_nbij' (fun ⟨⟨_i, j⟩, ⟨k, l⟩⟩ ↦ ⟨(k, l * j), (l, j)⟩)
(fun ⟨⟨i, _j⟩, ⟨k, l⟩⟩ ↦ ⟨(i * k, l), (i, k)⟩) <;> aesop (add simp mul_assoc)
set_option backward.isDefEq.respectTransparency.types false in
theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b = b := by
ext x
simp_all [← map_div_right_divisors, sum_eq_single 1]
end Module
section Semiring
variable [Semiring R]
set_option backward.isDefEq.respectTransparency.types false in
instance instMonoid : Monoid (ArithmeticFunction R) where
one_mul := one_smul'
mul_one f := by
ext x
simp_all [← map_div_left_divisors, sum_eq_single 1]
mul_assoc := mul_smul'
instance instSemiring : Semiring (ArithmeticFunction R) where
zero_mul f := by ext; simp
mul_zero f := by ext; simp
left_distrib a b c := by ext; simp [← sum_add_distrib, mul_add]
right_distrib a b c := by ext; simp [← sum_add_distrib, add_mul]
end Semiring
instance [CommSemiring R] : CommSemiring (ArithmeticFunction R) where
mul_comm f g := by
ext
rw [ArithmeticFunction.mul_apply, ← map_swap_divisorsAntidiagonal, sum_map]
simp [mul_comm]
instance [CommRing R] : CommRing (ArithmeticFunction R) where
neg_add_cancel := neg_add_cancel
mul_comm := mul_comm
instance {S : Type*} [Semiring R] [AddCommMonoid S] [Module R S] :
Module R (ArithmeticFunction S) := fast_instance% FunLike.module
-- note that `smul_apply` would be a more suitable name, but is already in use for the action of
-- `ArithmeticFunction R` on `ArithmeticFunction S`
@[deprecated smul_apply +typeChanged (since := "2026-10-29")]
theorem smul_map {S : Type*} [Semiring R] [AddCommMonoid S] [Module R S]
(x : R) (f : ArithmeticFunction S) (n : ℕ) : (x • f) n = x • f n := by
rfl
-- We can deduce the `Algebra` structure from the `Module` structure here due to the lack of
-- a more natural definition of `algebraMap`.
instance {S : Type*} [CommSemiring R] [Semiring S] [Algebra R S] :
Algebra R (ArithmeticFunction S) :=
.ofModule (fun x f g ↦ ext fun n ↦ by simp [Finset.smul_sum])
fun x f g ↦ ext fun n ↦ by simp [Finset.smul_sum]
@[simp]
theorem algebraMap_apply_one {S : Type*} [CommSemiring R] [Semiring S] [Algebra R S] (x : R) :
algebraMap R (ArithmeticFunction S) x 1 = algebraMap R S x := by
simp [Algebra.algebraMap_eq_smul_one]
instance {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] :
Module (ArithmeticFunction R) (ArithmeticFunction M) where
one_smul := one_smul'
mul_smul := mul_smul'
smul_add r x y := by
ext
simp only [ArithmeticFunction.smul_apply, add_apply, smul_add, sum_add_distrib]
smul_zero r := by
ext
simp only [ArithmeticFunction.smul_apply, zero_apply, smul_zero, sum_const_zero]
add_smul r s x := by
ext
simp only [ArithmeticFunction.smul_apply, add_apply, add_smul, sum_add_distrib]
zero_smul r := by
ext
simp only [ArithmeticFunction.smul_apply, zero_apply, zero_smul, sum_const_zero]
section DirichletInverse
section Ring
/- We use `(hf : Invertible (f 1))` instead of `[hf : Invertible (f 1)]` because in practice such
an instance is unlikely to be automatically synthesized due to the presence of `f`. -/
variable [Ring R] (f : ℕ → R) (hf : Invertible (f 1))
/-- Given an inverse of `f 1`, construct the Dirichlet inverse of `f`. We use `Invertible` to make
this definition computable when `f` is computable. -/
def dirichletInverseFun (n : ℕ) : R :=
if n = 0 then 0
else if n = 1 then ⅟(f 1)
else - ⅟(f 1) * ∑ d : n.properDivisors,
have : d < n := (Nat.mem_properDivisors.mp d.2).2
f (n / d) * dirichletInverseFun d
@[simp]
theorem dirichletInverseFun_apply_zero : dirichletInverseFun f hf 0 = 0 := by
rw [dirichletInverseFun, ite_eq_left rfl]
@[simp]
theorem dirichletInverseFun_apply_one : dirichletInverseFun f hf 1 = ⅟(f 1) := by
rw [dirichletInverseFun, ite_eq_right one_ne_zero, ite_eq_left rfl]
@[simp]
theorem dirichletInverseFun_apply_ne {n : ℕ} (hn0 : n ≠ 0) (hn1 : n ≠ 1) :
dirichletInverseFun f hf n =
- ⅟(f 1) * ∑ d ∈ n.properDivisors, f (n / d) * dirichletInverseFun f hf d := by
rw [dirichletInverseFun, ite_eq_right hn0, ite_eq_right hn1]
conv_rhs => rw [← Finset.sum_attach, Finset.attach_eq_univ]
/-- Given an inverse of `f 1`, construct the Dirichlet inverse of `f`. -/
@[simp]
def dirichletInverse : ArithmeticFunction R :=
⟨dirichletInverseFun f hf, dirichletInverseFun_apply_zero f hf⟩
set_option backward.isDefEq.respectTransparency false in
theorem self_mul_dirichletInverse (f : ArithmeticFunction R) (hf : Invertible (f 1)) :
f * dirichletInverse f hf = 1 := by
ext n
by_cases hn0 : n = 0
· simp [hn0]
by_cases hn1 : n = 1
· simp [hn1]
rw [dirichletInverse, ArithmeticFunction.mul_apply, coe_mk,
Nat.sum_divisorsAntidiagonal' fun x y ↦ f x * dirichletInverseFun f hf y,
← Nat.cons_self_properDivisors hn0]
simp [hn0, hn1, pos_of_ne_zero]
end Ring
section CommRing
variable [CommRing R] (f : ArithmeticFunction R)
theorem dirichletInverse_mul_self (hf : Invertible (f 1)) : dirichletInverse f hf * f = 1 := by
rw [mul_comm, self_mul_dirichletInverse]
variable {f} in
theorem isUnit_iff_isUnit_apply_one : IsUnit f ↔ IsUnit (f 1) := by
constructor
· rintro ⟨f, rfl⟩
refine ⟨⟨f.val 1, f⁻¹.val 1, ?_, ?_⟩, rfl⟩
· rw [← ArithmeticFunction.mul_apply_one, Units.mul_inv, one_one]
· rw [← ArithmeticFunction.mul_apply_one, Units.inv_mul, one_one]
· suffices Invertible (f 1) → Invertible f by simpa using Nonempty.map this
exact fun hf ↦ ⟨_, dirichletInverse_mul_self f hf, self_mul_dirichletInverse f hf⟩
end CommRing
end DirichletInverse
/-- Multiplicative functions -/
def IsMultiplicative [MonoidWithZero R] (f : ArithmeticFunction R) : Prop :=
f 1 = 1 ∧ ∀ {m n : ℕ}, m.Coprime n → f (m * n) = f m * f n
namespace IsMultiplicative
section MonoidWithZero
variable [MonoidWithZero R]
@[simp, arith_mult]
theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
h.1
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
(h : m.gcd n = 1) : f (m * n) = f m * f n :=
hf.2 h
end MonoidWithZero
open scoped Function in -- required for scoped `on` notation
theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : ArithmeticFunction R}
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
f (∏ i ∈ s, g i) = ∏ i ∈ s, f (g i) := by
classical
induction s using Finset.induction_on with
| empty => simp [hf]
| insert _ _ has ih =>
rw [coe_insert, Set.pairwise_insert_of_symm] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Coprime.prod_right fun i hi => hs.2 _ hi (hi.ne_of_notMem has).symm
theorem map_prod_of_prime [CommMonoidWithZero R] {f : ArithmeticFunction R}
(h_mult : ArithmeticFunction.IsMultiplicative f)
(t : Finset ℕ) (ht : ∀ p ∈ t, p.Prime) :
f (∏ a ∈ t, a) = ∏ a ∈ t, f a :=
map_prod _ h_mult t fun x hx y hy hxy => (coprime_primes (ht x hx) (ht y hy)).mpr hxy
theorem map_prod_of_subset_primeFactors [CommMonoidWithZero R] {f : ArithmeticFunction R}
(h_mult : ArithmeticFunction.IsMultiplicative f) (l : ℕ)
(t : Finset ℕ) (ht : t ⊆ l.primeFactors) :
f (∏ a ∈ t, a) = ∏ a ∈ t, f a :=
map_prod_of_prime h_mult t fun _ a => prime_of_mem_primeFactors (ht a)
theorem prod_primeFactors [CommMonoidWithZero R] {f : ArithmeticFunction R}
(h_mult : f.IsMultiplicative) {l : ℕ} (hl : Squarefree l) :
∏ a ∈ l.primeFactors, f a = f l := by
rw [← h_mult.map_prod_of_subset_primeFactors l _ Subset.rfl,
prod_primeFactors_of_squarefree hl]
theorem map_div_of_coprime [GroupWithZero R] {f : ArithmeticFunction R}
(hf : IsMultiplicative f) {l d : ℕ} (hdl : d ∣ l) (hl : (l / d).Coprime d) (hd : f d ≠ 0) :
f (l / d) = f l / f d := by
apply (div_eq_of_eq_mul hd ..).symm
rw [← hf.right hl, Nat.div_mul_cancel hdl]
@[arith_mult]
theorem natCast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun cop => by simp [h.2 cop]⟩
@[arith_mult]
theorem intCast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun cop => by simp [h.2 cop]⟩
@[arith_mult]
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f * g) := by
refine ⟨by simp [hf.1, hg.1], ?_⟩
simp only [ArithmeticFunction.mul_apply]
intro m n cop
rw [sum_mul_sum, ← sum_product']
symm
apply sum_nbij fun ((i, j), k, l) ↦ (i * k, j * l)
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
simp only [mem_divisorsAntidiagonal, Ne, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
simp only [mem_divisorsAntidiagonal, mul_eq_zero, Ne]
constructor
· ring
rw [mul_eq_zero] at *
exact not_or_intro ha hb
· simp only [Set.InjOn, mem_coe, mem_divisorsAntidiagonal, mem_product, Prod.mk_inj]
rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩ ⟨⟨c1, c2⟩, ⟨d1, d2⟩⟩ hcd h
ext
· trans gcd (a1 * a2) (a1 * b1)
· rw [gcd_mul_left, cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one, mul_one]
· rw [← hcd.1.1, ← hcd.2.1] at cop
rw [← hcd.1.1, h.1, gcd_mul_left, cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one,
mul_one]
· trans gcd (a1 * a2) (a2 * b2)
· rw [mul_comm, gcd_mul_left, cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one,
mul_one]
· rw [← hcd.1.1, ← hcd.2.1] at cop
rw [← hcd.1.1, h.2, mul_comm, gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one, mul_one]
· trans gcd (b1 * b2) (a1 * b1)
· rw [mul_comm, gcd_mul_right, cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one,
one_mul]
· rw [← hcd.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.1, mul_comm c1 d1, gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one, mul_one]
· trans gcd (b1 * b2) (a2 * b2)
· rw [gcd_mul_right, cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one, one_mul]
· rw [← hcd.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.2, gcd_mul_right,
cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one, one_mul]
· simp only [Set.SurjOn, Set.subset_def, mem_coe, mem_divisorsAntidiagonal, mem_product,
Set.mem_image]
rintro ⟨b1, b2⟩ h
use ((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
· rw [Ne, mul_eq_zero, not_or] at h
simp [h.2.1, h.2.2]
rw [mul_comm n m, h.1]
· simp only [mem_divisorsAntidiagonal, mem_product]
rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
rw [hf.map_mul_of_coprime cop.coprime_mul_right.coprime_mul_right_right,
hg.map_mul_of_coprime cop.coprime_mul_left.coprime_mul_left_right]
ring
/-- 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 multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunction R)
(hf : f.IsMultiplicative) {n : ℕ} (hn : n ≠ 0) :
f n = n.factorization.prod fun p k => f (p ^ k) :=
Nat.multiplicative_factorization f (fun _ _ => hf.2) hf.1 hn
/-- A recapitulation of the definition of multiplicative that is simpler for proofs -/
theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
IsMultiplicative f ↔
f 1 = 1 ∧ ∀ {m n : ℕ}, m ≠ 0 → n ≠ 0 → m.Coprime n → f (m * n) = f m * f n := by
refine and_congr_right' (forall₂_congr fun m n => ⟨fun h _ _ => h, fun h hmn => ?_⟩)
rcases eq_or_ne m 0 with (rfl | hm)
· simp
rcases eq_or_ne n 0 with (rfl | hn)
· simp
exact h hm hn hmn
/-- Two multiplicative functions `f` and `g` are equal if and only if
they agree on prime powers -/
theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction R)
(hf : f.IsMultiplicative) (g : ArithmeticFunction R) (hg : g.IsMultiplicative) :
f = g ↔ ∀ p i : ℕ, Nat.Prime p → f (p ^ i) = g (p ^ i) := by
constructor <;> intro h
· simp [h]
ext n
by_cases hn : n = 0
· rw [hn, ArithmeticFunction.map_zero, ArithmeticFunction.map_zero]
rw [multiplicative_factorization f hf hn, multiplicative_factorization g hg hn]
exact prod_congr rfl fun p hp ↦ h p _ (prime_of_mem_primeFactors hp)
theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R}
(hf : f.IsMultiplicative) {x y : ℕ} :
f (x.lcm y) * f (x.gcd y) = f x * f y := by
by_cases hx : x = 0
· simp only [hx, f.map_zero, zero_mul, lcm_zero_left, gcd_zero_left]
by_cases hy : y = 0
· simp only [hy, f.map_zero, mul_zero, lcm_zero_right, gcd_zero_right, zero_mul]
have hgcd_ne_zero : x.gcd y ≠ 0 := gcd_ne_zero_left hx
have hlcm_ne_zero : x.lcm y ≠ 0 := lcm_ne_zero hx hy
have hfi_zero : ∀ {i}, f (i ^ 0) = 1 := by
intro i; rw [pow_zero, hf.1]
iterate 4 rw [hf.multiplicative_factorization f (by assumption),
Finsupp.prod_of_support_subset _ _ _ (fun _ _ => hfi_zero)
(s := (x.primeFactors ∪ y.primeFactors))]
· rw [← prod_mul_distrib, ← prod_mul_distrib]
apply prod_congr rfl
intro p _
rcases Nat.le_or_le (x.factorization p) (y.factorization p) with h | h <;>
simp only [factorization_lcm hx hy, Finsupp.sup_apply, h, sup_of_le_right,
sup_of_le_left, inf_of_le_right, factorization_gcd hx hy, Finsupp.inf_apply,
inf_of_le_left, mul_comm]
· apply subset_union_right
· apply subset_union_left
· rw [factorization_gcd hx hy, Finsupp.support_inf]
apply inter_subset_union
· simp [factorization_lcm hx hy]
theorem map_gcd [CommGroupWithZero R] {f : ArithmeticFunction R}
(hf : f.IsMultiplicative) {x y : ℕ} (hf_lcm : f (x.lcm y) ≠ 0) :
f (x.gcd y) = f x * f y / f (x.lcm y) := by
rw [← hf.lcm_apply_mul_gcd_apply, mul_div_cancel_left₀ _ hf_lcm]
theorem map_lcm [CommGroupWithZero R] {f : ArithmeticFunction R}
(hf : f.IsMultiplicative) {x y : ℕ} (hf_gcd : f (x.gcd y) ≠ 0) :
f (x.lcm y) = f x * f y / f (x.gcd y) := by
rw [← hf.lcm_apply_mul_gcd_apply, mul_div_cancel_right₀ _ hf_gcd]
theorem eq_zero_of_squarefree_of_dvd_eq_zero [MonoidWithZero R] {f : ArithmeticFunction R}
(hf : IsMultiplicative f) {m n : ℕ} (hn : Squarefree n) (hmn : m ∣ n)
(h_zero : f m = 0) :
f n = 0 := by
rcases hmn with ⟨k, rfl⟩
simp only [zero_mul, hf.map_mul_of_coprime (coprime_of_squarefree_mul hn), h_zero]
end IsMultiplicative
@[simp, arith_mult]
theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : ArithmeticFunction R) :=
IsMultiplicative.iff_ne_zero.2 ⟨by simp, by
intro m n hm hn hmn
by_cases h : m = 1 <;> aesop⟩
@[arith_mult]
theorem isMultiplicative_finsetProd [CommSemiring R] {ι : Type*}
(f : ι → ArithmeticFunction R) (s : Finset ι) (hf : ∀ i ∈ s, IsMultiplicative (f i)) :
IsMultiplicative (∏ i ∈ s, f i) := by
induction s using Finset.cons_induction
case empty => simp
case cons a s ha ih =>
rw [Finset.prod_cons]
exact (hf a (by grind)).mul (by grind)
@[arith_mult]
theorem IsMultiplicative.pow [CommSemiring R] {f : ArithmeticFunction R}
(hf : f.IsMultiplicative) {k : ℕ} : IsMultiplicative (f ^ k) := by
induction k
case zero => simp
case succ k hk =>
rw [pow_succ]
exact hk.mul hf
end ArithmeticFunction
¤ Dauer der Verarbeitung: 0.4 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|