Ideals and Gröbner bases

Ideals

An ideal is everything that follows from a set of polynomial equations by adding and multiplying. This page is the dictionary between ideals and the shapes their equations cut out, and how each entry is computed.

Ideals

Let R=K[x1,…,xn]R = K[x_1, \dots, x_n]. An ideal of RR is a set of polynomials closed under addition and under multiplication by any polynomial. The ideal generated by f1,…,fsf_1, \dots, f_s is the set of all combinations

⟨f1,…,fs⟩={ q1f1+⋯+qsfs:qi∈R }. \langle f_1, \dots, f_s \rangle = \{\, q_1 f_1 + \dots + q_s f_s : q_i \in R \,\}.

These are exactly the equations that follow from f1=0,…,fs=0f_1 = 0, \dots, f_s = 0 by adding and multiplying. Hilbert's basis theorem says every ideal of RR is generated by finitely many polynomials, so every ideal can be held as a list.

The same ideal has many generating lists. To compare ideals, or to test whether a polynomial is in one, the library computes a Gröbner basis, the first time it is needed.

import { ring, ideal } from "@ratmath/structures";

const R = ring("x, y, z");
const I = ideal(R, ["x z - y^2", "x^3 - z^2"]);
String(I);                         // "(−y² + xz, x³ − z²)"
I.contains("x^3 z - y^2 z^2");     // false
I.contains("x^4 z - x z^3");       // true: x z · (x³ − z²)
String(I.reduce("y^4"));           // "x²z²": the normal form of y⁴ modulo I
I.dimension;                       // 1: the solution set is a curve
I.equals(ideal(R, ["y^2 - x z", "z^2 - x^3", "x^4 z - x z^3"]));   // true

Algebra and geometry

An ideal II has a solution set V(I)V(I), the points where every polynomial of II vanishes. Operations on ideals correspond to operations on solution sets:

IdealsSolution setsMethod
I+JI + J (generators of both)V(I)∩V(J)V(I) \cap V(J)I.add(J)
I⋅JI \cdot J (products of generators)V(I)∪V(J)V(I) \cup V(J)I.mul(J)
I∩JI \cap JV(I)∪V(J)V(I) \cup V(J)I.intersect(J)
I:J={f:fJ⊆I}I : J = \{f : fJ \subseteq I\}contains V(I)∖V(J)V(I) \setminus V(J)I.quotient(J)
I:f∞I : f^\infty (saturation)the closure of V(I)∖V(f)V(I) \setminus V(f)I.saturate(f)
I∩K[some variables]I \cap K[\text{some variables}]the closure of the projectionI.eliminate(vars)
I\sqrt Ithe same set V(I)V(I)I.radical()

The product and the intersection have the same solutions, and IJ⊆I∩JIJ \subseteq I \cap J always, but they can differ as ideals: ⟨x⟩⋅⟨x⟩=⟨x2⟩\langle x\rangle \cdot \langle x\rangle = \langle x^2\rangle while ⟨x⟩∩⟨x⟩=⟨x⟩\langle x\rangle \cap \langle x\rangle = \langle x\rangle.

const A = ideal(R, ["x", "y"]);        // the z-axis
const B = ideal(R, ["z"]);             // the plane z = 0
String(A.add(B));                      // "(x, y, z)": the origin
A.intersect(B).basis.map(String);      // ["yz", "xz"]: the axis together with the plane
A.mul(B).equals(A.intersect(B));       // true here

const S = ring("x, y");
const J = ideal(S, ["x^2", "x y"]);    // the y-axis, with something extra at the origin
J.quotient("x").basis.map(String);     // ["y", "x"]
J.radical().basis.map(String);         // ["x"]
J.saturate("y").basis.map(String);     // ["x"]: away from y = 0 the ideal is just (x)

Intersections are computed with a classical trick: introduce a new variable tt, form tI+(1−t)JtI + (1 - t)J, and eliminate tt. The quotient by one polynomial is (I∩⟨g⟩)/g(I \cap \langle g\rangle)/g, and saturation adds 1−tf1 - tf and eliminates tt.

Elimination

The elimination theorem: if GG is a Gröbner basis of II for an order in which every monomial containing x1,…,xkx_1, \dots, x_k ranks above every monomial without them, then the elements of GG that do not involve x1,…,xkx_1, \dots, x_k are a Gröbner basis of I∩K[xk+1,…,xn]I \cap K[x_{k+1}, \dots, x_n]. So eliminating variables is a matter of choosing the order and reading off part of the basis.

A typical use is finding the equation of a curve or surface given by parameters. The curve x=t2−1x = t^2 - 1, y=t3−ty = t^3 - t is the solution set of x−t2+1=0, y−t3+t=0x - t^2 + 1 = 0,\ y - t^3 + t = 0 in (t,x,y)(t, x, y)-space, projected to the (x,y)(x, y)-plane:

const T = ring("t, x, y");
ideal(T, ["x - t^2 + 1", "y - t^3 + t"]).eliminate("t").basis.map(String);
      // ["x³ + x² − y²"]: the nodal cubic y² = x²(x + 1)

const U = ring("s, t, x, y, z");
ideal(U, ["x - s t", "y - s", "z - t^2"]).eliminate(["s", "t"]).basis.map(String);
      // ["y²z − x²"]: the Whitney umbrella

Compare resultants, which eliminate one variable from two polynomials. Elimination ideals handle any number of each and add no extra factors.

Radicals and the Nullstellensatz

Different ideals can have the same solutions: ⟨x⟩\langle x \rangle and ⟨x2⟩\langle x^2 \rangle both describe x=0x = 0. The radical I\sqrt I is the set of polynomials some power of which lies in II. Hilbert's Nullstellensatz says that over an algebraically closed field such as the complex numbers,

f vanishes at every point of V(I)  ⟺  f∈I, f \text{ vanishes at every point of } V(I) \iff f \in \sqrt I ,

and in particular V(I)V(I) is empty exactly when 1∈I1 \in I. So "does f=0f = 0 follow from the equations?" has a definite algebraic answer, and it can be tested without finding the radical: f∈If \in \sqrt I exactly when 1∈I+⟨1−tf⟩1 \in I + \langle 1 - t f \rangle for a new variable tt (Rabinowitsch's trick).

const Q = ideal(S, ["x^2", "y^3"]);
Q.contains("x + y");                   // false
Q.radicalContains("x + y");            // true
Q.exponentOf("x + y");                 // 4: (x + y)⁴ is in Q and (x + y)³ is not

const cert = Q.radicalContains("x + y", { certificate: true });
cert.power;                            // 4
cert.cofactors.map(String);            // ["x² + 4xy + 6y²", "4x + y"]
      // (x + y)⁴ = (x² + 4xy + 6y²)·x² + (4x + y)·y³, and cert.check confirms it

The certificate is a proof: an explicit identity fk=∑cifif^k = \sum c_i f_i that can be checked by multiplying out. This is how a theorem of geometry is proved by algebra: write the hypotheses as polynomial equations, and show the conclusion lies in the radical of the ideal they generate.

I.radical() itself is computed for ideals with finitely many solutions (by adding the square-free part of each variable's minimal polynomial, a method due to Seidenberg), for ideals with one generator, and for ideals generated by monomials. It throws for the rest; radicalContains works for every ideal.

Prime and maximal ideals

An ideal P≠RP \neq R is prime when fg∈Pfg \in P forces f∈Pf \in P or g∈Pg \in P; its solution set cannot be split into two smaller ones. It is maximal when no proper ideal is larger; over the complex numbers the maximal ideals are the single points ⟨x1−a1,…,xn−an⟩\langle x_1 - a_1, \dots, x_n - a_n \rangle. Over the rationals a maximal ideal is a point together with all its conjugates.

ideal(S, ["x^2 + y^2 - 1"]).isPrime();        // true: the circle is one piece
ideal(S, ["x y"]).isPrime();                  // false: two lines
ideal(S, ["x - 1", "y - 2"]).isMaximal();     // true: the point (1, 2)
ideal(S, ["x^2 - 2", "y - x"]).isMaximal();   // true: the pair (±√2, ±√2), one point over Q
ideal(S, ["x^2 - 1", "y"]).isMaximal();       // false: two rational points

isMaximal is decided over Q for every ideal. isPrime is decided for ideals with finitely many solutions, for one generator, and for linear generators, and returns null otherwise: a general test needs primary decomposition, which this library does not have.

Try itEdit the code and run it with @ratmath/structures and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs