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.

Over ℚ and over GF(p), grobx is 7× faster than Maple, msolve, or Macaulay2. 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 resident set of Sage's process, in bytes
checker "exact", or the number of random points of the cheap mode

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 reaches grobx as instance text, its variables renamed v0, v1, …, and the basis comes back as basis text (grobx's MANUAL.md, Formats). grobx reads ASCII names only, and a Sage variable may carry any Python identifier.

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. 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 raises:

  • 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.Error among them, for what grobx rejects: a prime above 2^64, or a keyword's value;
  • RuntimeError where a deadline or a memory ceiling stopped the call, and where the checker rejected the basis, with the checker's reason.

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. 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.

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.155.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.155.1
File Size Uploaded Provenance Actions
grobx_sage-0.155.1.tar.gz 21.0 kB Without provenance Details for grobx_sage-0.155.1.tar.gz

Built distribution (wheel)

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

Total release size: 39.8 kB

Release files / grobx_sage-0.155.1.tar.gz

Download URL grobx_sage-0.155.1.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0557b27113fe48ef2783ca3db88b77530739d7d24185ed29204db3833d111811
BLAKE2b-256 checksum
How to use checksums
4b8673a5357567a6792550be4cd00e94ee6a2cac0882a3f0ebd2ff9f6b6ee684
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.155.1-py3-none-any.whl

Download URL grobx_sage-0.155.1-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df54d23bdae3512f023c6f6211f56cf26bd4fb8f7d2d53a7542457478c6223fe
BLAKE2b-256 checksum
How to use checksums
52e14c511d46a136136da03b2b7690b7b24f4df046e59dcc2ccf32a5ba6e03d6
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.155.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