Rings¶
This module provides the abstract base class Ring from which
all rings in Sage (used to) derive, as well as a selection of more
specific base classes.
Warning
Those classes, except maybe for the lowest ones like
Field,
are being progressively deprecated in favor of the corresponding
categories. which are more flexible, in particular with respect to multiple
inheritance.
The class inheritance hierarchy is:
Ring(to be deprecated)Algebra(deprecated and essentially removed)CommutativeRing(deprecated and essentially removed)NoetherianRing(deprecated and essentially removed)CommutativeAlgebra(deprecated and essentially removed)IntegralDomain(deprecated and essentially removed)DedekindDomain(deprecated and essentially removed)PrincipalIdealDomain(deprecated and essentially removed)
Other subclaasses of Ring are
Some aspects of this structure may seem strange, but this is an unfortunate consequence of the fact that Cython classes do not support multiple inheritance.
(A distinct but equally awkward issue is that sometimes we may not know in
advance whether or not a ring belongs in one of these classes; e.g. some
orders in number fields are Dedekind domains, but others are not, and we still
want to offer a unified interface, so orders are never instances of the
deprecated DedekindDomain class.)
AUTHORS:
David Harvey (2006-10-16): changed
CommutativeAlgebrato derive fromCommutativeRinginstead of fromAlgebra.David Loeffler (2009-07-09): documentation fixes, added to reference manual.
Simon King (2011-03-29): Proper use of the category framework for rings.
Simon King (2011-05-20): Modify multiplication and _ideal_class_ to support ideals of non-commutative rings.
- class sage.rings.ring.Ring[source]¶
Bases:
ParentGeneric ring class.
- base_extend(X)[source]¶
EXAMPLES:
sage: QQ.base_extend(GF(7)) Traceback (most recent call last): ... TypeError: no base extension defined sage: ZZ.base_extend(GF(7)) Finite Field of size 7
>>> from sage.all import * >>> QQ.base_extend(GF(Integer(7))) Traceback (most recent call last): ... TypeError: no base extension defined >>> ZZ.base_extend(GF(Integer(7))) Finite Field of size 7
- category()[source]¶
Return the category to which this ring belongs.
Note
This method exists because sometimes a ring is its own base ring. During initialisation of a ring \(R\), it may be checked whether the base ring (hence, the ring itself) is a ring. Hence, it is necessary that
R.category()tells thatRis a ring, even before its category is properly initialised.EXAMPLES:
sage: FreeAlgebra(QQ, 3, 'x').category() # todo: use a ring which is not an algebra! # needs sage.combinat sage.modules Category of algebras with basis over Rational Field
>>> from sage.all import * >>> FreeAlgebra(QQ, Integer(3), 'x').category() # todo: use a ring which is not an algebra! # needs sage.combinat sage.modules Category of algebras with basis over Rational Field
Since a quotient of the integers is its own base ring, and during initialisation of a ring it is tested whether the base ring belongs to the category of rings, the following is an indirect test that the
category()method of rings returns the category of rings even before the initialisation was successful:sage: I = Integers(15) sage: I.base_ring() is I True sage: I.category() Join of Category of finite commutative rings and Category of subquotients of monoids and Category of quotients of semigroups and Category of finite enumerated sets
[Python]>>> from sage.all import * >>> I = Integers(Integer(15)) >>> I.base_ring() is I True >>> I.category() Join of Category of finite commutative rings and Category of subquotients of monoids and Category of quotients of semigroups and Category of finite enumerated sets
- gens()[source]¶
Return a tuple whose entries are the generators for this object, in order.
EXAMPLES:
sage: ZZ.gens() (1,) sage: ZZ["y"].gens() (y,) sage: InfinitePolynomialRing(QQ, "a").gens() (a_*,)
>>> from sage.all import * >>> ZZ.gens() (1,) >>> ZZ["y"].gens() (y,) >>> InfinitePolynomialRing(QQ, "a").gens() (a_*,)
- one()[source]¶
Return the one element of this ring (cached), if it exists.
EXAMPLES:
sage: ZZ.one() 1 sage: QQ.one() 1 sage: QQ['x'].one() 1
>>> from sage.all import * >>> ZZ.one() 1 >>> QQ.one() 1 >>> QQ['x'].one() 1
The result is cached:
sage: ZZ.one() is ZZ.one() True
[Python]>>> from sage.all import * >>> ZZ.one() is ZZ.one() True
- order()[source]¶
The number of elements of
self.EXAMPLES:
sage: GF(19).order() 19 sage: QQ.order() +Infinity
>>> from sage.all import * >>> GF(Integer(19)).order() 19 >>> QQ.order() +Infinity
- zero()[source]¶
Return the zero element of this ring (cached).
EXAMPLES:
sage: ZZ.zero() 0 sage: QQ.zero() 0 sage: QQ['x'].zero() 0
>>> from sage.all import * >>> ZZ.zero() 0 >>> QQ.zero() 0 >>> QQ['x'].zero() 0
The result is cached:
sage: ZZ.zero() is ZZ.zero() True
[Python]>>> from sage.all import * >>> ZZ.zero() is ZZ.zero() True