-
-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cardinality of special linear group #36881
Fix cardinality of special linear group #36881
Conversation
9cb6027
to
7a28d2f
Compare
@dimpase, @jukkakohonen and @videlec can you please review this PR ? |
Have you located the reason for the infinite recursion? |
Yes, the is_finite() function is calling this cardinality function, and it seems that it is calling the order function (Considering that other classes have their own order function). I didn't find any special function that calculates the cardinality of these special linear groups. So, maybe it is not implemented yet, so it is calling the order function of some class from which it is derived, but that function is calling back this cardinality function. |
Orders of special linear groups over fields are known, you can just implement formulae. Less sure for more general cases |
I checked and found that order function is implemented only for gap-based groups and there is only one function available for other groups which is going in infinite recursion. Here below is a example of a gap-based special linear group which is working perfect. sage: F = FiniteField(3)
sage: SL(2,F).order()
24 But when it comes to other groups which are not gap-based then it is going in infinite recursion like below sage: q = 7
....: FqT.<T> = GF(q)[]
....: N = T^2+1
....: FqTN = QuotientRing(FqT, N*FqT)
....: S = SL(2,FqTN)
....: S.order()
---------------------------------------------------------------------------
RecursionError Traceback (most recent call last)
... This is happening because in below code it is first trying to make an object of LinearMatrixGroup_gap but if it fails then it is simply making an object of LinearMatrixGroup_generic and that class does not have properties of gap and because of that it is not able to calculate order/cardinality of the gorup. sage/src/sage/groups/matrix_gps/linear.py Lines 308 to 316 in 879ac37
|
Should we be able to iterate over such a group? |
There should be a special Here |
I have implemented the order function for linear matrix groups. I discovered that GAP does not support linear matrix groups over the rational field (and some other fields), which was the main cause of the error. Consequently, I attempted to address this issue in GAP, but it proved to be very non-trivial. Therefore, I implemented the function in Sage. Additionally, I have another question: Why do we use functions from GAP when we can implement all of those functions from scratch in Sage as well? In this case, we would have the flexibility to construct functions according to our needs. I understand it may take considerable time, but we can proceed step by step. The same can be applied to Magma, which was also causing some errors, as can be found in the Discussion and in issue #36841. |
In this commit, I have fixed the :trac:`36876` and :trac:`35490`. And I have also added some doc tests covering this changes.
Added more doctests.
Corrected the error of previous commit.
91ec122
to
baa3b50
Compare
I have also included a documentation change in this pr only because it is a very small change. Is it okay ? |
Documentation preview for this PR (built with commit baa3b50; changes) is ready! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
q = self.base_ring().order() | ||
ord = prod(q**n - q**i for i in range(n)) | ||
if self._special: | ||
return ord / (q-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be //
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly yes, but it doesn't look serious to me. Since this ticket is about to be merged, please open a new one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but also no, rational numbers behave weirdly, e.g. is_prime(7 / 1)
is False
. But I will open a new PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grhkm21, have you made another PR for the changes you suggested? If not then, should I create a new PR for this?
sagemathgh-37980: Fix order computation for linear groups GL(n, R) and SL(n, R) sagemath#36881 introduced some wrong results for orders of linear groups since it did not check whether the base ring is a field. We add the necessary checks as well as formulas for some further cases, namely $\mathbb{Z}$ and $\mathbb{Z}/q\mathbb{Z}.$ Finally, we add a `NotImplementedError` for the cases that are not supported. The formula for the general linear group over $\mathbb{Z}/q\mathbb{Z}$ is taken from https://math.stackexchange.com/a/2044571, and for the order of the special linear group we use the group isomorphism induced by the determinant. Fixes sagemath#37934. URL: sagemath#37980 Reported by: Sebastian A. Spindler Reviewer(s): Travis Scrimshaw
sagemathgh-37980: Fix order computation for linear groups GL(n, R) and SL(n, R) sagemath#36881 introduced some wrong results for orders of linear groups since it did not check whether the base ring is a field. We add the necessary checks as well as formulas for some further cases, namely $\mathbb{Z}$ and $\mathbb{Z}/q\mathbb{Z}.$ Finally, we add a `NotImplementedError` for the cases that are not supported. The formula for the general linear group over $\mathbb{Z}/q\mathbb{Z}$ is taken from https://math.stackexchange.com/a/2044571, and for the order of the special linear group we use the group isomorphism induced by the determinant. Fixes sagemath#37934. URL: sagemath#37980 Reported by: Sebastian A. Spindler Reviewer(s): Travis Scrimshaw
sagemathgh-37980: Fix order computation for linear groups GL(n, R) and SL(n, R) sagemath#36881 introduced some wrong results for orders of linear groups since it did not check whether the base ring is a field. We add the necessary checks as well as formulas for some further cases, namely $\mathbb{Z}$ and $\mathbb{Z}/q\mathbb{Z}.$ Finally, we add a `NotImplementedError` for the cases that are not supported. The formula for the general linear group over $\mathbb{Z}/q\mathbb{Z}$ is taken from https://math.stackexchange.com/a/2044571, and for the order of the special linear group we use the group isomorphism induced by the determinant. Fixes sagemath#37934. URL: sagemath#37980 Reported by: Sebastian A. Spindler Reviewer(s): Travis Scrimshaw
This patch fixes #36876 and fixes #35490. In this PR, I have implemented a method to fix the
answer given by cardinality function for finite special linear groups
(before it was going into infinite recursion). This also fixes the answer given by is_finite()
function for finite special linear groups.
📝 Checklist
⌛ Dependencies
None