# Ticket #9054: trac_9054-part10.patch

File trac_9054-part10.patch, 10.4 KB (added by was, 11 years ago)

morphisms of function fields

• ## sage/rings/function_field/function_field.py

```# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1275044128 25200
# Node ID c09927d141ce689ff0e3f6a4213869d6e9672f80
# Parent  37ea57b6855e1262b342052382f9b761e03da4bd
trac 9054 (part 10): morphisms of function fields

diff -r 37ea57b6855e -r c09927d141ce sage/rings/function_field/function_field.py```
 a return True return False def hom(self, im_gens, base_morphism=None): """ Create a homomorphism from self to another function field. INPUT: - ``im_gens`` -- a list of images of the generators of self and of successive base rings. - ``base_morphism`` -- (default: None) a homomorphism of the base ring, after the im_gens are used.  Thus if im_gens has length 2, then base_morphism should be a morphism from self.base_ring().base_ring(). EXAMPLES:: We create a rational function field, and a quadratic extension of it:: sage: R. = FunctionField(QQ); S. = R[] sage: L. = R.extension(y^2 - x^3 - 1) We make the field automorphism that sends y to -y:: sage: f = L.hom(-y); f Morphism of function fields defined by y |--> -y Evaluation works:: sage: f(y*x - 1/x) -x*y - 1/x We try to define an invalid morphism:: sage: f = L.hom(y+1); f Traceback (most recent call last): ... ValueError: invalid morphism We make a morphism of the base rational function field:: sage: phi = R.hom(x+1); phi Morphism of function fields defined by x |--> x + 1 sage: phi(x^3 - 3) x^3 + 3*x^2 + 3*x - 2 sage: (x+1)^3-3 x^3 + 3*x^2 + 3*x - 2 We make a morphism by specifying where the generators and the base generators go:: sage: L.hom([-y, x]) Morphism of function fields defined by y |--> -y,  x |--> x We make another extension of a rational function field:: sage: R2. = FunctionField(QQ); S2. = R2[] sage: L2. = R.extension((4*w)^2 - (t+1)^3 - 1) We define a morphism, by givin the images of generators:: sage: f = L.hom([4*w, t+1]); f Morphism of function fields defined by y |--> 4*w,  x |--> t + 1 Evaluation works, as expected:: sage: f(y+x) 4*w + t + 1 sage: f(x*y + x/(x^2+1)) (4*t + 4)*w + (t + 1)/(t^2 + 2*t + 2) """ if not isinstance(im_gens, (list,tuple)): im_gens = [im_gens] if len(im_gens) > 1: base_morphism = self.base_field().hom(im_gens[1:], base_morphism) return maps.FunctionFieldMorphism(self.Hom(im_gens[0].parent()), im_gens[0], base_morphism) class FunctionField_polymod(FunctionField): """ A function field defined by a univariate polynomial, as an """ return self def hom(self, im_gens, base_morphism=None): """ Create a homomorphism from self to another function field. INPUT: - ``im_gens`` -- exactly one element of some function field - ``base_morphism`` -- ignored OUTPUT: - a map between function fields EXAMPLES:: We make a map from a rational function field to itself:: sage: R. = FunctionField(GF(7)) sage: R.hom( (x^4 + 2)/x) Morphism of function fields defined by x |--> (x^4 + 2)/x We construct a map from a rational function field into a non-rational extension field:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x) sage: f = R.hom(y^2 + y  + 2); f Morphism of function fields defined by x |--> y^2 + y + 2 sage: f(x) y^2 + y + 2 sage: f(x^2) 5*y^2 + (x^3 + 6*x + 4)*y + 2*x^3 + 5*x + 4 """ if not isinstance(im_gens, (list,tuple)): im_gens = [im_gens] if len(im_gens) != 1: raise ValueError, "there must be exactly one generator" x = im_gens[0] return maps.FunctionFieldMorphism_rational(self.Hom(x.parent()), x) def field(self): """ Return the underlying field, forgetting the function field
• ## sage/rings/function_field/maps.py

`diff -r 37ea57b6855e -r c09927d141ce sage/rings/function_field/maps.py`
 a v = y.list() w = v + [self._zero]*(self._n - len(v)) return self._V(w) ########################################################################## # Morphisms between function fields class FunctionFieldMorphism(Map): """ EXAMPLES:: sage: R. = FunctionField(QQ); S. = R[] sage: L. = R.extension(y^2 - x^2) sage: f = L.hom(-y); f Morphism of function fields defined by y |--> -y """ def __init__(self, parent, im_gen, base_morphism): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2); f Morphism of function fields defined by y |--> 2*y sage: type(f) sage: factor(L.polynomial()) y^3 + 6*x^3 + x sage: f(y).charpoly('y') y^3 + 6*x^3 + x """ self._im_gen = im_gen self._base_morphism = base_morphism Map.__init__(self, parent) # Verify that the morphism is valid: R = self.codomain()['X'] v = parent.domain().polynomial().list() if base_morphism is not None: v = [base_morphism(a) for a in v] f = R(v) if f(im_gen): raise ValueError, "invalid morphism" def is_injective(self): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) sage: f.is_injective() True """ return True def __repr__(self): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) sage: f.__repr__() 'Morphism of function fields defined by y |--> 2*y' """ return "Morphism of function fields defined by %s"%self._short_repr() def __nonzero__(self): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) sage: f.__nonzero__() True sage: bool(f) True """ return True def _short_repr(self): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) sage: f._short_repr() 'y |--> 2*y' """ a = '%s |--> %s'%(self.domain().gen(), self._im_gen) if self._base_morphism is not None: a += ',  ' + self._base_morphism._short_repr() return a def _call_(self, x): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); S. = R[] sage: L. = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) sage: f(y/x + x^2/(x+1))            # indirect doctest 2/x*y + x^2/(x + 1) sage: f(y) 2*y """ v = x.list() if self._base_morphism is not None: v = [self._base_morphism(a) for a in v] f = v[0].parent()['X'](v) return f(self._im_gen) class FunctionFieldMorphism_rational(FunctionFieldMorphism): def __init__(self, parent, im_gen): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); f = R.hom(1/x); f Morphism of function fields defined by x |--> 1/x sage: type(f) """ Map.__init__(self, parent) self._im_gen = im_gen self._base_morphism = None def _call_(self, x): """ EXAMPLES:: sage: R. = FunctionField(GF(7)); f = R.hom(1/x); f Morphism of function fields defined by x |--> 1/x sage: f(x+1)                          # indirect doctest (x + 1)/x sage: 1/x + 1 (x + 1)/x """ a = x.element() return a.subs({a.parent().gen():self._im_gen})
• ## sage/rings/function_field/todo.txt

`diff -r 37ea57b6855e -r c09927d141ce sage/rings/function_field/todo.txt`
 a TODO: [ ] isomorphisms between function fields: K.hom([top gen, next one down, etc.]) make sure you include easy way to gens all the way down. [ ] Hess's algorithm [ ] reduction algorithm [ ] Hess's RR spaces algorithm [ ] factoring polynomials in n variables over rational function field [ ] reduction algorithm [ ] new implementation of the function field API using Singular; for *speed*, but with less base rings supported...? [ ] polynomial factoring of any univariate poly over a non-rational function field [ ] checking irreducibility in FunctionField_polymod constructor DONE: [x] isomorphisms between function fields: K.hom([top gen, next one down, etc.]) make sure you include easy way to gens all the way down. [x] inverses of fractional ideals [x] factor for elements of the rational function field [x] ideals