Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241852 views
1
#################################################################################
2
#
3
# (c) Copyright 2010 William Stein
4
#
5
# This file is part of PSAGE
6
#
7
# PSAGE is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# PSAGE is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#
20
#################################################################################
21
22
23
from sage.rings.ideal import Ideal_generic
24
25
class FunctionFieldIdeal(Ideal_generic):
26
"""
27
A fractional ideal of a function field.
28
29
EXAMPLES::
30
31
sage: R.<x> = FunctionField(GF(7))
32
sage: S = R.maximal_order(); I = S.ideal(x^3+1)
33
sage: isinstance(I, sage.rings.function_field.function_field_ideal.FunctionFieldIdeal)
34
True
35
"""
36
pass
37
38
class FunctionFieldIdeal_module(FunctionFieldIdeal):
39
"""
40
A fractional ideal specified by a finitely generated module over
41
the integers of the base field.
42
43
EXAMPLES::
44
45
An ideal in a rational function field::
46
47
sage: R.<x> = FunctionField(QQ); S.<y> = R[]
48
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
49
sage: I = M.ideal(y)
50
sage: I
51
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
52
sage: I^2
53
Ideal (x^3 + 1, (-x^3 - 1)*y) of Order in Function field in y defined by y^2 - x^3 - 1
54
"""
55
def __init__(self, ring, module):
56
"""
57
INPUT:
58
59
- ``ring`` -- an order in a function field
60
- ``module`` -- a module
61
62
EXAMPLES::
63
64
sage: R.<x> = FunctionField(QQ); S.<y> = R[]
65
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
66
sage: I = M.ideal(y)
67
sage: type(I)
68
<class 'sage.rings.function_field.function_field_ideal.FunctionFieldIdeal_module'>
69
"""
70
self._ring = ring
71
self._module = module
72
self._structure = ring.fraction_field().vector_space()
73
V, from_V, to_V = self._structure
74
gens = tuple([from_V(a) for a in module.basis()])
75
Ideal_generic.__init__(self, ring, gens, coerce=False)
76
77
def __contains__(self, x):
78
"""
79
Return True if x is in this ideal.
80
81
EXAMPLES::
82
83
sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
84
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
85
sage: I = M.ideal_with_gens_over_base([1, y]); I
86
Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
87
sage: y in I
88
True
89
sage: y/x in I
90
False
91
sage: y^2 - 2 in I
92
True
93
"""
94
return self._structure[2](x) in self._module
95
96
def module(self):
97
"""
98
Return module over the maximal order of the base field that
99
underlies self.
100
101
The formation of this module is compatible with the vector
102
space corresponding to the function field.
103
104
OUTPUT:
105
106
- a module over the maximal order of the base field of self
107
108
EXAMPLES::
109
110
sage: R.<x> = FunctionField(GF(7))
111
sage: S = R.maximal_order(); S
112
Maximal order in Rational function field in x over Finite Field of size 7
113
sage: R.polynomial_ring()
114
Univariate Polynomial Ring in x over Rational function field in x over Finite Field of size 7
115
sage: I = S.ideal_with_gens_over_base([x^2 + 1, x*(x^2+1)])
116
sage: I.gens()
117
(x^2 + 1,)
118
sage: I.module()
119
Free module of degree 1 and rank 1 over Maximal order in Rational function field in x over Finite Field of size 7
120
User basis matrix:
121
[x^2 + 1]
122
sage: V, from_V, to_V = R.vector_space(); V
123
Vector space of dimension 1 over Rational function field in x over Finite Field of size 7
124
sage: I.module().is_submodule(V)
125
True
126
"""
127
return self._module
128
129
def __add__(self, other):
130
"""
131
Add together two ideals.
132
133
EXAMPLES::
134
135
sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
136
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
137
sage: I = M.ideal(y); J = M.ideal(y+1)
138
sage: Z = I + J; Z
139
Ideal (y + 1, 6*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
140
sage: 1 in Z
141
True
142
sage: M.ideal(y^2) + M.ideal(y^3) == M.ideal(y^2,y^3)
143
True
144
"""
145
if not isinstance(other, FunctionFieldIdeal_module):
146
other = self.ring().ideal(other)
147
return FunctionFieldIdeal_module(self.ring(), self.module() + other.module())
148
149
def intersection(self, other):
150
"""
151
Return the intersection of the ideals self and other.
152
153
EXAMPLES::
154
155
sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
156
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
157
sage: I = M.ideal(y^3); J = M.ideal(y^2)
158
sage: Z = I.intersection(J); Z
159
Ideal (6*x^6 + 5*x^3 + 6, (6*x^3 + 6)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
160
sage: y^2 in Z
161
False
162
sage: y^3 in Z
163
True
164
"""
165
if not isinstance(other, FunctionFieldIdeal_module):
166
other = self.ring().ideal(other)
167
if self.ring() != other.ring():
168
raise ValueError, "rings must be the same"
169
return FunctionFieldIdeal_module(self.ring(), self.module().intersection(other.module()))
170
171
def __cmp__(self, other):
172
"""
173
Compare self and other.
174
175
EXAMPLES::
176
177
sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
178
sage: L.<y> = R.extension(y^2 - x^3 - 1)
179
sage: M = L.equation_order()
180
sage: I = M.ideal(y*(y+1)); J = M.ideal((y^2-2)*(y+1))
181
sage: I+J == J+I # indirect test
182
True
183
sage: I == J
184
False
185
sage: I < J
186
True
187
sage: J < I
188
False
189
"""
190
if not isinstance(other, FunctionFieldIdeal_module):
191
other = self.ring().ideal(other)
192
if self.ring() != other.ring():
193
raise ValueError, "rings must be the same"
194
return cmp(self.module(), other.module())
195
196
def __invert__(self):
197
"""
198
Return the inverse of this fractional ideal.
199
200
EXAMPLES::
201
202
sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
203
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
204
sage: I = M.ideal(y)
205
sage: I.__invert__()
206
Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
207
sage: I^(-1)
208
Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
209
sage: I.__invert__() * I
210
Ideal (1, 6*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
211
"""
212
if len(self.gens()) == 0:
213
raise ZeroDivisionError
214
215
# NOTE: If I = (g0, ..., gn), then {x : x*I is in R}
216
# is the intersection over i of {x : x*gi is in R}
217
# Thus (I + J)^(-1) = I^(-1) intersect J^(-1).
218
219
G = self.gens()
220
R = self.ring()
221
inv = R.ideal(~G[0])
222
for g in G[1:]:
223
inv = inv.intersection(R.ideal(~g))
224
return inv
225
226
def ideal_with_gens(R, gens):
227
"""
228
Return fractional ideal in the order of R with given generators
229
over R.
230
231
EXAMPLES::
232
233
sage: R.<x> = FunctionField(QQ); S.<y> = R[]
234
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
235
sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(M, [y])
236
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
237
"""
238
K = R.fraction_field()
239
return ideal_with_gens_over_base(R, [b*K(g) for b in R.basis() for g in gens])
240
241
242
def ideal_with_gens_over_base(R, gens):
243
"""
244
Return fractional ideal in the given order R with given generators
245
over the maximal order of the base field.
246
247
EXAMPLES::
248
249
sage: R.<x> = FunctionField(QQ); S.<y> = R[]
250
sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
251
sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(M, [x^3+1,-y])
252
Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
253
"""
254
K = R.fraction_field()
255
V, from_V, to_V = K.vector_space()
256
257
# We handle the case of a rational function field separately,
258
# since this is the base case and is used, e.g,. internally
259
# by the linear algebra Hermite form code.
260
import function_field_order
261
if isinstance(R, function_field_order.FunctionFieldOrder_rational):
262
try:
263
v = R._ring.ideal([x.element() for x in gens]).gens_reduced()
264
assert len(v) == 1
265
basis = [to_V(v[0])]
266
M = V.span_of_basis(basis, check=False, already_echelonized=True, base_ring=R)
267
except Exception, msg:
268
print msg # TODO --for debugging
269
raise
270
else:
271
# General case
272
S = V.base_field().maximal_order()
273
M = V.span([to_V(b) for b in gens], base_ring=S)
274
275
return FunctionFieldIdeal_module(R, M)
276
277