257 lines
8.3 KiB
Plaintext
257 lines
8.3 KiB
Plaintext
## structure.gi RAQ Implementation of definitiions, reps, and elt operations
|
|
|
|
## Create structures with generators
|
|
InstallGlobalFunction(CloneOfTypeByGenerators,
|
|
function(cat, fam, gens, genAttrib, tableCstr)
|
|
local M;
|
|
if not(IsEmpty(gens) or IsIdenticalObj(FamilyObj(gens), fam)) then
|
|
Error("<fam> and family of <gens> do not match");
|
|
fi;
|
|
M := Objectify(NewType( fam, cat and IsAttributeStoringRep), rec());
|
|
Setter(genAttrib)(M, AsList(gens));
|
|
SetConstructorFromTable(M, tableCstr);
|
|
return M;
|
|
end);
|
|
|
|
## Functions for each of the magma categories here
|
|
InstallGlobalFunction(LeftQuasigroup, function(arg)
|
|
local fam;
|
|
if Length(arg) = 0 then
|
|
Error("usage: LeftQuasigroup([<family>], <gens>)");
|
|
fi;
|
|
# Extract the family
|
|
if IsFamily(arg[1]) then
|
|
fam := arg[1];
|
|
Remove(arg, 1);
|
|
arg := Flat(arg);
|
|
else
|
|
arg := Flat(arg);
|
|
fam := FamilyObj(arg);
|
|
fi;
|
|
return CloneOfTypeByGenerators(IsLeftQuasigroup, fam, arg,
|
|
GeneratorsOfLeftQuasigroup,
|
|
LeftQuasigroupByMultiplicationTableNC);
|
|
end);
|
|
|
|
InstallGlobalFunction(LeftRack, function(arg)
|
|
local fam;
|
|
if Length(arg) = 0 then
|
|
Error("usage: LeftRack([<family>], <gens>)");
|
|
fi;
|
|
# Extract the family
|
|
if IsFamily(arg[1]) then
|
|
fam := arg[1];
|
|
Remove(arg, 1);
|
|
arg := Flat(arg);
|
|
else
|
|
arg := Flat(arg);
|
|
fam := FamilyObj(arg);
|
|
fi;
|
|
return CloneOfTypeByGenerators(IsLeftRack, fam, arg,
|
|
GeneratorsOfLeftQuasigroup,
|
|
LeftRackByMultiplicationTableNC);
|
|
end);
|
|
|
|
InstallGlobalFunction(LeftQuandle, function(arg)
|
|
local fam;
|
|
if Length(arg) = 0 then
|
|
Error("usage: LeftQuandle([<family>], <gens>)");
|
|
fi;
|
|
# Extract the family
|
|
if IsFamily(arg[1]) then
|
|
fam := arg[1];
|
|
Remove(arg, 1);
|
|
arg := Flat(arg);
|
|
else
|
|
arg := Flat(arg);
|
|
fam := FamilyObj(arg);
|
|
fi;
|
|
return CloneOfTypeByGenerators(IsLeftQuandle, fam, arg,
|
|
GeneratorsOfLeftQuasigroup,
|
|
LeftQuandleByMultiplicationTableNC);
|
|
end);
|
|
|
|
InstallGlobalFunction(RightQuasigroup, function(arg)
|
|
local fam;
|
|
if Length(arg) = 0 then
|
|
Error("usage: RightQuasigroup([<family>], <gens>)");
|
|
fi;
|
|
# Extract the family
|
|
if IsFamily(arg[1]) then
|
|
fam := arg[1];
|
|
Remove(arg, 1);
|
|
arg := Flat(arg);
|
|
else
|
|
arg := Flat(arg);
|
|
fam := FamilyObj(arg);
|
|
fi;
|
|
return CloneOfTypeByGenerators(IsRightQuasigroup, fam, arg,
|
|
GeneratorsOfRightQuasigroup,
|
|
RightQuasigroupByMultiplicationTableNC);
|
|
end);
|
|
|
|
InstallGlobalFunction(RightRack, function(arg)
|
|
local fam;
|
|
if Length(arg) = 0 then
|
|
Error("usage: RightRack([<family>], <gens>)");
|
|
fi;
|
|
# Extract the family
|
|
if IsFamily(arg[1]) then
|
|
fam := arg[1];
|
|
Remove(arg, 1);
|
|
arg := Flat(arg);
|
|
else
|
|
arg := Flat(arg);
|
|
fam := FamilyObj(arg);
|
|
fi;
|
|
return CloneOfTypeByGenerators(IsRightRack, fam, arg,
|
|
GeneratorsOfRightQuasigroup,
|
|
RightRackByMultiplicationTableNC);
|
|
end);
|
|
|
|
InstallGlobalFunction(RightQuandle, function(arg)
|
|
local fam;
|
|
if Length(arg) = 0 then
|
|
Error("usage: RightQuandle([<family>], <gens>)");
|
|
fi;
|
|
# Extract the family
|
|
if IsFamily(arg[1]) then
|
|
fam := arg[1];
|
|
Remove(arg, 1);
|
|
arg := Flat(arg);
|
|
else
|
|
arg := Flat(arg);
|
|
fam := FamilyObj(arg);
|
|
fi;
|
|
return CloneOfTypeByGenerators(IsRightQuandle, fam, arg,
|
|
GeneratorsOfRightQuasigroup,
|
|
RightQuandleByMultiplicationTableNC);
|
|
end);
|
|
|
|
|
|
## View and print and such
|
|
LeftObjString@ := function(Q)
|
|
# Don't test distributivity if we haven't already
|
|
if HasIsLSelfDistributive(Q) and IsLeftRack(Q) then
|
|
if HasIsElementwiseIdempotent(Q) and IsElementwiseIdempotent(Q) then
|
|
return "LeftQuandle";
|
|
fi;
|
|
return "LeftRack";
|
|
fi;
|
|
return "LeftQuasigroup";
|
|
end;
|
|
|
|
RightObjString@ := function(Q)
|
|
# Don't test distributivity if we haven't already
|
|
if HasIsRSelfDistributive(Q) and IsRightRack(Q) then
|
|
if HasIsElementwiseIdempotent(Q) and IsElementwiseIdempotent(Q) then
|
|
return "RightQuandle";
|
|
fi;
|
|
return "RightRack";
|
|
fi;
|
|
return "RightQuasigroup";
|
|
end;
|
|
|
|
InstallMethod(String, "for a left quasigroup",
|
|
[IsLeftQuasigroup],
|
|
Q -> Concatenation(LeftObjString@(Q), "(...)"));
|
|
|
|
InstallMethod(String, "for a left quasigroup with generators",
|
|
[IsLeftQuasigroup and HasGeneratorsOfLeftQuasigroup],
|
|
Q -> Concatenation(LeftObjString@(Q), "( ",
|
|
String(GeneratorsOfLeftQuasigroup(Q)), " )"));
|
|
|
|
InstallMethod(String, "for a left quasigroup with multiplication table",
|
|
[IsLeftQuasigroup and HasMultiplicationTable],
|
|
Q -> Concatenation(LeftObjString@(Q),
|
|
"ByMultiplicationTableNC( ",
|
|
String(MultiplicationTable(Q)), " )"));
|
|
|
|
InstallMethod(String, "for a right quasigroup",
|
|
[IsRightQuasigroup],
|
|
Q -> Concatenation(RightObjString@(Q), "(...)"));
|
|
|
|
InstallMethod(String, "for a right quasigroup with generators",
|
|
[IsRightQuasigroup and HasGeneratorsOfRightQuasigroup],
|
|
Q -> Concatenation(RightObjString@(Q), "( ",
|
|
String(GeneratorsOfRightQuasigroup(Q)), " )"));
|
|
|
|
InstallMethod(String, "for a right quasigroup with multiplication table",
|
|
[IsRightQuasigroup and HasMultiplicationTable],
|
|
Q -> Concatenation(RightObjString@(Q),
|
|
"ByMultiplicationTableNC( ",
|
|
String(MultiplicationTable(Q)), " )"));
|
|
|
|
InstallMethod(PrintString, "for a left quasigroup",
|
|
[IsLeftQuasigroup], Q -> String(Q));
|
|
|
|
InstallMethod(PrintString, "for a right quasigroup",
|
|
[IsRightQuasigroup], Q -> String(Q));
|
|
|
|
InstallMethod(DisplayString, "for a left quasigroup",
|
|
[IsLeftQuasigroup], Q -> String(Q));
|
|
|
|
InstallMethod(DisplayString, "for a right quasigroup",
|
|
[IsRightQuasigroup], Q -> String(Q));
|
|
|
|
InstallMethod(Display, "for a left quasigroup with multiplication table",
|
|
[IsLeftQuasigroup and HasMultiplicationTable],
|
|
function(Q)
|
|
Print(LeftObjString@(Q), " with ", Size(Q),
|
|
" elements, generated by ",
|
|
GeneratorsOfLeftQuasigroup(Q), ", with table\n");
|
|
Display(MultiplicationTable(Q));
|
|
end);
|
|
|
|
InstallMethod(Display, "for a right quasigroup with multiplication table",
|
|
[IsRightQuasigroup and HasMultiplicationTable],
|
|
function(Q)
|
|
Print(RightObjString@(Q), " with ", Size(Q),
|
|
" elements, generated by ",
|
|
GeneratorsOfRightQuasigroup(Q), ", with table\n");
|
|
Display(MultiplicationTable(Q));
|
|
end);
|
|
|
|
LeftObjView@ := function(Q)
|
|
# Don't test distributivity if we haven't already
|
|
if HasIsLSelfDistributive(Q) and IsLeftRack(Q) then
|
|
if HasIsElementwiseIdempotent(Q) and IsElementwiseIdempotent(Q) then
|
|
return "<left quandle";
|
|
fi;
|
|
return "<left rack";
|
|
fi;
|
|
return "<left quasigroup";
|
|
end;
|
|
|
|
RightObjView@ := function(Q)
|
|
# Don't test distributivity if we haven't already
|
|
if HasIsRSelfDistributive(Q) and IsRightRack(Q) then
|
|
if HasIsElementwiseIdempotent(Q) and IsElementwiseIdempotent(Q) then
|
|
return "<right quandle";
|
|
fi;
|
|
return "<right rack";
|
|
fi;
|
|
return "<right quasigroup";
|
|
end;
|
|
|
|
InstallMethod(ViewString, "for a left quasigroup",
|
|
[IsLeftQuasigroup],
|
|
Q -> Concatenation(LeftObjView@(Q), ">"));
|
|
|
|
InstallMethod(ViewString, "for a left quasigroup with generators",
|
|
[IsLeftQuasigroup and HasGeneratorsOfLeftQuasigroup],
|
|
Q -> Concatenation(LeftObjView@(Q), " with ",
|
|
String(Size(GeneratorsOfLeftQuasigroup(Q))),
|
|
" generators>"));
|
|
|
|
InstallMethod(ViewString, "for a right quasigroup",
|
|
[IsRightQuasigroup],
|
|
Q -> Concatenation(RightObjView@(Q), ">"));
|
|
|
|
InstallMethod(ViewString, "for a right quasigroup with generators",
|
|
[IsRightQuasigroup and HasGeneratorsOfRightQuasigroup],
|
|
Q -> Concatenation(RightObjView@(Q), " with ",
|
|
String(Size(GeneratorsOfRightQuasigroup(Q))),
|
|
" generators>"));
|
|
|