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

Add string methods for inverse semigroups/monoids #882

Merged
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
21 changes: 19 additions & 2 deletions lib/invsgp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,21 @@ InstallMethod( PrintObj,
end );

InstallMethod( String,
"for a inverse semigroup with known generators",
"for a inverse semigroup with known generators as an inverse semigroup",
[ IsInverseSemigroup and HasGeneratorsOfInverseSemigroup ],
function( S )
return STRINGIFY( "InverseSemigroup( ",
GeneratorsOfInverseSemigroup( S ), " )" );
end );

InstallMethod( String,
"for a inverse semigroup with known generators as a semigroup",
[ IsInverseSemigroup and HasGeneratorsOfSemigroup ],
function( S )
return STRINGIFY( "Semigroup( ",
GeneratorsOfSemigroup( S ), " )" );
end );

InstallMethod( PrintString,
"for a inverse semigroup with known generators",
[ IsInverseSemigroup and HasGeneratorsOfInverseSemigroup ],
Expand Down Expand Up @@ -426,13 +434,22 @@ InstallMethod( PrintObj,
end );

InstallMethod( String,
"for a inverse monoid with known generators",
"for a inverse monoid with known generators as a monoid",
[ IsInverseMonoid and HasGeneratorsOfMonoid ],
function( S )
return STRINGIFY( "Monoid( ",
GeneratorsOfMonoid( S ), " )" );
end );

InstallMethod( String,
"for a inverse monoid with known generators as an inverse monoid",
[ IsInverseMonoid and HasGeneratorsOfInverseMonoid ],
function( S )
return STRINGIFY( "InverseMonoid( ",
GeneratorsOfInverseMonoid( S ), " )" );
end );


InstallMethod( PrintString,
"for a inverse monoid with known generators",
[ IsInverseMonoid and HasGeneratorsOfInverseMonoid ],
Expand Down
60 changes: 60 additions & 0 deletions tst/testinstall/invsgp.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#############################################################################
##
#W invsgp.tst GAP library James D. Mitchell
##
##
#Y Copyright (C) 2016
##

gap> START_TEST("invsgp.tst");

# Test String method for inverse semigroup with generators as a semigroup
gap> S := Semigroup(Transformation([1, 2, 3, 4, 5, 6, 7, 7, 7]),
> Transformation([4, 6, 3, 6, 6, 6, 7, 7, 7]),
> Transformation([4, 5, 6, 1, 6, 6, 7, 7, 7]),
> Transformation([6, 6, 3, 1, 6, 6, 7, 7, 7]),
> Transformation([4, 6, 6, 1, 2, 6, 7, 7, 7]));;
gap> IsInverseSemigroup(S);
true
gap> String(S);
"Semigroup( [ Transformation( [ 1, 2, 3, 4, 5, 6, 7, 7, 7 ] ), Transformation(\
[ 4, 6, 3, 6, 6, 6, 7, 7, 7 ] ), Transformation( [ 4, 5, 6, 1, 6, 6, 7, 7, 7 \
] ), Transformation( [ 6, 6, 3, 1, 6, 6, 7, 7, 7 ] ), Transformation( [ 4, 6, \
6, 1, 2, 6, 7, 7, 7 ] ) ] )"
gap> S = EvalString(String(S));
true

# Test String method for inverse monoid with generators as a monoid
gap> S := Monoid(Transformation([1, 2, 3, 4, 5, 6, 7, 7, 7]),
> Transformation([4, 6, 3, 6, 6, 6, 7, 7, 7]),
> Transformation([4, 5, 6, 1, 6, 6, 7, 7, 7]),
> Transformation([6, 6, 3, 1, 6, 6, 7, 7, 7]),
> Transformation([4, 6, 6, 1, 2, 6, 7, 7, 7]));;
gap> IsInverseMonoid(S);
true
gap> String(S);
"Monoid( [ Transformation( [ 1, 2, 3, 4, 5, 6, 7, 7, 7 ] ), Transformation( [ \
4, 6, 3, 6, 6, 6, 7, 7, 7 ] ), Transformation( [ 4, 5, 6, 1, 6, 6, 7, 7, 7 ] )\
, Transformation( [ 6, 6, 3, 1, 6, 6, 7, 7, 7 ] ), Transformation( [ 4, 6, 6, \
1, 2, 6, 7, 7, 7 ] ) ] )"
gap> S = EvalString(String(S));
true

# Test string method for inverse monoid with inverse monoid generators
gap> S := InverseMonoid(PartialPerm([1, 2, 3]), PartialPerm([1], [2]));;
gap> String(S);
"InverseMonoid( [ PartialPermNC( [ 1, 2, 3 ], [ 1, 2, 3 ] ), PartialPermNC( [ \
1 ], [ 2 ] ) ] )"
gap> S = EvalString(String(S));
true

# Test string method for inverse semigroup with inverse semigroup generators
gap> S := InverseSemigroup(PartialPerm([1, 2, 3]), PartialPerm([1], [2]));;
gap> String(S);
"InverseMonoid( [ PartialPermNC( [ 1, 2, 3 ], [ 1, 2, 3 ] ), PartialPermNC( [ \
1 ], [ 2 ] ) ] )"
gap> S = EvalString(String(S));
true

#
gap> STOP_TEST( "invsgp.tst", 1090000);