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

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 r ↔ Prime (C r)

Next tactic:
induction' Fintype.card σ with d hd
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
  · symm
    induction' Fintype.card σ with d hd
    · 

Proof state:
case convert_3.zero
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 r ↔ Prime (C r)

Next tactic:
exact (isEmptyAlgEquiv R (Fin 0)).toMulEquiv.symm.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]
  convert_to Prime (C r) ↔ _
  · congr!
    apply rename_C
  · symm
    induction' Fintype.card σ with d hd
    · exact (isEmptyAlgEquiv R (Fin 0)).toMulEquiv.symm.prime_iff
    · 

Proof state:
case convert_3.succ
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))
d : ℕ
hd : Prime r ↔ Prime (C r)
⊢ Prime r ↔ Prime (C r)

Next tactic:
rw [hd, ← Polynomial.prime_C_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]
  convert_to Prime (C r) ↔ _
  · congr!
    apply rename_C
  · symm
    induction' Fintype.card σ with d hd
    · exact (isEmptyAlgEquiv R (Fin 0)).toMulEquiv.symm.prime_iff
    · rw [hd, ← Polynomial.prime_C_iff]
      

Proof state:
case convert_3.succ
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))
d : ℕ
hd : Prime r ↔ Prime (C r)
⊢ Prime (Polynomial.C (C r)) ↔ Prime (C r)

Next tactic:
rw [that d]
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
  · symm
    induction' Fintype.card σ with d hd
    · exact (isEmptyAlgEquiv R (Fin 0)).toMulEquiv.symm.prime_iff
    · rw [hd, ← Polynomial.prime_C_iff]
      rw [that d]
      -- Porting note: change ?_ to _ and watch it time out
      

Proof state:
case convert_3.succ
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))
d : ℕ
hd : Prime r ↔ Prime (C r)
⊢ Prime (Polynomial.C (C r)) ↔ Prime ((f d) (Polynomial.C (C r)))

Next tactic:
refine @MulEquiv.prime_iff (MvPolynomial (Fin d) R)[X] (MvPolynomial (Fin (d + 1)) R)
        ?_ ?_ (Polynomial.C (C r)) ?_
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| 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
hr : Prime r
h : C r = 0
⊢ r = 0

Next tactic:
rw [← C_inj, h]
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, 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
h : C r = 0
⊢ 0 = C 0

Next tactic:
simp
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| 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
hr : Prime r
h : IsUnit (C r)
⊢ IsUnit r

Next tactic:
rw [← constantCoeff_C _ r]
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        

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
h : IsUnit (C r)
⊢ IsUnit (constantCoeff (C r))
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
h : IsUnit (C r)
⊢ Type ?u.550102

Next tactic:
exact h.map _
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => 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
hr : Prime r
a b : MvPolynomial σ R
hd : C r ∣ a * b
⊢ C r ∣ a ∨ C r ∣ b

Next tactic:
obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      

Proof state:
case intro.intro.intro.intro
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : C r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
⊢ C r ∣ (rename Subtype.val) a' ∨ C r ∣ (rename Subtype.val) b'

Next tactic:
rw [← algebraMap_eq] at hd
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      

Proof state:
case intro.intro.intro.intro
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
⊢ C r ∣ (rename Subtype.val) a' ∨ C r ∣ (rename Subtype.val) b'

Next tactic:
have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      

Proof state:
case intro.intro.intro.intro
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
⊢ C r ∣ (rename Subtype.val) a' ∨ C r ∣ (rename Subtype.val) b'

Next tactic:
have : algebraMap R _ r ∣ a' * b' := by convert this <;> simp
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      have : algebraMap R _ r ∣ a' * b' := 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
hr : Prime r
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
⊢ (algebraMap R (MvPolynomial { x // x ∈ s } R)) r ∣ a' * b'

Next tactic:
convert this
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      have : algebraMap R _ r ∣ a' * b' := by convert this <;> 

Proof state:
case 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
hr : Prime r
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
⊢ (algebraMap R (MvPolynomial { x // x ∈ s } R)) r =
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r)

Next tactic:
simp
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      have : algebraMap R _ r ∣ a' * b' := by convert this <;> 

Proof state:
case h.e'_4
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
⊢ a' * b' = ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')

Next tactic:
simp
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      have : algebraMap R _ r ∣ a' * b' := by convert this <;> simp
      

Proof state:
case intro.intro.intro.intro
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this✝ :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
this : (algebraMap R (MvPolynomial { x // x ∈ s } R)) r ∣ a' * b'
⊢ C r ∣ (rename Subtype.val) a' ∨ C r ∣ (rename Subtype.val) b'

Next tactic:
rw [← rename_C ((↑) : s → σ)]
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      have : algebraMap R _ r ∣ a' * b' := by convert this <;> simp
      rw [← rename_C ((↑) : s → σ)]
      

Proof state:
case intro.intro.intro.intro
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this✝ :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
this : (algebraMap R (MvPolynomial { x // x ∈ s } R)) r ∣ a' * b'
⊢ (rename Subtype.val) (C r) ∣ (rename Subtype.val) a' ∨ (rename Subtype.val) (C r) ∣ (rename Subtype.val) b'

Next tactic:
let f := @AlgHom.toRingHom R (MvPolynomial s R)
        (MvPolynomial σ R) _ _ _ _ _ (@rename _ _ R _ ((↑) : s → σ))
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
    ⟨fun h =>
      hr.1 <| by
        rw [← C_inj, h]
        simp,
      fun h =>
      hr.2.1 <| by
        rw [← constantCoeff_C _ r]
        exact h.map _,
      fun a b hd => by
      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
      rw [← algebraMap_eq] at hd
      have := (@killCompl s σ R _ ((↑) : s → σ) Subtype.coe_injective).toRingHom.map_dvd hd
      have : algebraMap R _ r ∣ a' * b' := by convert this <;> simp
      rw [← rename_C ((↑) : s → σ)]
      let f := @AlgHom.toRingHom R (MvPolynomial s R)
        (MvPolynomial σ R) _ _ _ _ _ (@rename _ _ R _ ((↑) : s → σ))
      

Proof state:
case intro.intro.intro.intro
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
s : Finset σ
a' b' : MvPolynomial { x // x ∈ s } R
hd : (algebraMap R (MvPolynomial σ R)) r ∣ (rename Subtype.val) a' * (rename Subtype.val) b'
this✝ :
  ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((algebraMap R (MvPolynomial σ R)) r) ∣
    ↑(killCompl (_ : Function.Injective fun a => ↑a)) ((rename Subtype.val) a' * (rename Subtype.val) b')
this : (algebraMap R (MvPolynomial { x // x ∈ s } R)) r ∣ a' * b'
f : MvPolynomial { x // x ∈ s } R →+* MvPolynomial σ R := ↑(rename Subtype.val)
⊢ (rename Subtype.val) (C r) ∣ (rename Subtype.val) a' ∨ (rename Subtype.val) (C r) ∣ (rename Subtype.val) b'

Next tactic:
exact (((prime_C_iff_of_fintype s).2 hr).2.2 a' b' this).imp f.map_dvd f.map_dvd
theorem prime_rename_iff (s : Set σ) {p : MvPolynomial s R} :
    Prime (rename ((↑) : s → σ) p) ↔ Prime (p : MvPolynomial s 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
s : Set σ
p : MvPolynomial (↑s) R
⊢ Prime ((rename Subtype.val) p) ↔ Prime p

Next tactic:
classical
    symm
    let eqv :=
      (sumAlgEquiv R (↥sᶜ) s).symm.trans
        (renameEquiv R <| (Equiv.sumComm (↥sᶜ) s).trans <| Equiv.Set.sumCompl s)
    have : (rename (↑)).toRingHom = eqv.toAlgHom.toRingHom.comp C := by
      apply ringHom_ext
      · intro
        dsimp
        erw [iterToSum_C_C, rename_C, rename_C]
      · intro
        dsimp
        erw [iterToSum_C_X, rename_X, rename_X]
        rfl
    rw [← @prime_C_iff (MvPolynomial s R) (↥sᶜ) instCommRingMvPolynomial p]
    rw [@MulEquiv.prime_iff (MvPolynomial ↑sᶜ (MvPolynomial ↑s R)) (MvPolynomial σ R) (_) (_)]
    rotate_left
    exact eqv.toMulEquiv
    convert Iff.rfl
    apply RingHom.congr_fun this p
theorem prime_rename_iff (s : Set σ) {p : MvPolynomial s R} :
    Prime (rename ((↑) : s → σ) p) ↔ Prime (p : MvPolynomial s R) := by
  classical
    

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
s : Set σ
p : MvPolynomial (↑s) R
⊢ Prime ((rename Subtype.val) p) ↔ Prime p

Next tactic:
symm
theorem prime_rename_iff (s : Set σ) {p : MvPolynomial s R} :
    Prime (rename ((↑) : s → σ) p) ↔ Prime (p : MvPolynomial s R) := by
  classical
    symm
    

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
s : Set σ
p : MvPolynomial (↑s) R
⊢ Prime p ↔ Prime ((rename Subtype.val) p)

Next tactic:
let eqv :=
      (sumAlgEquiv R (↥sᶜ) s).symm.trans
        (renameEquiv R <| (Equiv.sumComm (↥sᶜ) s).trans <| Equiv.Set.sumCompl s)
theorem prime_rename_iff (s : Set σ) {p : MvPolynomial s R} :
    Prime (rename ((↑) : s → σ) p) ↔ Prime (p : MvPolynomial s R) := by
  classical
    symm
    let eqv :=
      (sumAlgEquiv R (↥sᶜ) s).symm.trans
        (renameEquiv R <| (Equiv.sumComm (↥sᶜ) s).trans <| Equiv.Set.sumCompl s)
    

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
s : Set σ
p : MvPolynomial (↑s) R
eqv : MvPolynomial (↑sᶜ) (MvPolynomial (↑s) R) ≃ₐ[R] MvPolynomial σ R :=
  AlgEquiv.trans (AlgEquiv.symm (sumAlgEquiv R ↑sᶜ ↑s))
    (renameEquiv R ((Equiv.sumComm ↑sᶜ ↑s).trans (Equiv.Set.sumCompl s)))
⊢ Prime p ↔ Prime ((rename Subtype.val) p)

Next tactic:
have : (rename (↑)).toRingHom = eqv.toAlgHom.toRingHom.comp C := by
      apply ringHom_ext
      · intro
        dsimp
        erw [iterToSum_C_C, rename_C, rename_C]
      · intro
        dsimp
        erw [iterToSum_C_X, rename_X, rename_X]
        rfl