Path: blob/master/sage/rings/function_field/function_field_order.py
4036 views
r"""1Orders in Function Fields23AUTHORS:45- William Stein (2010): initial version67- Maarten Derickx (2011-09-14): fixed ideal_with_gens_over_base() for rational function fields89- Julian Rueth (2011-09-14): added check in _element_constructor_1011EXAMPLES:1213Maximal orders in rational function fields::1415sage: K.<x> = FunctionField(QQ)16sage: O = K.maximal_order()17sage: I = O.ideal(1/x); I18Ideal (1/x) of Maximal order in Rational function field in x over Rational Field19sage: 1/x in O20False2122Equation orders in extensions of rational function fields::2324sage: K.<x> = FunctionField(GF(3)); R.<y> = K[]25sage: L.<y> = K.extension(y^3-y-x)26sage: O = L.equation_order()27sage: 1/y in O28False29sage: x/y in O30True31"""32#*****************************************************************************33# Copyright (C) 2010 William Stein <[email protected]>34# Copyright (C) 2011 Maarten Derickx <[email protected]>35# Copyright (C) 2011 Julian Rueth <[email protected]>36#37# Distributed under the terms of the GNU General Public License (GPL)38# as published by the Free Software Foundation; either version 2 of39# the License, or (at your option) any later version.40# http://www.gnu.org/licenses/41#*****************************************************************************4243from sage.rings.ring import IntegralDomain, PrincipalIdealDomain44from sage.rings.ideal import is_Ideal4546class FunctionFieldOrder(IntegralDomain):47"""48Base class for orders in function fields.49"""50def __init__(self, fraction_field):51"""52INPUT:5354- ``fraction_field`` -- the function field in which this is an order.5556EXAMPLES::5758sage: R = FunctionField(QQ,'y').maximal_order()59sage: isinstance(R, sage.rings.function_field.function_field_order.FunctionFieldOrder)60True61"""62IntegralDomain.__init__(self, self)63self._fraction_field = fraction_field6465def _repr_(self):66"""67EXAMPLES::6869sage: FunctionField(QQ,'y').maximal_order()._repr_()70'Maximal order in Rational function field in y over Rational Field'71"""72return "Order in %s"%self.fraction_field()7374def is_finite(self):75"""76Returns False since orders are never finite.7778EXAMPLES::7980sage: FunctionField(QQ,'y').maximal_order().is_finite()81False82"""83return False8485def is_field(self, proof=True):86"""87Returns False since orders are never fields.8889EXAMPLES::9091sage: FunctionField(QQ,'y').maximal_order().is_field()92False93"""94return False9596def is_noetherian(self):97"""98Returns True since orders in function fields are noetherian.99100EXAMPLES::101102sage: FunctionField(QQ,'y').maximal_order().is_noetherian()103True104"""105return True106107def fraction_field(self):108"""109Returns the function field in which this is an order.110111EXAMPLES::112113sage: FunctionField(QQ,'y').maximal_order().fraction_field()114Rational function field in y over Rational Field115"""116return self._fraction_field117118function_field = fraction_field119120def ideal_with_gens_over_base(self, gens):121"""122Returns the fractional ideal with basis ``gens`` over the123maximal order of the base field. That this is really an ideal124is not checked.125126INPUT:127128- ``gens`` -- list of elements that are a basis for the129ideal over the maximal order of the base field130131EXAMPLES:132133We construct an ideal in a rational function field::134135sage: K.<y> = FunctionField(QQ)136sage: O = K.maximal_order()137sage: I = O.ideal_with_gens_over_base([y]); I138Ideal (y) of Maximal order in Rational function field in y over Rational Field139sage: I*I140Ideal (y^2) of Maximal order in Rational function field in y over Rational Field141142We construct some ideals in a nontrivial function field::143144sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]145sage: L.<y> = K.extension(y^2 - x^3 - 1)146sage: O = L.equation_order(); O147Order in Function field in y defined by y^2 + 6*x^3 + 6148sage: I = O.ideal_with_gens_over_base([1, y]); I149Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6150sage: I.module()151Free module of degree 2 and rank 2 over Maximal order in Rational function field in x over Finite Field of size 7152Echelon basis matrix:153[1 0]154[0 1]155156There is no check if the resulting object is really an ideal::157158sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]159sage: L.<y> = K.extension(y^2 - x^3 - 1)160sage: O = L.equation_order()161sage: I = O.ideal_with_gens_over_base([y]); I162Ideal (y) of Order in Function field in y defined by y^2 + 6*x^3 + 6163sage: y in I164True165sage: y^2 in I166False167"""168from function_field_ideal import ideal_with_gens_over_base169return ideal_with_gens_over_base(self, [self(a) for a in gens])170171def ideal(self, *gens):172"""173Returns the fractional ideal generated by the elements in ``gens``.174175INPUT:176177- ``gens`` -- a list of generators or an ideal in a ring which178coerces to this order.179180EXAMPLES::181182sage: K.<y> = FunctionField(QQ)183sage: O = K.maximal_order()184sage: O.ideal(y)185Ideal (y) of Maximal order in Rational function field in y over Rational Field186sage: O.ideal([y,1/y]) == O.ideal(y,1/y) # multiple generators may be given as a list187True188189A fractional ideal of a nontrivial extension::190191sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]192sage: O = K.maximal_order()193sage: I = O.ideal(x^2-4)194sage: L.<y> = K.extension(y^2 - x^3 - 1)195sage: S = L.equation_order()196sage: S.ideal(1/y)197Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6198sage: I2 = S.ideal(x^2-4); I2199Ideal (x^2 + 3, (x^2 + 3)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6200sage: I2 == S.ideal(I)201True202"""203if len(gens) == 1:204gens = gens[0]205if not isinstance(gens, (list, tuple)):206if is_Ideal(gens):207gens = gens.gens()208else:209gens = [gens]210from function_field_ideal import ideal_with_gens211return ideal_with_gens(self, gens)212213class FunctionFieldOrder_basis(FunctionFieldOrder):214"""215An order given by a basis over the maximal order of the base216field.217"""218def __init__(self, basis, check=True):219"""220EXAMPLES::221222sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]223sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)224sage: O = L.equation_order(); O225Order in Function field in y defined by y^4 + x*y + 4*x + 1226sage: type(O)227<class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_basis_with_category'>228229The basis only defines an order if the module it generates is closed under multiplication230and contains the identity element (only checked when ``check`` is True)::231232sage: K.<x> = FunctionField(QQ)233sage: R.<y> = K[]234sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x));235sage: y.is_integral()236False237sage: L.order(y)238Traceback (most recent call last):239...240ValueError: The module generated by basis [1, y, y^2, y^3, y^4] must be closed under multiplication241242The 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)::243244sage: L.order(L(x))245Traceback (most recent call last):246...247ValueError: Basis [1, x, x^2, x^3, x^4] is not linearly independent248sage: sage.rings.function_field.function_field_order.FunctionFieldOrder_basis([y,y,y^3,y^4,y^5])249Traceback (most recent call last):250...251ValueError: Basis [y, y, y^3, y^4, 2*x*y + (x^4 + 1)/x] is not linearly independent252"""253if len(basis) == 0:254raise ValueError, "basis must have positive length"255256fraction_field = basis[0].parent()257if len(basis) != fraction_field.degree():258raise ValueError, "length of basis must equal degree of field"259260FunctionFieldOrder.__init__(self, fraction_field)261262self._basis = tuple(basis)263V, fr, to = fraction_field.vector_space()264R = fraction_field.base_field().maximal_order()265self._module = V.span([to(b) for b in basis], base_ring=R)266self._ring = fraction_field.polynomial_ring()267self._populate_coercion_lists_(coerce_list=[self._ring])268if check:269if self._module.rank() != fraction_field.degree():270raise ValueError, "Basis %s is not linearly independent"%(basis)271if not to(fraction_field(1)) in self._module:272raise ValueError, "The identity element must be in the module spanned by basis %s"%(basis)273if not all(to(a*b) in self._module for a in basis for b in basis):274raise ValueError, "The module generated by basis %s must be closed under multiplication"%(basis)275IntegralDomain.__init__(self, self, names = fraction_field.variable_names(), normalize = False)276277def _element_constructor_(self, f, check=True):278"""279Make ``f`` into an element of this order.280281INPUT::282283- ``f`` -- the element284- ``check`` -- check if the element is in the order285286EXAMPLES::287288sage: K.<x> = FunctionField(QQ)289sage: K.maximal_order()._element_constructor_(x)290x291"""292fraction_field=self.fraction_field()293294if f.parent() is fraction_field:295f = f.element()296f = self._ring(f)297if check:298V, fr, to = fraction_field.vector_space()299f_vector = to(fraction_field(f))300if not f_vector in self._module:301raise ValueError, "%s is not an element of %s"%(f_vector,self)302return fraction_field._element_class(self, f)303304def fraction_field(self):305"""306Returns the function field in which this is an order.307308EXAMPLES::309310sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]311sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)312sage: O = L.equation_order()313sage: O.fraction_field()314Function field in y defined by y^4 + x*y + 4*x + 1315"""316return self._fraction_field317318def polynomial(self):319"""320Returns the defining polynomial of the function field of which this is an order.321322EXAMPLES::323324sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]325sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)326sage: O = L.equation_order()327sage: O.polynomial()328y^4 + x*y + 4*x + 1329"""330return self._fraction_field.polynomial()331332def basis(self):333"""334Returns a basis of self over the maximal order of the base field.335336EXAMPLES::337338sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]339sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)340sage: O = L.equation_order()341sage: O.basis()342(1, y, y^2, y^3)343"""344return self._basis345346def free_module(self):347"""348Returns the free module formed by the basis over the maximal order of the base field.349350EXAMPLES::351352sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]353sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)354sage: O = L.equation_order()355sage: O.free_module()356Free module of degree 4 and rank 4 over Maximal order in Rational function field in x over Finite Field of size 7357Echelon basis matrix:358[1 0 0 0]359[0 1 0 0]360[0 0 1 0]361[0 0 0 1]362"""363return self._module364365class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder):366"""367The maximal order in a rational function field.368"""369def __init__(self, function_field):370"""371EXAMPLES::372373sage: K.<t> = FunctionField(GF(19)); K374Rational function field in t over Finite Field of size 19375sage: R = K.maximal_order(); R376Maximal order in Rational function field in t over Finite Field of size 19377sage: type(R)378<class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_rational_with_category'>379"""380FunctionFieldOrder.__init__(self, function_field)381PrincipalIdealDomain.__init__(self, self, names = function_field.variable_names(), normalize = False)382self._ring = function_field._ring383self._populate_coercion_lists_(coerce_list=[self._ring])384self._gen = self(self._ring.gen())385self._basis = (self(1),)386387def basis(self):388"""389Returns the basis (=1) for this order as a module over the polynomial ring.390391EXAMPLES::392393sage: K.<t> = FunctionField(GF(19))394sage: O = K.maximal_order()395sage: O.basis()396(1,)397sage: parent(O.basis()[0])398Maximal order in Rational function field in t over Finite Field of size 19399"""400return self._basis401402def ideal(self, *gens):403"""404Returns the fractional ideal generated by ``gens``.405406EXAMPLES::407408sage: K.<x> = FunctionField(QQ)409sage: O = K.maximal_order()410sage: O.ideal(x)411Ideal (x) of Maximal order in Rational function field in x over Rational Field412sage: O.ideal([x,1/x]) == O.ideal(x,1/x) # multiple generators may be given as a list413True414sage: O.ideal(x^3+1,x^3+6)415Ideal (1) of Maximal order in Rational function field in x over Rational Field416sage: I = O.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1)); I417Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field418sage: O.ideal(I)419Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field420"""421if len(gens) == 1:422gens = gens[0]423if not isinstance(gens, (list, tuple)):424if is_Ideal(gens):425gens = gens.gens()426else:427gens = (gens,)428from function_field_ideal import ideal_with_gens429return ideal_with_gens(self, gens)430431def _repr_(self):432"""433EXAMPLES::434435sage: FunctionField(QQ,'y').maximal_order()._repr_()436'Maximal order in Rational function field in y over Rational Field'437"""438return "Maximal order in %s"%self.fraction_field()439440def gen(self, n=0):441"""442Returns the ``n``-th generator of self. Since there is only one generator ``n`` must be 0.443444EXAMPLES::445446sage: O = FunctionField(QQ,'y').maximal_order()447sage: O.gen()448y449sage: O.gen(1)450Traceback (most recent call last):451...452IndexError: Only one generator.453"""454if n != 0: raise IndexError, "Only one generator."455return self._gen456457def ngens(self):458"""459Returns 1, the number of generators of self.460461EXAMPLES::462463sage: FunctionField(QQ,'y').maximal_order().ngens()4641465"""466return 1467468def _element_constructor_(self, f):469"""470Make ``f`` into an element of this order.471472EXAMPLES::473474sage: K.<y> = FunctionField(QQ)475sage: O = K.maximal_order()476sage: O._element_constructor_(y)477y478sage: O._element_constructor_(1/y)479Traceback (most recent call last):480...481ValueError: `1/y` is not a member of `Maximal order in Rational function field in y over Rational Field`482"""483if f.parent() is self.fraction_field():484if not f.denominator() in self.fraction_field().constant_base_field():485raise ValueError("`%s` is not a member of `%s`"%(f,self))486f = f.element()487from function_field_element import FunctionFieldElement_rational488return FunctionFieldElement_rational(self, self._ring(f))489490491