Ticket #9054: trac_9054-part11.patch

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

# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1275102704 25200
# Node ID fc499898d65740ebf6dde302176c3d94c17f964a
# Parent  895c087105d68eb942c643bd078c17cc26480136
trac 9054 -- part 11: misc fixes; integrality, etc.

diff -r 895c087105d6 -r fc499898d657 sage/rings/function_field/function_field.py
 a that arithmetic with a tower of 3 fields is fully supported:: sage: S. = L[] sage: M. = L.extension(t^2*y - x) sage: M. = L.extension(t^2 - x*y) sage: M Function field in t defined by y*t^2 + 4*x Function field in t defined by t^2 + 4*x*y sage: t^2 (4*x^2/(4*x^4 + 4))*y^4 + 2*x^3/(4*x^4 + 4) x*y sage: 1/t 4/(4*x)*y*t ((1/(x^4 + 1))*y^4 + 2*x/(4*x^4 + 4))*t sage: M.base_field() Function field in y defined by y^5 + 3*x*y + (4*x^4 + 4)/x sage: M.base_field().base_field() sage: K. = FunctionField(QQ); R. = K[] sage: K.extension(y^5 - x^3 - 3*x + x*y) Function field in y defined by y^5 + x*y - x^3 - 3*x A nonintegral defining polynomial:: sage: K. = FunctionField(QQ); R. = K[] sage: K.extension(y^3 + (1/t)*y + t^3/(t+1)) Function field in y defined by y^3 + 1/t*y + t^3/(t + 1) The defining polynomial need not be monic or integral:: sage: K.extension(t*y^3 + (1/t)*y + t^3/(t+1)) Function field in y defined by t*y^3 + 1/t*y + t^3/(t + 1) """ if names is None: names = f.variable_name() Rational function field in x over Rational Field sage: M.base_field().base_field().constant_field() Rational Field sage: M.constant_field() sage: M.constant_base_field() Rational Field """ def __init__(self, polynomial, names, category=CAT): """ return self._hash def monic_integral_model(self, names): """ Return a function field isomorphic to self, but with defining polynomial that is monic and integral over the base field. INPUT:: - ``names`` -- name of the generator of the new field this function constructs EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(x^2*y^5 - 1/x); L Function field in alpha defined by x^2*y^5 - 1/x sage: A, from_A, to_A = L.monic_integral_model('beta') sage: A Function field in beta defined by y^5 - x^12 sage: from_A Morphism of function fields defined by beta |--> x^3*alpha sage: to_A Morphism of function fields defined by alpha |--> 1/x^3*beta sage: to_A(alpha) 1/x^3*beta sage: from_A(to_A(alpha)) alpha sage: from_A(to_A(1/alpha)) x^3*alpha^4 sage: from_A(to_A(1/alpha)) == 1/alpha True """ g, d = self._make_monic(self.polynomial()) R = self.base_field() K = R.extension(g, names=names) to_K = self.hom(K.gen() / d) from_K = K.hom(self.gen() * d) return K, from_K, to_K def _make_monic(self, f): r""" Let alpha be a root of f.  This function returns a monic integral polynomial g and an element d of the base field such that g(alpha*d) = 0. EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[]; sage: L. = K.extension(x^2*y^5 - 1/x) sage: g, d = L._make_monic(L.polynomial()); g,d (y^5 - x^12, x^3) sage: g(alpha*d) 0 """ R = f.base_ring() if not isinstance(R, RationalFunctionField): raise NotImplementedError # make f monic n = f.degree() c = f.leading_coefficient() if c != 1: f = f / c # find lcm of denominators from sage.rings.arith import lcm # would be good to replace this by minimal... d = lcm([b.denominator() for b in f.list() if b]) if d != 1: x = f.parent().gen() g = (d**n) * f(x/d) else: g = f return g, d def constant_field(self): """ Return the constant field of this function field.  This is simply the constant field of the base field, which this function field is a finite extension of. Return the algebraic closure of the constant field of the base field in this function field. EXAMPLES:: sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^5 - (x^3 + 2*x*y + 1/x)) sage: L.constant_field() Traceback (most recent call last): ... NotImplementedError """ raise NotImplementedError def constant_base_field(self): """ Return the constant field of the base rational function field. EXAMPLES:: sage: K. = FunctionField(QQ) sage: R. = K[] sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x sage: L.constant_field() sage: L.constant_base_field() Rational Field """ return self.base_field().constant_field() return self.base_field().constant_base_field() def degree(self): """ def equation_order(self): """ If we view self as being presented as K[y]/(f(y)), then this function returns the order generated by the class of y. function returns the order generated by the class of y.  If f is not monic, then self._make_monic is called, and instead we get the order generated by some integral multiple of a root of alpha. EXAMPLES:: sage: L. = K.extension(y^5 - (x^3 + 2*x*y + 1/x)) sage: L.equation_order() Order in Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x We try an example, in which the defining polynomial is not monic and is not integral:: sage: K. = FunctionField(QQ); R. = K[] sage: L. = K.extension(x^2*y^5 - 1/x); L Function field in alpha defined by x^2*y^5 - 1/x sage: O = L.equation_order(); O Order in Function field in alpha defined by x^2*y^5 - 1/x sage: O.basis() (1, x^3*alpha, x^6*alpha^2, x^9*alpha^3, x^12*alpha^4) """ return self.order(self.gen(), check=False) d = self._make_monic(self.polynomial()) return self.order(d*self.gen(), check=False) class RationalFunctionField(FunctionField): Finite Field of size 7 sage: K.maximal_order() Maximal order in Rational function field in t over Finite Field of size 7 We define a morphism:: sage: K. = FunctionField(QQ) sage: L = FunctionField(QQ, 'tbar')         # give var name as second input sage: K.hom(L.gen()) Morphism of function fields defined by W |--> tbar """ def __init__(self, constant_field, names, category=CAT): """ """ if names is None: raise ValueError, "variable name must be specified" elif not isinstance(names, tuple): names = (names, ) if not constant_field.is_field(): raise TypeError, "constant_field must be a field" ParentWithGens.__init__(self, self, names=names, category = category) EXAMPLES:: sage: FunctionField(QQ,'alpha').random_element() (-1/2*a^2 - 4)/(-12*a^2 + 1/2*a - 1/95) (-1/2*alpha^2 - 4)/(-12*alpha^2 + 1/2*alpha - 1/95) """ return self(self._field.random_element(*args, **kwds)) sage: K. = FunctionField(QQ) sage: K.maximal_order() Maximal order in Rational function field in t over Rational Field sage: K.equation_order() Maximal order in Rational function field in t over Rational Field """ try: return self._maximal_order except AttributeError: self._maximal_order = FunctionFieldOrder_rational(self) return self._maximal_order def constant_field(self): equation_order = maximal_order def constant_base_field(self): """ Return the field that this rational function field is a transcendental extension of. """ return self._constant_field constant_field = constant_base_field
