Skip to content

Commit 2dcdfaa

Browse files
committed
feat: add an element to a linear indep family, more general version (#31515)
1 parent 45c3796 commit 2dcdfaa

File tree

11 files changed

+70
-56
lines changed

11 files changed

+70
-56
lines changed

Mathlib/Analysis/Normed/Unbundled/FiniteExtension.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ theorem exists_nonarchimedean_pow_mul_seminorm_of_finiteDimensional (hfd : Finit
181181
∃ f : AlgebraNorm K L, IsPowMul f ∧ (∀ (x : K), f ((algebraMap K L) x) = ‖x‖) ∧
182182
IsNonarchimedean f := by
183183
-- Choose a basis B = {1, e2,..., en} of the K-vector space L
184-
set h1 : LinearIndepOn K id ({1} : Set L) :=
185-
LinearIndepOn.id_singleton _ one_ne_zero
184+
have h1 : LinearIndepOn K id ({1} : Set L) := .singleton one_ne_zero
186185
set ι := { x // x ∈ LinearIndepOn.extend h1 (Set.subset_univ ({1} : Set L)) }
187186
set B : Basis ι K L := Basis.extend h1
188187
letI hfin : Fintype ι := FiniteDimensional.fintypeBasisIndex B

Mathlib/Geometry/Euclidean/Altitude.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ theorem affineSpan_pair_eq_altitude_iff {n : ℕ} [NeZero n] (s : Simplex ℝ P
129129
simpa using h
130130
· rw [finrank_direction_altitude, finrank_span_set_eq_card]
131131
· simp
132-
· exact LinearIndepOn.id_singleton _ <| by simpa using hne
132+
· exact .singleton <| by simpa using hne
133133

134134
/-- The foot of an altitude is the orthogonal projection of a vertex of a simplex onto the
135135
opposite face. -/

Mathlib/LinearAlgebra/AffineSpace/Independent.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ theorem affineIndependent_of_ne {p₁ p₂ : P} (h : p₁ ≠ p₂) : AffineInde
662662
· simp at hi
663663
· simp [i₁]
664664
haveI : Unique { x // x ≠ (0 : Fin 2) } := ⟨⟨i₁⟩, he'⟩
665-
apply linearIndependent_unique
665+
refine .of_subsingleton default ?_
666666
rw [he' default]
667667
simpa using h.symm
668668

Mathlib/LinearAlgebra/Dimension/Constructions.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ variable [StrongRankCondition F] [NoZeroSMulDivisors F E] [Nontrivial E]
535535
theorem Subalgebra.rank_bot : Module.rank F (⊥ : Subalgebra F E) = 1 :=
536536
(Subalgebra.toSubmoduleEquiv (⊥ : Subalgebra F E)).symm.rank_eq.trans <| by
537537
rw [Algebra.toSubmodule_bot, one_eq_span, rank_span_set, mk_singleton _]
538-
letI := Module.nontrivial F E
539-
exact LinearIndepOn.id_singleton _ one_ne_zero
538+
have := Module.nontrivial F E
539+
exact .singleton one_ne_zero
540540

541541
@[simp]
542542
theorem Subalgebra.finrank_bot : finrank F (⊥ : Subalgebra F E) = 1 :=

Mathlib/LinearAlgebra/Dimension/RankNullity.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ independent of the first one. -/
137137
theorem exists_linearIndependent_pair_of_one_lt_rank [StrongRankCondition R]
138138
[NoZeroSMulDivisors R M] (h : 1 < Module.rank R M) {x : M} (hx : x ≠ 0) :
139139
∃ y, LinearIndependent R ![x, y] := by
140-
obtain ⟨y, hy⟩ := exists_linearIndependent_snoc_of_lt_rank (linearIndependent_unique ![x] hx) h
140+
obtain ⟨y, hy⟩ := exists_linearIndependent_snoc_of_lt_rank (.of_subsingleton (v := ![x]) 0 hx) h
141141
have : Fin.snoc ![x] y = ![x, y] := by simp [Fin.snoc, ← List.ofFn_inj]
142142
rw [this] at hy
143143
exact ⟨y, hy⟩

Mathlib/LinearAlgebra/FiniteDimensional/Basic.lean

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,9 @@ section finrank_eq_one
532532
/-- A vector space with a nonzero vector `v` has dimension 1 iff `v` spans.
533533
-/
534534
theorem finrank_eq_one_iff_of_nonzero (v : V) (nz : v ≠ 0) :
535-
finrank K V = 1 ↔ span K ({v} : Set V) = ⊤ :=
536-
fun h => by simpa using (basisSingleton Unit h v nz).span_eq, fun s =>
537-
finrank_eq_card_basis
538-
(Basis.mk (LinearIndepOn.id_singleton _ nz)
539-
(by simp [← s]))⟩
535+
finrank K V = 1 ↔ span K ({v} : Set V) = ⊤ where
536+
mp h := by simpa using (basisSingleton Unit h v nz).span_eq
537+
mpr s := finrank_eq_card_basis <| .mk (.of_subsingleton (v := ![v]) 0 nz) <| by simp [← s]
540538

541539
/-- A module with a nonzero vector `v` has dimension 1 iff every vector is a multiple of `v`.
542540
-/

Mathlib/LinearAlgebra/LinearIndependent/Basic.lean

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,10 @@ alias LinearIndependent.linearCombination_ne_of_not_mem_support :=
272272

273273
end Subtype
274274

275-
section union
276-
277-
open LinearMap Finsupp
278-
279275
theorem LinearIndepOn.id_imageₛ {s : Set M} {f : M →ₗ[R] M'} (hs : LinearIndepOn R id s)
280276
(hf_inj : Set.InjOn f (span R s)) : LinearIndepOn R id (f '' s) :=
281277
id_image <| hs.map_injOn f (by simpa using hf_inj)
282278

283-
end union
284-
285279
theorem surjective_of_linearIndependent_of_span [Nontrivial R] (hv : LinearIndependent R v)
286280
(f : ι' ↪ ι) (hss : range v ⊆ span R (range (v ∘ f))) : Surjective f := by
287281
intro i
@@ -559,30 +553,21 @@ theorem linearIndependent_monoidHom (G : Type*) [MulOneClass G] (L : Type*) [Com
559553
end Module
560554

561555
section Nontrivial
556+
variable [Ring R] [AddCommGroup M] [Module R M] [Nontrivial R] [NoZeroSMulDivisors R M]
557+
{v : ι → M} {i : ι}
562558

563-
variable [Ring R] [Nontrivial R] [AddCommGroup M]
564-
variable [Module R M] [NoZeroSMulDivisors R M]
565-
variable {s t : Set M}
566-
567-
theorem linearIndependent_unique_iff (v : ι → M) [Unique ι] :
568-
LinearIndependent R v ↔ v default ≠ 0 := by
569-
simp only [linearIndependent_iff, Finsupp.linearCombination_unique, smul_eq_zero]
570-
refine ⟨fun h hv => ?_, fun hv l hl => Finsupp.unique_ext <| hl.resolve_right hv⟩
571-
have := h (Finsupp.single default 1) (Or.inr hv)
572-
exact one_ne_zero (Finsupp.single_eq_zero.1 this)
559+
lemma linearIndependent_unique_iff [Unique ι] : LinearIndependent R v ↔ v default ≠ 0 := by
560+
refine ⟨?_, .of_subsingleton _⟩
561+
simpa [linearIndependent_iff, Finsupp.linearCombination_unique, Finsupp.ext_iff,
562+
Unique.forall_iff, or_imp] using fun h hv ↦ by simpa using h (.single default 1) hv
573563

564+
@[deprecated LinearIndependent.of_subsingleton (since := "2025-11-11")]
574565
alias ⟨_, linearIndependent_unique⟩ := linearIndependent_unique_iff
575566

576567
variable (R) in
577568
@[simp]
578-
theorem linearIndepOn_singleton_iff {i : ι} {v : ι → M} : LinearIndepOn R v {i} ↔ v i ≠ 0 :=
579-
fun h ↦ h.ne_zero rfl, fun h ↦ linearIndependent_unique _ h⟩
580-
581-
alias ⟨_, LinearIndepOn.singleton⟩ := linearIndepOn_singleton_iff
582-
583-
variable (R) in
584-
theorem LinearIndepOn.id_singleton {x : M} (hx : x ≠ 0) : LinearIndepOn R id {x} :=
585-
linearIndependent_unique Subtype.val hx
569+
theorem linearIndepOn_singleton_iff : LinearIndepOn R v {i} ↔ v i ≠ 0 :=
570+
fun h ↦ h.ne_zero rfl, .singleton⟩
586571

587572
@[simp]
588573
theorem linearIndependent_subsingleton_index_iff [Subsingleton ι] (f : ι → M) :

Mathlib/LinearAlgebra/LinearIndependent/Defs.lean

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,9 @@ end Semiring
702702

703703
section Module
704704

705-
variable {v : ι → M}
706705
variable [Ring R] [AddCommGroup M] [AddCommGroup M']
707706
variable [Module R M] [Module R M']
707+
variable {v : ι → M} {i : ι}
708708

709709
theorem linearIndependent_iff_ker :
710710
LinearIndependent R v ↔ LinearMap.ker (Finsupp.linearCombination R v) = ⊥ :=
@@ -856,6 +856,29 @@ theorem linearIndependent_iff_eq_zero_of_smul_mem_span :
856856
simp [hij]
857857
· simp [hl]⟩
858858

859+
/-- Version of `LinearIndependent.of_subsingleton` that works for the zero ring. -/
860+
lemma LinearIndependent.of_subsingleton' [Subsingleton ι] (i : ι)
861+
(hi : ∀ r : R, r • v i = 0 → r = 0) : LinearIndependent R v := by
862+
let := uniqueOfSubsingleton i
863+
simpa [linearIndependent_iff, Finsupp.linearCombination_unique, Finsupp.ext_iff,
864+
Unique.forall_iff] using fun _ ↦ hi _
865+
866+
/-- Version of `LinearIndepOn.singleton` that works for the zero ring. -/
867+
@[simp]
868+
lemma LinearIndepOn.singleton' (hi : ∀ r : R, r • v i = 0 → r = 0) : LinearIndepOn R v {i} :=
869+
LinearIndependent.of_subsingleton' ⟨i, rfl⟩ hi
870+
871+
variable [NoZeroSMulDivisors R M]
872+
873+
lemma LinearIndependent.of_subsingleton [Subsingleton ι] (i : ι) (hi : v i ≠ 0) :
874+
LinearIndependent R v := .of_subsingleton' i (by simp [hi])
875+
876+
lemma LinearIndepOn.singleton (hi : v i ≠ 0) : LinearIndepOn R v {i} := by simp [hi]
877+
878+
variable (R) in
879+
@[deprecated LinearIndepOn.singleton (since := "2025-11-11")]
880+
lemma LinearIndepOn.id_singleton {x : M} (hx : x ≠ 0) : LinearIndepOn R id {x} := .singleton hx
881+
859882
end Module
860883

861884
/-!

Mathlib/LinearAlgebra/LinearIndependent/Lemmas.lean

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,19 @@ lemma LinearMap.bijective_of_linearIndependent_of_span_eq_top {N : Type*} [AddCo
480480
rw [Set.range_comp, ← Submodule.map_span, hv, Submodule.map_top] at hsp
481481
rwa [← range_eq_top]
482482

483+
/-- Version of `LinearIndepOn.insert` that works when the scalars are not a field. -/
484+
lemma LinearIndepOn.insert' {s : Set ι} {i : ι} (hs : LinearIndepOn R v s)
485+
(hx : ∀ r : R, r • v i ∈ Submodule.span R (v '' s) → r = 0) :
486+
LinearIndepOn R v (insert i s) := by
487+
rw [← Set.union_singleton]
488+
refine hs.union (.singleton' fun r hr ↦ hx _ <| by simp [hr]) ?_
489+
simp +contextual [disjoint_span_singleton'', hx]
490+
491+
/-- Version of `LinearIndepOn.id_insert` that works when the scalars are not a field. -/
492+
lemma LinearIndepOn.id_insert' {s : Set M} {x : M} (hs : LinearIndepOn R id s)
493+
(hx : ∀ r : R, r • x ∈ Submodule.span R s → r = 0) : LinearIndepOn R id (insert x s) :=
494+
hs.insert' <| by simpa
495+
483496
end Module
484497

485498
/-!
@@ -512,7 +525,7 @@ protected theorem LinearIndepOn.insert {s : Set ι} {x : ι} (hs : LinearIndepOn
512525
(hx : v x ∉ span K (v '' s)) : LinearIndepOn K v (insert x s) := by
513526
rw [← union_singleton]
514527
have x0 : v x ≠ 0 := fun h => hx (h ▸ zero_mem _)
515-
apply hs.union (LinearIndepOn.singleton _ x0)
528+
apply hs.union (LinearIndepOn.singleton x0)
516529
rwa [image_singleton, disjoint_span_singleton' x0]
517530

518531
protected theorem LinearIndepOn.id_insert (hs : LinearIndepOn K id s) (hx : x ∉ span K s) :
@@ -589,9 +602,8 @@ theorem LinearIndepOn.notMem_span_iff_id {s : Set V} {a : V} (h : LinearIndepOn
589602
alias LinearIndepOn.not_mem_span_iff_id := LinearIndepOn.notMem_span_iff_id
590603

591604
theorem linearIndepOn_id_pair {x y : V} (hx : x ≠ 0) (hy : ∀ a : K, a • x ≠ y) :
592-
LinearIndepOn K id {x, y} :=
593-
pair_comm y x ▸ (LinearIndepOn.id_singleton K hx).id_insert (x := y) <|
594-
mt mem_span_singleton.1 <| not_exists.2 hy
605+
LinearIndepOn K id {x, y} := by
606+
rw [pair_comm]; exact .id_insert (.singleton hx) <| by simpa [mem_span_singleton]
595607

596608
/-- `LinearIndepOn.pair_iff` is a version that works over arbitrary rings. -/
597609
theorem linearIndepOn_pair_iff {i j : ι} (v : ι → V) (hij : i ≠ j) (hi : v i ≠ 0) :

Mathlib/LinearAlgebra/Span/Basic.lean

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,11 @@ theorem map_strict_mono_of_ker_inf_eq {f : F} (hab : p < p')
589589
(q : LinearMap.ker f ⊓ p = LinearMap.ker f ⊓ p') : Submodule.map f p < Submodule.map f p' :=
590590
map_strict_mono_or_ker_sup_lt_ker_sup f hab |>.resolve_right q.not_lt
591591

592+
/-- Version of `disjoint_span_singleton` that works when the scalars are not a field. -/
593+
lemma disjoint_span_singleton'' {s : Submodule R M} {x : M} :
594+
Disjoint s (R ∙ x) ↔ ∀ r : R, r • x ∈ s → r • x = 0 := by
595+
rw [disjoint_comm]; simp +contextual [disjoint_def, mem_span_singleton]
596+
592597
end Ring
593598

594599
section DivisionRing
@@ -612,21 +617,14 @@ theorem covBy_span_singleton_sup {x : V} {s : Submodule K V} (h : x ∉ s) : Cov
612617
by simpa, (wcovBy_span_singleton_sup _ _).2
613618

614619
theorem disjoint_span_singleton : Disjoint s (K ∙ x) ↔ x ∈ s → x = 0 := by
615-
refine disjoint_def.trans ⟨fun H hx => H x hx <| subset_span <| mem_singleton x, ?_⟩
616-
intro H y hy hyx
617-
obtain ⟨c, rfl⟩ := mem_span_singleton.1 hyx
618-
by_cases hc : c = 0
619-
· rw [hc, zero_smul]
620-
· rw [s.smul_mem_iff hc] at hy
621-
rw [H hy, smul_zero]
620+
simpa +contextual [disjoint_span_singleton'', or_iff_not_imp_left, forall_swap (β := ¬_),
621+
s.smul_mem_iff] using ⟨fun h ↦ h _ one_ne_zero, fun h _ _ ↦ h⟩
622622

623-
theorem disjoint_span_singleton' (x0 : x ≠ 0) : Disjoint s (K ∙ x) ↔ x ∉ s :=
624-
disjoint_span_singleton.trans ⟨fun h₁ h₂ => x0 (h₁ h₂), fun h₁ h₂ => (h₁ h₂).elim⟩
623+
theorem disjoint_span_singleton' (hx : x ≠ 0) : Disjoint s (K ∙ x) ↔ x ∉ s := by
624+
simp [disjoint_span_singleton, hx]
625625

626626
lemma disjoint_span_singleton_of_notMem (hx : x ∉ s) : Disjoint s (K ∙ x) := by
627-
rw [disjoint_span_singleton]
628-
intro h
629-
contradiction
627+
simp [disjoint_span_singleton, hx]
630628

631629
@[deprecated (since := "2025-05-23")]
632630
alias disjoint_span_singleton_of_not_mem := disjoint_span_singleton_of_notMem

0 commit comments

Comments
 (0)