l3lab/ntp-mathlib huggingface dataset:
theorem adjoin_algebraic_toSubalgebra {S : Set E} (hS : ∀ x ∈ S, IsAlgebraic F x) :
    (IntermediateField.adjoin F S).toSubalgebra = Algebra.adjoin F S := by
  simp only [isAlgebraic_iff_isIntegral] at hS
  have : Algebra.IsIntegral F (Algebra.adjoin F S) := by
    

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S✝ : Set E
α : E
S : Set E
hS : ∀ x ∈ S, IsIntegral F x
⊢ Algebra.IsIntegral F ↥(Algebra.adjoin F S)

Next tactic:
rwa [← le_integralClosure_iff_isIntegral, Algebra.adjoin_le_iff]
theorem adjoin_algebraic_toSubalgebra {S : Set E} (hS : ∀ x ∈ S, IsAlgebraic F x) :
    (IntermediateField.adjoin F S).toSubalgebra = Algebra.adjoin F S := by
  simp only [isAlgebraic_iff_isIntegral] at hS
  have : Algebra.IsIntegral F (Algebra.adjoin F S) := by
    rwa [← le_integralClosure_iff_isIntegral, Algebra.adjoin_le_iff]
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S✝ : Set E
α : E
S : Set E
hS : ∀ x ∈ S, IsIntegral F x
this : Algebra.IsIntegral F ↥(Algebra.adjoin F S)
⊢ (adjoin F S).toSubalgebra = Algebra.adjoin F S

Next tactic:
have := isField_of_isIntegral_of_isField' this (Field.toIsField F)
theorem adjoin_algebraic_toSubalgebra {S : Set E} (hS : ∀ x ∈ S, IsAlgebraic F x) :
    (IntermediateField.adjoin F S).toSubalgebra = Algebra.adjoin F S := by
  simp only [isAlgebraic_iff_isIntegral] at hS
  have : Algebra.IsIntegral F (Algebra.adjoin F S) := by
    rwa [← le_integralClosure_iff_isIntegral, Algebra.adjoin_le_iff]
  have := isField_of_isIntegral_of_isField' this (Field.toIsField F)
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S✝ : Set E
α : E
S : Set E
hS : ∀ x ∈ S, IsIntegral F x
this✝ : Algebra.IsIntegral F ↥(Algebra.adjoin F S)
this : IsField ↥(Algebra.adjoin F S)
⊢ (adjoin F S).toSubalgebra = Algebra.adjoin F S

Next tactic:
rw [← ((Algebra.adjoin F S).toIntermediateField' this).eq_adjoin_of_eq_algebra_adjoin F S]
theorem adjoin_algebraic_toSubalgebra {S : Set E} (hS : ∀ x ∈ S, IsAlgebraic F x) :
    (IntermediateField.adjoin F S).toSubalgebra = Algebra.adjoin F S := by
  simp only [isAlgebraic_iff_isIntegral] at hS
  have : Algebra.IsIntegral F (Algebra.adjoin F S) := by
    rwa [← le_integralClosure_iff_isIntegral, Algebra.adjoin_le_iff]
  have := isField_of_isIntegral_of_isField' this (Field.toIsField F)
  rw [← ((Algebra.adjoin F S).toIntermediateField' this).eq_adjoin_of_eq_algebra_adjoin F S] <;> 

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S✝ : Set E
α : E
S : Set E
hS : ∀ x ∈ S, IsIntegral F x
this✝ : Algebra.IsIntegral F ↥(Algebra.adjoin F S)
this : IsField ↥(Algebra.adjoin F S)
⊢ (Subalgebra.toIntermediateField' (Algebra.adjoin F S) this).toSubalgebra = Algebra.adjoin F S

Next tactic:
rfl
theorem adjoin_simple_toSubalgebra_of_integral (hα : IsIntegral F α) :
    F⟮α⟯.toSubalgebra = Algebra.adjoin F {α} := by
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
hα : IsIntegral F α
⊢ F⟮α⟯.toSubalgebra = Algebra.adjoin F {α}

Next tactic:
apply adjoin_algebraic_toSubalgebra
theorem adjoin_simple_toSubalgebra_of_integral (hα : IsIntegral F α) :
    F⟮α⟯.toSubalgebra = Algebra.adjoin F {α} := by
  apply adjoin_algebraic_toSubalgebra
  

Proof state:
case hS
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
hα : IsIntegral F α
⊢ ∀ x ∈ {α}, IsAlgebraic F x

Next tactic:
rintro x (rfl : x = α)
theorem adjoin_simple_toSubalgebra_of_integral (hα : IsIntegral F α) :
    F⟮α⟯.toSubalgebra = Algebra.adjoin F {α} := by
  apply adjoin_algebraic_toSubalgebra
  rintro x (rfl : x = α)
  

Proof state:
case hS
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
x : E
hα : IsIntegral F x
⊢ IsAlgebraic F x

Next tactic:
rwa [isAlgebraic_iff_isIntegral]
/-- Characterize `IsSplittingField` with `IntermediateField.adjoin` instead of `Algebra.adjoin`. -/
theorem _root_.isSplittingField_iff_intermediateField {p : F[X]} :
    p.IsSplittingField F E ↔ p.Splits (algebraMap F E) ∧ adjoin F (p.rootSet E) = ⊤ := by
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
⊢ IsSplittingField F E p ↔ Splits (algebraMap F E) p ∧ adjoin F (rootSet p E) = ⊤

Next tactic:
rw [← toSubalgebra_injective.eq_iff,
      adjoin_algebraic_toSubalgebra fun _ ↦ isAlgebraic_of_mem_rootSet]
/-- Characterize `IsSplittingField` with `IntermediateField.adjoin` instead of `Algebra.adjoin`. -/
theorem _root_.isSplittingField_iff_intermediateField {p : F[X]} :
    p.IsSplittingField F E ↔ p.Splits (algebraMap F E) ∧ adjoin F (p.rootSet E) = ⊤ := by
  rw [← toSubalgebra_injective.eq_iff,
      adjoin_algebraic_toSubalgebra fun _ ↦ isAlgebraic_of_mem_rootSet]
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
⊢ IsSplittingField F E p ↔ Splits (algebraMap F E) p ∧ Algebra.adjoin F (rootSet p E) = ⊤.toSubalgebra

Next tactic:
exact ⟨fun ⟨spl, adj⟩ ↦ ⟨spl, adj⟩, fun ⟨spl, adj⟩ ↦ ⟨spl, adj⟩⟩
theorem isSplittingField_iff {p : F[X]} {K : IntermediateField F E} :
    p.IsSplittingField F K ↔ p.Splits (algebraMap F K) ∧ K = adjoin F (p.rootSet E) := by
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
K : IntermediateField F E
⊢ IsSplittingField F (↥K) p ↔ Splits (algebraMap F ↥K) p ∧ K = adjoin F (rootSet p E)

Next tactic:
suffices _ → (Algebra.adjoin F (p.rootSet K) = ⊤ ↔ K = adjoin F (p.rootSet E)) by
    exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩
theorem isSplittingField_iff {p : F[X]} {K : IntermediateField F E} :
    p.IsSplittingField F K ↔ p.Splits (algebraMap F K) ∧ K = adjoin F (p.rootSet E) := by
  suffices _ → (Algebra.adjoin F (p.rootSet K) = ⊤ ↔ K = adjoin F (p.rootSet E)) by
    

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
K : IntermediateField F E
this : ?m.898846 → (Algebra.adjoin F (rootSet p ↥K) = ⊤ ↔ K = adjoin F (rootSet p E))
⊢ IsSplittingField F (↥K) p ↔ Splits (algebraMap F ↥K) p ∧ K = adjoin F (rootSet p E)

Next tactic:
exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩
theorem isSplittingField_iff {p : F[X]} {K : IntermediateField F E} :
    p.IsSplittingField F K ↔ p.Splits (algebraMap F K) ∧ K = adjoin F (p.rootSet E) := by
  suffices _ → (Algebra.adjoin F (p.rootSet K) = ⊤ ↔ K = adjoin F (p.rootSet E)) by
    exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
K : IntermediateField F E
⊢ Splits (algebraMap F ↥K) p → (Algebra.adjoin F (rootSet p ↥K) = ⊤ ↔ K = adjoin F (rootSet p E))

Next tactic:
rw [← toSubalgebra_injective.eq_iff,
      adjoin_algebraic_toSubalgebra fun x ↦ isAlgebraic_of_mem_rootSet]
theorem isSplittingField_iff {p : F[X]} {K : IntermediateField F E} :
    p.IsSplittingField F K ↔ p.Splits (algebraMap F K) ∧ K = adjoin F (p.rootSet E) := by
  suffices _ → (Algebra.adjoin F (p.rootSet K) = ⊤ ↔ K = adjoin F (p.rootSet E)) by
    exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩
  rw [← toSubalgebra_injective.eq_iff,
      adjoin_algebraic_toSubalgebra fun x ↦ isAlgebraic_of_mem_rootSet]
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
K : IntermediateField F E
⊢ Splits (algebraMap F ↥K) p → (Algebra.adjoin F (rootSet p ↥K) = ⊤ ↔ K.toSubalgebra = Algebra.adjoin F (rootSet p E))

Next tactic:
refine fun hp ↦ (adjoin_rootSet_eq_range hp K.val).symm.trans ?_
theorem isSplittingField_iff {p : F[X]} {K : IntermediateField F E} :
    p.IsSplittingField F K ↔ p.Splits (algebraMap F K) ∧ K = adjoin F (p.rootSet E) := by
  suffices _ → (Algebra.adjoin F (p.rootSet K) = ⊤ ↔ K = adjoin F (p.rootSet E)) by
    exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩
  rw [← toSubalgebra_injective.eq_iff,
      adjoin_algebraic_toSubalgebra fun x ↦ isAlgebraic_of_mem_rootSet]
  refine fun hp ↦ (adjoin_rootSet_eq_range hp K.val).symm.trans ?_
  

Proof state:
F : Type u_1
inst✝² : Field F
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
S : Set E
α : E
p : F[X]
K : IntermediateField F E
hp : Splits (algebraMap F ↥K) p
⊢ Algebra.adjoin F (rootSet p E) = AlgHom.range (val K) ↔ K.toSubalgebra = Algebra.adjoin F (rootSet p E)

Next tactic:
rw [← K.range_val, eq_comm]
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
⊢ (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra

Next tactic:
let S1 := E1.toSubalgebra
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
⊢ (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra

Next tactic:
let S2 := E2.toSubalgebra
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
⊢ (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra

Next tactic:
refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
⊢ ∀ x ∈ S1 ⊔ S2, x⁻¹ ∈ S1 ⊔ S2

Next tactic:
suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
    · rw [← Subtype.coe_mk x, hx', Subalgebra.coe_zero, inv_zero]
      exact (S1 ⊔ S2).zero_mem
    · obtain ⟨y, h⟩ := this.mul_inv_cancel hx'
      exact (congr_arg (· ∈ S1 ⊔ S2) <| eq_inv_of_mul_eq_one_right <| Subtype.ext_iff.mp h).mp y.2
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
this : IsField ↥(S1 ⊔ S2)
⊢ ∀ x ∈ S1 ⊔ S2, x⁻¹ ∈ S1 ⊔ S2

Next tactic:
intro x hx
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
this : IsField ↥(S1 ⊔ S2)
x : L
hx : x ∈ S1 ⊔ S2
⊢ x⁻¹ ∈ S1 ⊔ S2

Next tactic:
by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
    · 

Proof state:
case pos
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
this : IsField ↥(S1 ⊔ S2)
x : L
hx : x ∈ S1 ⊔ S2
hx' : { val := x, property := hx } = 0
⊢ x⁻¹ ∈ S1 ⊔ S2

Next tactic:
rw [← Subtype.coe_mk x, hx', Subalgebra.coe_zero, inv_zero]
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
    · rw [← Subtype.coe_mk x, hx', Subalgebra.coe_zero, inv_zero]
      

Proof state:
case pos
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
this : IsField ↥(S1 ⊔ S2)
x : L
hx : x ∈ S1 ⊔ S2
hx' : { val := x, property := hx } = 0
⊢ 0 ∈ S1 ⊔ S2

Next tactic:
exact (S1 ⊔ S2).zero_mem
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
    · rw [← Subtype.coe_mk x, hx', Subalgebra.coe_zero, inv_zero]
      exact (S1 ⊔ S2).zero_mem
    · 

Proof state:
case neg
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
this : IsField ↥(S1 ⊔ S2)
x : L
hx : x ∈ S1 ⊔ S2
hx' : ¬{ val := x, property := hx } = 0
⊢ x⁻¹ ∈ S1 ⊔ S2

Next tactic:
obtain ⟨y, h⟩ := this.mul_inv_cancel hx'
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
    · rw [← Subtype.coe_mk x, hx', Subalgebra.coe_zero, inv_zero]
      exact (S1 ⊔ S2).zero_mem
    · obtain ⟨y, h⟩ := this.mul_inv_cancel hx'
      

Proof state:
case neg.intro
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
this : IsField ↥(S1 ⊔ S2)
x : L
hx : x ∈ S1 ⊔ S2
hx' : ¬{ val := x, property := hx } = 0
y : ↥(S1 ⊔ S2)
h : { val := x, property := hx } * y = 1
⊢ x⁻¹ ∈ S1 ⊔ S2

Next tactic:
exact (congr_arg (· ∈ S1 ⊔ S2) <| eq_inv_of_mul_eq_one_right <| Subtype.ext_iff.mp h).mp y.2
theorem sup_toSubalgebra [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    (E1 ⊔ E2).toSubalgebra = E1.toSubalgebra ⊔ E2.toSubalgebra := by
  let S1 := E1.toSubalgebra
  let S2 := E2.toSubalgebra
  refine'
    le_antisymm
      (show _ ≤ (S1 ⊔ S2).toIntermediateField _ from
        sup_le (show S1 ≤ _ from le_sup_left) (show S2 ≤ _ from le_sup_right))
      (le_sup_toSubalgebra E1 E2)
  suffices IsField (S1 ⊔ S2 : Subalgebra K L) by
    intro x hx
    by_cases hx' : (⟨x, hx⟩ : (S1 ⊔ S2 : Subalgebra K L)) = 0
    · rw [← Subtype.coe_mk x, hx', Subalgebra.coe_zero, inv_zero]
      exact (S1 ⊔ S2).zero_mem
    · obtain ⟨y, h⟩ := this.mul_inv_cancel hx'
      exact (congr_arg (· ∈ S1 ⊔ S2) <| eq_inv_of_mul_eq_one_right <| Subtype.ext_iff.mp h).mp y.2
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
S1 : Subalgebra K L := E1.toSubalgebra
S2 : Subalgebra K L := E2.toSubalgebra
⊢ IsField ↥(S1 ⊔ S2)

Next tactic:
exact
    isField_of_isIntegral_of_isField'
      (Algebra.isIntegral_sup.mpr
        ⟨Algebra.IsIntegral.of_finite K E1, Algebra.IsIntegral.of_finite K E2⟩)
      (Field.toIsField K)
instance finiteDimensional_sup [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    FiniteDimensional K (E1 ⊔ E2 : IntermediateField K L) := by
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
⊢ FiniteDimensional K ↥(E1 ⊔ E2)

Next tactic:
let g := Algebra.TensorProduct.productMap E1.val E2.val
instance finiteDimensional_sup [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    FiniteDimensional K (E1 ⊔ E2 : IntermediateField K L) := by
  let g := Algebra.TensorProduct.productMap E1.val E2.val
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
g : TensorProduct K ↥E1 ↥E2 →ₐ[K] L := Algebra.TensorProduct.productMap (val E1) (val E2)
⊢ FiniteDimensional K ↥(E1 ⊔ E2)

Next tactic:
suffices g.range = (E1 ⊔ E2).toSubalgebra by
    have h : FiniteDimensional K (Subalgebra.toSubmodule g.range) :=
      g.toLinearMap.finiteDimensional_range
    rwa [this] at h
instance finiteDimensional_sup [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    FiniteDimensional K (E1 ⊔ E2 : IntermediateField K L) := by
  let g := Algebra.TensorProduct.productMap E1.val E2.val
  suffices g.range = (E1 ⊔ E2).toSubalgebra by
    

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
g : TensorProduct K ↥E1 ↥E2 →ₐ[K] L := Algebra.TensorProduct.productMap (val E1) (val E2)
this : AlgHom.range g = (E1 ⊔ E2).toSubalgebra
⊢ FiniteDimensional K ↥(E1 ⊔ E2)

Next tactic:
have h : FiniteDimensional K (Subalgebra.toSubmodule g.range) :=
      g.toLinearMap.finiteDimensional_range
instance finiteDimensional_sup [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    FiniteDimensional K (E1 ⊔ E2 : IntermediateField K L) := by
  let g := Algebra.TensorProduct.productMap E1.val E2.val
  suffices g.range = (E1 ⊔ E2).toSubalgebra by
    have h : FiniteDimensional K (Subalgebra.toSubmodule g.range) :=
      g.toLinearMap.finiteDimensional_range
    

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
g : TensorProduct K ↥E1 ↥E2 →ₐ[K] L := Algebra.TensorProduct.productMap (val E1) (val E2)
this : AlgHom.range g = (E1 ⊔ E2).toSubalgebra
h : FiniteDimensional K ↥(Subalgebra.toSubmodule (AlgHom.range g))
⊢ FiniteDimensional K ↥(E1 ⊔ E2)

Next tactic:
rwa [this] at h
instance finiteDimensional_sup [h1 : FiniteDimensional K E1] [h2 : FiniteDimensional K E2] :
    FiniteDimensional K (E1 ⊔ E2 : IntermediateField K L) := by
  let g := Algebra.TensorProduct.productMap E1.val E2.val
  suffices g.range = (E1 ⊔ E2).toSubalgebra by
    have h : FiniteDimensional K (Subalgebra.toSubmodule g.range) :=
      g.toLinearMap.finiteDimensional_range
    rwa [this] at h
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
h1 : FiniteDimensional K ↥E1
h2 : FiniteDimensional K ↥E2
g : TensorProduct K ↥E1 ↥E2 →ₐ[K] L := Algebra.TensorProduct.productMap (val E1) (val E2)
⊢ AlgHom.range g = (E1 ⊔ E2).toSubalgebra

Next tactic:
rw [Algebra.TensorProduct.productMap_range, E1.range_val, E2.range_val, sup_toSubalgebra]
theorem toSubalgebra_iSup_of_directed (dir : Directed (· ≤ ·) t) :
    (iSup t).toSubalgebra = ⨆ i, (t i).toSubalgebra := by
  

Proof state:
F : Type u_1
inst✝⁵ : Field F
E : Type u_2
inst✝⁴ : Field E
inst✝³ : Algebra F E
S : Set E
α : E
K : Type u_3
L : Type u_4
inst✝² : Field K
inst✝¹ : Field L
inst✝ : Algebra K L
E1 E2 : IntermediateField K L
ι : Type u_5
t : ι → IntermediateField K L
dir : Directed (fun x x_1 => x ≤ x_1) t
⊢ (iSup t).toSubalgebra = ⨆ i, (t i).toSubalgebra

Next tactic:
cases isEmpty_or_nonempty ι