# mathlibdocumentation

linear_algebra.basis

# Bases

This file defines bases in a module or vector space.

It is inspired by Isabelle/HOL's linear algebra, and hence indirectly by HOL Light.

## Main definitions

All definitions are given for families of vectors, i.e. v : ι → M where M is the module or vector space and ι : Type* is an arbitrary indexing type.

• is_basis R v states that the vector family v is a basis, i.e. it is linearly independent and spans the entire space.

• is_basis.repr hv x is the basis version of linear_independent.repr hv x. It returns the linear combination representing x : M on a basis v of M (using classical choice). The argument hv must be a proof that is_basis R v. is_basis.repr hv is given as a linear map as well.

• is_basis.constr hv f constructs a linear map M₁ →ₗ[R] M₂ given the values f : ι → M₂ at the basis v : ι → M₁, given hv : is_basis R v.

## Main statements

• is_basis.ext states that two linear maps are equal if they coincide on a basis.

• exists_is_basis states that every vector space has a basis.

## Implementation notes

We use families instead of sets because it allows us to say that two identical vectors are linearly dependent. For bases, this is useful as well because we can easily derive ordered bases by using an ordered index type ι.

## Tags

basis, bases

def is_basis {ι : Type u_1} (R : Type u_3) {M : Type u_5} (v : ι → M) [ring R] [ M] :
Prop

A family of vectors is a basis if it is linearly independent and all vectors are in the span.

Equations
theorem is_basis.mem_span {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (x : M) :

theorem is_basis.comp {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (f : ι' → ι) (hf : function.bijective f) :
(v f)

theorem is_basis.injective {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [nontrivial R] (hv : v) :

theorem is_basis.range {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :
(λ (x : (set.range v)), x)

def is_basis.repr {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :

Given a basis, any vector can be written as a linear combination of the basis vectors. They are given by this linear map. This is one direction of module_equiv_finsupp.

Equations
theorem is_basis.total_repr {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (x : M) :
M R v) ((hv.repr) x) = x

theorem is_basis.total_comp_repr {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :

theorem is_basis.ext {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] {f g : M →ₗ[R] M'} (hv : v) (h : ∀ (i : ι), f (v i) = g (v i)) :
f = g

theorem is_basis.repr_ker {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :

theorem is_basis.repr_range {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :

theorem is_basis.repr_total {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (x : ι →₀ R) (hx : x ) :
(hv.repr) ( M R v) x) = x

theorem is_basis.repr_eq_single {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) {i : ι} :
(hv.repr) (v i) =

@[simp]
theorem is_basis.repr_self_apply {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (i j : ι) :
((hv.repr) (v i)) j = ite (i = j) 1 0

theorem is_basis.repr_eq_iff {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) {f : M →ₗ[R] ι →₀ R} :
hv.repr = f ∀ (i : ι), f (v i) =

theorem is_basis.repr_apply_eq {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) {f : M → ι → R} (hadd : ∀ (x y : M), f (x + y) = f x + f y) (hsmul : ∀ (c : R) (x : M), f (c x) = c f x) (f_eq : ∀ (i : ι), f (v i) = 1)) (x : M) (i : ι) :
((hv.repr) x) i = f x i

theorem is_basis.range_repr_self {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (i : ι) :
(_.repr) (v i) = finsupp.single v i, _⟩ 1

@[simp]
theorem is_basis.range_repr {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] {x : M} (hv : v) (i : ι) :
((_.repr) x) v i, _⟩ = ((hv.repr) x) i

def is_basis.constr {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) (f : ι → M') :
M →ₗ[R] M'

Construct a linear map given the value at the basis.

Equations
theorem is_basis.constr_apply {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) (f : ι → M') (x : M) :
(hv.constr f) x = ((hv.repr) x).sum (λ (b : ι) (a : R), a f b)

@[simp]
theorem constr_basis {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] {f : ι → M'} {i : ι} (hv : v) :
(hv.constr f) (v i) = f i

theorem constr_eq {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] {g : ι → M'} {f : M →ₗ[R] M'} (hv : v) (h : ∀ (i : ι), g i = f (v i)) :
hv.constr g = f

theorem constr_self {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) (f : M →ₗ[R] M') :
hv.constr (λ (i : ι), f (v i)) = f

theorem constr_zero {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) :
hv.constr (λ (i : ι), 0) = 0

theorem constr_add {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] {g f : ι → M'} (hv : v) :
hv.constr (λ (i : ι), f i + g i) = hv.constr f + hv.constr g

theorem constr_neg {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] {f : ι → M'} (hv : v) :
hv.constr (λ (i : ι), -f i) = -hv.constr f

theorem constr_sub {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) {g f : ι → M'} (hs : v) :
hv.constr (λ (i : ι), f i - g i) = hs.constr f - hs.constr g

theorem constr_smul {ι : Type u_1} {R : Type u_2} {M : Type u_3} [comm_ring R] [ M] {v : ι → R} {f : ι → M} {a : R} (hv : v) :
hv.constr (λ (b : ι), a f b) = a hv.constr f

theorem constr_range {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] [nonempty ι] (hv : v) {f : ι → M'} :
(hv.constr f).range = (set.range f)

def module_equiv_finsupp {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :

Canonical equivalence between a module and the linear combinations of basis vectors.

Equations
@[simp]
theorem module_equiv_finsupp_apply_basis {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) (i : ι) :
(v i) =

def linear_equiv_of_is_basis {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {M' : Type u_6} [ring R] [add_comm_group M'] [ M] [ M'] {v : ι → M} {v' : ι' → M'} (hv : v) (hv' : v') (e : ι ι') :
M ≃ₗ[R] M'

Isomorphism between the two modules, given two modules M and M' with respective bases v and v' and a bijection between the indexing sets of the two bases.

Equations
def linear_equiv_of_is_basis' {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {M' : Type u_6} [ring R] [add_comm_group M'] [ M] [ M'] {v : ι → M} {v' : ι' → M'} (f : M → M') (g : M' → M) (hv : v) (hv' : v') (hf : ∀ (i : ι), f (v i) ) (hg : ∀ (i : ι'), g (v' i) ) (hgf : ∀ (i : ι), g (f (v i)) = v i) (hfg : ∀ (i : ι'), f (g (v' i)) = v' i) :
M ≃ₗ[R] M'

Isomorphism between the two modules, given two modules M and M' with respective bases v and v' and a bijection between the two bases.

Equations
@[simp]
theorem linear_equiv_of_is_basis_comp {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {M'' : Type u_7} [ring R] [add_comm_group M'] [add_comm_group M''] [ M] [ M'] [ M''] {ι'' : Type u_4} {v : ι → M} {v' : ι' → M'} {v'' : ι'' → M''} (hv : v) (hv' : v') (hv'' : v'') (e : ι ι') (f : ι' ι'') :
hv' e).trans hv'' f) = hv'' (e.trans f)

@[simp]
theorem linear_equiv_of_is_basis_refl {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hv : v) :
(equiv.refl ι) =

theorem linear_equiv_of_is_basis_trans_symm {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) (e : ι ι') {v' : ι' → M'} (hv' : v') :
hv' e).trans hv e.symm) =

theorem linear_equiv_of_is_basis_symm_trans {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hv : v) (e : ι ι') {v' : ι' → M'} (hv' : v') :
hv e.symm).trans hv' e) =

theorem is_basis_inl_union_inr {ι : Type u_1} {ι' : Type u_2} {R : Type u_3} {M : Type u_5} {M' : Type u_6} [ring R] [add_comm_group M'] [ M] [ M'] {v : ι → M} {v' : ι' → M'} (hv : v) (hv' : v') :
(sum.elim ( M M') v) ( M M') v'))

theorem is_basis_singleton_one {ι : Type u_1} (R : Type u_2) [unique ι] [ring R] :
(λ (_x : ι), 1)

theorem linear_equiv.is_basis {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] (hs : v) (f : M ≃ₗ[R] M') :
(f v)

theorem is_basis_span {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] (hs : v) :
(λ (i : ι), v i, _⟩)

theorem is_basis_empty {ι : Type u_1} {R : Type u_3} {M : Type u_5} [ring R] [ M] (h_empty : ¬) (h : ∀ (x : M), x = 0) :
(λ (x : ι), 0)

theorem is_basis_empty_bot {ι : Type u_1} {R : Type u_3} {M : Type u_5} [ring R] [ M] (h_empty : ¬) :
(λ (_x : ι), 0)

def is_basis.equiv_fun {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) :
M ≃ₗ[R] ι → R

A module over R with a finite basis is linearly equivalent to functions from its basis to R.

Equations
def module.fintype_of_fintype {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) [fintype R] :

A module over a finite ring that admits a finite basis is finite.

Equations
theorem module.card_fintype {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) [fintype R] [fintype M] :

@[simp]
theorem is_basis.equiv_fun_symm_apply {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) (x : ι → R) :
(h.equiv_fun.symm) x = ∑ (i : ι), x i v i

Given a basis v indexed by ι, the canonical linear equivalence between ι → R and M maps a function x : ι → R to the linear combination ∑_i x i • v i.

theorem is_basis.equiv_fun_apply {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) (u : M) :
(h.equiv_fun) u = ((h.repr) u)

theorem is_basis.equiv_fun_total {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) (u : M) :
∑ (i : ι), (h.equiv_fun) u i v i = u

@[simp]
theorem is_basis.equiv_fun_self {ι : Type u_1} {R : Type u_3} {M : Type u_5} {v : ι → M} [ring R] [ M] [fintype ι] (h : v) (i j : ι) :
(h.equiv_fun) (v i) j = ite (i = j) 1 0

@[simp]
theorem is_basis.constr_apply_fintype {ι : Type u_1} {R : Type u_3} {M : Type u_5} {M' : Type u_6} {v : ι → M} [ring R] [add_comm_group M'] [ M] [ M'] [fintype ι] (h : v) (f : ι → M') (x : M) :
(h.constr f) x = ∑ (i : ι), (h.equiv_fun) x i f i

theorem exists_subset_is_basis {K : Type u_4} {V : Type u} [field K] [ V] {s : set V} (hs : (λ (x : s), x)) :
∃ (b : set V), s b

theorem exists_sum_is_basis {ι : Type u_1} {K : Type u_4} {V : Type u} [field K] [ V] {v : ι → V} (hs : v) :
∃ (ι' : Type u) (v' : ι' → V), (sum.elim v v')

theorem exists_is_basis (K : Type u_4) (V : Type u) [field K] [ V] :
∃ (b : set V), (λ (i : b), i)

theorem linear_map.exists_left_inverse_of_injective {K : Type u_4} {V : Type u} {V' : Type u_8} [field K] [add_comm_group V'] [ V] [ V'] (f : V →ₗ[K] V') (hf_inj : f.ker = ) :
∃ (g : V' →ₗ[K] V),

theorem submodule.exists_is_compl {K : Type u_4} {V : Type u} [field K] [ V] (p : V) :
∃ (q : V), q

theorem linear_map.exists_right_inverse_of_surjective {K : Type u_4} {V : Type u} {V' : Type u_8} [field K] [add_comm_group V'] [ V] [ V'] (f : V →ₗ[K] V') (hf_surj : f.range = ) :
∃ (g : V' →ₗ[K] V),

theorem quotient_prod_linear_equiv {K : Type u_4} {V : Type u} [field K] [ V] (p : V) :

theorem vector_space.card_fintype (K : Type u_4) (V : Type u) [field K] [ V] [fintype K] [fintype V] :
∃ (n : ), =

theorem pi.linear_independent_std_basis {R : Type u_3} {η : Type u_9} {ιs : η → Type u_10} {Ms : η → Type u_11} [ring R] [Π (i : η), add_comm_group (Ms i)] [Π (i : η), (Ms i)] [decidable_eq η] (v : Π (j : η), ιs jMs j) (hs : ∀ (i : η), (v i)) :
(λ (ji : Σ (j : η), ιs j), Ms ji.fst) (v ji.fst ji.snd))

theorem pi.is_basis_std_basis {R : Type u_3} {η : Type u_9} {ιs : η → Type u_10} {Ms : η → Type u_11} [ring R] [Π (i : η), add_comm_group (Ms i)] [Π (i : η), (Ms i)] [fintype η] [decidable_eq η] (s : Π (j : η), ιs jMs j) (hs : ∀ (j : η), (s j)) :
(λ (ji : Σ (j : η), ιs j), Ms ji.fst) (s ji.fst ji.snd))

theorem pi.is_basis_fun₀ (R : Type u_3) (η : Type u_9) [ring R] [fintype η] [decidable_eq η] :
(λ (ji : Σ (j : η), unit), (λ (i : η), R) ji.fst) 1)

theorem pi.is_basis_fun (R : Type u_3) (η : Type u_9) [ring R] [fintype η] [decidable_eq η] :
(λ (i : η), (λ (i : η), R) i) 1)

@[simp]
theorem pi.is_basis_fun_repr (R : Type u_3) (η : Type u_9) [ring R] [fintype η] [decidable_eq η] (x : η → R) (i : η) :
((_.repr) x) i = x i