Skip to content

Fixing bugs in the exterior algebra Gröbner basis F4 algorithm implementation#41596

Merged
vbraun merged 2 commits intosagemath:developfrom
tscrim:algebras/exterior_gb_fixes
Feb 11, 2026
Merged

Fixing bugs in the exterior algebra Gröbner basis F4 algorithm implementation#41596
vbraun merged 2 commits intosagemath:developfrom
tscrim:algebras/exterior_gb_fixes

Conversation

@tscrim
Copy link
Copy Markdown
Collaborator

@tscrim tscrim commented Feb 5, 2026

This fixes serious bugs in the computation of the Gröbner basis of exterior algebra:

  • not doing all proper reductions (thanks to Michael Cuntz to pointing out);
  • wrong type of Gröbner basis (as defined by Stokes), which reduces uniquely but does not work for ideal containment;
  • modifying internal states of elements during specific reduction steps (i.e., they are not acting like immutable (hence, hashable) elements).

We rework the implementation to address these (and hopefully some optimizations).

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@tscrim
Copy link
Copy Markdown
Collaborator Author

tscrim commented Feb 5, 2026

@fchapoton Can you review this? I know this is a bit outside your usual expertise, but I'm happy to help explain stuff. This is a fairly serious bug silently returning wrong answers, so I want to get it reviewed and merged quickly.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 5, 2026

Documentation preview for this PR (built with commit 8a1fdc1; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@fchapoton
Copy link
Copy Markdown
Contributor

I can try, but maybe not in depth. You introduced a TAB in the reference file, near Stokes, I think

@fchapoton fchapoton self-assigned this Feb 5, 2026
Comment thread src/sage/algebras/exterior_algebra_groebner.pyx Outdated
Comment thread src/sage/algebras/exterior_algebra_groebner.pyx Outdated
@tscrim
Copy link
Copy Markdown
Collaborator Author

tscrim commented Feb 6, 2026

Thank you. Fixed.

@fchapoton
Copy link
Copy Markdown
Contributor

Some stupid questions:

  • what is the leading monomial ? in top degree ?
  • what is the semantic of .ls and .lsi ?
  • you are using both subsets as bitsets and some kind of canonical numbering by integers, right ?

I am afraid that I will not be able to check the math, sorry. Given that the tests pass, I am ready to give a positive review based on trust and my superficial reading. Would it be enough for you ?

@tscrim
Copy link
Copy Markdown
Collaborator Author

tscrim commented Feb 7, 2026

The leading monomial/support/coefficient is the usual term from Groebner theory, where a particular term ordering is taken (here only degrevlex, deglex, neglex are implemented). The leading support is stored in ls, with the corresponding integer being lsi in the (finite) ordering of monomials. (Both are stored for faster comparisons, look-up, and indexing.)

Honestly, I don't expect someone to fully go through the math as I had to do some for this as it doesn't appear to be in the literature in this form AFAIK. The implementation mostly uses the ideas from the classical F4 algorithm taken with making sure it expands the GB by things that remove the leading term (which doesn't happen in the classical theory). If this and the passing doctests are sufficient for you, then let's get this in as this now covers cases that were broken before.

Copy link
Copy Markdown
Contributor

@fchapoton fchapoton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, looks good enough and the tests pass locally

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 7, 2026
sagemathgh-41596: Fixing bugs in the exterior algebra Gröbner basis F4 algorithm implementation
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

This fixes serious bugs in the computation of the Gröbner basis of
exterior algebra:
- not doing all proper reductions (thanks to Michael Cuntz to pointing
out);
- wrong type of Gröbner basis (as defined by Stokes), which reduces
uniquely but does not work for ideal containment;
- modifying internal states of elements during specific reduction steps
(i.e., they are not acting like immutable (hence, hashable) elements).

We rework the implementation to address these (and hopefully some
optimizations).

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41596
Reported by: Travis Scrimshaw
Reviewer(s): Frédéric Chapoton
@tscrim
Copy link
Copy Markdown
Collaborator Author

tscrim commented Feb 9, 2026

Thank you very much.

@dimpase
Copy link
Copy Markdown
Member

dimpase commented Feb 9, 2026

I wonder in which dimensions $d$ (i.e. number of variables) one has to work to get Groebner basis approach more efficient than the brute force linear algebra (as, unlike in the polynomial rings, everything is finite-dimensional, i.e. a quotient of the dimension $2^d$ module).

@tscrim
Copy link
Copy Markdown
Collaborator Author

tscrim commented Feb 10, 2026

That's a good question. By brute-force-linear-algebra, you mean construct a basis in echelon form for the whole ideal, correct? My guess is something like $d \leq 5$. Definitely need to optimize both implementations first...

@vbraun vbraun merged commit 13d3e6b into sagemath:develop Feb 11, 2026
17 of 22 checks passed
@dimpase
Copy link
Copy Markdown
Member

dimpase commented Feb 11, 2026

That's a good question. By brute-force-linear-algebra, you mean construct a basis in echelon form for the whole ideal, correct? My guess is something like d ≤ 5 . Definitely need to optimize both implementations first...

This depends on the field you are a lot.
Over a finite field you can do $d\le 15$ - and this probably means that over the rationals you can go close to this with a multimodal algorithm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants