l3lab/ntp-mathlib huggingface dataset:
instance : SetLike (IntermediateField K L) L :=
  ⟨fun S => S.toSubalgebra.carrier, by
    

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S : IntermediateField K L
⊢ Function.Injective fun S => S.carrier

Next tactic:
rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩
instance : SetLike (IntermediateField K L) L :=
  ⟨fun S => S.toSubalgebra.carrier, by
    rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩
    

Proof state:
case mk.mk.mk.mk
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S : IntermediateField K L
toSubsemiring✝¹ : Subsemiring L
algebraMap_mem'✝¹ : ∀ (r : K), (algebraMap K L) r ∈ toSubsemiring✝¹.carrier
inv_mem'✝¹ :
  ∀
    x ∈
      { toSubsemiring := toSubsemiring✝¹,
                algebraMap_mem' := algebraMap_mem'✝¹ }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier,
    x⁻¹ ∈
      { toSubsemiring := toSubsemiring✝¹,
                algebraMap_mem' := algebraMap_mem'✝¹ }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier
toSubsemiring✝ : Subsemiring L
algebraMap_mem'✝ : ∀ (r : K), (algebraMap K L) r ∈ toSubsemiring✝.carrier
inv_mem'✝ :
  ∀
    x ∈
      { toSubsemiring := toSubsemiring✝,
                algebraMap_mem' := algebraMap_mem'✝ }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier,
    x⁻¹ ∈
      { toSubsemiring := toSubsemiring✝,
                algebraMap_mem' := algebraMap_mem'✝ }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier
⊢ (fun S => S.carrier)
        { toSubalgebra := { toSubsemiring := toSubsemiring✝¹, algebraMap_mem' := algebraMap_mem'✝¹ },
          inv_mem' := inv_mem'✝¹ } =
      (fun S => S.carrier)
        { toSubalgebra := { toSubsemiring := toSubsemiring✝, algebraMap_mem' := algebraMap_mem'✝ },
          inv_mem' := inv_mem'✝ } →
    { toSubalgebra := { toSubsemiring := toSubsemiring✝¹, algebraMap_mem' := algebraMap_mem'✝¹ },
        inv_mem' := inv_mem'✝¹ } =
      { toSubalgebra := { toSubsemiring := toSubsemiring✝, algebraMap_mem' := algebraMap_mem'✝ },
        inv_mem' := inv_mem'✝ }

Next tactic:
simp
protected theorem neg_mem {x : L} (hx : x ∈ S) : -x ∈ S := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S : IntermediateField K L
x : L
hx : x ∈ S
⊢ -x ∈ S

Next tactic:
show -x ∈S.toSubalgebra
protected theorem neg_mem {x : L} (hx : x ∈ S) : -x ∈ S := by
  show -x ∈S.toSubalgebra; 

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S : IntermediateField K L
x : L
hx : x ∈ S
⊢ -x ∈ S.toSubalgebra

Next tactic:
simpa
theorem coe_nat_mem (n : ℕ) : (n : L) ∈ S := by 

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S : IntermediateField K L
n : ℕ
⊢ ↑n ∈ S

Next tactic:
simpa using coe_int_mem S n
@[simp]
theorem toSubalgebra_toIntermediateField (S : Subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) :
    (S.toIntermediateField inv_mem).toSubalgebra = S := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
inv_mem : ∀ x ∈ S, x⁻¹ ∈ S
⊢ (Subalgebra.toIntermediateField S inv_mem).toSubalgebra = S

Next tactic:
ext
@[simp]
theorem toSubalgebra_toIntermediateField (S : Subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) :
    (S.toIntermediateField inv_mem).toSubalgebra = S := by
  ext
  

Proof state:
case h
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
inv_mem : ∀ x ∈ S, x⁻¹ ∈ S
x✝ : L
⊢ x✝ ∈ (Subalgebra.toIntermediateField S inv_mem).toSubalgebra ↔ x✝ ∈ S

Next tactic:
rfl
@[simp]
theorem toIntermediateField_toSubalgebra (S : IntermediateField K L) :
    (S.toSubalgebra.toIntermediateField fun x => S.inv_mem) = S := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ S : IntermediateField K L
⊢ Subalgebra.toIntermediateField S.toSubalgebra (_ : ∀ x ∈ S, x⁻¹ ∈ S) = S

Next tactic:
ext
@[simp]
theorem toIntermediateField_toSubalgebra (S : IntermediateField K L) :
    (S.toSubalgebra.toIntermediateField fun x => S.inv_mem) = S := by
  ext
  

Proof state:
case h
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ S : IntermediateField K L
x✝ : L
⊢ x✝ ∈ Subalgebra.toIntermediateField S.toSubalgebra (_ : ∀ x ∈ S, x⁻¹ ∈ S) ↔ x✝ ∈ S

Next tactic:
rfl
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
⊢ x⁻¹ ∈ S

Next tactic:
by_cases hx0 : x = 0
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    by_cases hx0 : x = 0
    · 

Proof state:
case pos
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
hx0 : x = 0
⊢ x⁻¹ ∈ S

Next tactic:
rw [hx0, inv_zero]
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    by_cases hx0 : x = 0
    · rw [hx0, inv_zero]
      

Proof state:
case pos
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
hx0 : x = 0
⊢ 0 ∈ S

Next tactic:
exact S.zero_mem
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    by_cases hx0 : x = 0
    · rw [hx0, inv_zero]
      exact S.zero_mem
    

Proof state:
case neg
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
hx0 : ¬x = 0
⊢ x⁻¹ ∈ S

Next tactic:
letI hS' := hS.toField
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    by_cases hx0 : x = 0
    · rw [hx0, inv_zero]
      exact S.zero_mem
    letI hS' := hS.toField
    

Proof state:
case neg
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
hx0 : ¬x = 0
hS' : Field ↥S := IsField.toField hS
⊢ x⁻¹ ∈ S

Next tactic:
obtain ⟨y, hy⟩ := hS.mul_inv_cancel (show (⟨x, hx⟩ : S) ≠ 0 from Subtype.ne_of_val_ne hx0)
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    by_cases hx0 : x = 0
    · rw [hx0, inv_zero]
      exact S.zero_mem
    letI hS' := hS.toField
    obtain ⟨y, hy⟩ := hS.mul_inv_cancel (show (⟨x, hx⟩ : S) ≠ 0 from Subtype.ne_of_val_ne hx0)
    

Proof state:
case neg.intro
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
hx0 : ¬x = 0
hS' : Field ↥S := IsField.toField hS
y : ↥S
hy : { val := x, property := hx } * y = 1
⊢ x⁻¹ ∈ S

Next tactic:
rw [Subtype.ext_iff, S.coe_mul, S.coe_one, Subtype.coe_mk, mul_eq_one_iff_inv_eq₀ hx0] at hy
/-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/
def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L :=
  S.toIntermediateField fun x hx => by
    by_cases hx0 : x = 0
    · rw [hx0, inv_zero]
      exact S.zero_mem
    letI hS' := hS.toField
    obtain ⟨y, hy⟩ := hS.mul_inv_cancel (show (⟨x, hx⟩ : S) ≠ 0 from Subtype.ne_of_val_ne hx0)
    rw [Subtype.ext_iff, S.coe_mul, S.coe_one, Subtype.coe_mk, mul_eq_one_iff_inv_eq₀ hx0] at hy
    

Proof state:
case neg.intro
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x : L
hx : x ∈ S
hx0 : ¬x = 0
hS' : Field ↥S := IsField.toField hS
y : ↥S
hy : x⁻¹ = ↑y
⊢ x⁻¹ ∈ S

Next tactic:
exact hy.symm ▸ y.2
@[simp]
theorem toSubalgebra_toIntermediateField' (S : Subalgebra K L) (hS : IsField S) :
    (S.toIntermediateField' hS).toSubalgebra = S := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
⊢ (Subalgebra.toIntermediateField' S hS).toSubalgebra = S

Next tactic:
ext
@[simp]
theorem toSubalgebra_toIntermediateField' (S : Subalgebra K L) (hS : IsField S) :
    (S.toIntermediateField' hS).toSubalgebra = S := by
  ext
  

Proof state:
case h
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
S : Subalgebra K L
hS : IsField ↥S
x✝ : L
⊢ x✝ ∈ (Subalgebra.toIntermediateField' S hS).toSubalgebra ↔ x✝ ∈ S

Next tactic:
rfl
@[simp]
theorem toIntermediateField'_toSubalgebra (S : IntermediateField K L) :
    S.toSubalgebra.toIntermediateField' (Field.toIsField S) = S := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ S : IntermediateField K L
⊢ Subalgebra.toIntermediateField' S.toSubalgebra (_ : IsField ↥S) = S

Next tactic:
ext
@[simp]
theorem toIntermediateField'_toSubalgebra (S : IntermediateField K L) :
    S.toSubalgebra.toIntermediateField' (Field.toIsField S) = S := by
  ext
  

Proof state:
case h
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ S : IntermediateField K L
x✝ : L
⊢ x✝ ∈ Subalgebra.toIntermediateField' S.toSubalgebra (_ : IsField ↥S) ↔ x✝ ∈ S

Next tactic:
rfl
@[simp, norm_cast]
theorem coe_sum {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∑ i, f i) : L) = ∑ i, (f i : L) := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
⊢ ↑(∑ i : ι, f i) = ∑ i : ι, ↑(f i)

Next tactic:
classical
    induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
    · simp
    · rw [Finset.sum_insert hi, AddMemClass.coe_add, H, Finset.sum_insert hi]
@[simp, norm_cast]
theorem coe_sum {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∑ i, f i) : L) = ∑ i, (f i : L) := by
  classical
    

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
⊢ ↑(∑ i : ι, f i) = ∑ i : ι, ↑(f i)

Next tactic:
induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
@[simp, norm_cast]
theorem coe_sum {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∑ i, f i) : L) = ∑ i, (f i : L) := by
  classical
    induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
    · 

Proof state:
case empty
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
⊢ ↑(∑ i in ∅, f i) = ∑ i in ∅, ↑(f i)

Next tactic:
simp
@[simp, norm_cast]
theorem coe_sum {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∑ i, f i) : L) = ∑ i, (f i : L) := by
  classical
    induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
    · simp
    · 

Proof state:
case insert
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
i : ι
s : Finset ι
hi : i ∉ s
H : ↑(∑ i in s, f i) = ∑ i in s, ↑(f i)
⊢ ↑(∑ i in insert i s, f i) = ∑ i in insert i s, ↑(f i)

Next tactic:
rw [Finset.sum_insert hi, AddMemClass.coe_add, H, Finset.sum_insert hi]
@[norm_cast] --Porting note: `simp` can prove it
theorem coe_prod {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∏ i, f i) : L) = ∏ i, (f i : L) := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
⊢ ↑(∏ i : ι, f i) = ∏ i : ι, ↑(f i)

Next tactic:
classical
    induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
    · simp
    · rw [Finset.prod_insert hi, MulMemClass.coe_mul, H, Finset.prod_insert hi]
@[norm_cast] --Porting note: `simp` can prove it
theorem coe_prod {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∏ i, f i) : L) = ∏ i, (f i : L) := by
  classical
    

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
⊢ ↑(∏ i : ι, f i) = ∏ i : ι, ↑(f i)

Next tactic:
induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
@[norm_cast] --Porting note: `simp` can prove it
theorem coe_prod {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∏ i, f i) : L) = ∏ i, (f i : L) := by
  classical
    induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
    · 

Proof state:
case empty
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
⊢ ↑(∏ i in ∅, f i) = ∏ i in ∅, ↑(f i)

Next tactic:
simp
@[norm_cast] --Porting note: `simp` can prove it
theorem coe_prod {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∏ i, f i) : L) = ∏ i, (f i : L) := by
  classical
    induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H
    · simp
    · 

Proof state:
case insert
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁵ : Field K
inst✝⁴ : Field L
inst✝³ : Field L'
inst✝² : Algebra K L
inst✝¹ : Algebra K L'
S : IntermediateField K L
ι : Type u_4
inst✝ : Fintype ι
f : ι → ↥S
i : ι
s : Finset ι
hi : i ∉ s
H : ↑(∏ i in s, f i) = ∏ i in s, ↑(f i)
⊢ ↑(∏ i in insert i s, f i) = ∏ i in insert i s, ↑(f i)

