# Examples of graded modules with basis#

This class illustrates an implementation of a graded module with basis: the free module over partitions.

INPUT:

• R – base ring

The implementation involves the following:

• A choice of how to represent elements. In this case, the basis elements are partitions. The algebra is constructed as a CombinatorialFreeModule on the set of partitions, so it inherits all of the methods for such objects, and has operations like addition already defined.

sage: A = GradedModulesWithBasis(QQ).example()

• A basis function - this module is graded by the non-negative integers, so there is a function defined in this module, creatively called basis(), which takes an integer $$d$$ as input and returns a family of partitions representing a basis for the algebra in degree $$d$$.

sage: A.basis(2)
Lazy family (Term map from Partitions to An example of a graded module with basis: the free module on partitions over Rational Field(i))_{i in Partitions of the integer 2}
sage: A.basis(6)[Partition([3,2,1])]
P[3, 2, 1]

• If the algebra is called A, then its basis function is stored as A.basis. Thus the function can be used to find a basis for the degree $$d$$ piece: essentially, just call A.basis(d). More precisely, call x for each x in A.basis(d).

sage: [m for m in A.basis(4)]
[P[4], P[3, 1], P[2, 2], P[2, 1, 1], P[1, 1, 1, 1]]

• For dealing with basis elements: degree_on_basis(), and _repr_term(). The first of these defines the degree of any monomial, and then the degree method for elements – see the next item – uses it to compute the degree for a linear combination of monomials. The last of these determines the print representation for monomials, which automatically produces the print representation for general elements.

sage: A.degree_on_basis(Partition([4,3]))
7
sage: A._repr_term(Partition([4,3]))
'P[4, 3]'

• There is a class for elements, which inherits from IndexedFreeModuleElement. An element is determined by a dictionary whose keys are partitions and whose corresponding values are the coefficients. The class implements two things: an is_homogeneous method and a degree method.

sage: p = A.monomial(Partition([3,2,1])); p
P[3, 2, 1]
sage: p.is_homogeneous()
True
sage: p.degree()
6

basis(d=None)#

Return the basis for (the d-th homogeneous component of) self.

INPUT:

• d – (optional, default None) nonnegative integer or None

OUTPUT:

If d is None, returns the basis of the module. Otherwise, returns the basis of the homogeneous component of degree d (i.e., the subfamily of the basis of the whole module which consists only of the basis vectors lying in $$F_d \setminus \bigcup_{i<d} F_i$$).

The basis is always returned as a family.

EXAMPLES:

sage: A = ModulesWithBasis(ZZ).Filtered().example()
sage: A.basis(4)
Lazy family (Term map from Partitions to An example of a
filtered module with basis: the free module on partitions
over Integer Ring(i))_{i in Partitions of the integer 4}


Without arguments, the full basis is returned:

sage: A.basis()
Lazy family (Term map from Partitions to An example of a
filtered module with basis: the free module on partitions
over Integer Ring(i))_{i in Partitions}
sage: A.basis()
Lazy family (Term map from Partitions to An example of a
filtered module with basis: the free module on partitions
over Integer Ring(i))_{i in Partitions}


Checking this method on a filtered algebra. Note that this will typically raise a NotImplementedError when this feature is not implemented.

sage: A = AlgebrasWithBasis(ZZ).Filtered().example()
sage: A.basis(4)
Traceback (most recent call last):
...
NotImplementedError: infinite set


Without arguments, the full basis is returned:

sage: A.basis()
Lazy family (Term map from Free abelian monoid indexed by
{'x', 'y', 'z'} to An example of a filtered algebra with
basis: the universal enveloping algebra of Lie algebra
of RR^3 with cross product over Integer Ring(i))_{i in
Free abelian monoid indexed by {'x', 'y', 'z'}}


An example with a graded algebra:

sage: E.<x,y> = ExteriorAlgebra(QQ)
sage: E.basis()
Lazy family (Term map from Subsets of {0,1} to
The exterior algebra of rank 2 over Rational Field(i))_{i in
Subsets of {0,1}}

degree_on_basis(t)#

The degree of the element determined by the partition t in this graded module.

INPUT:

• t – the index of an element of the basis of this module, i.e. a partition

OUTPUT: an integer, the degree of the corresponding basis element

EXAMPLES:

sage: A = GradedModulesWithBasis(QQ).example()
sage: A.degree_on_basis(Partition((2,1)))
3
sage: A.degree_on_basis(Partition((4,2,1,1,1,1)))
10
sage: type(A.degree_on_basis(Partition((1,1))))
<class 'sage.rings.integer.Integer'>