Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/rings/function_field/maps.py
4045 views
1
r"""
2
Function Field Morphisms
3
4
AUTHORS:
5
6
- William Stein (2010): initial version
7
8
- Julian Rueth (2011-09-14): refactored class hierarchy
9
10
EXAMPLES::
11
12
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
13
sage: K.hom(1/x)
14
Morphism of function fields defined by x |--> 1/x
15
sage: L.<y> = K.extension(y^2-x)
16
sage: K.hom(y)
17
Morphism of function fields defined by x |--> y
18
sage: L.hom([y,x])
19
Morphism of function fields defined by y |--> y, x |--> x
20
sage: L.hom([x,y])
21
Traceback (most recent call last):
22
...
23
ValueError: invalid morphism
24
"""
25
#*****************************************************************************
26
# Copyright (C) 2010 William Stein <[email protected]>
27
# Copyright (C) 2011 Julian Rueth <[email protected]>
28
#
29
# Distributed under the terms of the GNU General Public License (GPL)
30
# as published by the Free Software Foundation; either version 2 of
31
# the License, or (at your option) any later version.
32
# http://www.gnu.org/licenses/
33
#*****************************************************************************
34
35
from sage.categories.morphism import Morphism
36
from sage.rings.morphism import RingHomomorphism
37
38
class FunctionFieldIsomorphism(Morphism):
39
r"""
40
A base class for isomorphisms between function fields and
41
vector spaces.
42
43
EXAMPLES::
44
45
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
46
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
47
sage: V, f, t = L.vector_space()
48
sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldIsomorphism)
49
True
50
"""
51
def _repr_type(self):
52
"""
53
Return the type of this map (an isomorphism), for the purposes of printing out self.
54
55
EXAMPLES::
56
57
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
58
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
59
sage: V, f, t = L.vector_space()
60
sage: f._repr_type()
61
'Isomorphism'
62
"""
63
return "Isomorphism"
64
65
def is_injective(self):
66
"""
67
Return True, since this isomorphism is injective.
68
69
EXAMPLES::
70
71
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
72
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
73
sage: V, f, t = L.vector_space()
74
sage: f.is_injective()
75
True
76
"""
77
return True
78
79
def is_surjective(self):
80
"""
81
Return True, since this isomorphism is surjective.
82
83
EXAMPLES::
84
85
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
86
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
87
sage: V, f, t = L.vector_space()
88
sage: f.is_surjective()
89
True
90
"""
91
return True
92
93
class MapVectorSpaceToFunctionField(FunctionFieldIsomorphism):
94
r"""
95
An isomorphism from a vector space to a function field.
96
97
EXAMPLES::
98
99
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
100
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
101
sage: V, f, t = L.vector_space(); f
102
Isomorphism morphism:
103
From: Vector space of dimension 2 over Rational function field in x over Rational Field
104
To: Function field in y defined by y^2 - x*y + 4*x^3
105
"""
106
def __init__(self, V, K):
107
"""
108
EXAMPLES::
109
110
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
111
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
112
sage: V, f, t = L.vector_space(); type(f)
113
<class 'sage.rings.function_field.maps.MapVectorSpaceToFunctionField'>
114
"""
115
self._V = V
116
self._K = K
117
self._R = K.polynomial_ring()
118
from sage.categories.homset import Hom
119
FunctionFieldIsomorphism.__init__(self, Hom(V, K))
120
121
def _call_(self, v):
122
"""
123
EXAMPLES::
124
125
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
126
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
127
sage: V, f, t = L.vector_space()
128
sage: f(x*V.0 + (1/x^3)*V.1) # indirect doctest
129
1/x^3*y + x
130
"""
131
f = self._R(self._V(v).list())
132
return self._K(f)
133
134
def domain(self):
135
"""
136
Return the vector space which is the domain of this isomorphism.
137
138
EXAMPLES::
139
140
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
141
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
142
sage: V, f, t = L.vector_space()
143
sage: f.domain()
144
Vector space of dimension 2 over Rational function field in x over Rational Field
145
"""
146
return self._V
147
148
def codomain(self):
149
"""
150
Return the function field which is the codomain of this isomorphism.
151
152
EXAMPLES::
153
154
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
155
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
156
sage: V, f, t = L.vector_space()
157
sage: f.codomain()
158
Function field in y defined by y^2 - x*y + 4*x^3
159
"""
160
return self._K
161
162
class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism):
163
"""
164
An isomorphism from a function field to a vector space.
165
166
EXAMPLES::
167
168
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
169
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
170
sage: V, f, t = L.vector_space(); t
171
Isomorphism morphism:
172
From: Function field in y defined by y^2 - x*y + 4*x^3
173
To: Vector space of dimension 2 over Rational function field in x over Rational Field
174
"""
175
def __init__(self, K, V):
176
"""
177
EXAMPLES::
178
179
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
180
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
181
sage: V, f, t = L.vector_space(); type(t)
182
<class 'sage.rings.function_field.maps.MapFunctionFieldToVectorSpace'>
183
"""
184
self._V = V
185
self._K = K
186
self._zero = K.base_ring()(0)
187
self._n = K.degree()
188
from sage.categories.homset import Hom
189
FunctionFieldIsomorphism.__init__(self, Hom(K, V))
190
191
def domain(self):
192
"""
193
Return the function field which is the domain of this isomorphism.
194
195
EXAMPLES::
196
197
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
198
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
199
sage: V, f, t = L.vector_space()
200
sage: t.domain()
201
Function field in y defined by y^2 - x*y + 4*x^3
202
"""
203
return self._K
204
205
def codomain(self):
206
"""
207
Return the vector space which is the domain of this isomorphism.
208
209
EXAMPLES::
210
211
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
212
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
213
sage: V, f, t = L.vector_space()
214
sage: t.codomain()
215
Vector space of dimension 2 over Rational function field in x over Rational Field
216
"""
217
return self._V
218
219
def _repr_type(self):
220
"""
221
EXAMPLES::
222
223
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
224
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
225
sage: V, f, t = L.vector_space()
226
sage: t._repr_type()
227
'Isomorphism'
228
"""
229
return "Isomorphism"
230
231
def _call_(self, x):
232
"""
233
EXAMPLES::
234
235
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
236
sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
237
sage: V, f, t = L.vector_space()
238
sage: t(x + (1/x^3)*y) # indirect doctest
239
(x, 1/x^3)
240
"""
241
y = self._K(x)
242
v = y.list()
243
w = v + [self._zero]*(self._n - len(v))
244
return self._V(w)
245
246
class FunctionFieldMorphism(RingHomomorphism):
247
r"""
248
Base class for morphisms between function fields.
249
"""
250
def __init__(self, parent, im_gen, base_morphism):
251
"""
252
EXAMPLES::
253
254
sage: K.<x> = FunctionField(QQ)
255
sage: f = K.hom(1/x); f
256
Morphism of function fields defined by x |--> 1/x
257
sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldMorphism)
258
True
259
"""
260
RingHomomorphism.__init__(self, parent)
261
262
self._im_gen = im_gen
263
self._base_morphism = base_morphism
264
265
def is_injective(self):
266
"""
267
Returns True since homomorphisms of fields are injective.
268
269
EXAMPLES::
270
271
sage: K.<x> = FunctionField(QQ)
272
sage: f = K.hom(1/x); f
273
Morphism of function fields defined by x |--> 1/x
274
sage: f.is_injective()
275
True
276
"""
277
return True
278
279
def __repr__(self):
280
"""
281
EXAMPLES::
282
283
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
284
sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
285
sage: f = L.hom(y*2)
286
sage: f.__repr__()
287
'Morphism of function fields defined by y |--> 2*y'
288
"""
289
return "Morphism of function fields defined by %s"%self._short_repr()
290
291
def _short_repr(self):
292
"""
293
EXAMPLES::
294
295
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
296
sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
297
sage: f = L.hom(y*2)
298
sage: f._short_repr()
299
'y |--> 2*y'
300
"""
301
a = '%s |--> %s'%(self.domain().gen(), self._im_gen)
302
if self._base_morphism is not None:
303
a += ', ' + self._base_morphism._short_repr()
304
return a
305
306
class FunctionFieldMorphism_polymod(FunctionFieldMorphism):
307
"""
308
Morphism from a finite extension of a function field to a function field.
309
310
EXAMPLES::
311
312
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
313
sage: L.<y> = K.extension(y^2 - x)
314
sage: f = L.hom(-y); f
315
Morphism of function fields defined by y |--> -y
316
"""
317
def __init__(self, parent, im_gen, base_morphism):
318
"""
319
EXAMPLES::
320
321
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
322
sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
323
sage: f = L.hom(y*2); f
324
Morphism of function fields defined by y |--> 2*y
325
sage: type(f)
326
<class 'sage.rings.function_field.maps.FunctionFieldMorphism_polymod'>
327
sage: factor(L.polynomial())
328
y^3 + 6*x^3 + x
329
sage: f(y).charpoly('y')
330
y^3 + 6*x^3 + x
331
"""
332
FunctionFieldMorphism.__init__(self, parent, im_gen, base_morphism)
333
# Verify that the morphism is valid:
334
R = self.codomain()['X']
335
v = parent.domain().polynomial().list()
336
if base_morphism is not None:
337
v = [base_morphism(a) for a in v]
338
f = R(v)
339
if f(im_gen):
340
raise ValueError, "invalid morphism"
341
342
def _call_(self, x):
343
"""
344
EXAMPLES::
345
346
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
347
sage: L.<y> = K.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
348
sage: f(y/x + x^2/(x+1)) # indirect doctest
349
2/x*y + x^2/(x + 1)
350
sage: f(y)
351
2*y
352
"""
353
v = x.list()
354
if self._base_morphism is not None:
355
v = [self._base_morphism(a) for a in v]
356
f = v[0].parent()['X'](v)
357
return f(self._im_gen)
358
359
class FunctionFieldMorphism_rational(FunctionFieldMorphism):
360
"""
361
Morphism from a rational function field to a function field.
362
363
EXAMPLES::
364
365
sage: K.<x> = FunctionField(QQ)
366
sage: f = K.hom(1/x); f
367
Morphism of function fields defined by x |--> 1/x
368
"""
369
def __init__(self, parent, im_gen):
370
"""
371
EXAMPLES::
372
373
sage: K.<x> = FunctionField(GF(7))
374
sage: f = K.hom(1/x); f
375
Morphism of function fields defined by x |--> 1/x
376
sage: type(f)
377
<class 'sage.rings.function_field.maps.FunctionFieldMorphism_rational'>
378
"""
379
FunctionFieldMorphism.__init__(self, parent, im_gen, None)
380
381
def _call_(self, x):
382
"""
383
EXAMPLES::
384
385
sage: K.<x> = FunctionField(GF(7))
386
sage: f = K.hom(1/x); f
387
Morphism of function fields defined by x |--> 1/x
388
sage: f(x+1) # indirect doctest
389
(x + 1)/x
390
sage: 1/x + 1
391
(x + 1)/x
392
"""
393
a = x.element()
394
return a.subs({a.parent().gen():self._im_gen})
395
396