Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/schemes/generic/homset.py
4079 views
1
r"""
2
Set of homomorphisms between two 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
26
27
#*****************************************************************************
28
# Copyright (C) 2011 Volker Braun <[email protected]>
29
# Copyright (C) 2006 William Stein <[email protected]>
30
#
31
# Distributed under the terms of the GNU General Public License (GPL)
32
# as published by the Free Software Foundation; either version 2 of
33
# the License, or (at your option) any later version.
34
# http://www.gnu.org/licenses/
35
#*****************************************************************************
36
37
38
from sage.categories.homset import HomsetWithBase
39
from sage.structure.factory import UniqueFactory
40
41
from sage.rings.all import ( gcd, ZZ, QQ,
42
is_CommutativeRing, is_RingHomomorphism, is_RationalField, is_FiniteField )
43
44
from sage.schemes.generic.scheme import is_Scheme
45
from sage.schemes.generic.spec import Spec, is_Spec
46
from sage.schemes.generic.morphism import (
47
SchemeMorphism,
48
SchemeMorphism_structure_map, SchemeMorphism_spec,
49
SchemeMorphism_point_affine,
50
SchemeMorphism_point_projective_ring,
51
SchemeMorphism_point_projective_field )
52
53
54
def is_SchemeHomset(H):
55
r"""
56
Test whether ``H`` is a scheme Hom-set.
57
58
EXAMPLES::
59
60
sage: f = Spec(QQ).identity_morphism(); f
61
Scheme endomorphism of Spectrum of Rational Field
62
Defn: Identity map
63
sage: from sage.schemes.generic.homset import is_SchemeHomset
64
sage: is_SchemeHomset(f)
65
False
66
sage: is_SchemeHomset(f.parent())
67
True
68
sage: is_SchemeHomset('a string')
69
False
70
"""
71
return isinstance(H, SchemeHomset_generic)
72
73
74
#*******************************************************************
75
# Factory for Hom sets of schemes
76
#*******************************************************************
77
class SchemeHomsetFactory(UniqueFactory):
78
"""
79
Factory for Hom-sets of schemes.
80
81
EXAMPLES::
82
83
sage: A2 = AffineSpace(QQ,2)
84
sage: A3 = AffineSpace(QQ,3)
85
sage: Hom = A3.Hom(A2)
86
87
The Hom-sets are unique::
88
89
sage: Hom is copy(Hom)
90
True
91
sage: Hom is A3.Hom(A2)
92
True
93
sage: loads(Hom.dumps()) is Hom
94
True
95
96
Here is a tricky point. The Hom-sets are not identical if
97
domains/codomains are isomorphic but not identiacal::
98
99
sage: A3_iso = AffineSpace(QQ,3)
100
sage: [ A3_iso is A3, A3_iso == A3 ]
101
[False, True]
102
sage: Hom_iso = A3_iso.Hom(A2)
103
sage: Hom_iso is Hom
104
False
105
sage: Hom_iso == Hom
106
True
107
108
TESTS::
109
110
sage: Hom.base()
111
Integer Ring
112
sage: Hom.base_ring()
113
Integer Ring
114
"""
115
116
def create_key_and_extra_args(self, X, Y, category=None, base=ZZ,
117
check=True):
118
"""
119
Create a key that uniquely determines the Hom-set.
120
121
INPUT:
122
123
- ``X`` -- a scheme. The domain of the morphisms.
124
125
- ``Y`` -- a scheme. The codomain of the morphisms.
126
127
- ``category`` -- a category for the Hom-sets (default: schemes over
128
given base).
129
130
- ``base`` -- a scheme or a ring. The base scheme of domain
131
and codomain schemes. If a ring is specified, the spectrum
132
of that ring will be used as base scheme.
133
134
- ``check`` -- boolean (default: ``True``).
135
136
EXAMPLES::
137
138
sage: A2 = AffineSpace(QQ,2)
139
sage: A3 = AffineSpace(QQ,3)
140
sage: A3.Hom(A2) # indirect doctest
141
Set of morphisms
142
From: Affine Space of dimension 3 over Rational Field
143
To: Affine Space of dimension 2 over Rational Field
144
sage: from sage.schemes.generic.homset import SchemeHomsetFactory
145
sage: SHOMfactory = SchemeHomsetFactory('test')
146
sage: key, extra = SHOMfactory.create_key_and_extra_args(A3,A2,check=False)
147
sage: key
148
(..., ..., Category of schemes over Integer Ring)
149
sage: extra
150
{'Y': Affine Space of dimension 2 over Rational Field,
151
'X': Affine Space of dimension 3 over Rational Field,
152
'base_ring': Integer Ring, 'check': False}
153
"""
154
if not is_Scheme(X) and is_CommutativeRing(X):
155
X = Spec(X)
156
if not is_Scheme(Y) and is_CommutativeRing(Y):
157
Y = Spec(Y)
158
if is_Spec(base):
159
base_spec = base
160
base_ring = base.coordinate_ring()
161
elif is_CommutativeRing(base):
162
base_spec = Spec(base)
163
base_ring = base
164
else:
165
raise ValueError(
166
'The base must be a commutative ring or its spectrum.')
167
if not category:
168
from sage.categories.schemes import Schemes
169
category = Schemes(base_spec)
170
key = tuple([id(X), id(Y), category])
171
extra = {'X':X, 'Y':Y, 'base_ring':base_ring, 'check':check}
172
return key, extra
173
174
def create_object(self, version, key, **extra_args):
175
"""
176
Create a :class:`SchemeHomset_generic`.
177
178
INPUT:
179
180
- ``version`` -- object version. Currently not used.
181
182
- ``key`` -- a key created by :meth:`create_key_and_extra_args`.
183
184
- ``extra_args`` -- a dictionary of extra keyword arguments.
185
186
EXAMPLES::
187
188
sage: A2 = AffineSpace(QQ,2)
189
sage: A3 = AffineSpace(QQ,3)
190
sage: A3.Hom(A2) is A3.Hom(A2) # indirect doctest
191
True
192
sage: from sage.schemes.generic.homset import SchemeHomsetFactory
193
sage: SHOMfactory = SchemeHomsetFactory('test')
194
sage: SHOMfactory.create_object(0, [id(A3),id(A2),A3.category()], check=True,
195
... X=A3, Y=A2, base_ring=QQ)
196
Set of morphisms
197
From: Affine Space of dimension 3 over Rational Field
198
To: Affine Space of dimension 2 over Rational Field
199
"""
200
category = key[2]
201
X = extra_args.pop('X')
202
Y = extra_args.pop('Y')
203
base_ring = extra_args.pop('base_ring')
204
if is_Spec(X):
205
return Y._point_homset(X, Y, category=category, base=base_ring, **extra_args)
206
try:
207
return X._homset(X, Y, category=category, base=base_ring, **extra_args)
208
except AttributeError:
209
return SchemeHomset_generic(X, Y, category=category, base=base_ring, **extra_args)
210
211
212
SchemeHomset = SchemeHomsetFactory('sage.schemes.generic.homset.SchemeHomset')
213
214
215
216
#*******************************************************************
217
# Base class
218
#*******************************************************************
219
class SchemeHomset_generic(HomsetWithBase):
220
r"""
221
The base class for Hom-sets of schemes.
222
223
INPUT:
224
225
- ``X`` -- a scheme. The domain of the Hom-set.
226
227
- ``Y`` -- a scheme. The codomain of the Hom-set.
228
229
- ``category`` -- a category (optional). The category of the
230
Hom-set.
231
232
- ``check`` -- boolean (optional, default=``True``). Whether to
233
check the defining data for consistency.
234
235
EXAMPLES::
236
237
sage: from sage.schemes.generic.homset import SchemeHomset_generic
238
sage: A2 = AffineSpace(QQ,2)
239
sage: Hom = SchemeHomset_generic(A2, A2); Hom
240
Set of morphisms
241
From: Affine Space of dimension 2 over Rational Field
242
To: Affine Space of dimension 2 over Rational Field
243
sage: Hom.category()
244
Category of hom sets in Category of Schemes
245
"""
246
Element = SchemeMorphism
247
248
def __call__(self, *args, **kwds):
249
r"""
250
Make Hom-sets callable.
251
252
See the ``_call_()`` method of the derived class. All
253
arguments are handed through.
254
255
EXAMPLES::
256
257
sage: A2 = AffineSpace(QQ,2)
258
sage: A2(4,5)
259
(4, 5)
260
"""
261
# Homset (base of HomsetWithBase) overrides __call__ @#$
262
from sage.structure.parent import Set_generic
263
return Set_generic.__call__(self, *args, **kwds)
264
265
def _repr_(self):
266
r"""
267
Return a string representation.
268
269
OUTPUT:
270
271
A string.
272
273
EXAMPLES::
274
275
sage: A = AffineSpace(4, QQ)
276
sage: print A.structure_morphism()._repr_()
277
Scheme morphism:
278
From: Affine Space of dimension 4 over Rational Field
279
To: Spectrum of Rational Field
280
Defn: Structure map
281
"""
282
s = 'Set of morphisms'
283
s += '\n From: %s' % self.domain()
284
s += '\n To: %s' % self.codomain()
285
return s
286
287
def natural_map(self):
288
r"""
289
Return a natural map in the Hom space.
290
291
OUTPUT:
292
293
A :class:`SchemeMorphism` if there is a natural map from
294
domain to codomain. Otherwise, a ``NotImplementedError`` is
295
raised.
296
297
EXAMPLES::
298
299
sage: A = AffineSpace(4, QQ)
300
sage: A.structure_morphism() # indirect doctest
301
Scheme morphism:
302
From: Affine Space of dimension 4 over Rational Field
303
To: Spectrum of Rational Field
304
Defn: Structure map
305
"""
306
X = self.domain()
307
Y = self.codomain()
308
if is_Spec(Y) and Y.coordinate_ring() == X.base_ring():
309
return SchemeMorphism_structure_map(self)
310
raise NotImplementedError
311
312
def _element_constructor_(self, x, check=True):
313
"""
314
Construct a scheme morphism.
315
316
INPUT:
317
318
- `x` -- a ring morphism, or a list or a tuple that define a
319
ring morphism.
320
321
- ``check`` -- boolean (default: ``True``) passed onto
322
functions called by this one to be more careful about input
323
argument type checking.
324
325
EXAMPLES::
326
327
sage: f = ZZ.hom(QQ); f
328
Ring Coercion morphism:
329
From: Integer Ring
330
To: Rational Field
331
332
sage: H = Hom(Spec(QQ, ZZ), Spec(ZZ)); H
333
Set of rational points of Spectrum of Integer Ring
334
335
sage: phi = H(f); phi
336
Affine Scheme morphism:
337
From: Spectrum of Rational Field
338
To: Spectrum of Integer Ring
339
Defn: Ring Coercion morphism:
340
From: Integer Ring
341
To: Rational Field
342
343
TESTS:
344
345
sage: H._element_constructor_(f)
346
Affine Scheme morphism:
347
From: Spectrum of Rational Field
348
To: Spectrum of Integer Ring
349
Defn: Ring Coercion morphism:
350
From: Integer Ring
351
To: Rational Field
352
353
We illustrate input type checking::
354
355
sage: R.<x,y> = QQ[]
356
sage: A.<x,y> = AffineSpace(R)
357
sage: C = A.subscheme(x*y-1)
358
sage: H = C.Hom(C); H
359
Set of morphisms
360
From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
361
x*y - 1
362
To: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
363
x*y - 1
364
sage: H(1)
365
Traceback (most recent call last):
366
...
367
TypeError: x must be a ring homomorphism, list or tuple
368
"""
369
if isinstance(x, (list, tuple)):
370
return self.domain()._morphism(self, x, check=check)
371
372
if is_RingHomomorphism(x):
373
return SchemeMorphism_spec(self, x, check=check)
374
375
raise TypeError, "x must be a ring homomorphism, list or tuple"
376
377
378
#*******************************************************************
379
# Base class for points
380
#*******************************************************************
381
class SchemeHomset_points(SchemeHomset_generic):
382
"""
383
Set of rational points of the scheme.
384
385
Recall that the `K`-rational points of a scheme `X` over `k` can
386
be identified with the set of morphisms `Spec(K) \to X`. In Sage,
387
the rational points are implemented by such scheme morphisms.
388
389
INPUT:
390
391
See :class:`SchemeHomset_generic`.
392
393
EXAMPLES::
394
395
sage: from sage.schemes.generic.homset import SchemeHomset_points
396
sage: SchemeHomset_points(Spec(QQ), AffineSpace(ZZ,2))
397
Set of rational points of Affine Space of dimension 2 over Rational Field
398
"""
399
400
def __init__(self, X, Y, category=None, check=True, base=ZZ):
401
"""
402
Python constructor.
403
404
INPUT:
405
406
See :class:`SchemeHomset_generic`.
407
408
EXAMPLES::
409
410
sage: from sage.schemes.generic.homset import SchemeHomset_points
411
sage: SchemeHomset_points(Spec(QQ), AffineSpace(ZZ,2))
412
Set of rational points of Affine Space of dimension 2 over Rational Field
413
"""
414
if check and not is_Spec(X):
415
raise ValueError('The domain must be an affine scheme.')
416
SchemeHomset_generic.__init__(self, X, Y, category=category, check=check, base=base)
417
418
def _element_constructor_(self, *v, **kwds):
419
"""
420
The element contstructor.
421
422
INPUT:
423
424
- ``v`` -- anything that determines a scheme morphism in the
425
Hom-set.
426
427
OUTPUT:
428
429
The scheme morphism determined by ``v``.
430
431
EXAMPLES::
432
433
sage: A2 = AffineSpace(ZZ,2)
434
sage: F = GF(3)
435
sage: F_points = A2(F); type(F_points)
436
<class 'sage.schemes.generic.homset.SchemeHomset_points_affine_with_category'>
437
sage: F_points([2,5])
438
(2, 2)
439
440
sage: P2 = ProjectiveSpace(GF(3),2)
441
sage: F.<a> = GF(9,'a')
442
sage: F_points = P2(F)
443
sage: type(F_points)
444
<class 'sage.schemes.generic.homset.SchemeHomset_points_projective_field_with_category'>
445
sage: F_points([4,2*a])
446
(1 : 2*a : 1)
447
448
TESTS::
449
450
sage: F_points._element_constructor_([4,2*a])
451
(1 : 2*a : 1)
452
"""
453
if len(v) == 1:
454
v = v[0]
455
return self.codomain()._point(self, v, **kwds)
456
457
def extended_codomain(self):
458
"""
459
Return the codomain with extended base, if necessary.
460
461
OUTPUT:
462
463
The codomain scheme, with its base ring extended to the
464
codomain. That is, the codomain is of the form `Spec(R)` and
465
the base ring of the domain is extended to `R`.
466
467
EXAMPLES::
468
469
sage: P2 = ProjectiveSpace(QQ,2)
470
sage: K.<a> = NumberField(x^2 + x - (3^3-3))
471
sage: K_points = P2(K); K_points
472
Set of rational points of Projective Space of dimension 2
473
over Number Field in a with defining polynomial x^2 + x - 24
474
475
sage: K_points.codomain()
476
Projective Space of dimension 2 over Rational Field
477
478
sage: K_points.extended_codomain()
479
Projective Space of dimension 2 over Number Field in a with
480
defining polynomial x^2 + x - 24
481
"""
482
if '_extended_codomain' in self.__dict__:
483
return self._extended_codomain
484
R = self.domain().coordinate_ring()
485
if R is not self.codomain().base_ring():
486
X = self.codomain().base_extend(R)
487
else:
488
X = self.codomain()
489
self._extended_codomain = X
490
return X
491
492
def _repr_(self):
493
"""
494
Return a string representation of ``self``.
495
496
OUTPUT:
497
498
A string.
499
500
EXAMPLES::
501
502
sage: P2 = ProjectiveSpace(ZZ,2)
503
sage: P2(QQ)._repr_()
504
'Set of rational points of Projective Space of dimension 2 over Rational Field'
505
"""
506
return 'Set of rational points of '+str(self.extended_codomain())
507
508
def value_ring(self):
509
"""
510
Return `R` for a point Hom-set `X(Spec(R))`.
511
512
OUTPUT:
513
514
A commutative ring.
515
516
EXAMPLES::
517
518
sage: P2 = ProjectiveSpace(ZZ,2)
519
sage: P2(QQ).value_ring()
520
Rational Field
521
"""
522
dom = self.domain()
523
if not is_Spec(dom):
524
raise ValueError("value rings are defined for Spec domains only!")
525
return dom.coordinate_ring()
526
527
528
#*******************************************************************
529
# Affine varieties
530
#*******************************************************************
531
class SchemeHomset_points_spec(SchemeHomset_generic):
532
"""
533
Set of rational points of an affine variety.
534
535
INPUT:
536
537
See :class:`SchemeHomset_generic`.
538
539
EXAMPLES::
540
541
sage: from sage.schemes.generic.homset import SchemeHomset_points_spec
542
sage: SchemeHomset_points_spec(Spec(QQ), Spec(QQ))
543
Set of rational points of Spectrum of Rational Field
544
"""
545
546
def _element_constructor_(self, *args, **kwds):
547
"""
548
The element contstructor.
549
550
EXAMPLES::
551
552
sage: X = Spec(QQ)
553
sage: ring_hom = QQ.hom((1,), QQ); ring_hom
554
Ring endomorphism of Rational Field
555
Defn: 1 |--> 1
556
sage: Hom = X.Hom(X)
557
sage: Hom(ring_hom)
558
Affine Scheme endomorphism of Spectrum of Rational Field
559
Defn: Ring endomorphism of Rational Field
560
Defn: 1 |--> 1
561
562
TESTS::
563
564
sage: Hom._element_constructor_(ring_hom)
565
Affine Scheme endomorphism of Spectrum of Rational Field
566
Defn: Ring endomorphism of Rational Field
567
Defn: 1 |--> 1
568
"""
569
return SchemeHomset_generic._element_constructor_(self, *args, **kwds)
570
571
def _repr_(self):
572
"""
573
Return a string representation of ``self``.
574
575
OUTPUT:
576
577
A string.
578
579
EXAMPLES::
580
581
sage: from sage.schemes.generic.homset import SchemeHomset_points_spec
582
sage: S = SchemeHomset_points_spec(Spec(QQ), Spec(QQ))
583
sage: S._repr_()
584
'Set of rational points of Spectrum of Rational Field'
585
"""
586
return 'Set of rational points of '+str(self.codomain())
587
588
589
590
#*******************************************************************
591
# Affine varieties
592
#*******************************************************************
593
class SchemeHomset_points_affine(SchemeHomset_points):
594
"""
595
Set of rational points of an affine variety.
596
597
INPUT:
598
599
See :class:`SchemeHomset_generic`.
600
601
EXAMPLES::
602
603
sage: from sage.schemes.generic.homset import SchemeHomset_points_affine
604
sage: SchemeHomset_points_affine(Spec(QQ), AffineSpace(ZZ,2))
605
Set of rational points of Affine Space of dimension 2 over Rational Field
606
"""
607
608
def points(self, B=0):
609
r"""
610
Return some or all rational points of an affine scheme.
611
612
INPUT:
613
614
- ``B`` -- integer (optional, default: 0). The bound for the
615
height of the coordinates.
616
617
OUTPUT:
618
619
- If the base ring is a finite field: all points of the scheme,
620
given by coordinate tuples.
621
622
- If the base ring is `\QQ` or `\ZZ`: the subset of points whose
623
coordinates have height ``B`` or less.
624
625
EXAMPLES: The bug reported at #11526 is fixed::
626
627
sage: A2 = AffineSpace(ZZ,2)
628
sage: F = GF(3)
629
sage: A2(F).points()
630
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
631
632
sage: R = ZZ
633
sage: A.<x,y> = R[]
634
sage: I = A.ideal(x^2-y^2-1)
635
sage: V = AffineSpace(R,2)
636
sage: X = V.subscheme(I)
637
sage: M = X(R)
638
sage: M.points(1)
639
[(-1, 0), (1, 0)]
640
"""
641
R = self.value_ring()
642
if is_RationalField(R) or R == ZZ:
643
if not B > 0:
644
raise TypeError, "A positive bound B (= %s) must be specified."%B
645
from sage.schemes.generic.rational_point import enum_affine_rational_field
646
return enum_affine_rational_field(self,B)
647
elif is_FiniteField(R):
648
from sage.schemes.generic.rational_point import enum_affine_finite_field
649
return enum_affine_finite_field(self)
650
else:
651
raise TypeError, "Unable to enumerate points over %s."%R
652
653
654
#*******************************************************************
655
# Projective varieties
656
#*******************************************************************
657
class SchemeHomset_points_projective_field(SchemeHomset_points):
658
"""
659
Set of rational points of a projective variety over a field.
660
661
INPUT:
662
663
See :class:`SchemeHomset_generic`.
664
665
EXAMPLES::
666
667
sage: from sage.schemes.generic.homset import SchemeHomset_points_projective_field
668
sage: SchemeHomset_points_projective_field(Spec(QQ), ProjectiveSpace(QQ,2))
669
Set of rational points of Projective Space of dimension 2 over Rational Field
670
"""
671
def points(self, B=0):
672
"""
673
Return some or all rational points of a projective scheme.
674
675
INPUT:
676
677
- `B` -- integer (optional, default=0). The bound for the
678
coordinates.
679
680
OUTPUT:
681
682
A list of points. Over a finite field, all points are
683
returned. Over an infinite field, all points satisfying the
684
bound are returned.
685
686
EXAMPLES::
687
688
sage: P1 = ProjectiveSpace(GF(2),1)
689
sage: F.<a> = GF(4,'a')
690
sage: P1(F).points()
691
[(0 : 1), (1 : 0), (1 : 1), (a : 1), (a + 1 : 1)]
692
"""
693
from sage.schemes.generic.rational_point import enum_projective_rational_field
694
from sage.schemes.generic.rational_point import enum_projective_finite_field
695
R = self.value_ring()
696
if is_RationalField(R):
697
if not B > 0:
698
raise TypeError, "A positive bound B (= %s) must be specified."%B
699
return enum_projective_rational_field(self,B)
700
elif is_FiniteField(R):
701
return enum_projective_finite_field(self.extended_codomain())
702
else:
703
raise TypeError, "Unable to enumerate points over %s."%R
704
705
class SchemeHomset_points_projective_ring(SchemeHomset_points):
706
"""
707
Set of rational points of a projective variety over a commutative ring.
708
709
INPUT:
710
711
See :class:`SchemeHomset_generic`.
712
713
EXAMPLES::
714
715
sage: from sage.schemes.generic.homset import SchemeHomset_points_projective_ring
716
sage: SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))
717
Set of rational points of Projective Space of dimension 2 over Integer Ring
718
"""
719
def _element_constructor_(self, *v, **kwds):
720
r"""
721
The element constructor.
722
723
This is currently not implemented.
724
725
EXAMPLES::
726
727
sage: from sage.schemes.generic.homset import SchemeHomset_points_projective_ring
728
sage: Hom = SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))
729
sage: Hom(1,2,3)
730
Traceback (most recent call last):
731
...
732
NotImplementedError
733
734
TESTS::
735
736
sage: Hom._element_constructor_(1,2,3)
737
Traceback (most recent call last):
738
...
739
NotImplementedError
740
"""
741
check = kwds.get('check', True)
742
raise NotImplementedError
743
744
def points(self, B=0):
745
"""
746
Return some or all rational points of a projective scheme.
747
748
INPUT:
749
750
- `B` -- integer (optional, default=0). The bound for the
751
coordinates.
752
753
OUTPUT:
754
755
This is currently not implemented and will raise ``NotImplementedError``.
756
757
EXAMPLES::
758
759
sage: from sage.schemes.generic.homset import SchemeHomset_points_projective_ring
760
sage: Hom = SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))
761
sage: Hom.points(5)
762
Traceback (most recent call last):
763
...
764
NotImplementedError
765
"""
766
raise NotImplementedError # fixed when _element_constructor_ is defined.
767
R = self.value_ring()
768
if R == ZZ:
769
if not B > 0:
770
raise TypeError, "A positive bound B (= %s) must be specified."%B
771
from sage.schemes.generic.rational_points import enum_projective_rational_field
772
return enum_projective_rational_field(self,B)
773
else:
774
raise TypeError, "Unable to enumerate points over %s."%R
775
776
777
#*******************************************************************
778
# Abelian varieties
779
#*******************************************************************
780
class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_field):
781
r"""
782
Set of rational points of an abelian variety.
783
784
INPUT:
785
786
See :class:`SchemeHomset_generic`.
787
788
TESTS:
789
790
The bug reported at trac #1785 is fixed::
791
792
sage: K.<a> = NumberField(x^2 + x - (3^3-3))
793
sage: E = EllipticCurve('37a')
794
sage: X = E(K)
795
sage: X
796
Abelian group of points on Elliptic Curve defined by
797
y^2 + y = x^3 + (-1)*x over Number Field in a with
798
defining polynomial x^2 + x - 24
799
sage: P = X([3,a])
800
sage: P
801
(3 : a : 1)
802
sage: P in E
803
False
804
sage: P in E.base_extend(K)
805
True
806
sage: P in X.codomain()
807
False
808
sage: P in X.extended_codomain()
809
True
810
"""
811
812
def _element_constructor_(self, *v, **kwds):
813
"""
814
The element contstructor.
815
816
INPUT:
817
818
- ``v`` -- anything that determines a scheme morphism in the
819
Hom-set.
820
821
OUTPUT:
822
823
The scheme morphism determined by ``v``.
824
825
EXAMPLES::
826
827
sage: E = EllipticCurve('37a')
828
sage: X = E(QQ)
829
sage: P = X([0,1,0]); P
830
(0 : 1 : 0)
831
sage: type(P)
832
<class 'sage.schemes.elliptic_curves.ell_point.EllipticCurvePoint_number_field'>
833
834
TESTS::
835
836
sage: X._element_constructor_([0,1,0])
837
(0 : 1 : 0)
838
"""
839
if len(v) == 1:
840
v = v[0]
841
return self.codomain()._point(self.extended_codomain(), v, **kwds)
842
843
def _repr_(self):
844
"""
845
Return a string representation of ``self``.
846
847
OUTPUT:
848
849
String.
850
851
EXAMPLES::
852
853
sage: E = EllipticCurve('37a')
854
sage: X = E(QQ)
855
sage: X._repr_()
856
'Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field'
857
"""
858
s = 'Abelian group of points on ' + str(self.extended_codomain())
859
return s
860
861
def base_extend(self, R):
862
"""
863
Extend the base ring.
864
865
This is currently not implemented except for the trivial case
866
``R==ZZ``.
867
868
INPUT:
869
870
- ``R`` -- a ring.
871
872
EXAMPLES::
873
874
sage: E = EllipticCurve('37a')
875
sage: Hom = E.point_homset(); Hom
876
Abelian group of points on Elliptic Curve defined
877
by y^2 + y = x^3 - x over Rational Field
878
sage: Hom.base_ring()
879
Integer Ring
880
sage: Hom.base_extend(QQ)
881
Traceback (most recent call last):
882
...
883
NotImplementedError: Abelian variety point sets are not
884
implemented as modules over rings other than ZZ.
885
"""
886
if R is not ZZ:
887
raise NotImplementedError('Abelian variety point sets are not '
888
'implemented as modules over rings other than ZZ.')
889
return self
890
891
892
from sage.structure.sage_object import register_unpickle_override
893
register_unpickle_override('sage.schemes.generic.homset',
894
'SchemeHomsetModule_abelian_variety_coordinates_field',
895
SchemeHomset_points_abelian_variety_field)
896
897
898