Examples of graded modules with basis

sage.categories.examples.graded_modules_with_basis.Example[source]

alias of GradedPartitionModule

class sage.categories.examples.graded_modules_with_basis.GradedPartitionModule(base_ring)[source]

Bases: CombinatorialFreeModule

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()                                # needs sage.modules
    
    >>> from sage.all import *
    >>> A = GradedModulesWithBasis(QQ).example()                                # needs sage.modules
    
  • A basis function - this module is graded by the nonnegative 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)                                                              # needs sage.modules
    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])]                                          # needs sage.modules
    P[3, 2, 1]
    
    >>> from sage.all import *
    >>> A.basis(Integer(2))                                                              # needs sage.modules
    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}
    >>> A.basis(Integer(6))[Partition([Integer(3),Integer(2),Integer(1)])]                                          # needs sage.modules
    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)]                                                 # needs sage.modules
    [P[4], P[3, 1], P[2, 2], P[2, 1, 1], P[1, 1, 1, 1]]
    
    >>> from sage.all import *
    >>> [m for m in A.basis(Integer(4))]                                                 # needs sage.modules
    [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]))                                     # needs sage.modules
    7
    sage: A._repr_term(Partition([4,3]))                                          # needs sage.modules
    'P[4, 3]'
    
    >>> from sage.all import *
    >>> A.degree_on_basis(Partition([Integer(4),Integer(3)]))                                     # needs sage.modules
    7
    >>> A._repr_term(Partition([Integer(4),Integer(3)]))                                          # needs sage.modules
    '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                                   # needs sage.modules
    P[3, 2, 1]
    sage: p.is_homogeneous()                                                      # needs sage.modules
    True
    sage: p.degree()                                                              # needs sage.modules
    6
    
    >>> from sage.all import *
    >>> p = A.monomial(Partition([Integer(3),Integer(2),Integer(1)])); p                                   # needs sage.modules
    P[3, 2, 1]
    >>> p.is_homogeneous()                                                      # needs sage.modules
    True
    >>> p.degree()                                                              # needs sage.modules
    6
    
basis(d=None)[source]

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

INPUT:

  • d – (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}
>>> from sage.all import *
>>> A = ModulesWithBasis(ZZ).Filtered().example()
>>> A.basis(Integer(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}
>>> from sage.all import *
>>> 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}
>>> 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
>>> from sage.all import *
>>> A = AlgebrasWithBasis(ZZ).Filtered().example()
>>> A.basis(Integer(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'}}
>>> from sage.all import *
>>> 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}}
>>> from sage.all import *
>>> E = ExteriorAlgebra(QQ, names=('x', 'y',)); (x, y,) = E._first_ngens(2)
>>> 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)[source]

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: integer, the degree of the corresponding basis element

EXAMPLES:

sage: # needs sage.modules
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'>
>>> from sage.all import *
>>> # needs sage.modules
>>> A = GradedModulesWithBasis(QQ).example()
>>> A.degree_on_basis(Partition((Integer(2),Integer(1))))
3
>>> A.degree_on_basis(Partition((Integer(4),Integer(2),Integer(1),Integer(1),Integer(1),Integer(1))))
10
>>> type(A.degree_on_basis(Partition((Integer(1),Integer(1)))))
<class 'sage.rings.integer.Integer'>