Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/schemes/projective/projective_homset.py
8820 views
1
r"""
2
Set of homomorphisms between two proejctive schemes
3
4
For schemes `X` and `Y`, this module implements the set of morphisms
5
`Hom(X,Y)`. This is done by :class:`SchemeHomset_generic`.
6
7
As a special case, the Hom-sets can also represent the points of a
8
scheme. Recall that the `K`-rational points of a scheme `X` over `k`
9
can be identified with the set of morphisms `Spec(K) \to X`. In Sage
10
the rational points are implemented by such scheme morphisms. This is
11
done by :class:`SchemeHomset_points` and its subclasses.
12
13
.. note::
14
15
You should not create the Hom-sets manually. Instead, use the
16
:meth:`~sage.structure.parent.Hom` method that is inherited by all
17
schemes.
18
19
AUTHORS:
20
21
- William Stein (2006): initial version.
22
23
- Volker Braun (2011-08-11): significant improvement and refactoring.
24
25
- Ben Hutz (June 2012): added support for projective ring
26
"""
27
28
29
#*****************************************************************************
30
# Copyright (C) 2011 Volker Braun <[email protected]>
31
# Copyright (C) 2006 William Stein <[email protected]>
32
#
33
# Distributed under the terms of the GNU General Public License (GPL)
34
# as published by the Free Software Foundation; either version 2 of
35
# the License, or (at your option) any later version.
36
# http://www.gnu.org/licenses/
37
#*****************************************************************************
38
39
from sage.rings.all import ZZ
40
from sage.schemes.generic.homset import SchemeHomset_points
41
42
from sage.rings.rational_field import is_RationalField
43
from sage.rings.finite_rings.constructor import is_FiniteField
44
45
#*******************************************************************
46
# Projective varieties
47
#*******************************************************************
48
class SchemeHomset_points_projective_field(SchemeHomset_points):
49
"""
50
Set of rational points of a projective variety over a field.
51
52
INPUT:
53
54
See :class:`SchemeHomset_generic`.
55
56
EXAMPLES::
57
58
sage: from sage.schemes.projective.projective_homset import SchemeHomset_points_projective_field
59
sage: SchemeHomset_points_projective_field(Spec(QQ), ProjectiveSpace(QQ,2))
60
Set of rational points of Projective Space of dimension 2 over Rational Field
61
"""
62
def points(self, B=0):
63
"""
64
Return some or all rational points of a projective scheme.
65
66
INPUT:
67
68
- `B` -- integer (optional, default=0). The bound for the
69
coordinates.
70
71
OUTPUT:
72
73
A list of points. Over a finite field, all points are
74
returned. Over an infinite field, all points satisfying the
75
bound are returned.
76
77
EXAMPLES::
78
79
sage: P1 = ProjectiveSpace(GF(2),1)
80
sage: F.<a> = GF(4,'a')
81
sage: P1(F).points()
82
[(0 : 1), (1 : 0), (1 : 1), (a : 1), (a + 1 : 1)]
83
"""
84
from sage.schemes.projective.projective_rational_point import enum_projective_rational_field
85
from sage.schemes.projective.projective_rational_point import enum_projective_finite_field
86
R = self.value_ring()
87
if is_RationalField(R):
88
if not B > 0:
89
raise TypeError, "A positive bound B (= %s) must be specified."%B
90
return enum_projective_rational_field(self,B)
91
elif is_FiniteField(R):
92
return enum_projective_finite_field(self.extended_codomain())
93
else:
94
raise TypeError, "Unable to enumerate points over %s."%R
95
96
class SchemeHomset_points_projective_ring(SchemeHomset_points):
97
"""
98
Set of rational points of a projective variety over a commutative ring.
99
100
INPUT:
101
102
See :class:`SchemeHomset_generic`.
103
104
EXAMPLES::
105
106
sage: from sage.schemes.projective.projective_homset import SchemeHomset_points_projective_ring
107
sage: SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))
108
Set of rational points of Projective Space of dimension 2 over Integer Ring
109
"""
110
111
def points(self, B=0):
112
"""
113
Return some or all rational points of a projective scheme.
114
115
INPUT:
116
117
- `B` -- integer (optional, default=0). The bound for the
118
coordinates.
119
120
EXAMPLES::
121
122
sage: from sage.schemes.projective.projective_homset import SchemeHomset_points_projective_ring
123
sage: H = SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))
124
sage: H.points(3)
125
[(0 : 0 : 1), (0 : 1 : -3), (0 : 1 : -2), (0 : 1 : -1), (0 : 1 : 0), (0
126
: 1 : 1), (0 : 1 : 2), (0 : 1 : 3), (0 : 2 : -3), (0 : 2 : -1), (0 : 2 :
127
1), (0 : 2 : 3), (0 : 3 : -2), (0 : 3 : -1), (0 : 3 : 1), (0 : 3 : 2),
128
(1 : -3 : -3), (1 : -3 : -2), (1 : -3 : -1), (1 : -3 : 0), (1 : -3 : 1),
129
(1 : -3 : 2), (1 : -3 : 3), (1 : -2 : -3), (1 : -2 : -2), (1 : -2 : -1),
130
(1 : -2 : 0), (1 : -2 : 1), (1 : -2 : 2), (1 : -2 : 3), (1 : -1 : -3),
131
(1 : -1 : -2), (1 : -1 : -1), (1 : -1 : 0), (1 : -1 : 1), (1 : -1 : 2),
132
(1 : -1 : 3), (1 : 0 : -3), (1 : 0 : -2), (1 : 0 : -1), (1 : 0 : 0), (1
133
: 0 : 1), (1 : 0 : 2), (1 : 0 : 3), (1 : 1 : -3), (1 : 1 : -2), (1 : 1 :
134
-1), (1 : 1 : 0), (1 : 1 : 1), (1 : 1 : 2), (1 : 1 : 3), (1 : 2 : -3),
135
(1 : 2 : -2), (1 : 2 : -1), (1 : 2 : 0), (1 : 2 : 1), (1 : 2 : 2), (1 :
136
2 : 3), (1 : 3 : -3), (1 : 3 : -2), (1 : 3 : -1), (1 : 3 : 0), (1 : 3 :
137
1), (1 : 3 : 2), (1 : 3 : 3), (2 : -3 : -3), (2 : -3 : -2), (2 : -3 :
138
-1), (2 : -3 : 0), (2 : -3 : 1), (2 : -3 : 2), (2 : -3 : 3), (2 : -2 :
139
-3), (2 : -2 : -1), (2 : -2 : 1), (2 : -2 : 3), (2 : -1 : -3), (2 : -1 :
140
-2), (2 : -1 : -1), (2 : -1 : 0), (2 : -1 : 1), (2 : -1 : 2), (2 : -1 :
141
3), (2 : 0 : -3), (2 : 0 : -1), (2 : 0 : 1), (2 : 0 : 3), (2 : 1 : -3),
142
(2 : 1 : -2), (2 : 1 : -1), (2 : 1 : 0), (2 : 1 : 1), (2 : 1 : 2), (2 :
143
1 : 3), (2 : 2 : -3), (2 : 2 : -1), (2 : 2 : 1), (2 : 2 : 3), (2 : 3 :
144
-3), (2 : 3 : -2), (2 : 3 : -1), (2 : 3 : 0), (2 : 3 : 1), (2 : 3 : 2),
145
(2 : 3 : 3), (3 : -3 : -2), (3 : -3 : -1), (3 : -3 : 1), (3 : -3 : 2),
146
(3 : -2 : -3), (3 : -2 : -2), (3 : -2 : -1), (3 : -2 : 0), (3 : -2 : 1),
147
(3 : -2 : 2), (3 : -2 : 3), (3 : -1 : -3), (3 : -1 : -2), (3 : -1 : -1),
148
(3 : -1 : 0), (3 : -1 : 1), (3 : -1 : 2), (3 : -1 : 3), (3 : 0 : -2), (3
149
: 0 : -1), (3 : 0 : 1), (3 : 0 : 2), (3 : 1 : -3), (3 : 1 : -2), (3 : 1
150
: -1), (3 : 1 : 0), (3 : 1 : 1), (3 : 1 : 2), (3 : 1 : 3), (3 : 2 : -3),
151
(3 : 2 : -2), (3 : 2 : -1), (3 : 2 : 0), (3 : 2 : 1), (3 : 2 : 2), (3 :
152
2 : 3), (3 : 3 : -2), (3 : 3 : -1), (3 : 3 : 1), (3 : 3 : 2)]
153
"""
154
R = self.value_ring()
155
if R == ZZ:
156
if not B > 0:
157
raise TypeError, "A positive bound B (= %s) must be specified."%B
158
from sage.schemes.projective.projective_rational_point import enum_projective_rational_field
159
return enum_projective_rational_field(self,B)
160
else:
161
raise TypeError, "Unable to enumerate points over %s."%R
162
163
164
#*******************************************************************
165
# Abelian varieties
166
#*******************************************************************
167
class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_field):
168
r"""
169
Set of rational points of an abelian variety.
170
171
INPUT:
172
173
See :class:`SchemeHomset_generic`.
174
175
TESTS:
176
177
The bug reported at trac #1785 is fixed::
178
179
sage: K.<a> = NumberField(x^2 + x - (3^3-3))
180
sage: E = EllipticCurve('37a')
181
sage: X = E(K)
182
sage: X
183
Abelian group of points on Elliptic Curve defined by
184
y^2 + y = x^3 + (-1)*x over Number Field in a with
185
defining polynomial x^2 + x - 24
186
sage: P = X([3,a])
187
sage: P
188
(3 : a : 1)
189
sage: P in E
190
False
191
sage: P in E.base_extend(K)
192
True
193
sage: P in X.codomain()
194
False
195
sage: P in X.extended_codomain()
196
True
197
"""
198
199
def _element_constructor_(self, *v, **kwds):
200
"""
201
The element contstructor.
202
203
INPUT:
204
205
- ``v`` -- anything that determines a scheme morphism in the
206
Hom-set.
207
208
OUTPUT:
209
210
The scheme morphism determined by ``v``.
211
212
EXAMPLES::
213
214
sage: E = EllipticCurve('37a')
215
sage: X = E(QQ)
216
sage: P = X([0,1,0]); P
217
(0 : 1 : 0)
218
sage: type(P)
219
<class 'sage.schemes.elliptic_curves.ell_point.EllipticCurvePoint_number_field'>
220
221
TESTS::
222
223
sage: X._element_constructor_([0,1,0])
224
(0 : 1 : 0)
225
"""
226
if len(v) == 1:
227
v = v[0]
228
return self.codomain()._point(self.extended_codomain(), v, **kwds)
229
230
def _repr_(self):
231
"""
232
Return a string representation of ``self``.
233
234
OUTPUT:
235
236
String.
237
238
EXAMPLES::
239
240
sage: E = EllipticCurve('37a')
241
sage: X = E(QQ)
242
sage: X._repr_()
243
'Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field'
244
"""
245
s = 'Abelian group of points on ' + str(self.extended_codomain())
246
return s
247
248
def base_extend(self, R):
249
"""
250
Extend the base ring.
251
252
This is currently not implemented except for the trivial case
253
``R==ZZ``.
254
255
INPUT:
256
257
- ``R`` -- a ring.
258
259
EXAMPLES::
260
261
sage: E = EllipticCurve('37a')
262
sage: Hom = E.point_homset(); Hom
263
Abelian group of points on Elliptic Curve defined
264
by y^2 + y = x^3 - x over Rational Field
265
sage: Hom.base_ring()
266
Integer Ring
267
sage: Hom.base_extend(QQ)
268
Traceback (most recent call last):
269
...
270
NotImplementedError: Abelian variety point sets are not
271
implemented as modules over rings other than ZZ.
272
"""
273
if R is not ZZ:
274
raise NotImplementedError('Abelian variety point sets are not '
275
'implemented as modules over rings other than ZZ.')
276
return self
277
278
279
from sage.structure.sage_object import register_unpickle_override
280
register_unpickle_override('sage.schemes.generic.homset',
281
'SchemeHomsetModule_abelian_variety_coordinates_field',
282
SchemeHomset_points_abelian_variety_field)
283
284
285