Skip to content

Commit

Permalink
Merge pull request #882 from james-d-mitchell/string-methods-inv-semi
Browse files Browse the repository at this point in the history
Add string methods for inverse semigroups/monoids
  • Loading branch information
markuspf authored Aug 17, 2016
2 parents 08a718f + af2ee30 commit 04a34cc
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
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);

0 comments on commit 04a34cc

Please sign in to comment.