Ideals of commutative rings¶
Sage provides functionality for computing with ideals. One can create
an ideal in any commutative or non-commutative ring \(R\) by giving a
list of generators, using the notation R.ideal([a,b,...]). The case
of non-commutative rings is implemented in
noncommutative_ideals.
A more convenient notation may be R*[a,b,...] or [a,b,...]*R.
If \(R\) is non-commutative, the former creates a left and the latter
a right ideal, and R*[a,b,...]*R creates a two-sided ideal.
- sage.rings.ideal.Cyclic(R, n=None, homog=False, singular=None)[source]¶
- Ideal of cyclic - n-roots from 1-st- nvariables of- Rif- Ris coercible to- Singular.- INPUT: - R– base ring to construct ideal for
- n– number of cyclic roots (default:- None); if- None, then- nis set to- R.ngens()
- homog– boolean (default:- False); if- Truea homogeneous ideal is returned using the last variable in the ideal
- singular– Singular instance to use
 - Note - Rwill be set as the active ring in- Singular- EXAMPLES: - An example from a multivariate polynomial ring over the rationals: - sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='lex') sage: I = sage.rings.ideal.Cyclic(P); I # needs sage.libs.singular Ideal (x + y + z, x*y + x*z + y*z, x*y*z - 1) of Multivariate Polynomial Ring in x, y, z over Rational Field sage: I.groebner_basis() # needs sage.libs.singular [x + y + z, y^2 + y*z + z^2, z^3 - 1] - >>> from sage.all import * >>> P = PolynomialRing(QQ, Integer(3), order='lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3) >>> I = sage.rings.ideal.Cyclic(P); I # needs sage.libs.singular Ideal (x + y + z, x*y + x*z + y*z, x*y*z - 1) of Multivariate Polynomial Ring in x, y, z over Rational Field >>> I.groebner_basis() # needs sage.libs.singular [x + y + z, y^2 + y*z + z^2, z^3 - 1] - We compute a Groebner basis for cyclic 6, which is a standard benchmark and test ideal: - sage: R.<x,y,z,t,u,v> = QQ['x,y,z,t,u,v'] sage: I = sage.rings.ideal.Cyclic(R, 6) # needs sage.libs.singular sage: B = I.groebner_basis() # needs sage.libs.singular sage: len(B) # needs sage.libs.singular 45 - >>> from sage.all import * >>> R = QQ['x,y,z,t,u,v']; (x, y, z, t, u, v,) = R._first_ngens(6) >>> I = sage.rings.ideal.Cyclic(R, Integer(6)) # needs sage.libs.singular >>> B = I.groebner_basis() # needs sage.libs.singular >>> len(B) # needs sage.libs.singular 45 
- sage.rings.ideal.FieldIdeal(R)[source]¶
- Let - q = R.base_ring().order()and \((x_0,...,x_n)\)- = R.gens()then if \(q\) is finite this constructor returns\[\langle x_0^q - x_0, ... , x_n^q - x_n \rangle.\]- We call this ideal the field ideal and the generators the field equations. - EXAMPLES: - The field ideal generated from the polynomial ring over two variables in the finite field of size 2: - sage: P.<x,y> = PolynomialRing(GF(2), 2) sage: I = sage.rings.ideal.FieldIdeal(P); I Ideal (x^2 + x, y^2 + y) of Multivariate Polynomial Ring in x, y over Finite Field of size 2 - >>> from sage.all import * >>> P = PolynomialRing(GF(Integer(2)), Integer(2), names=('x', 'y',)); (x, y,) = P._first_ngens(2) >>> I = sage.rings.ideal.FieldIdeal(P); I Ideal (x^2 + x, y^2 + y) of Multivariate Polynomial Ring in x, y over Finite Field of size 2 - Another, similar example: - sage: Q.<x1,x2,x3,x4> = PolynomialRing(GF(2^4, name='alpha'), 4) # needs sage.rings.finite_rings sage: J = sage.rings.ideal.FieldIdeal(Q); J # needs sage.rings.finite_rings Ideal (x1^16 + x1, x2^16 + x2, x3^16 + x3, x4^16 + x4) of Multivariate Polynomial Ring in x1, x2, x3, x4 over Finite Field in alpha of size 2^4 - >>> from sage.all import * >>> Q = PolynomialRing(GF(Integer(2)**Integer(4), name='alpha'), Integer(4), names=('x1', 'x2', 'x3', 'x4',)); (x1, x2, x3, x4,) = Q._first_ngens(4)# needs sage.rings.finite_rings >>> J = sage.rings.ideal.FieldIdeal(Q); J # needs sage.rings.finite_rings Ideal (x1^16 + x1, x2^16 + x2, x3^16 + x3, x4^16 + x4) of Multivariate Polynomial Ring in x1, x2, x3, x4 over Finite Field in alpha of size 2^4 
- sage.rings.ideal.Ideal(*args, **kwds)[source]¶
- Create the ideal in ring with given generators. - There are some shorthand notations for creating an ideal, in addition to using the - Ideal()function:- R.ideal(gens, coerce=True)
- gens*R
- R*gens
 - INPUT: - R– a ring (optional; if not given, will try to infer it from- gens)
