Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 018309f

Browse files
committed
chore(linear_algebra/basis): replace explicit arguments for 0 ≠ 1 with nontrivial R (#3678)
1 parent 6186c69 commit 018309f

File tree

6 files changed

+42
-37
lines changed

6 files changed

+42
-37
lines changed

archive/sensitivity.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ begin
369369
have hdW := dim_span li,
370370
rw set.range_restrict at hdW,
371371
convert hdW,
372-
rw [cardinal.mk_image_eq ((dual_pair_e_ε _).is_basis.injective zero_ne_one), cardinal.fintype_card] },
372+
rw [cardinal.mk_image_eq (dual_pair_e_ε _).is_basis.injective, cardinal.fintype_card] },
373373
rw ← findim_eq_dim ℝ at ⊢ dim_le dim_add dimW,
374374
rw [← findim_eq_dim ℝ, ← findim_eq_dim ℝ] at dim_add,
375375
norm_cast at ⊢ dim_le dim_add dimW,

src/linear_algebra/basis.lean

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ begin
125125
exact false.elim (not_nonempty_iff_imp_false.1 h i)
126126
end
127127

128-
lemma linear_independent.ne_zero
129-
{i : ι} (ne : 0 ≠ (1:R)) (hv : linear_independent R v) : v i ≠ 0 :=
130-
λ h, ne $ eq.symm begin
128+
lemma linear_independent.ne_zero [nontrivial R]
129+
{i : ι} (hv : linear_independent R v) : v i ≠ 0 :=
130+
λ h, @zero_ne_one R _ _ $ eq.symm begin
131131
suffices : (finsupp.single i 1 : ι →₀ R) i = 0, {simpa},
132132
rw linear_independent_iff.1 hv (finsupp.single i 1),
133133
{simp},
@@ -153,7 +153,7 @@ lemma linear_independent.unique (hv : linear_independent R v) {l₁ l₂ : ι
153153
finsupp.total ι M R v l₁ = finsupp.total ι M R v l₂ → l₁ = l₂ :=
154154
by apply linear_map.ker_eq_bot.1 hv
155155

156-
lemma linear_independent.injective (zero_ne_one : (0 : R) ≠ 1) (hv : linear_independent R v) :
156+
lemma linear_independent.injective [nontrivial R] (hv : linear_independent R v) :
157157
injective v :=
158158
begin
159159
intros i j hij,
@@ -254,12 +254,13 @@ lemma linear_independent.to_subtype_range
254254
begin
255255
by_cases zero_eq_one : (0 : R) = 1,
256256
{ apply linear_independent_of_zero_eq_one zero_eq_one },
257+
haveI : nontrivial R := ⟨⟨0, 1, zero_eq_one⟩⟩,
257258
rw linear_independent_subtype,
258259
intros l hl₁ hl₂,
259260
have h_bij : bij_on v (v ⁻¹' ↑l.support) ↑l.support,
260261
{ apply bij_on.mk,
261262
{ apply maps_to_preimage },
262-
{ apply (linear_independent.injective zero_eq_one hv).inj_on },
263+
{ apply (linear_independent.injective hv).inj_on },
263264
intros x hx,
264265
rcases mem_range.1 (((finsupp.mem_supported _ _).1 hl₁ : ↑(l.support) ⊆ range v) hx)
265266
with ⟨i, hi⟩,
@@ -424,12 +425,13 @@ lemma linear_independent_Union_finite {η : Type*} {ιs : η → Type*}
424425
begin
425426
by_cases zero_eq_one : (0 : R) = 1,
426427
{ apply linear_independent_of_zero_eq_one zero_eq_one },
428+
haveI : nontrivial R := ⟨⟨0, 1, zero_eq_one⟩⟩,
427429
apply linear_independent.of_subtype_range,
428430
{ rintros ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ hxy,
429431
by_cases h_cases : x₁ = y₁,
430432
subst h_cases,
431433
{ apply sigma.eq,
432-
rw linear_independent.injective zero_eq_one (hindep _) hxy,
434+
rw linear_independent.injective (hindep _) hxy,
433435
refl },
434436
{ have h0 : f x₁ x₂ = 0,
435437
{ apply disjoint_def.1 (hd x₁ {y₁} (finite_singleton y₁)
@@ -438,7 +440,7 @@ begin
438440
simp only at hxy,
439441
rw hxy,
440442
exact (subset_span (mem_range_self y₂)) },
441-
exact false.elim ((hindep x₁).ne_zero zero_eq_one h0) } },
443+
exact false.elim ((hindep x₁).ne_zero h0) } },
442444
rw range_sigma_eq_Union_range,
443445
apply linear_independent_Union_finite_subtype (λ j, (hindep j).to_subtype_range) hd,
444446
end
@@ -534,9 +536,9 @@ end⟩
534536

535537
end repr
536538

537-
lemma surjective_of_linear_independent_of_span
539+
lemma surjective_of_linear_independent_of_span [nontrivial R]
538540
(hv : linear_independent R v) (f : ι' ↪ ι)
539-
(hss : range v ⊆ span R (range (v ∘ f))) (zero_ne_one : 0 ≠ (1 : R)):
541+
(hss : range v ⊆ span R (range (v ∘ f))) :
540542
surjective f :=
541543
begin
542544
intros i,
@@ -559,12 +561,12 @@ begin
559561
exact hi'.2
560562
end
561563

562-
lemma eq_of_linear_independent_of_span_subtype {s t : set M} (zero_ne_one : (0 : R) ≠ 1)
564+
lemma eq_of_linear_independent_of_span_subtype [nontrivial R] {s t : set M}
563565
(hs : linear_independent R (λ x, x : s → M)) (h : t ⊆ s) (hst : s ⊆ span R t) : s = t :=
564566
begin
565567
let f : t ↪ s := ⟨λ x, ⟨x.1, h x.2⟩, λ a b hab, subtype.coe_injective (subtype.mk.inj hab)⟩,
566568
have h_surj : surjective f,
567-
{ apply surjective_of_linear_independent_of_span hs f _ zero_ne_one,
569+
{ apply surjective_of_linear_independent_of_span hs f _,
568570
convert hst; simp [f, comp], },
569571
show s = t,
570572
{ apply subset.antisymm _ h,
@@ -622,13 +624,14 @@ lemma linear_independent_inl_union_inr' {v : ι → M} {v' : ι' → M'}
622624
begin
623625
by_cases zero_eq_one : (0 : R) = 1,
624626
{ apply linear_independent_of_zero_eq_one zero_eq_one },
625-
have inj_v : injective v := (linear_independent.injective zero_eq_one hv),
626-
have inj_v' : injective v' := (linear_independent.injective zero_eq_one hv'),
627+
haveI : nontrivial R := ⟨⟨0, 1, zero_eq_one⟩⟩,
628+
have inj_v : injective v := (linear_independent.injective hv),
629+
have inj_v' : injective v' := (linear_independent.injective hv'),
627630
apply linear_independent.of_subtype_range,
628631
{ apply sum.elim_injective,
629632
{ exact inl_injective.comp inj_v },
630633
{ exact inr_injective.comp inj_v' },
631-
{ intros, simp [hv.ne_zero zero_eq_one] } },
634+
{ intros, simp [hv.ne_zero] } },
632635
{ rw sum.elim_range,
633636
refine (hv.image _).to_subtype_range.union (hv'.image _).to_subtype_range _;
634637
[simp, simp, skip],
@@ -703,21 +706,21 @@ have h4 : g a = 0, from calc
703706
-- Now we're done; the last two facts together imply that `g` vanishes on every element of `insert a s`.
704707
(finset.forall_mem_insert _ _ _).2 ⟨h4, h3⟩)
705708

706-
lemma le_of_span_le_span {s t u: set M} (zero_ne_one : (0 : R) ≠ 1)
709+
lemma le_of_span_le_span [nontrivial R] {s t u: set M}
707710
(hl : linear_independent R (coe : u → M )) (hsu : s ⊆ u) (htu : t ⊆ u)
708711
(hst : span R s ≤ span R t) : s ⊆ t :=
709712
begin
710-
have := eq_of_linear_independent_of_span_subtype zero_ne_one
713+
have := eq_of_linear_independent_of_span_subtype
711714
(hl.mono (set.union_subset hsu htu))
712715
(set.subset_union_right _ _)
713716
(set.union_subset (set.subset.trans subset_span hst) subset_span),
714717
rw ← this, apply set.subset_union_left
715718
end
716719

717-
lemma span_le_span_iff {s t u: set M} (zero_ne_one : (0 : R) ≠ 1)
720+
lemma span_le_span_iff [nontrivial R] {s t u: set M}
718721
(hl : linear_independent R (coe : u → M)) (hsu : s ⊆ u) (htu : t ⊆ u) :
719722
span R s ≤ span R t ↔ s ⊆ t :=
720-
⟨le_of_span_le_span zero_ne_one hl hsu htu, span_mono⟩
723+
⟨le_of_span_le_span hl hsu htu, span_mono⟩
721724

722725
variables (R) (v)
723726
/-- A family of vectors is a basis if it is linearly independent and all vectors are in the span. -/
@@ -737,8 +740,8 @@ begin
737740
{ rw[set.range_comp, range_iff_surjective.2 hf.2, image_univ, hv.2] }
738741
end
739742

740-
lemma is_basis.injective (hv : is_basis R v) (zero_ne_one : (0 : R) ≠ 1) : injective v :=
741-
λ x y h, linear_independent.injective zero_ne_one hv.1 h
743+
lemma is_basis.injective [nontrivial R] (hv : is_basis R v) : injective v :=
744+
λ x y h, linear_independent.injective hv.1 h
742745

743746
lemma is_basis.range (hv : is_basis R v) : is_basis R (λ x, x : range v → M) :=
744747
⟨hv.1.to_subtype_range, by { convert hv.2, ext i, exact ⟨λ ⟨p, hp⟩, hp ▸ p.2, λ hi, ⟨⟨i, hi⟩, rfl⟩⟩ }⟩
@@ -1082,7 +1085,7 @@ lemma exists_sum_is_basis (hs : linear_independent K v) :
10821085
begin
10831086
-- This is a hack: we jump through hoops to reuse `exists_subset_is_basis`.
10841087
let s := set.range v,
1085-
let e : ι ≃ s := equiv.set.range v (hs.injective zero_ne_one),
1088+
let e : ι ≃ s := equiv.set.range v hs.injective,
10861089
have : (λ x, x : s → V) = v ∘ e.symm := by { funext, dsimp, rw [equiv.set.apply_range_symm v], },
10871090
have : linear_independent K (λ x, x : s → V),
10881091
{ rw this,
@@ -1113,7 +1116,7 @@ have ∀t, ∀(s' : finset V), ↑s' ⊆ s → s ∩ ↑t = ∅ → s ⊆ (span
11131116
assume t, finset.induction_on t
11141117
(assume s' hs' _ hss',
11151118
have s = ↑s',
1116-
from eq_of_linear_independent_of_span_subtype zero_ne_one hs hs' $
1119+
from eq_of_linear_independent_of_span_subtype hs hs' $
11171120
by simpa using hss',
11181121
⟨s', by simp [this]⟩)
11191122
(assume b₁ t hb₁t ih s' hs' hst hss',

src/linear_algebra/dimension.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ theorem is_basis.le_span {v : ι → V} {J : set V} (hv : is_basis K v)
5353
(hJ : span K J = ⊤) : cardinal.mk (range v) ≤ cardinal.mk J :=
5454
begin
5555
cases le_or_lt cardinal.omega (cardinal.mk J) with oJ oJ,
56-
{ have := cardinal.mk_range_eq_of_injective (linear_independent.injective zero_ne_one hv.1),
56+
{ have := cardinal.mk_range_eq_of_injective (linear_independent.injective hv.1),
5757
let S : J → set ι := λ j, ↑(is_basis.repr hv j).support,
5858
let S' : J → set V := λ j, v '' S j,
5959
have hs : range v ⊆ ⋃ j, S' j,
@@ -94,14 +94,14 @@ begin
9494
apply le_antisymm,
9595
{ convert cardinal.lift_le.{u' (max w w')}.2 (hv.le_span hv'.2),
9696
{ rw cardinal.lift_max.{w u' w'},
97-
apply (cardinal.mk_range_eq_of_injective (hv.injective zero_ne_one)).symm, },
97+
apply (cardinal.mk_range_eq_of_injective hv.injective).symm, },
9898
{ rw cardinal.lift_max.{w' u' w},
99-
apply (cardinal.mk_range_eq_of_injective (hv'.injective zero_ne_one)).symm, }, },
99+
apply (cardinal.mk_range_eq_of_injective hv'.injective).symm, }, },
100100
{ convert cardinal.lift_le.{u' (max w w')}.2 (hv'.le_span hv.2),
101101
{ rw cardinal.lift_max.{w' u' w},
102-
apply (cardinal.mk_range_eq_of_injective (hv'.injective zero_ne_one)).symm, },
102+
apply (cardinal.mk_range_eq_of_injective hv'.injective).symm, },
103103
{ rw cardinal.lift_max.{w u' w'},
104-
apply (cardinal.mk_range_eq_of_injective (hv.injective zero_ne_one)).symm, }, }
104+
apply (cardinal.mk_range_eq_of_injective hv.injective).symm, }, }
105105
end
106106

107107
theorem is_basis.mk_range_eq_dim {v : ι → V} (h : is_basis K v) :
@@ -111,13 +111,13 @@ begin
111111
rcases this with ⟨v', e⟩,
112112
rw e,
113113
apply cardinal.lift_inj.1,
114-
rw cardinal.mk_range_eq_of_injective (h.injective zero_ne_one),
114+
rw cardinal.mk_range_eq_of_injective h.injective,
115115
convert @mk_eq_mk_of_basis _ _ _ _ _ _ _ _ _ h v'.property
116116
end
117117

118118
theorem is_basis.mk_eq_dim {v : ι → V} (h : is_basis K v) :
119119
cardinal.lift.{w u'} (cardinal.mk ι) = cardinal.lift.{u' w} (dim K V) :=
120-
by rw [←h.mk_range_eq_dim, cardinal.mk_range_eq_of_injective (h.injective zero_ne_one)]
120+
by rw [←h.mk_range_eq_dim, cardinal.mk_range_eq_of_injective h.injective]
121121

122122
variables [add_comm_group V₂] [vector_space K V₂]
123123

@@ -143,7 +143,7 @@ by rw [←cardinal.lift_inj, ← (@is_basis_singleton_one punit K _ _).mk_eq_dim
143143
lemma dim_span {v : ι → V} (hv : linear_independent K v) :
144144
dim K ↥(span K (range v)) = cardinal.mk (range v) :=
145145
by rw [←cardinal.lift_inj, ← (is_basis_span hv).mk_eq_dim,
146-
cardinal.mk_range_eq_of_injective (@linear_independent.injective ι K V v _ _ _ zero_ne_one hv)]
146+
cardinal.mk_range_eq_of_injective (@linear_independent.injective ι K V v _ _ _ _ hv)]
147147

148148
lemma dim_span_set {s : set V} (hs : linear_independent K (λ x, x : s → V)) :
149149
dim K ↥(span K s) = cardinal.mk s :=

src/linear_algebra/finite_dimensional.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ cardinality of the basis. -/
184184
lemma dim_eq_card_basis {ι : Type w} [fintype ι] {b : ι → V} (h : is_basis K b) :
185185
dim K V = fintype.card ι :=
186186
by rw [←h.mk_range_eq_dim, cardinal.fintype_card,
187-
set.card_range_of_injective (h.injective zero_ne_one)]
187+
set.card_range_of_injective h.injective]
188188

189189

190190
/-- If a vector space has a finite basis, then its dimension is equal to the cardinality of the

src/linear_algebra/matrix.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ theorem linear_equiv_matrix_range {ι κ M₁ M₂ : Type*}
213213
linear_equiv_matrix hv₁ hv₂ f k i :=
214214
if H : (0 : R) = 1 then eq_of_zero_eq_one H _ _ else
215215
begin
216+
haveI : nontrivial R := ⟨⟨0, 1, H⟩⟩,
216217
simp_rw [linear_equiv_matrix, linear_equiv.trans_apply, linear_equiv_matrix'_apply,
217-
← equiv.of_injective_apply _ (hv₁.injective H), ← equiv.of_injective_apply _ (hv₂.injective H),
218+
← equiv.of_injective_apply _ hv₁.injective, ← equiv.of_injective_apply _ hv₂.injective,
218219
to_matrix_of_equiv, ← linear_equiv.trans_apply, linear_equiv.arrow_congr_trans], congr' 3;
219220
refine function.left_inverse.injective linear_equiv.symm_symm _; ext x;
220221
simp_rw [linear_equiv.symm_trans_apply, equiv_fun_basis_symm_apply, fun_congr_left_symm,
221222
fun_congr_left_apply, fun_left_apply],
222-
convert (finset.sum_equiv (equiv.of_injective _ (hv₁.injective H)) _).symm,
223+
convert (finset.sum_equiv (equiv.of_injective _ hv₁.injective) _).symm,
223224
simp_rw [equiv.symm_apply_apply, equiv.of_injective_apply, subtype.coe_mk],
224-
convert (finset.sum_equiv (equiv.of_injective _ (hv₂.injective H)) _).symm,
225+
convert (finset.sum_equiv (equiv.of_injective _ hv₂.injective) _).symm,
225226
simp_rw [equiv.symm_apply_apply, equiv.of_injective_apply, subtype.coe_mk]
226227
end
227228

@@ -531,8 +532,9 @@ theorem trace_aux_range (R : Type u) [comm_ring R] {M : Type v} [add_comm_group
531532
trace_aux R hb.range = trace_aux R hb :=
532533
linear_map.ext $ λ f, if H : 0 = 1 then eq_of_zero_eq_one H _ _ else
533534
begin
535+
haveI : nontrivial R := ⟨⟨0, 1, H⟩⟩,
534536
change ∑ i : set.range b, _ = ∑ i : ι, _, simp_rw [matrix.diag_apply], symmetry,
535-
convert finset.sum_equiv (equiv.of_injective _ $ hb.injective H) _, ext i,
537+
convert finset.sum_equiv (equiv.of_injective _ hb.injective) _, ext i,
536538
exact (linear_equiv_matrix_range hb hb f i i).symm
537539
end
538540

src/ring_theory/noetherian.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ begin
351351
have : ∀ a b : ℕ, a ≤ b ↔
352352
span R ((coe ∘ f) '' {m | m ≤ a}) ≤ span R ((coe ∘ f) '' {m | m ≤ b}),
353353
{ assume a b,
354-
rw [span_le_span_iff zero_ne_one hs (this a) (this b),
354+
rw [span_le_span_iff hs (this a) (this b),
355355
set.image_subset_image_iff (subtype.coe_injective.comp f.injective),
356356
set.subset_def],
357357
exact ⟨λ hab x (hxa : x ≤ a), le_trans hxa hab, λ hx, hx a (le_refl a)⟩ },

0 commit comments

Comments
 (0)