Do not inherit from hyperelliptic curves for padic elliptic curve code#41496
Do not inherit from hyperelliptic curves for padic elliptic curve code#41496vbraun merged 24 commits intosagemath:developfrom
Conversation
|
It would be good to have the help of someone who was involved in writing the p-adic elliptic curve code, or someone who uses it. Not me! |
|
I've asked Sabrina for help on this PR who is experienced with writing and using this code (she's the one who helped with the PR for the new hyperelliptic curve code in the weighted projective model). There's two things to do here:
I can handle 1, I think from the sage/python point of view and I hope Sabrina can help with 2. I suppose the question from the "community" which I have is whether it's OK for there to be this code duplication in ell and hyperell due to the impending different projective spaces. |
|
Documentation preview for this PR (built with commit c1de859; changes) is ready! 🎉 |
|
Now I can see the CI is passing with the first sketch of this PR I will start refactoring the code to try and follow more model sagemath guidelines. |
I do not object to code duplication as a temporary measure until #39161 is merged. I think it's a good approach. You could also make use of helper functions if it's duplication of something that isn't getting changed in #39161. I can help review this, although I haven't worked with curves over p-adic fields before. It's close enough to my research area that I don't mind an excuse to learn about it. If you have any recommended references on the subject for someone who is familiar with elliptic curves but not over p-adic fields that would be helpful for me to review this. From your comments, I take it you're looking for feedback but not a full review yet? You can mark the PR as a draft until it's ready for a full review. I'll still answer any discussion questions here while it's a draft, but know not to take a detailed look at the code until it's ready that way. |
|
And just to be sure, the only sense in which this PR would change behaviour is that if |
|
I could mark it as a draft now, it was not in this state before as I wanted the CI to run everything when I originally removed functionality from the old class. I don't have a good resource and the p-adic stuff is something I do not know much about. One of the core dependencies is this monsky_washnitzer.py file, but Sabrina explained to me that this is really in the Affine model, and if you look at #39161 then you can see the only changes of this file are cosmetic so I expect this to go smoothly. For this PR to be merged now is a matter of aesthetic I believe. The code works for genus one and is of the same form as the code in the hyperelliptic branch. A criticism could be made of the code itself which maybe is ready for a proper review for. The mathematical work is in
My daughter is sick at the moment so I do not think I will work on this over the weekend so please do as little or as much as you like. Sabrina said she would also look at it but from my cursory look I'm not sure there's much to optimise in here after all and really this is about cleaning up the old code to modern SageMath standards |
Not only this, but also because of this inheritance Some common ones (like hyperelliptic_polynomials) are already in EllipticCurve and I have introduced all other necessary methods to ensure Doctests pass, but some non-documented functions could now fail I suppose... |
If all existing doctests pass without changes then I think that's good enough that it's unlikely this is breaking anything. By non-documented functions do you mean private methods (i.e. |
CI will run on a draft PR. In terms of how much you need to do to clean up old code to our current standards, when it comes to refactoring old code, my standards are lower than for new code. Refactoring is important but not very interesting work, so as long as the code quality is non-decreasing and you aren't doing something that will make cleaning up the code harder later on I am okay with it. Of course it is nice if you can clean up the old code while you're doing the refactoring, but I will not require you to do that for a positive review. In terms of optimizations, as long as you aren't doing anything that degrades performance it's fine. If you've identified areas that can be optimized, you can add a TODO note in the code and optionally file an issue and tag the issue with If you just want to copy all the needed functions from hyperelliptic curves to elliptic curves (and adapt the doctests accordingly) and remove the inheritance, and leave the rest of the cleanup and optimizations for future work, that's fine by me. A TODO comment and opening an issue (or issues) for what that future work you've identified is would be appreciated in that case. |
|
It would mean cross referencing the API for hyperelliptic generic and the generic elliptic curve. I can do this if we want |
|
I think potentially the "right" thing to do would be to depreciate all the additional hyperelliptic methods, or move them to the elliptic curve generic if that's better. I don't like that the curve over padic gets a bunch of generic functions just because of a different parent to elliptic curves over other fields |
|
Using So it looks like these are the functions we are missing for backwards compatibility at the moment. |
Are actually totally critical, so that's a bug. |
|
A minor mathematical comment: a curve y^2=F(x) with F of degree 4 over a field K is only an elliptic curve over K if it has K - rational points. |
|
Thanks @JohnCremona -- I think because of how we have coded the EllipticCurve constructor for this case we will only ever have an odd degree model? You can't make an elliptic curve with a x^4 term in sage directly right? |
|
I have added all the functions I think need to be included, once I have updated the docstrngs I will make this as ready for review, but if you bhave feedback on the code itself I would be interested. |
…GiacomoPope/sage into remove_hyperelliptic_from_padic
vincentmacri
left a comment
There was a problem hiding this comment.
Okay! Just some cleanup and improvements to error handling left. I'm assuming the remaining TODO items are meant for future work?
|
Thanks for the detailed review! Really appreciate the time you've given to this PR |
vincentmacri
left a comment
There was a problem hiding this comment.
A couple last small things.
Of course! I do have an ulterior motive though: one of my supervisors and I are hoping to get an undergraduate summer research student to do some work that depends on #39161, lol. |
Co-authored-by: Vincent Macri <vincent.macri@ucalgary.ca>
|
Test failures seem irrelevant. Looks good to me! Thanks for doing this work! |
|
I'll get back to looking at #39161 once this PR is merged into develop. |
sagemathgh-41496: Do not inherit from hyperelliptic curves for padic elliptic curve code In the much larger PR sagemath#39161 there is an effort to move from projective space to weighted projective space $$(1 : g + 1 : 1)$$ for hyperelliptic curves. Among many other things, making this change allows for correct arithmetic in Jacobian(H) which currently fails for many curves. When making this change, it was noticed that to access the coleman integral, `EllipticCurve_padic_field` inherits `HyperellipticCurve_padic_field`: ```py class EllipticCurve_padic_field(EllipticCurve_field, HyperellipticCurve_padic_field): .... ``` to access many useful functions. However, it doesnt make sense for elliptic curves to be over weighted projective space and so there's a tension between this inheritance and the work in sagemath#39161. The proposal here is to move the code from the current implementation of `HyperellipticCurve_padic_field` into `EllipticCurve_padic_field` and then when `HyperellipticCurve_padic_field` changes model, the `EllipticCurve_padic_field` methods will be unchanged. There are many TODO here as in moving from the hyperelliptic curve to elliptic curve code, we lose many docstrings and examples which need to be repopulated. This code is also old and could do with some general clean up. Before I start cleaning this up and doing more work, I want to know whether this kind of PR would be accepted in helping sagemath#39161 move forward. URL: sagemath#41496 Reported by: Giacomo Pope Reviewer(s): Giacomo Pope, sabrinakunzweiler, Vincent Macri
sagemathgh-41496: Do not inherit from hyperelliptic curves for padic elliptic curve code In the much larger PR sagemath#39161 there is an effort to move from projective space to weighted projective space $$(1 : g + 1 : 1)$$ for hyperelliptic curves. Among many other things, making this change allows for correct arithmetic in Jacobian(H) which currently fails for many curves. When making this change, it was noticed that to access the coleman integral, `EllipticCurve_padic_field` inherits `HyperellipticCurve_padic_field`: ```py class EllipticCurve_padic_field(EllipticCurve_field, HyperellipticCurve_padic_field): .... ``` to access many useful functions. However, it doesnt make sense for elliptic curves to be over weighted projective space and so there's a tension between this inheritance and the work in sagemath#39161. The proposal here is to move the code from the current implementation of `HyperellipticCurve_padic_field` into `EllipticCurve_padic_field` and then when `HyperellipticCurve_padic_field` changes model, the `EllipticCurve_padic_field` methods will be unchanged. There are many TODO here as in moving from the hyperelliptic curve to elliptic curve code, we lose many docstrings and examples which need to be repopulated. This code is also old and could do with some general clean up. Before I start cleaning this up and doing more work, I want to know whether this kind of PR would be accepted in helping sagemath#39161 move forward. URL: sagemath#41496 Reported by: Giacomo Pope Reviewer(s): Giacomo Pope, sabrinakunzweiler, Vincent Macri
In the much larger PR #39161 there is an effort to move from projective space to weighted projective space$$(1 : g + 1 : 1)$$ for hyperelliptic curves. Among many other things, making this change allows for correct arithmetic in Jacobian(H) which currently fails for many curves.
When making this change, it was noticed that to access the coleman integral,
EllipticCurve_padic_fieldinheritsHyperellipticCurve_padic_field:to access many useful functions. However, it doesnt make sense for elliptic curves to be over weighted projective space and so there's a tension between this inheritance and the work in #39161.
The proposal here is to move the code from the current implementation of
HyperellipticCurve_padic_fieldintoEllipticCurve_padic_fieldand then whenHyperellipticCurve_padic_fieldchanges model, theEllipticCurve_padic_fieldmethods will be unchanged.There are many TODO here as in moving from the hyperelliptic curve to elliptic curve code, we lose many docstrings and examples which need to be repopulated. This code is also old and could do with some general clean up.
Before I start cleaning this up and doing more work, I want to know whether this kind of PR would be accepted in helping #39161 move forward.