Homset categories - Category Framework

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

# Homset categories

class sage.categories.homsets.Homsets

  Bases: `Category_singleton`

  The category of all homsets.

  EXAMPLES:

  Sage

      sage: from sage.categories.homsets import Homsets
      sage: Homsets()
      Category of homsets

  Python

      >>> from sage.all import *
      >>> from sage.categories.homsets import Homsets
      >>> Homsets()
      Category of homsets

  This is a subcategory of `Sets()`:

  Sage

      sage: Homsets().super_categories()
      [Category of sets]

  [Python]

      >>> from sage.all import *
      >>> Homsets().super_categories()
      [Category of sets]

  By this, we assume that all homsets implemented in Sage are sets, or equivalently that we only implement locally small categories. See Wikipedia article Category_(mathematics).

  Issue #17364: every homset category shall be a subcategory of the category of all homsets:

  Sage

      sage: Schemes().Homsets().is_subcategory(Homsets())
      True
      sage: AdditiveMagmas().Homsets().is_subcategory(Homsets())
      True
      sage: AdditiveMagmas().AdditiveUnital().Homsets().is_subcategory(Homsets())
      True

  Python

      >>> from sage.all import *
      >>> Schemes().Homsets().is_subcategory(Homsets())
      True
      >>> AdditiveMagmas().Homsets().is_subcategory(Homsets())
      True
      >>> AdditiveMagmas().AdditiveUnital().Homsets().is_subcategory(Homsets())
      True

  This is tested in `HomsetsCategory._test_homsets_category()`.

  class Endset(base_category)

    Bases: `CategoryWithAxiom_singleton`

    The category of all endomorphism sets.

    This category serves too purposes: making sure that the `Endset` axiom is implemented in the category where it’s defined, namely `Homsets`, and specifying that `Endsets` are monoids.

    EXAMPLES:

    Sage

        sage: from sage.categories.homsets import Homsets
        sage: Homsets().Endset()
        Category of endsets

    Python

        >>> from sage.all import *
        >>> from sage.categories.homsets import Homsets
        >>> Homsets().Endset()
        Category of endsets

    class ParentMethods

      Bases: `object`

      is_endomorphism_set()

        Return `True` as `self` is in the category of `Endsets`.

        EXAMPLES:

        Sage

            sage: P.<t> = ZZ[]
            sage: E = End(P)
            sage: E.is_endomorphism_set()
            True

        Python

            >>> from sage.all import *
            >>> P = ZZ['t']; (t,) = P._first_ngens(1)
            >>> E = End(P)
            >>> E.is_endomorphism_set()
            True

    extra_super_categories()

      Implement the fact that endsets are monoids.

      See also

      `CategoryWithAxiom.extra_super_categories()`

      EXAMPLES:

      Sage

          sage: from sage.categories.homsets import Homsets
          sage: Homsets().Endset().extra_super_categories()
          [Category of monoids]

      Python

          >>> from sage.all import *
          >>> from sage.categories.homsets import Homsets
          >>> Homsets().Endset().extra_super_categories()
          [Category of monoids]

  class ParentMethods

    Bases: `object`

    is_endomorphism_set()

      Return `True` if the domain and codomain of `self` are the same object.

      EXAMPLES:

      Sage

          sage: P.<t> = ZZ[]
          sage: f = P.hom([1/2*t])
          sage: f.parent().is_endomorphism_set()
          False
          sage: g = P.hom([2*t])
          sage: g.parent().is_endomorphism_set()
          True

      Python

          >>> from sage.all import *
          >>> P = ZZ['t']; (t,) = P._first_ngens(1)
          >>> f = P.hom([Integer(1)/Integer(2)*t])
          >>> f.parent().is_endomorphism_set()
          False
          >>> g = P.hom([Integer(2)*t])
          >>> g.parent().is_endomorphism_set()
          True

  class SubcategoryMethods

    Bases: `object`

    Endset()

      Return the subcategory of the homsets of `self` that are endomorphism sets.

      EXAMPLES:

      Sage

          sage: Sets().Homsets().Endset()
          Category of endsets of sets

          sage: Posets().Homsets().Endset()
          Category of endsets of posets

      Python

          >>> from sage.all import *
          >>> Sets().Homsets().Endset()
          Category of endsets of sets

          >>> Posets().Homsets().Endset()
          Category of endsets of posets

  super_categories()

    Return the super categories of `self`.

    EXAMPLES:

    Sage

        sage: from sage.categories.homsets import Homsets
        sage: Homsets()
        Category of homsets

    Python

        >>> from sage.all import *
        >>> from sage.categories.homsets import Homsets
        >>> Homsets()
        Category of homsets

