#10668: Refactor category support for morphisms (Hom is not a functorial
construction!)
--------------------------+-------------------------------------------------
   Reporter:  nthiery     |       Owner:  nthiery
       Type:  defect      |      Status:  new    
   Priority:  major       |   Milestone:         
  Component:  categories  |    Keywords:         
     Author:              |    Upstream:  N/A    
   Reviewer:              |      Merged:         
Work_issues:              |  
--------------------------+-------------------------------------------------

Comment(by SimonKing):

 I just uploaded a preliminary patch, implementing my approach. The patch
 isn't finished (lacking doc tests), but is ready for discussion. It
 depends on #10667 (though it might apply with some noise without #10667 -
 test, if you like).

 Features:

 '''__Structure of hom sets__'''

 As I announced, I introduced an attribute for categories `C` that
 determines a category which `C.hom_category()` is sub-category of. I call
 this attribute `C.hom_structure`:
 {{{
 # This was already fixed by #10667
 sage: LeftModules(ZZ).hom_category()
 Category of hom sets in Category of left modules over Integer Ring
 sage: type(LeftModules(ZZ).hom_category())
 <class 'sage.categories.sets_cat.Sets.HomCategory'>
 # This is new:
 sage: LeftModules(ZZ).hom_category().is_subcategory(RightModules(ZZ))
 True
 sage: issubclass(LeftModules(ZZ).hom_category().parent_class,
 RightModules(ZZ).parent_class)
 True
 # Reason for it working:
 sage: LeftModules(ZZ).hom_structure
 Category of right modules over Integer Ring
 }}}
 The attribute `C.hom_structure` is used in
 `sage.categories.HomCategory.extra_super_categories()`.

 '''Hierarchy of hom-categories'''

 Recall that currently, the hierarchy of hom-categories goes parallel with
 the hierarchy of their base categories, which is wrong.

 However, if `C1` is a ''full'' sub-category of `C2` then (and ''only''
 then) we should indeed have
 `C1.hom_category().is_subcategory(C2.hom_category())`. Similar to the
 method `C.super_categories()`, I introduce an attribute
 `C.full_subcategory_of`, that provides a list of immediate super
 categories in which `C` is full.

 With that, I have:
 {{{
 sage: IntegralDomains().full_subcategory_of
 [Category of commutative rings, Category of domains]
 sage: Domains().full_subcategory_of
 [Category of rings]
 sage:
 
IntegralDomains().hom_category().is_subcategory(CommutativeRings().hom_category())
 True
 sage:
 IntegralDomains().hom_category().is_subcategory(Rings().hom_category())
 True
 }}}
 and, in particular
 {{{
 sage: issubclass(IntegralDomains().hom_category().parent_class,
 Rings().hom_category().parent_class)
 True
 }}}

 '''Self-criticism'''

 It is not very pythonic to do those things with an attribute - usually,
 methods are better. However, an attribute is easier to add, and it is
 faster to access.

 I am not sure whether I got the "full subcategory" business right in all
 cases.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10668#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to