Ticket #14084: trac14084_integral_domains.patch

File trac14084_integral_domains.patch, 8.6 KB (added by SimonKing, 7 years ago)
  • sage/categories/pushout.py

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1360443771 -3600
    # Node ID c7b9bf46e5172bcc4cb87b7a2d8305e14239d10d
    # Parent  b6c04eb72ffebf8cb9d5c28d6927b8e8568de829
    #14084: Define the FractionFields functor on integral domains, not rings.
    Choose the category of power series rings and of p-adic rings/fields appropriately.
    
    diff --git a/sage/categories/pushout.py b/sage/categories/pushout.py
    a b  
    18941894    EXAMPLE::
    18951895
    18961896        sage: F = QQ.construction()[0]
     1897        sage: F
     1898        FractionField
     1899        sage: F.domain()
     1900        Category of integral domains
     1901        sage: F.codomain()
     1902        Category of fields
    18971903        sage: F(GF(5)) is GF(5)
    18981904        True
    18991905        sage: F(ZZ['t'])
     
    19231929            sage: F(ZZ['t'])
    19241930            Fraction Field of Univariate Polynomial Ring in t over Integer Ring
    19251931        """
    1926         Functor.__init__(self, Rings(), Fields())
     1932        Functor.__init__(self, IntegralDomains(), Fields())
    19271933
    19281934    def _apply_functor(self, R):
    19291935        """
  • sage/rings/multi_power_series_ring.py

    diff --git a/sage/rings/multi_power_series_ring.py b/sage/rings/multi_power_series_ring.py
    a b  
    177177AUTHORS:
    178178
    179179- Niles Johnson (2010-07): initial code
    180 - Simon King (2012-08): Use category and coercion framework, :trac:`13412`
    181 
     180- Simon King (2012-08, 2013-02): Use category and coercion framework, :trac:`13412` and :trac: `14084`
    182181
    183182"""
    184183
     
    201200from sage.structure.nonexact import Nonexact
    202201
    203202from sage.rings.multi_power_series_ring_element import MPowerSeries
    204 
     203from sage.categories.commutative_rings import CommutativeRings
     204_CommutativeRings = CommutativeRings()
     205from sage.categories.integral_domains import IntegralDomains
     206_IntegralDomains = IntegralDomains()
    205207
    206208def is_MPowerSeriesRing(x):
    207209    """
     
    292294
    293295        EXAMPLES::
    294296
    295                 sage: R.<t,u,v> = PowerSeriesRing(QQ)
    296                 sage: g = 1 + v + 3*u*t^2 - 2*v^2*t^2
    297                 sage: g = g.add_bigoh(5); g
    298                 1 + v + 3*t^2*u - 2*t^2*v^2 + O(t, u, v)^5
    299                 sage: g in R
    300                 True
     297            sage: R.<t,u,v> = PowerSeriesRing(QQ)
     298            sage: g = 1 + v + 3*u*t^2 - 2*v^2*t^2
     299            sage: g = g.add_bigoh(5); g
     300            1 + v + 3*t^2*u - 2*t^2*v^2 + O(t, u, v)^5
     301            sage: g in R
     302            True
     303
     304        TESTS:
     305
     306        By :trac:`14084`, the multi-variate power series ring belongs to the
     307        category of integral domains, if the base ring does::
     308
     309            sage: P = ZZ[['x','y']]
     310            sage: P.category()
     311            Category of integral domains
     312            sage: TestSuite(P).run()
     313
     314        Otherwise, it belongs to the category of commutative rings::
     315
     316            sage: P = Integers(15)[['x','y']]
     317            sage: P.category()
     318            Category of commutative rings
     319            sage: TestSuite(P).run()
     320
    301321        """
    302322        order = TermOrder(order,num_gens)
    303323        self._term_order = order
     
    311331        # Multivariate power series rings inherit from power series rings. But
    312332        # apparently we can not call their initialisation. Instead, initialise
    313333        # CommutativeRing and Nonexact:
    314         CommutativeRing.__init__(self, base_ring, name_list)
     334        CommutativeRing.__init__(self, base_ring, name_list, category =
     335                                 _IntegralDomains if base_ring in
     336                                 _IntegralDomains else _CommutativeRings)
    315337        Nonexact.__init__(self, default_prec)
    316338
    317339        # underlying polynomial ring in which to represent elements
  • sage/rings/padics/local_generic.py

    diff --git a/sage/rings/padics/local_generic.py b/sage/rings/padics/local_generic.py
    a b  
    1717#                  http://www.gnu.org/licenses/
    1818#*****************************************************************************
    1919
    20 from sage.categories.commutative_rings import CommutativeRings
    2120from sage.rings.ring import CommutativeRing
    2221from sage.structure.parent import Parent
    2322from sage.rings.integer import Integer
     
    3231            sage: R = Zp(5) #indirect doctest
    3332            sage: R.precision_cap()
    3433            20
     34
     35        In :trac:`14084`, the category framework has been implemented for p-adic rings::
     36
     37            sage: TestSuite(R).run()
     38            sage: K = Qp(7)
     39            sage: TestSuite(K).run()
     40
    3541        """
    3642        self._prec = prec
    37         Parent.__init__(self, base, element_constructor=element_class, names=(names,), normalize=False, category=CommutativeRings())
     43        self.Element = element_class
     44        Parent.__init__(self, base, names=(names,), normalize=False, category=getattr(self,'_default_category',None))
    3845
    3946    def is_capped_relative(self):
    4047        """
  • sage/rings/power_series_ring.py

    diff --git a/sage/rings/power_series_ring.py b/sage/rings/power_series_ring.py
    a b  
    139139from sage.structure.unique_representation import UniqueRepresentation
    140140from sage.structure.parent import normalize_names
    141141import sage.categories.commutative_rings as commutative_rings
     142_CommutativeRings = commutative_rings.CommutativeRings()
     143import sage.categories.integral_domains as integral_domains
     144_IntegralDomains = integral_domains.IntegralDomains()
     145import sage.categories.fields as fields
     146_Fields = fields.Fields()
    142147
    143148def PowerSeriesRing(base_ring, name=None, arg2=None, names=None,
    144149                    sparse=False, default_prec=None, order='negdeglex', num_gens=None):
     
    291296        sage: L.default_prec()
    292297        5
    293298
     299    By :trac:`14084`, a power series ring belongs to the category of integral
     300    domains, if the base ring does::
     301
     302        sage: P = ZZ[['x']]
     303        sage: P.category()
     304        Category of integral domains
     305        sage: TestSuite(P).run()
     306        sage: M = ZZ[['x','y']]
     307        sage: M.category()
     308        Category of integral domains
     309        sage: TestSuite(M).run()
     310
     311    Otherwise, it belongs to the category of commutative rings::
     312
     313        sage: P = Integers(15)[['x']]
     314        sage: P.category()
     315        Category of commutative rings
     316        sage: TestSuite(P).run()
     317        sage: M = Integers(15)[['x','y']]
     318        sage: M.category()
     319        Category of commutative rings
     320        sage: TestSuite(M).run()
     321
    294322    """
    295323    #multivariate case:
    296324    # examples for first case:
     
    354382    if not (name is None or isinstance(name, str)):
    355383        raise TypeError, "variable name must be a string or None"
    356384       
    357     if isinstance(base_ring, field.Field):
     385    if base_ring in _Fields:
    358386        R = PowerSeriesRing_over_field(base_ring, name, default_prec, sparse=sparse)
    359     elif isinstance(base_ring, integral_domain.IntegralDomain):
     387    elif base_ring in _IntegralDomains:
    360388        R = PowerSeriesRing_domain(base_ring, name, default_prec, sparse=sparse)
    361     elif isinstance(base_ring, commutative_ring.CommutativeRing):
     389    elif base_ring in _CommutativeRings:
    362390        R = PowerSeriesRing_generic(base_ring, name, default_prec, sparse=sparse)
    363391    else:
    364392        raise TypeError, "base_ring must be a commutative ring"
     
    424452    EXAMPLES:
    425453
    426454    This base class inherits from :class:`~sage.rings.ring.CommutativeRing`.
    427     Since trac ticket #11900, it is also initialised as such::
     455    Since :trac:`11900`, it is also initialised as such, and since :trac:`14084`
     456    it is actually initialised as an integral domain::
    428457
    429458        sage: R.<x> = ZZ[[]]
    430459        sage: R.category()
    431         Category of commutative rings
     460        Category of integral domains
    432461        sage: TestSuite(R).run()
    433462
    434463    """
     
    470499            self.__mpoly_ring = PolynomialRing(K.base_ring(), names=names)
    471500            assert is_MPolynomialRing(self.__mpoly_ring)
    472501            self.Element = power_series_mpoly.PowerSeries_mpoly
    473         commutative_ring.CommutativeRing.__init__(self, base_ring, names=name)
     502        commutative_ring.CommutativeRing.__init__(self, base_ring, names=name,
     503                                                  category=getattr(self,'_default_category',
     504                                                                  _CommutativeRings))
    474505        Nonexact.__init__(self, default_prec)
    475506        self.__generator = self.element_class(self, R.gen(), check=True, is_gen=True)
    476507
  • sage/rings/ring.pyx

    diff --git a/sage/rings/ring.pyx b/sage/rings/ring.pyx
    a b  
    20502050    """
    20512051    Generic field
    20522052    """
    2053     _default_category = Fields()
     2053    _default_category = _Fields
    20542054
    20552055    def fraction_field(self):
    20562056        """