Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
Zhangir Azerbayev
squashed?
4365a98
raw
history blame
5.46 kB
/-
Copyright (c) 2019 Johannes HΓΆlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes HΓΆlzl, Patrick Massot, Casper Putz, Anne Baanen
-/
import linear_algebra.matrix.determinant
/-!
# Changing the index type of a matrix
This file concerns the map `matrix.reindex`, mapping a `m` by `n` matrix
to an `m'` by `n'` matrix, as long as `m ≃ m'` and `n ≃ n'`.
## Main definitions
* `matrix.reindex_linear_equiv R A`: `matrix.reindex` is an `R`-linear equivalence between
`A`-matrices.
* `matrix.reindex_alg_equiv R`: `matrix.reindex` is an `R`-algebra equivalence between `R`-matrices.
## Tags
matrix, reindex
-/
namespace matrix
open equiv
open_locale matrix
variables {l m n o : Type*} {l' m' n' o' : Type*} {m'' n'' : Type*}
variables (R A : Type*)
section add_comm_monoid
variables [semiring R] [add_comm_monoid A] [module R A]
/-- The natural map that reindexes a matrix's rows and columns with equivalent types,
`matrix.reindex`, is a linear equivalence. -/
def reindex_linear_equiv (eβ‚˜ : m ≃ m') (eβ‚™ : n ≃ n') : matrix m n A ≃ₗ[R] matrix m' n' A :=
{ map_add' := Ξ» _ _, rfl,
map_smul' := Ξ» _ _, rfl,
..(reindex eβ‚˜ eβ‚™)}
@[simp] lemma reindex_linear_equiv_apply
(eβ‚˜ : m ≃ m') (eβ‚™ : n ≃ n') (M : matrix m n A) :
reindex_linear_equiv R A eβ‚˜ eβ‚™ M = reindex eβ‚˜ eβ‚™ M :=
rfl
@[simp] lemma reindex_linear_equiv_symm (eβ‚˜ : m ≃ m') (eβ‚™ : n ≃ n') :
(reindex_linear_equiv R A eβ‚˜ eβ‚™).symm = reindex_linear_equiv R A eβ‚˜.symm eβ‚™.symm :=
rfl
@[simp] lemma reindex_linear_equiv_refl_refl :
reindex_linear_equiv R A (equiv.refl m) (equiv.refl n) = linear_equiv.refl R _ :=
linear_equiv.ext $ Ξ» _, rfl
lemma reindex_linear_equiv_trans (e₁ : m ≃ m') (eβ‚‚ : n ≃ n') (e₁' : m' ≃ m'')
(eβ‚‚' : n' ≃ n'') : (reindex_linear_equiv R A e₁ eβ‚‚).trans (reindex_linear_equiv R A e₁' eβ‚‚') =
(reindex_linear_equiv R A (e₁.trans e₁') (eβ‚‚.trans eβ‚‚') : _ ≃ₗ[R] _) :=
by { ext, refl }
lemma reindex_linear_equiv_comp (e₁ : m ≃ m') (eβ‚‚ : n ≃ n') (e₁' : m' ≃ m'')
(eβ‚‚' : n' ≃ n'') :
(reindex_linear_equiv R A e₁' eβ‚‚') ∘ (reindex_linear_equiv R A e₁ eβ‚‚)
= reindex_linear_equiv R A (e₁.trans e₁') (eβ‚‚.trans eβ‚‚') :=
by { rw [← reindex_linear_equiv_trans], refl }
lemma reindex_linear_equiv_comp_apply (e₁ : m ≃ m') (eβ‚‚ : n ≃ n') (e₁' : m' ≃ m'')
(eβ‚‚' : n' ≃ n'') (M : matrix m n A) :
(reindex_linear_equiv R A e₁' eβ‚‚') (reindex_linear_equiv R A e₁ eβ‚‚ M) =
reindex_linear_equiv R A (e₁.trans e₁') (eβ‚‚.trans eβ‚‚') M :=
minor_minor _ _ _ _ _
lemma reindex_linear_equiv_one [decidable_eq m] [decidable_eq m'] [has_one A]
(e : m ≃ m') : (reindex_linear_equiv R A e e (1 : matrix m m A)) = 1 :=
minor_one_equiv e.symm
end add_comm_monoid
section semiring
variables [semiring R] [semiring A] [module R A]
lemma reindex_linear_equiv_mul [fintype n] [fintype n']
(eβ‚˜ : m ≃ m') (eβ‚™ : n ≃ n') (eβ‚’ : o ≃ o') (M : matrix m n A) (N : matrix n o A) :
reindex_linear_equiv R A eβ‚˜ eβ‚™ M ⬝ reindex_linear_equiv R A eβ‚™ eβ‚’ N =
reindex_linear_equiv R A eβ‚˜ eβ‚’ (M ⬝ N) :=
minor_mul_equiv M N _ _ _
lemma mul_reindex_linear_equiv_one [fintype n] [fintype o] [decidable_eq o] (e₁ : o ≃ n)
(eβ‚‚ : o ≃ n') (M : matrix m n A) : M.mul (reindex_linear_equiv R A e₁ eβ‚‚ 1) =
reindex_linear_equiv R A (equiv.refl m) (e₁.symm.trans eβ‚‚) M :=
mul_minor_one _ _ _
end semiring
section algebra
variables [comm_semiring R] [fintype n] [fintype m] [decidable_eq m] [decidable_eq n]
/--
For square matrices with coefficients in commutative semirings, the natural map that reindexes
a matrix's rows and columns with equivalent types, `matrix.reindex`, is an equivalence of algebras.
-/
def reindex_alg_equiv (e : m ≃ n) : matrix m m R ≃ₐ[R] matrix n n R :=
{ to_fun := reindex e e,
map_mul' := Ξ» a b, (reindex_linear_equiv_mul R R e e e a b).symm,
commutes' := Ξ» r, by simp [algebra_map, algebra.to_ring_hom, minor_smul],
..(reindex_linear_equiv R R e e) }
@[simp] lemma reindex_alg_equiv_apply (e : m ≃ n) (M : matrix m m R) :
reindex_alg_equiv R e M = reindex e e M :=
rfl
@[simp] lemma reindex_alg_equiv_symm (e : m ≃ n) :
(reindex_alg_equiv R e).symm = reindex_alg_equiv R e.symm :=
rfl
@[simp] lemma reindex_alg_equiv_refl : reindex_alg_equiv R (equiv.refl m) = alg_equiv.refl :=
alg_equiv.ext $ Ξ» _, rfl
lemma reindex_alg_equiv_mul (e : m ≃ n) (M : matrix m m R) (N : matrix m m R) :
reindex_alg_equiv R e (M ⬝ N) = reindex_alg_equiv R e M ⬝ reindex_alg_equiv R e N :=
(reindex_alg_equiv R e).map_mul M N
end algebra
/-- Reindexing both indices along the same equivalence preserves the determinant.
For the `simp` version of this lemma, see `det_minor_equiv_self`.
-/
lemma det_reindex_linear_equiv_self [comm_ring R] [fintype m] [decidable_eq m]
[fintype n] [decidable_eq n] (e : m ≃ n) (M : matrix m m R) :
det (reindex_linear_equiv R R e e M) = det M :=
det_reindex_self e M
/-- Reindexing both indices along the same equivalence preserves the determinant.
For the `simp` version of this lemma, see `det_minor_equiv_self`.
-/
lemma det_reindex_alg_equiv [comm_ring R] [fintype m] [decidable_eq m] [fintype n] [decidable_eq n]
(e : m ≃ n) (A : matrix m m R) :
det (reindex_alg_equiv R e A) = det A :=
det_reindex_self e A
end matrix