Commit 2021-05-10 07:36 ef90a7ab
View on Github →refactor(*): bundle is_basis (#7496)
This PR replaces the definition of a basis used in mathlib and fixes the usages throughout.
Rationale: Previously, is_basis was a predicate on a family of vectors, saying this family is linear independent and spans the whole space. We encountered many small annoyances when working with these unbundled definitions, for example complicated is_basis arguments being hidden in the goal view or slow elaboration when mapping a basis to a slightly different set of basis vectors. The idea to turn basis into a bundled structure originated in the discussion on #4949. @digama0 suggested on Zulip to identify these "bundled bases" with their map repr : M ≃ₗ[R] (ι →₀ R) that sends a vector to its coordinates. (In fact, that specific map used to be only a linear_map rather than an equiv.)
Overview of the changes:
- The
is_basispredicate has been replaced with thebasisstructure. - Parameters of the form
{b : ι → M} (hb : is_basis R b)become a single parameter(b : basis ι R M). - Constructing a basis from a linear independent family spanning the whole space is now spelled
basis.mk hli hspan, instead ofand.intro hli hspan. - You can also use
basis.of_reprto construct a basis from an equivalencee : M ≃ₗ[R] (ι →₀ R). Ifιis afintype, you can usebasis.of_equiv_fun (e : M ≃ₗ[R] (ι → R))instead, saving you from having to work withfinsupps. - Most declaration names that used to contain
is_basisare now spelled withbasis, e.g.pi.is_basis_funis nowpi.basis_fun. - Theorems of the form
exists_is_basis K V : ∃ (s : set V) (b : s -> V), is_basis K bandfinite_dimensional.exists_is_basis_finset K V : [finite_dimensional K V] -> ∃ (s : finset V) (b : s -> V), is_basis K bhave been replaced with (noncomputable) defs such asbasis.of_vector_space K V : basis (basis.of_vector_space_index K V) K Vandfinite_dimensional.finset_basis : basis (finite_dimensional.finset_basis_index K V) K V; the indexing sets being a separate definition means we can declare afintype (basis.of_vector_space_index K V)instance on finite dimensional spaces, rather than having to usecases exists_is_basis_fintype K V with ...each time. - Definitions of a
basisare now, wherever practical, accompanied bysimplemmas giving the values ofcoe_fnandreprfor that basis. - Some auxiliary results like
pi.is_basis_fun₀have been removed since they are no longer needed. Basic API overview:
basis ι R Mis the type ofι-indexedR-bases for a moduleM, represented by a linear equivM ≃ₗ[R] ι →₀ R.- the basis vectors of a basis
bare given byb ifori : ι basis.repris the isomorphism sendingx : Mto its coordinatesbasis.repr b x : ι →₀ R. The inverse ofb.reprisfinsupp.total _ _ _ b. The converse, turning this isomorphism into a basis, is calledbasis.of_repr.- If
ιis finite, there is a variant ofreprcalledbasis.equiv_fun b : M ≃ₗ[R] ι → R. The converse, turning this isomorphism into a basis, is calledbasis.of_equiv_fun. basis.constr hv fconstructs a linear mapM₁ →ₗ[R] M₂given the valuesf : ι → M₂at the basis elements⇑b : ι → M₁.basis.mk: a linear independent set of vectors spanning the whole module determines a basis (the converse consists ofbasis.linear_independentandbasis.span_eqbasis.extstates that two linear maps are equal if they coincide on a basis; similar results are available for linear equivs (if they coincide on the basis vectors), elements (if their coordinates coincide) and the functionsb.reprand⇑b.basis.of_vector_spacestates that every vector space has a basis.basis.reindexuses an equiv to map a basis to a different indexing set,basis.mapuses a linear equiv to map a basis to a different module Zulip discussions:- https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Bundled.20basis
- https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.234949