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

Commit 0bcfff9

Browse files
feat(linear_algebra/basis) remove several [nontrivial R] (#7642)
We remove some unnecessary `nontrivial R`.
1 parent a51d1e0 commit 0bcfff9

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

src/linear_algebra/basis.lean

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@ repr_eq_iff'.mpr (λ i, by rw [h, b₂.repr_self])
230230

231231
end ext
232232

233+
section map
234+
235+
variables (f : M ≃ₗ[R] M')
236+
237+
/-- Apply the linear equivalence `f` to the basis vectors. -/
238+
protected def map : basis ι R M' :=
239+
of_repr (f.symm.trans b.repr)
240+
241+
@[simp] lemma map_apply (i) : b.map f i = f (b i) := rfl
242+
243+
end map
244+
233245
section reindex
234246

235247
variables (b' : basis ι' R M')
@@ -263,31 +275,44 @@ lemma range_reindex : set.range (b.reindex e) = set.range b :=
263275
by rw [coe_reindex, range_reindex']
264276

265277
/-- `b.reindex_range` is a basis indexed by `range b`, the basis vectors themselves. -/
266-
def reindex_range [nontrivial R] : basis (range b) R M :=
267-
b.reindex (equiv.of_injective b b.injective)
278+
def reindex_range : basis (range b) R M :=
279+
if h : nontrivial R then
280+
by letI := h; exact b.reindex (equiv.of_injective b (basis.injective b))
281+
else
282+
by letI : subsingleton R := not_nontrivial_iff_subsingleton.mp h; exact
283+
basis.of_repr (module.subsingleton_equiv R M (range b))
268284

269285
lemma finsupp.single_apply_left {α β γ : Type*} [has_zero γ]
270286
{f : α → β} (hf : function.injective f)
271287
(x z : α) (y : γ) :
272288
finsupp.single (f x) y (f z) = finsupp.single x y z :=
273289
by simp [finsupp.single_apply, hf.eq_iff]
274290

275-
lemma reindex_range_self [nontrivial R] (i : ι) (h := set.mem_range_self i) :
291+
lemma reindex_range_self (i : ι) (h := set.mem_range_self i) :
276292
b.reindex_range ⟨b i, h⟩ = b i :=
277-
by rw [reindex_range, reindex_apply, equiv.apply_of_injective_symm b b.injective, subtype.coe_mk]
293+
begin
294+
by_cases htr : nontrivial R,
295+
{ letI := htr,
296+
simp [htr, reindex_range, reindex_apply, equiv.apply_of_injective_symm b b.injective,
297+
subtype.coe_mk] },
298+
{ letI : subsingleton R := not_nontrivial_iff_subsingleton.mp htr,
299+
letI := module.subsingleton R M,
300+
simp [reindex_range] }
301+
end
278302

279-
lemma reindex_range_repr_self [nontrivial R] (i : ι) :
303+
lemma reindex_range_repr_self (i : ι) :
280304
b.reindex_range.repr (b i) = finsupp.single ⟨b i, mem_range_self i⟩ 1 :=
281305
calc b.reindex_range.repr (b i) = b.reindex_range.repr (b.reindex_range ⟨b i, mem_range_self i⟩) :
282306
congr_arg _ (b.reindex_range_self _ _).symm
283307
... = finsupp.single ⟨b i, mem_range_self i⟩ 1 : b.reindex_range.repr_self _
284308

285-
@[simp] lemma reindex_range_apply [nontrivial R] (x : range b) : b.reindex_range x = x :=
309+
@[simp] lemma reindex_range_apply (x : range b) : b.reindex_range x = x :=
286310
by { rcases x with ⟨bi, ⟨i, rfl⟩⟩, exact b.reindex_range_self i, }
287311

288-
lemma reindex_range_repr' [nontrivial R] (x : M) {bi : M} {i : ι} (h : b i = bi) :
312+
lemma reindex_range_repr' (x : M) {bi : M} {i : ι} (h : b i = bi) :
289313
b.reindex_range.repr x ⟨bi, ⟨i, h⟩⟩ = b.repr x i :=
290314
begin
315+
nontriviality,
291316
subst h,
292317
refine (b.repr_apply_eq (λ x i, b.reindex_range.repr x ⟨b i, _⟩) _ _ _ x i).symm,
293318
{ intros x y,
@@ -303,7 +328,7 @@ begin
303328
exact λ i j h, b.injective (subtype.mk.inj h) }
304329
end
305330

306-
@[simp] lemma reindex_range_repr [nontrivial R] (x : M) (i : ι) (h := set.mem_range_self i) :
331+
@[simp] lemma reindex_range_repr (x : M) (i : ι) (h := set.mem_range_self i) :
307332
b.reindex_range.repr x ⟨b i, h⟩ = b.repr x i :=
308333
b.reindex_range_repr' _ rfl
309334

@@ -400,18 +425,6 @@ b.ext' (λ i, by simp)
400425

401426
end equiv
402427

403-
section map
404-
405-
variables (f : M ≃ₗ[R] M')
406-
407-
/-- Apply the linear equivalence `f` to the basis vectors. -/
408-
protected def map : basis ι R M' :=
409-
of_repr (f.symm.trans b.repr)
410-
411-
@[simp] lemma map_apply (i) : b.map f i = f (b i) := rfl
412-
413-
end map
414-
415428
section prod
416429

417430
variables (b' : basis ι' R M')

src/linear_algebra/finsupp.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,14 @@ begin
809809
simp_rw ←exists_prop,
810810
exact finsupp.mem_span_iff_total R,
811811
end
812+
813+
/-- If `subsingleton R`, then `M ≃ₗ[R] ι →₀ R` for any type `ι`. -/
814+
@[simps]
815+
def module.subsingleton_equiv (R M ι: Type*) [semiring R] [subsingleton R] [add_comm_monoid M]
816+
[module R M] : M ≃ₗ[R] ι →₀ R :=
817+
{ to_fun := λ m, 0,
818+
inv_fun := λ f, 0,
819+
left_inv := λ m, by { letI := module.subsingleton R M, simp only [eq_iff_true_of_subsingleton] },
820+
right_inv := λ f, by simp only [eq_iff_true_of_subsingleton],
821+
map_add' := λ m n, (add_zero 0).symm,
822+
map_smul' := λ r m, (smul_zero r).symm }

src/linear_algebra/matrix/to_lin.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ linear_map.to_matrix_id v₁
307307
lemma matrix.to_lin_one : matrix.to_lin v₁ v₁ 1 = id :=
308308
by rw [← linear_map.to_matrix_id v₁, matrix.to_lin_to_matrix]
309309

310-
theorem linear_map.to_matrix_reindex_range [nontrivial R] [decidable_eq M₁] [decidable_eq M₂]
310+
theorem linear_map.to_matrix_reindex_range [decidable_eq M₁] [decidable_eq M₂]
311311
(f : M₁ →ₗ[R] M₂) (k : m) (i : n) :
312312
linear_map.to_matrix v₁.reindex_range v₂.reindex_range f
313313
⟨v₂ k, mem_range_self k⟩ ⟨v₁ i, mem_range_self i⟩ =
@@ -407,7 +407,7 @@ by simp_rw [linear_map.to_matrix_alg_equiv, alg_equiv.of_linear_equiv_apply,
407407
lemma matrix.to_lin_alg_equiv_one : matrix.to_lin_alg_equiv v₁ 1 = id :=
408408
by rw [← linear_map.to_matrix_alg_equiv_id v₁, matrix.to_lin_alg_equiv_to_matrix_alg_equiv]
409409

410-
theorem linear_map.to_matrix_alg_equiv_reindex_range [nontrivial R] [decidable_eq M₁]
410+
theorem linear_map.to_matrix_alg_equiv_reindex_range [decidable_eq M₁]
411411
(f : M₁ →ₗ[R] M₁) (k i : n) :
412412
linear_map.to_matrix_alg_equiv v₁.reindex_range f
413413
⟨v₁ k, mem_range_self k⟩ ⟨v₁ i, mem_range_self i⟩ =

0 commit comments

Comments
 (0)