Ask Your Question

implement algebras with some extra structure

asked 2019-09-03 21:05:43 +0100

heluani gravatar image

updated 2019-09-04 13:52:20 +0100

I seem not to be understanding the way to implement categories with extra structure. Suppose I want to implement the category Cs of pairs (A,S) where A is a QQ-algebra and S is a linear endomorphism of A with the obvious morphisms. Algebras(QQ) is a full subcategory of Cs by adding the zero endormophism. And we also have the forgetful functor from Cs to Algebras(QQ) which consists to simply forget S.

Now from reading the examples in or I could set up

class Cs(Category)
    def super_categories(self):

And that woul d give me a canonical forgetful functor Cs -> Algebras(QQ). Now my problem is when I want to create a parent of Cs() starting from a parent in Algebras(QQ). That is, I could set up a new parent and elements which will have to implement the methods for Algebras(QQ):

sage: from sage.misc.abstract_method import abstract_methods_of_class
sage: abstract_methods_of_class(Algebras(QQ).parent_class)
{'optional': ['algebra_generators'], 'required': ['__contains__']}
sage: abstract_methods_of_class(Algebras(QQ).element_class)
{'optional': ['_add_', '_mul_'], 'required': ['__nonzero__']}

But instead of implementing those methods I would want to use the methods of the underlying parent of Algebras(QQ). Something like a hypothetical PolynomialRing(QQ, 'x', category=Cs()). In other words I'm looking to implement the functor A -> (A, 0) above.

Finally I have similar concerns about implementing Cs() in the other two possible ways, namely as the subcategory of the category of arrows in VectorSpaces(QQ) with the same source and target an object from Algebras(QQ), or as a super category of Algebras(QQ) using _subcategory_hook_. Always I get to the point where I don't know how to implement something like PolynomialRing(QQ, category=Cs()). What I am doing now is keeping a copy of the algebra A inside of an instance of Cs.parent_class and then implementing the element and parent mehods of Algebras(QQ) by pointing to the corresponding methods of A but that seems silly. I'd appreciate any pointer.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-06 11:43:55 +0100

heluani gravatar image

What I found was the easiest is to define my parents as inheriting from the corresponding objects from Algebras(QQ), and then reset the category using Parent's methods since I am guaranteed to have a subcategory. For example

 def CParent (MPolynomialRing_libsingular)
    def __init__(self, n, names, order)
        self._somedata = somevalue
        super(CParent, self).__init__(QQ, n, names, order)

This way I don't even need to implement an element class and I can focus on morphisms which is the only thing that changes in this category.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-09-03 21:05:43 +0100

Seen: 272 times

Last updated: Sep 06 '19