-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
Morphisms and Objects of Categories #10667
Comments
comment:1
If a category has not its own implementation of a hom-category, currently the join of the hom-categories of its super-categories is chosen. Hence, we have
I don't like that. One problem is that, for test suites, one would like to have a sample object -- but there is no way to create a sample object for a join of arbitrary categories. Moreover, the "hom sets in the Category of rings" are simply wrong for the category of commutative rings. Instead, I suggest to walk through the list of all super categories of
Of course, it may happen that several super categories have different custom implementation of hom categories, and we pick just one. But I think this should be taken care of manually, as join categories have a serious drawback, IMHO. |
comment:2
Hi Simon! Replying to @simon-king-jena:
Yeah. As mentioned in the code and in the road map [1], HomCategory is If you want to improve things in this direction, please jump right Thanks again for your continuous motion toward improving Sage in this Cheers, [1] http://trac.sagemath.org/sage_trac/wiki/CategoriesRoadMap |
comment:3
cc me! Thanks :) |
comment:4
Depends on #10496, #10659, #8611, #10467 I wont to get the patch finally off my plate. So, here it is, although it isn't finished yet. My patch provides the following:
Note that I interprete
Some categories have a custom containment test, e.g., the category of fields. The containment test of
The documentation for the new containers for objects and morphisms are added to the Sage reference manual -- please have a look.
But that approach yields to quite unnatural constructions. For example,
In other words, a ring homomorphism is considered a homset of the category of rings - of course, it should just be an element of a homset:
Fixing that bug required to re-structure
Note that by this change, it is now impossible to define nonsense such as Hom-categories Compare #10668: This part of my patch is not finished, yet. I suppose that eventually this ticket here will depend on #10668. Just for now, I implemented what I described in my previous post. Otherwise, many tests from the new test suites described below would fail. Test Suites The test suites of categories have been extended to test against the specification of the new features. In particular, the containers for morphisms and objects provide a test suite. The test suites for The patch adds a method Similarly, I introduce a method
which meant that the endomorphisms of the rational field used to belong to the "Category of hom sets in Category of rings". I didn't observe any problems changing it into the "Category of hom sets in Category of quotient fields".
Groupoids Groupoids are considered as a category with a single object. However, this object did not exist. The patch provides it, modeled as an empty set:
The elements of
Note that this point of view is needed in order to have a functorial approach towards actions, namely: If we want to view a group action of
Actually, that was the starting point for my work on this ticket. On the other hand, I do think that considering Need for Speed Of course, testing containment in a category
Here are some timings. Their purpose is to show that Setting:
Sanity tests:
Timings without the new patch (but with #10496, #10659, #8611 and #10467):
Timings with the patch, including the new syntax
Or, directly testing containment in the class of objects:
|
Author: Simon King |
comment:5
So, what's the status of the ticket? I need more info! First thing: I am still not happy with the groupoids. But can this perhaps be solved in a different ticket? Second and more urgent thing? Why does my example of pointed sets not inherit from The problem is:
So, the category is initialised. But:
What goes wrong in my implementation? |
comment:6
Hi Simon! I have only browsed quickly through this yet. I'll try to have a look
I wrote this comment. This won't break indeed, but there might
As I said, don't bother understanding: that's going to be removed. If |
comment:7
Thanks to Nicolas for his comments on sage-algebra explaining why my example of pointed sets didn't work well. It is now fixed. Hence, ready for review! |
comment:8
I updated the patch, so that it now applies to |
comment:9
Since the patchbot keeps complaining that the patch did not apply to good old sage-4.6.1 and since I just verified once again that the patch cleanly applies to sage-4.6.2.alpha4, I replaced the patch by an identical copy and hope that it pushes the patchbot to try it another time with the new sage version. |
comment:10
On #9054, William expressed his anger about category containment tests being too slow. That reminded me of the ticket here. Since the patches do not apply, it needs work. But I guess it is worth while to resume work on that ticket. |
comment:11
I have updated the patch, so that it should apply against sage-4.7.2.alpha2. I did not run tests, yet. Here are some timings:
Anyway, I try to squeeze |
comment:12
I created a new version of my patch. The aim is to make the performance of containment tests even better. I did the following, compared with the old patch:
I guess the best news is that the containment test via category framework can now compete with a pure class check, if that class check is done in Python. I take, for example, commutative rings:
Since
Hence, The reason for that speedup is Cython. While Caveat: I did not run the full tests, yet, and I would like to try and remove some custom containment tests in the category framework, that tend to be slower than the generic test and might not be needed with #9138. |
comment:13
I forgot to mention that I also improved With sage-4.7.2.alpha1 plus #9138 and #11115:
With sage-4.7.2.alpha2 plus #9138 and #11115 and the patch from here:
|
comment:14
I leave it as "needs review", but I think I have to adopt the Cython improvements on morphism containment tests as well. |
Work Issues: doctests |
comment:15
Replying to @simon-king-jena:
Nope, it wouldn't easily work for the morphisms. It turns out that I have to fix many doctests. |
comment:53
Replying to @nthiery:
I am not 100% certain that they work well. At least for getting the tests of elliptic curves pass, we probably need #11670 (uniqueness of number fields). And note that (currently) I only introduce
But all that were uncovered by new tests introduced with this patch.
Why would one not want uniqueness for temporarily created parents? When the same parent is frequently created, then it is more efficient to just use a cache. Or are you concerned that one creates too many different parents that will stay in cache forever?
No, what I just wrote can't be a method of Hence, it is not But I think it would be a good idea to add a |
comment:54
It turns out that #11670 will not solve the problem. But it seems to me that I come closer to a solution: In contrast to many other cases, hom sets of number fields are not unique parents. With my patch, they are even less unique. Here is a show case: sage-4.6.2
With my patch, we still have
but then
I don't know yet why this is the case, because the |
comment:55
Aha! I understand!
By consequence, In other words: Via category inheritance, We thus have:
I guess, until number fields are truly unique parents, I should add an |
comment:56
I think I found a valid work-around: Sometimes, a number field is created with passing the option With that change (not yet posted), we have
With the old patch, one would have the following error:
Running doctests, and then I hope the most serious problems have finally disappeared... |
Changed work issues from Cartesian products to Cope with non-unique number fields |
comment:57
Replying to @simon-king-jena:
Possibly so. Or about creating many different parents that each need a Honestly, I don't have a specific use case, just a bad feeling about
+1. I am not sure about the name though. What about something like
UniqueRepresentation is meant to also be used by non Parents. So I'd Cheers, |
comment:58
Hi Simon, Replying to @simon-king-jena:
:-)
I am not very keen on having a class inherit (indirectly) from Cheers, |
comment:59
Replying to @nthiery:
Sorry, I meant to write
And
No, it could not, because most parents are no |
comment:60
Replying to @nthiery:
Yes, what I did doesn't fully convince me. With my patch, the But it would be possible to have a custom While |
comment:61
Next: I accidentally found that quotient rings are no unique parents either. I guess they should be, right? |
comment:62
Replying to @simon-king-jena:
Dealt with on a different ticket, I mean... |
comment:63
Replying to @simon-king-jena:
Sound good. |
comment:64
Replying to @simon-king-jena:
Yes, it would work. Yet, in a perfect world, UniqueRepresentation
Good point :-) |
comment:65
I am not sure if the attached patch is up to date. Unfortunately, applying it to sage-4.7.2.alpha3 gives 5 hunks that fail to apply. I hope that I'll be able to get finally a working version during the upcoming sage days 34. |
Changed keywords from objects morphisms containment to objects morphisms containment sd34 |
Purpose
Introduce a framework for testing whether or not something is a morphism in a category. See the discussion on sage-algebra. Here is a summary of the discussion.
Methods for categories
Categories
C
should have a methodC.has_morphism(f)
answering whetherf
is a morphism inC
. By symmetry, we want a methodC.has_object(X)
, answering whetherX
is an object inC
.Note that we want
X in C
to be true if and only ifX
is an object ofC
(so, it is synonymous toC.has_object(X)
). This currently is not always the case:but of course
f
is not an object of the hom-category (it is only contained in an object of the hom-category).Class/Set of objects and morphisms
It would be nice to have container classes for the objects and for the morphisms of a category. Then,
f in C.morphisms()
would be a very natural notation forC.has_morphism(f)
, andX in C.objects()
would be another way of sayingX in C
.Of course, since
f in C.morphisms()
andf in C.objects()
are nice notations, they should be as fast as possible -- otherwise, people wouldn't use them.Further discussion should be put in comments to this ticket.
Depends on #9138
Depends on #11115
Depends on #11780
CC: @nilesjohnson @jpflori
Component: categories
Keywords: objects morphisms containment sd34
Work Issues: Cope with non-unique number fields
Author: Simon King
Issue created by migration from https://trac.sagemath.org/ticket/10667
The text was updated successfully, but these errors were encountered: