grobx
grobx computes reduced Gröbner bases of polynomial ideals over prime fields GF(p), p a prime below 2^64, and over the rationals ℚ. This is its Python module. It takes the ideal's generators as text and returns the basis as text, takes and returns python-flint's polynomials, or takes Sage's polynomials and returns the basis as text.
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.
The package is a wheel for CPython 3.12 and later on Linux on x86-64 and aarch64, on Windows on x86-64, and on macOS on Apple Silicon and Intel.
Install
pip install grobx
Example
import grobx
r = grobx.groebner("x,y\n7\nx^2+y,\nx*y-1\n")
r.basis # '[y^2+x,\nx*y+6,\nx^2+y]:\n'
The input is msolve's format: the variables on line 1, separated by commas, the largest first; the characteristic on line 2, a prime below 2^64 for GF(p) or 0 for ℚ; then the generators, separated by commas. Over ℚ:
r = grobx.groebner("x,y,z\n0\nx+y+z,\nx*y+y*z+z*x,\nx*y*z-1\n")
print(r.basis)
# [x+y+z,
# y^2+y*z+z^2,
# z^3-1]:
The call
grobx.groebner(input, *, order=None, threads=0, seed=None, deadline=None, cancel=None,
memory=None, checker=None, cofactors=False, exact_reduction=False, report=False)
input is the instance text, or python-flint's polynomials (python-flint below).
| Keyword | Meaning |
|---|---|
order |
None for the input's order, grevlex for a text; or "grevlex", "deglex", "lex", or "block:k1,…,km": grevlex blocks of k1, …, km variables and a last block of the rest |
threads |
How many threads the call may use, 0 for all the machine has |
seed |
The one source of every random choice, 0 to 2^64 − 1; None draws one |
deadline |
A time limit on the whole call, in milliseconds |
cancel |
A grobx.Cancel that another thread raises by set() to stop the call |
memory |
A ceiling on the memory grobx allocates, in bytes |
checker |
Has the checker rule on the result: an error bound in [0, 1), 0 for exact |
cofactors |
Whether the result carries the cofactor matrix |
exact_reduction |
Whether every row is reduced on its own, none ruled zero by random draws; slower on some systems over GF(p) |
report |
Whether the result carries the call report |
The call releases the GIL while it computes. A Ctrl-C stops it: the call raises its cancel flag,
waits for grobx to stop, and raises KeyboardInterrupt. This holds for every call of the module.
It returns a grobx.Result, which always holds a basis, one the checker accepted where the call
asked for it:
| Attribute | Meaning |
|---|---|
basis |
The basis: its text for a text, a list of polynomials for python-flint's |
cofactors |
The cofactor text, or for python-flint's a list per element of a polynomial per generator, where the call asked for them |
report |
The call report, where the call asked for it |
sink_error |
The first error a write to report_file met, else None |
seed |
The seed the call ran under |
What grobx refuses or fails at raises a grobx.Error:
| Exception | When | Attributes |
|---|---|---|
grobx.Invalid |
An instance or a keyword's value the call cannot take; also a ValueError |
|
grobx.Stopped |
A bound stopped the call | stopped: "deadline", "cancel", or "memory"; seed; report; sink_error |
grobx.Rejected |
The checker rejected the basis, which the call does not return | flaw, seed, report, sink_error |
grobx.Error |
Any other failure, such as the lift over ℚ dropping its records |
The instance and the seed give a rejected basis again, by the same call without the checker. A
keyword's value of a type the call does not take raises TypeError, an integer out of its type's
range OverflowError, and a report_file that cannot be created OSError.
python-flint
import flint
import grobx
ctx = flint.nmod_mpoly_ctx.get(names=("x", "y"), ordering="degrevlex", modulus=7)
x, y = ctx.gens()
grobx.groebner([x**2 + y, x*y - 1]).basis
# [y^2 + x, x*y + 6, x^2 + y]
grobx.groebner takes the generators as python-flint's nmod_mpoly, of a prime modulus below
2^64, or fmpq_mpoly, all of one context, and its basis is the reduced Gröbner basis as a list
of monic polynomials of that context, in increasing order of their leading monomials; the zero
ideal's basis is []. The context's ordering is the call's order, and an order given must be it.
The polynomials reach grobx as FLINT's own structs, with no text between: grobx reads their terms
and writes the basis's through the functions of the libflint python-flint loaded. grobx does not
depend on python-flint, and needs it only where it is given its polynomials. The checker rules on
them as on their text. With cofactors=True, cofactors[i][j] is the cofactor of generator j
in element i, a polynomial of the context: basis[i] == sum(cofactors[i][j] * polys[j] for j),
the generators as given.
| Ordering of the context | grobx's order |
|---|---|
degrevlex |
grevlex |
deglex |
deglex |
lex |
lex |
The call raises TypeError for no polynomial, a type it does not take, or polynomials of two types
or contexts; grobx.Invalid for what grobx refuses, such as a modulus that is no prime, a degree
past 2^31 − 1, or an order that is not the context's; grobx.Stopped where a bound stopped the
call; and grobx.Error where python-flint's objects match no layout. The zero ideal is given as
[ctx.from_dict({})].
python-flint does not say where an object keeps its FLINT struct. The first call that meets
python-flint loaded finds it for each type: of the offsets inside the object, the one at which
FLINT's functions read a probe context and probe polynomials as python-flint reads them. It then
checks the offsets by a basis it computes and writes, against the basis known. A python-flint whose
objects match no offset leaves the call raising grobx.Error at every call, with what failed; it
never reads through an offset it has not checked. On Linux and macOS, grobx finds libflint through
python-flint's own extension module; on Windows it opens the one flint*.dll beside python-flint,
as its wheel or conda installs it.
Sage
import grobx
R.<x,y> = PolynomialRing(GF(7))
grobx.groebner_sage([x^2 + y, x*y - 1]).basis
# [{(0, 2): 1, (1, 0): 1}, {(1, 1): 1, (0, 0): 6}, {(2, 0): 1, (0, 1): 1}]
grobx.groebner_sage(polys, *, order="grevlex", threads=0, seed=None, deadline=None, cancel=None, memory=None, checker=None, cofactors=False, exact_reduction=False, report=False, report_file=None)
takes the generators as Sage's
polynomials of one ring over ℚ or GF(p), p a prime below 2^64, and returns a grobx.SageResult.
Its basis holds the elements of the basis text, in its order, each a dict from a term's tuple of
exponents, one per generator of the ring, to its coefficient: a residue over GF(p), and over ℚ an
int, the element's coefficients with no common factor and the leading one positive. order
is grobx's order, as grobx.groebner takes it: the call does not read the ring's term order. The
other keywords are those of grobx.groebner. Where grobx.groebner raises
grobx.Stopped or grobx.Rejected, this call returns, and the result's fields say so:
| Attribute | Meaning |
|---|---|
basis |
The list of the elements' dicts; None where a bound stopped the call or the checker rejected the basis |
stopped |
The bound that stopped the call, "deadline", "cancel", or "memory"; else None |
certified |
The checker's verdict; None where it did not rule |
flaw |
Why the checker rejected the result |
cofactors |
A list per element of a dict per generator, as basis holds an element, over ℚ each coefficient a fractions.Fraction; None where the call did not ask for them or the result holds no basis |
report, sink_error, seed |
As grobx.Result's |
The polynomials reach grobx as Sage holds them, with no text between, and the checker rules on them
as read: Sage's MPolynomial_libsingular, whose terms grobx reads from Singular's polynomial in
place, and its MPolynomial_polydict, of a ring Singular does not hold, such as one of
implementation="generic", whose terms grobx reads from the dict Sage keeps them in. grobx does not
depend on Sage; the call is there in every install and
needs Sage only where it is given its polynomials. The PyPI package grobx-sage calls it and
returns Sage's own basis.
The call raises TypeError for no polynomial, a type it does not take, polynomials of two rings, or
a ring over another field than ℚ or GF(p); grobx.Invalid for what grobx refuses, such as a prime
past 2^64, or a term of an MPolynomial_polydict that is none of its ring: Sage takes a key of any
length and a negative exponent into its dict, so grobx checks each term's count of exponents, their
signs, and that its coefficient is an element of the base ring. It raises RuntimeError where
Sage's objects or Singular's polynomials match no layout grobx reads.
Sage does not say where its objects keep their pointers to Singular's polynomial and ring. The first
call that meets Sage's libsingular loaded finds them by the values of the objects' words alone,
before it reads
through any, and checks them by a basis it computes, against the basis known. Singular's own structs
are read at the offsets of Singular 4.4.1 as Sage 10.10 builds it. Each call checks them on its
ring before it reads a term: Singular's count of the ring's variables, the read of every exponent
of monomials of the ring, against Sage's exponents and against Singular's own pGetExp_Var, and
how Singular holds the ring's coefficients: over GF(p) as residues below 2^29 and as GMP integers
above, over ℚ by constants that Singular holds in each of its forms, an integer in the word itself,
one larger in a GMP integer, and a fraction of two, each read for its value and its form. The first
call's bases are over two primes and over ℚ. A
Sage whose objects match no layout leaves the call raising RuntimeError, with what failed; it
never reads a basis from an offset it has not checked. The call runs on Linux and macOS, where Sage
does.
Documentation
The manual describes the formats, the bounds, the checker, and the engine. grobx.com has the benchmarks and the instance corpus, and GitHub the source.
License
GPL-3.0-only. Copyright Code1 GmbH.
Code1 GmbH also offers grobx under a commercial license.
Metadata
Release files for grobx 0.202.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| grobx-0.202.1-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details for grobx-0.202.1-cp312-abi3-win_amd64.whl |
| grobx-0.202.1-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details for grobx-0.202.1-cp312-abi3-manylinux_2_28_x86_64.whl |
| grobx-0.202.1-cp312-abi3-manylinux_2_28_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ ARM64 | Details for grobx-0.202.1-cp312-abi3-manylinux_2_28_aarch64.whl |
| grobx-0.202.1-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details for grobx-0.202.1-cp312-abi3-macosx_11_0_arm64.whl |
| grobx-0.202.1-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details for grobx-0.202.1-cp312-abi3-macosx_10_12_x86_64.whl |
Total release size: 33.5 MB
Release files / grobx-0.202.1-cp312-abi3-win_amd64.whl
| Download URL | grobx-0.202.1-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 7.7 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2451fd468e851804e36169bf1b7d16eb007918adc6ea4d42b9e4dbd33a07b7c7
|
|
BLAKE2b-256 checksum How to use checksums |
3451dd99301a0b5312826183e69a7e239cc14371f8f2add11fa47ac436ffb779
|
| 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-0.202.1-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | grobx-0.202.1-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b31f16caaf21f8609d1c4eec67aeb97119834f2089541121094f92707dd3594f
|
|
BLAKE2b-256 checksum How to use checksums |
469866778a83a7ea569465c9f5647cede7a8cc9e892c8a8ea2f9eed7b20ceca1
|
| 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-0.202.1-cp312-abi3-manylinux_2_28_aarch64.whl
| Download URL | grobx-0.202.1-cp312-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0f319709b89f073ed2c440f54a1b0837891f0b924194b0a24805fdf1e5274023
|
|
BLAKE2b-256 checksum How to use checksums |
0ea8541ecf5005234c7f987e84fcd2168436a086d9f91a1eddd39e750aac299a
|
| 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-0.202.1-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | grobx-0.202.1-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e7c99380cdc4cba511c048e45406eb7045ed3526786e6da12a5a0be1e0747552
|
|
BLAKE2b-256 checksum How to use checksums |
8e56c1dd664b8a2d1ab52dff712c5b5c0b77bd15f80bfdcc5c833b197dda5528
|
| 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-0.202.1-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | grobx-0.202.1-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
fbed83c0a44e9d427cb1ec35e725f275f4c4ef3a53c22ae6f58dd7c97b642046
|
|
BLAKE2b-256 checksum How to use checksums |
27645bd9b0a32e296a07bf8abe307a5f2c05276e5354852a07ca843de7d3d703
|
| 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 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.