l3lab/ntp-mathlib huggingface dataset:
theorem isIntegral_quotientMap_iff {I : Ideal S} :
    (Ideal.quotientMap I f le_rfl).IsIntegral ↔
      ((Ideal.Quotient.mk I).comp f : R →+* S ⧸ I).IsIntegral := by
  let g := Ideal.Quotient.mk (I.comap f)
  -- Porting note: added type ascription
  have : (Ideal.quotientMap I f le_rfl).comp g = (Ideal.Quotient.mk I).comp f :=
    Ideal.quotientMap_comp_mk le_rfl
  refine' ⟨fun h => _, fun h => RingHom.IsIntegral.tower_top g _ (this ▸ h)⟩
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g✝ : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
g : R →+* R ⧸ Ideal.comap f I := Ideal.Quotient.mk (Ideal.comap f I)
this :
  RingHom.comp (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) g = RingHom.comp (Ideal.Quotient.mk I) f
h : RingHom.IsIntegral (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I))
⊢ RingHom.IsIntegral (RingHom.comp (Ideal.Quotient.mk I) f)

Next tactic:
refine' this ▸ RingHom.IsIntegral.trans g (Ideal.quotientMap I f le_rfl) _ h
theorem isIntegral_quotientMap_iff {I : Ideal S} :
    (Ideal.quotientMap I f le_rfl).IsIntegral ↔
      ((Ideal.Quotient.mk I).comp f : R →+* S ⧸ I).IsIntegral := by
  let g := Ideal.Quotient.mk (I.comap f)
  -- Porting note: added type ascription
  have : (Ideal.quotientMap I f le_rfl).comp g = (Ideal.Quotient.mk I).comp f :=
    Ideal.quotientMap_comp_mk le_rfl
  refine' ⟨fun h => _, fun h => RingHom.IsIntegral.tower_top g _ (this ▸ h)⟩
  refine' this ▸ RingHom.IsIntegral.trans g (Ideal.quotientMap I f le_rfl) _ h
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g✝ : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
g : R →+* R ⧸ Ideal.comap f I := Ideal.Quotient.mk (Ideal.comap f I)
this :
  RingHom.comp (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) g = RingHom.comp (Ideal.Quotient.mk I) f
h : RingHom.IsIntegral (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I))
⊢ RingHom.IsIntegral g

Next tactic:
exact g.isIntegral_of_surjective Ideal.Quotient.mk_surjective
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
⊢ IsField R

Next tactic:
have := hS.nontrivial
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; 

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this : Nontrivial S
⊢ IsField R

Next tactic:
have := Module.nontrivial R S
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝ : Nontrivial S
this : Nontrivial R
⊢ IsField R

Next tactic:
refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
  -- Let `a_inv` be the inverse of `algebraMap R S a`,
  -- then we need to show that `a_inv` is of the form `algebraMap R S b`.
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝ : Nontrivial S
this : Nontrivial R
a : R
ha : a ≠ 0
⊢ ∃ b, a * b = 1

Next tactic:
obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel fun h ↦ ha (hRS (h.trans (RingHom.map_zero _).symm))
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
  -- Let `a_inv` be the inverse of `algebraMap R S a`,
  -- then we need to show that `a_inv` is of the form `algebraMap R S b`.
  obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel fun h ↦ ha (hRS (h.trans (RingHom.map_zero _).symm))
  

Proof state:
case intro
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝ : Nontrivial S
this : Nontrivial R
a : R
ha : a ≠ 0
a_inv : S
ha_inv : (algebraMap R S) a * a_inv = 1
⊢ ∃ b, a * b = 1

Next tactic:
letI : Invertible a_inv := (Units.mkOfMulEqOne a_inv _ <| mul_comm _ a_inv ▸ ha_inv).invertible
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
  -- Let `a_inv` be the inverse of `algebraMap R S a`,
  -- then we need to show that `a_inv` is of the form `algebraMap R S b`.
  obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel fun h ↦ ha (hRS (h.trans (RingHom.map_zero _).symm))
  letI : Invertible a_inv := (Units.mkOfMulEqOne a_inv _ <| mul_comm _ a_inv ▸ ha_inv).invertible
  -- Let `p : R[X]` be monic with root `a_inv`,
  

