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. If p
and q
are submodules of a module, p ≤ q
means that p ⊆ q
.
Many of the relevant definitions, including module
, submodule
, and linear_map
, are found in
src/algebra/module.lean
.
Main definitions
- Many constructors for linear maps, including
prod
andcoprod
submodule.span s
is defined to be the smallest submodule containing the sets
.- If
p
is a submodule ofM
,submodule.quotient p
is the quotient ofM
with respect top
: that is, elements ofM
are identified if their difference is inp
. This is itself a module. - The kernel
ker
and rangerange
of a linear map are submodules of the domain and codomain respectively. linear_equiv M M₂
, the type of linear equivalences betweenM
andM₂
, is a structure that extendslinear_map
andequiv
.- The general linear group is defined to be the group of invertible linear maps from
M
to itself.
Main statements
- The first and second isomorphism laws for modules are proved as
quot_ker_equiv_range
andquotient_inf_equiv_sup_quotient
.
Notations
- We continue to use the notation
M →ₗ[R] M₂
for the type of linear maps fromM
toM₂
over the ringR
. - We introduce the notations
M ≃ₗ M₂
andM ≃ₗ[R] M₂
forlinear_equiv M M₂
. In the first, the ringR
is implicit.
Implementation notes
We note that, when constructing linear maps, it is convenient to use operations defined on bundled
maps (prod
, coprod
, arithmetic operations like +
) instead of defining a function and proving
it is linear.
Tags
linear algebra, vector space, module
decomposing x : ι → R
as a sum along the canonical basis
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.
If a function g
is a left and right inverse of a linear map f
, then g
is linear itself.
The constant 0 map is linear.
Equations
- linear_map.inhabited = {default := 0}
The sum of two linear maps is linear.
The type of linear maps is an additive monoid.
Equations
- linear_map.add_comm_monoid = {add := has_add.add linear_map.has_add, add_assoc := _, zero := 0, zero_add := _, add_zero := _, add_comm := _}
Equations
- _ = _
λb, f b • x
is a linear map.
Equations
- linear_map.has_one = {one := linear_map.id _inst_6}
Equations
- linear_map.has_mul = {mul := linear_map.comp _inst_6}
Equations
- linear_map.monoid = {mul := has_mul.mul linear_map.has_mul, mul_assoc := _, one := 1, one_mul := _, mul_one := _}
A linear map f
applied to x : ι → R
can be computed using the image under f
of elements
of the canonical basis.
The first projection of a product is a linear map.
The second projection of a product is a linear map.
The prod of two linear maps is a linear map.
The left injection into a product is a linear map.
Equations
- linear_map.inl R M M₂ = {to_fun := ⇑(add_monoid_hom.inl M M₂), map_add' := _, map_smul' := _}
The right injection into a product is a linear map.
Equations
- linear_map.inr R M M₂ = {to_fun := ⇑(add_monoid_hom.inr M M₂), map_add' := _, map_smul' := _}
The coprod function λ x : M × M₂, f x.1 + g x.2
is a linear map.
prod.map
of two linear maps.
Equations
- f.prod_map g = (f.comp (linear_map.fst R M M₂)).prod (g.comp (linear_map.snd R M M₂))
The negation of a linear map is linear.
The type of linear maps is an additive group.
Equations
- linear_map.add_comm_group = {add := has_add.add linear_map.has_add, add_assoc := _, zero := 0, zero_add := _, add_zero := _, neg := has_neg.neg linear_map.has_neg, add_left_neg := _, add_comm := _}
Equations
Equations
- linear_map.semimodule = {to_distrib_mul_action := {to_mul_action := {to_has_scalar := {smul := has_scalar.smul linear_map.has_scalar}, one_smul := _, mul_smul := _}, smul_add := _, smul_zero := _}, add_smul := _, zero_smul := _}
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₃
.
Equations
- linear_map.endomorphism_ring = {add := add_comm_group.add linear_map.add_comm_group, add_assoc := _, zero := add_comm_group.zero linear_map.add_comm_group, zero_add := _, add_zero := _, neg := add_comm_group.neg linear_map.add_comm_group, add_left_neg := _, add_comm := _, mul := has_mul.mul linear_map.has_mul, mul_assoc := _, one := 1, one_mul := _, mul_one := _, left_distrib := _, right_distrib := _}
The family of linear maps M₂ → M
parameterised by f ∈ M₂ → R
, x ∈ M
, is linear in f
, x
.
Properties of submodules
Equations
- submodule.partial_order = {le := λ (p p' : submodule R M), ∀ ⦃x : M⦄, x ∈ p → x ∈ p', lt := partial_order.lt (partial_order.lift coe submodule.coe_injective), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _}
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 _
The set {0}
is the bottom element of the lattice of submodules.
Equations
Equations
- submodule.order_bot = {bot := ⊥, le := partial_order.le submodule.partial_order, lt := partial_order.lt submodule.partial_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, bot_le := _}
The universal set is the top element of the lattice of submodules.
Equations
- submodule.order_top = {top := ⊤, le := partial_order.le submodule.partial_order, lt := partial_order.lt submodule.partial_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_top := _}
Equations
- submodule.complete_lattice = {sup := λ (a b : submodule R M), has_Inf.Inf {x : submodule R M | a ≤ x ∧ b ≤ x}, le := order_top.le submodule.order_top, lt := order_top.lt submodule.order_top, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := has_inf.inf submodule.has_inf, inf_le_left := _, inf_le_right := _, le_inf := _, top := order_top.top submodule.order_top, le_top := _, bot := order_bot.bot submodule.order_bot, bot_le := _, Sup := λ (tt : set (submodule R M)), has_Inf.Inf {t : submodule R M | ∀ (t' : submodule R M), t' ∈ tt → t' ≤ t}, Inf := has_Inf.Inf submodule.has_Inf, le_Sup := _, Sup_le := _, Inf_le := _, le_Inf := _}
Equations
- submodule.add_comm_monoid_submodule = {add := has_sup.sup (semilattice_sup.to_has_sup (submodule R M)), add_assoc := _, zero := ⊥, zero_add := _, add_zero := _, add_comm := _}
The pushforward of a submodule p ⊆ M
by f : M → M₂
The pullback of a submodule p ⊆ M₂
along f : M → M₂
The span of a set s ⊆ M
is the smallest submodule of M that contains s
.
Equations
- submodule.span R s = has_Inf.Inf {p : submodule R M | s ⊆ ↑p}
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
.
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 := _}
The product of two submodules is a submodule.
The equivalence relation associated to a submodule p
, defined by x ≈ y
iff y - x ∈ p
.
The quotient of a module M
by a submodule p ⊆ M
.
Equations
Map associating to an element of M
the corresponding element of M/p
,
when p
is a submodule of M
.
Equations
Equations
Equations
- submodule.quotient.inhabited p = {default := 0}
Equations
- submodule.quotient.has_add p = {add := λ (a b : p.quotient), quotient.lift_on₂' a b (λ (a b : M), submodule.quotient.mk (a + b)) _}
Equations
- submodule.quotient.has_neg p = {neg := λ (a : p.quotient), quotient.lift_on' a (λ (a : M), submodule.quotient.mk (-a)) _}
Equations
- submodule.quotient.add_comm_group p = {add := has_add.add (submodule.quotient.has_add p), add_assoc := _, zero := 0, zero_add := _, add_zero := _, neg := has_neg.neg (submodule.quotient.has_neg p), add_left_neg := _, add_comm := _}
Equations
- submodule.quotient.has_scalar p = {smul := λ (a : R) (x : p.quotient), quotient.lift_on' x (λ (x : M), submodule.quotient.mk (a • x)) _}
Equations
- submodule.quotient.semimodule p = semimodule.of_core {to_has_scalar := {smul := has_scalar.smul (submodule.quotient.has_scalar p)}, smul_add := _, add_smul := _, mul_smul := _, one_smul := _}
Properties of linear maps
The range of a linear map f : M → M₂
is a submodule of M₂
.
Equations
- f.range = submodule.map f ⊤
Restrict the codomain of a linear map f
to f.range
.
Equations
- f.range_restrict = linear_map.cod_restrict f.range f _
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 ⊥
If the union of the kernels ker f
and ker g
spans the domain, then the range of
prod f g
is equal to the product of range f
and range g
.
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))
The map from a module M
to the quotient of M
by a submodule p
as a linear map.
The map from the quotient of M
by a submodule p
to M₂
induced by a linear map f : M → M₂
vanishing on p
, as a linear map.
The map from the quotient of M
by submodule p
to the quotient of M₂
by submodule q
along
f : M → M₂
is linear.
The correspondence theorem for modules: there is an order isomorphism between submodules of the
quotient of M
by p
, and submodules of M
larger than p
.
Equations
- submodule.comap_mkq.rel_iso p = {to_equiv := {to_fun := λ (p' : submodule R p.quotient), ⟨submodule.comap p.mkq p', _⟩, inv_fun := λ (q : {p' // p ≤ p'}), submodule.map p.mkq ↑q, left_inv := _, right_inv := _}, map_rel_iff' := _}
The ordering on submodules of the quotient of M
by p
embeds into the ordering on submodules
of M
.
Equations
- submodule.comap_mkq.order_embedding p = (rel_iso.to_rel_embedding (submodule.comap_mkq.rel_iso p)).trans (subtype.rel_embedding has_le.le (λ (p' : submodule R M), p ≤ p'))
Linear equivalences
- to_fun : M → M₂
- map_add' : ∀ (x y : M), c.to_fun (x + y) = c.to_fun x + c.to_fun y
- map_smul' : ∀ (c_1 : R) (x : M), c.to_fun (c_1 • x) = c_1 • c.to_fun x
- inv_fun : M₂ → M
- left_inv : function.left_inverse c.inv_fun c.to_fun
- right_inv : function.right_inverse c.inv_fun c.to_fun
A linear equivalence is an invertible linear map.
Equations
- linear_equiv.has_coe = {coe := linear_equiv.to_linear_map _inst_7}
The identity map is a linear equivalence.
Equations
- linear_equiv.refl R M = {to_fun := linear_map.id.to_fun, map_add' := _, map_smul' := _, inv_fun := (equiv.refl M).inv_fun, left_inv := _, right_inv := _}
Linear equivalences are symmetric.
Linear equivalences are transitive.
A linear equivalence is an additive equivalence.
A linear equivalence of two modules restricts to a linear equivalence from any submodule of the domain onto the image of the submodule.
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 := _}
Product of linear equivalences; the maps come from equiv.prod_congr
.
Linear equivalence between a curried and uncurried function.
Differs from tensor_product.curry
.
Equations
- linear_equiv.uncurry R V V₂ = {to_fun := (equiv.arrow_arrow_equiv_prod_arrow V V₂ R).to_fun, map_add' := _, map_smul' := _, inv_fun := (equiv.arrow_arrow_equiv_prod_arrow 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)
The top submodule of M
is linearly equivalent to M
.
If a linear map has an inverse, it is a linear equivalence.
Equivalence given by a block lower diagonal matrix. e₁
and e₂
are diagonal square blocks,
and f
is a rectangular block below the diagonal.
Equations
- e₁.skew_prod e₂ f = {to_fun := ((↑e₁.comp (linear_map.fst R M M₃)).prod (↑e₂.comp (linear_map.snd R M M₃) + f.comp (linear_map.fst R M M₃))).to_fun, map_add' := _, map_smul' := _, inv_fun := λ (p : M₂ × M₄), (⇑(e₁.symm) p.fst, ⇑(e₂.symm) (p.snd - ⇑f (⇑(e₁.symm) p.fst))), left_inv := _, right_inv := _}
An injective
linear map f : M →ₗ[R] M₂
defines a linear equivalence
between M
and f.range
.
Equations
- linear_equiv.of_injective f h = {to_fun := ((equiv.set.range ⇑f _).trans (equiv.set.of_eq _)).to_fun, map_add' := _, map_smul' := _, inv_fun := ((equiv.set.range ⇑f _).trans (equiv.set.of_eq _)).inv_fun, left_inv := _, right_inv := _}
A bijective linear map is a linear equivalence. Here, bijectivity is described by saying that
the kernel of f
is {0}
and the range is the universal set.
Equations
- linear_equiv.of_bijective f hf₁ hf₂ = (linear_equiv.of_injective f hf₁).trans (linear_equiv.of_top f.range hf₂)
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
.
If s ≤ t
, then we can view s
as a submodule of t
by taking the comap
of t.subtype
.
If p = ⊥
, then M / p ≃ₗ[R] M
.
Equations
- p.quot_equiv_of_eq_bot hp = linear_equiv.of_linear (p.liftq linear_map.id _) p.mkq _ _
Quotienting by equal submodules gives linearly equivalent quotients.
Equations
- p.quot_equiv_of_eq q h = {to_fun := (quotient.congr (equiv.refl M) _).to_fun, map_add' := _, map_smul' := _, inv_fun := (quotient.congr (equiv.refl M) _).inv_fun, left_inv := _, right_inv := _}
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₂)
.
Given modules M
, M₂
over a commutative ring, together with submodules p ⊆ M
, q ⊆ M₂
, the
natural map $\{f ∈ Hom(M, M₂) | f(p) ⊆ q \} \to Hom(M/p, M₂/q)$ is linear.
Equations
- p.mapq_linear q = {to_fun := λ (f : ↥(p.compatible_maps q)), p.mapq q f.val _, map_add' := _, map_smul' := _}
An equivalence whose underlying function is linear is a linear equivalence.
The first isomorphism law for modules. The quotient of M
by the kernel of f
is linearly
equivalent to the range of f
.
Equations
- f.quot_ker_equiv_range = (linear_equiv.of_injective (f.ker.liftq f _) _).trans (linear_equiv.of_eq (f.ker.liftq f _).range f.range _)
Canonical linear map from the quotient p/(p ∩ p')
to (p+p')/p'
, mapping x + (p ∩ p')
to x + p'
, where p
and p'
are submodules of an ambient module.
Equations
- linear_map.quotient_inf_to_sup_quotient p p' = (submodule.comap p.subtype (p ⊓ p')).liftq ((submodule.comap (p ⊔ p').subtype p').mkq.comp (submodule.of_le _)) _
Second Isomorphism Law : the canonical map from p/(p ∩ p')
to (p+p')/p'
as a linear isomorphism.
Equations
pi
construction for linear functions. From a family of linear functions it produces a linear
function into a family of modules.
The projections from a family of modules are linear maps.
If I
and J
are disjoint index sets, the product of the kernels of the J
th projections of
φ
is linearly equivalent to the product over I
.
Equations
- linear_map.infi_ker_proj_equiv R φ hd hu = linear_equiv.of_linear (linear_map.pi (λ (i : ↥I), (linear_map.proj ↑i).comp (⨅ (i : ι) (H : i ∈ J), (linear_map.proj i).ker).subtype)) (linear_map.cod_restrict (⨅ (i : ι) (H : i ∈ J), (linear_map.proj i).ker) (linear_map.pi (λ (i : ι), dite (i ∈ I) (λ (h : i ∈ I), linear_map.proj ⟨i, h⟩) (λ (h : i ∉ I), 0))) _) _ _
diag i j
is the identity map if i = j
. Otherwise it is the constant 0 map.
Equations
- linear_map.diag i j = function.update 0 i linear_map.id j
The standard basis of the product of φ
.
Equations
- linear_map.std_basis R φ i = linear_map.pi (linear_map.diag i)
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_map.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)) _ _
Equations
- _ = _
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' := _}