### Navigation

- index
- modules |
- next |
- previous |
- Category Theory »

# Covariant Functorial Constructions

A functorial construction is a collection of functors \((F_{Cat})_{Cat}\) (indexed by a collection of categories) which associate to a sequence of parents \((A, B, ...)\) in a category \(Cat\) a parent \(F_{Cat}(A, B, ...)\). Typical examples of functorial constructions are `cartesian_product` and `tensor_product`.

The category of \(F_{Cat}(A, B, ...)\), which only depends on \(Cat\), is called the (functorial) construction category.

A functorial construction is (category)-covariant if for every categories \(Cat\) and \(SuperCat\), the category of \(F_{Cat}(A, B, ...)\) is a subcategory of the category of \(F_{SuperCat}(A, B, ...)\) whenever \(Cat\) is a subcategory of \(SuperCat\). A functorial construction is (category)-regressive if the category of \(F_{Cat}(A, B, ...)\) is a subcategory of \(Cat\).

The goal of this module is to provide generic support for covariant functorial constructions. In particular, given some parents \(A\), \(B\), ..., in respective categories \(Cat_A\), \(Cat_B\), ..., it provides tools for calculating the best known category for the parent \(F(A,B,...)\). For examples, knowing that cartesian products of semigroups (resp. monoids, groups) have a semigroup (resp. monoid, group) structure, and given a group \(B\) and two monoids \(A\) and \(C\) it can calculate that \(A \times B \times C\) is naturally endowed with a monoid structure.

See `CovariantFunctorialConstruction`, `CovariantConstructionCategory` and `RegressiveCovariantConstructionCategory` for more details.

AUTHORS:

> - Nicolas M. Thiery (2010): initial revision

class `sage.categories.covariant_functorial_construction.``CovariantConstructionCategory`(category, *args)

  Bases: `sage.categories.covariant_functorial_construction.FunctorialConstructionCategory`

  Abstract class for categories \(F_{Cat}\) obtained through a covariant functorial construction

  `additional_structure`()

    Return the additional structure defined by `self`.

    By default, a functorial construction category `A.F()` defines additional structure if and only if \(A\) is the category defining \(F\). The rationale is that, for a subcategory \(B\) of \(A\), the fact that \(B.F()\) morphisms shall preserve the \(F\)-specific structure is already imposed by \(A.F()\).

    See also

    - `Category.additional_structure()`.
    - `is_construction_defined_by_base()`.

    EXAMPLES:

    > sage: Modules(ZZ).Graded().additional_structure() Category of graded modules over Integer Ring sage: Algebras(ZZ).Graded().additional_structure()

    TESTS:

        sage: Modules(ZZ).Graded().additional_structure.__module__
        'sage.categories.covariant_functorial_construction'

  classmethod `default_super_categories`(category, *args)

    Return the default super categories of \(F_{Cat}(A,B,...)\) for \(A,B,...\) parents in \(Cat\).

    INPUT:

    > - `cls` – the category class for the functor \(F\)
    > - `category` – a category \(Cat\)
    > - `*args` – further arguments for the functor

    OUTPUT: a (join) category

    The default implementation is to return the join of the categories of \(F(A,B,...)\) for \(A,B,...\) in turn in each of the super categories of `category`.

    This is implemented as a class method, in order to be able to reconstruct the functorial category associated to each of the super categories of `category`.

    EXAMPLES:

    Bialgebras are both algebras and coalgebras:

        sage: Bialgebras(QQ).super_categories()
        [Category of algebras over Rational Field, Category of coalgebras over Rational Field]

    Hence tensor products of bialgebras are tensor products of algebras and tensor products of coalgebras:

        sage: Bialgebras(QQ).TensorProducts().super_categories()
        [Category of tensor products of algebras over Rational Field, Category of tensor products of coalgebras over Rational Field]

    Here is how `default_super_categories()` was called internally:

        sage: sage.categories.tensor.TensorProductsCategory.default_super_categories(Bialgebras(QQ))
        Join of Category of tensor products of algebras over Rational Field and Category of tensor products of coalgebras over Rational Field

    We now show a similar example, with the `Algebra` functor which takes a parameter \(\QQ\):

        sage: FiniteMonoids().super_categories()
        [Category of monoids, Category of finite semigroups]
        sage: sorted(FiniteMonoids().Algebras(QQ).super_categories(), key=str)
        [Category of finite dimensional algebras with basis over Rational Field,
         Category of finite set algebras over Rational Field,
         Category of monoid algebras over Rational Field]

    Note that neither the category of finite semigroup algebras nor that of monoid algebras appear in the result; this is because there is currently nothing specific implemented about them.

    Here is how `default_super_categories()` was called internally:

        sage: sage.categories.algebra_functor.AlgebrasCategory.default_super_categories(FiniteMonoids(), QQ)
        Join of Category of finite dimensional algebras with basis over Rational Field
            and Category of monoid algebras over Rational Field
            and Category of finite set algebras over Rational Field

  `is_construction_defined_by_base`()

    Return whether the construction is defined by the base of `self`.

    EXAMPLES:

    The graded functorial construction is defined by the modules category. Hence this method returns `True` for graded modules and `False` for other graded xxx categories:

        sage: Modules(ZZ).Graded().is_construction_defined_by_base()
        True
        sage: Algebras(QQ).Graded().is_construction_defined_by_base()
        False
        sage: Modules(ZZ).WithBasis().Graded().is_construction_defined_by_base()
        False

    This is implemented as follows: given the base category \(A\) and the construction \(F\) of `self`, that is `self=A.F()`, check whether no super category of \(A\) has \(F\) defined.

    Note

    Recall that, when \(A\) does not implement the construction `F`, a join category is returned. Therefore, in such cases, this method is not available:

        sage: Coalgebras(QQ).Graded().is_construction_defined_by_base()
        Traceback (most recent call last):
        ...
        AttributeError: 'JoinCategory_with_category' object has no attribute 'is_construction_defined_by_base'

