Ticket #9054: trac_9054-part11.patch

File trac_9054-part11.patch, 12.3 KB (added by was, 7 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 b  
    2424that arithmetic with a tower of 3 fields is fully supported::
    2525
    2626    sage: S.<t> = L[]
    27     sage: M.<t> = L.extension(t^2*y - x)
     27    sage: M.<t> = L.extension(t^2 - x*y)
    2828    sage: M
    29     Function field in t defined by y*t^2 + 4*x
     29    Function field in t defined by t^2 + 4*x*y
    3030    sage: t^2
    31     (4*x^2/(4*x^4 + 4))*y^4 + 2*x^3/(4*x^4 + 4)
     31    x*y
    3232    sage: 1/t
    33     4/(4*x)*y*t
     33    ((1/(x^4 + 1))*y^4 + 2*x/(4*x^4 + 4))*t
    3434    sage: M.base_field()
    3535    Function field in y defined by y^5 + 3*x*y + (4*x^4 + 4)/x
    3636    sage: M.base_field().base_field()
     
    108108            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    109109            sage: K.extension(y^5 - x^3 - 3*x + x*y)
    110110            Function field in y defined by y^5 + x*y - x^3 - 3*x
     111
     112
     113        A nonintegral defining polynomial::
     114
     115            sage: K.<t> = FunctionField(QQ); R.<y> = K[]
     116            sage: K.extension(y^3 + (1/t)*y + t^3/(t+1))
     117            Function field in y defined by y^3 + 1/t*y + t^3/(t + 1)
     118
     119        The defining polynomial need not be monic or integral::
     120
     121            sage: K.extension(t*y^3 + (1/t)*y + t^3/(t+1))
     122            Function field in y defined by t*y^3 + 1/t*y + t^3/(t + 1)
    111123        """
    112124        if names is None:
    113125            names = f.variable_name()
     
    314326        Rational function field in x over Rational Field
    315327        sage: M.base_field().base_field().constant_field()
    316328        Rational Field
    317         sage: M.constant_field()
     329        sage: M.constant_base_field()
    318330        Rational Field
    319331    """
    320332    def __init__(self, polynomial, names, category=CAT):
     
    381393        """
    382394        return self._hash
    383395
     396    def monic_integral_model(self, names):
     397        """
     398        Return a function field isomorphic to self, but with defining
     399        polynomial that is monic and integral over the base field.
     400
     401        INPUT::
     402
     403            - ``names`` -- name of the generator of the new field this function constructs
     404
     405        EXAMPLES::
     406
     407            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     408            sage: L.<alpha> = K.extension(x^2*y^5 - 1/x); L
     409            Function field in alpha defined by x^2*y^5 - 1/x
     410            sage: A, from_A, to_A = L.monic_integral_model('beta')
     411            sage: A
     412            Function field in beta defined by y^5 - x^12
     413            sage: from_A
     414            Morphism of function fields defined by beta |--> x^3*alpha
     415            sage: to_A
     416            Morphism of function fields defined by alpha |--> 1/x^3*beta
     417            sage: to_A(alpha)
     418            1/x^3*beta
     419            sage: from_A(to_A(alpha))
     420            alpha
     421            sage: from_A(to_A(1/alpha))
     422            x^3*alpha^4
     423            sage: from_A(to_A(1/alpha)) == 1/alpha
     424            True           
     425        """
     426        g, d = self._make_monic(self.polynomial())
     427        R = self.base_field()
     428        K = R.extension(g, names=names)
     429        to_K = self.hom(K.gen() / d)
     430        from_K = K.hom(self.gen() * d)
     431        return K, from_K, to_K
     432
     433    def _make_monic(self, f):
     434        r"""
     435        Let alpha be a root of f.  This function returns a monic
     436        integral polynomial g and an element d of the base field such
     437        that g(alpha*d) = 0.
     438       
     439        EXAMPLES::
     440       
     441            sage: K.<x> = FunctionField(QQ); R.<y> = K[];
     442            sage: L.<alpha> = K.extension(x^2*y^5 - 1/x)
     443            sage: g, d = L._make_monic(L.polynomial()); g,d
     444            (y^5 - x^12, x^3)
     445            sage: g(alpha*d)
     446            0
     447        """
     448        R = f.base_ring()
     449        if not isinstance(R, RationalFunctionField):
     450            raise NotImplementedError
     451       
     452        # make f monic
     453        n = f.degree()
     454        c = f.leading_coefficient()
     455        if c != 1:
     456            f = f / c
     457
     458        # find lcm of denominators
     459        from sage.rings.arith import lcm
     460        # would be good to replace this by minimal...
     461        d = lcm([b.denominator() for b in f.list() if b])
     462        if d != 1:
     463            x = f.parent().gen()
     464            g = (d**n) * f(x/d)
     465        else:
     466            g = f
     467        return g, d
     468
    384469    def constant_field(self):
    385470        """
    386         Return the constant field of this function field.  This is
    387         simply the constant field of the base field, which this
    388         function field is a finite extension of.
     471        Return the algebraic closure of the constant field of the base
     472        field in this function field.
     473
     474        EXAMPLES::
     475
     476            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     477            sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     478            sage: L.constant_field()
     479            Traceback (most recent call last):
     480            ...
     481            NotImplementedError
     482        """
     483        raise NotImplementedError
     484
     485    def constant_base_field(self):
     486        """
     487        Return the constant field of the base rational function field.
    389488               
    390489        EXAMPLES::
    391490
    392             sage: K.<x> = FunctionField(QQ)
    393             sage: R.<y> = K[]
     491            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    394492            sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    395493            Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
    396             sage: L.constant_field()
     494            sage: L.constant_base_field()
    397495            Rational Field
    398496        """
    399         return self.base_field().constant_field()
     497        return self.base_field().constant_base_field()
    400498
    401499    def degree(self):
    402500        """
     
    639737    def equation_order(self):
    640738        """
    641739        If we view self as being presented as K[y]/(f(y)), then this
    642         function returns the order generated by the class of y.
     740        function returns the order generated by the class of y.  If f
     741        is not monic, then self._make_monic is called, and instead we
     742        get the order generated by some integral multiple of a root of
     743        alpha.
    643744       
    644745        EXAMPLES::
    645746
     
    647748            sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    648749            sage: L.equation_order()
    649750            Order in Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     751
     752        We try an example, in which the defining polynomial is not
     753        monic and is not integral::
     754
     755            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     756            sage: L.<alpha> = K.extension(x^2*y^5 - 1/x); L
     757            Function field in alpha defined by x^2*y^5 - 1/x
     758            sage: O = L.equation_order(); O
     759            Order in Function field in alpha defined by x^2*y^5 - 1/x
     760            sage: O.basis()
     761            (1, x^3*alpha, x^6*alpha^2, x^9*alpha^3, x^12*alpha^4)
    650762        """
    651         return self.order(self.gen(), check=False)
     763        d = self._make_monic(self.polynomial())[1]
     764        return self.order(d*self.gen(), check=False)
    652765   
    653766
    654767class RationalFunctionField(FunctionField):
     
    677790        Finite Field of size 7
    678791        sage: K.maximal_order()
    679792        Maximal order in Rational function field in t over Finite Field of size 7
     793
     794    We define a morphism::
     795
     796        sage: K.<W> = FunctionField(QQ)
     797        sage: L = FunctionField(QQ, 'tbar')         # give var name as second input
     798        sage: K.hom(L.gen())
     799        Morphism of function fields defined by W |--> tbar
    680800    """
    681801    def __init__(self, constant_field, names, category=CAT):
    682802        """
     
    706826        """
    707827        if names is None:
    708828            raise ValueError, "variable name must be specified"
     829        elif not isinstance(names, tuple):
     830            names = (names, )
    709831        if not constant_field.is_field():
    710832            raise TypeError, "constant_field must be a field"
    711833        ParentWithGens.__init__(self, self, names=names, category = category)
     
    9151037        EXAMPLES::
    9161038
    9171039            sage: FunctionField(QQ,'alpha').random_element()
    918             (-1/2*a^2 - 4)/(-12*a^2 + 1/2*a - 1/95)
     1040            (-1/2*alpha^2 - 4)/(-12*alpha^2 + 1/2*alpha - 1/95)
    9191041        """
    9201042        return self(self._field.random_element(*args, **kwds))
    9211043
     
    10411163            sage: K.<t> = FunctionField(QQ)
    10421164            sage: K.maximal_order()
    10431165            Maximal order in Rational function field in t over Rational Field
     1166            sage: K.equation_order()
     1167            Maximal order in Rational function field in t over Rational Field
    10441168        """
    10451169        try: return self._maximal_order
    10461170        except AttributeError:
     
    10481172            self._maximal_order = FunctionFieldOrder_rational(self)
    10491173            return self._maximal_order
    10501174
    1051     def constant_field(self):
     1175    equation_order = maximal_order
     1176
     1177    def constant_base_field(self):
    10521178        """
    10531179        Return the field that this rational function field is a
    10541180        transcendental extension of.
     
    10611187        """
    10621188        return self._constant_field
    10631189
    1064 
     1190    constant_field = constant_base_field
    10651191
    10661192
    10671193       
  • sage/rings/function_field/maps.py

    diff -r 895c087105d6 -r fc499898d657 sage/rings/function_field/maps.py
    a b  
    55from sage.categories.map import Map
    66from sage.categories.homset import Hom
    77
     8from function_field_order import FunctionFieldOrder
     9
    810class FunctionFieldIsomorphism(Map):
    911    r"""
    1012    A base class for various isomorphisms between function fields and
     
    307309        Map.__init__(self, parent)
    308310        self._im_gen = im_gen
    309311        self._base_morphism = None
    310        
     312
    311313    def _call_(self, x):
    312314        """
    313315        EXAMPLES::
  • sage/rings/function_field/todo.txt

    diff -r 895c087105d6 -r fc499898d657 sage/rings/function_field/todo.txt
    a b  
    11TODO:
    22
    3 [ ] Hess's RR spaces algorithm
    4 [ ] factoring polynomials in n variables over rational function field
     3[ ] copyright headers
     4[ ] Docstring headers for each file with description of content of file
     5[ ] picling elements
    56
    6 [ ] reduction algorithm
    7 [ ] new implementation of the function field API using Singular; for *speed*, but with less base rings supported...?
     7[ ] RR space algorithm
     8
     9[ ] implement denominator in general, which is a guaranteed multiple of the denominator
     10    only when not pid...
     11[ ] reduction of divisors: algorithm
    812[ ] polynomial factoring of any univariate poly over a non-rational function field
    9 
    1013[ ] checking irreducibility in FunctionField_polymod constructor
    11 [ ] Docstring headers for each file with description of content of file
    12 [ ] copyright headers
    1314[ ] pickle doctests
    1415[ ] TestSuite(s).run() doctests
    15 [ ] non-monic defining polynomials
    16 [ ] a command FunctionField to make a new function field from anything.
    1716[ ] method function_field() on algebraic curves, that give back a corresponding function field object.
    18 
     17[ ] compute maximal separable subfield (requested by Voloch)
     18[ ] factoring polynomials in n variables over rational function field
     19[ ] x.valuation(...)  [bradshaw will do this]
     20[ ] optimization: new implementation of the function field API, but
     21    using multivariate poly rings in some cases; for *speed*, but with
     22    less base rings supported...?
    1923
    2024DONE:
     25[x] phi = morphism; phi(order); phi(ideal) --- won't do, since image of order or ideal often isn't one
     26    for general morphisms
     27[x] a command FunctionField to make a new function field from anything.
     28[x] constant_base_field versus constant_field
     29[x] fix when asking for equation order if defining polynomial not *integral*
     30[x] non-monic defining polynomials
     31[x] do not require defining polynomial to be monic
     32[x] issue with *underscores* and singular:
     33K.<t_ba> = FunctionField(QQ)
     34R.<u_ba> = K[]
     35L.<u_ba> = K.extension(u_ba^2 - t_ba)
     36L.equation_order()
     37BOOM!
     38
    2139[x] isomorphisms between function fields:
    2240     K.hom([top gen, next one down, etc.])
    2341    make sure you include easy way to gens all the way down.