# Ticket #8335: trac_8335_sd51.patch

File trac_8335_sd51.patch, 35.6 KB (added by pbruin, 8 years ago)

to work on during Sage Days 51

• ## sage/categories/pushout.py

```# HG changeset patch
# User Peter Bruin <peter.bruin@math.uzh.ch>
# Date 1374618061 -7200
# Node ID 6b7dc03ff604c73152aeb22cdeb5eba17f8bbe45
# Parent  c34bbb1813e6342c416fff2472043d9a8c2728b4
Trac 8335: unified and rebased, to be worked on during Sage Days 51

diff --git a/sage/categories/pushout.py b/sage/categories/pushout.py```
 a ... TypeError: Could not find a mapping of the passed element to this ring. """ rank = 7 rank = 4.5 def __init__(self, I, names=None, as_field=False): """ Note that the ``quo()`` method of a field used to return the integer zero. That strange behaviour was removed in trac ticket #9138. It now returns a trivial quotient ring when applied to a field:: ticket :trac:`9138`. It now returns a trivial quotient ring when applied to a field:: sage: F = ZZ.quo([5]*ZZ).construction()[0] sage: F(QQ) is Integers(1) True sage: F(QQ) Ring of integers modulo 1 sage: QQ.quo(5) Quotient of Rational Field by the ideal (1) """ I = self.I from sage.all import QQ """ rank = 3 def __init__(self, polys, names, embeddings, cyclotomic=None): def __init__(self, polys, names, embeddings, cyclotomic=None, conway=None, prefix=None): """ INPUT: - ``polys``: a list of polynomials - ``polys``: a list of polynomials (or of integers, for finite fields and unramified local extensions) - ``names``: a list of strings of the same length as the list ``polys`` - ``embeddings``: a list of approximate complex values, - ``cyclotomic``: optional integer. If it is provided, application of the functor to the rational field yields a cyclotomic field, rather than just a number field. - ``conway``: optional integer. If it is provided, application of the functor to finite fields yields pseudo-Conway extensions of the given degree. - ``prefix``: optional string.  If it is provided, it will allow application of this functor to some finite fields to function without providing a variable name REMARK: self.names = list(names) self.embeddings = list(embeddings) self.cyclotomic = int(cyclotomic) if cyclotomic is not None else None from sage.rings.integer import Integer self.conway = Integer(conway) if conway is not None else None self.prefix = prefix def _apply_functor(self, R): """ Univariate Quotient Polynomial Ring in a over Real Field with 53 bits of precision with modulus a^3 + a^2 + 1.00000000000000 """ from sage.all import QQ, ZZ, CyclotomicField from sage.rings.finite_rings.finite_field_base import is_FiniteField if self.cyclotomic: if R==QQ: return CyclotomicField(self.cyclotomic) if R==ZZ: return CyclotomicField(self.cyclotomic).maximal_order() if len(self.polys) == 1: return R.extension(self.polys[0], self.names[0], embedding=self.embeddings[0]) if len(self.polys) == 1 or self.conway is not None: if is_FiniteField(R): if self.conway is not None: return R.extension(self.conway, self.names[0], embedding=self.embeddings[0], prefix=self.prefix) else: return R.extension(self.polys[0], self.names[0], embedding=self.embeddings[0], prefix=self.prefix) else: return R.extension(self.polys[0], self.names[0], embedding=self.embeddings[0]) return R.extension(self.polys, self.names, embedding=self.embeddings) def __cmp__(self, other): associated with the pushout of the codomains of the two embeddings is returned, provided that it is a number field. - If these two extensions are defined by Conway polynomials over finite fields (indicated by the fact that their ``conway`` fields are integers and not None), merges them into a single extension of degree the lcm of the two degrees. - Otherwise, None is returned. REMARK: Algebraic extension with embeddings currently only why we use the admittedly strange rule above for merging. TESTS:: EXAMPLES: The following demonstrate coercions for finite fields using Conway or pseudo-Conway polynomials:: sage: k = GF(3^2); a = k.gen() sage: l = GF(3^3); b = l.gen() sage: a + b # indirect doctest z6^5 + 2*z6^4 + 2*z6^3 + z6^2 + 2*z6 + 1 Note that embeddings are compatible in lattices of such finite fields:: sage: m = GF(3^5); c = m.gen() sage: (a+b)+c == a+(b+c) # indirect doctest True sage: from sage.categories.pushout import pushout sage: n = pushout(k, l) sage: o = pushout(l, m) sage: q = pushout(n, o) sage: q(o(b)) == q(n(b)) # indirect doctest True Coercion is also available for number fields:: sage: P. = QQ[] sage: L. = NumberField(x^8-x^4+1, embedding=CDF.0) sage: c1+c2; parent(c1+c2)    #indirect doctest -b^6 + b^4 - 1 Number Field in b with defining polynomial x^8 - x^4 + 1 sage: from sage.categories.pushout import pushout sage: pushout(M1['x'],M2['x']) Univariate Polynomial Ring in x over Number Field in b with defining polynomial x^8 - x^4 + 1 CoercionException: ('Ambiguous Base Extension', Number Field in a with defining polynomial x^3 - 2, Number Field in b with defining polynomial x^6 - 2) """ if not isinstance(other,AlgebraicExtensionFunctor): if isinstance(other, AlgebraicClosureFunctor): return other elif not isinstance(other,AlgebraicExtensionFunctor): return None if self == other: return self #                return self #            if  other.embeddings==[None]: #                return other # ... or we may use the given embeddings: # ... or we may use the given embeddings from sage.rings.integer import Integer # finite fields use an Integer to encode the pseudo-Conway extension that allows pushouts if isinstance(self.conway, Integer) and isinstance(other.conway, Integer) and self.prefix is not None and self.prefix == other.prefix: if self.embeddings != [None] or other.embeddings != [None]: raise NotImplementedError polys = self.polys+other.polys return AlgebraicExtensionFunctor(polys,[None]*len(polys),[None]*len(polys),conway=self.conway.lcm(other.conway),prefix=self.prefix) if self.embeddings!=[None] and other.embeddings!=[None]: from sage.all import QQ KS = self(QQ) """ if len(self.polys)==1: return [self] return [AlgebraicExtensionFunctor([self.polys[i]], [self.names[i]], [self.embeddings[i]]) for i in range(len(self.polys))] return [AlgebraicExtensionFunctor([self.polys[i]], [self.names[i]], [self.embeddings[i]], conway=[self.polys[i].degree()] if self.conway is not None else None, prefix=self.prefix) for i in range(len(self.polys))] class AlgebraicClosureFunctor(ConstructionFunctor): """ S_tower = construction_tower(S) Rs = [c[1] for c in R_tower] Ss = [c[1] for c in S_tower] if R in Ss: return S elif S in Rs: return R if R_tower[-1][1] in Ss: if Rs[-1] in Ss: Rs, Ss = Ss, Rs R_tower, S_tower = S_tower, R_tower
