Skip to content
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

add a specialized parent object for elliptic-curve morphisms #36972

Merged

Conversation

yyyyx4
Copy link
Member

@yyyyx4 yyyyx4 commented Dec 26, 2023

Currently, the set of morphisms between elliptic curves is a generic SchemeHomset. However, the morphisms between abelian varieties such as elliptic curves have a lot more structure, which should be reflected in Sage by a specialized parent object.
This patch adds such a parent. The current implementation does not really do much except to enable convenience syntax for scalar multiplications. More advanced functionality (structure computation, finding elements, ...) can be added later.

@yyyyx4 yyyyx4 force-pushed the public/homset_for_elliptic_curve_morphisms branch from b3f03e7 to 42e31b5 Compare December 26, 2023 23:11
Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a sensible parent class to create to allow for more complex and interesting code to be included in the future. I cannot think of a reason not to add this parent class

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say there is a more natural way to set up the map from $\mathbb{Z}$ by using _coerce_map_from_, which could return True and then let _element_constructor_ handle constructing the map, which seems like the more natural case here. The other option would be to have _coerce_map_from_ simply return the map. The class for the morphism should be on its own with doctests too (if it survives this change).

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 5, 2024

Thanks for your comments, I think I've addressed them all with the new commits.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes. Sorry for a more incremental review (I am doing more parenting right now and having limited time because of that). There are a few smaller things, but I also have one bigger comment:

I am not sure if we want to instead have the endomorphisms as a separate subclass. I guess since the identity() method is implemented for general homsets, we would want to keep things together. Likewise, I am wondering if there is a use in overriding identity() to return a EllipticCurveHom_scalar.

After these comments are addressed, then it will be a positive review.

@tscrim
Copy link
Collaborator

tscrim commented Jan 12, 2024

So right now we get a really annoying but trivial (and dumb) doctest failures:

sage -t --long --random-seed=286735480429121101562228604801325644303 sage/doctest/forker.py
**********************************************************************
File "sage/doctest/forker.py", line 1560, in sage.doctest.forker.SageDocTestRunner.report_unexpected_exception
Failed example:
    sage0.eval("u")
Expected:
    '...EllipticCurve_field.__init__(self, K, ainvs)'
Got:
    '> /sage/src/sage/schemes/elliptic_curves/ell_field.py(51)__init__()\n-> super().__init__(R, data, category=category)'
**********************************************************************
File "sage/doctest/forker.py", line 1562, in sage.doctest.forker.SageDocTestRunner.report_unexpected_exception
Failed example:
    sage0.eval("p ainvs")
Expected:
    '(0, 0, 0, 0, 0)'
Got:
    "*** NameError: name 'ainvs' is not defined"
**********************************************************************

