Skip to content

Commit 2f8a80f

Browse files
committed
WIP make RecogniseGeneric take a RecogNode
1 parent f65f349 commit 2f8a80f

File tree

2 files changed

+56
-36
lines changed

2 files changed

+56
-36
lines changed

gap/base/recognition.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ DeclareSynonym("RecognizeGroup", RecogniseGroup);
599599
## </Description>
600600
## </ManSection>
601601
## <#/GAPDoc>
602-
DeclareGlobalFunction( "RecogniseGeneric" );
602+
# TODO: change documentation and update references from func to oper
603+
DeclareOperation( "RecogniseGeneric",
604+
[ IsRecogNode, IsObject, IsString, IsRecord, IsObject, IsBool ] );
603605
DeclareSynonym("RecognizeGeneric", RecogniseGeneric);
604606

605607
DeclareGlobalFunction( "PrintTreePos" );

gap/base/recognition.gi

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -580,15 +580,36 @@ end);
580580
InstallMethod(ViewString, "for recognition crises", [IsRecogCrisis],
581581
crisis -> "<recog crisis>");
582582

583-
InstallGlobalFunction( RecogniseGeneric,
584-
function(H, methoddb, depthString, knowledge, mandarins, isSafeForMandarins)
583+
# TODO, disable this to run test suite.
584+
InstallMethod( RecogniseGeneric,
585+
"compatibility method",
586+
[ IsGroup, IsObject, IsString, IsRecord, IsObject, IsBool ],
587+
function(H, methoddb, depthString, knowledge, mandarins, isSafeForMandarins)
588+
local ri;
589+
ri := RecogNode(
590+
H,
591+
IsIdenticalObj( methoddb, FindHomDbProjective ),
592+
knowledge
593+
);
594+
RecogniseGeneric(ri, methoddb, depthString, knowledge,
595+
mandarins, isSafeForMandarins);
596+
return ri;
597+
end);
598+
599+
# TODO: Update docs: new return value: crisis or true
600+
# TODO: Rename this into RecogniseRecogNode
601+
InstallMethod( RecogniseGeneric,
602+
"TODO",
603+
[ IsRecogNode, IsObject, IsString, IsObject, IsBool ],
604+
function(ri, methoddb, depthString, mandarins, isSafeForMandarins)
585605
# Assume all the generators have no memory!
586606
local depth, ri, allmethods, s, imageMandarins, y, counter_image, rifac,
587607
kernelGenerationSuccess, l, ll, kernelMandarins, x, z, crisis,
588608
kernelMandarinSuccess, immediateVerificationSuccess, N, riker,
589609
enlargeKernelSuccess, i, mandarinSLPs, nrNiceGensOfImageNode;
590610

591611
depth := Length(depthString);
612+
H := Grp(ri);
592613

593614
PrintTreePos("E",depthString,H);
594615
Info(InfoRecog,4,"Recognising: ",H);
@@ -607,24 +628,19 @@ InstallGlobalFunction( RecogniseGeneric,
607628
# TODO: enable passing NUM_MANDARINS as optional arg
608629
mandarins := List([1..NUM_MANDARINS_DEFAULT_VALUE], i -> PseudoRandom(H));
609630
fi;
610-
611-
# Set up the record and the group object:
612-
ri := RecogNode(
613-
H,
614-
IsIdenticalObj( methoddb, FindHomDbProjective ),
615-
knowledge
616-
);
617631
ri!.mandarins := mandarins;
618632
if isSafeForMandarins then
619633
SetFilterObj(ri, IsSafeForMandarins);
620634
fi;
635+
621636
# was here earlier: Setcalcnicegens(ri,CalcNiceGensGeneric);
637+
622638
Setmethodsforimage(ri,methoddb);
623639

624640
# Combine database of find homomorphism methods with hints
625641
allmethods := methoddb;
626-
if IsBound(knowledge.hints) then
627-
allmethods := Concatenation(allmethods, knowledge.hints);
642+
if IsBound(ri!.hints) then
643+
allmethods := Concatenation(allmethods, ri!.hints);
628644
SortBy(allmethods, a -> -a.rank);
629645
fi;
630646
# verify no rank occurs more than once
@@ -645,7 +661,7 @@ InstallGlobalFunction( RecogniseGeneric,
645661
Info(InfoRecog, 1,
646662
"RecogNode <ri> could not be recognised,",
647663
" IsReady(<ri>) is not set, recognition aborts");
648-
return ri;
664+
return true;
649665
fi;
650666

651667
# Handle the leaf case:
@@ -686,7 +702,7 @@ InstallGlobalFunction( RecogniseGeneric,
686702
if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi;
687703
# StopStoringRandEls(ri);
688704
SetFilterObj(ri,IsReady);
689-
return ri;
705+
return true;
690706
fi;
691707

692708
# The non-leaf case:
@@ -733,7 +749,7 @@ InstallGlobalFunction( RecogniseGeneric,
733749
"Kernel generation for RecogNode <ri> failed ",
734750
counter_image, " times, ",
735751
" IsReady(<ri>) is not set, recognition aborts");
736-
return ri;
752+
return true;
737753
fi;
738754

739755
if IsMatrixGroup(Image(Homom(ri))) then
@@ -745,30 +761,33 @@ InstallGlobalFunction( RecogniseGeneric,
745761
counter_image,").");
746762
fi;
747763

748-
Add(depthString,'F');
749-
rifac := RecogniseGeneric(
764+
rifac := RecogNode(
750765
Group(List(GeneratorsOfGroup(H), x->ImageElm(Homom(ri),x))),
751-
methodsforimage(ri), depthString,
752-
InitialDataForImageRecogNode(ri),
766+
methodsforimage(ri),
767+
InitialDataForImageRecogNode(ri));
768+
SetImageRecogNode(ri,rifac);
769+
SetParentRecogNode(rifac,ri);
770+
Add(depthString,'F');
771+
# TODO Change return value
772+
imageStatus := RecogniseGeneric(
773+
rifac,
774+
methodsforimage(ri),
775+
depthString,
753776
imageMandarins,
754777
IsSafeForMandarins(ri));
755778
Remove(depthString);
756779
PrintTreePos("F",depthString,H);
757-
SetImageRecogNode(ri,rifac);
758-
SetParentRecogNode(rifac,ri);
759-
if IsRecogCrisis(rifac) then
780+
if IsRecogCrisis(imageStatus) then
760781
# According to the mandarins, somewhere higher up in the recognition
761782
# tree, a kernel must have been too small.
762783
Info(InfoRecog, 2,
763784
"Backtrack to the last safe node (depth=", depth, ").");
764-
return rifac;
785+
return imageStatus;
765786
fi;
766-
# Check for IsReady after checking for a crisis, since
767-
# IsReady always returns false for a crisis.
768787
if not IsReady(rifac) then
769788
# IsReady was not set, thus abort the whole computation.
770789
if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi;
771-
return ri;
790+
return true;
772791
fi;
773792

774793
if IsMatrixGroup(H) then
@@ -786,6 +805,7 @@ InstallGlobalFunction( RecogniseGeneric,
786805

787806
# Now create the kernel generators with the stored method:
788807
# The value of kernelGenerationSuccess is either true or fail.
808+
# TODO: why doesn't this throw a crisis?
789809
kernelGenerationSuccess :=
790810
CallFuncList(findgensNmeth(ri).method,
791811
Concatenation([ri],findgensNmeth(ri).args));
@@ -863,7 +883,7 @@ InstallGlobalFunction( RecogniseGeneric,
863883
if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi;
864884
# StopStoringRandEls(ri);
865885
SetFilterObj(ri,IsReady);
866-
return ri;
886+
return true;
867887
fi;
868888

869889
Info(InfoRecog,2,"Going to the kernel (depth=",depth,").");
@@ -879,9 +899,11 @@ InstallGlobalFunction( RecogniseGeneric,
879899
# This is now in terms of the generators of H!
880900
N := Group(StripMemory(gensN(ri)));
881901

902+
riker := RecogNode(N, methoddb, InitialDataForKernelRecogNode(ri));
903+
SetKernelRecogNode(ri,riker);
904+
SetParentRecogNode(riker,ri);
882905
Add(depthString,'K');
883-
riker := RecogniseGeneric( N, methoddb, depthString,
884-
InitialDataForKernelRecogNode(ri),
906+
kernelStatus := RecogniseGeneric( N, methoddb, depthString,
885907
kernelMandarins,
886908
# TODO: extend this such that riker can also
887909
# be IsSafeForMandarins, if the responsible
@@ -890,9 +912,7 @@ InstallGlobalFunction( RecogniseGeneric,
890912
false);
891913
Remove(depthString);
892914
PrintTreePos("K",depthString,H);
893-
SetKernelRecogNode(ri,riker);
894-
SetParentRecogNode(riker,ri);
895-
if IsRecogCrisis(riker) then
915+
if IsRecogCrisis(kernelStatus) then
896916
# According to the mandarins, there was an error in the kernel
897917
# generation of the current node or higher up in the recognition
898918
# tree.
@@ -916,11 +936,9 @@ InstallGlobalFunction( RecogniseGeneric,
916936
kernelMandarinSuccess := true;
917937
Info(InfoRecog,2,"Back from kernel (depth=",depth,").");
918938

919-
# Check for IsReady after checking for a crisis, since
920-
# IsReady always returns false for a crisis.
921939
if not IsReady(riker) then
922940
# IsReady is not set, thus the whole computation aborts.
923-
return ri;
941+
return true;
924942
fi;
925943
if not immediateverification(ri) then
926944
immediateVerificationSuccess := true;
@@ -954,7 +972,7 @@ InstallGlobalFunction( RecogniseGeneric,
954972
if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi;
955973
# StopStoringRandEls(ri);
956974
SetFilterObj(ri,IsReady);
957-
return ri;
975+
return true;
958976
end);
959977

960978
InstallGlobalFunction( ValidateHomomInput,

0 commit comments

Comments
 (0)