• sage/rings/function_field/maps.py

diff -r 895c087105d6 -r fc499898d657 sage/rings/function_field/maps.py
 a from sage.categories.map import Map from sage.categories.homset import Hom from function_field_order import FunctionFieldOrder class FunctionFieldIsomorphism(Map): r""" A base class for various isomorphisms between function fields and Map.__init__(self, parent) self._im_gen = im_gen self._base_morphism = None def _call_(self, x): """ EXAMPLES::
• sage/rings/function_field/todo.txt

diff -r 895c087105d6 -r fc499898d657 sage/rings/function_field/todo.txt
 a TODO: [ ] Hess's RR spaces algorithm [ ] factoring polynomials in n variables over rational function field [ ] copyright headers [ ] Docstring headers for each file with description of content of file [ ] picling elements [ ] reduction algorithm [ ] new implementation of the function field API using Singular; for *speed*, but with less base rings supported...? [ ] RR space algorithm [ ] implement denominator in general, which is a guaranteed multiple of the denominator only when not pid... [ ] reduction of divisors: algorithm [ ] polynomial factoring of any univariate poly over a non-rational function field [ ] checking irreducibility in FunctionField_polymod constructor [ ] Docstring headers for each file with description of content of file [ ] copyright headers [ ] pickle doctests [ ] TestSuite(s).run() doctests [ ] 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. [ ] compute maximal separable subfield (requested by Voloch) [ ] factoring polynomials in n variables over rational function field [ ] x.valuation(...)  [bradshaw will do this] [ ] optimization: new implementation of the function field API, but using multivariate poly rings in some cases; for *speed*, but with less base rings supported...? DONE: [x] phi = morphism; phi(order); phi(ideal) --- won't do, since image of order or ideal often isn't one for general morphisms [x] a command FunctionField to make a new function field from anything. [x] constant_base_field versus constant_field [x] fix when asking for equation order if defining polynomial not *integral* [x] non-monic defining polynomials [x] do not require defining polynomial to be monic [x] issue with *underscores* and singular: K. = FunctionField(QQ) R. = K[] L. = K.extension(u_ba^2 - t_ba) L.equation_order() BOOM! [x] isomorphisms between function fields: K.hom([top gen, next one down, etc.]) make sure you include easy way to gens all the way down.