8.1 Categories

Module: sage.categories.category

Author: 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$ .

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

Module-level Functions

Schemes( [X=None])

is_Category( x)

Returns True if x is a category.

Class: AbelianCategory

class AbelianCategory

Functions: is_abelian

Class: AbelianGroups

class AbelianGroups
The category of all abelian groups.

sage: AbelianGroups()
Category of abelian groups

Special Functions: __reduce__

__reduce__( self)

sage: C = AbelianGroups()
sage: loads(C.dumps()) == C
True

Class: AbelianMonoids

class AbelianMonoids
The category of all monoids.

sage: AbelianMonoids()
Category of abelian monoids

Special Functions: __reduce__

__reduce__( self)

sage: C = AbelianMonoids()
sage: loads(C.dumps()) == C
True

Class: AbelianSemigroups

class AbelianSemigroups
The category of all abelian semigroups.

sage: AbelianSemigroups()
Category of abelian semigroups

Special Functions: __reduce__

__reduce__( self)

sage: C = AbelianSemigroups()
sage: loads(C.dumps()) == C
True

Class: AlgebraIdeals

class AlgebraIdeals
The category of ideals in a fixed algebra $ A$ .

sage: C = AlgebraIdeals(FreeAlgebra(QQ,2))
sage: loads(C.dumps()) == C
True
AlgebraIdeals( self, A)

Functions: algebra

Special Functions: __reduce__

Class: AlgebraModules

class AlgebraModules
The category of modules over a fixed algebra $ A$ .
AlgebraModules( self, A)

Functions: algebra

Special Functions: __reduce__

__reduce__( self)

sage: C = AlgebraModules(FreeAlgebra(QQ,2))
sage: loads(C.dumps()) == C
True

Class: Algebras

class Algebras
The category of algebras over a fixed base ring.

Functions: base_field

base_field( self)

Return the base field over which the algebras of this category are all defined.

Special Functions: __contains__,$  $ __reduce__

__reduce__( self)

sage: C = Algebras(ZZ)
sage: loads(C.dumps()) == C
True

Class: CommutativeAlgebraIdeals

class CommutativeAlgebraIdeals
The category of ideals in a fixed commutative algebra $ A$ .
CommutativeAlgebraIdeals( self, A)

Functions: algebra

Special Functions: __reduce__

__reduce__( self)

Class: CommutativeAlgebras

class CommutativeAlgebras
The category of commutative algebras over a given base ring.

sage: M = CommutativeAlgebras(GF(19))
sage: M
Category of commutative algebras over Finite Field of size 19

Special Functions: __reduce__

__reduce__( self)

sage: C = CommutativeAlgebras(ZZ)
sage: loads(C.dumps()) == C
True

Class: CommutativeRingIdeals

class CommutativeRingIdeals
The category of ideals in a fixed commutative ring.

sage: C = CommutativeRingIdeals(IntegerRing())
sage: C
Category of commutative ring ideals in Integer Ring
CommutativeRingIdeals( self, R)

Special Functions: __reduce__

__reduce__( self)

sage: C = CommutativeRingIdeals(ZZ)
sage: loads(C.dumps()) == C
True

Class: CommutativeRings

class CommutativeRings
The category of commutative rings.

sage: CommutativeRings()
Category of commutative rings

Special Functions: __reduce__

__reduce__( self)

sage: C = CommutativeRings()
sage: loads(C.dumps()) == C
True

Class: Elements

class Elements
The category of all elements of a given object.

sage: a = IntegerRing()(5)
sage: C = a.category(); C
Category of elements of Integer Ring
sage: a in C
True
sage: 2/3 in C
False
sage: loads(C.dumps()) == C
True
Elements( self, object)

Functions: object

Special Functions: __reduce__,$  $ _call_,$  $ _latex_,$  $ _repr_

_call_( self, x)

sage: V = VectorSpace(QQ,3)
sage: x = V.0
sage: C = x.category()
sage: C
Category of elements of Vector space of dimension 3 over Rational Field
sage: w = C([1,2,3]); w
(1, 2, 3)
sage: w.category()
Category of elements of Vector space of dimension 3 over Rational Field

Class: Fields

class Fields
The category of fields.

sage: K = Fields()
sage: K
Category of fields
sage: K(IntegerRing())
Rational Field
sage: K(PolynomialRing(GF(3)))
Fraction Field of Univariate Polynomial Ring in x over
Finite Field of size 3
sage: K(RealField())
Real Field with 53 bits of precision

Special Functions: __call__,$  $ __contains__,$  $ __reduce__

__reduce__( self)

sage: C = Fields()
sage: loads(C.dumps()) == C
True

Class: FiniteFields

class FiniteFields
The category of all finite fields.

sage: K = FiniteFields()
sage: K
Category of finite fields
sage: FiniteField(17) in K
True
sage: RationalField() in K
False
sage: K(RationalField())
Traceback (most recent call last):
...
TypeError: unable to canonically associate a finite field to Rational Field

Special Functions: __call__,$  $ __contains__,$  $ __reduce__

