forked from gap-system/gap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check arguments to
FreeSemigroup
more thoroughly
See gap-system#1385 It was previously possible to use `FreeSemigroup` to create a seemingly free semigroup with zero generators (rank zero), but this object believed itself to be infinite, and to contain elements (such a semigroup would be empty). Note that free semigroups of rank zero are not documented as being supported. Some other ways that one might want to create free semigroups of rank zero led to unhelpful error messages, and in general, the argument checking of `FreeSemigroup` was not very thorough and gave sometimes unhelpful error messages. In this commit, I overhaul the way that `FreeSemigroup` checks its arguments, in particular always disallowing a free semigroup of rank zero, and overall making the checking more robust, and making the error messages more descriptive. This addresses the _bugs_ reported in issue gap-system#1385, although it does not address the _feature request_ in that issue to support free semigroups of rank zero. I also took the opportunity to fix a typo in the documentation for `FreeSemigroup`, and to make a clarification. Further improvements could be made to this documentation, but I leave that to the future.
- Loading branch information
1 parent
f541fa8
commit a83c443
Showing
4 changed files
with
239 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# See https://github.com/gap-system/gap/issues/1385 | ||
gap> FreeSemigroup(); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup([]); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup(""); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup(0); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup(0, "name"); | ||
Error, free semigroups of rank zero are not supported |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#@local F | ||
gap> START_TEST("smgrpfre.tst"); | ||
|
||
# FreeSemigroup | ||
gap> FreeSemigroup(fail); | ||
Error, usage: FreeSemigroup( [<wfilt>, ]<rank>[, <name>] ) | ||
FreeSemigroup( [<wfilt>, ]<name1>[, <name2>, ...] ) | ||
FreeSemigroup( [<wfilt>, ]<names> ) | ||
FreeSemigroup( [<wfilt>, ]infinity[, <name>[, <init>]] ) | ||
|
||
# FreeSemigroup: rank 0 | ||
gap> FreeSemigroup(); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup([]); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup(""); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup(0); | ||
Error, free semigroups of rank zero are not supported | ||
gap> FreeSemigroup(0, "name"); | ||
Error, free semigroups of rank zero are not supported | ||
|
||
# FreeSemigroup(infinity[, name[, init]]) | ||
gap> FreeSemigroup(infinity); | ||
<free semigroup on the generators [ s1, s2, ... ]> | ||
gap> FreeSemigroup(infinity, fail); | ||
Error, FreeSemigroup( infinity, <name> ): <name> must be a string | ||
gap> FreeSemigroup(infinity, []); | ||
<free semigroup on the generators [ 1, 2, ... ]> | ||
gap> FreeSemigroup(infinity, ""); | ||
<free semigroup on the generators [ 1, 2, ... ]> | ||
gap> FreeSemigroup(infinity, "nicename"); | ||
<free semigroup on the generators [ nicename1, nicename2, ... ]> | ||
gap> FreeSemigroup(infinity, fail, fail); | ||
Error, FreeSemigroup( infinity, <name>, <init> ): <name> must be a string and \ | ||
<init> must be a list of nonempty strings | ||
gap> FreeSemigroup(infinity, "nicename", fail); | ||
Error, FreeSemigroup( infinity, <name>, <init> ): <init> must be a list of non\ | ||
empty strings | ||
gap> FreeSemigroup(infinity, "gen", []); | ||
<free semigroup on the generators [ gen1, gen2, ... ]> | ||
gap> FreeSemigroup(infinity, "gen", [""]); | ||
Error, FreeSemigroup( infinity, <name>, <init> ): <init> must be a list of non\ | ||
empty strings | ||
gap> FreeSemigroup(infinity, "gen", ["starter"]); | ||
<free semigroup on the generators [ starter, gen2, ... ]> | ||
gap> FreeSemigroup(infinity, "gen", ["starter", ""]); | ||
Error, FreeSemigroup( infinity, <name>, <init> ): <init> must be a list of non\ | ||
empty strings | ||
gap> F := FreeSemigroup(infinity, "gen", ["starter", "second", "third"]); | ||
<free semigroup on the generators [ starter, second, ... ]> | ||
gap> GeneratorsOfSemigroup(F){[1 .. 4]}; | ||
[ starter, second, third, gen4 ] | ||
gap> FreeSemigroup(infinity, "gen", ["starter"], fail); | ||
Error, usage: FreeSemigroup( [<wfilt>, ]<rank>[, <name>] ) | ||
FreeSemigroup( [<wfilt>, ]<name1>[, <name2>, ...] ) | ||
FreeSemigroup( [<wfilt>, ]<names> ) | ||
FreeSemigroup( [<wfilt>, ]infinity[, <name>[, <init>]] ) | ||
|
||
# FreeSemigroup(rank[, name]) | ||
gap> F := FreeSemigroup(1); | ||
<free semigroup on the generators [ s1 ]> | ||
gap> HasIsCommutative(F) and IsCommutative(F); | ||
true | ||
gap> F := FreeSemigroup(2); | ||
<free semigroup on the generators [ s1, s2 ]> | ||
gap> HasIsCommutative(F) and not IsCommutative(F); | ||
true | ||
gap> F := FreeSemigroup(10); | ||
<free semigroup on the generators [ s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 ]> | ||
gap> F := FreeSemigroup(3, fail); | ||
Error, FreeSemigroup( <rank>, <name> ): <name> must be a string | ||
gap> F := FreeSemigroup(4, ""); | ||
<free semigroup on the generators [ 1, 2, 3, 4 ]> | ||
gap> F := FreeSemigroup(5, []); | ||
<free semigroup on the generators [ 1, 2, 3, 4, 5 ]> | ||
gap> F := FreeSemigroup(4, "cheese"); | ||
<free semigroup on the generators [ cheese1, cheese2, cheese3, cheese4 ]> | ||
gap> FreeSemigroup(3, "car", fail); | ||
Error, usage: FreeSemigroup( [<wfilt>, ]<rank>[, <name>] ) | ||
FreeSemigroup( [<wfilt>, ]<name1>[, <name2>, ...] ) | ||
FreeSemigroup( [<wfilt>, ]<names> ) | ||
FreeSemigroup( [<wfilt>, ]infinity[, <name>[, <init>]] ) | ||
|
||
# FreeSemigroup( <name1>[, <name2>, ...] ) | ||
gap> FreeSemigroup("", "second"); | ||
Error, FreeSemigroup( <name1>, <name2>, ... ): the names must be nonempty stri\ | ||
ngs | ||
gap> FreeSemigroup("first", ""); | ||
Error, FreeSemigroup( <name1>, <name2>, ... ): the names must be nonempty stri\ | ||
ngs | ||
gap> FreeSemigroup("first", []); | ||
Error, FreeSemigroup( <name1>, <name2>, ... ): the names must be nonempty stri\ | ||
ngs | ||
gap> FreeSemigroup([], []); | ||
Error, FreeSemigroup( <name1>, <name2>, ... ): the names must be nonempty stri\ | ||
ngs | ||
gap> FreeSemigroup("bacon", "eggs", "beans"); | ||
<free semigroup on the generators [ bacon, eggs, beans ]> | ||
gap> FreeSemigroup("shed"); | ||
<free semigroup on the generators [ shed ]> | ||
|
||
# FreeSemigroup( [ <name1>[, <name2>, ...] ] ) | ||
gap> FreeSemigroup(["", "second"]); | ||
Error, FreeSemigroup( [ <name1>, <name2>, ... ] ): the names must be nonempty \ | ||
strings | ||
gap> FreeSemigroup(["first", ""]); | ||
Error, FreeSemigroup( [ <name1>, <name2>, ... ] ): the names must be nonempty \ | ||
strings | ||
gap> FreeSemigroup(["first", []]); | ||
Error, FreeSemigroup( [ <name1>, <name2>, ... ] ): the names must be nonempty \ | ||
strings | ||
gap> FreeSemigroup([[], []]); | ||
Error, FreeSemigroup( [ <name1>, <name2>, ... ] ): the names must be nonempty \ | ||
strings | ||
gap> FreeSemigroup(["bacon", "eggs", "beans"]); | ||
<free semigroup on the generators [ bacon, eggs, beans ]> | ||
gap> FreeSemigroup(["grid"]); | ||
<free semigroup on the generators [ grid ]> | ||
gap> FreeSemigroup(["grid"], fail); | ||
Error, usage: FreeSemigroup( [<wfilt>, ]<rank>[, <name>] ) | ||
FreeSemigroup( [<wfilt>, ]<name1>[, <name2>, ...] ) | ||
FreeSemigroup( [<wfilt>, ]<names> ) | ||
FreeSemigroup( [<wfilt>, ]infinity[, <name>[, <init>]] ) | ||
|
||
# | ||
gap> STOP_TEST( "smgrpfre.tst", 1); |