def polynomial_default_category(base_ring, multivariate):
    """
    Choose an appropriate category for a polynomial ring.

    INPUT:

    - ``base_ring``: The ring over which the polynomial ring shall be defined.
    - ``multivariate``: Will the polynomial ring be multivariate?

    EXAMPLES::

        sage: QQ['t'].category() is Category.join([EuclideanDomains(), CommutativeAlgebras(QQ)])
        True
        sage: QQ['s','t'].category() is Category.join([UniqueFactorizationDomains(), CommutativeAlgebras(QQ)])
        True
        sage: QQ['s']['t'].category() is Category.join([UniqueFactorizationDomains(), CommutativeAlgebras(QQ['s'])])
        True

    """
    if base_ring in _Fields:
        if multivariate:
            return JoinCategory(
                (_UniqueFactorizationDomains, CommutativeAlgebras(base_ring)))
        return JoinCategory(
            (_EuclideanDomains, CommutativeAlgebras(base_ring)))
    if base_ring in _UFD:  #base_ring.is_unique_factorization_domain():
        return JoinCategory(
            (_UniqueFactorizationDomains, CommutativeAlgebras(base_ring)))
    if base_ring in _ID:  #base_ring.is_integral_domain():
        return JoinCategory((_IntegralDomains, CommutativeAlgebras(base_ring)))
    if base_ring in _CommutativeRings:  #base_ring.is_commutative():
        return CommutativeAlgebras(base_ring)
    return Algebras(base_ring)
예제 #2
0
        sage: is_IntegerModRing(GF(13))
        True
        sage: is_IntegerModRing(GF(4, 'a'))
        False
        sage: is_IntegerModRing(10)
        False
        sage: is_IntegerModRing(ZZ)
        False
    """
    return isinstance(x, IntegerModRing_generic)


from sage.categories.commutative_rings import CommutativeRings
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
from sage.categories.category import JoinCategory
default_category = JoinCategory((CommutativeRings(), FiniteEnumeratedSets()))
ZZ = integer_ring.IntegerRing()


def _unit_gens_primepowercase(p, r):
    r"""
    Return a list of generators for `(\ZZ/p^r\ZZ)^*` and their orders.

    EXAMPLES::

        sage: from sage.rings.finite_rings.integer_mod_ring import _unit_gens_primepowercase
        sage: _unit_gens_primepowercase(2, 3)
        [(7, 2), (5, 2)]
        sage: _unit_gens_primepowercase(17, 1)
        [(3, 16)]
        sage: _unit_gens_primepowercase(3, 3)