• ## sage/interfaces/singular.py

`diff --git a/sage/interfaces/singular.py b/sage/interfaces/singular.py`
 a sage: singular.eval('minpoly = 1+z+z2+z3+z4') 'minpoly = 1+z+z2+z3+z4;' sage: singular('r3').sage_global_ring() Multivariate Polynomial Ring in a, b, c over Univariate Quotient Polynomial Ring in z over Finite Field of size 3 with modulus z^4 + z^3 + z^2 + z + 1 Multivariate Polynomial Ring in a, b, c over Finite Field in z of size 3^4 Real and complex fields in both Singular and Sage are defined with a precision. The precision in Singular is given in terms of digits, but in Sage it is given singular.eval('short=%s'%is_short) else: minpoly = ZZ[charstr[1]](minpoly) BR = br.extension(minpoly) BR = br.extension(minpoly,name=charstr[1]) else: BR = br 'minpoly = 1+z+z2+z3+z4;' sage: p = singular('z^4*a^3+z^2*a*b*c') sage: p.sage_poly() (2*z^3 + 2*z^2 + 2*z + 2)*a^3 + z^2*a*b*c (-z^3 - z^2 - z - 1)*a^3 + (z^2)*a*b*c sage: singular('z^4') (-z3-z2-z-1)
• ## sage/rings/finite_rings/constructor.py

`diff --git a/sage/rings/finite_rings/constructor.py b/sage/rings/finite_rings/constructor.py`
 a sage: a 2 The following demonstrate coercions for finite fields using Conway or pseudo-Conway polynomials:: sage: k = GF(5^2); a = k.gen() sage: l = GF(5^5); b = l.gen() sage: a + b 3*z10^5 + z10^4 + z10^2 + 3*z10 + 1 Note that embeddings are compatible in lattices of such finite fields:: sage: m = GF(5^3); c = m.gen() sage: (a+b)+c == a+(b+c) True sage: (a*b)*c == a*(b*c) True sage: from sage.categories.pushout import pushout sage: n = pushout(k, l) sage: o = pushout(l, m) sage: q = pushout(n, o) sage: q(o(b)) == q(n(b)) True Another check that embeddings are defined properly:: sage: k = GF(3**10) sage: l = GF(3**20) sage: l(k.gen()**10) == l(k.gen())**10 True """ def create_key_and_extra_args(self, order, name=None, modulus=None, names=None, impl=None, proof=None, **kwds): """ EXAMPLES:: sage: GF.create_key_and_extra_args(9, 'a') ((9, ('a',), x^2 + 2*x + 2, None, '{}', 3, 2, True), {}) sage: GF.create_key_and_extra_args(9, 'a', foo='value')
• ## sage/rings/finite_rings/element_base.pyx

`diff --git a/sage/rings/finite_rings/element_base.pyx b/sage/rings/finite_rings/element_base.pyx`
 a cdef class FiniteRingElement(CommutativeRingElement): def _nth_root_common(self, n, all, algorithm, cunningham): """ This function exists to reduce code duplication between finite field nth roots and integer_mod nth roots. This function exists to reduce code duplication between finite field nth roots and integer_mod nth roots. The inputs are described there. TESTS:: sage: a = Zmod(17)(13) sage: a._nth_root_common(4, True, "Johnston", False) [3, 5, 14, 12] - ``all`` - bool (default: ``False``); if ``True``, return all `n`\th roots of ``self``, instead of just one. - ``algorithm`` - string (default: ``None``); 'Johnston' is the only - ``algorithm`` - string (default: ``None``); 'Johnston' is the only currently supported option.  For IntegerMod elements, the problem is reduced to the prime modulus case using CRT and `p`-adic logs, and then this algorithm used. OUTPUT: If self has an `n`\th root, returns one (if ``all`` is ``False``) or a list of all of them (if ``all`` is ``True``).  Otherwise, raises a ValueError (if ``extend`` is ``False``) or a ``NotImplementedError`` (if ``extend`` is ``True``). list of all of them (if ``all`` is ``True``). Otherwise, raises a ``ValueError`` (if ``extend`` is ``False``) or a ``NotImplementedError`` (if ``extend`` is ``True``). .. warning:: The 'extend' option is not implemented (yet). The ``extend`` option is not implemented (yet). EXAMPLES::
• ## sage/rings/finite_rings/element_ntl_gf2e.pyx

`diff --git a/sage/rings/finite_rings/element_ntl_gf2e.pyx b/sage/rings/finite_rings/element_ntl_gf2e.pyx`
 a sage: g = K.random_element() sage: g.minpoly()(g) 0 We check that the NTL modulus is restored properly:: sage: k. = GF(2^1000) sage: b = a^(k.order()//(2^20-1)) sage: l. = GF(2^20) sage: b.minpoly() x^20 + x^17 + x^16 + x^14 + x^13 + x^11 + x^8 + x^7 + x^3 + x + 1 """ (self._parent._cache).F.restore() cdef GF2X_c r = GF2X_IrredPolyMod(GF2E_rep(self.x), GF2E_modulus())
• ## sage/rings/finite_rings/finite_field_base.pyx

`diff --git a/sage/rings/finite_rings/finite_field_base.pyx b/sage/rings/finite_rings/finite_field_base.pyx`
 a ... TypeError: images do not define a valid homomorphism """ if (self.characteristic() != codomain.characteristic()): raise ValueError, "no map from %s to %s"%(self, codomain) if (len(im_gens) != 1): [2^4 * 3] """ if self.__factored_unit_order is None: if self.characteristic() in []: # want to be [2,3,5,7,11] once #7240 is finished. from sage.rings.factorint import factor_cunningham self.__factored_unit_order = [factor_cunningham(self.order()-1)] else: self.__factored_unit_order = [(self.order()-1).factor()] self.__factored_unit_order = [(self.order()-1).factor()] return self.__factored_unit_order def cardinality(self): """ return hash("GF") + hash(self.order()) def construction(self): """ Return the construction of this finite field, as a ``ConstructionFunctor`` and the base field. EXAMPLES:: sage: v = GF(3^3).construction(); v (AlgebraicExtensionFunctor, Finite Field of size 3) sage: v[0].polys[0] z3^3 + 2*z3 + 1 sage: v = GF(2^1000,'a').construction(); v[0].polys[0] a^1000 + a^5 + a^4 + a^3 + 1 """ from sage.categories.pushout import AlgebraicExtensionFunctor if self.degree() == 1: # this is not of type FiniteField_prime_modn from sage.rings.integer import Integer return AlgebraicExtensionFunctor([self.polynomial()],[None],[None],conway=1), self.base_ring() elif hasattr(self, '_PCPT') and self._PCPT is not None: return AlgebraicExtensionFunctor([self.polynomial()],[self.variable_name()],[None],conway=self.degree(),prefix=self._prefix), self.base_ring() else: return AlgebraicExtensionFunctor([self.polynomial()],[self.variable_name()],[None]), self.base_ring() def extension(self, modulus, name=None, names=None, embedding=None, conway=None, prefix='z'): """ Return an extension of this finite field. INPUT: - ``modulus`` -- either a polynomial with coefficients in this field or an integer. If an Integer, returns the pseudo-Conway extension of this field of that degree. - ``name`` -- the name of the generator in the new extension - ``embedding`` -- currently not used; for compatibility with other ``AlgebraicExtensionFunctor`` calls. - ``conway`` -- currently not used; None or an ``Integer`` used to indicate that the extension is pseudo-Conway of the given degree. - ``prefix`` -- Passed on to the finite field constructor. See the documentation of ``GF`` in ``sage.rings.finite_rings.constructor`` OUTPUT: An extension of the given modulus, or pseudo-Conway of the given degree if ``conway`` is an integer. EXAMPLES:: sage: k = GF(2) sage: R. = k[] sage: k.extension(x^1000 + x^5 + x^4 + x^3 + 1, 'a') Finite Field in a of size 2^1000 sage: k = GF(3^4) sage: R. = k[] sage: k.extension(3) Finite Field in z12 of size 3^12 Extensions of non-prime finite fields by polynomials are not yet supported: we fall back to generic code:: sage: k.extension(x^5 + x^2 + x - 1) Univariate Quotient Polynomial Ring in x over Finite Field in z4 of size 3^4 with modulus x^5 + x^2 + x + 2 """ from constructor import GF from sage.rings.polynomial.all import is_Polynomial from sage.rings.integer import Integer if name is None and names is not None: name = names if self.degree() == 1: if isinstance(modulus, Integer): return GF(self.characteristic()**modulus, modulus='conway', name=name, prefix=prefix) elif isinstance(modulus, (list, tuple)): return GF(self.characteristic()**(len(modulus) - 1), name=name, modulus=modulus, prefix=prefix) elif is_Polynomial(modulus): if modulus.change_ring(self).is_irreducible(): return GF(self.characteristic()**(modulus.degree()), name=name, modulus=modulus, prefix=prefix) else: return Field.extension(self, modulus, name=name, embedding=embedding) elif isinstance(modulus, Integer): if hasattr(self, '_PCPT') and self._PCPT is not None: return GF(self.order()**modulus, name=name, prefix=prefix) return Field.extension(self, modulus, name=name, embedding=embedding) def subfields(self, degree=0, name=None): """ Return all proper subfields of ``self`` of the given ``degree``, or of all possible degrees if ``degree`` is `0`. The subfields are returned as absolute fields together with an embedding into ``self``. INPUT: - ``degree`` -- (default: `0`) an integer - ``name`` -- a string, a dictionary or ``None``: - If ``degree`` is nonzero, ``name`` must be a string (or ``None``, if this is a pseudo-Conway extension), and will be the variable name of the returned field. - If ``degree`` is zero, the dictionary should have keys the divisors of the degree of this field, with the desired variable name for the field of that degree as an entry. - As a shortcut, you can provide a string and the degree of each subfield will be appended for the variable name of that subfield. - If ``None``, uses the prefix of this field. OUTPUT: A list of pairs ``(K, e)``, where ``K`` ranges over the subfields of this field and ``e`` gives an embedding of ``K`` into this field. EXAMPLES:: sage: k. = GF(2^21) sage: k.subfields() [(Finite Field of size 2, Conversion map: From: Finite Field of size 2 To:   Finite Field in a of size 2^21), (Finite Field in z3 of size 2^3, Ring morphism: From: Finite Field in z3 of size 2^3 To:   Finite Field in a of size 2^21 Defn: z3 |--> a^20 + a^19 + a^17 + a^15 + a^11 + a^9 + a^8 + a^6 + a^2), (Finite Field in z7 of size 2^7, Ring morphism: From: Finite Field in z7 of size 2^7 To:   Finite Field in a of size 2^21 Defn: z7 |--> a^20 + a^19 + a^17 + a^15 + a^14 + a^6 + a^4 + a^3 + a)] """ from sage.rings.integer import Integer from constructor import GF p = self.characteristic() if degree != 0: degree = Integer(degree) if degree.divides(self.degree()): if hasattr(self, '_PCPT') and self._PCPT is not None: K = GF(p**degree, name=name, prefix=self._prefix) return [K, self.coerce_map_from(K)] elif degree == 1: K = GF(p) return [K, self.coerce_map_from(K)] else: deg_gen = self.multiplicative_generator()**((self.order() - 1)//(p**degree-1)) from homset import FiniteFieldHomset, FiniteFieldHomomorphism_im_gens K = GF(p**degree, modulus=deg_gen.minimal_polynomial(), name=name, prefix=self._prefix) return [K, FiniteFieldHomomorphism_im_gens(FiniteFieldHomset(K, self), deg_gen)] else: return [] if hasattr(self, '_PCPT') and self._PCPT is not None: if name is None: name = self._prefix else: if isinstance(name, str): prefix = name name = {} else: if self._prefix is None: prefix = self.variable_name() else: prefix = self._prefix if name is None: name = {} elif not isinstance(name, dict): raise ValueError, "name must be None, a string or a dictionary indexed by divisors of the degree" for m in self.degree().divisors(): name[m] = prefix + str(m) ans = [] from homset import FiniteFieldHomset, FiniteFieldHomomorphism_im_gens for m in self.degree().divisors(): if m == self.degree(): continue if hasattr(self, '_PCPT') and self._PCPT is not None: K = GF(p**m, prefix=name) ans.append((K, self.coerce_map_from(K))) elif m == 1: ans.append((GF(p), self.coerce_map_from(K))) else: deg_gen = self.multiplicative_generator()**((self.order() - 1)//(p**m-1)) K = GF(p**m, modulus=deg_gen.minimal_polynomial(), name=name[m]) print K ans.append((K, FiniteFieldHomomorphism_im_gens(FiniteFieldHomset(K, self), deg_gen))) return ans def algebraic_closure(self): """ Return the algebraic closure of ``self`` (not implemented). This is not yet implemented for finite fields. EXAMPLES:: sage: GF(5).algebraic_closure() Traceback (most recent call last): ... r""" Used to unpickle finite prime fields. Now superseded (hence no doctest), but kept around for backward compatibility. EXAMPLE:: sage: # not tested False """ return IS_INSTANCE(x, FiniteField)
• ## sage/rings/finite_rings/finite_field_ext_pari.py

`diff --git a/sage/rings/finite_rings/finite_field_ext_pari.py b/sage/rings/finite_rings/finite_field_ext_pari.py`
 a ... TypeError: no canonical coercion from Finite Field in a of size 2^2 to Finite Field in a of size 2^3 sage: FiniteField_ext_pari(16,'a')._coerce_(FiniteField_ext_pari(4,'a').0) Traceback (most recent call last): ... TypeError: no canonical coercion from Finite Field in a of size 2^2 to Finite Field in a of size 2^4 a^2 + a sage: k = FiniteField_ext_pari(8,'a') sage: k._coerce_(FiniteField(7,'a')(2)) Traceback (most recent call last): TypeError: no canonical coercion from Finite Field of size 7 to Finite Field in a of size 2^3 """ from sage.rings.integer_ring import ZZ from sage.rings.finite_rings.finite_field_base import is_FiniteField from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic if R is int or R is long or R is ZZ: return True if isinstance(R, FiniteField_ext_pari): if is_FiniteField(R): if R is self: return True from sage.rings.residue_field import ResidueField_generic if isinstance(R, ResidueField_generic): return False if R.characteristic() == self.characteristic(): if isinstance(R, IntegerModRing_generic): return True if R.degree() == 1: return True elif self.degree() % R.degree() == 0: # TODO: This is where we *would* do coercion from one nontrivial finite field to another... return False from sage.rings.residue_field import ResidueField_generic if isinstance(R, IntegerModRing_generic) and R.characteristic() == self.characteristic() and not isinstance(R, ResidueField_generic): return True if self.degree() % R.degree() == 0: if hasattr(self, '_PCPT') and hasattr(R, '_PCPT') and R._PCPT is not None: from homset import FiniteFieldHomset, FiniteFieldHomomorphism_im_gens return FiniteFieldHomomorphism_im_gens(FiniteFieldHomset(R, self), self.gen()**((self.order()-1)//(R.order()-1))) def __len__(self): """
