Skip to content

Commit a6bff3e

Browse files
committed
Fix Mandarins
1 parent 22122b3 commit a6bff3e

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

gap/base/recognition.gi

+34-22
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,16 @@ InstallGlobalFunction( RecogniseGeneric,
580580
fi;
581581
fi;
582582

583-
# TODO: store the mandarins and their SLPs?
583+
# TODO: store the mandarin SLPs here. Make sure, to only write when succesful.
584584
# check mandarins now
585585
for x in mandarins do
586586
s := SLPforElement(ri, x);
587587
if s = fail then
588+
# TODO: with the master branch rewriting the gens as slps never
589+
# fails. at least we never enter a second iteration of the
590+
# "recognise image" loop.
591+
Info(InfoRecog, 2,
592+
"Enter Mandarin crisis, backtrack to the last safe node.");
588593
return MANDARIN_CRISIS;
589594
fi;
590595
od;
@@ -608,6 +613,9 @@ InstallGlobalFunction( RecogniseGeneric,
608613
# fails, then somewhere higher up in the recognition tree, a kernel must
609614
# have been too small.
610615
if ForAny(mandarins, x->not ValidateHomomInput(ri, x)) then
616+
Info(InfoRecog, 2,
617+
"ValidateHomomInput for a mandarin failed,",
618+
" backtracking to the last safe node.");
611619
return MANDARIN_CRISIS;
612620
fi;
613621
# Compute the mandarins of the factor
@@ -655,6 +663,9 @@ InstallGlobalFunction( RecogniseGeneric,
655663
factorMandarins,
656664
IsSafeForMandarins(ri));
657665
Remove(depthString);
666+
PrintTreePos("F",depthString,H);
667+
SetImageRecogNode(ri,rifac);
668+
SetParentRecogNode(rifac,ri);
658669
if not IsReady(rifac) then
659670
# IsReady was not set, thus abort the whole computation.
660671
if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi;
@@ -665,9 +676,6 @@ InstallGlobalFunction( RecogniseGeneric,
665676
# tree, a kernel must have been too small.
666677
return MANDARIN_CRISIS;
667678
fi;
668-
PrintTreePos("F",depthString,H);
669-
SetImageRecogNode(ri,rifac);
670-
SetParentRecogNode(rifac,ri);
671679

672680
if IsMatrixGroup(H) then
673681
Info(InfoRecog,2,"Back from image (depth=",depth,
@@ -723,11 +731,8 @@ InstallGlobalFunction( RecogniseGeneric,
723731
x := mandarins[i];
724732
y := factorMandarins[i];
725733
s := SLPforElement(rifac, y);
726-
# TODO: these SLPs should be stored when they are computed for the
727-
# first time.
728-
if s = fail then
729-
Error("TODO: no SLP for factor");
730-
fi;
734+
# TODO: These SLPs should be stored when they are computed for the
735+
# first time. In particular, they can't be fail.
731736
z := ResultOfStraightLineProgram(s, pregensfac(ri));
732737
if not ri!.isequal(x, z) then
733738
Add( kernelMandarins, x / z );
@@ -740,12 +745,15 @@ InstallGlobalFunction( RecogniseGeneric,
740745
RECOG_HandleSpecialCaseKernelTrivialAndMarkedForImmediateVerification(ri);
741746
fi;
742747
if IsEmpty(gensN(ri)) and not IsEmpty(kernelMandarins) then
743-
# We found out that N is the trivial group, but the mandarins disagree!
748+
Info(InfoRecog, 2, "Kernel is trivial although mandarins disagree.");
744749
# We handle this in the same way as if recognition of the
745750
# kernel returned a MANDARIN_CRISIS.
746751
if not IsSafeForMandarins(ri) then
752+
Info(InfoRecog, 2, "Backtrack to the last safe node.");
747753
return MANDARIN_CRISIS;
748754
else
755+
Info(InfoRecog, 2,
756+
"Handle the mandarin crisis at depth=", depth, ".");
749757
if not TryToEnlargeKernelGeneratingSetAndUpdateSLPsDuringMandarinCrisis(ri) then
750758
# TODO: discard and re-recognise the image.
751759
ErrorNoReturn("TODO");
@@ -784,35 +792,34 @@ InstallGlobalFunction( RecogniseGeneric,
784792
kernelMandarins,
785793
# TODO: extend this such that riker can also
786794
# be IsSafeForMandarins, if the responsible
787-
# findgensNmeth is guaranteed to feed the
795+
# findgensNmeth is guaranteed to find the
788796
# generators for the whole kernel.
789797
false);
790798
Remove(depthString);
799+
PrintTreePos("K",depthString,H);
800+
SetKernelRecogNode(ri,riker);
801+
SetParentRecogNode(riker,ri);
802+
Info(InfoRecog,2,"Back from kernel (depth=",depth,").");
791803
if riker = MANDARIN_CRISIS then
792804
# According to the mandarins, there was an error in the kernel
793805
# generation of the current node or higher up in the recognition
794806
# tree.
807+
Info(InfoRecog, 2, "Enter mandarin crisis.");
795808
if not IsSafeForMandarins(ri) then
796-
# Backtrack to the first safe node on the way to the root.
809+
Info(InfoRecog, 2, "Backtrack to the last safe node.");
797810
return MANDARIN_CRISIS;
798811
fi;
812+
Info(InfoRecog, 2,
813+
"Handle the mandarin crisis at depth=", depth, ".");
799814
# We are the first safe node on the way to the root and thus need to
800815
# handle the crisis ourselves.
801-
enlargeKernelSuccess :=
802-
TryToEnlargeKernelGeneratingSetAndUpdateSLPsDuringMandarinCrisis(ri);
803-
if not enlargeKernelSuccess then
816+
if not TryToEnlargeKernelGeneratingSetAndUpdateSLPsDuringMandarinCrisis(ri) then
804817
# TODO: discard and re-recognise the image.
805818
ErrorNoReturn("TODO");
806819
fi;
807820
# This restarts the loop, since mandarinSuccess is false.
808821
continue;
809-
else
810-
mandarinSuccess := true;
811822
fi;
812-
PrintTreePos("K",depthString,H);
813-
SetKernelRecogNode(ri,riker);
814-
SetParentRecogNode(riker,ri);
815-
Info(InfoRecog,2,"Back from kernel (depth=",depth,").");
816823

817824
if not IsReady(riker) then
818825
# IsReady is not set, thus the whole computation aborts.
@@ -830,12 +837,16 @@ InstallGlobalFunction( RecogniseGeneric,
830837
fi;
831838
fi;
832839
for x in kernelMandarins do
833-
if SLPforElement(ri, x) = fail then
840+
if SLPforElement(riker, x) = fail then
841+
Info(InfoRecog, 2, "Enter mandarin crisis.");
834842
# We handle this in the same way as if recognition of the
835843
# kernel returned a MANDARIN_CRISIS.
836844
if not IsSafeForMandarins(ri) then
845+
Info(InfoRecog, 2, "Backtrack to the last safe node.");
837846
return MANDARIN_CRISIS;
838847
fi;
848+
Info(InfoRecog, 2,
849+
"Handle the mandarin crisis at depth=", depth, ".");
839850
if not TryToEnlargeKernelGeneratingSetAndUpdateSLPsDuringMandarinCrisis(ri) then
840851
# TODO: discard and re-recognise the image.
841852
ErrorNoReturn("TODO");
@@ -844,6 +855,7 @@ InstallGlobalFunction( RecogniseGeneric,
844855
continue;
845856
fi;
846857
od;
858+
mandarinSuccess := true;
847859
until mandarinSuccess and immediateVerificationSuccess;
848860

849861
SetNiceGens(ri,Concatenation(pregensfac(ri), NiceGens(riker)));

0 commit comments

Comments
 (0)