l3lab/ntp-mathlib huggingface dataset:
lemma IsAlgebraic.invOf {x : S} [Invertible x] (h : IsAlgebraic R x) : IsAlgebraic R (⅟ x) := by
  obtain ⟨p, hp, hp'⟩ := h
  refine ⟨p.reverse, by 

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
x : S
inst✝ : Invertible x
p : R[X]
hp : p ≠ 0
hp' : (aeval x) p = 0
⊢ reverse p ≠ 0

Next tactic:
simpa using hp
lemma IsAlgebraic.invOf {x : S} [Invertible x] (h : IsAlgebraic R x) : IsAlgebraic R (⅟ x) := by
  obtain ⟨p, hp, hp'⟩ := h
  refine ⟨p.reverse, by simpa using hp, ?_⟩
  

Proof state:
case intro.intro
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
x : S
inst✝ : Invertible x
p : R[X]
hp : p ≠ 0
hp' : (aeval x) p = 0
⊢ (aeval ⅟x) (reverse p) = 0

Next tactic:
rwa [Polynomial.aeval_def, Polynomial.eval₂_reverse_eq_zero_iff, ← Polynomial.aeval_def]
lemma IsAlgebraic.inv_iff {K} [Field K] [Algebra R K] {x : K} :
    IsAlgebraic R (x⁻¹) ↔ IsAlgebraic R x := by
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : Ring A
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra R S
inst✝³ : Algebra S A
inst✝² : IsScalarTower R S A
K : Type u_2
inst✝¹ : Field K
inst✝ : Algebra R K
x : K
⊢ IsAlgebraic R x⁻¹ ↔ IsAlgebraic R x

Next tactic:
by_cases hx : x = 0
lemma IsAlgebraic.inv_iff {K} [Field K] [Algebra R K] {x : K} :
    IsAlgebraic R (x⁻¹) ↔ IsAlgebraic R x := by
  by_cases hx : x = 0
  · 

Proof state:
case pos
R : Type u
S : Type u_1
A : Type v
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : Ring A
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra R S
inst✝³ : Algebra S A
inst✝² : IsScalarTower R S A
K : Type u_2
inst✝¹ : Field K
inst✝ : Algebra R K
x : K
hx : x = 0
⊢ IsAlgebraic R x⁻¹ ↔ IsAlgebraic R x

Next tactic:
simp [hx]
lemma IsAlgebraic.inv_iff {K} [Field K] [Algebra R K] {x : K} :
    IsAlgebraic R (x⁻¹) ↔ IsAlgebraic R x := by
  by_cases hx : x = 0
  · simp [hx]
  

Proof state:
case neg
R : Type u
S : Type u_1
A : Type v
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : Ring A
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra R S
inst✝³ : Algebra S A
inst✝² : IsScalarTower R S A
K : Type u_2
inst✝¹ : Field K
inst✝ : Algebra R K
x : K
hx : ¬x = 0
⊢ IsAlgebraic R x⁻¹ ↔ IsAlgebraic R x

Next tactic:
letI := invertibleOfNonzero hx
lemma IsAlgebraic.inv_iff {K} [Field K] [Algebra R K] {x : K} :
    IsAlgebraic R (x⁻¹) ↔ IsAlgebraic R x := by
  by_cases hx : x = 0
  · simp [hx]
  letI := invertibleOfNonzero hx
  

Proof state:
case neg
R : Type u
S : Type u_1
A : Type v
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : Ring A
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra R S
inst✝³ : Algebra S A
inst✝² : IsScalarTower R S A
K : Type u_2
inst✝¹ : Field K
inst✝ : Algebra R K
x : K
hx : ¬x = 0
this : Invertible x := invertibleOfNonzero hx
⊢ IsAlgebraic R x⁻¹ ↔ IsAlgebraic R x

Next tactic:
exact IsAlgebraic.invOf_iff (R := R) (x := x)
/-- An element of an algebra over a field is algebraic if and only if it is integral.-/
theorem isAlgebraic_iff_isIntegral {x : A} : IsAlgebraic K x ↔ IsIntegral K x := by
  

Proof state:
K : Type u
A : Type v
inst✝² : Field K
inst✝¹ : Ring A
inst✝ : Algebra K A
x : A
⊢ IsAlgebraic K x ↔ IsIntegral K x

Next tactic:
refine' ⟨_, IsIntegral.isAlgebraic⟩
/-- An element of an algebra over a field is algebraic if and only if it is integral.-/
theorem isAlgebraic_iff_isIntegral {x : A} : IsAlgebraic K x ↔ IsIntegral K x := by
  refine' ⟨_, IsIntegral.isAlgebraic⟩
  

Proof state:
K : Type u
A : Type v
inst✝² : Field K
inst✝¹ : Ring A
inst✝ : Algebra K A
x : A
⊢ IsAlgebraic K x → IsIntegral K x

Next tactic:
rintro ⟨p, hp, hpx⟩
/-- An element of an algebra over a field is algebraic if and only if it is integral.-/
theorem isAlgebraic_iff_isIntegral {x : A} : IsAlgebraic K x ↔ IsIntegral K x := by
  refine' ⟨_, IsIntegral.isAlgebraic⟩
  rintro ⟨p, hp, hpx⟩
  

Proof state:
case intro.intro
K : Type u
A : Type v
inst✝² : Field K
inst✝¹ : Ring A
inst✝ : Algebra K A
x : A
p : K[X]
hp : p ≠ 0
hpx : (aeval x) p = 0
⊢ IsIntegral K x

Next tactic:
refine' ⟨_, monic_mul_leadingCoeff_inv hp, _⟩
/-- An element of an algebra over a field is algebraic if and only if it is integral.-/
theorem isAlgebraic_iff_isIntegral {x : A} : IsAlgebraic K x ↔ IsIntegral K x := by
  refine' ⟨_, IsIntegral.isAlgebraic⟩
  rintro ⟨p, hp, hpx⟩
  refine' ⟨_, monic_mul_leadingCoeff_inv hp, _⟩
  

Proof state:
case intro.intro
K : Type u
A : Type v
inst✝² : Field K
inst✝¹ : Ring A
inst✝ : Algebra K A
x : A
p : K[X]
hp : p ≠ 0
hpx : (aeval x) p = 0
⊢ eval₂ (algebraMap K A) x (p * C (leadingCoeff p)⁻¹) = 0

Next tactic:
rw [← aeval_def, AlgHom.map_mul, hpx, zero_mul]
/-- If x is algebraic over R, then x is algebraic over S when S is an extension of R,
  and the map from `R` to `S` is injective. -/
theorem IsAlgebraic.tower_top_of_injective
    (hinj : Function.Injective (algebraMap R S)) {x : A}
    (A_alg : IsAlgebraic R x) : IsAlgebraic S x :=
  let ⟨p, hp₁, hp₂⟩ := A_alg
  ⟨p.map (algebraMap _ _), by
    

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R S A
hinj : Function.Injective ⇑(algebraMap R S)
x : A
A_alg : IsAlgebraic R x
p : R[X]
hp₁ : p ≠ 0
hp₂ : (aeval x) p = 0
⊢ map (algebraMap R S) p ≠ 0

Next tactic:
rwa [Ne.def, ← degree_eq_bot, degree_map_eq_of_injective hinj, degree_eq_bot]
/-- If x is algebraic over R, then x is algebraic over S when S is an extension of R,
  and the map from `R` to `S` is injective. -/
theorem IsAlgebraic.tower_top_of_injective
    (hinj : Function.Injective (algebraMap R S)) {x : A}
    (A_alg : IsAlgebraic R x) : IsAlgebraic S x :=
  let ⟨p, hp₁, hp₂⟩ := A_alg
  ⟨p.map (algebraMap _ _), by
    rwa [Ne.def, ← degree_eq_bot, degree_map_eq_of_injective hinj, degree_eq_bot], by 

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R S A
hinj : Function.Injective ⇑(algebraMap R S)
x : A
A_alg : IsAlgebraic R x
p : R[X]
hp₁ : p ≠ 0
hp₂ : (aeval x) p = 0
⊢ (aeval x) (map (algebraMap R S) p) = 0

