Path: blob/master/src/sage/schemes/projective/projective_homset.py
8820 views
r"""1Set of homomorphisms between two proejctive schemes23For schemes `X` and `Y`, this module implements the set of morphisms4`Hom(X,Y)`. This is done by :class:`SchemeHomset_generic`.56As a special case, the Hom-sets can also represent the points of a7scheme. Recall that the `K`-rational points of a scheme `X` over `k`8can be identified with the set of morphisms `Spec(K) \to X`. In Sage9the rational points are implemented by such scheme morphisms. This is10done by :class:`SchemeHomset_points` and its subclasses.1112.. note::1314You should not create the Hom-sets manually. Instead, use the15:meth:`~sage.structure.parent.Hom` method that is inherited by all16schemes.1718AUTHORS:1920- William Stein (2006): initial version.2122- Volker Braun (2011-08-11): significant improvement and refactoring.2324- Ben Hutz (June 2012): added support for projective ring25"""262728#*****************************************************************************29# Copyright (C) 2011 Volker Braun <[email protected]>30# Copyright (C) 2006 William Stein <[email protected]>31#32# Distributed under the terms of the GNU General Public License (GPL)33# as published by the Free Software Foundation; either version 2 of34# the License, or (at your option) any later version.35# http://www.gnu.org/licenses/36#*****************************************************************************3738from sage.rings.all import ZZ39from sage.schemes.generic.homset import SchemeHomset_points4041from sage.rings.rational_field import is_RationalField42from sage.rings.finite_rings.constructor import is_FiniteField4344#*******************************************************************45# Projective varieties46#*******************************************************************47class SchemeHomset_points_projective_field(SchemeHomset_points):48"""49Set of rational points of a projective variety over a field.5051INPUT:5253See :class:`SchemeHomset_generic`.5455EXAMPLES::5657sage: from sage.schemes.projective.projective_homset import SchemeHomset_points_projective_field58sage: SchemeHomset_points_projective_field(Spec(QQ), ProjectiveSpace(QQ,2))59Set of rational points of Projective Space of dimension 2 over Rational Field60"""61def points(self, B=0):62"""63Return some or all rational points of a projective scheme.6465INPUT:6667- `B` -- integer (optional, default=0). The bound for the68coordinates.6970OUTPUT:7172A list of points. Over a finite field, all points are73returned. Over an infinite field, all points satisfying the74bound are returned.7576EXAMPLES::7778sage: P1 = ProjectiveSpace(GF(2),1)79sage: F.<a> = GF(4,'a')80sage: P1(F).points()81[(0 : 1), (1 : 0), (1 : 1), (a : 1), (a + 1 : 1)]82"""83from sage.schemes.projective.projective_rational_point import enum_projective_rational_field84from sage.schemes.projective.projective_rational_point import enum_projective_finite_field85R = self.value_ring()86if is_RationalField(R):87if not B > 0:88raise TypeError, "A positive bound B (= %s) must be specified."%B89return enum_projective_rational_field(self,B)90elif is_FiniteField(R):91return enum_projective_finite_field(self.extended_codomain())92else:93raise TypeError, "Unable to enumerate points over %s."%R9495class SchemeHomset_points_projective_ring(SchemeHomset_points):96"""97Set of rational points of a projective variety over a commutative ring.9899INPUT:100101See :class:`SchemeHomset_generic`.102103EXAMPLES::104105sage: from sage.schemes.projective.projective_homset import SchemeHomset_points_projective_ring106sage: SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))107Set of rational points of Projective Space of dimension 2 over Integer Ring108"""109110def points(self, B=0):111"""112Return some or all rational points of a projective scheme.113114INPUT:115116- `B` -- integer (optional, default=0). The bound for the117coordinates.118119EXAMPLES::120121sage: from sage.schemes.projective.projective_homset import SchemeHomset_points_projective_ring122sage: H = SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))123sage: H.points(3)124[(0 : 0 : 1), (0 : 1 : -3), (0 : 1 : -2), (0 : 1 : -1), (0 : 1 : 0), (0125: 1 : 1), (0 : 1 : 2), (0 : 1 : 3), (0 : 2 : -3), (0 : 2 : -1), (0 : 2 :1261), (0 : 2 : 3), (0 : 3 : -2), (0 : 3 : -1), (0 : 3 : 1), (0 : 3 : 2),127(1 : -3 : -3), (1 : -3 : -2), (1 : -3 : -1), (1 : -3 : 0), (1 : -3 : 1),128(1 : -3 : 2), (1 : -3 : 3), (1 : -2 : -3), (1 : -2 : -2), (1 : -2 : -1),129(1 : -2 : 0), (1 : -2 : 1), (1 : -2 : 2), (1 : -2 : 3), (1 : -1 : -3),130(1 : -1 : -2), (1 : -1 : -1), (1 : -1 : 0), (1 : -1 : 1), (1 : -1 : 2),131(1 : -1 : 3), (1 : 0 : -3), (1 : 0 : -2), (1 : 0 : -1), (1 : 0 : 0), (1132: 0 : 1), (1 : 0 : 2), (1 : 0 : 3), (1 : 1 : -3), (1 : 1 : -2), (1 : 1 :133-1), (1 : 1 : 0), (1 : 1 : 1), (1 : 1 : 2), (1 : 1 : 3), (1 : 2 : -3),134(1 : 2 : -2), (1 : 2 : -1), (1 : 2 : 0), (1 : 2 : 1), (1 : 2 : 2), (1 :1352 : 3), (1 : 3 : -3), (1 : 3 : -2), (1 : 3 : -1), (1 : 3 : 0), (1 : 3 :1361), (1 : 3 : 2), (1 : 3 : 3), (2 : -3 : -3), (2 : -3 : -2), (2 : -3 :137-1), (2 : -3 : 0), (2 : -3 : 1), (2 : -3 : 2), (2 : -3 : 3), (2 : -2 :138-3), (2 : -2 : -1), (2 : -2 : 1), (2 : -2 : 3), (2 : -1 : -3), (2 : -1 :139-2), (2 : -1 : -1), (2 : -1 : 0), (2 : -1 : 1), (2 : -1 : 2), (2 : -1 :1403), (2 : 0 : -3), (2 : 0 : -1), (2 : 0 : 1), (2 : 0 : 3), (2 : 1 : -3),141(2 : 1 : -2), (2 : 1 : -1), (2 : 1 : 0), (2 : 1 : 1), (2 : 1 : 2), (2 :1421 : 3), (2 : 2 : -3), (2 : 2 : -1), (2 : 2 : 1), (2 : 2 : 3), (2 : 3 :143-3), (2 : 3 : -2), (2 : 3 : -1), (2 : 3 : 0), (2 : 3 : 1), (2 : 3 : 2),144(2 : 3 : 3), (3 : -3 : -2), (3 : -3 : -1), (3 : -3 : 1), (3 : -3 : 2),145(3 : -2 : -3), (3 : -2 : -2), (3 : -2 : -1), (3 : -2 : 0), (3 : -2 : 1),146(3 : -2 : 2), (3 : -2 : 3), (3 : -1 : -3), (3 : -1 : -2), (3 : -1 : -1),147(3 : -1 : 0), (3 : -1 : 1), (3 : -1 : 2), (3 : -1 : 3), (3 : 0 : -2), (3148: 0 : -1), (3 : 0 : 1), (3 : 0 : 2), (3 : 1 : -3), (3 : 1 : -2), (3 : 1149: -1), (3 : 1 : 0), (3 : 1 : 1), (3 : 1 : 2), (3 : 1 : 3), (3 : 2 : -3),150(3 : 2 : -2), (3 : 2 : -1), (3 : 2 : 0), (3 : 2 : 1), (3 : 2 : 2), (3 :1512 : 3), (3 : 3 : -2), (3 : 3 : -1), (3 : 3 : 1), (3 : 3 : 2)]152"""153R = self.value_ring()154if R == ZZ:155if not B > 0:156raise TypeError, "A positive bound B (= %s) must be specified."%B157from sage.schemes.projective.projective_rational_point import enum_projective_rational_field158return enum_projective_rational_field(self,B)159else:160raise TypeError, "Unable to enumerate points over %s."%R161162163#*******************************************************************164# Abelian varieties165#*******************************************************************166class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_field):167r"""168Set of rational points of an abelian variety.169170INPUT:171172See :class:`SchemeHomset_generic`.173174TESTS:175176The bug reported at trac #1785 is fixed::177178sage: K.<a> = NumberField(x^2 + x - (3^3-3))179sage: E = EllipticCurve('37a')180sage: X = E(K)181sage: X182Abelian group of points on Elliptic Curve defined by183y^2 + y = x^3 + (-1)*x over Number Field in a with184defining polynomial x^2 + x - 24185sage: P = X([3,a])186sage: P187(3 : a : 1)188sage: P in E189False190sage: P in E.base_extend(K)191True192sage: P in X.codomain()193False194sage: P in X.extended_codomain()195True196"""197198def _element_constructor_(self, *v, **kwds):199"""200The element contstructor.201202INPUT:203204- ``v`` -- anything that determines a scheme morphism in the205Hom-set.206207OUTPUT:208209The scheme morphism determined by ``v``.210211EXAMPLES::212213sage: E = EllipticCurve('37a')214sage: X = E(QQ)215sage: P = X([0,1,0]); P216(0 : 1 : 0)217sage: type(P)218<class 'sage.schemes.elliptic_curves.ell_point.EllipticCurvePoint_number_field'>219220TESTS::221222sage: X._element_constructor_([0,1,0])223(0 : 1 : 0)224"""225if len(v) == 1:226v = v[0]227return self.codomain()._point(self.extended_codomain(), v, **kwds)228229def _repr_(self):230"""231Return a string representation of ``self``.232233OUTPUT:234235String.236237EXAMPLES::238239sage: E = EllipticCurve('37a')240sage: X = E(QQ)241sage: X._repr_()242'Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field'243"""244s = 'Abelian group of points on ' + str(self.extended_codomain())245return s246247def base_extend(self, R):248"""249Extend the base ring.250251This is currently not implemented except for the trivial case252``R==ZZ``.253254INPUT:255256- ``R`` -- a ring.257258EXAMPLES::259260sage: E = EllipticCurve('37a')261sage: Hom = E.point_homset(); Hom262Abelian group of points on Elliptic Curve defined263by y^2 + y = x^3 - x over Rational Field264sage: Hom.base_ring()265Integer Ring266sage: Hom.base_extend(QQ)267Traceback (most recent call last):268...269NotImplementedError: Abelian variety point sets are not270implemented as modules over rings other than ZZ.271"""272if R is not ZZ:273raise NotImplementedError('Abelian variety point sets are not '274'implemented as modules over rings other than ZZ.')275return self276277278from sage.structure.sage_object import register_unpickle_override279register_unpickle_override('sage.schemes.generic.homset',280'SchemeHomsetModule_abelian_variety_coordinates_field',281SchemeHomset_points_abelian_variety_field)282283284285