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

Commit fdace95

Browse files
committed
feat(linear_algebra/matrix): generalize some is_basis.to_matrix results (#6127)
This PR contains some changes to the lemmas involving `is_basis.to_matrix`, allowing the bases involved to differ in their index type. Although you can prove there exists an `equiv` between those types, it's easier to not have to transport along that equiv. The PR also generalizes `linear_map.to_matrix_id` to a form with two different bases, `linear_map.to_matrix_id_eq_basis_to_matrix`. Marking the second as `simp` means the first can be proved automatically, hence the removal of `simp` on that one.
1 parent d405c5e commit fdace95

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/linear_algebra/matrix.lean

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ by rw [matrix.to_lin'_apply, hv₂.equiv_fun_symm_apply]
232232
by simp only [matrix.to_lin_apply, matrix.mul_vec, dot_product, hv₁.equiv_fun_self, mul_boole,
233233
finset.sum_ite_eq, finset.mem_univ, if_true]
234234

235-
@[simp]
235+
/-- This will be a special case of `linear_map.to_matrix_id_eq_basis_to_matrix`. -/
236236
lemma linear_map.to_matrix_id : linear_map.to_matrix hv₁ hv₁ id = 1 :=
237237
begin
238238
ext i j,
@@ -277,7 +277,7 @@ end to_matrix
277277

278278
section is_basis_to_matrix
279279

280-
variables {ι ι' : Type*} [fintype ι] [fintype ι']
280+
variables {ι ι' κ κ' : Type*} [fintype ι] [fintype ι'] [fintype κ] [fintype κ']
281281
variables {R M : Type*} [comm_ring R] [add_comm_group M] [module R M]
282282

283283
open function matrix
@@ -363,20 +363,42 @@ end is_basis
363363
section mul_linear_map_to_matrix
364364

365365
variables {N : Type*} [add_comm_group N] [module R N]
366-
variables {b : ι → M} {b' : ι' → M} {c : ι → N} {c' : ι' → N}
366+
variables {b : ι → M} {b' : ι' → M} {c : κ → N} {c' : κ' → N}
367367
variables (hb : is_basis R b) (hb' : is_basis R b') (hc : is_basis R c) (hc' : is_basis R c')
368368
variables (f : M →ₗ[R] N)
369369

370+
open linear_map
371+
370372
@[simp] lemma is_basis_to_matrix_mul_linear_map_to_matrix [decidable_eq ι'] :
371373
hc.to_matrix c' ⬝ linear_map.to_matrix hb' hc' f = linear_map.to_matrix hb' hc f :=
372374
(matrix.to_lin hb' hc).injective
373-
(by rw [to_lin_to_matrix, to_lin_mul hb' hc' hc, to_lin_to_matrix, hc.to_lin_to_matrix, id_comp])
375+
(by haveI := classical.dec_eq κ';
376+
rw [to_lin_to_matrix, to_lin_mul hb' hc' hc, to_lin_to_matrix, hc.to_lin_to_matrix, id_comp])
374377

375378
@[simp] lemma linear_map_to_matrix_mul_is_basis_to_matrix [decidable_eq ι] [decidable_eq ι'] :
376379
linear_map.to_matrix hb' hc' f ⬝ hb'.to_matrix b = linear_map.to_matrix hb hc' f :=
377380
(matrix.to_lin hb hc').injective
378381
(by rw [to_lin_to_matrix, to_lin_mul hb hb' hc', to_lin_to_matrix, hb'.to_lin_to_matrix, comp_id])
379382

383+
/-- A generalization of `linear_map.to_matrix_id`. -/
384+
@[simp] lemma linear_map.to_matrix_id_eq_basis_to_matrix [decidable_eq ι] :
385+
linear_map.to_matrix hb hb' id = hb'.to_matrix b :=
386+
by { haveI := classical.dec_eq ι',
387+
rw [← is_basis_to_matrix_mul_linear_map_to_matrix hb hb', to_matrix_id, matrix.mul_one] }
388+
389+
/-- A generalization of `is_basis.to_matrix_self`, in the opposite direction. -/
390+
@[simp] lemma is_basis.to_matrix_mul_to_matrix
391+
{ι'' : Type*} [fintype ι''] {b'' : ι'' → M} (hb'' : is_basis R b'') :
392+
hb.to_matrix b' ⬝ hb'.to_matrix b'' = hb.to_matrix b'' :=
393+
begin
394+
haveI := classical.dec_eq ι,
395+
haveI := classical.dec_eq ι',
396+
haveI := classical.dec_eq ι'',
397+
rw [← linear_map.to_matrix_id_eq_basis_to_matrix hb' hb,
398+
← linear_map.to_matrix_id_eq_basis_to_matrix hb'' hb',
399+
← to_matrix_comp, id_comp, linear_map.to_matrix_id_eq_basis_to_matrix],
400+
end
401+
380402
end mul_linear_map_to_matrix
381403

382404
end is_basis_to_matrix
@@ -387,7 +409,7 @@ section det
387409

388410
open linear_map matrix
389411

390-
variables {R : Type} [comm_ring R]
412+
variables {R : Type*} [comm_ring R]
391413
variables {M : Type*} [add_comm_group M] [module R M]
392414
variables {M' : Type*} [add_comm_group M'] [module R M']
393415
variables {ι : Type*} [decidable_eq ι] [fintype ι] {v : ι → M} {v' : ι → M'}

0 commit comments

Comments
 (0)