Next tactic:
simpa
/-- If L is an algebraic field extension of K and A is an algebraic algebra over L,
then A is algebraic over K. -/
protected theorem Algebra.IsAlgebraic.trans (L_alg : IsAlgebraic K L) (A_alg : IsAlgebraic L A) :
    IsAlgebraic K A := by
  

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝⁶ : Field K
inst✝⁵ : Field L
inst✝⁴ : Ring A
inst✝³ : Algebra K L
inst✝² : Algebra L A
inst✝¹ : Algebra K A
inst✝ : IsScalarTower K L A
L_alg : IsAlgebraic K L
A_alg : IsAlgebraic L A
⊢ IsAlgebraic K A

Next tactic:
rw [Algebra.isAlgebraic_iff_isIntegral] at L_alg A_alg ⊢
/-- If L is an algebraic field extension of K and A is an algebraic algebra over L,
then A is algebraic over K. -/
protected theorem Algebra.IsAlgebraic.trans (L_alg : IsAlgebraic K L) (A_alg : IsAlgebraic L A) :
    IsAlgebraic K A := by
  rw [Algebra.isAlgebraic_iff_isIntegral] at L_alg A_alg ⊢
  

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝⁶ : Field K
inst✝⁵ : Field L
inst✝⁴ : Ring A
inst✝³ : Algebra K L
inst✝² : Algebra L A
inst✝¹ : Algebra K A
inst✝ : IsScalarTower K L A
L_alg : Algebra.IsIntegral K L
A_alg : Algebra.IsIntegral L A
⊢ Algebra.IsIntegral K A

Next tactic:
exact L_alg.trans A_alg
theorem algHom_bijective (ha : Algebra.IsAlgebraic K L) (f : L →ₐ[K] L) :
    Function.Bijective f := by
  

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
f : L →ₐ[K] L
⊢ Function.Bijective ⇑f

Next tactic:
refine' ⟨f.injective, fun b ↦ _⟩
theorem algHom_bijective (ha : Algebra.IsAlgebraic K L) (f : L →ₐ[K] L) :
    Function.Bijective f := by
  refine' ⟨f.injective, fun b ↦ _⟩
  

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
f : L →ₐ[K] L
b : L
⊢ ∃ a, f a = b

Next tactic:
obtain ⟨p, hp, he⟩ := ha b
theorem algHom_bijective (ha : Algebra.IsAlgebraic K L) (f : L →ₐ[K] L) :
    Function.Bijective f := by
  refine' ⟨f.injective, fun b ↦ _⟩
  obtain ⟨p, hp, he⟩ := ha b
  

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
⊢ ∃ a, f a = b

Next tactic:
let f' : p.rootSet L → p.rootSet L := (rootSet_maps_to' (fun x ↦ x) f).restrict f _ _
theorem algHom_bijective (ha : Algebra.IsAlgebraic K L) (f : L →ₐ[K] L) :
    Function.Bijective f := by
  refine' ⟨f.injective, fun b ↦ _⟩
  obtain ⟨p, hp, he⟩ := ha b
  let f' : p.rootSet L → p.rootSet L := (rootSet_maps_to' (fun x ↦ x) f).restrict f _ _
  

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(rootSet p L) → ↑(rootSet p L) :=
  Set.MapsTo.restrict (⇑f) (rootSet p L) (rootSet p L) (_ : Set.MapsTo (⇑f) (rootSet p L) (rootSet p L))
⊢ ∃ a, f a = b

Next tactic:
have : f'.Surjective := Finite.injective_iff_surjective.1
    fun _ _ h ↦ Subtype.eq <| f.injective <| Subtype.ext_iff.1 h
theorem algHom_bijective (ha : Algebra.IsAlgebraic K L) (f : L →ₐ[K] L) :
    Function.Bijective f := by
  refine' ⟨f.injective, fun b ↦ _⟩
  obtain ⟨p, hp, he⟩ := ha b
  let f' : p.rootSet L → p.rootSet L := (rootSet_maps_to' (fun x ↦ x) f).restrict f _ _
  have : f'.Surjective := Finite.injective_iff_surjective.1
    fun _ _ h ↦ Subtype.eq <| f.injective <| Subtype.ext_iff.1 h
  

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(rootSet p L) → ↑(rootSet p L) :=
  Set.MapsTo.restrict (⇑f) (rootSet p L) (rootSet p L) (_ : Set.MapsTo (⇑f) (rootSet p L) (rootSet p L))
this : Function.Surjective f'
⊢ ∃ a, f a = b

Next tactic:
obtain ⟨a, ha⟩ := this ⟨b, mem_rootSet.2 ⟨hp, he⟩⟩
theorem algHom_bijective (ha : Algebra.IsAlgebraic K L) (f : L →ₐ[K] L) :
    Function.Bijective f := by
  refine' ⟨f.injective, fun b ↦ _⟩
  obtain ⟨p, hp, he⟩ := ha b
  let f' : p.rootSet L → p.rootSet L := (rootSet_maps_to' (fun x ↦ x) f).restrict f _ _
  have : f'.Surjective := Finite.injective_iff_surjective.1
    fun _ _ h ↦ Subtype.eq <| f.injective <| Subtype.ext_iff.1 h
  obtain ⟨a, ha⟩ := this ⟨b, mem_rootSet.2 ⟨hp, he⟩⟩
  

Proof state:
case intro.intro.intro
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha✝ : IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(rootSet p L) → ↑(rootSet p L) :=
  Set.MapsTo.restrict (⇑f) (rootSet p L) (rootSet p L) (_ : Set.MapsTo (⇑f) (rootSet p L) (rootSet p L))
this : Function.Surjective f'
a : ↑(rootSet p L)
ha : f' a = { val := b, property := (_ : b ∈ rootSet p L) }
⊢ ∃ a, f a = b

Next tactic:
exact ⟨a, Subtype.ext_iff.1 ha⟩
/-- Bijection between algebra equivalences and algebra homomorphisms -/
@[simps]
noncomputable def algEquivEquivAlgHom (ha : Algebra.IsAlgebraic K L) :
    (L ≃ₐ[K] L) ≃* (L →ₐ[K] L) where
  toFun ϕ := ϕ.toAlgHom
  invFun ϕ := AlgEquiv.ofBijective ϕ (ha.algHom_bijective ϕ)
  left_inv _ := by 

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
x✝ : L ≃ₐ[K] L
⊢ (fun ϕ => AlgEquiv.ofBijective ϕ (_ : Function.Bijective ⇑ϕ)) ((fun ϕ => ↑ϕ) x✝) = x✝

Next tactic:
ext
/-- Bijection between algebra equivalences and algebra homomorphisms -/
@[simps]
noncomputable def algEquivEquivAlgHom (ha : Algebra.IsAlgebraic K L) :
    (L ≃ₐ[K] L) ≃* (L →ₐ[K] L) where
  toFun ϕ := ϕ.toAlgHom
  invFun ϕ := AlgEquiv.ofBijective ϕ (ha.algHom_bijective ϕ)
  left_inv _ := by ext; 

Proof state:
case h
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
x✝ : L ≃ₐ[K] L
a✝ : L
⊢ ((fun ϕ => AlgEquiv.ofBijective ϕ (_ : Function.Bijective ⇑ϕ)) ((fun ϕ => ↑ϕ) x✝)) a✝ = x✝ a✝

Next tactic:
rfl
/-- Bijection between algebra equivalences and algebra homomorphisms -/
@[simps]
noncomputable def algEquivEquivAlgHom (ha : Algebra.IsAlgebraic K L) :
    (L ≃ₐ[K] L) ≃* (L →ₐ[K] L) where
  toFun ϕ := ϕ.toAlgHom
  invFun ϕ := AlgEquiv.ofBijective ϕ (ha.algHom_bijective ϕ)
  left_inv _ := by ext; rfl
  right_inv _ := by 

Proof state:
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
x✝ : L →ₐ[K] L
⊢ (fun ϕ => ↑ϕ) ((fun ϕ => AlgEquiv.ofBijective ϕ (_ : Function.Bijective ⇑ϕ)) x✝) = x✝

Next tactic:
ext
/-- Bijection between algebra equivalences and algebra homomorphisms -/
@[simps]
noncomputable def algEquivEquivAlgHom (ha : Algebra.IsAlgebraic K L) :
    (L ≃ₐ[K] L) ≃* (L →ₐ[K] L) where
  toFun ϕ := ϕ.toAlgHom
  invFun ϕ := AlgEquiv.ofBijective ϕ (ha.algHom_bijective ϕ)
  left_inv _ := by ext; rfl
  right_inv _ := by ext; 

Proof state:
case H
K : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
A : Type u_5
inst✝³ : CommRing K
inst✝² : Field L
inst✝¹ : Algebra K L
inst✝ : NoZeroSMulDivisors K L
ha : IsAlgebraic K L
x✝¹ : L →ₐ[K] L
x✝ : L
⊢ ((fun ϕ => ↑ϕ) ((fun ϕ => AlgEquiv.ofBijective ϕ (_ : Function.Bijective ⇑ϕ)) x✝¹)) x✝ = x✝¹ x✝

Next tactic:
rfl
theorem exists_integral_multiple [Algebra R S] {z : S} (hz : IsAlgebraic R z)
    (inj : ∀ x, algebraMap R S x = 0 → x = 0) :
    ∃ (x : integralClosure R S) (y : _) (_ : y ≠ (0 : R)), z * algebraMap R S y = x := by
  

Proof state:
R : Type u_1
S : Type u_2
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : CommRing S
inst✝ : Algebra R S
z : S
hz : IsAlgebraic R z
inj : ∀ (x : R), (algebraMap R S) x = 0 → x = 0
⊢ ∃ x y, ∃ (_ : y ≠ 0), z * (algebraMap R S) y = ↑x

Next tactic:
rcases hz with ⟨p, p_ne_zero, px⟩
theorem exists_integral_multiple [Algebra R S] {z : S} (hz : IsAlgebraic R z)
    (inj : ∀ x, algebraMap R S x = 0 → x = 0) :
    ∃ (x : integralClosure R S) (y : _) (_ : y ≠ (0 : R)), z * algebraMap R S y = x := by
  rcases hz with ⟨p, p_ne_zero, px⟩
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : CommRing S
inst✝ : Algebra R S
z : S
inj : ∀ (x : R), (algebraMap R S) x = 0 → x = 0
p : R[X]
p_ne_zero : p ≠ 0
px : (aeval z) p = 0
⊢ ∃ x y, ∃ (_ : y ≠ 0), z * (algebraMap R S) y = ↑x

Next tactic:
set a := p.leadingCoeff
theorem exists_integral_multiple [Algebra R S] {z : S} (hz : IsAlgebraic R z)
    (inj : ∀ x, algebraMap R S x = 0 → x = 0) :
    ∃ (x : integralClosure R S) (y : _) (_ : y ≠ (0 : R)), z * algebraMap R S y = x := by
  rcases hz with ⟨p, p_ne_zero, px⟩
  set a := p.leadingCoeff
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : CommRing S
inst✝ : Algebra R S
z : S
inj : ∀ (x : R), (algebraMap R S) x = 0 → x = 0
p : R[X]
p_ne_zero : p ≠ 0
px : (aeval z) p = 0
a : R := leadingCoeff p
⊢ ∃ x y, ∃ (_ : y ≠ 0), z * (algebraMap R S) y = ↑x

Next tactic:
have a_ne_zero : a ≠ 0 := mt Polynomial.leadingCoeff_eq_zero.mp p_ne_zero
theorem exists_integral_multiple [Algebra R S] {z : S} (hz : IsAlgebraic R z)
    (inj : ∀ x, algebraMap R S x = 0 → x = 0) :
    ∃ (x : integralClosure R S) (y : _) (_ : y ≠ (0 : R)), z * algebraMap R S y = x := by
  rcases hz with ⟨p, p_ne_zero, px⟩
  set a := p.leadingCoeff
  have a_ne_zero : a ≠ 0 := mt Polynomial.leadingCoeff_eq_zero.mp p_ne_zero
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : CommRing S
inst✝ : Algebra R S
z : S
inj : ∀ (x : R), (algebraMap R S) x = 0 → x = 0
p : R[X]
p_ne_zero : p ≠ 0
px : (aeval z) p = 0
a : R := leadingCoeff p
a_ne_zero : a ≠ 0
⊢ ∃ x y, ∃ (_ : y ≠ 0), z * (algebraMap R S) y = ↑x

Next tactic:
have x_integral : IsIntegral R (z * algebraMap R S a) :=
    ⟨p.integralNormalization, monic_integralNormalization p_ne_zero,
      integralNormalization_aeval_eq_zero px inj⟩
theorem exists_integral_multiple [Algebra R S] {z : S} (hz : IsAlgebraic R z)
    (inj : ∀ x, algebraMap R S x = 0 → x = 0) :
    ∃ (x : integralClosure R S) (y : _) (_ : y ≠ (0 : R)), z * algebraMap R S y = x := by
  rcases hz with ⟨p, p_ne_zero, px⟩
  set a := p.leadingCoeff
  have a_ne_zero : a ≠ 0 := mt Polynomial.leadingCoeff_eq_zero.mp p_ne_zero
  have x_integral : IsIntegral R (z * algebraMap R S a) :=
    ⟨p.integralNormalization, monic_integralNormalization p_ne_zero,
      integralNormalization_aeval_eq_zero px inj⟩
  

Proof state:
case intro.intro
R : Type u_1
S : Type u_2
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : CommRing S
inst✝ : Algebra R S
z : S
inj : ∀ (x : R), (algebraMap R S) x = 0 → x = 0
p : R[X]
p_ne_zero : p ≠ 0
px : (aeval z) p = 0
a : R := leadingCoeff p
a_ne_zero : a ≠ 0
x_integral : IsIntegral R (z * (algebraMap R S) a)
⊢ ∃ x y, ∃ (_ : y ≠ 0), z * (algebraMap R S) y = ↑x

Next tactic:
exact ⟨⟨_, x_integral⟩, a, a_ne_zero, rfl⟩
/-- A fraction `(a : S) / (b : S)` can be reduced to `(c : S) / (d : R)`,
if `S` is the integral closure of `R` in an algebraic extension `L` of `R`. -/
theorem IsIntegralClosure.exists_smul_eq_mul {L : Type*} [Field L] [Algebra R S] [Algebra S L]
    [Algebra R L] [IsScalarTower R S L] [IsIntegralClosure S R L] (h : Algebra.IsAlgebraic R L)
    (inj : Function.Injective (algebraMap R L)) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ (c : S) (d : _) (_ : d ≠ (0 : R)), d • a = b * c := by
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : IsDomain R
inst✝⁶ : CommRing S
L : Type u_3
inst✝⁵ : Field L
inst✝⁴ : Algebra R S
inst✝³ : Algebra S L
inst✝² : Algebra R L
inst✝¹ : IsScalarTower R S L
inst✝ : IsIntegralClosure S R L
h : Algebra.IsAlgebraic R L
inj : Function.Injective ⇑(algebraMap R L)
a b : S
hb : b ≠ 0
⊢ ∃ c d, ∃ (_ : d ≠ 0), d • a = b * c

Next tactic:
obtain ⟨c, d, d_ne, hx⟩ :=
    exists_integral_multiple (h (algebraMap _ L a / algebraMap _ L b))
      ((injective_iff_map_eq_zero _).mp inj)
/-- A fraction `(a : S) / (b : S)` can be reduced to `(c : S) / (d : R)`,
if `S` is the integral closure of `R` in an algebraic extension `L` of `R`. -/
theorem IsIntegralClosure.exists_smul_eq_mul {L : Type*} [Field L] [Algebra R S] [Algebra S L]
    [Algebra R L] [IsScalarTower R S L] [IsIntegralClosure S R L] (h : Algebra.IsAlgebraic R L)
    (inj : Function.Injective (algebraMap R L)) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ (c : S) (d : _) (_ : d ≠ (0 : R)), d • a = b * c := by
  obtain ⟨c, d, d_ne, hx⟩ :=
    exists_integral_multiple (h (algebraMap _ L a / algebraMap _ L b))
      ((injective_iff_map_eq_zero _).mp inj)
  

Proof state:
case intro.intro.intro
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : IsDomain R
inst✝⁶ : CommRing S
L : Type u_3
inst✝⁵ : Field L
inst✝⁴ : Algebra R S
inst✝³ : Algebra S L
inst✝² : Algebra R L
inst✝¹ : IsScalarTower R S L
inst✝ : IsIntegralClosure S R L
h : Algebra.IsAlgebraic R L
inj : Function.Injective ⇑(algebraMap R L)
a b : S
hb : b ≠ 0
c : ↥(integralClosure R L)
d : R
d_ne : d ≠ 0
hx : (algebraMap S L) a / (algebraMap S L) b * (algebraMap R L) d = ↑c
⊢ ∃ c d, ∃ (_ : d ≠ 0), d • a = b * c

Next tactic:
refine'
    ⟨IsIntegralClosure.mk' S (c : L) c.2, d, d_ne, IsIntegralClosure.algebraMap_injective S R L _⟩
