Ticket #9054: trac_9054-julian-combined.patch

File trac_9054-julian-combined.patch, 132.1 KB (added by mderickx, 6 years ago)

All julians patches after review.patch combined

  • new file doc/en/reference/function_fields.rst

    # HG changeset patch
    # User Maarten Derickx <m.derickx.student@gmail.com>
    # Date 1320603921 28800
    # Node ID e9358921aa011e6d19abdcf60337ead44f405d57
    # Parent  a479b7fa72f6bd30898111360d67c9df7971f3db
    * * *
    Trac 9054: undo changes to misc.unittest
    * * *
    #9054 fix jullians last comment
    * * *
    Trac 9054: check category in is_FunctionField()
    * * *
    Trac 9054: use UniqueFactory instead of cached_method in constructors
    * * *
    Trac 9054: use cached_method decorator
    * * *
    Trac 9054: check that elements are in maximal order
    * * *
    Trac 9054: added missing calls to super constructors
    * * *
    Trac 9054: refactored maps class hierarchy
    * * *
    Trac 9054: fixed and extended doctests. unified names of variables. added docs to reference manual
    * * *
    Trac 9054: cleanup code and imports
    * * *
    Trac 9054: authors and copyrights
    * * *
    Trac 9054: fixes in the reference manual
    * * *
    Trac 9054: fixes an AttributeError in factor()
    * * *
    Trac 9054: category for function field orders
    
    diff --git a/doc/en/reference/function_fields.rst b/doc/en/reference/function_fields.rst
    new file mode 100644
    - +  
     1Algebraic Function Fields
     2=========================
     3
     4.. toctree::
     5   :maxdepth: 2
     6
     7   sage/rings/function_field/function_field
     8   sage/rings/function_field/function_field_element
     9   sage/rings/function_field/function_field_order
     10   sage/rings/function_field/function_field_ideal
     11   sage/rings/function_field/maps
     12   sage/rings/function_field/constructor
  • doc/en/reference/index.rst

    diff --git a/doc/en/reference/index.rst b/doc/en/reference/index.rst
    a b  
    7171   rings_standard
    7272   rings_numerical
    7373   number_fields
     74   function_fields
    7475   padics
    7576   polynomial_rings
    7677   power_series
  • sage/categories/function_fields.py

    diff --git a/sage/categories/function_fields.py b/sage/categories/function_fields.py
    a b  
    11r"""
    2 FunctionFields
     2Function fields
    33"""
    44#*****************************************************************************
    55#  Copyright (C) 2005      David Kohel <kohel@maths.usyd.edu>
     
    3030    TESTS::
    3131
    3232        sage: TestSuite(FunctionFields()).run()
    33 
    3433    """
    35 
    3634    @cached_method
    3735    def super_categories(self):
    3836        """
     
    4341
    4442            sage: FunctionFields().super_categories()
    4543            [Category of fields]
    46 
    4744        """
    4845        return[Fields()]
    4946
    50 
    5147    def _call_(self, x):
    5248        r"""
    5349        Constructs an object in this category from the data in ``x``,
     
    6561            Function field in y defined by y^2 - x
    6662            sage: C(L.equation_order())
    6763            Function field in y defined by y^2 - x
    68            
    69 
    7064        """
    7165        try:
    7266            return x.function_field()
    7367        except AttributeError:
    7468            raise  TypeError, "unable to canonically associate a function field to %s"%x
    7569
    76 
    7770    class ParentMethods:
    7871        pass
    7972
  • sage/misc/sage_unittest.py

    diff --git a/sage/misc/sage_unittest.py b/sage/misc/sage_unittest.py
    a b  
    1313import unittest
    1414import sys
    1515import traceback
    16 import misc
    1716
    1817class TestSuite(object):
    1918    """
     
    255254        In conjonction with ``%pdb on``, this allows for the debbuger
    256255        to jump directly to the first failure location.
    257256        """
    258         time = options.get('cputime')
    259257        if type(skip) == str:
    260258            skip = [skip]
    261259        else:
     
    272270                # TODO: improve pretty printing
    273271                # could use the doc string of the test method?
    274272                tester.info(tester._prefix+"running .%s() . . ."%method_name, newline = False)
    275                 if time:
    276                     start_time = misc.cputime()
    277273                test_method = getattr(self._instance, method_name)
    278274                try:
    279275                    test_method(tester = tester)
    280                     tester.info(" pass", newline = not time)
    281                     if time:
    282                         tester.info(", cputime: %f"%misc.cputime(start_time))
     276                    tester.info(" pass")
    283277                except catch_exception as e:
    284278                    failed.append(method_name)
    285279                    if isinstance(e, TestSuiteFailure):
  • sage/rings/function_field/__init__.py

    diff --git a/sage/rings/function_field/__init__.py b/sage/rings/function_field/__init__.py
    a b  
    1 # Function fields
  • sage/rings/function_field/all.py

    diff --git a/sage/rings/function_field/all.py b/sage/rings/function_field/all.py
    a b  
    11from constructor import FunctionField
    2 
    3 
  • sage/rings/function_field/constructor.py

    diff --git a/sage/rings/function_field/constructor.py b/sage/rings/function_field/constructor.py
    a b  
    1 import function_field
    2 from sage.misc.cachefunc import cached_function
    3 from sage.misc.decorators import sage_wraps
     1r"""
     2Factories to construct Function Fields
    43
     4AUTHORS:
    55
    6 def FunctionField(X,names):
     6    - William Stein (2010): initial version
     7
     8    - Maarten Derickx (2011-09-11): added FunctionField_polymod_Constructor, use @cached_function
     9
     10    - Julian Rueth (2011-09-14): replaced @cached_function with UniqueFactory
     11
     12EXAMPLES::
     13
     14    sage: K.<x> = FunctionField(QQ); K
     15    Rational function field in x over Rational Field
     16    sage: L.<x> = FunctionField(QQ); L
     17    Rational function field in x over Rational Field
     18    sage: K is L
     19    True
     20"""
     21#*****************************************************************************
     22#       Copyright (C) 2010 William Stein <wstein@gmail.com>
     23#       Copyright (C) 2011 Maarten Derickx <m.derickx.student@gmail.com>
     24#       Copyright (C) 2011 Julian Rueth <julian.rueth@gmail.com>
     25#
     26#  Distributed under the terms of the GNU General Public License (GPL)
     27#  as published by the Free Software Foundation; either version 2 of
     28#  the License, or (at your option) any later version.
     29#                  http://www.gnu.org/licenses/
     30#*****************************************************************************
     31
     32from sage.structure.factory import UniqueFactory
     33
     34class FunctionFieldFactory(UniqueFactory):
    735    """
    8     Return the function field in one variable with constant field X. The function
    9     field returned is unique in the sence that if you call this function twice
     36    Return the function field in one variable with constant field ``F``. The function
     37    field returned is unique in the sense that if you call this function twice
    1038    with the same base field and name then you get the same python object back.
    1139
    1240    INPUT:
    1341
    14         - `X` -- a field; return the function field in one variable over X.
    15 
     42        - ``F`` -- a field
    1643        - ``names`` -- name of variable as a string or a tuple containg a string
    1744   
    1845    EXAMPLES::
    1946
    20         sage: FunctionField(QQ,'alpha')
    21         Rational function field in alpha over Rational Field
    22         sage: K.<alpha> = FunctionField(GF(7)); K
    23         Rational function field in alpha over Finite Field of size 7
     47        sage: K.<x> = FunctionField(QQ); K
     48        Rational function field in x over Rational Field
     49        sage: L.<y> = FunctionField(GF(7)); L
     50        Rational function field in y over Finite Field of size 7
     51        sage: R.<z> = L[]
     52        sage: M.<z> = L.extension(z^7-z-y); M
     53        Function field in z defined by z^7 + 6*z + 6*y
     54
     55    TESTS::
     56
     57        sage: K.<x> = FunctionField(QQ)
     58        sage: L.<x> = FunctionField(QQ)
     59        sage: K is L
     60        True
     61        sage: M.<x> = FunctionField(GF(7))
     62        sage: K is M
     63        False
     64        sage: N.<y> = FunctionField(QQ)
     65        sage: K is N
     66        False
    2467    """
    25     if not isinstance(names,tuple):
    26         names = (names,)
    27     return _FunctionField(X,names)
     68    def create_key(self, F, names):
     69        if not isinstance(names,tuple):
     70            names = (names,)
     71        return (F,names)
    2872
     73    def create_object(self, version, key, **extra_args):
     74        from function_field import RationalFunctionField
     75        return RationalFunctionField(key[0], names=key[1])
    2976
    30 @cached_function
    31 def _FunctionField(X, names):
     77FunctionField = FunctionFieldFactory("FunctionField")
     78
     79class FunctionFieldPolymodFactory(UniqueFactory):
    3280    """
    33     Does exactly the same as FunctionField, but with the disadvantage that it
    34     cannot be used for Pickling since it is decorated.
     81    Create a function field defined as an extension of another
     82    function field by adjoining a root of a univariate polynomial.
     83    The returned function field is unique in the sense that if you
     84    call this function twice with an equal ``polynomial`` and ``names``
     85    it returns the same python object in both calls.
    3586
    3687    INPUT:
    3788
    38         - `X` -- a field; return the function field in one variable over X.
    39 
    40         - ``names`` -- name of variable as a string
    41    
    42     EXAMPLES::
    43 
    44         sage: FunctionField(QQ,'alpha')
    45         Rational function field in alpha over Rational Field
    46         sage: K.<alpha> = FunctionField(GF(7)); K
    47         Rational function field in alpha over Finite Field of size 7
    48 
    49     """
    50     return function_field.RationalFunctionField(X, names=names)
    51 
    52 
    53 def FunctionField_polymod_Constructor(polynomial, names):
    54     """
    55     Constructs a FunctionField_polymod instance. This function takes care
    56     that it's unique.
    57 
     89        - ``polynomial`` -- a univariate polynomial over a function field
     90        - ``names`` -- variable names (as a tuple of length 1 or string)
     91        - ``category`` -- a category (defaults to category of function fields)
     92       
    5893    EXAMPLES::
    5994
    6095        sage: K.<x> = FunctionField(QQ)
     
    66101        sage: M.<w>=K.extension(x-y2^2) #indirect doctest
    67102        sage: L is M
    68103        True
    69    
    70104    """
    71     from sage.rings.polynomial.all import is_Polynomial
    72     if polynomial.parent().ngens()>1 or not is_Polynomial(polynomial):
    73         raise TypeError, "polynomial must be univariate a polynomial"
    74     if names is None:
    75         names = (polynomial.variable_name(), )
    76     if not isinstance(names,tuple):
    77         names = (names,)
    78     return _FunctionField_polymod_Constructor(polynomial, names)
     105    def create_key(self, polynomial, names):
     106        if names is None:
     107            names = polynomial.variable_name()
     108        if not isinstance(names,tuple):
     109            names = (names,)
     110        return (polynomial,names)
    79111
    80 @cached_function
    81 def _FunctionField_polymod_Constructor(polynomial, names):
    82     """
    83     Does exactly the same as FunctionField_polymod, but with the disadvantage that it
    84     cannot be used for Pickling since it is decorated.
     112    def create_object(self, version, key, **extra_args):
     113        from function_field import FunctionField_polymod
     114        return FunctionField_polymod(key[0], names=key[1])
    85115
    86    
    87     EXAMPLES::
    88 
    89         sage: K.<x> = FunctionField(QQ)
    90         sage: R.<y>=K[]
    91         sage: y2 = y*1
    92         sage: y2 is y
    93         False
    94         sage: L.<w>=K.extension(x-y^2) #indirect doctest
    95         sage: M.<w>=K.extension(x-y2^2) #indirect doctest
    96         sage: L is M
    97         True
    98    
    99 
    100     """
    101     return function_field.FunctionField_polymod(polynomial, names)
    102    
     116FunctionField_polymod = FunctionFieldPolymodFactory("FunctionField_polymod")
  • sage/rings/function_field/function_field.py

    diff --git a/sage/rings/function_field/function_field.py b/sage/rings/function_field/function_field.py
    a b  
    11r"""
    2 Function fields
     2Function Fields
    33
    4 EXAMPLES::
     4AUTHORS:
     5
     6- William Stein (2010): initial version
     7
     8- Robert Bradshaw (2010-05-30): added is_finite()
     9
     10- Julian Rueth (2011-06-08): fixed hom(), extension()
     11
     12- Maarten Derickx (2011-09-11): added doctests
     13
     14- Julian Rueth (2011-09-14): use @cached_method
     15
     16EXAMPLES:
    517
    618We create an extension of a rational function fields, and do some
    719simple arithmetic in it::
     
    4153    sage: TestSuite(K).run() #long time
    4254    sage: TestSuite(L).run() #long time
    4355    sage: TestSuite(M).run() #long time
    44     
    45 The following tow test suites do not pass '_test_elements' yet since
    46 R.an_element() has a _test_category method wich it should not have.
     56 
     57The following two test suites do not pass ``_test_elements`` yet since
     58``R.an_element()`` has a ``_test_category`` method wich it should not have.
    4759It is not the fault of the function field code so this will
    48 be fixed in another ticket.
     60be fixed in another ticket::
     61
    4962    sage: TestSuite(R).run(skip = '_test_elements') #long time
    5063    sage: TestSuite(S).run(skip = '_test_elements') #long time
     64"""
     65#*****************************************************************************
     66#       Copyright (C) 2010 William Stein <wstein@gmail.com>
     67#       Copyright (C) 2010 Robert Bradshaw <robertwb@math.washington.edu>
     68#       Copyright (C) 2011 Julian Rueth <julian.rueth@gmail.com>
     69#       Copyright (C) 2011 Maarten Derickx <m.derickx.student@gmail.com>
     70#
     71#  Distributed under the terms of the GNU General Public License (GPL)
     72#  as published by the Free Software Foundation; either version 2 of
     73#  the License, or (at your option) any later version.
     74#                  http://www.gnu.org/licenses/
     75#*****************************************************************************
    5176
    52    
    53 """
     77from sage.rings.ring import Field
     78from function_field_element import FunctionFieldElement, FunctionFieldElement_rational, FunctionFieldElement_polymod
    5479
    55 from sage.structure.category_object import CategoryObject
    56 from sage.rings.ring import Field
    57 from sage.rings.integer_ring import ZZ
    58 from sage.structure.parent_gens import ParentWithGens
    59 from sage.structure.parent import Parent
    60 import function_field_element
    61 import constructor
     80from sage.misc.cachefunc import cached_method
     81
    6282from sage.categories.function_fields import FunctionFields
    6383CAT = FunctionFields()
    6484
    65 import maps
    66 
    6785def is_FunctionField(x):
    6886    """
    69     Return True if x is of function field type.
     87    Return True if ``x`` is of function field type.
    7088
    7189    EXAMPLES::
    7290   
     
    7694        sage: is_FunctionField(FunctionField(QQ,'t'))
    7795        True
    7896    """
    79     return isinstance(x, FunctionField)
    80 
     97    if isinstance(x, FunctionField): return True
     98    return x in FunctionFields()
    8199
    82100class FunctionField(Field):
    83101    """
     
    90108        True
    91109    """
    92110    def some_elements(self):
    93          #the number of ellements could be made bigger late rbut right now the
    94          #TestSuite(F).run() take to long with more elements.
    95          return (self.random_element() for i in xrange(3))
     111         """
     112         Return a list of elements in the function field.
     113
     114         EXAMPLES::
     115
     116            sage: K.<x> = FunctionField(QQ)
     117            sage: elements = K.some_elements()
     118            sage: elements # random output
     119            [(x - 3/2)/(x^2 - 12/5*x + 1/18)]
     120            sage: False in [e in K for e in elements]
     121            False
     122         """
     123         return [self.random_element()]
    96124
    97125    def characteristic(self):
    98126        """
     
    105133            0
    106134            sage: R.<t> = FunctionField(GF(7))
    107135            sage: R.characteristic()
    108             7       
     136            7
    109137        """
    110138        return self.constant_field().characteristic()
    111139   
     
    132160
    133161        INPUT:
    134162       
    135             - `f` -- a univariate polynomial over self
     163            - ``f`` -- a univariate polynomial over self
    136164            - ``names`` -- None or string or length-1 tuple
    137165
    138166        OUTPUT:
     
    156184            sage: K.extension(t*y^3 + (1/t)*y + t^3/(t+1))
    157185            Function field in y defined by t*y^3 + 1/t*y + t^3/(t + 1)
    158186        """
    159         return constructor.FunctionField_polymod_Constructor(f, names)
     187        from constructor import FunctionField_polymod as FunctionField_polymod_Constructor
     188        return FunctionField_polymod_Constructor(f, names)
    160189
    161190    def order_with_basis(self, basis, check=True):
    162191        """
     
    177206
    178207        EXAMPLES::
    179208
    180             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^3 + x^3 + 4*x + 1)
    181             sage: O = L.order_with_basis([1, Y, Y^2]); O
    182             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     209            sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<y> = K.extension(y^3 + x^3 + 4*x + 1)
     210            sage: O = L.order_with_basis([1, y, y^2]); O
     211            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    183212            sage: O.basis()
    184             (1, Y, Y^2)
     213            (1, y, y^2)
    185214
    186215        Note that 1 does not need to be an element of the basis, as long it is in the module spanned by it::
    187216
    188             sage: O = L.order_with_basis([1+Y, Y, Y^2]); O
    189             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     217            sage: O = L.order_with_basis([1+y, y, y^2]); O
     218            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    190219            sage: O.basis()
    191             (Y + 1, Y, Y^2)
     220            (y + 1, y, y^2)
    192221       
    193 
    194222        The following error is raised when the module spanned by the basis is not closed under multiplication::
    195223
    196             sage: O = L.order_with_basis([1, x^2 + x*Y, (2/3)*Y^2]); O
     224            sage: O = L.order_with_basis([1, x^2 + x*y, (2/3)*y^2]); O
    197225            Traceback (most recent call last):
    198226            ...
    199             ValueError: The module generated by basis [1, x*Y + x^2, 2/3*Y^2] must be closed under multiplication
     227            ValueError: The module generated by basis [1, x*y + x^2, 2/3*y^2] must be closed under multiplication
    200228           
    201229        and this happens when the identity is not in the module spanned by the basis::
    202230
    203             sage: O = L.order_with_basis([x, x^2 + x*Y, (2/3)*Y^2])
     231            sage: O = L.order_with_basis([x, x^2 + x*y, (2/3)*y^2])
    204232            Traceback (most recent call last):
    205233            ...
    206             ValueError: The identity element must be in the module spanned by basis [x, x*Y + x^2, 2/3*Y^2]
    207            
    208 
     234            ValueError: The identity element must be in the module spanned by basis [x, x*y + x^2, 2/3*y^2]
    209235        """
    210236        from function_field_order import FunctionFieldOrder_basis
    211237        return FunctionFieldOrder_basis([self(a) for a in basis], check=check)
     
    223249
    224250        EXAMPLES::
    225251
    226             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^3 + x^3 + 4*x + 1)
    227             sage: O = L.order(Y); O
    228             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     252            sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<y> = K.extension(y^3 + x^3 + 4*x + 1)
     253            sage: O = L.order(y); O
     254            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    229255            sage: O.basis()
    230             (1, Y, Y^2)
     256            (1, y, y^2)
    231257
    232258            sage: Z = K.order(x); Z
    233259            Order in Rational function field in x over Rational Field
     
    258284
    259285        EXAMPLES::
    260286
    261             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^3 + x^3 + 4*x + 1)
     287            sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<y> = K.extension(y^3 + x^3 + 4*x + 1)
    262288            sage: L.equation_order()
    263             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     289            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    264290            sage: L._coerce_map_from_(L.equation_order())
    265291            True
    266292            sage: L._coerce_map_from_(GF(7))
     
    271297            return True
    272298        return False
    273299
    274     def hom(self, im_gens, base_morphism=None):
    275         """
    276         Create a homomorphism from self to another function field.
    277        
    278         INPUT:
    279 
    280            - ``im_gens`` -- a list of images of the generators of self
    281              and of successive base rings.
    282            
    283            - ``base_morphism`` -- (default: None) a homomorphism of
    284              the base ring, after the im_gens are used.  Thus if
    285              im_gens has length 2, then base_morphism should be a morphism
    286              from self.base_ring().base_ring().
    287 
    288         EXAMPLES::
    289        
    290         We create a rational function field, and a quadratic extension of it::
    291        
    292             sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    293             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    294 
    295         We make the field automorphism that sends y to -y::
    296        
    297             sage: f = L.hom(-y); f
    298             Morphism of function fields defined by y |--> -y
    299 
    300         Evaluation works::
    301        
    302             sage: f(y*x - 1/x)
    303             -x*y - 1/x
    304 
    305         We try to define an invalid morphism::
    306        
    307             sage: f = L.hom(y+1); f
    308             Traceback (most recent call last):
    309             ...
    310             ValueError: invalid morphism
    311 
    312         We make a morphism of the base rational function field::
    313        
    314             sage: phi = R.hom(x+1); phi
    315             Morphism of function fields defined by x |--> x + 1
    316             sage: phi(x^3 - 3)
    317             x^3 + 3*x^2 + 3*x - 2
    318             sage: (x+1)^3-3
    319             x^3 + 3*x^2 + 3*x - 2
    320 
    321         We make a morphism by specifying where the generators and the
    322         base generators go::
    323        
    324             sage: L.hom([-y, x])
    325             Morphism of function fields defined by y |--> -y,  x |--> x
    326 
    327         The usage of the keyword base_morphism is not implemented yet::
    328 
    329             sage: L.hom([-y, x-1], base_morphism=phi)
    330             Traceback (most recent call last):
    331             ...
    332             NotImplementedError: Function field homorphisms with optional argument base_morphism are not implemented yet. Please specify the images of the generators of the base fields manually.
    333            
    334                
    335         We make another extension of a rational function field::
    336        
    337             sage: R2.<t> = FunctionField(QQ); S2.<w> = R2[]
    338             sage: L2.<w> = R2.extension((4*w)^2 - (t+1)^3 - 1)
    339 
    340         We define a morphism, by giving the images of generators::
    341        
    342             sage: f = L.hom([4*w, t+1]); f
    343             Morphism of function fields defined by y |--> 4*w,  x |--> t + 1
    344 
    345         Evaluation works, as expected::
    346        
    347             sage: f(y+x)
    348             4*w + t + 1
    349             sage: f(x*y + x/(x^2+1))
    350             (4*t + 4)*w + (t + 1)/(t^2 + 2*t + 2)
    351 
    352         We make another extension of a rational function field::
    353 
    354             sage: R3.<yy> = FunctionField(QQ); S3.<xx> = R3[]
    355             sage: L3.<xx> = R3.extension(yy^2 - xx^3 - 1)
    356 
    357         This is the function field L with the generators exchanged. We define a morphism to L::
    358 
    359             sage: g = L3.hom([x,y]); g
    360             Morphism of function fields defined by xx |--> x, yy |--> y
    361 
    362         """
    363         if base_morphism is not None:
    364             raise NotImplementedError, "Function field homorphisms with optional argument base_morphism are not implemented yet. Please specify the images of the generators of the base fields manually." 
    365        
    366         if not isinstance(im_gens, (list,tuple)):
    367             im_gens = [im_gens]
    368         if len(im_gens) == 0:
    369             raise ValueError, "no images specified"
    370    
    371         if len(im_gens) > 1:
    372             base_morphism = self.base_field().hom(im_gens[1:], base_morphism)
    373 
    374         # the codomain of this morphism is the field containing all the im_gens
    375         codomain = im_gens[0].parent();
    376         if base_morphism is not None:
    377             if base_morphism.codomain().has_coerce_map_from(codomain):
    378                 codomain = base_morphism.codomain();
    379 
    380         return maps.FunctionFieldMorphism(self.Hom(codomain), im_gens[0], base_morphism)
    381 
    382300class FunctionField_polymod(FunctionField):
    383301    """
    384302    A function field defined by a univariate polynomial, as an
    385303    extension of the base field.
    386304   
    387     EXAMPLES::
     305    EXAMPLES:
    388306
    389307    We make a function field defined by a degree 5 polynomial over the
    390308    rational function field over the rational numbers::
    391309   
    392310        sage: K.<x> = FunctionField(QQ)
    393311        sage: R.<y> = K[]
    394         sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    395         Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     312        sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     313        Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    396314
    397315    We next make a function field over the above nontrivial function
    398316    field L::
    399317
    400         sage: S.<T> = L[]
    401         sage: M.<alpha> = L.extension(T^2 + w*T + y); M
    402         Function field in alpha defined by T^2 + w*T + w
    403         sage: 1/alpha
    404         ((x/(-x^4 - 1))*w^4 - 2*x^2/(-x^4 - 1))*alpha - 1
    405         sage: alpha * (1/alpha)
     318        sage: S.<z> = L[]
     319        sage: M.<z> = L.extension(z^2 + y*z + y); M
     320        Function field in z defined by z^2 + y*z + y
     321        sage: 1/z
     322        ((x/(-x^4 - 1))*y^4 - 2*x^2/(-x^4 - 1))*z - 1
     323        sage: z * (1/z)
    406324        1
    407325
    408326    We drill down the tower of function fields::
    409327   
    410328        sage: M.base_field()
    411         Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     329        Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    412330        sage: M.base_field().base_field()
    413331        Rational function field in x over Rational Field
    414332        sage: M.base_field().base_field().constant_field()
     
    418336
    419337    .. WARNING::
    420338
    421         It is not checked if the polynomial used to define this function field is irriducible
     339        It is not checked if the polynomial used to define this function field is irreducible
    422340        Hence it is not guaranteed that this object really is a field!
    423341        This is illustrated below.
    424342
     
    426344
    427345        sage: K.<x>=FunctionField(QQ)
    428346        sage: R.<y> = K[]
    429         sage: L.<w>=K.extension(x^2-y^2)
    430         sage: (w-x)*(w+x)
     347        sage: L.<y>=K.extension(x^2-y^2)
     348        sage: (y-x)*(y+x)
    431349        0
    432         sage: 1/(w-x)
     350        sage: 1/(y-x)
    433351        1
    434         sage: w-x==0; w+x==0
     352        sage: y-x==0; y+x==0
    435353        False
    436354        False
    437        
    438355    """
    439356    def __init__(self, polynomial, names,
    440             element_class = function_field_element.FunctionFieldElement_polymod,
     357            element_class = FunctionFieldElement_polymod,
    441358            category=CAT):
    442359        """
    443360        Create a function field defined as an extension of another
     
    451368       
    452369        EXAMPLES::
    453370
    454         We create an extension of function fields::
     371        We create an extension of a function field::
    455372       
    456373            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    457374            sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
     
    466383       
    467384            sage: L.<w> = K.extension(y^5 - x^3 - 3*x + x*y); L
    468385            Function field in w defined by y^5 + x*y - x^3 - 3*x
    469 
    470386        """
    471387        from sage.rings.polynomial.all import is_Polynomial
    472388        if polynomial.parent().ngens()>1 or not is_Polynomial(polynomial):
     
    492408        self._gen = self(self._ring.gen())
    493409
    494410    def __reduce__(self):
    495         return  constructor.FunctionField_polymod_Constructor, (self._polynomial, self._names)
     411        """
     412        Returns the arguments which were used to create this instance. The rationale for this is explained in the documentation of ``UniqueRepresentation``.
    496413
     414        EXAMPLES::
    497415
     416            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     417            sage: L = K.extension(y^2-x)
     418            sage: clazz,args = L.__reduce__()
     419            sage: clazz(*args)
     420            Function field in y defined by y^2 - x
     421        """
     422        from constructor import FunctionField_polymod as FunctionField_polymod_Constructor
     423        return  FunctionField_polymod_Constructor, (self._polynomial, self._names)
    498424
    499425    def __hash__(self):
    500426        """
     
    506432            sage: L = K.extension(y^5 - x^3 - 3*x + x*y); hash(L)
    507433            3183366741743088279             # 64-bit
    508434            2003022487                      # 32-bit
    509 
    510435        """
    511436        return self._hash
    512437
     
    515440        Return a function field isomorphic to self, but with defining
    516441        polynomial that is monic and integral over the base field.
    517442
    518         INPUT::
     443        INPUT:
    519444
    520445            - ``names`` -- name of the generator of the new field this function constructs
    521446
    522447        EXAMPLES::
    523448
    524449            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    525             sage: L.<alpha> = K.extension(x^2*y^5 - 1/x); L
    526             Function field in alpha defined by x^2*y^5 - 1/x
    527             sage: A, from_A, to_A = L.monic_integral_model('beta')
     450            sage: L.<y> = K.extension(x^2*y^5 - 1/x); L
     451            Function field in y defined by x^2*y^5 - 1/x
     452            sage: A, from_A, to_A = L.monic_integral_model('z')
    528453            sage: A
    529             Function field in beta defined by y^5 - x^12
     454            Function field in z defined by y^5 - x^12
    530455            sage: from_A
    531             Morphism of function fields defined by beta |--> x^3*alpha
     456            Morphism of function fields defined by z |--> x^3*y
    532457            sage: to_A
    533             Morphism of function fields defined by alpha |--> 1/x^3*beta
    534             sage: to_A(alpha)
    535             1/x^3*beta
    536             sage: from_A(to_A(alpha))
    537             alpha
    538             sage: from_A(to_A(1/alpha))
    539             x^3*alpha^4
    540             sage: from_A(to_A(1/alpha)) == 1/alpha
    541             True           
     458            Morphism of function fields defined by y |--> 1/x^3*z
     459            sage: to_A(y)
     460            1/x^3*z
     461            sage: from_A(to_A(y))
     462            y
     463            sage: from_A(to_A(1/y))
     464            x^3*y^4
     465            sage: from_A(to_A(1/y)) == 1/y
     466            True
    542467        """
    543468        g, d = self._make_monic_integral(self.polynomial())
    544469        R = self.base_field()
     
    549474
    550475    def _make_monic_integral(self, f):
    551476        r"""
    552         Let alpha be a root of f.  This function returns a monic
     477        Let y be a root of ``f``.  This function returns a monic
    553478        integral polynomial g and an element d of the base field such
    554         that g(alpha*d) = 0.
     479        that g(y*d)=0.
    555480       
    556481        EXAMPLES::
    557482       
    558483            sage: K.<x> = FunctionField(QQ); R.<y> = K[];
    559             sage: L.<alpha> = K.extension(x^2*y^5 - 1/x)
     484            sage: L.<y> = K.extension(x^2*y^5 - 1/x)
    560485            sage: g, d = L._make_monic_integral(L.polynomial()); g,d
    561486            (y^5 - x^12, x^3)
    562             sage: (alpha*d).is_integral()
     487            sage: (y*d).is_integral()
    563488            True
    564489            sage: g.is_monic()
    565490            True
    566             sage: g(alpha*d)
     491            sage: g(y*d)
    567492            0
    568        
    569493        """
    570494        R = f.base_ring()
    571495        if not isinstance(R, RationalFunctionField):
     
    596520        EXAMPLES::
    597521
    598522            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    599             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     523            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    600524            sage: L.constant_field()
    601525            Traceback (most recent call last):
    602526            ...
     
    611535        EXAMPLES::
    612536
    613537            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    614             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    615             Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     538            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     539            Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    616540            sage: L.constant_base_field()
    617541            Rational Field
    618542            sage: S.<z> = L[]
    619             sage: M.<z> = L.extension(z^2 - w)
     543            sage: M.<z> = L.extension(z^2 - y)
    620544            sage: M.constant_base_field()
    621545            Rational Field
    622            
    623546        """
    624547        return self.base_field().constant_base_field()
    625548
     
    632555
    633556            sage: K.<x> = FunctionField(QQ)
    634557            sage: R.<y> = K[]
    635             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    636             Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     558            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     559            Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    637560            sage: L.degree()
    638             5       
    639              
     561            5
    640562        """
    641563        return self._polynomial.degree()
    642564       
     
    647569        EXAMPLES::
    648570
    649571            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    650             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     572            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    651573            sage: L._repr_()
    652             'Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x'
    653        
     574            'Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x'
    654575        """
    655576        return "Function field in %s defined by %s"%(self.variable_name(), self._polynomial)
    656577
     
    661582        by definition the field K.
    662583       
    663584        EXAMPLES::
     585
    664586            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    665             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     587            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    666588            sage: L.base_field()
    667589            Rational function field in x over Rational Field
    668        
    669590        """
    670591        return self._base_field
    671592
    672 
    673593    def random_element(self, *args, **kwds):
    674594        """
    675595        Create a random element of this function field.  Parameters
     
    678598        EXAMPLES::
    679599
    680600            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    681             sage: L.<w> = K.extension(y^2 - (x^2 + x))
     601            sage: L.<y> = K.extension(y^2 - (x^2 + x))
    682602            sage: L.random_element() # random
    683             ((x^2 - x + 2/3)/(x^2 + 1/3*x - 1))*w^2 + ((-1/4*x^2 + 1/2*x - 1)/(-5/2*x + 2/3))*w + (-1/2*x^2 - 4)/(-12*x^2 + 1/2*x - 1/95)
    684        
     603            ((x^2 - x + 2/3)/(x^2 + 1/3*x - 1))*y^2 + ((-1/4*x^2 + 1/2*x - 1)/(-5/2*x + 2/3))*y + (-1/2*x^2 - 4)/(-12*x^2 + 1/2*x - 1/95)
    685604        """
    686605        return self(self._ring.random_element(degree=self.degree(), *args, **kwds))
    687606
     
    694613        EXAMPLES::
    695614
    696615            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    697             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     616            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    698617            sage: L.polynomial()
    699618            y^5 - 2*x*y + (-x^4 - 1)/x
    700        
    701619        """
    702620        return self._polynomial
    703621
    704622    def polynomial_ring(self):
    705623        """
    706         Return the polynomial ring used to represents elements of this
     624        Return the polynomial ring used to represent elements of this
    707625        function field.  If we view this function field as being presented
    708626        as K[y]/(f(y)), then this function returns the ring K[y].
    709627       
    710628        EXAMPLES::
    711629
    712630            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    713             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     631            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    714632            sage: L.polynomial_ring()
    715633            Univariate Polynomial Ring in y over Rational function field in x over Rational Field
    716        
    717634        """
    718635        return self._ring
    719636
     637    @cached_method
    720638    def vector_space(self):
    721639        """
    722640        Return a vector space V and isomorphisms self --> V and V --> self.
     
    728646       
    729647        OUTPUT:
    730648
    731             -  ``V`` - a vector space over base field
    732             -  ``from_V`` - an isomorphism from V to self
    733             -  ``to_V`` - an isomorphism from self to V
     649            -  ``V`` -- a vector space over base field
     650            -  ``from_V`` -- an isomorphism from V to self
     651            -  ``to_V`` -- an isomorphism from self to V
    734652
    735         EXAMPLES::
     653        EXAMPLES:
    736654
    737655        We define a function field::
    738656       
    739657            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    740             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    741             Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     658            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     659            Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    742660
    743661        We get the vector spaces, and maps back and forth::
    744662       
     
    746664            sage: V
    747665            Vector space of dimension 5 over Rational function field in x over Rational Field
    748666            sage: from_V
    749             Isomorphism map:
     667            Isomorphism morphism:
    750668              From: Vector space of dimension 5 over Rational function field in x over Rational Field
    751               To:   Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     669              To:   Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    752670            sage: to_V
    753             Isomorphism map:
    754               From: Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     671            Isomorphism morphism:
     672              From: Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    755673              To:   Vector space of dimension 5 over Rational function field in x over Rational Field
    756674
    757675        We convert an element of the vector space back to the function field::
    758676       
    759677            sage: from_V(V.1)
    760             w
     678            y
    761679
    762680        We define an interesting element of the function field::
    763681       
    764682            sage: a = 1/L.0; a
    765             (-x/(-x^4 - 1))*w^4 + 2*x^2/(-x^4 - 1)
     683            (-x/(-x^4 - 1))*y^4 + 2*x^2/(-x^4 - 1)
    766684
    767685        We convert it to the vector space, and get a vector over the base field::
    768686       
     
    780698            sage: to_V(from_V(v)) == v
    781699            True
    782700
     701        And we show how it works over an extension of an extension field::
    783702
    784         And we show how it works over an extension of an extension field.
    785 
    786             sage: R2.<z> = L[]; M.<w> = L.extension(z^2 -y)
     703            sage: R2.<z> = L[]; M.<z> = L.extension(z^2 -y)
    787704            sage: M.vector_space()
    788             (Vector space of dimension 2 over Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x, Isomorphism map:
    789               From: Vector space of dimension 2 over Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
    790               To:   Function field in w defined by z^2 - w, Isomorphism map:
    791               From: Function field in w defined by z^2 - w
    792               To:   Vector space of dimension 2 over Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x)
    793                    
     705            (Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x, Isomorphism morphism:
     706              From: Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
     707              To:   Function field in z defined by z^2 - y, Isomorphism morphism:
     708              From: Function field in z defined by z^2 - y
     709              To:   Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x)
    794710        """
    795         try: return self._vector_space
    796         except AttributeError:
    797             V = self.base_field()**self.degree()
    798             from_V = maps.MapVectorSpaceToFunctionField(V, self)
    799             to_V   = maps.MapFunctionFieldToVectorSpace(self, V)
    800             self._vector_space = (V, from_V, to_V)
    801             return self._vector_space
     711        V = self.base_field()**self.degree()
     712        from maps import MapVectorSpaceToFunctionField, MapFunctionFieldToVectorSpace
     713        from_V = MapVectorSpaceToFunctionField(V, self)
     714        to_V   = MapFunctionFieldToVectorSpace(self, V)
     715        self._vector_space = (V, from_V, to_V)
     716        return self._vector_space
    802717       
    803 
    804718    def maximal_order(self):
    805719        """
    806720        Return the maximal_order of self.  If we view self as L =
    807721        K[y]/(f(y)), then this is the ring of elements of L that are
    808722        integral over K.
    809723       
    810         EXAMPLES::
     724        EXAMPLES:
    811725
    812726        This is not yet implemented...::
    813727       
    814728            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    815             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     729            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    816730            sage: L.maximal_order()
    817731            Traceback (most recent call last):
    818732            ...
    819733            NotImplementedError
    820        
    821734        """
    822735        raise NotImplementedError
    823736
    824737    def _element_constructor_(self, x):
    825738        r"""
    826         Make x into an element of this function field, possibly not canonically.
     739        Make ``x`` into an element of this function field, possibly not canonically.
    827740
    828741        INPUT:
    829742       
    830             - ``x`` - the element
     743            - ``x`` -- the element
    831744         
    832745        OUTPUT:
    833746       
     
    836749        TESTS::
    837750
    838751            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    839             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     752            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    840753            sage: L._element_constructor_(L.polynomial_ring().gen())
    841             w
     754            y
    842755        """
    843756        if x.parent() is self._ring:
    844             return function_field_element.FunctionFieldElement_polymod(self, x)
    845         if isinstance(x, function_field_element.FunctionFieldElement):
    846             return function_field_element.FunctionFieldElement_polymod(self, self._ring(x.element()))           
    847         return function_field_element.FunctionFieldElement_polymod(self, self._ring(x))
    848    
     757            return FunctionFieldElement_polymod(self, x)
     758        if isinstance(x, FunctionFieldElement):
     759            return FunctionFieldElement_polymod(self, self._ring(x.element()))
     760        return FunctionFieldElement_polymod(self, self._ring(x))
    849761
    850762    def gen(self, n=0):
    851763        """
    852         Return the n-th generator of this function field.  By default n=0; any other
    853         value of n leads to an error.  The generator is the class of y, if we view
     764        Return the ``n``-th generator of this function field. By default ``n`` is 0; any other
     765        value of ``n`` leads to an error. The generator is the class of y, if we view
    854766        self as being presented as K[y]/(f(y)).
    855767       
    856768        EXAMPLES::
    857769
    858770            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    859             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     771            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    860772            sage: L.gen()
    861             w
     773            y
    862774            sage: L.gen(1)
    863775            Traceback (most recent call last):
    864776            ...
    865777            IndexError: Only one generator.
    866 
    867778        """
    868779        if n != 0: raise IndexError, "Only one generator."
    869780        return self._gen
     
    876787        EXAMPLES::
    877788       
    878789            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    879             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     790            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    880791            sage: L.ngens()
    881792            1
    882793        """
     
    886797        """
    887798        If we view self as being presented as K[y]/(f(y)), then this
    888799        function returns the order generated by the class of y.  If f
    889         is not monic, then self._make_monic_integral is called, and instead we
    890         get the order generated by some integral multiple of a root of
    891         alpha.
     800        is not monic, then :meth:`_make_monic_integral` is called, and instead we
     801        get the order generated by some integral multiple of a root of f.
    892802       
    893803        EXAMPLES::
    894804
    895805            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    896             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    897             sage: L.equation_order()
    898             Order in Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     806            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     807            sage: O = L.equation_order()
     808            sage: O.basis()
     809            (1, x*y, x^2*y^2, x^3*y^3, x^4*y^4)
    899810
    900811        We try an example, in which the defining polynomial is not
    901812        monic and is not integral::
    902813
    903814            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    904             sage: L.<alpha> = K.extension(x^2*y^5 - 1/x); L
    905             Function field in alpha defined by x^2*y^5 - 1/x
    906             sage: O = L.equation_order(); O
    907             Order in Function field in alpha defined by x^2*y^5 - 1/x
     815            sage: L.<y> = K.extension(x^2*y^5 - 1/x); L
     816            Function field in y defined by x^2*y^5 - 1/x
     817            sage: O = L.equation_order()
    908818            sage: O.basis()
    909             (1, x^3*alpha, x^6*alpha^2, x^9*alpha^3, x^12*alpha^4)
    910        
     819            (1, x^3*y, x^6*y^2, x^9*y^3, x^12*y^4)
    911820        """
    912821        d = self._make_monic_integral(self.polynomial())[1]
    913822        return self.order(d*self.gen(), check=False)
    914    
     823
     824    def hom(self, im_gens, base_morphism=None):
     825        """
     826        Create a homomorphism from self to another function field.
     827
     828        INPUT:
     829
     830           - ``im_gens`` -- a list of images of the generators of self
     831             and of successive base rings.
     832
     833           - ``base_morphism`` -- (default: None) a homomorphism of
     834             the base ring, after the im_gens are used.  Thus if
     835             im_gens has length 2, then base_morphism should be a morphism
     836             from self.base_ring().base_ring().
     837
     838        EXAMPLES:
     839
     840        We create a rational function field, and a quadratic extension of it::
     841
     842            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     843            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     844
     845        We make the field automorphism that sends y to -y::
     846
     847            sage: f = L.hom(-y); f
     848            Morphism of function fields defined by y |--> -y
     849
     850        Evaluation works::
     851
     852            sage: f(y*x - 1/x)
     853            -x*y - 1/x
     854
     855        We try to define an invalid morphism::
     856
     857            sage: f = L.hom(y+1)
     858            Traceback (most recent call last):
     859            ...
     860            ValueError: invalid morphism
     861
     862        We make a morphism of the base rational function field::
     863
     864            sage: phi = K.hom(x+1); phi
     865            Morphism of function fields defined by x |--> x + 1
     866            sage: phi(x^3 - 3)
     867            x^3 + 3*x^2 + 3*x - 2
     868            sage: (x+1)^3-3
     869            x^3 + 3*x^2 + 3*x - 2
     870
     871        We make a morphism by specifying where the generators and the
     872        base generators go::
     873
     874            sage: L.hom([-y, x])
     875            Morphism of function fields defined by y |--> -y,  x |--> x
     876
     877        The usage of the keyword base_morphism is not implemented yet::
     878
     879            sage: L.hom([-y, x-1], base_morphism=phi)
     880            Traceback (most recent call last):
     881            ...
     882            NotImplementedError: Function field homorphisms with optional argument base_morphism are not implemented yet. Please specify the images of the generators of the base fields manually.
     883
     884        We make another extension of a rational function field::
     885
     886            sage: K2.<t> = FunctionField(QQ); R2.<w> = K2[]
     887            sage: L2.<w> = K2.extension((4*w)^2 - (t+1)^3 - 1)
     888
     889        We define a morphism, by giving the images of generators::
     890
     891            sage: f = L.hom([4*w, t+1]); f
     892            Morphism of function fields defined by y |--> 4*w,  x |--> t + 1
     893
     894        Evaluation works, as expected::
     895
     896            sage: f(y+x)
     897            4*w + t + 1
     898            sage: f(x*y + x/(x^2+1))
     899            (4*t + 4)*w + (t + 1)/(t^2 + 2*t + 2)
     900
     901        We make another extension of a rational function field::
     902
     903            sage: K3.<yy> = FunctionField(QQ); R3.<xx> = K3[]
     904            sage: L3.<xx> = K3.extension(yy^2 - xx^3 - 1)
     905
     906        This is the function field L with the generators exchanged. We define a morphism to L::
     907
     908            sage: g = L3.hom([x,y]); g
     909            Morphism of function fields defined by xx |--> x, yy |--> y
     910        """
     911        if base_morphism is not None:
     912            raise NotImplementedError, "Function field homorphisms with optional argument base_morphism are not implemented yet. Please specify the images of the generators of the base fields manually."
     913
     914        if not isinstance(im_gens, (list,tuple)):
     915            im_gens = [im_gens]
     916        if len(im_gens) == 0:
     917            raise ValueError, "no images specified"
     918
     919        if len(im_gens) > 1:
     920            base_morphism = self.base_field().hom(im_gens[1:], base_morphism)
     921
     922        # the codomain of this morphism is the field containing all the im_gens
     923        codomain = im_gens[0].parent();
     924        if base_morphism is not None:
     925            if base_morphism.codomain().has_coerce_map_from(codomain):
     926                codomain = base_morphism.codomain();
     927
     928        from maps import FunctionFieldMorphism_polymod
     929        return FunctionFieldMorphism_polymod(self.Hom(codomain), im_gens[0], base_morphism)
    915930
    916931class RationalFunctionField(FunctionField):
    917932    """
     
    942957
    943958    We define a morphism::
    944959
    945         sage: K.<W> = FunctionField(QQ)
    946         sage: L = FunctionField(QQ, 'tbar')         # give var name as second input
     960        sage: K.<t> = FunctionField(QQ)
     961        sage: L = FunctionField(QQ, 'tbar') # give variable name as second input
    947962        sage: K.hom(L.gen())
    948         Morphism of function fields defined by W |--> tbar
     963        Morphism of function fields defined by t |--> tbar
    949964    """
    950965    def __init__(self, constant_field, names,
    951             element_class = function_field_element.FunctionFieldElement_rational,
     966            element_class = FunctionFieldElement_rational,
    952967            category=CAT):
    953968        """
    954969        Create a rational function field in one variable.
     
    9931008        self._gen = self(R.gen())
    9941009
    9951010    def __reduce__(self):
    996         return constructor.FunctionField, (self._constant_field, self._names)
     1011        """
     1012        Returns the arguments which were used to create this instance. The rationale for this is explained in the documentation of ``UniqueRepresentation``.
     1013
     1014        EXAMPLES::
     1015
     1016            sage: K.<x> = FunctionField(QQ)
     1017            sage: clazz,args = K.__reduce__()
     1018            sage: clazz(*args)
     1019            Rational function field in x over Rational Field
     1020        """
     1021        from constructor import FunctionField
     1022        return FunctionField, (self._constant_field, self._names)
    9971023   
    9981024    def __hash__(self):
    9991025        """
     
    10051031            sage: hash(K)
    10061032            502145503910697533              # 64-bit
    10071033            -500688323                      # 32-bit
    1008                        
    10091034        """
    10101035        return self._hash
    10111036
     
    10181043            sage: K.<t> = FunctionField(QQ)
    10191044            sage: K._repr_()
    10201045            'Rational function field in t over Rational Field'
    1021 
    10221046        """
    10231047        return "Rational function field in %s over %s"%(
    10241048            self.variable_name(), self._constant_field)
    10251049
    10261050    def _element_constructor_(self, x):
    10271051        r"""
    1028         Coerce x into an element of this function field, possibly not canonically.
     1052        Coerce ``x`` into an element of this function field, possibly not canonically.
    10291053
    10301054        INPUT:
    10311055       
    1032             - ``x`` - the element
     1056            - ``x`` -- the element
    10331057         
    10341058        OUTPUT:
    10351059       
     
    10441068            Rational function field in t over Rational Field
    10451069       
    10461070        """
    1047         #if isinstance(x, self._element_class):
    1048         #    if x.parent() is self:
    1049         #        return x
    1050         #    else:
    1051         #        return self._element_class(self, x)
    1052         #return self._element_class(self, x, y,
    1053         #        coerce=coerce, reduce = self.is_exact())
    10541071        if x.parent() is self._field:
    1055             return function_field_element.FunctionFieldElement_rational(self, x)
    1056         if isinstance(x, function_field_element.FunctionFieldElement):
    1057             return function_field_element.FunctionFieldElement_rational(self, self._field(x.element()))
     1072            return FunctionFieldElement_rational(self, x)
     1073        if isinstance(x, FunctionFieldElement):
     1074            return FunctionFieldElement_rational(self, self._field(x.element()))
    10581075        if x.parent() is self.polynomial_ring():
    10591076            return x[0]
    1060         return function_field_element.FunctionFieldElement_rational(self, self._field(x))
     1077        return FunctionFieldElement_rational(self, self._field(x))
    10611078
    1062     # nonoptimized
    10631079    def _to_bivariate_polynomial(self, f):
    10641080        """
    1065         Convert f from a univariate polynomial over the rational function
     1081        Convert ``f`` from a univariate polynomial over the rational function
    10661082        field into a bivariate polynomial and a denominator.
    10671083
    10681084        INPUT:
    10691085
    1070             - f -- a univariate polynomial over self.
     1086            - ``f`` -- a univariate polynomial over self.
    10711087
    10721088        OUTPUT:
    10731089
    1074             - 2-variate polynomial, denominator
     1090            - bivariate polynomial, denominator
    10751091
    10761092        EXAMPLES::
    10771093       
     
    10911107
    10921108    def _factor_univariate_polynomial(self, f, proof=True):
    10931109        """
    1094         Factor the univariate polynomial f over self.
     1110        Factor the univariate polynomial ``f`` over self.
    10951111
    10961112        EXAMPLES::
    10971113
     
    11031119            sage: f.factor()             # indirect doctest
    11041120            (1/t) * (X - t) * (X^2 - 1/t) * (X^2 + 1/t) * (X^2 + t*X + t^2)
    11051121            sage: f.factor().prod() == f
    1106             True       
     1122            True
    11071123
    1108         You must pass in proof=False over finite fields, due to
     1124        You must pass in ``proof=False`` over finite fields, due to
    11091125        Singular's factoring algorithm being incomplete::
    11101126
    11111127            sage: R.<t> = FunctionField(GF(7))
     
    11301146            (1/t) * (X + (a + 2)*t)^3
    11311147            sage: f.factor(proof=False).prod() == f
    11321148            True
    1133 
    11341149        """
    11351150        F, d = self._to_bivariate_polynomial(f)
    11361151        fac = F.factor(proof=proof)
     
    11481163        from sage.structure.factorization import Factorization
    11491164        return Factorization(w, unit=unit)
    11501165
     1166    @cached_method
    11511167    def polynomial_ring(self, var='x'):
    11521168        """
    1153         Return polynomial ring K[var] that could be used to represent
    1154         elements of self, if self were viewed as K[var]/(var).
     1169        Return a polynomial ring in one variable over this rational function field.
    11551170       
     1171        INPUT:
     1172
     1173            - ``var`` -- a string (default: 'x')
     1174
    11561175        EXAMPLES::
    11571176       
    11581177            sage: K.<x> = FunctionField(QQ)
     
    11601179            Univariate Polynomial Ring in x over Rational function field in x over Rational Field
    11611180            sage: K.polynomial_ring('T')
    11621181            Univariate Polynomial Ring in T over Rational function field in x over Rational Field
    1163        
    11641182        """
    1165         if var != 'x': return self[var]
    1166         try: return self._polynomial_ring
    1167         except AttributeError:
    1168             self._polynomial_ring = self[var]
    1169             return self._polynomial_ring
     1183        return self[var]
    11701184
     1185    @cached_method
    11711186    def vector_space(self):
    11721187        """
    11731188        Return a vector space V and isomorphisms self --> V and V --> self.
    11741189       
    11751190        OUTPUT:
    11761191
    1177             -  ``V`` - a vector space over the rational numbers
    1178             -  ``from_V`` - an isomorphism from V to self
    1179             -  ``to_V`` - an isomorphism from self to V
     1192            -  ``V`` -- a vector space over the rational numbers
     1193            -  ``from_V`` -- an isomorphism from V to self
     1194            -  ``to_V`` -- an isomorphism from self to V
    11801195
    11811196        EXAMPLES::
    11821197
    11831198            sage: K.<x> = FunctionField(QQ)
    11841199            sage: K.vector_space()
    1185             (Vector space of dimension 1 over Rational function field in x over Rational Field, Isomorphism map:
     1200            (Vector space of dimension 1 over Rational function field in x over Rational Field, Isomorphism morphism:
    11861201              From: Vector space of dimension 1 over Rational function field in x over Rational Field
    1187               To:   Rational function field in x over Rational Field, Isomorphism map:
     1202              To:   Rational function field in x over Rational Field, Isomorphism morphism:
    11881203              From: Rational function field in x over Rational Field
    11891204              To:   Vector space of dimension 1 over Rational function field in x over Rational Field)
    1190        
    11911205        """
    1192         try: return self._vector_space
    1193         except AttributeError:
    1194             V = self.base_field()**1
    1195             from_V = maps.MapVectorSpaceToFunctionField(V, self)
    1196             to_V   = maps.MapFunctionFieldToVectorSpace(self, V)
    1197             self._vector_space = (V, from_V, to_V)
    1198             return self._vector_space
     1206        V = self.base_field()**1
     1207        from maps import MapVectorSpaceToFunctionField, MapFunctionFieldToVectorSpace
     1208        from_V = MapVectorSpaceToFunctionField(V, self)
     1209        to_V   = MapFunctionFieldToVectorSpace(self, V)
     1210        self._vector_space = (V, from_V, to_V)
     1211        return self._vector_space
    11991212
    12001213    def random_element(self, *args, **kwds):
    12011214        """
     
    12071220
    12081221            sage: FunctionField(QQ,'alpha').random_element()
    12091222            (-1/2*alpha^2 - 4)/(-12*alpha^2 + 1/2*alpha - 1/95)
    1210        
    12111223        """
    12121224        return self(self._field.random_element(*args, **kwds))
    12131225
    12141226    def degree(self):
    12151227        """
    12161228        Return the degree over the base field of this rational
    1217         function field, which is 1.
    1218        
     1229        function field. Since the base field is the rational function
     1230        field itself, the degree is 1.
     1231
    12191232        EXAMPLES::
    12201233       
    12211234            sage: K.<t> = FunctionField(QQ)
    12221235            sage: K.degree()
    12231236            1
    1224        
    12251237        """
     1238        from sage.rings.integer_ring import ZZ
    12261239        return ZZ(1)
    12271240   
    12281241    def gen(self, n=0):
    12291242        """
    1230         Return the n-th generator of this function field.  If n is not
     1243        Return the ``n``-th generator of this function field.  If ``n`` is not
    12311244        0, then an IndexError is raised.
    12321245
    12331246        EXAMPLES::
     
    12541267            sage: K.<t> = FunctionField(QQ)
    12551268            sage: K.ngens()
    12561269            1
    1257        
    12581270        """
    12591271        return 1
    12601272   
     
    12681280            sage: K.<t> = FunctionField(GF(7))
    12691281            sage: K.base_field()
    12701282            Rational function field in t over Finite Field of size 7
    1271        
    12721283        """
    12731284        return self
    12741285
     
    12851296
    12861297            - a map between function fields
    12871298
    1288         EXAMPLES::
     1299        EXAMPLES:
    12891300
    12901301        We make a map from a rational function field to itself::
    12911302
    1292             sage: R.<x> = FunctionField(GF(7))
    1293             sage: R.hom( (x^4 + 2)/x)
     1303            sage: K.<x> = FunctionField(GF(7))
     1304            sage: K.hom( (x^4 + 2)/x)
    12941305            Morphism of function fields defined by x |--> (x^4 + 2)/x       
    12951306       
    12961307        We construct a map from a rational function field into a
    12971308        non-rational extension field::
    12981309       
    1299             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    1300             sage: L.<y> = R.extension(y^3 + 6*x^3 + x)
    1301             sage: f = R.hom(y^2 + y  + 2); f
     1310            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     1311            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     1312            sage: f = K.hom(y^2 + y  + 2); f
    13021313            Morphism of function fields defined by x |--> y^2 + y + 2
    13031314            sage: f(x)
    13041315            y^2 + y + 2
    13051316            sage: f(x^2)
    13061317            5*y^2 + (x^3 + 6*x + 4)*y + 2*x^3 + 5*x + 4       
    1307        
    13081318        """
     1319        from sage.structure.category_object import CategoryObject
    13091320        if isinstance(im_gens, CategoryObject):
    13101321            return self.Hom(im_gens).natural_map()
    13111322        if not isinstance(im_gens, (list,tuple)):
     
    13131324        if len(im_gens) != 1:
    13141325            raise ValueError, "there must be exactly one generator"
    13151326        x = im_gens[0]
    1316         return maps.FunctionFieldMorphism_rational(self.Hom(x.parent()), x)
     1327        from maps import FunctionFieldMorphism_rational
     1328        return FunctionFieldMorphism_rational(self.Hom(x.parent()), x)
    13171329
    13181330    def field(self):
    13191331        """
     
    13251337            sage: K.<t> = FunctionField(GF(7))
    13261338            sage: K.field()
    13271339            Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 7
    1328        
    13291340        """
    13301341        return self._field
    13311342
     1343    @cached_method
    13321344    def maximal_order(self):
    13331345        """
    13341346        Return the maximal order of this function field.  Since this
     
    13421354            Maximal order in Rational function field in t over Rational Field
    13431355            sage: K.equation_order()
    13441356            Maximal order in Rational function field in t over Rational Field
    1345        
    13461357        """
    1347         try: return self._maximal_order
    1348         except AttributeError:
    1349             from function_field_order import FunctionFieldOrder_rational
    1350             self._maximal_order = FunctionFieldOrder_rational(self)
    1351             return self._maximal_order
     1358        from function_field_order import FunctionFieldOrder_rational
     1359        return FunctionFieldOrder_rational(self)
    13521360
    13531361    equation_order = maximal_order
    13541362
     
    13671375        return self._constant_field
    13681376
    13691377    constant_field = constant_base_field
    1370 
    1371 
    1372        
    1373 
    1374    
    1375 
    1376 
  • sage/rings/function_field/function_field_element.pyx

    diff --git a/sage/rings/function_field/function_field_element.pyx b/sage/rings/function_field/function_field_element.pyx
    a b  
     1r"""
     2Function Field Elements
     3
     4AUTHORS:
     5
     6- William Stein: initial version
     7
     8- Robert Bradshaw (2010-05-27): cythonize function field elements
     9
     10- Julian Rueth (2011-06-28): treat zero correctly
     11
     12- Maarten Derickx (2011-09-11): added doctests, fixed pickling
     13"""
     14#*****************************************************************************
     15#       Copyright (C) 2010 William Stein <wstein@gmail.com>
     16#       Copyright (C) 2010 Robert Bradshaw <robertwb@math.washington.edu>
     17#       Copyright (C) 2011 Julian Rueth <julian.rueth@gmail.com>
     18#       Copyright (C) 2011 Maarten Derickx <m.derickx.student@gmail.com>
     19#
     20#  Distributed under the terms of the GNU General Public License (GPL)
     21#  as published by the Free Software Foundation; either version 2 of
     22#  the License, or (at your option) any later version.
     23#                  http://www.gnu.org/licenses/
     24#*****************************************************************************
     25
    126include "../../ext/stdsage.pxi"
    227
    328from sage.structure.element cimport FieldElement, RingElement, ModuleElement, Element
     
    1439        sage: sage.rings.function_field.function_field_element.is_FunctionFieldElement(0)
    1540        False
    1641    """
    17     return isinstance(x, FunctionFieldElement)
     42    if isinstance(x, FunctionFieldElement): return True
     43    from function_field import is_FunctionField
     44    return is_FunctionField(x.parent())
    1845
    1946def make_FunctionFieldElement(parent, element_class, representing_element):
    2047    """
     
    2653        sage: K.<x> = FunctionField(QQ)
    2754        sage: make_FunctionFieldElement(K, K._element_class, (x+1)/x)
    2855        (x + 1)/x
    29    
    3056    """
    3157    return element_class(parent, representing_element, reduce=False)
    3258
    3359cdef class FunctionFieldElement(FieldElement):
    34 
    35     cdef readonly object _x
    36     cdef readonly object _matrix
    37    
    3860    """
    3961    The abstract base class for function field elements.
    4062   
     
    4567        True
    4668    """
    4769
     70    cdef readonly object _x
     71    cdef readonly object _matrix
     72
    4873    def __reduce__(self):
    4974        """
    5075        EXAMPLES::
     
    5782        return (make_FunctionFieldElement,
    5883                (self._parent, type(self), self._x))
    5984
    60 
    6185    cdef FunctionFieldElement _new_c(self):
    6286        cdef FunctionFieldElement x = <FunctionFieldElement>PY_NEW_SAME_TYPE(self)
    6387        x._parent = self._parent
     
    79103   
    80104    def matrix(self):
    81105        r"""
    82         Return the matrix of multiplication by self when seeing the function field
    83         of where self is an element of as a vectorspace over its base field.
     106        Return the matrix of multiplication by self, interpreting self as an element
     107        of a vector space over its base field.
    84108
    85         EXAMPLES::
     109        EXAMPLES:
    86110
    87         A rational function field:
     111        A rational function field::
    88112       
    89113            sage: K.<t> = FunctionField(QQ)
    90114            sage: t.matrix()
     
    94118
    95119        Now an example in a nontrivial extension of a rational function field::
    96120       
    97             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    98             sage: Y.matrix()
     121            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     122            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     123            sage: y.matrix()
    99124            [     0      1]
    100125            [-4*x^3      x]
    101             sage: Y.matrix().charpoly('Z')
     126            sage: y.matrix().charpoly('Z')
    102127            Z^2 - x*Z + 4*x^3
    103128
    104129        An example in a relative extension, where neither function
    105130        field is rational::
    106131
    107             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    108             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
     132            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     133            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     134            sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - y^2*T + x)
    109135            sage: alpha.matrix()
    110136            [          0           1           0]
    111137            [          0           0           1]
    112             [         -x x*Y - 4*x^3           0]
     138            [         -x x*y - 4*x^3           0]
    113139
    114         We show that this matrix does indeed works as expected when making a
    115         vectorspace from a function field::
     140        We show that this matrix does indeed work as expected when making a
     141        vector space from a function field::
    116142
    117143            sage: K.<x>=FunctionField(QQ)
    118144            sage: R.<y> = K[]
    119             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     145            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    120146            sage: V, from_V, to_V = L.vector_space()
    121             sage: w5 = to_V(w^5)
    122             sage: w5 = to_V(w^5); w5
     147            sage: y5 = to_V(y^5); y5
    123148            ((x^4 + 1)/x, 2*x, 0, 0, 0)
    124             sage: w4xw = to_V(w^4) * w.matrix(); w4xw
     149            sage: y4y = to_V(y^4) * y.matrix(); y4y
    125150            ((x^4 + 1)/x, 2*x, 0, 0, 0)
    126             sage: w5 == w4xw
     151            sage: y5 == y4y
    127152            True
    128        
    129153        """
    130154        if self._matrix is None:
    131155            # Multiply each power of field generator on the left by this
     
    151175
    152176        EXAMPLES::
    153177
    154             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    155             sage: Y.trace()
     178            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     179            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     180            sage: y.trace()
    156181            x
    157182        """
    158183        return self.matrix().trace()
     
    163188
    164189        EXAMPLES::
    165190       
    166             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    167             sage: Y.norm()
     191            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     192            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     193            sage: y.norm()
    168194            4*x^3
    169195
    170 
    171196        The norm is relative::
    172197       
    173             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    174             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
    175             sage: alpha.norm()
     198            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     199            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
     200            sage: M.<z> = L.extension(z^3 - y^2*z + x)
     201            sage: z.norm()
    176202            -x
    177             sage: alpha.norm().parent()
    178             Function field in Y defined by y^2 - x*y + 4*x^3
     203            sage: z.norm().parent()
     204            Function field in y defined by y^2 - x*y + 4*x^3
    179205        """
    180206        return self.matrix().determinant()
    181207
     
    187213
    188214        EXAMPLES::
    189215
    190             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    191             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
     216            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     217            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
     218            sage: M.<z> = L.extension(z^3 - y^2*z + x)
    192219            sage: x.characteristic_polynomial('W')
    193220            W - x
    194             sage: Y.characteristic_polynomial('W')
     221            sage: y.characteristic_polynomial('W')
    195222            W^2 - x*W + 4*x^3
    196             sage: alpha.characteristic_polynomial('W')
    197             W^3 + (-x*Y + 4*x^3)*W + x
     223            sage: z.characteristic_polynomial('W')
     224            W^3 + (-x*y + 4*x^3)*W + x
    198225        """
    199226        return self.matrix().characteristic_polynomial(*args, **kwds)
    200227
     
    208235
    209236        EXAMPLES::
    210237
    211             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    212             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
     238            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     239            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
     240            sage: M.<z> = L.extension(z^3 - y^2*z + x)
    213241            sage: x.minimal_polynomial('W')
    214242            W - x
    215             sage: Y.minimal_polynomial('W')
     243            sage: y.minimal_polynomial('W')
    216244            W^2 - x*W + 4*x^3
    217             sage: alpha.minimal_polynomial('W')
    218             W^3 + (-x*Y + 4*x^3)*W + x
     245            sage: z.minimal_polynomial('W')
     246            W^3 + (-x*y + 4*x^3)*W + x
    219247        """
    220248        return self.matrix().minimal_polynomial(*args, **kwds)
    221249
     
    227255       
    228256        EXAMPLES::
    229257       
    230             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    231             sage: Y.is_integral()
     258            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     259            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     260            sage: y.is_integral()
    232261            True
    233             sage: (Y/x).is_integral()
     262            sage: (y/x).is_integral()
    234263            True
    235             sage: (Y/x)^2 - (Y/x) + 4*x
     264            sage: (y/x)^2 - (y/x) + 4*x
    236265            0
    237             sage: (Y/x^2).is_integral()
     266            sage: (y/x^2).is_integral()
    238267            False
    239             sage: f = (Y/x).minimal_polynomial('W'); f
     268            sage: (y/x).minimal_polynomial('W')
    240269            W^2 - W + 4*x           
    241270        """
    242271        R = self.parent().base_field().maximal_order()
     
    244273
    245274cdef class FunctionFieldElement_polymod(FunctionFieldElement):
    246275    """
     276    Elements of a finite extension of a function field.
     277
    247278    EXAMPLES::
    248279
    249         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    250         sage: x*Y + 1/x^3
    251         x*Y + 1/x^3       
     280        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     281        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     282        sage: x*y + 1/x^3
     283        x*y + 1/x^3       
    252284    """
    253285    def __init__(self, parent, x, reduce=True):
    254286        """
    255287        EXAMPLES::
    256288
    257              sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    258              sage: type(Y)
    259              <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_polymod'>             
     289            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     290            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     291            sage: type(y)
     292            <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_polymod'>             
    260293        """
    261294        FieldElement.__init__(self, parent)
    262295        if reduce:
     
    269302        Return the underlying polynomial that represents this element.
    270303       
    271304        EXAMPLES::
    272             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    273             sage: f = Y/x^2 + x/(x^2+1); f
    274             1/x^2*Y + x/(x^2 + 1)
     305            sage: K.<x> = FunctionField(QQ); R.<T> = K[]
     306            sage: L.<y> = K.extension(T^2 - x*T + 4*x^3)
     307            sage: f = y/x^2 + x/(x^2+1); f
     308            1/x^2*y + x/(x^2 + 1)
    275309            sage: f.element()
    276             1/x^2*y + x/(x^2 + 1)
     310            1/x^2*T + x/(x^2 + 1)
    277311            sage: type(f.element())
    278312            <class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>       
    279313        """
     
    283317        """
    284318        EXAMPLES::
    285319
    286             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    287             sage: Y._repr_()
    288             'Y'
     320            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     321            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     322            sage: y._repr_()
     323            'y'
    289324        """
    290325        return self._x._repr(name=self.parent().variable_name())
    291326       
     
    293328        """
    294329        EXAMPLES::
    295330
    296             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    297             sage: bool(Y)
     331            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     332            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     333            sage: bool(y)
    298334            True
    299335            sage: bool(L(0))
    300336            False
     
    307343        """
    308344        EXAMPLES::
    309345
    310             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     346            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     347            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    311348            sage: cmp(L(0), 0)
    312349            0
    313             sage: cmp(Y, L(2)) != 0
     350            sage: cmp(y, L(2)) != 0
    314351            True
    315352        """
    316353        cdef FunctionFieldElement left = <FunctionFieldElement>self
     
    321358        """
    322359        EXAMPLES::
    323360
    324             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    325             sage: (2*Y + x/(1+x^3))  +  (3*Y + 5*x*Y)         # indirect doctest
    326             (5*x + 5)*Y + x/(x^3 + 1)
    327             sage: (Y^2 - x*Y + 4*x^3)==0                      # indirect doctest
     361            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     362            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     363            sage: (2*y + x/(1+x^3))  +  (3*y + 5*x*y)         # indirect doctest
     364            (5*x + 5)*y + x/(x^3 + 1)
     365            sage: (y^2 - x*y + 4*x^3)==0                      # indirect doctest
    328366            True
     367            sage: -y+y
     368            0
    329369        """
    330370        cdef FunctionFieldElement res = self._new_c()
    331371        res._x = self._x + (<FunctionFieldElement>right)._x
     
    335375        """
    336376        EXAMPLES::
    337377
    338             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    339             sage: (2*Y + x/(1+x^3))  -  (3*Y + 5*x*Y)         # indirect doctest
    340             (-5*x - 1)*Y + x/(x^3 + 1)
     378            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     379            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     380            sage: (2*y + x/(1+x^3))  -  (3*y + 5*x*y)         # indirect doctest
     381            (-5*x - 1)*y + x/(x^3 + 1)
     382            sage: y-y
     383            0
    341384        """
    342385        cdef FunctionFieldElement res = self._new_c()
    343386        res._x = self._x - (<FunctionFieldElement>right)._x
     
    347390        """
    348391        EXAMPLES::
    349392
    350             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    351             sage: Y  *  (3*Y + 5*x*Y)                          # indirect doctest
    352             (5*x^2 + 3*x)*Y - 20*x^4 - 12*x^3
     393            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     394            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     395            sage: y  *  (3*y + 5*x*y)                          # indirect doctest
     396            (5*x^2 + 3*x)*y - 20*x^4 - 12*x^3
    353397        """
    354398        cdef FunctionFieldElement res = self._new_c()
    355399        res._x = (self._x * (<FunctionFieldElement>right)._x) % self._parent.polynomial()
     
    359403        """
    360404        EXAMPLES::
    361405
    362             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    363             sage: (2*Y + x/(1+x^3))  /  (2*Y + x/(1+x^3))       # indirect doctest
     406            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     407            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     408            sage: (2*y + x/(1+x^3))  /  (2*y + x/(1+x^3))       # indirect doctest
    364409            1
    365             sage: 1 / (Y^2 - x*Y + 4*x^3)                       # indirect doctest
     410            sage: 1 / (y^2 - x*y + 4*x^3)                       # indirect doctest
    366411            Traceback (most recent call last):
    367412            ...
    368413            ZeroDivisionError: Cannot invert 0
     
    373418        """
    374419        EXAMPLES::
    375420
    376             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    377             sage: a = ~(2*Y + 1/x); a                           # indirect doctest
    378             (-x^2/(8*x^5 + x^2 + 1/2))*Y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
    379             sage: a*(2*Y + 1/x)
     421            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     422            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     423            sage: a = ~(2*y + 1/x); a                           # indirect doctest
     424            (-x^2/(8*x^5 + x^2 + 1/2))*y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
     425            sage: a*(2*y + 1/x)
    380426            1
    381427        """
    382428        if self.is_zero():
     
    386432
    387433    def list(self):
    388434        """
     435        Return a list of coefficients of self, i.e., if self is an element of
     436        a function field K[y]/(f(y)), then return the coefficients of the
     437        reduced presentation as a polynomial in K[y].
     438
    389439        EXAMPLES::
    390440
    391             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    392             sage: a = ~(2*Y + 1/x); a
    393             (-x^2/(8*x^5 + x^2 + 1/2))*Y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
     441            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     442            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     443            sage: a = ~(2*y + 1/x); a
     444            (-x^2/(8*x^5 + x^2 + 1/2))*y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
    394445            sage: a.list()
    395446            [(2*x^3 + x)/(16*x^5 + 2*x^2 + 1), -x^2/(8*x^5 + x^2 + 1/2)]
    396             sage: (x*Y).list()
     447            sage: (x*y).list()
    397448            [0, x]
    398449        """
    399450        return self._x.padded_list(self.parent().degree())
    400451       
    401 
    402452cdef class FunctionFieldElement_rational(FunctionFieldElement):
    403453    """
     454    Elements of a rational function field.
     455
    404456    EXAMPLES::
    405457   
    406         sage: FunctionField(QQ, 't')
     458        sage: K.<t> = FunctionField(QQ); K
    407459        Rational function field in t over Rational Field
    408460    """
    409461    def __init__(self, parent, x, reduce=True):
     
    416468        FieldElement.__init__(self, parent)
    417469        self._x = x
    418470 
    419     # nonoptimized
    420 
    421471    def element(self):
    422472        """
    423473        Return the underlying fraction field element that represents this element.
    424474
    425475        EXAMPLES::
    426476
    427             sage: R.<a> = FunctionField(GF(7))
    428             sage: a.element()
    429             a
    430             sage: type(a.element())
     477            sage: K.<t> = FunctionField(GF(7))
     478            sage: t.element()
     479            t
     480            sage: type(t.element())
    431481            <type 'sage.rings.fraction_field_FpT.FpTElement'>       
    432482
    433             sage: R.<a> = FunctionField(GF(131101))
    434             sage: a.element()
    435             a
    436             sage: type(a.element())
     483            sage: K.<t> = FunctionField(GF(131101))
     484            sage: t.element()
     485            t
     486            sage: type(t.element())
    437487            <class 'sage.rings.fraction_field_element.FractionFieldElement_1poly_field'>
    438488        """
    439489        return self._x
    440490
    441491    def list(self):
    442492        """
     493        Return a list of coefficients of self, i.e., if self is an element of
     494        a function field K[y]/(f(y)), then return the coefficients of the
     495        reduced presentation as a polynomial in K[y].
     496        Since self is a member of a rational function field, this simply returns
     497        the list `[self]`
     498
    443499        EXAMPLES::
    444500
    445501            sage: K.<t> = FunctionField(QQ)
     
    505561        """
    506562        EXAMPLES::
    507563
    508 
    509564            sage: K.<t> = FunctionField(QQ)
    510565            sage: t - (3*t^3)                      # indirect doctest
    511566            -3*t^3 + t
     
    605660        """
    606661        Returns the square root of self.
    607662       
    608         EXMPLES::
     663        EXAMPLES::
    609664       
    610665            sage: K.<t> = FunctionField(QQ)
    611666            sage: f = t^2 - 2 + 1/t^2; f.sqrt()
     
    655710
    656711        EXAMPLES::
    657712
    658             sage: R.<x> = FunctionField(QQ)
    659             sage: S = R.maximal_order(); I = S.ideal(x^2+1)
    660             sage: t = S(x+1).inverse_mod(I); t
     713            sage: K.<x> = FunctionField(QQ)
     714            sage: O = K.maximal_order(); I = O.ideal(x^2+1)
     715            sage: t = O(x+1).inverse_mod(I); t
    661716            -1/2*x + 1/2
    662717            sage: (t*(x+1) - 1) in I
    663718            True           
  • sage/rings/function_field/function_field_ideal.py

    diff --git a/sage/rings/function_field/function_field_ideal.py b/sage/rings/function_field/function_field_ideal.py
    a b  
     1r"""
     2Ideals in Function Fields
     3
     4AUTHORS:
     5
     6- William Stein (2010): initial version
     7
     8- Maarten Derickx (2011-09-14): fixed ideal_with_gens_over_base()
     9
     10EXAMPLES:
     11
     12Ideals in the maximal order of a rational function field::
     13
     14    sage: K.<x> = FunctionField(QQ)
     15    sage: O = K.maximal_order()
     16    sage: I = O.ideal(x^3+1); I
     17    Ideal (x^3 + 1) of Maximal order in Rational function field in x over Rational Field
     18    sage: I^2
     19    Ideal (x^6 + 2*x^3 + 1) of Maximal order in Rational function field in x over Rational Field
     20    sage: ~I
     21    Ideal (1/(x^3 + 1)) of Maximal order in Rational function field in x over Rational Field
     22    sage: ~I * I
     23    Ideal (1) of Maximal order in Rational function field in x over Rational Field
     24
     25Ideals in the equation order of an extension of a rational function field::
     26
     27    sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     28    sage: L.<y> = K.extension(y^2-x^3-1)
     29    sage: O = L.equation_order()
     30    sage: I = O.ideal(y); I
     31    Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
     32    sage: I^2
     33    Ideal (x^3 + 1, (-x^3 - 1)*y) of Order in Function field in y defined by y^2 - x^3 - 1
     34    sage: ~I
     35    Ideal (-1, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 - x^3 - 1
     36    sage: ~I * I
     37    Ideal (1, y) of Order in Function field in y defined by y^2 - x^3 - 1
     38    sage: I.intersection(~I)
     39    Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
     40"""
     41#*****************************************************************************
     42#       Copyright (C) 2010 William Stein <wstein@gmail.com>
     43#       Copyright (C) 2011 Maarten Derickx <m.derickx.student@gmail.com>
     44#
     45#  Distributed under the terms of the GNU General Public License (GPL)
     46#  as published by the Free Software Foundation; either version 2 of
     47#  the License, or (at your option) any later version.
     48#                  http://www.gnu.org/licenses/
     49#*****************************************************************************
     50
    151from sage.rings.ideal import Ideal_generic
    252
    353class FunctionFieldIdeal(Ideal_generic):
     
    656
    757    EXAMPLES::
    858
    9         sage: R.<x> = FunctionField(GF(7))
    10         sage: S = R.maximal_order(); I = S.ideal(x^3+1)
     59        sage: K.<x> = FunctionField(GF(7))
     60        sage: O = K.maximal_order()
     61        sage: I = O.ideal(x^3+1)
    1162        sage: isinstance(I, sage.rings.function_field.function_field_ideal.FunctionFieldIdeal)
    1263        True   
    1364    """
     
    1869    A fractional ideal specified by a finitely generated module over
    1970    the integers of the base field.
    2071
    21     EXAMPLES::
     72    EXAMPLES:
    2273
    23     An ideal in a rational function field::
     74    An ideal in an extension of a rational function field::
    2475
    25         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    26         sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    27         sage: I = M.ideal(y)
     76        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     77        sage: L.<y> = K.extension(y^2 - x^3 - 1)
     78        sage: O = L.equation_order()
     79        sage: I = O.ideal(y)
    2880        sage: I
    2981        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
    3082        sage: I^2
     
    3991
    4092        EXAMPLES::
    4193
    42             sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    43             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    44             sage: I = M.ideal(y)
     94            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     95            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     96            sage: O = L.equation_order()
     97            sage: I = O.ideal(y)
    4598            sage: type(I)
    4699            <class 'sage.rings.function_field.function_field_ideal.FunctionFieldIdeal_module'>
    47100        """
     
    58111
    59112        EXAMPLES::
    60113
    61             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    62             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
    63             sage: I = M.ideal_with_gens_over_base([1, y]);  I
     114            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     115            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     116            sage: O = L.equation_order()
     117            sage: I = O.ideal_with_gens_over_base([1, y]);  I
    64118            Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    65119            sage: y in I
    66120            True
     
    85139
    86140        EXAMPLES::
    87141
    88             sage: R.<x> = FunctionField(GF(7))
    89             sage: S = R.maximal_order(); S
     142            sage: K.<x> = FunctionField(GF(7))
     143            sage: O = K.maximal_order(); O
    90144            Maximal order in Rational function field in x over Finite Field of size 7
    91             sage: R.polynomial_ring()
     145            sage: K.polynomial_ring()
    92146            Univariate Polynomial Ring in x over Rational function field in x over Finite Field of size 7
    93             sage: I = S.ideal_with_gens_over_base([x^2 + 1, x*(x^2+1)])
     147            sage: I = O.ideal_with_gens_over_base([x^2 + 1, x*(x^2+1)])
    94148            sage: I.gens()
    95149            (x^2 + 1,)
    96150            sage: I.module()
    97151            Free module of degree 1 and rank 1 over Maximal order in Rational function field in x over Finite Field of size 7
    98152            User basis matrix:
    99153            [x^2 + 1]
    100             sage: V, from_V, to_V = R.vector_space(); V
     154            sage: V, from_V, to_V = K.vector_space(); V
    101155            Vector space of dimension 1 over Rational function field in x over Finite Field of size 7
    102156            sage: I.module().is_submodule(V)
    103157            True       
     
    106160
    107161    def __add__(self, other):
    108162        """
    109         Add together two ideals.
     163        Add self and ``other``.
    110164       
    111165        EXAMPLES::
    112166       
    113             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    114             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    115             sage: I = M.ideal(y); J = M.ideal(y+1)
     167            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     168            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     169            sage: O = L.equation_order()
     170            sage: I = O.ideal(y); J = O.ideal(y+1)
    116171            sage: Z = I + J; Z
    117172            Ideal (y + 1, 6*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    118173            sage: 1 in Z
    119174            True
    120             sage: M.ideal(y^2) + M.ideal(y^3) == M.ideal(y^2,y^3)
     175            sage: O.ideal(y^2) + O.ideal(y^3) == O.ideal(y^2,y^3)
    121176            True
    122177        """
    123178        if not isinstance(other, FunctionFieldIdeal_module):
     
    126181
    127182    def intersection(self, other):
    128183        """
    129         Return the intersection of the ideals self and other.
     184        Return the intersection of the ideals self and ``other``.
    130185       
    131186        EXAMPLES::
    132187
    133             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    134             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    135             sage: I = M.ideal(y^3); J = M.ideal(y^2)
     188            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     189            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     190            sage: O = L.equation_order()
     191            sage: I = O.ideal(y^3); J = O.ideal(y^2)
    136192            sage: Z = I.intersection(J); Z
    137193            Ideal (x^6 + 2*x^3 + 1, (6*x^3 + 6)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    138194            sage: y^2 in Z
     
    148204
    149205    def __cmp__(self, other):
    150206        """
    151         Compare self and other.
     207        Compare self and ``other``.
    152208       
    153209        EXAMPLES::
    154210
    155             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    156             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    157             sage: M = L.equation_order()   
    158             sage: I = M.ideal(y*(y+1)); J = M.ideal((y^2-2)*(y+1))
     211            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     212            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     213            sage: O = L.equation_order()
     214            sage: I = O.ideal(y*(y+1)); J = O.ideal((y^2-2)*(y+1))
    159215            sage: I+J == J+I            # indirect test
    160216            True
    161217            sage: I == J
     
    177233
    178234        EXAMPLES::
    179235
    180             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    181             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    182             sage: I = M.ideal(y)
    183             sage: I.__invert__()
     236            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     237            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     238            sage: O = L.equation_order()
     239            sage: I = O.ideal(y)
     240            sage: ~I
    184241            Ideal (6, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    185242            sage: I^(-1)
    186243            Ideal (6, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    187             sage: I.__invert__() * I
     244            sage: ~I * I
    188245            Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    189246        """
    190247        if len(self.gens()) == 0:
     
    203260
    204261def ideal_with_gens(R, gens):
    205262    """
    206     Return fractional ideal in the order of R with given generators
    207     over R.
     263    Return fractional ideal in the order ``R`` with generators ``gens``
     264    over ``R``.
    208265
    209266    EXAMPLES::
    210267
    211         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    212         sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    213         sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(M, [y])
     268        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     269        sage: L.<y> = K.extension(y^2 - x^3 - 1)
     270        sage: O = L.equation_order()
     271        sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(O, [y])
    214272        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
    215273    """
    216274    K = R.fraction_field()
    217275    return ideal_with_gens_over_base(R, [b*K(g) for b in R.basis() for g in gens])
    218    
    219276
    220277def ideal_with_gens_over_base(R, gens):
    221278    """
    222     Return fractional ideal in the given order R with given generators
     279    Return fractional ideal in the order ``R`` with generators ``gens``
    223280    over the maximal order of the base field.
    224281
    225282    EXAMPLES::
    226283
    227         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    228         sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    229         sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(M, [x^3+1,-y])
     284        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     285        sage: L.<y> = K.extension(y^2 - x^3 - 1)
     286        sage: O = L.equation_order()
     287        sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(O, [x^3+1,-y])
    230288        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1   
     289   
     290    TESTS::
     291
     292        sage: K.<x> = FunctionField(QQ)
     293        sage: O = K.maximal_order()
     294        sage: I = O*x
     295        sage: ~I
     296        Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
     297        sage: ~I == O.ideal(1/x)
     298        True
     299        sage: O.ideal([x,1/x])
     300        Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
     301        sage: O.ideal([1/x,1/(x+1)])
     302        Ideal (1/(x^2 + x)) of Maximal order in Rational function field in x over Rational Field
    231303    """
    232304    K = R.fraction_field()
    233305    V, from_V, to_V = K.vector_space()
     
    237309    # by the linear algebra Hermite form code.
    238310    import function_field_order
    239311    if isinstance(R, function_field_order.FunctionFieldOrder_rational):
    240         try:
    241             v = R._ring.ideal([x.element() for x in gens]).gens_reduced()
    242             assert len(v) == 1
    243             basis = [to_V(v[0])]
    244             M = V.span_of_basis(basis, check=False, already_echelonized=True, base_ring=R)
    245         except Exception, msg:
    246             print msg   # TODO --for debugging
    247             raise
     312        from sage.modules import free_module_element
     313        gens = free_module_element.vector(x.element() for x in gens)
     314        d = gens.denominator()
     315        gens *= d
     316        v = R._ring.ideal(gens.list()).gens_reduced()
     317        assert len(v) == 1
     318        basis = [to_V(v[0]/d)]
     319        M = V.span_of_basis(basis, check=False, already_echelonized=True, base_ring=R)
    248320    else:
    249321        # General case
    250322        S = V.base_field().maximal_order()
  • sage/rings/function_field/function_field_order.py

    diff --git a/sage/rings/function_field/function_field_order.py b/sage/rings/function_field/function_field_order.py
    a b  
     1r"""
     2Orders in Function Fields
     3
     4AUTHORS:
     5
     6- William Stein (2010): initial version
     7
     8- Maarten Derickx (2011-09-14): fixed ideal_with_gens_over_base() for rational function fields
     9
     10- Julian Rueth (2011-09-14): added check in _element_constructor_
     11
     12EXAMPLES:
     13
     14Maximal orders in rational function fields::
     15
     16    sage: K.<x> = FunctionField(QQ)
     17    sage: O = K.maximal_order()
     18    sage: I = O.ideal(1/x); I
     19    Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
     20    sage: 1/x in O
     21    False
     22
     23Equation orders in extensions of rational function fields::
     24
     25    sage: K.<x> = FunctionField(GF(3)); R.<y> = K[]
     26    sage: L.<y> = K.extension(y^3-y-x)
     27    sage: O = L.equation_order()
     28    sage: 1/y in O
     29    False
     30    sage: x/y in O
     31    True
    132"""
    2 Orders in Function Fields
    3 """
    4 
    5 from sage.structure.parent_gens import ParentWithGens
     33#*****************************************************************************
     34#       Copyright (C) 2010 William Stein <wstein@gmail.com>
     35#       Copyright (C) 2011 Maarten Derickx <m.derickx.student@gmail.com>
     36#       Copyright (C) 2011 Julian Rueth <julian.rueth@gmail.com>
     37#
     38#  Distributed under the terms of the GNU General Public License (GPL)
     39#  as published by the Free Software Foundation; either version 2 of
     40#  the License, or (at your option) any later version.
     41#                  http://www.gnu.org/licenses/
     42#*****************************************************************************
    643
    744from sage.rings.ring import IntegralDomain, PrincipalIdealDomain
    845
    9 from sage.rings.ideal import is_Ideal
    10 
    1146class FunctionFieldOrder(IntegralDomain):
     47    """
     48    Base class for orders in function fields.
     49    """
    1250    def __init__(self, fraction_field):
    1351        """
     52        INPUT:
     53
     54            - ``fraction_field`` -- the function field in which this iss an order.
     55
    1456        EXAMPLES::
    1557
    1658            sage: R = FunctionField(QQ,'y').maximal_order()
    1759            sage: isinstance(R, sage.rings.function_field.function_field_order.FunctionFieldOrder)
    1860            True
    1961        """
     62        IntegralDomain.__init__(self, self)
    2063        self._fraction_field = fraction_field
    2164
    2265    def _repr_(self):
     
    3073
    3174    def is_finite(self):
    3275        """
     76        Returns False since orders are never finite.
     77
    3378        EXAMPLES::
    3479
    3580            sage: FunctionField(QQ,'y').maximal_order().is_finite()
     
    3984
    4085    def is_field(self, proof=True):
    4186        """
     87        Returns False since orders are never fields.
     88
    4289        EXAMPLES::
    4390
    4491            sage: FunctionField(QQ,'y').maximal_order().is_field()
     
    4895
    4996    def is_noetherian(self):
    5097        """
    51         Return True, since orders in function fields are noetherian.
     98        Returns True since orders in function fields are noetherian.
    5299       
    53100        EXAMPLES::
    54101
     
    59106
    60107    def fraction_field(self):
    61108        """
    62         Returns the function field in wich this is an order
     109        Returns the function field in which this is an order.
    63110
    64111        EXAMPLES::
    65112
     
    72119   
    73120    def ideal_with_gens_over_base(self, gens):
    74121        """
    75         Return the fractional ideal with given generators over the
    76         maximal ideal of the base field. That this is really an ideal
     122        Returns the fractional ideal with basis ``gens`` over the
     123        maximal order of the base field. That this is really an ideal
    77124        is not checked.
    78125
    79126        INPUT:
    80127
    81             - ``basis`` -- list of elements that are a basis for the
     128            - ``gens`` -- list of elements that are a basis for the
    82129              ideal over the maximal order of the base field
    83130           
    84         EXAMPLES::
     131        EXAMPLES:
    85132
    86133        We construct an ideal in a rational function field::
    87134       
    88             sage: R.<y> = FunctionField(QQ)
    89             sage: S = R.maximal_order()
    90             sage: I = S.ideal_with_gens_over_base([y]); I
     135            sage: K.<y> = FunctionField(QQ)
     136            sage: O = K.maximal_order()
     137            sage: I = O.ideal_with_gens_over_base([y]); I
    91138            Ideal (y) of Maximal order in Rational function field in y over Rational Field
    92139            sage: I*I
    93140            Ideal (y^2) of Maximal order in Rational function field in y over Rational Field
    94141
    95142        We construct some ideals in a nontrivial function field::
    96143
    97             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    98             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    99             sage: M = L.equation_order(); M
     144            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     145            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     146            sage: O = L.equation_order(); O
    100147            Order in Function field in y defined by y^2 + 6*x^3 + 6
    101             sage: I = M.ideal_with_gens_over_base([1, y]);  I
     148            sage: I = O.ideal_with_gens_over_base([1, y]);  I
    102149            Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    103150            sage: I.module()
    104151            Free module of degree 2 and rank 2 over Maximal order in Rational function field in x over Finite Field of size 7
    105152            Echelon basis matrix:
    106153            [1 0]
    107154            [0 1]
     155
     156        There is no check if the resulting object is really an ideal::
     157
     158            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     159            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     160            sage: O = L.equation_order()
     161            sage: I = O.ideal_with_gens_over_base([y]); I
     162            Ideal (y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
     163            sage: y in I
     164            True
     165            sage: y^2 in I
     166            False
    108167        """
    109168        from function_field_ideal import ideal_with_gens_over_base
    110169        return ideal_with_gens_over_base(self, [self(a) for a in gens])
    111170
    112171    def ideal(self, *gens):
    113172        """
    114         Return the fractional ideal generated by the element gens or
    115         the elements in gens if gens is a list.
     173        Returns the fractional ideal generated by the elements in ``gens``.
     174
     175        INPUT:
     176
     177            - ``gens`` -- a list of generators
    116178
    117179        EXAMPLES::
    118180
    119             sage: R.<y> = FunctionField(QQ)
    120             sage: S = R.maximal_order()
    121             sage: S.ideal(y)
     181            sage: K.<y> = FunctionField(QQ)
     182            sage: O = K.maximal_order()
     183            sage: O.ideal(y)
    122184            Ideal (y) of Maximal order in Rational function field in y over Rational Field
     185            sage: O.ideal([y,1/y]) == O.ideal(y,1/y) # multiple generators may be given as a list
     186            True
    123187
    124188        A fractional ideal of a nontrivial extension::
    125189
    126             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    127             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    128             sage: M = L.equation_order()
    129             sage: M.ideal(1/y)
     190            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     191            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     192            sage: O = L.equation_order()
     193            sage: O.ideal(1/y)
    130194            Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6       
    131195        """
    132196        if len(gens) == 1:
     
    136200        from function_field_ideal import ideal_with_gens
    137201        return ideal_with_gens(self, gens)
    138202
    139 
    140        
    141    
    142 
    143203class FunctionFieldOrder_basis(FunctionFieldOrder):
    144204    """
    145205    An order given by a basis over the maximal order of the base
     
    149209        """
    150210        EXAMPLES::
    151211
    152             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()
    153             sage: S
    154             Order in Function field in Y defined by y^4 + x*y + 4*x + 1
    155             sage: type(S)
    156             <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_basis_with_category'>
     212            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     213            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     214            sage: O = L.equation_order(); O
     215            Order in Function field in y defined by y^4 + x*y + 4*x + 1
     216            sage: type(O)
     217            <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_basis'>
    157218
    158219        The basis only defines an order if the module it generates is closed under multiplication
    159          and contains the identity element. This is only checked when check=True ::
     220         and contains the identity element (only checked when ``check`` is True)::
    160221
    161222            sage: K.<x> = FunctionField(QQ)
    162223            sage: R.<y> = K[]
    163             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x));
    164             sage: w.is_integral()
     224            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x));
     225            sage: y.is_integral()
    165226            False
    166             sage: L.order(w)
     227            sage: L.order(y)
    167228            Traceback (most recent call last):
    168229            ...
    169             ValueError: The module generated by basis [1, w, w^2, w^3, w^4] must be closed under multiplication
     230            ValueError: The module generated by basis [1, y, y^2, y^3, y^4] must be closed under multiplication
    170231           
    171         The basis also has to be linear independent and of the same rank as the degree of the function field of it's elements::
     232        The 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)::
    172233
    173234            sage: L.order(L(x))
    174235            Traceback (most recent call last):
    175236            ...
    176             ValueError: Basis [1, x, x^2, x^3, x^4] is not linear independent
    177             sage: sage.rings.function_field.function_field_order.FunctionFieldOrder_basis([w,w,w^3,w^4,w^5])
     237            ValueError: Basis [1, x, x^2, x^3, x^4] is not linearly independent
     238            sage: sage.rings.function_field.function_field_order.FunctionFieldOrder_basis([y,y,y^3,y^4,y^5])
    178239            Traceback (most recent call last):
    179240            ...
    180             ValueError: Basis [w, w, w^3, w^4, 2*x*w + (x^4 + 1)/x] is not linear independent
    181        
    182 
     241            ValueError: Basis [y, y, y^3, y^4, 2*x*y + (x^4 + 1)/x] is not linearly independent
    183242        """
    184243        if len(basis) == 0:
    185244            raise ValueError, "basis must have positive length"
     
    198257        self._populate_coercion_lists_(coerce_list=[self._ring])
    199258        if check:
    200259            if self._module.rank() != fraction_field.degree():
    201                 raise ValueError, "Basis %s is not linear independent"%(basis)
     260                raise ValueError, "Basis %s is not linearly independent"%(basis)
    202261            if not to(fraction_field(1)) in self._module:
    203262                raise ValueError, "The identity element must be in the module spanned by basis %s"%(basis)
    204263            if not all(to(a*b) in self._module for a in basis for b in basis):
     
    207266
    208267    def _element_constructor_(self, f, check=True):
    209268        """
     269        Make ``f`` into an element of this order.
     270
     271        INPUT::
     272
     273            - ``f`` -- the element
     274            - ``check`` -- check if the element is in the order
     275
    210276        EXAMPLES::
    211277
    212             sage: R.<y> = FunctionField(QQ)
    213             sage: R.maximal_order()._element_constructor_(y)
    214             y
    215        
    216         If check=True test if the element is indeed in the order.
     278            sage: K.<x> = FunctionField(QQ)
     279            sage: K.maximal_order()._element_constructor_(x)
     280            x
    217281        """
    218282        fraction_field=self.fraction_field()
    219283       
     
    229293
    230294    def fraction_field(self):
    231295        """
     296        Returns the function field in which this is an order.
     297
    232298        EXAMPLES::
    233299
    234             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()           
    235             sage: S.fraction_field()
    236             Function field in Y defined by y^4 + x*y + 4*x + 1
     300            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     301            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     302            sage: O = L.equation_order()
     303            sage: O.fraction_field()
     304            Function field in y defined by y^4 + x*y + 4*x + 1
    237305        """
    238306        return self._fraction_field
    239307
     
    243311       
    244312        EXAMPLES::
    245313
    246             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()           
    247             sage: S.polynomial()
     314            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     315            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     316            sage: O = L.equation_order()
     317            sage: O.polynomial()
    248318            y^4 + x*y + 4*x + 1
    249        
    250319        """
    251320        return self._fraction_field.polynomial()
    252321
    253 
    254322    def basis(self):
    255323        """
     324        Returns a basis of self over the maximal order of the base field.
     325
    256326        EXAMPLES::
    257327
    258             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()           
    259             sage: S.basis()
    260             (1, Y, Y^2, Y^3)
     328            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     329            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     330            sage: O = L.equation_order()
     331            sage: O.basis()
     332            (1, y, y^2, y^3)
    261333        """
    262334        return self._basis
    263335
    264336    def free_module(self):
    265337        """
     338        Returns the free module formed by the basis over the maximal order of the base field.
     339
    266340        EXAMPLES::
    267341
    268             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()
    269             sage: S.free_module()
     342            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     343            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     344            sage: O = L.equation_order()
     345            sage: O.free_module()
    270346            Free module of degree 4 and rank 4 over Maximal order in Rational function field in x over Finite Field of size 7
    271347            Echelon basis matrix:
    272348            [1 0 0 0]
     
    276352        """
    277353        return self._module
    278354
    279 ##     def polynomial_quotient_ring(self):
    280 ##         """
    281 ##         Return a quotient of a (possibly multivariate) polynomial ring
    282 ##         that is isomorphic to self, along with morphisms back and
    283 ##         forth.
    284 ##         """
    285 ##         raise NotImplementedError
    286    
    287 
    288 import function_field_element   
    289        
    290355class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder):
    291356    """
    292357    The maximal order in a rational function field.
     
    300365            sage: R = K.maximal_order(); R
    301366            Maximal order in Rational function field in t over Finite Field of size 19
    302367            sage: type(R)
    303             <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_rational_with_category'>
     368            <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_rational'>
    304369        """
    305370        FunctionFieldOrder.__init__(self, function_field)
    306         IntegralDomain.__init__(self, self, names = function_field.variable_names(), normalize = False)
     371        PrincipalIdealDomain.__init__(self, self, names = function_field.variable_names(), normalize = False)
    307372        self._ring = function_field._ring
    308373        self._populate_coercion_lists_(coerce_list=[self._ring])
    309374        self._gen = self(self._ring.gen())
     
    311376
    312377    def basis(self):
    313378        """
    314         Return basis (=1) for this order as a module over the polynomial ring.
     379        Returns the basis (=1) for this order as a module over the polynomial ring.
    315380       
    316381        EXAMPLES::
    317382
    318383            sage: K.<t> = FunctionField(GF(19))
    319             sage: M = K.maximal_order()
    320             sage: M.basis()
     384            sage: O = K.maximal_order()
     385            sage: O.basis()
    321386            (1,)
    322             sage: parent(M.basis()[0])
     387            sage: parent(O.basis()[0])
    323388            Maximal order in Rational function field in t over Finite Field of size 19
    324389        """
    325390        return self._basis
    326391
    327392    def ideal(self, *gens):
    328393        """
    329         Return the fractional ideal generated by the element gens or
    330         the elements in gens if gens is a list.
     394        Returns the fractional ideal generated by ``gens``.
    331395
    332396        EXAMPLES::
    333397
    334             sage: R.<y> = FunctionField(QQ)
    335             sage: S = R.maximal_order()
    336             sage: S.ideal(y)
    337             Ideal (y) of Maximal order in Rational function field in y over Rational Field
    338 
    339         A fractional ideal of a nontrivial extension::
    340 
    341             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    342             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    343             sage: M = L.equation_order()
    344             sage: M.ideal(1/y)
    345             Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    346 
    347         A non-principal ideal::
    348 
    349             sage: R.<x> = FunctionField(GF(7))
    350             sage: S = R.maximal_order()
    351             sage: S.ideal(x^3+1,x^3+6)
    352             Ideal (1) of Maximal order in Rational function field in x over Finite Field of size 7
    353             sage: S.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1))
    354             Ideal (x^2 + 1) of Maximal order in Rational function field in x over Finite Field of size 7   
     398            sage: K.<x> = FunctionField(QQ)
     399            sage: O = K.maximal_order()
     400            sage: O.ideal(x)
     401            Ideal (x) of Maximal order in Rational function field in x over Rational Field
     402            sage: O.ideal([x,1/x]) == O.ideal(x,1/x) # multiple generators may be given as a list
     403            True
     404            sage: O.ideal(x^3+1,x^3+6)
     405            Ideal (1) of Maximal order in Rational function field in x over Rational Field
     406            sage: O.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1))
     407            Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field
    355408        """
    356409        if len(gens) == 1:
    357410            gens = gens[0]
    358411            if not isinstance(gens, (list, tuple)):
    359                 if is_Ideal(gens):
    360                     gens = gens.gens()
    361                 else:
    362                     gens = [gens]
     412                gens = (gens,)
    363413        from function_field_ideal import ideal_with_gens
    364414        return ideal_with_gens(self, gens)
    365415
     
    374424
    375425    def gen(self, n=0):
    376426        """
     427        Returns the ``n``-th generator of self. Since there is only one generator ``n`` must be 0.
     428
    377429        EXAMPLES::
    378430
    379             sage: R = FunctionField(QQ,'y').maximal_order(); R.gen()
     431            sage: O = FunctionField(QQ,'y').maximal_order()
     432            sage: O.gen()
    380433            y
    381             sage: R.gen(1)
     434            sage: O.gen(1)
    382435            Traceback (most recent call last):
    383436            ...
    384437            IndexError: Only one generator.
     
    388441
    389442    def ngens(self):
    390443        """
     444        Returns 1, the number of generators of self.
     445
    391446        EXAMPLES::
    392447
    393             sage: R = FunctionField(QQ,'y').maximal_order(); R.ngens()
     448            sage: FunctionField(QQ,'y').maximal_order().ngens()
    394449            1
    395450        """
    396451        return 1
    397452
    398453    def _element_constructor_(self, f):
    399454        """
     455        Make ``f`` into an element of this order.
     456
    400457        EXAMPLES::
    401458
    402             sage: R.<y> = FunctionField(QQ)
    403             sage: R.maximal_order()._element_constructor_(y)
     459            sage: K.<y> = FunctionField(QQ)
     460            sage: O = K.maximal_order()
     461            sage: O._element_constructor_(y)
    404462            y
     463            sage: O._element_constructor_(1/y)
     464            Traceback (most recent call last):
     465            ...
     466            ValueError: `1/y` is not a member of `Maximal order in Rational function field in y over Rational Field`
    405467        """
    406         # HUGE TODO: have to check that f is really in self!!
    407        
    408468        if f.parent() is self.fraction_field():
     469            if not f.denominator() in self.fraction_field().constant_base_field():
     470                raise ValueError("`%s` is not a member of `%s`"%(f,self))
    409471            f = f.element()
    410         if f.parent() is self._ring:
    411             return function_field_element.FunctionFieldElement_rational(self, f)
    412         return function_field_element.FunctionFieldElement_rational(self, self._ring(f))
    413 
    414 ##     def polynomial_quotient_ring(self):
    415 ##         """
    416 ##         Return a quotient of a (possibly multivariate) polynomial ring
    417 ##         that is isomorphic to self, along with morphisms back and
    418 ##         forth.
    419 
    420 ##         EXAMPLES::
    421 ##         """
    422 ##         return self._ring
    423 
    424    
    425        
    426        
     472        from function_field_element import FunctionFieldElement_rational
     473        return FunctionFieldElement_rational(self, self._ring(f))
  • sage/rings/function_field/maps.py

    diff --git a/sage/rings/function_field/maps.py b/sage/rings/function_field/maps.py
    a b  
    11r"""
     2Function Field Morphisms
    23
     4AUTHORS:
     5
     6- William Stein (2010): initial version
     7
     8- Julian Rueth (2011-09-14): refactored class hierarchy
     9
     10EXAMPLES::
     11
     12    sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     13    sage: K.hom(1/x)
     14    Morphism of function fields defined by x |--> 1/x
     15    sage: L.<y> = K.extension(y^2-x)
     16    sage: K.hom(y)
     17    Morphism of function fields defined by x |--> y
     18    sage: L.hom([y,x])
     19    Morphism of function fields defined by y |--> y,  x |--> x
     20    sage: L.hom([x,y])
     21    Traceback (most recent call last):
     22    ...
     23    ValueError: invalid morphism
    324"""
     25#*****************************************************************************
     26#       Copyright (C) 2010 William Stein <wstein@gmail.com>
     27#       Copyright (C) 2011 Julian Rueth <julian.rueth@gmail.com>
     28#
     29#  Distributed under the terms of the GNU General Public License (GPL)
     30#  as published by the Free Software Foundation; either version 2 of
     31#  the License, or (at your option) any later version.
     32#                  http://www.gnu.org/licenses/
     33#*****************************************************************************
    434
    5 from sage.categories.map import Map
    6 from sage.categories.homset import Hom
     35from sage.categories.morphism import Morphism
     36from sage.rings.morphism import RingHomomorphism
    737
    8 from function_field_order import FunctionFieldOrder
    9 
    10 class FunctionFieldIsomorphism(Map):
     38class FunctionFieldIsomorphism(Morphism):
    1139    r"""
    12     A base class for various isomorphisms between function fields and
     40    A base class for isomorphisms between function fields and
    1341    vector spaces.
    1442
    1543    EXAMPLES::
    1644
    17         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     45        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     46        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    1847        sage: V, f, t = L.vector_space()
    1948        sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldIsomorphism)
    2049        True
     
    2554       
    2655        EXAMPLES::
    2756
    28             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     57            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     58            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    2959            sage: V, f, t = L.vector_space()
    3060            sage: f._repr_type()
    3161            'Isomorphism'
     
    3868       
    3969        EXAMPLES::
    4070
    41             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     71            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     72            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    4273            sage: V, f, t = L.vector_space()           
    4374            sage: f.is_injective()
    4475            True
     
    5182       
    5283        EXAMPLES::
    5384
    54             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     85            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     86            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    5587            sage: V, f, t = L.vector_space()           
    5688            sage: f.is_surjective()
    5789            True
     
    6092
    6193class MapVectorSpaceToFunctionField(FunctionFieldIsomorphism):
    6294    r"""
    63     An isomorphism from a vector space and a function field.
     95    An isomorphism from a vector space to a function field.
    6496   
    65     EXAMPLES:
     97    EXAMPLES::
    6698
    67         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     99        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     100        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    68101        sage: V, f, t = L.vector_space(); f
    69         Isomorphism map:
     102        Isomorphism morphism:
    70103          From: Vector space of dimension 2 over Rational function field in x over Rational Field
    71           To:   Function field in Y defined by y^2 - x*y + 4*x^3
     104          To:   Function field in y defined by y^2 - x*y + 4*x^3
    72105    """
    73106    def __init__(self, V, K):
    74107        """
    75108        EXAMPLES::
    76109       
    77             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     110            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     111            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    78112            sage: V, f, t = L.vector_space(); type(f)
    79113            <class 'sage.rings.function_field.maps.MapVectorSpaceToFunctionField'>
    80114        """
    81115        self._V = V
    82116        self._K = K
    83117        self._R = K.polynomial_ring()
     118        from sage.categories.homset import Hom
    84119        FunctionFieldIsomorphism.__init__(self, Hom(V, K))
    85120
    86121    def _call_(self, v):
    87122        """
    88123        EXAMPLES::
    89124
    90             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     125            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     126            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    91127            sage: V, f, t = L.vector_space()                       
    92128            sage: f(x*V.0 + (1/x^3)*V.1)         # indirect doctest
    93             1/x^3*Y + x
     129            1/x^3*y + x
    94130        """
    95131        f = self._R(self._V(v).list())
    96132        return self._K(f)
    97133
    98134    def domain(self):
    99135        """
     136        Return the vector space which is the domain of this isomorphism.
     137
    100138        EXAMPLES::
    101139
    102             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     140            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     141            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    103142            sage: V, f, t = L.vector_space()                                   
    104143            sage: f.domain()
    105144            Vector space of dimension 2 over Rational function field in x over Rational Field
     
    108147
    109148    def codomain(self):
    110149        """
     150        Return the function field which is the codomain of this isomorphism.
     151
    111152        EXAMPLES::
    112153
    113             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     154            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     155            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    114156            sage: V, f, t = L.vector_space()                                   
    115157            sage: f.codomain()
    116             Function field in Y defined by y^2 - x*y + 4*x^3
     158            Function field in y defined by y^2 - x*y + 4*x^3
    117159        """
    118160        return self._K
    119161
    120 
    121162class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism):
    122163    """
    123164    An isomorphism from a function field to a vector space.
    124165   
    125166    EXAMPLES::
    126167
    127         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     168        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     169        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    128170        sage: V, f, t = L.vector_space(); t
    129         Isomorphism map:
    130           From: Function field in Y defined by y^2 - x*y + 4*x^3
     171        Isomorphism morphism:
     172          From: Function field in y defined by y^2 - x*y + 4*x^3
    131173          To:   Vector space of dimension 2 over Rational function field in x over Rational Field
    132174    """
    133175    def __init__(self, K, V):
    134176        """
    135177        EXAMPLES::
    136178
    137             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     179            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     180            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    138181            sage: V, f, t = L.vector_space(); type(t)
    139182            <class 'sage.rings.function_field.maps.MapFunctionFieldToVectorSpace'>
    140183        """
     
    142185        self._K = K
    143186        self._zero = K.base_ring()(0)
    144187        self._n = K.degree()
     188        from sage.categories.homset import Hom
    145189        FunctionFieldIsomorphism.__init__(self, Hom(K, V))
    146190
    147191    def domain(self):
    148192        """
     193        Return the function field which is the domain of this isomorphism.
     194
    149195        EXAMPLES::
    150196
    151             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     197            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     198            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    152199            sage: V, f, t = L.vector_space()                                   
    153200            sage: t.domain()
    154             Function field in Y defined by y^2 - x*y + 4*x^3
     201            Function field in y defined by y^2 - x*y + 4*x^3
    155202        """
    156203        return self._K
    157204
    158205    def codomain(self):
    159206        """
     207        Return the vector space which is the domain of this isomorphism.
     208
    160209        EXAMPLES::
    161210
    162             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     211            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     212            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    163213            sage: V, f, t = L.vector_space()                                   
    164214            sage: t.codomain()
    165215            Vector space of dimension 2 over Rational function field in x over Rational Field       
     
    170220        """
    171221        EXAMPLES::
    172222
    173             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     223            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     224            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    174225            sage: V, f, t = L.vector_space()
    175226            sage: t._repr_type()
    176227            'Isomorphism'
     
    181232        """
    182233        EXAMPLES::
    183234
    184             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     235            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     236            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    185237            sage: V, f, t = L.vector_space()                                   
    186             sage: t(x + (1/x^3)*Y)                       # indirect doctest
     238            sage: t(x + (1/x^3)*y)                       # indirect doctest
    187239            (x, 1/x^3)
    188240        """
    189241        y = self._K(x)
     
    191243        w = v + [self._zero]*(self._n - len(v))
    192244        return self._V(w)
    193245
     246class FunctionFieldMorphism(RingHomomorphism):
     247    r"""
     248    Base class for morphisms between function fields.
     249    """
     250    def __init__(self, parent, im_gen, base_morphism):
     251        """
     252        EXAMPLES::
    194253
    195 ##########################################################################
    196 # Morphisms between function fields
     254            sage: K.<x> = FunctionField(QQ)
     255            sage: f = K.hom(1/x); f
     256            Morphism of function fields defined by x |--> 1/x
     257            sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldMorphism)
     258            True
     259        """
     260        RingHomomorphism.__init__(self, parent)
    197261
    198 class FunctionFieldMorphism(Map):
     262        self._im_gen = im_gen
     263        self._base_morphism = base_morphism
     264
     265    def is_injective(self):
     266        """
     267        Returns True since homomorphisms of fields are injective.
     268
     269        EXAMPLES::
     270
     271            sage: K.<x> = FunctionField(QQ)
     272            sage: f = K.hom(1/x); f
     273            Morphism of function fields defined by x |--> 1/x
     274            sage: f.is_injective()
     275            True
     276        """
     277        return True
     278
     279    def __repr__(self):
     280        """
     281        EXAMPLES::
     282
     283            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     284            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     285            sage: f = L.hom(y*2)
     286            sage: f.__repr__()     
     287            'Morphism of function fields defined by y |--> 2*y'
     288        """
     289        return "Morphism of function fields defined by %s"%self._short_repr()
     290
     291    def _short_repr(self):
     292        """
     293        EXAMPLES::
     294
     295            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     296            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     297            sage: f = L.hom(y*2)
     298            sage: f._short_repr()
     299            'y |--> 2*y'
     300        """
     301        a = '%s |--> %s'%(self.domain().gen(), self._im_gen)
     302        if self._base_morphism is not None:
     303            a += ',  ' + self._base_morphism._short_repr()
     304        return a
     305
     306class FunctionFieldMorphism_polymod(FunctionFieldMorphism):
    199307    """
     308    Morphism from a finite extension of a function field to a function field.
     309
    200310    EXAMPLES::
    201311
    202         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    203         sage: L.<y> = R.extension(y^2 - x^2)
     312        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     313        sage: L.<y> = K.extension(y^2 - x)
    204314        sage: f = L.hom(-y); f
    205315        Morphism of function fields defined by y |--> -y   
    206316    """
     
    208318        """
    209319        EXAMPLES::
    210320
    211             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    212             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2); f
     321            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     322            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     323            sage: f = L.hom(y*2); f
    213324            Morphism of function fields defined by y |--> 2*y
    214325            sage: type(f)
    215             <class 'sage.rings.function_field.maps.FunctionFieldMorphism'>
     326            <class 'sage.rings.function_field.maps.FunctionFieldMorphism_polymod'>
    216327            sage: factor(L.polynomial(), proof=False)
    217328            y^3 + 6*x^3 + x
    218329            sage: f(y).charpoly('y')
    219330            y^3 + 6*x^3 + x
    220331        """
    221         self._im_gen = im_gen
    222         self._base_morphism = base_morphism
    223         Map.__init__(self, parent)
     332        FunctionFieldMorphism.__init__(self, parent, im_gen, base_morphism)
    224333        # Verify that the morphism is valid:
    225334        R = self.codomain()['X']
    226335        v = parent.domain().polynomial().list()
     
    230339        if f(im_gen):
    231340            raise ValueError, "invalid morphism"
    232341   
    233     def is_injective(self):
    234         """
    235         EXAMPLES::
    236 
    237             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    238             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
    239             sage: f.is_injective()
    240             True
    241         """
    242         return True
    243 
    244     def __repr__(self):
    245         """
    246         EXAMPLES::
    247 
    248             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    249             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
    250             sage: f.__repr__()     
    251             'Morphism of function fields defined by y |--> 2*y'
    252         """
    253         return "Morphism of function fields defined by %s"%self._short_repr()
    254 
    255     def __nonzero__(self):
    256         """
    257         EXAMPLES::
    258 
    259             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    260             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
    261             sage: f.__nonzero__()
    262             True
    263             sage: bool(f)
    264             True
    265         """
    266         return True
    267 
    268     def _short_repr(self):
    269         """
    270         EXAMPLES::
    271 
    272             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    273             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
    274             sage: f._short_repr()
    275             'y |--> 2*y'
    276         """
    277         a = '%s |--> %s'%(self.domain().gen(), self._im_gen)
    278         if self._base_morphism is not None:
    279             a += ',  ' + self._base_morphism._short_repr()
    280         return a
    281    
    282342    def _call_(self, x):
    283343        """
    284344        EXAMPLES::
    285345
    286             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    287             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
     346            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     347            sage: L.<y> = K.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
    288348            sage: f(y/x + x^2/(x+1))            # indirect doctest
    289349            2/x*y + x^2/(x + 1)
    290350            sage: f(y)
     
    297357        return f(self._im_gen)
    298358
    299359class FunctionFieldMorphism_rational(FunctionFieldMorphism):
     360    """
     361    Morphism from a rational function field to a function field.
     362
     363    EXAMPLES::
     364
     365        sage: K.<x> = FunctionField(QQ)
     366        sage: f = K.hom(1/x); f
     367        Morphism of function fields defined by x |--> 1/x
     368    """
    300369    def __init__(self, parent, im_gen):
    301370        """
    302371        EXAMPLES::
    303372
    304             sage: R.<x> = FunctionField(GF(7)); f = R.hom(1/x); f
     373            sage: K.<x> = FunctionField(GF(7))
     374            sage: f = K.hom(1/x); f
    305375            Morphism of function fields defined by x |--> 1/x
    306376            sage: type(f)
    307377            <class 'sage.rings.function_field.maps.FunctionFieldMorphism_rational'>
    308378        """
    309         Map.__init__(self, parent)
    310         self._im_gen = im_gen
    311         self._base_morphism = None
     379        FunctionFieldMorphism.__init__(self, parent, im_gen, None)
    312380
    313381    def _call_(self, x):
    314382        """
    315383        EXAMPLES::
    316384
    317             sage: R.<x> = FunctionField(GF(7)); f = R.hom(1/x); f
     385            sage: K.<x> = FunctionField(GF(7))
     386            sage: f = K.hom(1/x); f
    318387            Morphism of function fields defined by x |--> 1/x
    319388            sage: f(x+1)                          # indirect doctest
    320389            (x + 1)/x
  • deleted file sage/rings/function_field/todo.txt

    diff --git a/sage/rings/function_field/todo.txt b/sage/rings/function_field/todo.txt
    deleted file mode 100644
    + -  
    1 TODO:
    2 
    3 [ ] copyright headers
    4 [ ] Docstring headers for each file with description of content of file
    5 [ ] picling elements
    6 
    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
    12 [ ] polynomial factoring of any univariate poly over a non-rational function field
    13 [ ] checking irreducibility in FunctionField_polymod constructor
    14 [ ] pickle doctests
    15 [ ] TestSuite(s).run() doctests
    16 [ ] method function_field() on algebraic curves, that give back a corresponding function field object.
    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...?
    23 
    24 DONE:
    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:
    33 K.<t_ba> = FunctionField(QQ)
    34 R.<u_ba> = K[]
    35 L.<u_ba> = K.extension(u_ba^2 - t_ba)
    36 L.equation_order()
    37 BOOM!
    38 
    39 [x] isomorphisms between function fields:
    40      K.hom([top gen, next one down, etc.])
    41     make sure you include easy way to gens all the way down.
    42 [x] inverses of fractional ideals
    43 [x] factor for elements of the rational function field
    44 [x] ideals
    45 [x] polynomial factoring of any univariate poly over a rational function field: reduce to bivariate over constant field?
    46 [x] conversion back and forth between a free module over base
    47 [x] random element
    48 [x] numerator, denominator
    49 [x] 100% coverage
    50 [x] matrix of element
    51 [x] norm
    52 [x] trace
  • sage/rings/polynomial/polynomial_element.pyx

    diff --git a/sage/rings/polynomial/polynomial_element.pyx b/sage/rings/polynomial/polynomial_element.pyx
    a b  
    4848import sage.rings.finite_rings.integer_mod_ring
    4949import sage.rings.complex_field
    5050import sage.rings.fraction_field_element
    51 import sage.rings.function_field
     51import sage.rings.function_field.function_field
    5252import sage.rings.infinity as infinity
    5353#import sage.misc.misc as misc
    5454from sage.misc.sage_eval import sage_eval