# Algebras With Basis¶

class sage.categories.algebras_with_basis.AlgebrasWithBasis(base, name=None)

The category of algebras with a distinguished basis

EXAMPLES:

sage: C = AlgebrasWithBasis(QQ); C
Category of algebras with basis over Rational Field
sage: C.super_categories()
[Category of modules with basis over Rational Field, Category of algebras over Rational Field]


We construct a typical parent in this category, and do some computations with it:

sage: A = C.example(); A
An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field

sage: A.category()
Category of algebras with basis over Rational Field

sage: A.one_basis()
word:
sage: A.one()
B[word: ]

sage: A.base_ring()
Rational Field
sage: A.basis().keys()
Words over {'a', 'b', 'c'}

sage: (a,b,c) = A.algebra_generators()
sage: a^3, b^2
(B[word: aaa], B[word: bb])
sage: a*c*b
B[word: acb]

sage: A.product
<bound method FreeAlgebra_with_category._product_from_product_on_basis_multiply of An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field>
sage: A.product(a*b,b)
B[word: abb]

sage: TestSuite(A).run(verbose=True)
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
running ._test_category() . . . pass
running ._test_characteristic() . . . pass
running ._test_distributivity() . . . pass
running ._test_elements() . . .
Running the test suite of self.an_element()
running ._test_category() . . . pass
running ._test_eq() . . . pass
running ._test_nonzero_equal() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_pickling() . . . pass
pass
running ._test_elements_eq_reflexive() . . . pass
running ._test_elements_eq_symmetric() . . . pass
running ._test_elements_eq_transitive() . . . pass
running ._test_elements_neq() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_one() . . . pass
running ._test_pickling() . . . pass
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass
sage: A.__class__
<class 'sage.categories.examples.algebras_with_basis.FreeAlgebra_with_category'>
sage: A.element_class
<class 'sage.combinat.free_module.FreeAlgebra_with_category.element_class'>


Please see the source code of $$A$$ (with A??) for how to implement other algebras with basis.

TESTS:

sage: TestSuite(AlgebrasWithBasis(QQ)).run()

class CartesianProducts(category, *args)

The category of algebras with basis, constructed as cartesian products of algebras with basis

Note: this construction give the direct products of algebras with basis. See comment in Algebras.CartesianProducts

ParentMethods

alias of CartesianProducts.ParentMethods

extra_super_categories()

A cartesian product of algebras with basis is endowed with a natural algebra with basis structure.

EXAMPLES:

sage: AlgebrasWithBasis(QQ).CartesianProducts().extra_super_categories()
[Category of algebras with basis over Rational Field]
sage: AlgebrasWithBasis(QQ).CartesianProducts().super_categories()
[Category of algebras with basis over Rational Field, Category of Cartesian products of algebras over Rational Field, Category of Cartesian products of modules with basis over Rational Field]

class AlgebrasWithBasis.ElementMethods
class AlgebrasWithBasis.ParentMethods
from_base_ring()

TESTS:

sage: A = AlgebrasWithBasis(QQ).example()
sage: A.from_base_ring(3)
3*B[word: ]

from_base_ring_from_one_basis(r)

INPUTS:

• $$r$$: an element of the coefficient ring

Implements the canonical embeding from the ground ring.

EXAMPLES:

sage: A = AlgebrasWithBasis(QQ).example()
sage: A.from_base_ring_from_one_basis(3)
3*B[word: ]
sage: A.from_base_ring(3)
3*B[word: ]
sage: A(3)
3*B[word: ]

one()

EXAMPLES:

sage: A = AlgebrasWithBasis(QQ).example()
sage: A.one_basis()
word:
sage: A.one()
B[word: ]

one_basis()

When the one of an algebra with basis is an element of this basis, this optional method can return the index of this element. This is used to provide a default implementation of one(), and an optimized default implementation of from_base_ring().

EXAMPLES:

sage: A = AlgebrasWithBasis(QQ).example()
sage: A.one_basis()
word:
sage: A.one()
B[word: ]
sage: A.from_base_ring(4)
4*B[word: ]

one_from_one_basis()

Returns the one of the algebra, as per Monoids.ParentMethods.one()

By default, this is implemented from one_basis(), if available.

EXAMPLES:

sage: A = AlgebrasWithBasis(QQ).example()
sage: A.one_basis()
word:
sage: A.one_from_one_basis()
B[word: ]
sage: A.one()
B[word: ]


TESTS:

Try to check that #5843 Heisenbug is fixed:

sage: A = AlgebrasWithBasis(QQ).example()
sage: B = AlgebrasWithBasis(QQ).example(('a', 'c'))
sage: A == B
False
sage: Aone = A.one_from_one_basis
sage: Bone = B.one_from_one_basis
sage: Aone is Bone
False


Even if called in the wrong order, they should returns their respective one:

sage: Bone().parent() is B
True
sage: Aone().parent() is A
True

product()

The product of the algebra, as per Magmas.ParentMethods.product()

By default, this is implemented using one of the following methods, in the specified order:

EXAMPLES:

sage: A = AlgebrasWithBasis(QQ).example()
sage: a, b, c = A.algebra_generators()
sage: A.product(a + 2*b, 3*c)
3*B[word: ac] + 6*B[word: bc]

product_on_basis(i, j)

The product of the algebra on the basis (optional)

INPUT:

• i, j – the indices of two elements of the basis of self

Returns the product of the two corresponding basis elements

If implemented, product() is defined from it by bilinearity.

EXAMPLES:

sage: A = AlgebrasWithBasis(QQ).example()
sage: Word = A.basis().keys()
sage: A.product_on_basis(Word("abc"),Word("cba"))
B[word: abccba]

class AlgebrasWithBasis.TensorProducts(category, *args)

The category of algebras with basis constructed by tensor product of algebras with basis

ElementMethods

alias of TensorProducts.ElementMethods

ParentMethods

alias of TensorProducts.ParentMethods

extra_super_categories()

EXAMPLES:

sage: AlgebrasWithBasis(QQ).TensorProducts().extra_super_categories()
[Category of algebras with basis over Rational Field]
sage: AlgebrasWithBasis(QQ).TensorProducts().super_categories()
[Category of algebras with basis over Rational Field,
Category of tensor products of algebras over Rational Field,
Category of tensor products of modules with basis over Rational Field]

AlgebrasWithBasis.example(alphabet=('a', 'b', 'c'))

Returns an example of algebra with basis:

sage: AlgebrasWithBasis(QQ).example()
An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field


An other set of generators can be specified as optional argument:

sage: AlgebrasWithBasis(QQ).example((1,2,3))
An example of an algebra with basis: the free algebra on the generators (1, 2, 3) over Rational Field

AlgebrasWithBasis.super_categories()

EXAMPLES:

sage: AlgebrasWithBasis(QQ).super_categories()
[Category of modules with basis over Rational Field, Category of algebras over Rational Field]


Algebras

Bialgebras