Add AsXXX structure conversion commands

This commit is contained in:
Glen Whitney 2017-10-28 23:48:35 -04:00
parent 479191ce0a
commit 98f3e9159a
2 changed files with 54 additions and 0 deletions

View File

@ -101,3 +101,11 @@ InstallImmediateMethod(GeneratorsOfMagma,
2,
q -> GeneratorsOfRightQuasigroup(q)
);
## Conversions into quasigroup/rack/quandle
DeclareAttribute("AsLeftQuasigroup", IsCollection);
DeclareAttribute("AsLeftRack", IsCollection);
DeclareAttribute("AsLeftQuandle", IsCollection);
DeclareAttribute("AsRightQuasigroup", IsCollection);
DeclareAttribute("AsRightRack", IsCollection);
DeclareAttribute("AsRightQuandle", IsCollection);

View File

@ -621,3 +621,49 @@ InstallOtherMethod(DirectProductOp, "for a list and non-quasigroup magma",
# Not seeing any additional structure; did I miss anything?
return MagmaByGenerators(gens);
end);
## Coversions among the structure types
InstallMethod(AsLeftQuasigroup, "for a left quasigroup",
[IsLeftQuasigroup], IdFunc);
InstallMethod(AsLeftRack, "for a left rack",
[IsLeftRack], IdFunc);
InstallMethod(AsLeftQuandle, "for a left quandle",
[IsLeftQuandle], IdFunc);
InstallMethod(AsRightQuasigroup, "for a right quasigroup",
[IsRightQuasigroup], IdFunc);
InstallMethod(AsRightRack, "for a right rack",
[IsRightRack], IdFunc);
InstallMethod(AsRightQuandle, "for a left quandle",
[IsLeftQuandle], IdFunc);
AsAStructure@ := function(struc, D)
local T,S;
D := AsSSortedList(D);
# Check if D is closed under *
T := MultiplicationTable(D);
if ForAny(T, l -> fail in l) then
return fail;
fi;
# it is, so check if it satisfies the properties of struc
S := struc(D);
# OK, good, so we are there, just record what we know
SetAsSSortedList(S, D);
SetMultiplicationTable(S, T);
SetIsFinite(S, true);
SetSize(S, Length(D));
return S;
end;
InstallMethod(AsLeftQuasigroup, "for an arbitrary collection",
[IsCollection], D -> AsAStructure@(LeftQuasigroup, D));
InstallMethod(AsLeftRack, "for an arbitrary collection",
[IsCollection], D -> AsAStructure@(LeftRack, D));
InstallMethod(AsLeftQuasigroup, "for an arbitrary collection",
[IsCollection], D -> AsAStructure@(LeftQuandle, D));
InstallMethod(AsRightQuasigroup, "for an arbitrary collection",
[IsCollection], D -> AsAStructure@(RightQuasigroup, D));
InstallMethod(AsRightRack, "for an arbitrary collection",
[IsCollection], D -> AsAStructure@(RightRack, D));
InstallMethod(AsRightQuasigroup, "for an arbitrary collection",
[IsCollection], D -> AsAStructure@(RightQuandle, D));