-- Mathlib/RingTheory/MvPowerSeries/Basic.lean
theorem coeff_eq_zero_of_constantCoeff_nilpotent
    {f : MvPowerSeries σ R} {m : ℕ} (hf : constantCoeff σ R f ^ m = 0)
    {d : σ →₀ ℕ} {n : ℕ} (hn : m + degree d ≤ n) : coeff R d (f ^ n) = 0

Proof state:
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
this : m ≤ #s
⊢ (constantCoeff σ R) f ^ #s = 0

Tactic:
obtain ⟨m', hm'⟩ := Nat.exists_eq_add_of_le this

Result:
case intro
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
this : m ≤ #s
m' : ℕ
hm' : #s = m + m'
⊢ (constantCoeff σ R) f ^ #s = 0

Proof state:
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ #(range n \ s) ≤ (∑ x ∈ range n \ s, k x).degree

Tactic:
convert Finset.card_nsmul_le_sum (range n \ s) (fun x ↦ degree (k x)) 1 _

Result:
case h.e'_3
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ #(range n \ s) = #(range n \ s) • 1

case h.e'_4
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ (∑ x ∈ range n \ s, k x).degree = ∑ x ∈ range n \ s, (k x).degree

σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ ∀ x ∈ range n \ s, 1 ≤ (fun x => (k x).degree) x

Proof state:
case h
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
⊢ ∏ i ∈ range n, (coeff R (k i)) f = 0

Tactic:
set s := {i ∈ range n | k i = 0} with hs_def

Result:
case h
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
⊢ ∏ i ∈ range n, (coeff R (k i)) f = 0

Proof state:
case h.h
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ m ≤ #s

Tactic:
rw [← Nat.add_le_add_iff_right, add_comm #s,
  Finset.card_sdiff_add_card_eq_card (filter_subset _ _), card_range]

Result:
case h.h
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ m + #(range n \ Finset.filter (fun i => k i = 0) (range n)) ≤ n

Proof state:
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
i : ℕ
hi : i < n
hi' : i < n → ¬k i = 0
⊢ ¬k i = 0

Tactic:
exact hi' hi

Result:
no goals

Proof state:
case h.e'_3
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ #(range n \ s) = #(range n \ s) • 1

Tactic:
simp only [Algebra.id.smul_eq_mul, mul_one]

Result:
no goals

Proof state:
case h
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ (∏ x ∈ range n \ s, (coeff R (k x)) f) * ∏ x ∈ s, (coeff R (k x)) f = 0

Tactic:
apply mul_eq_zero_of_right

Result:
case h.h
σ : Type u_1
R : Type u_3
inst✝ : CommSemiring R
f : MvPowerSeries σ R
m : ℕ
hf : (constantCoeff σ R) f ^ m = 0
d : σ →₀ ℕ
n : ℕ
hn : m + d.degree ≤ n
k : ℕ →₀ σ →₀ ℕ
hk : (range n).sum ⇑k = d ∧ k.support ⊆ range n
s : Finset ℕ := Finset.filter (fun i => k i = 0) (range n)
hs_def : s = Finset.filter (fun i => k i = 0) (range n)
hs : s ⊆ range n
hs' : ∀ i ∈ s, (coeff R (k i)) f = (constantCoeff σ R) f
hs'' : ∀ i ∈ s, k i = 0
⊢ ∏ x ∈ s, (coeff R (k x)) f = 0