Skip to content

Fix TwoCohomologyGeneric when there are no conditions on the tails, leading to either an unexpected error or even a wrong output - #6477

Merged
fingolfin merged 1 commit into
masterfrom
mh/fix-twocohomologygeneric-cocycle-dim
Aug 3, 2026
Merged

Fix TwoCohomologyGeneric when there are no conditions on the tails, leading to either an unexpected error or even a wrong output#6477
fingolfin merged 1 commit into
masterfrom
mh/fix-twocohomologygeneric-cocycle-dim

Conversation

@fingolfin

Copy link
Copy Markdown
Member

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)));

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>
@fingolfin
fingolfin requested a review from hulpke August 2, 2026 14:36
@fingolfin fingolfin added kind: bug Issues describing general bugs, and PRs fixing them topic: library release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes backport-to-4.16 labels Aug 2, 2026

@hulpke hulpke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this is an oversight in a case I never tried.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.09%. Comparing base (69b8ef5) to head (902fb6b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fingolfin
fingolfin merged commit 66968a3 into master Aug 3, 2026
31 of 33 checks passed
@fingolfin
fingolfin deleted the mh/fix-twocohomologygeneric-cocycle-dim branch August 3, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-4.16 kind: bug Issues describing general bugs, and PRs fixing them release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants