l3lab/ntp-mathlib huggingface dataset:
private lemma aux_IH {R : Type u} {S : Type v} {T : Type w}
  [CommRing R] [CommRing S] [CommRing T] [IsJacobson S] [Algebra R S] [Algebra R T]
  (IH : ∀ (Q : Ideal S), (IsMaximal Q) → RingHom.IsIntegral (algebraMap R (S ⧸ Q)))
  (v : S[X] ≃ₐ[R] T) (P : Ideal T) (hP : P.IsMaximal) :
  RingHom.IsIntegral (algebraMap R (T ⧸ P)) := by
  let Q := P.comap v.toAlgHom.toRingHom
  have hw : Ideal.map v Q = P := map_comap_of_surjective v v.surjective P
  haveI hQ : IsMaximal Q := comap_isMaximal_of_surjective _ v.surjective
  let w : (S[X] ⧸ Q) ≃ₐ[R] (T ⧸ P) := Ideal.quotientEquivAlg Q P v hw.symm
  let Q' := Q.comap (Polynomial.C)
  let w' : (S ⧸ Q') →ₐ[R] (S[X] ⧸ Q) := Ideal.quotientMapₐ Q (Cₐ R S) le_rfl
  have h_eq : algebraMap R (T ⧸ P) =
    w.toRingEquiv.toRingHom.comp (w'.toRingHom.comp (algebraMap R (S ⧸ Q'))) := by
    ext r
    simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
      RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe,
      AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes]
  rw [h_eq]
  apply RingHom.IsIntegral.trans
  apply RingHom.IsIntegral.trans
  · apply IH
    apply Polynomial.isMaximal_comap_C_of_isJacobson'
    exact hQ
  · suffices : w'.toRingHom = Ideal.quotientMap Q (Polynomial.C) le_rfl
    · rw [this]
      rw [isIntegral_quotientMap_iff _]
      

Proof state:
case hf.hg
n : ℕ
R : Type u
S : Type v
T : Type w
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
inst✝³ : CommRing T
inst✝² : IsJacobson S
inst✝¹ : Algebra R S
inst✝ : Algebra R T
IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q))
v : S[X] ≃ₐ[R] T
P : Ideal T
hP : IsMaximal P
Q : Ideal S[X] := comap (↑↑v) P
hw : map v Q = P
hQ : IsMaximal Q
w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q)
Q' : Ideal S := comap Polynomial.C Q
w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q')
h_eq :
  algebraMap R (T ⧸ P) =
    RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q')))
this : ↑w' = quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q)
⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk Q) Polynomial.C)

Next tactic:
apply Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson
private lemma aux_IH {R : Type u} {S : Type v} {T : Type w}
  [CommRing R] [CommRing S] [CommRing T] [IsJacobson S] [Algebra R S] [Algebra R T]
  (IH : ∀ (Q : Ideal S), (IsMaximal Q) → RingHom.IsIntegral (algebraMap R (S ⧸ Q)))
  (v : S[X] ≃ₐ[R] T) (P : Ideal T) (hP : P.IsMaximal) :
  RingHom.IsIntegral (algebraMap R (T ⧸ P)) := by
  let Q := P.comap v.toAlgHom.toRingHom
  have hw : Ideal.map v Q = P := map_comap_of_surjective v v.surjective P
  haveI hQ : IsMaximal Q := comap_isMaximal_of_surjective _ v.surjective
  let w : (S[X] ⧸ Q) ≃ₐ[R] (T ⧸ P) := Ideal.quotientEquivAlg Q P v hw.symm
  let Q' := Q.comap (Polynomial.C)
  let w' : (S ⧸ Q') →ₐ[R] (S[X] ⧸ Q) := Ideal.quotientMapₐ Q (Cₐ R S) le_rfl
  have h_eq : algebraMap R (T ⧸ P) =
    w.toRingEquiv.toRingHom.comp (w'.toRingHom.comp (algebraMap R (S ⧸ Q'))) := by
    ext r
    simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
      RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe,
      AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes]
  rw [h_eq]
  apply RingHom.IsIntegral.trans
  apply RingHom.IsIntegral.trans
  · apply IH
    apply Polynomial.isMaximal_comap_C_of_isJacobson'
    exact hQ
  · suffices : w'.toRingHom = Ideal.quotientMap Q (Polynomial.C) le_rfl
    · rw [this]
      rw [isIntegral_quotientMap_iff _]
      apply Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson
    · 

Proof state:
case this
n : ℕ
R : Type u
S : Type v
T : Type w
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
inst✝³ : CommRing T
inst✝² : IsJacobson S
inst✝¹ : Algebra R S
inst✝ : Algebra R T
IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q))
v : S[X] ≃ₐ[R] T
P : Ideal T
hP : IsMaximal P
Q : Ideal S[X] := comap (↑↑v) P
hw : map v Q = P
hQ : IsMaximal Q
w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q)
Q' : Ideal S := comap Polynomial.C Q
w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q')
h_eq :
  algebraMap R (T ⧸ P) =
    RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q')))
