Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/rings/function_field/function_field_ideal.py
4038 views
1
r"""
2
Ideals 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()
9
10
EXAMPLES:
11
12
Ideals in the maximal order of a rational function field::
13
14
sage: K.<x> = FunctionField(QQ)
15
sage: O = K.maximal_order()
16
sage: I = O.ideal(x^3+1); I
17
Ideal (x^3 + 1) of Maximal order in Rational function field in x over Rational Field
18
sage: I^2
19
Ideal (x^6 + 2*x^3 + 1) of Maximal order in Rational function field in x over Rational Field
20
sage: ~I
21
Ideal (1/(x^3 + 1)) of Maximal order in Rational function field in x over Rational Field
22
sage: ~I * I
23
Ideal (1) of Maximal order in Rational function field in x over Rational Field
24
25
Ideals in the equation order of an extension of a rational function field::
26
27
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
28
sage: L.<y> = K.extension(y^2-x^3-1)
29
sage: O = L.equation_order()
30
sage: I = O.ideal(y); I
31
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
32
sage: I^2
33
Ideal (x^3 + 1, (-x^3 - 1)*y) of Order in Function field in y defined by y^2 - x^3 - 1
34
sage: ~I
35
Ideal (-1, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 - x^3 - 1
36
sage: ~I * I
37
Ideal (1, y) of Order in Function field in y defined by y^2 - x^3 - 1
38
sage: I.intersection(~I)
39
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
40
"""
41
#*****************************************************************************
42
# Copyright (C) 2010 William Stein <[email protected]>
43
# Copyright (C) 2011 Maarten Derickx <[email protected]>
44
#
45
# Distributed under the terms of the GNU General Public License (GPL)
46
# as published by the Free Software Foundation; either version 2 of
47
# the License, or (at your option) any later version.
48
# http://www.gnu.org/licenses/
49
#*****************************************************************************
50
51
from sage.rings.ideal import Ideal_generic
52
53
class FunctionFieldIdeal(Ideal_generic):
54
"""
55
A fractional ideal of a function field.
56
57
EXAMPLES::
58
59
sage: K.<x> = FunctionField(GF(7))
60
sage: O = K.maximal_order()
61
sage: I = O.ideal(x^3+1)
62
sage: isinstance(I, sage.rings.function_field.function_field_ideal.FunctionFieldIdeal)
63
True
64
"""
65
pass
66
67
class FunctionFieldIdeal_module(FunctionFieldIdeal):
68
"""
69
A fractional ideal specified by a finitely generated module over
70
the integers of the base field.
71
72
EXAMPLES:
73
74
An ideal in an extension of a rational function field::
75
76
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
77
sage: L.<y> = K.extension(y^2 - x^3 - 1)
78
sage: O = L.equation_order()
79
sage: I = O.ideal(y)
80
sage: I
81
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
82
sage: I^2
83
Ideal (x^3 + 1, (-x^3 - 1)*y) of Order in Function field in y defined by y^2 - x^3 - 1
84
"""
85
def __init__(self, ring, module):
86
"""
87
INPUT:
88
89
- ``ring`` -- an order in a function field
90
- ``module`` -- a module
91
92
EXAMPLES::
93
94
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
95
sage: L.<y> = K.extension(y^2 - x^3 - 1)
96
sage: O = L.equation_order()
97
sage: I = O.ideal(y)
98
sage: type(I)
99
<class 'sage.rings.function_field.function_field_ideal.FunctionFieldIdeal_module'>
100
"""
101
self._ring = ring
102
self._module = module
103
self._structure = ring.fraction_field().vector_space()
104
V, from_V, to_V = self._structure
105
gens = tuple([from_V(a) for a in module.basis()])
106
Ideal_generic.__init__(self, ring, gens, coerce=False)
107
108
def __contains__(self, x):
109
"""
110
Return True if x is in this ideal.
111
112
EXAMPLES::
113
114
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
115
sage: L.<y> = K.extension(y^2 - x^3 - 1)
116
sage: O = L.equation_order()
117
sage: I = O.ideal_with_gens_over_base([1, y]); I
118
Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
119
sage: y in I
120
True
121
sage: y/x in I
122
False
123
sage: y^2 - 2 in I
124
True
125
"""
126
return self._structure[2](x) in self._module
127
128
def module(self):
129
"""
130
Return module over the maximal order of the base field that
131
underlies self.
132
133
The formation of this module is compatible with the vector
134
space corresponding to the function field.
135
136
OUTPUT:
137
138
- a module over the maximal order of the base field of self
139
140
EXAMPLES::
141
142
sage: K.<x> = FunctionField(GF(7))
143
sage: O = K.maximal_order(); O
144
Maximal order in Rational function field in x over Finite Field of size 7
145
sage: K.polynomial_ring()
146
Univariate Polynomial Ring in x over Rational function field in x over Finite Field of size 7
147
sage: I = O.ideal_with_gens_over_base([x^2 + 1, x*(x^2+1)])
148
sage: I.gens()
149
(x^2 + 1,)
150
sage: I.module()
151
Free module of degree 1 and rank 1 over Maximal order in Rational function field in x over Finite Field of size 7
152
User basis matrix:
153
[x^2 + 1]
154
sage: V, from_V, to_V = K.vector_space(); V
155
Vector space of dimension 1 over Rational function field in x over Finite Field of size 7
156
sage: I.module().is_submodule(V)
157
True
158
"""
159
return self._module
160
161
def __add__(self, other):
162
"""
163
Add self and ``other``.
164
165
EXAMPLES::
166
167
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
168
sage: L.<y> = K.extension(y^2 - x^3 - 1)
169
sage: O = L.equation_order()
170
sage: I = O.ideal(y); J = O.ideal(y+1)
171
sage: Z = I + J; Z
172
Ideal (y + 1, 6*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
173
sage: 1 in Z
174
True
175
sage: O.ideal(y^2) + O.ideal(y^3) == O.ideal(y^2,y^3)
176
True
177
"""
178
if not isinstance(other, FunctionFieldIdeal_module):
179
other = self.ring().ideal(other)
180
return FunctionFieldIdeal_module(self.ring(), self.module() + other.module())
181
182
def intersection(self, other):
183
"""
184
Return the intersection of the ideals self and ``other``.
185
186
EXAMPLES::
187
188
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
189
sage: L.<y> = K.extension(y^2 - x^3 - 1)
190
sage: O = L.equation_order()
191
sage: I = O.ideal(y^3); J = O.ideal(y^2)
192
sage: Z = I.intersection(J); Z
193
Ideal (x^6 + 2*x^3 + 1, (6*x^3 + 6)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
194
sage: y^2 in Z
195
False
196
sage: y^3 in Z
197
True
198
"""
199
if not isinstance(other, FunctionFieldIdeal_module):
200
other = self.ring().ideal(other)
201
if self.ring() != other.ring():
202
raise ValueError, "rings must be the same"
203
return FunctionFieldIdeal_module(self.ring(), self.module().intersection(other.module()))
204
205
def __cmp__(self, other):
206
"""
207
Compare self and ``other``.
208
209
EXAMPLES::
210
211
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
212
sage: L.<y> = K.extension(y^2 - x^3 - 1)
213
sage: O = L.equation_order()
214
sage: I = O.ideal(y*(y+1)); J = O.ideal((y^2-2)*(y+1))
215
sage: I+J == J+I # indirect test
216
True
217
sage: I == J
218
False
219
sage: I < J
220
True
221
sage: J < I
222
False
223
"""
224
if not isinstance(other, FunctionFieldIdeal_module):
225
other = self.ring().ideal(other)
226
if self.ring() != other.ring():
227
raise ValueError, "rings must be the same"
228
return cmp(self.module(), other.module())
229
230
def __invert__(self):
231
"""
232
Return the inverse of this fractional ideal.
233
234
EXAMPLES::
235
236
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
237
sage: L.<y> = K.extension(y^2 - x^3 - 1)
238
sage: O = L.equation_order()
239
sage: I = O.ideal(y)
240
sage: ~I
241
Ideal (6, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
242
sage: I^(-1)
243
Ideal (6, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
244
sage: ~I * I
245
Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
246
"""
247
if len(self.gens()) == 0:
248
raise ZeroDivisionError
249
250
# NOTE: If I = (g0, ..., gn), then {x : x*I is in R}
251
# is the intersection over i of {x : x*gi is in R}
252
# Thus (I + J)^(-1) = I^(-1) intersect J^(-1).
253
254
G = self.gens()
255
R = self.ring()
256
inv = R.ideal(~G[0])
257
for g in G[1:]:
258
inv = inv.intersection(R.ideal(~g))
259
return inv
260
261
def ideal_with_gens(R, gens):
262
"""
263
Return fractional ideal in the order ``R`` with generators ``gens``
264
over ``R``.
265
266
EXAMPLES::
267
268
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
269
sage: L.<y> = K.extension(y^2 - x^3 - 1)
270
sage: O = L.equation_order()
271
sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(O, [y])
272
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
273
"""
274
K = R.fraction_field()
275
return ideal_with_gens_over_base(R, [b*K(g) for b in R.basis() for g in gens])
276
277
def ideal_with_gens_over_base(R, gens):
278
"""
279
Return fractional ideal in the order ``R`` with generators ``gens``
280
over the maximal order of the base field.
281
282
EXAMPLES::
283
284
sage: K.<x> = FunctionField(QQ); R.<y> = K[]
285
sage: L.<y> = K.extension(y^2 - x^3 - 1)
286
sage: O = L.equation_order()
287
sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(O, [x^3+1,-y])
288
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
289
290
TESTS::
291
292
sage: K.<x> = FunctionField(QQ)
293
sage: O = K.maximal_order()
294
sage: I = O*x
295
sage: ~I
296
Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
297
sage: ~I == O.ideal(1/x)
298
True
299
sage: O.ideal([x,1/x])
300
Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
301
sage: O.ideal([1/x,1/(x+1)])
302
Ideal (1/(x^2 + x)) of Maximal order in Rational function field in x over Rational Field
303
"""
304
K = R.fraction_field()
305
V, from_V, to_V = K.vector_space()
306
307
# We handle the case of a rational function field separately,
308
# since this is the base case and is used, e.g,. internally
309
# by the linear algebra Hermite form code.
310
import function_field_order
311
if isinstance(R, function_field_order.FunctionFieldOrder_rational):
312
from sage.modules import free_module_element
313
gens = free_module_element.vector(x.element() for x in gens)
314
d = gens.denominator()
315
gens *= d
316
v = R._ring.ideal(gens.list()).gens_reduced()
317
assert len(v) == 1
318
basis = [to_V(v[0]/d)]
319
M = V.span_of_basis(basis, check=False, already_echelonized=True, base_ring=R)
320
else:
321
# General case
322
S = V.base_field().maximal_order()
323
M = V.span([to_V(b) for b in gens], base_ring=S)
324
325
return FunctionFieldIdeal_module(R, M)
326
327