Skip to content

FinitelyGeneratedMatrixGroup_gap.invariants_of_degree should return a basis of the space of invariants #35684

@mantepse

Description

@mantepse

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

- **OS**: Ubuntu 20.04
- **Sage Version**: 10.0

Steps To Reproduce

A colleague of mine discovered a bug in FinitelyGeneratedMatrixGroup_gap.invariants_of_degree, and I am not completely sure how to fix it. Here is the bug:

sage: gens = [matrix(QQ, [[-1,1],[-1,0]]), matrix(QQ, [[0,1],[1,0]])]
sage: G = MatrixGroup(gens)
sage: s = Sequence(G.invariants_of_degree(14))
sage: s.coefficient_matrix()[0].rank()
2
sage: len(s)
3

Expected Behavior

The invariants returned should be linearly independent, i.e., the rank of the matrix above should be 3.

Actual Behavior

The returned invariants are distinct, but not linearly independent.

Additional Information

Dear all, especially Ben!

A colleague of mine discovered a bug in FinitelyGeneratedMatrixGroup_gap.invariants_of_degree, and I am not completely sure how to fix it. Here is the bug:

sage: gens = [matrix(QQ, [[-1,1],[-1,0]]), matrix(QQ, [[0,1],[1,0]])]
sage: G = MatrixGroup(gens)
sage: s = Sequence(G.invariants_of_degree(14))
sage: s.coefficient_matrix()[0].rank()
2
Here is a fix, which I am not convinced of. It does a brute force check, adding invariants only if the rank increases.

This is certainly very inefficient, but also possibly wrong, because it relies on Sequence finding the correct universe.

diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
index 0b5f14014e..130d0bf4f1 100644
--- a/src/sage/groups/matrix_gps/finitely_generated.py
+++ b/src/sage/groups/matrix_gps/finitely_generated.py
@@ -1328,12 +1328,15 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
        ms = self.molien_series(prec=deg+1,chi=chi)
        if ms[deg].is_zero():
            return []
-        inv = set()
+        inv = []
        for e in IntegerVectors(deg, D):
            F = self.reynolds_operator(R.monomial(*e), chi=chi)
            if not F.is_zero():
                F = F / F.lc()
-                inv.add(F)
-                if len(inv) == ms[deg]:
+                inv.append(F)
+                rk = Sequence(inv).coefficient_matrix()[0].rank()
+                if rk == ms[deg]:
                    break
+                if rk < len(inv):
+                    inv.pop()
        return list(inv)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions