Categories

AUTHORS:

  • David Kohel and William Stein

Every Sage object lies in a category. Categories in Sage are modeled on the mathematical idea of category, and are distinct from Python classes, which are a programming construct.

In most cases, typing x.category() returns the category to which x belongs. If C is a category and x is any object, C(x) tries to make an object in C from x.

EXAMPLES: We create a couple of categories.

sage: Sets()
Category of sets
sage: GSets(AbelianGroup([2,4,9]))
Category of G-sets for Multiplicative Abelian Group isomorphic to C2 x C4 x C9
sage: Semigroups()
Category of semigroups
sage: VectorSpaces(FiniteField(11))
Category of vector spaces over Finite Field of size 11
sage: Ideals(IntegerRing())
Category of ring ideals in Integer Ring

The default category for elements x of an objects O is the category of all objects of O. For example,

sage: V = VectorSpace(RationalField(), 3)
sage: x = V.gen(1)
sage: x.category()
Category of elements of Vector space of dimension 3 over Rational Field
class sage.categories.category.Category(s=None)

The base class for all categories.

__call__(x)
__contains__(x)
__eq__(c)
__hash__()
__init__(s=None)
__weakref__
list of weak references to the object (if defined)
_call_(x)
_is_subclass(c)
_latex_()
_parameters()
_repr_()
category()
is_abelian()
is_subcategory(c)

Returns True if self is naturally embedded as a subcategory of c.

EXAMPLES:

sage: Rings  = Rings()
sage: AbGrps = AbelianGroups()
sage: Rings.is_subcategory(AbGrps)
True
sage: AbGrps.is_subcategory(Rings)
False

The is_subcategory function takes into account the base.

sage: M3 = VectorSpaces(FiniteField(3))
sage: M9 = VectorSpaces(FiniteField(9, 'a'))
sage: M3.is_subcategory(M9)
False
short_name()
class sage.categories.category.Category_uniq(s=None)
class sage.categories.category.Sets(s=None)

The category of sets.

EXAMPLES:
sage: Sets() Category of sets
__call__(X)
EXAMPLES:
sage: Sets()(ZZ) Set of elements of Integer Ring
__reduce__()

For pickling.

TESTS:
sage: loads(dumps(Sets())) is Sets() True
sage.categories.category.is_Category(x)
Returns True if x is a category.
class sage.categories.category.uniq
static __new__()
__weakref__
list of weak references to the object (if defined)
class sage.categories.category.uniq1
static __new__(arg1)
__weakref__
list of weak references to the object (if defined)

Previous topic

Category Theory

Next topic

Homsets

This Page