l3lab/ntp-mathlib huggingface dataset:
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
  · 

Proof state:
case mpr
R : Type u_1
n : ℕ
h : μ n = 1 ∨ μ n = -1
⊢ μ n ≠ 0

Next tactic:
rcases h with (h | h)
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) <;> 

Proof state:
case mpr.inl
R : Type u_1
n : ℕ
h : μ n = 1
⊢ μ n ≠ 0

Next tactic:
simp [h]
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) <;> 

Proof state:
case mpr.inr
R : Type u_1
n : ℕ
h : μ n = -1
⊢ μ n ≠ 0

Next tactic:
simp [h]
theorem moebius_apply_prime {p : ℕ} (hp : p.Prime) : μ p = -1 := by
  

Proof state:
R : Type u_1
p : ℕ
hp : Prime p
⊢ μ p = -1

Next tactic:
rw [moebius_apply_of_squarefree hp.squarefree, cardFactors_apply_prime hp, pow_one]
theorem moebius_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) :
    μ (p ^ k) = if k = 1 then -1 else 0 := by
  

Proof state:
R : Type u_1
p k : ℕ
hp : Prime p
hk : k ≠ 0
⊢ μ (p ^ k) = if k = 1 then -1 else 0

Next tactic:
split_ifs with h
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 with h
  · 

Proof state:
case pos
R : Type u_1
p k : ℕ
hp : Prime p
hk : k ≠ 0
h : k = 1
⊢ μ (p ^ k) = -1

Next tactic:
rw [h, pow_one, moebius_apply_prime hp]
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 with h
  · rw [h, pow_one, moebius_apply_prime hp]
  

Proof state:
case neg
R : Type u_1
p k : ℕ
hp : Prime p
hk : k ≠ 0
h : ¬k = 1
⊢ μ (p ^ k) = 0

Next tactic:
rw [moebius_eq_zero_of_not_squarefree]
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 with h
  · rw [h, pow_one, moebius_apply_prime hp]
  rw [moebius_eq_zero_of_not_squarefree]
  

Proof state:
case neg
R : Type u_1
p k : ℕ
hp : Prime p
hk : k ≠ 0
h : ¬k = 1
⊢ ¬Squarefree (p ^ k)

Next tactic:
rw [squarefree_pow_iff hp.ne_one hk, not_and_or]
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 with h
  · 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]
  

Proof state:
case neg
R : Type u_1
p k : ℕ
hp : Prime p
hk : k ≠ 0
h : ¬k = 1
⊢ ¬Squarefree p ∨ ¬k = 1

Next tactic:
exact Or.inr h
theorem moebius_apply_isPrimePow_not_prime {n : ℕ} (hn : IsPrimePow n) (hn' : ¬n.Prime) :
    μ n = 0 := by
  

Proof state:
R : Type u_1
n : ℕ
hn : IsPrimePow n
hn' : ¬Prime n
⊢ μ n = 0

Next tactic:
obtain ⟨p, k, hp, hk, rfl⟩ := (isPrimePow_nat_iff _).1 hn
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
  

Proof state:
case intro.intro.intro.intro
R : Type u_1
p k : ℕ
hp : Prime p
hk : 0 < k
hn : IsPrimePow (p ^ k)
hn' : ¬Prime (p ^ k)
⊢ μ (p ^ k) = 0

Next tactic:
rw [moebius_apply_prime_pow hp hk.ne', if_neg]
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
  rw [moebius_apply_prime_pow hp hk.ne', if_neg]
  

Proof state:
case intro.intro.intro.intro.hnc
R : Type u_1
p k : ℕ
hp : Prime p
hk : 0 < k
hn : IsPrimePow (p ^ k)
hn' : ¬Prime (p ^ k)
⊢ ¬k = 1

Next tactic:
rintro rfl
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
  rw [moebius_apply_prime_pow hp hk.ne', if_neg]
  rintro rfl
  

Proof state:
case intro.intro.intro.intro.hnc
R : Type u_1
p : ℕ
hp : Prime p
hk : 0 < 1
hn : IsPrimePow (p ^ 1)
hn' : ¬Prime (p ^ 1)
⊢ False

Next tactic:
exact hn' (by simpa)
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
  rw [moebius_apply_prime_pow hp hk.ne', if_neg]
  rintro rfl
  exact hn' (by 

Proof state:
R : Type u_1
p : ℕ
hp : Prime p
hk : 0 < 1
hn : IsPrimePow (p ^ 1)
hn' : ¬Prime (p ^ 1)
⊢ Prime (p ^ 1)

Next tactic:
simpa
theorem isMultiplicative_moebius : IsMultiplicative μ := by
  

Proof state:
R : Type u_1
⊢ IsMultiplicative μ

Next tactic:
rw [IsMultiplicative.iff_ne_zero]
theorem isMultiplicative_moebius : IsMultiplicative μ := by
  rw [IsMultiplicative.iff_ne_zero]
  

Proof state:
R : Type u_1
⊢ μ 1 = 1 ∧ ∀ {m n : ℕ}, m ≠ 0 → n ≠ 0 → Coprime m n → μ (m * n) = μ m * μ n

Next tactic:
refine' ⟨by simp, fun {n m} hn hm hnm => _⟩
theorem isMultiplicative_moebius : IsMultiplicative μ := by
  rw [IsMultiplicative.iff_ne_zero]
  refine' ⟨by 

Proof state:
R : Type u_1
⊢ μ 1 = 1

Next tactic:
simp
theorem isMultiplicative_moebius : IsMultiplicative μ := by
  rw [IsMultiplicative.iff_ne_zero]
  refine' ⟨by simp, fun {n m} hn hm hnm => _⟩
  

Proof state:
R : Type u_1
n m : ℕ
hn : n ≠ 0
hm : m ≠ 0
hnm : Coprime n m
⊢ μ (n * m) = μ n * μ m

Next tactic:
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]
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  

Proof state:
R : Type u_1
⊢ μ * ↑ζ = 1

Next tactic:
ext n
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  

Proof state:
case h
R : Type u_1
n : ℕ
⊢ (μ * ↑ζ) n = 1 n

Next tactic:
refine' recOnPosPrimePosCoprime _ _ _ _ n
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  refine' recOnPosPrimePosCoprime _ _ _ _ n
  · 

Proof state:
case h.refine'_1
R : Type u_1
n : ℕ
⊢ ∀ (p n : ℕ), Prime p → 0 < n → (μ * ↑ζ) (p ^ n) = 1 (p ^ n)

Next tactic:
intro p n hp hn
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  refine' recOnPosPrimePosCoprime _ _ _ _ n
  · intro p n hp hn
    

Proof state:
case h.refine'_1
R : Type u_1
n✝ p n : ℕ
hp : Prime p
hn : 0 < n
⊢ (μ * ↑ζ) (p ^ n) = 1 (p ^ n)

Next tactic:
rw [coe_mul_zeta_apply, sum_divisors_prime_pow hp, sum_range_succ']
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  refine' recOnPosPrimePosCoprime _ _ _ _ n
  · intro p n hp hn
    rw [coe_mul_zeta_apply, sum_divisors_prime_pow hp, sum_range_succ']
    

Proof state:
case h.refine'_1
R : Type u_1
n✝ p n : ℕ
hp : Prime p
hn : 0 < n
⊢ ∑ k in range n, μ (p ^ (k + 1)) + μ (p ^ 0) = 1 (p ^ n)

Next tactic:
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]
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      moebius_apply_prime_pow hp (Nat.succ_ne_zero _), Nat.succ_inj', sum_ite_eq', mem_range,
      if_pos hn, add_left_neg]
    

Proof state:
case h.refine'_1
R : Type u_1
n✝ p n : ℕ
hp : Prime p
hn : 0 < n
⊢ 0 = 1 (p ^ n)

Next tactic:
rw [one_apply_ne]
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    

Proof state:
case h.refine'_1
R : Type u_1
n✝ p n : ℕ
hp : Prime p
hn : 0 < n
⊢ p ^ n ≠ 1

Next tactic:
rw [Ne.def, pow_eq_one_iff]
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · 

Proof state:
case h.refine'_1
R : Type u_1
n✝ p n : ℕ
hp : Prime p
hn : 0 < n
⊢ ¬p = 1

Next tactic:
exact hp.ne_one
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · exact hp.ne_one
    · 

Proof state:
case h.refine'_1
R : Type u_1
n✝ p n : ℕ
hp : Prime p
hn : 0 < n
⊢ n ≠ 0

Next tactic:
exact hn.ne'
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · exact hp.ne_one
    · exact hn.ne'
  · 

Proof state:
case h.refine'_2
R : Type u_1
n : ℕ
⊢ (μ * ↑ζ) 0 = 1 0

Next tactic:
rw [ZeroHom.map_zero, ZeroHom.map_zero]
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · exact hp.ne_one
    · exact hn.ne'
  · rw [ZeroHom.map_zero, ZeroHom.map_zero]
  · 

Proof state:
case h.refine'_3
R : Type u_1
n : ℕ
⊢ (μ * ↑ζ) 1 = 1 1

Next tactic:
simp
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · exact hp.ne_one
    · exact hn.ne'
  · rw [ZeroHom.map_zero, ZeroHom.map_zero]
  · simp
  · 

Proof state:
case h.refine'_4
R : Type u_1
n : ℕ
⊢ ∀ (a b : ℕ), 1 < a → 1 < b → Coprime a b → (μ * ↑ζ) a = 1 a → (μ * ↑ζ) b = 1 b → (μ * ↑ζ) (a * b) = 1 (a * b)

Next tactic:
intro a b _ha _hb hab ha' hb'
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · exact hp.ne_one
    · exact hn.ne'
  · rw [ZeroHom.map_zero, ZeroHom.map_zero]
  · simp
  · intro a b _ha _hb hab ha' hb'
    

Proof state:
case h.refine'_4
R : Type u_1
n a b : ℕ
_ha : 1 < a
_hb : 1 < b
hab : Coprime a b
ha' : (μ * ↑ζ) a = 1 a
hb' : (μ * ↑ζ) b = 1 b
⊢ (μ * ↑ζ) (a * b) = 1 (a * b)

Next tactic:
rw [IsMultiplicative.map_mul_of_coprime _ hab, ha', hb',
      IsMultiplicative.map_mul_of_coprime isMultiplicative_one hab]
@[simp]
theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
  ext n
  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,
      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]
    · exact hp.ne_one
    · exact hn.ne'
  · rw [ZeroHom.map_zero, ZeroHom.map_zero]
  · simp
  · 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]
    

Proof state:
R : Type u_1
n a b : ℕ
_ha : 1 < a
_hb : 1 < b
hab : Coprime a b
ha' : (μ * ↑ζ) a = 1 a
hb' : (μ * ↑ζ) b = 1 b
⊢ IsMultiplicative (μ * ↑ζ)

Next tactic:
exact isMultiplicative_moebius.mul isMultiplicative_zeta.nat_cast
@[simp]
theorem coe_zeta_mul_moebius : (ζ * μ : ArithmeticFunction ℤ) = 1 := by
  

Proof state:
R : Type u_1
⊢ ↑ζ * μ = 1

Next tactic:
rw [mul_comm, moebius_mul_coe_zeta]
@[simp]
theorem coe_moebius_mul_coe_zeta [Ring R] : (μ * ζ : ArithmeticFunction R) = 1 := by
  

Proof state:
R : Type u_1
inst✝ : Ring R
⊢ ↑μ * ↑ζ = 1

Next tactic:
rw [← coe_coe, ← intCoe_mul, moebius_mul_coe_zeta, intCoe_one]
@[simp]
theorem coe_zeta_mul_coe_moebius [Ring R] : (ζ * μ : ArithmeticFunction R) = 1 := by
  

Proof state:
R : Type u_1
inst✝ : Ring R
⊢ ↑ζ * ↑μ = 1

Next tactic:
rw [← coe_coe, ← intCoe_mul, coe_zeta_mul_moebius, intCoe_one]
/-- 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
  

Proof state:
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
⊢ (∀ n > 0, ∑ i in divisors n, f i = g n) ↔ ∀ n > 0, ∑ x in divisorsAntidiagonal n, μ x.1 • g x.2 = f n

Next tactic:
let f' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else f x, if_pos rfl⟩
/-- 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
  let f' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else f x, if_pos rfl⟩
  

Proof state:
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
⊢ (∀ n > 0, ∑ i in divisors n, f i = g n) ↔ ∀ n > 0, ∑ x in divisorsAntidiagonal n, μ x.1 • g x.2 = f n

Next tactic:
let g' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else g x, if_pos rfl⟩
/-- 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
  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⟩
  

Proof state:
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
⊢ (∀ n > 0, ∑ i in divisors n, f i = g n) ↔ ∀ n > 0, ∑ x in divisorsAntidiagonal n, μ x.1 • g x.2 = f n

Next tactic:
trans (ζ : ArithmeticFunction ℤ) • f' = g'
/-- 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
  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'
  · 

Proof state:
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
⊢ (∀ n > 0, ∑ i in divisors n, f i = g n) ↔ ↑ζ • f' = g'

Next tactic:
rw [ext_iff]
/-- 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
  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'
  · rw [ext_iff]
    

Proof state:
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
⊢ (∀ n > 0, ∑ i in divisors n, f i = g n) ↔ ∀ (x : ℕ), (↑ζ • f') x = g' x

Next tactic:
apply forall_congr'
/-- 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
  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'
  · rw [ext_iff]
    apply forall_congr'
    

Proof state:
case h
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
⊢ ∀ (a : ℕ), a > 0 → ∑ i in divisors a, f i = g a ↔ (↑ζ • f') a = g' a

Next tactic:
intro n
/-- 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
  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'
  · rw [ext_iff]
    apply forall_congr'
    intro n
    

Proof state:
case h
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
n : ℕ
⊢ n > 0 → ∑ i in divisors n, f i = g n ↔ (↑ζ • f') n = g' n

Next tactic:
cases n with
    | zero => simp
    | 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]
      rw [sum_congr rfl fun x hx => ?_]
      rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors hx))]
/-- 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
  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'
  · rw [ext_iff]
    apply forall_congr'
    intro n
    cases n with
    

Proof state:
case h.zero
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
⊢ Nat.zero > 0 → ∑ i in divisors Nat.zero, f i = g Nat.zero ↔ (↑ζ • f') Nat.zero = g' Nat.zero

Next tactic:
| zero => simp
/-- 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
  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'
  · rw [ext_iff]
    apply forall_congr'
    intro n
    cases n with
    | zero => 

Proof state:
case h.zero
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
⊢ Nat.zero > 0 → ∑ i in divisors Nat.zero, f i = g Nat.zero ↔ (↑ζ • f') Nat.zero = g' Nat.zero

Next tactic:
simp
/-- 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
  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'
  · rw [ext_iff]
    apply forall_congr'
    intro n
    cases n with
    | zero => simp
    

Proof state:
case h.succ
R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
f' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) }
g' : ArithmeticFunction R :=
  { toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) }
n : ℕ
⊢ succ n > 0 → ∑ i in divisors (succ n), f i = g (succ n) ↔ (↑ζ • f') (succ n) = g' (succ n)

Next tactic:
| 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]
      rw [sum_congr rfl fun x hx => ?_]
      rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors hx))]