Sets With a Grading#
- class sage.categories.sets_with_grading.SetsWithGrading[source]#
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()
orsubset()
. If onlysubset()
is implemented, the first argument must be the grading for compatibility withgraded_component()
. Additionally either the parent must implementgrading()
or its elements must implement a methodgrade()
. See the examplesage.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() Category of facade infinite sets with grading sage: N.grading_set() Non negative integers
>>> from sage.all import * >>> N = SetsWithGrading().example(); N Non negative integers >>> N.category() Category of facade infinite sets with grading >>> N.grading_set() Non negative integers
The grading function is given by
N.grading
:sage: N.grading(4) 4
>>> from sage.all import * >>> N.grading(Integer(4)) 4
The graded component \(N_i\) is the set with one element \(i\):
sage: N.graded_component(grade=5) {5} sage: N.graded_component(grade=42) {42}
>>> from sage.all import * >>> N.graded_component(grade=Integer(5)) {5} >>> N.graded_component(grade=Integer(42)) {42}
Here are some information about this category:
sage: SetsWithGrading() Category of sets with grading sage: SetsWithGrading().super_categories() [Category of sets] sage: SetsWithGrading().all_super_categories() [Category of sets with grading, Category of sets, Category of sets with partial maps, Category of objects]
>>> from sage.all import * >>> SetsWithGrading() Category of sets with grading >>> SetsWithGrading().super_categories() [Category of sets] >>> SetsWithGrading().all_super_categories() [Category of sets with grading, 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[source]#
Bases:
object
- generating_series()[source]#
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() # needs 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.
- graded_component(grade)[source]#
Return the graded component of
self
with gradegrade
.The default implementation just calls the method
subset()
with the first argumentgrade
.EXAMPLES:
sage: N = SetsWithGrading().example(); N Non negative integers sage: N.graded_component(3) {3}
>>> from sage.all import * >>> N = SetsWithGrading().example(); N Non negative integers >>> N.graded_component(Integer(3)) {3}
- grading(elt)[source]#
Return the grading of the element
elt
ofself
.This default implementation calls
elt.grade()
.EXAMPLES:
sage: N = SetsWithGrading().example(); N Non negative integers sage: N.grading(4) 4
>>> from sage.all import * >>> N = SetsWithGrading().example(); N Non negative integers >>> N.grading(Integer(4)) 4
- grading_set()[source]#
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
>>> from sage.all import * >>> SetsWithGrading().example().grading_set() Non negative integers
- subset(*args, **options)[source]#
Return the subset of
self
described by the given parameters.See also
EXAMPLES:
sage: W = WeightedIntegerVectors([3,2,1]); W # needs sage.combinat Integer vectors weighted by [3, 2, 1] sage: W.subset(4) # needs sage.combinat Integer vectors of 4 weighted by [3, 2, 1]
>>> from sage.all import * >>> W = WeightedIntegerVectors([Integer(3),Integer(2),Integer(1)]); W # needs sage.combinat Integer vectors weighted by [3, 2, 1] >>> W.subset(Integer(4)) # needs sage.combinat Integer vectors of 4 weighted by [3, 2, 1]