Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/rings/function_field/function_field_order.py
4036 views
1
r"""
2
Orders in Function Fields
3
4
AUTHORS:
5
6
- William Stein (2010): initial version
7
8
- Maarten Derickx (2011-09-14): fixed ideal_with_gens_over_base() for rational function fields
9
10
- Julian Rueth (2011-09-14): added check in _element_constructor_
11
12
EXAMPLES:
13
14
Maximal orders in rational function fields::
15
16
sage: K.<x> = FunctionField(QQ)
17
sage: O = K.maximal_order()
18
sage: I = O.ideal(1/x); I
19
Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
20
sage: 1/x in O
21
False
22
23
Equation orders in extensions of rational function fields::
24
25
sage: K.<x> = FunctionField(GF(3)); R.<y> = K[]
26
sage: L.<y> = K.extension(y^3-y-x)
27
sage: O = L.equation_order()
28
sage: 1/y in O
29
False
30
sage: x/y in O
31
True
32
"""
33
#*****************************************************************************
34
# Copyright (C) 2010 William Stein <[email protected]>
35
# Copyright (C) 2011 Maarten Derickx <[email protected]>
36
# Copyright (C) 2011 Julian Rueth <[email protected]>
37
#
38
# Distributed under the terms of the GNU General Public License (GPL)
39
# as published by the Free Software Foundation; either version 2 of
40
# the License, or (at your option) any later version.
41
# http://www.gnu.org/licenses/
42
#*****************************************************************************
43
44
from sage.rings.ring import IntegralDomain, PrincipalIdealDomain
45
from sage.rings.ideal import is_Ideal
46
47
class FunctionFieldOrder(IntegralDomain):
48
"""
49
Base class for orders in function fields.
50
"""
51
def __init__(self, fraction_field):
52
"""
53
INPUT:
54
55
- ``fraction_field`` -- the function field in which this is an order.
56
57
EXAMPLES::
58
59
sage: R = FunctionField(QQ,'y').maximal_order()
60
sage: isinstance(R, sage.rings.function_field.function_field_order.FunctionFieldOrder)
61
True
62
"""
63
IntegralDomain.__init__(self, self)
64
self._fraction_field = fraction_field
65
66
def _repr_(self):
67
"""
68
EXAMPLES::
69
70
sage: FunctionField(QQ,'y').maximal_order()._repr_()
71
'Maximal order in Rational function field in y over Rational Field'
72
"""
73
return "Order in %s"%self.fraction_field()
74
75
def is_finite(self):
76
"""
77
Returns False since orders are never finite.
78
79
EXAMPLES::
80
81
sage: FunctionField(QQ,'y').maximal_order().is_finite()
82
False
83
"""
84
return False
85
86
def is_field(self, proof=True):
87
"""
88
Returns False since orders are never fields.
89
90
EXAMPLES::
91
92
sage: FunctionField(QQ,'y').maximal_order().is_field()
93
False
94
"""
95
return False
96
97
def is_noetherian(self):
98
"""
99
Returns True since orders in function fields are noetherian.
100
101
EXAMPLES::
102
103
sage: FunctionField(QQ,'y').maximal_order().is_noetherian()
104
True
105
"""
106
return True
107
108
def fraction_field(self):
109
"""
110
Returns the function field in which this is an order.
111
112
EXAMPLES::
113
114
sage: FunctionField(QQ,'y').maximal_order().fraction_field()
115
Rational function field in y over Rational Field
116
"""
117
return self._fraction_field
118
119
function_field = fraction_field
120
121
def ideal_with_gens_over_base(self, gens):
122
"""
123
Returns the fractional ideal with basis ``gens`` over the
124
maximal order of the base field. That this is really an ideal
125
is not checked.
126
127
INPUT:
128
129
- ``gens`` -- list of elements that are a basis for the
130
ideal over the maximal order of the base field
131
132
EXAMPLES:
133
134
We construct an ideal in a rational function field::
135
136
sage: K.<y> = FunctionField(QQ)
137
sage: O = K.maximal_order()
138
sage: I = O.ideal_with_gens_over_base([y]); I
139
Ideal (y) of Maximal order in Rational function field in y over Rational Field
140
sage: I*I
141
Ideal (y^2) of Maximal order in Rational function field in y over Rational Field
142
143
We construct some ideals in a nontrivial function field::
144
145
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
146
sage: L.<y> = K.extension(y^2 - x^3 - 1)
147
sage: O = L.equation_order(); O
148
Order in Function field in y defined by y^2 + 6*x^3 + 6
149
sage: I = O.ideal_with_gens_over_base([1, y]); I
150
Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
151
sage: I.module()
152
Free module of degree 2 and rank 2 over Maximal order in Rational function field in x over Finite Field of size 7
153
Echelon basis matrix:
154
[1 0]
155
[0 1]
156
157
There is no check if the resulting object is really an ideal::
158
159
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
160
sage: L.<y> = K.extension(y^2 - x^3 - 1)
161
sage: O = L.equation_order()
162
sage: I = O.ideal_with_gens_over_base([y]); I
163
Ideal (y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
164
sage: y in I
165
True
166
sage: y^2 in I
167
False
168
"""
169
from function_field_ideal import ideal_with_gens_over_base
170
return ideal_with_gens_over_base(self, [self(a) for a in gens])
171
172
def ideal(self, *gens):
173
"""
174
Returns the fractional ideal generated by the elements in ``gens``.
175
176
INPUT:
177
178
- ``gens`` -- a list of generators or an ideal in a ring which
179
coerces to this order.
180
181
EXAMPLES::
182
183
sage: K.<y> = FunctionField(QQ)
184
sage: O = K.maximal_order()
185
sage: O.ideal(y)
186
Ideal (y) of Maximal order in Rational function field in y over Rational Field
187
sage: O.ideal([y,1/y]) == O.ideal(y,1/y) # multiple generators may be given as a list
188
True
189
190
A fractional ideal of a nontrivial extension::
191
192
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
193
sage: O = K.maximal_order()
194
sage: I = O.ideal(x^2-4)
195
sage: L.<y> = K.extension(y^2 - x^3 - 1)
196
sage: S = L.equation_order()
197
sage: S.ideal(1/y)
198
Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
199
sage: I2 = S.ideal(x^2-4); I2
200
Ideal (x^2 + 3, (x^2 + 3)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
201
sage: I2 == S.ideal(I)
202
True
203
"""
204
if len(gens) == 1:
205
gens = gens[0]
206
if not isinstance(gens, (list, tuple)):
207
if is_Ideal(gens):
208
gens = gens.gens()
209
else:
210
gens = [gens]
211
from function_field_ideal import ideal_with_gens
212
return ideal_with_gens(self, gens)
213
214
class FunctionFieldOrder_basis(FunctionFieldOrder):
215
"""
216
An order given by a basis over the maximal order of the base
217
field.
218
"""
219
def __init__(self, basis, check=True):
220
"""
221
EXAMPLES::
222
223
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
224
sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
225
sage: O = L.equation_order(); O
226
Order in Function field in y defined by y^4 + x*y + 4*x + 1
227
sage: type(O)
228
<class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_basis_with_category'>
229
230
The basis only defines an order if the module it generates is closed under multiplication
231
and contains the identity element (only checked when ``check`` is True)::
232
233
sage: K.<x> = FunctionField(QQ)
234
sage: R.<y> = K[]
235
sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x));
236
sage: y.is_integral()
237
False
238
sage: L.order(y)
239
Traceback (most recent call last):
240
...
241
ValueError: The module generated by basis [1, y, y^2, y^3, y^4] must be closed under multiplication
242
243
The basis also has to be linearly independent and of the same rank as the degree of the function field of its elements (only checked when ``check`` is True)::
244
245
sage: L.order(L(x))
246
Traceback (most recent call last):
247
...
248
ValueError: Basis [1, x, x^2, x^3, x^4] is not linearly independent
249
sage: sage.rings.function_field.function_field_order.FunctionFieldOrder_basis([y,y,y^3,y^4,y^5])
250
Traceback (most recent call last):
251
...
252
ValueError: Basis [y, y, y^3, y^4, 2*x*y + (x^4 + 1)/x] is not linearly independent
253
"""
254
if len(basis) == 0:
255
raise ValueError, "basis must have positive length"
256
257
fraction_field = basis[0].parent()
258
if len(basis) != fraction_field.degree():
259
raise ValueError, "length of basis must equal degree of field"
260
261
FunctionFieldOrder.__init__(self, fraction_field)
262
263
self._basis = tuple(basis)
264
V, fr, to = fraction_field.vector_space()
265
R = fraction_field.base_field().maximal_order()
266
self._module = V.span([to(b) for b in basis], base_ring=R)
267
self._ring = fraction_field.polynomial_ring()
268
self._populate_coercion_lists_(coerce_list=[self._ring])
269
if check:
270
if self._module.rank() != fraction_field.degree():
271
raise ValueError, "Basis %s is not linearly independent"%(basis)
272
if not to(fraction_field(1)) in self._module:
273
raise ValueError, "The identity element must be in the module spanned by basis %s"%(basis)
274
if not all(to(a*b) in self._module for a in basis for b in basis):
275
raise ValueError, "The module generated by basis %s must be closed under multiplication"%(basis)
276
IntegralDomain.__init__(self, self, names = fraction_field.variable_names(), normalize = False)
277
278
def _element_constructor_(self, f, check=True):
279
"""
280
Make ``f`` into an element of this order.
281
282
INPUT::
283
284
- ``f`` -- the element
285
- ``check`` -- check if the element is in the order
286
287
EXAMPLES::
288
289
sage: K.<x> = FunctionField(QQ)
290
sage: K.maximal_order()._element_constructor_(x)
291
x
292
"""
293
fraction_field=self.fraction_field()
294
295
if f.parent() is fraction_field:
296
f = f.element()
297
f = self._ring(f)
298
if check:
299
V, fr, to = fraction_field.vector_space()
300
f_vector = to(fraction_field(f))
301
if not f_vector in self._module:
302
raise ValueError, "%s is not an element of %s"%(f_vector,self)
303
return fraction_field._element_class(self, f)
304
305
def fraction_field(self):
306
"""
307
Returns the function field in which this is an order.
308
309
EXAMPLES::
310
311
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
312
sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
313
sage: O = L.equation_order()
314
sage: O.fraction_field()
315
Function field in y defined by y^4 + x*y + 4*x + 1
316
"""
317
return self._fraction_field
318
319
def polynomial(self):
320
"""
321
Returns the defining polynomial of the function field of which this is an order.
322
323
EXAMPLES::
324
325
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
326
sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
327
sage: O = L.equation_order()
328
sage: O.polynomial()
329
y^4 + x*y + 4*x + 1
330
"""
331
return self._fraction_field.polynomial()
332
333
def basis(self):
334
"""
335
Returns a basis of self over the maximal order of the base field.
336
337
EXAMPLES::
338
339
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
340
sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
341
sage: O = L.equation_order()
342
sage: O.basis()
343
(1, y, y^2, y^3)
344
"""
345
return self._basis
346
347
def free_module(self):
348
"""
349
Returns the free module formed by the basis over the maximal order of the base field.
350
351
EXAMPLES::
352
353
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
354
sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
355
sage: O = L.equation_order()
356
sage: O.free_module()
357
Free module of degree 4 and rank 4 over Maximal order in Rational function field in x over Finite Field of size 7
358
Echelon basis matrix:
359
[1 0 0 0]
360
[0 1 0 0]
361
[0 0 1 0]
362
[0 0 0 1]
363
"""
364
return self._module
365
366
class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder):
367
"""
368
The maximal order in a rational function field.
369
"""
370
def __init__(self, function_field):
371
"""
372
EXAMPLES::
373
374
sage: K.<t> = FunctionField(GF(19)); K
375
Rational function field in t over Finite Field of size 19
376
sage: R = K.maximal_order(); R
377
Maximal order in Rational function field in t over Finite Field of size 19
378
sage: type(R)
379
<class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_rational_with_category'>
380
"""
381
FunctionFieldOrder.__init__(self, function_field)
382
PrincipalIdealDomain.__init__(self, self, names = function_field.variable_names(), normalize = False)
383
self._ring = function_field._ring
384
self._populate_coercion_lists_(coerce_list=[self._ring])
385
self._gen = self(self._ring.gen())
386
self._basis = (self(1),)
387
388
def basis(self):
389
"""
390
Returns the basis (=1) for this order as a module over the polynomial ring.
391
392
EXAMPLES::
393
394
sage: K.<t> = FunctionField(GF(19))
395
sage: O = K.maximal_order()
396
sage: O.basis()
397
(1,)
398
sage: parent(O.basis()[0])
399
Maximal order in Rational function field in t over Finite Field of size 19
400
"""
401
return self._basis
402
403
def ideal(self, *gens):
404
"""
405
Returns the fractional ideal generated by ``gens``.
406
407
EXAMPLES::
408
409
sage: K.<x> = FunctionField(QQ)
410
sage: O = K.maximal_order()
411
sage: O.ideal(x)
412
Ideal (x) of Maximal order in Rational function field in x over Rational Field
413
sage: O.ideal([x,1/x]) == O.ideal(x,1/x) # multiple generators may be given as a list
414
True
415
sage: O.ideal(x^3+1,x^3+6)
416
Ideal (1) of Maximal order in Rational function field in x over Rational Field
417
sage: I = O.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1)); I
418
Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field
419
sage: O.ideal(I)
420
Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field
421
"""
422
if len(gens) == 1:
423
gens = gens[0]
424
if not isinstance(gens, (list, tuple)):
425
if is_Ideal(gens):
426
gens = gens.gens()
427
else:
428
gens = (gens,)
429
from function_field_ideal import ideal_with_gens
430
return ideal_with_gens(self, gens)
431
432
def _repr_(self):
433
"""
434
EXAMPLES::
435
436
sage: FunctionField(QQ,'y').maximal_order()._repr_()
437
'Maximal order in Rational function field in y over Rational Field'
438
"""
439
return "Maximal order in %s"%self.fraction_field()
440
441
def gen(self, n=0):
442
"""
443
Returns the ``n``-th generator of self. Since there is only one generator ``n`` must be 0.
444
445
EXAMPLES::
446
447
sage: O = FunctionField(QQ,'y').maximal_order()
448
sage: O.gen()
449
y
450
sage: O.gen(1)
451
Traceback (most recent call last):
452
...
453
IndexError: Only one generator.
454
"""
455
if n != 0: raise IndexError, "Only one generator."
456
return self._gen
457
458
def ngens(self):
459
"""
460
Returns 1, the number of generators of self.
461
462
EXAMPLES::
463
464
sage: FunctionField(QQ,'y').maximal_order().ngens()
465
1
466
"""
467
return 1
468
469
def _element_constructor_(self, f):
470
"""
471
Make ``f`` into an element of this order.
472
473
EXAMPLES::
474
475
sage: K.<y> = FunctionField(QQ)
476
sage: O = K.maximal_order()
477
sage: O._element_constructor_(y)
478
y
479
sage: O._element_constructor_(1/y)
480
Traceback (most recent call last):
481
...
482
ValueError: `1/y` is not a member of `Maximal order in Rational function field in y over Rational Field`
483
"""
484
if f.parent() is self.fraction_field():
485
if not f.denominator() in self.fraction_field().constant_base_field():
486
raise ValueError("`%s` is not a member of `%s`"%(f,self))
487
f = f.element()
488
from function_field_element import FunctionFieldElement_rational
489
return FunctionFieldElement_rational(self, self._ring(f))
490
491