/-- A fraction `(a : S) / (b : S)` can be reduced to `(c : S) / (d : R)`,
if `S` is the integral closure of `R` in an algebraic extension `L` of `R`. -/
theorem IsIntegralClosure.exists_smul_eq_mul {L : Type*} [Field L] [Algebra R S] [Algebra S L]
    [Algebra R L] [IsScalarTower R S L] [IsIntegralClosure S R L] (h : Algebra.IsAlgebraic R L)
    (inj : Function.Injective (algebraMap R L)) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ (c : S) (d : _) (_ : d ≠ (0 : R)), d • a = b * c := by
  obtain ⟨c, d, d_ne, hx⟩ :=
    exists_integral_multiple (h (algebraMap _ L a / algebraMap _ L b))
      ((injective_iff_map_eq_zero _).mp inj)
  refine'
    ⟨IsIntegralClosure.mk' S (c : L) c.2, d, d_ne, IsIntegralClosure.algebraMap_injective S R L _⟩
  

Proof state:
case intro.intro.intro
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : IsDomain R
inst✝⁶ : CommRing S
L : Type u_3
inst✝⁵ : Field L
inst✝⁴ : Algebra R S
inst✝³ : Algebra S L
inst✝² : Algebra R L
inst✝¹ : IsScalarTower R S L
inst✝ : IsIntegralClosure S R L
h : Algebra.IsAlgebraic R L
inj : Function.Injective ⇑(algebraMap R L)
a b : S
hb : b ≠ 0
c : ↥(integralClosure R L)
d : R
d_ne : d ≠ 0
hx : (algebraMap S L) a / (algebraMap S L) b * (algebraMap R L) d = ↑c
⊢ (algebraMap S L) (d • a) = (algebraMap S L) (b * mk' S ↑c (_ : ↑c ∈ integralClosure R L))

Next tactic:
simp only [Algebra.smul_def, RingHom.map_mul, IsIntegralClosure.algebraMap_mk', ← hx, ←
    IsScalarTower.algebraMap_apply]
/-- A fraction `(a : S) / (b : S)` can be reduced to `(c : S) / (d : R)`,
if `S` is the integral closure of `R` in an algebraic extension `L` of `R`. -/
theorem IsIntegralClosure.exists_smul_eq_mul {L : Type*} [Field L] [Algebra R S] [Algebra S L]
    [Algebra R L] [IsScalarTower R S L] [IsIntegralClosure S R L] (h : Algebra.IsAlgebraic R L)
    (inj : Function.Injective (algebraMap R L)) (a : S) {b : S} (hb : b ≠ 0) :
    ∃ (c : S) (d : _) (_ : d ≠ (0 : R)), d • a = b * c := by
  obtain ⟨c, d, d_ne, hx⟩ :=
    exists_integral_multiple (h (algebraMap _ L a / algebraMap _ L b))
      ((injective_iff_map_eq_zero _).mp inj)
  refine'
    ⟨IsIntegralClosure.mk' S (c : L) c.2, d, d_ne, IsIntegralClosure.algebraMap_injective S R L _⟩
  simp only [Algebra.smul_def, RingHom.map_mul, IsIntegralClosure.algebraMap_mk', ← hx, ←
    IsScalarTower.algebraMap_apply]
  

Proof state:
case intro.intro.intro
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : IsDomain R
inst✝⁶ : CommRing S
L : Type u_3
inst✝⁵ : Field L
inst✝⁴ : Algebra R S
inst✝³ : Algebra S L
inst✝² : Algebra R L
inst✝¹ : IsScalarTower R S L
inst✝ : IsIntegralClosure S R L
h : Algebra.IsAlgebraic R L
inj : Function.Injective ⇑(algebraMap R L)
a b : S
hb : b ≠ 0
c : ↥(integralClosure R L)
d : R
d_ne : d ≠ 0
hx : (algebraMap S L) a / (algebraMap S L) b * (algebraMap R L) d = ↑c
⊢ (algebraMap R L) d * (algebraMap S L) a =
    (algebraMap S L) b * ((algebraMap S L) a / (algebraMap S L) b * (algebraMap R L) d)

Next tactic:
rw [← mul_assoc _ (_ / _), mul_div_cancel' (algebraMap S L a), mul_comm]