l3lab/ntp-mathlib huggingface dataset:
theorem Submodule.finrank_le_one_iff_isPrincipal (W : Submodule K V) [FiniteDimensional K W] :
    finrank K W ≤ 1 ↔ W.IsPrincipal := by
  

Proof state:
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
W : Submodule K V
inst✝ : FiniteDimensional K ↥W
⊢ finrank K ↥W ≤ 1 ↔ IsPrincipal W

Next tactic:
rw [← W.rank_le_one_iff_isPrincipal, ← finrank_eq_rank, ← Cardinal.natCast_le, Nat.cast_one]
theorem Module.finrank_le_one_iff_top_isPrincipal [FiniteDimensional K V] :
    finrank K V ≤ 1 ↔ (⊤ : Submodule K V).IsPrincipal := by
  

Proof state:
K : Type u
V : Type v
inst✝³ : DivisionRing K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
⊢ finrank K V ≤ 1 ↔ IsPrincipal ⊤

Next tactic:
rw [← Module.rank_le_one_iff_top_isPrincipal, ← finrank_eq_rank, ← Cardinal.natCast_le,
    Nat.cast_one]
theorem surjective_of_nonzero_of_finrank_eq_one {W A : Type*} [Semiring A] [Module A V]
    [AddCommGroup W] [Module K W] [Module A W] [LinearMap.CompatibleSMul V W K A]
    (h : finrank K W = 1) {f : V →ₗ[A] W} (w : f ≠ 0) : Surjective f := by
  

Proof state:
K : Type u
V : Type v
inst✝⁸ : DivisionRing K
inst✝⁷ : AddCommGroup V
inst✝⁶ : Module K V
W : Type u_1
A : Type u_2
inst✝⁵ : Semiring A
inst✝⁴ : Module A V
inst✝³ : AddCommGroup W
inst✝² : Module K W
inst✝¹ : Module A W
inst✝ : LinearMap.CompatibleSMul V W K A
h : finrank K W = 1
f : V →ₗ[A] W
w : f ≠ 0
⊢ Surjective ⇑f

Next tactic:
change Surjective (f.restrictScalars K)
theorem surjective_of_nonzero_of_finrank_eq_one {W A : Type*} [Semiring A] [Module A V]
    [AddCommGroup W] [Module K W] [Module A W] [LinearMap.CompatibleSMul V W K A]
    (h : finrank K W = 1) {f : V →ₗ[A] W} (w : f ≠ 0) : Surjective f := by
  change Surjective (f.restrictScalars K)
  

Proof state:
K : Type u
V : Type v
inst✝⁸ : DivisionRing K
inst✝⁷ : AddCommGroup V
inst✝⁶ : Module K V
W : Type u_1
A : Type u_2
inst✝⁵ : Semiring A
inst✝⁴ : Module A V
inst✝³ : AddCommGroup W
inst✝² : Module K W
inst✝¹ : Module A W
inst✝ : LinearMap.CompatibleSMul V W K A
h : finrank K W = 1
f : V →ₗ[A] W
w : f ≠ 0
⊢ Surjective ⇑(↑K f)

Next tactic:
obtain ⟨v, n⟩ := FunLike.ne_iff.mp w
theorem surjective_of_nonzero_of_finrank_eq_one {W A : Type*} [Semiring A] [Module A V]
    [AddCommGroup W] [Module K W] [Module A W] [LinearMap.CompatibleSMul V W K A]
    (h : finrank K W = 1) {f : V →ₗ[A] W} (w : f ≠ 0) : Surjective f := by
  change Surjective (f.restrictScalars K)
  obtain ⟨v, n⟩ := FunLike.ne_iff.mp w
  

Proof state:
case intro
K : Type u
V : Type v
inst✝⁸ : DivisionRing K
inst✝⁷ : AddCommGroup V
inst✝⁶ : Module K V
W : Type u_1
A : Type u_2
inst✝⁵ : Semiring A
inst✝⁴ : Module A V
inst✝³ : AddCommGroup W
inst✝² : Module K W
inst✝¹ : Module A W
inst✝ : LinearMap.CompatibleSMul V W K A
h : finrank K W = 1
f : V →ₗ[A] W
w : f ≠ 0
v : V
n : f v ≠ 0 v
⊢ Surjective ⇑(↑K f)

Next tactic:
intro z
theorem surjective_of_nonzero_of_finrank_eq_one {W A : Type*} [Semiring A] [Module A V]
    [AddCommGroup W] [Module K W] [Module A W] [LinearMap.CompatibleSMul V W K A]
    (h : finrank K W = 1) {f : V →ₗ[A] W} (w : f ≠ 0) : Surjective f := by
  change Surjective (f.restrictScalars K)
  obtain ⟨v, n⟩ := FunLike.ne_iff.mp w
  intro z
  

Proof state:
case intro
K : Type u
V : Type v
inst✝⁸ : DivisionRing K
inst✝⁷ : AddCommGroup V
inst✝⁶ : Module K V
W : Type u_1
A : Type u_2
inst✝⁵ : Semiring A
inst✝⁴ : Module A V
inst✝³ : AddCommGroup W
inst✝² : Module K W
inst✝¹ : Module A W
inst✝ : LinearMap.CompatibleSMul V W K A
h : finrank K W = 1
f : V →ₗ[A] W
w : f ≠ 0
v : V
n : f v ≠ 0 v
z : W
⊢ ∃ a, (↑K f) a = z

Next tactic:
obtain ⟨c, rfl⟩ := (finrank_eq_one_iff_of_nonzero' (f v) n).mp h z
theorem surjective_of_nonzero_of_finrank_eq_one {W A : Type*} [Semiring A] [Module A V]
    [AddCommGroup W] [Module K W] [Module A W] [LinearMap.CompatibleSMul V W K A]
    (h : finrank K W = 1) {f : V →ₗ[A] W} (w : f ≠ 0) : Surjective f := by
  change Surjective (f.restrictScalars K)
  obtain ⟨v, n⟩ := FunLike.ne_iff.mp w
  intro z
  obtain ⟨c, rfl⟩ := (finrank_eq_one_iff_of_nonzero' (f v) n).mp h z
  

Proof state:
case intro.intro
K : Type u
V : Type v
inst✝⁸ : DivisionRing K
inst✝⁷ : AddCommGroup V
inst✝⁶ : Module K V
W : Type u_1
A : Type u_2
inst✝⁵ : Semiring A
inst✝⁴ : Module A V
inst✝³ : AddCommGroup W
inst✝² : Module K W
inst✝¹ : Module A W
inst✝ : LinearMap.CompatibleSMul V W K A
h : finrank K W = 1
f : V →ₗ[A] W
w : f ≠ 0
v : V
n : f v ≠ 0 v
c : K
⊢ ∃ a, (↑K f) a = c • f v

Next tactic:
exact ⟨c • v, by simp⟩
theorem surjective_of_nonzero_of_finrank_eq_one {W A : Type*} [Semiring A] [Module A V]
    [AddCommGroup W] [Module K W] [Module A W] [LinearMap.CompatibleSMul V W K A]
    (h : finrank K W = 1) {f : V →ₗ[A] W} (w : f ≠ 0) : Surjective f := by
  change Surjective (f.restrictScalars K)
  obtain ⟨v, n⟩ := FunLike.ne_iff.mp w
  intro z
  obtain ⟨c, rfl⟩ := (finrank_eq_one_iff_of_nonzero' (f v) n).mp h z
  exact ⟨c • v, by 

Proof state:
K : Type u
V : Type v
inst✝⁸ : DivisionRing K
inst✝⁷ : AddCommGroup V
inst✝⁶ : Module K V
W : Type u_1
A : Type u_2
inst✝⁵ : Semiring A
inst✝⁴ : Module A V
inst✝³ : AddCommGroup W
inst✝² : Module K W
inst✝¹ : Module A W
inst✝ : LinearMap.CompatibleSMul V W K A
h : finrank K W = 1
f : V →ₗ[A] W
w : f ≠ 0
v : V
n : f v ≠ 0 v
c : K
⊢ (↑K f) (c • v) = c • f v

Next tactic:
simp
/-- Any `K`-algebra module that is 1-dimensional over `K` is simple. -/
theorem is_simple_module_of_finrank_eq_one {A} [Semiring A] [Module A V] [SMul K A]
    [IsScalarTower K A V] (h : finrank K V = 1) : IsSimpleOrder (Submodule A V) := by
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
A : Type u_1
inst✝³ : Semiring A
inst✝² : Module A V
inst✝¹ : SMul K A
inst✝ : IsScalarTower K A V
h : finrank K V = 1
⊢ IsSimpleOrder (Submodule A V)

Next tactic:
haveI := nontrivial_of_finrank_eq_succ h
/-- Any `K`-algebra module that is 1-dimensional over `K` is simple. -/
theorem is_simple_module_of_finrank_eq_one {A} [Semiring A] [Module A V] [SMul K A]
    [IsScalarTower K A V] (h : finrank K V = 1) : IsSimpleOrder (Submodule A V) := by
  haveI := nontrivial_of_finrank_eq_succ h
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
A : Type u_1
inst✝³ : Semiring A
inst✝² : Module A V
inst✝¹ : SMul K A
inst✝ : IsScalarTower K A V
h : finrank K V = 1
this : Nontrivial V
⊢ IsSimpleOrder (Submodule A V)

Next tactic:
refine' ⟨fun S => or_iff_not_imp_left.2 fun hn => _⟩
/-- Any `K`-algebra module that is 1-dimensional over `K` is simple. -/
theorem is_simple_module_of_finrank_eq_one {A} [Semiring A] [Module A V] [SMul K A]
    [IsScalarTower K A V] (h : finrank K V = 1) : IsSimpleOrder (Submodule A V) := by
  haveI := nontrivial_of_finrank_eq_succ h
  refine' ⟨fun S => or_iff_not_imp_left.2 fun hn => _⟩
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
A : Type u_1
inst✝³ : Semiring A
inst✝² : Module A V
inst✝¹ : SMul K A
inst✝ : IsScalarTower K A V
h : finrank K V = 1
this : Nontrivial V
S : Submodule A V
hn : ¬S = ⊥
⊢ S = ⊤

Next tactic:
rw [← restrictScalars_inj K] at hn ⊢
/-- Any `K`-algebra module that is 1-dimensional over `K` is simple. -/
theorem is_simple_module_of_finrank_eq_one {A} [Semiring A] [Module A V] [SMul K A]
    [IsScalarTower K A V] (h : finrank K V = 1) : IsSimpleOrder (Submodule A V) := by
  haveI := nontrivial_of_finrank_eq_succ h
  refine' ⟨fun S => or_iff_not_imp_left.2 fun hn => _⟩
  rw [← restrictScalars_inj K] at hn ⊢
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
A : Type u_1
inst✝³ : Semiring A
inst✝² : Module A V
inst✝¹ : SMul K A
inst✝ : IsScalarTower K A V
h : finrank K V = 1
this : Nontrivial V
S : Submodule A V
hn : ¬restrictScalars K S = restrictScalars K ⊥
⊢ restrictScalars K S = restrictScalars K ⊤

Next tactic:
haveI : FiniteDimensional _ _ := finiteDimensional_of_finrank_eq_succ h
/-- Any `K`-algebra module that is 1-dimensional over `K` is simple. -/
theorem is_simple_module_of_finrank_eq_one {A} [Semiring A] [Module A V] [SMul K A]
    [IsScalarTower K A V] (h : finrank K V = 1) : IsSimpleOrder (Submodule A V) := by
  haveI := nontrivial_of_finrank_eq_succ h
  refine' ⟨fun S => or_iff_not_imp_left.2 fun hn => _⟩
  rw [← restrictScalars_inj K] at hn ⊢
  haveI : FiniteDimensional _ _ := finiteDimensional_of_finrank_eq_succ h
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
A : Type u_1
inst✝³ : Semiring A
inst✝² : Module A V
inst✝¹ : SMul K A
inst✝ : IsScalarTower K A V
h : finrank K V = 1
this✝ : Nontrivial V
S : Submodule A V
hn : ¬restrictScalars K S = restrictScalars K ⊥
this : FiniteDimensional K V
⊢ restrictScalars K S = restrictScalars K ⊤

Next tactic:
refine' eq_top_of_finrank_eq ((Submodule.finrank_le _).antisymm _)
/-- Any `K`-algebra module that is 1-dimensional over `K` is simple. -/
theorem is_simple_module_of_finrank_eq_one {A} [Semiring A] [Module A V] [SMul K A]
    [IsScalarTower K A V] (h : finrank K V = 1) : IsSimpleOrder (Submodule A V) := by
  haveI := nontrivial_of_finrank_eq_succ h
  refine' ⟨fun S => or_iff_not_imp_left.2 fun hn => _⟩
  rw [← restrictScalars_inj K] at hn ⊢
  haveI : FiniteDimensional _ _ := finiteDimensional_of_finrank_eq_succ h
  refine' eq_top_of_finrank_eq ((Submodule.finrank_le _).antisymm _)
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
A : Type u_1
inst✝³ : Semiring A
inst✝² : Module A V
inst✝¹ : SMul K A
inst✝ : IsScalarTower K A V
h : finrank K V = 1
this✝ : Nontrivial V
S : Submodule A V
hn : ¬restrictScalars K S = restrictScalars K ⊥
this : FiniteDimensional K V
⊢ finrank K V ≤ finrank K ↥(restrictScalars K S)

Next tactic:
simpa only [h, finrank_bot] using Submodule.finrank_strictMono (Ne.bot_lt hn)
instance Subalgebra.finiteDimensional_bot : FiniteDimensional F (⊥ : Subalgebra F E) := by
  

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
⊢ FiniteDimensional F ↥⊥

Next tactic:
nontriviality E
instance Subalgebra.finiteDimensional_bot : FiniteDimensional F (⊥ : Subalgebra F E) := by
  nontriviality E
  

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
✝ : Nontrivial E
⊢ FiniteDimensional F ↥⊥

Next tactic:
exact finiteDimensional_of_rank_eq_one Subalgebra.rank_bot
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
⊢ S = ⊥

Next tactic:
nontriviality E
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
⊢ S = ⊥

Next tactic:
obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
⊢ S = ⊥

Next tactic:
haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this : FiniteDimensional F ↥S
⊢ S = ⊥

Next tactic:
rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
  -- porting note: fails without explicit type
  

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this : FiniteDimensional F ↥S
⊢ ¬toSubmodule ⊥ < toSubmodule S

Next tactic:
haveI : FiniteDimensional F (Subalgebra.toSubmodule S) :=
    S.toSubmoduleEquiv.symm.finiteDimensional
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F (Subalgebra.toSubmodule S) :=
    S.toSubmoduleEquiv.symm.finiteDimensional
  

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this✝ : FiniteDimensional F ↥S
this : FiniteDimensional F ↥(toSubmodule S)
⊢ ¬toSubmodule ⊥ < toSubmodule S

Next tactic:
refine fun hl => (Submodule.finrank_lt_finrank_of_lt hl).not_le (natCast_le.1 ?_)
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F (Subalgebra.toSubmodule S) :=
    S.toSubmoduleEquiv.symm.finiteDimensional
  refine fun hl => (Submodule.finrank_lt_finrank_of_lt hl).not_le (natCast_le.1 ?_)
  

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this✝ : FiniteDimensional F ↥S
this : FiniteDimensional F ↥(toSubmodule S)
hl : toSubmodule ⊥ < toSubmodule S
⊢ ↑(finrank F ↥(toSubmodule S)) ≤ ↑(finrank F ↥(toSubmodule ⊥))

Next tactic:
iterate 2 rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank]
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F (Subalgebra.toSubmodule S) :=
    S.toSubmoduleEquiv.symm.finiteDimensional
  refine fun hl => (Submodule.finrank_lt_finrank_of_lt hl).not_le (natCast_le.1 ?_)
  iterate 2 

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this✝ : FiniteDimensional F ↥S
this : FiniteDimensional F ↥(toSubmodule S)
hl : toSubmodule ⊥ < toSubmodule S
⊢ ↑(finrank F ↥(toSubmodule S)) ≤ ↑(finrank F ↥(toSubmodule ⊥))

Next tactic:
rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank]
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F (Subalgebra.toSubmodule S) :=
    S.toSubmoduleEquiv.symm.finiteDimensional
  refine fun hl => (Submodule.finrank_lt_finrank_of_lt hl).not_le (natCast_le.1 ?_)
  iterate 2 

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this✝ : FiniteDimensional F ↥S
this : FiniteDimensional F ↥(toSubmodule S)
hl : toSubmodule ⊥ < toSubmodule S
⊢ Module.rank F ↥S ≤ ↑(finrank F ↥(toSubmodule ⊥))

Next tactic:
rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank]
theorem Subalgebra.eq_bot_of_rank_le_one {S : Subalgebra F E} (h : Module.rank F S ≤ 1) :
    S = ⊥ := by
  nontriviality E
  obtain ⟨m, _, he⟩ := Cardinal.exists_nat_eq_of_le_nat (h.trans_eq Nat.cast_one.symm)
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F S := finiteDimensional_of_rank_eq_nat he
  rw [← not_bot_lt_iff, ← Subalgebra.toSubmodule.lt_iff_lt]
  -- porting note: fails without explicit type
  haveI : FiniteDimensional F (Subalgebra.toSubmodule S) :=
    S.toSubmoduleEquiv.symm.finiteDimensional
  refine fun hl => (Submodule.finrank_lt_finrank_of_lt hl).not_le (natCast_le.1 ?_)
  iterate 2 rw [Subalgebra.finrank_toSubmodule, finrank_eq_rank]
  

Proof state:
case intro.intro
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : Module.rank F ↥S ≤ 1
✝ : Nontrivial E
m : ℕ
left✝ : m ≤ 1
he : Module.rank F ↥S = ↑m
this✝ : FiniteDimensional F ↥S
this : FiniteDimensional F ↥(toSubmodule S)
hl : toSubmodule ⊥ < toSubmodule S
⊢ Module.rank F ↥S ≤ Module.rank F ↥⊥

Next tactic:
exact h.trans_eq Subalgebra.rank_bot.symm
theorem Subalgebra.eq_bot_of_finrank_one {S : Subalgebra F E} (h : finrank F S = 1) : S = ⊥ :=
  Subalgebra.eq_bot_of_rank_le_one <| by
    -- porting note: fails without explicit type
    

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : finrank F ↥S = 1
⊢ Module.rank F ↥S ≤ 1

Next tactic:
haveI : FiniteDimensional F S := finiteDimensional_of_finrank_eq_succ h
theorem Subalgebra.eq_bot_of_finrank_one {S : Subalgebra F E} (h : finrank F S = 1) : S = ⊥ :=
  Subalgebra.eq_bot_of_rank_le_one <| by
    -- porting note: fails without explicit type
    haveI : FiniteDimensional F S := finiteDimensional_of_finrank_eq_succ h
    

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
S : Subalgebra F E
h : finrank F ↥S = 1
this : FiniteDimensional F ↥S
⊢ Module.rank F ↥S ≤ 1

Next tactic:
rw [← finrank_eq_rank, h, Nat.cast_one]
theorem Subalgebra.bot_eq_top_iff_rank_eq_one [Nontrivial E] :
    (⊥ : Subalgebra F E) = ⊤ ↔ Module.rank F E = 1 := by
  -- porting note: removed `subalgebra_top_rank_eq_submodule_top_rank`
  

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝³ : Field F
inst✝² : Ring E
inst✝¹ : Algebra F E
inst✝ : Nontrivial E
⊢ ⊥ = ⊤ ↔ Module.rank F E = 1

Next tactic:
rw [← rank_top, Subalgebra.rank_eq_one_iff, eq_comm]
theorem Subalgebra.bot_eq_top_iff_finrank_eq_one [Nontrivial E] :
    (⊥ : Subalgebra F E) = ⊤ ↔ finrank F E = 1 := by
  

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝³ : Field F
inst✝² : Ring E
inst✝¹ : Algebra F E
inst✝ : Nontrivial E
⊢ ⊥ = ⊤ ↔ finrank F E = 1

Next tactic:
rw [← finrank_top, ← subalgebra_top_finrank_eq_submodule_top_finrank,
    Subalgebra.finrank_eq_one_iff, eq_comm]
theorem Subalgebra.isSimpleOrder_of_finrank (hr : finrank F E = 2) :
    IsSimpleOrder (Subalgebra F E) :=
  let i := nontrivial_of_finrank_pos (zero_lt_two.trans_eq hr.symm)
  { toNontrivial :=
      ⟨⟨⊥, ⊤, fun h => by 

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
hr : finrank F E = 2
i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two hr.symm)
h : ⊥ = ⊤
⊢ False

Next tactic:
cases hr.symm.trans (Subalgebra.bot_eq_top_iff_finrank_eq_one.1 h)
theorem Subalgebra.isSimpleOrder_of_finrank (hr : finrank F E = 2) :
    IsSimpleOrder (Subalgebra F E) :=
  let i := nontrivial_of_finrank_pos (zero_lt_two.trans_eq hr.symm)
  { toNontrivial :=
      ⟨⟨⊥, ⊤, fun h => by cases hr.symm.trans (Subalgebra.bot_eq_top_iff_finrank_eq_one.1 h)⟩⟩
    eq_bot_or_eq_top := by
      

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
hr : finrank F E = 2
i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two hr.symm)
⊢ ∀ (a : Subalgebra F E), a = ⊥ ∨ a = ⊤

Next tactic:
intro S
theorem Subalgebra.isSimpleOrder_of_finrank (hr : finrank F E = 2) :
    IsSimpleOrder (Subalgebra F E) :=
  let i := nontrivial_of_finrank_pos (zero_lt_two.trans_eq hr.symm)
  { toNontrivial :=
      ⟨⟨⊥, ⊤, fun h => by cases hr.symm.trans (Subalgebra.bot_eq_top_iff_finrank_eq_one.1 h)⟩⟩
    eq_bot_or_eq_top := by
      intro S
      

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
hr : finrank F E = 2
i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two hr.symm)
S : Subalgebra F E
⊢ S = ⊥ ∨ S = ⊤

Next tactic:
haveI : FiniteDimensional F E := finiteDimensional_of_finrank_eq_succ hr
theorem Subalgebra.isSimpleOrder_of_finrank (hr : finrank F E = 2) :
    IsSimpleOrder (Subalgebra F E) :=
  let i := nontrivial_of_finrank_pos (zero_lt_two.trans_eq hr.symm)
  { toNontrivial :=
      ⟨⟨⊥, ⊤, fun h => by cases hr.symm.trans (Subalgebra.bot_eq_top_iff_finrank_eq_one.1 h)⟩⟩
    eq_bot_or_eq_top := by
      intro S
      haveI : FiniteDimensional F E := finiteDimensional_of_finrank_eq_succ hr
      

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
hr : finrank F E = 2
i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two hr.symm)
S : Subalgebra F E
this : FiniteDimensional F E
⊢ S = ⊥ ∨ S = ⊤

Next tactic:
haveI : FiniteDimensional F S :=
        FiniteDimensional.finiteDimensional_submodule (Subalgebra.toSubmodule S)
theorem Subalgebra.isSimpleOrder_of_finrank (hr : finrank F E = 2) :
    IsSimpleOrder (Subalgebra F E) :=
  let i := nontrivial_of_finrank_pos (zero_lt_two.trans_eq hr.symm)
  { toNontrivial :=
      ⟨⟨⊥, ⊤, fun h => by cases hr.symm.trans (Subalgebra.bot_eq_top_iff_finrank_eq_one.1 h)⟩⟩
    eq_bot_or_eq_top := by
      intro S
      haveI : FiniteDimensional F E := finiteDimensional_of_finrank_eq_succ hr
      haveI : FiniteDimensional F S :=
        FiniteDimensional.finiteDimensional_submodule (Subalgebra.toSubmodule S)
      

Proof state:
K : Type u
V : Type v
F : Type u_1
E : Type u_2
inst✝² : Field F
inst✝¹ : Ring E
inst✝ : Algebra F E
hr : finrank F E = 2
i : Nontrivial E := nontrivial_of_finrank_pos (LT.lt.trans_eq zero_lt_two hr.symm)
S : Subalgebra F E
this✝ : FiniteDimensional F E
this : FiniteDimensional F ↥S
⊢ S = ⊥ ∨ S = ⊤

Next tactic:
have : finrank F S ≤ 2 := hr ▸ S.toSubmodule.finrank_le