23.1 Ideals

Module: sage.rings.ideal

Ideals

Sage provides functionality for computing with ideals. One can create an ideal in any commutative ring $ R$ by giving a list of generators, using the notation R.ideal([a,b,...]).

Module-level Functions

Cyclic( R, [n=None], [homog=False], [singular=Singular])

Ideal of cyclic n-roots from 1-st n variables of R if R is coercable to Singular. If n==None n is set to R.ngens()

Input:

R
- base ring to construct ideal for
n
- number of cyclic roots (default: None)
homog
- if True a homogenous ideal is returned using the last variable in the ideal (default: False)
singular
- singular instance to use

oteR will be set as the active ring in Singular

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)
sage: I
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()
[z^3 - 1, y^2 + y*z + z^2, x + y + z]

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)
sage: B = I.groebner_basis()
sage: len(B)
45

FieldIdeal( R)

Let q = R.base_ring().order() and (x0,...,x_n) = R.gens() then if q is finite this constructor returns

$ < x_0^q - x_0, ... , x_n^q - x_n >.$

We call this ideal the field ideal and the generators the field equations.

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

Antoher, similar example:

sage: Q.<x1,x2,x3,x4> = PolynomialRing(GF(2^4,name='alpha'), 4)
sage: J = sage.rings.ideal.FieldIdeal(Q); J
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

Ideal( R, [gens=[]], [coerce=True])

Create the ideal in ring with given generators.

There are some shorthand notations for creating an ideal, in addition to use the Ideal function:

        --  R.ideal(gens, coerce=True)
        --  gens*R
        --  R*gens

Input:

R
- a ring
gens
- list of elements
coerce
- bool (default: True); whether gens need to be coerced into ring.

Alternatively, one can also call this function with the syntax Ideal(gens) where gens is a nonempty list of generators or a single generator.

Output: The ideal of ring generated by gens.

sage: R, x = PolynomialRing(ZZ, 'x').objgen()
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

sage: ideal(x^2-2*x+1, x^2-1)
Ideal (x^2 - 1, x^2 - 2*x + 1) of Univariate Polynomial Ring in x over
Integer Ring
sage: ideal([x^2-2*x+1, x^2-1])
Ideal (x^2 - 1, x^2 - 2*x + 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

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 (t^2, 1, t) 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

TESTS:

sage: R, x = PolynomialRing(ZZ, 'x').objgen()
sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2])
sage: I == loads(dumps(I))
True

sage: I = Ideal(R, [4 + 3*x + x^2, 1 + x^2])
sage: I == loads(dumps(I))
True

sage: I = Ideal((4 + 3*x + x^2, 1 + x^2))
sage: I == loads(dumps(I))
True

Katsura( R, [n=None], [homog=False], [singular=Singular])

n-th katsura ideal of R if R is coercable to Singular. If n==None n is set to R.ngens()

Input:

R
- base ring to construct ideal for
n
- which katsura ideal of R
homog
- if True a homogenous ideal is returned using the last variable in the ideal (default: False)
singular
- singular instance to use

sage: P.<x,y,z> = PolynomialRing(QQ,3)
sage: I = sage.rings.ideal.Katsura(P,3); I
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,1)
sage: J = sage.rings.ideal.Katsura(Q,1); J
Ideal (x - 1) of Multivariate Polynomial Ring in x over Rational Field

is_Ideal( x)

Returns True if object is an ideal of a ring.

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: R = ZZ
sage: is_Ideal(R)
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

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

Class: Ideal_fractional

class Ideal_fractional

Special Functions: __repr__

Class: Ideal_generic

class Ideal_generic
An ideal.
Ideal_generic( self, ring, gens, [coerce=True])

Functions: base_ring,$ \,$ category,$ \,$ gens,$ \,$ gens_reduced,$ \,$ is_maximal,$ \,$ is_prime,$ \,$ is_principal,$ \,$ is_trivial,$ \,$ reduce,$ \,$ ring

base_ring( self)

Returns the base ring of this ideal.

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

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

And p-adic numbers:

sage: R = Zp(7, prec=10); R
7-adic Ring with capped relative precision 10
sage: I = 7*R; I
Principal ideal (7 + O(7^11)) of 7-adic Ring with capped relative precision
10
sage: I.base_ring()
7-adic Ring with capped relative precision 10

category( self)

Return the category of this ideal.

Note that category is dependent on the ring of the ideal.

sage: I = ZZ.ideal(7)
sage: J = ZZ[x].ideal(7,x)
sage: K = ZZ[x].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

gens( self)

Return a set of generators / a basis of self. This is usually the set of generators provided during object creation.

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)

sage: ZZ.ideal(5,10).gens()
(5,)

gens_reduced( self)

