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

Improve viewing of empty semigroups #3052

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/magma.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,15 @@ InstallMethod( AsSubmagma,
end );


#############################################################################
##
#M IsEmpty( <M> ) . . . . . . . . . . . . . . test whether a magma is empty
##
InstallMethod(IsEmpty, "for a magma with generators of magma",
[IsMagma and HasGeneratorsOfMagma],
M -> IsEmpty(GeneratorsOfMagma(M)));


#############################################################################
##
#E
Expand Down
15 changes: 9 additions & 6 deletions lib/semigrp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function(S)

str := "\><";

if HasIsTrivial(S) and IsTrivial(S) then
if IsEmpty(S) then
Append(str, "\>empty\< ");
elif HasIsTrivial(S) and IsTrivial(S) then
Append(str, "\>trivial\< ");
else
if HasIsFinite(S) and not IsFinite(S) then
Expand All @@ -49,7 +51,7 @@ function(S)
fi;
fi;

if not IsGroup(S) then
if not IsGroup(S) and not IsEmpty(S) then
if HasIsTrivial(S) and IsTrivial(S) then
# do nothing
elif HasIsZeroSimpleSemigroup(S) and IsZeroSimpleSemigroup(S) then
Expand All @@ -72,7 +74,10 @@ function(S)

Append(str, SemigroupViewStringPrefix(S));

if HasIsMonoid(S) and IsMonoid(S) then
if IsEmpty(S) then
Append(str, "\>semigroup\<>\<");
return str;
elif HasIsMonoid(S) and IsMonoid(S) then
Append(str, "\>monoid\< ");
if HasGeneratorsOfInverseMonoid(S) then
nrgens := Length(GeneratorsOfInverseMonoid(S));
Expand Down Expand Up @@ -108,9 +113,7 @@ function(S)
if nrgens > 1 or nrgens = 0 then
Append(str, "s");
fi;
Append(str, "\<");

Append(str, ">\<");
Append(str, "\<>\<");

return str;
end);
Expand Down
2 changes: 1 addition & 1 deletion tst/testbugfix/2012-11-21-t00263.tst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ true
gap> Size(t);
infinity
gap> t := Subsemigroup(s, []);
<semigroup of size 0, with 0 generators>
<empty semigroup>
gap> HasSize(t);
true
gap> Size(t);
Expand Down
2 changes: 1 addition & 1 deletion tst/testbugfix/2018-05-09-submagma.tst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ false

#
gap> sub:=Submagma(mgm,[]);
<commutative semigroup with 0 generators>
<empty semigroup>
gap> Size(sub);
0
gap> IsTrivial(sub);
Expand Down
10 changes: 9 additions & 1 deletion tst/testinstall/semigrp.tst
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ gap> GeneratorsOfInverseMonoid(S);
gap> S := FreeSemigroup(2);
<free semigroup on the generators [ s1, s2 ]>
gap> T := Subsemigroup(S, []);
<semigroup of size 0, with 0 generators>
<empty semigroup>
gap> IsTrivial(T);
false
gap> IsEmpty(T);
Expand Down Expand Up @@ -501,6 +501,14 @@ Rank 2: [H size = 1, 1 L-class, 1 R-class]
Rank 2: [H size = 1, 1 L-class, 1 R-class]
Rank 1: *[H size = 1, 1 L-class, 1 R-class]

# test printing an empty semigroup
gap> S := FullTransformationMonoid(1);;
gap> Subsemigroup(S, []);
<empty transformation semigroup>
gap> S := SymmetricInverseMonoid(1);;
gap> Subsemigroup(S, []);
<empty partial perm semigroup>

#
gap> STOP_TEST( "semigrp.tst", 1);

Expand Down