Fix TwoCohomologyGeneric when there are no conditions on the tails, leading to either an unexpected error or even a wrong output - #6477
Merged
Conversation
If no conditions on the tails were collected, the whole space of tail
vectors consists of cocycles, and `TwoCohomologyGeneric` said so by
using an identity matrix. But it sized that matrix by the number of
rewriting rules instead of by the dimension `nvars` of the space the
cocycles actually live in.
For modules of dimension 1 the two often agree, but for higher
dimensional modules they do not, and the wrongly sized matrix either
triggered the assertion in the coboundary loop
Error, SolutionMat: matrix and vector incompatible
or, if that assertion was not reached (it sits inside a conditional),
silently produced a wrong dimension for `r.cohomology`.
An example which errors before this change:
TwoCohomologyGeneric(CyclicGroup(2),
GModuleByMats([IdentityMat(2, GF(2))], 2, GF(2)));
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hulpke
approved these changes
Aug 2, 2026
hulpke
left a comment
Contributor
There was a problem hiding this comment.
Yes, this is an oversight in a case I never tried.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6477 +/- ##
=======================================
Coverage 79.08% 79.09%
=======================================
Files 685 685
Lines 293736 293736
Branches 8664 8664
=======================================
+ Hits 232314 232321 +7
+ Misses 59621 59613 -8
- Partials 1801 1802 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If no conditions on the tails were collected, the whole space of tail vectors consists of cocycles, and
TwoCohomologyGenericsaid so by using an identity matrix. But it sized that matrix by the number of rewriting rules instead of by the dimensionnvarsof the space the cocycles actually live in.For modules of dimension 1 the two often agree, but for higher dimensional modules they do not, and the wrongly sized matrix either triggered the assertion in the coboundary loop
or, if that assertion was not reached (it sits inside a conditional), silently produced a wrong dimension for
r.cohomology.An example which errors before this change: