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

Rename QuaternionGroup to DicyclicGroup, Document IsDihedralGroup and IsQuaternionGroup #2729

Merged
merged 8 commits into from
Sep 14, 2018

Conversation

markuspf
Copy link
Member

@markuspf markuspf commented Aug 22, 2018

This PR renames QuaternionGroup to DicyclicGroup and QuaternionGroupCons to DicyclicGroupCons.

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 to DicyclicGroupCons as well, as it happily produces Dicyclic groups. I'll submit a PR for polycyclic, but have left the declaration of QuaternionGroupCons in here for the time being to not break code.

Additionally we enable existing documentation for IsDihedralGroup and IsQuaternionGroup, 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 using QuaternionGroup for which IsQuaternionGroup was false.

Closes #2725

@markuspf markuspf added kind: bug Issues describing general bugs, and PRs fixing them kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) topic: library do not comment yet PRs on which the author does not yet want any comment (e.g. only submitted for test results) release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Aug 22, 2018
@codecov
Copy link

codecov bot commented Aug 22, 2018

Codecov Report

Merging #2729 into master will decrease coverage by 0.3%.
The diff coverage is 93.05%.

@@            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
Impacted Files Coverage Δ
grp/basicfp.gi 99.07% <ø> (-0.93%) ⬇️
grp/basicpcg.gi 100% <ø> (ø) ⬆️
grp/basicprm.gi 100% <ø> (ø) ⬆️
grp/basicmat.gi 99.3% <100%> (ø) ⬆️
grp/basic.gd 97.9% <91.66%> (-2.1%) ⬇️
lib/grpnames.gi 87.24% <94.11%> (+0.04%) ⬆️
src/listoper.c 63.93% <0%> (-16.73%) ⬇️
src/compiler.c 71.44% <0%> (-15.77%) ⬇️
src/vars.c 74.48% <0%> (-12.39%) ⬇️
src/exprs.c 83.02% <0%> (-11.33%) ⬇️
... and 15 more

@markuspf markuspf force-pushed the quaternion-fix-2 branch 3 times, most recently from fd3bbbd to 739a1a4 Compare August 24, 2018 23:21
@markuspf
Copy link
Member Author

This is still far from perfect; we don't have IsDycyclicGroup yet, and the recognition is in lib/grpnames.g{d,i} and construction is in grp/; I don't know whether we want to move anything anywhere anytime soon though (and I don't want this PR to baloon into a huge project).

@markuspf markuspf removed do not comment yet PRs on which the author does not yet want any comment (e.g. only submitted for test results) do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) labels Aug 29, 2018
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.
Copy link
Member

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"/>
Copy link
Member

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

@markuspf markuspf changed the title Rename QuaternionGroup to DicyclicGroup Rename QuaternionGroup to DicyclicGroup, Document IsDihedralGroup and IsQuaternionGroup Aug 30, 2018
lib/grpnames.gd Outdated
DeclareAttribute( "GeneralisedQuaternionGenerators", IsGroup );
# Backwards compatibility
DeclareSynonym( "IsQuaternionGroup", IsGeneralisedQuaternionGroup );
DeclareSynonym( "QuaternionGenerators", GeneralisedQuaternionGenerators );
Copy link
Member

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove SetDihedralGenerators call here?

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.

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

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

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

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

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

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

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

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

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

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

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

@markuspf markuspf merged commit 16202bc into gap-system:master Sep 14, 2018
@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Aug 22, 2019
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.11.0 milestone Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Issues describing general bugs, and PRs fixing them kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: added PRs introducing changes that have since been mentioned in the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quaternion groups and Dicyclic groups, bug? confusion?
4 participants