Rings¶
- class sage.categories.rings.Rings(base_category)[source]¶
Bases:
CategoryWithAxiom_singleton
The category of rings.
Associative rings with unit, not necessarily commutative
EXAMPLES:
sage: Rings() Category of rings sage: sorted(Rings().super_categories(), key=str) [Category of rngs, Category of semirings] sage: sorted(Rings().axioms()) ['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse', 'AdditiveUnital', 'Associative', 'Distributive', 'Unital'] sage: Rings() is (CommutativeAdditiveGroups() & Monoids()).Distributive() True sage: Rings() is Rngs().Unital() True sage: Rings() is Semirings().AdditiveInverse() True
>>> from sage.all import * >>> Rings() Category of rings >>> sorted(Rings().super_categories(), key=str) [Category of rngs, Category of semirings] >>> sorted(Rings().axioms()) ['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse', 'AdditiveUnital', 'Associative', 'Distributive', 'Unital'] >>> Rings() is (CommutativeAdditiveGroups() & Monoids()).Distributive() True >>> Rings() is Rngs().Unital() True >>> Rings() is Semirings().AdditiveInverse() True
Todo
(see Issue #sage_trac/wiki/CategoriesRoadMap)
Make Rings() into a subcategory or alias of Algebras(ZZ);
A parent P in the category
Rings()
should automatically be in the categoryAlgebras(P)
.
- Commutative[source]¶
alias of
CommutativeRings
- Division[source]¶
alias of
DivisionRings
- class ElementMethods[source]¶
Bases:
object
- inverse_of_unit()[source]¶
Return the inverse of this element if it is a unit.
OUTPUT: an element in the same ring as this element
EXAMPLES:
sage: R.<x> = ZZ[] sage: S = R.quo(x^2 + x + 1) # needs sage.libs.pari sage: S(1).inverse_of_unit() # needs sage.libs.pari 1
>>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> S = R.quo(x**Integer(2) + x + Integer(1)) # needs sage.libs.pari >>> S(Integer(1)).inverse_of_unit() # needs sage.libs.pari 1
This method fails when the element is not a unit:
sage: 2.inverse_of_unit() Traceback (most recent call last): ... ArithmeticError: inverse does not exist
>>> from sage.all import * >>> Integer(2).inverse_of_unit() Traceback (most recent call last): ... ArithmeticError: inverse does not exist
The inverse returned is in the same ring as this element:
sage: a = -1 sage: a.parent() Integer Ring sage: a.inverse_of_unit().parent() Integer Ring
>>> from sage.all import * >>> a = -Integer(1) >>> a.parent() Integer Ring >>> a.inverse_of_unit().parent() Integer Ring
Note that this is often not the case when computing inverses in other ways:
sage: (~a).parent() Rational Field sage: (1/a).parent() Rational Field
>>> from sage.all import * >>> (~a).parent() Rational Field >>> (Integer(1)/a).parent() Rational Field
- is_unit()[source]¶
Return whether this element is a unit in the ring.
Note
This is a generic implementation for (non-commutative) rings which only works for the one element, its additive inverse, and the zero element. Most rings should provide a more specialized implementation.
EXAMPLES:
sage: # needs sage.modules sage: MS = MatrixSpace(ZZ, 2) sage: MS.one().is_unit() True sage: MS.zero().is_unit() False sage: MS([1,2,3,4]).is_unit() False
>>> from sage.all import * >>> # needs sage.modules >>> MS = MatrixSpace(ZZ, Integer(2)) >>> MS.one().is_unit() True >>> MS.zero().is_unit() False >>> MS([Integer(1),Integer(2),Integer(3),Integer(4)]).is_unit() False
- class MorphismMethods[source]¶
Bases:
object
- extend_to_fraction_field()[source]¶
Return the extension of this morphism to fraction fields of the domain and the codomain.
EXAMPLES:
sage: S.<x> = QQ[] sage: f = S.hom([x + 1]); f Ring endomorphism of Univariate Polynomial Ring in x over Rational Field Defn: x |--> x + 1 sage: g = f.extend_to_fraction_field(); g # needs sage.libs.singular Ring endomorphism of Fraction Field of Univariate Polynomial Ring in x over Rational Field Defn: x |--> x + 1 sage: g(x) # needs sage.libs.singular x + 1 sage: g(1/x) # needs sage.libs.singular 1/(x + 1)
>>> from sage.all import * >>> S = QQ['x']; (x,) = S._first_ngens(1) >>> f = S.hom([x + Integer(1)]); f Ring endomorphism of Univariate Polynomial Ring in x over Rational Field Defn: x |--> x + 1 >>> g = f.extend_to_fraction_field(); g # needs sage.libs.singular Ring endomorphism of Fraction Field of Univariate Polynomial Ring in x over Rational Field Defn: x |--> x + 1 >>> g(x) # needs sage.libs.singular x + 1 >>> g(Integer(1)/x) # needs sage.libs.singular 1/(x + 1)
If this morphism is not injective, it does not extend to the fraction field and an error is raised:
sage: f = GF(5).coerce_map_from(ZZ) sage: f.extend_to_fraction_field() Traceback (most recent call last): ... ValueError: the morphism is not injective
>>> from sage.all import * >>> f = GF(Integer(5)).coerce_map_from(ZZ) >>> f.extend_to_fraction_field() Traceback (most recent call last): ... ValueError: the morphism is not injective
- is_injective()[source]¶
Return whether or not this morphism is injective.
EXAMPLES:
sage: # needs sage.libs.singular sage: R.<x,y> = QQ[] sage: R.hom([x, y^2], R).is_injective() True sage: R.hom([x, x^2], R).is_injective() False sage: S.<u,v> = R.quotient(x^3*y) sage: R.hom([v, u], S).is_injective() False sage: S.hom([-u, v], S).is_injective() True sage: S.cover().is_injective() False
>>> from sage.all import * >>> # needs sage.libs.singular >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> R.hom([x, y**Integer(2)], R).is_injective() True >>> R.hom([x, x**Integer(2)], R).is_injective() False >>> S = R.quotient(x**Integer(3)*y, names=('u', 'v',)); (u, v,) = S._first_ngens(2) >>> R.hom([v, u], S).is_injective() False >>> S.hom([-u, v], S).is_injective() True >>> S.cover().is_injective() False
If the domain is a field, the homomorphism is injective:
sage: K.<x> = FunctionField(QQ) sage: L.<y> = FunctionField(QQ) sage: f = K.hom([y]); f Function Field morphism: From: Rational function field in x over Rational Field To: Rational function field in y over Rational Field Defn: x |--> y sage: f.is_injective() True
>>> from sage.all import * >>> K = FunctionField(QQ, names=('x',)); (x,) = K._first_ngens(1) >>> L = FunctionField(QQ, names=('y',)); (y,) = L._first_ngens(1) >>> f = K.hom([y]); f Function Field morphism: From: Rational function field in x over Rational Field To: Rational function field in y over Rational Field Defn: x |--> y >>> f.is_injective() True
Unless the codomain is the zero ring:
sage: codomain = Integers(1) sage: f = QQ.hom([Zmod(1)(0)], check=False) sage: f.is_injective() False
>>> from sage.all import * >>> codomain = Integers(Integer(1)) >>> f = QQ.hom([Zmod(Integer(1))(Integer(0))], check=False) >>> f.is_injective() False
Homomorphism from rings of characteristic zero to rings of positive characteristic can not be injective:
sage: R.<x> = ZZ[] sage: f = R.hom([GF(3)(1)]); f Ring morphism: From: Univariate Polynomial Ring in x over Integer Ring To: Finite Field of size 3 Defn: x |--> 1 sage: f.is_injective() False
>>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> f = R.hom([GF(Integer(3))(Integer(1))]); f Ring morphism: From: Univariate Polynomial Ring in x over Integer Ring To: Finite Field of size 3 Defn: x |--> 1 >>> f.is_injective() False
A morphism whose domain is an order in a number field is injective if the codomain has characteristic zero:
sage: K.<x> = FunctionField(QQ) sage: f = ZZ.hom(K); f Composite map: From: Integer Ring To: Rational function field in x over Rational Field Defn: Conversion via FractionFieldElement_1poly_field map: From: Integer Ring To: Fraction Field of Univariate Polynomial Ring in x over Rational Field then Isomorphism: From: Fraction Field of Univariate Polynomial Ring in x over Rational Field To: Rational function field in x over Rational Field sage: f.is_injective() True
>>> from sage.all import * >>> K = FunctionField(QQ, names=('x',)); (x,) = K._first_ngens(1) >>> f = ZZ.hom(K); f Composite map: From: Integer Ring To: Rational function field in x over Rational Field Defn: Conversion via FractionFieldElement_1poly_field map: From: Integer Ring To: Fraction Field of Univariate Polynomial Ring in x over Rational Field then Isomorphism: From: Fraction Field of Univariate Polynomial Ring in x over Rational Field To: Rational function field in x over Rational Field >>> f.is_injective() True
A coercion to the fraction field is injective:
sage: R = ZpFM(3) # needs sage.rings.padics sage: R.fraction_field().coerce_map_from(R).is_injective() True
>>> from sage.all import * >>> R = ZpFM(Integer(3)) # needs sage.rings.padics >>> R.fraction_field().coerce_map_from(R).is_injective() True
- class ParentMethods[source]¶
Bases:
object
- bracket(x, y)[source]¶
Return the Lie bracket \([x, y] = x y - y x\) of \(x\) and \(y\).
INPUT:
x
,y
– elements ofself
EXAMPLES:
sage: # needs sage.combinat sage.modules sage: F = AlgebrasWithBasis(QQ).example() sage: F An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field sage: a, b, c = F.algebra_generators() sage: F.bracket(a, b) B[word: ab] - B[word: ba]
>>> from sage.all import * >>> # needs sage.combinat sage.modules >>> F = AlgebrasWithBasis(QQ).example() >>> F An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field >>> a, b, c = F.algebra_generators() >>> F.bracket(a, b) B[word: ab] - B[word: ba]
This measures the default of commutation between \(x\) and \(y\). \(F\) endowed with the bracket operation is a Lie algebra; in particular, it satisfies Jacobi’s identity:
sage: (F.bracket(F.bracket(a,b), c) + F.bracket(F.bracket(b,c), a) # needs sage.combinat sage.modules ....: + F.bracket(F.bracket(c,a), b)) 0
>>> from sage.all import * >>> (F.bracket(F.bracket(a,b), c) + F.bracket(F.bracket(b,c), a) # needs sage.combinat sage.modules ... + F.bracket(F.bracket(c,a), b)) 0
- characteristic()[source]¶
Return the characteristic of this ring.
EXAMPLES:
sage: QQ.characteristic() 0 sage: GF(19).characteristic() 19 sage: Integers(8).characteristic() 8 sage: Zp(5).characteristic() # needs sage.rings.padics 0
>>> from sage.all import * >>> QQ.characteristic() 0 >>> GF(Integer(19)).characteristic() 19 >>> Integers(Integer(8)).characteristic() 8 >>> Zp(Integer(5)).characteristic() # needs sage.rings.padics 0
- free_module(base=None, basis=None, map=True)[source]¶
Return a free module \(V\) over the specified subring together with maps to and from \(V\).
The default implementation only supports the case that the base ring is the ring itself.
INPUT:
base
– a subring \(R\) so that this ring is isomorphic to a finite-rank free \(R\)-module \(V\)basis
– (optional) a basis for this ring over the basemap
– boolean (default:True
); whether to return \(R\)-linear maps to and from \(V\)
OUTPUT: a finite-rank free \(R\)-module \(V\)
An \(R\)-module isomorphism from \(V\) to this ring (only included if
map
isTrue
)An \(R\)-module isomorphism from this ring to \(V\) (only included if
map
isTrue
)
EXAMPLES:
sage: # needs sage.modules sage: R.<x> = QQ[[]] sage: V, from_V, to_V = R.free_module(R) sage: v = to_V(1 + x); v (1 + x) sage: from_V(v) 1 + x sage: W, from_W, to_W = R.free_module(R, basis=(1 - x)) sage: W is V True sage: w = to_W(1 + x); w (1 - x^2) sage: from_W(w) 1 + x + O(x^20)
>>> from sage.all import * >>> # needs sage.modules >>> R = QQ[['x']]; (x,) = R._first_ngens(1) >>> V, from_V, to_V = R.free_module(R) >>> v = to_V(Integer(1) + x); v (1 + x) >>> from_V(v) 1 + x >>> W, from_W, to_W = R.free_module(R, basis=(Integer(1) - x)) >>> W is V True >>> w = to_W(Integer(1) + x); w (1 - x^2) >>> from_W(w) 1 + x + O(x^20)
- ideal(*args, **kwds)[source]¶
Create an ideal of this ring.
INPUT:
an element or a list/tuple/sequence of elements, the generators
coerce
– boolean (default:True
); whether to first coerce the elements into this ring. This must be a keyword argument. Only set it toFalse
if you are certain that each generator is already in the ring.ideal_class
– callable (default:self._ideal_class_()
); this must be a keyword argument. A constructor for ideals, taking the ring as the first argument and then the generators. Usually a subclass ofIdeal_generic
orIdeal_nc
.Further named arguments (such as
side
in the case of non-commutative rings) are forwarded to the ideal class.
The keyword
side
can be one of'twosided'
,'left'
,'right'
. It determines whether the resulting ideal is twosided, a left ideal or a right ideal.EXAMPLES:
Matrix rings:
sage: # needs sage.modules sage: MS = MatrixSpace(QQ, 2, 2) sage: MS.ideal(2) Twosided Ideal ( [2 0] [0 2] ) of Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: MS.ideal([MS.0, MS.1], side='right') Right Ideal ( [1 0] [0 0], [0 1] [0 0] ) of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
>>> from sage.all import * >>> # needs sage.modules >>> MS = MatrixSpace(QQ, Integer(2), Integer(2)) >>> MS.ideal(Integer(2)) Twosided Ideal ( [2 0] [0 2] ) of Full MatrixSpace of 2 by 2 dense matrices over Rational Field >>> MS.ideal([MS.gen(0), MS.gen(1)], side='right') Right Ideal ( [1 0] [0 0], <BLANKLINE> [0 1] [0 0] ) of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
Polynomial rings:
sage: R.<x,y> = QQ[] sage: R.ideal(x,y) Ideal (x, y) of Multivariate Polynomial Ring in x, y over Rational Field sage: R.ideal(x+y^2) Ideal (y^2 + x) of Multivariate Polynomial Ring in x, y over Rational Field sage: R.ideal( [x^3,y^3+x^3] ) Ideal (x^3, x^3 + y^3) of Multivariate Polynomial Ring in x, y over Rational Field
>>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> R.ideal(x,y) Ideal (x, y) of Multivariate Polynomial Ring in x, y over Rational Field >>> R.ideal(x+y**Integer(2)) Ideal (y^2 + x) of Multivariate Polynomial Ring in x, y over Rational Field >>> R.ideal( [x**Integer(3),y**Integer(3)+x**Integer(3)] ) Ideal (x^3, x^3 + y^3) of Multivariate Polynomial Ring in x, y over Rational Field
Non-commutative rings:
sage: A = SteenrodAlgebra(2) # needs sage.combinat sage.modules sage: A.ideal(A.1, A.2^2) # needs sage.combinat sage.modules Twosided Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis sage: A.ideal(A.1, A.2^2, side='left') # needs sage.combinat sage.modules Left Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis
>>> from sage.all import * >>> A = SteenrodAlgebra(Integer(2)) # needs sage.combinat sage.modules >>> A.ideal(A.gen(1), A.gen(2)**Integer(2)) # needs sage.combinat sage.modules Twosided Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis >>> A.ideal(A.gen(1), A.gen(2)**Integer(2), side='left') # needs sage.combinat sage.modules Left Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis
- ideal_monoid()[source]¶
The monoid of the ideals of this ring.
EXAMPLES:
sage: # needs sage.modules sage: MS = MatrixSpace(QQ, 2, 2) sage: isinstance(MS, Ring) False sage: MS in Rings() True sage: MS.ideal_monoid() Monoid of ideals of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
>>> from sage.all import * >>> # needs sage.modules >>> MS = MatrixSpace(QQ, Integer(2), Integer(2)) >>> isinstance(MS, Ring) False >>> MS in Rings() True >>> MS.ideal_monoid() Monoid of ideals of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
Note that the monoid is cached:
sage: MS.ideal_monoid() is MS.ideal_monoid() # needs sage.modules True
>>> from sage.all import * >>> MS.ideal_monoid() is MS.ideal_monoid() # needs sage.modules True
More examples:
sage: # needs sage.combinat sage.modules sage: F.<x,y,z> = FreeAlgebra(ZZ, 3) sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F sage: Q = F.quotient(I) sage: Q.ideal_monoid() Monoid of ideals of Quotient of Free Algebra on 3 generators (x, y, z) over Integer Ring by the ideal (x*y + y*z, x^2 + x*y - y*x - y^2) sage: F.<x,y,z> = FreeAlgebra(ZZ, implementation='letterplace') sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F sage: Q = F.quo(I) sage: Q.ideal_monoid() Monoid of ideals of Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Integer Ring by the ideal (x*y + y*z, x*x + x*y - y*x - y*y) sage: ZZ.ideal_monoid() Monoid of ideals of Integer Ring sage: R.<x> = QQ[]; R.ideal_monoid() Monoid of ideals of Univariate Polynomial Ring in x over Rational Field
>>> from sage.all import * >>> # needs sage.combinat sage.modules >>> F = FreeAlgebra(ZZ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = F._first_ngens(3) >>> I = F * [x*y + y*z, x**Integer(2) + x*y - y*x - y**Integer(2)] * F >>> Q = F.quotient(I) >>> Q.ideal_monoid() Monoid of ideals of Quotient of Free Algebra on 3 generators (x, y, z) over Integer Ring by the ideal (x*y + y*z, x^2 + x*y - y*x - y^2) >>> F = FreeAlgebra(ZZ, implementation='letterplace', names=('x', 'y', 'z',)); (x, y, z,) = F._first_ngens(3) >>> I = F * [x*y + y*z, x**Integer(2) + x*y - y*x - y**Integer(2)] * F >>> Q = F.quo(I) >>> Q.ideal_monoid() Monoid of ideals of Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Integer Ring by the ideal (x*y + y*z, x*x + x*y - y*x - y*y) >>> ZZ.ideal_monoid() Monoid of ideals of Integer Ring >>> R = QQ['x']; (x,) = R._first_ngens(1); R.ideal_monoid() Monoid of ideals of Univariate Polynomial Ring in x over Rational Field
- is_commutative()[source]¶
Return whether the ring is commutative.
The answer is
True
only if the category is a sub-category ofCommutativeRings
.It is recommended to use instead
R in Rings().Commutative()
.EXAMPLES:
sage: Q.<i,j,k> = QuaternionAlgebra(QQ, -1, -1) # needs sage.combinat sage.modules sage: Q.is_commutative() # needs sage.combinat sage.modules False
>>> from sage.all import * >>> Q = QuaternionAlgebra(QQ, -Integer(1), -Integer(1), names=('i', 'j', 'k',)); (i, j, k,) = Q._first_ngens(3)# needs sage.combinat sage.modules >>> Q.is_commutative() # needs sage.combinat sage.modules False
- is_integral_domain(proof=True)[source]¶
Return
True
if this ring is an integral domain.INPUT:
proof
– boolean (default:True
); determine what to do in unknown cases
ALGORITHM:
If the parameter
proof
is set toTrue
, the returned value is correct but the method might throw an error. Otherwise, if it is set toFalse
, the method returnsTrue
if it can establish thatself
is an integral domain andFalse
otherwise.EXAMPLES:
sage: QQ.is_integral_domain() True sage: ZZ.is_integral_domain() True sage: ZZ['x,y,z'].is_integral_domain() True sage: Integers(8).is_integral_domain() False sage: Zp(7).is_integral_domain() # needs sage.rings.padics True sage: Qp(7).is_integral_domain() # needs sage.rings.padics True sage: R.<a,b> = QQ[] sage: S.<x,y> = R.quo((b^3)) # needs sage.libs.singular sage: S.is_integral_domain() # needs sage.libs.singular False sage: R = ZZ.quotient(ZZ.ideal(10)); R.is_integral_domain() False
>>> from sage.all import * >>> QQ.is_integral_domain() True >>> ZZ.is_integral_domain() True >>> ZZ['x,y,z'].is_integral_domain() True >>> Integers(Integer(8)).is_integral_domain() False >>> Zp(Integer(7)).is_integral_domain() # needs sage.rings.padics True >>> Qp(Integer(7)).is_integral_domain() # needs sage.rings.padics True >>> R = QQ['a, b']; (a, b,) = R._first_ngens(2) >>> S = R.quo((b**Integer(3)), names=('x', 'y',)); (x, y,) = S._first_ngens(2)# needs sage.libs.singular >>> S.is_integral_domain() # needs sage.libs.singular False >>> R = ZZ.quotient(ZZ.ideal(Integer(10))); R.is_integral_domain() False
This illustrates the use of the
proof
parameter:sage: R.<a,b> = ZZ[] sage: S.<x,y> = R.quo((b^3)) # needs sage.libs.singular sage: S.is_integral_domain(proof=True) # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError sage: S.is_integral_domain(proof=False) # needs sage.libs.singular False
>>> from sage.all import * >>> R = ZZ['a, b']; (a, b,) = R._first_ngens(2) >>> S = R.quo((b**Integer(3)), names=('x', 'y',)); (x, y,) = S._first_ngens(2)# needs sage.libs.singular >>> S.is_integral_domain(proof=True) # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError >>> S.is_integral_domain(proof=False) # needs sage.libs.singular False
- is_noetherian()[source]¶
Return
True
if this ring is Noetherian.EXAMPLES:
sage: QQ.is_noetherian() True sage: ZZ.is_noetherian() True
>>> from sage.all import * >>> QQ.is_noetherian() True >>> ZZ.is_noetherian() True
- is_prime_field()[source]¶
Return
True
if this ring is one of the prime fields \(\QQ\) or \(\GF{p}\).EXAMPLES:
sage: QQ.is_prime_field() True sage: GF(3).is_prime_field() True sage: GF(9, 'a').is_prime_field() # needs sage.rings.finite_rings False sage: ZZ.is_prime_field() False sage: QQ['x'].is_prime_field() False sage: Qp(19).is_prime_field() # needs sage.rings.padics False
>>> from sage.all import * >>> QQ.is_prime_field() True >>> GF(Integer(3)).is_prime_field() True >>> GF(Integer(9), 'a').is_prime_field() # needs sage.rings.finite_rings False >>> ZZ.is_prime_field() False >>> QQ['x'].is_prime_field() False >>> Qp(Integer(19)).is_prime_field() # needs sage.rings.padics False
- is_ring()[source]¶
Return
True
, since this in an object of the category of rings.EXAMPLES:
sage: Parent(QQ,category=Rings()).is_ring() True
>>> from sage.all import * >>> Parent(QQ,category=Rings()).is_ring() True
- is_subring(other)[source]¶
Return
True
if the canonical map fromself
toother
is injective.This raises a
NotImplementedError
if not known.EXAMPLES:
sage: ZZ.is_subring(QQ) True sage: ZZ.is_subring(GF(19)) False
>>> from sage.all import * >>> ZZ.is_subring(QQ) True >>> ZZ.is_subring(GF(Integer(19))) False
- is_zero()[source]¶
Return
True
if this is the zero ring.EXAMPLES:
sage: Integers(1).is_zero() True sage: Integers(2).is_zero() False sage: QQ.is_zero() False sage: R.<x> = ZZ[] sage: R.quo(1).is_zero() True sage: R.<x> = GF(101)[] sage: R.quo(77).is_zero() True sage: R.quo(x^2 + 1).is_zero() # needs sage.libs.pari False
>>> from sage.all import * >>> Integers(Integer(1)).is_zero() True >>> Integers(Integer(2)).is_zero() False >>> QQ.is_zero() False >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> R.quo(Integer(1)).is_zero() True >>> R = GF(Integer(101))['x']; (x,) = R._first_ngens(1) >>> R.quo(Integer(77)).is_zero() True >>> R.quo(x**Integer(2) + Integer(1)).is_zero() # needs sage.libs.pari False
- principal_ideal(gen, coerce=True)[source]¶
Return the principal ideal generated by gen.
EXAMPLES:
sage: R.<x,y> = ZZ[] sage: R.principal_ideal(x+2*y) Ideal (x + 2*y) of Multivariate Polynomial Ring in x, y over Integer Ring
>>> from sage.all import * >>> R = ZZ['x, y']; (x, y,) = R._first_ngens(2) >>> R.principal_ideal(x+Integer(2)*y) Ideal (x + 2*y) of Multivariate Polynomial Ring in x, y over Integer Ring
- quo(I, names=None, **kwds)[source]¶
Quotient of a ring by a two-sided ideal.
Note
This is a synonym for
quotient()
.EXAMPLES:
sage: MS = MatrixSpace(QQ, 2) # needs sage.modules sage: I = MS * MS.gens() * MS # needs sage.modules
>>> from sage.all import * >>> MS = MatrixSpace(QQ, Integer(2)) # needs sage.modules >>> I = MS * MS.gens() * MS # needs sage.modules
MS
is not an instance ofRing
.However it is an instance of the parent class of the category of rings. The quotient method is inherited from there:
sage: isinstance(MS, sage.rings.ring.Ring) # needs sage.modules False sage: isinstance(MS, Rings().parent_class) # needs sage.modules True sage: MS.quo(I, names=['a','b','c','d']) # needs sage.modules Quotient of Full MatrixSpace of 2 by 2 dense matrices over Rational Field by the ideal ( [1 0] [0 0], [0 1] [0 0], [0 0] [1 0], [0 0] [0 1] )
>>> from sage.all import * >>> isinstance(MS, sage.rings.ring.Ring) # needs sage.modules False >>> isinstance(MS, Rings().parent_class) # needs sage.modules True >>> MS.quo(I, names=['a','b','c','d']) # needs sage.modules Quotient of Full MatrixSpace of 2 by 2 dense matrices over Rational Field by the ideal ( [1 0] [0 0], <BLANKLINE> [0 1] [0 0], <BLANKLINE> [0 0] [1 0], <BLANKLINE> [0 0] [0 1] )
A test with a subclass of
Ring
:sage: # needs sage.libs.singular sage: R.<x,y> = PolynomialRing(QQ, 2) sage: S.<a,b> = R.quo((x^2, y)) sage: S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y) sage: S.gens() (a, 0) sage: a == b False
>>> from sage.all import * >>> # needs sage.libs.singular >>> R = PolynomialRing(QQ, Integer(2), names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> S = R.quo((x**Integer(2), y), names=('a', 'b',)); (a, b,) = S._first_ngens(2) >>> S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y) >>> S.gens() (a, 0) >>> a == b False
- quotient(I, names=None, **kwds)[source]¶
Quotient of a ring by a two-sided ideal.
INPUT:
I
– a twosided ideal of this ringnames
– (optional) names of the generators of the quotient (if there are multiple generators, you can specify a single character string and the generators are named in sequence starting with 0).further named arguments that may be passed to the quotient ring constructor.
EXAMPLES:
Usually, a ring inherits a method
sage.rings.ring.Ring.quotient()
. So, we need a bit of effort to make the following example work with the category framework:sage: # needs sage.combinat sage.modules sage: F.<x,y,z> = FreeAlgebra(QQ) sage: from sage.rings.noncommutative_ideals import Ideal_nc sage: from itertools import product sage: class PowerIdeal(Ideal_nc): ....: def __init__(self, R, n): ....: self._power = n ....: Ideal_nc.__init__(self, R, [R.prod(m) ....: for m in product(R.gens(), repeat=n)]) ....: def reduce(self, x): ....: R = self.ring() ....: return add([c*R(m) for m, c in x ....: if len(m) < self._power], R(0)) sage: I = PowerIdeal(F, 3) sage: Q = Rings().parent_class.quotient(F, I); Q Quotient of Free Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x^3, x^2*y, x^2*z, x*y*x, x*y^2, x*y*z, x*z*x, x*z*y, x*z^2, y*x^2, y*x*y, y*x*z, y^2*x, y^3, y^2*z, y*z*x, y*z*y, y*z^2, z*x^2, z*x*y, z*x*z, z*y*x, z*y^2, z*y*z, z^2*x, z^2*y, z^3) sage: Q.0 xbar sage: Q.1 ybar sage: Q.2 zbar sage: Q.0*Q.1 xbar*ybar sage: Q.0*Q.1*Q.0 0
>>> from sage.all import * >>> # needs sage.combinat sage.modules >>> F = FreeAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = F._first_ngens(3) >>> from sage.rings.noncommutative_ideals import Ideal_nc >>> from itertools import product >>> class PowerIdeal(Ideal_nc): ... def __init__(self, R, n): ... self._power = n ... Ideal_nc.__init__(self, R, [R.prod(m) ... for m in product(R.gens(), repeat=n)]) ... def reduce(self, x): ... R = self.ring() ... return add([c*R(m) for m, c in x ... if len(m) < self._power], R(Integer(0))) >>> I = PowerIdeal(F, Integer(3)) >>> Q = Rings().parent_class.quotient(F, I); Q Quotient of Free Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x^3, x^2*y, x^2*z, x*y*x, x*y^2, x*y*z, x*z*x, x*z*y, x*z^2, y*x^2, y*x*y, y*x*z, y^2*x, y^3, y^2*z, y*z*x, y*z*y, y*z^2, z*x^2, z*x*y, z*x*z, z*y*x, z*y^2, z*y*z, z^2*x, z^2*y, z^3) >>> Q.gen(0) xbar >>> Q.gen(1) ybar >>> Q.gen(2) zbar >>> Q.gen(0)*Q.gen(1) xbar*ybar >>> Q.gen(0)*Q.gen(1)*Q.gen(0) 0
An example with polynomial rings:
sage: R.<x> = PolynomialRing(ZZ) sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2]) sage: S = R.quotient(I, 'a') sage: S.gens() (a,) sage: # needs sage.libs.singular sage: R.<x,y> = PolynomialRing(QQ, 2) sage: S.<a,b> = R.quotient((x^2, y)) sage: S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y) sage: S.gens() (a, 0) sage: a == b False
>>> from sage.all import * >>> R = PolynomialRing(ZZ, names=('x',)); (x,) = R._first_ngens(1) >>> I = R.ideal([Integer(4) + Integer(3)*x + x**Integer(2), Integer(1) + x**Integer(2)]) >>> S = R.quotient(I, 'a') >>> S.gens() (a,) >>> # needs sage.libs.singular >>> R = PolynomialRing(QQ, Integer(2), names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> S = R.quotient((x**Integer(2), y), names=('a', 'b',)); (a, b,) = S._first_ngens(2) >>> S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y) >>> S.gens() (a, 0) >>> a == b False
- quotient_ring(I, names=None, **kwds)[source]¶
Quotient of a ring by a two-sided ideal.
Note
This is a synonym for
quotient()
.INPUT:
I
– an ideal of \(R\)names
– (optional) names of the generators of the quotient. (If there are multiple generators, you can specify a single character string and the generators are named in sequence starting with 0.)further named arguments that may be passed to the quotient ring constructor.
OUTPUT:
R/I
– the quotient ring of \(R\) by the ideal \(I\)EXAMPLES:
sage: MS = MatrixSpace(QQ, 2) # needs sage.modules sage: I = MS * MS.gens() * MS # needs sage.modules
>>> from sage.all import * >>> MS = MatrixSpace(QQ, Integer(2)) # needs sage.modules >>> I = MS * MS.gens() * MS # needs sage.modules
MS
is not an instance ofRing
, but it is an instance of the parent class of the category of rings. The quotient method is inherited from there:sage: isinstance(MS, sage.rings.ring.Ring) # needs sage.modules False sage: isinstance(MS, Rings().parent_class) # needs sage.modules True sage: MS.quotient_ring(I, names=['a','b','c','d']) # needs sage.modules Quotient of Full MatrixSpace of 2 by 2 dense matrices over Rational Field by the ideal ( [1 0] [0 0], [0 1] [0 0], [0 0] [1 0], [0 0] [0 1] )
>>> from sage.all import * >>> isinstance(MS, sage.rings.ring.Ring) # needs sage.modules False >>> isinstance(MS, Rings().parent_class) # needs sage.modules True >>> MS.quotient_ring(I, names=['a','b','c','d']) # needs sage.modules Quotient of Full MatrixSpace of 2 by 2 dense matrices over Rational Field by the ideal ( [1 0] [0 0], <BLANKLINE> [0 1] [0 0], <BLANKLINE> [0 0] [1 0], <BLANKLINE> [0 0] [0 1] )
A test with a subclass of
Ring
:sage: R.<x> = PolynomialRing(ZZ) sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2]) sage: S = R.quotient_ring(I, 'a') sage: S.gens() (a,) sage: # needs sage.libs.singular sage: R.<x,y> = PolynomialRing(QQ,2) sage: S.<a,b> = R.quotient_ring((x^2, y)) sage: S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y) sage: S.gens() (a, 0) sage: a == b False
>>> from sage.all import * >>> R = PolynomialRing(ZZ, names=('x',)); (x,) = R._first_ngens(1) >>> I = R.ideal([Integer(4) + Integer(3)*x + x**Integer(2), Integer(1) + x**Integer(2)]) >>> S = R.quotient_ring(I, 'a') >>> S.gens() (a,) >>> # needs sage.libs.singular >>> R = PolynomialRing(QQ,Integer(2), names=('x', 'y',)); (x, y,) = R._first_ngens(2) >>> S = R.quotient_ring((x**Integer(2), y), names=('a', 'b',)); (a, b,) = S._first_ngens(2) >>> S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y) >>> S.gens() (a, 0) >>> a == b False
- unit_ideal()[source]¶
Return the unit ideal of this ring.
EXAMPLES:
sage: Zp(7).unit_ideal() # needs sage.rings.padics Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20
>>> from sage.all import * >>> Zp(Integer(7)).unit_ideal() # needs sage.rings.padics Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20
- zero_ideal()[source]¶
Return the zero ideal of this ring (cached).
EXAMPLES:
sage: ZZ.zero_ideal() Principal ideal (0) of Integer Ring sage: QQ.zero_ideal() Principal ideal (0) of Rational Field sage: QQ['x'].zero_ideal() Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field
>>> from sage.all import * >>> ZZ.zero_ideal() Principal ideal (0) of Integer Ring >>> QQ.zero_ideal() Principal ideal (0) of Rational Field >>> QQ['x'].zero_ideal() Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field
The result is cached:
sage: ZZ.zero_ideal() is ZZ.zero_ideal() True
>>> from sage.all import * >>> ZZ.zero_ideal() is ZZ.zero_ideal() True
- class SubcategoryMethods[source]¶
Bases:
object
- Division()[source]¶
Return the full subcategory of the division objects of
self
.A ring satisfies the division axiom if all nonzero elements have multiplicative inverses.
EXAMPLES:
sage: Rings().Division() Category of division rings sage: Rings().Commutative().Division() Category of fields
>>> from sage.all import * >>> Rings().Division() Category of division rings >>> Rings().Commutative().Division() Category of fields
- NoZeroDivisors()[source]¶
Return the full subcategory of the objects of
self
having no nonzero zero divisors.A zero divisor in a ring \(R\) is an element \(x \in R\) such that there exists a nonzero element \(y \in R\) such that \(x \cdot y = 0\) or \(y \cdot x = 0\) (see Wikipedia article Zero_divisor).
EXAMPLES:
sage: Rings().NoZeroDivisors() Category of domains
>>> from sage.all import * >>> Rings().NoZeroDivisors() Category of domains