Skip to main content

Grobx for Sage

The Python module grobx_sage computes reduced Gröbner bases of Sage's polynomial ideals with grobx's Python module. Its groebner_basis(I) is called as Sage's I.groebner_basis() is, for the fields and orders grobx computes in, returns what Sage's returns, and raises an error for anything else. Its groebner(I) also returns the cofactors and the call report (groebner below).

Over ℚ, GF(p), and GF(2), grobx is at least 10× faster than any other software. grobx.com/benchmarks.html gives the time and memory of every instance.

import grobx_sage
R.<x,y> = PolynomialRing(GF(7))
grobx_sage.groebner_basis(R.ideal(x^2 + y, x*y - 1))
# [x^2 + y, x*y - 1, y^2 + x]

Setup

sage -pip install grobx-sage installs the module grobx_sage from PyPI into Sage's Python, and grobx's Python module with it. make dist builds the package from this directory into dist/: the sdist, and the wheel grobx_sage-<version>-py3-none-any.whl, which sage -pip install takes as well.

groebner_basis

groebner_basis(I, *, threads=None, seed=None, deadline=None, memory=None, checker=None) returns the reduced Gröbner basis of the ideal I in its ring's term order. The ring is a multivariate polynomial ring over ℚ or GF(p), p a prime below 2^64, or a Boolean polynomial ring (Boolean rings below). The basis is an immutable PolynomialSequence of monic polynomials of that ring, the largest leading monomial first, as Sage returns it. The zero ideal's basis is [0].

Term order of the ring grobx's order
degrevlex, Sage's default, or dp grevlex
deglex deglex
lex or lp lex
degrevlex(k1),…,degrevlex(km) block:k1,…,k(m−1): grevlex in each block, the blocks in turn

The sum TermOrder("degrevlex", k1) + … + TermOrder("degrevlex", km) is the same block order, and so is dp(k1),…,dp(km). Sage lowercases an order's name, so its Dp is dp, which is grevlex.

The keywords are those of grobx.groebner (grobx's python/README.md, The call). A keyword left at None takes grobx's default.

Keyword Value
threads how many threads the call may use; 0 is all the machine has
seed the seed of every random choice, below 2^64
deadline a time limit on the whole call, in milliseconds
memory a ceiling on the memory grobx allocates in Sage's process, in bytes
checker an error bound in [0, 1), 0 for exact

checker has grobx's checker certify the result: that the basis is a Gröbner basis of I, and reduced.

Ctrl-C raises grobx's cancel flag. groebner_basis raises KeyboardInterrupt once grobx has stopped.

The ideal's polynomials reach grobx as Sage holds them, with no text between: grobx.groebner_sage reads their terms from Singular's polynomials in place, or, in a ring Singular does not hold, from Sage's dicts (grobx's python/README.md, Sage), the checker included, and the basis comes back as terms.

groebner

groebner(I, *, threads=None, seed=None, deadline=None, memory=None, checker=None, cofactors=False, exact_reduction=False, report=False, report_file=None) computes the basis of groebner_basis above and returns a grobx_sage.Result. The keywords are those of grobx.groebner but order, which the ring gives, and cancel, whose place Ctrl-C takes.

Attribute Meaning
basis The basis, as groebner_basis returns it
cofactors A list per element of the basis of one polynomial of the ring per generator in I.gens(); None where the call did not ask for them
report, sink_error, seed As grobx.Result's
import grobx_sage
R.<x,y> = PolynomialRing(GF(7))
I = R.ideal(x^2 + y, x*y - 1)
r = grobx_sage.groebner(I, cofactors=True)
all(g == sum(c*f for c, f in zip(row, I.gens())) for g, row in zip(r.basis, r.cofactors))
# True

Boolean rings

A Boolean polynomial ring B = BooleanPolynomialRing(n, names, order=…) is its cover ring B.cover_ring(), GF(2)[x] in the same term order, modulo the field equations x² + x. groebner_basis computes the basis of the ideal and the field equations of all variables in the cover ring, maps it into B, and drops the field equations, which map to 0 there. Their cofactors go with them. The result is PolyBoRi's I.groebner_basis(). The orders are those of groebner_basis above. The zero ideal's basis is [0], where Sage's own groebner_basis raises IndexError.

Errors

groebner_basis and groebner raise:

  • TypeError for anything but an ideal of a multivariate polynomial ring, an ideal of PolynomialRing(K, 'x') among them; PolynomialRing(K, 'x', 1) is the multivariate ring in one variable;
  • ValueError for a base ring other than ℚ and GF(p), such as ZZ, RR, GF(p^k), a number field, or a fraction field;
  • ValueError for any other order: degneglex, the negative orders, the weighted orders, matrix orders, and a block order with a block that is not degrevlex;
  • ValueError, grobx.Invalid among them, for what grobx rejects: a prime above 2^64, or a keyword's value;
  • grobx.Stopped where a deadline or a memory ceiling stopped the call, and grobx.Rejected where the checker rejected the basis, with the checker's reason; each carries the call's seed, as the Python module raises them.

groebner raises OSError where report_file cannot be created.

Test

make test builds the wheel and grobx's wheel from this tree, the latter by maturin and zig, installs both under Sage in the Docker image SAGE_IMAGE (sagemath/sagemath:10.10 by default), and runs test_grobx_sage.py against the installed module. It compares groebner_basis with Sage's groebner_basis on small systems over ℚ, GF(2), GF(65521), and GF(2^64 − 59) and on random Boolean systems, in degrevlex, dp, Dp, deglex, lp, lex, and three block orders, and on rings with Unicode names, one variable, and twelve variables, each in a ring Singular holds and in one it does not, the latter without the orders under Singular's names, which Sage 10.10 cannot compare monomials in there. It checks the keywords, that every input grobx does not compute raises its error, and that a deadline and a Ctrl-C stop grobx on cyclic-9. It checks that the cofactors of groebner give its basis. It also runs grobx's python/sage/test_sage.py, which compares grobx.groebner_sage with grobx.groebner on the same instance as text, for both kinds of ring, over primes on both sides of 2^29 and up to 2^64 − 59, in rings of every kind of term order and on a fraction marked as not reduced, and checks its cofactors and its errors.

The wheels and the test reach the container as a tar on standard input. The container's user sage cannot read a bind mount of a home directory that is closed to others.

Metadata

Release files for grobx-sage 0.202.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grobx-sage 0.202.1
File Size Uploaded Provenance Actions
grobx_sage-0.202.1.tar.gz 22.7 kB Without provenance Details for grobx_sage-0.202.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grobx-sage 0.202.1
File Interpreter ABI Platform Actions
grobx_sage-0.202.1-py3-none-any.whl Python 3 none any Details for grobx_sage-0.202.1-py3-none-any.whl

Total release size: 42.0 kB

Release files / grobx_sage-0.202.1.tar.gz

Download URL grobx_sage-0.202.1.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2cd433182f99329f767b5e2041f2b0e6c0656a50ba0a92f551bb30994722ddaa
BLAKE2b-256 checksum
How to use checksums
f767b6c09052a991411c1dc5351e76a8a4735bfec8d4e5a749b0c7f795d814c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / grobx_sage-0.202.1-py3-none-any.whl

Download URL grobx_sage-0.202.1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2f00696caca7b1578d1b05879fd3ed2d6616faa5bf927cfee51a20ed6cb5f63
BLAKE2b-256 checksum
How to use checksums
c4f55400c21d25f0e6a2e3020b8e4683f36b45ab1194b1ef9855c4dbfa46522f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for grobx-sage 0.202.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page