l3lab/ntp-mathlib huggingface dataset:
/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/
theorem isPrime_map_C_iff_isPrime (P : Ideal R) :
    IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) ↔ IsPrime P := by
  -- Porting note: the following proof avoids quotient rings
  -- It can be golfed substantially by using something like
  -- `(Quotient.isDomain_iff_prime (map C P : Ideal R[X]))`
  constructor
  · intro H
    have := @comap_isPrime R R[X] (R →+* R[X]) _ _ _ C (map C P) H
    convert this using 1
    ext x
    simp only [mem_comap, mem_map_C_iff]
    constructor
    · rintro h (- | n)
      · rwa [coeff_C_zero]
      · simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]
    · intro h
      simpa only [coeff_C_zero] using h 0
  · intro h
    constructor
    · rw [Ne.def, eq_top_iff_one, mem_map_C_iff, not_forall]
      use 0
      rw [coeff_one_zero, ← eq_top_iff_one]
      exact h.1
    · intro f g
      simp only [mem_map_C_iff]
      contrapose!
      rintro ⟨hf, hg⟩
      classical
        let m := Nat.find hf
        let n := Nat.find hg
        refine' ⟨m + n, _⟩
        rw [coeff_mul, ← Finset.insert_erase ((Finset.mem_antidiagonal (a := (m,n))).mpr rfl),
          Finset.sum_insert (Finset.not_mem_erase _ _), (P.add_mem_iff_left _).not]
        · apply mt h.2
          rw [not_or]
          exact ⟨Nat.find_spec hf, Nat.find_spec hg⟩
        apply P.sum_mem
        rintro ⟨i, j⟩ hij
        rw [Finset.mem_erase, Finset.mem_antidiagonal] at hij
        simp only [Ne.def, Prod.mk.inj_iff, not_and_or] at hij
        obtain hi | hj : i < m ∨ j < n := by
          rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq]
          rintro (hmi | rfl)
          · rw [← not_le]
            intro hnj
            exact (add_lt_add_of_lt_of_le hmi hnj).ne hij.2.symm
          · simp only [eq_self_iff_true, not_true, false_or_iff, add_right_inj,
              not_and_self_iff] at hij
        · rw [mul_comm]
          

Proof state:
case mk.inl
R : Type u
S : Type u_1
inst✝ : CommRing R
P : Ideal R
h : IsPrime P
f g : R[X]
hf : ∃ n, coeff f n ∉ P
hg : ∃ n, coeff g n ∉ P
m : ℕ := Nat.find hf
n : ℕ := Nat.find hg
i j : ℕ
hij : (¬i = Nat.find hf ∨ ¬j = Nat.find hg) ∧ i + j = Nat.find hf + Nat.find hg
hi : i < m
⊢ coeff g (i, j).2 * coeff f (i, j).1 ∈ P

Next tactic:
apply P.mul_mem_left
/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/
theorem isPrime_map_C_iff_isPrime (P : Ideal R) :
    IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) ↔ IsPrime P := by
  -- Porting note: the following proof avoids quotient rings
  -- It can be golfed substantially by using something like
  -- `(Quotient.isDomain_iff_prime (map C P : Ideal R[X]))`
  constructor
  · intro H
    have := @comap_isPrime R R[X] (R →+* R[X]) _ _ _ C (map C P) H
    convert this using 1
    ext x
    simp only [mem_comap, mem_map_C_iff]
    constructor
    · rintro h (- | n)
      · rwa [coeff_C_zero]
      · simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]
    · intro h
      simpa only [coeff_C_zero] using h 0
  · intro h
    constructor
    · rw [Ne.def, eq_top_iff_one, mem_map_C_iff, not_forall]
      use 0
      rw [coeff_one_zero, ← eq_top_iff_one]
      exact h.1
    · intro f g
      simp only [mem_map_C_iff]
      contrapose!
      rintro ⟨hf, hg⟩
      classical
        let m := Nat.find hf
        let n := Nat.find hg
        refine' ⟨m + n, _⟩
        rw [coeff_mul, ← Finset.insert_erase ((Finset.mem_antidiagonal (a := (m,n))).mpr rfl),
          Finset.sum_insert (Finset.not_mem_erase _ _), (P.add_mem_iff_left _).not]
        · apply mt h.2
          rw [not_or]
          exact ⟨Nat.find_spec hf, Nat.find_spec hg⟩
        apply P.sum_mem
        rintro ⟨i, j⟩ hij
        rw [Finset.mem_erase, Finset.mem_antidiagonal] at hij
        simp only [Ne.def, Prod.mk.inj_iff, not_and_or] at hij
        obtain hi | hj : i < m ∨ j < n := by
          rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq]
          rintro (hmi | rfl)
          · rw [← not_le]
            intro hnj
            exact (add_lt_add_of_lt_of_le hmi hnj).ne hij.2.symm
          · simp only [eq_self_iff_true, not_true, false_or_iff, add_right_inj,
              not_and_self_iff] at hij
        · rw [mul_comm]
          apply P.mul_mem_left
          

