Skip to content
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

Merged

Conversation

hungaborhorvath
Copy link
Contributor

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 I put in a forced 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 (408ms vs 644ms for Socle.tst, 1884ms vs 2332ms for MinimalNormalSubgroups.tst). The reason is that CRISP is rather aggressively checks for solvability and finiteness (in fact, there is a CRISP_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.

# 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
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

@fingolfin fingolfin left a 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;

Copy link
Member

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)
Copy link
Member

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;
Copy link
Member

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... :)

Copy link
Contributor Author

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);;
Copy link
Member

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?

Copy link
Contributor Author

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.

@codecov-io
Copy link

codecov-io commented Nov 5, 2016

Current coverage is 48.88% (diff: 66.66%)

Merging #711 into master will increase coverage by 0.05%

@@             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          

Powered by Codecov. Last update becaeff...3602058

# 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);
Copy link
Member

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 );
Copy link
Member

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

Copy link
Contributor Author

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.

@fingolfin fingolfin merged commit 3602058 into gap-system:master Nov 9, 2016
fingolfin added a commit that referenced this pull request Nov 9, 2016
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.
@hungaborhorvath hungaborhorvath deleted the MinimalNormalSubgroupsFixes branch November 9, 2016 19:02
@olexandr-konovalov olexandr-konovalov added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: added PRs introducing changes that have since been mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants