Cartesian Product Functorial Construction - Category Framework

Skip to content
Back to top
View this page
Edit this page

# Cartesian Product Functorial Construction

AUTHORS:

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

class sage.categories.cartesian_product.CartesianProductFunctor(category=None)

  Bases: `CovariantFunctorialConstruction`, `MultivariateConstructionFunctor`

  The Cartesian product functor.

  EXAMPLES:

  Sage

      sage: cartesian_product
      The cartesian_product functorial construction

  Python

      >>> from sage.all import *
      >>> cartesian_product
      The cartesian_product functorial construction

  `cartesian_product` takes a finite collection of sets, and constructs the Cartesian product of those sets:

  Sage

      sage: A = FiniteEnumeratedSet(['a','b','c'])
      sage: B = FiniteEnumeratedSet([1,2])
      sage: C = cartesian_product([A, B]); C
      The Cartesian product of ({'a', 'b', 'c'}, {1, 2})
      sage: C.an_element()
      ('a', 1)
      sage: C.list()         # todo: not implemented
      [['a', 1], ['a', 2], ['b', 1], ['b', 2], ['c', 1], ['c', 2]]

  [Python]

      >>> from sage.all import *
      >>> A = FiniteEnumeratedSet(['a','b','c'])
      >>> B = FiniteEnumeratedSet([Integer(1),Integer(2)])
      >>> C = cartesian_product([A, B]); C
      The Cartesian product of ({'a', 'b', 'c'}, {1, 2})
      >>> C.an_element()
      ('a', 1)
      >>> C.list()         # todo: not implemented
      [['a', 1], ['a', 2], ['b', 1], ['b', 2], ['c', 1], ['c', 2]]

  If those sets are endowed with more structure, say they are monoids (hence in the category `Monoids()`), then the result is automatically endowed with its natural monoid structure:

  Sage

      sage: M = Monoids().example()
      sage: M
      An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd')
      sage: M.rename('M')
      sage: C = cartesian_product([M, ZZ, QQ])
      sage: C
      The Cartesian product of (M, Integer Ring, Rational Field)
      sage: C.an_element()
      ('abcd', 1, 1/2)
      sage: C.an_element()^2
      ('abcdabcd', 1, 1/4)
      sage: C.category()
      Category of Cartesian products of monoids

      sage: Monoids().CartesianProducts()
      Category of Cartesian products of monoids

  Python

      >>> from sage.all import *
      >>> M = Monoids().example()
      >>> M
      An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd')
      >>> M.rename('M')
      >>> C = cartesian_product([M, ZZ, QQ])
      >>> C
      The Cartesian product of (M, Integer Ring, Rational Field)
      >>> C.an_element()
      ('abcd', 1, 1/2)
      >>> C.an_element()**Integer(2)
      ('abcdabcd', 1, 1/4)
      >>> C.category()
      Category of Cartesian products of monoids

      >>> Monoids().CartesianProducts()
      Category of Cartesian products of monoids

  The Cartesian product functor is covariant: if `A` is a subcategory of `B`, then `A.CartesianProducts()` is a subcategory of `B.CartesianProducts()` (see also `CovariantFunctorialConstruction`):

  Sage

      sage: C.categories()
      [Category of Cartesian products of monoids,
       Category of monoids,
       Category of Cartesian products of semigroups,
       Category of semigroups,
       Category of Cartesian products of unital magmas,
       Category of Cartesian products of magmas,
       Category of unital magmas,
       Category of magmas,
       Category of Cartesian products of sets,
       Category of sets, ...]

      [Category of Cartesian products of monoids,
       Category of monoids,
       Category of Cartesian products of semigroups,
       Category of semigroups,
       Category of Cartesian products of magmas,
       Category of unital magmas,
       Category of magmas,
       Category of Cartesian products of sets,
       Category of sets,
       Category of sets with partial maps,
       Category of objects]

  [Python]

      >>> from sage.all import *
      >>> C.categories()
      [Category of Cartesian products of monoids,
       Category of monoids,
       Category of Cartesian products of semigroups,
       Category of semigroups,
       Category of Cartesian products of unital magmas,
       Category of Cartesian products of magmas,
       Category of unital magmas,
       Category of magmas,
       Category of Cartesian products of sets,
       Category of sets, ...]

      [Category of Cartesian products of monoids,
       Category of monoids,
       Category of Cartesian products of semigroups,
       Category of semigroups,
       Category of Cartesian products of magmas,
       Category of unital magmas,
       Category of magmas,
       Category of Cartesian products of sets,
       Category of sets,
       Category of sets with partial maps,
       Category of objects]

  Hence, the role of `Monoids().CartesianProducts()` is solely to provide mathematical information and algorithms which are relevant to Cartesian product of monoids. For example, it specifies that the result is again a monoid, and that its multiplicative unit is the Cartesian product of the units of the underlying sets:

  Sage

      sage: C.one()
      ('', 1, 1)

  Python

      >>> from sage.all import *
      >>> C.one()
      ('', 1, 1)

  Those are implemented in the nested class `Monoids.CartesianProducts` of `Monoids(QQ)`. This nested class is itself a subclass of `CartesianProductsCategory`.

  symbol = ' (+) '

class sage.categories.cartesian_product.CartesianProductsCategory(category, *args)

  Bases: `CovariantConstructionCategory`

  An abstract base class for all `CartesianProducts` categories.

  CartesianProducts()

    Return the category of (finite) Cartesian products of objects of `self`.

    By associativity of Cartesian products, this is `self` (a Cartesian product of Cartesian products of \(A\)’s is a Cartesian product of \(A\)’s).

    EXAMPLES:

    Sage

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

    Python

        >>> from sage.all import *
        >>> ModulesWithBasis(QQ).CartesianProducts().CartesianProducts()
        Category of Cartesian products of vector spaces with basis over Rational Field

  base_ring()

    The base ring of a Cartesian product is the base ring of the underlying category.

    EXAMPLES:

    Sage

        sage: Algebras(ZZ).CartesianProducts().base_ring()
        Integer Ring

    Python

        >>> from sage.all import *
        >>> Algebras(ZZ).CartesianProducts().base_ring()
        Integer Ring