Theorem: Polynomial.coeff_expand
File: Mathlib/Data/Polynomial/Expand.lean

tactic: simp only [expand_eq_sum]
state_before: R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
⊢ coeff (↑(expand R p) f) n = if p ∣ n then coeff f (n / p) else 0

tactic: simp_rw [coeff_sum, ← pow_mul, C_mul_X_pow_eq_monomial, coeff_monomial, sum]
state_before: R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
⊢ coeff (sum f fun e a => ↑C a * (X ^ p) ^ e) n = if p ∣ n then coeff f (n / p) else 0

tactic: split_ifs with h
state_before: R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
⊢ (∑ x in support f, if p * x = n then coeff f x else 0) = if p ∣ n then coeff f (n / p) else 0

tactic: rw [Finset.sum_eq_single (n / p), Nat.mul_div_cancel' h, if_pos rfl]
state_before: case inl
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
⊢ (∑ x in support f, if p * x = n then coeff f x else 0) = coeff f (n / p)

tactic: intro b _ hb2
state_before: case inl.h₀
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
⊢ ∀ (b : ℕ), b ∈ support f → b ≠ n / p → (if p * b = n then coeff f b else 0) = 0

tactic: rw [if_neg]
state_before: case inl.h₀
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
b : ℕ
a✝ : b ∈ support f
hb2 : b ≠ n / p
⊢ (if p * b = n then coeff f b else 0) = 0

tactic: intro hb3
state_before: case inl.h₀.hnc
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
b : ℕ
a✝ : b ∈ support f
hb2 : b ≠ n / p
⊢ ¬p * b = n

tactic: apply hb2
state_before: case inl.h₀.hnc
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
b : ℕ
a✝ : b ∈ support f
hb2 : b ≠ n / p
hb3 : p * b = n
⊢ False

tactic: rw [← hb3, Nat.mul_div_cancel_left b hp]
state_before: case inl.h₀.hnc
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
b : ℕ
a✝ : b ∈ support f
hb2 : b ≠ n / p
hb3 : p * b = n
⊢ b = n / p

tactic: intro hn
state_before: case inl.h₁
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
⊢ ¬n / p ∈ support f → (if p * (n / p) = n then coeff f (n / p) else 0) = 0

tactic: rw [not_mem_support_iff.1 hn]
state_before: case inl.h₁
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
hn : ¬n / p ∈ support f
⊢ (if p * (n / p) = n then coeff f (n / p) else 0) = 0

tactic: split_ifs <;> rfl
state_before: case inl.h₁
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : p ∣ n
hn : ¬n / p ∈ support f
⊢ (if p * (n / p) = n then 0 else 0) = 0

tactic: rw [Finset.sum_eq_zero]
state_before: case inr
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : ¬p ∣ n
⊢ (∑ x in support f, if p * x = n then coeff f x else 0) = 0

tactic: intro k _
state_before: case inr
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : ¬p ∣ n
⊢ ∀ (x : ℕ), x ∈ support f → (if p * x = n then coeff f x else 0) = 0

tactic: rw [if_neg]
state_before: case inr
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : ¬p ∣ n
k : ℕ
a✝ : k ∈ support f
⊢ (if p * k = n then coeff f k else 0) = 0

tactic: exact fun hkn => h ⟨k, hkn.symm⟩
state_before: case inr.hnc
R : Type u
inst✝¹ : CommSemiring R
S : Type v
inst✝ : CommSemiring S
p✝ q p : ℕ
hp : 0 < p
f : R[X]
n : ℕ
h : ¬p ∣ n
k : ℕ
a✝ : k ∈ support f
⊢ ¬p * k = n