Same as gens() for this ideal, since there is currently no special gens_reduced algorithm implemented for this ring.

This method is provided so that ideals in ZZ have the method gens_reduced(), just like ideals of number fields.

sage: ZZ.ideal(5).gens_reduced()
(5,)

is_maximal( self)

Returns True if the ideal is maximal in the ring containing the ideal.

TODO: Make self.is_maximal() work! Write this code!

sage: R = ZZ
sage: I = R.ideal(7)
sage: I.is_maximal()
Traceback (most recent call last):
...
NotImplementedError

is_prime( self)

Returns True if the ideal is prime in the ring containing the ideal.

TODO: Make self.is_prime() work! Write this code!

sage: R = ZZ[x]
sage: I = R.ideal(7)
sage: I.is_prime()
Traceback (most recent call last):
...
NotImplementedError

is_principal( self)

Returns True if the ideal is principal in the ring containing the ideal.

TODO: Code is naive. Only keeps track of ideal generators as set during intiialization of the ideal. (Can the base ring change? See example below.)

sage: R = ZZ[x]
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

is_trivial( self)
Return True if this ideal is (0) or (1).

TESTS:

sage: I = ZZ.ideal(5)
sage: I.is_trivial()
False

sage: I = ZZ['x'].ideal(-1)
sage: I.is_trivial()
True

sage: I = ZZ['x'].ideal(ZZ['x'].gen()^2)
sage: I.is_trivial()
False

sage: I = QQ['x', 'y'].ideal(-5)
sage: I.is_trivial()
True

sage: I = CC['x'].ideal(0)
sage: I.is_trivial()
True

reduce( self, f)

Return the reduction the element of $ f$ modulo the ideal $ I$ (=self). This is an element of $ R$ that is equivalent modulo $ I$ to $ f$ .

sage: ZZ.ideal(5).reduce(17)
2
sage: parent(ZZ.ideal(5).reduce(17))
Integer Ring

ring( self)

Returns the ring containing this ideal.

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

Note that self.ring() is different from self.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

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')
sage: S = PolynomialRing(Rbar, 'y'); y = Rbar.gen(); S
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)
sage: J.ring()
Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in
a over Rational Field with modulus x^2 - 3

Special Functions: __add__,$ \,$ __cmp__,$ \,$ __contains__,$ \,$ __init__,$ \,$ __mul__,$ \,$ __radd__,$ \,$ __repr__,$ \,$ __rmul__,$ \,$ _contains_,$ \,$ _latex_,$ \,$ _repr_short

Class: Ideal_pid

class Ideal_pid
An ideal of a principal ideal domain.
Ideal_pid( self, ring, gen)

Functions: gcd,$ \,$ is_prime,$ \,$ reduce

gcd( self, other)

Returns 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 other is neither principal nor when the generator of self is contained in other. Also, it seems that this class is used only in PIDs--is this redundant? Note: second example is broken.

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

TESTS: We cannot take the gcd of a principal ideal with a non-principal ideal as well: ( gcd(I,J) should be (7) )

sage: I = ZZ.ideal(7)
sage: J = ZZ[x].ideal(7,x)
sage: I.gcd(J)
Traceback (most recent call last):
...
NotImplementedError
sage: J.gcd(I)
Traceback (most recent call last):
...
AttributeError: 'Ideal_generic' object has no attribute 'gcd'

Note:

sage: type(I)
<class 'sage.rings.ideal.Ideal_pid'>
sage: type(J)
<class 'sage.rings.ideal.Ideal_generic'>

is_prime( self)

Returns True if 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)

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()
True

reduce( self, f)

Return the reduction of f modulo self.

sage: I = 8*ZZ
sage: I.reduce(10)
2
sage: n = 10; n.mod(I)
2

Special Functions: __add__,$ \,$ __init__

Class: Ideal_principal

class Ideal_principal
A principal ideal.
Ideal_principal( self, ring, gen)

Functions: divides,$ \,$ gen,$ \,$ is_principal

divides( self, other)

Returns True if self divides other.

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

gen( self)

Returns the generator of the principal ideal. The generators are elements of the ring containing the ideal.

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

Note that the generator belongs to the ring from which the ideal was initialized:

sage: R = ZZ[x]
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

is_principal( self)

Returns True if 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.

Note that SAGE automatically coerces ideals into principals ideals during initialization:

sage: R = ZZ[x]
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

Special Functions: __cmp__,$ \,$ __contains__,$ \,$ __init__,$ \,$ __repr__

__contains__( self, x)

Returns True if x is in the ideal self.

sage: P.<x> = PolynomialRing(ZZ)
sage: I = P.ideal(x^2-2)
sage: x^2 in I
False
sage: x^2-2 in I
True
sage: x^2-3 in I
False

See About this document... for information on suggesting changes.