Proof state:
case mk.inl.a
R : Type u
S : Type u_1
inst✝ : CommRing R
P : Ideal R
h : IsPrime P
f g : R[X]
hf : ∃ n, coeff f n ∉ P
hg : ∃ n, coeff g n ∉ P
m : ℕ := Nat.find hf
n : ℕ := Nat.find hg
i j : ℕ
hij : (¬i = Nat.find hf ∨ ¬j = Nat.find hg) ∧ i + j = Nat.find hf + Nat.find hg
hi : i < m
⊢ coeff f (i, j).1 ∈ P

Next tactic:
exact Classical.not_not.1 (Nat.find_min hf hi)
/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/
theorem isPrime_map_C_iff_isPrime (P : Ideal R) :
    IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) ↔ IsPrime P := by
  -- Porting note: the following proof avoids quotient rings
  -- It can be golfed substantially by using something like
  -- `(Quotient.isDomain_iff_prime (map C P : Ideal R[X]))`
  constructor
  · intro H
    have := @comap_isPrime R R[X] (R →+* R[X]) _ _ _ C (map C P) H
    convert this using 1
    ext x
    simp only [mem_comap, mem_map_C_iff]
    constructor
    · rintro h (- | n)
      · rwa [coeff_C_zero]
      · simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]
    · intro h
      simpa only [coeff_C_zero] using h 0
  · intro h
    constructor
    · rw [Ne.def, eq_top_iff_one, mem_map_C_iff, not_forall]
      use 0
      rw [coeff_one_zero, ← eq_top_iff_one]
      exact h.1
    · intro f g
      simp only [mem_map_C_iff]
      contrapose!
      rintro ⟨hf, hg⟩
      classical
        let m := Nat.find hf
        let n := Nat.find hg
        refine' ⟨m + n, _⟩
        rw [coeff_mul, ← Finset.insert_erase ((Finset.mem_antidiagonal (a := (m,n))).mpr rfl),
          Finset.sum_insert (Finset.not_mem_erase _ _), (P.add_mem_iff_left _).not]
        · apply mt h.2
          rw [not_or]
          exact ⟨Nat.find_spec hf, Nat.find_spec hg⟩
        apply P.sum_mem
        rintro ⟨i, j⟩ hij
        rw [Finset.mem_erase, Finset.mem_antidiagonal] at hij
        simp only [Ne.def, Prod.mk.inj_iff, not_and_or] at hij
        obtain hi | hj : i < m ∨ j < n := by
          rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq]
          rintro (hmi | rfl)
          · rw [← not_le]
            intro hnj
            exact (add_lt_add_of_lt_of_le hmi hnj).ne hij.2.symm
          · simp only [eq_self_iff_true, not_true, false_or_iff, add_right_inj,
              not_and_self_iff] at hij
        · rw [mul_comm]
          apply P.mul_mem_left
          exact Classical.not_not.1 (Nat.find_min hf hi)
        · 

Proof state:
case mk.inr
R : Type u
S : Type u_1
inst✝ : CommRing R
P : Ideal R
h : IsPrime P
f g : R[X]
hf : ∃ n, coeff f n ∉ P
hg : ∃ n, coeff g n ∉ P
m : ℕ := Nat.find hf
n : ℕ := Nat.find hg
i j : ℕ
hij : (¬i = Nat.find hf ∨ ¬j = Nat.find hg) ∧ i + j = Nat.find hf + Nat.find hg
hj : j < n
⊢ coeff f (i, j).1 * coeff g (i, j).2 ∈ P

Next tactic:
apply P.mul_mem_left
/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/
theorem isPrime_map_C_iff_isPrime (P : Ideal R) :
    IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) ↔ IsPrime P := by
  -- Porting note: the following proof avoids quotient rings
  -- It can be golfed substantially by using something like
  -- `(Quotient.isDomain_iff_prime (map C P : Ideal R[X]))`
  constructor
  · intro H
    have := @comap_isPrime R R[X] (R →+* R[X]) _ _ _ C (map C P) H
    convert this using 1
    ext x
    simp only [mem_comap, mem_map_C_iff]
    constructor
    · rintro h (- | n)
      · rwa [coeff_C_zero]
      · simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]
    · intro h
      simpa only [coeff_C_zero] using h 0
  · intro h
    constructor
    · rw [Ne.def, eq_top_iff_one, mem_map_C_iff, not_forall]
      use 0
      rw [coeff_one_zero, ← eq_top_iff_one]
      exact h.1
    · intro f g
      simp only [mem_map_C_iff]
      contrapose!
      rintro ⟨hf, hg⟩
      classical
        let m := Nat.find hf
        let n := Nat.find hg
        refine' ⟨m + n, _⟩
        rw [coeff_mul, ← Finset.insert_erase ((Finset.mem_antidiagonal (a := (m,n))).mpr rfl),
          Finset.sum_insert (Finset.not_mem_erase _ _), (P.add_mem_iff_left _).not]
        · apply mt h.2
          rw [not_or]
          exact ⟨Nat.find_spec hf, Nat.find_spec hg⟩
        apply P.sum_mem
        rintro ⟨i, j⟩ hij
        rw [Finset.mem_erase, Finset.mem_antidiagonal] at hij
        simp only [Ne.def, Prod.mk.inj_iff, not_and_or] at hij
        obtain hi | hj : i < m ∨ j < n := by
          rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq]
          rintro (hmi | rfl)
          · rw [← not_le]
            intro hnj
            exact (add_lt_add_of_lt_of_le hmi hnj).ne hij.2.symm
          · simp only [eq_self_iff_true, not_true, false_or_iff, add_right_inj,
              not_and_self_iff] at hij
        · rw [mul_comm]
          apply P.mul_mem_left
          exact Classical.not_not.1 (Nat.find_min hf hi)
        · apply P.mul_mem_left
          

Proof state:
case mk.inr.a
R : Type u
S : Type u_1
inst✝ : CommRing R
P : Ideal R
h : IsPrime P
f g : R[X]
hf : ∃ n, coeff f n ∉ P
hg : ∃ n, coeff g n ∉ P
m : ℕ := Nat.find hf
n : ℕ := Nat.find hg
i j : ℕ
hij : (¬i = Nat.find hf ∨ ¬j = Nat.find hg) ∧ i + j = Nat.find hf + Nat.find hg
hj : j < n
⊢ coeff g (i, j).2 ∈ P

Next tactic:
exact Classical.not_not.1 (Nat.find_min hg hj)
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
⊢ Prime r → Prime (C r)

Next tactic:
intro hr
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Prime r
⊢ Prime (C r)

Next tactic:
have := hr.1
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    have := hr.1
    

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Prime r
this : r ≠ 0
⊢ Prime (C r)

Next tactic:
rw [← Ideal.span_singleton_prime] at hr ⊢
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    have := hr.1
    rw [← Ideal.span_singleton_prime] at hr ⊢
    · 

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Ideal.IsPrime (Ideal.span {r})
this : r ≠ 0
⊢ Ideal.IsPrime (Ideal.span {C r})

Next tactic:
rw [← Set.image_singleton, ← Ideal.map_span]
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    have := hr.1
    rw [← Ideal.span_singleton_prime] at hr ⊢
    · rw [← Set.image_singleton, ← Ideal.map_span]
      

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Ideal.IsPrime (Ideal.span {r})
this : r ≠ 0
⊢ Ideal.IsPrime (Ideal.map C (Ideal.span {r}))

Next tactic:
apply Ideal.isPrime_map_C_of_isPrime hr
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    have := hr.1
    rw [← Ideal.span_singleton_prime] at hr ⊢
    · rw [← Set.image_singleton, ← Ideal.map_span]
      apply Ideal.isPrime_map_C_of_isPrime hr
    · 

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Ideal.IsPrime (Ideal.span {r})
this : r ≠ 0
⊢ C r ≠ 0

Next tactic:
intro h
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    have := hr.1
    rw [← Ideal.span_singleton_prime] at hr ⊢
    · rw [← Set.image_singleton, ← Ideal.map_span]
      apply Ideal.isPrime_map_C_of_isPrime hr
    · intro h; 

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Ideal.IsPrime (Ideal.span {r})
this : r ≠ 0
h : C r = 0
⊢ False

Next tactic:
apply (this (C_eq_zero.mp h))
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, by
    intro hr
    have := hr.1
    rw [← Ideal.span_singleton_prime] at hr ⊢
    · rw [← Set.image_singleton, ← Ideal.map_span]
      apply Ideal.isPrime_map_C_of_isPrime hr
    · intro h; apply (this (C_eq_zero.mp h))
    · 

Proof state:
R : Type u
S : Type u_1
σ : Type v
M : Type w
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : AddCommGroup M
inst✝ : Module R M
r : R
hr : Prime r
this : r ≠ 0
⊢ r ≠ 0

Next tactic:
assumption
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
⊢ Prime (C r) ↔ Prime r

Next tactic:
let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
⊢ Prime (C r) ↔ Prime r

Next tactic:
let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
⊢ Prime (C r) ↔ Prime r

Next tactic:
have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; rfl
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
d : ℕ
⊢ C r = (f d) (Polynomial.C (C r))

Next tactic:
rw [← finSuccEquiv_comp_C_eq_C]
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; 

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
d : ℕ
⊢ (RingHom.comp (↑(AlgEquiv.symm (finSuccEquiv R d))) (RingHom.comp Polynomial.C C)) r = (f d) (Polynomial.C (C r))

Next tactic:
rfl
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; rfl
  

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
that : ∀ (d : ℕ), C r = (f d) (Polynomial.C (C r))
⊢ Prime (C r) ↔ Prime r

Next tactic:
rw [(renameEquiv R (Fintype.equivFin σ)).toMulEquiv.prime_iff]
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; rfl
  rw [(renameEquiv R (Fintype.equivFin σ)).toMulEquiv.prime_iff]
  

Proof state:
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
that : ∀ (d : ℕ), C r = (f d) (Polynomial.C (C r))
⊢ Prime ((AlgEquiv.toMulEquiv (renameEquiv R (Fintype.equivFin σ))) (C r)) ↔ Prime r

Next tactic:
convert_to Prime (C r) ↔ _
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; rfl
  rw [(renameEquiv R (Fintype.equivFin σ)).toMulEquiv.prime_iff]
  convert_to Prime (C r) ↔ _
  · 

Proof state:
case h.e'_1.a
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
that : ∀ (d : ℕ), C r = (f d) (Polynomial.C (C r))
⊢ Prime ((AlgEquiv.toMulEquiv (renameEquiv R (Fintype.equivFin σ))) (C r)) ↔ Prime (C r)

Next tactic:
congr!
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; rfl
  rw [(renameEquiv R (Fintype.equivFin σ)).toMulEquiv.prime_iff]
  convert_to Prime (C r) ↔ _
  · congr!
    

Proof state:
case h.e'_1.a.a.h.e'_3
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
that : ∀ (d : ℕ), C r = (f d) (Polynomial.C (C r))
⊢ (AlgEquiv.toMulEquiv (renameEquiv R (Fintype.equivFin σ))) (C r) = C r

Next tactic:
apply rename_C
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
    Prime (C r : MvPolynomial σ R) ↔ Prime r := by
  let f (d : ℕ) := (finSuccEquiv R d).symm.toMulEquiv
  let _coe' (d : ℕ) : CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R)
    (fun _ => (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R) := inferInstance
  have that (d : ℕ) : @C R (Fin (d+1)) _ r = (f d) (Polynomial.C (@C R (Fin d) _ r)) := by
    rw [← finSuccEquiv_comp_C_eq_C]; rfl
  rw [(renameEquiv R (Fintype.equivFin σ)).toMulEquiv.prime_iff]
  convert_to Prime (C r) ↔ _
  · congr!
    apply rename_C
  · 

Proof state:
case convert_3
R✝ : Type u
S : Type u_1
σ✝ : Type v
M : Type w
inst✝⁵ : CommRing R✝
inst✝⁴ : CommRing S
inst✝³ : AddCommGroup M
inst✝² : Module R✝ M
r✝ : R✝
R : Type u
σ : Type v
r : R
inst✝¹ : CommRing R
inst✝ : Fintype σ
f : (d : ℕ) → (MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R :=
  fun d => AlgEquiv.toMulEquiv (AlgEquiv.symm (finSuccEquiv R d))
_coe' : (d : ℕ) →
  CoeFun ((MvPolynomial (Fin d) R)[X] ≃* MvPolynomial (Fin (d + 1)) R) fun x =>
    (MvPolynomial (Fin d) R)[X] → MvPolynomial (Fin (d + 1)) R :=
  fun d => inferInstance
that : ∀ (d : ℕ), C r = (f d) (Polynomial.C (C r))
⊢ Prime (C r) ↔ Prime r

Next tactic:
symm