• ## sage/rings/finite_rings/finite_field_givaro.py

`diff --git a/sage/rings/finite_rings/finite_field_givaro.py b/sage/rings/finite_rings/finite_field_givaro.py`
 a sage: F9 = FiniteField_givaro(9) sage: F81 = FiniteField_givaro(81) sage: F81(F9.gen()) Traceback (most recent call last): ... TypeError: unable to coerce from a finite field other than the prime subfield 2*a^3 + 2*a^2 + 1 """ return self._cache.element_from_data(e) return True if R.degree() == 1: return True elif self.degree() % R.degree() == 0: # This is where we *would* do coercion from one nontrivial finite field to another... # We use this error message for backward compatibility until #8335 is finished raise TypeError, "unable to coerce from a finite field other than the prime subfield" if self.degree() % R.degree() == 0: if hasattr(self, '_PCPT') and hasattr(R, '_PCPT') and R._PCPT is not None: from homset import FiniteFieldHomset, FiniteFieldHomomorphism_im_gens return FiniteFieldHomomorphism_im_gens(FiniteFieldHomset(R, self), self.gen()**((self.order()-1)//(R.order()-1))) def gen(self, n=0): r"""
• ## sage/rings/finite_rings/finite_field_ntl_gf2e.py

`diff --git a/sage/rings/finite_rings/finite_field_ntl_gf2e.py b/sage/rings/finite_rings/finite_field_ntl_gf2e.py`
 a return True if isinstance(R, ResidueField_generic): return False if isinstance(R, IntegerModRing_generic) and R.characteristic() % 2 == 0: return True if R.characteristic() == 2: if isinstance(R, IntegerModRing_generic): return True if R.degree() == 1: return True elif self.degree() % R.degree() == 0: # This is where we *would* do coercion from one nontrivial finite field to another... raise NotImplementedError if self._PCPT is not None and hasattr(R, '_PCPT') and R._PCPT is not None: from homset import FiniteFieldHomset, FiniteFieldHomomorphism_im_gens return FiniteFieldHomomorphism_im_gens(FiniteFieldHomset(R, self), self.gen()**((self.order()-1)//(R.order()-1))) def gen(self, ignored=None): r"""
• ## sage/rings/finite_rings/finite_field_prime_modn.py

`diff --git a/sage/rings/finite_rings/finite_field_prime_modn.py b/sage/rings/finite_rings/finite_field_prime_modn.py`
 a if to_ZZ is not None: return integer_mod.Integer_to_IntegerMod(self) * to_ZZ def construction(self): """ Returns the construction of this finite field (for use by sage.categories.pushout) EXAMPLES:: sage: GF(3).construction() (QuotientFunctor, Integer Ring) """ return integer_mod_ring.IntegerModRing_generic.construction(self) def characteristic(self): r""" Return the characteristic of \code{self}.
• ## sage/rings/finite_rings/homset.py

`diff --git a/sage/rings/finite_rings/homset.py b/sage/rings/finite_rings/homset.py`
 a """ Set of homomorphisms with domain a given finite field. """ #     def __init__(self, R, S, category=None): #         if category is None: #             from sage.categories.finite_fields import FiniteFields #             category = FiniteFields() #         RingHomset_generic.__init__(self, R, S, category) def __call__(self, im_gens, check=True): """ Construct the homomorphism defined by ``im_gens``.
• ## sage/rings/finite_rings/integer_mod.pyx

`diff --git a/sage/rings/finite_rings/integer_mod.pyx b/sage/rings/finite_rings/integer_mod.pyx`
 a IntegerMod_abstract.__init__(self, parent) if empty: return if self.__modulus.int32 == 1: self.ivalue = 0 return cdef long x if PY_TYPE_CHECK(value, int): x = value
• ## sage/rings/finite_rings/integer_mod_ring.py

`diff --git a/sage/rings/finite_rings/integer_mod_ring.py b/sage/rings/finite_rings/integer_mod_ring.py`
 a """ return True def extension(self, poly, name=None, names=None, embedding=None): if self.modulus() == 1: return self else: from sage.rings.ring import CommutativeRing return CommutativeRing.extension(self, poly, name, names, embedding) @cached_method def is_prime_field(self): """
• ## sage/rings/polynomial/polynomial_quotient_ring.py

`diff --git a/sage/rings/polynomial/polynomial_quotient_ring.py b/sage/rings/polynomial/polynomial_quotient_ring.py`
 a -  ``ring`` - a univariate polynomial ring in one variable. -  ``polynomial`` - element -  ``polynomial`` - element with unit leading coefficient -  ``names`` - (optional) name for the variable
• ## sage/rings/polynomial/polynomial_quotient_ring_element.py

`diff --git a/sage/rings/polynomial/polynomial_quotient_ring_element.py b/sage/rings/polynomial/polynomial_quotient_ring_element.py`
 a raise TypeError, "polynomial must be in the polynomial ring of the parent" f = parent.modulus() if polynomial.degree() >= f.degree(): if polynomial.degree() >= f.degree() and polynomial.degree() >= 0: try: polynomial %= f except AttributeError: while R.degree() >= B.degree(): S = P((R.leading_coefficient()/B.leading_coefficient())) * X**(R.degree()-B.degree()) Q = Q + S R = R - S*B R = R - S*B polynomial = R self._polynomial = polynomial
• ## sage/rings/polynomial/polynomial_ring.py

`diff --git a/sage/rings/polynomial/polynomial_ring.py b/sage/rings/polynomial/polynomial_ring.py`
 a from polynomial_real_mpfr_dense import PolynomialRealDense from sage.rings.polynomial.polynomial_singular_interface import PolynomialRing_singular_repr from sage.rings.fraction_field_element import FractionFieldElement from sage.rings.finite_rings.element_base import FiniteRingElement from polynomial_element import PolynomialBaseringInjection x = x.numerator() * x.denominator().inverse_of_unit() else: raise TypeError, "denominator must be a unit" elif isinstance(x, pari_gen): if x.type() == 't_RFRAC': raise TypeError, "denominator must be a unit" if x.type() != 't_POL': x = x.Polrev() elif isinstance(x, FiniteRingElement): try: return self(x.polynomial()) except AttributeError: pass return C(self, x, check, is_gen, construct=construct, **kwds) def is_integral_domain(self, proof = True):
• ## sage/sets/set.py

`diff --git a/sage/sets/set.py b/sage/sets/set.py`
 a sage: Set(GF(2)) + Set(GF(4,'a')) {0, 1, a, a + 1} sage: Set(GF(8,'b')) + Set(GF(4,'a')) {0, 1, b, b + 1, b^2, b^2 + 1, b^2 + b, b^2 + b + 1, a, a + 1, 1, 0} {0, 1, b, b + 1, b^2, b^2 + 1, b^2 + b, b^2 + b + 1, a, a + 1} """ return self.union(X) sage: X = Set(GF(9,'b')).intersection(Set(GF(27,'c'))) sage: X {} {0, 1, 2} sage: X = Set(GF(9,'b')).intersection(Set(GF(27,'b'))) sage: X {} {0, 1, 2} """ if is_Set(X): if self is X: sage: X = Set(GF(9,'b')).difference(Set(GF(27,'c'))) sage: X {0, 1, 2, b, b + 1, b + 2, 2*b, 2*b + 1, 2*b + 2} {b, b + 1, b + 2, 2*b, 2*b + 1, 2*b + 2} sage: X = Set(GF(9,'b')).difference(Set(GF(27,'b'))) sage: X {0, 1, 2, b, b + 1, b + 2, 2*b, 2*b + 1, 2*b + 2} {b, b + 1, b + 2, 2*b, 2*b + 1, 2*b + 2} """ if is_Set(X): if self is X: