# Ticket #9054: trac_9054-part4.patch

File trac_9054-part4.patch, 12.6 KB (added by was, 12 years ago)
• ## sage/rings/function_field/function_field.py

```# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1274953602 25200
# Node ID ad21a9d32f9940caf21acdb26441b953be22a462
# Parent  7f05bf6d613ef8004b9d767401fe6ddfc70c8b38
[mq]: trac_9054-part4.patch

diff -r 7f05bf6d613e -r ad21a9d32f99 sage/rings/function_field/function_field.py```
 a names = f.variable_name() return FunctionField_polymod(f, names) def order_with_basis(self, basis, check=True): """ Return the order with given basis over the maximal order of the base field. INPUT: - ``basis`` -- a list of elements of self - ``check`` -- bool (default: True); if True, check that the basis is really linearly independent OUTPUT: - an order in this function field EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^3 + x^3 + 4*x + 1) sage: O = L.order_with_basis([1, Y, Y^2]); O Order in Function field in Y defined by y^3 + x^3 + 4*x + 1 sage: O.basis() (1, Y, Y^2) sage: O = L.order_with_basis([x, x^2 + x*Y, (2/3)*Y^2]); O Order in Function field in Y defined by y^3 + x^3 + 4*x + 1 sage: O.basis() (x, x*Y + x^2, 2/3*Y^2) """ from function_field_order import FunctionFieldOrder_basis return FunctionFieldOrder_basis([self(a) for a in basis], check=check) def order(self, x, check=True): """ Return the order in this function field generated over the maximal order by x or the elements of x if x is a list. INPUT: - ``x`` -- element of self, or a list of elements of self - ``check`` -- bool (default: True); if True, check that x really generates an order EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^3 + x^3 + 4*x + 1) sage: O = L.order(Y); O Order in Function field in Y defined by y^3 + x^3 + 4*x + 1 sage: O.basis() (1, Y, Y^2) sage: Z = K.order(x); Z Order in Rational function field in x over Rational Field sage: Z.basis() (1,) Orders with multiple generators, not yet supported:: sage: Z = K.order([x,x^2]); Z Traceback (most recent call last): ... NotImplementedError """ if not isinstance(x, (list, tuple)): x = [x] if len(x) == 1: g = x[0] basis = [self(1)] for i in range(self.degree()-1): basis.append(basis[-1]*g) else: raise NotImplementedError return self.order_with_basis(basis, check=check) def _coerce_map_from_(self, R): """ Return True if there is a coerce map from R to self. EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^3 + x^3 + 4*x + 1) sage: L.equation_order() Order in Function field in Y defined by y^3 + x^3 + 4*x + 1 sage: L._coerce_map_from_(L.equation_order()) True sage: L._coerce_map_from_(GF(7)) False """ from function_field_order import FunctionFieldOrder if isinstance(R, FunctionFieldOrder) and R.fraction_field() == self: return True return False class FunctionField_polymod(FunctionField): """ A function field defined by a univariate polynomial, as an sage: L._element_constructor_(L.polynomial_ring().gen()) w """ if x.parent() is self: return x if x.parent() is self._ring: return function_field_element.FunctionFieldElement_polymod(self, x) if isinstance(x, function_field_element.FunctionFieldElement): return function_field_element.FunctionFieldElement_polymod(self, self._ring(x.element())) return function_field_element.FunctionFieldElement_polymod(self, self._ring(x)) ... IndexError: Only one generator. """ if n != 0: raise IndexError, "Only one generator." if n != 0: raise IndexError, "Only one generator." return self._gen def ngens(self): sage: L.ngens() 1 """ return ZZ(1) return 1 def equation_order(self): """ sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^5 - (x^3 + 2*x*y + 1/x)) sage: L.equation_order() Traceback (most recent call last): ... NotImplementedError Order in Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x """ raise NotImplementedError return self.order(self.gen(), check=False) class RationalFunctionField(FunctionField): """ sage: K.constant_field() Finite Field of size 7 sage: K.maximal_order() Univariate Polynomial Ring in t over Finite Field of size 7 Maximal order in Rational function field in t over Finite Field of size 7 """ def __init__(self, constant_field, names, category=CAT): """ Rational function field in t over Rational Field """ if x.parent() is self._field: return function_field_element.FunctionFieldElement_P1(self, x) return function_field_element.FunctionFieldElement_rational(self, x) if isinstance(x, function_field_element.FunctionFieldElement): K = x.parent() if K is self: return x else: raise TypeError return function_field_element.FunctionFieldElement_P1(self, self._field(x)) return function_field_element.FunctionFieldElement_rational(self, self._field(x.element())) return function_field_element.FunctionFieldElement_rational(self, self._field(x)) def polynomial_ring(self): """ Return polynomial ring underlying this function field. EXAMPLES:: sage: K. = FunctionField(QQ) sage: K.polynomial_ring() Univariate Polynomial Ring in x over Rational Field """ return self._ring def vector_space(self): """ Return a vector space V and isomorphisms self --> V and V --> self. OUTPUT: -  ``V`` - a vector space over the rational numbers -  ``from_V`` - an isomorphism from V to self -  ``to_V`` - an isomorphism from self to V EXAMPLES:: sage: K. = FunctionField(QQ) sage: K.vector_space() (Vector space of dimension 1 over Rational function field in x over Rational Field, Isomorphism map: From: Vector space of dimension 1 over Rational function field in x over Rational Field To:   Rational function field in x over Rational Field, Isomorphism map: From: Rational function field in x over Rational Field To:   Vector space of dimension 1 over Rational function field in x over Rational Field) """ try: return self._vector_space except AttributeError: V = self.base_field()**1 from_V = maps.MapVectorSpaceToFunctionField(V, self) to_V   = maps.MapFunctionFieldToVectorSpace(self, V) self._vector_space = (V, from_V, to_V) return self._vector_space def random_element(self, *args, **kwds): """ sage: K.ngens() 1 """ return ZZ(1) return 1 def base_field(self): """ sage: K. = FunctionField(QQ) sage: K.maximal_order() Univariate Polynomial Ring in t over Rational Field Maximal order in Rational function field in t over Rational Field """ return self._ring try: return self._maximal_order except AttributeError: from function_field_order import FunctionFieldOrder_rational self._maximal_order = FunctionFieldOrder_rational(self) return self._maximal_order def constant_field(self): """
• ## sage/rings/function_field/function_field_element.py

`diff -r 7f05bf6d613e -r ad21a9d32f99 sage/rings/function_field/function_field_element.py`
 a minpoly = minimal_polynomial def is_integral(self): r""" Determine if self is integral over the maximal order of the base field. EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^2 - x*y + 4*x^3) sage: Y.is_integral() True sage: (Y/x).is_integral() True sage: (Y/x)^2 - (Y/x) + 4*x 0 sage: (Y/x^2).is_integral() False sage: f = (Y/x).minimal_polynomial('W'); f W^2 - W + 4*x """ R = self.parent().base_field().maximal_order() return all([a in R for a in self.minimal_polynomial()]) class FunctionFieldElement_polymod(FunctionFieldElement): """ EXAMPLES:: FieldElement.__init__(self, parent) self._x = x def element(self): """ Return the underlying polynomial that represents this element. EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[]; L. = K.extension(y^2 - x*y + 4*x^3) sage: f = Y/x^2 + x/(x^2+1); f 1/x^2*Y + x/(x^2 + 1) sage: f.element() 1/x^2*y + x/(x^2 + 1) sage: type(f.element()) """ return self._x def _repr_(self): """ EXAMPLES:: return self._x.padded_list(self.parent().degree()) class FunctionFieldElement_P1(FunctionFieldElement): class FunctionFieldElement_rational(FunctionFieldElement): """ EXAMPLES:: FieldElement.__init__(self, parent) self._x = x def element(self): """ Return the underlying fraction field element that represents this element. EXAMPLES:: sage: R. = FunctionField(GF(7)) sage: a.element() a sage: type(a.element()) """ return self._x def list(self): """ EXAMPLES::
• ## sage/rings/function_field/todo.txt

`diff -r 7f05bf6d613e -r ad21a9d32f99 sage/rings/function_field/todo.txt`
 a TODO: [ ] conversion back and forth between a free module over base [ ] ideals [ ] polynomial factoring of any univariate poly over a function field: reduce to bivariate over constant field? [ ] checking irreducibility in FunctionField_polymod constructor [ ] Docstring headers for each file with description of content of file [ ] copyright headers [ ] polynomial factoring of any univariate poly over a function field: reduce to bivariate over constant field? [ ] checking irreducibility in FunctionField_polymod constructor [ ] pickle doctests [ ] TestSuite(s).run() doctests [ ] ideals [ ] non-monic defining polynomials [ ] a command FunctionField to make a new function field from anything. [ ] method function_field() on algebraic curves, that give back a corresponding function field object. [ ] random element DONE: [x] conversion back and forth between a free module over base [x] random element [x] numerator, denominator [x] 100% coverage [x] matrix of element