Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

is an object of a subcategory an object of the ambient category?

I have defined a category Cs() and its subcategory Ds() as follows:


class Cs(Category_over_base_ring):
    ...
    def __init__(self, K):
       Category_over_base_ring.__init__(self, K)

    def super_categories(self):
        return [ GradedAlgebras(self.base_field()) ] 

class Ds(CategoryWithAxiom):
    _base_category_class_and_axiom = (GradedAlgebrasWithDerivation, 'Commutative')    

Cs.Commutative = Ds
The omitted code I think its irrelevant. I can check that `Ds()` is a subcategory of `Cs()`:

sage: C = Cs(QQ)
sage: D = Ds(QQ)
sage: D.is_subcategory(C) 
True
sage: 
Now I create a parent of `Ds()` as follows:

class DParent (Parent,UniqueRepresentation):
    def __init__(self,K, *args, **kwds ): 
        if not (K in Fields() or \
            (isinstance(K, Category) and K.is_subcategory(Fields()))):
            raise ValueError(
                "base must be a field or a subcategory of Fields(); got {}".format(K))
        self._base_algebra = PolynomialRing(K,*args,**kwds)
        super(DParent,self).__init__(self,
            category=Ds(K))
...
And I can check that these parents are objects of `Ds()` but not of `Cs()`:

sage: J = DParent(QQ, 1, 'x', order=TermOrder('wdeglex', (2,)))
sage: J in C
False
sage: J in D
True

Where can I be making a mistake?

is an object of a subcategory an object of the ambient category?

I have defined a category Cs() and its subcategory Ds() as follows:


class Cs(Category_over_base_ring):
    ...
    def __init__(self, K):
       Category_over_base_ring.__init__(self, K)

    def super_categories(self):
        return [ GradedAlgebras(self.base_field()) ] 

class Ds(CategoryWithAxiom):
    _base_category_class_and_axiom = (GradedAlgebrasWithDerivation, 'Commutative')    

Cs.Commutative = Ds

The omitted code I think its irrelevant. I can check that `Ds()` Ds() is a subcategory of `Cs()`: Cs():


sage: C = Cs(QQ)
sage: D = Ds(QQ)
sage: D.is_subcategory(C) 
True
sage: 

Now I create a parent of `Ds()` Ds() as follows: follows:


class DParent (Parent,UniqueRepresentation):
    def __init__(self,K, *args, **kwds ): 
        if not (K in Fields() or \
            (isinstance(K, Category) and K.is_subcategory(Fields()))):
            raise ValueError(
                "base must be a field or a subcategory of Fields(); got {}".format(K))
        self._base_algebra = PolynomialRing(K,*args,**kwds)
        super(DParent,self).__init__(self,
            category=Ds(K))
...

And I can check that these parents are objects of `Ds()` Ds() but not of `Cs()`: Cs():


sage: J = DParent(QQ, 1, 'x', order=TermOrder('wdeglex', (2,)))
sage: J in C
False
sage: J in D
True

Where can I be making a mistake?

mistake?

is an object of a subcategory an object of the ambient category?

I have defined a category Cs() and its subcategory Ds() as follows:


class Cs(Category_over_base_ring):
    ...
    def __init__(self, K):
       Category_over_base_ring.__init__(self, K)

    def super_categories(self):
        return [ GradedAlgebras(self.base_field()) ] 

class Ds(CategoryWithAxiom):
    _base_category_class_and_axiom = (GradedAlgebrasWithDerivation, (Cs, 'Commutative')    

Cs.Commutative = Ds

The omitted code I think its irrelevant. I can check that Ds() is a subcategory of Cs():


sage: C = Cs(QQ)
sage: D = Ds(QQ)
sage: D.is_subcategory(C) 
True
sage: 

Now I create a parent of Ds() as follows:


class DParent (Parent,UniqueRepresentation):
    def __init__(self,K, *args, **kwds ): 
        if not (K in Fields() or \
            (isinstance(K, Category) and K.is_subcategory(Fields()))):
            raise ValueError(
                "base must be a field or a subcategory of Fields(); got {}".format(K))
        self._base_algebra = PolynomialRing(K,*args,**kwds)
        super(DParent,self).__init__(self,
            category=Ds(K))
...

And I can check that these parents are objects of Ds() but not of Cs():


sage: J = DParent(QQ, 1, 'x', order=TermOrder('wdeglex', (2,)))
sage: J in C
False
sage: J in D
True

Where can I be making a mistake?

is an object of a subcategory an object of the ambient category?

I have defined a category Cs() and its subcategory Ds() as follows:


class Cs(Category_over_base_ring):
    ...
    def __init__(self, K):
       Category_over_base_ring.__init__(self, K)

    def super_categories(self):
        return [ GradedAlgebras(self.base_field()) ] 

class Ds(CategoryWithAxiom):
    _base_category_class_and_axiom = (Cs, 'Commutative')    

Cs.Commutative = Ds

The omitted code I think its irrelevant. I can check that Ds() is a subcategory of Cs():


sage: C = Cs(QQ)
sage: D = Ds(QQ)
sage: D.is_subcategory(C) 
True
sage: 

Now I create a parent of Ds() as follows:


class DParent (Parent,UniqueRepresentation):
    def __init__(self,K, *args, **kwds ): 
        if not (K in Fields() or \
            (isinstance(K, Category) and K.is_subcategory(Fields()))):
            raise ValueError(
                "base must be a field or a subcategory of Fields(); got {}".format(K))
        self._base_algebra = PolynomialRing(K,*args,**kwds)
        super(DParent,self).__init__(self,
            category=Ds(K))
...

And I can check that these parents are objects of Ds() but not of Cs():


sage: J = DParent(QQ, 1, 'x', order=TermOrder('wdeglex', (2,)))
sage: J in C
False
sage: J in D
True

Where can I be making a mistake?

Addition: I am looking at the implementation in sage/categories/category.py and I am more puzzled:

sage: J.category().is_subcategory(C)
True
sage: C.__contains__(J)
False

But at least I get


sage: c = J.categories()
sage: any(isinstance(cat,C.subcategory_class) for cat in c)
True
sage: C.__classcontains__(C.subcategory_class,J)
True
sage: