From 763dfd55d78e2feafc51ffa7b2fc9a90842ddc42 Mon Sep 17 00:00:00 2001 From: Peter Bruin Date: Fri, 16 Feb 2024 15:33:10 +0100 Subject: [PATCH 1/3] make EllipticCurvePoint_field inherit from EllipticCurvePoint --- .../schemes/elliptic_curves/ell_generic.py | 5 +- src/sage/schemes/elliptic_curves/ell_point.py | 103 +++++++----------- .../schemes/projective/projective_homset.py | 4 +- 3 files changed, 45 insertions(+), 67 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py index 07271b9fd39..d5f29c83eeb 100644 --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -572,10 +572,7 @@ def __call__(self, *args, **kwds): P = args[0] if isinstance(P, groups.AdditiveAbelianGroupElement) and isinstance(P.parent(),ell_torsion.EllipticCurveTorsionSubgroup): return self(P.element()) - if isinstance(args[0], - (ell_point.EllipticCurvePoint_field, - ell_point.EllipticCurvePoint_number_field, - ell_point.EllipticCurvePoint)): + if isinstance(args[0], ell_point.EllipticCurvePoint): if P.curve() is self: return P # check if denominator of the point contains a factor of the diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index bcfe8d5c1d2..27d0bc848ba 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -1,18 +1,15 @@ r""" Points on elliptic curves -The base class ``EllipticCurvePoint_field``, derived from -``AdditiveGroupElement``, provides support for points on elliptic -curves defined over general fields. The derived classes -``EllipticCurvePoint_number_field`` and -``EllipticCurvePoint_finite_field`` provide further support for point -on curves defined over number fields (including the rational field +The base class :class:`EllipticCurvePoint` currently provides little +functionality of its own. Its derived class +:class:`EllipticCurvePoint_field` provides support for points on +elliptic curves over general fields. The derived classes +:class:`EllipticCurvePoint_number_field` and +:class:`EllipticCurvePoint_finite_field` provide further support for +points on curves over number fields (including the rational field `\QQ`) and over finite fields. -The class ``EllipticCurvePoint``, which is based on -``SchemeMorphism_point_projective_ring``, currently has little extra -functionality. - EXAMPLES: An example over `\QQ`:: @@ -107,7 +104,6 @@ - Mariah Lenox (March 2011) -- Added ``tate_pairing`` and ``ate_pairing`` functions to ``EllipticCurvePoint_finite_field`` class - """ # **************************************************************************** @@ -134,6 +130,8 @@ from sage.rings.real_mpfr import RealField from sage.rings.real_mpfr import RR import sage.groups.generic as generic + +from sage.structure.element import AdditiveGroupElement from sage.structure.sequence import Sequence from sage.structure.richcmp import richcmp @@ -153,14 +151,44 @@ PariError = () -class EllipticCurvePoint(SchemeMorphism_point_projective_ring): +class EllipticCurvePoint(AdditiveGroupElement, + SchemeMorphism_point_projective_ring): """ A point on an elliptic curve. """ - pass + def curve(self): + """ + Return the curve that this point is on. + + This is a synonym for :meth:`scheme`. + EXAMPLES:: -class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): + sage: E = EllipticCurve('389a') + sage: P = E([-1, 1]) + sage: P.curve() + Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field + + sage: E = EllipticCurve(QQ, [1, 1]) + sage: P = E(0, 1) + sage: P.scheme() + Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field + sage: P.scheme() == P.curve() + True + sage: x = polygen(ZZ, 'x') + sage: K. = NumberField(x^2 - 3,'a') # needs sage.rings.number_field + sage: P = E.base_extend(K)(1, a) # needs sage.rings.number_field + sage: P.scheme() # needs sage.rings.number_field + Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3 + """ + return self.scheme() + + +# While the class EllipticCurvePoint itself currently provides little +# functionality, inheritance from EllipticCurvePoint is checked in the +# __contains__() and __call__() methods of EllipticCurve_generic. +class EllipticCurvePoint_field(EllipticCurvePoint, + SchemeMorphism_point_abelian_variety_field): """ A point on an elliptic curve over a field. The point has coordinates in the base field. @@ -275,7 +303,6 @@ def __init__(self, curve, v, check=True): v = (R.zero(), R.one(), R.zero()) SchemeMorphism_point_abelian_variety_field.__init__(self, point_homset, v, check=check) - # AdditiveGroupElement.__init__(self, point_homset) self.normalize_coordinates() @@ -426,39 +453,6 @@ def __pari__(self): else: return pari([0]) - def scheme(self): - """ - Return the scheme of this point, i.e., the curve it is on. - This is synonymous with :meth:`curve` which is perhaps more - intuitive. - - EXAMPLES:: - - sage: E = EllipticCurve(QQ,[1,1]) - sage: P = E(0,1) - sage: P.scheme() - Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field - sage: P.scheme() == P.curve() - True - sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3,'a') # needs sage.rings.number_field - sage: P = E.base_extend(K)(1, a) # needs sage.rings.number_field - sage: P.scheme() # needs sage.rings.number_field - Elliptic Curve defined by y^2 = x^3 + x + 1 - over Number Field in a with defining polynomial x^2 - 3 - """ - # The following text is just not true: it applies to the class - # EllipticCurvePoint, which appears to be never used, but does - # not apply to EllipticCurvePoint_field which is simply derived - # from AdditiveGroupElement. - # - # "Technically, points on curves in Sage are scheme maps from - # the domain Spec(F) where F is the base field of the curve to - # the codomain which is the curve. See also domain() and - # codomain()." - - return self.codomain() - def order(self): r""" Return the order of this point on the elliptic curve. @@ -499,19 +493,6 @@ def order(self): additive_order = order - def curve(self): - """ - Return the curve that this point is on. - - EXAMPLES:: - - sage: E = EllipticCurve('389a') - sage: P = E([-1,1]) - sage: P.curve() - Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field - """ - return self.scheme() - def __bool__(self): """ Return ``True`` if this is not the zero point on the curve. diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py index 2a61c1dd17c..9a2334657e8 100644 --- a/src/sage/schemes/projective/projective_homset.py +++ b/src/sage/schemes/projective/projective_homset.py @@ -594,11 +594,11 @@ class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_f sage: P (3 : a : 1) sage: P in E - False + True sage: P in E.base_extend(K) True sage: P in X.codomain() - False + True sage: P in X.extended_codomain() True From 0e8e479c60388cf7ef341ae0298ca64b3b2e35df Mon Sep 17 00:00:00 2001 From: Peter Bruin Date: Thu, 22 Feb 2024 10:30:43 +0100 Subject: [PATCH 2/3] make EllipticCurve_generic.__contains__() only return True if base fields agree --- src/sage/schemes/elliptic_curves/ell_generic.py | 5 +---- src/sage/schemes/projective/projective_homset.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py index d5f29c83eeb..a534f2df9e4 100644 --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -456,10 +456,7 @@ def __contains__(self, P): P = self(P) except TypeError: return False - if P.curve() == self: - return True - x, y, a = P[0], P[1], self.ainvs() - return y**2 + a[0]*x*y + a[2]*y == x**3 + a[1]*x**2 + a[3]*x + a[4] + return P.curve() == self def __call__(self, *args, **kwds): r""" diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py index 9a2334657e8..2a61c1dd17c 100644 --- a/src/sage/schemes/projective/projective_homset.py +++ b/src/sage/schemes/projective/projective_homset.py @@ -594,11 +594,11 @@ class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_f sage: P (3 : a : 1) sage: P in E - True + False sage: P in E.base_extend(K) True sage: P in X.codomain() - True + False sage: P in X.extended_codomain() True From fa733648f7830df9304f92150beaf529efaa4109 Mon Sep 17 00:00:00 2001 From: Peter Bruin Date: Fri, 10 May 2024 20:45:07 +0200 Subject: [PATCH 3/3] remove unimportant comment --- src/sage/schemes/elliptic_curves/ell_point.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 27d0bc848ba..439b7b2246d 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -184,9 +184,6 @@ def curve(self): return self.scheme() -# While the class EllipticCurvePoint itself currently provides little -# functionality, inheritance from EllipticCurvePoint is checked in the -# __contains__() and __call__() methods of EllipticCurve_generic. class EllipticCurvePoint_field(EllipticCurvePoint, SchemeMorphism_point_abelian_variety_field): """