# First Operations on Ideals

In the following, note that since ideals of a full polynomial ring $P$ are regarded as subrings of $P$, the ring $P$ itself is a valid ideal as well (the ideal containing 1).

## Simple Ideal Constructions

The following basic constructions involve no Gröbner basis computation.

### `I + J: RngMPol, RngMPol -> RngMPol`

Given ideals $I$ and $J$ of the same polynomial ring $P$, return the sum of $I$ and $J$, which is the ideal generated by the generators of $I$ and those of $J$.

### `I * J: RngMPol, RngMPol -> RngMPol`

Given ideals $I$ and $J$ of the same polynomial ring $P$, return the product of $I$ and $J$, which is the ideal generated by the products of the generators of $I$ and those of $J$.

### `I ^ k: RngMPol, RngIntElt -> RngMPol`

Given an ideal $I$ of the polynomial ring $P$, and an integer $k$, return the $k$-th power of $I$.

### `I / J: RngMPol, RngMPol -> RngMPolRes`

Given an ideal $I$ of a polynomial ring $P$ over a field and an ideal $J$ of $P$, such that $J \subset I$, return the affine algebra $I/J$.

## Basic Commutative Algebra Operations

The following important basic operations on ideals involve Gröbner basis computation and use the standard algorithms as described in Chapter 1.8 of [[Greuel and Pfister, 2002](../../references.md#cite-grpf02)], for example, unless otherwise stated.

### `QuotientDimension(I): RngMPol -> RngIntElt`

Given an ideal $I$ of a polynomial ring $P$ over a field $K$, return the dimension of $P/I$ as a $K$-vector space. Note that this is quite different from the function [`Dimension`](dimension.md#function-dpoly-ideal-dimension) below (which returns the Krull dimension of an ideal). If $I$ is not of Krull dimension 0 then the vector space is infinite and `Infinity` is returned.

### `ColonIdeal(I, J): RngMPol, RngMPol -> RngMPol`

### `IdealQuotient(I, J): RngMPol, RngMPol -> RngMPol`

Given ideals $I$ and $J$ of the same polynomial ring $P$, return the colon ideal $I:J$ (or ideal quotient of $I$ by $J$), consisting of the polynomials $f$ of $P$ such that $f*g$ is in I for all $g$ in $J$.

### `ColonIdeal(I, f): RngMPol, RngMPolElt -> RngMPol, RngIntElt`

### `IdealQuotient(I, f): RngMPol, RngMPolElt -> RngMPol, RngIntElt`

Given an ideal $I$ and an element $f$ of a polynomial ring $P$, return the saturation (colon) ideal $I:f^\infty$, consisting of the polynomials $g$ of $P$ such that there exists an $i \geq 1$ with $f^i*g \in I$. An integer $s$ with $s \geq 1$ is also returned such that $I:f^\infty = I:f^s$. Note that if $s$ is not needed, only one return value of the function should be expected which increases the efficiency enormously. Note also that this function is *not* equivalent to taking the ideal quotient of $I$ by the ideal of $P$ generated by $f$. It is in some ways a more natural operation mathematically, corresponding to taking the full inverse image of the localised ideal $I_f$ under the localisation map $P \rightarrow P_f$, and can be faster than the $I:f$ computation, if $s$ is not required. In this case, the computation goes by the elimination of extra variable $t$ from the ideal $<I,1-f*t>$.

### `ColonIdealEquivalent(I, f): RngMPol, RngMPolElt -> RngMPol, RngMPolElt`

### `Saturation(I, f): RngMPol, RngMPolElt -> RngMPol, RngMPolElt`

Given an ideal $I$ and an element $f$ of a polynomial ring $P$, return the saturation (colon) ideal $C=I:f^\infty$, and a polynomial $g\in P$ such that $C=I:\langle g\rangle$ and $g$ is of minimal degree. The irreducible factors of $g$ will be a subset of the irreducible factors of $f$ (and the corresponding multiplicities may be greater or lesser, depending on how often an irreducible factor divides the ideal $I$).

### `Saturation(I, J): RngMPol, RngMPol -> RngMPol`

Given ideals $I$ and $J$ of some polynomial ring $P$, return the saturation $(I:J^\infty)$: that is, the ideal $\{ f \in P: \exists n > 0, f J^n \subseteq I\}$.

### `Saturation(I): RngMPol -> RngMPol`

Given an ideal $I$ of a polynomial ring $P$, return the saturation of $I$ with respect to the irrelevant ideal of $P$ – that is, the ideal of all elements of $P$ having positive degree.

### `Generic(I): RngMPol -> RngMPol`

Given an ideal $I$ of a generic polynomial ring $P$, return $P$.

### `LeadingMonomialIdeal(I): RngMPol -> RngMPol`

Given an ideal $I$, return the leading monomial ideal of $I$; that is, the ideal generated by all the leading monomials of $I$.

### `I meet J: RngMPol, RngMPol -> RngMPol`

Given ideals $I$ and $J$ of the same polynomial ring $P$, return the intersection of $I$ and $J$.

### `&meet S: [ RngMPol ] -> RngMPol`

Given a set or sequence $S$ of ideals of the same polynomial ring $P$, return the intersection of all the ideals of $S$.

### `RegularSequence(I): RngMPol -> SeqEnum`

```magma
Homogeneous: BoolElt                    Default: true
```

Given an ideal $I$ of a polynomial ring $P$ over a field, computes and returns a maximal regular sequence in $I$. The algorithm used is that of Eisenbud and Sturmfels ([[Eisenbud and Sturmfels, 1994](../../references.md#cite-eis-sturm-reg-94)]) that tries to construct a regular sequence of fairly sparse polynomials. If parameter `Homogeneous` is `true` (the default), and $I$ is a homogeneous ideal with respect to the variable weights, then the regular sequence constructed will also consist of homogeneous polynomials.

### `ReesIdeal(P, I): RngMPol, RngMPol -> RngMPol, Map`

### `ReesIdeal(P, J, I): RngMPol, RngMPol, RngMPol -> RngMPol, Map`

### `ReesIdeal(R, I): RngMPolRes, RngMPol -> RngMPol, Map`

```magma
a: RngMPolElt                    Default: 1
```

```magma
a: RngMPolElt                    Default: 1
```

In each case $P$ is a multivariate polynomial ring and $I$ is an ideal of $P$. In the third case $R$ is an affine quotient algebra of the form $P/J$. In the second case $J$ is another ideal of $P$ and we write $R$ for the affine algebra $P/J$. In the first case, let $R = P$.

The Rees algebra $R(I)$ is the finitely-generated, graded polynomial algebra isomorphic to the algebra

$$
R \oplus I \oplus I^2 \oplus I^3 \oplus \ldots
$$

where $I$ gives the first graded part, $I^2$ the second etc. and the multiplication is the obvious one. Here $I$ is thought of as an ideal of $R$, rather than $P$ for the second and third signatures. $Proj$ of this algebra represents the blow-up of the affine scheme $Spec(R)$ along the closed subscheme defined by $I$ (see Chapter 2, Section 7 of [[Hartshorne, 1977](../../references.md#cite-hartshorne)]).

The function returns the *Rees ideal*, $K$, such that, if $R_1$ is the generic polynomial ring of $K$, then $R_1/K$ is an affine algebra isomorphic to $R(I)/<a-torsion>$, where $a$ is an element of $P$ (or $R$ in the third case) that gives a non-zero divisor in $R$ and is $1$ by default. In the first case, any such $a$ remains a non-zero divisor in $R(I)$, so is redundant. However, in the second and third cases, $a$ can be specified to be not equal to $1$ by use of the `a` parameter. Geometrically, dividing out by $a$-torsion gives the coordinate ring of the maximal closed subscheme of the blow-up that is flat over the generic point and the codimension one points defined by the vanishing of $a$, if these points are regular.

## Ideal Predicates

### `I eq J: RngMPol, RngMPol -> BoolElt`

Given two ideals $I$ and $J$ of the same polynomial ring $P$, return whether $I$ and $J$ are equal. Involves the use of a Gröbner basis for each ideal.

### `I ne J: RngMPol, RngMPol -> BoolElt`

Given two ideals $I$ and $J$ of the same polynomial ring $P$, return whether $I$ and $J$ are not equal. Involves the use of a Gröbner basis for each ideal.

### `I notsubset J: RngMPol, RngMPol -> BoolElt`

Given two ideals $I$ and $J$ in the same polynomial ring $P$ return whether $I$ is not contained in $J$. Involves the use of a Gröbner basis for $J$.

### `I subset J: RngMPol, RngMPol -> BoolElt`

Given two ideals $I$ and $J$ in the same polynomial ring $P$ return whether $I$ is contained in $J$. Involves the use of a Gröbner basis for $J$.

### `IsZero(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is the zero ideal (contains zero alone).

### `IsProper(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is proper; that is, whether $I$ is strictly contained in $P$, or whether the Gröbner basis of $I$ does not contain 1 alone.

### `IsHomogeneous(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, this function returns whether $I$ is homogeneous with respect to the weights on the variables of $P$ (i.e., whether $I$ possesses a basis consisting of homogeneous polynomials alone). Checks whether the current basis of $I$ consists of homogeneous polynomials and, if not and the current basis isn’t Gröbner, then whether an easy Gröbner basis consists of homogeneous elements.

### `IsPrincipal(I): RngMPol -> BoolElt, RngMPolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is principal, and if so, return also a generator of $I$. This will be true if and only if an arbitrary Gröbner basis consists of a single (generating) element.

### `IsPrimary(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is primary. An ideal $I$ is primary if and only if for all $ab \in I$, either $a \in I$ or $b^n \in I$ for some $n \geq 1$. The restrictions on $I$ are the same as for the function [`PrimaryDecomposition`](radical-decomposition.md#function-dpoly-ideal-primarydecomposition)—see the description of that function. In general, this function computes or retrieves the primary decomposition and checks whether it has a unique element.

### `IsPrime(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is prime. An ideal $I$ is prime if and only if for all $ab \in I$, either $a \in I$ or $b \in I$. The restrictions on $I$ are the same as for the function [`PrimaryDecomposition`](radical-decomposition.md#function-dpoly-ideal-primarydecomposition)—see the description of that function. Again, this function computes the primary decomposition or uses the already stored one.

### `IsMaximal(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is maximal. The restrictions on $I$ are the same as for the function [`PrimaryDecomposition`](radical-decomposition.md#function-dpoly-ideal-primarydecomposition)—see the description of that function. Checks first whether $I$ is zero-dimensional (see below) and, if so, then checks whether it is prime. NB: given that $I$ is of dimension 0, the prime/primary decomposition computation is relatively fast.

### `IsRadical(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether $I$ is radical; that is, whether the radical of $I$ is $I$ itself. The restrictions on $I$ are the same as for the function [`Radical`](radical-decomposition.md#function-dpoly-ideal-radical)—see the description of that function. The function computes the radical or uses the already stored one.

### `IsZeroDimensional(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, defined over a field, return whether $I$ is zero-dimensional (so the quotient of $P$ by $I$ has non-zero finite dimension as a vector space over the coefficient field – see the section on dimension for further details). Note that the full polynomial ring $P$ as an ideal of itself has dimension $-1$, so it is not zero-dimensional.

### `HasGrevlexOrder(I): RngMPol -> BoolElt`

Given an ideal $I$ of the polynomial ring $P$, return whether the monomial order of $I$ is the `grevlex` order.

### `Example: Ideal Arithmetic (ex-d1b8ee)`

We construct some ideals in ${\mathbb{Q}}[x, y, z]$ and perform basic arithmetic on them.

```magma
> P<x,y,z> := PolynomialRing(RationalField(), 3);
> I := ideal<P | x*y - 1, x^3*z^2 - y^2, x*z^3 - x - 1>;
> J := ideal<P | x*y - 1, x^2*z - y, x*z^3 - x - 1>;
> A := I * J;
> A;
Ideal of Polynomial ring of rank 3 over Rational Field
Order: Lexicographical
Variables: x, y, z
Basis:
[
    x^2*y^2 - 2*x*y + 1,
    x^3*y*z - x^2*z - x*y^2 + y,
    x^2*y*z^3 - x^2*y - x*y - x*z^3 + x + 1,
    x^4*y*z^2 - x^3*z^2 - x*y^3 + y^2,
    x^5*z^3 - x^3*y*z^2 - x^2*y^2*z + y^3,
    x^4*z^5 - x^4*z^2 - x^3*z^2 - x*y^2*z^3 + x*y^2 + y^2,
    x^2*y*z^3 - x^2*y - x*y - x*z^3 + x + 1,
    x^3*z^4 - x^3*z - x^2*z - x*y*z^3 + x*y + y,
    x^2*z^6 - 2*x^2*z^3 + x^2 - 2*x*z^3 + 2*x + 1
]
> M := I meet J;
> M;
Ideal of Polynomial ring of rank 3 over Rational Field
Order: Lexicographical
Variables: x, y, z
Basis:
[
    x^4 + x^3 - x*z^2 + z^12 - 4*z^9 + 6*z^6 - z^4 - 4*z^3 + z + 1,
    x^5 + x^4 - x^2*z^2 + z^9 - 3*z^6 + 3*z^3 - z - 1,
    x*z^3 - x - 1,
    y - z^3 + 1
]
> A eq M;
true
> QuotientDimension(A);
24
> ColonIdeal(I, J);
Ideal of Polynomial ring of rank 3 over Rational Field
Order: Lexicographical
Variables: x, y, z
Inhomogeneous, Dimension 0
Basis:
[
    x*y - 1,
    x^3*z^2 - y^2,
    x*z^3 - x - 1
]

```

## Element Operations with Ideals

### `f in I: RngMPolElt, RngMPol -> BoolElt`

Given a polynomial $f$ from a polynomial ring $P$, together with an ideal $I$ of $P$, return whether $f$ is in $I$. The function computes the normal form of $f$ relative to some Gröbner basis of $I$ and checks if this is zero.

### `f notin I: RngMPolElt, RngMPol -> BoolElt`

Given a polynomial $f$ from a polynomial ring $P$, together with an ideal $I$ of $P$, return whether $f$ is not in $I$. As with `in`, this performs a normal form computation.

### `IsInRadical(f, I): RngMPolElt, RngMPol -> BoolElt`

Given a polynomial $f$ from a polynomial ring $P$, together with an ideal $I$ of $P$, return whether $f$ is in the radical of $I$. Note that using this function is much quicker in general than actually computing the radical of $I$. It uses the algorithm described in section 1.8.6 of [[Greuel and Pfister, 2002](../../references.md#cite-grpf02)].

### `JacobianIdeal(f): RngMPolElt -> RngMPol`

Return the ideal generated by all first partial derivatives of the polynomial $f$.

### `Example: Element Operations (ex-273d4e)`

We demonstrate the element operations with respect to an ideal of ${\mathbb{Q}}[x, y, z]$.

```magma
> P<x, y, z> := PolynomialRing(RationalField(), 3);
> I := ideal<P | (x + y)^3, (y - z)^2, y^2*z + z>;
> NormalForm(y^2*z + z, I);
0
> NormalForm(x^3, I);
-3*x^2*y - 3*x*z^4 - 6*x*z^2 + 1/2*z^3 + 3/2*z
> NormalForm(z^4 + y^2, I);
2*z^4 + 2*z^2
> x + y in I;
false
> IsInRadical(x + y, I);
true
> IsInRadical((x + y)^2, I);
true
> IsInRadical(z, I);
false
> SPolynomial(x^4 + y - z, x^2 + y - z);
-x^2*y + x^2*z + y - z

```