⊢ ↑w' = quotientMap Q Polynomial.C (_ : comap Polynomial.C Q ≤ comap Polynomial.C Q)

Next tactic:
rfl
private lemma aux_IH {R : Type u} {S : Type v} {T : Type w}
  [CommRing R] [CommRing S] [CommRing T] [IsJacobson S] [Algebra R S] [Algebra R T]
  (IH : ∀ (Q : Ideal S), (IsMaximal Q) → RingHom.IsIntegral (algebraMap R (S ⧸ Q)))
  (v : S[X] ≃ₐ[R] T) (P : Ideal T) (hP : P.IsMaximal) :
  RingHom.IsIntegral (algebraMap R (T ⧸ P)) := by
  let Q := P.comap v.toAlgHom.toRingHom
  have hw : Ideal.map v Q = P := map_comap_of_surjective v v.surjective P
  haveI hQ : IsMaximal Q := comap_isMaximal_of_surjective _ v.surjective
  let w : (S[X] ⧸ Q) ≃ₐ[R] (T ⧸ P) := Ideal.quotientEquivAlg Q P v hw.symm
  let Q' := Q.comap (Polynomial.C)
  let w' : (S ⧸ Q') →ₐ[R] (S[X] ⧸ Q) := Ideal.quotientMapₐ Q (Cₐ R S) le_rfl
  have h_eq : algebraMap R (T ⧸ P) =
    w.toRingEquiv.toRingHom.comp (w'.toRingHom.comp (algebraMap R (S ⧸ Q'))) := by
    ext r
    simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
      RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe,
      AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes]
  rw [h_eq]
  apply RingHom.IsIntegral.trans
  apply RingHom.IsIntegral.trans
  · apply IH
    apply Polynomial.isMaximal_comap_C_of_isJacobson'
    exact hQ
  · suffices : w'.toRingHom = Ideal.quotientMap Q (Polynomial.C) le_rfl
    · rw [this]
      rw [isIntegral_quotientMap_iff _]
      apply Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson
    · rfl
  · 

Proof state:
case hg
n : ℕ
R : Type u
S : Type v
T : Type w
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
inst✝³ : CommRing T
inst✝² : IsJacobson S
inst✝¹ : Algebra R S
inst✝ : Algebra R T
IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q))
v : S[X] ≃ₐ[R] T
P : Ideal T
hP : IsMaximal P
Q : Ideal S[X] := comap (↑↑v) P
hw : map v Q = P
hQ : IsMaximal Q
w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q)
Q' : Ideal S := comap Polynomial.C Q
w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q')
h_eq :
  algebraMap R (T ⧸ P) =
    RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q')))
⊢ RingHom.IsIntegral (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w))

Next tactic:
apply RingHom.isIntegral_of_surjective
private lemma aux_IH {R : Type u} {S : Type v} {T : Type w}
  [CommRing R] [CommRing S] [CommRing T] [IsJacobson S] [Algebra R S] [Algebra R T]
  (IH : ∀ (Q : Ideal S), (IsMaximal Q) → RingHom.IsIntegral (algebraMap R (S ⧸ Q)))
  (v : S[X] ≃ₐ[R] T) (P : Ideal T) (hP : P.IsMaximal) :
  RingHom.IsIntegral (algebraMap R (T ⧸ P)) := by
  let Q := P.comap v.toAlgHom.toRingHom
  have hw : Ideal.map v Q = P := map_comap_of_surjective v v.surjective P
  haveI hQ : IsMaximal Q := comap_isMaximal_of_surjective _ v.surjective
  let w : (S[X] ⧸ Q) ≃ₐ[R] (T ⧸ P) := Ideal.quotientEquivAlg Q P v hw.symm
  let Q' := Q.comap (Polynomial.C)
  let w' : (S ⧸ Q') →ₐ[R] (S[X] ⧸ Q) := Ideal.quotientMapₐ Q (Cₐ R S) le_rfl
  have h_eq : algebraMap R (T ⧸ P) =
    w.toRingEquiv.toRingHom.comp (w'.toRingHom.comp (algebraMap R (S ⧸ Q'))) := by
    ext r
    simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
      RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe,
      AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes]
  rw [h_eq]
  apply RingHom.IsIntegral.trans
  apply RingHom.IsIntegral.trans
  · apply IH
    apply Polynomial.isMaximal_comap_C_of_isJacobson'
    exact hQ
  · suffices : w'.toRingHom = Ideal.quotientMap Q (Polynomial.C) le_rfl
    · rw [this]
      rw [isIntegral_quotientMap_iff _]
      apply Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson
    · rfl
  · apply RingHom.isIntegral_of_surjective
    

Proof state:
case hg.hf
n : ℕ
R : Type u
S : Type v
T : Type w
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
inst✝³ : CommRing T
inst✝² : IsJacobson S
inst✝¹ : Algebra R S
inst✝ : Algebra R T
IH : ∀ (Q : Ideal S), IsMaximal Q → RingHom.IsIntegral (algebraMap R (S ⧸ Q))
v : S[X] ≃ₐ[R] T
P : Ideal T
hP : IsMaximal P
Q : Ideal S[X] := comap (↑↑v) P
hw : map v Q = P
hQ : IsMaximal Q
w : (S[X] ⧸ Q) ≃ₐ[R] T ⧸ P := quotientEquivAlg Q P v (_ : P = map v Q)
Q' : Ideal S := comap Polynomial.C Q
w' : S ⧸ Q' →ₐ[R] S[X] ⧸ Q := quotientMapₐ Q (Ideal.MvPolynomial.Cₐ R S) (_ : Q' ≤ Q')
h_eq :
  algebraMap R (T ⧸ P) =
    RingHom.comp (RingEquiv.toRingHom (AlgEquiv.toRingEquiv w)) (RingHom.comp (↑w') (algebraMap R (S ⧸ Q')))
⊢ Function.Surjective ⇑(RingEquiv.toRingHom (AlgEquiv.toRingEquiv w))

Next tactic:
exact w.surjective
private theorem quotient_mk_comp_C_isIntegral_of_jacobson' {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) (hP : P.IsMaximal) :
    RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) := by
  

Proof state:
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin n) R)
hP : IsMaximal P
⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))

Next tactic:
induction' n with n IH
private theorem quotient_mk_comp_C_isIntegral_of_jacobson' {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) (hP : P.IsMaximal) :
    RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) := by
  induction' n with n IH
  · 

Proof state:
case zero
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin Nat.zero) R)
hP : IsMaximal P
⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin Nat.zero) R ⧸ P))

Next tactic:
apply RingHom.isIntegral_of_surjective
private theorem quotient_mk_comp_C_isIntegral_of_jacobson' {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) (hP : P.IsMaximal) :
    RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) := by
  induction' n with n IH
  · apply RingHom.isIntegral_of_surjective
    

Proof state:
case zero.hf
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin Nat.zero) R)
hP : IsMaximal P
⊢ Function.Surjective ⇑(algebraMap R (MvPolynomial (Fin Nat.zero) R ⧸ P))

Next tactic:
apply Function.Surjective.comp Quotient.mk_surjective
private theorem quotient_mk_comp_C_isIntegral_of_jacobson' {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) (hP : P.IsMaximal) :
    RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) := by
  induction' n with n IH
  · apply RingHom.isIntegral_of_surjective
    apply Function.Surjective.comp Quotient.mk_surjective
    

Proof state:
case zero.hf
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin Nat.zero) R)
hP : IsMaximal P
⊢ Function.Surjective fun x => (algebraMap R (MvPolynomial (Fin Nat.zero) R)) x

Next tactic:
exact C_surjective (Fin 0)
private theorem quotient_mk_comp_C_isIntegral_of_jacobson' {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) (hP : P.IsMaximal) :
    RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) := by
  induction' n with n IH
  · apply RingHom.isIntegral_of_surjective
    apply Function.Surjective.comp Quotient.mk_surjective
    exact C_surjective (Fin 0)
  · 

Proof state:
case succ
n✝ : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
n : ℕ
IH :
  ∀ (P : Ideal (MvPolynomial (Fin n) R)), IsMaximal P → RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))
P : Ideal (MvPolynomial (Fin (Nat.succ n)) R)
hP : IsMaximal P
⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin (Nat.succ n)) R ⧸ P))

Next tactic:
apply aux_IH IH (finSuccEquiv R n).symm P hP
theorem quotient_mk_comp_C_isIntegral_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) [hP : P.IsMaximal] :
    RingHom.IsIntegral (RingHom.comp (Quotient.mk P) (MvPolynomial.C)) := by
  

Proof state:
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin n) R)
hP : IsMaximal P
⊢ RingHom.IsIntegral (RingHom.comp (Quotient.mk P) MvPolynomial.C)

Next tactic:
change RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))
theorem quotient_mk_comp_C_isIntegral_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) [hP : P.IsMaximal] :
    RingHom.IsIntegral (RingHom.comp (Quotient.mk P) (MvPolynomial.C)) := by
  change RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))
  

Proof state:
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin n) R)
hP : IsMaximal P
⊢ RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))

Next tactic:
apply quotient_mk_comp_C_isIntegral_of_jacobson'
theorem quotient_mk_comp_C_isIntegral_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    (P : Ideal (MvPolynomial (Fin n) R)) [hP : P.IsMaximal] :
    RingHom.IsIntegral (RingHom.comp (Quotient.mk P) (MvPolynomial.C)) := by
  change RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))
  apply quotient_mk_comp_C_isIntegral_of_jacobson'
  

Proof state:
case hP
n : ℕ
R : Type u_1
inst✝¹ : CommRing R
inst✝ : IsJacobson R
P : Ideal (MvPolynomial (Fin n) R)
hP : IsMaximal P
⊢ IsMaximal P

Next tactic:
infer_instance
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  

Proof state:
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C)

Next tactic:
cases nonempty_fintype σ
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  

Proof state:
case intro
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C)

Next tactic:
have e := (Fintype.equivFin σ).symm
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  

Proof state:
case intro
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C)

Next tactic:
let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  

Proof state:
case intro
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C)

Next tactic:
have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
  

Proof state:
case intro
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
hf' : Function.Surjective (⇑f ∘ ⇑(renameEquiv R e))
⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C)

Next tactic:
change Function.Surjective ↑f' at hf'
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
  change Function.Surjective ↑f' at hf'
  

Proof state:
case intro
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
hf' : Function.Surjective ⇑f'
⊢ RingHom.IsIntegral (RingHom.comp f MvPolynomial.C)

Next tactic:
have : (f'.comp C).IsIntegral := by
    haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf'
    let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S :=
      Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h
    have hfg : g.comp (Quotient.mk (RingHom.ker f')) = f' := ringHom_ext (fun r => rfl) fun i => rfl
    rw [← hfg, RingHom.comp_assoc]
    refine' (quotient_mk_comp_C_isIntegral_of_jacobson (RingHom.ker f')).trans _ g
      (g.isIntegral_of_surjective _)
    rw [← hfg] at hf'
    norm_num at hf'
    exact Function.Surjective.of_comp hf'
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
  change Function.Surjective ↑f' at hf'
  have : (f'.comp C).IsIntegral := by
    

Proof state:
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
hf' : Function.Surjective ⇑f'
⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C)

Next tactic:
haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf'
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
  change Function.Surjective ↑f' at hf'
  have : (f'.comp C).IsIntegral := by
    haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf'
    

Proof state:
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
hf' : Function.Surjective ⇑f'
this : IsMaximal (ker f')
⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C)

Next tactic:
let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S :=
      Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
  change Function.Surjective ↑f' at hf'
  have : (f'.comp C).IsIntegral := by
    haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf'
    let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S :=
      Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h
    

Proof state:
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
hf' : Function.Surjective ⇑f'
this : IsMaximal (ker f')
g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ x ∈ ker f', x ∈ ker f')
⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C)

Next tactic:
have hfg : g.comp (Quotient.mk (RingHom.ker f')) = f' := ringHom_ext (fun r => rfl) fun i => rfl
theorem comp_C_integral_of_surjective_of_jacobson {R : Type*} [CommRing R] [IsJacobson R]
    {σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
    (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
  cases nonempty_fintype σ
  have e := (Fintype.equivFin σ).symm
  let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
  have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
  change Function.Surjective ↑f' at hf'
  have : (f'.comp C).IsIntegral := by
    haveI : f'.ker.IsMaximal := ker_isMaximal_of_surjective f' hf'
    let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S :=
      Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h
    have hfg : g.comp (Quotient.mk (RingHom.ker f')) = f' := ringHom_ext (fun r => rfl) fun i => rfl
    

Proof state:
n : ℕ
R : Type u_1
inst✝³ : CommRing R
inst✝² : IsJacobson R
σ : Type u_2
inst✝¹ : _root_.Finite σ
S : Type u_3
inst✝ : Field S
f : MvPolynomial σ R →+* S
hf : Function.Surjective ⇑f
val✝ : Fintype σ
e : Fin (Fintype.card σ) ≃ σ
f' : MvPolynomial (Fin (Fintype.card σ)) R →+* S :=
  RingHom.comp f (RingEquiv.toRingHom (AlgEquiv.toRingEquiv (renameEquiv R e)))
hf' : Function.Surjective ⇑f'
this : IsMaximal (ker f')
g : MvPolynomial (Fin (Fintype.card σ)) R ⧸ ker f' →+* S := Quotient.lift (ker f') f' (_ : ∀ x ∈ ker f', x ∈ ker f')
hfg : RingHom.comp g (Quotient.mk (ker f')) = f'
⊢ RingHom.IsIntegral (RingHom.comp f' MvPolynomial.C)

Next tactic:
rw [← hfg, RingHom.comp_assoc]