The Symmetric Group
The symmetric group of permutations of 5 elements (order = 120)
>
S5(set):=permute(5);
S5(ident):=[1,2,3,4,5];
S5(mult):=proc(a,b) local i;
[seq(a[b[i]],i=1..5)];
end;
S5(inverse):=proc(a) local i,out;
out:=[seq(i,i=1..5)]:
for i from 1 to 5 do
out[a[i]]:=i;
od;
out;
end;
If S5 is not closed then it will print a pair of elements for which g1 * g2 is not
in the group. If S5 is closed then it will print "all done!" and nothing else.
>
for g1 in S5(set) do
for g2 in S5(set) do
if not member(S5(mult)(g1,g2),S5(set)) then
print(g1,g2,S5(mult)(g1,g2));
fi;
od;
od;
print("all done!");
> S5(mult)([2,1,4,3,5],[5,2,3,1,4]);
>
The symmetric group of order n!