Ticket #7880: trac_7880-sets_with_partial_maps.patch

File trac_7880-sets_with_partial_maps.patch, 14.0 KB (added by davidloeffler, 11 years ago)

replaces previous patch

  • sage/categories/category.py

    # HG changeset patch
    # User David Roe <roed@math.harvard.edu>
    # Date 1260893170 18000
    # Node ID 68803d688e191798e021663f7c51ecb59901894f
    # Parent  9ac54f4f5d808ad515e1ae07d5c3e87b3c0585f9
    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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 sage/categories/finite_semigroups.py
    a b  
    3434         Category of finite enumerated sets,
    3535         Category of enumerated sets,
    3636         Category of sets,
     37         Category of sets with partial maps,
    3738         Category of objects]
    3839        sage: FiniteSemigroups().example()
    3940        An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')
  • sage/categories/infinite_enumerated_sets.py

    diff -r 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 sage/categories/primer.py
    a b  
    127127         Category of monoids,
    128128         Category of semigroups,
    129129         Category of sets,
     130         Category of sets with partial maps,
    130131         Category of objects]
    131132
    132133        sage: EuclideanDomains().category_graph().plot(talk = True)
     
    297298     Category of finite enumerated sets,
    298299     Category of enumerated sets,
    299300     Category of sets,
     301     Category of sets with partial maps,
    300302     Category of objects]
    301303    sage: S.__class__.mro()
    302304    [<class 'sage.categories.examples.finite_semigroups.LeftRegularBand_with_category'>,
     
    310312     <class 'sage.categories.finite_enumerated_sets.FiniteEnumeratedSets.parent_class'>,
    311313     <class 'sage.categories.enumerated_sets.EnumeratedSets.parent_class'>,
    312314     <class 'sage.categories.sets_cat.Sets.parent_class'>,
     315     <class 'sage.categories.category.SetsWithPartialMaps.parent_class'>,
    313316     <class 'sage.categories.objects.Objects.parent_class'>,
    314317     <type 'object'>]
    315318    sage: x.__class__.mro()
     
    323326     <class 'sage.categories.category.FiniteEnumeratedSets.element_class'>,
    324327     <class 'sage.categories.enumerated_sets.EnumeratedSets.element_class'>,
    325328     <class 'sage.categories.sets_cat.Sets.element_class'>,
     329     <class 'sage.categories.category.SetsWithPartialMaps.element_class'>,
    326330     <class 'sage.categories.objects.Objects.element_class'>,
    327331     <type 'object'>]
    328332
     
    502506     Category of commutative additive monoids,
    503507     Category of commutative additive semigroups,
    504508     Category of sets,
     509     Category of sets with partial maps,
    505510     Category of objects]
    506511
    507512Todo: any better convention? Maybe we should further specify that subcategories of Modules() go first?
  • sage/categories/semigroups.py

    diff -r 9ac54f4f5d80 -r 68803d688e19 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 9ac54f4f5d80 -r 68803d688e19 sage/categories/sets_cat.py
    a b  
    1717from sage.misc.lazy_attribute import lazy_attribute
    1818from sage.categories.category import Category, HomCategory
    1919# Do not use sage.categories.all here to avoid initialization loop
    20 from sage.categories.objects import Objects
     20from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
    2121
    2222class Sets(Category):
    2323    """
     
    3232        sage: Sets()
    3333        Category of sets
    3434        sage: Sets().super_categories()
    35         [Category of objects]
     35        [Category of sets with partial maps]
    3636        sage: Sets().all_super_categories()
    37         [Category of sets, Category of objects]
     37        [Category of sets, Category of sets with partial maps, Category of objects]
    3838
    3939    Let us consider an example of set::
    4040
     
    6161        <type 'sage.structure.category_object.CategoryObject'>
    6262        <type 'sage.structure.sage_object.SageObject'>
    6363        <class 'sage.categories.sets_cat.Sets.parent_class'>
     64        <class 'sage.categories.category.SetsWithPartialMaps.parent_class'>
    6465        <class 'sage.categories.objects.Objects.parent_class'>
    6566        <type 'object'>
    6667
     
    109110        <type 'sage.structure.element.Element'>
    110111        <type 'sage.structure.sage_object.SageObject'>
    111112        <class 'sage.categories.sets_cat.Sets.element_class'>
     113        <class 'sage.categories.category.SetsWithPartialMaps.element_class'>
    112114        <class 'sage.categories.objects.Objects.element_class'>
    113115        <type 'object'>
    114116
     
    124126    @cached_method
    125127    def super_categories(self):
    126128        """
     129        We include SetsWithPartialMaps between Sets and Objects so that we
     130        can define morphisms between sets that are only partially defined
     131        (and have the Homset constructor not complain that SetsWithPartialMaps
     132        is not a supercategory of Fields, for example.
     133
    127134        EXAMPLES::
    128135
    129136            sage: Sets().super_categories()
    130             [Category of objects]
     137            [Category of sets with partial maps]
    131138        """
    132         return [Objects()]
     139        return [SetsWithPartialMaps()]
    133140
    134141    def __call__(self, X):
    135142        """
  • sage/categories/sets_with_partial_maps.py

    diff -r 9ac54f4f5d80 -r 68803d688e19 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/category_object.pyx

    diff -r 9ac54f4f5d80 -r 68803d688e19 sage/structure/category_object.pyx
    a b  
    179179             Category of commutative additive semigroups,
    180180             Category of monoids,
    181181             Category of semigroups,
    182              Category of sets,
     182             Category of sets,
     183             Category of sets with partial maps,
    183184             Category of objects]
    184185        """
    185186        return self.category().all_super_categories()