-
-
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
Adding support for morphisms to the category framework #8807
Comments
Implementing induced homomorphisms; Functors on morphisms; some doc tests |
Attachment: 8807functors_and_induced_morphisms.patch.gz Fixing a buglet in the construction functor of Laurent Polynomial Rings. To be applied after the first patch |
comment:1
Attachment: 8807functors_and_induced_morphisms.p1.patch.gz Cc to the original authors. I solved the problem. Please apply both patches in order. New Code I cleaned the framework for functors. There is a generic call method that (in contrast to the old generic call method) has a return value. It relies on three methods _coerce_into_domain, _apply_functor and _apply_functor_to_morphism. The default methods are already enough for forgetful functor and most construction functors. I implemented a new class for Ring Homomorphisms that are induced by a homomorphism of the base ring. This enables the application of the construction functors for matrix and polynomial rings. Tests All new code is tested, and I added also some doc tests for old code. This is related with #8800. However, #8800 should not be closed, because the old code is still not completely covered by tests yet. Suggestion: The further work on #8800 will build upon this ticket. Showcases We start with a homomorphism of polynomial rings.
Now we construct polynomial rings based on
The construction of induced homomorphisms is recursive, and so we have:
And this can also be achieved using construction functors:
With the second patch, Laurent polynomial rings work as well:
|
comment:2
I applied this patch to sage-4.5, and ran "make ptestlong", and their are failures all over the place, e.g.,
|
comment:3
Dear William, thanks for looking at this! Indeed it has been a long time since I wrote it, so it is time to resume work, taking a fresh look at my own code. I think this will be my project for the rest of Sage Days 24! |
comment:4
It seems that my patch crashed the coercion system. Funny coincidence that I held a tutorial on coercion today...
Cheers, |
comment:5
And there it is:
So, the problem is that I gave the matrix constructor got a wrong codomain, namely the category
Since the construction functor can not know about the base ring, I guess |
comment:6
I went through the file and found that indeed in some cases wrong categories were chosen. I count this as an argument pro my approach to have a generic After doing the appropriate changes, I am running ptestlong as well. |
comment:7
I produced a new patch (I hope I got the The problem was:
Solution:
One remark concerning doctests. The genuinely new code (induced morphisms) is doctested. In my patch, I however did not add tests for sage.categories.pushout. This is done in #8800. I hope that the ticket from #8800 still applies with the new patch that I posted here. |
comment:8
Replying to @simon-king-jena:
Unfortunately, #8800 does not apply with the new patch from here. Suggestion: I'll rebase #8800 relative to the new patch here. So, #8807 would be reviewed first, and the next to review would be #8800, which contains many doctests. I hope this is acceptable. |
comment:9
Review: Just a few trivial comments, after which I could give this a positive review. The patch applies fine to 4.6.rc0 (though the related one at #8800 does not then apply cleanly) and all tests pass. There is no time regression (long tests took 667s before and 642s after, using -tp 20). Here are the minor issues in docstrings: line 44: "one should implement two methods" -- do you mean three? _apply_functor_to_morphism: first line of docstring is a copy from the previous function but should presumably be "Apply the functor to a morphism between ... something" In the new Is the spelling of " |
comment:10
Hi John! Replying to @JohnCremona:
That's good news! As my patch only adds functionality, without changing the method resolution order of existing classes and without replacing existing algorithms, it is no surprise that the speed remains fine.
You know, there are three types of mathematicians: Some can count, and others can't. But isn't it pythonesque? Recall the Holy Hand Grenade of Antioch from the movie "Monty Python and the Holy Grail"... :)
Right.
OK, but I hope such example needs to be constructed on purpose. It used to happen with the matrix constructor, for example: The functor was supposed to take a ring R into the ring(!!) of m by n matrices over R. But if the matrix constructor does not produce square matrices, the result is of course not a ring. This bug existed before and is fixed in my patch (now, the functor's codomain is only expected to be the category of rings if m equals n). However, this is exactly the situation that is covered by the
This wasn't my idea. As I mentioned on the other ticket, I will be unable to do any programming work at least until next week. But it should be one of the first things I'll do once I'm settled in Jena. Best regards, Simon |
comment:11
Replying to @JohnCremona:
Corrected.
Corrected.
Done. I define a class that behaves like the matrix constructor used to.
That spelling is old, so, I won't touch it. I am running Cheers, |
comment:12
OK, patch is updated. Please only apply |
Reviewer: John Cremona |
Attachment: trac-8807_induced_morphisms.patch.gz This patch applies to sage-4.6; it is the only patch to be applied |
comment:13
Looks good, about to test with 4.6.1.alpha2. |
comment:14
All tests pass -- but I forgot -long, so hold on... |
comment:15
...all long tests pass! |
comment:16
Replying to @JohnCremona:
Sorry, I am a complete idiot. I imported the patch and did sage -b but never qpushed it. Back to square one. |
comment:18
Third time lucky: I did apply the patch, and rebuild, and test the entire library with -long, and all tests pass. (4.6.1.alpha2, 64-bit), |
comment:19
Release manager: after merging this patch, please also do the one at #10318 which has a positive review and just does a lot of spelling corrections, mostly on the file which this one affects most. |
comment:21
To the buildbot and the release manager: Apply trac-8807_induced_morphisms.patch |
Merged: sage-4.6.2.alpha0 |
Working on the doc tests for sage.category at #8800, I found that support for morphisms is missing in the category framework. I think this is important, and therefore I am opening this ticket.
Some thoughts on implementing support.
Let f be a morphism in a category C, and let F be a functor, F.domain()==C. Then F(f) should by default try F(f.domain()).hom(f,F(f.codomain())). This relies on the call method of F(f.domain()).Hom(F.codomain()), which in turn uses _coerce_impl. I think it is there where the support should be implemented.
Example:
In sage.rings.homset.RingHomset_generic_with_category._coerce_impl, one has
Why not instead
If I do so, the following works:
It should be straight forward to change the call method of
C
so thatC(f)
reproduces the above construction. Similarly, ifF
is a functor thenF(f)
should callF(f.domain()).hom(f,F(f.codomain()))
.CC: @sagetrac-kohel @williamstein @wdjoyner @robertwb
Component: categories
Keywords: morphisms functors categories
Author: Simon King
Reviewer: John Cremona
Merged: sage-4.6.2.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/8807
The text was updated successfully, but these errors were encountered: