Ticket #9944: trac_9944.patch

File trac_9944.patch, 3.9 KB (added by mhansen, 9 years ago)
  • new file sage/categories/polynomial_rings.py

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1284849691 25200
    # Node ID ad4e9cd85475d30844f6f757f7566490092d12cf
    # Parent  478ba3a91f6d9dd6dbe85a3107f7562d810e4ead
    #9944 - Categories for polynomial rings.
    
    diff --git a/sage/categories/polynomial_rings.py b/sage/categories/polynomial_rings.py
    new file mode 100644
    - +  
     1"""
     2Polynomial Rings
     3"""
     4
     5from category_types import Category_over_base_ring
     6import sage.categories.basic as categories
     7from sage.misc.cachefunc import cached_method
     8
     9class PolynomialRings(Category_over_base_ring):
     10    @cached_method
     11    def super_categories(self):
     12        """
     13        EXAMPLES::
     14
     15            sage: from sage.categories.polynomial_rings import PolynomialRings
     16            sage: PolynomialRings(ZZ).super_categories()
     17            [Category of unique factorization domains]
     18            sage: PolynomialRings(GF(7)).super_categories()
     19            [Category of euclidean domains]
     20        """
     21        R_cat = self.base_ring().category()
     22        if R_cat.is_subcategory(categories.Fields()):
     23            return [categories.EuclideanDomains()]
     24        elif R_cat.is_subcategory(categories.UniqueFactorizationDomains()):
     25            return [categories.UniqueFactorizationDomains()]
     26        elif R_cat.is_subcategory(categories.IntegralDomains()):
     27            return [categories.IntegralDomains()]
     28        else:
     29            return [categories.CommutativeRings()]
  • sage/categories/principal_ideal_domains.py

    diff --git a/sage/categories/principal_ideal_domains.py b/sage/categories/principal_ideal_domains.py
    a b  
    99#******************************************************************************
    1010
    1111from sage.categories.category import Category
    12 from sage.categories.basic import GcdDomains
    1312from sage.misc.cachefunc import cached_method
    1413
    1514class PrincipalIdealDomains(Category):
     
    2726      sage: PrincipalIdealDomains()
    2827      Category of principal ideal domains
    2928      sage: PrincipalIdealDomains().super_categories()
    30       [Category of gcd domains]
     29      [Category of unique factorization domains]
    3130
    3231    See also: http://en.wikipedia.org/wiki/Principal_ideal_domain
    3332
     
    4241        EXAMPLES::
    4342
    4443            sage: PrincipalIdealDomains().super_categories()
    45             [Category of gcd domains]
     44            [Category of unique factorization domains]
    4645        """
    47         return [GcdDomains()]
     46        from sage.categories.basic import UniqueFactorizationDomains
     47        return [UniqueFactorizationDomains()]
    4848
    4949    class ParentMethods:
    5050        pass
  • sage/rings/polynomial/polynomial_ring.py

    diff --git a/sage/rings/polynomial/polynomial_ring.py b/sage/rings/polynomial/polynomial_ring.py
    a b  
    9494
    9595from sage.structure.element import Element
    9696import sage.algebras.algebra
     97import sage.categories.basic as categories
    9798import sage.rings.commutative_ring as commutative_ring
    9899import sage.rings.commutative_algebra as commutative_algebra
    99100import sage.rings.ring as ring
     
    122123ZZ_sage = IntegerRing()
    123124
    124125from sage.interfaces.singular import SingularElement
    125 
     126from sage.categories.polynomial_rings import PolynomialRings
    126127
    127128def is_PolynomialRing(x):
    128129    """
     
    183184            0
    184185            sage: (x - 2/3)*(x^2 - 8*x + 16)
    185186            x^3 - 26/3*x^2 + 64/3*x - 32/3
     187           
     188            sage: category(ZZ['x'])
     189            Category of polynomial rings over Integer Ring
    186190        """
    187         sage.algebras.algebra.Algebra.__init__(self, base_ring, names=name, normalize=True)
     191        sage.algebras.algebra.Algebra.__init__(self, base_ring, names=name, normalize=True,
     192                                               category=PolynomialRings(base_ring))
    188193        self.__is_sparse = sparse
    189194        if element_class:
    190195            self._polynomial_class = element_class