Proof state:
case intro
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝¹ : Nontrivial S
this✝ : Nontrivial R
a : R
ha : a ≠ 0
a_inv : S
ha_inv : (algebraMap R S) a * a_inv = 1
this : Invertible a_inv :=
  Units.invertible (Units.mkOfMulEqOne a_inv ((algebraMap R S) a) (_ : a_inv * (algebraMap R S) a = 1))
⊢ ∃ b, a * b = 1

Next tactic:
obtain ⟨p, p_monic, hp⟩ := H a_inv
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
  -- Let `a_inv` be the inverse of `algebraMap R S a`,
  -- then we need to show that `a_inv` is of the form `algebraMap R S b`.
  obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel fun h ↦ ha (hRS (h.trans (RingHom.map_zero _).symm))
  letI : Invertible a_inv := (Units.mkOfMulEqOne a_inv _ <| mul_comm _ a_inv ▸ ha_inv).invertible
  -- Let `p : R[X]` be monic with root `a_inv`,
  obtain ⟨p, p_monic, hp⟩ := H a_inv
  -- and `q` be `p` with coefficients reversed (so `q(a) = q'(a) * a + 1`).
  -- We have `q(a) = 0`, so `-q'(a)` is the inverse of `a`.
  

Proof state:
case intro.intro.intro
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝¹ : Nontrivial S
this✝ : Nontrivial R
a : R
ha : a ≠ 0
a_inv : S
ha_inv : (algebraMap R S) a * a_inv = 1
this : Invertible a_inv :=
  Units.invertible (Units.mkOfMulEqOne a_inv ((algebraMap R S) a) (_ : a_inv * (algebraMap R S) a = 1))
p : R[X]
p_monic : Monic p
hp : eval₂ (algebraMap R S) a_inv p = 0
⊢ ∃ b, a * b = 1

Next tactic:
use -p.reverse.divX.eval a
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
  -- Let `a_inv` be the inverse of `algebraMap R S a`,
  -- then we need to show that `a_inv` is of the form `algebraMap R S b`.
  obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel fun h ↦ ha (hRS (h.trans (RingHom.map_zero _).symm))
  letI : Invertible a_inv := (Units.mkOfMulEqOne a_inv _ <| mul_comm _ a_inv ▸ ha_inv).invertible
  -- Let `p : R[X]` be monic with root `a_inv`,
  obtain ⟨p, p_monic, hp⟩ := H a_inv
  -- and `q` be `p` with coefficients reversed (so `q(a) = q'(a) * a + 1`).
  -- We have `q(a) = 0`, so `-q'(a)` is the inverse of `a`.
  use -p.reverse.divX.eval a -- -q'(a)
  

Proof state:
case h
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝¹ : Nontrivial S
this✝ : Nontrivial R
a : R
ha : a ≠ 0
a_inv : S
ha_inv : (algebraMap R S) a * a_inv = 1
this : Invertible a_inv :=
  Units.invertible (Units.mkOfMulEqOne a_inv ((algebraMap R S) a) (_ : a_inv * (algebraMap R S) a = 1))
p : R[X]
p_monic : Monic p
hp : eval₂ (algebraMap R S) a_inv p = 0
⊢ a * -eval a (divX (reverse p)) = 1

