# Covariant Functorial Constructions¶

A functorial construction is a collection of functors $$(F_{Cat})_{Cat}$$ which associate to parents $$A, B, ...$$ in some category $$Cat$$ a parent $$F_{Cat}(A, B, ...)$$. Examples of functorial constructions are $$F$$ = cartesian product, tensor product, $$\QQ$$-algebras, ... 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 parent $$A$$, $$B$$, $$C$$ of respective categories $$Cat_A$$, $$Cat_B$$, $$Cat_C$$, it provide tools for calculating the best known category for the parent $$F(A,B,C)$$. For examples, knowing that cartesian products of semigroups (resp. monoids, groups), have a structure of semigroups (resp. monoids, groups), 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.

AUTHORS:

• Nicolas M. Thiery (2010): initial revision
class sage.categories.covariant_functorial_construction.CovariantConstructionCategory(category, *args)

Abstract class for categories $$F_{Cat}$$ obtained through a covariant functorial construction

base_category()

Returns 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)

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

INPUT:

• cls – the category class for the functorial construction $$F$$
• category – a category $$Cat$$
• *args – further arguments for the functor

OUTPUT: the image category of the functor $$F_{Cat}$$

EXAMPLES:

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

sage: sage.categories.algebra_functor.AlgebrasCategory.category_of(FiniteMonoids(), QQ)
Category of monoid algebras over Rational Field

classmethod default_super_categories(category, *args)

Returns the default super categories of $$F_{Cat}(A,B,C)$$ for $$A,B,C$$ 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,C)$$ for $$A,B,C$$ 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 finite semigroups, Category of monoids]
sage: FiniteMonoids().Algebras(QQ).super_categories()
[Category of semigroup 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)
Category of monoid algebras over Rational Field

extra_super_categories()

Returns 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()

Returns 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.CovariantFunctorialConstruction

An abstract class for construction functors $$F$$ (eg $$F$$ = cartesian product, tensor product, $$\QQ$$-algebras, ...) 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$$, $$C$$ respectively in the categories $$Cat_A$$, $$Cat_B$$, $$Cat_C$$, the category of $$F(A,B,C)$$ is $$F_{Cat}$$ where $$Cat$$ is the meet of the categories $$Cat_A$$, $$Cat_B$$, $$Cat_C$$.

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 hiearchy. 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)

Returns the category of $$F(A,B,C)$$ for $$A,B,C$$ 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))
Category of Cartesian products of monoids

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

category_from_category(category)

Returns the category of $$F(A,B,C)$$ for $$A,B,C$$ parents in category

INPUT:

• self: a functor $$F$$
• category: a category

EXAMPLES:

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


# TODO: add support for parametrized functors

category_from_parents(parents)

Returns the category of $$F(A,B,C)$$ for $$A,B,C$$ 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)) # todo: not implemented (see upcoming category patch #5985)

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

Abstract class for categories $$F_{Cat}$$ obtained through a regressive covariant functorial construction

classmethod default_super_categories(category, *args)

Returns the default super categories of ...

INPUT:

• category – a category

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)
Join of Category of monoids and Category of subquotients of semigroups


#### Previous topic

Coercion via Construction Functors

#### Next topic

Cartesian Product Functorial Construction