Skip to content

Commit 2288eab

Browse files
committed
chore(LinearAlgebra): golf (#10569)
- rename `span_eq_top_of_linearIndependent_of_card_eq_finrank` to `LinearIndependent.span_eq_top_of_card_eq_finrank`; - add a version `LinearIndependent.span_eq_top_of_card_eq_finrank'` with different typeclass assumptions; - use `rfl` to prove `Algebra.discr_def`; - golf `Algebra.discr_not_zero_of_basis`.
1 parent c9a8b43 commit 2288eab

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

Mathlib/LinearAlgebra/FiniteDimensional.lean

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -933,29 +933,30 @@ end Span
933933

934934
section Basis
935935

936-
theorem span_eq_top_of_linearIndependent_of_card_eq_finrank {ι : Type*} [hι : Nonempty ι]
937-
[Fintype ι] {b : ι → V} (lin_ind : LinearIndependent K b)
936+
theorem LinearIndependent.span_eq_top_of_card_eq_finrank' {ι : Type*}
937+
[Fintype ι] [FiniteDimensional K V] {b : ι → V} (lin_ind : LinearIndependent K b)
938938
(card_eq : Fintype.card ι = finrank K V) : span K (Set.range b) = ⊤ := by
939-
by_cases fin : FiniteDimensional K V
940-
· by_contra ne_top
941-
have lt_top : span K (Set.range b) < ⊤ := lt_of_le_of_ne le_top ne_top
942-
exact ne_of_lt (Submodule.finrank_lt lt_top)
943-
(_root_.trans (finrank_span_eq_card lin_ind) card_eq)
944-
· exfalso
945-
apply ne_of_lt (Fintype.card_pos_iff.mpr hι)
946-
symm
947-
replace fin := (not_iff_not.2 IsNoetherian.iff_fg).2 fin
948-
calc
949-
Fintype.card ι = finrank K V := card_eq
950-
_ = 0 := dif_neg (mt IsNoetherian.iff_rank_lt_aleph0.mpr fin)
951-
#align span_eq_top_of_linear_independent_of_card_eq_finrank span_eq_top_of_linearIndependent_of_card_eq_finrank
939+
by_contra ne_top
940+
rw [← finrank_span_eq_card lin_ind] at card_eq
941+
exact ne_of_lt (Submodule.finrank_lt <| lt_top_iff_ne_top.2 ne_top) card_eq
942+
943+
theorem LinearIndependent.span_eq_top_of_card_eq_finrank {ι : Type*} [Nonempty ι]
944+
[Fintype ι] {b : ι → V} (lin_ind : LinearIndependent K b)
945+
(card_eq : Fintype.card ι = finrank K V) : span K (Set.range b) = ⊤ :=
946+
have : FiniteDimensional K V := .of_finrank_pos <| card_eq ▸ Fintype.card_pos
947+
lin_ind.span_eq_top_of_card_eq_finrank' card_eq
948+
#align span_eq_top_of_linear_independent_of_card_eq_finrank LinearIndependent.span_eq_top_of_card_eq_finrank
949+
950+
@[deprecated] -- 2024-02-14
951+
alias span_eq_top_of_linearIndependent_of_card_eq_finrank :=
952+
LinearIndependent.span_eq_top_of_card_eq_finrank
952953

953954
/-- A linear independent family of `finrank K V` vectors forms a basis. -/
954955
@[simps! repr_apply]
955956
noncomputable def basisOfLinearIndependentOfCardEqFinrank {ι : Type*} [Nonempty ι] [Fintype ι]
956957
{b : ι → V} (lin_ind : LinearIndependent K b) (card_eq : Fintype.card ι = finrank K V) :
957958
Basis ι K V :=
958-
Basis.mk lin_ind <| (span_eq_top_of_linearIndependent_of_card_eq_finrank lin_ind card_eq).ge
959+
Basis.mk lin_ind <| (lin_ind.span_eq_top_of_card_eq_finrank card_eq).ge
959960
#align basis_of_linear_independent_of_card_eq_finrank basisOfLinearIndependentOfCardEqFinrank
960961

961962
@[simp]

Mathlib/RingTheory/Discriminant.lean

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ noncomputable def discr (A : Type u) {B : Type v} [CommRing A] [CommRing B] [Alg
7070
[Fintype ι] (b : ι → B) := (traceMatrix A b).det
7171
#align algebra.discr Algebra.discr
7272

73-
theorem discr_def [Fintype ι] (b : ι → B) : discr A b = (traceMatrix A b).det := by
74-
-- Porting note: `unfold discr` was not necessary. `rfl` still does not work.
75-
unfold discr
76-
convert rfl
73+
theorem discr_def [Fintype ι] (b : ι → B) : discr A b = (traceMatrix A b).det := rfl
7774

7875
variable {A C} in
7976
/-- Mapping a family of vectors along an `AlgEquiv` preserves the discriminant. -/
@@ -141,19 +138,8 @@ variable [Module.Finite K L] [IsAlgClosed E]
141138
/-- If `b` is a basis of a finite separable field extension `L/K`, then `Algebra.discr K b ≠ 0`. -/
142139
theorem discr_not_zero_of_basis [IsSeparable K L] (b : Basis ι K L) :
143140
discr K b ≠ 0 := by
144-
cases isEmpty_or_nonempty ι
145-
-- Porting note: the following proof was `simp [discr]`. Variations like `exact this` do not work.
146-
· have : det (traceMatrix K ↑b) ≠ 0 := by simp
147-
unfold discr
148-
convert this
149-
· have :=
150-
span_eq_top_of_linearIndependent_of_card_eq_finrank b.linearIndependent
151-
(finrank_eq_card_basis b).symm
152-
classical
153-
rw [discr_def, traceMatrix]
154-
simp_rw [← Basis.mk_apply b.linearIndependent this.ge]
155-
rw [← traceMatrix, traceMatrix_of_basis, ← BilinForm.nondegenerate_iff_det_ne_zero]
156-
exact traceForm_nondegenerate _ _
141+
rw [discr_def, traceMatrix_of_basis, ← BilinForm.nondegenerate_iff_det_ne_zero]
142+
exact traceForm_nondegenerate _ _
157143
#align algebra.discr_not_zero_of_basis Algebra.discr_not_zero_of_basis
158144

159145
/-- If `b` is a basis of a finite separable field extension `L/K`,

0 commit comments

Comments
 (0)