Ticket #7880: 7585_4_sets_with_partial_maps.patch

File 7585_4_sets_with_partial_maps.patch, 13.8 KB (added by robertwb, 11 years ago)
  • sage/categories/category.py

    # HG changeset patch
    # User David Roe <roed@math.harvard.edu>
    # Date 1260893170 18000
    # Node ID 63f07c30b694571b900ad6cdad0cd20230c1d2bc
    # Parent  081dadd2f119edf305fae88c98e1fff8af08792e
    Changed the supercategory order in categories to insert SetsWithPartialMaps in between Sets and Objects.  This allows maps between sets that are only partially defined (before this change the Hom function would complain when one tried to create such a map), which is the whole point of the SetsWithPartialMaps category.
    
    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/category.py
    a b  
    778778             Category of commutative additive monoids,
    779779             Category of commutative additive semigroups,
    780780             Category of sets,
     781             Category of sets with partial maps,
    781782             Category of objects]
    782783
    783784        This is an associative operation::
     
    10091010        'rings',
    10101011        'rngs',
    10111012        'semigroups',
    1012         'sets']
     1013        'sets',
     1014        'sets with partial maps']
    10131015        sage: G.plot()
    10141016
    10151017        sage: sage.categories.category.category_graph().plot()
     
    11971199        sage: J.super_categories()
    11981200        [Category of groups, Category of commutative additive monoids]
    11991201        sage: J.all_super_categories(proper = True)
    1200         [Category of groups, Category of monoids, Category of semigroups, Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of objects]
     1202        [Category of groups, Category of monoids, Category of semigroups, Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of sets with partial maps, Category of objects]
    12011203
    12021204    """
    12031205
  • sage/categories/coalgebras.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/coalgebras.py
    a b  
    3434         Category of commutative additive monoids,
    3535         Category of commutative additive semigroups,
    3636         Category of sets,
     37         Category of sets with partial maps,
    3738         Category of objects]
    3839
    3940    TESTS::
  • sage/categories/commutative_additive_groups.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/commutative_additive_groups.py
    a b  
    2424        sage: CommutativeAdditiveGroups().super_categories()
    2525        [Category of commutative additive monoids]
    2626        sage: CommutativeAdditiveGroups().all_super_categories()
    27         [Category of commutative additive groups, Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of objects]
     27        [Category of commutative additive groups, Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of sets with partial maps, Category of objects]
    2828
    2929    TESTS::
    3030
  • sage/categories/commutative_additive_monoids.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/commutative_additive_monoids.py
    a b  
    2626        sage: CommutativeAdditiveMonoids().super_categories()
    2727        [Category of commutative additive semigroups]
    2828        sage: CommutativeAdditiveMonoids().all_super_categories()
    29         [Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of objects]
     29        [Category of commutative additive monoids, Category of commutative additive semigroups, Category of sets, Category of sets with partial maps, Category of objects]
    3030
    3131    TESTS::
    3232
  • sage/categories/commutative_additive_semigroups.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/commutative_additive_semigroups.py
    a b  
    2626        sage: CommutativeAdditiveSemigroups().super_categories()
    2727        [Category of sets]
    2828        sage: CommutativeAdditiveSemigroups().all_super_categories()
    29         [Category of commutative additive semigroups, Category of sets, Category of objects]
     29        [Category of commutative additive semigroups, Category of sets, Category of sets with partial maps, Category of objects]
    3030
    3131    TESTS::
    3232
  • sage/categories/enumerated_sets.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/enumerated_sets.py
    a b  
    7575        sage: EnumeratedSets().super_categories()
    7676        [Category of sets]
    7777        sage: EnumeratedSets().all_super_categories()
    78         [Category of enumerated sets, Category of sets, Category of objects]
     78        [Category of enumerated sets, Category of sets, Category of sets with partial maps, Category of objects]
    7979
    8080    TESTS::
    8181
  • sage/categories/finite_enumerated_sets.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/finite_enumerated_sets.py
    a b  
    2828        [Category of finite enumerated sets,
    2929         Category of enumerated sets,
    3030         Category of sets,
     31         Category of sets with partial maps,
    3132         Category of objects]
    3233
    3334    TESTS::
  • sage/categories/finite_semigroups.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/finite_semigroups.py
    a b  
    3333         Category of finite enumerated sets,
    3434         Category of enumerated sets,
    3535         Category of sets,
     36         Category of sets with partial maps,
    3637         Category of objects]
    3738        sage: FiniteSemigroups().example()
    3839        An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')
  • sage/categories/infinite_enumerated_sets.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/infinite_enumerated_sets.py
    a b  
    3535        [Category of infinite enumerated sets,
    3636         Category of enumerated sets,
    3737         Category of sets,
     38         Category of sets with partial maps,
    3839         Category of objects]
    3940
    4041    TESTS::
  • sage/categories/modules.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/modules.py
    a b  
    4242         Category of commutative additive monoids,
    4343         Category of commutative additive semigroups,
    4444         Category of sets,
     45         Category of sets with partial maps,
    4546         Category of objects]
    4647
    4748        sage: Modules(ZZ).super_categories()
  • sage/categories/monoids.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/monoids.py
    a b  
    3232        [Category of monoids,
    3333         Category of semigroups,
    3434         Category of sets,
     35         Category of sets with partial maps,
    3536         Category of objects]
    3637
    3738    TESTS::
  • sage/categories/primer.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/primer.py
    a b  
    122122         Category of monoids,
    123123         Category of semigroups,
    124124         Category of sets,
     125         Category of sets with partial maps,
    125126         Category of objects]
    126127
    127128        sage: CommutativeRings().category_graph().plot(talk = True)
     
    292293     Category of finite enumerated sets,
    293294     Category of enumerated sets,
    294295     Category of sets,
     296     Category of sets with partial maps,
    295297     Category of objects]
    296298    sage: S.__class__.mro()
    297299    [<class 'sage.categories.examples.finite_semigroups.LeftRegularBand_with_category'>,
     
    305307     <class 'sage.categories.finite_enumerated_sets.FiniteEnumeratedSets.parent_class'>,
    306308     <class 'sage.categories.enumerated_sets.EnumeratedSets.parent_class'>,
    307309     <class 'sage.categories.sets_cat.Sets.parent_class'>,
     310     <class 'sage.categories.category.SetsWithPartialMaps.parent_class'>,
    308311     <class 'sage.categories.objects.Objects.parent_class'>,
    309312     <type 'object'>]
    310313    sage: x.__class__.mro()
     
    318321     <class 'sage.categories.category.FiniteEnumeratedSets.element_class'>,
    319322     <class 'sage.categories.enumerated_sets.EnumeratedSets.element_class'>,
    320323     <class 'sage.categories.sets_cat.Sets.element_class'>,
     324     <class 'sage.categories.category.SetsWithPartialMaps.element_class'>,
    321325     <class 'sage.categories.objects.Objects.element_class'>,
    322326     <type 'object'>]
    323327
     
    491495     Category of commutative additive monoids,
    492496     Category of commutative additive semigroups,
    493497     Category of sets,
     498     Category of sets with partial maps,
    494499     Category of objects]
    495500
    496501Todo: any better convention? Maybe we should further specify that subcategories of Modules() go first?
  • sage/categories/semigroups.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/semigroups.py
    a b  
    3535        sage: Semigroups().super_categories()
    3636        [Category of sets]
    3737        sage: Semigroups().all_super_categories()
    38         [Category of semigroups, Category of sets, Category of objects]
     38        [Category of semigroups, Category of sets, Category of sets with partial maps, Category of objects]
    3939
    4040    TESTS::
    4141
  • sage/categories/sets_cat.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/sets_cat.py
    a b  
    1616from sage.misc.lazy_attribute import lazy_attribute
    1717from sage.categories.category import Category, HomCategory
    1818# Do not use sage.categories.all here to avoid initialization loop
    19 from sage.categories.objects import Objects
     19from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
    2020
    2121class Sets(Category):
    2222    """
     
    3131        sage: Sets()
    3232        Category of sets
    3333        sage: Sets().super_categories()
    34         [Category of objects]
     34        [Category of sets with partial maps]
    3535        sage: Sets().all_super_categories()
    36         [Category of sets, Category of objects]
     36        [Category of sets, Category of sets with partial maps, Category of objects]
    3737
    3838    Let us consider an example of set::
    3939
     
    6060        <type 'sage.structure.category_object.CategoryObject'>
    6161        <type 'sage.structure.sage_object.SageObject'>
    6262        <class 'sage.categories.sets_cat.Sets.parent_class'>
     63        <class 'sage.categories.category.SetsWithPartialMaps.parent_class'>
    6364        <class 'sage.categories.objects.Objects.parent_class'>
    6465        <type 'object'>
    6566
     
    102103        <type 'sage.structure.element.Element'>
    103104        <type 'sage.structure.sage_object.SageObject'>
    104105        <class 'sage.categories.sets_cat.Sets.element_class'>
     106        <class 'sage.categories.category.SetsWithPartialMaps.element_class'>
    105107        <class 'sage.categories.objects.Objects.element_class'>
    106108        <type 'object'>
    107109
     
    117119    @cached_method
    118120    def super_categories(self):
    119121        """
     122        We include SetsWithPartialMaps between Sets and Objects so that we
     123        can define morphisms between sets that are only partially defined
     124        (and have the Homset constructor not complain that SetsWithPartialMaps
     125        is not a supercategory of Fields, for example.
     126
    120127        EXAMPLES::
    121128
    122129            sage: Sets().super_categories()
    123             [Category of objects]
     130            [Category of sets with partial maps]
    124131        """
    125         return [Objects()]
     132        return [SetsWithPartialMaps()]
    126133
    127134    def __call__(self, X):
    128135        """
  • sage/categories/sets_with_partial_maps.py

    diff -r 081dadd2f119 -r 63f07c30b694 sage/categories/sets_with_partial_maps.py
    a b  
    2727    EXAMPLES::
    2828
    2929        sage: SetsWithPartialMaps()
    30         Category with objects Sets and morphisms partially defined maps
     30        Category of sets with partial maps
    3131
    3232        sage: SetsWithPartialMaps().super_categories()
    33         [Category of sets]
     33        [Category of objects]
    3434
    3535    TESTS::
    3636
     
    4545        EXAMPLES::
    4646
    4747            sage: SetsWithPartialMaps()
    48             Category with objects Sets and morphisms partially defined maps
    49 
    50         FIXME: is this the desired result?
     48            Category of sets with partial maps
    5149        """
    52         return "Category with objects Sets and morphisms partially defined maps"
     50        return "Category of sets with partial maps"
    5351
    5452    @cached_method
    5553    def super_categories(self):
     
    5755        EXAMPLES::
    5856
    5957            sage: SetsWithPartialMaps().super_categories()
    60             [Category of sets]
     58            [Category of objects]
    6159        """
    62         from sets_cat import Sets
    63         return [Sets()]
     60        from objects import Objects
     61        return [Objects()]
  • sage/structure/parent.pyx

    diff -r 081dadd2f119 -r 63f07c30b694 sage/structure/parent.pyx
    a b  
    371371             Category of monoids,
    372372             Category of semigroups,
    373373             Category of sets,
     374             Category of sets with partial maps,
    374375             Category of objects]
    375376        """
    376377        return self.category().all_super_categories()