RAQ/gap/structure.gi

133 lines
3.6 KiB
Plaintext
Raw Normal View History

## structure.gi RAQ Implementation of definitiions, reps, and elt operations
## Create structures with generators
InstallGlobalFunction(CloneOfTypeByGenerators,
function(cat, fam, gens, genAttrib)
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));
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
2017-10-18 11:25:13 +00:00
fam := arg[1];
Remove(arg, 1);
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
else
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
fam := FamilyObj(arg[1]);
fi;
return CloneOfTypeByGenerators(IsLeftQuasigroup, fam, arg,
GeneratorsOfLeftQuasigroup);
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
2017-10-18 11:25:13 +00:00
fam := arg[1];
Remove(arg, 1);
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
else
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
fam := FamilyObj(arg[1]);
fi;
return CloneOfTypeByGenerators(IsLeftRack, fam, arg,
GeneratorsOfLeftQuasigroup);
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
2017-10-18 11:25:13 +00:00
fam := arg[1];
Remove(arg, 1);
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
else
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
fam := FamilyObj(arg[1]);
fi;
return CloneOfTypeByGenerators(IsRightQuasigroup, fam, arg,
GeneratorsOfRightQuasigroup);
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
2017-10-18 11:25:13 +00:00
fam := arg[1];
Remove(arg, 1);
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
else
2017-10-18 11:25:13 +00:00
arg := Flat(arg);
fam := FamilyObj(arg[1]);
fi;
return CloneOfTypeByGenerators(IsRightRack, fam, arg,
GeneratorsOfRightQuasigroup);
end);
## And now create them from multiplication tables
InstallGlobalFunction(LeftQuasigroupByMultiplicationTable,
function(T)
if not IsLeftQuasigroupTable(T) then
Error("Multiplication table <T> must have each row a permutation of ",
"the same entries.");
fi;
return MagmaByMultiplicationTableCreatorNC(
CanonicalCayleyTableOfLeftQuasigroupTable(T),
LeftQuasigroup,
IsLeftQuotientElement and IsMagmaByMultiplicationTableObj
);
end);
## And define the operation
InstallOtherMethod(LeftQuotient,
"for two elts in magma by mult table, when left has left quotients",
IsIdenticalObj,
[IsLeftQuotientElement, IsMagmaByMultiplicationTableObj],
function (l,r)
return DivisionTable(FamilyObj(l))[l![1],r![1]];
end);
## Create division tables as needed
InstallMethod(LeftDivisionTable,
"for a family with a multiplication table",
[IsFamily and HasMultiplicationTable],
function(fam)
local LS, n;
LS := LeftSectionList(fam);
n := Size(T);
return List(T, x->ListPerm(Inverse(x), n));
end);
## Create section lists as needed
InstallMethod(LeftSectionList,
"for a family with a multiplication table",
[IsFamily and HasMultiplicationTable],
function(fam)
return List(MultiplicationTable(fam), x->PermList(x));
end);