Skip to content

Commit 15320b0

Browse files
committed
Add function RECOG.TryNonGroupElements
This function extends the previous test whether SLPforElement correctly handles non-group-elements, by generating random non-group-elements for every node of the recognition tree. It also sets RECOG.TestGroupOptions.tryNonGroupElements := true.
1 parent be59506 commit 15320b0

File tree

1 file changed

+45
-34
lines changed

1 file changed

+45
-34
lines changed

gap/base/recognition.gi

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ RECOG.TestGroupOptions := rec(
991991

992992
# if the following is set to true, then we test what happens if SLPforElement
993993
# is called with elements outside the group
994-
tryNonGroupElements := false
994+
tryNonGroupElements := true,
995995
);
996996

997997

@@ -1000,7 +1000,7 @@ RECOG.TestGroupOptions := rec(
10001000
# 'optionlist' is an optional list of options overriding
10011001
# RECOG.TestGroupOptions
10021002
RECOG.TestGroup := function(g,proj,size, optionlist...)
1003-
local l,r,ri,s,x,count,lvl,seedMT,seedRS,gens,supergroup, options;
1003+
local l,r,ri,s,x,count,lvl,seedMT,seedRS,gens,res, options;
10041004
count := 0;
10051005

10061006
options := ShallowCopy(RECOG.TestGroupOptions);
@@ -1076,38 +1076,11 @@ RECOG.TestGroup := function(g,proj,size, optionlist...)
10761076
fi;
10771077
until count >= options.inTests;
10781078

1079-
if IsPermGroup(g) then
1080-
supergroup := SymmetricGroup(LargestMovedPoint(g) + 2);
1081-
elif IsMatrixGroup(g) then
1082-
supergroup := GL(DimensionOfMatrixGroup(g), DefaultFieldOfMatrixGroup(g));
1083-
else
1084-
supergroup := fail;
1085-
fi;
1086-
1087-
if supergroup <> fail and options.tryNonGroupElements then
1088-
count := 0;
1089-
repeat
1090-
count := count + 1;
1091-
#Print(".\c");
1092-
x := PseudoRandom(supergroup);
1093-
s := SLPforElement(ri,x);
1094-
if s <> fail and not isequal(ri)(ResultOfStraightLineProgram(s,l),x) then
1095-
Print("ALARM: set count to -1 to skip test!\n");
1096-
Print("group := ", g, ";\n");
1097-
Print("recogsize := ", Size(ri), ";\n");
1098-
Print("proj := ", proj, ";\n");
1099-
Print("x := ", x, ";\n");
1100-
Print("s := ", s, ";\n");
1101-
if s <> fail then
1102-
Print("result := ", ResultOfStraightLineProgram(s,l), ";\n");
1103-
fi;
1104-
1105-
Error("Alarm: SLPforElement did not work on (possibly) non-group element!\n");
1106-
if count = -1 then
1107-
return fail;
1108-
fi;
1109-
fi;
1110-
until count >= options.inTests;
1079+
if options.tryNonGroupElements then
1080+
res := RECOG.TryNonGroupElements(ri, options.inTests);
1081+
if res <> true then
1082+
return res;
1083+
fi;
11111084
fi;
11121085

11131086
#Print("\n30 random elements successfully sifted!\n");
@@ -1161,6 +1134,44 @@ RECOG.testAllSubgroups := function(g, options...)
11611134
od;
11621135
end;
11631136

1137+
# Recurses over all nodes in the tree rooted in ri.
1138+
# For each non-leaf node this function generates inTests random elements, which
1139+
# probably are not in Grp(ri), and tests whether SLPforElement correctly
1140+
# handles them.
1141+
# If such a test fails, then this function returns the node and the random
1142+
# element which caused the test to fail.
1143+
# If all tests passed, then it returns true;
1144+
RECOG.TryNonGroupElements := function(ri, inTests)
1145+
local G, niceGens, parentGroup, random, slp, resultOfSLP, i, res;
1146+
if IsLeaf(ri) or ri = fail then
1147+
return true;
1148+
fi;
1149+
G := Grp(ri);
1150+
niceGens := NiceGens(ri);
1151+
if IsPermGroup(G) then
1152+
parentGroup := SymmetricGroup(MovedPoints(G));
1153+
elif IsMatrixGroup(G) then
1154+
parentGroup := GL(DimensionOfMatrixGroup(G),
1155+
DefaultFieldOfMatrixGroup(G));
1156+
else
1157+
ErrorNoReturn("Grp(ri) must be a permutation, a matrix or a",
1158+
" projective group");
1159+
fi;
1160+
for i in [1 .. inTests] do
1161+
random := PseudoRandom(parentGroup);
1162+
slp := SLPforElement(ri, random);
1163+
if slp <> fail then
1164+
resultOfSLP := ResultOfStraightLineProgram(slp, niceGens);
1165+
if not isequal(ri)(resultOfSLP, random) then
1166+
Print("TryNonGroupElements: SLPforElement did not work!\n");
1167+
return [ri, random];
1168+
fi;
1169+
fi;
1170+
od;
1171+
res := RECOG.TryNonGroupElements(RIFac(ri), inTests);
1172+
if res <> true then return res; fi;
1173+
return RECOG.TryNonGroupElements(RIKer(ri), inTests);
1174+
end;
11641175

11651176
RECOG.TestRecognitionNode := function(ri,stop,recurse)
11661177
local err, grp, x, slp, y, ef, ek, i;

0 commit comments

Comments
 (0)