Next tactic:
nth_rewrite 1 [mul_neg, ← eval_X (x := a), ← eval_mul, ← p_monic, ← coeff_zero_reverse,
    ← add_eq_zero_iff_neg_eq, ← eval_C (a := p.reverse.coeff 0), ← eval_add, X_mul_divX_add,
    ← (injective_iff_map_eq_zero' _).mp hRS, ← aeval_algebraMap_apply_eq_algebraMap_eval]
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField {R S : Type*} [CommRing R] [CommRing S]
    [Algebra R S] (H : Algebra.IsIntegral R S)
    (hRS : Function.Injective (algebraMap R S)) (hS : IsField S) : IsField R := by
  have := hS.nontrivial; have := Module.nontrivial R S
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {a} ha ↦ ?_⟩
  -- Let `a_inv` be the inverse of `algebraMap R S a`,
  -- then we need to show that `a_inv` is of the form `algebraMap R S b`.
  obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel fun h ↦ ha (hRS (h.trans (RingHom.map_zero _).symm))
  letI : Invertible a_inv := (Units.mkOfMulEqOne a_inv _ <| mul_comm _ a_inv ▸ ha_inv).invertible
  -- Let `p : R[X]` be monic with root `a_inv`,
  obtain ⟨p, p_monic, hp⟩ := H a_inv
  -- and `q` be `p` with coefficients reversed (so `q(a) = q'(a) * a + 1`).
  -- We have `q(a) = 0`, so `-q'(a)` is the inverse of `a`.
  use -p.reverse.divX.eval a -- -q'(a)
  nth_rewrite 1 [mul_neg, ← eval_X (x := a), ← eval_mul, ← p_monic, ← coeff_zero_reverse,
    ← add_eq_zero_iff_neg_eq, ← eval_C (a := p.reverse.coeff 0), ← eval_add, X_mul_divX_add,
    ← (injective_iff_map_eq_zero' _).mp hRS, ← aeval_algebraMap_apply_eq_algebraMap_eval]
  

Proof state:
case h
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹¹ : CommRing R✝
inst✝¹⁰ : CommRing A
inst✝⁹ : Ring B
inst✝⁸ : CommRing S✝
inst✝⁷ : CommRing T
inst✝⁶ : Algebra A B
inst✝⁵ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁴ : Algebra R✝ A
inst✝³ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hRS : Function.Injective ⇑(algebraMap R S)
hS : IsField S
this✝¹ : Nontrivial S
this✝ : Nontrivial R
a : R
ha : a ≠ 0
a_inv : S
ha_inv : (algebraMap R S) a * a_inv = 1
this : Invertible a_inv :=
  Units.invertible (Units.mkOfMulEqOne a_inv ((algebraMap R S) a) (_ : a_inv * (algebraMap R S) a = 1))
p : R[X]
p_monic : Monic p
hp : eval₂ (algebraMap R S) a_inv p = 0
⊢ (aeval ((algebraMap R S) a)) (reverse p) = 0

Next tactic:
rwa [← eval₂_reverse_eq_zero_iff] at hp
theorem isField_of_isIntegral_of_isField' {R S : Type*} [CommRing R] [CommRing S] [IsDomain S]
    [Algebra R S] (H : Algebra.IsIntegral R S) (hR : IsField R) : IsField S := by
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹² : CommRing R✝
inst✝¹¹ : CommRing A
inst✝¹⁰ : Ring B
inst✝⁹ : CommRing S✝
inst✝⁸ : CommRing T
inst✝⁷ : Algebra A B
inst✝⁶ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁵ : Algebra R✝ A
inst✝⁴ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : IsDomain S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hR : IsField R
⊢ IsField S

Next tactic:
refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {x} hx ↦ ?_⟩
theorem isField_of_isIntegral_of_isField' {R S : Type*} [CommRing R] [CommRing S] [IsDomain S]
    [Algebra R S] (H : Algebra.IsIntegral R S) (hR : IsField R) : IsField S := by
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {x} hx ↦ ?_⟩
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹² : CommRing R✝
inst✝¹¹ : CommRing A
inst✝¹⁰ : Ring B
inst✝⁹ : CommRing S✝
inst✝⁸ : CommRing T
inst✝⁷ : Algebra A B
inst✝⁶ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁵ : Algebra R✝ A
inst✝⁴ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : IsDomain S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hR : IsField R
x : S
hx : x ≠ 0
⊢ ∃ b, x * b = 1

Next tactic:
have : Module.Finite R (adjoin R {x}) := ⟨(Submodule.fg_top _).mpr (H x).fg_adjoin_singleton⟩
theorem isField_of_isIntegral_of_isField' {R S : Type*} [CommRing R] [CommRing S] [IsDomain S]
    [Algebra R S] (H : Algebra.IsIntegral R S) (hR : IsField R) : IsField S := by
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {x} hx ↦ ?_⟩
  have : Module.Finite R (adjoin R {x}) := ⟨(Submodule.fg_top _).mpr (H x).fg_adjoin_singleton⟩
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹² : CommRing R✝
inst✝¹¹ : CommRing A
inst✝¹⁰ : Ring B
inst✝⁹ : CommRing S✝
inst✝⁸ : CommRing T
inst✝⁷ : Algebra A B
inst✝⁶ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁵ : Algebra R✝ A
inst✝⁴ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : IsDomain S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hR : IsField R
x : S
hx : x ≠ 0
this : Module.Finite R ↥(adjoin R {x})
⊢ ∃ b, x * b = 1

Next tactic:
letI := hR.toField
theorem isField_of_isIntegral_of_isField' {R S : Type*} [CommRing R] [CommRing S] [IsDomain S]
    [Algebra R S] (H : Algebra.IsIntegral R S) (hR : IsField R) : IsField S := by
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {x} hx ↦ ?_⟩
  have : Module.Finite R (adjoin R {x}) := ⟨(Submodule.fg_top _).mpr (H x).fg_adjoin_singleton⟩
  letI := hR.toField
  

Proof state:
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹² : CommRing R✝
inst✝¹¹ : CommRing A
inst✝¹⁰ : Ring B
inst✝⁹ : CommRing S✝
inst✝⁸ : CommRing T
inst✝⁷ : Algebra A B
inst✝⁶ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁵ : Algebra R✝ A
inst✝⁴ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : IsDomain S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hR : IsField R
x : S
hx : x ≠ 0
this✝ : Module.Finite R ↥(adjoin R {x})
this : Field R := IsField.toField hR
⊢ ∃ b, x * b = 1

Next tactic:
obtain ⟨y, hy⟩ := FiniteDimensional.exists_mul_eq_one R
    (K := adjoin R {x}) (x := ⟨x, subset_adjoin rfl⟩) (mt Subtype.ext_iff.mp hx)
theorem isField_of_isIntegral_of_isField' {R S : Type*} [CommRing R] [CommRing S] [IsDomain S]
    [Algebra R S] (H : Algebra.IsIntegral R S) (hR : IsField R) : IsField S := by
  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, fun {x} hx ↦ ?_⟩
  have : Module.Finite R (adjoin R {x}) := ⟨(Submodule.fg_top _).mpr (H x).fg_adjoin_singleton⟩
  letI := hR.toField
  obtain ⟨y, hy⟩ := FiniteDimensional.exists_mul_eq_one R
    (K := adjoin R {x}) (x := ⟨x, subset_adjoin rfl⟩) (mt Subtype.ext_iff.mp hx)
  

Proof state:
case intro
R✝ : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝¹² : CommRing R✝
inst✝¹¹ : CommRing A
inst✝¹⁰ : Ring B
inst✝⁹ : CommRing S✝
inst✝⁸ : CommRing T
inst✝⁷ : Algebra A B
inst✝⁶ : Algebra R✝ B
f : R✝ →+* S✝
g : S✝ →+* T
inst✝⁵ : Algebra R✝ A
inst✝⁴ : IsScalarTower R✝ A B
R : Type u_6
S : Type u_7
inst✝³ : CommRing R
inst✝² : CommRing S
inst✝¹ : IsDomain S
inst✝ : Algebra R S
H : Algebra.IsIntegral R S
hR : IsField R
x : S
hx : x ≠ 0
this✝ : Module.Finite R ↥(adjoin R {x})
this : Field R := IsField.toField hR
y : ↥(adjoin R {x})
hy : { val := x, property := (_ : x ∈ ↑(adjoin R {x})) } * y = 1
⊢ ∃ b, x * b = 1

Next tactic:
exact ⟨y, Subtype.ext_iff.mp hy⟩
/-- `ℤ` with its usual ring structure is not a field. -/
theorem Int.not_isField : ¬IsField ℤ := fun h =>
  Int.not_even_one <|
    (h.mul_inv_cancel two_ne_zero).imp fun a => by 

Proof state:
h : IsField ℤ
a : ℤ
⊢ 2 * a = 1 → 1 = a + a

Next tactic:
rw [← two_mul]
/-- `ℤ` with its usual ring structure is not a field. -/
theorem Int.not_isField : ¬IsField ℤ := fun h =>
  Int.not_even_one <|
    (h.mul_inv_cancel two_ne_zero).imp fun a => by rw [← two_mul]; 

Proof state:
h : IsField ℤ
a : ℤ
⊢ 2 * a = 1 → 1 = 2 * a

Next tactic:
exact Eq.symm
theorem isIntegral_of_mem_ringOfIntegers {K : Type*} [Field K] {x : K} (hx : x ∈ 𝓞 K) :
    IsIntegral ℤ (⟨x, hx⟩ : 𝓞 K) := by
  

Proof state:
K✝ : Type u_1
L : Type u_2
inst✝² : Field K✝
inst✝¹ : Field L
nf : NumberField K✝
K : Type u_3
inst✝ : Field K
x : K
hx : x ∈ 𝓞 K
⊢ IsIntegral ℤ { val := x, property := hx }

Next tactic:
obtain ⟨P, hPm, hP⟩ := hx
theorem isIntegral_of_mem_ringOfIntegers {K : Type*} [Field K] {x : K} (hx : x ∈ 𝓞 K) :
    IsIntegral ℤ (⟨x, hx⟩ : 𝓞 K) := by
  obtain ⟨P, hPm, hP⟩ := hx
  

Proof state:
case intro.intro
K✝ : Type u_1
L : Type u_2
inst✝² : Field K✝
inst✝¹ : Field L
nf : NumberField K✝
K : Type u_3
inst✝ : Field K
x : K
P : Polynomial ℤ
hPm : Polynomial.Monic P
hP : Polynomial.eval₂ (algebraMap ℤ K) x P = 0
⊢ IsIntegral ℤ { val := x, property := (_ : ∃ p, Polynomial.Monic p ∧ Polynomial.eval₂ (algebraMap ℤ K) x p = 0) }

Next tactic:
refine' ⟨P, hPm, _⟩
theorem isIntegral_of_mem_ringOfIntegers {K : Type*} [Field K] {x : K} (hx : x ∈ 𝓞 K) :
    IsIntegral ℤ (⟨x, hx⟩ : 𝓞 K) := by
  obtain ⟨P, hPm, hP⟩ := hx
  refine' ⟨P, hPm, _⟩
  

Proof state:
case intro.intro
K✝ : Type u_1
L : Type u_2
inst✝² : Field K✝
inst✝¹ : Field L
nf : NumberField K✝
K : Type u_3
inst✝ : Field K
x : K
P : Polynomial ℤ
hPm : Polynomial.Monic P
hP : Polynomial.eval₂ (algebraMap ℤ K) x P = 0
⊢ Polynomial.eval₂ (algebraMap ℤ ↥(𝓞 K))
      { val := x, property := (_ : ∃ p, Polynomial.Monic p ∧ Polynomial.eval₂ (algebraMap ℤ K) x p = 0) } P =
    0

Next tactic:
rw [← Polynomial.aeval_def, ← Subalgebra.coe_eq_zero, Polynomial.aeval_subalgebra_coe,
    Polynomial.aeval_def, Subtype.coe_mk, hP]
/-- Given an algebra between two fields, create an algebra between their two rings of integers. -/
instance inst_ringOfIntegersAlgebra [Algebra K L] : Algebra (𝓞 K) (𝓞 L) :=
  RingHom.toAlgebra
    { toFun := fun k => ⟨algebraMap K L k, IsIntegral.algebraMap k.2⟩
      map_zero' := Subtype.ext <| by simp only [Subtype.coe_mk, Subalgebra.coe_zero, map_zero]
      map_one' := Subtype.ext <| by 

Proof state:
K : Type u_1
L : Type u_2
inst✝² : Field K
inst✝¹ : Field L
nf : NumberField K
inst✝ : Algebra K L
⊢ ↑((fun k => { val := (algebraMap K L) ↑k, property := (_ : IsIntegral ℤ ((algebraMap K L) ↑k)) }) 1) = ↑1

Next tactic:
simp only [Subtype.coe_mk, Subalgebra.coe_one, map_one]