Implementing a new parent: a (draft of) tutorialΒΆ


The easiest approach for implementing a new parent is to start from a close example in sage.categories.examples. Here, we will get through the process of implementing a finite semigroup. Start by copy-pasting the code of the class sage.categories.examples.finite_semigroups.LeftRegularBand into, say, a cell of the notebook. and query-replace every occurence of FiniteSemigroups().example(...) in the documentation by LeftRegularBand.

This will be equivalent to:

sage: from sage.categories.examples.finite_semigroups import LeftRegularBand

Now, try:

sage: S = LeftRegularBand(); S
An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')

and play around with the examples in the documentation of S.

Rename the class to ShiftSemigroup, and modify the product to implement the semigroup generated by the given alphabet such that au
= u for any u of length 3.

Use TestSuite to test the newly implemented semigroup, and draw its Cayley graph.

Add another option to the constructor to generalize the construction to any u of length k.

Lookup the Sloane for the sequence of the sizes of those semigroups.

Now implement the commutative monoid of subsets of \{1,\dots,n\} endowed with union as product. What is its category? What are the extra functionalities available there? Implement iteration and cardinality.

TODO: the tutorial should explain there how to reuse the enumerated set of subsets, and endow it with more structure.

Previous topic

Elements, parents, and categories in Sage: a (draft of) primer

Next topic

Categories

This Page