- gens– list of elements generating the ideal
- coerce– boolean (default:- True); whether- gensneed to be coerced into the ring
 - OUTPUT: the ideal of ring generated by - gens- EXAMPLES: - sage: R.<x> = ZZ[] sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2]) sage: I Ideal (x^2 + 3*x + 4, x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring sage: Ideal(R, [4 + 3*x + x^2, 1 + x^2]) Ideal (x^2 + 3*x + 4, x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring sage: Ideal((4 + 3*x + x^2, 1 + x^2)) Ideal (x^2 + 3*x + 4, x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring - >>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> I = R.ideal([Integer(4) + Integer(3)*x + x**Integer(2), Integer(1) + x**Integer(2)]) >>> I Ideal (x^2 + 3*x + 4, x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring >>> Ideal(R, [Integer(4) + Integer(3)*x + x**Integer(2), Integer(1) + x**Integer(2)]) Ideal (x^2 + 3*x + 4, x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring >>> Ideal((Integer(4) + Integer(3)*x + x**Integer(2), Integer(1) + x**Integer(2))) Ideal (x^2 + 3*x + 4, x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring - sage: ideal(x^2-2*x+1, x^2-1) Ideal (x^2 - 2*x + 1, x^2 - 1) of Univariate Polynomial Ring in x over Integer Ring sage: ideal([x^2-2*x+1, x^2-1]) Ideal (x^2 - 2*x + 1, x^2 - 1) of Univariate Polynomial Ring in x over Integer Ring sage: l = [x^2-2*x+1, x^2-1] sage: ideal(f^2 for f in l) Ideal (x^4 - 4*x^3 + 6*x^2 - 4*x + 1, x^4 - 2*x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring - >>> from sage.all import * >>> ideal(x**Integer(2)-Integer(2)*x+Integer(1), x**Integer(2)-Integer(1)) Ideal (x^2 - 2*x + 1, x^2 - 1) of Univariate Polynomial Ring in x over Integer Ring >>> ideal([x**Integer(2)-Integer(2)*x+Integer(1), x**Integer(2)-Integer(1)]) Ideal (x^2 - 2*x + 1, x^2 - 1) of Univariate Polynomial Ring in x over Integer Ring >>> l = [x**Integer(2)-Integer(2)*x+Integer(1), x**Integer(2)-Integer(1)] >>> ideal(f**Integer(2) for f in l) Ideal (x^4 - 4*x^3 + 6*x^2 - 4*x + 1, x^4 - 2*x^2 + 1) of Univariate Polynomial Ring in x over Integer Ring - This example illustrates how Sage finds a common ambient ring for the ideal, even though 1 is in the integers (in this case). - sage: R.<t> = ZZ['t'] sage: i = ideal(1,t,t^2) sage: i Ideal (1, t, t^2) of Univariate Polynomial Ring in t over Integer Ring sage: ideal(1/2,t,t^2) Principal ideal (1) of Univariate Polynomial Ring in t over Rational Field - >>> from sage.all import * >>> R = ZZ['t']; (t,) = R._first_ngens(1) >>> i = ideal(Integer(1),t,t**Integer(2)) >>> i Ideal (1, t, t^2) of Univariate Polynomial Ring in t over Integer Ring >>> ideal(Integer(1)/Integer(2),t,t**Integer(2)) Principal ideal (1) of Univariate Polynomial Ring in t over Rational Field - This shows that the issues at Issue #1104 are resolved: - sage: Ideal(3, 5) Principal ideal (1) of Integer Ring sage: Ideal(ZZ, 3, 5) Principal ideal (1) of Integer Ring sage: Ideal(2, 4, 6) Principal ideal (2) of Integer Ring - >>> from sage.all import * >>> Ideal(Integer(3), Integer(5)) Principal ideal (1) of Integer Ring >>> Ideal(ZZ, Integer(3), Integer(5)) Principal ideal (1) of Integer Ring >>> Ideal(Integer(2), Integer(4), Integer(6)) Principal ideal (2) of Integer Ring - You have to provide enough information that Sage can figure out which ring to put the ideal in. - sage: I = Ideal([]) Traceback (most recent call last): ... ValueError: unable to determine which ring to embed the ideal in sage: I = Ideal() Traceback (most recent call last): ... ValueError: need at least one argument - >>> from sage.all import * >>> I = Ideal([]) Traceback (most recent call last): ... ValueError: unable to determine which ring to embed the ideal in >>> I = Ideal() Traceback (most recent call last): ... ValueError: need at least one argument - Note that some rings use different ideal implementations than the standard, even if they are PIDs.: - sage: R.<x> = GF(5)[] sage: I = R * (x^2 + 3) sage: type(I) <class 'sage.rings.polynomial.ideal.Ideal_1poly_field'> - >>> from sage.all import * >>> R = GF(Integer(5))['x']; (x,) = R._first_ngens(1) >>> I = R * (x**Integer(2) + Integer(3)) >>> type(I) <class 'sage.rings.polynomial.ideal.Ideal_1poly_field'> - You can also pass in a specific ideal type: - sage: from sage.rings.ideal import Ideal_pid sage: I = Ideal(x^2+3,ideal_class=Ideal_pid) sage: type(I) <class 'sage.rings.ideal.Ideal_pid'> - >>> from sage.all import * >>> from sage.rings.ideal import Ideal_pid >>> I = Ideal(x**Integer(2)+Integer(3),ideal_class=Ideal_pid) >>> type(I) <class 'sage.rings.ideal.Ideal_pid'> 
- class sage.rings.ideal.Ideal_fractional(ring, gens, coerce=True, **kwds)[source]¶
- Bases: - Ideal_generic- Fractional ideal of a ring. - See - Ideal().
- class sage.rings.ideal.Ideal_generic(ring, gens, coerce=True, **kwds)[source]¶
- Bases: - MonoidElement- An ideal. - See - Ideal().- absolute_norm()[source]¶
- Return the absolute norm of this ideal. - In the general case, this is just the ideal itself, since the ring it lies in can’t be implicitly assumed to be an extension of anything. - We include this function for compatibility with cases such as ideals in number fields. - Todo - Implement this method. - EXAMPLES: - sage: R.<t> = GF(9, names='a')[] # needs sage.rings.finite_rings sage: I = R.ideal(t^4 + t + 1) # needs sage.rings.finite_rings sage: I.absolute_norm() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError - >>> from sage.all import * >>> R = GF(Integer(9), names='a')['t']; (t,) = R._first_ngens(1)# needs sage.rings.finite_rings >>> I = R.ideal(t**Integer(4) + t + Integer(1)) # needs sage.rings.finite_rings >>> I.absolute_norm() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError 
 - apply_morphism(phi)[source]¶
- Apply the morphism - phito every element of this ideal. Returns an ideal in the domain of- phi.- EXAMPLES: - sage: # needs sage.rings.real_mpfr sage: psi = CC['x'].hom([-CC['x'].0]) sage: J = ideal([CC['x'].0 + 1]); J Principal ideal (x + 1.00000000000000) of Univariate Polynomial Ring in x over Complex Field with 53 bits of precision sage: psi(J) Principal ideal (x - 1.00000000000000) of Univariate Polynomial Ring in x over Complex Field with 53 bits of precision sage: J.apply_morphism(psi) Principal ideal (x - 1.00000000000000) of Univariate Polynomial Ring in x over Complex Field with 53 bits of precision - >>> from sage.all import * >>> # needs sage.rings.real_mpfr >>> psi = CC['x'].hom([-CC['x'].gen(0)]) >>> J = ideal([CC['x'].gen(0) + Integer(1)]); J Principal ideal (x + 1.00000000000000) of Univariate Polynomial Ring in x over Complex Field with 53 bits of precision >>> psi(J) Principal ideal (x - 1.00000000000000) of Univariate Polynomial Ring in x over Complex Field with 53 bits of precision >>> J.apply_morphism(psi) Principal ideal (x - 1.00000000000000) of Univariate Polynomial Ring in x over Complex Field with 53 bits of precision - sage: psi = ZZ['x'].hom([-ZZ['x'].0]) sage: J = ideal([ZZ['x'].0, 2]); J Ideal (x, 2) of Univariate Polynomial Ring in x over Integer Ring sage: psi(J) Ideal (-x, 2) of Univariate Polynomial Ring in x over Integer Ring sage: J.apply_morphism(psi) Ideal (-x, 2) of Univariate Polynomial Ring in x over Integer Ring - >>> from sage.all import * >>> psi = ZZ['x'].hom([-ZZ['x'].gen(0)]) >>> J = ideal([ZZ['x'].gen(0), Integer(2)]); J Ideal (x, 2) of Univariate Polynomial Ring in x over Integer Ring >>> psi(J) Ideal (-x, 2) of Univariate Polynomial Ring in x over Integer Ring >>> J.apply_morphism(psi) Ideal (-x, 2) of Univariate Polynomial Ring in x over Integer Ring 
 - associated_primes()[source]¶
- Return the list of associated prime ideals of this ideal. - EXAMPLES: - sage: R = ZZ['x'] sage: I = R.ideal(7) sage: I.associated_primes() Traceback (most recent call last): ... NotImplementedError - >>> from sage.all import * >>> R = ZZ['x'] >>> I = R.ideal(Integer(7)) >>> I.associated_primes() Traceback (most recent call last): ... NotImplementedError 
 - base_ring()[source]¶
- Return the base ring of this ideal. - EXAMPLES: - sage: R = ZZ sage: I = 3*R; I Principal ideal (3) of Integer Ring sage: J = 2*I; J Principal ideal (6) of Integer Ring sage: I.base_ring(); J.base_ring() Integer Ring Integer Ring - >>> from sage.all import * >>> R = ZZ >>> I = Integer(3)*R; I Principal ideal (3) of Integer Ring >>> J = Integer(2)*I; J Principal ideal (6) of Integer Ring >>> I.base_ring(); J.base_ring() Integer Ring Integer Ring - We construct an example of an ideal of a quotient ring: - sage: R = PolynomialRing(QQ, 'x'); x = R.gen() sage: I = R.ideal(x^2 - 2) sage: I.base_ring() Rational Field - >>> from sage.all import * >>> R = PolynomialRing(QQ, 'x'); x = R.gen() >>> I = R.ideal(x**Integer(2) - Integer(2)) >>> I.base_ring() Rational Field - And \(p\)-adic numbers: - sage: R = Zp(7, prec=10); R # needs sage.rings.padics 7-adic Ring with capped relative precision 10 sage: I = 7*R; I # needs sage.rings.padics Principal ideal (7 + O(7^11)) of 7-adic Ring with capped relative precision 10 sage: I.base_ring() # needs sage.rings.padics 7-adic Ring with capped relative precision 10 - >>> from sage.all import * >>> R = Zp(Integer(7), prec=Integer(10)); R # needs sage.rings.padics 7-adic Ring with capped relative precision 10 >>> I = Integer(7)*R; I # needs sage.rings.padics Principal ideal (7 + O(7^11)) of 7-adic Ring with capped relative precision 10 >>> I.base_ring() # needs sage.rings.padics 7-adic Ring with capped relative precision 10 
 - category()[source]¶
- Return the category of this ideal. - Note - category is dependent on the ring of the ideal. - EXAMPLES: - sage: P.<x> = ZZ[] sage: I = ZZ.ideal(7) sage: J = P.ideal(7,x) sage: K = P.ideal(7) sage: I.category() Category of ring ideals in Integer Ring sage: J.category() Category of ring ideals in Univariate Polynomial Ring in x over Integer Ring sage: K.category() Category of ring ideals in Univariate Polynomial Ring in x over Integer Ring - >>> from sage.all import * >>> P = ZZ['x']; (x,) = P._first_ngens(1) >>> I = ZZ.ideal(Integer(7)) >>> J = P.ideal(Integer(7),x) >>> K = P.ideal(Integer(7)) >>> I.category() Category of ring ideals in Integer Ring >>> J.category() Category of ring ideals in Univariate Polynomial Ring in x over Integer Ring >>> K.category() Category of ring ideals in Univariate Polynomial Ring in x over Integer Ring 
 - embedded_primes()[source]¶
- Return the list of embedded primes of this ideal. - EXAMPLES: - sage: R.<x, y> = QQ[] sage: I = R.ideal(x^2, x*y) sage: I.embedded_primes() # needs sage.libs.singular [Ideal (y, x) of Multivariate Polynomial Ring in x, y over Rational Field] - >>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> I = R.ideal(x**Integer(2), x*y) >>> I.embedded_primes() # needs sage.libs.singular [Ideal (y, x) of Multivariate Polynomial Ring in x, y over Rational Field] 
 - free_resolution(*args, **kwds)[source]¶
- Return a free resolution of - self.- For input options, see - FreeResolution.- EXAMPLES: - sage: R.<x> = PolynomialRing(QQ) sage: I = R.ideal([x^4 + 3*x^2 + 2]) sage: I.free_resolution() # needs sage.modules S^1 <-- S^1 <-- 0 - >>> from sage.all import * >>> R = PolynomialRing(QQ, names=('x',)); (x,) = R._first_ngens(1) >>> I = R.ideal([x**Integer(4) + Integer(3)*x**Integer(2) + Integer(2)]) >>> I.free_resolution() # needs sage.modules S^1 <-- S^1 <-- 0 
 - gen(i)[source]¶
- Return the - i-th generator in the current basis of this ideal.- EXAMPLES: - sage: P.<x,y> = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I Ideal (x, y + 1) of Multivariate Polynomial Ring in x, y over Rational Field sage: I.gen(1) y + 1 sage: ZZ.ideal(5,10).gen() 5 - >>> from sage.all import * >>> P = PolynomialRing(QQ,Integer(2), names=('x', 'y',)); (x, y,) = P._first_ngens(2) >>> I = Ideal([x,y+Integer(1)]); I Ideal (x, y + 1) of Multivariate Polynomial Ring in x, y over Rational Field >>> I.gen(Integer(1)) y + 1 >>> ZZ.ideal(Integer(5),Integer(10)).gen() 5 
 - gens()[source]¶
- Return a set of generators / a basis of - self.- This is the set of generators provided during creation of this ideal. - EXAMPLES: - sage: P.<x,y> = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I Ideal (x, y + 1) of Multivariate Polynomial Ring in x, y over Rational Field sage: I.gens() [x, y + 1] - >>> from sage.all import * >>> P = PolynomialRing(QQ,Integer(2), names=('x', 'y',)); (x, y,) = P._first_ngens(2) >>> I = Ideal([x,y+Integer(1)]); I Ideal (x, y + 1) of Multivariate Polynomial Ring in x, y over Rational Field >>> I.gens() [x, y + 1] - sage: ZZ.ideal(5,10).gens() (5,) - >>> from sage.all import * >>> ZZ.ideal(Integer(5),Integer(10)).gens() (5,) 
 - gens_reduced()[source]¶
- Same as - gens()for this ideal, since there is currently no special- gens_reducedalgorithm implemented for this ring.- This method is provided so that ideals in \(\ZZ\) have the method - gens_reduced(), just like ideals of number fields.- EXAMPLES: - sage: ZZ.ideal(5).gens_reduced() (5,) - >>> from sage.all import * >>> ZZ.ideal(Integer(5)).gens_reduced() (5,) 
 - graded_free_resolution(*args, **kwds)[source]¶
- Return a graded free resolution of - self.- For input options, see - GradedFiniteFreeResolution.- EXAMPLES: - sage: R.<x> = PolynomialRing(QQ) sage: I = R.ideal([x^3]) sage: I.graded_free_resolution() # needs sage.modules S(0) <-- S(-3) <-- 0 - >>> from sage.all import * >>> R = PolynomialRing(QQ, names=('x',)); (x,) = R._first_ngens(1) >>> I = R.ideal([x**Integer(3)]) >>> I.graded_free_resolution() # needs sage.modules S(0) <-- S(-3) <-- 0 
 - is_maximal()[source]¶
- Return - Trueif the ideal is maximal in the ring containing the ideal.- Todo - This is not implemented for many rings. Implement it! - EXAMPLES: - sage: R = ZZ sage: I = R.ideal(7) sage: I.is_maximal() True sage: R.ideal(16).is_maximal() False sage: S = Integers(8) sage: S.ideal(0).is_maximal() False sage: S.ideal(2).is_maximal() True sage: S.ideal(4).is_maximal() False - >>> from sage.all import * >>> R = ZZ >>> I = R.ideal(Integer(7)) >>> I.is_maximal() True >>> R.ideal(Integer(16)).is_maximal() False >>> S = Integers(Integer(8)) >>> S.ideal(Integer(0)).is_maximal() False >>> S.ideal(Integer(2)).is_maximal() True >>> S.ideal(Integer(4)).is_maximal() False 
 - is_primary(P=None)[source]¶
- Return - Trueif this ideal is primary (or \(P\)-primary, if a prime ideal \(P\) is specified).- Recall that an ideal \(I\) is primary if and only if \(I\) has a unique associated prime (see page 52 in [AM1969]). If this prime is \(P\), then \(I\) is said to be \(P\)-primary. - INPUT: - P– (default:- None) a prime ideal in the same ring
 - EXAMPLES: - sage: R.<x, y> = QQ[] sage: I = R.ideal([x^2, x*y]) sage: I.is_primary() # needs sage.libs.singular False sage: J = I.primary_decomposition()[1]; J # needs sage.libs.singular Ideal (y, x^2) of Multivariate Polynomial Ring in x, y over Rational Field sage: J.is_primary() # needs sage.libs.singular True sage: J.is_prime() # needs sage.libs.singular False - >>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> I = R.ideal([x**Integer(2), x*y]) >>> I.is_primary() # needs sage.libs.singular False >>> J = I.primary_decomposition()[Integer(1)]; J # needs sage.libs.singular Ideal (y, x^2) of Multivariate Polynomial Ring in x, y over Rational Field >>> J.is_primary() # needs sage.libs.singular True >>> J.is_prime() # needs sage.libs.singular False - Some examples from the Macaulay2 documentation: - sage: # needs sage.rings.finite_rings sage: R.<x, y, z> = GF(101)[] sage: I = R.ideal([y^6]) sage: I.is_primary() # needs sage.libs.singular True sage: I.is_primary(R.ideal([y])) # needs sage.libs.singular True sage: I = R.ideal([x^4, y^7]) sage: I.is_primary() # needs sage.libs.singular True sage: I = R.ideal([x*y, y^2]) sage: I.is_primary() # needs sage.libs.singular False - >>> from sage.all import * >>> # needs sage.rings.finite_rings >>> R = GF(Integer(101))['x, y, z']; (x, y, z,) = R._first_ngens(3) >>> I = R.ideal([y**Integer(6)]) >>> I.is_primary() # needs sage.libs.singular True >>> I.is_primary(R.ideal([y])) # needs sage.libs.singular True >>> I = R.ideal([x**Integer(4), y**Integer(7)]) >>> I.is_primary() # needs sage.libs.singular True >>> I = R.ideal([x*y, y**Integer(2)]) >>> I.is_primary() # needs sage.libs.singular False - Note - This uses the list of associated primes. 
 - is_prime()[source]¶
- Return - Trueif this ideal is prime.- EXAMPLES: - sage: R.<x, y> = QQ[] sage: I = R.ideal([x, y]) sage: I.is_prime() # a maximal ideal # needs sage.libs.singular True sage: I = R.ideal([x^2 - y]) sage: I.is_prime() # a non-maximal prime ideal # needs sage.libs.singular True sage: I = R.ideal([x^2, y]) sage: I.is_prime() # a non-prime primary ideal # needs sage.libs.singular False sage: I = R.ideal([x^2, x*y]) sage: I.is_prime() # a non-prime non-primary ideal # needs sage.libs.singular False sage: S = Integers(8) sage: S.ideal(0).is_prime() False sage: S.ideal(2).is_prime() True sage: S.ideal(4).is_prime() False - >>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> I = R.ideal([x, y]) >>> I.is_prime() # a maximal ideal # needs sage.libs.singular True >>> I = R.ideal([x**Integer(2) - y]) >>> I.is_prime() # a non-maximal prime ideal # needs sage.libs.singular True >>> I = R.ideal([x**Integer(2), y]) >>> I.is_prime() # a non-prime primary ideal # needs sage.libs.singular False >>> I = R.ideal([x**Integer(2), x*y]) >>> I.is_prime() # a non-prime non-primary ideal # needs sage.libs.singular False >>> S = Integers(Integer(8)) >>> S.ideal(Integer(0)).is_prime() False >>> S.ideal(Integer(2)).is_prime() True >>> S.ideal(Integer(4)).is_prime() False - Note that this method is not implemented for all rings where it could be: - sage: R.<x> = ZZ[] sage: I = R.ideal(7) sage: I.is_prime() # when implemented, should be True Traceback (most recent call last): ... NotImplementedError - >>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> I = R.ideal(Integer(7)) >>> I.is_prime() # when implemented, should be True Traceback (most recent call last): ... NotImplementedError - Note - For general rings, uses the list of associated primes. 
 - is_principal()[source]¶
- Return - Trueif the ideal is principal in the ring containing the ideal.- Todo - Code is naive. Only keeps track of ideal generators as set during initialization of the ideal. (Can the base ring change? See example below.) - EXAMPLES: - sage: R.<x> = ZZ[] sage: I = R.ideal(2, x) sage: I.is_principal() Traceback (most recent call last): ... NotImplementedError sage: J = R.base_extend(QQ).ideal(2, x) sage: J.is_principal() True - >>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> I = R.ideal(Integer(2), x) >>> I.is_principal() Traceback (most recent call last): ... NotImplementedError >>> J = R.base_extend(QQ).ideal(Integer(2), x) >>> J.is_principal() True 
 - minimal_associated_primes()[source]¶
- Return the list of minimal associated prime ideals of this ideal. - EXAMPLES: - sage: R = ZZ['x'] sage: I = R.ideal(7) sage: I.minimal_associated_primes() Traceback (most recent call last): ... NotImplementedError - >>> from sage.all import * >>> R = ZZ['x'] >>> I = R.ideal(Integer(7)) >>> I.minimal_associated_primes() Traceback (most recent call last): ... NotImplementedError 
 - ngens()[source]¶
- Return the number of generators in the basis. - EXAMPLES: - sage: P.<x,y> = PolynomialRing(QQ,2) sage: I = Ideal([x,y+1]); I Ideal (x, y + 1) of Multivariate Polynomial Ring in x, y over Rational Field sage: I.ngens() 2 sage: ZZ.ideal(5,10).ngens() 1 - >>> from sage.all import * >>> P = PolynomialRing(QQ,Integer(2), names=('x', 'y',)); (x, y,) = P._first_ngens(2) >>> I = Ideal([x,y+Integer(1)]); I Ideal (x, y + 1) of Multivariate Polynomial Ring in x, y over Rational Field >>> I.ngens() 2 >>> ZZ.ideal(Integer(5),Integer(10)).ngens() 1 
 - norm()[source]¶
- Return the norm of this ideal. - In the general case, this is just the ideal itself, since the ring it lies in can’t be implicitly assumed to be an extension of anything. - We include this function for compatibility with cases such as ideals in number fields. - EXAMPLES: - sage: R.<t> = GF(8, names='a')[] # needs sage.rings.finite_rings sage: I = R.ideal(t^4 + t + 1) # needs sage.rings.finite_rings sage: I.norm() # needs sage.rings.finite_rings Principal ideal (t^4 + t + 1) of Univariate Polynomial Ring in t over Finite Field in a of size 2^3 - >>> from sage.all import * >>> R = GF(Integer(8), names='a')['t']; (t,) = R._first_ngens(1)# needs sage.rings.finite_rings >>> I = R.ideal(t**Integer(4) + t + Integer(1)) # needs sage.rings.finite_rings >>> I.norm() # needs sage.rings.finite_rings Principal ideal (t^4 + t + 1) of Univariate Polynomial Ring in t over Finite Field in a of size 2^3 
 - primary_decomposition()[source]¶
- Return a decomposition of this ideal into primary ideals. - EXAMPLES: - sage: R = ZZ['x'] sage: I = R.ideal(7) sage: I.primary_decomposition() Traceback (most recent call last): ... NotImplementedError - >>> from sage.all import * >>> R = ZZ['x'] >>> I = R.ideal(Integer(7)) >>> I.primary_decomposition() Traceback (most recent call last): ... NotImplementedError 
 - random_element(*args, **kwds)[source]¶
- Return a random element in this ideal. - EXAMPLES: - sage: P.<a,b,c> = GF(5)[[]] sage: I = P.ideal([a^2, a*b + c, c^3]) sage: I.random_element() # random 2*a^5*c + a^2*b*c^4 + ... + O(a, b, c)^13 - >>> from sage.all import * >>> P = GF(Integer(5))[['a, b, c']]; (a, b, c,) = P._first_ngens(3) >>> I = P.ideal([a**Integer(2), a*b + c, c**Integer(3)]) >>> I.random_element() # random 2*a^5*c + a^2*b*c^4 + ... + O(a, b, c)^13 
 - reduce(f)[source]¶
- Return the reduction of the element of \(f\) modulo - self.- This is an element of \(R\) that is equivalent modulo \(I\) to \(f\) where \(I\) is - self.- EXAMPLES: - sage: ZZ.ideal(5).reduce(17) 2 sage: parent(ZZ.ideal(5).reduce(17)) Integer Ring - >>> from sage.all import * >>> ZZ.ideal(Integer(5)).reduce(Integer(17)) 2 >>> parent(ZZ.ideal(Integer(5)).reduce(Integer(17))) Integer Ring 
 - ring()[source]¶
- Return the ring containing this ideal. - EXAMPLES: - sage: R = ZZ sage: I = 3*R; I Principal ideal (3) of Integer Ring sage: J = 2*I; J Principal ideal (6) of Integer Ring sage: I.ring(); J.ring() Integer Ring Integer Ring - >>> from sage.all import * >>> R = ZZ >>> I = Integer(3)*R; I Principal ideal (3) of Integer Ring >>> J = Integer(2)*I; J Principal ideal (6) of Integer Ring >>> I.ring(); J.ring() Integer Ring Integer Ring - Note that - self.ring()is different from- self.base_ring()- sage: R = PolynomialRing(QQ, 'x'); x = R.gen() sage: I = R.ideal(x^2 - 2) sage: I.base_ring() Rational Field sage: I.ring() Univariate Polynomial Ring in x over Rational Field - >>> from sage.all import * >>> R = PolynomialRing(QQ, 'x'); x = R.gen() >>> I = R.ideal(x**Integer(2) - Integer(2)) >>> I.base_ring() Rational Field >>> I.ring() Univariate Polynomial Ring in x over Rational Field - Another example using polynomial rings: - sage: R = PolynomialRing(QQ, 'x'); x = R.gen() sage: I = R.ideal(x^2 - 3) sage: I.ring() Univariate Polynomial Ring in x over Rational Field sage: Rbar = R.quotient(I, names='a') # needs sage.libs.pari sage: S = PolynomialRing(Rbar, 'y'); y = Rbar.gen(); S # needs sage.libs.pari Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in a over Rational Field with modulus x^2 - 3 sage: J = S.ideal(y^2 + 1) # needs sage.libs.pari sage: J.ring() # needs sage.libs.pari Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in a over Rational Field with modulus x^2 - 3 - >>> from sage.all import * >>> R = PolynomialRing(QQ, 'x'); x = R.gen() >>> I = R.ideal(x**Integer(2) - Integer(3)) >>> I.ring() Univariate Polynomial Ring in x over Rational Field >>> Rbar = R.quotient(I, names='a') # needs sage.libs.pari >>> S = PolynomialRing(Rbar, 'y'); y = Rbar.gen(); S # needs sage.libs.pari Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in a over Rational Field with modulus x^2 - 3 >>> J = S.ideal(y**Integer(2) + Integer(1)) # needs sage.libs.pari >>> J.ring() # needs sage.libs.pari Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in a over Rational Field with modulus x^2 - 3 
 
- class sage.rings.ideal.Ideal_pid(ring, gens, coerce=True, **kwds)[source]¶
- Bases: - Ideal_principal- An ideal of a principal ideal domain. - See - Ideal().- EXAMPLES: - sage: I = 8*ZZ sage: I Principal ideal (8) of Integer Ring - >>> from sage.all import * >>> I = Integer(8)*ZZ >>> I Principal ideal (8) of Integer Ring - gcd(other)[source]¶
- Return the greatest common divisor of the principal ideal with the ideal - other; that is, the largest principal ideal contained in both the ideal and- other- Todo - This is not implemented in the case when - otheris neither principal nor when the generator of- selfis contained in- other. Also, it seems that this class is used only in PIDs–is this redundant?- Note - The second example is broken. - EXAMPLES: - An example in the principal ideal domain \(\ZZ\): - sage: R = ZZ sage: I = R.ideal(42) sage: J = R.ideal(70) sage: I.gcd(J) Principal ideal (14) of Integer Ring sage: J.gcd(I) Principal ideal (14) of Integer Ring - >>> from sage.all import * >>> R = ZZ >>> I = R.ideal(Integer(42)) >>> J = R.ideal(Integer(70)) >>> I.gcd(J) Principal ideal (14) of Integer Ring >>> J.gcd(I) Principal ideal (14) of Integer Ring 
 - is_maximal()[source]¶
- Return whether this ideal is maximal. - Principal ideal domains have Krull dimension 1 (or 0), so an ideal is maximal if and only if it’s prime (and nonzero if the ring is not a field). - EXAMPLES: - sage: # needs sage.rings.finite_rings sage: R.<t> = GF(5)[] sage: p = R.ideal(t^2 + 2) sage: p.is_maximal() True sage: p = R.ideal(t^2 + 1) sage: p.is_maximal() False sage: p = R.ideal(0) sage: p.is_maximal() False sage: p = R.ideal(1) sage: p.is_maximal() False - >>> from sage.all import * >>> # needs sage.rings.finite_rings >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1) >>> p = R.ideal(t**Integer(2) + Integer(2)) >>> p.is_maximal() True >>> p = R.ideal(t**Integer(2) + Integer(1)) >>> p.is_maximal() False >>> p = R.ideal(Integer(0)) >>> p.is_maximal() False >>> p = R.ideal(Integer(1)) >>> p.is_maximal() False 
 - is_prime()[source]¶
- Return - Trueif the ideal is prime.- This relies on the ring elements having a method - is_irreducible()implemented, since an ideal \((a)\) is prime iff \(a\) is irreducible (or 0).- EXAMPLES: - sage: ZZ.ideal(2).is_prime() True sage: ZZ.ideal(-2).is_prime() True sage: ZZ.ideal(4).is_prime() False sage: ZZ.ideal(0).is_prime() True sage: R.<x> = QQ[] sage: P = R.ideal(x^2 + 1); P Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over Rational Field sage: P.is_prime() # needs sage.libs.pari True - >>> from sage.all import * >>> ZZ.ideal(Integer(2)).is_prime() True >>> ZZ.ideal(-Integer(2)).is_prime() True >>> ZZ.ideal(Integer(4)).is_prime() False >>> ZZ.ideal(Integer(0)).is_prime() True >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> P = R.ideal(x**Integer(2) + Integer(1)); P Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over Rational Field >>> P.is_prime() # needs sage.libs.pari True - In fields, only the zero ideal is prime: - sage: RR.ideal(0).is_prime() True sage: RR.ideal(7).is_prime() False - >>> from sage.all import * >>> RR.ideal(Integer(0)).is_prime() True >>> RR.ideal(Integer(7)).is_prime() False 
 - radical()[source]¶
- Return the radical of this ideal. - EXAMPLES: - sage: ZZ.ideal(12).radical() Principal ideal (6) of Integer Ring - >>> from sage.all import * >>> ZZ.ideal(Integer(12)).radical() Principal ideal (6) of Integer Ring 
 - reduce(f)[source]¶
- Return the reduction of \(f\) modulo - self.- EXAMPLES: - sage: I = 8*ZZ sage: I.reduce(10) 2 sage: n = 10; n.mod(I) 2 - >>> from sage.all import * >>> I = Integer(8)*ZZ >>> I.reduce(Integer(10)) 2 >>> n = Integer(10); n.mod(I) 2 
 - residue_field()[source]¶
- Return the residue class field of this ideal, which must be prime. - Todo - Implement this for more general rings. Currently only defined for \(\ZZ\) and for number field orders. - EXAMPLES: - sage: # needs sage.libs.pari sage: P = ZZ.ideal(61); P Principal ideal (61) of Integer Ring sage: F = P.residue_field(); F Residue field of Integers modulo 61 sage: pi = F.reduction_map(); pi Partially defined reduction map: From: Rational Field To: Residue field of Integers modulo 61 sage: pi(123/234) 6 sage: pi(1/61) Traceback (most recent call last): ... ZeroDivisionError: Cannot reduce rational 1/61 modulo 61: it has negative valuation sage: lift = F.lift_map(); lift Lifting map: From: Residue field of Integers modulo 61 To: Integer Ring sage: lift(F(12345/67890)) 33 sage: (12345/67890) % 61 33 - >>> from sage.all import * >>> # needs sage.libs.pari >>> P = ZZ.ideal(Integer(61)); P Principal ideal (61) of Integer Ring >>> F = P.residue_field(); F Residue field of Integers modulo 61 >>> pi = F.reduction_map(); pi Partially defined reduction map: From: Rational Field To: Residue field of Integers modulo 61 >>> pi(Integer(123)/Integer(234)) 6 >>> pi(Integer(1)/Integer(61)) Traceback (most recent call last): ... ZeroDivisionError: Cannot reduce rational 1/61 modulo 61: it has negative valuation >>> lift = F.lift_map(); lift Lifting map: From: Residue field of Integers modulo 61 To: Integer Ring >>> lift(F(Integer(12345)/Integer(67890))) 33 >>> (Integer(12345)/Integer(67890)) % Integer(61) 33 
 
- class sage.rings.ideal.Ideal_principal(ring, gens, coerce=True, **kwds)[source]¶
- Bases: - Ideal_generic- A principal ideal. - See - Ideal().- divides(other)[source]¶
- Return - Trueif- selfdivides- other.- EXAMPLES: - sage: P.<x> = PolynomialRing(QQ) sage: I = P.ideal(x) sage: J = P.ideal(x^2) sage: I.divides(J) True sage: J.divides(I) False - >>> from sage.all import * >>> P = PolynomialRing(QQ, names=('x',)); (x,) = P._first_ngens(1) >>> I = P.ideal(x) >>> J = P.ideal(x**Integer(2)) >>> I.divides(J) True >>> J.divides(I) False 
 - gen(i=0)[source]¶
- Return the generator of the principal ideal. - The generator is an element of the ring containing the ideal. - EXAMPLES: - A simple example in the integers: - sage: R = ZZ sage: I = R.ideal(7) sage: J = R.ideal(7, 14) sage: I.gen(); J.gen() 7 7 - >>> from sage.all import * >>> R = ZZ >>> I = R.ideal(Integer(7)) >>> J = R.ideal(Integer(7), Integer(14)) >>> I.gen(); J.gen() 7 7 - Note that the generator belongs to the ring from which the ideal was initialized: - sage: R.<x> = ZZ[] sage: I = R.ideal(x) sage: J = R.base_extend(QQ).ideal(2,x) sage: a = I.gen(); a x sage: b = J.gen(); b 1 sage: a.base_ring() Integer Ring sage: b.base_ring() Rational Field - >>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> I = R.ideal(x) >>> J = R.base_extend(QQ).ideal(Integer(2),x) >>> a = I.gen(); a x >>> b = J.gen(); b 1 >>> a.base_ring() Integer Ring >>> b.base_ring() Rational Field 
 - is_principal()[source]¶
- Return - Trueif the ideal is principal in the ring containing the ideal. When the ideal construction is explicitly principal (i.e. when we define an ideal with one element) this is always the case.- EXAMPLES: - Note that Sage automatically coerces ideals into principal ideals during initialization: - sage: R.<x> = ZZ[] sage: I = R.ideal(x) sage: J = R.ideal(2,x) sage: K = R.base_extend(QQ).ideal(2,x) sage: I Principal ideal (x) of Univariate Polynomial Ring in x over Integer Ring sage: J Ideal (2, x) of Univariate Polynomial Ring in x over Integer Ring sage: K Principal ideal (1) of Univariate Polynomial Ring in x over Rational Field sage: I.is_principal() True sage: K.is_principal() True - >>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> I = R.ideal(x) >>> J = R.ideal(Integer(2),x) >>> K = R.base_extend(QQ).ideal(Integer(2),x) >>> I Principal ideal (x) of Univariate Polynomial Ring in x over Integer Ring >>> J Ideal (2, x) of Univariate Polynomial Ring in x over Integer Ring >>> K Principal ideal (1) of Univariate Polynomial Ring in x over Rational Field >>> I.is_principal() True >>> K.is_principal() True 
 
- sage.rings.ideal.Katsura(R, n=None, homog=False, singular=None)[source]¶
- \(n\)-th katsura ideal of \(R\) if \(R\) is coercible to - Singular.- INPUT: - R– base ring to construct ideal for
- n– (default:- None) which katsura ideal of \(R\). If- None, then- nis set to- R.ngens()
- homog– boolean (default:- False); if- Truea homogeneous ideal is returned using the last variable in the ideal
- singular– Singular instance to use
 - EXAMPLES: - sage: P.<x,y,z> = PolynomialRing(QQ, 3) sage: I = sage.rings.ideal.Katsura(P, 3); I # needs sage.libs.singular Ideal (x + 2*y + 2*z - 1, x^2 + 2*y^2 + 2*z^2 - x, 2*x*y + 2*y*z - y) of Multivariate Polynomial Ring in x, y, z over Rational Field - >>> from sage.all import * >>> P = PolynomialRing(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3) >>> I = sage.rings.ideal.Katsura(P, Integer(3)); I # needs sage.libs.singular Ideal (x + 2*y + 2*z - 1, x^2 + 2*y^2 + 2*z^2 - x, 2*x*y + 2*y*z - y) of Multivariate Polynomial Ring in x, y, z over Rational Field - sage: Q.<x> = PolynomialRing(QQ, implementation='singular') # needs sage.libs.singular sage: J = sage.rings.ideal.Katsura(Q,1); J # needs sage.libs.singular Ideal (x - 1) of Multivariate Polynomial Ring in x over Rational Field - >>> from sage.all import * >>> Q = PolynomialRing(QQ, implementation='singular', names=('x',)); (x,) = Q._first_ngens(1)# needs sage.libs.singular >>> J = sage.rings.ideal.Katsura(Q,Integer(1)); J # needs sage.libs.singular Ideal (x - 1) of Multivariate Polynomial Ring in x over Rational Field 
- sage.rings.ideal.is_Ideal(x)[source]¶
- Return - Trueif object is an ideal of a ring.- EXAMPLES: - A simple example involving the ring of integers. Note that Sage does not interpret rings objects themselves as ideals. However, one can still explicitly construct these ideals: - sage: from sage.rings.ideal import is_Ideal sage: R = ZZ sage: is_Ideal(R) doctest:warning... DeprecationWarning: The function is_Ideal is deprecated; use 'isinstance(..., Ideal_generic)' instead. See https://github.com/sagemath/sage/issues/38266 for details. False sage: 1*R; is_Ideal(1*R) Principal ideal (1) of Integer Ring True sage: 0*R; is_Ideal(0*R) Principal ideal (0) of Integer Ring True - >>> from sage.all import * >>> from sage.rings.ideal import is_Ideal >>> R = ZZ >>> is_Ideal(R) doctest:warning... DeprecationWarning: The function is_Ideal is deprecated; use 'isinstance(..., Ideal_generic)' instead. See https://github.com/sagemath/sage/issues/38266 for details. False >>> Integer(1)*R; is_Ideal(Integer(1)*R) Principal ideal (1) of Integer Ring True >>> Integer(0)*R; is_Ideal(Integer(0)*R) Principal ideal (0) of Integer Ring True - Sage recognizes ideals of polynomial rings as well: - sage: R = PolynomialRing(QQ, 'x'); x = R.gen() sage: I = R.ideal(x^2 + 1); I Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over Rational Field sage: is_Ideal(I) True sage: is_Ideal((x^2 + 1)*R) True - >>> from sage.all import * >>> R = PolynomialRing(QQ, 'x'); x = R.gen() >>> I = R.ideal(x**Integer(2) + Integer(1)); I Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over Rational Field >>> is_Ideal(I) True >>> is_Ideal((x**Integer(2) + Integer(1))*R) True