Linear algebra #
This file defines the basics of linear algebra. It sets up the "categorical/lattice structure" of modules over a ring, submodules, and linear maps.
Many of the relevant definitions, including module
, submodule
, and linear_map
, are found in
src/algebra/module
.
Main definitions #
- Many constructors for (semi)linear maps
submodule.span s
is defined to be the smallest submodule containing the sets
.- The kernel
ker
and rangerange
of a linear map are submodules of the domain and codomain respectively. - The general linear group is defined to be the group of invertible linear maps from
M
to itself.
See linear_algebra.quotient
for quotients by submodules.
Main theorems #
See linear_algebra.isomorphisms
for Noether's three isomorphism theorems for modules.
Notations #
- We continue to use the notations
M →ₛₗ[σ] M₂
andM →ₗ[R] M₂
for the type of semilinear (resp. linear) maps fromM
toM₂
over the ring homomorphismσ
(resp. over the ringR
). - We introduce the notation
R ∙ v
for the span of a singleton,submodule.span R {v}
. This is\.
, not the same as the scalar multiplication•
/\bub
.
Implementation notes #
We note that, when constructing linear maps, it is convenient to use operations defined on bundled
maps (linear_map.prod
, linear_map.coprod
, arithmetic operations like +
) instead of defining a
function and proving it is linear.
TODO #
- Parts of this file have not yet been generalized to semilinear maps
Tags #
linear algebra, vector space, module
Given fintype α
, linear_equiv_fun_on_fintype R
is the natural R
-linear equivalence between
α →₀ β
and α → β
.
Equations
- finsupp.linear_equiv_fun_on_fintype R M α = {to_fun := coe_fn finsupp.has_coe_to_fun, map_add' := _, map_smul' := _, inv_fun := finsupp.equiv_fun_on_fintype.inv_fun, left_inv := _, right_inv := _}
Properties of linear maps #
The restriction of a linear map f : M → M₂
to a submodule p ⊆ M
gives a linear map
p → M₂
.
Equations
- f.dom_restrict p = f.comp p.subtype
A linear map f : M₂ → M
whose values lie in a submodule p ⊆ M
can be restricted to a
linear map M₂ → p.
Restrict domain and codomain of an endomorphism.
Equations
- f.restrict hf = linear_map.cod_restrict p (f.dom_restrict p) _
Equations
- linear_map.unique_of_left = {to_inhabited := {default := default (M →ₛₗ[σ₁₂] M₂) linear_map.inhabited}, uniq := _}
Evaluation of a σ₁₂
-linear map at a fixed a
, as an add_monoid_hom
.
linear_map.to_add_monoid_hom
promoted to an add_monoid_hom
Equations
- linear_map.to_add_monoid_hom' = {to_fun := linear_map.to_add_monoid_hom σ₁₂, map_zero' := _, map_add' := _}
When f
is an R
-linear map taking values in S
, then λb, f b • x
is an R
-linear map.
A linear map f
applied to x : ι → R
can be computed using the image under f
of elements
of the canonical basis.
Applying a linear map at v : M
, seen as S
-linear map from M →ₗ[R] M₂
to M₂
.
See linear_map.applyₗ
for a version where S = R
.
The equivalence between R-linear maps from R
to M
, and points of M
itself.
This says that the forgetful functor from R
-modules to types is representable, by R
.
This as an S
-linear equivalence, under the assumption that S
acts on M
commuting with R
.
When R
is commutative, we can take this to be the usual action with S = R
.
Otherwise, S = ℕ
shows that the equivalence is additive.
See note [bundled maps over different rings].
Composition by f : M₂ → M₃
is a linear map from the space of linear maps M → M₂
to the space of linear maps M₂ → M₃
.
Applying a linear map at v : M
, seen as a linear map from M →ₗ[R] M₂
to M₂
.
See also linear_map.applyₗ'
for a version that works with two different semirings.
This is the linear_map
version of add_monoid_hom.eval
.
Alternative version of dom_restrict
as a linear map.
Equations
- linear_map.dom_restrict' p = {to_fun := λ (φ : M →ₗ[R] M₂), φ.dom_restrict p, map_add' := _, map_smul' := _}
The family of linear maps M₂ → M
parameterised by f ∈ M₂ → R
, x ∈ M
, is linear in f
, x
.
The R
-linear equivalence between additive morphisms A →+ B
and ℕ
-linear morphisms A →ₗ[ℕ] B
.
Equations
- add_monoid_hom_lequiv_nat R = {to_fun := add_monoid_hom.to_nat_linear_map _inst_3, map_add' := _, map_smul' := _, inv_fun := linear_map.to_add_monoid_hom (ring_hom.id ℕ), left_inv := _, right_inv := _}
The R
-linear equivalence between additive morphisms A →+ B
and ℤ
-linear morphisms A →ₗ[ℤ] B
.
Equations
- add_monoid_hom_lequiv_int R = {to_fun := add_monoid_hom.to_int_linear_map _inst_3, map_add' := _, map_smul' := _, inv_fun := linear_map.to_add_monoid_hom (ring_hom.id ℤ), left_inv := _, right_inv := _}
Properties of submodules #
If two submodules p
and p'
satisfy p ⊆ p'
, then of_le p p'
is the linear map version of
this inclusion.
Equations
- submodule.of_le h = linear_map.cod_restrict p' p.subtype _
Equations
- submodule.unique = {to_inhabited := {default := ⊥}, uniq := _}
Equations
The pushforward of a submodule p ⊆ M
by f : M → M₂
The pushforward of a submodule by an injective linear map is linearly equivalent to the original submodule.
The pullback of a submodule p ⊆ M₂
along f : M → M₂
map f
and comap f
form a galois_insertion
when f
is surjective.
Equations
map f
and comap f
form a galois_coinsertion
when f
is injective.
Equations
The infimum of a family of invariant submodule of an endomorphism is also an invariant submodule.
The span of a set s ⊆ M
is the smallest submodule of M that contains s
.
A version of submodule.span_eq
for when the span is by a smaller ring.
Alias of submodule.map_span
.
Alias of submodule.map_span_le
.
Alias of submodule.span_preimage_le
.
An induction principle for span membership. If p
holds for 0 and all elements of s
, and is
preserved under addition and scalar multiplication, then p
holds for all elements of the span of
s
.
The difference with submodule.span_induction
is that this acts on the subtype.
span
forms a Galois insertion with the coercion from submodule to set.
Equations
- submodule.gi R M = {choice := λ (s : set M) (_x : ↑(submodule.span R s) ≤ s), submodule.span R s, gc := _, le_l_u := _, choice_eq := _}
See submodule.span_smul_eq
(in ring_theory.ideal.operations
) for
span R (r • s) = r • span R s
that holds for arbitrary r
in a comm_semiring
.
We can regard coe_supr_of_chain
as the statement that coe : (submodule R M) → set M
is
Scott continuous for the ω-complete partial order induced by the complete lattice structures.
If R
is "smaller" ring than S
then the span by R
is smaller than the span by S
.
A version of submodule.span_le_restrict_scalars
with coercions.
Taking the span by a large ring of the span by the small ring is the same as taking the span by just the large ring.
f
is an explicit argument so we can apply
this theorem and obtain h
as a new goal.
For every element in the span of a set, there exists a finite subset of the set such that the element is contained in the span of the subset.
The product of two submodules is a submodule.
Properties of linear maps #
If two linear maps are equal on a set s
, then they are equal on submodule.span s
.
See also linear_map.eq_on_span'
for a version using set.eq_on
.
If two linear maps are equal on a set s
, then they are equal on submodule.span s
.
This version uses set.eq_on
, and the hidden argument will expand to h : x ∈ (span R s : set M)
.
See linear_map.eq_on_span
for a version that takes h : x ∈ span R s
as an argument.
If s
generates the whole module and linear maps f
, g
are equal on s
, then they are
equal.
If the range of v : ι → M
generates the whole module and linear maps f
, g
are equal at
each v i
, then they are equal.
The range of a linear map f : M → M₂
is a submodule of M₂
.
See Note [range copy pattern].
The decreasing sequence of submodules consisting of the ranges of the iterates of a linear map.
Restrict the codomain of a linear map f
to f.range
.
This is the bundled version of set.range_factorization
.
Equations
- f.range_restrict = linear_map.cod_restrict f.range f _
The range of a linear map is finite if the domain is finite.
Note: this instance can form a diamond with subtype.fintype
in the
presence of fintype M₂
.
Equations
Given an element x
of a module M
over R
, the natural map from
R
to scalar multiples of x
.
Equations
The range of to_span_singleton x
is the span of x
.
The kernel of a linear map f : M → M₂
is defined to be comap f ⊥
. This is equivalent to the
set of x : M
such that f x = 0
. The kernel is a submodule of M
.
Equations
- f.ker = submodule.comap f ⊥
The increasing sequence of submodules consisting of the kernels of the iterates of a linear map.
Under the canonical linear map from a submodule p
to the ambient space M
, the image of the
maximal submodule of p
is just p
.
If N ⊆ M
then submodules of N
are the same as submodules of M
contained in N
Equations
- submodule.map_subtype.rel_iso p = {to_equiv := {to_fun := λ (p' : submodule R ↥p), ⟨submodule.map p.subtype p', _⟩, inv_fun := λ (q : {p' // p' ≤ p}), submodule.comap p.subtype ↑q, left_inv := _, right_inv := _}, map_rel_iff' := _}
If p ⊆ M
is a submodule, the ordering of submodules of p
is embedded in the ordering of
submodules of M
.
Equations
- submodule.map_subtype.order_embedding p = (rel_iso.to_rel_embedding (submodule.map_subtype.rel_iso p)).trans (subtype.rel_embedding has_le.le (λ (p' : submodule R M), p' ≤ p))
A monomorphism is injective.
If O
is a submodule of M
, and Φ : O →ₗ M'
is a linear map,
then (ϕ : O →ₗ M').submodule_image N
is ϕ(N)
as a submodule of M'
Equations
- ϕ.submodule_image N = submodule.map ϕ (submodule.comap O.subtype N)
Linear equivalences #
Between two zero modules, the zero map is an equivalence.
Between two zero modules, the zero map is the only equivalence.
Equations
- linear_equiv.unique = {to_inhabited := {default := 0}, uniq := _}
A linear equivalence of two modules restricts to a linear equivalence from any submodule
p
of the domain onto the image of that submodule.
This is linear_equiv.of_submodule'
but with map
on the right instead of comap
on the left.
Equations
- e.of_submodule p = {to_fun := (linear_map.cod_restrict (submodule.map ↑e p) (↑e.dom_restrict p) _).to_fun, map_add' := _, map_smul' := _, inv_fun := λ (y : ↥(submodule.map ↑e p)), ⟨⇑↑(e.symm) ↑y, _⟩, left_inv := _, right_inv := _}
Linear equivalence between a curried and uncurried function.
Differs from tensor_product.curry
.
Equations
- linear_equiv.curry R V V₂ = {to_fun := (equiv.curry V V₂ R).to_fun, map_add' := _, map_smul' := _, inv_fun := (equiv.curry V V₂ R).inv_fun, left_inv := _, right_inv := _}
Linear equivalence between two equal submodules.
Equations
- linear_equiv.of_eq p q h = {to_fun := (equiv.set.of_eq _).to_fun, map_add' := _, map_smul' := _, inv_fun := (equiv.set.of_eq _).inv_fun, left_inv := _, right_inv := _}
A linear equivalence which maps a submodule of one module onto another, restricts to a linear equivalence of the two submodules.
Equations
- e.of_submodules p q h = (e.of_submodule p).trans (linear_equiv.of_eq (submodule.map ↑e p) q h)
A linear equivalence of two modules restricts to a linear equivalence from the preimage of any submodule to that submodule.
This is linear_equiv.of_submodule
but with comap
on the left instead of map
on the right.
Equations
- f.of_submodule' U = (f.symm.of_submodules U (submodule.comap ↑(f.symm.symm) U) _).symm
The top submodule of M
is linearly equivalent to M
.
If a linear map has an inverse, it is a linear equivalence.
An linear map f : M →ₗ[R] M₂
with a left-inverse g : M₂ →ₗ[R] M
defines a linear
equivalence between M
and f.range
.
This is a computable alternative to linear_equiv.of_injective
, and a bidirectional version of
linear_map.range_restrict
.
An injective
linear map f : M →ₗ[R] M₂
defines a linear equivalence
between M
and f.range
. See also linear_map.of_left_inverse
.
Equations
A bijective linear map is a linear equivalence.
Equations
- linear_equiv.of_bijective f hf₁ hf₂ = (linear_equiv.of_injective f hf₁).trans (linear_equiv.of_top f.range _)
Multiplying by a unit a
of the ring R
is a linear equivalence.
Equations
- linear_equiv.smul_of_unit a = linear_equiv.of_linear (↑a • 1) (↑a⁻¹ • 1) _ _
A linear isomorphism between the domains and codomains of two spaces of linear maps gives a linear isomorphism between the two function spaces.
If M₂
and M₃
are linearly isomorphic then the two spaces of linear maps from M
into M₂
and M
into M₃
are linearly isomorphic.
Equations
- f.congr_right = (linear_equiv.refl R M).arrow_congr f
If M
and M₂
are linearly isomorphic then the two spaces of linear maps from M
and M₂
to
themselves are linearly isomorphic.
Equations
- e.conj = e.arrow_congr e
Multiplying by a nonzero element a
of the field K
is a linear equivalence.
Equations
- linear_equiv.smul_of_ne_zero K M a ha = linear_equiv.smul_of_unit (units.mk0 a ha)
Given a nonzero element x
of a vector space M
over a field K
, the natural
map from K
to the span of x
, with invertibility check to consider it as an
isomorphism.
Equations
- linear_equiv.to_span_nonzero_singleton K M x h = (linear_equiv.of_injective (linear_map.to_span_singleton K M x) _).trans (linear_equiv.of_eq (linear_map.to_span_singleton K M x).range (submodule.span K {x}) _)
Given a nonzero element x
of a vector space M
over a field K
, the natural map
from the span of x
to K
.
Given p
a submodule of the module M
and q
a submodule of p
, p.equiv_subtype_map q
is the natural linear_equiv
between q
and q.map p.subtype
.
Equations
- p.equiv_subtype_map q = {to_fun := (linear_map.cod_restrict (submodule.map p.subtype q) (p.subtype.dom_restrict q) _).to_fun, map_add' := _, map_smul' := _, inv_fun := λ (ᾰ : ↥(submodule.map p.subtype q)), subtype.cases_on ᾰ (λ (x : M) (hx : x ∈ submodule.map p.subtype q), ⟨⟨x, _⟩, _⟩), left_inv := _, right_inv := _}
If s ≤ t
, then we can view s
as a submodule of t
by taking the comap
of t.subtype
.
Given modules M
, M₂
over a commutative ring, together with submodules p ⊆ M
, q ⊆ M₂
,
the set of maps $\{f ∈ Hom(M, M₂) | f(p) ⊆ q \}$ is a submodule of Hom(M, M₂)
.
An equivalence whose underlying function is linear is a linear equivalence.
An additive equivalence whose underlying function preserves smul
is a linear equivalence.
Given an R
-module M
and a function m → n
between arbitrary types,
construct a linear map (n → M) →ₗ[R] (m → M)
Given an R
-module M
and an equivalence m ≃ n
between arbitrary types,
construct a linear equivalence (n → M) ≃ₗ[R] (m → M)
Equations
- linear_equiv.fun_congr_left R M e = linear_equiv.of_linear (linear_map.fun_left R M ⇑e) (linear_map.fun_left R M ⇑(e.symm)) _ _
The group of invertible linear maps from M
to itself
Equations
- linear_map.general_linear_group R M = units (M →ₗ[R] M)
An invertible linear map f
determines an equivalence from M
to itself.
An equivalence from M
to itself determines an invertible linear map.
The general linear group on R
and M
is multiplicatively equivalent to the type of linear
equivalences between M
and itself.
Equations
- linear_map.general_linear_group.general_linear_equiv R M = {to_fun := linear_map.general_linear_group.to_linear_equiv _inst_3, inv_fun := linear_map.general_linear_group.of_linear_equiv _inst_3, left_inv := _, right_inv := _, map_mul' := _}