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

Proof state:
case insert.hy
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 (∑ x in s, f x)

Next tactic:
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
  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 

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]))
  · apply hnp; simp
  · exact ih (fun i hi ↦ hnp i (by simp [hi]))
      (fun i j hi hj ↦ h_comm i j (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 : ι), i ∈ insert j✝ s → j ∈ insert j✝ s → Commute (f i) (f j)
i j : ι
hi : i ∈ s
hj : j ∈ 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]))
  · 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 

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 : ι), i ∈ insert j✝ s → j ∈ insert j✝ s → Commute (f i) (f j)
i j : ι
hi : i ∈ s
hj : j ∈ s
⊢ j ∈ insert j✝ s

Next tactic:
simp [hj]
theorem isNilpotent_mul_left (h : IsNilpotent x) : 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
h : IsNilpotent x
⊢ IsNilpotent (x * y)

Next tactic:
obtain ⟨n, hn⟩ := h
theorem isNilpotent_mul_left (h : IsNilpotent x) : IsNilpotent (x * y) := by
  obtain ⟨n, hn⟩ := h
  

Proof state:
case 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
⊢ IsNilpotent (x * y)

Next tactic:
use n
theorem isNilpotent_mul_left (h : IsNilpotent x) : IsNilpotent (x * y) := by
  obtain ⟨n, hn⟩ := h
  use n
  

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
⊢ (x * y) ^ n = 0

Next tactic:
rw [h_comm.mul_pow, hn, zero_mul]
protected lemma isNilpotent_mul_left_iff (hy : y ∈ nonZeroDivisorsLeft R) :
    IsNilpotent (x * y) ↔ IsNilpotent x := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hy : y ∈ nonZeroDivisorsLeft R
⊢ IsNilpotent (x * y) ↔ IsNilpotent x

Next tactic:
refine' ⟨_, h_comm.isNilpotent_mul_left⟩
protected lemma isNilpotent_mul_left_iff (hy : y ∈ nonZeroDivisorsLeft R) :
    IsNilpotent (x * y) ↔ IsNilpotent x := by
  refine' ⟨_, h_comm.isNilpotent_mul_left⟩
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hy : y ∈ nonZeroDivisorsLeft R
⊢ IsNilpotent (x * y) → IsNilpotent x

Next tactic:
rintro ⟨k, hk⟩
protected lemma isNilpotent_mul_left_iff (hy : y ∈ nonZeroDivisorsLeft R) :
    IsNilpotent (x * y) ↔ IsNilpotent x := by
  refine' ⟨_, h_comm.isNilpotent_mul_left⟩
  rintro ⟨k, hk⟩
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hy : y ∈ nonZeroDivisorsLeft R
k : ℕ
hk : (x * y) ^ k = 0
⊢ IsNilpotent x

Next tactic:
rw [mul_pow h_comm] at hk
protected lemma isNilpotent_mul_left_iff (hy : y ∈ nonZeroDivisorsLeft R) :
    IsNilpotent (x * y) ↔ IsNilpotent x := by
  refine' ⟨_, h_comm.isNilpotent_mul_left⟩
  rintro ⟨k, hk⟩
  rw [mul_pow h_comm] at hk
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hy : y ∈ nonZeroDivisorsLeft R
k : ℕ
hk : x ^ k * y ^ k = 0
⊢ IsNilpotent x

Next tactic:
exact ⟨k, (nonZeroDivisorsLeft R).pow_mem hy k _ hk⟩
theorem isNilpotent_mul_right (h : 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
h : IsNilpotent y
⊢ IsNilpotent (x * y)

Next tactic:
rw [h_comm.eq]
theorem isNilpotent_mul_right (h : IsNilpotent y) : IsNilpotent (x * y) := by
  rw [h_comm.eq]
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
h : IsNilpotent y
⊢ IsNilpotent (y * x)

Next tactic:
exact h_comm.symm.isNilpotent_mul_left h
protected lemma isNilpotent_mul_right_iff (hx : x ∈ nonZeroDivisorsRight R) :
    IsNilpotent (x * y) ↔ IsNilpotent y := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hx : x ∈ nonZeroDivisorsRight R
⊢ IsNilpotent (x * y) ↔ IsNilpotent y

Next tactic:
refine' ⟨_, h_comm.isNilpotent_mul_right⟩
protected lemma isNilpotent_mul_right_iff (hx : x ∈ nonZeroDivisorsRight R) :
    IsNilpotent (x * y) ↔ IsNilpotent y := by
  refine' ⟨_, h_comm.isNilpotent_mul_right⟩
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hx : x ∈ nonZeroDivisorsRight R
⊢ IsNilpotent (x * y) → IsNilpotent y

Next tactic:
rintro ⟨k, hk⟩
protected lemma isNilpotent_mul_right_iff (hx : x ∈ nonZeroDivisorsRight R) :
    IsNilpotent (x * y) ↔ IsNilpotent y := by
  refine' ⟨_, h_comm.isNilpotent_mul_right⟩
  rintro ⟨k, hk⟩
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hx : x ∈ nonZeroDivisorsRight R
k : ℕ
hk : (x * y) ^ k = 0
⊢ IsNilpotent y

Next tactic:
rw [mul_pow h_comm] at hk
protected lemma isNilpotent_mul_right_iff (hx : x ∈ nonZeroDivisorsRight R) :
    IsNilpotent (x * y) ↔ IsNilpotent y := by
  refine' ⟨_, h_comm.isNilpotent_mul_right⟩
  rintro ⟨k, hk⟩
  rw [mul_pow h_comm] at hk
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
inst✝ : Semiring R
h_comm : Commute x y
hx : x ∈ nonZeroDivisorsRight R
k : ℕ
hk : x ^ k * y ^ k = 0
⊢ IsNilpotent y

Next tactic:
exact ⟨k, (nonZeroDivisorsRight R).pow_mem hx k _ hk⟩
theorem isNilpotent_sub (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x - y) := by
  

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

Next tactic:
rw [← neg_right_iff] at h_comm
theorem isNilpotent_sub (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x - y) := by
  rw [← neg_right_iff] at h_comm
  

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

Next tactic:
rw [← isNilpotent_neg_iff] at hy
theorem isNilpotent_sub (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x - y) := by
  rw [← neg_right_iff] at h_comm
  rw [← isNilpotent_neg_iff] at hy
  

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

Next tactic:
rw [sub_eq_add_neg]
theorem isNilpotent_sub (hx : IsNilpotent x) (hy : IsNilpotent y) : IsNilpotent (x - y) := by
  rw [← neg_right_iff] at h_comm
  rw [← isNilpotent_neg_iff] at hy
  rw [sub_eq_add_neg]
  

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

Next tactic:
exact h_comm.isNilpotent_add hx hy
theorem nilradical_eq_sInf (R : Type*) [CommSemiring R] :
    nilradical R = sInf { J : Ideal R | J.IsPrime } :=
  (Ideal.radical_eq_sInf ⊥).trans <| by 

Proof state:
R✝ : Type u_1
S : Type u_2
x✝ y✝ : R✝
inst✝¹ : CommSemiring R✝
x y : R✝
R : Type u_3
inst✝ : CommSemiring R
⊢ sInf {J | ⊥ ≤ J ∧ Ideal.IsPrime J} = sInf {J | Ideal.IsPrime J}

Next tactic:
simp_rw [and_iff_right bot_le]
theorem nilpotent_iff_mem_prime : IsNilpotent x ↔ ∀ J : Ideal R, J.IsPrime → x ∈ J := by
  

Proof state:
R : Type u_1
S : Type u_2
x✝ y✝ : R
inst✝ : CommSemiring R
x y : R
⊢ IsNilpotent x ↔ ∀ (J : Ideal R), Ideal.IsPrime J → x ∈ J

Next tactic:
rw [← mem_nilradical, nilradical_eq_sInf, Submodule.mem_sInf]
theorem nilpotent_iff_mem_prime : IsNilpotent x ↔ ∀ J : Ideal R, J.IsPrime → x ∈ J := by
  rw [← mem_nilradical, nilradical_eq_sInf, Submodule.mem_sInf]
  

Proof state:
R : Type u_1
S : Type u_2
x✝ y✝ : R
inst✝ : CommSemiring R
x y : R
⊢ (∀ p ∈ {J | Ideal.IsPrime J}, x ∈ p) ↔ ∀ (J : Ideal R), Ideal.IsPrime J → x ∈ J

Next tactic:
rfl
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
⊢ IsNilpotent (mulLeft R a) ↔ IsNilpotent a

Next tactic:
constructor
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> 

Proof state:
case mp
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
⊢ IsNilpotent (mulLeft R a) → IsNilpotent a

Next tactic:
rintro ⟨n, hn⟩
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> 

Proof state:
case mpr
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
⊢ IsNilpotent a → IsNilpotent (mulLeft R a)

Next tactic:
rintro ⟨n, hn⟩
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> 

Proof state:
case mp.intro
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : mulLeft R a ^ n = 0
⊢ IsNilpotent a

Next tactic:
use n
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> 

Proof state:
case mpr.intro
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : a ^ n = 0
⊢ IsNilpotent (mulLeft R a)

Next tactic:
use n
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> use n <;>
      

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : mulLeft R a ^ n = 0
⊢ a ^ n = 0

Next tactic:
simp only [mulLeft_eq_zero_iff, pow_mulLeft] at hn ⊢
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> use n <;>
      

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : a ^ n = 0
⊢ mulLeft R a ^ n = 0

Next tactic:
simp only [mulLeft_eq_zero_iff, pow_mulLeft] at hn ⊢
@[simp]
theorem isNilpotent_mulLeft_iff (a : A) : IsNilpotent (mulLeft R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> use n <;>
      simp only [mulLeft_eq_zero_iff, pow_mulLeft] at hn ⊢ <;>
    

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : a ^ n = 0
⊢ a ^ n = 0

Next tactic:
exact hn
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
⊢ IsNilpotent (mulRight R a) ↔ IsNilpotent a

Next tactic:
constructor
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> 

Proof state:
case mp
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
⊢ IsNilpotent (mulRight R a) → IsNilpotent a

Next tactic:
rintro ⟨n, hn⟩
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> 

Proof state:
case mpr
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
⊢ IsNilpotent a → IsNilpotent (mulRight R a)

Next tactic:
rintro ⟨n, hn⟩
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> 

Proof state:
case mp.intro
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : mulRight R a ^ n = 0
⊢ IsNilpotent a

Next tactic:
use n
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> 

Proof state:
case mpr.intro
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : a ^ n = 0
⊢ IsNilpotent (mulRight R a)

Next tactic:
use n
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> use n <;>
      

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : mulRight R a ^ n = 0
⊢ a ^ n = 0

Next tactic:
simp only [mulRight_eq_zero_iff, pow_mulRight] at hn ⊢
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> use n <;>
      

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : a ^ n = 0
⊢ mulRight R a ^ n = 0

Next tactic:
simp only [mulRight_eq_zero_iff, pow_mulRight] at hn ⊢
@[simp]
theorem isNilpotent_mulRight_iff (a : A) : IsNilpotent (mulRight R a) ↔ IsNilpotent a := by
  constructor <;> rintro ⟨n, hn⟩ <;> use n <;>
      simp only [mulRight_eq_zero_iff, pow_mulRight] at hn ⊢ <;>
    

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝² : CommSemiring R
inst✝¹ : Semiring A
inst✝ : Algebra R A
a : A
n : ℕ
hn : a ^ n = 0
⊢ a ^ n = 0

Next tactic:
exact hn
@[simp]
lemma isNilpotent_toMatrix_iff (b : Basis ι R M) (f : M →ₗ[R] M) :
    IsNilpotent (toMatrix b b f) ↔ IsNilpotent f := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
ι : Type u_3
M : Type u_4
inst✝³ : Fintype ι
inst✝² : DecidableEq ι
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
b : Basis ι R M
f : M →ₗ[R] M
⊢ IsNilpotent ((toMatrix b b) f) ↔ IsNilpotent f

Next tactic:
refine' exists_congr fun k ↦ _
@[simp]
lemma isNilpotent_toMatrix_iff (b : Basis ι R M) (f : M →ₗ[R] M) :
    IsNilpotent (toMatrix b b f) ↔ IsNilpotent f := by
  refine' exists_congr fun k ↦ _
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
ι : Type u_3
M : Type u_4
inst✝³ : Fintype ι
inst✝² : DecidableEq ι
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
b : Basis ι R M
f : M →ₗ[R] M
k : ℕ
⊢ (toMatrix b b) f ^ k = 0 ↔ f ^ k = 0

Next tactic:
rw [toMatrix_pow]
@[simp]
lemma isNilpotent_toMatrix_iff (b : Basis ι R M) (f : M →ₗ[R] M) :
    IsNilpotent (toMatrix b b f) ↔ IsNilpotent f := by
  refine' exists_congr fun k ↦ _
  rw [toMatrix_pow]
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
A : Type v
inst✝⁶ : CommSemiring R
inst✝⁵ : Semiring A
inst✝⁴ : Algebra R A
ι : Type u_3
M : Type u_4
inst✝³ : Fintype ι
inst✝² : DecidableEq ι
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
b : Basis ι R M
f : M →ₗ[R] M
k : ℕ
⊢ (toMatrix b b) (f ^ k) = 0 ↔ f ^ k = 0

Next tactic:
exact (toMatrix b b).map_eq_zero_iff
theorem IsNilpotent.mapQ (hnp : IsNilpotent f) : IsNilpotent (p.mapQ p f hp) := by
  

Proof state:
R : Type u_1
S : Type u_2
x y : R
M : Type v
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
f : End R M
p : Submodule R M
hp : p ≤ Submodule.comap f p
hnp : IsNilpotent f
⊢ IsNilpotent (Submodule.mapQ p p f hp)

Next tactic:
obtain ⟨k, hk⟩ := hnp
theorem IsNilpotent.mapQ (hnp : IsNilpotent f) : IsNilpotent (p.mapQ p f hp) := by
  obtain ⟨k, hk⟩ := hnp
  

Proof state:
case intro
R : Type u_1
S : Type u_2
x y : R
M : Type v
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
f : End R M
p : Submodule R M
hp : p ≤ Submodule.comap f p
k : ℕ
hk : f ^ k = 0
⊢ IsNilpotent (Submodule.mapQ p p f hp)

Next tactic:
use k
theorem IsNilpotent.mapQ (hnp : IsNilpotent f) : IsNilpotent (p.mapQ p f hp) := by
  obtain ⟨k, hk⟩ := hnp
  use k
  

Proof state:
case h
R : Type u_1
S : Type u_2
x y : R
M : Type v
inst✝² : Ring R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
f : End R M
p : Submodule R M
hp : p ≤ Submodule.comap f p
k : ℕ
hk : f ^ k = 0
⊢ Submodule.mapQ p p f hp ^ k = 0

Next tactic:
simp [← p.mapQ_pow, hk]
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  

Proof state:
R✝ : Type u_1
S : Type u_2
x y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
⊢ IsReduced R

Next tactic:
refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  

Proof state:
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
k : ℕ
hk : x ^ k = 0
⊢ x = 0

Next tactic:
induction' k with k ih
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  induction' k with k ih
  · 

Proof state:
case zero
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
hk : x ^ Nat.zero = 0
⊢ x = 0

Next tactic:
rw [Nat.zero_eq, pow_zero] at hk
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  induction' k with k ih
  · rw [Nat.zero_eq, pow_zero] at hk
    

Proof state:
case zero
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
hk : 1 = 0
⊢ x = 0

Next tactic:
exact eq_zero_of_zero_eq_one hk.symm x
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  induction' k with k ih
  · rw [Nat.zero_eq, pow_zero] at hk
    exact eq_zero_of_zero_eq_one hk.symm x
  · 

Proof state:
case succ
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
k : ℕ
ih : x ^ k = 0 → x = 0
hk : x ^ Nat.succ k = 0
⊢ x = 0

Next tactic:
obtain ⟨m : M, hm : m ≠ 0⟩ := exists_ne (0 : M)
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  induction' k with k ih
  · rw [Nat.zero_eq, pow_zero] at hk
    exact eq_zero_of_zero_eq_one hk.symm x
  · obtain ⟨m : M, hm : m ≠ 0⟩ := exists_ne (0 : M)
    

Proof state:
case succ.intro
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
k : ℕ
ih : x ^ k = 0 → x = 0
hk : x ^ Nat.succ k = 0
m : M
hm : m ≠ 0
⊢ x = 0

Next tactic:
have : x ^ (k + 1) • m = 0 := by simp only [hk, zero_smul]
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  induction' k with k ih
  · rw [Nat.zero_eq, pow_zero] at hk
    exact eq_zero_of_zero_eq_one hk.symm x
  · obtain ⟨m : M, hm : m ≠ 0⟩ := exists_ne (0 : M)
    have : x ^ (k + 1) • m = 0 := by 

Proof state:
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
k : ℕ
ih : x ^ k = 0 → x = 0
hk : x ^ Nat.succ k = 0
m : M
hm : m ≠ 0
⊢ x ^ (k + 1) • m = 0

Next tactic:
simp only [hk, zero_smul]
lemma NoZeroSMulDivisors.isReduced (R M : Type*)
    [MonoidWithZero R] [Zero M] [MulActionWithZero R M] [Nontrivial M] [NoZeroSMulDivisors R M] :
    IsReduced R := by
  refine ⟨fun x ⟨k, hk⟩ ↦ ?_⟩
  induction' k with k ih
  · rw [Nat.zero_eq, pow_zero] at hk
    exact eq_zero_of_zero_eq_one hk.symm x
  · obtain ⟨m : M, hm : m ≠ 0⟩ := exists_ne (0 : M)
    have : x ^ (k + 1) • m = 0 := by simp only [hk, zero_smul]
    

Proof state:
case succ.intro
R✝ : Type u_1
S : Type u_2
x✝¹ y : R✝
R : Type u_3
M : Type u_4
inst✝⁴ : MonoidWithZero R
inst✝³ : Zero M
inst✝² : MulActionWithZero R M
inst✝¹ : Nontrivial M
inst✝ : NoZeroSMulDivisors R M
x : R
x✝ : IsNilpotent x
k : ℕ
ih : x ^ k = 0 → x = 0
hk : x ^ Nat.succ k = 0
m : M
hm : m ≠ 0
this : x ^ (k + 1) • m = 0
⊢ x = 0

Next tactic:
rw [pow_succ, mul_smul] at this