Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am not very familiar with the case when R is not a field, so let me try to answer the case when R is a field.

If R is a field and I is a zero-dimensional ideal, then R/I is a finite dimensional vector space and a basis can be computed using the method normal_basis:

sage: R.<x,y,z> = QQ[]
sage: I = R.ideal([x^2 + y^2 - 1, z^3, z - x^3])
sage: I.dimension()
sage: I.normal_basis()
[y^3*z^2, y^2*z^2, x*y*z^2, y*z^2, x*z^2, z^2, y^3*z, y^2*z, x*y*z, y*z, x*z, z, y^3, y^2, x*y, y, x, 1]

If the ideal is of positive dimension, then Sage does not currently have a way to compute this directly. However, we can use Singular for this. Given a Gröbner basis of an ideal, the function kbase can be used to find the finitely-many monomials of certain degree in a vector space basis of this infinite-dimensional space. Let us define a wrapper function:

def kbasis(I, d):
    gb = I.groebner_basis()
    # the Singular interface works with ideals, but in Sage we prefer
    # polynomial sequences, so we need these conversions
    return singular.kbase(gb.ideal(), d).sage().gens()

Now we get:

sage: R.<x,y,z> = QQ[]
sage: I = R.ideal([x^2 + y^2 - 1, z^3])
sage: kbasis(I, 0)
sage: kbasis(I, 1)
[z, y, x]
sage: kbasis(I, 2)
[z^2, y*z, x*z, y^2, x*y]
sage: kbasis(I, 3)
[y*z^2, x*z^2, y^2*z, x*y*z, y^3, x*y^2]

In Sage, we can now even construct the infinite union over all degrees of these finite sets, which might be convenient for some purposes:

sage: D = DisjointUnionEnumeratedSets(Family(NN, lambda d: kbasis(I, d), name='kbasis_I'))
sage: D
Disjoint union of Lazy family (kbasis_I(i))_{i in Non negative integer semiring}
sage: D[0:15]
[1, z, y, x, z^2, y*z, x*z, y^2, x*y, y*z^2, x*z^2, y^2*z, x*y*z, y^3, x*y^2]