Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/schemes/toric/homset.py
4108 views
1
r"""
2
Set of homomorphisms between two toric varieties.
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
- Volker Braun (2012-02-18): Initial version
22
23
EXAMPLES:
24
25
Here is a simple example, the projection of
26
`\mathbb{P}^1\times\mathbb{P}^1\to \mathbb{P}^1` ::
27
28
sage: P1xP1 = toric_varieties.P1xP1()
29
sage: P1 = toric_varieties.P1()
30
sage: hom_set = P1xP1.Hom(P1); hom_set
31
Set of morphisms
32
From: 2-d CPR-Fano toric variety covered by 4 affine patches
33
To: 1-d CPR-Fano toric variety covered by 2 affine patches
34
35
In terms of the fan, we can define this morphism by the projection
36
onto the first coordinate. The Hom-set can construct the morphism from
37
the projection matrix alone::
38
39
sage: hom_set(matrix([[1],[0]]))
40
Scheme morphism:
41
From: 2-d CPR-Fano toric variety covered by 4 affine patches
42
To: 1-d CPR-Fano toric variety covered by 2 affine patches
43
Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
44
to Rational polyhedral fan in 1-d lattice N.
45
sage: _.as_polynomial_map()
46
Scheme morphism:
47
From: 2-d CPR-Fano toric variety covered by 4 affine patches
48
To: 1-d CPR-Fano toric variety covered by 2 affine patches
49
Defn: Defined on coordinates by sending [s : t : x : y] to
50
[s : t]
51
52
In the case of toric algebraic schemes (defined by polynomials in
53
toric varieties), this module defines the underlying morphism of the
54
ambient toric varieties::
55
56
sage: P1xP1.inject_variables()
57
Defining s, t, x, y
58
sage: S = P1xP1.subscheme([s*x-t*y])
59
sage: type(S.Hom(S))
60
<class 'sage.schemes.toric.homset.SchemeHomset_toric_variety_with_category'>
61
"""
62
63
64
65
#*****************************************************************************
66
# Copyright (C) 2010 Volker Braun <[email protected]>
67
# Copyright (C) 2010 Andrey Novoseltsev <[email protected]>
68
#
69
# Distributed under the terms of the GNU General Public License (GPL)
70
# as published by the Free Software Foundation; either version 2 of
71
# the License, or (at your option) any later version.
72
# http://www.gnu.org/licenses/
73
#*****************************************************************************
74
75
76
from sage.rings.all import ZZ, is_RingHomomorphism
77
from sage.matrix.matrix import is_Matrix
78
from sage.matrix.matrix_space import MatrixSpace
79
from sage.geometry.fan_morphism import FanMorphism
80
81
from sage.schemes.generic.homset import (SchemeHomset_generic,
82
SchemeHomset_points)
83
84
85
class SchemeHomset_toric_variety(SchemeHomset_generic):
86
"""
87
Set of homomorphisms between two toric varieties.
88
89
EXAMPLES::
90
91
sage: P1xP1 = toric_varieties.P1xP1()
92
sage: P1 = toric_varieties.P1()
93
sage: hom_set = P1xP1.Hom(P1); hom_set
94
Set of morphisms
95
From: 2-d CPR-Fano toric variety covered by 4 affine patches
96
To: 1-d CPR-Fano toric variety covered by 2 affine patches
97
sage: type(hom_set)
98
<class 'sage.schemes.toric.homset.SchemeHomset_toric_variety_with_category'>
99
100
sage: hom_set(matrix([[1],[0]]))
101
Scheme morphism:
102
From: 2-d CPR-Fano toric variety covered by 4 affine patches
103
To: 1-d CPR-Fano toric variety covered by 2 affine patches
104
Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
105
to Rational polyhedral fan in 1-d lattice N.
106
"""
107
108
def __init__(self, X, Y, category=None, check=True, base=ZZ):
109
"""
110
The Python constructor.
111
112
INPUT:
113
114
The same as for any homset, see
115
:mod:`~sage.categories.homset`.
116
117
EXAMPLES::
118
119
sage: P1xP1 = toric_varieties.P1xP1()
120
sage: P1 = toric_varieties.P1()
121
sage: hom_set = P1xP1.Hom(P1); hom_set
122
Set of morphisms
123
From: 2-d CPR-Fano toric variety covered by 4 affine patches
124
To: 1-d CPR-Fano toric variety covered by 2 affine patches
125
126
An integral matrix defines a fan morphism, since we think of
127
the matrix as a linear map on the toric lattice. This is why
128
we need to ``register_conversion`` in the constructor
129
below. The result is::
130
131
sage: hom_set(matrix([[1],[0]]))
132
Scheme morphism:
133
From: 2-d CPR-Fano toric variety covered by 4 affine patches
134
To: 1-d CPR-Fano toric variety covered by 2 affine patches
135
Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
136
to Rational polyhedral fan in 1-d lattice N.
137
"""
138
SchemeHomset_generic.__init__(self, X, Y, category=category, check=check, base=base)
139
self.register_conversion(MatrixSpace(ZZ, X.fan().dim(), Y.fan().dim()))
140
141
def _element_constructor_(self, x, check=True):
142
"""
143
Construct a scheme morphism.
144
145
INPUT:
146
147
- `x` -- anything that defines a morphism of toric
148
varieties. A matrix, fan morphism, or a list or tuple of
149
homogeneous polynomials that define a morphism.
150
151
- ``check`` -- boolean (default: ``True``) passed onto
152
functions called by this to be more careful about input
153
argument type checking
154
155
OUTPUT:
156
157
The morphism of toric varieties determined by ``x``.
158
159
EXAMPLES:
160
161
First, construct from fan morphism::
162
163
sage: dP8.<t,x0,x1,x2> = toric_varieties.dP8()
164
sage: P2.<y0,y1,y2> = toric_varieties.P2()
165
sage: hom_set = dP8.Hom(P2)
166
167
sage: fm = FanMorphism(identity_matrix(2), dP8.fan(), P2.fan())
168
sage: hom_set(fm) # calls hom_set._element_constructor_()
169
Scheme morphism:
170
From: 2-d CPR-Fano toric variety covered by 4 affine patches
171
To: 2-d CPR-Fano toric variety covered by 3 affine patches
172
Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
173
to Rational polyhedral fan in 2-d lattice N.
174
175
A matrix will automatically be converted to a fan morphism::
176
177
sage: hom_set(identity_matrix(2))
178
Scheme morphism:
179
From: 2-d CPR-Fano toric variety covered by 4 affine patches
180
To: 2-d CPR-Fano toric variety covered by 3 affine patches
181
Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
182
to Rational polyhedral fan in 2-d lattice N.
183
184
Alternatively, one can use homogeneous polynomials to define morphisms::
185
186
sage: P2.inject_variables()
187
Defining y0, y1, y2
188
sage: dP8.inject_variables()
189
Defining t, x0, x1, x2
190
sage: hom_set([x0,x1,x2])
191
Scheme morphism:
192
From: 2-d CPR-Fano toric variety covered by 4 affine patches
193
To: 2-d CPR-Fano toric variety covered by 3 affine patches
194
Defn: Defined on coordinates by sending [t : x0 : x1 : x2] to
195
[x0 : x1 : x2]
196
197
A morphism of the coordinate ring will also work::
198
199
sage: ring_hom = P2.coordinate_ring().hom([x0,x1,x2], dP8.coordinate_ring())
200
sage: ring_hom
201
Ring morphism:
202
From: Multivariate Polynomial Ring in y0, y1, y2 over Rational Field
203
To: Multivariate Polynomial Ring in t, x0, x1, x2 over Rational Field
204
Defn: y0 |--> x0
205
y1 |--> x1
206
y2 |--> x2
207
sage: hom_set(ring_hom)
208
Scheme morphism:
209
From: 2-d CPR-Fano toric variety covered by 4 affine patches
210
To: 2-d CPR-Fano toric variety covered by 3 affine patches
211
Defn: Defined on coordinates by sending [t : x0 : x1 : x2] to
212
[x0 : x1 : x2]
213
"""
214
from sage.schemes.toric.morphism import SchemeMorphism_polynomial_toric_variety
215
if isinstance(x, (list, tuple)):
216
return SchemeMorphism_polynomial_toric_variety(self, x, check=check)
217
218
if is_RingHomomorphism(x):
219
assert x.domain() is self.codomain().coordinate_ring()
220
assert x.codomain() is self.domain().coordinate_ring()
221
return SchemeMorphism_polynomial_toric_variety(self, x.im_gens(), check=check)
222
223
from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety
224
if isinstance(x, FanMorphism):
225
return SchemeMorphism_fan_toric_variety(self, x, check=check)
226
227
if is_Matrix(x):
228
fm = FanMorphism(x, self.domain().fan(), self.codomain().fan())
229
return SchemeMorphism_fan_toric_variety(self, fm, check=check)
230
231
raise TypeError, "x must be a fan morphism or a list/tuple of polynomials"
232
233
234
class SchemeHomset_points_toric_field(SchemeHomset_points):
235
"""
236
Set of rational points of a toric variety.
237
238
INPUT:
239
240
- same as for :class:`SchemeHomset_points`.
241
242
OUPUT:
243
244
A scheme morphism of type
245
:class:`SchemeHomset_points_toric_field`.
246
247
EXAMPLES::
248
249
sage: P1xP1 = toric_varieties.P1xP1()
250
sage: P1xP1(QQ)
251
Set of rational points of 2-d CPR-Fano toric variety
252
covered by 4 affine patches
253
254
TESTS::
255
256
sage: import sage.schemes.toric.homset as HOM
257
sage: HOM.SchemeHomset_points_toric_field(Spec(QQ), P1xP1)
258
Set of rational points of 2-d CPR-Fano toric variety covered by 4 affine patches
259
"""
260
pass
261
262