Linear maps and matrices #
This file defines the maps to send matrices to a linear map, and to send linear maps between modules with a finite bases to matrices. This defines a linear equivalence between linear maps between finite-dimensional vector spaces and matrices indexed by the respective bases.
Main definitions #
In the list below, and in all this file, R
is a commutative ring (semiring
is sometimes enough), M
and its variations are R
-modules, ι
, κ
, n
and m
are finite
types used for indexing.
LinearMap.toMatrix
: given basesv₁ : ι → M₁
andv₂ : κ → M₂
, theR
-linear equivalence fromM₁ →ₗ[R] M₂
toMatrix κ ι R
Matrix.toLin
: the inverse ofLinearMap.toMatrix
LinearMap.toMatrix'
: theR
-linear equivalence from(m → R) →ₗ[R] (n → R)
toMatrix m n R
(with the standard basis onm → R
andn → R
)Matrix.toLin'
: the inverse ofLinearMap.toMatrix'
algEquivMatrix
: given a basis indexed byn
, theR
-algebra equivalence betweenR
-endomorphisms ofM
andMatrix n n R
Issues #
This file was originally written without attention to non-commutative rings, and so mostly only works in the commutative setting. This should be fixed.
In particular, Matrix.mulVec
gives us a linear equivalence
Matrix m n R ≃ₗ[R] (n → R) →ₗ[Rᵐᵒᵖ] (m → R)
while Matrix.vecMul
gives us a linear equivalence
Matrix m n R ≃ₗ[Rᵐᵒᵖ] (m → R) →ₗ[R] (n → R)
.
At present, the first equivalence is developed in detail but only for commutative rings
(and we omit the distinction between Rᵐᵒᵖ
and R
),
while the second equivalence is developed only in brief, but for not-necessarily-commutative rings.
Naming is slightly inconsistent between the two developments.
In the original (commutative) development linear
is abbreviated to lin
,
although this is not consistent with the rest of mathlib.
In the new (non-commutative) development linear
is not abbreviated, and declarations use _right
to indicate they use the right action of matrices on vectors (via Matrix.vecMul
).
When the two developments are made uniform, the names should be made uniform, too,
by choosing between linear
and lin
consistently,
and (presumably) adding _left
where necessary.
Tags #
linear_map, matrix, linear_equiv, diagonal, det, trace
Matrix.vecMul M
is a linear map.
Equations
- M.vecMulLinear = { toFun := fun (x : m → R) => Matrix.vecMul x M, map_add' := ⋯, map_smul' := ⋯ }
Instances For
Linear maps (m → R) →ₗ[R] (n → R)
are linearly equivalent over Rᵐᵒᵖ
to Matrix m n R
,
by having matrices act by right multiplication.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A Matrix m n R
is linearly equivalent over Rᵐᵒᵖ
to a linear map (m → R) →ₗ[R] (n → R)
,
by having matrices act by right multiplication.
Equations
- Matrix.toLinearMapRight' = LinearMap.toMatrixRight'.symm
Instances For
If M
and M'
are each other's inverse matrices, they provide an equivalence between n → A
and m → A
corresponding to M.vecMul
and M'.vecMul
.
Equations
- Matrix.toLinearEquivRight'OfInv hMM' hM'M = { toFun := ⇑(Matrix.toLinearMapRight' M'), map_add' := ⋯, map_smul' := ⋯, invFun := ⇑(Matrix.toLinearMapRight' M), left_inv := ⋯, right_inv := ⋯ }
Instances For
From this point on, we only work with commutative rings,
and fail to distinguish between Rᵐᵒᵖ
and R
.
This should eventually be remedied.
Matrix.mulVec M
is a linear map.
Equations
- M.mulVecLin = { toFun := M.mulVec, map_add' := ⋯, map_smul' := ⋯ }
Instances For
A variant of Matrix.mulVecLin_submatrix
that keeps around LinearEquiv
s.
Linear maps (n → R) →ₗ[R] (m → R)
are linearly equivalent to Matrix m n R
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A Matrix m n R
is linearly equivalent to a linear map (n → R) →ₗ[R] (m → R)
.
Note that the forward-direction does not require DecidableEq
and is Matrix.vecMulLin
.
Equations
- Matrix.toLin' = LinearMap.toMatrix'.symm
Instances For
A variant of Matrix.toLin'_submatrix
that keeps around LinearEquiv
s.
Shortcut lemma for Matrix.toLin'_mul
and LinearMap.comp_apply
If M
and M'
are each other's inverse matrices, they provide an equivalence between m → A
and n → A
corresponding to M.mulVec
and M'.mulVec
.
Equations
- Matrix.toLin'OfInv hMM' hM'M = { toFun := ⇑(Matrix.toLin' M'), map_add' := ⋯, map_smul' := ⋯, invFun := ⇑(Matrix.toLin' M), left_inv := ⋯, right_inv := ⋯ }
Instances For
Linear maps (n → R) →ₗ[R] (n → R)
are algebra equivalent to Matrix n n R
.
Equations
- LinearMap.toMatrixAlgEquiv' = AlgEquiv.ofLinearEquiv LinearMap.toMatrix' ⋯ ⋯
Instances For
A Matrix n n R
is algebra equivalent to a linear map (n → R) →ₗ[R] (n → R)
.
Equations
- Matrix.toLinAlgEquiv' = LinearMap.toMatrixAlgEquiv'.symm
Instances For
Given bases of two modules M₁
and M₂
over a commutative ring R
, we get a linear
equivalence between linear maps M₁ →ₗ M₂
and matrices over R
indexed by the bases.
Equations
- LinearMap.toMatrix v₁ v₂ = (v₁.equivFun.arrowCongr v₂.equivFun).trans LinearMap.toMatrix'
Instances For
LinearMap.toMatrix'
is a particular case of LinearMap.toMatrix
, for the standard basis
Pi.basisFun R n
.
Given bases of two modules M₁
and M₂
over a commutative ring R
, we get a linear
equivalence between matrices over R
indexed by the bases and linear maps M₁ →ₗ M₂
.
Equations
- Matrix.toLin v₁ v₂ = (LinearMap.toMatrix v₁ v₂).symm
Instances For
Matrix.toLin'
is a particular case of Matrix.toLin
, for the standard basis
Pi.basisFun R n
.
This will be a special case of LinearMap.toMatrix_id_eq_basis_toMatrix
.
Shortcut lemma for Matrix.toLin_mul
and LinearMap.comp_apply
.
If M
and M
are each other's inverse matrices, Matrix.toLin M
and Matrix.toLin M'
form a linear equivalence.
Equations
- Matrix.toLinOfInv v₁ v₂ hMM' hM'M = { toFun := ⇑((Matrix.toLin v₁ v₂) M), map_add' := ⋯, map_smul' := ⋯, invFun := ⇑((Matrix.toLin v₂ v₁) M'), left_inv := ⋯, right_inv := ⋯ }
Instances For
Given a basis of a module M₁
over a commutative ring R
, we get an algebra
equivalence between linear maps M₁ →ₗ M₁
and square matrices over R
indexed by the basis.
Equations
- LinearMap.toMatrixAlgEquiv v₁ = AlgEquiv.ofLinearEquiv (LinearMap.toMatrix v₁ v₁) ⋯ ⋯
Instances For
Given a basis of a module M₁
over a commutative ring R
, we get an algebra
equivalence between square matrices over R
indexed by the basis and linear maps M₁ →ₗ M₁
.
Equations
- Matrix.toLinAlgEquiv v₁ = (LinearMap.toMatrixAlgEquiv v₁).symm
Instances For
leftMulMatrix b x
is the matrix corresponding to the linear map fun y ↦ x * y
.
leftMulMatrix_eq_repr_mul
gives a formula for the entries of leftMulMatrix
.
This definition is useful for doing (more) explicit computations with LinearMap.mulLeft
,
such as the trace form or norm map for algebras.
Equations
- Algebra.leftMulMatrix b = { toFun := fun (x : S) => (LinearMap.toMatrix b b) ((Algebra.lmul R S) x), map_one' := ⋯, map_mul' := ⋯, map_zero' := ⋯, map_add' := ⋯, commutes' := ⋯ }
Instances For
The natural equivalence between linear endomorphisms of finite free modules and square matrices is compatible with the algebra structures.
Equations
- algEquivMatrix' = { toFun := (↑LinearMap.toMatrix').toFun, invFun := LinearMap.toMatrix'.invFun, left_inv := ⋯, right_inv := ⋯, map_mul' := ⋯, map_add' := ⋯, commutes' := ⋯ }
Instances For
A linear equivalence of two modules induces an equivalence of algebras of their endomorphisms.
Equations
- e.algConj = { toFun := (↑e.conj).toFun, invFun := e.conj.invFun, left_inv := ⋯, right_inv := ⋯, map_mul' := ⋯, map_add' := ⋯, commutes' := ⋯ }
Instances For
A basis of a module induces an equivalence of algebras from the endomorphisms of the module to square matrices.
Equations
- algEquivMatrix h = h.equivFun.algConj.trans algEquivMatrix'
Instances For
The standard basis of the space linear maps between two modules induced by a basis of the domain and codomain.
If M₁
and M₂
are modules with basis b₁
and b₂
respectively indexed
by finite types ι₁
and ι₂
,
then Basis.linearMap b₁ b₂
is the basis of M₁ →ₗ[R] M₂
indexed by ι₂ × ι₁
where (i, j)
indexes the linear map that sends b j
to b i
and sends all other basis vectors to 0
.
Equations
- b₁.linearMap b₂ = (Matrix.stdBasis R ι₂ ι₁).map (LinearMap.toMatrix b₁ b₂).symm
Instances For
The standard basis of the endomorphism algebra of a module induced by a basis of the module.
If M
is a module with basis b
indexed by a finite type ι
,
then Basis.end b
is the basis of Module.End R M
indexed by ι × ι
where (i, j)
indexes the linear map that sends b j
to b i
and sends all other basis vectors to 0
.
Equations
- b.end = b.linearMap b
Instances For
Let M
be an A
-module. Every A
-linear map Mⁿ → Mⁿ
corresponds to a n×n
-matrix whose entries
are A
-linear maps M → M
. In another word, we haveEnd(Mⁿ) ≅ Matₙₓₙ(End(M))
defined by:
(f : Mⁿ → Mⁿ) ↦ (x ↦ f (0, ..., x at j-th position, ..., 0) i)ᵢⱼ
and
m : Matₙₓₙ(End(M)) ↦ (v ↦ ∑ⱼ mᵢⱼ(vⱼ))
.
See also LinearMap.toMatrix'
Equations
- One or more equations did not get rendered due to their size.
Instances For
Let M
be an A
-module. Every A
-linear map Mⁿ → Mⁿ
corresponds to a n×n
-matrix whose entries
are R
-linear maps M → M
. In another word, we haveEnd(Mⁿ) ≅ Matₙₓₙ(End(M))
defined by:
(f : Mⁿ → Mⁿ) ↦ (x ↦ f (0, ..., x at j-th position, ..., 0) i)ᵢⱼ
and
m : Matₙₓₙ(End(M)) ↦ (v ↦ ∑ⱼ mᵢⱼ(vⱼ))
.
See also LinearMap.toMatrix'
Equations
- endVecAlgEquivMatrixEnd ι R A M = { toEquiv := (endVecRingEquivMatrixEnd ι A M).toEquiv, map_mul' := ⋯, map_add' := ⋯, commutes' := ⋯ }