l3lab/ntp-mathlib huggingface dataset:
theorem IsNilpotent.sub_one_isUnit [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
hnil : IsNilpotent r
⊢ IsUnit (r - 1)

Next tactic:
obtain ⟨n, hn⟩ := hnil
theorem IsNilpotent.sub_one_isUnit [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
  obtain ⟨n, hn⟩ := hnil
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
n : ℕ
hn : r ^ n = 0
⊢ IsUnit (r - 1)

Next tactic:
refine' ⟨⟨r - 1, -∑ i in Finset.range n, r ^ i, _, _⟩, rfl⟩
theorem IsNilpotent.sub_one_isUnit [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
  obtain ⟨n, hn⟩ := hnil
  refine' ⟨⟨r - 1, -∑ i in Finset.range n, r ^ i, _, _⟩, rfl⟩
  · 

Proof state:
case intro.refine'_1
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
n : ℕ
hn : r ^ n = 0
⊢ (r - 1) * -∑ i in Finset.range n, r ^ i = 1

Next tactic:
rw [mul_neg, mul_geom_sum, hn]
theorem IsNilpotent.sub_one_isUnit [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
  obtain ⟨n, hn⟩ := hnil
  refine' ⟨⟨r - 1, -∑ i in Finset.range n, r ^ i, _, _⟩, rfl⟩
  · rw [mul_neg, mul_geom_sum, hn]
    

Proof state:
case intro.refine'_1
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
n : ℕ
hn : r ^ n = 0
⊢ -(0 - 1) = 1

Next tactic:
simp
theorem IsNilpotent.sub_one_isUnit [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
  obtain ⟨n, hn⟩ := hnil
  refine' ⟨⟨r - 1, -∑ i in Finset.range n, r ^ i, _, _⟩, rfl⟩
  · rw [mul_neg, mul_geom_sum, hn]
    simp
  · 

Proof state:
case intro.refine'_2
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
n : ℕ
hn : r ^ n = 0
⊢ (-∑ i in Finset.range n, r ^ i) * (r - 1) = 1

Next tactic:
rw [neg_mul, geom_sum_mul, hn]
theorem IsNilpotent.sub_one_isUnit [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
  obtain ⟨n, hn⟩ := hnil
  refine' ⟨⟨r - 1, -∑ i in Finset.range n, r ^ i, _, _⟩, rfl⟩
  · rw [mul_neg, mul_geom_sum, hn]
    simp
  · rw [neg_mul, geom_sum_mul, hn]
    

Proof state:
case intro.refine'_2
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
n : ℕ
hn : r ^ n = 0
⊢ -(0 - 1) = 1

Next tactic:
simp
theorem Commute.IsNilpotent.add_isUnit [Ring R] {r : R} {u : Rˣ} (hnil : IsNilpotent r)
    (hru : Commute r (↑u⁻¹ : R)) : IsUnit (u + r) := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
u : Rˣ
hnil : IsNilpotent r
hru : Commute r ↑u⁻¹
⊢ IsUnit (↑u + r)

Next tactic:
rw [← Units.isUnit_mul_units _ u⁻¹, add_mul, Units.mul_inv, ← IsUnit.neg_iff, add_comm, neg_add,
    ← sub_eq_add_neg]
theorem Commute.IsNilpotent.add_isUnit [Ring R] {r : R} {u : Rˣ} (hnil : IsNilpotent r)
    (hru : Commute r (↑u⁻¹ : R)) : IsUnit (u + r) := by
  rw [← Units.isUnit_mul_units _ u⁻¹, add_mul, Units.mul_inv, ← IsUnit.neg_iff, add_comm, neg_add,
    ← sub_eq_add_neg]
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
u : Rˣ
hnil : IsNilpotent r
hru : Commute r ↑u⁻¹
⊢ IsUnit (-(r * ↑u⁻¹) - 1)

Next tactic:
obtain ⟨n, hn⟩ := hnil
theorem Commute.IsNilpotent.add_isUnit [Ring R] {r : R} {u : Rˣ} (hnil : IsNilpotent r)
    (hru : Commute r (↑u⁻¹ : R)) : IsUnit (u + r) := by
  rw [← Units.isUnit_mul_units _ u⁻¹, add_mul, Units.mul_inv, ← IsUnit.neg_iff, add_comm, neg_add,
    ← sub_eq_add_neg]
  obtain ⟨n, hn⟩ := hnil
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
u : Rˣ
hru : Commute r ↑u⁻¹
n : ℕ
hn : r ^ n = 0
⊢ IsUnit (-(r * ↑u⁻¹) - 1)

Next tactic:
refine' IsNilpotent.sub_one_isUnit ⟨n, _⟩
theorem Commute.IsNilpotent.add_isUnit [Ring R] {r : R} {u : Rˣ} (hnil : IsNilpotent r)
    (hru : Commute r (↑u⁻¹ : R)) : IsUnit (u + r) := by
  rw [← Units.isUnit_mul_units _ u⁻¹, add_mul, Units.mul_inv, ← IsUnit.neg_iff, add_comm, neg_add,
    ← sub_eq_add_neg]
  obtain ⟨n, hn⟩ := hnil
  refine' IsNilpotent.sub_one_isUnit ⟨n, _⟩
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
u : Rˣ
hru : Commute r ↑u⁻¹
n : ℕ
hn : r ^ n = 0
⊢ (-(r * ↑u⁻¹)) ^ n = 0

Next tactic:
rw [neg_pow, hru.mul_pow, hn]
theorem Commute.IsNilpotent.add_isUnit [Ring R] {r : R} {u : Rˣ} (hnil : IsNilpotent r)
    (hru : Commute r (↑u⁻¹ : R)) : IsUnit (u + r) := by
  rw [← Units.isUnit_mul_units _ u⁻¹, add_mul, Units.mul_inv, ← IsUnit.neg_iff, add_comm, neg_add,
    ← sub_eq_add_neg]
  obtain ⟨n, hn⟩ := hnil
  refine' IsNilpotent.sub_one_isUnit ⟨n, _⟩
  rw [neg_pow, hru.mul_pow, hn]
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Ring R
r : R
u : Rˣ
hru : Commute r ↑u⁻¹
n : ℕ
hn : r ^ n = 0
⊢ (-1) ^ n * (0 * ↑u⁻¹ ^ n) = 0

Next tactic:
simp
theorem isReduced_of_injective [MonoidWithZero R] [MonoidWithZero S] {F : Type*}
    [MonoidWithZeroHomClass F R S] (f : F) (hf : Function.Injective f) [IsReduced S] :
    IsReduced R := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝³ : MonoidWithZero R
inst✝² : MonoidWithZero S
F : Type u_3
inst✝¹ : MonoidWithZeroHomClass F R S
f : F
hf : Function.Injective ⇑f
inst✝ : IsReduced S
⊢ IsReduced R

Next tactic:
constructor
theorem isReduced_of_injective [MonoidWithZero R] [MonoidWithZero S] {F : Type*}
    [MonoidWithZeroHomClass F R S] (f : F) (hf : Function.Injective f) [IsReduced S] :
    IsReduced R := by
  constructor
  

Proof state:
case eq_zero
R : Type u_1
S : Type u_2
x y : R
inst✝³ : MonoidWithZero R
inst✝² : MonoidWithZero S
F : Type u_3
inst✝¹ : MonoidWithZeroHomClass F R S
f : F
hf : Function.Injective ⇑f
inst✝ : IsReduced S
⊢ ∀ (x : R), IsNilpotent x → x = 0

Next tactic:
intro x hx
theorem isReduced_of_injective [MonoidWithZero R] [MonoidWithZero S] {F : Type*}
    [MonoidWithZeroHomClass F R S] (f : F) (hf : Function.Injective f) [IsReduced S] :
    IsReduced R := by
  constructor
  intro x hx
  

Proof state:
case eq_zero
R : Type u_1
S : Type u_2
x✝ y : R
inst✝³ : MonoidWithZero R
inst✝² : MonoidWithZero S
F : Type u_3
inst✝¹ : MonoidWithZeroHomClass F R S
f : F
hf : Function.Injective ⇑f
inst✝ : IsReduced S
x : R
hx : IsNilpotent x
⊢ x = 0

Next tactic:
apply hf
theorem isReduced_of_injective [MonoidWithZero R] [MonoidWithZero S] {F : Type*}
    [MonoidWithZeroHomClass F R S] (f : F) (hf : Function.Injective f) [IsReduced S] :
    IsReduced R := by
  constructor
  intro x hx
  apply hf
  

Proof state:
case eq_zero.a
R : Type u_1
S : Type u_2
x✝ y : R
inst✝³ : MonoidWithZero R
inst✝² : MonoidWithZero S
F : Type u_3
inst✝¹ : MonoidWithZeroHomClass F R S
f : F
hf : Function.Injective ⇑f
inst✝ : IsReduced S
x : R
hx : IsNilpotent x
⊢ f x = f 0

Next tactic:
rw [map_zero]
theorem isReduced_of_injective [MonoidWithZero R] [MonoidWithZero S] {F : Type*}
    [MonoidWithZeroHomClass F R S] (f : F) (hf : Function.Injective f) [IsReduced S] :
    IsReduced R := by
  constructor
  intro x hx
  apply hf
  rw [map_zero]
  

Proof state:
case eq_zero.a
R : Type u_1
S : Type u_2
x✝ y : R
inst✝³ : MonoidWithZero R
inst✝² : MonoidWithZero S
F : Type u_3
inst✝¹ : MonoidWithZeroHomClass F R S
f : F
hf : Function.Injective ⇑f
inst✝ : IsReduced S
x : R
hx : IsNilpotent x
⊢ f x = 0

Next tactic:
exact (hx.map f).eq_zero
theorem RingHom.ker_isRadical_iff_reduced_of_surjective {S F} [CommSemiring R] [CommRing S]
    [RingHomClass F R S] {f : F} (hf : Function.Surjective f) :
    (RingHom.ker f).IsRadical ↔ IsReduced S := by
  

Proof state:
R : Type u_1
S✝ : Type u_2
x y : R
S : Type u_3
F : Type u_4
inst✝² : CommSemiring R
inst✝¹ : CommRing S
inst✝ : RingHomClass F R S
f : F
hf : Function.Surjective ⇑f
⊢ Ideal.IsRadical (ker f) ↔ IsReduced S

Next tactic:
simp_rw [isReduced_iff, hf.forall, IsNilpotent, ← map_pow, ← RingHom.mem_ker]
theorem RingHom.ker_isRadical_iff_reduced_of_surjective {S F} [CommSemiring R] [CommRing S]
    [RingHomClass F R S] {f : F} (hf : Function.Surjective f) :
    (RingHom.ker f).IsRadical ↔ IsReduced S := by
  simp_rw [isReduced_iff, hf.forall, IsNilpotent, ← map_pow, ← RingHom.mem_ker]
  

Proof state:
R : Type u_1
S✝ : Type u_2
x y : R
S : Type u_3
F : Type u_4
inst✝² : CommSemiring R
inst✝¹ : CommRing S
inst✝ : RingHomClass F R S
f : F
hf : Function.Surjective ⇑f
⊢ Ideal.IsRadical (ker f) ↔ ∀ (x : R), (∃ n, x ^ n ∈ ker f) → x ∈ ker f

Next tactic:
rfl
theorem zero_isRadical_iff [MonoidWithZero R] : IsRadical (0 : R) ↔ IsReduced R := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : MonoidWithZero R
⊢ IsRadical 0 ↔ IsReduced R

Next tactic:
simp_rw [isReduced_iff, IsNilpotent, exists_imp, ← zero_dvd_iff]
theorem zero_isRadical_iff [MonoidWithZero R] : IsRadical (0 : R) ↔ IsReduced R := by
  simp_rw [isReduced_iff, IsNilpotent, exists_imp, ← zero_dvd_iff]
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : MonoidWithZero R
⊢ IsRadical 0 ↔ ∀ (x : R) (x_1 : ℕ), 0 ∣ x ^ x_1 → 0 ∣ x

Next tactic:
exact forall_swap
theorem isRadical_iff_span_singleton [CommSemiring R] :
    IsRadical y ↔ (Ideal.span ({y} : Set R)).IsRadical := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : CommSemiring R
⊢ IsRadical y ↔ Ideal.IsRadical (Ideal.span {y})

Next tactic:
simp_rw [IsRadical, ← Ideal.mem_span_singleton]
theorem isRadical_iff_span_singleton [CommSemiring R] :
    IsRadical y ↔ (Ideal.span ({y} : Set R)).IsRadical := by
  simp_rw [IsRadical, ← Ideal.mem_span_singleton]
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : CommSemiring R
⊢ (∀ (n : ℕ) (x : R), x ^ n ∈ Ideal.span {y} → x ∈ Ideal.span {y}) ↔ Ideal.IsRadical (Ideal.span {y})

Next tactic:
exact forall_swap.trans (forall_congr' fun r => exists_imp.symm)
theorem isReduced_iff_pow_one_lt [MonoidWithZero R] (k : ℕ) (hk : 1 < k) :
    IsReduced R ↔ ∀ x : R, x ^ k = 0 → x = 0 := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : MonoidWithZero R
k : ℕ
hk : 1 < k
⊢ IsReduced R ↔ ∀ (x : R), x ^ k = 0 → x = 0

Next tactic:
simp_rw [← zero_isRadical_iff, isRadical_iff_pow_one_lt k hk, zero_dvd_iff]
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hx : IsNilpotent x
hy : IsNilpotent y
⊢ IsNilpotent (x + y)

Next tactic:
obtain ⟨n, hn⟩ := hx
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hy : IsNilpotent y
n : ℕ
hn : x ^ n = 0
⊢ IsNilpotent (x + y)

Next tactic:
obtain ⟨m, hm⟩ := hy
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
⊢ IsNilpotent (x + y)

Next tactic:
use n + m - 1
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
⊢ (x + y) ^ (n + m - 1) = 0

Next tactic:
rw [h_comm.add_pow']
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
⊢ ∑ m_1 in Finset.antidiagonal (n + m - 1), Nat.choose (n + m - 1) m_1.1 • (x ^ m_1.1 * y ^ m_1.2) = 0

Next tactic:
apply Finset.sum_eq_zero
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  apply Finset.sum_eq_zero
  

Proof state:
case h.h
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
⊢ ∀ x_1 ∈ Finset.antidiagonal (n + m - 1), Nat.choose (n + m - 1) x_1.1 • (x ^ x_1.1 * y ^ x_1.2) = 0

Next tactic:
rintro ⟨i, j⟩ hij
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  apply Finset.sum_eq_zero
  rintro ⟨i, j⟩ hij
  

Proof state:
case h.h.mk
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
i j : ℕ
hij : (i, j) ∈ Finset.antidiagonal (n + m - 1)
⊢ Nat.choose (n + m - 1) (i, j).1 • (x ^ (i, j).1 * y ^ (i, j).2) = 0

Next tactic:
suffices x ^ i * y ^ j = 0 by simp only [this, nsmul_eq_mul, mul_zero]
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  apply Finset.sum_eq_zero
  rintro ⟨i, j⟩ hij
  suffices x ^ i * y ^ j = 0 by 

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
i j : ℕ
hij : (i, j) ∈ Finset.antidiagonal (n + m - 1)
this : x ^ i * y ^ j = 0
⊢ Nat.choose (n + m - 1) (i, j).1 • (x ^ (i, j).1 * y ^ (i, j).2) = 0

Next tactic:
simp only [this, nsmul_eq_mul, mul_zero]
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  apply Finset.sum_eq_zero
  rintro ⟨i, j⟩ hij
  suffices x ^ i * y ^ j = 0 by simp only [this, nsmul_eq_mul, mul_zero]
  

Proof state:
case h.h.mk
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
i j : ℕ
hij : (i, j) ∈ Finset.antidiagonal (n + m - 1)
⊢ x ^ i * y ^ j = 0

Next tactic:
cases' Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi hj
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  apply Finset.sum_eq_zero
  rintro ⟨i, j⟩ hij
  suffices x ^ i * y ^ j = 0 by simp only [this, nsmul_eq_mul, mul_zero]
  cases' Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi hj
  · 

Proof state:
case h.h.mk.inl
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
i j : ℕ
hij : (i, j) ∈ Finset.antidiagonal (n + m - 1)
hi : n ≤ (i, j).1
⊢ x ^ i * y ^ j = 0

Next tactic:
rw [pow_eq_zero_of_le hi hn, zero_mul]
theorem isNilpotent_add (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x + y) := by
  obtain ⟨n, hn⟩ := hx
  obtain ⟨m, hm⟩ := hy
  use n + m - 1
  rw [h_comm.add_pow']
  apply Finset.sum_eq_zero
  rintro ⟨i, j⟩ hij
  suffices x ^ i * y ^ j = 0 by simp only [this, nsmul_eq_mul, mul_zero]
  cases' Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi hj
  · rw [pow_eq_zero_of_le hi hn, zero_mul]
  · 

Proof state:
case h.h.mk.inr
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
n : ℕ
hn : x ^ n = 0
m : ℕ
hm : y ^ m = 0
i j : ℕ
hij : (i, j) ∈ Finset.antidiagonal (n + m - 1)
hj : m ≤ (i, j).2
⊢ x ^ i * y ^ j = 0

Next tactic:
rw [pow_eq_zero_of_le hj hm, mul_zero]
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
s : Finset ι
f : ι → R
hnp : ∀ i ∈ s, IsNilpotent (f i)
h_comm : ∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)
⊢ IsNilpotent (∑ i in s, f i)

Next tactic:
classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  apply Commute.isNilpotent_add
  · exact Commute.sum_right _ _ _ (fun i hi ↦ h_comm _ _ (by simp) (by simp [hi]))
  · apply hnp; simp
  · exact ih (fun i hi ↦ hnp i (by simp [hi]))
      (fun i j hi hj ↦ h_comm i j (by simp [hi]) (by simp [hj]))
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
s : Finset ι
f : ι → R
hnp : ∀ i ∈ s, IsNilpotent (f i)
h_comm : ∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)
⊢ IsNilpotent (∑ i in s, f i)

Next tactic:
induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  

Proof state:
case empty
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
hnp : ∀ i ∈ ∅, IsNilpotent (f i)
h_comm : ∀ (i j : ι), i ∈ ∅ → j ∈ ∅ → Commute (f i) (f j)
⊢ IsNilpotent (∑ i in ∅, f i)

Next tactic:
| empty => simp
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => 

Proof state:
case empty
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
hnp : ∀ i ∈ ∅, IsNilpotent (f i)
h_comm : ∀ (i j : ι), i ∈ ∅ → j ∈ ∅ → Commute (f i) (f j)
⊢ IsNilpotent (∑ i in ∅, f i)

Next tactic:
simp
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  

Proof state:
case insert
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
⊢ IsNilpotent (∑ i in insert j s, f i)

Next tactic:
rw [Finset.sum_insert hj]
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  

Proof state:
case insert
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
⊢ IsNilpotent (f j + ∑ x in s, f x)

Next tactic:
apply Commute.isNilpotent_add
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  apply Commute.isNilpotent_add
  · 

Proof state:
case insert.h_comm
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
⊢ Commute (f j) (∑ x in s, f x)

Next tactic:
exact Commute.sum_right _ _ _ (fun i hi ↦ h_comm _ _ (by simp) (by simp [hi]))
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  apply Commute.isNilpotent_add
  · exact Commute.sum_right _ _ _ (fun i hi ↦ h_comm _ _ (by 

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
i : ι
hi : i ∈ s
⊢ j ∈ insert j s

Next tactic:
simp
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  apply Commute.isNilpotent_add
  · exact Commute.sum_right _ _ _ (fun i hi ↦ h_comm _ _ (by simp) (by 

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
i : ι
hi : i ∈ s
⊢ i ∈ insert j s

Next tactic:
simp [hi]
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  apply Commute.isNilpotent_add
  · exact Commute.sum_right _ _ _ (fun i hi ↦ h_comm _ _ (by simp) (by simp [hi]))
  · 

Proof state:
case insert.hx
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
⊢ IsNilpotent (f j)

Next tactic:
apply hnp
protected lemma isNilpotent_sum {ι : Type*} {s : Finset ι} {f : ι → R}
    (hnp : ∀ i ∈ s, IsNilpotent (f i)) (h_comm : ∀ i j, i ∈ s → j ∈ s → Commute (f i) (f j)) :
    IsNilpotent (∑ i in s, f i) := by
  classical
  induction s using Finset.induction with
  | empty => simp
  | @insert j s hj ih => ?_
  rw [Finset.sum_insert hj]
  apply Commute.isNilpotent_add
  · exact Commute.sum_right _ _ _ (fun i hi ↦ h_comm _ _ (by simp) (by simp [hi]))
  · apply hnp; 

Proof state:
case insert.hx.a
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm✝ : Commute x y
ι : Type u_3
f : ι → R
j : ι
s : Finset ι
hj : j ∉ s
ih : (∀ i ∈ s, IsNilpotent (f i)) → (∀ (i j : ι), i ∈ s → j ∈ s → Commute (f i) (f j)) → IsNilpotent (∑ i in s, f i)
hnp : ∀ i ∈ insert j s, IsNilpotent (f i)
h_comm : ∀ (i j_1 : ι), i ∈ insert j s → j_1 ∈ insert j s → Commute (f i) (f j_1)
⊢ j ∈ insert j s

Next tactic:
simp