Path: blob/master/sage/schemes/hyperelliptic_curves/jacobian_homset.py
4159 views
"""1Rational point sets on a Jacobian23EXAMPLES::45sage: x = QQ['x'].06sage: f = x^5 + x + 17sage: C = HyperellipticCurve(f); C8Hyperelliptic Curve over Rational Field defined by y^2 = x^5 + x + 19sage: C(QQ)10Set of rational points of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 + x + 111sage: P = C([0,1,1])12sage: J = C.jacobian(); J13Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 + x + 114sage: Q = J(QQ)(P); Q15(x, y - 1)16sage: Q + Q17(x^2, y - 1/2*x - 1)18sage: Q*319(x^2 - 1/64*x + 1/8, y + 255/512*x + 65/64)2021::2223sage: F.<a> = GF(3)24sage: R.<x> = F[]25sage: f = x^5-126sage: C = HyperellipticCurve(f)27sage: J = C.jacobian()28sage: X = J(F)29sage: a = x^2-x+130sage: b = -x +131sage: c = x-132sage: d = 033sage: D1 = X([a,b])34sage: D135(x^2 + 2*x + 1, y + x + 2)36sage: D2 = X([c,d])37sage: D238(x + 2, y)39sage: D1+D240(x^2 + 2*x + 2, y + 2*x + 1)41"""4243#*****************************************************************************44# Copyright (C) 2006 David Kohel <[email protected]>45# Distributed under the terms of the GNU General Public License (GPL)46# http://www.gnu.org/licenses/47#*****************************************************************************4849from sage.rings.all import is_Polynomial, PolynomialRing, Integer, is_Integer, ZZ50from sage.schemes.generic.homset import SchemeHomset_points51from sage.schemes.generic.morphism import is_SchemeMorphism52from sage.schemes.generic.spec import Spec, is_Spec53from jacobian_morphism import JacobianMorphism_divisor_class_field5455class JacobianHomset_divisor_classes(SchemeHomset_points):56def __init__(self, Y, X, **kwds):57R = X.base_ring()58S = Y.coordinate_ring()59SchemeHomset_points.__init__(self, Y, X, **kwds)60P2 = X.curve()._printing_ring61if S != R:62y = str(P2.gen())63x = str(P2.base_ring().gen())64P1 = PolynomialRing(S,name=x)65P2 = PolynomialRing(P1,name=y)66self._printing_ring = P26768def __call__(self, P):69r"""70Returns a rational point P in the abstract Homset J(K), given:71720. A point P in J = Jac(C), returning P; 1. A point P on the curve73C such that J = Jac(C), where C is an odd degree model, returning74[P - oo]; 2. A pair of points (P, Q) on the curve C such that J =75Jac(C), returning [P-Q]; 2. A list of polynomials (a,b) such that76`b^2 + h*b - f = 0 mod a`, returning [(a(x),y-b(x))].7778EXAMPLES::7980sage: P.<x> = PolynomialRing(QQ)81sage: f = x^5 - x + 1; h = x82sage: C = HyperellipticCurve(f,h,'u,v')83sage: P = C(0,1,1)84sage: J = C.jacobian()85sage: Q = J(QQ)(P)86sage: for i in range(6): i*Q87(1)88(u, v - 1)89(u^2, v + u - 1)90(u^2, v + 1)91(u, v + 1)92(1)9394::9596sage: F.<a> = GF(3)97sage: R.<x> = F[]98sage: f = x^5-199sage: C = HyperellipticCurve(f)100sage: J = C.jacobian()101sage: X = J(F)102sage: a = x^2-x+1103sage: b = -x +1104sage: c = x-1105sage: d = 0106sage: D1 = X([a,b])107sage: D1108(x^2 + 2*x + 1, y + x + 2)109sage: D2 = X([c,d])110sage: D2111(x + 2, y)112sage: D1+D2113(x^2 + 2*x + 2, y + 2*x + 1)114115"""116if isinstance(P,(int,long,Integer)) and P == 0:117R = PolynomialRing(self.value_ring(), 'x')118return JacobianMorphism_divisor_class_field(self, (R(1),R(0)))119elif isinstance(P,(list,tuple)):120if len(P) == 1 and P[0] == 0:121R = PolynomialRing(self.value_ring(), 'x')122return JacobianMorphism_divisor_class_field(self, (R(1),R(0)))123elif len(P) == 2:124P1 = P[0]125P2 = P[1]126if is_Integer(P1) and is_Integer(P2):127R = PolynomialRing(self.value_ring(), 'x')128P1 = R(P1)129P2 = R(P2)130return JacobianMorphism_divisor_class_field(self, tuple([P1,P2]))131if is_Integer(P1) and is_Polynomial(P2):132R = PolynomialRing(self.value_ring(), 'x')133P1 = R(P1)134return JacobianMorphism_divisor_class_field(self, tuple([P1,P2]))135if is_Integer(P2) and is_Polynomial(P1):136R = PolynomialRing(self.value_ring(), 'x')137P2 = R(P2)138return JacobianMorphism_divisor_class_field(self, tuple([P1,P2]))139if is_Polynomial(P1) and is_Polynomial(P2):140return JacobianMorphism_divisor_class_field(self, tuple(P))141if is_SchemeMorphism(P1) and is_SchemeMorphism(P2):142return self(P1) - self(P2)143raise TypeError, "Argument P (= %s) must have length 2."%P144elif isinstance(P,JacobianMorphism_divisor_class_field) and self == P.parent():145return P146elif is_SchemeMorphism(P):147x0 = P[0]; y0 = P[1]148R, x = PolynomialRing(self.value_ring(), 'x').objgen()149return self((x-x0,R(y0)))150raise TypeError, "Argument P (= %s) does not determine a divisor class"%P151152def _cmp_(self,other):153if self.curve() == other.curve():154return 0155else:156return -1157158def _morphism(self, *args, **kwds):159return JacobianMorphism_divisor_class_field(*args, **kwds)160161def curve(self):162return self.codomain().curve()163164def value_ring(self):165"""166Returns S for a homset X(T) where T = Spec(S).167"""168T = self.domain()169if is_Spec(T):170return T.coordinate_ring()171else:172raise TypeError, "Domain of argument must be of the form Spec(S)."173174def base_extend(self, R):175if R != ZZ:176raise NotImplementedError, "Jacobian point sets viewed as modules over rings other than ZZ not implemented"177return self178179180