# using inheritance to create a new Parent class

I have an algebra (and a group as well) I would like to represent in Sage. In fact, the code for doing this is already written, but the structures do not inherit from any existing Sage structures, and lately I have also been finding bugs in the algebraic manipulations. I would like to make this code compatible with the larger Sage framework by correctly using inheritance. I found this article: http://flask.sagenb.org/home/pub/82/, from which I understand that there is a way to inherit from a generic "algebra" parent and thus get a lot of bug-free structure. My problem is that this article discusses only the specific example of a field, and I don't know where to begin with my algebra. In particular, the article says, "When implementing a parent in Sage, one should start with a class that inherits from :class:sage.structure.parent.Parent," - where can I find a list of such classes? The example inherits from the derived class "sage.rings.field.Field". I do not know where to find the class analogous to this for algebras (or groups). I also need lots of documentation explaining what the algebra (and group) parent comes with.

Thank you!

edit retag close merge delete

Sort by » oldest newest most voted

The best thing to do is to use the source. The group algebra of a group is implemented nicely in SAGE_ROOT/devel/sage/sage/categories/examples/hopf_algebras_with_basis.py, in a way which works well with inheritance and the category structure in Sage. See also the patches at http://trac.sagemath.org/sage_trac/ticket/6670, for a very similar implementation, but one which also implements coercion.

This implementation doesn't inherit from a generic algebra structure, but instead from CombinatorialFreeModule (an implementation of free modules which is well suited to incorporating algebraic structures), and then sets the category appropriately, which helps to automatically implement some structure.

The patches at http://trac.sagemath.org/sage_trac/ticket/10052 (merged into prerelease versions of Sage 4.7.1) does something similar to implement the Steenrod algebra and its sub-Hopf algebras.

more