-
Notifications
You must be signed in to change notification settings - Fork 160
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 rankings for Socle and MinimalNormalSubgroups #711
Fix rankings for Socle and MinimalNormalSubgroups #711
Conversation
# should have and IsSolvable check, as well, | ||
# but methods for solvable groups are only in CRISP | ||
# which aggeressively checks for solvability, anyway | ||
if IsNilpotentGroup(G) then |
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 will run into an infinite loop if for some reason this method gets selected by the method selection for a nilpotent group. One should use
not HasNilpotentGroup(G) and IsNilpotentGroup(G)
.
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.
No, because the nilpotent method is ranked higher. I first tried exiting with TryNextMethod
, but that did not work, and then I checked the manual and this is the way it is supposed to be used.
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 is assuming that the methods provided are static. One could imagine that the current method for nilpotent groups goes away at some point or for some strange reason becomes ranked lower. Then the problem would crop up. (It is not likely, but neither is the extra test hard.)
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.
Sorry, I did not see your suggestion about checking for HasIsNilpotentGroup
first. Applied it.
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.
Sorry -- the suggestion wasn't there first place and then I realized the fix might not be obvious and added it. Thanks for changing it.
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.
Looks good overall to me. Could you perhaps rebase it on master, as with your other PRs?
if (not HasIsNilpotentGroup(G) and IsNilpotentGroup(G)) then | ||
return MinimalNormalSubgroups( G ); | ||
fi; | ||
|
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.
Something is wrong with the indentation here (tabs vs spaces perhaps?)
@@ -1693,7 +1693,8 @@ InstallMethod( Socle, "for elementary abelian groups", | |||
## | |||
InstallMethod( Socle, "for nilpotent groups", | |||
[ IsGroup and IsNilpotentGroup ], | |||
SUM_FLAGS, | |||
RankFilter( IsGroup and IsFinite and IsNilpotentGroup ) | |||
- RankFilter( IsGroup and IsNilpotentGroup ), | |||
function(G) |
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.
Looks reasonable.
Of course this constitutes a rather large drop in rank for that method, so there could be some regressions. Alas, I don't think that's a reason to block this patch -- we'll just have to watch out for regressions, and should there be any, fix them.
@@ -2232,11 +2232,20 @@ InstallMethod(NormalSubgroups,"homomorphism principle perm groups",true, | |||
## | |||
#M Socle(<G>) | |||
## | |||
InstallMethod(Socle,"from normal subgroups",true,[IsGroup],0, | |||
InstallMethod(Socle,"from normal subgroups",true,[IsGroup and IsFinite],0, | |||
function(G) | |||
local n,i,s; | |||
if Size(G)=1 then return G;fi; |
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.
I know this is not part of your patch, but I wonder whether we should replace Size(G)=1
by IsTrivial(G)
here. It should never be worse, but in theory, it can handle some cases efficiently which Size(G)=1
can not. Then again, those cases are mostly cases where G is huge, and for those cases, we plan on doing more complicated stuff below anyway...
So, probably don't do anyhing, and ignore me thinking out loud... :)
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.
Ok. :-)
true | ||
gap> G := SmallGroup(24,12);; | ||
gap> IdGroup(Socle(G)); | ||
[ 4, 2 ] | ||
gap> A := DihedralGroup(16);; |
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.
Could you briefly elaborate why this particular tests were added?
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.
Hm, I do not remember exactly, but probably to increase code coverage.... Rebase and indentation should be fixed.
328269a
to
bc47381
Compare
Current coverage is 48.88% (diff: 66.66%)@@ master #711 diff @@
==========================================
Files 424 424
Lines 222089 222095 +6
Methods 3426 3426
Messages 0 0
Branches 0 0
==========================================
+ Hits 108441 108563 +122
+ Misses 113648 113532 -116
Partials 0 0
|
# but methods for solvable groups are only in CRISP | ||
# which aggeressively checks for solvability, anyway | ||
if (not HasIsNilpotentGroup(G) and IsNilpotentGroup(G)) then | ||
return Socle(G); |
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 line is not covered by the tests according to https://codecov.io/gh/gap-system/gap/pull/711/compare
# but methods for solvable groups are only in CRISP | ||
# which aggeressively checks for solvability, anyway | ||
if (not HasIsNilpotentGroup(G) and IsNilpotentGroup(G)) then | ||
return MinimalNormalSubgroups( G ); |
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 line is not covered by the tests according to https://codecov.io/gh/gap-system/gap/pull/711/compare
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.
@fingolfin Actually, these two lines will never run if CRISP is loaded, because CRISP has a redispatch for finiteness and solvability checking with a higher rank, and then the CRISP method will be chosen. Nevertheless, I added a test for Socle
and one for MinimalNormalSubgroups
, and they are supposed to trigger the codelines in question if CRISP is not loaded.
Fixed the rankings of Socle and MinimalNormalSubgroups methods for nilpotent groups. Some old methods for Socle or for MinimalNormalSubgroups were called for arbitrary groups, but they seem to only work for finite groups, and thus their filters have been changed. Further, for two methods we now force an IsNilpotent check, because for such groups the nilpotent method seems to be much more faster. Added some new tests. All tests run without packages, as well. Interestingly, they are much faster without packages. The reason is that CRISP is rather aggressively checks for solvability and finiteness (in fact, there is a `CRISP_RedispatchOnCondition` command, which seems to redispatch even if there were other applicable methods with lower ranks. And solvable methods are slower than nilpotent methods, thus the speed difference. Note that there are no explicit methods for solvable groups without CRISP, thus we never force an `IsSolvableGroup` check in the low ranked methods.
Fixed the rankings of
Socle
andMinimalNormalSubgroups
methods for nilpotent groups.Some old methods for
Socle
or forMinimalNormalSubgroups
were called for arbitrary groups, but they seem to only work for finite groups, and thus their filters have been changed. Further, for two methods I put in a forcedIsNilpotent
check, because for such groups the nilpotent method seems to be much more faster.Added some new tests. All tests run without packages, as well. Interestingly, they are much faster without packages (408ms vs 644ms for
Socle.tst
, 1884ms vs 2332ms forMinimalNormalSubgroups.tst
). The reason is that CRISP is rather aggressively checks for solvability and finiteness (in fact, there is aCRISP_RedispatchOnCondition
command, which I guess does redispatch even if there were other applicable methods with lower ranks. And solvable methods are slower than nilpotent methods, thus the speed difference.Note that there are no explicit methods for solvable groups without CRISP, thus I never forced an
IsSolvableGroup
check in the low ranked methods.