l3lab/ntp-mathlib huggingface dataset:
theorem prod_map_sum [CommSemiring α] {s : Multiset (Multiset α)} :
    prod (s.map sum) = sum ((Sections s).map prod) :=
  Multiset.induction_on s (by 

Proof state:
α : Type u_1
inst✝ : CommSemiring α
s : Multiset (Multiset α)
⊢ prod (map sum 0) = sum (map prod (Sections 0))

Next tactic:
simp
theorem prod_map_sum [CommSemiring α] {s : Multiset (Multiset α)} :
    prod (s.map sum) = sum ((Sections s).map prod) :=
  Multiset.induction_on s (by simp) fun a s ih => by
    

Proof state:
α : Type u_1
inst✝ : CommSemiring α
s✝ : Multiset (Multiset α)
a : Multiset α
s : Multiset (Multiset α)
ih : prod (map sum s) = sum (map prod (Sections s))
⊢ prod (map sum (a ::ₘ s)) = sum (map prod (Sections (a ::ₘ s)))

Next tactic:
simp [ih, map_bind, sum_map_mul_left, sum_map_mul_right]
@[simp]
theorem curry_uncurry {n} (f : Function.OfArity α β n) :
    curry (uncurry f) = f :=
  match n with
  | 0 => rfl
  | n + 1 => funext fun a => by
    

Proof state:
α β : Type u
n✝ n : ℕ
f : OfArity α β (n + 1)
a : α
⊢ curry (uncurry f) a = f a

Next tactic:
dsimp [curry, uncurry, Function.comp_def]
@[simp]
theorem curry_uncurry {n} (f : Function.OfArity α β n) :
    curry (uncurry f) = f :=
  match n with
  | 0 => rfl
  | n + 1 => funext fun a => by
    dsimp [curry, uncurry, Function.comp_def]
    

Proof state:
α β : Type u
n✝ n : ℕ
f : OfArity α β (n + 1)
a : α
⊢ (curry fun args => uncurry (f (Fin.cons a args 0)) fun x => Fin.cons a args (Fin.succ x)) = f a

Next tactic:
simp only [Fin.cons_zero, Fin.cons_succ]
@[simp]
theorem curry_uncurry {n} (f : Function.OfArity α β n) :
    curry (uncurry f) = f :=
  match n with
  | 0 => rfl
  | n + 1 => funext fun a => by
    dsimp [curry, uncurry, Function.comp_def]
    simp only [Fin.cons_zero, Fin.cons_succ]
    

Proof state:
α β : Type u
n✝ n : ℕ
f : OfArity α β (n + 1)
a : α
⊢ (curry fun args => uncurry (f a) fun x => args x) = f a

Next tactic:
rw [curry_uncurry]
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  

Proof state:
α β : Type u
n : ℕ
f : (Fin n → α) → β
⊢ uncurry (curry f) = f

Next tactic:
ext args
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  ext args
  

Proof state:
case h
α β : Type u
n : ℕ
f : (Fin n → α) → β
args : Fin n → α
⊢ uncurry (curry f) args = f args

Next tactic:
induction args using Fin.consInduction with
  | h0 => rfl
  | h a as ih =>
    dsimp [curry, uncurry, Function.comp_def]
    simp only [Fin.cons_zero, Fin.cons_succ, ih (f <| Fin.cons a ·)]
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  ext args
  induction args using Fin.consInduction with
  

Proof state:
case h.h0
α β : Type u
n : ℕ
f : (Fin 0 → α) → β
⊢ uncurry (curry f) Fin.elim0 = f Fin.elim0

Next tactic:
| h0 => rfl
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  ext args
  induction args using Fin.consInduction with
  | h0 => 

Proof state:
case h.h0
α β : Type u
n : ℕ
f : (Fin 0 → α) → β
⊢ uncurry (curry f) Fin.elim0 = f Fin.elim0

Next tactic:
rfl
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  ext args
  induction args using Fin.consInduction with
  | h0 => rfl
  

Proof state:
case h.h
α β : Type u
n n✝ : ℕ
a : α
as : Fin n✝ → α
ih : ∀ (f : (Fin n✝ → α) → β), uncurry (curry f) as = f as
f : (Fin (n✝ + 1) → α) → β
⊢ uncurry (curry f) (Fin.cons a as) = f (Fin.cons a as)

Next tactic:
| h a as ih =>
    dsimp [curry, uncurry, Function.comp_def]
    simp only [Fin.cons_zero, Fin.cons_succ, ih (f <| Fin.cons a ·)]
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  ext args
  induction args using Fin.consInduction with
  | h0 => rfl
  | h a as ih =>
    

Proof state:
case h.h
α β : Type u
n n✝ : ℕ
a : α
as : Fin n✝ → α
ih : ∀ (f : (Fin n✝ → α) → β), uncurry (curry f) as = f as
f : (Fin (n✝ + 1) → α) → β
⊢ uncurry (curry f) (Fin.cons a as) = f (Fin.cons a as)

Next tactic:
dsimp [curry, uncurry, Function.comp_def]
@[simp]
theorem uncurry_curry {n} (f : (Fin n → α) → β) :
    uncurry (curry f) = f := by
  ext args
  induction args using Fin.consInduction with
  | h0 => rfl
  | h a as ih =>
    dsimp [curry, uncurry, Function.comp_def]
    

Proof state:
case h.h
α β : Type u
n n✝ : ℕ
a : α
as : Fin n✝ → α
ih : ∀ (f : (Fin n✝ → α) → β), uncurry (curry f) as = f as
f : (Fin (n✝ + 1) → α) → β
⊢ (uncurry (curry fun args => f (Fin.cons (Fin.cons a as 0) args)) fun x => Fin.cons a as (Fin.succ x)) =
    f (Fin.cons a as)

Next tactic:
simp only [Fin.cons_zero, Fin.cons_succ, ih (f <| Fin.cons a ·)]
theorem finite_of_finite [Finite K] [FiniteDimensional K V] : Finite V := by
  

Proof state:
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
V₂ : Type v'
inst✝³ : AddCommGroup V₂
inst✝² : Module K V₂
inst✝¹ : _root_.Finite K
inst✝ : FiniteDimensional K V
⊢ _root_.Finite V

Next tactic:
cases nonempty_fintype K
theorem finite_of_finite [Finite K] [FiniteDimensional K V] : Finite V := by
  cases nonempty_fintype K
  

Proof state:
case intro
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
V₂ : Type v'
inst✝³ : AddCommGroup V₂
inst✝² : Module K V₂
inst✝¹ : _root_.Finite K
inst✝ : FiniteDimensional K V
val✝ : Fintype K
⊢ _root_.Finite V

Next tactic:
haveI := fintypeOfFintype K V
theorem finite_of_finite [Finite K] [FiniteDimensional K V] : Finite V := by
  cases nonempty_fintype K
  haveI := fintypeOfFintype K V
  

Proof state:
case intro
K : Type u
V : Type v
inst✝⁶ : DivisionRing K
inst✝⁵ : AddCommGroup V
inst✝⁴ : Module K V
V₂ : Type v'
inst✝³ : AddCommGroup V₂
inst✝² : Module K V₂
inst✝¹ : _root_.Finite K
inst✝ : FiniteDimensional K V
val✝ : Fintype K
this : Fintype V
⊢ _root_.Finite V

Next tactic:
infer_instance
/-- If a vector space is `FiniteDimensional`, `Basis.ofVectorSpace` is indexed by
  a finite type.-/
noncomputable instance [FiniteDimensional K V] : Fintype (Basis.ofVectorSpaceIndex K V) := by
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
⊢ Fintype ↑(Basis.ofVectorSpaceIndex K V)

Next tactic:
letI : IsNoetherian K V := IsNoetherian.iff_fg.2 inferInstance
/-- If a vector space is `FiniteDimensional`, `Basis.ofVectorSpace` is indexed by
  a finite type.-/
noncomputable instance [FiniteDimensional K V] : Fintype (Basis.ofVectorSpaceIndex K V) := by
  letI : IsNoetherian K V := IsNoetherian.iff_fg.2 inferInstance
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
this : IsNoetherian K V := iff_fg.mpr inferInstance
⊢ Fintype ↑(Basis.ofVectorSpaceIndex K V)

Next tactic:
infer_instance
/-- A subspace of a finite-dimensional space is also finite-dimensional. -/
instance finiteDimensional_submodule [FiniteDimensional K V] (S : Submodule K V) :
    FiniteDimensional K S := by
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
⊢ FiniteDimensional K ↥S

Next tactic:
letI : IsNoetherian K V := iff_fg.2 ?_
/-- A subspace of a finite-dimensional space is also finite-dimensional. -/
instance finiteDimensional_submodule [FiniteDimensional K V] (S : Submodule K V) :
    FiniteDimensional K S := by
  letI : IsNoetherian K V := iff_fg.2 ?_
  

Proof state:
case refine_2
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
this : IsNoetherian K V := iff_fg.mpr ?refine_1
⊢ FiniteDimensional K ↥S
case refine_1
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
⊢ Module.Finite K V

Next tactic:
exact
    iff_fg.1
      (IsNoetherian.iff_rank_lt_aleph0.2
        (lt_of_le_of_lt (rank_submodule_le _) (rank_lt_aleph0 K V)))
/-- A subspace of a finite-dimensional space is also finite-dimensional. -/
instance finiteDimensional_submodule [FiniteDimensional K V] (S : Submodule K V) :
    FiniteDimensional K S := by
  letI : IsNoetherian K V := iff_fg.2 ?_
  exact
    iff_fg.1
      (IsNoetherian.iff_rank_lt_aleph0.2
        (lt_of_le_of_lt (rank_submodule_le _) (rank_lt_aleph0 K V)))
  

Proof state:
case refine_1
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
⊢ Module.Finite K V

Next tactic:
infer_instance
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
⊢ S = ⊤

Next tactic:
haveI : IsNoetherian K V := iff_fg.2 inferInstance
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this : IsNoetherian K V
⊢ S = ⊤

Next tactic:
set bS := Basis.ofVectorSpace K S with bS_eq
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
⊢ S = ⊤

Next tactic:
have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by 

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
⊢ LinearIndependent K fun (x : ↑(Basis.ofVectorSpaceIndex K ↥S)) => ↑x

Next tactic:
simpa using bS.linearIndependent
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by 

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
⊢ Disjoint (span K (Basis.ofVectorSpaceIndex K ↥S)) (LinearMap.ker (Submodule.subtype S))

Next tactic:
simp
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this✝ : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
this : LinearIndependent (ι := { x // x ∈ Subtype.val '' Basis.ofVectorSpaceIndex K ↥S }) K Subtype.val
⊢ S = ⊤

Next tactic:
set b := Basis.extend this with b_eq
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
  set b := Basis.extend this with b_eq
  -- porting note: `letI` now uses `this` so we need to give different names
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this✝ : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
this : LinearIndependent (ι := { x // x ∈ Subtype.val '' Basis.ofVectorSpaceIndex K ↥S }) K Subtype.val
b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ))) K V :=
  Basis.extend this
b_eq : b = Basis.extend this
⊢ S = ⊤

Next tactic:
letI i1 : Fintype (this.extend _) :=
    (finite_of_linearIndependent (by simpa using b.linearIndependent)).fintype
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
  set b := Basis.extend this with b_eq
  -- porting note: `letI` now uses `this` so we need to give different names
  letI i1 : Fintype (this.extend _) :=
    (finite_of_linearIndependent (by 

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this✝ : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
this : LinearIndependent (ι := { x // x ∈ Subtype.val '' Basis.ofVectorSpaceIndex K ↥S }) K Subtype.val
b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ))) K V :=
  Basis.extend this
b_eq : b = Basis.extend this
⊢ LinearIndependent (ι := { x // x ∈ LinearIndependent.extend this ?m.210910 }) ?m.211065 Subtype.val

Next tactic:
simpa using b.linearIndependent
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
  set b := Basis.extend this with b_eq
  -- porting note: `letI` now uses `this` so we need to give different names
  letI i1 : Fintype (this.extend _) :=
    (finite_of_linearIndependent (by simpa using b.linearIndependent)).fintype
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this✝ : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
this : LinearIndependent (ι := { x // x ∈ Subtype.val '' Basis.ofVectorSpaceIndex K ↥S }) K Subtype.val
b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ))) K V :=
  Basis.extend this
b_eq : b = Basis.extend this
i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ)) :=
  Set.Finite.fintype
    (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ)))
⊢ S = ⊤

Next tactic:
letI i2 : Fintype (((↑) : S → V) '' Basis.ofVectorSpaceIndex K S) :=
    (finite_of_linearIndependent this).fintype
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
  set b := Basis.extend this with b_eq
  -- porting note: `letI` now uses `this` so we need to give different names
  letI i1 : Fintype (this.extend _) :=
    (finite_of_linearIndependent (by simpa using b.linearIndependent)).fintype
  letI i2 : Fintype (((↑) : S → V) '' Basis.ofVectorSpaceIndex K S) :=
    (finite_of_linearIndependent this).fintype
  

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this✝ : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
this : LinearIndependent (ι := { x // x ∈ Subtype.val '' Basis.ofVectorSpaceIndex K ↥S }) K Subtype.val
b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ))) K V :=
  Basis.extend this
b_eq : b = Basis.extend this
i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ)) :=
  Set.Finite.fintype
    (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ)))
i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K ↥S) :=
  Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K ↥S))
⊢ S = ⊤

Next tactic:
letI i3 : Fintype (Basis.ofVectorSpaceIndex K S) :=
    (finite_of_linearIndependent (by simpa using bS.linearIndependent)).fintype
/-- If a submodule has maximal dimension in a finite dimensional space, then it is equal to the
whole space. -/
theorem _root_.Submodule.eq_top_of_finrank_eq [FiniteDimensional K V] {S : Submodule K V}
    (h : finrank K S = finrank K V) : S = ⊤ := by
  haveI : IsNoetherian K V := iff_fg.2 inferInstance
  set bS := Basis.ofVectorSpace K S with bS_eq
  have : LinearIndependent K ((↑) : ((↑) '' Basis.ofVectorSpaceIndex K S : Set V) → V) :=
    LinearIndependent.image_subtype (f := Submodule.subtype S)
      (by simpa using bS.linearIndependent) (by simp)
  set b := Basis.extend this with b_eq
  -- porting note: `letI` now uses `this` so we need to give different names
  letI i1 : Fintype (this.extend _) :=
    (finite_of_linearIndependent (by simpa using b.linearIndependent)).fintype
  letI i2 : Fintype (((↑) : S → V) '' Basis.ofVectorSpaceIndex K S) :=
    (finite_of_linearIndependent this).fintype
  letI i3 : Fintype (Basis.ofVectorSpaceIndex K S) :=
    (finite_of_linearIndependent (by 

Proof state:
K : Type u
V : Type v
inst✝⁵ : DivisionRing K
inst✝⁴ : AddCommGroup V
inst✝³ : Module K V
V₂ : Type v'
inst✝² : AddCommGroup V₂
inst✝¹ : Module K V₂
inst✝ : FiniteDimensional K V
S : Submodule K V
h : finrank K ↥S = finrank K V
this✝ : IsNoetherian K V
bS : Basis (↑(Basis.ofVectorSpaceIndex K ↥S)) K ↥S := Basis.ofVectorSpace K ↥S
bS_eq : bS = Basis.ofVectorSpace K ↥S
this : LinearIndependent (ι := { x // x ∈ Subtype.val '' Basis.ofVectorSpaceIndex K ↥S }) K Subtype.val
b : Basis (↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ))) K V :=
  Basis.extend this
b_eq : b = Basis.extend this
i1 : Fintype ↑(LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ)) :=
  Set.Finite.fintype
    (_ : Set.Finite (LinearIndependent.extend this (_ : Subtype.val '' Basis.ofVectorSpaceIndex K ↥S ⊆ Set.univ)))
i2 : Fintype ↑(Subtype.val '' Basis.ofVectorSpaceIndex K ↥S) :=
  Set.Finite.fintype (_ : Set.Finite (Subtype.val '' Basis.ofVectorSpaceIndex K ↥S))
⊢ LinearIndependent (ι := { x // x ∈ Basis.ofVectorSpaceIndex K ↥S }) ?m.216598 Subtype.val

Next tactic:
simpa using bS.linearIndependent