-- Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean
theorem exists_lt_finrank_of_infinite_dimensional
    [Algebra.IsAlgebraic F E] (hnfd : ¬ FiniteDimensional F E) (n : ℕ) :
    ∃ L : IntermediateField F E, FiniteDimensional F L ∧ n < finrank F L

Proof state:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
this : FiniteDimensional F ↥F⟮x⟯
h : ¬n + 1 < finrank F ↥L'
h1 : L = L'
⊢ False

Tactic:
have h2 : F⟮x⟯ ≤ L' := le_sup_right

Result:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
this : FiniteDimensional F ↥F⟮x⟯
h : ¬n + 1 < finrank F ↥L'
h1 : L = L'
h2 : F⟮x⟯ ≤ L'
⊢ False

Proof state:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
this : FiniteDimensional F ↥F⟮x⟯
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Tactic:
refine ⟨L', inferInstance, by_contra fun h ↦ ?_⟩

Result:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
this : FiniteDimensional F ↥F⟮x⟯
h : ¬n + 1 < finrank F ↥L'
⊢ False

Proof state:
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
⊢ ∃ L, FiniteDimensional F ↥L ∧ n < finrank F ↥L

Tactic:
induction' n with n ih

Result:
case zero
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
⊢ ∃ L, FiniteDimensional F ↥L ∧ 0 < finrank F ↥L

case succ
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
ih : ∃ L, FiniteDimensional F ↥L ∧ n < finrank F ↥L
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Proof state:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
this : FiniteDimensional F ↥F⟮x⟯
h : ¬n + 1 < finrank F ↥L'
h1 : L = L'
h2 : F⟮x⟯ ≤ L'
⊢ False

Tactic:
exact hx <| (h1.symm ▸ h2) <| mem_adjoin_simple_self F x

Result:
no goals

Proof state:
case zero
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
⊢ ∃ L, FiniteDimensional F ↥L ∧ 0 < finrank F ↥L

Tactic:
exact ⟨⊥, Subalgebra.finite_bot, finrank_pos⟩

Result:
no goals

Proof state:
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥⊤
hn : n < finrank F ↥L
hnfd : ∀ (x : E), x ∈ L
⊢ FiniteDimensional F E

Tactic:
exact topEquiv.toLinearEquiv.finiteDimensional

Result:
no goals

Proof state:
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
⊢ ∃ x, x ∉ L

Tactic:
contrapose! hnfd

Result:
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
hnfd : ∀ (x : E), x ∈ L
⊢ FiniteDimensional F E

Proof state:
case succ
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
ih : ∃ L, FiniteDimensional F ↥L ∧ n < finrank F ↥L
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Tactic:
obtain ⟨L, fin, hn⟩ := ih

Result:
case succ.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Proof state:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Tactic:
haveI := adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral (R := F) x)

Result:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
this : FiniteDimensional F ↥F⟮x⟯
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Proof state:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Tactic:
let L' := L ⊔ F⟮x⟯

Result:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
L' : IntermediateField F E := L ⊔ F⟮x⟯
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Proof state:
case succ.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L

Tactic:
obtain ⟨x, hx⟩ : ∃ x : E, x ∉ L := by
  contrapose! hnfd
  rw [show L = ⊤ from eq_top_iff.2 fun x _ ↦ hnfd x] at fin
  exact topEquiv.toLinearEquiv.finiteDimensional

Result:
case succ.intro.intro.intro
F : Type u_1
inst✝³ : Field F
E : Type u_2
inst✝² : Field E
inst✝¹ : Algebra F E
inst✝ : Algebra.IsAlgebraic F E
hnfd : ¬FiniteDimensional F E
n : ℕ
L : IntermediateField F E
fin : FiniteDimensional F ↥L
hn : n < finrank F ↥L
x : E
hx : x ∉ L
⊢ ∃ L, FiniteDimensional F ↥L ∧ n + 1 < finrank F ↥L