Theorem: Nat.ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq
File: Mathlib/NumberTheory/ArithmeticFunction.lean

tactic: let f' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else f x, if_pos rfl⟩
state_before: R : Type u_1
inst✝ : AddCommGroup R
f g : ℕ → R
⊢ (∀ (n : ℕ), 0 < n → ∑ i in divisors n, f i = g n) ↔
    ∀ (n : ℕ), 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: let g' : ArithmeticFunction R := ⟨fun x => if x = 0 then 0 else g x, if_pos rfl⟩
state_before: 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 < n → ∑ i in divisors n, f i = g n) ↔
    ∀ (n : ℕ), 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: trans (ζ : ArithmeticFunction ℤ) • f' = g'
state_before: 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 < n → ∑ i in divisors n, f i = g n) ↔
    ∀ (n : ℕ), 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: trans μ • g' = f'
state_before: 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) }
⊢ ↑ζ • f' = g' ↔ ∀ (n : ℕ), 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: rw [ext_iff]
state_before: 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 < n → ∑ i in divisors n, f i = g n) ↔ ↑ζ • f' = g'

tactic: apply forall_congr'
state_before: 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 < n → ∑ i in divisors n, f i = g n) ↔ ∀ (x : ℕ), ↑(↑ζ • f') x = ↑g' x

tactic: intro n
state_before: 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 : ℕ), 0 < a → ∑ i in divisors a, f i = g a ↔ ↑(↑ζ • f') a = ↑g' a

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]  intros x hx         rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors ?_))]
  exact n.succ; assumption
state_before: 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 : ℕ
⊢ 0 < n → ∑ i in divisors n, f i = g n ↔ ↑(↑ζ • f') n = ↑g' n

tactic: simp
state_before: 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) }
⊢ 0 < Nat.zero → ∑ i in divisors Nat.zero, f i = g Nat.zero ↔ ↑(↑ζ • f') Nat.zero = ↑g' Nat.zero

tactic: rw [coe_zeta_smul_apply]
state_before: 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 : ℕ
⊢ 0 < succ n → ∑ i in divisors (succ n), f i = g (succ n) ↔ ↑(↑ζ • f') (succ n) = ↑g' (succ n)

tactic: simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', if_false, ZeroHom.coe_mk]
state_before: 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 : ℕ
⊢ 0 < succ n → ∑ i in divisors (succ n), f i = g (succ n) ↔ ∑ i in divisors (succ n), ↑f' i = ↑g' (succ n)

tactic: simp only [coe_mk, succ_ne_zero, ite_false]
state_before: 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 : ℕ
⊢ ∑ i in divisors (succ n), f i = g (succ n) ↔
    ∑ x in divisors (succ n),
        ↑{ toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) } x =
      ↑{ toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) } (succ n)

tactic: rw [sum_congr rfl]
state_before: 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 : ℕ
⊢ ∑ i in divisors (succ n), f i = g (succ n) ↔ (∑ x in divisors (succ n), if x = 0 then 0 else f x) = g (succ n)

tactic: intros x hx
state_before: 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 : ℕ
⊢ ∀ (x : ℕ), x ∈ divisors (succ n) → f x = if x = 0 then 0 else f x

tactic: rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors ?_))]
state_before: 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 x : ℕ
hx : x ∈ divisors (succ n)
⊢ f x = if x = 0 then 0 else f x

tactic: exact n.succ
state_before: 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 x : ℕ
hx : x ∈ divisors (succ n)
⊢ ℕ

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 x : ℕ
hx : x ∈ divisors (succ n)
⊢ x ∈ divisors ?m.681674

tactic: assumption
state_before: 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 x : ℕ
hx : x ∈ divisors (succ n)
⊢ x ∈ divisors (succ n)

tactic: constructor <;> intro h
state_before: 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) }
⊢ ↑ζ • f' = g' ↔ μ • g' = f'

tactic: rw [← h, ← mul_smul, moebius_mul_coe_zeta, one_smul]
state_before: case mp
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) }
h : ↑ζ • f' = g'
⊢ μ • g' = f'

tactic: rw [← h, ← mul_smul, coe_zeta_mul_moebius, one_smul]
state_before: case mpr
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) }
h : μ • g' = f'
⊢ ↑ζ • f' = g'

tactic: rw [ext_iff]
state_before: 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) }
⊢ μ • g' = f' ↔ ∀ (n : ℕ), 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: apply forall_congr'
state_before: 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) }
⊢ (∀ (x : ℕ), ↑(μ • g') x = ↑f' x) ↔ ∀ (n : ℕ), 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: intro n
state_before: 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 : ℕ), ↑(μ • g') a = ↑f' a ↔ 0 < a → ∑ x in divisorsAntidiagonal a, ↑μ x.fst • g x.snd = f a

tactic: cases n with
| zero => simp
| succ n =>
  simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', smul_apply, if_false,
    ZeroHom.coe_mk]
  simp only [Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
  rw [sum_congr rfl]  intros x hx         rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
state_before: 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 : ℕ
⊢ ↑(μ • g') n = ↑f' n ↔ 0 < n → ∑ x in divisorsAntidiagonal n, ↑μ x.fst • g x.snd = f n

tactic: simp
state_before: 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) }
⊢ ↑(μ • g') Nat.zero = ↑f' Nat.zero ↔
    0 < Nat.zero → ∑ x in divisorsAntidiagonal Nat.zero, ↑μ x.fst • g x.snd = f Nat.zero

tactic: simp only [n.succ_ne_zero, forall_prop_of_true, succ_pos', smul_apply, if_false,
  ZeroHom.coe_mk]
state_before: 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 : ℕ
⊢ ↑(μ • g') (succ n) = ↑f' (succ n) ↔ 0 < succ n → ∑ x in divisorsAntidiagonal (succ n), ↑μ x.fst • g x.snd = f (succ n)

tactic: simp only [Nat.isUnit_iff, coe_mk, ZeroHom.toFun_eq_coe, succ_ne_zero, ite_false]
state_before: 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 : ℕ
⊢ ∑ x in divisorsAntidiagonal (succ n),
        ↑μ x.fst •
          ↑{ toFun := fun x => if x = 0 then 0 else g x, map_zero' := (_ : (if 0 = 0 then 0 else g 0) = 0) } x.snd =
      ↑{ toFun := fun x => if x = 0 then 0 else f x, map_zero' := (_ : (if 0 = 0 then 0 else f 0) = 0) } (succ n) ↔
    ∑ x in divisorsAntidiagonal (succ n), ↑μ x.fst • g x.snd = f (succ n)

tactic: rw [sum_congr rfl]
state_before: 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 : ℕ
⊢ (∑ x in divisorsAntidiagonal (succ n), ↑μ x.fst • if x.snd = 0 then 0 else g x.snd) = f (succ n) ↔
    ∑ x in divisorsAntidiagonal (succ n), ↑μ x.fst • g x.snd = f (succ n)

tactic: intros x hx
state_before: 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 : ℕ
⊢ ∀ (x : ℕ × ℕ), x ∈ divisorsAntidiagonal (succ n) → (↑μ x.fst • if x.snd = 0 then 0 else g x.snd) = ↑μ x.fst • g x.snd

tactic: rw [if_neg (ne_of_gt (Nat.pos_of_mem_divisors (snd_mem_divisors_of_mem_antidiagonal hx)))]
state_before: 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 : ℕ
x : ℕ × ℕ
hx : x ∈ divisorsAntidiagonal (succ n)
⊢ (↑μ x.fst • if x.snd = 0 then 0 else g x.snd) = ↑μ x.fst • g x.snd