__reduce__( self)

sage: C = FiniteFields()
sage: loads(C.dumps()) == C
True

Class: FreeModules

class FreeModules
The category of free modules over a base ring.

sage: FreeModules(IntegerRing())
Category of free modules over Integer Ring
FreeModules( self, R)

Functions: is_abelian

Special Functions: __call__,$  $ __reduce__

__reduce__( self)

sage: C = FreeModules(ZZ)
sage: loads(C.dumps()) == C
True

Class: GroupAlgebras

class GroupAlgebras

sage: GroupAlgebras(IntegerRing())
Category of group algebras over Integer Ring

Special Functions: __reduce__

__reduce__( self)

sage: C = GroupAlgebras(ZZ)
sage: loads(C.dumps()) == C
True

Class: Groups

class Groups
The category of groups.

sage: Groups()
Category of groups

Special Functions: __reduce__

__reduce__( self)

sage: C = Groups()
sage: loads(C.dumps()) == C
True

Class: GSets

class GSets
The category of $ G$ -sets, for a group $ G$ .

sage: S = SymmetricGroup(3)
sage: GSets(S)
Category of G-sets for Symmetric group of order 3! as a permutation group
GSets( self, G)

Special Functions: __reduce__,$  $ __repr__

__reduce__( self)

sage: S8 = SymmetricGroup(8)
sage: C = GSets(S8)
sage: loads(C.dumps()) == C
True

Class: HeckeModules

class HeckeModules
The category of Hecke modules.

A Hecke module is a module $ M$ over the anemic Hecke algebra, i.e., the Hecke algebra generated by Hecke operators $ T_n$ with $ n$ coprime to the level of $ M$ . (Every Hecke module defines a level function, which is a positive integer.) The reason we require that $ M$ only be a module over the anemic Hecke algebra is that many natural maps, e.g., degeneracy maps, Atkin-Lehner operators, etc., are $ \mathbf{T}$ -module homomorphisms; but they are homomorphisms over the anemic Hecke algebra.

We create the category of Hecke modules over $ \mathbf{Q}$ .

sage: C = HeckeModules(RationalField()); C
Category of Hecke modules over Rational Field

Note that the base ring can be an arbitrary commutative ring.

sage: HeckeModules(IntegerRing())
Category of Hecke modules over Integer Ring
sage: HeckeModules(FiniteField(5))
Category of Hecke modules over Finite Field of size 5

The base ring doesn't have to be a principal ideal domain.

sage: HeckeModules(PolynomialRing(IntegerRing()))
Category of Hecke modules over Univariate Polynomial Ring in x over Integer
Ring
HeckeModules( self, R)

Special Functions: __reduce__

__reduce__( self)

sage: C = HeckeModules(ZZ)
sage: loads(C.dumps()) == C
True

Class: Ideals

class Ideals
The category of all ideals in a fixed ring.

sage: Ideals(Integers(200))
Category of ring ideals in Ring of integers modulo 200
sage: C = Ideals(IntegerRing()); C
Category of ring ideals in Integer Ring
sage: I = C([8,12,18])
sage: I
Principal ideal (2) of Integer Ring
Ideals( self, R)

Special Functions: __reduce__

__reduce__( self)

sage: C = RingIdeals(ZZ)
sage: loads(C.dumps()) == C
True

Class: MatrixAlgebras

class MatrixAlgebras
The category of matrix algebras over a field.

sage: MatrixAlgebras(RationalField())
Category of matrix algebras over Rational Field

Special Functions: __reduce__

__reduce__( self)

sage: C = MatrixAlgebras(ZZ)
sage: loads(C.dumps()) == C
True

Class: Modules

class Modules
The category of all modules over a base ring.

sage: Modules(RationalField())
Category of ring modules over Rational Field

sage: Modules(Integers(9))
Category of ring modules over Ring of integers modulo 9

Special Functions: __reduce__

__reduce__( self)

sage: C = RingModules(ZZ)
sage: loads(C.dumps()) == C
True

Class: MonoidAlgebras

class MonoidAlgebras
The category of all monoid algebras over a given base ring.

sage: MonoidAlgebras(GF(2))
Category of monoid algebras over Finite Field of size 2

Special Functions: __reduce__

__reduce__( self)

sage: C = MonoidAlgebras(ZZ)
sage: loads(C.dumps()) == C
True

Class: Monoids

class Monoids
The category of monoids.

sage: Monoids()
Category of monoids

Special Functions: __reduce__

__reduce__( self)

sage: C = Monoids()
sage: loads(C.dumps()) == C
True

Class: NumberFields

class NumberFields
The category of number fields.

We create the category of number fields.

sage: C = NumberFields()
sage: C
Category of number fields

Notice that the rational numbers $ \mathbf{Q}$ are not considered as an object in this category.

sage: RationalField() in C
False

However, we can define a degree 1 extension of $ \mathbf{Q}$ , which is in this category.

