-
-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor category support for morphisms (Hom is not a functorial construction!) #10668
Comments
Replying to @nthiery:
I don't see why this should be wrong: Any ring homomorphism is a set homomorphism. Hence,
You mean "Cat.HomMethods will provide...", I guess.
The approach with I don't know whether we need special methods for homset, but of course it would be nice to have homsets that are vector spaces. What about the following approach:
That would be a good candidate for your
I guess that would be an extension of the Anyway, my suggestion is to start with the |
comment:2
Replying to @simon-king-jena:
Very short answer for now: here the question is whether Hom_Rings()(A,B) is an object of Hom_Sets(). It's not. The point of VectorSpaces().HomCategory() is to encode mathematical information about the homsets, like the fact that Hom(A,B) is itself a vector space. We don't want this information to be applied to a homset of a subcategory (a homset in Algebras() being certainly not a vector space). |
This comment has been minimized.
This comment has been minimized.
comment:3
Replying to @nthiery:
Right. Nevertheless, I believe that an attribute like So, for now, the only detail that I have to withdraw from my proposal is that |
This comment has been minimized.
This comment has been minimized.
comment:5
Replying to @nthiery: More later when I'll have recharged my battery ... |
Replying to @nthiery:
Not in a sub-category! Namely, if
I don't see such hierarchy.
I really think the Any category would provide its own hom-structure (and there would be no inheritance for sub-categories), of course Then, homsets in In particular, there is no need to provide |
comment:7
Replying to @simon-king-jena:
Of course addition should not be put in MorphismMethods. On the other That is not a vague though that popped up when I created this ticket,
And I think mine is no more complicated, while being more consistent It seems like most of the discussion comes from confusion and
Cat.HomCategory() will still use the standard super_categories() Cheers, PS: by the way, I am wondering if we should be using Cat.objects() or |
comment:8
Replying to @nthiery:
I see. Yes, for those kind of methods, your approach makes very much sense. But what would actually prevent us from doing both? Our two approaches are good for different things, and they are orthogonal to each other. If I understand correctly, you suggest that there should be Is there any reason to not have a double inheritance from
OK.
OK, this is what I suggested above: One needs to introduce a standard mechanism to declare the category which |
comment:9
Ah, good, we now fund the point were we did not understand each
And that's a second misunderstanding: this mechanism already exists, What do you think of using the occasion to rename Cat.hom_category() Cheers, |
comment:10
Replying to @nthiery:
What mechanism do you mean? I am of course aware of the Of course, it would suffice to make What I plan is: Remove inheritance of the hom-categories of the super-categories of the base-category from
Then, in the init-method of the category of vector spaces, one would simply add the line
Similarly (I hope that I am not confusing things now), one would add the line
to the init method of right modules; and
Personally, I don't like uppercase method names, and I remember that it is officially recommended to avoid capital letters in Python method or function or module names, whereas upper case is recommended to use for classes (but I do not remember where I was reading that recommendation). Best regards, Simon |
comment:11
A technical question: For things to work, it is needed that I thought that the inheritance would be provided by the category framework, if we have So, how can one inherit the parent class of a super-category? |
comment:12
Replying to @simon-king-jena:
Sorry for asking: It seems to work. I misinterpreted an error message. |
comment:13
I wonder whether it wouldn't be better to build upon #10667. There, amongst other things, I try to separate I suggest that I prepare my patch on top of #10667; you can of course do differently with the implementation of your approach. |
comment:14
Replying to @simon-king-jena:
Sure, please take the easiest route for you! #10667 is already large enough, and I see the point of not introducing yet another dependency :-) Cheers, |
comment:15
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
The attribute 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 With that, I have:
and, in particular
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. |
Attachment: trac10668-category_support_for_homsets.patch.gz Category support for hom categories - depends on #10667 |
comment:16
Hi Simon! I finally got to work on this. See: http://combinat.sagemath.org/patches/file/tip/category-hom_methods-nt.patch It's just a proof of concept. The core of the patch implementing the About attributes for specifying homset structures / full sub categoriesI much prefer to use methods instead:
About full subcategoriesI totally agree that we want this concept. I am not sure yet about the
Then full_super_categories and all_super_categories, ... would extract We could be more fancy to avoid breaking backward compatibility:
where annotated_list would be a helper class whose instances would
Things that still need discussion
Cheers, |
comment:17
Replying to @nthiery: Some notes after face to face discussion with Simon:
Eventually yes.
Each category should have a
For There are 5-6 explicit hom functions in Sage that would need to be
The new
+1
That would make sense. Comments anyone? Little inconvenient: possible confusion between
|
comment:18
Some food for thought (taken from Rings.HomCategory before #12876): When X is a quotient field, we can build a morphism from X to Y by |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:58
Replying to @simon-king-jena:
Good catch; that piece had not been refactored. Now it even works :-) |
comment:59
Replying to @simon-king-jena:
The second piece is done now. I am about to work on the doc of
Yes indeed, thanks so much! |
comment:60
Replying to @simon-king-jena:
Done. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:62
I believe all discussion points have been addressed. Hence back to |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:65
All tests pass and all issues have been addressed. Hence, it's a positive review, of course modulo #16340. |
Changed branch from public/categories/morphism-methods-10668 to |
Changed commit from |
comment:67
Thanks Simon :-) And thanks for coming over; that was a productive trip! |
Before this ticket, Hom was implemented as a covariant functorial construction:
The intention was to model the fact that a morphism in a category is
also a morphism in any super category, via the forgetful functor. With
the example above, if A and B are rings, then a ring morphism phi:
A->B is also a set morphism. However, at the level of parents, and as
noted in the documentation of sage.category.HomCategory, this is
mathematically plain wrong: if A and B are rings, then Hom(A,B) in the
category of rings does not coincide with Hom(A,B) in the category of
sets.
I, Nicolas, take full blame for this misfeature; it was just the
shortest route to implement some urgently needed features about
morphisms, and still get that huge chunk of category code done.
Status of the current reimplementation:
Add support for a MorphismsMethods subclass, similar to
ElementMethods and ParentMethods. If Cat is a category, then
Cat.MorphismMethods will provide generic methods for morphisms in
Cat and in any subcategory. This can be achieved by:
Building of a hierarchy of abstract classes Cat.morphism_class,
similar to Cat.element_class and Cat.parent_class (10 lines of
code; see Category.element_class).
Having morphisms in Cat inherit from
Cat.morphism_class
; thisis implemented by overriding
Parent.morphism_class
. Analternative would have been to override
Category.element_class
in
HomsetsCategory.element_class
.Rename both HomCategory and hom_category to Homsets, for consistency
with the other constructions like CartesianProducts, ...
Fix HomCategory: for Cat a category, the purpose of
Cat.hom_category() shall be to provide mathematical information
about its homsets (e.g. that a homset in the category of vector
spaces is also a vector space). It is only a subcategory of the
homsets of the full super categories of Cat (a homset in the
category of finite groups is also a homset in the category of
groups).
Remove HomCategory from the global namespace.
Potential further desirable features for a later ticket:
If CatA is a subcategory of CatB, add automatic coercion (or just
conversion?) from Hom(A,B, CatA) to Hom(A, B, CatB), modeling the
appropriate forgetful functor. There are too many such coercions
for them to be registered explicitly. So this probably needs to be
implemented through a specific CatB._has_coerce_map_from(A) for
homsets.
Extend/use sage.categories.pushout to handle mixed morphism
arithmetic (e.g. having the sum of an algebra morphism and a
coalgebra morphism return a vector space morphism).
Depends on #16340
CC: @sagetrac-sage-combinat @simon-king-jena
Component: categories
Author: Nicolas M. Thiéry
Branch:
a937938
Reviewer: Simon King
Issue created by migration from https://trac.sagemath.org/ticket/10668
The text was updated successfully, but these errors were encountered: