Bases: Category

The category of sets with a grading.

A set with a grading is a set $$S$$ equipped with a grading by some other set $$I$$ (by default the set $$\NN$$ of the non-negative integers):

$S = \biguplus_{i\in I} S_i$

where the graded components $$S_i$$ are (usually finite) sets. The grading function maps each element $$s$$ of $$S$$ to its grade $$i$$, so that $$s\in S_i$$.

From implementation point of view, if the graded set is enumerated then each graded component should be enumerated (there is a check in the method _test_graded_components()). The contrary needs not be true.

To implement this category, a parent must either implement graded_component() or subset(). If only subset() is implemented, the first argument must be the grading for compatibility with graded_component(). Additionally either the parent must implement grading() or its elements must implement a method grade(). See the example sage.categories.examples.sets_with_grading.NonNegativeIntegers.

Finally, if the graded set is enumerated (see EnumeratedSets) then each graded component should be enumerated. The contrary needs not be true.

EXAMPLES:

A typical example of a set with a grading is the set of non-negative integers graded by themselves:

sage: N = SetsWithGrading().example(); N
Non negative integers
sage: N.category()
Non negative integers


The grading function is given by N.grading:

sage: N.grading(4)
4


The graded component $$N_i$$ is the set with one element $$i$$:

sage: N.graded_component(grade=5)
{5}
{42}


sage: SetsWithGrading()
[Category of sets]
Category of sets,
Category of sets with partial maps,
Category of objects]


Todo

• This should be moved to Sets().WithGrading().

• Should the grading set be a parameter for this category?

• Does the enumeration need to be compatible with the grading? Be careful that the fact that graded components are allowed to be finite or infinite make the answer complicated.

class ParentMethods#

Bases: object

generating_series()#

Default implementation for generating series.

OUTPUT:

A series, indexed by the grading set.

EXAMPLES:

   sage: N = SetsWithGrading().example(); N
Non negative integers
sage: N.generating_series()
1/(-z + 1)

sage: Permutations().generating_series()                                # optional - sage.combinat
1 + z + 2*z^2 + 6*z^3 + 24*z^4 + 120*z^5 + 720*z^6 + O(z^7)

.. TODO::

- Very likely, this should always return a lazy power series.


Return the graded component of self with grade grade.

The default implementation just calls the method subset() with the first argument grade.

EXAMPLES:

sage: N = SetsWithGrading().example(); N
Non negative integers
{3}


Return the grading of the element elt of self.

This default implementation calls elt.grade().

EXAMPLES:

sage: N = SetsWithGrading().example(); N
Non negative integers
4


Return the set self is graded by. By default, this is the set of non-negative integers.

EXAMPLES:

sage: SetsWithGrading().example().grading_set()
Non negative integers

subset(*args, **options)#

Return the subset of self described by the given parameters.

EXAMPLES:

sage: W = WeightedIntegerVectors([3,2,1]); W                            # optional - sage.combinat
Integer vectors weighted by [3, 2, 1]
sage: W.subset(4)                                                       # optional - sage.combinat
Integer vectors of 4 weighted by [3, 2, 1]

super_categories()#

EXAMPLES:

sage: SetsWithGrading().super_categories()
[Category of sets]