Generalize CayleyTableByPerms so that it is more useful in rack/quandle context

This commit is contained in:
Glen Whitney 2017-10-24 16:16:27 +02:00
parent 54c503e356
commit 2521a38635
2 changed files with 28 additions and 14 deletions

View File

@ -117,7 +117,7 @@ DeclareOperation( "LoopFromFile", [ IsString, IsString ] );
## CREATING QUASIGROUPS AND LOOPS BY SECTIONS ## CREATING QUASIGROUPS AND LOOPS BY SECTIONS
## ------------------------------------------------------------------------- ## -------------------------------------------------------------------------
DeclareOperation( "CayleyTableByPerms", [ IsPermCollection ] ); DeclareGlobalFunction("CayleyTableByPerms");
DeclareOperation( "QuasigroupByLeftSection", [ IsPermCollection ] ); DeclareOperation( "QuasigroupByLeftSection", [ IsPermCollection ] );
DeclareOperation( "LoopByLeftSection", [ IsPermCollection ] ); DeclareOperation( "LoopByLeftSection", [ IsPermCollection ] );
DeclareOperation( "QuasigroupByRightSection", [ IsPermCollection ] ); DeclareOperation( "QuasigroupByRightSection", [ IsPermCollection ] );

View File

@ -438,30 +438,44 @@ end );
############################################################################# #############################################################################
## ##
#O CayleyTableByPerms( perms ) #O CayleyTableByPerms( perms, [X] )
## ##
## Given a set <perms> of n permutations of an n-element set X, returns ## Given a set <perms> of n permutations of an n-element set <X> of natural
## n by n Cayley table ct such that ct[i][j] = X[j]^perms[i]. ## numbers, returns an n by n Cayley table ct such that
## The operation is safe only if at most one permutation of <perms> is ## ct[i][j] = X[j]^perms[i].
## the identity permutation, and all other permutations of <perms> ##
## move all points of X. ## Note that the argument <X> is optional, and if omitted, the function will
## assume that at most one permutation of <perms> is the identity
## permutation, and that all other permutations of <perms>
## move all points of <X>.
InstallMethod( CayleyTableByPerms, InstallGlobalFunction( CayleyTableByPerms,
"for a list of permutations", function( perms, rest... )
[ IsPermCollection ],
function( perms )
local n, pts, max; local n, pts, max;
n := Length( perms ); n := Length( perms );
if n=1 then if n=1 then
return [ [ 1 ] ]; return [ [ 1 ] ];
fi; fi;
# one of perms[ 1 ], perms[ 2 ] must move all points # one of perms[ 1 ], perms[ 2 ] must move all points
pts := MovedPoints( perms[ 2 ] ); if Length(rest) > 0 then
if pts = [] then pts := rest[0];
else
pts := MovedPoints( perms[ 2 ] );
if pts = [] then
pts := MovedPoints( perms[ 1 ] ); pts := MovedPoints( perms[ 1 ] );
fi;
fi;
if Length(pts) <> n then
Error("perms for cayley table of size ", n, " cannot act on ",
Length(pts), " points.");
fi; fi;
max := Maximum( pts ); max := Maximum( pts );
# we permute the whole interval [1..max] and then keep only those coordinates corresponding to pts if max = n then
# Common case, we are permuting [1..n]
return List( perms, x -> ListPerm(x, n));
fi;
# Otherwise we permute the whole interval [1..max] and then keep only those coordinates corresponding to pts
return List( perms, p -> Permuted( [1..max], p^(-1) ){ pts } ); return List( perms, p -> Permuted( [1..max], p^(-1) ){ pts } );
end); end);