-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Implementing SchemeMorphism_sum
#37705
base: develop
Are you sure you want to change the base?
Conversation
return s | ||
|
||
def _add_(self, other): | ||
r""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this _add_
method should only be provided when the underlying scheme is in the category of additive magmas.
sage: E = EllipticCurve(j=42)
sage: E.categories()
[Category of abelian varieties over Rational Field,
Category of commutative additive groups,
Category of additive groups,
Category of additive inverse additive unital additive magmas,
Category of commutative additive monoids,
Category of additive monoids,
Category of additive unital additive magmas,
Category of commutative additive semigroups,
Category of additive commutative additive magmas,
Category of additive semigroups,
Category of additive magmas,
Category of schemes over Rational Field,
Category of schemes,
Category of sets,
Category of sets with partial maps,
Category of objects]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem: For Jacobians of HyperellipticCurve, nothing is declared. What laws does the addition of points of it satisfy?
sage: R.<x> = QQ[]
sage: J = HyperellipticCurve(x^5 + x + 1).jacobian()
sage: phi = End(J).identity()
sage: EJ = End(J)
sage: EJ.categories()
[Category of endsets of schemes over Rational Field,
Category of endsets,
Category of monoids,
Category of semigroups,
Category of unital magmas,
Category of magmas,
Category of homsets of schemes over Rational Field,
Category of homsets,
Category of sets,
Category of sets with partial maps,
Category of objects]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has an abelian group structure - it's basically a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look into how to add this categories structure, I'm not too familiar with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed the jacobian issue so that (nice) jacobians have an abelian variety structure.
sage: EllipticCurve(j=42).categories()
[Category of abelian varieties over Rational Field,
Category of commutative additive groups,
Category of additive groups,
Category of additive inverse additive unital additive magmas,
Category of commutative additive monoids,
Category of additive monoids,
Category of additive unital additive magmas,
Category of commutative additive semigroups,
Category of additive commutative additive magmas,
Category of additive semigroups,
Category of additive magmas,
Category of schemes over Rational Field,
Category of schemes,
Category of sets,
Category of sets with partial maps,
Category of objects]
sage: Jacobian_generic(HyperellipticCurve(x^5 + 1)).categories() == EllipticCurve(j=42).categories()
True
You mentioned that
I think this
_add_
method should only be provided when the underlying scheme is in the category of additive magmas.
How should I implement this? Should I check if self in AdditiveMagmas() and other in AdditiveMagmas()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just provide it via the category, as AbelianVarieties.MorphismMethods._add_
etc.
I think you'll be better off with making a class for arbitrary finite |
Okay, that should just be |
sort of, but the implementation of |
What |
I can overload the constructor of Just a heads up, this PR is my first time writing any structural code, and I had 0 experience with Parent/Element/Category's. I'm just reading the wiki as I go.. |
I don't understand how multi-hierarchy should be done in Sage. Here I want the I think I won't inherit from FormalSum, but instead modify the previous implementation so that instead of |
Yes, don't try to inherit from |
Update: I don't think this is possible, since not everything is hashable. For example, consider hashing an endomorphism of an elliptic curve over |
Okay I spent an unnecessary large amount of time on this and here are some thoughts for future people who come across this
Currently, sage: SchemeMorphism.mro()
[<class 'sage.schemes.generic.morphism.SchemeMorphism'>,
<class 'sage.structure.element.Element'>,
<class 'sage.structure.sage_object.SageObject'>,
<class 'object'>]
sage: EllipticCurveHom.mro()
[<class 'sage.schemes.elliptic_curves.hom.EllipticCurveHom'>,
<class 'sage.categories.morphism.Morphism'>,
<class 'sage.categories.map.Map'>,
<class 'sage.structure.element.Element'>,
<class 'sage.structure.sage_object.SageObject'>,
<class 'object'>] A natural solution would be to try to make sage: E = EllipticCurve(GF(101), [5, 5])
....: P = E.random_point()
....: type(P).mro()
[...
<class 'sage.structure.element.ModuleElement'>,
...
<class 'sage.schemes.generic.morphism.SchemeMorphism'>,
...] It is both a
Matthias suggested providing the
It seems to me that categories is a really useful concept that should be used more in Sage, especially since it can serve as a "typeclass" system (or traits in Rust) independent from Python's types. I think they should be used more, e.g. instead of testing |
Something about "Test modularized distributions" is failing, and not just for me |
Concerning the motivation in the ticket: it would look to me you'd first need endomorphism rings of abelian varieties and then homomorphisms to/from them can be modules over them (by pre- and/or post-composition). Concerning changes to the coercion framework: I guess the main issue with morphisms sets that also form Z-modules is that there's the very general (partial) composition operation and that there is a distinguished set of endomorphisms somewhere that is canonically isomorphic to Z, which produces an action of Z on the set as well. It may well be possible to tweak things so that this works. It works for matrices ... However, whenever you tweak the coercion system you have to be very careful about performance: it tries quite hard to stay out of the way of low-level operations (or at least provide a fast path for it) and that's easily ruined by small changes. The other thing is a general design: it's of course nice if an object can be everything it is at once, but we have forgetful functors for a reason in maths: if you overload all meaning onto an object you could end up with a very restricted notion of morphism. You'll have to be able to dress down the information you're keeping track of so that you can also consider the object in a category with more permissive morphisms. So I think in many cases it will be more flexible to just implement the particular view you're interested in and facilitate easy conversion to objects that emphasize other aspects, and I suspect in some cases you may have to go with that approach. It's not clear to me whether this is one of those cases. |
A relevant old ticket: |
Yes, unrelated to this PR and on my list of things to fix. |
To: Closed subscheme of Affine Space of dimension 2 over Rational Field | ||
defined by: x*y - 1 | ||
Set of scheme endomorphisms of Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: | ||
x*y - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap long doctest output lines, see https://doc.sagemath.org/html/en/developer/coding_basics.html#writing-testable-examples
Do you mind explaining this a bit more? What should the classes inheritance look like? There is Thanks for the other two comments, I will think about these. I agree that sometimes it's more appropriate to separate functionalities, it will just be the most convenient if both functionalities exist at the same time, but maybe in this case that'll make things a lot messier. |
I will have a look at that. This line seems interesting:
They basically do a mathematically wrong thing, but say "when it's mathematically wrong, just don't define the relevant methods"... |
Very nice to see that all examples in #14279 have been sped up by ~5x though, either by my CPU or by Sage |
src/sage/schemes/generic/homset.py
Outdated
@@ -582,7 +644,7 @@ def _coerce_map_from_(self, other): | |||
except AttributeError: # no .ambient_space | |||
return False | |||
elif isinstance(other, SchemeHomset_points): | |||
#we are converting between scheme points | |||
#we are converting between scheme points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#we are converting between scheme points | |
# we are converting between scheme points |
src/sage/schemes/generic/morphism.py
Outdated
Sum morphism: | ||
From: Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | ||
To: Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | ||
Via: (Scheme endomorphism of Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | ||
Defn: Identity map, Scheme endomorphism of Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | ||
Defn: Identity map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sum morphism: | |
From: Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
To: Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
Via: (Scheme endomorphism of Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
Defn: Identity map, Scheme endomorphism of Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
Defn: Identity map) | |
Sum morphism: | |
From: Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
To: Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
Via: (Scheme endomorphism of Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
Defn: Identity map, | |
Scheme endomorphism of Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 - 8*x | |
Defn: Identity map) |
Documentation preview for this PR (built with commit 95e0930; changes) is ready! 🎉 |
I will fix this after my exams are done, but I think a more productive and better way to approach this is to fix the issue with SchemeMorphism and Morphism being incompatible first, just so we don't duplicate code between the two classes... Otherwise, we will need both |
draft until I can think of a sane way to implement this that does not copy and pasting more code and maintaining the same code on two different places |
This PR implements a
SchemeMorphism_sum
class, which is a sum of scheme morphisms. It is refactored out from @yyyyx4'sEllipticHom_sum
class for sum of elliptic curve homomorphisms (zero or isogeny). As a result, we can now mess around with sum of jacobian homomorphisms. This is a step towards defining the endomorphism ring of um things (elliptic curves and jacobians?).cc: @kwankyu
Four questions:
EllipticCurveHom
) overload it?_repr_
description of sum morphisms #37704sage.categories.homset.Homset
?TODO:
Useno, as not all morphisms are hashable.FormalSum
or similar to store the summandsSchemeMorphism
vsMorphism
- inheriting elliptic curve morphisms fromSchemeMorphism
fails.