sage: x = PolynomialRing(RationalField()).gen()
sage: K = NumberField(x - 1); K
Number Field in a with defining polynomial x - 1
sage: K in C
True

We can also coerce $ \mathbf{Q}$ into the category of number fields.

sage: C(RationalField())
Number Field in a with defining polynomial x - 1

Number fields all lie in this category, irregardless of the name of the variable.

sage: K = NumberField(x^2 + 1, name='a')
sage: K in C
True

Special Functions: __call__,$  $ __contains__,$  $ __reduce__

__reduce__( self)

sage: C = NumberFields()
sage: loads(C.dumps()) == C
True

Class: Objects

class Objects
The category of all SAGE objects.

sage: Objects()
Category of objects

Special Functions: __contains__,$  $ __reduce__

Class: RingIdeals

class RingIdeals
The category of all ideals in a fixed ring.

sage: Ideals(Integers(200))
Category of ring ideals in Ring of integers modulo 200
sage: C = Ideals(IntegerRing()); C
Category of ring ideals in Integer Ring
sage: I = C([8,12,18])
sage: I
Principal ideal (2) of Integer Ring
RingIdeals( self, R)

Special Functions: __reduce__

__reduce__( self)

sage: C = RingIdeals(ZZ)
sage: loads(C.dumps()) == C
True

Class: RingModules

class RingModules
The category of all modules over a base ring.

sage: Modules(RationalField())
Category of ring modules over Rational Field

sage: Modules(Integers(9))
Category of ring modules over Ring of integers modulo 9

Special Functions: __reduce__

__reduce__( self)

sage: C = RingModules(ZZ)
sage: loads(C.dumps()) == C
True

Class: Rings

class Rings
The category of all rings.

sage: Rings()
Category of rings

Special Functions: __reduce__

__reduce__( self)

sage: C = Rings()
sage: loads(C.dumps()) == C
True

Class: Schemes_abstract

class Schemes_abstract
The category of all abstract schemes.

sage: Schemes()
Category of Schemes
Schemes_abstract( self)

Special Functions: __call__,$  $ __reduce__

__call__( self, x)

Fetch the category of schemes.

sage: S = Schemes(); S
Category of Schemes

We create a scheme from a ring.

sage: X = S(ZZ); X
Spectrum of Integer Ring

We create a scheme from a scheme (do nothing).

sage: S(X)
Spectrum of Integer Ring

We create a scheme morphism from a ring homomorphism.x

sage: phi = Z.hom(Q); phi
Coercion morphism:
  From: Integer Ring
  To:   Rational Field
sage: f = S(phi); f
Affine Scheme morphism:
  From: Spectrum of Rational Field
  To:   Spectrum of Integer Ring
  Defn: Coercion morphism:
          From: Integer Ring
          To:   Rational Field

sage: f.domain()
Spectrum of Rational Field
sage: f.codomain()
Spectrum of Integer Ring
sage: S(f)
Affine Scheme morphism:
  From: Spectrum of Rational Field
  To:   Spectrum of Integer Ring
  Defn: Coercion morphism:
          From: Integer Ring
          To:   Rational Field

Class: Schemes_over_base

class Schemes_over_base
The category of schemes over a given base scheme.

sage: Schemes(Spec(ZZ))
Category of schemes over Spectrum of Integer Ring
Schemes_over_base( self, Y)

Functions: base_scheme

Special Functions: __reduce__,$  $ _repr_

__reduce__( self)

sage: C = Schemes(ZZ)
sage: loads(C.dumps()) == C
True

Class: Semigroups

class Semigroups
The category of all semigroups.

sage: Semigroups()
Category of semigroups

Special Functions: __reduce__

__reduce__( self)

sage: C = Semigroups()
sage: loads(C.dumps()) == C
True

Class: Sequences

class Sequences
The category of all elements of a given object.

sage: v = Sequence([1,2,3]); v
[1, 2, 3]
sage: C = v.category(); C
Category of sequences in Integer Ring
sage: loads(C.dumps()) == C
True
sage: Sequences(ZZ) is C
True
Sequences( self, object)

Functions: object

Special Functions: __reduce__,$  $ _call_,$  $ _latex_,$  $ _repr_

_call_( self, x)

sage: v = Sequence([1,2,3]); v
[1, 2, 3]
sage: C = v.category(); C
Category of sequences in Integer Ring            
sage: w = C([2/1, 3/1, GF(2)(5)]); w
[2, 3, 1]
sage: w.category()
Category of sequences in Integer Ring

Class: Sets

class Sets
The category of sets.

sage: Sets()
Category of sets

Special Functions: __call__,$  $ __reduce__

Class: VectorSpaces

class VectorSpaces
The category of vector spaces over a specified field, with an emedding in an ambient vector space.

sage: VectorSpaces(RationalField())
Category of vector spaces over Rational Field
VectorSpaces( self, K)

Functions: base_field

Special Functions: __call__,$  $ __reduce__

__reduce__( self)

sage: C = QQ^10      # vector space
sage: loads(C.dumps()) == C
True

See About this document... for information on suggesting changes.