class `sage.categories.covariant_functorial_construction.``CovariantFunctorialConstruction`

  Bases: `sage.structure.unique_representation.UniqueRepresentation`, `sage.structure.sage_object.SageObject`

  An abstract class for construction functors \(F\) (eg \(F\) = cartesian product, tensor product, \(\QQ\)-algebra, ...) such that:

  > - Each category \(Cat\) (eg \(Cat=\) `Groups()`) can provide a category \(F_{Cat}\) for parents constructed via this functor (e.g. \(F_{Cat} =\) `CartesianProductsOf(Groups())`).
  > - For every category \(Cat\), \(F_{Cat}\) is a subcategory of \(F_{SuperCat}\) for every super category \(SuperCat\) of \(Cat\) (the functorial construction is (category)-covariant).
  > - For parents \(A\), \(B\), ..., respectively in the categories \(Cat_A\), \(Cat_B\), ..., the category of \(F(A,B,...)\) is \(F_{Cat}\) where \(Cat\) is the meet of the categories \(Cat_A\), \(Cat_B\), ...,.

  This covers two slightly different use cases:

  > - In the first use case, one uses directly the construction functor to create new parents:

  >       sage: tensor()  # todo: not implemented (add an example)

  >   or even new elements, which indirectly constructs the corresponding parent:

  >       sage: tensor(...) # todo: not implemented

  > - In the second use case, one implements a parent, and then put it in the category \(F_{Cat}\) to specify supplementary mathematical information about that parent.

  The main purpose of this class is to handle automatically the trivial part of the category hierarchy. For example, `CartesianProductsOf(Groups())` is set automatically as a subcategory of `CartesianProductsOf(Monoids())`.

  In practice, each subclass of this class should provide the following attributes:

  > - `_functor_category` - a string which should match the name of the nested category class to be used in each category to specify information and generic operations for elements of this category.
  > - `_functor_name` - an string which specifies the name of the functor, and also (when relevant) of the method on parents and elements used for calling the construction.

  TODO: What syntax do we want for \(F_{Cat}\)? For example, for the tensor product construction, which one of the followings do we want (see chat on IRC, on 07/12/2009):

  > - `tensor(Cat)`
  > - `tensor((Cat, Cat))`
  > - `tensor.of((Cat, Cat))`
  > - `tensor.category_from_categories((Cat, Cat, Cat))`
  > - `Cat.TensorProducts()`

  The syntax `Cat.TensorProducts()` does not supports well multivariate constructions like `tensor.of([Algebras(), HopfAlgebras(), ...])`. Also it forces every category to be (somehow) aware of all the tensorial construction that could apply to it, even those which are only induced from super categories.

  Note: for each functorial construction, there probably is one (or several) largest categories on which it applies. For example, the `CartesianProducts()` construction makes only sense for concrete categories, that is subcategories of `Sets()`. Maybe we want to model this one way or the other.

  `category_from_categories`(categories)

    Return the category of \(F(A,B,...)\) for \(A,B,...\) parents in the given categories.

    INPUT:

    > - `self`: a functor \(F\)
    > - `categories`: a non empty tuple of categories

    EXAMPLES:

        sage: Cat1 = Rings()
        sage: Cat2 = Groups()
        sage: cartesian_product.category_from_categories((Cat1, Cat1, Cat1))
        Join of Category of rings and ...
            and Category of Cartesian products of monoids
            and Category of Cartesian products of commutative additive groups

        sage: cartesian_product.category_from_categories((Cat1, Cat2))
        Category of Cartesian products of monoids

  `category_from_category`(category)

    Return the category of \(F(A,B,...)\) for \(A,B,...\) parents in `category`.

    INPUT:

    > - `self`: a functor \(F\)
    > - `category`: a category

    EXAMPLES:

        sage: tensor.category_from_category(ModulesWithBasis(QQ))
        Category of tensor products of vector spaces with basis over Rational Field

    # TODO: add support for parametrized functors

  `category_from_parents`(parents)

    Return the category of \(F(A,B,...)\) for \(A,B,...\) parents.

    INPUT:

    > - self: a functor F
    > - parents: a list (or iterable) of parents.

    EXAMPLES:

        sage: E = CombinatorialFreeModule(QQ, ["a", "b", "c"])
        sage: tensor.category_from_parents((E, E, E))
        Category of tensor products of vector spaces with basis over Rational Field

class `sage.categories.covariant_functorial_construction.``FunctorialConstructionCategory`(category, *args)

  Bases: `sage.categories.category.Category`

  Abstract class for categories \(F_{Cat}\) obtained through a functorial construction

  `base_category`()

    Return the base category of the category `self`.

    For any category `B` = \(F_{Cat}\) obtained through a functorial construction \(F\), the call `B.base_category()` returns the category \(Cat\).

    EXAMPLES:

        sage: Semigroups().Quotients().base_category()
        Category of semigroups

  classmethod `category_of`(category, *args)

    Return the image category of the functor \(F_{Cat}\).

    This is the main entry point for constructing the category \(F_{Cat}\) of parents \(F(A,B,...)\) constructed from parents \(A,B,...\) in \(Cat\).

    INPUT:

    > - `cls` – the category class for the functorial construction \(F\)
    > - `category` – a category \(Cat\)
    > - `*args` – further arguments for the functor

    EXAMPLES:

        sage: sage.categories.tensor.TensorProductsCategory.category_of(ModulesWithBasis(QQ))
        Category of tensor products of vector spaces with basis over Rational Field

        sage: sage.categories.algebra_functor.AlgebrasCategory.category_of(FiniteMonoids(), QQ)
        Join of Category of finite dimensional algebras with basis over Rational Field
            and Category of monoid algebras over Rational Field
            and Category of finite set algebras over Rational Field

  `extra_super_categories`()

    Return the extra super categories of a construction category.

    Default implementation which returns `[]`.

    EXAMPLES:

        sage: Sets().Subquotients().extra_super_categories()
        []
        sage: Semigroups().Quotients().extra_super_categories()
        []

  `super_categories`()

    Return the super categories of a construction category.

    EXAMPLES:

        sage: Sets().Subquotients().super_categories()
        [Category of sets]
        sage: Semigroups().Quotients().super_categories()
        [Category of subquotients of semigroups, Category of quotients of sets]

class `sage.categories.covariant_functorial_construction.``RegressiveCovariantConstructionCategory`(category, *args)

  Bases: `sage.categories.covariant_functorial_construction.CovariantConstructionCategory`

  Abstract class for categories \(F_{Cat}\) obtained through a regressive covariant functorial construction

  classmethod `default_super_categories`(category, *args)

    Return the default super categories of \(F_{Cat}(A,B,...)\) for \(A,B,...\) parents in \(Cat\).

    INPUT:

    - `cls` – the category class for the functor \(F\)
    - `category` – a category \(Cat\)
    - `*args` – further arguments for the functor

    OUTPUT:

    A join category.

    This implements the property that an induced subcategory is a subcategory.

    EXAMPLES:

    A subquotient of a monoid is a monoid, and a subquotient of semigroup:

        sage: Monoids().Subquotients().super_categories()
        [Category of monoids, Category of subquotients of semigroups]

    TESTS:

        sage: C = Monoids().Subquotients()
        sage: C.__class__.default_super_categories(C.base_category(), *C._args)
        Category of unital subquotients of semigroups

### Navigation

- index
- modules |
- next |
- previous |
- Category Theory »