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
## -------------------------------------------------------------------------
DeclareOperation( "CayleyTableByPerms", [ IsPermCollection ] );
DeclareGlobalFunction("CayleyTableByPerms");
DeclareOperation( "QuasigroupByLeftSection", [ IsPermCollection ] );
DeclareOperation( "LoopByLeftSection", [ 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
## n by n Cayley table ct such that ct[i][j] = X[j]^perms[i].
## The operation is safe only if at most one permutation of <perms> is
## the identity permutation, and all other permutations of <perms>
## move all points of X.
## Given a set <perms> of n permutations of an n-element set <X> of natural
## numbers, returns an n by n Cayley table ct such that
## ct[i][j] = X[j]^perms[i].
##
## 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,
"for a list of permutations",
[ IsPermCollection ],
function( perms )
InstallGlobalFunction( CayleyTableByPerms,
function( perms, rest... )
local n, pts, max;
n := Length( perms );
if n=1 then
return [ [ 1 ] ];
fi;
# one of perms[ 1 ], perms[ 2 ] must move all points
pts := MovedPoints( perms[ 2 ] );
if pts = [] then
if Length(rest) > 0 then
pts := rest[0];
else
pts := MovedPoints( perms[ 2 ] );
if pts = [] then
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;
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 } );
end);