Next tactic:
rw [Finset.prod_insert hi, MulMemClass.coe_mul, H, Finset.prod_insert hi]
/-- Given `f : L →ₐ[K] L'`, `S.comap f` is the intermediate field between `K` and `L`
  such that `f x ∈ S ↔ x ∈ S.comap f`. -/
def comap (f : L →ₐ[K] L') (S : IntermediateField K L') : IntermediateField K L where
  __ := S.toSubalgebra.comap f
  inv_mem' x hx := show f x⁻¹ ∈ S by 

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
f : L →ₐ[K] L'
S : IntermediateField K L'
src✝ : Subalgebra K L := Subalgebra.comap f S.toSubalgebra
x : L
hx :
  x ∈
    { toSubsemiring := src✝.toSubsemiring,
              algebraMap_mem' :=
                (_ : ∀ (r : K), (algebraMap K L) r ∈ src✝.carrier) }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier
⊢ f x⁻¹ ∈ S

Next tactic:
rw [map_inv₀ f x]
/-- Given `f : L →ₐ[K] L'`, `S.comap f` is the intermediate field between `K` and `L`
  such that `f x ∈ S ↔ x ∈ S.comap f`. -/
def comap (f : L →ₐ[K] L') (S : IntermediateField K L') : IntermediateField K L where
  __ := S.toSubalgebra.comap f
  inv_mem' x hx := show f x⁻¹ ∈ S by rw [map_inv₀ f x]; 

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
f : L →ₐ[K] L'
S : IntermediateField K L'
src✝ : Subalgebra K L := Subalgebra.comap f S.toSubalgebra
x : L
hx :
  x ∈
    { toSubsemiring := src✝.toSubsemiring,
              algebraMap_mem' :=
                (_ : ∀ (r : K), (algebraMap K L) r ∈ src✝.carrier) }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier
⊢ (f x)⁻¹ ∈ S

Next tactic:
exact S.inv_mem hx
/-- Given `f : L →ₐ[K] L'`, `S.map f` is the intermediate field between `K` and `L'`
such that `x ∈ S ↔ f x ∈ S.map f`. -/
def map (f : L →ₐ[K] L') (S : IntermediateField K L) : IntermediateField K L' where
  __ := S.toSubalgebra.map f
  inv_mem' := by
    

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
f : L →ₐ[K] L'
S : IntermediateField K L
src✝ : Subalgebra K L' := Subalgebra.map f S.toSubalgebra
⊢ ∀
    x ∈
      { toSubsemiring := src✝.toSubsemiring,
                algebraMap_mem' :=
                  (_ :
                    ∀ (r : K), (algebraMap K L') r ∈ src✝.carrier) }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier,
    x⁻¹ ∈
      { toSubsemiring := src✝.toSubsemiring,
                algebraMap_mem' :=
                  (_ : ∀ (r : K), (algebraMap K L') r ∈ src✝.carrier) }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier

Next tactic:
rintro _ ⟨x, hx, rfl⟩
/-- Given `f : L →ₐ[K] L'`, `S.map f` is the intermediate field between `K` and `L'`
such that `x ∈ S ↔ f x ∈ S.map f`. -/
def map (f : L →ₐ[K] L') (S : IntermediateField K L) : IntermediateField K L' where
  __ := S.toSubalgebra.map f
  inv_mem' := by
    rintro _ ⟨x, hx, rfl⟩
    

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : Field L'
inst✝¹ : Algebra K L
inst✝ : Algebra K L'
S✝ : IntermediateField K L
f : L →ₐ[K] L'
S : IntermediateField K L
src✝ : Subalgebra K L' := Subalgebra.map f S.toSubalgebra
x : L
hx : x ∈ ↑S.toSubsemiring
⊢ (↑f x)⁻¹ ∈
    { toSubsemiring := src✝.toSubsemiring,
              algebraMap_mem' :=
                (_ : ∀ (r : K), (algebraMap K L') r ∈ src✝.carrier) }.toSubsemiring.toSubmonoid.toSubsemigroup.carrier

Next tactic:
exact ⟨x⁻¹, S.inv_mem hx, map_inv₀ f x⟩
theorem aeval_coe {R : Type*} [CommRing R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
    (x : S) (P : R[X]) : aeval (x : L) P = aeval x P := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
P : R[X]
⊢ (aeval ↑x) P = ↑((aeval x) P)

Next tactic:
refine' Polynomial.induction_on' P (fun f g hf hg => _) fun n r => _
theorem aeval_coe {R : Type*} [CommRing R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
    (x : S) (P : R[X]) : aeval (x : L) P = aeval x P := by
  refine' Polynomial.induction_on' P (fun f g hf hg => _) fun n r => _
  · 

Proof state:
case refine'_1
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
P f g : R[X]
hf : (aeval ↑x) f = ↑((aeval x) f)
hg : (aeval ↑x) g = ↑((aeval x) g)
⊢ (aeval ↑x) (f + g) = ↑((aeval x) (f + g))

Next tactic:
rw [aeval_add, aeval_add, AddMemClass.coe_add, hf, hg]
theorem aeval_coe {R : Type*} [CommRing R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
    (x : S) (P : R[X]) : aeval (x : L) P = aeval x P := by
  refine' Polynomial.induction_on' P (fun f g hf hg => _) fun n r => _
  · rw [aeval_add, aeval_add, AddMemClass.coe_add, hf, hg]
  · 

Proof state:
case refine'_2
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
P : R[X]
n : ℕ
r : R
⊢ (aeval ↑x) ((monomial n) r) = ↑((aeval x) ((monomial n) r))

Next tactic:
simp only [MulMemClass.coe_mul, aeval_monomial, SubmonoidClass.coe_pow, mul_eq_mul_right_iff]
theorem aeval_coe {R : Type*} [CommRing R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
    (x : S) (P : R[X]) : aeval (x : L) P = aeval x P := by
  refine' Polynomial.induction_on' P (fun f g hf hg => _) fun n r => _
  · rw [aeval_add, aeval_add, AddMemClass.coe_add, hf, hg]
  · simp only [MulMemClass.coe_mul, aeval_monomial, SubmonoidClass.coe_pow, mul_eq_mul_right_iff]
    

Proof state:
case refine'_2
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
P : R[X]
n : ℕ
r : R
⊢ (algebraMap R L) r = ↑((algebraMap R ↥S) r) ∨ ↑x ^ n = 0

Next tactic:
left
theorem aeval_coe {R : Type*} [CommRing R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
    (x : S) (P : R[X]) : aeval (x : L) P = aeval x P := by
  refine' Polynomial.induction_on' P (fun f g hf hg => _) fun n r => _
  · rw [aeval_add, aeval_add, AddMemClass.coe_add, hf, hg]
  · simp only [MulMemClass.coe_mul, aeval_monomial, SubmonoidClass.coe_pow, mul_eq_mul_right_iff]
    left
    

Proof state:
case refine'_2.h
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
P : R[X]
n : ℕ
r : R
⊢ (algebraMap R L) r = ↑((algebraMap R ↥S) r)

Next tactic:
rfl
theorem coe_isIntegral_iff {R : Type*} [CommRing R] [Algebra R K] [Algebra R L]
    [IsScalarTower R K L] {x : S} : IsIntegral R (x : L) ↔ IsIntegral R x := by
  

Proof state:
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
⊢ IsIntegral R ↑x ↔ IsIntegral R x

Next tactic:
refine' ⟨fun h => _, fun h => _⟩
theorem coe_isIntegral_iff {R : Type*} [CommRing R] [Algebra R K] [Algebra R L]
    [IsScalarTower R K L] {x : S} : IsIntegral R (x : L) ↔ IsIntegral R x := by
  refine' ⟨fun h => _, fun h => _⟩
  · 

Proof state:
case refine'_1
K : Type u_1
L : Type u_2
L' : Type u_3
inst✝⁸ : Field K
inst✝⁷ : Field L
inst✝⁶ : Field L'
inst✝⁵ : Algebra K L
inst✝⁴ : Algebra K L'
S : IntermediateField K L
R : Type u_4
inst✝³ : CommRing R
inst✝² : Algebra R K
inst✝¹ : Algebra R L
inst✝ : IsScalarTower R K L
x : ↥S
h : IsIntegral R ↑x
⊢ IsIntegral R x

Next tactic:
obtain ⟨P, hPmo, hProot⟩ := h