-
Notifications
You must be signed in to change notification settings - Fork 161
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
Rename QuaternionGroup to DicyclicGroup, Document IsDihedralGroup and IsQuaternionGroup #2729
Conversation
6337f4a
to
00008ba
Compare
Codecov Report
@@ Coverage Diff @@
## master #2729 +/- ##
==========================================
- Coverage 75.81% 75.5% -0.31%
==========================================
Files 481 481
Lines 241520 244905 +3385
==========================================
+ Hits 183104 184925 +1821
- Misses 58416 59980 +1564
|
fd3bbbd
to
739a1a4
Compare
739a1a4
to
bdea973
Compare
This is still far from perfect; we don't have |
grp/basic.gd
Outdated
## <A>n</A> in the category given by the filter <A>filt</A>. Here, <A>n</A> | ||
## is a multiple of 4. | ||
## constructs the dicyclic group of size <A>n</A> in the category given by the | ||
## filter <A>filt</A>. Here, <A>n</A> is a multiple of 4. |
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 text seems to refer to implicitly refer to DicyclicGroup
only, but is of course listed directly after QuaternionGroup
. I'd rephrase to e.g. "DicyclicGroup constucts ... " and then perhaps insert one sentence that mentions QuaternionGroup
does the same but is restricted to inputs which are powers of 2, and that is provided for backwards compatibility.
lib/grpnames.gd
Outdated
@@ -455,6 +457,7 @@ InstallTrueMethod( IsGroup, IsDihedralGroup ); | |||
#P IsQuaternionGroup( <G> ) | |||
#A QuaternionGenerators( <G> ) | |||
## | |||
## <#GAPDoc Label="IsQuaternionGroup"> | |||
## <ManSection> | |||
## <Prop Name="IsQuaternionGroup" Arg="G"/> | |||
## <Attr Name="QuaternionGenerators" Arg="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 change and the one a bit above changes four functions from undocumented to documented -- that's important for release notes, but not mentioned in the PR title or description (and hence easy to miss when creating release notes). Please mention this change in the PR title or description.
But in addition, I am a bit concerned about this: documenting QuaternionGenerators
will cause people want to use it. But AFAICT we don't provide any methods for computing this attribute -- it is only set as a side effect of IsQuaternionGroup
. Same for DihedralGenerators
.
That said, I am not actively opposed to this change, but I am wary about the seemingly carefree approach to making it (I am sure you actually did spend time thinking carefully about it, it just isn't that clear from what is visibly documented in the system).
lib/grpnames.gd
Outdated
DeclareAttribute( "GeneralisedQuaternionGenerators", IsGroup ); | ||
# Backwards compatibility | ||
DeclareSynonym( "IsQuaternionGroup", IsGeneralisedQuaternionGroup ); | ||
DeclareSynonym( "QuaternionGenerators", GeneralisedQuaternionGenerators ); |
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.
Both probably should use DeclareSynonymAttr
, so that HasFOO
works.
lib/grpnames.gi
Outdated
fi; # now Zn is normal in G and Zn = < s | s^n = 1 > | ||
|
||
# choose t in G\Zn and check dihedral structure | ||
repeat t := Random(G); until not t in Zn; | ||
if not (Order(t) = 2 and ForAll(GeneratorsOfGroup(Zn),s->t*s*t*s=s^0)) | ||
then return false; fi; | ||
then return fail; fi; | ||
|
||
# choose generator s of Zn | ||
repeat s := Random(Zn); until Order(s) = n; | ||
SetDihedralGenerators(G,[t,s]); |
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.
Remove SetDihedralGenerators
call here?
473d04b
to
3092c37
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.
Some more optional remarks
grp/basic.gd
Outdated
## <A>n</A> in the category given by the filter <A>filt</A>. Here, <A>n</A> | ||
## is a multiple of 4. | ||
## <Ref Func="DicyclicGroup"/> constructs the dicyclic group of size <A>n</A> | ||
## in the category given by the # filter <A>filt</A>. Here, <A>n</A> is a |
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.
Oops, something went wrong here rewrapping? At least there is a #
in the middle of the line.
grp/basic.gd
Outdated
## is a multiple of 4. | ||
## <Ref Func="DicyclicGroup"/> constructs the dicyclic group of size <A>n</A> | ||
## in the category given by the # filter <A>filt</A>. Here, <A>n</A> is a | ||
## multiple of 4. <Ref Func="QuaternionGroup"/> is a synonym for |
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.
Optional: Perhaps instead of "... n is a multiple of 4" this should say "... n should/must/... be a multiple of 4"?
grp/basic.gd
Outdated
elif Length(args) = 3 then | ||
res[1] := args[1]; | ||
res[2] := args[2]; | ||
res[3] := args[3]; |
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.
Optional: how about res := args;
instead?
grp/basic.gd
Outdated
size := res[2]; | ||
elif Length(args) = 2 then | ||
res[1] := args[1]; | ||
res[2] := args[2]; |
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.
Optional: how about res := args;
instead?
grp/basic.gd
Outdated
|
||
if Length(args) = 1 then | ||
res[1] := IsPcGroup; | ||
res[2] := args[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.
All of this comment is optional.
How about res := [ IsPcGroup, args[1] ];
instead?
And the three places setting size could all be removed, if instead after the fi;
in line 415, you add size := res[Length(res)]
.
With all those change,s you can also remove the initial res := []
, and the function is much more compact.
I'd be happy to implement that in a commit I push on here; but we can also just the code leave it as it is now, after all, this is now just tweaking the color of the bikeshed ;-).
grp/basic.gd
Outdated
ErrorNoReturn("usage: <size> must be a power of 2 and at least 8"); | ||
elif quaternion = "warn" then | ||
Info(InfoWarning, 1, "Warning: QuaternionGroup called with <size> ", size, | ||
" which is less than 8, or not a power of 2."); |
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.
Optional: we could be less mysterious and just tell the user explicitly what the problem is (also, I'd remove the trailing period, which is unusual in info messages):
elif quaternion = "warn" then
if not IsPrimePowerInt(size) then
Info(InfoWarning, 1, "Warning: QuaternionGroup called with <size> ", size, " which is not a power of 2");
else
Info(InfoWarning, 1, "Warning: QuaternionGroup called with <size> ", size, " which is less than 8");
fi;
## If it is, methods may set the attribute <Ref Attr="GeneralisedQuaternionGenerators" /> | ||
## to [<A>t</A>,<A>s</A>], where <A>t</A> and <A>s</A> are two elements such that <A>G</A> = | ||
## <M>\langle t, s | s^{(2^k)} = 1, t^2 = s^{(2^k-1)}, s^t = s^{-1} \rangle</M>. | ||
## <Ref Prop="IsQuaternionGroup"/> and <Ref Attr="QuaternionGenerators" /> are |
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.
Optional: perhaps start this sentence with the "The synonyms ..." ?
lib/grpnames.gi
Outdated
|
||
gens := DoComputeDihedralGenerators(G); | ||
if gens = fail then | ||
ErrorNoReturn("G is not a dihedral group"); |
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.
Optional: insert before the error: SetIsDihedralGroup(G, false);
. Or insert before the if
the following: SetIsDihedralGroup(G, gens <> fail);
(and then remove the other call to SetIsDihedralGroup
below). The same can of course be done in the quaternion case.
lib/grpnames.gi
Outdated
function(G) | ||
local gens; | ||
|
||
if not HasDihedralGenerators(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.
Options: InstallTrueMethod(IsDihedralGroup, HasDihedralGenerators);
in the .gd
file, and then remove this if
(the method can only be called if the dihedral generators are not (yet) known; though even if my claim was wrong, clearly it wouldn't be wrong to recompute them, only inefficient)
Of course the same could be done in the quaternion case.
grp/basic.gd
Outdated
local size; | ||
|
||
if Length(args) = 1 then | ||
res := [ IsPcGroup, args[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 now errors out, because the local res
is missing. Either add it back, or simply replace res
by args
(args is not used anymore later).
The other test failure seems to be due to the changed warning. Perhaps this tidbit is helpful (it's been for me, at least):
TestDirectory("tst/testinstall", rec(rewriteToFile:=true));
b96934c
to
f4605ad
Compare
This PR renames
QuaternionGroup
toDicyclicGroup
andQuaternionGroupCons
toDicyclicGroupCons
.This is because these functions/constructors allow creation of groups that are not strictly speaking (generalised) quaternion groups: Their only requirement is that the given size of the group is a multiple of four, but the common definition of a generalised quaternion group is that its size is a power of 2 greater than 8.
The polycyclic package installs a method for
QuaternionGroupCons
which should probably be changed toDicyclicGroupCons
as well, as it happily produces Dicyclic groups. I'll submit a PR for polycyclic, but have left the declaration ofQuaternionGroupCons
in here for the time being to not break code.Additionally we enable existing documentation for
IsDihedralGroup
andIsQuaternionGroup
, methods to recognise whether a given group is a dihedral group or a (generalised) quaternion group: Issue #2725 arose because one could create a group usingQuaternionGroup
for whichIsQuaternionGroup
wasfalse
.Closes #2725