This comes from the fact that the construction is done differently, so the steps needed by Pbd are different. At least, I believe that to be the problem. Basically, this is a very brittle test, but we will have to fix it. `:/

Some additional comments on the category:

  • _endomorphism_ring_is_commutative should be a method of the elliptic curve since it
  • Sorry it this is mathematically wrong; I am not an expert in this area. You could at least check if the characteristic is 0 for the endset's extra_super_categories() since that would be a quick check. Of course you can do the full check there, but it seems from your code comments that it would be (relatively) expensive to do on construction (without enough benefits). Of course, you could refine the category in is_commutative(), but I don't think we would get any benefits from doing that.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 13, 2024

Fixed the doctest (we have to do u twice now) and turned _endomorphism_ring_is_commutative() into a method.

It's true that characteristic 0 implies commutative endomorphism rings for elliptic curves, but this is no longer true for higher-dimensional abelian varieties: For example, a product of an elliptic curve with itself has $\mathbb Z^{2\times 2}$ in its endomorphism ring. So we cannot set this as a subcategory; it really depends on the object of which we take the End(), just like the .endomorphism_ring_is_commutative() method for elliptic curves over finite fields does. Anyway, I'd argue that this is a non‑issue for the moment: We have no obligation to register something with the finest possible category in which it lies, and I find it hard to imagine that anyone would run End(X) in CommutativeRings() rather than just End(X).is_commutative() as things stand.

Copy link

Documentation preview for this PR (built with commit 157ea69; changes) is ready! 🎉

@yyyyx4 yyyyx4 requested a review from tscrim January 13, 2024 14:28
Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing that and the explanations.

Yes, I agree that we do not need to give the most refined category. It could be done lazily by refining the category when is_commutative() is called.

Thanks for all the fixes. This LGTM now; positive review. We can always make further improvements later on.

@tscrim
Copy link
Collaborator

tscrim commented Jan 18, 2024

PS - Sorry for the delay in getting the final review done.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 18, 2024

No worries, thanks for the review!

@vbraun vbraun merged commit a2151eb into sagemath:develop Jan 22, 2024
@yyyyx4 yyyyx4 deleted the public/homset_for_elliptic_curve_morphisms branch January 22, 2024 01:05
@amanmoon amanmoon mentioned this pull request Feb 10, 2024
3 tasks
@mkoeppe mkoeppe added this to the sage-10.3 milestone Mar 7, 2024
vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 18, 2024
sagemathgh-37262: Added automatic size labeler
    
I have implemented the `automatic size labeler`, which now assigns
labels to pull requests based on the number of lines changed

**Minimal**
Typically involves very small changes, bug fixes, or updates that
require only a few lines of code, often less than 50.
sagemath#37208 sagemath#37146 sagemath#37043

**Small**
Involves more substantial changes than minimal, potentially adding new
features or making modifications to existing ones. The range is usually
between 50 to 100 lines of code.
sagemath#37152 sagemath#37132

**Moderate**
Represents a significant portion of the codebase being modified, such as
adding new features, refactoring, or making extensive changes to
existing functionalities. This might involve between 100 to 300 lines of
code.
sagemath#36919 sagemath#37112

**Large**
Involves substantial and complex changes across various parts of the
codebase. This could include major architectural changes, the
introduction of new modules, or a significant overhaul of existing
features, often exceeding 300 lines of code.
sagemath#37125 sagemath#36977 sagemath#36972

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.

Fixes: sagemath#37254
    
URL: sagemath#37262
Reported by: Aman Moon
Reviewer(s): Sebastian Oehms
vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 20, 2024
sagemathgh-37262: Added automatic size labeler
    
I have implemented the `automatic size labeler`, which now assigns
labels to pull requests based on the number of lines changed

**Minimal**
Typically involves very small changes, bug fixes, or updates that
require only a few lines of code, often less than 50.
sagemath#37208 sagemath#37146 sagemath#37043

**Small**
Involves more substantial changes than minimal, potentially adding new
features or making modifications to existing ones. The range is usually
between 50 to 100 lines of code.
sagemath#37152 sagemath#37132

**Moderate**
Represents a significant portion of the codebase being modified, such as
adding new features, refactoring, or making extensive changes to
existing functionalities. This might involve between 100 to 300 lines of
code.
sagemath#36919 sagemath#37112

**Large**
Involves substantial and complex changes across various parts of the
codebase. This could include major architectural changes, the
introduction of new modules, or a significant overhaul of existing
features, often exceeding 300 lines of code.
sagemath#37125 sagemath#36977 sagemath#36972

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.

Fixes: sagemath#37254
    
URL: sagemath#37262
Reported by: Aman Moon
Reviewer(s): Sebastian Oehms
vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 25, 2024
sagemathgh-37262: Added automatic size labeler
    
I have implemented the `automatic size labeler`, which now assigns
labels to pull requests based on the number of lines changed

**Minimal**
Typically involves very small changes, bug fixes, or updates that
require only a few lines of code, often less than 50.
sagemath#37208 sagemath#37146 sagemath#37043

**Small**
Involves more substantial changes than minimal, potentially adding new
features or making modifications to existing ones. The range is usually
between 50 to 100 lines of code.
sagemath#37152 sagemath#37132

**Moderate**
Represents a significant portion of the codebase being modified, such as
adding new features, refactoring, or making extensive changes to
existing functionalities. This might involve between 100 to 300 lines of
code.
sagemath#36919 sagemath#37112

**Large**
Involves substantial and complex changes across various parts of the
codebase. This could include major architectural changes, the
introduction of new modules, or a significant overhaul of existing
features, often exceeding 300 lines of code.
sagemath#37125 sagemath#36977 sagemath#36972

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.

Fixes: sagemath#37254
    
URL: sagemath#37262
Reported by: Aman Moon
Reviewer(s): Sebastian Oehms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants