number_theory.arithmetic_function
⟷
Mathlib.NumberTheory.ArithmeticFunction
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -641,18 +641,18 @@ theorem ArithmeticFunction.IsMultiplicative.map_prod {ι : Type _} [CommMonoidWi
#align nat.arithmetic_function.is_multiplicative.map_prod ArithmeticFunction.IsMultiplicative.map_prod
-/
-#print ArithmeticFunction.IsMultiplicative.nat_cast /-
-theorem ArithmeticFunction.IsMultiplicative.nat_cast {f : ArithmeticFunction ℕ} [Semiring R]
+#print ArithmeticFunction.IsMultiplicative.natCast /-
+theorem ArithmeticFunction.IsMultiplicative.natCast {f : ArithmeticFunction ℕ} [Semiring R]
(h : f.IsMultiplicative) : ArithmeticFunction.IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun m n cop => by simp [cop, h]⟩
-#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.nat_cast
+#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.natCast
-/
-#print ArithmeticFunction.IsMultiplicative.int_cast /-
-theorem ArithmeticFunction.IsMultiplicative.int_cast {f : ArithmeticFunction ℤ} [Ring R]
+#print ArithmeticFunction.IsMultiplicative.intCast /-
+theorem ArithmeticFunction.IsMultiplicative.intCast {f : ArithmeticFunction ℤ} [Ring R]
(h : f.IsMultiplicative) : ArithmeticFunction.IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun m n cop => by simp [cop, h]⟩
-#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.int_cast
+#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.intCast
-/
#print ArithmeticFunction.IsMultiplicative.mul /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -7,8 +7,8 @@ import Algebra.BigOperators.Ring
import Algebra.Module.BigOperators
import NumberTheory.Divisors
import Data.Nat.Squarefree
-import Data.Nat.Gcd.BigOperators
-import Algebra.Invertible
+import Data.Nat.GCD.BigOperators
+import Algebra.Invertible.Defs
import Data.Nat.Factorization.Basic
#align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
@@ -577,22 +577,22 @@ theorem ArithmeticFunction.ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kp
#align nat.arithmetic_function.ppow_apply ArithmeticFunction.ppow_apply
-/
-#print ArithmeticFunction.ppow_succ /-
-theorem ArithmeticFunction.ppow_succ {f : ArithmeticFunction R} {k : ℕ} :
+#print ArithmeticFunction.ppow_succ' /-
+theorem ArithmeticFunction.ppow_succ' {f : ArithmeticFunction R} {k : ℕ} :
f.ppow (k + 1) = f.pmul (f.ppow k) := by
ext x
- rw [ppow_apply (Nat.succ_pos k), pow_succ]
+ rw [ppow_apply (Nat.succ_pos k), pow_succ']
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ ArithmeticFunction.ppow_succ
+#align nat.arithmetic_function.ppow_succ ArithmeticFunction.ppow_succ'
-/
-#print ArithmeticFunction.ppow_succ' /-
-theorem ArithmeticFunction.ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
+#print ArithmeticFunction.ppow_succ /-
+theorem ArithmeticFunction.ppow_succ {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
f.ppow (k + 1) = (f.ppow k).pmul f := by
ext x
- rw [ppow_apply (Nat.succ_pos k), pow_succ']
+ rw [ppow_apply (Nat.succ_pos k), pow_succ]
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ' ArithmeticFunction.ppow_succ'
+#align nat.arithmetic_function.ppow_succ' ArithmeticFunction.ppow_succ
-/
end Pmul
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -363,8 +363,8 @@ theorem ArithmeticFunction.one_smul' (b : ArithmeticFunction M) :
intro y ymem ynmem
have y1ne : y.fst ≠ 1 := by
intro con
- simp only [Con, mem_divisors_antidiagonal, one_mul, Ne.def] at ymem
- simp only [mem_singleton, Prod.ext_iff] at ynmem
+ simp only [Con, mem_divisors_antidiagonal, one_mul, Ne.def] at ymem
+ simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y1ne]
#align nat.arithmetic_function.one_smul' ArithmeticFunction.one_smul'
@@ -389,8 +389,8 @@ instance : Monoid (ArithmeticFunction R) :=
intro y ymem ynmem
have y2ne : y.snd ≠ 1 := by
intro con
- simp only [Con, mem_divisors_antidiagonal, mul_one, Ne.def] at ymem
- simp only [mem_singleton, Prod.ext_iff] at ynmem
+ simp only [Con, mem_divisors_antidiagonal, mul_one, Ne.def] at ymem
+ simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y2ne]
mul_assoc := ArithmeticFunction.mul_smul' }
@@ -635,7 +635,7 @@ theorem ArithmeticFunction.IsMultiplicative.map_prod {ι : Type _} [CommMonoidWi
classical
induction' s using Finset.induction_on with a s has ih hs
· simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.Coprime.prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod ArithmeticFunction.IsMultiplicative.map_prod
@@ -666,58 +666,58 @@ theorem ArithmeticFunction.IsMultiplicative.mul [CommSemiring R] {f g : Arithmet
symm
apply sum_bij fun (x : (ℕ × ℕ) × ℕ × ℕ) h => (x.1.1 * x.2.1, x.1.2 * x.2.2)
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
simp only [mem_divisors_antidiagonal, Nat.mul_eq_zero, Ne.def]
constructor; · ring
rw [Nat.mul_eq_zero] at *
apply not_or_of_not ha hb
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
dsimp only
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
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨c1, c2⟩, ⟨d1, d2⟩⟩ hab hcd h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hab
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hab
rcases hab with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hcd
- simp only [Prod.mk.inj_iff] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hcd
+ simp only [Prod.mk.inj_iff] at h
ext <;> dsimp only
· trans Nat.gcd (a1 * a2) (a1 * b1)
· rw [Nat.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, ← hcd.2.1] at cop
rw [← hcd.1.1, h.1, Nat.gcd_mul_left,
cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one, mul_one]
· trans Nat.gcd (a1 * a2) (a2 * b2)
·
rw [mul_comm, Nat.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, ← hcd.2.1] at cop
rw [← hcd.1.1, h.2, mul_comm, Nat.gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one, mul_one]
· trans Nat.gcd (b1 * b2) (a1 * b1)
·
rw [mul_comm, Nat.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.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.1, mul_comm c1 d1, Nat.gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one, mul_one]
· trans Nat.gcd (b1 * b2) (a2 * b2)
·
rw [Nat.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.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.2, Nat.gcd_mul_right,
cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one, one_mul]
· rintro ⟨b1, b2⟩ h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
use((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
simp only [exists_prop, Prod.mk.inj_iff, Ne.def, mem_product, mem_divisors_antidiagonal]
rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
- · rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h ; simp [h.2.1, h.2.2]
+ · rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h; simp [h.2.1, h.2.2]
rw [mul_comm n m, h.1]⟩
#align nat.arithmetic_function.is_multiplicative.mul ArithmeticFunction.IsMultiplicative.mul
-/
@@ -972,7 +972,7 @@ theorem ArithmeticFunction.cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.
revert h0
apply s.induction_on; · simp
intro a t h h0
- rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
+ rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
simp [h0, card_factors_mul, h]
#align nat.arithmetic_function.card_factors_multiset_prod ArithmeticFunction.cardFactors_multiset_prod
-/
@@ -1091,7 +1091,7 @@ theorem ArithmeticFunction.moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0
theorem ArithmeticFunction.moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 :=
by
constructor <;> intro h
- · rw [moebius_ne_zero_iff_squarefree] at h
+ · rw [moebius_ne_zero_iff_squarefree] at h
rw [moebius_apply_of_squarefree h]
apply neg_one_pow_eq_or
· rcases h with (h | h) <;> simp [h]
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -62,14 +62,14 @@ namespace Nat
variable (R : Type _)
-#print Nat.ArithmeticFunction /-
+#print ArithmeticFunction /-
/-- 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 `arithmetic_functions` is by
Dirichlet convolution. -/
def ArithmeticFunction [Zero R] :=
ZeroHom ℕ R
deriving Zero, Inhabited
-#align nat.arithmetic_function Nat.ArithmeticFunction
+#align nat.arithmetic_function ArithmeticFunction
-/
variable {R}
@@ -83,44 +83,44 @@ variable [Zero R]
instance : CoeFun (ArithmeticFunction R) fun _ => ℕ → R :=
ZeroHom.hasCoeToFun
-#print Nat.ArithmeticFunction.toFun_eq /-
+#print ArithmeticFunction.toFun_eq /-
@[simp]
-theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f :=
+theorem ArithmeticFunction.toFun_eq (f : ArithmeticFunction R) : f.toFun = f :=
rfl
-#align nat.arithmetic_function.to_fun_eq Nat.ArithmeticFunction.toFun_eq
+#align nat.arithmetic_function.to_fun_eq ArithmeticFunction.toFun_eq
-/
-#print Nat.ArithmeticFunction.map_zero /-
+#print ArithmeticFunction.map_zero /-
@[simp]
-theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
+theorem ArithmeticFunction.map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
ZeroHom.map_zero' f
-#align nat.arithmetic_function.map_zero Nat.ArithmeticFunction.map_zero
+#align nat.arithmetic_function.map_zero ArithmeticFunction.map_zero
-/
-#print Nat.ArithmeticFunction.coe_inj /-
-theorem coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g :=
+#print ArithmeticFunction.coe_inj /-
+theorem ArithmeticFunction.coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g :=
⟨fun h => ZeroHom.coe_inj h, fun h => h ▸ rfl⟩
-#align nat.arithmetic_function.coe_inj Nat.ArithmeticFunction.coe_inj
+#align nat.arithmetic_function.coe_inj ArithmeticFunction.coe_inj
-/
-#print Nat.ArithmeticFunction.zero_apply /-
+#print ArithmeticFunction.zero_apply /-
@[simp]
-theorem zero_apply {x : ℕ} : (0 : ArithmeticFunction R) x = 0 :=
+theorem ArithmeticFunction.zero_apply {x : ℕ} : (0 : ArithmeticFunction R) x = 0 :=
ZeroHom.zero_apply x
-#align nat.arithmetic_function.zero_apply Nat.ArithmeticFunction.zero_apply
+#align nat.arithmetic_function.zero_apply ArithmeticFunction.zero_apply
-/
-#print Nat.ArithmeticFunction.ext /-
+#print ArithmeticFunction.ext /-
@[ext]
-theorem ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g :=
+theorem ArithmeticFunction.ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g :=
ZeroHom.ext h
-#align nat.arithmetic_function.ext Nat.ArithmeticFunction.ext
+#align nat.arithmetic_function.ext ArithmeticFunction.ext
-/
-#print Nat.ArithmeticFunction.ext_iff /-
-theorem ext_iff {f g : ArithmeticFunction R} : f = g ↔ ∀ x, f x = g x :=
+#print ArithmeticFunction.ext_iff /-
+theorem ArithmeticFunction.ext_iff {f g : ArithmeticFunction R} : f = g ↔ ∀ x, f x = g x :=
ZeroHom.ext_iff
-#align nat.arithmetic_function.ext_iff Nat.ArithmeticFunction.ext_iff
+#align nat.arithmetic_function.ext_iff ArithmeticFunction.ext_iff
-/
section One
@@ -130,91 +130,95 @@ variable [One R]
instance : One (ArithmeticFunction R) :=
⟨⟨fun x => ite (x = 1) 1 0, rfl⟩⟩
-#print Nat.ArithmeticFunction.one_apply /-
-theorem one_apply {x : ℕ} : (1 : ArithmeticFunction R) x = ite (x = 1) 1 0 :=
+#print ArithmeticFunction.one_apply /-
+theorem ArithmeticFunction.one_apply {x : ℕ} : (1 : ArithmeticFunction R) x = ite (x = 1) 1 0 :=
rfl
-#align nat.arithmetic_function.one_apply Nat.ArithmeticFunction.one_apply
+#align nat.arithmetic_function.one_apply ArithmeticFunction.one_apply
-/
-#print Nat.ArithmeticFunction.one_one /-
+#print ArithmeticFunction.one_one /-
@[simp]
-theorem one_one : (1 : ArithmeticFunction R) 1 = 1 :=
+theorem ArithmeticFunction.one_one : (1 : ArithmeticFunction R) 1 = 1 :=
rfl
-#align nat.arithmetic_function.one_one Nat.ArithmeticFunction.one_one
+#align nat.arithmetic_function.one_one ArithmeticFunction.one_one
-/
-#print Nat.ArithmeticFunction.one_apply_ne /-
+#print ArithmeticFunction.one_apply_ne /-
@[simp]
-theorem one_apply_ne {x : ℕ} (h : x ≠ 1) : (1 : ArithmeticFunction R) x = 0 :=
+theorem ArithmeticFunction.one_apply_ne {x : ℕ} (h : x ≠ 1) : (1 : ArithmeticFunction R) x = 0 :=
if_neg h
-#align nat.arithmetic_function.one_apply_ne Nat.ArithmeticFunction.one_apply_ne
+#align nat.arithmetic_function.one_apply_ne ArithmeticFunction.one_apply_ne
-/
end One
end Zero
-#print Nat.ArithmeticFunction.natCoe /-
-instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
+#print ArithmeticFunction.natCoe /-
+instance ArithmeticFunction.natCoe [AddMonoidWithOne R] :
+ Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
⟨fun f => ⟨↑(f : ℕ → ℕ), by trans ↑(f 0); rfl; simp⟩⟩
-#align nat.arithmetic_function.nat_coe Nat.ArithmeticFunction.natCoe
+#align nat.arithmetic_function.nat_coe ArithmeticFunction.natCoe
-/
-#print Nat.ArithmeticFunction.natCoe_nat /-
+#print ArithmeticFunction.natCoe_nat /-
@[simp]
-theorem natCoe_nat (f : ArithmeticFunction ℕ) : (↑f : ArithmeticFunction ℕ) = f :=
- ext fun _ => cast_id _
-#align nat.arithmetic_function.nat_coe_nat Nat.ArithmeticFunction.natCoe_nat
+theorem ArithmeticFunction.natCoe_nat (f : ArithmeticFunction ℕ) :
+ (↑f : ArithmeticFunction ℕ) = f :=
+ ArithmeticFunction.ext fun _ => cast_id _
+#align nat.arithmetic_function.nat_coe_nat ArithmeticFunction.natCoe_nat
-/
-#print Nat.ArithmeticFunction.natCoe_apply /-
+#print ArithmeticFunction.natCoe_apply /-
@[simp]
-theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ} :
+theorem ArithmeticFunction.natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x :=
rfl
-#align nat.arithmetic_function.nat_coe_apply Nat.ArithmeticFunction.natCoe_apply
+#align nat.arithmetic_function.nat_coe_apply ArithmeticFunction.natCoe_apply
-/
-#print Nat.ArithmeticFunction.intCoe /-
-instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
+#print ArithmeticFunction.intCoe /-
+instance ArithmeticFunction.intCoe [AddGroupWithOne R] :
+ Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
⟨fun f => ⟨↑(f : ℕ → ℤ), by trans ↑(f 0); rfl; simp⟩⟩
-#align nat.arithmetic_function.int_coe Nat.ArithmeticFunction.intCoe
+#align nat.arithmetic_function.int_coe ArithmeticFunction.intCoe
-/
-#print Nat.ArithmeticFunction.intCoe_int /-
+#print ArithmeticFunction.intCoe_int /-
@[simp]
-theorem intCoe_int (f : ArithmeticFunction ℤ) : (↑f : ArithmeticFunction ℤ) = f :=
- ext fun _ => Int.cast_id _
-#align nat.arithmetic_function.int_coe_int Nat.ArithmeticFunction.intCoe_int
+theorem ArithmeticFunction.intCoe_int (f : ArithmeticFunction ℤ) :
+ (↑f : ArithmeticFunction ℤ) = f :=
+ ArithmeticFunction.ext fun _ => Int.cast_id _
+#align nat.arithmetic_function.int_coe_int ArithmeticFunction.intCoe_int
-/
-#print Nat.ArithmeticFunction.intCoe_apply /-
+#print ArithmeticFunction.intCoe_apply /-
@[simp]
-theorem intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ} :
+theorem ArithmeticFunction.intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x :=
rfl
-#align nat.arithmetic_function.int_coe_apply Nat.ArithmeticFunction.intCoe_apply
+#align nat.arithmetic_function.int_coe_apply ArithmeticFunction.intCoe_apply
-/
-#print Nat.ArithmeticFunction.coe_coe /-
+#print ArithmeticFunction.coe_coe /-
@[simp]
-theorem coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} :
+theorem ArithmeticFunction.coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} :
((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = f := by ext; simp
-#align nat.arithmetic_function.coe_coe Nat.ArithmeticFunction.coe_coe
+#align nat.arithmetic_function.coe_coe ArithmeticFunction.coe_coe
-/
-#print Nat.ArithmeticFunction.natCoe_one /-
+#print ArithmeticFunction.natCoe_one /-
@[simp]
-theorem natCoe_one [AddMonoidWithOne R] : ((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 :=
- by ext n; simp [one_apply]
-#align nat.arithmetic_function.nat_coe_one Nat.ArithmeticFunction.natCoe_one
+theorem ArithmeticFunction.natCoe_one [AddMonoidWithOne R] :
+ ((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 := by ext n; simp [one_apply]
+#align nat.arithmetic_function.nat_coe_one ArithmeticFunction.natCoe_one
-/
-#print Nat.ArithmeticFunction.intCoe_one /-
+#print ArithmeticFunction.intCoe_one /-
@[simp]
-theorem intCoe_one [AddGroupWithOne R] : ((1 : ArithmeticFunction ℤ) : ArithmeticFunction R) = 1 :=
- by ext n; simp [one_apply]
-#align nat.arithmetic_function.int_coe_one Nat.ArithmeticFunction.intCoe_one
+theorem ArithmeticFunction.intCoe_one [AddGroupWithOne R] :
+ ((1 : ArithmeticFunction ℤ) : ArithmeticFunction R) = 1 := by ext n; simp [one_apply]
+#align nat.arithmetic_function.int_coe_one ArithmeticFunction.intCoe_one
-/
section AddMonoid
@@ -224,19 +228,19 @@ variable [AddMonoid R]
instance : Add (ArithmeticFunction R) :=
⟨fun f g => ⟨fun n => f n + g n, by simp⟩⟩
-#print Nat.ArithmeticFunction.add_apply /-
+#print ArithmeticFunction.add_apply /-
@[simp]
-theorem add_apply {f g : ArithmeticFunction R} {n : ℕ} : (f + g) n = f n + g n :=
+theorem ArithmeticFunction.add_apply {f g : ArithmeticFunction R} {n : ℕ} : (f + g) n = f n + g n :=
rfl
-#align nat.arithmetic_function.add_apply Nat.ArithmeticFunction.add_apply
+#align nat.arithmetic_function.add_apply ArithmeticFunction.add_apply
-/
instance : AddMonoid (ArithmeticFunction R) :=
{ ArithmeticFunction.hasZero R,
ArithmeticFunction.hasAdd with
- add_assoc := fun _ _ _ => ext fun _ => add_assoc _ _ _
- zero_add := fun _ => ext fun _ => zero_add _
- add_zero := fun _ => ext fun _ => add_zero _ }
+ add_assoc := fun _ _ _ => ArithmeticFunction.ext fun _ => add_assoc _ _ _
+ zero_add := fun _ => ArithmeticFunction.ext fun _ => zero_add _
+ add_zero := fun _ => ArithmeticFunction.ext fun _ => add_zero _ }
end AddMonoid
@@ -248,13 +252,14 @@ instance [AddMonoidWithOne R] : AddMonoidWithOne (ArithmeticFunction R) :=
natCast_succ := fun _ => by ext <;> by_cases x = 1 <;> simp [Nat.cast, *] }
instance [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) :=
- { ArithmeticFunction.instAddMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ }
+ { ArithmeticFunction.instAddMonoid with
+ add_comm := fun _ _ => ArithmeticFunction.ext fun _ => add_comm _ _ }
instance [AddGroup R] : AddGroup (ArithmeticFunction R) :=
{
ArithmeticFunction.instAddMonoid with
neg := fun f => ⟨fun n => -f n, by simp⟩
- add_left_neg := fun _ => ext fun _ => add_left_neg _ }
+ add_left_neg := fun _ => ArithmeticFunction.ext fun _ => add_left_neg _ }
instance [AddCommGroup R] : AddCommGroup (ArithmeticFunction R) :=
{ ArithmeticFunction.addCommMonoid, ArithmeticFunction.addGroup with }
@@ -268,12 +273,12 @@ variable {M : Type _} [Zero R] [AddCommMonoid M] [SMul R M]
instance : SMul (ArithmeticFunction R) (ArithmeticFunction M) :=
⟨fun f g => ⟨fun n => ∑ x in divisorsAntidiagonal n, f x.fst • g x.snd, by simp⟩⟩
-#print Nat.ArithmeticFunction.smul_apply /-
+#print ArithmeticFunction.smul_apply /-
@[simp]
-theorem smul_apply {f : ArithmeticFunction R} {g : ArithmeticFunction M} {n : ℕ} :
- (f • g) n = ∑ x in divisorsAntidiagonal n, f x.fst • g x.snd :=
+theorem ArithmeticFunction.smul_apply {f : ArithmeticFunction R} {g : ArithmeticFunction M}
+ {n : ℕ} : (f • g) n = ∑ x in divisorsAntidiagonal n, f x.fst • g x.snd :=
rfl
-#align nat.arithmetic_function.smul_apply Nat.ArithmeticFunction.smul_apply
+#align nat.arithmetic_function.smul_apply ArithmeticFunction.smul_apply
-/
end SMul
@@ -283,39 +288,40 @@ end SMul
instance [Semiring R] : Mul (ArithmeticFunction R) :=
⟨(· • ·)⟩
-#print Nat.ArithmeticFunction.mul_apply /-
+#print ArithmeticFunction.mul_apply /-
@[simp]
-theorem mul_apply [Semiring R] {f g : ArithmeticFunction R} {n : ℕ} :
+theorem ArithmeticFunction.mul_apply [Semiring R] {f g : ArithmeticFunction R} {n : ℕ} :
(f * g) n = ∑ x in divisorsAntidiagonal n, f x.fst * g x.snd :=
rfl
-#align nat.arithmetic_function.mul_apply Nat.ArithmeticFunction.mul_apply
+#align nat.arithmetic_function.mul_apply ArithmeticFunction.mul_apply
-/
-#print Nat.ArithmeticFunction.mul_apply_one /-
-theorem mul_apply_one [Semiring R] {f g : ArithmeticFunction R} : (f * g) 1 = f 1 * g 1 := by simp
-#align nat.arithmetic_function.mul_apply_one Nat.ArithmeticFunction.mul_apply_one
+#print ArithmeticFunction.mul_apply_one /-
+theorem ArithmeticFunction.mul_apply_one [Semiring R] {f g : ArithmeticFunction R} :
+ (f * g) 1 = f 1 * g 1 := by simp
+#align nat.arithmetic_function.mul_apply_one ArithmeticFunction.mul_apply_one
-/
-#print Nat.ArithmeticFunction.natCoe_mul /-
+#print ArithmeticFunction.natCoe_mul /-
@[simp, norm_cast]
-theorem natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} :
+theorem ArithmeticFunction.natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} :
(↑(f * g) : ArithmeticFunction R) = f * g := by ext n; simp
-#align nat.arithmetic_function.nat_coe_mul Nat.ArithmeticFunction.natCoe_mul
+#align nat.arithmetic_function.nat_coe_mul ArithmeticFunction.natCoe_mul
-/
-#print Nat.ArithmeticFunction.intCoe_mul /-
+#print ArithmeticFunction.intCoe_mul /-
@[simp, norm_cast]
-theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
+theorem ArithmeticFunction.intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
(↑(f * g) : ArithmeticFunction R) = f * g := by ext n; simp
-#align nat.arithmetic_function.int_coe_mul Nat.ArithmeticFunction.intCoe_mul
+#align nat.arithmetic_function.int_coe_mul ArithmeticFunction.intCoe_mul
-/
section Module
variable {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M]
-#print Nat.ArithmeticFunction.mul_smul' /-
-theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
+#print ArithmeticFunction.mul_smul' /-
+theorem ArithmeticFunction.mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
(f * g) • h = f • g • h := by
ext n
simp only [mul_apply, smul_apply, sum_smul, mul_smul, smul_sum, Finset.sum_sigma']
@@ -343,12 +349,12 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
· simp only [true_and_iff, mem_divisors_antidiagonal, and_true_iff, Prod.mk.inj_iff,
eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H ⊢
rw [H.2.1]
-#align nat.arithmetic_function.mul_smul' Nat.ArithmeticFunction.mul_smul'
+#align nat.arithmetic_function.mul_smul' ArithmeticFunction.mul_smul'
-/
-#print Nat.ArithmeticFunction.one_smul' /-
-theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b = b :=
- by
+#print ArithmeticFunction.one_smul' /-
+theorem ArithmeticFunction.one_smul' (b : ArithmeticFunction M) :
+ (1 : ArithmeticFunction R) • b = b := by
ext
rw [smul_apply]
by_cases x0 : x = 0; · simp [x0]
@@ -361,7 +367,7 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y1ne]
-#align nat.arithmetic_function.one_smul' Nat.ArithmeticFunction.one_smul'
+#align nat.arithmetic_function.one_smul' ArithmeticFunction.one_smul'
-/
end Module
@@ -373,7 +379,7 @@ variable [Semiring R]
instance : Monoid (ArithmeticFunction R) :=
{ ArithmeticFunction.hasOne,
ArithmeticFunction.hasMul with
- one_mul := one_smul'
+ one_mul := ArithmeticFunction.one_smul'
mul_one := fun f => by
ext
rw [mul_apply]
@@ -387,7 +393,7 @@ instance : Monoid (ArithmeticFunction R) :=
simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y2ne]
- mul_assoc := mul_smul' }
+ mul_assoc := ArithmeticFunction.mul_smul' }
instance : Semiring (ArithmeticFunction R) :=
{ ArithmeticFunction.hasZero R, ArithmeticFunction.hasMul, ArithmeticFunction.hasAdd,
@@ -417,8 +423,8 @@ instance [CommRing R] : CommRing (ArithmeticFunction R) :=
instance {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] :
Module (ArithmeticFunction R) (ArithmeticFunction M)
where
- one_smul := one_smul'
- hMul_smul := mul_smul'
+ one_smul := ArithmeticFunction.one_smul'
+ hMul_smul := ArithmeticFunction.mul_smul'
smul_add r x y := by ext; simp only [sum_add_distrib, smul_add, smul_apply, add_apply]
smul_zero r := by ext; simp only [smul_apply, sum_const_zero, smul_zero, zero_apply]
add_smul r s x := by ext; simp only [add_smul, sum_add_distrib, smul_apply, add_apply]
@@ -426,31 +432,31 @@ instance {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] :
section Zeta
-#print Nat.ArithmeticFunction.zeta /-
+#print ArithmeticFunction.zeta /-
/-- `ζ 0 = 0`, otherwise `ζ x = 1`. The Dirichlet Series is the Riemann ζ. -/
-def zeta : ArithmeticFunction ℕ :=
+def ArithmeticFunction.zeta : ArithmeticFunction ℕ :=
⟨fun x => ite (x = 0) 0 1, rfl⟩
-#align nat.arithmetic_function.zeta Nat.ArithmeticFunction.zeta
+#align nat.arithmetic_function.zeta ArithmeticFunction.zeta
-/
-scoped[ArithmeticFunction] notation "ζ" => Nat.ArithmeticFunction.zeta
+scoped[ArithmeticFunction] notation "ζ" => ArithmeticFunction.zeta
-#print Nat.ArithmeticFunction.zeta_apply /-
+#print ArithmeticFunction.zeta_apply /-
@[simp]
-theorem zeta_apply {x : ℕ} : ζ x = if x = 0 then 0 else 1 :=
+theorem ArithmeticFunction.zeta_apply {x : ℕ} : ζ x = if x = 0 then 0 else 1 :=
rfl
-#align nat.arithmetic_function.zeta_apply Nat.ArithmeticFunction.zeta_apply
+#align nat.arithmetic_function.zeta_apply ArithmeticFunction.zeta_apply
-/
-#print Nat.ArithmeticFunction.zeta_apply_ne /-
-theorem zeta_apply_ne {x : ℕ} (h : x ≠ 0) : ζ x = 1 :=
+#print ArithmeticFunction.zeta_apply_ne /-
+theorem ArithmeticFunction.zeta_apply_ne {x : ℕ} (h : x ≠ 0) : ζ x = 1 :=
if_neg h
-#align nat.arithmetic_function.zeta_apply_ne Nat.ArithmeticFunction.zeta_apply_ne
+#align nat.arithmetic_function.zeta_apply_ne ArithmeticFunction.zeta_apply_ne
-/
-#print Nat.ArithmeticFunction.coe_zeta_smul_apply /-
+#print ArithmeticFunction.coe_zeta_smul_apply /-
@[simp]
-theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
+theorem ArithmeticFunction.coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
{f : ArithmeticFunction M} {x : ℕ} :
((↑ζ : ArithmeticFunction R) • f) x = ∑ i in divisors x, f i :=
by
@@ -460,20 +466,20 @@ theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
rcases mem_divisors_antidiagonal.1 hi with ⟨rfl, h⟩
rw [nat_coe_apply, zeta_apply_ne (left_ne_zero_of_mul h), cast_one, one_smul]
· rw [← map_div_left_divisors, sum_map, Function.Embedding.coeFn_mk]
-#align nat.arithmetic_function.coe_zeta_smul_apply Nat.ArithmeticFunction.coe_zeta_smul_apply
+#align nat.arithmetic_function.coe_zeta_smul_apply ArithmeticFunction.coe_zeta_smul_apply
-/
-#print Nat.ArithmeticFunction.coe_zeta_mul_apply /-
+#print ArithmeticFunction.coe_zeta_mul_apply /-
@[simp]
-theorem coe_zeta_mul_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
+theorem ArithmeticFunction.coe_zeta_mul_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
(↑ζ * f) x = ∑ i in divisors x, f i :=
- coe_zeta_smul_apply
-#align nat.arithmetic_function.coe_zeta_mul_apply Nat.ArithmeticFunction.coe_zeta_mul_apply
+ ArithmeticFunction.coe_zeta_smul_apply
+#align nat.arithmetic_function.coe_zeta_mul_apply ArithmeticFunction.coe_zeta_mul_apply
-/
-#print Nat.ArithmeticFunction.coe_mul_zeta_apply /-
+#print ArithmeticFunction.coe_mul_zeta_apply /-
@[simp]
-theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
+theorem ArithmeticFunction.coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
(f * ζ) x = ∑ i in divisors x, f i := by
rw [mul_apply]
trans ∑ i in divisors_antidiagonal x, f i.1
@@ -481,19 +487,19 @@ theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
rcases mem_divisors_antidiagonal.1 hi with ⟨rfl, h⟩
rw [nat_coe_apply, zeta_apply_ne (right_ne_zero_of_mul h), cast_one, mul_one]
· rw [← map_div_right_divisors, sum_map, Function.Embedding.coeFn_mk]
-#align nat.arithmetic_function.coe_mul_zeta_apply Nat.ArithmeticFunction.coe_mul_zeta_apply
+#align nat.arithmetic_function.coe_mul_zeta_apply ArithmeticFunction.coe_mul_zeta_apply
-/
-#print Nat.ArithmeticFunction.zeta_mul_apply /-
-theorem zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (ζ * f) x = ∑ i in divisors x, f i := by
- rw [← nat_coe_nat ζ, coe_zeta_mul_apply]
-#align nat.arithmetic_function.zeta_mul_apply Nat.ArithmeticFunction.zeta_mul_apply
+#print ArithmeticFunction.zeta_mul_apply /-
+theorem ArithmeticFunction.zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} :
+ (ζ * f) x = ∑ i in divisors x, f i := by rw [← nat_coe_nat ζ, coe_zeta_mul_apply]
+#align nat.arithmetic_function.zeta_mul_apply ArithmeticFunction.zeta_mul_apply
-/
-#print Nat.ArithmeticFunction.mul_zeta_apply /-
-theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑ i in divisors x, f i := by
- rw [← nat_coe_nat ζ, coe_mul_zeta_apply]
-#align nat.arithmetic_function.mul_zeta_apply Nat.ArithmeticFunction.mul_zeta_apply
+#print ArithmeticFunction.mul_zeta_apply /-
+theorem ArithmeticFunction.mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} :
+ (f * ζ) x = ∑ i in divisors x, f i := by rw [← nat_coe_nat ζ, coe_mul_zeta_apply]
+#align nat.arithmetic_function.mul_zeta_apply ArithmeticFunction.mul_zeta_apply
-/
end Zeta
@@ -502,98 +508,100 @@ open scoped ArithmeticFunction
section Pmul
-#print Nat.ArithmeticFunction.pmul /-
+#print ArithmeticFunction.pmul /-
/-- This is the pointwise product of `arithmetic_function`s. -/
-def pmul [MulZeroClass R] (f g : ArithmeticFunction R) : ArithmeticFunction R :=
+def ArithmeticFunction.pmul [MulZeroClass R] (f g : ArithmeticFunction R) : ArithmeticFunction R :=
⟨fun x => f x * g x, by simp⟩
-#align nat.arithmetic_function.pmul Nat.ArithmeticFunction.pmul
+#align nat.arithmetic_function.pmul ArithmeticFunction.pmul
-/
-#print Nat.ArithmeticFunction.pmul_apply /-
+#print ArithmeticFunction.pmul_apply /-
@[simp]
-theorem pmul_apply [MulZeroClass R] {f g : ArithmeticFunction R} {x : ℕ} : f.pmul g x = f x * g x :=
+theorem ArithmeticFunction.pmul_apply [MulZeroClass R] {f g : ArithmeticFunction R} {x : ℕ} :
+ f.pmul g x = f x * g x :=
rfl
-#align nat.arithmetic_function.pmul_apply Nat.ArithmeticFunction.pmul_apply
+#align nat.arithmetic_function.pmul_apply ArithmeticFunction.pmul_apply
-/
-#print Nat.ArithmeticFunction.pmul_comm /-
-theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g = g.pmul f := by
- ext; simp [mul_comm]
-#align nat.arithmetic_function.pmul_comm Nat.ArithmeticFunction.pmul_comm
+#print ArithmeticFunction.pmul_comm /-
+theorem ArithmeticFunction.pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) :
+ f.pmul g = g.pmul f := by ext; simp [mul_comm]
+#align nat.arithmetic_function.pmul_comm ArithmeticFunction.pmul_comm
-/
section NonAssocSemiring
variable [NonAssocSemiring R]
-#print Nat.ArithmeticFunction.pmul_zeta /-
+#print ArithmeticFunction.pmul_zeta /-
@[simp]
-theorem pmul_zeta (f : ArithmeticFunction R) : f.pmul ↑ζ = f :=
+theorem ArithmeticFunction.pmul_zeta (f : ArithmeticFunction R) : f.pmul ↑ζ = f :=
by
ext x
cases x <;> simp [Nat.succ_ne_zero]
-#align nat.arithmetic_function.pmul_zeta Nat.ArithmeticFunction.pmul_zeta
+#align nat.arithmetic_function.pmul_zeta ArithmeticFunction.pmul_zeta
-/
-#print Nat.ArithmeticFunction.zeta_pmul /-
+#print ArithmeticFunction.zeta_pmul /-
@[simp]
-theorem zeta_pmul (f : ArithmeticFunction R) : (ζ : ArithmeticFunction R).pmul f = f :=
- by
+theorem ArithmeticFunction.zeta_pmul (f : ArithmeticFunction R) :
+ (ζ : ArithmeticFunction R).pmul f = f := by
ext x
cases x <;> simp [Nat.succ_ne_zero]
-#align nat.arithmetic_function.zeta_pmul Nat.ArithmeticFunction.zeta_pmul
+#align nat.arithmetic_function.zeta_pmul ArithmeticFunction.zeta_pmul
-/
end NonAssocSemiring
variable [Semiring R]
-#print Nat.ArithmeticFunction.ppow /-
+#print ArithmeticFunction.ppow /-
/-- This is the pointwise power of `arithmetic_function`s. -/
-def ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
+def ArithmeticFunction.ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
if h0 : k = 0 then ζ
else ⟨fun x => f x ^ k, by rw [map_zero]; exact zero_pow (Nat.pos_of_ne_zero h0)⟩
-#align nat.arithmetic_function.ppow Nat.ArithmeticFunction.ppow
+#align nat.arithmetic_function.ppow ArithmeticFunction.ppow
-/
-#print Nat.ArithmeticFunction.ppow_zero /-
+#print ArithmeticFunction.ppow_zero /-
@[simp]
-theorem ppow_zero {f : ArithmeticFunction R} : f.ppow 0 = ζ := by rw [ppow, dif_pos rfl]
-#align nat.arithmetic_function.ppow_zero Nat.ArithmeticFunction.ppow_zero
+theorem ArithmeticFunction.ppow_zero {f : ArithmeticFunction R} : f.ppow 0 = ζ := by
+ rw [ppow, dif_pos rfl]
+#align nat.arithmetic_function.ppow_zero ArithmeticFunction.ppow_zero
-/
-#print Nat.ArithmeticFunction.ppow_apply /-
+#print ArithmeticFunction.ppow_apply /-
@[simp]
-theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppow k x = f x ^ k := by
- rw [ppow, dif_neg (ne_of_gt kpos)]; rfl
-#align nat.arithmetic_function.ppow_apply Nat.ArithmeticFunction.ppow_apply
+theorem ArithmeticFunction.ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) :
+ f.ppow k x = f x ^ k := by rw [ppow, dif_neg (ne_of_gt kpos)]; rfl
+#align nat.arithmetic_function.ppow_apply ArithmeticFunction.ppow_apply
-/
-#print Nat.ArithmeticFunction.ppow_succ /-
-theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) :=
- by
+#print ArithmeticFunction.ppow_succ /-
+theorem ArithmeticFunction.ppow_succ {f : ArithmeticFunction R} {k : ℕ} :
+ f.ppow (k + 1) = f.pmul (f.ppow k) := by
ext x
rw [ppow_apply (Nat.succ_pos k), pow_succ]
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ Nat.ArithmeticFunction.ppow_succ
+#align nat.arithmetic_function.ppow_succ ArithmeticFunction.ppow_succ
-/
-#print Nat.ArithmeticFunction.ppow_succ' /-
-theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
+#print ArithmeticFunction.ppow_succ' /-
+theorem ArithmeticFunction.ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
f.ppow (k + 1) = (f.ppow k).pmul f := by
ext x
rw [ppow_apply (Nat.succ_pos k), pow_succ']
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ' Nat.ArithmeticFunction.ppow_succ'
+#align nat.arithmetic_function.ppow_succ' ArithmeticFunction.ppow_succ'
-/
end Pmul
-#print Nat.ArithmeticFunction.IsMultiplicative /-
+#print ArithmeticFunction.IsMultiplicative /-
/-- Multiplicative functions -/
-def IsMultiplicative [MonoidWithZero R] (f : ArithmeticFunction R) : Prop :=
+def ArithmeticFunction.IsMultiplicative [MonoidWithZero R] (f : ArithmeticFunction R) : Prop :=
f 1 = 1 ∧ ∀ {m n : ℕ}, m.Coprime n → f (m * n) = f m * f n
-#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
+#align nat.arithmetic_function.is_multiplicative ArithmeticFunction.IsMultiplicative
-/
namespace IsMultiplicative
@@ -602,53 +610,55 @@ section MonoidWithZero
variable [MonoidWithZero R]
-#print Nat.ArithmeticFunction.IsMultiplicative.map_one /-
+#print ArithmeticFunction.IsMultiplicative.map_one /-
@[simp]
-theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
+theorem ArithmeticFunction.IsMultiplicative.map_one {f : ArithmeticFunction R}
+ (h : f.IsMultiplicative) : f 1 = 1 :=
h.1
-#align nat.arithmetic_function.is_multiplicative.map_one Nat.ArithmeticFunction.IsMultiplicative.map_one
+#align nat.arithmetic_function.is_multiplicative.map_one ArithmeticFunction.IsMultiplicative.map_one
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime /-
+#print ArithmeticFunction.IsMultiplicative.map_mul_of_coprime /-
@[simp]
-theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
- (h : m.Coprime n) : f (m * n) = f m * f n :=
+theorem ArithmeticFunction.IsMultiplicative.map_mul_of_coprime {f : ArithmeticFunction R}
+ (hf : f.IsMultiplicative) {m n : ℕ} (h : m.Coprime n) : f (m * n) = f m * f n :=
hf.2 h
-#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
+#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
-/
end MonoidWithZero
-#print Nat.ArithmeticFunction.IsMultiplicative.map_prod /-
-theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
- (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
- f (∏ i in s, g i) = ∏ i in s, f (g i) := by
+#print ArithmeticFunction.IsMultiplicative.map_prod /-
+theorem ArithmeticFunction.IsMultiplicative.map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ)
+ {f : ArithmeticFunction R} (hf : f.IsMultiplicative) (s : Finset ι)
+ (hs : (s : Set ι).Pairwise (Coprime on g)) : f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
induction' s using Finset.induction_on with a s has ih hs
· simp [hf]
rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.Coprime.prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
-#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
+#align nat.arithmetic_function.is_multiplicative.map_prod ArithmeticFunction.IsMultiplicative.map_prod
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.nat_cast /-
-theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
- IsMultiplicative (f : ArithmeticFunction R) :=
+#print ArithmeticFunction.IsMultiplicative.nat_cast /-
+theorem ArithmeticFunction.IsMultiplicative.nat_cast {f : ArithmeticFunction ℕ} [Semiring R]
+ (h : f.IsMultiplicative) : ArithmeticFunction.IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun m n cop => by simp [cop, h]⟩
-#align nat.arithmetic_function.is_multiplicative.nat_cast Nat.ArithmeticFunction.IsMultiplicative.nat_cast
+#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.nat_cast
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.int_cast /-
-theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
- IsMultiplicative (f : ArithmeticFunction R) :=
+#print ArithmeticFunction.IsMultiplicative.int_cast /-
+theorem ArithmeticFunction.IsMultiplicative.int_cast {f : ArithmeticFunction ℤ} [Ring R]
+ (h : f.IsMultiplicative) : ArithmeticFunction.IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun m n cop => by simp [cop, h]⟩
-#align nat.arithmetic_function.is_multiplicative.int_cast Nat.ArithmeticFunction.IsMultiplicative.int_cast
+#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.int_cast
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.mul /-
-theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
- (hg : g.IsMultiplicative) : IsMultiplicative (f * g) :=
+#print ArithmeticFunction.IsMultiplicative.mul /-
+theorem ArithmeticFunction.IsMultiplicative.mul [CommSemiring R] {f g : ArithmeticFunction R}
+ (hf : f.IsMultiplicative) (hg : g.IsMultiplicative) :
+ ArithmeticFunction.IsMultiplicative (f * g) :=
⟨by simp [hf, hg], by
simp only [mul_apply]
intro m n cop
@@ -709,33 +719,35 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
· rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h ; simp [h.2.1, h.2.2]
rw [mul_comm n m, h.1]⟩
-#align nat.arithmetic_function.is_multiplicative.mul Nat.ArithmeticFunction.IsMultiplicative.mul
+#align nat.arithmetic_function.is_multiplicative.mul ArithmeticFunction.IsMultiplicative.mul
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.pmul /-
-theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
- (hg : g.IsMultiplicative) : IsMultiplicative (f.pmul g) :=
+#print ArithmeticFunction.IsMultiplicative.pmul /-
+theorem ArithmeticFunction.IsMultiplicative.pmul [CommSemiring R] {f g : ArithmeticFunction R}
+ (hf : f.IsMultiplicative) (hg : g.IsMultiplicative) :
+ ArithmeticFunction.IsMultiplicative (f.pmul g) :=
⟨by simp [hf, hg], fun m n cop =>
by
simp only [pmul_apply, hf.map_mul_of_coprime cop, hg.map_mul_of_coprime cop]
ring⟩
-#align nat.arithmetic_function.is_multiplicative.pmul Nat.ArithmeticFunction.IsMultiplicative.pmul
+#align nat.arithmetic_function.is_multiplicative.pmul ArithmeticFunction.IsMultiplicative.pmul
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.multiplicative_factorization /-
+#print ArithmeticFunction.IsMultiplicative.multiplicative_factorization /-
/-- 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) :
+theorem ArithmeticFunction.IsMultiplicative.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) :=
multiplicative_factorization f (fun _ _ => hf.2) hf.1 hn
-#align nat.arithmetic_function.is_multiplicative.multiplicative_factorization Nat.ArithmeticFunction.IsMultiplicative.multiplicative_factorization
+#align nat.arithmetic_function.is_multiplicative.multiplicative_factorization ArithmeticFunction.IsMultiplicative.multiplicative_factorization
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.iff_ne_zero /-
+#print ArithmeticFunction.IsMultiplicative.iff_ne_zero /-
/-- A recapitulation of the definition of multiplicative that is simpler for proofs -/
-theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
- IsMultiplicative f ↔
+theorem ArithmeticFunction.IsMultiplicative.iff_ne_zero [MonoidWithZero R]
+ {f : ArithmeticFunction R} :
+ ArithmeticFunction.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 => _⟩)
@@ -744,15 +756,15 @@ theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
rcases eq_or_ne n 0 with (rfl | hn)
· simp
exact h hm hn hmn
-#align nat.arithmetic_function.is_multiplicative.iff_ne_zero Nat.ArithmeticFunction.IsMultiplicative.iff_ne_zero
+#align nat.arithmetic_function.is_multiplicative.iff_ne_zero ArithmeticFunction.IsMultiplicative.iff_ne_zero
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers /-
+#print ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers /-
/-- 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) :=
+theorem ArithmeticFunction.IsMultiplicative.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 p i _; rw [h]
@@ -765,82 +777,85 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
simp only [support_factorization, List.mem_toFinset]
intro p hp
exact h p _ (Nat.prime_of_mem_factors hp)
-#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
+#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
-/
end IsMultiplicative
section SpecialFunctions
-#print Nat.ArithmeticFunction.id /-
+#print ArithmeticFunction.id /-
/-- The identity on `ℕ` as an `arithmetic_function`. -/
-def id : ArithmeticFunction ℕ :=
+def ArithmeticFunction.id : ArithmeticFunction ℕ :=
⟨id, rfl⟩
-#align nat.arithmetic_function.id Nat.ArithmeticFunction.id
+#align nat.arithmetic_function.id ArithmeticFunction.id
-/
-#print Nat.ArithmeticFunction.id_apply /-
+#print ArithmeticFunction.id_apply /-
@[simp]
-theorem id_apply {x : ℕ} : id x = x :=
+theorem ArithmeticFunction.id_apply {x : ℕ} : ArithmeticFunction.id x = x :=
rfl
-#align nat.arithmetic_function.id_apply Nat.ArithmeticFunction.id_apply
+#align nat.arithmetic_function.id_apply ArithmeticFunction.id_apply
-/
-#print Nat.ArithmeticFunction.pow /-
+#print ArithmeticFunction.pow /-
/-- `pow k n = n ^ k`, except `pow 0 0 = 0`. -/
-def pow (k : ℕ) : ArithmeticFunction ℕ :=
- id.ppow k
-#align nat.arithmetic_function.pow Nat.ArithmeticFunction.pow
+def ArithmeticFunction.pow (k : ℕ) : ArithmeticFunction ℕ :=
+ ArithmeticFunction.id.ppow k
+#align nat.arithmetic_function.pow ArithmeticFunction.pow
-/
-#print Nat.ArithmeticFunction.pow_apply /-
+#print ArithmeticFunction.pow_apply /-
@[simp]
-theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :=
+theorem ArithmeticFunction.pow_apply {k n : ℕ} :
+ ArithmeticFunction.pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :=
by
cases k
· simp [pow]
simp [pow, (ne_of_lt (Nat.succ_pos k)).symm]
-#align nat.arithmetic_function.pow_apply Nat.ArithmeticFunction.pow_apply
+#align nat.arithmetic_function.pow_apply ArithmeticFunction.pow_apply
-/
-#print Nat.ArithmeticFunction.pow_zero_eq_zeta /-
-theorem pow_zero_eq_zeta : pow 0 = ζ := by ext n; simp
-#align nat.arithmetic_function.pow_zero_eq_zeta Nat.ArithmeticFunction.pow_zero_eq_zeta
+#print ArithmeticFunction.pow_zero_eq_zeta /-
+theorem ArithmeticFunction.pow_zero_eq_zeta : ArithmeticFunction.pow 0 = ζ := by ext n; simp
+#align nat.arithmetic_function.pow_zero_eq_zeta ArithmeticFunction.pow_zero_eq_zeta
-/
-#print Nat.ArithmeticFunction.sigma /-
+#print ArithmeticFunction.sigma /-
/-- `σ k n` is the sum of the `k`th powers of the divisors of `n` -/
-def sigma (k : ℕ) : ArithmeticFunction ℕ :=
+def ArithmeticFunction.sigma (k : ℕ) : ArithmeticFunction ℕ :=
⟨fun n => ∑ d in divisors n, d ^ k, by simp⟩
-#align nat.arithmetic_function.sigma Nat.ArithmeticFunction.sigma
+#align nat.arithmetic_function.sigma ArithmeticFunction.sigma
-/
-scoped[ArithmeticFunction] notation "σ" => Nat.ArithmeticFunction.sigma
+scoped[ArithmeticFunction] notation "σ" => ArithmeticFunction.sigma
-#print Nat.ArithmeticFunction.sigma_apply /-
-theorem sigma_apply {k n : ℕ} : σ k n = ∑ d in divisors n, d ^ k :=
+#print ArithmeticFunction.sigma_apply /-
+theorem ArithmeticFunction.sigma_apply {k n : ℕ} : σ k n = ∑ d in divisors n, d ^ k :=
rfl
-#align nat.arithmetic_function.sigma_apply Nat.ArithmeticFunction.sigma_apply
+#align nat.arithmetic_function.sigma_apply ArithmeticFunction.sigma_apply
-/
-#print Nat.ArithmeticFunction.sigma_one_apply /-
-theorem sigma_one_apply (n : ℕ) : σ 1 n = ∑ d in divisors n, d := by simp [sigma_apply]
-#align nat.arithmetic_function.sigma_one_apply Nat.ArithmeticFunction.sigma_one_apply
+#print ArithmeticFunction.sigma_one_apply /-
+theorem ArithmeticFunction.sigma_one_apply (n : ℕ) : σ 1 n = ∑ d in divisors n, d := by
+ simp [sigma_apply]
+#align nat.arithmetic_function.sigma_one_apply ArithmeticFunction.sigma_one_apply
-/
-#print Nat.ArithmeticFunction.sigma_zero_apply /-
-theorem sigma_zero_apply (n : ℕ) : σ 0 n = (divisors n).card := by simp [sigma_apply]
-#align nat.arithmetic_function.sigma_zero_apply Nat.ArithmeticFunction.sigma_zero_apply
+#print ArithmeticFunction.sigma_zero_apply /-
+theorem ArithmeticFunction.sigma_zero_apply (n : ℕ) : σ 0 n = (divisors n).card := by
+ simp [sigma_apply]
+#align nat.arithmetic_function.sigma_zero_apply ArithmeticFunction.sigma_zero_apply
-/
-#print Nat.ArithmeticFunction.sigma_zero_apply_prime_pow /-
-theorem sigma_zero_apply_prime_pow {p i : ℕ} (hp : p.Prime) : σ 0 (p ^ i) = i + 1 := by
- rw [sigma_zero_apply, divisors_prime_pow hp, card_map, card_range]
-#align nat.arithmetic_function.sigma_zero_apply_prime_pow Nat.ArithmeticFunction.sigma_zero_apply_prime_pow
+#print ArithmeticFunction.sigma_zero_apply_prime_pow /-
+theorem ArithmeticFunction.sigma_zero_apply_prime_pow {p i : ℕ} (hp : p.Prime) :
+ σ 0 (p ^ i) = i + 1 := by rw [sigma_zero_apply, divisors_prime_pow hp, card_map, card_range]
+#align nat.arithmetic_function.sigma_zero_apply_prime_pow ArithmeticFunction.sigma_zero_apply_prime_pow
-/
-#print Nat.ArithmeticFunction.zeta_mul_pow_eq_sigma /-
-theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k :=
+#print ArithmeticFunction.zeta_mul_pow_eq_sigma /-
+theorem ArithmeticFunction.zeta_mul_pow_eq_sigma {k : ℕ} : ζ * ArithmeticFunction.pow k = σ k :=
by
ext
rw [Sigma, zeta_mul_apply]
@@ -849,12 +864,13 @@ theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k :=
rw [pow_apply, if_neg (not_and_of_not_right _ _)]
contrapose! hx
simp [hx]
-#align nat.arithmetic_function.zeta_mul_pow_eq_sigma Nat.ArithmeticFunction.zeta_mul_pow_eq_sigma
+#align nat.arithmetic_function.zeta_mul_pow_eq_sigma ArithmeticFunction.zeta_mul_pow_eq_sigma
-/
-#print Nat.ArithmeticFunction.isMultiplicative_one /-
-theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : ArithmeticFunction R) :=
- IsMultiplicative.iff_ne_zero.2
+#print ArithmeticFunction.isMultiplicative_one /-
+theorem ArithmeticFunction.isMultiplicative_one [MonoidWithZero R] :
+ ArithmeticFunction.IsMultiplicative (1 : ArithmeticFunction R) :=
+ ArithmeticFunction.IsMultiplicative.iff_ne_zero.2
⟨by simp, by
intro m n hm hn hmn
rcases eq_or_ne m 1 with (rfl | hm')
@@ -862,69 +878,73 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
rw [one_apply_ne, one_apply_ne hm', MulZeroClass.zero_mul]
rw [Ne.def, mul_eq_one, not_and_or]
exact Or.inl hm'⟩
-#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
+#align nat.arithmetic_function.is_multiplicative_one ArithmeticFunction.isMultiplicative_one
-/
-#print Nat.ArithmeticFunction.isMultiplicative_zeta /-
-theorem isMultiplicative_zeta : IsMultiplicative ζ :=
- IsMultiplicative.iff_ne_zero.2 ⟨by simp, by simp (config := { contextual := true })⟩
-#align nat.arithmetic_function.is_multiplicative_zeta Nat.ArithmeticFunction.isMultiplicative_zeta
+#print ArithmeticFunction.isMultiplicative_zeta /-
+theorem ArithmeticFunction.isMultiplicative_zeta : ArithmeticFunction.IsMultiplicative ζ :=
+ ArithmeticFunction.IsMultiplicative.iff_ne_zero.2
+ ⟨by simp, by simp (config := { contextual := true })⟩
+#align nat.arithmetic_function.is_multiplicative_zeta ArithmeticFunction.isMultiplicative_zeta
-/
-#print Nat.ArithmeticFunction.isMultiplicative_id /-
-theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id :=
+#print ArithmeticFunction.isMultiplicative_id /-
+theorem ArithmeticFunction.isMultiplicative_id :
+ ArithmeticFunction.IsMultiplicative ArithmeticFunction.id :=
⟨rfl, fun _ _ _ => rfl⟩
-#align nat.arithmetic_function.is_multiplicative_id Nat.ArithmeticFunction.isMultiplicative_id
+#align nat.arithmetic_function.is_multiplicative_id ArithmeticFunction.isMultiplicative_id
-/
-#print Nat.ArithmeticFunction.IsMultiplicative.ppow /-
-theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
- {k : ℕ} : IsMultiplicative (f.ppow k) :=
+#print ArithmeticFunction.IsMultiplicative.ppow /-
+theorem ArithmeticFunction.IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R}
+ (hf : f.IsMultiplicative) {k : ℕ} : ArithmeticFunction.IsMultiplicative (f.ppow k) :=
by
induction' k with k hi
· exact is_multiplicative_zeta.nat_cast
· rw [ppow_succ]
apply hf.pmul hi
-#align nat.arithmetic_function.is_multiplicative.ppow Nat.ArithmeticFunction.IsMultiplicative.ppow
+#align nat.arithmetic_function.is_multiplicative.ppow ArithmeticFunction.IsMultiplicative.ppow
-/
-#print Nat.ArithmeticFunction.isMultiplicative_pow /-
-theorem isMultiplicative_pow {k : ℕ} : IsMultiplicative (pow k) :=
- isMultiplicative_id.ppow
-#align nat.arithmetic_function.is_multiplicative_pow Nat.ArithmeticFunction.isMultiplicative_pow
+#print ArithmeticFunction.isMultiplicative_pow /-
+theorem ArithmeticFunction.isMultiplicative_pow {k : ℕ} :
+ ArithmeticFunction.IsMultiplicative (ArithmeticFunction.pow k) :=
+ ArithmeticFunction.isMultiplicative_id.ppow
+#align nat.arithmetic_function.is_multiplicative_pow ArithmeticFunction.isMultiplicative_pow
-/
-#print Nat.ArithmeticFunction.isMultiplicative_sigma /-
-theorem isMultiplicative_sigma {k : ℕ} : IsMultiplicative (σ k) :=
+#print ArithmeticFunction.isMultiplicative_sigma /-
+theorem ArithmeticFunction.isMultiplicative_sigma {k : ℕ} :
+ ArithmeticFunction.IsMultiplicative (σ k) :=
by
rw [← zeta_mul_pow_eq_sigma]
apply is_multiplicative_zeta.mul is_multiplicative_pow
-#align nat.arithmetic_function.is_multiplicative_sigma Nat.ArithmeticFunction.isMultiplicative_sigma
+#align nat.arithmetic_function.is_multiplicative_sigma ArithmeticFunction.isMultiplicative_sigma
-/
-#print Nat.ArithmeticFunction.cardFactors /-
+#print ArithmeticFunction.cardFactors /-
/-- `Ω n` is the number of prime factors of `n`. -/
-def cardFactors : ArithmeticFunction ℕ :=
+def ArithmeticFunction.cardFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.length, by simp⟩
-#align nat.arithmetic_function.card_factors Nat.ArithmeticFunction.cardFactors
+#align nat.arithmetic_function.card_factors ArithmeticFunction.cardFactors
-/
-scoped[ArithmeticFunction] notation "Ω" => Nat.ArithmeticFunction.cardFactors
+scoped[ArithmeticFunction] notation "Ω" => ArithmeticFunction.cardFactors
-#print Nat.ArithmeticFunction.cardFactors_apply /-
-theorem cardFactors_apply {n : ℕ} : Ω n = n.factors.length :=
+#print ArithmeticFunction.cardFactors_apply /-
+theorem ArithmeticFunction.cardFactors_apply {n : ℕ} : Ω n = n.factors.length :=
rfl
-#align nat.arithmetic_function.card_factors_apply Nat.ArithmeticFunction.cardFactors_apply
+#align nat.arithmetic_function.card_factors_apply ArithmeticFunction.cardFactors_apply
-/
-#print Nat.ArithmeticFunction.cardFactors_one /-
+#print ArithmeticFunction.cardFactors_one /-
@[simp]
-theorem cardFactors_one : Ω 1 = 0 := by simp [card_factors]
-#align nat.arithmetic_function.card_factors_one Nat.ArithmeticFunction.cardFactors_one
+theorem ArithmeticFunction.cardFactors_one : Ω 1 = 0 := by simp [card_factors]
+#align nat.arithmetic_function.card_factors_one ArithmeticFunction.cardFactors_one
-/
-#print Nat.ArithmeticFunction.cardFactors_eq_one_iff_prime /-
-theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime :=
+#print ArithmeticFunction.cardFactors_eq_one_iff_prime /-
+theorem ArithmeticFunction.cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime :=
by
refine' ⟨fun h => _, fun h => List.length_eq_one.2 ⟨n, factors_prime h⟩⟩
cases n
@@ -934,70 +954,71 @@ theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime :=
rw [← prod_factors n.succ_ne_zero, hx, List.prod_singleton]
apply prime_of_mem_factors
rw [hx, List.mem_singleton]
-#align nat.arithmetic_function.card_factors_eq_one_iff_prime Nat.ArithmeticFunction.cardFactors_eq_one_iff_prime
+#align nat.arithmetic_function.card_factors_eq_one_iff_prime ArithmeticFunction.cardFactors_eq_one_iff_prime
-/
-#print Nat.ArithmeticFunction.cardFactors_mul /-
-theorem cardFactors_mul {m n : ℕ} (m0 : m ≠ 0) (n0 : n ≠ 0) : Ω (m * n) = Ω m + Ω n := by
+#print ArithmeticFunction.cardFactors_mul /-
+theorem ArithmeticFunction.cardFactors_mul {m n : ℕ} (m0 : m ≠ 0) (n0 : n ≠ 0) :
+ Ω (m * n) = Ω m + Ω n := by
rw [card_factors_apply, card_factors_apply, card_factors_apply, ← Multiset.coe_card, ← factors_eq,
UniqueFactorizationMonoid.normalizedFactors_mul m0 n0, factors_eq, factors_eq,
Multiset.card_add, Multiset.coe_card, Multiset.coe_card]
-#align nat.arithmetic_function.card_factors_mul Nat.ArithmeticFunction.cardFactors_mul
+#align nat.arithmetic_function.card_factors_mul ArithmeticFunction.cardFactors_mul
-/
-#print Nat.ArithmeticFunction.cardFactors_multiset_prod /-
-theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.Prod ≠ 0) :
+#print ArithmeticFunction.cardFactors_multiset_prod /-
+theorem ArithmeticFunction.cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.Prod ≠ 0) :
Ω s.Prod = (Multiset.map Ω s).Sum := by
revert h0
apply s.induction_on; · simp
intro a t h h0
rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
simp [h0, card_factors_mul, h]
-#align nat.arithmetic_function.card_factors_multiset_prod Nat.ArithmeticFunction.cardFactors_multiset_prod
+#align nat.arithmetic_function.card_factors_multiset_prod ArithmeticFunction.cardFactors_multiset_prod
-/
-#print Nat.ArithmeticFunction.cardFactors_apply_prime /-
+#print ArithmeticFunction.cardFactors_apply_prime /-
@[simp]
-theorem cardFactors_apply_prime {p : ℕ} (hp : p.Prime) : Ω p = 1 :=
- cardFactors_eq_one_iff_prime.2 hp
-#align nat.arithmetic_function.card_factors_apply_prime Nat.ArithmeticFunction.cardFactors_apply_prime
+theorem ArithmeticFunction.cardFactors_apply_prime {p : ℕ} (hp : p.Prime) : Ω p = 1 :=
+ ArithmeticFunction.cardFactors_eq_one_iff_prime.2 hp
+#align nat.arithmetic_function.card_factors_apply_prime ArithmeticFunction.cardFactors_apply_prime
-/
-#print Nat.ArithmeticFunction.cardFactors_apply_prime_pow /-
+#print ArithmeticFunction.cardFactors_apply_prime_pow /-
@[simp]
-theorem cardFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) : Ω (p ^ k) = k := by
- rw [card_factors_apply, hp.factors_pow, List.length_replicate]
-#align nat.arithmetic_function.card_factors_apply_prime_pow Nat.ArithmeticFunction.cardFactors_apply_prime_pow
+theorem ArithmeticFunction.cardFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) : Ω (p ^ k) = k :=
+ by rw [card_factors_apply, hp.factors_pow, List.length_replicate]
+#align nat.arithmetic_function.card_factors_apply_prime_pow ArithmeticFunction.cardFactors_apply_prime_pow
-/
-#print Nat.ArithmeticFunction.cardDistinctFactors /-
+#print ArithmeticFunction.cardDistinctFactors /-
/-- `ω n` is the number of distinct prime factors of `n`. -/
-def cardDistinctFactors : ArithmeticFunction ℕ :=
+def ArithmeticFunction.cardDistinctFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.dedup.length, by simp⟩
-#align nat.arithmetic_function.card_distinct_factors Nat.ArithmeticFunction.cardDistinctFactors
+#align nat.arithmetic_function.card_distinct_factors ArithmeticFunction.cardDistinctFactors
-/
-scoped[ArithmeticFunction] notation "ω" => Nat.ArithmeticFunction.cardDistinctFactors
+scoped[ArithmeticFunction] notation "ω" => ArithmeticFunction.cardDistinctFactors
-#print Nat.ArithmeticFunction.cardDistinctFactors_zero /-
-theorem cardDistinctFactors_zero : ω 0 = 0 := by simp
-#align nat.arithmetic_function.card_distinct_factors_zero Nat.ArithmeticFunction.cardDistinctFactors_zero
+#print ArithmeticFunction.cardDistinctFactors_zero /-
+theorem ArithmeticFunction.cardDistinctFactors_zero : ω 0 = 0 := by simp
+#align nat.arithmetic_function.card_distinct_factors_zero ArithmeticFunction.cardDistinctFactors_zero
-/
-#print Nat.ArithmeticFunction.cardDistinctFactors_one /-
+#print ArithmeticFunction.cardDistinctFactors_one /-
@[simp]
-theorem cardDistinctFactors_one : ω 1 = 0 := by simp [card_distinct_factors]
-#align nat.arithmetic_function.card_distinct_factors_one Nat.ArithmeticFunction.cardDistinctFactors_one
+theorem ArithmeticFunction.cardDistinctFactors_one : ω 1 = 0 := by simp [card_distinct_factors]
+#align nat.arithmetic_function.card_distinct_factors_one ArithmeticFunction.cardDistinctFactors_one
-/
-#print Nat.ArithmeticFunction.cardDistinctFactors_apply /-
-theorem cardDistinctFactors_apply {n : ℕ} : ω n = n.factors.dedup.length :=
+#print ArithmeticFunction.cardDistinctFactors_apply /-
+theorem ArithmeticFunction.cardDistinctFactors_apply {n : ℕ} : ω n = n.factors.dedup.length :=
rfl
-#align nat.arithmetic_function.card_distinct_factors_apply Nat.ArithmeticFunction.cardDistinctFactors_apply
+#align nat.arithmetic_function.card_distinct_factors_apply ArithmeticFunction.cardDistinctFactors_apply
-/
-#print Nat.ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree /-
-theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠ 0) :
+#print ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree /-
+theorem ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠ 0) :
ω n = Ω n ↔ Squarefree n :=
by
rw [squarefree_iff_nodup_factors h0, card_distinct_factors_apply]
@@ -1006,117 +1027,120 @@ theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠
apply List.nodup_dedup
· rw [h.dedup]
rfl
-#align nat.arithmetic_function.card_distinct_factors_eq_card_factors_iff_squarefree Nat.ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree
+#align nat.arithmetic_function.card_distinct_factors_eq_card_factors_iff_squarefree ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree
-/
-#print Nat.ArithmeticFunction.cardDistinctFactors_apply_prime_pow /-
+#print ArithmeticFunction.cardDistinctFactors_apply_prime_pow /-
@[simp]
-theorem cardDistinctFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) : ω (p ^ k) = 1 :=
- by
+theorem ArithmeticFunction.cardDistinctFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime)
+ (hk : k ≠ 0) : ω (p ^ k) = 1 := by
rw [card_distinct_factors_apply, hp.factors_pow, List.replicate_dedup hk, List.length_singleton]
-#align nat.arithmetic_function.card_distinct_factors_apply_prime_pow Nat.ArithmeticFunction.cardDistinctFactors_apply_prime_pow
+#align nat.arithmetic_function.card_distinct_factors_apply_prime_pow ArithmeticFunction.cardDistinctFactors_apply_prime_pow
-/
-#print Nat.ArithmeticFunction.cardDistinctFactors_apply_prime /-
+#print ArithmeticFunction.cardDistinctFactors_apply_prime /-
@[simp]
-theorem cardDistinctFactors_apply_prime {p : ℕ} (hp : p.Prime) : ω p = 1 := by
+theorem ArithmeticFunction.cardDistinctFactors_apply_prime {p : ℕ} (hp : p.Prime) : ω p = 1 := by
rw [← pow_one p, card_distinct_factors_apply_prime_pow hp one_ne_zero]
-#align nat.arithmetic_function.card_distinct_factors_apply_prime Nat.ArithmeticFunction.cardDistinctFactors_apply_prime
+#align nat.arithmetic_function.card_distinct_factors_apply_prime ArithmeticFunction.cardDistinctFactors_apply_prime
-/
-#print Nat.ArithmeticFunction.moebius /-
+#print ArithmeticFunction.moebius /-
/-- `μ` 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`. -/
-def moebius : ArithmeticFunction ℤ :=
- ⟨fun n => if Squarefree n then (-1) ^ cardFactors n else 0, by simp⟩
-#align nat.arithmetic_function.moebius Nat.ArithmeticFunction.moebius
+def ArithmeticFunction.moebius : ArithmeticFunction ℤ :=
+ ⟨fun n => if Squarefree n then (-1) ^ ArithmeticFunction.cardFactors n else 0, by simp⟩
+#align nat.arithmetic_function.moebius ArithmeticFunction.moebius
-/
-scoped[ArithmeticFunction] notation "μ" => Nat.ArithmeticFunction.moebius
+scoped[ArithmeticFunction] notation "μ" => ArithmeticFunction.moebius
-#print Nat.ArithmeticFunction.moebius_apply_of_squarefree /-
+#print ArithmeticFunction.moebius_apply_of_squarefree /-
@[simp]
-theorem moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) : μ n = (-1) ^ cardFactors n :=
+theorem ArithmeticFunction.moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) :
+ μ n = (-1) ^ ArithmeticFunction.cardFactors n :=
if_pos h
-#align nat.arithmetic_function.moebius_apply_of_squarefree Nat.ArithmeticFunction.moebius_apply_of_squarefree
+#align nat.arithmetic_function.moebius_apply_of_squarefree ArithmeticFunction.moebius_apply_of_squarefree
-/
-#print Nat.ArithmeticFunction.moebius_eq_zero_of_not_squarefree /-
+#print ArithmeticFunction.moebius_eq_zero_of_not_squarefree /-
@[simp]
-theorem moebius_eq_zero_of_not_squarefree {n : ℕ} (h : ¬Squarefree n) : μ n = 0 :=
+theorem ArithmeticFunction.moebius_eq_zero_of_not_squarefree {n : ℕ} (h : ¬Squarefree n) :
+ μ n = 0 :=
if_neg h
-#align nat.arithmetic_function.moebius_eq_zero_of_not_squarefree Nat.ArithmeticFunction.moebius_eq_zero_of_not_squarefree
+#align nat.arithmetic_function.moebius_eq_zero_of_not_squarefree ArithmeticFunction.moebius_eq_zero_of_not_squarefree
-/
-#print Nat.ArithmeticFunction.moebius_apply_one /-
-theorem moebius_apply_one : μ 1 = 1 := by simp
-#align nat.arithmetic_function.moebius_apply_one Nat.ArithmeticFunction.moebius_apply_one
+#print ArithmeticFunction.moebius_apply_one /-
+theorem ArithmeticFunction.moebius_apply_one : μ 1 = 1 := by simp
+#align nat.arithmetic_function.moebius_apply_one ArithmeticFunction.moebius_apply_one
-/
-#print Nat.ArithmeticFunction.moebius_ne_zero_iff_squarefree /-
-theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n :=
+#print ArithmeticFunction.moebius_ne_zero_iff_squarefree /-
+theorem ArithmeticFunction.moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n :=
by
constructor <;> intro h
· contrapose! h
simp [h]
· simp [h, pow_ne_zero]
-#align nat.arithmetic_function.moebius_ne_zero_iff_squarefree Nat.ArithmeticFunction.moebius_ne_zero_iff_squarefree
+#align nat.arithmetic_function.moebius_ne_zero_iff_squarefree ArithmeticFunction.moebius_ne_zero_iff_squarefree
-/
-#print Nat.ArithmeticFunction.moebius_ne_zero_iff_eq_or /-
-theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 :=
+#print ArithmeticFunction.moebius_ne_zero_iff_eq_or /-
+theorem ArithmeticFunction.moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 :=
by
constructor <;> intro h
· rw [moebius_ne_zero_iff_squarefree] at h
rw [moebius_apply_of_squarefree h]
apply neg_one_pow_eq_or
· rcases h with (h | h) <;> simp [h]
-#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or Nat.ArithmeticFunction.moebius_ne_zero_iff_eq_or
+#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or ArithmeticFunction.moebius_ne_zero_iff_eq_or
-/
-#print Nat.ArithmeticFunction.moebius_apply_prime /-
-theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
+#print ArithmeticFunction.moebius_apply_prime /-
+theorem ArithmeticFunction.moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
rw [moebius_apply_of_squarefree hp.squarefree, card_factors_apply_prime hp, pow_one]
-#align nat.arithmetic_function.moebius_apply_prime Nat.ArithmeticFunction.moebius_apply_prime
+#align nat.arithmetic_function.moebius_apply_prime ArithmeticFunction.moebius_apply_prime
-/
-#print Nat.ArithmeticFunction.moebius_apply_prime_pow /-
-theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
+#print ArithmeticFunction.moebius_apply_prime_pow /-
+theorem ArithmeticFunction.moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
μ (p ^ k) = if k = 1 then -1 else 0 := by
split_ifs
· rw [h, pow_one, moebius_apply_prime hp]
rw [moebius_eq_zero_of_not_squarefree]
rw [squarefree_pow_iff hp.ne_one hk, not_and_or]
exact Or.inr h
-#align nat.arithmetic_function.moebius_apply_prime_pow Nat.ArithmeticFunction.moebius_apply_prime_pow
+#align nat.arithmetic_function.moebius_apply_prime_pow ArithmeticFunction.moebius_apply_prime_pow
-/
-#print Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime /-
-theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' : ¬n.Prime) : μ n = 0 :=
+#print ArithmeticFunction.moebius_apply_isPrimePow_not_prime /-
+theorem ArithmeticFunction.moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n)
+ (hn' : ¬n.Prime) : μ n = 0 :=
by
obtain ⟨p, k, hp, hk, rfl⟩ := (isPrimePow_nat_iff _).1 hn
rw [moebius_apply_prime_pow hp hk.ne', if_neg]
rintro rfl
exact hn' (by simpa)
-#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime
+#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime ArithmeticFunction.moebius_apply_isPrimePow_not_prime
-/
-#print Nat.ArithmeticFunction.isMultiplicative_moebius /-
-theorem isMultiplicative_moebius : IsMultiplicative μ :=
+#print ArithmeticFunction.isMultiplicative_moebius /-
+theorem ArithmeticFunction.isMultiplicative_moebius : ArithmeticFunction.IsMultiplicative μ :=
by
rw [is_multiplicative.iff_ne_zero]
refine' ⟨by simp, fun n m hn hm hnm => _⟩
simp only [moebius, ZeroHom.coe_mk, squarefree_mul hnm, ite_and, card_factors_mul hn hm]
rw [pow_add, mul_comm, ite_zero_mul, mul_ite_zero, mul_comm]
-#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
+#align nat.arithmetic_function.is_multiplicative_moebius ArithmeticFunction.isMultiplicative_moebius
-/
open UniqueFactorizationMonoid
-#print Nat.ArithmeticFunction.moebius_mul_coe_zeta /-
+#print ArithmeticFunction.moebius_mul_coe_zeta /-
@[simp]
-theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 :=
+theorem ArithmeticFunction.moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 :=
by
ext n
refine' rec_on_pos_prime_pos_coprime _ _ _ _ n
@@ -1135,28 +1159,28 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 :=
rw [is_multiplicative.map_mul_of_coprime _ hab, ha', hb',
is_multiplicative.map_mul_of_coprime is_multiplicative_one hab]
exact is_multiplicative_moebius.mul is_multiplicative_zeta.nat_cast
-#align nat.arithmetic_function.moebius_mul_coe_zeta Nat.ArithmeticFunction.moebius_mul_coe_zeta
+#align nat.arithmetic_function.moebius_mul_coe_zeta ArithmeticFunction.moebius_mul_coe_zeta
-/
-#print Nat.ArithmeticFunction.coe_zeta_mul_moebius /-
+#print ArithmeticFunction.coe_zeta_mul_moebius /-
@[simp]
-theorem coe_zeta_mul_moebius : (ζ * μ : ArithmeticFunction ℤ) = 1 := by
+theorem ArithmeticFunction.coe_zeta_mul_moebius : (ζ * μ : ArithmeticFunction ℤ) = 1 := by
rw [mul_comm, moebius_mul_coe_zeta]
-#align nat.arithmetic_function.coe_zeta_mul_moebius Nat.ArithmeticFunction.coe_zeta_mul_moebius
+#align nat.arithmetic_function.coe_zeta_mul_moebius ArithmeticFunction.coe_zeta_mul_moebius
-/
-#print Nat.ArithmeticFunction.coe_moebius_mul_coe_zeta /-
+#print ArithmeticFunction.coe_moebius_mul_coe_zeta /-
@[simp]
-theorem coe_moebius_mul_coe_zeta [Ring R] : (μ * ζ : ArithmeticFunction R) = 1 := by
- rw [← coe_coe, ← int_coe_mul, moebius_mul_coe_zeta, int_coe_one]
-#align nat.arithmetic_function.coe_moebius_mul_coe_zeta Nat.ArithmeticFunction.coe_moebius_mul_coe_zeta
+theorem ArithmeticFunction.coe_moebius_mul_coe_zeta [Ring R] : (μ * ζ : ArithmeticFunction R) = 1 :=
+ by rw [← coe_coe, ← int_coe_mul, moebius_mul_coe_zeta, int_coe_one]
+#align nat.arithmetic_function.coe_moebius_mul_coe_zeta ArithmeticFunction.coe_moebius_mul_coe_zeta
-/
-#print Nat.ArithmeticFunction.coe_zeta_mul_coe_moebius /-
+#print ArithmeticFunction.coe_zeta_mul_coe_moebius /-
@[simp]
-theorem coe_zeta_mul_coe_moebius [Ring R] : (ζ * μ : ArithmeticFunction R) = 1 := by
- rw [← coe_coe, ← int_coe_mul, coe_zeta_mul_moebius, int_coe_one]
-#align nat.arithmetic_function.coe_zeta_mul_coe_moebius Nat.ArithmeticFunction.coe_zeta_mul_coe_moebius
+theorem ArithmeticFunction.coe_zeta_mul_coe_moebius [Ring R] : (ζ * μ : ArithmeticFunction R) = 1 :=
+ by rw [← coe_coe, ← int_coe_mul, coe_zeta_mul_moebius, int_coe_one]
+#align nat.arithmetic_function.coe_zeta_mul_coe_moebius ArithmeticFunction.coe_zeta_mul_coe_moebius
-/
section CommRing
@@ -1166,35 +1190,37 @@ variable [CommRing R]
instance : Invertible (ζ : ArithmeticFunction R)
where
invOf := μ
- invOf_hMul_self := coe_moebius_mul_coe_zeta
- hMul_invOf_self := coe_zeta_mul_coe_moebius
+ invOf_hMul_self := ArithmeticFunction.coe_moebius_mul_coe_zeta
+ hMul_invOf_self := ArithmeticFunction.coe_zeta_mul_coe_moebius
-#print Nat.ArithmeticFunction.zetaUnit /-
+#print ArithmeticFunction.zetaUnit /-
/-- A unit in `arithmetic_function R` that evaluates to `ζ`, with inverse `μ`. -/
-def zetaUnit : (ArithmeticFunction R)ˣ :=
- ⟨ζ, μ, coe_zeta_mul_coe_moebius, coe_moebius_mul_coe_zeta⟩
-#align nat.arithmetic_function.zeta_unit Nat.ArithmeticFunction.zetaUnit
+def ArithmeticFunction.zetaUnit : (ArithmeticFunction R)ˣ :=
+ ⟨ζ, μ, ArithmeticFunction.coe_zeta_mul_coe_moebius, ArithmeticFunction.coe_moebius_mul_coe_zeta⟩
+#align nat.arithmetic_function.zeta_unit ArithmeticFunction.zetaUnit
-/
-#print Nat.ArithmeticFunction.coe_zetaUnit /-
+#print ArithmeticFunction.coe_zetaUnit /-
@[simp]
-theorem coe_zetaUnit : ((zetaUnit : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = ζ :=
+theorem ArithmeticFunction.coe_zetaUnit :
+ ((ArithmeticFunction.zetaUnit : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = ζ :=
rfl
-#align nat.arithmetic_function.coe_zeta_unit Nat.ArithmeticFunction.coe_zetaUnit
+#align nat.arithmetic_function.coe_zeta_unit ArithmeticFunction.coe_zetaUnit
-/
-#print Nat.ArithmeticFunction.inv_zetaUnit /-
+#print ArithmeticFunction.inv_zetaUnit /-
@[simp]
-theorem inv_zetaUnit : ((zetaUnit⁻¹ : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = μ :=
+theorem ArithmeticFunction.inv_zetaUnit :
+ ((ArithmeticFunction.zetaUnit⁻¹ : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = μ :=
rfl
-#align nat.arithmetic_function.inv_zeta_unit Nat.ArithmeticFunction.inv_zetaUnit
+#align nat.arithmetic_function.inv_zeta_unit ArithmeticFunction.inv_zetaUnit
-/
end CommRing
-#print Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq /-
+#print ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq /-
/-- Möbius inversion for functions to an `add_comm_group`. -/
-theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
+theorem ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
(∀ n : ℕ, 0 < n → ∑ i in n.divisors, f i = g n) ↔
∀ n : ℕ, 0 < n → ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd = f n :=
by
@@ -1220,12 +1246,12 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', smul_apply, if_false, ZeroHom.coe_mk]
rw [sum_congr rfl fun x hx => _]
rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
-#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
+#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
-/
-#print Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq /-
+#print ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq /-
/-- Möbius inversion for functions to a `ring`. -/
-theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
+theorem ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
(∀ n : ℕ, 0 < n → ∑ i in n.divisors, f i = g n) ↔
∀ n : ℕ, 0 < n → ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd = f n :=
by
@@ -1233,22 +1259,22 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
apply forall_congr'
refine' fun a => imp_congr_right fun _ => (sum_congr rfl fun x hx => _).congr_left
rw [zsmul_eq_mul]
-#align nat.arithmetic_function.sum_eq_iff_sum_mul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq
+#align nat.arithmetic_function.sum_eq_iff_sum_mul_moebius_eq ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq
-/
-#print Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq /-
+#print ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq /-
/-- Möbius inversion for functions to a `comm_group`. -/
-theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
+theorem ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
(∀ n : ℕ, 0 < n → ∏ i in n.divisors, f i = g n) ↔
∀ n : ℕ, 0 < n → ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n :=
- @sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
-#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
+ @ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
+#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
-/
-#print Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero /-
+#print ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero /-
/-- Möbius inversion for functions to a `comm_group_with_zero`. -/
-theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
- (hf : ∀ n : ℕ, 0 < n → f n ≠ 0) (hg : ∀ n : ℕ, 0 < n → g n ≠ 0) :
+theorem ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R]
+ {f g : ℕ → R} (hf : ∀ n : ℕ, 0 < n → f n ≠ 0) (hg : ∀ n : ℕ, 0 < n → g n ≠ 0) :
(∀ n : ℕ, 0 < n → ∏ i in n.divisors, f i = g n) ↔
∀ n : ℕ, 0 < n → ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n :=
by
@@ -1269,7 +1295,7 @@ theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g :
intro x hx
rw [dif_pos (Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_antidiagonal hx)),
Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
-#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
+#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
-/
end SpecialFunctions
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -622,7 +622,13 @@ end MonoidWithZero
#print Nat.ArithmeticFunction.IsMultiplicative.map_prod /-
theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
- f (∏ i in s, g i) = ∏ i in s, f (g i) := by classical
+ f (∏ i in s, g i) = ∏ i in s, f (g i) := by
+ classical
+ induction' s using Finset.induction_on with a s has ih hs
+ · simp [hf]
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
+ rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
+ exact Nat.Coprime.prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -622,13 +622,7 @@ end MonoidWithZero
#print Nat.ArithmeticFunction.IsMultiplicative.map_prod /-
theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
- f (∏ i in s, g i) = ∏ i in s, f (g i) := by
- classical
- induction' s using Finset.induction_on with a s has ih hs
- · simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
- rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
- exact Nat.Coprime.prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
+ f (∏ i in s, g i) = ∏ i in s, f (g i) := by classical
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -1123,7 +1123,7 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 :=
· intro p n hp hn
rw [coe_mul_zeta_apply, sum_divisors_prime_pow hp, sum_range_succ']
simp_rw [Function.Embedding.coeFn_mk, pow_zero, moebius_apply_one,
- moebius_apply_prime_pow hp (Nat.succ_ne_zero _), Nat.succ_inj', sum_ite_eq', mem_range,
+ moebius_apply_prime_pow hp (Nat.succ_ne_zero _), Nat.succ_inj, sum_ite_eq', mem_range,
if_pos hn, add_left_neg]
rw [one_apply_ne]
rw [Ne.def, pow_eq_one_iff]
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -628,7 +628,7 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
· simp [hf]
rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
- exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
+ exact Nat.Coprime.prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -1108,7 +1108,7 @@ theorem isMultiplicative_moebius : IsMultiplicative μ :=
rw [is_multiplicative.iff_ne_zero]
refine' ⟨by simp, fun n m hn hm hnm => _⟩
simp only [moebius, ZeroHom.coe_mk, squarefree_mul hnm, ite_and, card_factors_mul hn hm]
- rw [pow_add, mul_comm, ite_mul_zero_left, ite_mul_zero_right, mul_comm]
+ rw [pow_add, mul_comm, ite_zero_mul, mul_ite_zero, mul_comm]
#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
-/
@@ -1261,13 +1261,11 @@ theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g :
(forall_congr' fun n => _) <;>
refine' imp_congr_right fun hn => _
· dsimp
- rw [dif_pos hn, ← Units.eq_iff, ← Units.coeHom_apply, MonoidHom.map_prod, Units.val_mk0,
- prod_congr rfl _]
+ rw [dif_pos hn, ← Units.eq_iff, ← Units.coeHom_apply, map_prod, Units.val_mk0, prod_congr rfl _]
intro x hx
rw [dif_pos (Nat.pos_of_mem_divisors hx), Units.coeHom_apply, Units.val_mk0]
· dsimp
- rw [dif_pos hn, ← Units.eq_iff, ← Units.coeHom_apply, MonoidHom.map_prod, Units.val_mk0,
- prod_congr rfl _]
+ rw [dif_pos hn, ← Units.eq_iff, ← Units.coeHom_apply, map_prod, Units.val_mk0, prod_congr rfl _]
intro x hx
rw [dif_pos (Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_antidiagonal hx)),
Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,13 +3,13 @@ Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
-import Mathbin.Algebra.BigOperators.Ring
-import Mathbin.Algebra.Module.BigOperators
-import Mathbin.NumberTheory.Divisors
-import Mathbin.Data.Nat.Squarefree
-import Mathbin.Data.Nat.Gcd.BigOperators
-import Mathbin.Algebra.Invertible
-import Mathbin.Data.Nat.Factorization.Basic
+import Algebra.BigOperators.Ring
+import Algebra.Module.BigOperators
+import NumberTheory.Divisors
+import Data.Nat.Squarefree
+import Data.Nat.Gcd.BigOperators
+import Algebra.Invertible
+import Data.Nat.Factorization.Basic
#align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -592,7 +592,7 @@ end Pmul
#print Nat.ArithmeticFunction.IsMultiplicative /-
/-- 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
+ f 1 = 1 ∧ ∀ {m n : ℕ}, m.Coprime n → f (m * n) = f m * f n
#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
-/
@@ -612,7 +612,7 @@ theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
#print Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime /-
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
- (h : m.coprime n) : f (m * n) = f m * f n :=
+ (h : m.Coprime n) : f (m * n) = f m * f n :=
hf.2 h
#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
-/
@@ -621,7 +621,7 @@ end MonoidWithZero
#print Nat.ArithmeticFunction.IsMultiplicative.map_prod /-
theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
- (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
+ (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
induction' s using Finset.induction_on with a s has ih hs
@@ -736,7 +736,7 @@ theorem multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunct
/-- 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 :=
+ 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)
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -418,7 +418,7 @@ instance {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] :
Module (ArithmeticFunction R) (ArithmeticFunction M)
where
one_smul := one_smul'
- mul_smul := mul_smul'
+ hMul_smul := mul_smul'
smul_add r x y := by ext; simp only [sum_add_distrib, smul_add, smul_apply, add_apply]
smul_zero r := by ext; simp only [smul_apply, sum_const_zero, smul_zero, zero_apply]
add_smul r s x := by ext; simp only [add_smul, sum_add_distrib, smul_apply, add_apply]
@@ -1166,8 +1166,8 @@ variable [CommRing R]
instance : Invertible (ζ : ArithmeticFunction R)
where
invOf := μ
- invOf_mul_self := coe_moebius_mul_coe_zeta
- mul_invOf_self := coe_zeta_mul_coe_moebius
+ invOf_hMul_self := coe_moebius_mul_coe_zeta
+ hMul_invOf_self := coe_zeta_mul_coe_moebius
#print Nat.ArithmeticFunction.zetaUnit /-
/-- A unit in `arithmetic_function R` that evaluates to `ζ`, with inverse `μ`. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/63721b2c3eba6c325ecf8ae8cca27155a4f6306f
@@ -703,7 +703,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one, one_mul]
· rintro ⟨b1, b2⟩ h
simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
- use ((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
+ use((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
simp only [exists_prop, Prod.mk.inj_iff, Ne.def, mem_product, mem_divisors_antidiagonal]
rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,11 +2,6 @@
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-
-! This file was ported from Lean 3 source module number_theory.arithmetic_function
-! leanprover-community/mathlib commit 61b5e2755ccb464b68d05a9acf891ae04992d09d
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Algebra.BigOperators.Ring
import Mathbin.Algebra.Module.BigOperators
@@ -16,6 +11,8 @@ import Mathbin.Data.Nat.Gcd.BigOperators
import Mathbin.Algebra.Invertible
import Mathbin.Data.Nat.Factorization.Basic
+#align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d"
+
/-!
# Arithmetic Functions and Dirichlet Convolution
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -133,9 +133,11 @@ variable [One R]
instance : One (ArithmeticFunction R) :=
⟨⟨fun x => ite (x = 1) 1 0, rfl⟩⟩
+#print Nat.ArithmeticFunction.one_apply /-
theorem one_apply {x : ℕ} : (1 : ArithmeticFunction R) x = ite (x = 1) 1 0 :=
rfl
#align nat.arithmetic_function.one_apply Nat.ArithmeticFunction.one_apply
+-/
#print Nat.ArithmeticFunction.one_one /-
@[simp]
@@ -144,18 +146,22 @@ theorem one_one : (1 : ArithmeticFunction R) 1 = 1 :=
#align nat.arithmetic_function.one_one Nat.ArithmeticFunction.one_one
-/
+#print Nat.ArithmeticFunction.one_apply_ne /-
@[simp]
theorem one_apply_ne {x : ℕ} (h : x ≠ 1) : (1 : ArithmeticFunction R) x = 0 :=
if_neg h
#align nat.arithmetic_function.one_apply_ne Nat.ArithmeticFunction.one_apply_ne
+-/
end One
end Zero
+#print Nat.ArithmeticFunction.natCoe /-
instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
⟨fun f => ⟨↑(f : ℕ → ℕ), by trans ↑(f 0); rfl; simp⟩⟩
#align nat.arithmetic_function.nat_coe Nat.ArithmeticFunction.natCoe
+-/
#print Nat.ArithmeticFunction.natCoe_nat /-
@[simp]
@@ -172,35 +178,47 @@ theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ}
#align nat.arithmetic_function.nat_coe_apply Nat.ArithmeticFunction.natCoe_apply
-/
+#print Nat.ArithmeticFunction.intCoe /-
instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
⟨fun f => ⟨↑(f : ℕ → ℤ), by trans ↑(f 0); rfl; simp⟩⟩
#align nat.arithmetic_function.int_coe Nat.ArithmeticFunction.intCoe
+-/
+#print Nat.ArithmeticFunction.intCoe_int /-
@[simp]
theorem intCoe_int (f : ArithmeticFunction ℤ) : (↑f : ArithmeticFunction ℤ) = f :=
ext fun _ => Int.cast_id _
#align nat.arithmetic_function.int_coe_int Nat.ArithmeticFunction.intCoe_int
+-/
+#print Nat.ArithmeticFunction.intCoe_apply /-
@[simp]
theorem intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x :=
rfl
#align nat.arithmetic_function.int_coe_apply Nat.ArithmeticFunction.intCoe_apply
+-/
+#print Nat.ArithmeticFunction.coe_coe /-
@[simp]
theorem coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} :
((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = f := by ext; simp
#align nat.arithmetic_function.coe_coe Nat.ArithmeticFunction.coe_coe
+-/
+#print Nat.ArithmeticFunction.natCoe_one /-
@[simp]
theorem natCoe_one [AddMonoidWithOne R] : ((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 :=
by ext n; simp [one_apply]
#align nat.arithmetic_function.nat_coe_one Nat.ArithmeticFunction.natCoe_one
+-/
+#print Nat.ArithmeticFunction.intCoe_one /-
@[simp]
theorem intCoe_one [AddGroupWithOne R] : ((1 : ArithmeticFunction ℤ) : ArithmeticFunction R) = 1 :=
by ext n; simp [one_apply]
#align nat.arithmetic_function.int_coe_one Nat.ArithmeticFunction.intCoe_one
+-/
section AddMonoid
@@ -209,10 +227,12 @@ variable [AddMonoid R]
instance : Add (ArithmeticFunction R) :=
⟨fun f g => ⟨fun n => f n + g n, by simp⟩⟩
+#print Nat.ArithmeticFunction.add_apply /-
@[simp]
theorem add_apply {f g : ArithmeticFunction R} {n : ℕ} : (f + g) n = f n + g n :=
rfl
#align nat.arithmetic_function.add_apply Nat.ArithmeticFunction.add_apply
+-/
instance : AddMonoid (ArithmeticFunction R) :=
{ ArithmeticFunction.hasZero R,
@@ -251,11 +271,13 @@ variable {M : Type _} [Zero R] [AddCommMonoid M] [SMul R M]
instance : SMul (ArithmeticFunction R) (ArithmeticFunction M) :=
⟨fun f g => ⟨fun n => ∑ x in divisorsAntidiagonal n, f x.fst • g x.snd, by simp⟩⟩
+#print Nat.ArithmeticFunction.smul_apply /-
@[simp]
theorem smul_apply {f : ArithmeticFunction R} {g : ArithmeticFunction M} {n : ℕ} :
(f • g) n = ∑ x in divisorsAntidiagonal n, f x.fst • g x.snd :=
rfl
#align nat.arithmetic_function.smul_apply Nat.ArithmeticFunction.smul_apply
+-/
end SMul
@@ -264,29 +286,38 @@ end SMul
instance [Semiring R] : Mul (ArithmeticFunction R) :=
⟨(· • ·)⟩
+#print Nat.ArithmeticFunction.mul_apply /-
@[simp]
theorem mul_apply [Semiring R] {f g : ArithmeticFunction R} {n : ℕ} :
(f * g) n = ∑ x in divisorsAntidiagonal n, f x.fst * g x.snd :=
rfl
#align nat.arithmetic_function.mul_apply Nat.ArithmeticFunction.mul_apply
+-/
+#print Nat.ArithmeticFunction.mul_apply_one /-
theorem mul_apply_one [Semiring R] {f g : ArithmeticFunction R} : (f * g) 1 = f 1 * g 1 := by simp
#align nat.arithmetic_function.mul_apply_one Nat.ArithmeticFunction.mul_apply_one
+-/
+#print Nat.ArithmeticFunction.natCoe_mul /-
@[simp, norm_cast]
theorem natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} :
(↑(f * g) : ArithmeticFunction R) = f * g := by ext n; simp
#align nat.arithmetic_function.nat_coe_mul Nat.ArithmeticFunction.natCoe_mul
+-/
+#print Nat.ArithmeticFunction.intCoe_mul /-
@[simp, norm_cast]
theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
(↑(f * g) : ArithmeticFunction R) = f * g := by ext n; simp
#align nat.arithmetic_function.int_coe_mul Nat.ArithmeticFunction.intCoe_mul
+-/
section Module
variable {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M]
+#print Nat.ArithmeticFunction.mul_smul' /-
theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
(f * g) • h = f • g • h := by
ext n
@@ -316,7 +347,9 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H ⊢
rw [H.2.1]
#align nat.arithmetic_function.mul_smul' Nat.ArithmeticFunction.mul_smul'
+-/
+#print Nat.ArithmeticFunction.one_smul' /-
theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b = b :=
by
ext
@@ -332,6 +365,7 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
tauto
simp [y1ne]
#align nat.arithmetic_function.one_smul' Nat.ArithmeticFunction.one_smul'
+-/
end Module
@@ -402,13 +436,14 @@ def zeta : ArithmeticFunction ℕ :=
#align nat.arithmetic_function.zeta Nat.ArithmeticFunction.zeta
-/
--- mathport name: arithmetic_function.zeta
scoped[ArithmeticFunction] notation "ζ" => Nat.ArithmeticFunction.zeta
+#print Nat.ArithmeticFunction.zeta_apply /-
@[simp]
theorem zeta_apply {x : ℕ} : ζ x = if x = 0 then 0 else 1 :=
rfl
#align nat.arithmetic_function.zeta_apply Nat.ArithmeticFunction.zeta_apply
+-/
#print Nat.ArithmeticFunction.zeta_apply_ne /-
theorem zeta_apply_ne {x : ℕ} (h : x ≠ 0) : ζ x = 1 :=
@@ -416,6 +451,7 @@ theorem zeta_apply_ne {x : ℕ} (h : x ≠ 0) : ζ x = 1 :=
#align nat.arithmetic_function.zeta_apply_ne Nat.ArithmeticFunction.zeta_apply_ne
-/
+#print Nat.ArithmeticFunction.coe_zeta_smul_apply /-
@[simp]
theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
{f : ArithmeticFunction M} {x : ℕ} :
@@ -428,13 +464,17 @@ theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
rw [nat_coe_apply, zeta_apply_ne (left_ne_zero_of_mul h), cast_one, one_smul]
· rw [← map_div_left_divisors, sum_map, Function.Embedding.coeFn_mk]
#align nat.arithmetic_function.coe_zeta_smul_apply Nat.ArithmeticFunction.coe_zeta_smul_apply
+-/
+#print Nat.ArithmeticFunction.coe_zeta_mul_apply /-
@[simp]
theorem coe_zeta_mul_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
(↑ζ * f) x = ∑ i in divisors x, f i :=
coe_zeta_smul_apply
#align nat.arithmetic_function.coe_zeta_mul_apply Nat.ArithmeticFunction.coe_zeta_mul_apply
+-/
+#print Nat.ArithmeticFunction.coe_mul_zeta_apply /-
@[simp]
theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
(f * ζ) x = ∑ i in divisors x, f i := by
@@ -445,14 +485,19 @@ theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
rw [nat_coe_apply, zeta_apply_ne (right_ne_zero_of_mul h), cast_one, mul_one]
· rw [← map_div_right_divisors, sum_map, Function.Embedding.coeFn_mk]
#align nat.arithmetic_function.coe_mul_zeta_apply Nat.ArithmeticFunction.coe_mul_zeta_apply
+-/
+#print Nat.ArithmeticFunction.zeta_mul_apply /-
theorem zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (ζ * f) x = ∑ i in divisors x, f i := by
rw [← nat_coe_nat ζ, coe_zeta_mul_apply]
#align nat.arithmetic_function.zeta_mul_apply Nat.ArithmeticFunction.zeta_mul_apply
+-/
+#print Nat.ArithmeticFunction.mul_zeta_apply /-
theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑ i in divisors x, f i := by
rw [← nat_coe_nat ζ, coe_mul_zeta_apply]
#align nat.arithmetic_function.mul_zeta_apply Nat.ArithmeticFunction.mul_zeta_apply
+-/
end Zeta
@@ -460,77 +505,99 @@ open scoped ArithmeticFunction
section Pmul
+#print Nat.ArithmeticFunction.pmul /-
/-- This is the pointwise product of `arithmetic_function`s. -/
def pmul [MulZeroClass R] (f g : ArithmeticFunction R) : ArithmeticFunction R :=
⟨fun x => f x * g x, by simp⟩
#align nat.arithmetic_function.pmul Nat.ArithmeticFunction.pmul
+-/
+#print Nat.ArithmeticFunction.pmul_apply /-
@[simp]
theorem pmul_apply [MulZeroClass R] {f g : ArithmeticFunction R} {x : ℕ} : f.pmul g x = f x * g x :=
rfl
#align nat.arithmetic_function.pmul_apply Nat.ArithmeticFunction.pmul_apply
+-/
+#print Nat.ArithmeticFunction.pmul_comm /-
theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g = g.pmul f := by
ext; simp [mul_comm]
#align nat.arithmetic_function.pmul_comm Nat.ArithmeticFunction.pmul_comm
+-/
section NonAssocSemiring
variable [NonAssocSemiring R]
+#print Nat.ArithmeticFunction.pmul_zeta /-
@[simp]
theorem pmul_zeta (f : ArithmeticFunction R) : f.pmul ↑ζ = f :=
by
ext x
cases x <;> simp [Nat.succ_ne_zero]
#align nat.arithmetic_function.pmul_zeta Nat.ArithmeticFunction.pmul_zeta
+-/
+#print Nat.ArithmeticFunction.zeta_pmul /-
@[simp]
theorem zeta_pmul (f : ArithmeticFunction R) : (ζ : ArithmeticFunction R).pmul f = f :=
by
ext x
cases x <;> simp [Nat.succ_ne_zero]
#align nat.arithmetic_function.zeta_pmul Nat.ArithmeticFunction.zeta_pmul
+-/
end NonAssocSemiring
variable [Semiring R]
+#print Nat.ArithmeticFunction.ppow /-
/-- This is the pointwise power of `arithmetic_function`s. -/
def ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
if h0 : k = 0 then ζ
else ⟨fun x => f x ^ k, by rw [map_zero]; exact zero_pow (Nat.pos_of_ne_zero h0)⟩
#align nat.arithmetic_function.ppow Nat.ArithmeticFunction.ppow
+-/
+#print Nat.ArithmeticFunction.ppow_zero /-
@[simp]
theorem ppow_zero {f : ArithmeticFunction R} : f.ppow 0 = ζ := by rw [ppow, dif_pos rfl]
#align nat.arithmetic_function.ppow_zero Nat.ArithmeticFunction.ppow_zero
+-/
+#print Nat.ArithmeticFunction.ppow_apply /-
@[simp]
theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppow k x = f x ^ k := by
rw [ppow, dif_neg (ne_of_gt kpos)]; rfl
#align nat.arithmetic_function.ppow_apply Nat.ArithmeticFunction.ppow_apply
+-/
+#print Nat.ArithmeticFunction.ppow_succ /-
theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) :=
by
ext x
rw [ppow_apply (Nat.succ_pos k), pow_succ]
induction k <;> simp
#align nat.arithmetic_function.ppow_succ Nat.ArithmeticFunction.ppow_succ
+-/
+#print Nat.ArithmeticFunction.ppow_succ' /-
theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
f.ppow (k + 1) = (f.ppow k).pmul f := by
ext x
rw [ppow_apply (Nat.succ_pos k), pow_succ']
induction k <;> simp
#align nat.arithmetic_function.ppow_succ' Nat.ArithmeticFunction.ppow_succ'
+-/
end Pmul
+#print Nat.ArithmeticFunction.IsMultiplicative /-
/-- 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
#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
+-/
namespace IsMultiplicative
@@ -538,19 +605,24 @@ section MonoidWithZero
variable [MonoidWithZero R]
+#print Nat.ArithmeticFunction.IsMultiplicative.map_one /-
@[simp]
theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
h.1
#align nat.arithmetic_function.is_multiplicative.map_one Nat.ArithmeticFunction.IsMultiplicative.map_one
+-/
+#print Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime /-
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
(h : m.coprime n) : f (m * n) = f m * f n :=
hf.2 h
#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
+-/
end MonoidWithZero
+#print Nat.ArithmeticFunction.IsMultiplicative.map_prod /-
theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
@@ -561,6 +633,7 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
+-/
#print Nat.ArithmeticFunction.IsMultiplicative.nat_cast /-
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
@@ -569,11 +642,14 @@ theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicati
#align nat.arithmetic_function.is_multiplicative.nat_cast Nat.ArithmeticFunction.IsMultiplicative.nat_cast
-/
+#print Nat.ArithmeticFunction.IsMultiplicative.int_cast /-
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun m n cop => by simp [cop, h]⟩
#align nat.arithmetic_function.is_multiplicative.int_cast Nat.ArithmeticFunction.IsMultiplicative.int_cast
+-/
+#print Nat.ArithmeticFunction.IsMultiplicative.mul /-
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f * g) :=
⟨by simp [hf, hg], by
@@ -637,7 +713,9 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
· rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h ; simp [h.2.1, h.2.2]
rw [mul_comm n m, h.1]⟩
#align nat.arithmetic_function.is_multiplicative.mul Nat.ArithmeticFunction.IsMultiplicative.mul
+-/
+#print Nat.ArithmeticFunction.IsMultiplicative.pmul /-
theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f.pmul g) :=
⟨by simp [hf, hg], fun m n cop =>
@@ -645,7 +723,9 @@ theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicat
simp only [pmul_apply, hf.map_mul_of_coprime cop, hg.map_mul_of_coprime cop]
ring⟩
#align nat.arithmetic_function.is_multiplicative.pmul Nat.ArithmeticFunction.IsMultiplicative.pmul
+-/
+#print Nat.ArithmeticFunction.IsMultiplicative.multiplicative_factorization /-
/-- 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)
@@ -653,7 +733,9 @@ theorem multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunct
f n = n.factorization.Prod fun p k => f (p ^ k) :=
multiplicative_factorization f (fun _ _ => hf.2) hf.1 hn
#align nat.arithmetic_function.is_multiplicative.multiplicative_factorization Nat.ArithmeticFunction.IsMultiplicative.multiplicative_factorization
+-/
+#print Nat.ArithmeticFunction.IsMultiplicative.iff_ne_zero /-
/-- A recapitulation of the definition of multiplicative that is simpler for proofs -/
theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
IsMultiplicative f ↔
@@ -666,7 +748,9 @@ theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
· simp
exact h hm hn hmn
#align nat.arithmetic_function.is_multiplicative.iff_ne_zero Nat.ArithmeticFunction.IsMultiplicative.iff_ne_zero
+-/
+#print Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers /-
/-- 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)
@@ -685,6 +769,7 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
intro p hp
exact h p _ (Nat.prime_of_mem_factors hp)
#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
+-/
end IsMultiplicative
@@ -711,6 +796,7 @@ def pow (k : ℕ) : ArithmeticFunction ℕ :=
#align nat.arithmetic_function.pow Nat.ArithmeticFunction.pow
-/
+#print Nat.ArithmeticFunction.pow_apply /-
@[simp]
theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :=
by
@@ -718,6 +804,7 @@ theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :
· simp [pow]
simp [pow, (ne_of_lt (Nat.succ_pos k)).symm]
#align nat.arithmetic_function.pow_apply Nat.ArithmeticFunction.pow_apply
+-/
#print Nat.ArithmeticFunction.pow_zero_eq_zeta /-
theorem pow_zero_eq_zeta : pow 0 = ζ := by ext n; simp
@@ -731,7 +818,6 @@ def sigma (k : ℕ) : ArithmeticFunction ℕ :=
#align nat.arithmetic_function.sigma Nat.ArithmeticFunction.sigma
-/
--- mathport name: arithmetic_function.sigma
scoped[ArithmeticFunction] notation "σ" => Nat.ArithmeticFunction.sigma
#print Nat.ArithmeticFunction.sigma_apply /-
@@ -756,6 +842,7 @@ theorem sigma_zero_apply_prime_pow {p i : ℕ} (hp : p.Prime) : σ 0 (p ^ i) = i
#align nat.arithmetic_function.sigma_zero_apply_prime_pow Nat.ArithmeticFunction.sigma_zero_apply_prime_pow
-/
+#print Nat.ArithmeticFunction.zeta_mul_pow_eq_sigma /-
theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k :=
by
ext
@@ -766,7 +853,9 @@ theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k :=
contrapose! hx
simp [hx]
#align nat.arithmetic_function.zeta_mul_pow_eq_sigma Nat.ArithmeticFunction.zeta_mul_pow_eq_sigma
+-/
+#print Nat.ArithmeticFunction.isMultiplicative_one /-
theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : ArithmeticFunction R) :=
IsMultiplicative.iff_ne_zero.2
⟨by simp, by
@@ -777,6 +866,7 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
rw [Ne.def, mul_eq_one, not_and_or]
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
+-/
#print Nat.ArithmeticFunction.isMultiplicative_zeta /-
theorem isMultiplicative_zeta : IsMultiplicative ζ :=
@@ -790,6 +880,7 @@ theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id :=
#align nat.arithmetic_function.is_multiplicative_id Nat.ArithmeticFunction.isMultiplicative_id
-/
+#print Nat.ArithmeticFunction.IsMultiplicative.ppow /-
theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
{k : ℕ} : IsMultiplicative (f.ppow k) :=
by
@@ -798,6 +889,7 @@ theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf :
· rw [ppow_succ]
apply hf.pmul hi
#align nat.arithmetic_function.is_multiplicative.ppow Nat.ArithmeticFunction.IsMultiplicative.ppow
+-/
#print Nat.ArithmeticFunction.isMultiplicative_pow /-
theorem isMultiplicative_pow {k : ℕ} : IsMultiplicative (pow k) :=
@@ -820,7 +912,6 @@ def cardFactors : ArithmeticFunction ℕ :=
#align nat.arithmetic_function.card_factors Nat.ArithmeticFunction.cardFactors
-/
--- mathport name: card_factors
scoped[ArithmeticFunction] notation "Ω" => Nat.ArithmeticFunction.cardFactors
#print Nat.ArithmeticFunction.cardFactors_apply /-
@@ -889,7 +980,6 @@ def cardDistinctFactors : ArithmeticFunction ℕ :=
#align nat.arithmetic_function.card_distinct_factors Nat.ArithmeticFunction.cardDistinctFactors
-/
--- mathport name: card_distinct_factors
scoped[ArithmeticFunction] notation "ω" => Nat.ArithmeticFunction.cardDistinctFactors
#print Nat.ArithmeticFunction.cardDistinctFactors_zero /-
@@ -903,9 +993,11 @@ theorem cardDistinctFactors_one : ω 1 = 0 := by simp [card_distinct_factors]
#align nat.arithmetic_function.card_distinct_factors_one Nat.ArithmeticFunction.cardDistinctFactors_one
-/
+#print Nat.ArithmeticFunction.cardDistinctFactors_apply /-
theorem cardDistinctFactors_apply {n : ℕ} : ω n = n.factors.dedup.length :=
rfl
#align nat.arithmetic_function.card_distinct_factors_apply Nat.ArithmeticFunction.cardDistinctFactors_apply
+-/
#print Nat.ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree /-
theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠ 0) :
@@ -944,13 +1036,14 @@ def moebius : ArithmeticFunction ℤ :=
#align nat.arithmetic_function.moebius Nat.ArithmeticFunction.moebius
-/
--- mathport name: moebius
scoped[ArithmeticFunction] notation "μ" => Nat.ArithmeticFunction.moebius
+#print Nat.ArithmeticFunction.moebius_apply_of_squarefree /-
@[simp]
theorem moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) : μ n = (-1) ^ cardFactors n :=
if_pos h
#align nat.arithmetic_function.moebius_apply_of_squarefree Nat.ArithmeticFunction.moebius_apply_of_squarefree
+-/
#print Nat.ArithmeticFunction.moebius_eq_zero_of_not_squarefree /-
@[simp]
@@ -991,6 +1084,7 @@ theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
#align nat.arithmetic_function.moebius_apply_prime Nat.ArithmeticFunction.moebius_apply_prime
-/
+#print Nat.ArithmeticFunction.moebius_apply_prime_pow /-
theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
μ (p ^ k) = if k = 1 then -1 else 0 := by
split_ifs
@@ -999,6 +1093,7 @@ theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
rw [squarefree_pow_iff hp.ne_one hk, not_and_or]
exact Or.inr h
#align nat.arithmetic_function.moebius_apply_prime_pow Nat.ArithmeticFunction.moebius_apply_prime_pow
+-/
#print Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime /-
theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' : ¬n.Prime) : μ n = 0 :=
@@ -1010,6 +1105,7 @@ theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' :
#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime
-/
+#print Nat.ArithmeticFunction.isMultiplicative_moebius /-
theorem isMultiplicative_moebius : IsMultiplicative μ :=
by
rw [is_multiplicative.iff_ne_zero]
@@ -1017,9 +1113,11 @@ theorem isMultiplicative_moebius : IsMultiplicative μ :=
simp only [moebius, ZeroHom.coe_mk, squarefree_mul hnm, ite_and, card_factors_mul hn hm]
rw [pow_add, mul_comm, ite_mul_zero_left, ite_mul_zero_right, mul_comm]
#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
+-/
open UniqueFactorizationMonoid
+#print Nat.ArithmeticFunction.moebius_mul_coe_zeta /-
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 :=
by
@@ -1041,21 +1139,28 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 :=
is_multiplicative.map_mul_of_coprime is_multiplicative_one hab]
exact is_multiplicative_moebius.mul is_multiplicative_zeta.nat_cast
#align nat.arithmetic_function.moebius_mul_coe_zeta Nat.ArithmeticFunction.moebius_mul_coe_zeta
+-/
+#print Nat.ArithmeticFunction.coe_zeta_mul_moebius /-
@[simp]
theorem coe_zeta_mul_moebius : (ζ * μ : ArithmeticFunction ℤ) = 1 := by
rw [mul_comm, moebius_mul_coe_zeta]
#align nat.arithmetic_function.coe_zeta_mul_moebius Nat.ArithmeticFunction.coe_zeta_mul_moebius
+-/
+#print Nat.ArithmeticFunction.coe_moebius_mul_coe_zeta /-
@[simp]
theorem coe_moebius_mul_coe_zeta [Ring R] : (μ * ζ : ArithmeticFunction R) = 1 := by
rw [← coe_coe, ← int_coe_mul, moebius_mul_coe_zeta, int_coe_one]
#align nat.arithmetic_function.coe_moebius_mul_coe_zeta Nat.ArithmeticFunction.coe_moebius_mul_coe_zeta
+-/
+#print Nat.ArithmeticFunction.coe_zeta_mul_coe_moebius /-
@[simp]
theorem coe_zeta_mul_coe_moebius [Ring R] : (ζ * μ : ArithmeticFunction R) = 1 := by
rw [← coe_coe, ← int_coe_mul, coe_zeta_mul_moebius, int_coe_one]
#align nat.arithmetic_function.coe_zeta_mul_coe_moebius Nat.ArithmeticFunction.coe_zeta_mul_coe_moebius
+-/
section CommRing
@@ -1067,20 +1172,26 @@ instance : Invertible (ζ : ArithmeticFunction R)
invOf_mul_self := coe_moebius_mul_coe_zeta
mul_invOf_self := coe_zeta_mul_coe_moebius
+#print Nat.ArithmeticFunction.zetaUnit /-
/-- A unit in `arithmetic_function R` that evaluates to `ζ`, with inverse `μ`. -/
def zetaUnit : (ArithmeticFunction R)ˣ :=
⟨ζ, μ, coe_zeta_mul_coe_moebius, coe_moebius_mul_coe_zeta⟩
#align nat.arithmetic_function.zeta_unit Nat.ArithmeticFunction.zetaUnit
+-/
+#print Nat.ArithmeticFunction.coe_zetaUnit /-
@[simp]
theorem coe_zetaUnit : ((zetaUnit : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = ζ :=
rfl
#align nat.arithmetic_function.coe_zeta_unit Nat.ArithmeticFunction.coe_zetaUnit
+-/
+#print Nat.ArithmeticFunction.inv_zetaUnit /-
@[simp]
theorem inv_zetaUnit : ((zetaUnit⁻¹ : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = μ :=
rfl
#align nat.arithmetic_function.inv_zeta_unit Nat.ArithmeticFunction.inv_zetaUnit
+-/
end CommRing
@@ -1115,6 +1226,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
-/
+#print Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq /-
/-- Möbius inversion for functions to a `ring`. -/
theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
(∀ n : ℕ, 0 < n → ∑ i in n.divisors, f i = g n) ↔
@@ -1125,6 +1237,7 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
refine' fun a => imp_congr_right fun _ => (sum_congr rfl fun x hx => _).congr_left
rw [zsmul_eq_mul]
#align nat.arithmetic_function.sum_eq_iff_sum_mul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq
+-/
#print Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq /-
/-- Möbius inversion for functions to a `comm_group`. -/
@@ -1135,6 +1248,7 @@ theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
-/
+#print Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero /-
/-- Möbius inversion for functions to a `comm_group_with_zero`. -/
theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
(hf : ∀ n : ℕ, 0 < n → f n ≠ 0) (hg : ∀ n : ℕ, 0 < n → g n ≠ 0) :
@@ -1161,6 +1275,7 @@ theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g :
rw [dif_pos (Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_antidiagonal hx)),
Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
+-/
end SpecialFunctions
mathlib commit https://github.com/leanprover-community/mathlib/commit/a3e83f0fa4391c8740f7d773a7a9b74e311ae2a3
@@ -1087,8 +1087,8 @@ end CommRing
#print Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq /-
/-- Möbius inversion for functions to an `add_comm_group`. -/
theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
- (∀ n : ℕ, 0 < n → (∑ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd) = f n :=
+ (∀ n : ℕ, 0 < n → ∑ i in n.divisors, f i = g n) ↔
+ ∀ n : ℕ, 0 < n → ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd = f n :=
by
let f' : arithmetic_function R := ⟨fun x => if x = 0 then 0 else f x, if_pos rfl⟩
let g' : arithmetic_function R := ⟨fun x => if x = 0 then 0 else g x, if_pos rfl⟩
@@ -1117,8 +1117,8 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
/-- Möbius inversion for functions to a `ring`. -/
theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
- (∀ n : ℕ, 0 < n → (∑ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd) = f n :=
+ (∀ n : ℕ, 0 < n → ∑ i in n.divisors, f i = g n) ↔
+ ∀ n : ℕ, 0 < n → ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd = f n :=
by
rw [sum_eq_iff_sum_smul_moebius_eq]
apply forall_congr'
@@ -1129,8 +1129,8 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
#print Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq /-
/-- Möbius inversion for functions to a `comm_group`. -/
theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
- (∀ n : ℕ, 0 < n → (∏ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
+ (∀ n : ℕ, 0 < n → ∏ i in n.divisors, f i = g n) ↔
+ ∀ n : ℕ, 0 < n → ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n :=
@sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
-/
@@ -1138,8 +1138,8 @@ theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
/-- Möbius inversion for functions to a `comm_group_with_zero`. -/
theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
(hf : ∀ n : ℕ, 0 < n → f n ≠ 0) (hg : ∀ n : ℕ, 0 < n → g n ≠ 0) :
- (∀ n : ℕ, 0 < n → (∏ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
+ (∀ n : ℕ, 0 < n → ∏ i in n.divisors, f i = g n) ↔
+ ∀ n : ℕ, 0 < n → ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n :=
by
refine'
Iff.trans
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -555,11 +555,11 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
- induction' s using Finset.induction_on with a s has ih hs
- · simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
- rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
- exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
+ induction' s using Finset.induction_on with a s has ih hs
+ · simp [hf]
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
+ rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
+ exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
#print Nat.ArithmeticFunction.IsMultiplicative.nat_cast /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -70,7 +70,8 @@ variable (R : Type _)
often instead defined as functions from `ℕ+`. Multiplication on `arithmetic_functions` is by
Dirichlet convolution. -/
def ArithmeticFunction [Zero R] :=
- ZeroHom ℕ R deriving Zero, Inhabited
+ ZeroHom ℕ R
+deriving Zero, Inhabited
#align nat.arithmetic_function Nat.ArithmeticFunction
-/
@@ -294,7 +295,7 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
pick_goal 5
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H; exact ⟨(k, l * j), (l, j)⟩
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- simp only [Finset.mem_sigma, mem_divisors_antidiagonal] at H⊢
+ simp only [Finset.mem_sigma, mem_divisors_antidiagonal] at H ⊢
rcases H with ⟨⟨rfl, n0⟩, rfl, i0⟩
refine' ⟨⟨(mul_assoc _ _ _).symm, n0⟩, rfl, _⟩
rw [mul_ne_zero_iff] at *
@@ -302,17 +303,17 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H; simp only [mul_assoc]
· rintro ⟨⟨a, b⟩, ⟨c, d⟩⟩ ⟨⟨i, j⟩, ⟨k, l⟩⟩ H₁ H₂
simp only [Finset.mem_sigma, mem_divisors_antidiagonal, and_imp, Prod.mk.inj_iff, add_comm,
- heq_iff_eq] at H₁ H₂⊢
+ heq_iff_eq] at H₁ H₂ ⊢
rintro rfl h2 rfl rfl
exact ⟨⟨Eq.trans H₁.2.1.symm H₂.2.1, rfl⟩, rfl, rfl⟩
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H; refine' ⟨⟨(i * k, l), (i, k)⟩, _, _⟩
- · simp only [Finset.mem_sigma, mem_divisors_antidiagonal] at H⊢
+ · simp only [Finset.mem_sigma, mem_divisors_antidiagonal] at H ⊢
rcases H with ⟨⟨rfl, n0⟩, rfl, j0⟩
refine' ⟨⟨mul_assoc _ _ _, n0⟩, rfl, _⟩
rw [mul_ne_zero_iff] at *
exact ⟨n0.1, j0.1⟩
· simp only [true_and_iff, mem_divisors_antidiagonal, and_true_iff, Prod.mk.inj_iff,
- eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H⊢
+ eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H ⊢
rw [H.2.1]
#align nat.arithmetic_function.mul_smul' Nat.ArithmeticFunction.mul_smul'
@@ -326,8 +327,8 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
intro y ymem ynmem
have y1ne : y.fst ≠ 1 := by
intro con
- simp only [Con, mem_divisors_antidiagonal, one_mul, Ne.def] at ymem
- simp only [mem_singleton, Prod.ext_iff] at ynmem
+ simp only [Con, mem_divisors_antidiagonal, one_mul, Ne.def] at ymem
+ simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y1ne]
#align nat.arithmetic_function.one_smul' Nat.ArithmeticFunction.one_smul'
@@ -351,8 +352,8 @@ instance : Monoid (ArithmeticFunction R) :=
intro y ymem ynmem
have y2ne : y.snd ≠ 1 := by
intro con
- simp only [Con, mem_divisors_antidiagonal, mul_one, Ne.def] at ymem
- simp only [mem_singleton, Prod.ext_iff] at ynmem
+ simp only [Con, mem_divisors_antidiagonal, mul_one, Ne.def] at ymem
+ simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y2ne]
mul_assoc := mul_smul' }
@@ -556,7 +557,7 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
classical
induction' s using Finset.induction_on with a s has ih hs
· simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
@@ -582,58 +583,58 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
symm
apply sum_bij fun (x : (ℕ × ℕ) × ℕ × ℕ) h => (x.1.1 * x.2.1, x.1.2 * x.2.2)
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
simp only [mem_divisors_antidiagonal, Nat.mul_eq_zero, Ne.def]
constructor; · ring
rw [Nat.mul_eq_zero] at *
apply not_or_of_not ha hb
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
dsimp only
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
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨c1, c2⟩, ⟨d1, d2⟩⟩ hab hcd h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hab
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hab
rcases hab with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hcd
- simp only [Prod.mk.inj_iff] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at hcd
+ simp only [Prod.mk.inj_iff] at h
ext <;> dsimp only
· trans Nat.gcd (a1 * a2) (a1 * b1)
· rw [Nat.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, ← hcd.2.1] at cop
rw [← hcd.1.1, h.1, Nat.gcd_mul_left,
cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one, mul_one]
· trans Nat.gcd (a1 * a2) (a2 * b2)
·
rw [mul_comm, Nat.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, ← hcd.2.1] at cop
rw [← hcd.1.1, h.2, mul_comm, Nat.gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one, mul_one]
· trans Nat.gcd (b1 * b2) (a1 * b1)
·
rw [mul_comm, Nat.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.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.1, mul_comm c1 d1, Nat.gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one, mul_one]
· trans Nat.gcd (b1 * b2) (a2 * b2)
·
rw [Nat.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.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.2, Nat.gcd_mul_right,
cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one, one_mul]
· rintro ⟨b1, b2⟩ h
- simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
use ((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
simp only [exists_prop, Prod.mk.inj_iff, Ne.def, mem_product, mem_divisors_antidiagonal]
rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
- · rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h; simp [h.2.1, h.2.2]
+ · rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h ; simp [h.2.1, h.2.2]
rw [mul_comm n m, h.1]⟩
#align nat.arithmetic_function.is_multiplicative.mul Nat.ArithmeticFunction.IsMultiplicative.mul
@@ -862,7 +863,7 @@ theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.Prod ≠ 0) :
revert h0
apply s.induction_on; · simp
intro a t h h0
- rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
+ rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
simp [h0, card_factors_mul, h]
#align nat.arithmetic_function.card_factors_multiset_prod Nat.ArithmeticFunction.cardFactors_multiset_prod
-/
@@ -977,7 +978,7 @@ theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n :
theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 :=
by
constructor <;> intro h
- · rw [moebius_ne_zero_iff_squarefree] at h
+ · rw [moebius_ne_zero_iff_squarefree] at h
rw [moebius_apply_of_squarefree h]
apply neg_one_pow_eq_or
· rcases h with (h | h) <;> simp [h]
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
! This file was ported from Lean 3 source module number_theory.arithmetic_function
-! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
+! leanprover-community/mathlib commit 61b5e2755ccb464b68d05a9acf891ae04992d09d
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -19,6 +19,9 @@ import Mathbin.Data.Nat.Factorization.Basic
/-!
# Arithmetic Functions and Dirichlet Convolution
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
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,
@@ -62,12 +65,14 @@ namespace Nat
variable (R : Type _)
+#print Nat.ArithmeticFunction /-
/-- 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 `arithmetic_functions` is by
Dirichlet convolution. -/
def ArithmeticFunction [Zero R] :=
ZeroHom ℕ R deriving Zero, Inhabited
#align nat.arithmetic_function Nat.ArithmeticFunction
+-/
variable {R}
@@ -80,33 +85,45 @@ variable [Zero R]
instance : CoeFun (ArithmeticFunction R) fun _ => ℕ → R :=
ZeroHom.hasCoeToFun
+#print Nat.ArithmeticFunction.toFun_eq /-
@[simp]
theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f :=
rfl
#align nat.arithmetic_function.to_fun_eq Nat.ArithmeticFunction.toFun_eq
+-/
+#print Nat.ArithmeticFunction.map_zero /-
@[simp]
theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
ZeroHom.map_zero' f
#align nat.arithmetic_function.map_zero Nat.ArithmeticFunction.map_zero
+-/
+#print Nat.ArithmeticFunction.coe_inj /-
theorem coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g :=
⟨fun h => ZeroHom.coe_inj h, fun h => h ▸ rfl⟩
#align nat.arithmetic_function.coe_inj Nat.ArithmeticFunction.coe_inj
+-/
+#print Nat.ArithmeticFunction.zero_apply /-
@[simp]
theorem zero_apply {x : ℕ} : (0 : ArithmeticFunction R) x = 0 :=
ZeroHom.zero_apply x
#align nat.arithmetic_function.zero_apply Nat.ArithmeticFunction.zero_apply
+-/
+#print Nat.ArithmeticFunction.ext /-
@[ext]
theorem ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g :=
ZeroHom.ext h
#align nat.arithmetic_function.ext Nat.ArithmeticFunction.ext
+-/
+#print Nat.ArithmeticFunction.ext_iff /-
theorem ext_iff {f g : ArithmeticFunction R} : f = g ↔ ∀ x, f x = g x :=
ZeroHom.ext_iff
#align nat.arithmetic_function.ext_iff Nat.ArithmeticFunction.ext_iff
+-/
section One
@@ -119,10 +136,12 @@ theorem one_apply {x : ℕ} : (1 : ArithmeticFunction R) x = ite (x = 1) 1 0 :=
rfl
#align nat.arithmetic_function.one_apply Nat.ArithmeticFunction.one_apply
+#print Nat.ArithmeticFunction.one_one /-
@[simp]
theorem one_one : (1 : ArithmeticFunction R) 1 = 1 :=
rfl
#align nat.arithmetic_function.one_one Nat.ArithmeticFunction.one_one
+-/
@[simp]
theorem one_apply_ne {x : ℕ} (h : x ≠ 1) : (1 : ArithmeticFunction R) x = 0 :=
@@ -137,16 +156,20 @@ instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticF
⟨fun f => ⟨↑(f : ℕ → ℕ), by trans ↑(f 0); rfl; simp⟩⟩
#align nat.arithmetic_function.nat_coe Nat.ArithmeticFunction.natCoe
+#print Nat.ArithmeticFunction.natCoe_nat /-
@[simp]
theorem natCoe_nat (f : ArithmeticFunction ℕ) : (↑f : ArithmeticFunction ℕ) = f :=
ext fun _ => cast_id _
#align nat.arithmetic_function.nat_coe_nat Nat.ArithmeticFunction.natCoe_nat
+-/
+#print Nat.ArithmeticFunction.natCoe_apply /-
@[simp]
theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x :=
rfl
#align nat.arithmetic_function.nat_coe_apply Nat.ArithmeticFunction.natCoe_apply
+-/
instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
⟨fun f => ⟨↑(f : ℕ → ℤ), by trans ↑(f 0); rfl; simp⟩⟩
@@ -200,18 +223,18 @@ instance : AddMonoid (ArithmeticFunction R) :=
end AddMonoid
instance [AddMonoidWithOne R] : AddMonoidWithOne (ArithmeticFunction R) :=
- { ArithmeticFunction.addMonoid,
+ { ArithmeticFunction.instAddMonoid,
ArithmeticFunction.hasOne with
natCast := fun n => ⟨fun x => if x = 1 then (n : R) else 0, by simp⟩
natCast_zero := by ext <;> simp [Nat.cast]
natCast_succ := fun _ => by ext <;> by_cases x = 1 <;> simp [Nat.cast, *] }
instance [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) :=
- { ArithmeticFunction.addMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ }
+ { ArithmeticFunction.instAddMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ }
instance [AddGroup R] : AddGroup (ArithmeticFunction R) :=
{
- ArithmeticFunction.addMonoid with
+ ArithmeticFunction.instAddMonoid with
neg := fun f => ⟨fun n => -f n, by simp⟩
add_left_neg := fun _ => ext fun _ => add_left_neg _ }
@@ -336,8 +359,8 @@ instance : Monoid (ArithmeticFunction R) :=
instance : Semiring (ArithmeticFunction R) :=
{ ArithmeticFunction.hasZero R, ArithmeticFunction.hasMul, ArithmeticFunction.hasAdd,
- ArithmeticFunction.addCommMonoid, ArithmeticFunction.addMonoidWithOne,
- ArithmeticFunction.monoid with
+ ArithmeticFunction.addCommMonoid, ArithmeticFunction.instAddMonoidWithOne,
+ ArithmeticFunction.instMonoid with
zero_mul := fun f => by ext;
simp only [mul_apply, MulZeroClass.zero_mul, sum_const_zero, zero_apply]
mul_zero := fun f => by ext;
@@ -350,7 +373,7 @@ instance : Semiring (ArithmeticFunction R) :=
end Semiring
instance [CommSemiring R] : CommSemiring (ArithmeticFunction R) :=
- { ArithmeticFunction.semiring with
+ { ArithmeticFunction.instSemiring with
mul_comm := fun f g => by
ext
rw [mul_apply, ← map_swap_divisors_antidiagonal, sum_map]
@@ -371,10 +394,12 @@ instance {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] :
section Zeta
+#print Nat.ArithmeticFunction.zeta /-
/-- `ζ 0 = 0`, otherwise `ζ x = 1`. The Dirichlet Series is the Riemann ζ. -/
def zeta : ArithmeticFunction ℕ :=
⟨fun x => ite (x = 0) 0 1, rfl⟩
#align nat.arithmetic_function.zeta Nat.ArithmeticFunction.zeta
+-/
-- mathport name: arithmetic_function.zeta
scoped[ArithmeticFunction] notation "ζ" => Nat.ArithmeticFunction.zeta
@@ -384,9 +409,11 @@ theorem zeta_apply {x : ℕ} : ζ x = if x = 0 then 0 else 1 :=
rfl
#align nat.arithmetic_function.zeta_apply Nat.ArithmeticFunction.zeta_apply
+#print Nat.ArithmeticFunction.zeta_apply_ne /-
theorem zeta_apply_ne {x : ℕ} (h : x ≠ 0) : ζ x = 1 :=
if_neg h
#align nat.arithmetic_function.zeta_apply_ne Nat.ArithmeticFunction.zeta_apply_ne
+-/
@[simp]
theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
@@ -534,10 +561,12 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
+#print Nat.ArithmeticFunction.IsMultiplicative.nat_cast /-
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
⟨by simp [h], fun m n cop => by simp [cop, h]⟩
#align nat.arithmetic_function.is_multiplicative.nat_cast Nat.ArithmeticFunction.IsMultiplicative.nat_cast
+-/
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
@@ -660,20 +689,26 @@ end IsMultiplicative
section SpecialFunctions
+#print Nat.ArithmeticFunction.id /-
/-- The identity on `ℕ` as an `arithmetic_function`. -/
def id : ArithmeticFunction ℕ :=
⟨id, rfl⟩
#align nat.arithmetic_function.id Nat.ArithmeticFunction.id
+-/
+#print Nat.ArithmeticFunction.id_apply /-
@[simp]
theorem id_apply {x : ℕ} : id x = x :=
rfl
#align nat.arithmetic_function.id_apply Nat.ArithmeticFunction.id_apply
+-/
+#print Nat.ArithmeticFunction.pow /-
/-- `pow k n = n ^ k`, except `pow 0 0 = 0`. -/
def pow (k : ℕ) : ArithmeticFunction ℕ :=
id.ppow k
#align nat.arithmetic_function.pow Nat.ArithmeticFunction.pow
+-/
@[simp]
theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :=
@@ -683,30 +718,42 @@ theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :
simp [pow, (ne_of_lt (Nat.succ_pos k)).symm]
#align nat.arithmetic_function.pow_apply Nat.ArithmeticFunction.pow_apply
+#print Nat.ArithmeticFunction.pow_zero_eq_zeta /-
theorem pow_zero_eq_zeta : pow 0 = ζ := by ext n; simp
#align nat.arithmetic_function.pow_zero_eq_zeta Nat.ArithmeticFunction.pow_zero_eq_zeta
+-/
+#print Nat.ArithmeticFunction.sigma /-
/-- `σ k n` is the sum of the `k`th powers of the divisors of `n` -/
def sigma (k : ℕ) : ArithmeticFunction ℕ :=
⟨fun n => ∑ d in divisors n, d ^ k, by simp⟩
#align nat.arithmetic_function.sigma Nat.ArithmeticFunction.sigma
+-/
-- mathport name: arithmetic_function.sigma
scoped[ArithmeticFunction] notation "σ" => Nat.ArithmeticFunction.sigma
+#print Nat.ArithmeticFunction.sigma_apply /-
theorem sigma_apply {k n : ℕ} : σ k n = ∑ d in divisors n, d ^ k :=
rfl
#align nat.arithmetic_function.sigma_apply Nat.ArithmeticFunction.sigma_apply
+-/
+#print Nat.ArithmeticFunction.sigma_one_apply /-
theorem sigma_one_apply (n : ℕ) : σ 1 n = ∑ d in divisors n, d := by simp [sigma_apply]
#align nat.arithmetic_function.sigma_one_apply Nat.ArithmeticFunction.sigma_one_apply
+-/
+#print Nat.ArithmeticFunction.sigma_zero_apply /-
theorem sigma_zero_apply (n : ℕ) : σ 0 n = (divisors n).card := by simp [sigma_apply]
#align nat.arithmetic_function.sigma_zero_apply Nat.ArithmeticFunction.sigma_zero_apply
+-/
+#print Nat.ArithmeticFunction.sigma_zero_apply_prime_pow /-
theorem sigma_zero_apply_prime_pow {p i : ℕ} (hp : p.Prime) : σ 0 (p ^ i) = i + 1 := by
rw [sigma_zero_apply, divisors_prime_pow hp, card_map, card_range]
#align nat.arithmetic_function.sigma_zero_apply_prime_pow Nat.ArithmeticFunction.sigma_zero_apply_prime_pow
+-/
theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k :=
by
@@ -730,13 +777,17 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
+#print Nat.ArithmeticFunction.isMultiplicative_zeta /-
theorem isMultiplicative_zeta : IsMultiplicative ζ :=
IsMultiplicative.iff_ne_zero.2 ⟨by simp, by simp (config := { contextual := true })⟩
#align nat.arithmetic_function.is_multiplicative_zeta Nat.ArithmeticFunction.isMultiplicative_zeta
+-/
+#print Nat.ArithmeticFunction.isMultiplicative_id /-
theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id :=
⟨rfl, fun _ _ _ => rfl⟩
#align nat.arithmetic_function.is_multiplicative_id Nat.ArithmeticFunction.isMultiplicative_id
+-/
theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
{k : ℕ} : IsMultiplicative (f.ppow k) :=
@@ -747,32 +798,43 @@ theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf :
apply hf.pmul hi
#align nat.arithmetic_function.is_multiplicative.ppow Nat.ArithmeticFunction.IsMultiplicative.ppow
+#print Nat.ArithmeticFunction.isMultiplicative_pow /-
theorem isMultiplicative_pow {k : ℕ} : IsMultiplicative (pow k) :=
isMultiplicative_id.ppow
#align nat.arithmetic_function.is_multiplicative_pow Nat.ArithmeticFunction.isMultiplicative_pow
+-/
+#print Nat.ArithmeticFunction.isMultiplicative_sigma /-
theorem isMultiplicative_sigma {k : ℕ} : IsMultiplicative (σ k) :=
by
rw [← zeta_mul_pow_eq_sigma]
apply is_multiplicative_zeta.mul is_multiplicative_pow
#align nat.arithmetic_function.is_multiplicative_sigma Nat.ArithmeticFunction.isMultiplicative_sigma
+-/
+#print Nat.ArithmeticFunction.cardFactors /-
/-- `Ω n` is the number of prime factors of `n`. -/
def cardFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.length, by simp⟩
#align nat.arithmetic_function.card_factors Nat.ArithmeticFunction.cardFactors
+-/
-- mathport name: card_factors
scoped[ArithmeticFunction] notation "Ω" => Nat.ArithmeticFunction.cardFactors
+#print Nat.ArithmeticFunction.cardFactors_apply /-
theorem cardFactors_apply {n : ℕ} : Ω n = n.factors.length :=
rfl
#align nat.arithmetic_function.card_factors_apply Nat.ArithmeticFunction.cardFactors_apply
+-/
+#print Nat.ArithmeticFunction.cardFactors_one /-
@[simp]
theorem cardFactors_one : Ω 1 = 0 := by simp [card_factors]
#align nat.arithmetic_function.card_factors_one Nat.ArithmeticFunction.cardFactors_one
+-/
+#print Nat.ArithmeticFunction.cardFactors_eq_one_iff_prime /-
theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime :=
by
refine' ⟨fun h => _, fun h => List.length_eq_one.2 ⟨n, factors_prime h⟩⟩
@@ -784,13 +846,17 @@ theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime :=
apply prime_of_mem_factors
rw [hx, List.mem_singleton]
#align nat.arithmetic_function.card_factors_eq_one_iff_prime Nat.ArithmeticFunction.cardFactors_eq_one_iff_prime
+-/
+#print Nat.ArithmeticFunction.cardFactors_mul /-
theorem cardFactors_mul {m n : ℕ} (m0 : m ≠ 0) (n0 : n ≠ 0) : Ω (m * n) = Ω m + Ω n := by
rw [card_factors_apply, card_factors_apply, card_factors_apply, ← Multiset.coe_card, ← factors_eq,
UniqueFactorizationMonoid.normalizedFactors_mul m0 n0, factors_eq, factors_eq,
Multiset.card_add, Multiset.coe_card, Multiset.coe_card]
#align nat.arithmetic_function.card_factors_mul Nat.ArithmeticFunction.cardFactors_mul
+-/
+#print Nat.ArithmeticFunction.cardFactors_multiset_prod /-
theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.Prod ≠ 0) :
Ω s.Prod = (Multiset.map Ω s).Sum := by
revert h0
@@ -799,36 +865,48 @@ theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.Prod ≠ 0) :
rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
simp [h0, card_factors_mul, h]
#align nat.arithmetic_function.card_factors_multiset_prod Nat.ArithmeticFunction.cardFactors_multiset_prod
+-/
+#print Nat.ArithmeticFunction.cardFactors_apply_prime /-
@[simp]
theorem cardFactors_apply_prime {p : ℕ} (hp : p.Prime) : Ω p = 1 :=
cardFactors_eq_one_iff_prime.2 hp
#align nat.arithmetic_function.card_factors_apply_prime Nat.ArithmeticFunction.cardFactors_apply_prime
+-/
+#print Nat.ArithmeticFunction.cardFactors_apply_prime_pow /-
@[simp]
theorem cardFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) : Ω (p ^ k) = k := by
rw [card_factors_apply, hp.factors_pow, List.length_replicate]
#align nat.arithmetic_function.card_factors_apply_prime_pow Nat.ArithmeticFunction.cardFactors_apply_prime_pow
+-/
+#print Nat.ArithmeticFunction.cardDistinctFactors /-
/-- `ω n` is the number of distinct prime factors of `n`. -/
def cardDistinctFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.dedup.length, by simp⟩
#align nat.arithmetic_function.card_distinct_factors Nat.ArithmeticFunction.cardDistinctFactors
+-/
-- mathport name: card_distinct_factors
scoped[ArithmeticFunction] notation "ω" => Nat.ArithmeticFunction.cardDistinctFactors
+#print Nat.ArithmeticFunction.cardDistinctFactors_zero /-
theorem cardDistinctFactors_zero : ω 0 = 0 := by simp
#align nat.arithmetic_function.card_distinct_factors_zero Nat.ArithmeticFunction.cardDistinctFactors_zero
+-/
+#print Nat.ArithmeticFunction.cardDistinctFactors_one /-
@[simp]
theorem cardDistinctFactors_one : ω 1 = 0 := by simp [card_distinct_factors]
#align nat.arithmetic_function.card_distinct_factors_one Nat.ArithmeticFunction.cardDistinctFactors_one
+-/
theorem cardDistinctFactors_apply {n : ℕ} : ω n = n.factors.dedup.length :=
rfl
#align nat.arithmetic_function.card_distinct_factors_apply Nat.ArithmeticFunction.cardDistinctFactors_apply
+#print Nat.ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree /-
theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠ 0) :
ω n = Ω n ↔ Squarefree n :=
by
@@ -839,24 +917,31 @@ theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠
· rw [h.dedup]
rfl
#align nat.arithmetic_function.card_distinct_factors_eq_card_factors_iff_squarefree Nat.ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree
+-/
+#print Nat.ArithmeticFunction.cardDistinctFactors_apply_prime_pow /-
@[simp]
theorem cardDistinctFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) : ω (p ^ k) = 1 :=
by
rw [card_distinct_factors_apply, hp.factors_pow, List.replicate_dedup hk, List.length_singleton]
#align nat.arithmetic_function.card_distinct_factors_apply_prime_pow Nat.ArithmeticFunction.cardDistinctFactors_apply_prime_pow
+-/
+#print Nat.ArithmeticFunction.cardDistinctFactors_apply_prime /-
@[simp]
theorem cardDistinctFactors_apply_prime {p : ℕ} (hp : p.Prime) : ω p = 1 := by
rw [← pow_one p, card_distinct_factors_apply_prime_pow hp one_ne_zero]
#align nat.arithmetic_function.card_distinct_factors_apply_prime Nat.ArithmeticFunction.cardDistinctFactors_apply_prime
+-/
+#print Nat.ArithmeticFunction.moebius /-
/-- `μ` 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`. -/
def moebius : ArithmeticFunction ℤ :=
⟨fun n => if Squarefree n then (-1) ^ cardFactors n else 0, by simp⟩
#align nat.arithmetic_function.moebius Nat.ArithmeticFunction.moebius
+-/
-- mathport name: moebius
scoped[ArithmeticFunction] notation "μ" => Nat.ArithmeticFunction.moebius
@@ -866,14 +951,19 @@ theorem moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) : μ n = (-1) ^
if_pos h
#align nat.arithmetic_function.moebius_apply_of_squarefree Nat.ArithmeticFunction.moebius_apply_of_squarefree
+#print Nat.ArithmeticFunction.moebius_eq_zero_of_not_squarefree /-
@[simp]
theorem moebius_eq_zero_of_not_squarefree {n : ℕ} (h : ¬Squarefree n) : μ n = 0 :=
if_neg h
#align nat.arithmetic_function.moebius_eq_zero_of_not_squarefree Nat.ArithmeticFunction.moebius_eq_zero_of_not_squarefree
+-/
+#print Nat.ArithmeticFunction.moebius_apply_one /-
theorem moebius_apply_one : μ 1 = 1 := by simp
#align nat.arithmetic_function.moebius_apply_one Nat.ArithmeticFunction.moebius_apply_one
+-/
+#print Nat.ArithmeticFunction.moebius_ne_zero_iff_squarefree /-
theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n :=
by
constructor <;> intro h
@@ -881,7 +971,9 @@ theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n :
simp [h]
· simp [h, pow_ne_zero]
#align nat.arithmetic_function.moebius_ne_zero_iff_squarefree Nat.ArithmeticFunction.moebius_ne_zero_iff_squarefree
+-/
+#print Nat.ArithmeticFunction.moebius_ne_zero_iff_eq_or /-
theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 :=
by
constructor <;> intro h
@@ -890,10 +982,13 @@ theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n =
apply neg_one_pow_eq_or
· rcases h with (h | h) <;> simp [h]
#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or Nat.ArithmeticFunction.moebius_ne_zero_iff_eq_or
+-/
+#print Nat.ArithmeticFunction.moebius_apply_prime /-
theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
rw [moebius_apply_of_squarefree hp.squarefree, card_factors_apply_prime hp, pow_one]
#align nat.arithmetic_function.moebius_apply_prime Nat.ArithmeticFunction.moebius_apply_prime
+-/
theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
μ (p ^ k) = if k = 1 then -1 else 0 := by
@@ -904,6 +999,7 @@ theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
exact Or.inr h
#align nat.arithmetic_function.moebius_apply_prime_pow Nat.ArithmeticFunction.moebius_apply_prime_pow
+#print Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime /-
theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' : ¬n.Prime) : μ n = 0 :=
by
obtain ⟨p, k, hp, hk, rfl⟩ := (isPrimePow_nat_iff _).1 hn
@@ -911,6 +1007,7 @@ theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' :
rintro rfl
exact hn' (by simpa)
#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime
+-/
theorem isMultiplicative_moebius : IsMultiplicative μ :=
by
@@ -986,6 +1083,7 @@ theorem inv_zetaUnit : ((zetaUnit⁻¹ : (ArithmeticFunction R)ˣ) : ArithmeticF
end CommRing
+#print Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq /-
/-- Möbius inversion for functions to an `add_comm_group`. -/
theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
(∀ n : ℕ, 0 < n → (∑ i in n.divisors, f i) = g n) ↔
@@ -1014,6 +1112,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
rw [sum_congr rfl fun x hx => _]
rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
+-/
/-- Möbius inversion for functions to a `ring`. -/
theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
@@ -1026,12 +1125,14 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
rw [zsmul_eq_mul]
#align nat.arithmetic_function.sum_eq_iff_sum_mul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq
+#print Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq /-
/-- Möbius inversion for functions to a `comm_group`. -/
theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
(∀ n : ℕ, 0 < n → (∏ i in n.divisors, f i) = g n) ↔
∀ n : ℕ, 0 < n → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
@sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
+-/
/-- Möbius inversion for functions to a `comm_group_with_zero`. -/
theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -56,7 +56,7 @@ arithmetic functions, dirichlet convolution, divisors
open Finset
-open BigOperators
+open scoped BigOperators
namespace Nat
@@ -428,7 +428,7 @@ theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑
end Zeta
-open ArithmeticFunction
+open scoped ArithmeticFunction
section Pmul
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -134,11 +134,7 @@ end One
end Zero
instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
- ⟨fun f =>
- ⟨↑(f : ℕ → ℕ), by
- trans ↑(f 0)
- rfl
- simp⟩⟩
+ ⟨fun f => ⟨↑(f : ℕ → ℕ), by trans ↑(f 0); rfl; simp⟩⟩
#align nat.arithmetic_function.nat_coe Nat.ArithmeticFunction.natCoe
@[simp]
@@ -153,11 +149,7 @@ theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ}
#align nat.arithmetic_function.nat_coe_apply Nat.ArithmeticFunction.natCoe_apply
instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
- ⟨fun f =>
- ⟨↑(f : ℕ → ℤ), by
- trans ↑(f 0)
- rfl
- simp⟩⟩
+ ⟨fun f => ⟨↑(f : ℕ → ℤ), by trans ↑(f 0); rfl; simp⟩⟩
#align nat.arithmetic_function.int_coe Nat.ArithmeticFunction.intCoe
@[simp]
@@ -173,24 +165,17 @@ theorem intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ}
@[simp]
theorem coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} :
- ((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = f :=
- by
- ext
- simp
+ ((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = f := by ext; simp
#align nat.arithmetic_function.coe_coe Nat.ArithmeticFunction.coe_coe
@[simp]
theorem natCoe_one [AddMonoidWithOne R] : ((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 :=
- by
- ext n
- simp [one_apply]
+ by ext n; simp [one_apply]
#align nat.arithmetic_function.nat_coe_one Nat.ArithmeticFunction.natCoe_one
@[simp]
theorem intCoe_one [AddGroupWithOne R] : ((1 : ArithmeticFunction ℤ) : ArithmeticFunction R) = 1 :=
- by
- ext n
- simp [one_apply]
+ by ext n; simp [one_apply]
#align nat.arithmetic_function.int_coe_one Nat.ArithmeticFunction.intCoe_one
section AddMonoid
@@ -266,18 +251,12 @@ theorem mul_apply_one [Semiring R] {f g : ArithmeticFunction R} : (f * g) 1 = f
@[simp, norm_cast]
theorem natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} :
- (↑(f * g) : ArithmeticFunction R) = f * g :=
- by
- ext n
- simp
+ (↑(f * g) : ArithmeticFunction R) = f * g := by ext n; simp
#align nat.arithmetic_function.nat_coe_mul Nat.ArithmeticFunction.natCoe_mul
@[simp, norm_cast]
theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
- (↑(f * g) : ArithmeticFunction R) = f * g :=
- by
- ext n
- simp
+ (↑(f * g) : ArithmeticFunction R) = f * g := by ext n; simp
#align nat.arithmetic_function.int_coe_mul Nat.ArithmeticFunction.intCoe_mul
section Module
@@ -290,23 +269,20 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
simp only [mul_apply, smul_apply, sum_smul, mul_smul, smul_sum, Finset.sum_sigma']
apply Finset.sum_bij
pick_goal 5
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- exact ⟨(k, l * j), (l, j)⟩
+ · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H; exact ⟨(k, l * j), (l, j)⟩
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
simp only [Finset.mem_sigma, mem_divisors_antidiagonal] at H⊢
rcases H with ⟨⟨rfl, n0⟩, rfl, i0⟩
refine' ⟨⟨(mul_assoc _ _ _).symm, n0⟩, rfl, _⟩
rw [mul_ne_zero_iff] at *
exact ⟨i0.2, n0.2⟩
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- simp only [mul_assoc]
+ · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H; simp only [mul_assoc]
· rintro ⟨⟨a, b⟩, ⟨c, d⟩⟩ ⟨⟨i, j⟩, ⟨k, l⟩⟩ H₁ H₂
simp only [Finset.mem_sigma, mem_divisors_antidiagonal, and_imp, Prod.mk.inj_iff, add_comm,
heq_iff_eq] at H₁ H₂⊢
rintro rfl h2 rfl rfl
exact ⟨⟨Eq.trans H₁.2.1.symm H₂.2.1, rfl⟩, rfl, rfl⟩
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- refine' ⟨⟨(i * k, l), (i, k)⟩, _, _⟩
+ · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H; refine' ⟨⟨(i * k, l), (i, k)⟩, _, _⟩
· simp only [Finset.mem_sigma, mem_divisors_antidiagonal] at H⊢
rcases H with ⟨⟨rfl, n0⟩, rfl, j0⟩
refine' ⟨⟨mul_assoc _ _ _, n0⟩, rfl, _⟩
@@ -321,11 +297,9 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
by
ext
rw [smul_apply]
- by_cases x0 : x = 0
- · simp [x0]
+ by_cases x0 : x = 0; · simp [x0]
have h : {(1, x)} ⊆ divisors_antidiagonal x := by simp [x0]
- rw [← sum_subset h]
- · simp
+ rw [← sum_subset h]; · simp
intro y ymem ynmem
have y1ne : y.fst ≠ 1 := by
intro con
@@ -348,11 +322,9 @@ instance : Monoid (ArithmeticFunction R) :=
mul_one := fun f => by
ext
rw [mul_apply]
- by_cases x0 : x = 0
- · simp [x0]
+ by_cases x0 : x = 0; · simp [x0]
have h : {(x, 1)} ⊆ divisors_antidiagonal x := by simp [x0]
- rw [← sum_subset h]
- · simp
+ rw [← sum_subset h]; · simp
intro y ymem ynmem
have y2ne : y.snd ≠ 1 := by
intro con
@@ -366,17 +338,13 @@ instance : Semiring (ArithmeticFunction R) :=
{ ArithmeticFunction.hasZero R, ArithmeticFunction.hasMul, ArithmeticFunction.hasAdd,
ArithmeticFunction.addCommMonoid, ArithmeticFunction.addMonoidWithOne,
ArithmeticFunction.monoid with
- zero_mul := fun f => by
- ext
+ zero_mul := fun f => by ext;
simp only [mul_apply, MulZeroClass.zero_mul, sum_const_zero, zero_apply]
- mul_zero := fun f => by
- ext
+ mul_zero := fun f => by ext;
simp only [mul_apply, sum_const_zero, MulZeroClass.mul_zero, zero_apply]
- left_distrib := fun a b c => by
- ext
+ left_distrib := fun a b c => by ext;
simp only [← sum_add_distrib, mul_add, mul_apply, add_apply]
- right_distrib := fun a b c => by
- ext
+ right_distrib := fun a b c => by ext;
simp only [← sum_add_distrib, add_mul, mul_apply, add_apply] }
end Semiring
@@ -396,18 +364,10 @@ instance {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] :
where
one_smul := one_smul'
mul_smul := mul_smul'
- smul_add r x y := by
- ext
- simp only [sum_add_distrib, smul_add, smul_apply, add_apply]
- smul_zero r := by
- ext
- simp only [smul_apply, sum_const_zero, smul_zero, zero_apply]
- add_smul r s x := by
- ext
- simp only [add_smul, sum_add_distrib, smul_apply, add_apply]
- zero_smul r := by
- ext
- simp only [smul_apply, sum_const_zero, zero_smul, zero_apply]
+ smul_add r x y := by ext; simp only [sum_add_distrib, smul_add, smul_apply, add_apply]
+ smul_zero r := by ext; simp only [smul_apply, sum_const_zero, smul_zero, zero_apply]
+ add_smul r s x := by ext; simp only [add_smul, sum_add_distrib, smul_apply, add_apply]
+ zero_smul r := by ext; simp only [smul_apply, sum_const_zero, zero_smul, zero_apply]
section Zeta
@@ -482,10 +442,8 @@ theorem pmul_apply [MulZeroClass R] {f g : ArithmeticFunction R} {x : ℕ} : f.p
rfl
#align nat.arithmetic_function.pmul_apply Nat.ArithmeticFunction.pmul_apply
-theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g = g.pmul f :=
- by
- ext
- simp [mul_comm]
+theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g = g.pmul f := by
+ ext; simp [mul_comm]
#align nat.arithmetic_function.pmul_comm Nat.ArithmeticFunction.pmul_comm
section NonAssocSemiring
@@ -513,10 +471,7 @@ variable [Semiring R]
/-- This is the pointwise power of `arithmetic_function`s. -/
def ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
if h0 : k = 0 then ζ
- else
- ⟨fun x => f x ^ k, by
- rw [map_zero]
- exact zero_pow (Nat.pos_of_ne_zero h0)⟩
+ else ⟨fun x => f x ^ k, by rw [map_zero]; exact zero_pow (Nat.pos_of_ne_zero h0)⟩
#align nat.arithmetic_function.ppow Nat.ArithmeticFunction.ppow
@[simp]
@@ -524,10 +479,8 @@ theorem ppow_zero {f : ArithmeticFunction R} : f.ppow 0 = ζ := by rw [ppow, dif
#align nat.arithmetic_function.ppow_zero Nat.ArithmeticFunction.ppow_zero
@[simp]
-theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppow k x = f x ^ k :=
- by
- rw [ppow, dif_neg (ne_of_gt kpos)]
- rfl
+theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppow k x = f x ^ k := by
+ rw [ppow, dif_neg (ne_of_gt kpos)]; rfl
#align nat.arithmetic_function.ppow_apply Nat.ArithmeticFunction.ppow_apply
theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) :=
@@ -603,8 +556,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
simp only [mem_divisors_antidiagonal, Ne.def, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
simp only [mem_divisors_antidiagonal, Nat.mul_eq_zero, Ne.def]
- constructor
- · ring
+ constructor; · ring
rw [Nat.mul_eq_zero] at *
apply not_or_of_not ha hb
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
@@ -652,8 +604,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
simp only [exists_prop, Prod.mk.inj_iff, Ne.def, mem_product, mem_divisors_antidiagonal]
rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
- · rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h
- simp [h.2.1, h.2.2]
+ · rw [Nat.mul_eq_zero, Decidable.not_or_iff_and_not] at h; simp [h.2.1, h.2.2]
rw [mul_comm n m, h.1]⟩
#align nat.arithmetic_function.is_multiplicative.mul Nat.ArithmeticFunction.IsMultiplicative.mul
@@ -693,8 +644,7 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
f = g ↔ ∀ p i : ℕ, Nat.Prime p → f (p ^ i) = g (p ^ i) :=
by
constructor
- · intro h p i _
- rw [h]
+ · intro h p i _; rw [h]
intro h
ext n
by_cases hn : n = 0
@@ -733,9 +683,7 @@ theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k :
simp [pow, (ne_of_lt (Nat.succ_pos k)).symm]
#align nat.arithmetic_function.pow_apply Nat.ArithmeticFunction.pow_apply
-theorem pow_zero_eq_zeta : pow 0 = ζ := by
- ext n
- simp
+theorem pow_zero_eq_zeta : pow 0 = ζ := by ext n; simp
#align nat.arithmetic_function.pow_zero_eq_zeta Nat.ArithmeticFunction.pow_zero_eq_zeta
/-- `σ k n` is the sum of the `k`th powers of the divisors of `n` -/
@@ -1049,8 +997,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
· rw [ext_iff]
apply forall_congr'
intro n
- cases n
- · simp
+ cases n; · simp
rw [coe_zeta_smul_apply]
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', if_false, ZeroHom.coe_mk]
rw [sum_congr rfl fun x hx => _]
@@ -1062,8 +1009,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
· rw [ext_iff]
apply forall_congr'
intro n
- cases n
- · simp
+ cases n; · simp
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', smul_apply, if_false, ZeroHom.coe_mk]
rw [sum_congr rfl fun x hx => _]
rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
mathlib commit https://github.com/leanprover-community/mathlib/commit/06a655b5fcfbda03502f9158bbf6c0f1400886f9
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
! This file was ported from Lean 3 source module number_theory.arithmetic_function
-! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e
+! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -778,7 +778,7 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
rcases eq_or_ne m 1 with (rfl | hm')
· simp
rw [one_apply_ne, one_apply_ne hm', MulZeroClass.zero_mul]
- rw [Ne.def, Nat.mul_eq_one_iff, not_and_or]
+ rw [Ne.def, mul_eq_one, not_and_or]
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -368,10 +368,10 @@ instance : Semiring (ArithmeticFunction R) :=
ArithmeticFunction.monoid with
zero_mul := fun f => by
ext
- simp only [mul_apply, zero_mul, sum_const_zero, zero_apply]
+ simp only [mul_apply, MulZeroClass.zero_mul, sum_const_zero, zero_apply]
mul_zero := fun f => by
ext
- simp only [mul_apply, sum_const_zero, mul_zero, zero_apply]
+ simp only [mul_apply, sum_const_zero, MulZeroClass.mul_zero, zero_apply]
left_distrib := fun a b c => by
ext
simp only [← sum_add_distrib, mul_add, mul_apply, add_apply]
@@ -777,7 +777,7 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
intro m n hm hn hmn
rcases eq_or_ne m 1 with (rfl | hm')
· simp
- rw [one_apply_ne, one_apply_ne hm', zero_mul]
+ rw [one_apply_ne, one_apply_ne hm', MulZeroClass.zero_mul]
rw [Ne.def, Nat.mul_eq_one_iff, not_and_or]
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
nat_cast
/int_cast
/rat_cast
to natCast
/intCast
/ratCast
(#11486)
Now that I am defining NNRat.cast
, I want a definitive answer to this naming issue. Plenty of lemmas in mathlib already use natCast
/intCast
/ratCast
over nat_cast
/int_cast
/rat_cast
, and this matches with the general expectation that underscore-separated name parts correspond to a single declaration.
@@ -652,18 +652,18 @@ theorem map_prod_of_subset_primeFactors [CommSemiring R] {f : ArithmeticFunction
map_prod_of_prime h_mult t fun _ a => prime_of_mem_primeFactors (ht a)
@[arith_mult]
-theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
+theorem natCast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- Porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
-#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.nat_cast
+#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.natCast
@[arith_mult]
-theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
+theorem intCast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- Porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
-#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.int_cast
+#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.intCast
@[arith_mult]
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
@@ -926,7 +926,7 @@ theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id :=
theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
{k : ℕ} : IsMultiplicative (f.ppow k) := by
induction' k with k hi
- · exact isMultiplicative_zeta.nat_cast
+ · exact isMultiplicative_zeta.natCast
· rw [ppow_succ']
apply hf.pmul hi
#align nat.arithmetic_function.is_multiplicative.ppow ArithmeticFunction.IsMultiplicative.ppow
@@ -1146,7 +1146,7 @@ theorem IsMultiplicative.prodPrimeFactors_one_add_of_squarefree [CommSemiring R]
· simp_rw [prodPrimeFactors_apply hn.ne_zero, add_apply, natCoe_apply]
apply Finset.prod_congr rfl; intro p hp;
rw [zeta_apply_ne (prime_of_mem_factors <| List.mem_toFinset.mp hp).ne_zero, cast_one]
- rw [isMultiplicative_zeta.nat_cast.prodPrimeFactors_add_of_squarefree h_mult hn,
+ rw [isMultiplicative_zeta.natCast.prodPrimeFactors_add_of_squarefree h_mult hn,
coe_zeta_mul_apply]
theorem IsMultiplicative.prodPrimeFactors_one_sub_of_squarefree [CommRing R]
@@ -1157,7 +1157,7 @@ theorem IsMultiplicative.prodPrimeFactors_one_sub_of_squarefree [CommRing R]
rw [pmul_apply, intCoe_apply, ArithmeticFunction.moebius_apply_prime
(prime_of_mem_factors (List.mem_toFinset.mp hp))]
ring
- · rw [(isMultiplicative_moebius.int_cast.pmul hf).prodPrimeFactors_one_add_of_squarefree hn]
+ · rw [(isMultiplicative_moebius.intCast.pmul hf).prodPrimeFactors_one_add_of_squarefree hn]
simp_rw [pmul_apply, intCoe_apply]
open UniqueFactorizationMonoid
@@ -1180,7 +1180,7 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
· intro a b _ha _hb hab ha' hb'
rw [IsMultiplicative.map_mul_of_coprime _ hab, ha', hb',
IsMultiplicative.map_mul_of_coprime isMultiplicative_one hab]
- exact isMultiplicative_moebius.mul isMultiplicative_zeta.nat_cast
+ exact isMultiplicative_moebius.mul isMultiplicative_zeta.natCast
#align nat.arithmetic_function.moebius_mul_coe_zeta ArithmeticFunction.moebius_mul_coe_zeta
@[simp]
@@ -1073,12 +1073,17 @@ theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n :
· simp [h, pow_ne_zero]
#align nat.arithmetic_function.moebius_ne_zero_iff_squarefree ArithmeticFunction.moebius_ne_zero_iff_squarefree
+theorem moebius_eq_or (n : ℕ) : μ n = 0 ∨ μ n = 1 ∨ μ n = -1 := by
+ simp only [moebius, coe_mk]
+ split_ifs
+ · right
+ exact neg_one_pow_eq_or ..
+ · left
+ rfl
+
theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 := by
- constructor <;> intro h
- · rw [moebius_ne_zero_iff_squarefree] at h
- rw [moebius_apply_of_squarefree h]
- apply neg_one_pow_eq_or
- · rcases h with (h | h) <;> simp [h]
+ have := moebius_eq_or n
+ aesop
#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or ArithmeticFunction.moebius_ne_zero_iff_eq_or
theorem moebius_sq_eq_one_of_squarefree {l : ℕ} (hl : Squarefree l) : μ l ^ 2 = 1 := by
@@ -1100,6 +1105,10 @@ theorem abs_moebius {n : ℕ} :
· exact abs_moebius_eq_one_of_squarefree h
· simp only [moebius_eq_zero_of_not_squarefree h, abs_zero]
+theorem abs_moebius_le_one {n : ℕ} : |μ n| ≤ 1 := by
+ rw [abs_moebius, apply_ite (· ≤ 1)]
+ simp
+
theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
rw [moebius_apply_of_squarefree hp.squarefree, cardFactors_apply_prime hp, pow_one]
#align nat.arithmetic_function.moebius_apply_prime ArithmeticFunction.moebius_apply_prime
@@ -335,7 +335,7 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
intro y ymem ynmem
have y1ne : y.fst ≠ 1 := by
intro con
- simp only [Con, mem_divisorsAntidiagonal, one_mul, Ne.def] at ymem
+ simp only [Con, mem_divisorsAntidiagonal, one_mul, Ne] at ymem
simp only [mem_singleton, Prod.ext_iff] at ynmem
-- Porting note: `tauto` worked from here.
cases y
@@ -368,7 +368,7 @@ instance instMonoid : Monoid (ArithmeticFunction R) :=
have y2ne : y.snd ≠ 1 := by
intro con
cases y; subst con -- Porting note: added
- simp only [Con, mem_divisorsAntidiagonal, mul_one, Ne.def] at ymem
+ simp only [Con, mem_divisorsAntidiagonal, mul_one, Ne] at ymem
simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
simp [y2ne]
@@ -675,14 +675,14 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
symm
apply sum_nbij fun ((i, j), k, l) ↦ (i * k, j * l)
· rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at h
+ simp only [mem_divisorsAntidiagonal, Ne, mem_product] at h
rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
- simp only [mem_divisorsAntidiagonal, Nat.mul_eq_zero, Ne.def]
+ simp only [mem_divisorsAntidiagonal, Nat.mul_eq_zero, Ne]
constructor
· ring
rw [Nat.mul_eq_zero] at *
apply not_or_of_not ha hb
- · simp only [Set.InjOn, mem_coe, mem_divisorsAntidiagonal, Ne.def, mem_product, Prod.mk.inj_iff]
+ · simp only [Set.InjOn, mem_coe, mem_divisorsAntidiagonal, Ne, mem_product, Prod.mk.inj_iff]
rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩ ⟨⟨c1, c2⟩, ⟨d1, d2⟩⟩ hcd h
simp only [Prod.mk.inj_iff] at h
ext <;> dsimp only
@@ -709,7 +709,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
· rw [← hcd.1.1, ← hcd.2.1] at cop
rw [← hcd.2.1, h.2, Nat.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, Ne.def, mem_product,
+ · simp only [Set.SurjOn, Set.subset_def, mem_coe, mem_divisorsAntidiagonal, Ne, mem_product,
Set.mem_image, exists_prop, Prod.mk.inj_iff]
rintro ⟨b1, b2⟩ h
dsimp at h
@@ -719,7 +719,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
· rw [Nat.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, Ne.def, mem_product]
+ · simp only [mem_divisorsAntidiagonal, Ne, mem_product]
rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
dsimp only
rw [hf.map_mul_of_coprime cop.coprime_mul_right.coprime_mul_right_right,
@@ -908,7 +908,7 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
rcases eq_or_ne m 1 with (rfl | hm')
· simp
rw [one_apply_ne, one_apply_ne hm', zero_mul]
- rw [Ne.def, mul_eq_one, not_and_or]
+ rw [Ne, mul_eq_one, not_and_or]
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one ArithmeticFunction.isMultiplicative_one
@@ -1163,7 +1163,7 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
moebius_apply_prime_pow hp (Nat.succ_ne_zero _), Nat.succ_inj', sum_ite_eq', mem_range,
if_pos hn, add_left_neg]
rw [one_apply_ne]
- rw [Ne.def, pow_eq_one_iff]
+ rw [Ne, pow_eq_one_iff]
· exact hp.ne_one
· exact hn.ne'
· rw [ZeroHom.map_zero, ZeroHom.map_zero]
We change the following field in the definition of an additive commutative monoid:
nsmul_succ : ∀ (n : ℕ) (x : G),
- AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+ AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x
where the latter is more natural
We adjust the definitions of ^
in monoids, groups, etc.
Originally there was a warning comment about why this natural order was preferred
use
x * npowRec n x
and notnpowRec n x * x
in the definition to make sure that definitional unfolding ofnpowRec
is blocked, to avoid deep recursion issues.
but it seems to no longer apply.
Remarks on the PR :
pow_succ
and pow_succ'
have switched their meanings.Ideal.IsPrime.mul_mem_pow
which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul
.@@ -548,18 +548,18 @@ theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppo
rfl
#align nat.arithmetic_function.ppow_apply ArithmeticFunction.ppow_apply
-theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) := by
+theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) := by
ext x
- rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ]
+ rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ']
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ ArithmeticFunction.ppow_succ
+#align nat.arithmetic_function.ppow_succ ArithmeticFunction.ppow_succ'
-theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
+theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
f.ppow (k + 1) = (f.ppow k).pmul f := by
ext x
- rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ']
+ rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ]
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ' ArithmeticFunction.ppow_succ'
+#align nat.arithmetic_function.ppow_succ' ArithmeticFunction.ppow_succ
end Pmul
@@ -927,7 +927,7 @@ theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf :
{k : ℕ} : IsMultiplicative (f.ppow k) := by
induction' k with k hi
· exact isMultiplicative_zeta.nat_cast
- · rw [ppow_succ]
+ · rw [ppow_succ']
apply hf.pmul hi
#align nat.arithmetic_function.is_multiplicative.ppow ArithmeticFunction.IsMultiplicative.ppow
@@ -1081,6 +1081,25 @@ theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n =
· rcases h with (h | h) <;> simp [h]
#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or ArithmeticFunction.moebius_ne_zero_iff_eq_or
+theorem moebius_sq_eq_one_of_squarefree {l : ℕ} (hl : Squarefree l) : μ l ^ 2 = 1 := by
+ rw [moebius_apply_of_squarefree hl, ← pow_mul, mul_comm, pow_mul, neg_one_sq, one_pow]
+
+theorem abs_moebius_eq_one_of_squarefree {l : ℕ} (hl : Squarefree l) : |μ l| = 1 := by
+ simp only [moebius_apply_of_squarefree hl, abs_pow, abs_neg, abs_one, one_pow]
+
+theorem moebius_sq {n : ℕ} :
+ μ n ^ 2 = if Squarefree n then 1 else 0 := by
+ split_ifs with h
+ · exact moebius_sq_eq_one_of_squarefree h
+ · simp only [pow_eq_zero_iff, moebius_eq_zero_of_not_squarefree h,
+ zero_pow (show 2 ≠ 0 by norm_num)]
+
+theorem abs_moebius {n : ℕ} :
+ |μ n| = if Squarefree n then 1 else 0 := by
+ split_ifs with h
+ · exact abs_moebius_eq_one_of_squarefree h
+ · simp only [moebius_eq_zero_of_not_squarefree h, abs_zero]
+
theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
rw [moebius_apply_of_squarefree hp.squarefree, cardFactors_apply_prime hp, pow_one]
#align nat.arithmetic_function.moebius_apply_prime ArithmeticFunction.moebius_apply_prime
These will be caught by the linter in a future lean version.
@@ -967,8 +967,7 @@ lemma cardFactors_zero : Ω 0 = 0 := rfl
theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime := by
refine' ⟨fun h => _, fun h => List.length_eq_one.2 ⟨n, factors_prime h⟩⟩
cases' n with n
- · contrapose! h
- simp
+ · simp at h
rcases List.length_eq_one.1 h with ⟨x, hx⟩
rw [← prod_factors n.succ_ne_zero, hx, List.prod_singleton]
apply prime_of_mem_factors
@@ -837,7 +837,7 @@ end IsMultiplicative
section SpecialFunctions
/-- The identity on `ℕ` as an `ArithmeticFunction`. -/
-nonrec -- Porting note: added
+nonrec -- Porting note (#11445): added
def id : ArithmeticFunction ℕ :=
⟨id, rfl⟩
#align nat.arithmetic_function.id ArithmeticFunction.id
nsmul
and zsmul
to default automatically (#6262)
This PR removes the default values for nsmul
and zsmul
, forcing the user to populate them manually.
The previous behavior can be obtained by writing nsmul := nsmulRec
and zsmul := zsmulRec
, which is now in the docstring for these fields.
The motivation here is to make it more obvious when module diamonds are being introduced, or at least where they might be hiding; you can now simply search for nsmulRec
in the source code.
Arguably we should do the same thing for intCast
, natCast
, pow
, and zpow
too, but diamonds are less common in those fields, so I'll leave them to a subsequent PR.
Co-authored-by: Matthew Ballard <matt@mrb.email>
@@ -238,7 +238,8 @@ instance instAddMonoid : AddMonoid (ArithmeticFunction R) :=
ArithmeticFunction.add with
add_assoc := fun _ _ _ => ext fun _ => add_assoc _ _ _
zero_add := fun _ => ext fun _ => zero_add _
- add_zero := fun _ => ext fun _ => add_zero _ }
+ add_zero := fun _ => ext fun _ => add_zero _
+ nsmul := nsmulRec }
#align nat.arithmetic_function.add_monoid ArithmeticFunction.instAddMonoid
end AddMonoid
@@ -254,10 +255,13 @@ instance instAddMonoidWithOne [AddMonoidWithOne R] : AddMonoidWithOne (Arithmeti
instance instAddCommMonoid [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) :=
{ ArithmeticFunction.instAddMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ }
+instance [NegZeroClass R] : Neg (ArithmeticFunction R) where
+ neg f := ⟨fun n => -f n, by simp⟩
+
instance [AddGroup R] : AddGroup (ArithmeticFunction R) :=
{ ArithmeticFunction.instAddMonoid with
- neg := fun f => ⟨fun n => -f n, by simp⟩
- add_left_neg := fun _ => ext fun _ => add_left_neg _ }
+ add_left_neg := fun _ => ext fun _ => add_left_neg _
+ zsmul := zsmulRec }
instance [AddCommGroup R] : AddCommGroup (ArithmeticFunction R) :=
{ show AddGroup (ArithmeticFunction R) by infer_instance with
@@ -402,7 +406,8 @@ instance [CommSemiring R] : CommSemiring (ArithmeticFunction R) :=
instance [CommRing R] : CommRing (ArithmeticFunction R) :=
{ ArithmeticFunction.instSemiring with
add_left_neg := add_left_neg
- mul_comm := mul_comm }
+ mul_comm := mul_comm
+ zsmul := (· • ·) }
instance {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] :
Module (ArithmeticFunction R) (ArithmeticFunction M) where
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -159,7 +159,7 @@ 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] -- porting note: added `coe` tag.
+@[coe] -- Porting note: added `coe` tag.
def natToArithmeticFunction [AddMonoidWithOne R] :
(ArithmeticFunction ℕ) → (ArithmeticFunction R) :=
fun f => ⟨fun n => ↑(f n), by simp⟩
@@ -333,7 +333,7 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
intro con
simp only [Con, mem_divisorsAntidiagonal, one_mul, Ne.def] at ymem
simp only [mem_singleton, Prod.ext_iff] at ynmem
- -- porting note: `tauto` worked from here.
+ -- Porting note: `tauto` worked from here.
cases y
subst con
simp only [true_and, one_mul, x0, not_false_eq_true, and_true] at ynmem ymem
@@ -363,7 +363,7 @@ instance instMonoid : Monoid (ArithmeticFunction R) :=
intro y ymem ynmem
have y2ne : y.snd ≠ 1 := by
intro con
- cases y; subst con -- porting note: added
+ cases y; subst con -- Porting note: added
simp only [Con, mem_divisorsAntidiagonal, mul_one, Ne.def] at ymem
simp only [mem_singleton, Prod.ext_iff] at ynmem
tauto
@@ -372,7 +372,7 @@ instance instMonoid : Monoid (ArithmeticFunction R) :=
#align nat.arithmetic_function.monoid ArithmeticFunction.instMonoid
instance instSemiring : Semiring (ArithmeticFunction R) :=
- -- porting note: I reorganized this instance
+ -- Porting note: I reorganized this instance
{ ArithmeticFunction.instAddMonoidWithOne,
ArithmeticFunction.instMonoid,
ArithmeticFunction.instAddCommMonoid with
@@ -474,12 +474,12 @@ theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
theorem zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (ζ * f) x = ∑ i in divisors x, f i :=
coe_zeta_mul_apply
- --porting note: was `by rw [← nat_coe_nat ζ, coe_zeta_mul_apply]`. Is this `theorem` obsolete?
+ -- Porting note: was `by rw [← nat_coe_nat ζ, coe_zeta_mul_apply]`. Is this `theorem` obsolete?
#align nat.arithmetic_function.zeta_mul_apply ArithmeticFunction.zeta_mul_apply
theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑ i in divisors x, f i :=
coe_mul_zeta_apply
- --porting note: was `by rw [← natCoe_nat ζ, coe_mul_zeta_apply]`. Is this `theorem` obsolete=
+ -- Porting note: was `by rw [← natCoe_nat ζ, coe_mul_zeta_apply]`. Is this `theorem` obsolete=
#align nat.arithmetic_function.mul_zeta_apply ArithmeticFunction.mul_zeta_apply
end Zeta
@@ -649,14 +649,14 @@ theorem map_prod_of_subset_primeFactors [CommSemiring R] {f : ArithmeticFunction
@[arith_mult]
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
- -- porting note: was `by simp [cop, h]`
+ -- Porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.nat_cast
@[arith_mult]
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
- -- porting note: was `by simp [cop, h]`
+ -- Porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.int_cast
@@ -740,7 +740,7 @@ theorem pdiv [CommGroupWithZero R] {f g : ArithmeticFunction R} (hf : IsMultipli
/-- 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` -/
-nonrec -- porting note: added
+nonrec -- Porting note: added
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) :=
@@ -832,7 +832,7 @@ end IsMultiplicative
section SpecialFunctions
/-- The identity on `ℕ` as an `ArithmeticFunction`. -/
-nonrec -- porting note: added
+nonrec -- Porting note: added
def id : ArithmeticFunction ℕ :=
⟨id, rfl⟩
#align nat.arithmetic_function.id ArithmeticFunction.id
@@ -851,7 +851,7 @@ def pow (k : ℕ) : ArithmeticFunction ℕ :=
theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k := by
cases k
· simp [pow]
- rename_i k -- porting note: added
+ rename_i k -- Porting note: added
simp [pow, k.succ_pos.ne']
#align nat.arithmetic_function.pow_apply ArithmeticFunction.pow_apply
@@ -1222,7 +1222,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
| succ n =>
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', smul_apply, if_false,
ZeroHom.coe_mk]
- -- porting note: added following `simp only`
+ -- Porting note: added following `simp only`
simp only [f', g', Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
rw [sum_congr rfl fun x hx => ?_]
rw [if_neg (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)).ne']
@@ -1207,7 +1207,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
| succ n =>
rw [coe_zeta_smul_apply]
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', if_false, ZeroHom.coe_mk]
- simp only [coe_mk, succ_ne_zero, ite_false]
+ simp only [f', g', coe_mk, succ_ne_zero, ite_false]
rw [sum_congr rfl fun x hx => ?_]
rw [if_neg (Nat.pos_of_mem_divisors hx).ne']
trans μ • g' = f'
@@ -1223,7 +1223,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', smul_apply, if_false,
ZeroHom.coe_mk]
-- porting note: added following `simp only`
- simp only [Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
+ simp only [f', g', Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
rw [sum_congr rfl fun x hx => ?_]
rw [if_neg (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)).ne']
#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
arith_mult
: an aesop
tactic for proving IsMultiplicative
statements (#9310)
Add a tactic that proves multiplicativity of arithmetic functions using Aesop by applying structural lemmas, akin to the continuity
and measurability
tactics.
Co-authored-by: Arend Mellendijk <FLDutchmann@users.noreply.github.com>
@@ -9,6 +9,7 @@ import Mathlib.NumberTheory.Divisors
import Mathlib.Data.Nat.Squarefree
import Mathlib.Data.Nat.GCD.BigOperators
import Mathlib.Data.Nat.Factorization.Basic
+import Mathlib.Tactic.ArithMult
#align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
@@ -609,7 +610,7 @@ section MonoidWithZero
variable [MonoidWithZero R]
-@[simp]
+@[simp, arith_mult]
theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
h.1
#align nat.arithmetic_function.is_multiplicative.map_one ArithmeticFunction.IsMultiplicative.map_one
@@ -645,18 +646,21 @@ theorem map_prod_of_subset_primeFactors [CommSemiring R] {f : ArithmeticFunction
f (∏ a in t, a) = ∏ a : ℕ in t, f a :=
map_prod_of_prime h_mult t fun _ a => prime_of_mem_primeFactors (ht a)
+@[arith_mult]
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.nat_cast
+@[arith_mult]
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.int_cast
+@[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], ?_⟩
@@ -718,6 +722,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
ring
#align nat.arithmetic_function.is_multiplicative.mul ArithmeticFunction.IsMultiplicative.mul
+@[arith_mult]
theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f.pmul g) :=
⟨by simp [hf, hg], fun {m n} cop => by
@@ -725,6 +730,7 @@ theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicat
ring⟩
#align nat.arithmetic_function.is_multiplicative.pmul ArithmeticFunction.IsMultiplicative.pmul
+@[arith_mult]
theorem pdiv [CommGroupWithZero R] {f g : ArithmeticFunction R} (hf : IsMultiplicative f)
(hg : IsMultiplicative g) : IsMultiplicative (pdiv f g) :=
⟨ by simp [hf, hg], fun {m n} cop => by
@@ -769,6 +775,7 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
exact Finset.prod_congr rfl fun p hp ↦ h p _ (Nat.prime_of_mem_primeFactors hp)
#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
+@[arith_mult]
theorem prodPrimeFactors [CommMonoidWithZero R] (f : ℕ → R) :
IsMultiplicative (prodPrimeFactors f) := by
rw [iff_ne_zero]
@@ -888,6 +895,7 @@ theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k := by
simp [hx]
#align nat.arithmetic_function.zeta_mul_pow_eq_sigma ArithmeticFunction.zeta_mul_pow_eq_sigma
+@[arith_mult]
theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : ArithmeticFunction R) :=
IsMultiplicative.iff_ne_zero.2
⟨by simp, by
@@ -899,14 +907,17 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one ArithmeticFunction.isMultiplicative_one
+@[arith_mult]
theorem isMultiplicative_zeta : IsMultiplicative ζ :=
IsMultiplicative.iff_ne_zero.2 ⟨by simp, by simp (config := { contextual := true })⟩
#align nat.arithmetic_function.is_multiplicative_zeta ArithmeticFunction.isMultiplicative_zeta
+@[arith_mult]
theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id :=
⟨rfl, fun {_ _} _ => rfl⟩
#align nat.arithmetic_function.is_multiplicative_id ArithmeticFunction.isMultiplicative_id
+@[arith_mult]
theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
{k : ℕ} : IsMultiplicative (f.ppow k) := by
induction' k with k hi
@@ -915,10 +926,12 @@ theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf :
apply hf.pmul hi
#align nat.arithmetic_function.is_multiplicative.ppow ArithmeticFunction.IsMultiplicative.ppow
+@[arith_mult]
theorem isMultiplicative_pow {k : ℕ} : IsMultiplicative (pow k) :=
isMultiplicative_id.ppow
#align nat.arithmetic_function.is_multiplicative_pow ArithmeticFunction.isMultiplicative_pow
+@[arith_mult]
theorem isMultiplicative_sigma {k : ℕ} : IsMultiplicative (σ k) := by
rw [← zeta_mul_pow_eq_sigma]
apply isMultiplicative_zeta.mul isMultiplicative_pow
@@ -1085,6 +1098,7 @@ theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' :
exact hn' (by simpa)
#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime ArithmeticFunction.moebius_apply_isPrimePow_not_prime
+@[arith_mult]
theorem isMultiplicative_moebius : IsMultiplicative μ := by
rw [IsMultiplicative.iff_ne_zero]
refine' ⟨by simp, fun {n m} hn hm hnm => _⟩
have
, replace
and suffices
(#10640)
No changes to tactic file, it's just boring fixes throughout the library.
This follows on from #6964.
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -802,8 +802,8 @@ theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R
· simp only [hy, f.map_zero, mul_zero, Nat.lcm_zero_right, Nat.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
- · intro i; rw [Nat.pow_zero, hf.1]
+ have hfi_zero : ∀ {i}, f (i ^ 0) = 1 := by
+ intro i; rw [Nat.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))]
This adds individual scopes ArithmeticFunction.zeta
, ..., ArithmeticFunction.Omega
, ArithmeticFunction.Moebius
, ArithmeticFunction.vonMangoldt
for the notations ζ
, σ
, ω
, Ω
and μ
, Λ
.
This makes it possible to access a selected subset of these instead of either none or all of them.
We also add the lemma ArithmeticFunction.pmul_assoc
.
@@ -21,6 +21,7 @@ functions are endowed with a multiplication, given by Dirichlet convolution, and
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`.
* The pointwise operations `pmul` and `ppow` differ from the multiplication
@@ -34,6 +35,7 @@ to form the Dirichlet ring.
* `μ` is the Möbius function (spelled `moebius` in code).
## Main Results
+
* Several forms of Möbius inversion:
* `sum_eq_iff_sum_mul_moebius_eq` for functions to a `CommRing`
* `sum_eq_iff_sum_smul_moebius_eq` for functions to an `AddCommGroup`
@@ -47,14 +49,21 @@ to form the Dirichlet ring.
* `prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero` for functions to a `CommGroupWithZero`
## 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
-/
@@ -418,10 +427,12 @@ def zeta : ArithmeticFunction ℕ :=
⟨fun x => ite (x = 0) 0 1, rfl⟩
#align nat.arithmetic_function.zeta ArithmeticFunction.zeta
--- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[ArithmeticFunction] notation "ζ" => ArithmeticFunction.zeta
+@[inherit_doc]
+scoped[ArithmeticFunction.zeta] notation "ζ" => ArithmeticFunction.zeta
+
@[simp]
theorem zeta_apply {x : ℕ} : ζ x = if x = 0 then 0 else 1 :=
rfl
@@ -491,6 +502,11 @@ theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g
simp [mul_comm]
#align nat.arithmetic_function.pmul_comm ArithmeticFunction.pmul_comm
+lemma pmul_assoc [CommMonoidWithZero R] (f₁ f₂ f₃ : ArithmeticFunction R) :
+ pmul (pmul f₁ f₂) f₃ = pmul f₁ (pmul f₂ f₃) := by
+ ext
+ simp only [pmul_apply, mul_assoc]
+
section NonAssocSemiring
variable [NonAssocSemiring R]
@@ -842,10 +858,12 @@ def sigma (k : ℕ) : ArithmeticFunction ℕ :=
⟨fun n => ∑ d in divisors n, d ^ k, by simp⟩
#align nat.arithmetic_function.sigma ArithmeticFunction.sigma
--- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[ArithmeticFunction] notation "σ" => ArithmeticFunction.sigma
+@[inherit_doc]
+scoped[ArithmeticFunction.sigma] notation "σ" => ArithmeticFunction.sigma
+
theorem sigma_apply {k n : ℕ} : σ k n = ∑ d in divisors n, d ^ k :=
rfl
#align nat.arithmetic_function.sigma_apply ArithmeticFunction.sigma_apply
@@ -911,10 +929,12 @@ def cardFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.length, by simp⟩
#align nat.arithmetic_function.card_factors ArithmeticFunction.cardFactors
--- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[ArithmeticFunction] notation "Ω" => ArithmeticFunction.cardFactors
+@[inherit_doc]
+scoped[ArithmeticFunction.Omega] notation "Ω" => ArithmeticFunction.cardFactors
+
theorem cardFactors_apply {n : ℕ} : Ω n = n.factors.length :=
rfl
#align nat.arithmetic_function.card_factors_apply ArithmeticFunction.cardFactors_apply
@@ -965,10 +985,12 @@ def cardDistinctFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.dedup.length, by simp⟩
#align nat.arithmetic_function.card_distinct_factors ArithmeticFunction.cardDistinctFactors
--- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[ArithmeticFunction] notation "ω" => ArithmeticFunction.cardDistinctFactors
+@[inherit_doc]
+scoped[ArithmeticFunction.omega] notation "ω" => ArithmeticFunction.cardDistinctFactors
+
theorem cardDistinctFactors_zero : ω 0 = 0 := by simp
#align nat.arithmetic_function.card_distinct_factors_zero ArithmeticFunction.cardDistinctFactors_zero
@@ -1008,10 +1030,12 @@ def moebius : ArithmeticFunction ℤ :=
⟨fun n => if Squarefree n then (-1) ^ cardFactors n else 0, by simp⟩
#align nat.arithmetic_function.moebius ArithmeticFunction.moebius
--- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[ArithmeticFunction] notation "μ" => ArithmeticFunction.moebius
+@[inherit_doc]
+scoped[ArithmeticFunction.Moebius] notation "μ" => ArithmeticFunction.moebius
+
@[simp]
theorem moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) : μ n = (-1) ^ cardFactors n :=
if_pos h
@@ -63,7 +63,7 @@ open Finset
open BigOperators
-namespace Nat
+open Nat
variable (R : Type*)
@@ -72,7 +72,7 @@ variable (R : Type*)
Dirichlet convolution. -/
def ArithmeticFunction [Zero R] :=
ZeroHom ℕ R
-#align nat.arithmetic_function Nat.ArithmeticFunction
+#align nat.arithmetic_function ArithmeticFunction
instance ArithmeticFunction.zero [Zero R] : Zero (ArithmeticFunction R) :=
inferInstanceAs (Zero (ZeroHom ℕ R))
@@ -93,7 +93,7 @@ instance : FunLike (ArithmeticFunction R) ℕ R :=
@[simp]
theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f := rfl
-#align nat.arithmetic_function.to_fun_eq Nat.ArithmeticFunction.toFun_eq
+#align nat.arithmetic_function.to_fun_eq ArithmeticFunction.toFun_eq
@[simp]
theorem coe_mk (f : ℕ → R) (hf) : @DFunLike.coe (ArithmeticFunction R) _ _ _
@@ -102,25 +102,25 @@ theorem coe_mk (f : ℕ → R) (hf) : @DFunLike.coe (ArithmeticFunction R) _ _ _
@[simp]
theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
ZeroHom.map_zero' f
-#align nat.arithmetic_function.map_zero Nat.ArithmeticFunction.map_zero
+#align nat.arithmetic_function.map_zero ArithmeticFunction.map_zero
theorem coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g :=
DFunLike.coe_fn_eq
-#align nat.arithmetic_function.coe_inj Nat.ArithmeticFunction.coe_inj
+#align nat.arithmetic_function.coe_inj ArithmeticFunction.coe_inj
@[simp]
theorem zero_apply {x : ℕ} : (0 : ArithmeticFunction R) x = 0 :=
ZeroHom.zero_apply x
-#align nat.arithmetic_function.zero_apply Nat.ArithmeticFunction.zero_apply
+#align nat.arithmetic_function.zero_apply ArithmeticFunction.zero_apply
@[ext]
theorem ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g :=
ZeroHom.ext h
-#align nat.arithmetic_function.ext Nat.ArithmeticFunction.ext
+#align nat.arithmetic_function.ext ArithmeticFunction.ext
theorem ext_iff {f g : ArithmeticFunction R} : f = g ↔ ∀ x, f x = g x :=
DFunLike.ext_iff
-#align nat.arithmetic_function.ext_iff Nat.ArithmeticFunction.ext_iff
+#align nat.arithmetic_function.ext_iff ArithmeticFunction.ext_iff
section One
@@ -131,17 +131,17 @@ instance one : One (ArithmeticFunction R) :=
theorem one_apply {x : ℕ} : (1 : ArithmeticFunction R) x = ite (x = 1) 1 0 :=
rfl
-#align nat.arithmetic_function.one_apply Nat.ArithmeticFunction.one_apply
+#align nat.arithmetic_function.one_apply ArithmeticFunction.one_apply
@[simp]
theorem one_one : (1 : ArithmeticFunction R) 1 = 1 :=
rfl
-#align nat.arithmetic_function.one_one Nat.ArithmeticFunction.one_one
+#align nat.arithmetic_function.one_one ArithmeticFunction.one_one
@[simp]
theorem one_apply_ne {x : ℕ} (h : x ≠ 1) : (1 : ArithmeticFunction R) x = 0 :=
if_neg h
-#align nat.arithmetic_function.one_apply_ne Nat.ArithmeticFunction.one_apply_ne
+#align nat.arithmetic_function.one_apply_ne ArithmeticFunction.one_apply_ne
end One
@@ -156,18 +156,18 @@ def natToArithmeticFunction [AddMonoidWithOne R] :
instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
⟨natToArithmeticFunction⟩
-#align nat.arithmetic_function.nat_coe Nat.ArithmeticFunction.natCoe
+#align nat.arithmetic_function.nat_coe ArithmeticFunction.natCoe
@[simp]
theorem natCoe_nat (f : ArithmeticFunction ℕ) : natToArithmeticFunction f = f :=
ext fun _ => cast_id _
-#align nat.arithmetic_function.nat_coe_nat Nat.ArithmeticFunction.natCoe_nat
+#align nat.arithmetic_function.nat_coe_nat ArithmeticFunction.natCoe_nat
@[simp]
theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x :=
rfl
-#align nat.arithmetic_function.nat_coe_apply Nat.ArithmeticFunction.natCoe_apply
+#align nat.arithmetic_function.nat_coe_apply ArithmeticFunction.natCoe_apply
/-- 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. -/
@@ -178,38 +178,38 @@ def ofInt [AddGroupWithOne R] :
instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
⟨ofInt⟩
-#align nat.arithmetic_function.int_coe Nat.ArithmeticFunction.intCoe
+#align nat.arithmetic_function.int_coe ArithmeticFunction.intCoe
@[simp]
theorem intCoe_int (f : ArithmeticFunction ℤ) : ofInt f = f :=
ext fun _ => Int.cast_id
-#align nat.arithmetic_function.int_coe_int Nat.ArithmeticFunction.intCoe_int
+#align nat.arithmetic_function.int_coe_int ArithmeticFunction.intCoe_int
@[simp]
theorem intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ} :
(f : ArithmeticFunction R) x = f x := rfl
-#align nat.arithmetic_function.int_coe_apply Nat.ArithmeticFunction.intCoe_apply
+#align nat.arithmetic_function.int_coe_apply ArithmeticFunction.intCoe_apply
@[simp]
theorem coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} :
((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = (f : ArithmeticFunction R) := by
ext
simp
-#align nat.arithmetic_function.coe_coe Nat.ArithmeticFunction.coe_coe
+#align nat.arithmetic_function.coe_coe ArithmeticFunction.coe_coe
@[simp]
theorem natCoe_one [AddMonoidWithOne R] :
((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 := by
ext n
simp [one_apply]
-#align nat.arithmetic_function.nat_coe_one Nat.ArithmeticFunction.natCoe_one
+#align nat.arithmetic_function.nat_coe_one ArithmeticFunction.natCoe_one
@[simp]
theorem intCoe_one [AddGroupWithOne R] : ((1 : ArithmeticFunction ℤ) :
ArithmeticFunction R) = 1 := by
ext n
simp [one_apply]
-#align nat.arithmetic_function.int_coe_one Nat.ArithmeticFunction.intCoe_one
+#align nat.arithmetic_function.int_coe_one ArithmeticFunction.intCoe_one
section AddMonoid
@@ -221,7 +221,7 @@ instance add : Add (ArithmeticFunction R) :=
@[simp]
theorem add_apply {f g : ArithmeticFunction R} {n : ℕ} : (f + g) n = f n + g n :=
rfl
-#align nat.arithmetic_function.add_apply Nat.ArithmeticFunction.add_apply
+#align nat.arithmetic_function.add_apply ArithmeticFunction.add_apply
instance instAddMonoid : AddMonoid (ArithmeticFunction R) :=
{ ArithmeticFunction.zero R,
@@ -229,7 +229,7 @@ instance instAddMonoid : AddMonoid (ArithmeticFunction R) :=
add_assoc := fun _ _ _ => ext fun _ => add_assoc _ _ _
zero_add := fun _ => ext fun _ => zero_add _
add_zero := fun _ => ext fun _ => add_zero _ }
-#align nat.arithmetic_function.add_monoid Nat.ArithmeticFunction.instAddMonoid
+#align nat.arithmetic_function.add_monoid ArithmeticFunction.instAddMonoid
end AddMonoid
@@ -239,7 +239,7 @@ instance instAddMonoidWithOne [AddMonoidWithOne R] : AddMonoidWithOne (Arithmeti
natCast := fun n => ⟨fun x => if x = 1 then (n : R) else 0, by simp⟩
natCast_zero := by ext; simp
natCast_succ := fun n => by ext x; by_cases h : x = 1 <;> simp [h] }
-#align nat.arithmetic_function.add_monoid_with_one Nat.ArithmeticFunction.instAddMonoidWithOne
+#align nat.arithmetic_function.add_monoid_with_one ArithmeticFunction.instAddMonoidWithOne
instance instAddCommMonoid [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) :=
{ ArithmeticFunction.instAddMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ }
@@ -266,7 +266,7 @@ instance : SMul (ArithmeticFunction R) (ArithmeticFunction M) :=
theorem smul_apply {f : ArithmeticFunction R} {g : ArithmeticFunction M} {n : ℕ} :
(f • g) n = ∑ x in divisorsAntidiagonal n, f x.fst • g x.snd :=
rfl
-#align nat.arithmetic_function.smul_apply Nat.ArithmeticFunction.smul_apply
+#align nat.arithmetic_function.smul_apply ArithmeticFunction.smul_apply
end SMul
@@ -279,24 +279,24 @@ instance [Semiring R] : Mul (ArithmeticFunction R) :=
theorem mul_apply [Semiring R] {f g : ArithmeticFunction R} {n : ℕ} :
(f * g) n = ∑ x in divisorsAntidiagonal n, f x.fst * g x.snd :=
rfl
-#align nat.arithmetic_function.mul_apply Nat.ArithmeticFunction.mul_apply
+#align nat.arithmetic_function.mul_apply ArithmeticFunction.mul_apply
theorem mul_apply_one [Semiring R] {f g : ArithmeticFunction R} : (f * g) 1 = f 1 * g 1 := by simp
-#align nat.arithmetic_function.mul_apply_one Nat.ArithmeticFunction.mul_apply_one
+#align nat.arithmetic_function.mul_apply_one ArithmeticFunction.mul_apply_one
@[simp, norm_cast]
theorem natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} :
(↑(f * g) : ArithmeticFunction R) = f * g := by
ext n
simp
-#align nat.arithmetic_function.nat_coe_mul Nat.ArithmeticFunction.natCoe_mul
+#align nat.arithmetic_function.nat_coe_mul ArithmeticFunction.natCoe_mul
@[simp, norm_cast]
theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
(↑(f * g) : ArithmeticFunction R) = ↑f * g := by
ext n
simp
-#align nat.arithmetic_function.int_coe_mul Nat.ArithmeticFunction.intCoe_mul
+#align nat.arithmetic_function.int_coe_mul ArithmeticFunction.intCoe_mul
section Module
@@ -308,7 +308,7 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
simp only [mul_apply, smul_apply, sum_smul, mul_smul, smul_sum, Finset.sum_sigma']
apply Finset.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)
-#align nat.arithmetic_function.mul_smul' Nat.ArithmeticFunction.mul_smul'
+#align nat.arithmetic_function.mul_smul' ArithmeticFunction.mul_smul'
theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b = b := by
ext x
@@ -330,7 +330,7 @@ theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b
tauto
simp [y1ne]
-#align nat.arithmetic_function.one_smul' Nat.ArithmeticFunction.one_smul'
+#align nat.arithmetic_function.one_smul' ArithmeticFunction.one_smul'
end Module
@@ -359,7 +359,7 @@ instance instMonoid : Monoid (ArithmeticFunction R) :=
tauto
simp [y2ne]
mul_assoc := mul_smul' }
-#align nat.arithmetic_function.monoid Nat.ArithmeticFunction.instMonoid
+#align nat.arithmetic_function.monoid ArithmeticFunction.instMonoid
instance instSemiring : Semiring (ArithmeticFunction R) :=
-- porting note: I reorganized this instance
@@ -378,7 +378,7 @@ instance instSemiring : Semiring (ArithmeticFunction R) :=
right_distrib := fun a b c => by
ext
simp only [← sum_add_distrib, add_mul, mul_apply, add_apply] }
-#align nat.arithmetic_function.semiring Nat.ArithmeticFunction.instSemiring
+#align nat.arithmetic_function.semiring ArithmeticFunction.instSemiring
end Semiring
@@ -416,20 +416,20 @@ section Zeta
/-- `ζ 0 = 0`, otherwise `ζ x = 1`. The Dirichlet Series is the Riemann `ζ`. -/
def zeta : ArithmeticFunction ℕ :=
⟨fun x => ite (x = 0) 0 1, rfl⟩
-#align nat.arithmetic_function.zeta Nat.ArithmeticFunction.zeta
+#align nat.arithmetic_function.zeta ArithmeticFunction.zeta
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
-scoped[Nat.ArithmeticFunction] notation "ζ" => Nat.ArithmeticFunction.zeta
+scoped[ArithmeticFunction] notation "ζ" => ArithmeticFunction.zeta
@[simp]
theorem zeta_apply {x : ℕ} : ζ x = if x = 0 then 0 else 1 :=
rfl
-#align nat.arithmetic_function.zeta_apply Nat.ArithmeticFunction.zeta_apply
+#align nat.arithmetic_function.zeta_apply ArithmeticFunction.zeta_apply
theorem zeta_apply_ne {x : ℕ} (h : x ≠ 0) : ζ x = 1 :=
if_neg h
-#align nat.arithmetic_function.zeta_apply_ne Nat.ArithmeticFunction.zeta_apply_ne
+#align nat.arithmetic_function.zeta_apply_ne ArithmeticFunction.zeta_apply_ne
-- Porting note: removed `@[simp]`, LHS not in normal form
theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
@@ -441,13 +441,13 @@ theorem coe_zeta_smul_apply {M} [Semiring R] [AddCommMonoid M] [Module R M]
rcases mem_divisorsAntidiagonal.1 hi with ⟨rfl, h⟩
rw [natCoe_apply, zeta_apply_ne (left_ne_zero_of_mul h), cast_one, one_smul]
· rw [← map_div_left_divisors, sum_map, Function.Embedding.coeFn_mk]
-#align nat.arithmetic_function.coe_zeta_smul_apply Nat.ArithmeticFunction.coe_zeta_smul_apply
+#align nat.arithmetic_function.coe_zeta_smul_apply ArithmeticFunction.coe_zeta_smul_apply
-- Porting note: removed `@[simp]` to make the linter happy.
theorem coe_zeta_mul_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
(↑ζ * f) x = ∑ i in divisors x, f i :=
coe_zeta_smul_apply
-#align nat.arithmetic_function.coe_zeta_mul_apply Nat.ArithmeticFunction.coe_zeta_mul_apply
+#align nat.arithmetic_function.coe_zeta_mul_apply ArithmeticFunction.coe_zeta_mul_apply
-- Porting note: removed `@[simp]` to make the linter happy.
theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
@@ -458,17 +458,17 @@ theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
rcases mem_divisorsAntidiagonal.1 hi with ⟨rfl, h⟩
rw [natCoe_apply, zeta_apply_ne (right_ne_zero_of_mul h), cast_one, mul_one]
· rw [← map_div_right_divisors, sum_map, Function.Embedding.coeFn_mk]
-#align nat.arithmetic_function.coe_mul_zeta_apply Nat.ArithmeticFunction.coe_mul_zeta_apply
+#align nat.arithmetic_function.coe_mul_zeta_apply ArithmeticFunction.coe_mul_zeta_apply
theorem zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (ζ * f) x = ∑ i in divisors x, f i :=
coe_zeta_mul_apply
--porting note: was `by rw [← nat_coe_nat ζ, coe_zeta_mul_apply]`. Is this `theorem` obsolete?
-#align nat.arithmetic_function.zeta_mul_apply Nat.ArithmeticFunction.zeta_mul_apply
+#align nat.arithmetic_function.zeta_mul_apply ArithmeticFunction.zeta_mul_apply
theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑ i in divisors x, f i :=
coe_mul_zeta_apply
--porting note: was `by rw [← natCoe_nat ζ, coe_mul_zeta_apply]`. Is this `theorem` obsolete=
-#align nat.arithmetic_function.mul_zeta_apply Nat.ArithmeticFunction.mul_zeta_apply
+#align nat.arithmetic_function.mul_zeta_apply ArithmeticFunction.mul_zeta_apply
end Zeta
@@ -479,17 +479,17 @@ section Pmul
/-- This is the pointwise product of `ArithmeticFunction`s. -/
def pmul [MulZeroClass R] (f g : ArithmeticFunction R) : ArithmeticFunction R :=
⟨fun x => f x * g x, by simp⟩
-#align nat.arithmetic_function.pmul Nat.ArithmeticFunction.pmul
+#align nat.arithmetic_function.pmul ArithmeticFunction.pmul
@[simp]
theorem pmul_apply [MulZeroClass R] {f g : ArithmeticFunction R} {x : ℕ} : f.pmul g x = f x * g x :=
rfl
-#align nat.arithmetic_function.pmul_apply Nat.ArithmeticFunction.pmul_apply
+#align nat.arithmetic_function.pmul_apply ArithmeticFunction.pmul_apply
theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g = g.pmul f := by
ext
simp [mul_comm]
-#align nat.arithmetic_function.pmul_comm Nat.ArithmeticFunction.pmul_comm
+#align nat.arithmetic_function.pmul_comm ArithmeticFunction.pmul_comm
section NonAssocSemiring
@@ -499,13 +499,13 @@ variable [NonAssocSemiring R]
theorem pmul_zeta (f : ArithmeticFunction R) : f.pmul ↑ζ = f := by
ext x
cases x <;> simp [Nat.succ_ne_zero]
-#align nat.arithmetic_function.pmul_zeta Nat.ArithmeticFunction.pmul_zeta
+#align nat.arithmetic_function.pmul_zeta ArithmeticFunction.pmul_zeta
@[simp]
theorem zeta_pmul (f : ArithmeticFunction R) : (ζ : ArithmeticFunction R).pmul f = f := by
ext x
cases x <;> simp [Nat.succ_ne_zero]
-#align nat.arithmetic_function.zeta_pmul Nat.ArithmeticFunction.zeta_pmul
+#align nat.arithmetic_function.zeta_pmul ArithmeticFunction.zeta_pmul
end NonAssocSemiring
@@ -514,30 +514,30 @@ variable [Semiring R]
/-- This is the pointwise power of `ArithmeticFunction`s. -/
def ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
if h0 : k = 0 then ζ else ⟨fun x ↦ f x ^ k, by simp_rw [map_zero, zero_pow h0]⟩
-#align nat.arithmetic_function.ppow Nat.ArithmeticFunction.ppow
+#align nat.arithmetic_function.ppow ArithmeticFunction.ppow
@[simp]
theorem ppow_zero {f : ArithmeticFunction R} : f.ppow 0 = ζ := by rw [ppow, dif_pos rfl]
-#align nat.arithmetic_function.ppow_zero Nat.ArithmeticFunction.ppow_zero
+#align nat.arithmetic_function.ppow_zero ArithmeticFunction.ppow_zero
@[simp]
theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppow k x = f x ^ k := by
- rw [ppow, dif_neg (ne_of_gt kpos)]
+ rw [ppow, dif_neg (Nat.ne_of_gt kpos)]
rfl
-#align nat.arithmetic_function.ppow_apply Nat.ArithmeticFunction.ppow_apply
+#align nat.arithmetic_function.ppow_apply ArithmeticFunction.ppow_apply
theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) := by
ext x
rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ]
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ Nat.ArithmeticFunction.ppow_succ
+#align nat.arithmetic_function.ppow_succ ArithmeticFunction.ppow_succ
theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
f.ppow (k + 1) = (f.ppow k).pmul f := by
ext x
rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ']
induction k <;> simp
-#align nat.arithmetic_function.ppow_succ' Nat.ArithmeticFunction.ppow_succ'
+#align nat.arithmetic_function.ppow_succ' ArithmeticFunction.ppow_succ'
end Pmul
@@ -585,7 +585,7 @@ end ProdPrimeFactors
/-- 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
-#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
+#align nat.arithmetic_function.is_multiplicative ArithmeticFunction.IsMultiplicative
namespace IsMultiplicative
@@ -596,17 +596,17 @@ variable [MonoidWithZero R]
@[simp]
theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
h.1
-#align nat.arithmetic_function.is_multiplicative.map_one Nat.ArithmeticFunction.IsMultiplicative.map_one
+#align nat.arithmetic_function.is_multiplicative.map_one ArithmeticFunction.IsMultiplicative.map_one
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
(h : m.Coprime n) : f (m * n) = f m * f n :=
hf.2 h
-#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
+#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
end MonoidWithZero
-theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
+theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : ArithmeticFunction R}
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
@@ -615,7 +615,7 @@ theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.A
rw [coe_insert, Set.pairwise_insert_of_symmetric (Coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact .prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
-#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
+#align nat.arithmetic_function.is_multiplicative.map_prod ArithmeticFunction.IsMultiplicative.map_prod
theorem map_prod_of_prime [CommSemiring R] {f : ArithmeticFunction R}
(h_mult : ArithmeticFunction.IsMultiplicative f)
@@ -633,13 +633,13 @@ theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicati
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
-#align nat.arithmetic_function.is_multiplicative.nat_cast Nat.ArithmeticFunction.IsMultiplicative.nat_cast
+#align nat.arithmetic_function.is_multiplicative.nat_cast ArithmeticFunction.IsMultiplicative.nat_cast
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
-#align nat.arithmetic_function.is_multiplicative.int_cast Nat.ArithmeticFunction.IsMultiplicative.int_cast
+#align nat.arithmetic_function.is_multiplicative.int_cast ArithmeticFunction.IsMultiplicative.int_cast
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f * g) := by
@@ -700,14 +700,14 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
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
-#align nat.arithmetic_function.is_multiplicative.mul Nat.ArithmeticFunction.IsMultiplicative.mul
+#align nat.arithmetic_function.is_multiplicative.mul ArithmeticFunction.IsMultiplicative.mul
theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f.pmul g) :=
⟨by simp [hf, hg], fun {m n} cop => by
simp only [pmul_apply, hf.map_mul_of_coprime cop, hg.map_mul_of_coprime cop]
ring⟩
-#align nat.arithmetic_function.is_multiplicative.pmul Nat.ArithmeticFunction.IsMultiplicative.pmul
+#align nat.arithmetic_function.is_multiplicative.pmul ArithmeticFunction.IsMultiplicative.pmul
theorem pdiv [CommGroupWithZero R] {f g : ArithmeticFunction R} (hf : IsMultiplicative f)
(hg : IsMultiplicative g) : IsMultiplicative (pdiv f g) :=
@@ -723,7 +723,7 @@ theorem multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunct
(hf : f.IsMultiplicative) {n : ℕ} (hn : n ≠ 0) :
f n = n.factorization.prod fun p k => f (p ^ k) :=
multiplicative_factorization f (fun _ _ => hf.2) hf.1 hn
-#align nat.arithmetic_function.is_multiplicative.multiplicative_factorization Nat.ArithmeticFunction.IsMultiplicative.multiplicative_factorization
+#align nat.arithmetic_function.is_multiplicative.multiplicative_factorization ArithmeticFunction.IsMultiplicative.multiplicative_factorization
/-- A recapitulation of the definition of multiplicative that is simpler for proofs -/
theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
@@ -735,7 +735,7 @@ theorem iff_ne_zero [MonoidWithZero R] {f : ArithmeticFunction R} :
rcases eq_or_ne n 0 with (rfl | hn)
· simp
exact h hm hn hmn
-#align nat.arithmetic_function.is_multiplicative.iff_ne_zero Nat.ArithmeticFunction.IsMultiplicative.iff_ne_zero
+#align nat.arithmetic_function.is_multiplicative.iff_ne_zero ArithmeticFunction.IsMultiplicative.iff_ne_zero
/-- Two multiplicative functions `f` and `g` are equal if and only if
they agree on prime powers -/
@@ -751,7 +751,7 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
· rw [hn, ArithmeticFunction.map_zero, ArithmeticFunction.map_zero]
rw [multiplicative_factorization f hf hn, multiplicative_factorization g hg hn]
exact Finset.prod_congr rfl fun p hp ↦ h p _ (Nat.prime_of_mem_primeFactors hp)
-#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
+#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
theorem prodPrimeFactors [CommMonoidWithZero R] (f : ℕ → R) :
IsMultiplicative (prodPrimeFactors f) := by
@@ -781,13 +781,13 @@ 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]
+ · simp only [hx, f.map_zero, zero_mul, Nat.lcm_zero_left, Nat.gcd_zero_left]
by_cases hy : y = 0
- · simp only [hy, f.map_zero, mul_zero, lcm_zero_right, gcd_zero_right, zero_mul]
+ · simp only [hy, f.map_zero, mul_zero, Nat.lcm_zero_right, Nat.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
- · intro i; rw [pow_zero, hf.1]
+ · intro i; rw [Nat.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))]
@@ -812,53 +812,53 @@ section SpecialFunctions
nonrec -- porting note: added
def id : ArithmeticFunction ℕ :=
⟨id, rfl⟩
-#align nat.arithmetic_function.id Nat.ArithmeticFunction.id
+#align nat.arithmetic_function.id ArithmeticFunction.id
@[simp]
theorem id_apply {x : ℕ} : id x = x :=
rfl
-#align nat.arithmetic_function.id_apply Nat.ArithmeticFunction.id_apply
+#align nat.arithmetic_function.id_apply ArithmeticFunction.id_apply
/-- `pow k n = n ^ k`, except `pow 0 0 = 0`. -/
def pow (k : ℕ) : ArithmeticFunction ℕ :=
id.ppow k
-#align nat.arithmetic_function.pow Nat.ArithmeticFunction.pow
+#align nat.arithmetic_function.pow ArithmeticFunction.pow
@[simp]
theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k := by
cases k
· simp [pow]
rename_i k -- porting note: added
- simp [pow, (ne_of_lt (Nat.succ_pos k)).symm]
-#align nat.arithmetic_function.pow_apply Nat.ArithmeticFunction.pow_apply
+ simp [pow, k.succ_pos.ne']
+#align nat.arithmetic_function.pow_apply ArithmeticFunction.pow_apply
theorem pow_zero_eq_zeta : pow 0 = ζ := by
ext n
simp
-#align nat.arithmetic_function.pow_zero_eq_zeta Nat.ArithmeticFunction.pow_zero_eq_zeta
+#align nat.arithmetic_function.pow_zero_eq_zeta ArithmeticFunction.pow_zero_eq_zeta
/-- `σ k n` is the sum of the `k`th powers of the divisors of `n` -/
def sigma (k : ℕ) : ArithmeticFunction ℕ :=
⟨fun n => ∑ d in divisors n, d ^ k, by simp⟩
-#align nat.arithmetic_function.sigma Nat.ArithmeticFunction.sigma
+#align nat.arithmetic_function.sigma ArithmeticFunction.sigma
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
-scoped[Nat.ArithmeticFunction] notation "σ" => Nat.ArithmeticFunction.sigma
+scoped[ArithmeticFunction] notation "σ" => ArithmeticFunction.sigma
theorem sigma_apply {k n : ℕ} : σ k n = ∑ d in divisors n, d ^ k :=
rfl
-#align nat.arithmetic_function.sigma_apply Nat.ArithmeticFunction.sigma_apply
+#align nat.arithmetic_function.sigma_apply ArithmeticFunction.sigma_apply
theorem sigma_one_apply (n : ℕ) : σ 1 n = ∑ d in divisors n, d := by simp [sigma_apply]
-#align nat.arithmetic_function.sigma_one_apply Nat.ArithmeticFunction.sigma_one_apply
+#align nat.arithmetic_function.sigma_one_apply ArithmeticFunction.sigma_one_apply
theorem sigma_zero_apply (n : ℕ) : σ 0 n = (divisors n).card := by simp [sigma_apply]
-#align nat.arithmetic_function.sigma_zero_apply Nat.ArithmeticFunction.sigma_zero_apply
+#align nat.arithmetic_function.sigma_zero_apply ArithmeticFunction.sigma_zero_apply
theorem sigma_zero_apply_prime_pow {p i : ℕ} (hp : p.Prime) : σ 0 (p ^ i) = i + 1 := by
rw [sigma_zero_apply, divisors_prime_pow hp, card_map, card_range]
-#align nat.arithmetic_function.sigma_zero_apply_prime_pow Nat.ArithmeticFunction.sigma_zero_apply_prime_pow
+#align nat.arithmetic_function.sigma_zero_apply_prime_pow ArithmeticFunction.sigma_zero_apply_prime_pow
theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k := by
ext
@@ -868,7 +868,7 @@ theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k := by
rw [pow_apply, if_neg (not_and_of_not_right _ _)]
contrapose! hx
simp [hx]
-#align nat.arithmetic_function.zeta_mul_pow_eq_sigma Nat.ArithmeticFunction.zeta_mul_pow_eq_sigma
+#align nat.arithmetic_function.zeta_mul_pow_eq_sigma ArithmeticFunction.zeta_mul_pow_eq_sigma
theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : ArithmeticFunction R) :=
IsMultiplicative.iff_ne_zero.2
@@ -879,15 +879,15 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
rw [one_apply_ne, one_apply_ne hm', zero_mul]
rw [Ne.def, mul_eq_one, not_and_or]
exact Or.inl hm'⟩
-#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
+#align nat.arithmetic_function.is_multiplicative_one ArithmeticFunction.isMultiplicative_one
theorem isMultiplicative_zeta : IsMultiplicative ζ :=
IsMultiplicative.iff_ne_zero.2 ⟨by simp, by simp (config := { contextual := true })⟩
-#align nat.arithmetic_function.is_multiplicative_zeta Nat.ArithmeticFunction.isMultiplicative_zeta
+#align nat.arithmetic_function.is_multiplicative_zeta ArithmeticFunction.isMultiplicative_zeta
theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id :=
⟨rfl, fun {_ _} _ => rfl⟩
-#align nat.arithmetic_function.is_multiplicative_id Nat.ArithmeticFunction.isMultiplicative_id
+#align nat.arithmetic_function.is_multiplicative_id ArithmeticFunction.isMultiplicative_id
theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
{k : ℕ} : IsMultiplicative (f.ppow k) := by
@@ -895,35 +895,35 @@ theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf :
· exact isMultiplicative_zeta.nat_cast
· rw [ppow_succ]
apply hf.pmul hi
-#align nat.arithmetic_function.is_multiplicative.ppow Nat.ArithmeticFunction.IsMultiplicative.ppow
+#align nat.arithmetic_function.is_multiplicative.ppow ArithmeticFunction.IsMultiplicative.ppow
theorem isMultiplicative_pow {k : ℕ} : IsMultiplicative (pow k) :=
isMultiplicative_id.ppow
-#align nat.arithmetic_function.is_multiplicative_pow Nat.ArithmeticFunction.isMultiplicative_pow
+#align nat.arithmetic_function.is_multiplicative_pow ArithmeticFunction.isMultiplicative_pow
theorem isMultiplicative_sigma {k : ℕ} : IsMultiplicative (σ k) := by
rw [← zeta_mul_pow_eq_sigma]
apply isMultiplicative_zeta.mul isMultiplicative_pow
-#align nat.arithmetic_function.is_multiplicative_sigma Nat.ArithmeticFunction.isMultiplicative_sigma
+#align nat.arithmetic_function.is_multiplicative_sigma ArithmeticFunction.isMultiplicative_sigma
/-- `Ω n` is the number of prime factors of `n`. -/
def cardFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.length, by simp⟩
-#align nat.arithmetic_function.card_factors Nat.ArithmeticFunction.cardFactors
+#align nat.arithmetic_function.card_factors ArithmeticFunction.cardFactors
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
-scoped[Nat.ArithmeticFunction] notation "Ω" => Nat.ArithmeticFunction.cardFactors
+scoped[ArithmeticFunction] notation "Ω" => ArithmeticFunction.cardFactors
theorem cardFactors_apply {n : ℕ} : Ω n = n.factors.length :=
rfl
-#align nat.arithmetic_function.card_factors_apply Nat.ArithmeticFunction.cardFactors_apply
+#align nat.arithmetic_function.card_factors_apply ArithmeticFunction.cardFactors_apply
@[simp, nolint simpNF] -- this is a `dsimp` lemma
lemma cardFactors_zero : Ω 0 = 0 := rfl
@[simp] theorem cardFactors_one : Ω 1 = 0 := rfl
-#align nat.arithmetic_function.card_factors_one Nat.ArithmeticFunction.cardFactors_one
+#align nat.arithmetic_function.card_factors_one ArithmeticFunction.cardFactors_one
@[simp]
theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime := by
@@ -935,50 +935,50 @@ theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime := by
rw [← prod_factors n.succ_ne_zero, hx, List.prod_singleton]
apply prime_of_mem_factors
rw [hx, List.mem_singleton]
-#align nat.arithmetic_function.card_factors_eq_one_iff_prime Nat.ArithmeticFunction.cardFactors_eq_one_iff_prime
+#align nat.arithmetic_function.card_factors_eq_one_iff_prime ArithmeticFunction.cardFactors_eq_one_iff_prime
theorem cardFactors_mul {m n : ℕ} (m0 : m ≠ 0) (n0 : n ≠ 0) : Ω (m * n) = Ω m + Ω n := by
rw [cardFactors_apply, cardFactors_apply, cardFactors_apply, ← Multiset.coe_card, ← factors_eq,
UniqueFactorizationMonoid.normalizedFactors_mul m0 n0, factors_eq, factors_eq,
Multiset.card_add, Multiset.coe_card, Multiset.coe_card]
-#align nat.arithmetic_function.card_factors_mul Nat.ArithmeticFunction.cardFactors_mul
+#align nat.arithmetic_function.card_factors_mul ArithmeticFunction.cardFactors_mul
theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.prod ≠ 0) :
Ω s.prod = (Multiset.map Ω s).sum := by
induction s using Multiset.induction_on with
| empty => simp
| cons ih => simp_all [cardFactors_mul, not_or]
-#align nat.arithmetic_function.card_factors_multiset_prod Nat.ArithmeticFunction.cardFactors_multiset_prod
+#align nat.arithmetic_function.card_factors_multiset_prod ArithmeticFunction.cardFactors_multiset_prod
@[simp]
theorem cardFactors_apply_prime {p : ℕ} (hp : p.Prime) : Ω p = 1 :=
cardFactors_eq_one_iff_prime.2 hp
-#align nat.arithmetic_function.card_factors_apply_prime Nat.ArithmeticFunction.cardFactors_apply_prime
+#align nat.arithmetic_function.card_factors_apply_prime ArithmeticFunction.cardFactors_apply_prime
@[simp]
theorem cardFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) : Ω (p ^ k) = k := by
rw [cardFactors_apply, hp.factors_pow, List.length_replicate]
-#align nat.arithmetic_function.card_factors_apply_prime_pow Nat.ArithmeticFunction.cardFactors_apply_prime_pow
+#align nat.arithmetic_function.card_factors_apply_prime_pow ArithmeticFunction.cardFactors_apply_prime_pow
/-- `ω n` is the number of distinct prime factors of `n`. -/
def cardDistinctFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.dedup.length, by simp⟩
-#align nat.arithmetic_function.card_distinct_factors Nat.ArithmeticFunction.cardDistinctFactors
+#align nat.arithmetic_function.card_distinct_factors ArithmeticFunction.cardDistinctFactors
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
-scoped[Nat.ArithmeticFunction] notation "ω" => Nat.ArithmeticFunction.cardDistinctFactors
+scoped[ArithmeticFunction] notation "ω" => ArithmeticFunction.cardDistinctFactors
theorem cardDistinctFactors_zero : ω 0 = 0 := by simp
-#align nat.arithmetic_function.card_distinct_factors_zero Nat.ArithmeticFunction.cardDistinctFactors_zero
+#align nat.arithmetic_function.card_distinct_factors_zero ArithmeticFunction.cardDistinctFactors_zero
@[simp]
theorem cardDistinctFactors_one : ω 1 = 0 := by simp [cardDistinctFactors]
-#align nat.arithmetic_function.card_distinct_factors_one Nat.ArithmeticFunction.cardDistinctFactors_one
+#align nat.arithmetic_function.card_distinct_factors_one ArithmeticFunction.cardDistinctFactors_one
theorem cardDistinctFactors_apply {n : ℕ} : ω n = n.factors.dedup.length :=
rfl
-#align nat.arithmetic_function.card_distinct_factors_apply Nat.ArithmeticFunction.cardDistinctFactors_apply
+#align nat.arithmetic_function.card_distinct_factors_apply ArithmeticFunction.cardDistinctFactors_apply
theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠ 0) :
ω n = Ω n ↔ Squarefree n := by
@@ -988,49 +988,49 @@ theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠
apply List.nodup_dedup
· rw [h.dedup]
rfl
-#align nat.arithmetic_function.card_distinct_factors_eq_card_factors_iff_squarefree Nat.ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree
+#align nat.arithmetic_function.card_distinct_factors_eq_card_factors_iff_squarefree ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree
@[simp]
theorem cardDistinctFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
ω (p ^ k) = 1 := by
rw [cardDistinctFactors_apply, hp.factors_pow, List.replicate_dedup hk, List.length_singleton]
-#align nat.arithmetic_function.card_distinct_factors_apply_prime_pow Nat.ArithmeticFunction.cardDistinctFactors_apply_prime_pow
+#align nat.arithmetic_function.card_distinct_factors_apply_prime_pow ArithmeticFunction.cardDistinctFactors_apply_prime_pow
@[simp]
theorem cardDistinctFactors_apply_prime {p : ℕ} (hp : p.Prime) : ω p = 1 := by
rw [← pow_one p, cardDistinctFactors_apply_prime_pow hp one_ne_zero]
-#align nat.arithmetic_function.card_distinct_factors_apply_prime Nat.ArithmeticFunction.cardDistinctFactors_apply_prime
+#align nat.arithmetic_function.card_distinct_factors_apply_prime ArithmeticFunction.cardDistinctFactors_apply_prime
/-- `μ` 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`. -/
def moebius : ArithmeticFunction ℤ :=
⟨fun n => if Squarefree n then (-1) ^ cardFactors n else 0, by simp⟩
-#align nat.arithmetic_function.moebius Nat.ArithmeticFunction.moebius
+#align nat.arithmetic_function.moebius ArithmeticFunction.moebius
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
-scoped[Nat.ArithmeticFunction] notation "μ" => Nat.ArithmeticFunction.moebius
+scoped[ArithmeticFunction] notation "μ" => ArithmeticFunction.moebius
@[simp]
theorem moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) : μ n = (-1) ^ cardFactors n :=
if_pos h
-#align nat.arithmetic_function.moebius_apply_of_squarefree Nat.ArithmeticFunction.moebius_apply_of_squarefree
+#align nat.arithmetic_function.moebius_apply_of_squarefree ArithmeticFunction.moebius_apply_of_squarefree
@[simp]
theorem moebius_eq_zero_of_not_squarefree {n : ℕ} (h : ¬Squarefree n) : μ n = 0 :=
if_neg h
-#align nat.arithmetic_function.moebius_eq_zero_of_not_squarefree Nat.ArithmeticFunction.moebius_eq_zero_of_not_squarefree
+#align nat.arithmetic_function.moebius_eq_zero_of_not_squarefree ArithmeticFunction.moebius_eq_zero_of_not_squarefree
theorem moebius_apply_one : μ 1 = 1 := by simp
-#align nat.arithmetic_function.moebius_apply_one Nat.ArithmeticFunction.moebius_apply_one
+#align nat.arithmetic_function.moebius_apply_one ArithmeticFunction.moebius_apply_one
theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n := by
constructor <;> intro h
· contrapose! h
simp [h]
· simp [h, pow_ne_zero]
-#align nat.arithmetic_function.moebius_ne_zero_iff_squarefree Nat.ArithmeticFunction.moebius_ne_zero_iff_squarefree
+#align nat.arithmetic_function.moebius_ne_zero_iff_squarefree ArithmeticFunction.moebius_ne_zero_iff_squarefree
theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 := by
constructor <;> intro h
@@ -1038,11 +1038,11 @@ theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n =
rw [moebius_apply_of_squarefree h]
apply neg_one_pow_eq_or
· rcases h with (h | h) <;> simp [h]
-#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or Nat.ArithmeticFunction.moebius_ne_zero_iff_eq_or
+#align nat.arithmetic_function.moebius_ne_zero_iff_eq_or ArithmeticFunction.moebius_ne_zero_iff_eq_or
theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
rw [moebius_apply_of_squarefree hp.squarefree, cardFactors_apply_prime hp, pow_one]
-#align nat.arithmetic_function.moebius_apply_prime Nat.ArithmeticFunction.moebius_apply_prime
+#align nat.arithmetic_function.moebius_apply_prime ArithmeticFunction.moebius_apply_prime
theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
μ (p ^ k) = if k = 1 then -1 else 0 := by
@@ -1051,7 +1051,7 @@ theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
rw [moebius_eq_zero_of_not_squarefree]
rw [squarefree_pow_iff hp.ne_one hk, not_and_or]
exact Or.inr h
-#align nat.arithmetic_function.moebius_apply_prime_pow Nat.ArithmeticFunction.moebius_apply_prime_pow
+#align nat.arithmetic_function.moebius_apply_prime_pow ArithmeticFunction.moebius_apply_prime_pow
theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' : ¬n.Prime) :
μ n = 0 := by
@@ -1059,7 +1059,7 @@ theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' :
rw [moebius_apply_prime_pow hp hk.ne', if_neg]
rintro rfl
exact hn' (by simpa)
-#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime Nat.ArithmeticFunction.moebius_apply_isPrimePow_not_prime
+#align nat.arithmetic_function.moebius_apply_is_prime_pow_not_prime ArithmeticFunction.moebius_apply_isPrimePow_not_prime
theorem isMultiplicative_moebius : IsMultiplicative μ := by
rw [IsMultiplicative.iff_ne_zero]
@@ -1067,7 +1067,7 @@ theorem isMultiplicative_moebius : IsMultiplicative μ := by
simp only [moebius, ZeroHom.coe_mk, coe_mk, ZeroHom.toFun_eq_coe, Eq.ndrec, ZeroHom.coe_mk,
IsUnit.mul_iff, Nat.isUnit_iff, squarefree_mul hnm, ite_zero_mul_ite_zero,
cardFactors_mul hn hm, pow_add]
-#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
+#align nat.arithmetic_function.is_multiplicative_moebius ArithmeticFunction.isMultiplicative_moebius
theorem IsMultiplicative.prodPrimeFactors_one_add_of_squarefree [CommSemiring R]
{f : ArithmeticFunction R} (h_mult : f.IsMultiplicative) {n : ℕ} (hn : Squarefree n) :
@@ -1098,7 +1098,7 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
refine' recOnPosPrimePosCoprime _ _ _ _ n
· intro p n hp hn
rw [coe_mul_zeta_apply, sum_divisors_prime_pow hp, sum_range_succ']
- simp_rw [pow_zero, moebius_apply_one,
+ simp_rw [Nat.pow_zero, moebius_apply_one,
moebius_apply_prime_pow hp (Nat.succ_ne_zero _), Nat.succ_inj', sum_ite_eq', mem_range,
if_pos hn, add_left_neg]
rw [one_apply_ne]
@@ -1111,22 +1111,22 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
rw [IsMultiplicative.map_mul_of_coprime _ hab, ha', hb',
IsMultiplicative.map_mul_of_coprime isMultiplicative_one hab]
exact isMultiplicative_moebius.mul isMultiplicative_zeta.nat_cast
-#align nat.arithmetic_function.moebius_mul_coe_zeta Nat.ArithmeticFunction.moebius_mul_coe_zeta
+#align nat.arithmetic_function.moebius_mul_coe_zeta ArithmeticFunction.moebius_mul_coe_zeta
@[simp]
theorem coe_zeta_mul_moebius : (ζ * μ : ArithmeticFunction ℤ) = 1 := by
rw [mul_comm, moebius_mul_coe_zeta]
-#align nat.arithmetic_function.coe_zeta_mul_moebius Nat.ArithmeticFunction.coe_zeta_mul_moebius
+#align nat.arithmetic_function.coe_zeta_mul_moebius ArithmeticFunction.coe_zeta_mul_moebius
@[simp]
theorem coe_moebius_mul_coe_zeta [Ring R] : (μ * ζ : ArithmeticFunction R) = 1 := by
rw [← coe_coe, ← intCoe_mul, moebius_mul_coe_zeta, intCoe_one]
-#align nat.arithmetic_function.coe_moebius_mul_coe_zeta Nat.ArithmeticFunction.coe_moebius_mul_coe_zeta
+#align nat.arithmetic_function.coe_moebius_mul_coe_zeta ArithmeticFunction.coe_moebius_mul_coe_zeta
@[simp]
theorem coe_zeta_mul_coe_moebius [Ring R] : (ζ * μ : ArithmeticFunction R) = 1 := by
rw [← coe_coe, ← intCoe_mul, coe_zeta_mul_moebius, intCoe_one]
-#align nat.arithmetic_function.coe_zeta_mul_coe_moebius Nat.ArithmeticFunction.coe_zeta_mul_coe_moebius
+#align nat.arithmetic_function.coe_zeta_mul_coe_moebius ArithmeticFunction.coe_zeta_mul_coe_moebius
section CommRing
@@ -1140,17 +1140,17 @@ instance : Invertible (ζ : ArithmeticFunction R) where
/-- A unit in `ArithmeticFunction R` that evaluates to `ζ`, with inverse `μ`. -/
def zetaUnit : (ArithmeticFunction R)ˣ :=
⟨ζ, μ, coe_zeta_mul_coe_moebius, coe_moebius_mul_coe_zeta⟩
-#align nat.arithmetic_function.zeta_unit Nat.ArithmeticFunction.zetaUnit
+#align nat.arithmetic_function.zeta_unit ArithmeticFunction.zetaUnit
@[simp]
theorem coe_zetaUnit : ((zetaUnit : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = ζ :=
rfl
-#align nat.arithmetic_function.coe_zeta_unit Nat.ArithmeticFunction.coe_zetaUnit
+#align nat.arithmetic_function.coe_zeta_unit ArithmeticFunction.coe_zetaUnit
@[simp]
theorem inv_zetaUnit : ((zetaUnit⁻¹ : (ArithmeticFunction R)ˣ) : ArithmeticFunction R) = μ :=
rfl
-#align nat.arithmetic_function.inv_zeta_unit Nat.ArithmeticFunction.inv_zetaUnit
+#align nat.arithmetic_function.inv_zeta_unit ArithmeticFunction.inv_zetaUnit
end CommRing
@@ -1171,7 +1171,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', if_false, ZeroHom.coe_mk]
simp only [coe_mk, succ_ne_zero, ite_false]
rw [sum_congr rfl fun x hx => ?_]
- rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors hx))]
+ rw [if_neg (Nat.pos_of_mem_divisors hx).ne']
trans μ • g' = f'
· constructor <;> intro h
· rw [← h, ← mul_smul, moebius_mul_coe_zeta, one_smul]
@@ -1187,8 +1187,8 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
-- porting note: added following `simp only`
simp only [Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
rw [sum_congr rfl fun x hx => ?_]
- rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
-#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
+ rw [if_neg (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)).ne']
+#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
/-- Möbius inversion for functions to a `Ring`. -/
theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
@@ -1198,14 +1198,14 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
apply forall_congr'
refine' fun a => imp_congr_right fun _ => (sum_congr rfl fun x _hx => _).congr_left
rw [zsmul_eq_mul]
-#align nat.arithmetic_function.sum_eq_iff_sum_mul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq
+#align nat.arithmetic_function.sum_eq_iff_sum_mul_moebius_eq ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq
/-- Möbius inversion for functions to a `CommGroup`. -/
theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
(∀ n > 0, ∏ i in n.divisors, f i = g n) ↔
∀ n > 0, ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n :=
@sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
-#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
+#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
/-- Möbius inversion for functions to a `CommGroupWithZero`. -/
theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
@@ -1231,7 +1231,7 @@ theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g :
intro x hx
rw [dif_pos (Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_antidiagonal hx)),
Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
-#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
+#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
/-- Möbius inversion for functions to an `AddCommGroup`, where the equalities only hold on a
well-behaved set. -/
@@ -1322,5 +1322,3 @@ theorem prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero [CommGroupWithZero R]
end SpecialFunctions
end ArithmeticFunction
-
-end Nat
@@ -552,7 +552,7 @@ theorem pdiv_apply [GroupWithZero R] (f g : ArithmeticFunction R) (n : ℕ) :
pdiv f g n = f n / g n := rfl
/-- This result only holds for `DivisionSemiring`s instead of `GroupWithZero`s because zeta takes
-values in ℕ, and hence the coersion requires an `AddMonoidWithOne`. TODO: Generalise zeta -/
+values in ℕ, and hence the coercion requires an `AddMonoidWithOne`. TODO: Generalise zeta -/
@[simp]
theorem pdiv_zeta [DivisionSemiring R] (f : ArithmeticFunction R) :
pdiv f zeta = f := by
f ^ n
(#9617)
This involves moving lemmas from Algebra.GroupPower.Ring
to Algebra.GroupWithZero.Basic
and changing some 0 < n
assumptions to n ≠ 0
.
From LeanAPAP
@@ -513,13 +513,7 @@ variable [Semiring R]
/-- This is the pointwise power of `ArithmeticFunction`s. -/
def ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
- if h0 : k = 0 then ζ
- else
- ⟨fun x => f x ^ k, by
- -- porting note: added next line
- dsimp only
- rw [map_zero]
- exact zero_pow (Nat.pos_of_ne_zero h0)⟩
+ if h0 : k = 0 then ζ else ⟨fun x ↦ f x ^ k, by simp_rw [map_zero, zero_pow h0]⟩
#align nat.arithmetic_function.ppow Nat.ArithmeticFunction.ppow
@[simp]
@@ -632,7 +632,7 @@ theorem map_prod_of_prime [CommSemiring R] {f : ArithmeticFunction R}
theorem map_prod_of_subset_primeFactors [CommSemiring R] {f : ArithmeticFunction R}
(h_mult : ArithmeticFunction.IsMultiplicative f) (l : ℕ)
(t : Finset ℕ) (ht : t ⊆ l.primeFactors) :
- f (∏ a in t, a) = ∏ a : ℕ in t, f a :=
+ f (∏ a in t, a) = ∏ a : ℕ in t, f a :=
map_prod_of_prime h_mult t fun _ a => prime_of_mem_primeFactors (ht a)
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
@@ -764,7 +764,7 @@ theorem prodPrimeFactors [CommMonoidWithZero R] (f : ℕ → R) :
rw [iff_ne_zero]
refine ⟨prodPrimeFactors_apply one_ne_zero, ?_⟩
intro x y hx hy hxy
- have hxy₀: x*y ≠ 0 := by exact Nat.mul_ne_zero hx hy
+ have hxy₀ : x * y ≠ 0 := mul_ne_zero hx hy
rw [prodPrimeFactors_apply hxy₀, prodPrimeFactors_apply hx, prodPrimeFactors_apply hy,
Nat.primeFactors_mul hx hy, ← Finset.prod_union hxy.disjoint_primeFactors]
@@ -778,7 +778,8 @@ theorem prodPrimeFactors_add_of_squarefree [CommSemiring R] {f g : ArithmeticFun
factors_eq]
apply Finset.sum_congr rfl
intro t ht
- erw [t.prod_val, ← prod_primeFactors_sdiff_of_squarefree hn (Finset.mem_powerset.mp ht),
+ rw [t.prod_val, Function.id_def,
+ ← prod_primeFactors_sdiff_of_squarefree hn (Finset.mem_powerset.mp ht),
hf.map_prod_of_subset_primeFactors n t (Finset.mem_powerset.mp ht),
← hg.map_prod_of_subset_primeFactors n (_ \ t) (Finset.sdiff_subset _ t)]
FunLike
(#9833)
This follows up from #9785, which renamed FunLike
to DFunLike
, by introducing a new abbreviation FunLike F α β := DFunLike F α (fun _ => β)
, to make the non-dependent use of FunLike
easier.
I searched for the pattern DFunLike.*fun
and DFunLike.*λ
in all files to replace expressions of the form DFunLike F α (fun _ => β)
with FunLike F α β
. I did this everywhere except for extends
clauses for two reasons: it would conflict with #8386, and more importantly extends
must directly refer to a structure with no unfolding of def
s or abbrev
s.
@@ -88,8 +88,8 @@ section Zero
variable [Zero R]
-- porting note: used to be `CoeFun`
-instance : DFunLike (ArithmeticFunction R) ℕ fun _ ↦ R :=
- inferInstanceAs (DFunLike (ZeroHom ℕ R) ℕ fun _ ↦ R)
+instance : FunLike (ArithmeticFunction R) ℕ R :=
+ inferInstanceAs (FunLike (ZeroHom ℕ R) ℕ R)
@[simp]
theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f := rfl
FunLike
to DFunLike
(#9785)
This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.
This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:
sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@@ -88,15 +88,15 @@ section Zero
variable [Zero R]
-- porting note: used to be `CoeFun`
-instance : FunLike (ArithmeticFunction R) ℕ fun _ ↦ R :=
- inferInstanceAs (FunLike (ZeroHom ℕ R) ℕ fun _ ↦ R)
+instance : DFunLike (ArithmeticFunction R) ℕ fun _ ↦ R :=
+ inferInstanceAs (DFunLike (ZeroHom ℕ R) ℕ fun _ ↦ R)
@[simp]
theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f := rfl
#align nat.arithmetic_function.to_fun_eq Nat.ArithmeticFunction.toFun_eq
@[simp]
-theorem coe_mk (f : ℕ → R) (hf) : @FunLike.coe (ArithmeticFunction R) _ _ _
+theorem coe_mk (f : ℕ → R) (hf) : @DFunLike.coe (ArithmeticFunction R) _ _ _
(ZeroHom.mk f hf) = f := rfl
@[simp]
@@ -105,7 +105,7 @@ theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
#align nat.arithmetic_function.map_zero Nat.ArithmeticFunction.map_zero
theorem coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g :=
- FunLike.coe_fn_eq
+ DFunLike.coe_fn_eq
#align nat.arithmetic_function.coe_inj Nat.ArithmeticFunction.coe_inj
@[simp]
@@ -119,7 +119,7 @@ theorem ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g :=
#align nat.arithmetic_function.ext Nat.ArithmeticFunction.ext
theorem ext_iff {f g : ArithmeticFunction R} : f = g ↔ ∀ x, f x = g x :=
- FunLike.ext_iff
+ DFunLike.ext_iff
#align nat.arithmetic_function.ext_iff Nat.ArithmeticFunction.ext_iff
section One
A bunch of lemmas in Algebra.BigOperators.Ring
were not about rings. This PR moves them along with some lemmas from Data.Fintype.BigOperators
to their correct place.
I create a new file with the content from #6605 to avoid importing Fin
material in finset files as a result.
From LeanAPAP
@@ -652,7 +652,7 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
refine ⟨by simp [hf.1, hg.1], ?_⟩
simp only [mul_apply]
intro m n cop
- rw [sum_mul_sum]
+ 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
$
with <|
(#9319)
See Zulip thread for the discussion.
@@ -1080,7 +1080,7 @@ theorem IsMultiplicative.prodPrimeFactors_one_add_of_squarefree [CommSemiring R]
trans (∏ᵖ p ∣ n, ((ζ:ArithmeticFunction R) + f) p)
· simp_rw [prodPrimeFactors_apply hn.ne_zero, add_apply, natCoe_apply]
apply Finset.prod_congr rfl; intro p hp;
- rw [zeta_apply_ne (prime_of_mem_factors $ List.mem_toFinset.mp hp).ne_zero, cast_one]
+ rw [zeta_apply_ne (prime_of_mem_factors <| List.mem_toFinset.mp hp).ne_zero, cast_one]
rw [isMultiplicative_zeta.nat_cast.prodPrimeFactors_add_of_squarefree h_mult hn,
coe_zeta_mul_apply]
@@ -1251,7 +1251,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq_on [AddCommGroup R] {f g : ℕ → R}
suffices ∑ d in n.divisors, μ (n/d) • G d = f n from by
rw [Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • g y), ← this, sum_congr rfl]
intro d hd
- rw [← h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
+ rw [← h d (Nat.pos_of_mem_divisors hd) <| hs d n (Nat.dvd_of_mem_divisors hd) hnP]
rw [← Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • G y)]
apply sum_eq_iff_sum_smul_moebius_eq.mp _ n hn
intro _ _; rfl
@@ -1261,7 +1261,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq_on [AddCommGroup R] {f g : ℕ → R}
suffices ∑ d in n.divisors, F d = g n from by
rw [← this, sum_congr rfl]
intro d hd
- rw [← h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
+ rw [← h d (Nat.pos_of_mem_divisors hd) <| hs d n (Nat.dvd_of_mem_divisors hd) hnP]
apply sum_eq_iff_sum_smul_moebius_eq.mpr _ n hn
intro _ _; rfl
@@ -586,10 +586,6 @@ theorem prodPrimeFactors_apply [CommMonoidWithZero R] {f: ℕ → R} {n : ℕ} (
∏ᵖ p ∣ n, f p = ∏ p in n.primeFactors, f p :=
if_neg hn
-theorem prodPrimeFactors_apply_of_ne_zero [CommMonoidWithZero R] {f : ℕ → R} {n : ℕ}
- (hn : n ≠ 0) : ∏ᵖ p ∣ n, f p = ∏ p in n.primeFactors, f p :=
- prodPrimeFactors_apply hn
-
end ProdPrimeFactors
/-- Multiplicative functions -/
@@ -775,7 +771,7 @@ theorem prodPrimeFactors [CommMonoidWithZero R] (f : ℕ → R) :
theorem prodPrimeFactors_add_of_squarefree [CommSemiring R] {f g : ArithmeticFunction R}
(hf : IsMultiplicative f) (hg : IsMultiplicative g) {n : ℕ} (hn : Squarefree n) :
∏ᵖ p ∣ n, (f + g) p = (f * g) n := by
- rw [prodPrimeFactors_apply_of_ne_zero hn.ne_zero]
+ rw [prodPrimeFactors_apply hn.ne_zero]
simp_rw [add_apply (f:=f) (g:=g)]
rw [Finset.prod_add, mul_apply, sum_divisorsAntidiagonal (f · * g ·),
← divisors_filter_squarefree_of_squarefree hn, sum_divisors_filter_squarefree hn.ne_zero,
Lemmas around this were a mess, throth in terms of names, statement and location. This PR standardises everything to be in Algebra.BigOperators.Basic
and changes the lemmas to take in InjOn
and SurjOn
assumptions where possible (and where impossible make sure the hypotheses are taken in the correct order) and moves the equality of functions hypothesis last.
Also add a few lemmas that help fix downstream uses by golfing.
From LeanAPAP and LeanCamCombi
@@ -306,35 +306,8 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
(f * g) • h = f • g • h := by
ext n
simp only [mul_apply, smul_apply, sum_smul, mul_smul, smul_sum, Finset.sum_sigma']
- apply Finset.sum_bij
- pick_goal 5
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ _H
- exact ⟨(k, l * j), (l, j)⟩
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- simp only [Finset.mem_sigma, mem_divisorsAntidiagonal] at H ⊢
- rcases H with ⟨⟨rfl, n0⟩, rfl, i0⟩
- refine' ⟨⟨(mul_assoc _ _ _).symm, n0⟩, trivial, _⟩
- rw [mul_ne_zero_iff] at *
- exact ⟨i0.2, n0.2⟩
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ _H
- simp only [mul_assoc]
- · rintro ⟨⟨a, b⟩, ⟨c, d⟩⟩ ⟨⟨i, j⟩, ⟨k, l⟩⟩ H₁ H₂
- simp only [Finset.mem_sigma, mem_divisorsAntidiagonal, and_imp, Prod.mk.inj_iff, add_comm,
- heq_iff_eq] at H₁ H₂ ⊢
- simp only [Sigma.mk.inj_iff, Prod.mk.injEq, heq_eq_eq, and_imp] -- porting note: added
- rintro h h2 rfl rfl
- subst h -- porting note: added. The `rintro h ...` above was `rintro rfl ...`
- exact ⟨⟨Eq.trans H₁.2.1.symm H₂.2.1, rfl⟩, rfl, rfl⟩
- · rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- refine' ⟨⟨(i * k, l), (i, k)⟩, _, _⟩
- · simp only [Finset.mem_sigma, mem_divisorsAntidiagonal] at H ⊢
- rcases H with ⟨⟨rfl, n0⟩, rfl, j0⟩
- refine' ⟨⟨mul_assoc _ _ _, n0⟩, trivial, _⟩
- rw [mul_ne_zero_iff] at *
- exact ⟨n0.1, j0.1⟩
- · simp only [true_and_iff, mem_divisorsAntidiagonal, and_true_iff, Prod.mk.inj_iff,
- eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H ⊢
- rw [H.2.1]
+ apply Finset.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)
#align nat.arithmetic_function.mul_smul' Nat.ArithmeticFunction.mul_smul'
theorem one_smul' (b : ArithmeticFunction M) : (1 : ArithmeticFunction R) • b = b := by
@@ -679,69 +652,64 @@ theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative)
#align nat.arithmetic_function.is_multiplicative.int_cast Nat.ArithmeticFunction.IsMultiplicative.int_cast
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
- (hg : g.IsMultiplicative) : IsMultiplicative (f * g) :=
- ⟨by
- -- porting note was `simp [hf, hg]`.
- simp [hf.1, hg.1],
- by
- simp only [mul_apply]
- intro m n cop
- rw [sum_mul_sum]
- symm
- apply sum_bij fun (x : (ℕ × ℕ) × ℕ × ℕ) _h => (x.1.1 * x.2.1, x.1.2 * x.2.2)
- · rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at h
- rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
- simp only [mem_divisorsAntidiagonal, Nat.mul_eq_zero, Ne.def]
- constructor
- · ring
- rw [Nat.mul_eq_zero] at *
- apply not_or_of_not ha hb
- · rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
- simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at h
- rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
- dsimp only
- 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
- · rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨c1, c2⟩, ⟨d1, d2⟩⟩ hab hcd h
- simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at hab
- rcases hab with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
- simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at hcd
- simp only [Prod.mk.inj_iff] at h
- ext <;> dsimp only
- · trans Nat.gcd (a1 * a2) (a1 * b1)
- · rw [Nat.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, Nat.gcd_mul_left,
- cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one, mul_one]
- · trans Nat.gcd (a1 * a2) (a2 * b2)
- · rw [mul_comm, Nat.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, Nat.gcd_mul_left,
- cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one, mul_one]
- · trans Nat.gcd (b1 * b2) (a1 * b1)
- · rw [mul_comm, Nat.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, Nat.gcd_mul_left,
- cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one, mul_one]
- · trans Nat.gcd (b1 * b2) (a2 * b2)
- · rw [Nat.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, Nat.gcd_mul_right,
- cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one, one_mul]
- · rintro ⟨b1, b2⟩ h
- simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at h
- use ((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
- simp only [exists_prop, Prod.mk.inj_iff, Ne.def, mem_product, mem_divisorsAntidiagonal]
- rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
- Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
- · rw [Nat.mul_eq_zero, not_or] at h
- simp [h.2.1, h.2.2]
- rw [mul_comm n m, h.1]⟩
+ (hg : g.IsMultiplicative) : IsMultiplicative (f * g) := by
+ refine ⟨by simp [hf.1, hg.1], ?_⟩
+ simp only [mul_apply]
+ intro m n cop
+ rw [sum_mul_sum]
+ symm
+ apply sum_nbij fun ((i, j), k, l) ↦ (i * k, j * l)
+ · rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ h
+ simp only [mem_divisorsAntidiagonal, Ne.def, mem_product] at h
+ rcases h with ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
+ simp only [mem_divisorsAntidiagonal, Nat.mul_eq_zero, Ne.def]
+ constructor
+ · ring
+ rw [Nat.mul_eq_zero] at *
+ apply not_or_of_not ha hb
+ · simp only [Set.InjOn, mem_coe, mem_divisorsAntidiagonal, Ne.def, mem_product, Prod.mk.inj_iff]
+ rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩ ⟨⟨c1, c2⟩, ⟨d1, d2⟩⟩ hcd h
+ simp only [Prod.mk.inj_iff] at h
+ ext <;> dsimp only
+ · trans Nat.gcd (a1 * a2) (a1 * b1)
+ · rw [Nat.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, Nat.gcd_mul_left,
+ cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one, mul_one]
+ · trans Nat.gcd (a1 * a2) (a2 * b2)
+ · rw [mul_comm, Nat.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, Nat.gcd_mul_left,
+ cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one, mul_one]
+ · trans Nat.gcd (b1 * b2) (a1 * b1)
+ · rw [mul_comm, Nat.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, Nat.gcd_mul_left,
+ cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one, mul_one]
+ · trans Nat.gcd (b1 * b2) (a2 * b2)
+ · rw [Nat.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, Nat.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, Ne.def, mem_product,
+ Set.mem_image, exists_prop, Prod.mk.inj_iff]
+ rintro ⟨b1, b2⟩ h
+ dsimp at h
+ use ((b1.gcd m, b2.gcd m), (b1.gcd n, b2.gcd n))
+ rw [← cop.gcd_mul _, ← cop.gcd_mul _, ← h.1, Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop h.1,
+ Nat.gcd_mul_gcd_of_coprime_of_mul_eq_mul cop.symm _]
+ · rw [Nat.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, Ne.def, mem_product]
+ rintro ⟨⟨a1, a2⟩, ⟨b1, b2⟩⟩ ⟨⟨rfl, ha⟩, ⟨rfl, hb⟩⟩
+ dsimp only
+ 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
#align nat.arithmetic_function.is_multiplicative.mul Nat.ArithmeticFunction.IsMultiplicative.mul
theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
prodPrimeFactors
as an ArithmeticFunction
(#6662)
Define the arithmetic function $n \mapsto \prod_{p \mid n} f(p)$. This PR further proves that it's multiplicative and relates it to Dirichlet convolution. Finally it proves two identities that can be applied in a context where you're not working exclusively with ArithmeticFunction
s
This construction was mentioned on zulip
Co-authored-by: Arend Mellendijk <FLDutchmann@users.noreply.github.com>
@@ -47,8 +47,12 @@ to form the Dirichlet ring.
* `prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero` for functions to a `CommGroupWithZero`
## Notation
-The arithmetic functions `ζ` and `σ` have Greek letter names, which are localized notation in
-the namespace `ArithmeticFunction`.
+All notation is localized in the namespace `ArithmeticFunction`.
+
+The arithmetic functions `ζ`, `σ`, `ω`, `Ω` and `μ` have Greek letter names.
+
+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
@@ -590,6 +594,31 @@ theorem pdiv_zeta [DivisionSemiring R] (f : ArithmeticFunction R) :
end Pdiv
+section ProdPrimeFactors
+
+/-- The map $n \mapsto \prod_{p \mid n} f(p)$ as an arithmetic function -/
+def prodPrimeFactors [CommMonoidWithZero R] (f : ℕ → R) : ArithmeticFunction R where
+ toFun d := if d = 0 then 0 else ∏ p in d.primeFactors, f p
+ map_zero' := if_pos rfl
+
+open Std.ExtendedBinder
+
+/-- `∏ᵖ p ∣ n, f p` is custom notation for `prodPrimeFactors f n` -/
+scoped syntax (name := bigproddvd) "∏ᵖ " extBinder " ∣ " term ", " term:67 : term
+scoped macro_rules (kind := bigproddvd)
+ | `(∏ᵖ $x:ident ∣ $n, $r) => `(prodPrimeFactors (fun $x ↦ $r) $n)
+
+@[simp]
+theorem prodPrimeFactors_apply [CommMonoidWithZero R] {f: ℕ → R} {n : ℕ} (hn : n ≠ 0) :
+ ∏ᵖ p ∣ n, f p = ∏ p in n.primeFactors, f p :=
+ if_neg hn
+
+theorem prodPrimeFactors_apply_of_ne_zero [CommMonoidWithZero R] {f : ℕ → R} {n : ℕ}
+ (hn : n ≠ 0) : ∏ᵖ p ∣ n, f p = ∏ p in n.primeFactors, f p :=
+ prodPrimeFactors_apply hn
+
+end ProdPrimeFactors
+
/-- 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
@@ -625,6 +654,18 @@ theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.A
exact .prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
+theorem map_prod_of_prime [CommSemiring R] {f : ArithmeticFunction R}
+ (h_mult : ArithmeticFunction.IsMultiplicative f)
+ (t : Finset ℕ) (ht : ∀ p ∈ t, p.Prime) :
+ f (∏ a in t, a) = ∏ a : ℕ in 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 [CommSemiring R] {f : ArithmeticFunction R}
+ (h_mult : ArithmeticFunction.IsMultiplicative f) (l : ℕ)
+ (t : Finset ℕ) (ht : t ⊆ l.primeFactors) :
+ f (∏ a in t, a) = ∏ a : ℕ in t, f a :=
+ map_prod_of_prime h_mult t fun _ a => prime_of_mem_primeFactors (ht a)
+
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
@@ -754,6 +795,29 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
exact Finset.prod_congr rfl fun p hp ↦ h p _ (Nat.prime_of_mem_primeFactors hp)
#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
+theorem prodPrimeFactors [CommMonoidWithZero R] (f : ℕ → R) :
+ IsMultiplicative (prodPrimeFactors f) := by
+ rw [iff_ne_zero]
+ refine ⟨prodPrimeFactors_apply one_ne_zero, ?_⟩
+ intro x y hx hy hxy
+ have hxy₀: x*y ≠ 0 := by exact Nat.mul_ne_zero hx hy
+ rw [prodPrimeFactors_apply hxy₀, prodPrimeFactors_apply hx, prodPrimeFactors_apply hy,
+ Nat.primeFactors_mul hx hy, ← Finset.prod_union hxy.disjoint_primeFactors]
+
+theorem prodPrimeFactors_add_of_squarefree [CommSemiring R] {f g : ArithmeticFunction R}
+ (hf : IsMultiplicative f) (hg : IsMultiplicative g) {n : ℕ} (hn : Squarefree n) :
+ ∏ᵖ p ∣ n, (f + g) p = (f * g) n := by
+ rw [prodPrimeFactors_apply_of_ne_zero hn.ne_zero]
+ simp_rw [add_apply (f:=f) (g:=g)]
+ rw [Finset.prod_add, mul_apply, sum_divisorsAntidiagonal (f · * g ·),
+ ← divisors_filter_squarefree_of_squarefree hn, sum_divisors_filter_squarefree hn.ne_zero,
+ factors_eq]
+ apply Finset.sum_congr rfl
+ intro t ht
+ erw [t.prod_val, ← prod_primeFactors_sdiff_of_squarefree hn (Finset.mem_powerset.mp ht),
+ hf.map_prod_of_subset_primeFactors n t (Finset.mem_powerset.mp ht),
+ ← hg.map_prod_of_subset_primeFactors n (_ \ t) (Finset.sdiff_subset _ t)]
+
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
@@ -1046,6 +1110,27 @@ theorem isMultiplicative_moebius : IsMultiplicative μ := by
cardFactors_mul hn hm, pow_add]
#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
+theorem IsMultiplicative.prodPrimeFactors_one_add_of_squarefree [CommSemiring R]
+ {f : ArithmeticFunction R} (h_mult : f.IsMultiplicative) {n : ℕ} (hn : Squarefree n) :
+ ∏ p in n.primeFactors, (1 + f p) = ∑ d in n.divisors, f d := by
+ trans (∏ᵖ p ∣ n, ((ζ:ArithmeticFunction R) + f) p)
+ · simp_rw [prodPrimeFactors_apply hn.ne_zero, add_apply, natCoe_apply]
+ apply Finset.prod_congr rfl; intro p hp;
+ rw [zeta_apply_ne (prime_of_mem_factors $ List.mem_toFinset.mp hp).ne_zero, cast_one]
+ rw [isMultiplicative_zeta.nat_cast.prodPrimeFactors_add_of_squarefree h_mult hn,
+ coe_zeta_mul_apply]
+
+theorem IsMultiplicative.prodPrimeFactors_one_sub_of_squarefree [CommRing R]
+ (f : ArithmeticFunction R) (hf : f.IsMultiplicative) {n : ℕ} (hn : Squarefree n) :
+ ∏ p in n.primeFactors, (1 - f p) = ∑ d in n.divisors, μ d * f d := by
+ trans (∏ p in n.primeFactors, (1 + (ArithmeticFunction.pmul (μ:ArithmeticFunction R) f) p))
+ · apply Finset.prod_congr rfl; intro p hp
+ rw [pmul_apply, intCoe_apply, ArithmeticFunction.moebius_apply_prime
+ (prime_of_mem_factors (List.mem_toFinset.mp hp))]
+ ring
+ · rw [(isMultiplicative_moebius.int_cast.pmul hf).prodPrimeFactors_one_add_of_squarefree hn]
+ simp_rw [pmul_apply, intCoe_apply]
+
open UniqueFactorizationMonoid
@[simp]
cardFactors_zero
(#9287)
dsimp
lemma cardFactors_zero
cardFactors_one
a dsimp
lemmacardFactors_eq_one_iff_prime
a simp
lemma@@ -896,10 +896,13 @@ theorem cardFactors_apply {n : ℕ} : Ω n = n.factors.length :=
rfl
#align nat.arithmetic_function.card_factors_apply Nat.ArithmeticFunction.cardFactors_apply
-@[simp]
-theorem cardFactors_one : Ω 1 = 0 := by simp [cardFactors]
+@[simp, nolint simpNF] -- this is a `dsimp` lemma
+lemma cardFactors_zero : Ω 0 = 0 := rfl
+
+@[simp] theorem cardFactors_one : Ω 1 = 0 := rfl
#align nat.arithmetic_function.card_factors_one Nat.ArithmeticFunction.cardFactors_one
+@[simp]
theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime := by
refine' ⟨fun h => _, fun h => List.length_eq_one.2 ⟨n, factors_prime h⟩⟩
cases' n with n
prod_zero_iff_exists_zero
(#9281)
Multiset.prod_eq_zero_iff
a simp
lemma.prod_zero_iff_exists_zero
; it was a bad API version of Multiset.prod_eq_zero_iff
.Ideal.mul_eq_bot
a simp
lemma`.Ideal.multiset_prod_eq_bot
(a simp
lemma), deprecate Ideal.prod_eq_bot
.The deprecated lemmas prod_zero_iff_exists_zero
and Ideal.prod_eq_bot
use ∃ x ∈ s, x = 0
instead of a simpler 0 ∈ s
in the RHS.
@@ -919,13 +919,9 @@ theorem cardFactors_mul {m n : ℕ} (m0 : m ≠ 0) (n0 : n ≠ 0) : Ω (m * n) =
theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.prod ≠ 0) :
Ω s.prod = (Multiset.map Ω s).sum := by
- revert h0
- -- porting note: was `apply s.induction_on`
- refine s.induction_on ?_ ?_
- · simp
- intro a t h h0
- rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
- simp [h0, cardFactors_mul, h]
+ induction s using Multiset.induction_on with
+ | empty => simp
+ | cons ih => simp_all [cardFactors_mul, not_or]
#align nat.arithmetic_function.card_factors_multiset_prod Nat.ArithmeticFunction.cardFactors_multiset_prod
@[simp]
List.prod
, Multiset.prod
, Finset.prod
(#9005)
Add coprime_xxx_prod_left_iff
, coprime_xxx_prod_right_iff
lemma for List
, Multiset
, Finset
and Fintype
. This is a PR separated from #8887.
Co-authored-by: jeh <hodellurt@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -622,7 +622,7 @@ theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.A
· simp [hf]
rw [coe_insert, Set.pairwise_insert_of_symmetric (Coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
- exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
+ exact .prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
(if P then 1 else 0) • a
(#8347)
Two simple lemmas, smul_ite_zero
, and ite_smul_zero
.
Also delete Finset.sum_univ_ite
since it is now provable by simp
thanks to these.
Rename and turn around the following to match the direction that simp
goes in:
ite_mul_zero_left
→ ite_zero_mul
ite_mul_zero_right
→ mul_ite_zero
ite_and_mul_zero
→ ite_zero_mul_ite_zero
@@ -1042,15 +1042,9 @@ theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' :
theorem isMultiplicative_moebius : IsMultiplicative μ := by
rw [IsMultiplicative.iff_ne_zero]
refine' ⟨by simp, fun {n m} hn hm hnm => _⟩
- -- porting note: the rest of this proof was a single `simp only` with all the lemmas thrown in
- -- followed by the last `rw`.
- simp only [moebius, ZeroHom.coe_mk]
- dsimp only [coe_mk, ZeroHom.toFun_eq_coe, Eq.ndrec, ZeroHom.coe_mk]
- simp only [IsUnit.mul_iff, Nat.isUnit_iff, squarefree_mul hnm, ite_and, mul_ite, ite_mul,
- zero_mul, mul_zero]
- rw [cardFactors_mul hn hm, pow_add, ite_mul_zero_left, ite_mul_zero_right]
- split_ifs <;> -- porting note: added
- simp -- porting note: added
+ simp only [moebius, ZeroHom.coe_mk, coe_mk, ZeroHom.toFun_eq_coe, Eq.ndrec, ZeroHom.coe_mk,
+ IsUnit.mul_iff, Nat.isUnit_iff, squarefree_mul hnm, ite_zero_mul_ite_zero,
+ cardFactors_mul hn hm, pow_add]
#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
open UniqueFactorizationMonoid
@@ -768,7 +768,7 @@ theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R
iterate 4 rw [hf.multiplicative_factorization f (by assumption),
Finsupp.prod_of_support_subset _ _ _ (fun _ _ => hfi_zero)
(s := (x.primeFactors ⊔ y.primeFactors))]
- · rw [←Finset.prod_mul_distrib, ←Finset.prod_mul_distrib]
+ · rw [← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib]
apply Finset.prod_congr rfl
intro p _
rcases Nat.le_or_le (x.factorization p) (y.factorization p) with h | h <;>
@@ -1207,19 +1207,19 @@ theorem sum_eq_iff_sum_smul_moebius_eq_on [AddCommGroup R] {f g : ℕ → R}
let G := fun (n:ℕ) => (∑ i in n.divisors, f i)
intro n hn hnP
suffices ∑ d in n.divisors, μ (n/d) • G d = f n from by
- rw [Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • g y), ←this, sum_congr rfl]
+ rw [Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • g y), ← this, sum_congr rfl]
intro d hd
- rw [←h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
- rw [←Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • G y)]
+ rw [← h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
+ rw [← Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • G y)]
apply sum_eq_iff_sum_smul_moebius_eq.mp _ n hn
intro _ _; rfl
· intro h
let F := fun (n:ℕ) => ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd
intro n hn hnP
suffices ∑ d in n.divisors, F d = g n from by
- rw [←this, sum_congr rfl]
+ rw [← this, sum_congr rfl]
intro d hd
- rw [←h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
+ rw [← h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
apply sum_eq_iff_sum_smul_moebius_eq.mpr _ n hn
intro _ _; rfl
@@ -1048,9 +1048,7 @@ theorem isMultiplicative_moebius : IsMultiplicative μ := by
dsimp only [coe_mk, ZeroHom.toFun_eq_coe, Eq.ndrec, ZeroHom.coe_mk]
simp only [IsUnit.mul_iff, Nat.isUnit_iff, squarefree_mul hnm, ite_and, mul_ite, ite_mul,
zero_mul, mul_zero]
- rw [cardFactors_mul hn hm] -- porting note: `simp` does not seem to use this lemma.
- simp only [moebius, ZeroHom.coe_mk, squarefree_mul hnm, ite_and, cardFactors_mul hn hm]
- rw [pow_add, ite_mul_zero_left, ite_mul_zero_right]
+ rw [cardFactors_mul hn hm, pow_add, ite_mul_zero_left, ite_mul_zero_right]
split_ifs <;> -- porting note: added
simp -- porting note: added
#align nat.arithmetic_function.is_multiplicative_moebius Nat.ArithmeticFunction.isMultiplicative_moebius
mathlib can't make up its mind on whether to spell "the prime factors of n
" as n.factors.toFinset
or n.factorization.support
, even though those two are defeq. This PR proposes to unify everything to a new definition Nat.primeFactors
, and streamline the existing scattered API about n.factors.toFinset
and n.factorization.support
to Nat.primeFactors
. We also get to write a bit more API that didn't make sense before, eg primeFactors_mono
.
@@ -751,10 +751,7 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
by_cases hn : n = 0
· rw [hn, ArithmeticFunction.map_zero, ArithmeticFunction.map_zero]
rw [multiplicative_factorization f hf hn, multiplicative_factorization g hg hn]
- refine' Finset.prod_congr rfl _
- simp only [support_factorization, List.mem_toFinset]
- intro p hp
- exact h p _ (Nat.prime_of_mem_factors hp)
+ exact Finset.prod_congr rfl fun p hp ↦ h p _ (Nat.prime_of_mem_primeFactors hp)
#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R}
@@ -770,7 +767,7 @@ theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R
· 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.factorization.support ⊔ y.factorization.support))]
+ (s := (x.primeFactors ⊔ y.primeFactors))]
· rw [←Finset.prod_mul_distrib, ←Finset.prod_mul_distrib]
apply Finset.prod_congr rfl
intro p _
@@ -782,7 +779,7 @@ theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R
· apply Finset.subset_union_left
· rw [factorization_gcd hx hy, Finsupp.support_inf, Finset.sup_eq_union]
apply Finset.inter_subset_union
- · rw [factorization_lcm hx hy, Finsupp.support_sup, Finset.sup_eq_union]
+ · simp [factorization_lcm hx hy]
end IsMultiplicative
@@ -766,7 +766,7 @@ theorem lcm_apply_mul_gcd_apply [CommMonoidWithZero R] {f : ArithmeticFunction R
· 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
+ have hfi_zero : ∀ {i}, f (i ^ 0) = 1
· intro i; rw [pow_zero, hf.1]
iterate 4 rw [hf.multiplicative_factorization f (by assumption),
Finsupp.prod_of_support_subset _ _ _ (fun _ _ => hfi_zero)
@@ -757,6 +757,33 @@ theorem eq_iff_eq_on_prime_powers [CommMonoidWithZero R] (f : ArithmeticFunction
exact h p _ (Nat.prime_of_mem_factors hp)
#align nat.arithmetic_function.is_multiplicative.eq_iff_eq_on_prime_powers Nat.ArithmeticFunction.IsMultiplicative.eq_iff_eq_on_prime_powers
+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
+ · 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.factorization.support ⊔ y.factorization.support))]
+ · rw [←Finset.prod_mul_distrib, ←Finset.prod_mul_distrib]
+ apply Finset.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, ge_iff_le, Finsupp.sup_apply, h, sup_of_le_right,
+ sup_of_le_left, inf_of_le_right, Nat.factorization_gcd hx hy, Finsupp.inf_apply,
+ inf_of_le_left, mul_comm]
+ · apply Finset.subset_union_right
+ · apply Finset.subset_union_left
+ · rw [factorization_gcd hx hy, Finsupp.support_inf, Finset.sup_eq_union]
+ apply Finset.inter_subset_union
+ · rw [factorization_lcm hx hy, Finsupp.support_sup, Finset.sup_eq_union]
+
end IsMultiplicative
section SpecialFunctions
@@ -1185,10 +1185,10 @@ theorem sum_eq_iff_sum_smul_moebius_eq_on [AddCommGroup R] {f g : ℕ → R}
let G := fun (n:ℕ) => (∑ i in n.divisors, f i)
intro n hn hnP
suffices ∑ d in n.divisors, μ (n/d) • G d = f n from by
- rw [Nat.sum_divisorsAntidiagonal' (f:= fun x y => μ x • g y), ←this, sum_congr rfl]
+ rw [Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • g y), ←this, sum_congr rfl]
intro d hd
rw [←h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
- rw [←Nat.sum_divisorsAntidiagonal' (f:= fun x y => μ x • G y)]
+ rw [←Nat.sum_divisorsAntidiagonal' (f := fun x y => μ x • G y)]
apply sum_eq_iff_sum_smul_moebius_eq.mp _ n hn
intro _ _; rfl
· intro h
@@ -93,7 +93,7 @@ theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f := rfl
@[simp]
theorem coe_mk (f : ℕ → R) (hf) : @FunLike.coe (ArithmeticFunction R) _ _ _
- (ZeroHom.mk f hf) = f := rfl
+ (ZeroHom.mk f hf) = f := rfl
@[simp]
theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 :=
@@ -711,7 +711,7 @@ theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicat
#align nat.arithmetic_function.is_multiplicative.pmul Nat.ArithmeticFunction.IsMultiplicative.pmul
theorem pdiv [CommGroupWithZero R] {f g : ArithmeticFunction R} (hf : IsMultiplicative f)
- (hg : IsMultiplicative g) : IsMultiplicative (pdiv f g) :=
+ (hg : IsMultiplicative g) : IsMultiplicative (pdiv f g) :=
⟨ by simp [hf, hg], fun {m n} cop => by
simp only [pdiv_apply, map_mul_of_coprime hf cop, map_mul_of_coprime hg cop,
div_eq_mul_inv, mul_inv]
@@ -147,7 +147,7 @@ end Zero
this in `natCoe` because it gets unfolded too much. -/
@[coe] -- porting note: added `coe` tag.
def natToArithmeticFunction [AddMonoidWithOne R] :
- (ArithmeticFunction ℕ) → (ArithmeticFunction R) :=
+ (ArithmeticFunction ℕ) → (ArithmeticFunction R) :=
fun f => ⟨fun n => ↑(f n), by simp⟩
instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) :=
@@ -169,7 +169,7 @@ theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ}
this in `intCoe` because it gets unfolded too much. -/
@[coe]
def ofInt [AddGroupWithOne R] :
- (ArithmeticFunction ℤ) → (ArithmeticFunction R) :=
+ (ArithmeticFunction ℤ) → (ArithmeticFunction R) :=
fun f => ⟨fun n => ↑(f n), by simp⟩
instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) :=
@@ -592,7 +592,7 @@ end Pdiv
/-- 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
+ f 1 = 1 ∧ ∀ {m n : ℕ}, m.Coprime n → f (m * n) = f m * f n
#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
namespace IsMultiplicative
@@ -608,19 +608,19 @@ theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
- (h : m.coprime n) : f (m * n) = f m * f n :=
+ (h : m.Coprime n) : f (m * n) = f m * f n :=
hf.2 h
#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
end MonoidWithZero
theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
- (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
+ (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
induction' s using Finset.induction_on with a s has ih hs
· simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (Coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
@@ -729,7 +729,7 @@ theorem multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunct
/-- 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
+ 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
@@ -592,7 +592,7 @@ end Pdiv
/-- 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
+ f 1 = 1 ∧ ∀ {m n : ℕ}, m.coprime n → f (m * n) = f m * f n
#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
namespace IsMultiplicative
@@ -608,19 +608,19 @@ theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
- (h : m.Coprime n) : f (m * n) = f m * f n :=
+ (h : m.coprime n) : f (m * n) = f m * f n :=
hf.2 h
#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
end MonoidWithZero
theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
- (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
+ (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
induction' s using Finset.induction_on with a s has ih hs
· simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (Coprime.symmetric.comap g)] at hs
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
@@ -729,7 +729,7 @@ theorem multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunct
/-- 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
+ 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
Some changes have already been review and delegated in #6910 and #7148.
The diff that needs looking at is https://github.com/leanprover-community/mathlib4/pull/7174/commits/64d6d07ee18163627c8f517eb31455411921c5ac
The std bump PR was insta-merged already!
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -592,7 +592,7 @@ end Pdiv
/-- 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
+ f 1 = 1 ∧ ∀ {m n : ℕ}, m.Coprime n → f (m * n) = f m * f n
#align nat.arithmetic_function.is_multiplicative Nat.ArithmeticFunction.IsMultiplicative
namespace IsMultiplicative
@@ -608,19 +608,19 @@ theorem map_one {f : ArithmeticFunction R} (h : f.IsMultiplicative) : f 1 = 1 :=
@[simp]
theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {m n : ℕ}
- (h : m.coprime n) : f (m * n) = f m * f n :=
+ (h : m.Coprime n) : f (m * n) = f m * f n :=
hf.2 h
#align nat.arithmetic_function.is_multiplicative.map_mul_of_coprime Nat.ArithmeticFunction.IsMultiplicative.map_mul_of_coprime
end MonoidWithZero
theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
- (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
+ (hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (Coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
induction' s using Finset.induction_on with a s has ih hs
· simp [hf]
- rw [coe_insert, Set.pairwise_insert_of_symmetric (coprime.symmetric.comap g)] at hs
+ rw [coe_insert, Set.pairwise_insert_of_symmetric (Coprime.symmetric.comap g)] at hs
rw [prod_insert has, prod_insert has, hf.map_mul_of_coprime, ih hs.1]
exact Nat.coprime_prod_right fun i hi => hs.2 _ hi (hi.ne_of_not_mem has).symm
#align nat.arithmetic_function.is_multiplicative.map_prod Nat.ArithmeticFunction.IsMultiplicative.map_prod
@@ -729,7 +729,7 @@ theorem multiplicative_factorization [CommMonoidWithZero R] (f : ArithmeticFunct
/-- 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
+ 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
@@ -8,7 +8,6 @@ import Mathlib.Algebra.Module.BigOperators
import Mathlib.NumberTheory.Divisors
import Mathlib.Data.Nat.Squarefree
import Mathlib.Data.Nat.GCD.BigOperators
-import Mathlib.Algebra.Invertible
import Mathlib.Data.Nat.Factorization.Basic
#align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
MulZeroClass.
in mul_zero
/zero_mul
(#6682)
Search&replace MulZeroClass.mul_zero
-> mul_zero
, MulZeroClass.zero_mul
-> zero_mul
.
These were introduced by Mathport, as the full name of mul_zero
is actually MulZeroClass.mul_zero
(it's exported with the short name).
@@ -392,10 +392,10 @@ instance instSemiring : Semiring (ArithmeticFunction R) :=
ArithmeticFunction.instAddCommMonoid with
zero_mul := fun f => by
ext
- simp only [mul_apply, MulZeroClass.zero_mul, sum_const_zero, zero_apply]
+ simp only [mul_apply, zero_mul, sum_const_zero, zero_apply]
mul_zero := fun f => by
ext
- simp only [mul_apply, sum_const_zero, MulZeroClass.mul_zero, zero_apply]
+ simp only [mul_apply, sum_const_zero, mul_zero, zero_apply]
left_distrib := fun a b c => by
ext
simp only [← sum_add_distrib, mul_add, mul_apply, add_apply]
@@ -830,7 +830,7 @@ theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : Arithmet
intro m n hm _hn hmn
rcases eq_or_ne m 1 with (rfl | hm')
· simp
- rw [one_apply_ne, one_apply_ne hm', MulZeroClass.zero_mul]
+ rw [one_apply_ne, one_apply_ne hm', zero_mul]
rw [Ne.def, mul_eq_one, not_and_or]
exact Or.inl hm'⟩
#align nat.arithmetic_function.is_multiplicative_one Nat.ArithmeticFunction.isMultiplicative_one
@@ -1027,8 +1027,6 @@ theorem isMultiplicative_moebius : IsMultiplicative μ := by
zero_mul, mul_zero]
rw [cardFactors_mul hn hm] -- porting note: `simp` does not seem to use this lemma.
simp only [moebius, ZeroHom.coe_mk, squarefree_mul hnm, ite_and, cardFactors_mul hn hm]
- simp only [Nat.isUnit_iff, ZeroHom.toFun_eq_coe, IsUnit.mul_iff, mul_ite, ite_mul,
- zero_mul, mul_zero]
rw [pow_add, ite_mul_zero_left, ite_mul_zero_right]
split_ifs <;> -- porting note: added
simp -- porting note: added
@@ -1042,7 +1040,7 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
refine' recOnPosPrimePosCoprime _ _ _ _ n
· intro p n hp hn
rw [coe_mul_zeta_apply, sum_divisors_prime_pow hp, sum_range_succ']
- simp_rw [Function.Embedding.coeFn_mk, pow_zero, moebius_apply_one,
+ simp_rw [pow_zero, moebius_apply_one,
moebius_apply_prime_pow hp (Nat.succ_ne_zero _), Nat.succ_inj', sum_ite_eq', mem_range,
if_pos hn, add_left_neg]
rw [one_apply_ne]
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -62,7 +62,7 @@ open BigOperators
namespace Nat
-variable (R : Type _)
+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
@@ -252,7 +252,7 @@ instance [AddCommGroup R] : AddCommGroup (ArithmeticFunction R) :=
section SMul
-variable {M : Type _} [Zero R] [AddCommMonoid M] [SMul R M]
+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`. -/
@@ -297,7 +297,7 @@ theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} :
section Module
-variable {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M]
+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
@@ -418,7 +418,7 @@ instance [CommRing R] : CommRing (ArithmeticFunction R) :=
add_left_neg := add_left_neg
mul_comm := mul_comm }
-instance {M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] :
+instance {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] :
Module (ArithmeticFunction R) (ArithmeticFunction M) where
one_smul := one_smul'
mul_smul := mul_smul'
@@ -615,7 +615,7 @@ theorem map_mul_of_coprime {f : ArithmeticFunction R} (hf : f.IsMultiplicative)
end MonoidWithZero
-theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
+theorem map_prod {ι : Type*} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.ArithmeticFunction R}
(hf : f.IsMultiplicative) (s : Finset ι) (hs : (s : Set ι).Pairwise (coprime on g)) :
f (∏ i in s, g i) = ∏ i in s, f (g i) := by
classical
Define pointwise division of arithmetic functions and prove it preserves multiplicativity.
@@ -571,6 +571,26 @@ theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
end Pmul
+section Pdiv
+
+/-- This is the pointwise division of `ArithmeticFunction`s. -/
+def pdiv [GroupWithZero R] (f g : ArithmeticFunction R) : ArithmeticFunction R :=
+ ⟨fun n => f n / g n, by simp only [map_zero, ne_eq, not_true, div_zero]⟩
+
+@[simp]
+theorem pdiv_apply [GroupWithZero R] (f g : ArithmeticFunction R) (n : ℕ) :
+ pdiv f g n = f n / g n := rfl
+
+/-- This result only holds for `DivisionSemiring`s instead of `GroupWithZero`s because zeta takes
+values in ℕ, and hence the coersion requires an `AddMonoidWithOne`. TODO: Generalise zeta -/
+@[simp]
+theorem pdiv_zeta [DivisionSemiring R] (f : ArithmeticFunction R) :
+ pdiv f zeta = f := by
+ ext n
+ cases n <;> simp [succ_ne_zero]
+
+end Pdiv
+
/-- 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
@@ -691,6 +711,13 @@ theorem pmul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicat
ring⟩
#align nat.arithmetic_function.is_multiplicative.pmul Nat.ArithmeticFunction.IsMultiplicative.pmul
+theorem pdiv [CommGroupWithZero R] {f g : ArithmeticFunction R} (hf : IsMultiplicative f)
+ (hg : IsMultiplicative g) : IsMultiplicative (pdiv f g) :=
+ ⟨ by simp [hf, hg], fun {m n} cop => by
+ simp only [pdiv_apply, map_mul_of_coprime hf cop, map_mul_of_coprime hg cop,
+ div_eq_mul_inv, mul_inv]
+ apply mul_mul_mul_comm ⟩
+
/-- 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` -/
nonrec -- porting note: added
@@ -2,11 +2,6 @@
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-
-! This file was ported from Lean 3 source module number_theory.arithmetic_function
-! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Algebra.Module.BigOperators
@@ -16,6 +11,8 @@ import Mathlib.Data.Nat.GCD.BigOperators
import Mathlib.Algebra.Invertible
import Mathlib.Data.Nat.Factorization.Basic
+#align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
+
/-!
# Arithmetic Functions and Dirichlet Convolution
@@ -229,7 +229,6 @@ instance instAddMonoid : AddMonoid (ArithmeticFunction R) :=
add_assoc := fun _ _ _ => ext fun _ => add_assoc _ _ _
zero_add := fun _ => ext fun _ => zero_add _
add_zero := fun _ => ext fun _ => add_zero _ }
--- porting note: have I aligned this correctly?
#align nat.arithmetic_function.add_monoid Nat.ArithmeticFunction.instAddMonoid
end AddMonoid
@@ -240,15 +239,13 @@ instance instAddMonoidWithOne [AddMonoidWithOne R] : AddMonoidWithOne (Arithmeti
natCast := fun n => ⟨fun x => if x = 1 then (n : R) else 0, by simp⟩
natCast_zero := by ext; simp
natCast_succ := fun n => by ext x; by_cases h : x = 1 <;> simp [h] }
--- porting note: have I aligned this correctly?
#align nat.arithmetic_function.add_monoid_with_one Nat.ArithmeticFunction.instAddMonoidWithOne
instance instAddCommMonoid [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) :=
{ ArithmeticFunction.instAddMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ }
instance [AddGroup R] : AddGroup (ArithmeticFunction R) :=
- {
- ArithmeticFunction.instAddMonoid with
+ { ArithmeticFunction.instAddMonoid with
neg := fun f => ⟨fun n => -f n, by simp⟩
add_left_neg := fun _ => ext fun _ => add_left_neg _ }
@@ -408,7 +405,6 @@ instance instSemiring : Semiring (ArithmeticFunction R) :=
right_distrib := fun a b c => by
ext
simp only [← sum_add_distrib, add_mul, mul_apply, add_apply] }
--- porting note: have I aligned this correctly?
#align nat.arithmetic_function.semiring Nat.ArithmeticFunction.instSemiring
end Semiring
@@ -449,7 +445,6 @@ def zeta : ArithmeticFunction ℕ :=
⟨fun x => ite (x = 0) 0 1, rfl⟩
#align nat.arithmetic_function.zeta Nat.ArithmeticFunction.zeta
--- mathport name: arithmetic_function.zeta
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[Nat.ArithmeticFunction] notation "ζ" => Nat.ArithmeticFunction.zeta
@@ -500,7 +495,6 @@ theorem zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (ζ * f) x = ∑
theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑ i in divisors x, f i :=
coe_mul_zeta_apply
--porting note: was `by rw [← natCoe_nat ζ, coe_mul_zeta_apply]`. Is this `theorem` obsolete=
-
#align nat.arithmetic_function.mul_zeta_apply Nat.ArithmeticFunction.mul_zeta_apply
end Zeta
@@ -549,7 +543,9 @@ def ppow (f : ArithmeticFunction R) (k : ℕ) : ArithmeticFunction R :=
if h0 : k = 0 then ζ
else
⟨fun x => f x ^ k, by
- simp_rw [map_zero] -- porting note: was `rw [map_zero]`
+ -- porting note: added next line
+ dsimp only
+ rw [map_zero]
exact zero_pow (Nat.pos_of_ne_zero h0)⟩
#align nat.arithmetic_function.ppow Nat.ArithmeticFunction.ppow
@@ -565,17 +561,15 @@ theorem ppow_apply {f : ArithmeticFunction R} {k x : ℕ} (kpos : 0 < k) : f.ppo
theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul (f.ppow k) := by
ext x
- simp_rw [ppow_apply (Nat.succ_pos k), pow_succ] -- porting note: was `rw [..., pow_succ]`
+ rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ]
induction k <;> simp
- · exact pow_succ'' _ _ -- porting note: added
#align nat.arithmetic_function.ppow_succ Nat.ArithmeticFunction.ppow_succ
theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
f.ppow (k + 1) = (f.ppow k).pmul f := by
ext x
- rw [ppow_apply (Nat.succ_pos k), pow_succ''] -- porting note: was `pow_succ'`
+ rw [ppow_apply (Nat.succ_pos k), _root_.pow_succ']
induction k <;> simp
- rw [pow_mul_comm'] -- porting note: added
#align nat.arithmetic_function.ppow_succ' Nat.ArithmeticFunction.ppow_succ'
end Pmul
@@ -618,21 +612,21 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
- ⟨by simp [h], fun {m n} cop => by cases h; rename_i j h; simp [h cop]⟩
+ ⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
#align nat.arithmetic_function.is_multiplicative.nat_cast Nat.ArithmeticFunction.IsMultiplicative.nat_cast
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
- ⟨by simp [h], fun {m n} cop => by cases h; rename_i j h; simp [h cop]⟩
+ ⟨by simp [h], fun {m n} cop => by simp [h.2 cop]⟩
#align nat.arithmetic_function.is_multiplicative.int_cast Nat.ArithmeticFunction.IsMultiplicative.int_cast
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f * g) :=
- ⟨by -- porting note was `simp [hf, hg]`.
- have f1 := hf.left; have g1 := hg.left
- simp only [mul_apply, divisorsAntidiagonal_one, ZeroHom.toFun_eq_coe, sum_singleton]
- rw [f1, g1, mul_one], by
+ ⟨by
+ -- porting note was `simp [hf, hg]`.
+ simp [hf.1, hg.1],
+ by
simp only [mul_apply]
intro m n cop
rw [sum_mul_sum]
@@ -778,7 +772,6 @@ def sigma (k : ℕ) : ArithmeticFunction ℕ :=
⟨fun n => ∑ d in divisors n, d ^ k, by simp⟩
#align nat.arithmetic_function.sigma Nat.ArithmeticFunction.sigma
--- mathport name: arithmetic_function.sigma
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[Nat.ArithmeticFunction] notation "σ" => Nat.ArithmeticFunction.sigma
@@ -848,7 +841,6 @@ def cardFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.length, by simp⟩
#align nat.arithmetic_function.card_factors Nat.ArithmeticFunction.cardFactors
--- mathport name: card_factors
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[Nat.ArithmeticFunction] notation "Ω" => Nat.ArithmeticFunction.cardFactors
@@ -863,10 +855,9 @@ theorem cardFactors_one : Ω 1 = 0 := by simp [cardFactors]
theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime := by
refine' ⟨fun h => _, fun h => List.length_eq_one.2 ⟨n, factors_prime h⟩⟩
- cases n
+ cases' n with n
· contrapose! h
simp
- rename_i n -- porting note: added
rcases List.length_eq_one.1 h with ⟨x, hx⟩
rw [← prod_factors n.succ_ne_zero, hx, List.prod_singleton]
apply prime_of_mem_factors
@@ -883,7 +874,8 @@ theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.prod ≠ 0) :
Ω s.prod = (Multiset.map Ω s).sum := by
revert h0
-- porting note: was `apply s.induction_on`
- refine s.induction_on ?_ ?_; · simp
+ refine s.induction_on ?_ ?_
+ · simp
intro a t h h0
rw [Multiset.prod_cons, mul_ne_zero_iff] at h0
simp [h0, cardFactors_mul, h]
@@ -904,7 +896,6 @@ def cardDistinctFactors : ArithmeticFunction ℕ :=
⟨fun n => n.factors.dedup.length, by simp⟩
#align nat.arithmetic_function.card_distinct_factors Nat.ArithmeticFunction.cardDistinctFactors
--- mathport name: card_distinct_factors
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[Nat.ArithmeticFunction] notation "ω" => Nat.ArithmeticFunction.cardDistinctFactors
@@ -948,7 +939,6 @@ def moebius : ArithmeticFunction ℤ :=
⟨fun n => if Squarefree n then (-1) ^ cardFactors n else 0, by simp⟩
#align nat.arithmetic_function.moebius Nat.ArithmeticFunction.moebius
--- mathport name: moebius
-- porting note: added `Nat.` to the scoped namespace
@[inherit_doc]
scoped[Nat.ArithmeticFunction] notation "μ" => Nat.ArithmeticFunction.moebius
@@ -1084,7 +1074,7 @@ theorem inv_zetaUnit : ((zetaUnit⁻¹ : (ArithmeticFunction R)ˣ) : ArithmeticF
end CommRing
-/-- Möbius inversion for functions to an `add_comm_group`. -/
+/-- Möbius inversion for functions to an `AddCommGroup`. -/
theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
(∀ n > 0, ∑ i in n.divisors, f i = g n) ↔
∀ n > 0, ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd = f n := by
@@ -1100,10 +1090,8 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
rw [coe_zeta_smul_apply]
simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', if_false, ZeroHom.coe_mk]
simp only [coe_mk, succ_ne_zero, ite_false]
- rw [sum_congr rfl] -- porting note: was `rw [sum_congr rfl fun x hx => _]`
- intros x hx -- porting note: added
- rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors ?_))]
- exact n.succ; assumption -- porting note: added
+ rw [sum_congr rfl fun x hx => ?_]
+ rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors hx))]
trans μ • g' = f'
· constructor <;> intro h
· rw [← h, ← mul_smul, moebius_mul_coe_zeta, one_smul]
@@ -1118,8 +1106,7 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
ZeroHom.coe_mk]
-- porting note: added following `simp only`
simp only [Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
- rw [sum_congr rfl] -- porting note: was `rw [sum_congr rfl fun x hx => _]`
- intros x hx -- porting note: added
+ rw [sum_congr rfl fun x hx => ?_]
rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
#align nat.arithmetic_function.sum_eq_iff_sum_smul_moebius_eq Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
@@ -1166,7 +1153,7 @@ theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g :
Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
-/-- Möbius inversion for functions to an `add_comm_group`, where the equalities only hold on a
+/-- Möbius inversion for functions to an `AddCommGroup`, where the equalities only hold on a
well-behaved set. -/
theorem sum_eq_iff_sum_smul_moebius_eq_on [AddCommGroup R] {f g : ℕ → R}
(s : Set ℕ) (hs : ∀ m n, m ∣ n → n ∈ s → m ∈ s) :
Co-authored-by: Komyyy <pol_tta@outlook.jp> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -567,7 +567,6 @@ theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul
ext x
simp_rw [ppow_apply (Nat.succ_pos k), pow_succ] -- porting note: was `rw [..., pow_succ]`
induction k <;> simp
- · exact pow_one _ -- porting note: added
· exact pow_succ'' _ _ -- porting note: added
#align nat.arithmetic_function.ppow_succ Nat.ArithmeticFunction.ppow_succ
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -238,8 +238,8 @@ instance instAddMonoidWithOne [AddMonoidWithOne R] : AddMonoidWithOne (Arithmeti
{ ArithmeticFunction.instAddMonoid,
ArithmeticFunction.one with
natCast := fun n => ⟨fun x => if x = 1 then (n : R) else 0, by simp⟩
- natCast_zero := by ext ; simp ;
- natCast_succ := fun n => by ext x ; by_cases h : x = 1 <;> simp [h] }
+ natCast_zero := by ext; simp
+ natCast_succ := fun n => by ext x; by_cases h : x = 1 <;> simp [h] }
-- porting note: have I aligned this correctly?
#align nat.arithmetic_function.add_monoid_with_one Nat.ArithmeticFunction.instAddMonoidWithOne
@@ -619,19 +619,19 @@ theorem map_prod {ι : Type _} [CommMonoidWithZero R] (g : ι → ℕ) {f : Nat.
theorem nat_cast {f : ArithmeticFunction ℕ} [Semiring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
- ⟨by simp [h], fun {m n} cop => by cases h ; rename_i j h; simp [h cop]⟩
+ ⟨by simp [h], fun {m n} cop => by cases h; rename_i j h; simp [h cop]⟩
#align nat.arithmetic_function.is_multiplicative.nat_cast Nat.ArithmeticFunction.IsMultiplicative.nat_cast
theorem int_cast {f : ArithmeticFunction ℤ} [Ring R] (h : f.IsMultiplicative) :
IsMultiplicative (f : ArithmeticFunction R) :=
-- porting note: was `by simp [cop, h]`
- ⟨by simp [h], fun {m n} cop => by cases h ; rename_i j h; simp [h cop]⟩
+ ⟨by simp [h], fun {m n} cop => by cases h; rename_i j h; simp [h cop]⟩
#align nat.arithmetic_function.is_multiplicative.int_cast Nat.ArithmeticFunction.IsMultiplicative.int_cast
theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicative)
(hg : g.IsMultiplicative) : IsMultiplicative (f * g) :=
⟨by -- porting note was `simp [hf, hg]`.
- have f1 := hf.left ; have g1 := hg.left
+ have f1 := hf.left; have g1 := hg.left
simp only [mul_apply, divisorsAntidiagonal_one, ZeroHom.toFun_eq_coe, sum_singleton]
rw [f1, g1, mul_one], by
simp only [mul_apply]
This PR is the result of running
find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;
which firstly replaces .
focusing dots with ·
and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.
@@ -567,8 +567,8 @@ theorem ppow_succ {f : ArithmeticFunction R} {k : ℕ} : f.ppow (k + 1) = f.pmul
ext x
simp_rw [ppow_apply (Nat.succ_pos k), pow_succ] -- porting note: was `rw [..., pow_succ]`
induction k <;> simp
- . exact pow_one _ -- porting note: added
- . exact pow_succ'' _ _ -- porting note: added
+ · exact pow_one _ -- porting note: added
+ · exact pow_succ'' _ _ -- porting note: added
#align nat.arithmetic_function.ppow_succ Nat.ArithmeticFunction.ppow_succ
theorem ppow_succ' {f : ArithmeticFunction R} {k : ℕ} {kpos : 0 < k} :
@@ -666,22 +666,19 @@ theorem mul [CommSemiring R] {f g : ArithmeticFunction R} (hf : f.IsMultiplicati
rw [← hcd.1.1, h.1, Nat.gcd_mul_left,
cop.coprime_mul_left.coprime_mul_right_right.gcd_eq_one, mul_one]
· trans Nat.gcd (a1 * a2) (a2 * b2)
- ·
- rw [mul_comm, Nat.gcd_mul_left, cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one,
+ · rw [mul_comm, Nat.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, Nat.gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.gcd_eq_one, mul_one]
· trans Nat.gcd (b1 * b2) (a1 * b1)
- ·
- rw [mul_comm, Nat.gcd_mul_right,
+ · rw [mul_comm, Nat.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, Nat.gcd_mul_left,
cop.coprime_mul_right.coprime_mul_left_right.symm.gcd_eq_one, mul_one]
· trans Nat.gcd (b1 * b2) (a2 * b2)
- ·
- rw [Nat.gcd_mul_right, cop.coprime_mul_left.coprime_mul_right_right.symm.gcd_eq_one,
+ · rw [Nat.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, Nat.gcd_mul_right,
∑'
precedence (#5615)
∑
, ∏
and variants).([^a-zA-Zα-ωΑ-Ω'𝓝ℳ₀𝕂ₛ)]) \(([∑∏][^()∑∏]*,[^()∑∏:]*)\) ([⊂⊆=<≤])
replaced by $1 $2 $3
@@ -1090,8 +1090,8 @@ end CommRing
/-- Möbius inversion for functions to an `add_comm_group`. -/
theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
- (∀ n > 0, (∑ i in n.divisors, f i) = g n) ↔
- ∀ n > 0, (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd) = f n := by
+ (∀ n > 0, ∑ i in n.divisors, f i = g n) ↔
+ ∀ n > 0, ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd = f n := by
let f' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else f x, if_pos rfl⟩
let g' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else g x, if_pos rfl⟩
trans (ζ : ArithmeticFunction ℤ) • f' = g'
@@ -1129,8 +1129,8 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
/-- Möbius inversion for functions to a `Ring`. -/
theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
- (∀ n > 0, (∑ i in n.divisors, f i) = g n) ↔
- ∀ n > 0, (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd) = f n := by
+ (∀ n > 0, ∑ i in n.divisors, f i = g n) ↔
+ ∀ n > 0, ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd = f n := by
rw [sum_eq_iff_sum_smul_moebius_eq]
apply forall_congr'
refine' fun a => imp_congr_right fun _ => (sum_congr rfl fun x _hx => _).congr_left
@@ -1139,16 +1139,16 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
/-- Möbius inversion for functions to a `CommGroup`. -/
theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
- (∀ n > 0, (∏ i in n.divisors, f i) = g n) ↔
- ∀ n > 0, (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
+ (∀ n > 0, ∏ i in n.divisors, f i = g n) ↔
+ ∀ n > 0, ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n :=
@sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
/-- Möbius inversion for functions to a `CommGroupWithZero`. -/
theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
(hf : ∀ n : ℕ, 0 < n → f n ≠ 0) (hg : ∀ n : ℕ, 0 < n → g n ≠ 0) :
- (∀ n > 0, (∏ i in n.divisors, f i) = g n) ↔
- ∀ n > 0, (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n := by
+ (∀ n > 0, ∏ i in n.divisors, f i = g n) ↔
+ ∀ n > 0, ∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst = f n := by
refine'
Iff.trans
(Iff.trans (forall_congr' fun n => _)
The standard version of Moebius inversion can't be used when the equalities only hold on a subset of the natural numbers (e.g. the squarefree numbers). Add variants of all the Moebius inversion results that generalise to well-behaved subsets of the naturals.
@@ -43,6 +43,12 @@ to form the Dirichlet ring.
* `sum_eq_iff_sum_smul_moebius_eq` for functions to an `AddCommGroup`
* `prod_eq_iff_prod_pow_moebius_eq` for functions to a `CommGroup`
* `prod_eq_iff_prod_pow_moebius_eq_of_nonzero` for functions to a `CommGroupWithZero`
+ * And variants that apply when the equalities only hold on a set `S : Set ℕ` such that
+ `m ∣ n → n ∈ S → m ∈ S`:
+ * `sum_eq_iff_sum_mul_moebius_eq_on` for functions to a `CommRing`
+ * `sum_eq_iff_sum_smul_moebius_eq_on` for functions to an `AddCommGroup`
+ * `prod_eq_iff_prod_pow_moebius_eq_on` for functions to a `CommGroup`
+ * `prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero` for functions to a `CommGroupWithZero`
## Notation
The arithmetic functions `ζ` and `σ` have Greek letter names, which are localized notation in
@@ -1084,8 +1090,8 @@ end CommRing
/-- Möbius inversion for functions to an `add_comm_group`. -/
theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
- (∀ n : ℕ, 0 < n → (∑ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd) = f n := by
+ (∀ n > 0, (∑ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd) = f n := by
let f' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else f x, if_pos rfl⟩
let g' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else g x, if_pos rfl⟩
trans (ζ : ArithmeticFunction ℤ) • f' = g'
@@ -1123,8 +1129,8 @@ theorem sum_eq_iff_sum_smul_moebius_eq [AddCommGroup R] {f g : ℕ → R} :
/-- Möbius inversion for functions to a `Ring`. -/
theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
- (∀ n : ℕ, 0 < n → (∑ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd) = f n := by
+ (∀ n > 0, (∑ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd) = f n := by
rw [sum_eq_iff_sum_smul_moebius_eq]
apply forall_congr'
refine' fun a => imp_congr_right fun _ => (sum_congr rfl fun x _hx => _).congr_left
@@ -1133,16 +1139,16 @@ theorem sum_eq_iff_sum_mul_moebius_eq [Ring R] {f g : ℕ → R} :
/-- Möbius inversion for functions to a `CommGroup`. -/
theorem prod_eq_iff_prod_pow_moebius_eq [CommGroup R] {f g : ℕ → R} :
- (∀ n : ℕ, 0 < n → (∏ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
+ (∀ n > 0, (∏ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
@sum_eq_iff_sum_smul_moebius_eq (Additive R) _ _ _
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq
/-- Möbius inversion for functions to a `CommGroupWithZero`. -/
theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g : ℕ → R}
(hf : ∀ n : ℕ, 0 < n → f n ≠ 0) (hg : ∀ n : ℕ, 0 < n → g n ≠ 0) :
- (∀ n : ℕ, 0 < n → (∏ i in n.divisors, f i) = g n) ↔
- ∀ n : ℕ, 0 < n → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n := by
+ (∀ n > 0, (∏ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n := by
refine'
Iff.trans
(Iff.trans (forall_congr' fun n => _)
@@ -1164,6 +1170,92 @@ theorem prod_eq_iff_prod_pow_moebius_eq_of_nonzero [CommGroupWithZero R] {f g :
Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
#align nat.arithmetic_function.prod_eq_iff_prod_pow_moebius_eq_of_nonzero Nat.ArithmeticFunction.prod_eq_iff_prod_pow_moebius_eq_of_nonzero
+/-- Möbius inversion for functions to an `add_comm_group`, where the equalities only hold on a
+well-behaved set. -/
+theorem sum_eq_iff_sum_smul_moebius_eq_on [AddCommGroup R] {f g : ℕ → R}
+ (s : Set ℕ) (hs : ∀ m n, m ∣ n → n ∈ s → m ∈ s) :
+ (∀ n > 0, n ∈ s → (∑ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, n ∈ s → (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd) = f n := by
+ constructor
+ · intro h
+ let G := fun (n:ℕ) => (∑ i in n.divisors, f i)
+ intro n hn hnP
+ suffices ∑ d in n.divisors, μ (n/d) • G d = f n from by
+ rw [Nat.sum_divisorsAntidiagonal' (f:= fun x y => μ x • g y), ←this, sum_congr rfl]
+ intro d hd
+ rw [←h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
+ rw [←Nat.sum_divisorsAntidiagonal' (f:= fun x y => μ x • G y)]
+ apply sum_eq_iff_sum_smul_moebius_eq.mp _ n hn
+ intro _ _; rfl
+ · intro h
+ let F := fun (n:ℕ) => ∑ x : ℕ × ℕ in n.divisorsAntidiagonal, μ x.fst • g x.snd
+ intro n hn hnP
+ suffices ∑ d in n.divisors, F d = g n from by
+ rw [←this, sum_congr rfl]
+ intro d hd
+ rw [←h d (Nat.pos_of_mem_divisors hd) $ hs d n (Nat.dvd_of_mem_divisors hd) hnP]
+ apply sum_eq_iff_sum_smul_moebius_eq.mpr _ n hn
+ intro _ _; rfl
+
+theorem sum_eq_iff_sum_smul_moebius_eq_on' [AddCommGroup R] {f g : ℕ → R}
+ (s : Set ℕ) (hs : ∀ m n, m ∣ n → n ∈ s → m ∈ s) (hs₀ : 0 ∉ s) :
+ (∀ n ∈ s, (∑ i in n.divisors, f i) = g n) ↔
+ ∀ n ∈ s, (∑ x in n.divisorsAntidiagonal, μ x.fst • g x.snd) = f n := by
+ have : ∀ P : ℕ → Prop, ((∀ n ∈ s, P n) ↔ (∀ n > 0, n ∈ s → P n)) := fun P ↦ by
+ refine' forall_congr' (fun n ↦ ⟨fun h _ ↦ h, fun h hn ↦ h _ hn⟩)
+ contrapose! hs₀
+ simpa [nonpos_iff_eq_zero.mp hs₀] using hn
+ simpa only [this] using sum_eq_iff_sum_smul_moebius_eq_on s hs
+
+/-- Möbius inversion for functions to a `Ring`, where the equalities only hold on a well-behaved
+set. -/
+theorem sum_eq_iff_sum_mul_moebius_eq_on [Ring R] {f g : ℕ → R}
+ (s : Set ℕ) (hs : ∀ m n, m ∣ n → n ∈ s → m ∈ s) :
+ (∀ n > 0, n ∈ s → (∑ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, n ∈ s →
+ (∑ x : ℕ × ℕ in n.divisorsAntidiagonal, (μ x.fst : R) * g x.snd) = f n := by
+ rw [sum_eq_iff_sum_smul_moebius_eq_on s hs]
+ apply forall_congr'
+ intro a; refine' imp_congr_right _
+ refine' fun _ => imp_congr_right fun _ => (sum_congr rfl fun x _hx => _).congr_left
+ rw [zsmul_eq_mul]
+
+/-- Möbius inversion for functions to a `CommGroup`, where the equalities only hold on a
+well-behaved set. -/
+theorem prod_eq_iff_prod_pow_moebius_eq_on [CommGroup R] {f g : ℕ → R}
+ (s : Set ℕ) (hs : ∀ m n, m ∣ n → n ∈ s → m ∈ s) :
+ (∀ n > 0, n ∈ s → (∏ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, n ∈ s → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n :=
+ @sum_eq_iff_sum_smul_moebius_eq_on (Additive R) _ _ _ s hs
+
+/-- Möbius inversion for functions to a `CommGroupWithZero`, where the equalities only hold on
+a well-behaved set. -/
+theorem prod_eq_iff_prod_pow_moebius_eq_on_of_nonzero [CommGroupWithZero R]
+ (s : Set ℕ) (hs : ∀ m n, m ∣ n → n ∈ s → m ∈ s) {f g : ℕ → R}
+ (hf : ∀ n > 0, f n ≠ 0) (hg : ∀ n > 0, g n ≠ 0):
+ (∀ n > 0, n ∈ s → (∏ i in n.divisors, f i) = g n) ↔
+ ∀ n > 0, n ∈ s → (∏ x : ℕ × ℕ in n.divisorsAntidiagonal, g x.snd ^ μ x.fst) = f n := by
+ refine'
+ Iff.trans
+ (Iff.trans (forall_congr' fun n => _)
+ (@prod_eq_iff_prod_pow_moebius_eq_on Rˣ _
+ (fun n => if h : 0 < n then Units.mk0 (f n) (hf n h) else 1)
+ (fun n => if h : 0 < n then Units.mk0 (g n) (hg n h) else 1)
+ s hs) )
+ (forall_congr' fun n => _) <;>
+ refine' imp_congr_right fun hn => _
+ · dsimp
+ rw [dif_pos hn, ← Units.eq_iff, ← Units.coeHom_apply, map_prod, Units.val_mk0,
+ prod_congr rfl _]
+ intro x hx
+ rw [dif_pos (Nat.pos_of_mem_divisors hx), Units.coeHom_apply, Units.val_mk0]
+ · dsimp
+ rw [dif_pos hn, ← Units.eq_iff, ← Units.coeHom_apply, map_prod, Units.val_mk0,
+ prod_congr rfl _]
+ intro x hx
+ rw [dif_pos (Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_antidiagonal hx)),
+ Units.coeHom_apply, Units.val_zpow_eq_zpow_val, Units.val_mk0]
+
end SpecialFunctions
end ArithmeticFunction
at
and goals (#5387)
Changes are of the form
some_tactic at h⊢
-> some_tactic at h ⊢
some_tactic at h
-> some_tactic at h
@@ -308,7 +308,7 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ _H
exact ⟨(k, l * j), (l, j)⟩
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
- simp only [Finset.mem_sigma, mem_divisorsAntidiagonal] at H⊢
+ simp only [Finset.mem_sigma, mem_divisorsAntidiagonal] at H ⊢
rcases H with ⟨⟨rfl, n0⟩, rfl, i0⟩
refine' ⟨⟨(mul_assoc _ _ _).symm, n0⟩, trivial, _⟩
rw [mul_ne_zero_iff] at *
@@ -317,20 +317,20 @@ theorem mul_smul' (f g : ArithmeticFunction R) (h : ArithmeticFunction M) :
simp only [mul_assoc]
· rintro ⟨⟨a, b⟩, ⟨c, d⟩⟩ ⟨⟨i, j⟩, ⟨k, l⟩⟩ H₁ H₂
simp only [Finset.mem_sigma, mem_divisorsAntidiagonal, and_imp, Prod.mk.inj_iff, add_comm,
- heq_iff_eq] at H₁ H₂⊢
+ heq_iff_eq] at H₁ H₂ ⊢
simp only [Sigma.mk.inj_iff, Prod.mk.injEq, heq_eq_eq, and_imp] -- porting note: added
rintro h h2 rfl rfl
subst h -- porting note: added. The `rintro h ...` above was `rintro rfl ...`
exact ⟨⟨Eq.trans H₁.2.1.symm H₂.2.1, rfl⟩, rfl, rfl⟩
· rintro ⟨⟨i, j⟩, ⟨k, l⟩⟩ H
refine' ⟨⟨(i * k, l), (i, k)⟩, _, _⟩
- · simp only [Finset.mem_sigma, mem_divisorsAntidiagonal] at H⊢
+ · simp only [Finset.mem_sigma, mem_divisorsAntidiagonal] at H ⊢
rcases H with ⟨⟨rfl, n0⟩, rfl, j0⟩
refine' ⟨⟨mul_assoc _ _ _, n0⟩, trivial, _⟩
rw [mul_ne_zero_iff] at *
exact ⟨n0.1, j0.1⟩
· simp only [true_and_iff, mem_divisorsAntidiagonal, and_true_iff, Prod.mk.inj_iff,
- eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H⊢
+ eq_self_iff_true, Ne.def, mem_sigma, heq_iff_eq] at H ⊢
rw [H.2.1]
#align nat.arithmetic_function.mul_smul' Nat.ArithmeticFunction.mul_smul'
@@ -487,13 +487,13 @@ theorem coe_mul_zeta_apply [Semiring R] {f : ArithmeticFunction R} {x : ℕ} :
#align nat.arithmetic_function.coe_mul_zeta_apply Nat.ArithmeticFunction.coe_mul_zeta_apply
theorem zeta_mul_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (ζ * f) x = ∑ i in divisors x, f i :=
-coe_zeta_mul_apply
---porting note: was `by rw [← nat_coe_nat ζ, coe_zeta_mul_apply]`. Is this `theorem` obsolete?
+ coe_zeta_mul_apply
+ --porting note: was `by rw [← nat_coe_nat ζ, coe_zeta_mul_apply]`. Is this `theorem` obsolete?
#align nat.arithmetic_function.zeta_mul_apply Nat.ArithmeticFunction.zeta_mul_apply
theorem mul_zeta_apply {f : ArithmeticFunction ℕ} {x : ℕ} : (f * ζ) x = ∑ i in divisors x, f i :=
-coe_mul_zeta_apply
---porting note: was `by rw [← natCoe_nat ζ, coe_mul_zeta_apply]`. Is this `theorem` obsolete=
+ coe_mul_zeta_apply
+ --porting note: was `by rw [← natCoe_nat ζ, coe_mul_zeta_apply]`. Is this `theorem` obsolete=
#align nat.arithmetic_function.mul_zeta_apply Nat.ArithmeticFunction.mul_zeta_apply
@@ -141,7 +141,7 @@ end One
end Zero
-/-- Coerc an arithmetic function with values in `ℕ` to one with values in `R`. We cannot inline
+/-- 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] -- porting note: added `coe` tag.
def natToArithmeticFunction [AddMonoidWithOne R] :
The unported dependencies are