Skip to content

Add option to return full Groebner basis under elimination order over QQ - #374

Draft
wegank wants to merge 2 commits into
algebraic-solving:masterfrom
wegank:elim-full-basis
Draft

wegank wants to merge 2 commits into
algebraic-solving:masterfrom
wegank:elim-full-basis

Conversation

@wegank

@wegank wegank commented Oct 1, 2026

Copy link
Copy Markdown
Member

Closes #339.

Over the rationals, -e k used to return only the basis of the elimination ideal: the multi-modular lifting kept only the elements of the modular Gröbner basis free of the eliminated variables. Algorithms such as Suzuki–Sato's for comprehensive Gröbner systems need the full basis with respect to the elimination order.

This PR adds a --elim-full-basis command line option. Combined with -e k, it returns the full reduced Gröbner basis for the elimination order over QQ. Without the flag, behaviour is unchanged.

./msolve -e 1 --elim-full-basis -g 2 -f input_files/elim-qq.ms

returns the same 7 polynomials as the characteristic-p run in the tutorial, ending with t*z-1.

Changes

  • Lifting (src/msolve/lifting-gb.c, src/msolve/duplicate.c): two helpers, lift_elim_ideal_only and lifted_nvars, decide which elements are lifted and how many variables the stored leading monomials have. They are used in the learning phase, the application phase (filtering and bad-prime staircase check), the lifting setup and the buffer duplication. A new elim_full_basis field in md_t enables the full-basis mode.
  • CLI and output (src/msolve/main.c, src/msolve/msolve-data.h): new long-only option with help text. With the flag, no variables are dropped from the output (gens->elim = 0), and the header prints the elimination monomial order like the characteristic-p output.
  • Robustness: in the application phase, bs == NULL is now checked before bs is dereferenced. A prime whose basis has fewer elements than expected is rejected before its element lengths are read.
  • Docs: tutorial (the passage quoted in [Feature request] Full basis under elimination order in characteristic 0 #339, plus an example) and README.md.
  • Test: test/diff/diff_elim-full-qq.sh runs a parametric system with rational coefficients with -e 1/2, -t 1/2 and -l 2/44.

The Julia/library entry point export_groebner_qq is untouched so its ABI stays stable. Exposing the option there can be done in a follow-up.

Testing

  • make check: 69/69 pass.
  • Compared against Singular (via Sage, block order dp(k),dp(n-k)) on 14 random and parametric systems, with coefficients up to 544 bits, for all four -t/-l combinations. All results agree, up to normalisation, since msolve prints with denominators cleared. The default mode still returns exactly the elimination-ideal part.

AI disclosure

This change was written with the assistance of generative AI (Claude Code, Claude Opus 5.5), reviewed and tested by me.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

🤖 Generated with Claude Code

Over the rationals, msolve only lifted the elements of the modular
Groebner basis which do not involve the eliminated variables, hence it
returned the basis of the elimination ideal only. Some algorithms, e.g.
Suzuki-Sato's algorithm for comprehensive Groebner systems, need the
full Groebner basis w.r.t. the elimination order.

The new --elim-full-basis command line option, combined with -e, makes
the multi-modular lifting keep all elements of the basis (and all
variables in their leading monomials) in the learning and application
phases, and outputs the full basis together with the elimination
monomial order in the header. The default behaviour is unchanged.

While at it, the application phase now checks that the basis is not
NULL before dereferencing it, and rejects primes for which the basis
has fewer elements than expected before reading their lengths.

Closes algebraic-solving#339.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wegank
wegank marked this pull request as draft October 1, 2026 20:23
The test script and its input and expected output files have to be
listed in AC_CONFIG_LINKS so that they are shipped in the distribution
tarball and linked into the build tree, otherwise make distcheck fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Full basis under elimination order in characteristic 0

1 participant