class sage.categories.homsets.HomsetsCategory(category, *args)

  Bases: `FunctorialConstructionCategory`, `CategoryWithParameters`

  base()

    If this homsets category is subcategory of a category with a base, return that base.

    Todo

    Is this really useful?

    EXAMPLES:

    Sage

        sage: ModulesWithBasis(ZZ).Homsets().base()
        Integer Ring

    Python

        >>> from sage.all import *
        >>> ModulesWithBasis(ZZ).Homsets().base()
        Integer Ring

  classmethod default_super_categories(category)

    Return the default super categories of `category.Homsets()`.

    INPUT:

    - `cls` – the category class for the functor \(F\)

    - `category` – a category \(Cat\)

    OUTPUT: a category

    As for the other functorial constructions, if `category` implements a nested `Homsets` class, this method is used in combination with `category.Homsets().extra_super_categories()` to compute the super categories of `category.Homsets()`.

    EXAMPLES:

    If `category` has one or more full super categories, then the join of their respective homsets category is returned. In this example, this join consists of a single category:

    Sage

        sage: from sage.categories.homsets import HomsetsCategory
        sage: from sage.categories.additive_groups import AdditiveGroups

        sage: C = AdditiveGroups()
        sage: C.full_super_categories()
        [Category of additive inverse additive unital additive magmas,
         Category of additive monoids]
        sage: H = HomsetsCategory.default_super_categories(C); H
        Category of homsets of additive monoids
        sage: type(H)
        <class 'sage.categories.additive_monoids.AdditiveMonoids.Homsets_with_category'>

    Python

        >>> from sage.all import *
        >>> from sage.categories.homsets import HomsetsCategory
        >>> from sage.categories.additive_groups import AdditiveGroups

        >>> C = AdditiveGroups()
        >>> C.full_super_categories()
        [Category of additive inverse additive unital additive magmas,
         Category of additive monoids]
        >>> H = HomsetsCategory.default_super_categories(C); H
        Category of homsets of additive monoids
        >>> type(H)
        <class 'sage.categories.additive_monoids.AdditiveMonoids.Homsets_with_category'>

    and, given that nothing specific is currently implemented for homsets of additive groups, `H` is directly the category thereof:

    Sage

        sage: C.Homsets()
        Category of homsets of additive monoids

    [Python]

        >>> from sage.all import *
        >>> C.Homsets()
        Category of homsets of additive monoids

    Similarly for rings: a ring homset is just a homset of unital magmas and additive magmas:

    Sage

        sage: Rings().Homsets()
        Category of homsets of unital magmas and additive unital additive magmas

    Python

        >>> from sage.all import *
        >>> Rings().Homsets()
        Category of homsets of unital magmas and additive unital additive magmas

    Otherwise, if `category` implements a nested class `Homsets`, this method returns the category of all homsets:

    Sage

        sage: AdditiveMagmas.Homsets
        <class 'sage.categories.additive_magmas.AdditiveMagmas.Homsets'>
        sage: HomsetsCategory.default_super_categories(AdditiveMagmas())
        Category of homsets

    [Python]

        >>> from sage.all import *
        >>> AdditiveMagmas.Homsets
        <class 'sage.categories.additive_magmas.AdditiveMagmas.Homsets'>
        >>> HomsetsCategory.default_super_categories(AdditiveMagmas())
        Category of homsets

    which gives one of the super categories of `category.Homsets()`:

    Sage

        sage: AdditiveMagmas().Homsets().super_categories()
        [Category of additive magmas, Category of homsets]
        sage: AdditiveMagmas().AdditiveUnital().Homsets().super_categories()
        [Category of additive unital additive magmas, Category of homsets]

    Python

        >>> from sage.all import *
        >>> AdditiveMagmas().Homsets().super_categories()
        [Category of additive magmas, Category of homsets]
        >>> AdditiveMagmas().AdditiveUnital().Homsets().super_categories()
        [Category of additive unital additive magmas, Category of homsets]

    the other coming from `category.Homsets().extra_super_categories()`:

    Sage

        sage: AdditiveMagmas().Homsets().extra_super_categories()
        [Category of additive magmas]

    [Python]

        >>> from sage.all import *
        >>> AdditiveMagmas().Homsets().extra_super_categories()
        [Category of additive magmas]

    Finally, as a last resort, this method returns a stub category modelling the homsets of this category:

    Sage

        sage: hasattr(Posets, "Homsets")
        False
        sage: H = HomsetsCategory.default_super_categories(Posets()); H
        Category of homsets of posets
        sage: type(H)
        <class 'sage.categories.homsets.HomsetsOf_with_category'>
        sage: Posets().Homsets()
        Category of homsets of posets

    Python

        >>> from sage.all import *
        >>> hasattr(Posets, "Homsets")
        False
        >>> H = HomsetsCategory.default_super_categories(Posets()); H
        Category of homsets of posets
        >>> type(H)
        <class 'sage.categories.homsets.HomsetsOf_with_category'>
        >>> Posets().Homsets()
        Category of homsets of posets

class sage.categories.homsets.HomsetsOf(category, *args)

  Bases: `HomsetsCategory`

  Default class for homsets of a category.

  This is used when a category \(C\) defines some additional structure but not a homset category of its own. Indeed, unlike for covariant functorial constructions, we cannot represent the homset category of \(C\) by just the join of the homset categories of its super categories.

  EXAMPLES:

  Sage

      sage: C = (Magmas() & Posets()).Homsets(); C
      Category of homsets of magmas and posets
      sage: type(C)
      <class 'sage.categories.homsets.HomsetsOf_with_category'>

  Python

      >>> from sage.all import *
      >>> C = (Magmas() & Posets()).Homsets(); C
      Category of homsets of magmas and posets
      >>> type(C)
      <class 'sage.categories.homsets.HomsetsOf_with_category'>

  super_categories()

    Return the super categories of `self`.

    A stub homset category admits a single super category, namely the category of all homsets.

    EXAMPLES:

    Sage

        sage: C = (Magmas() & Posets()).Homsets(); C
        Category of homsets of magmas and posets
        sage: type(C)
        <class 'sage.categories.homsets.HomsetsOf_with_category'>
        sage: C.super_categories()
        [Category of homsets]

    Python

        >>> from sage.all import *
        >>> C = (Magmas() & Posets()).Homsets(); C
        Category of homsets of magmas and posets
        >>> type(C)
        <class 'sage.categories.homsets.HomsetsOf_with_category'>
        >>> C.super_categories()
        [Category of homsets]