-
Notifications
You must be signed in to change notification settings - Fork 19
Improve RecogniseGeneric and document RecogNode #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ InstallGlobalFunction( RecogniseGroup, | |
| InstallGlobalFunction( TryFindHomMethod, | ||
| function( g, method, projective ) | ||
| local result,ri; | ||
| ri := EmptyRecognitionInfoRecord(rec(),g,projective); | ||
| ri := RecogNode(g,projective); | ||
| Unbind(g!.pseudorandomfunc); | ||
| result := method(ri,g); | ||
| if result in [TemporaryFailure, NeverApplicable] then | ||
|
|
@@ -141,11 +141,13 @@ InstallGlobalFunction( TryFindHomMethod, | |
| fi; | ||
| end ); | ||
|
|
||
| InstallGlobalFunction( EmptyRecognitionInfoRecord, | ||
| function(r,H,projective) | ||
| InstallMethod( RecogNode, | ||
| "standard method", | ||
| [ IsGroup, IsBool, IsRecord ], | ||
| function(H,projective,r) | ||
| local ri; | ||
| ri := ShallowCopy(r); | ||
| Objectify( RecognitionInfoType, ri ); | ||
| Objectify( RecogNodeType, ri ); | ||
| SetGrp(ri,H); | ||
| Setslpforelement(ri,SLPforElementGeneric); | ||
| SetgensN(ri,[]); # this will grow over time | ||
|
|
@@ -212,6 +214,20 @@ InstallGlobalFunction( EmptyRecognitionInfoRecord, | |
| return ri; | ||
| end ); | ||
|
|
||
| InstallOtherMethod( RecogNode, | ||
| "for a group", | ||
| [ IsGroup ], | ||
| function(H) | ||
| return RecogNode(H, false, rec()); | ||
| end ); | ||
|
|
||
| InstallOtherMethod( RecogNode, | ||
| "for a group and a boolean", | ||
| [ IsGroup, IsBool ], | ||
| function(H, projective) | ||
| return RecogNode(H, projective, rec()); | ||
| end ); | ||
|
|
||
| # Sets the stamp used by RandomElm, RandomElmOrd, and related functions. | ||
| RECOG.SetPseudoRandomStamp := function(g,st) | ||
| if IsBound(g!.pseudorandomfunc) then | ||
|
|
@@ -229,9 +245,9 @@ end; | |
| # if called with stamp := "B". | ||
| # | ||
| # The components of the recog record involved are explained in | ||
| # EmptyRecognitionInfoRecord. | ||
| # RecogNode. | ||
| # | ||
| # HACK: For recog records created by EmptyRecognitionInfoRecord the method | ||
| # HACK: For recog records created by RecogNode the method | ||
| # RandomElm is by default stored in the component ri!.Grp!.pseudorandomfunc. | ||
| # A method for PseudoRandom is installed such that it calls | ||
| # RandomElm(ri, "PseudoRandom", false). | ||
|
|
@@ -452,35 +468,38 @@ InstallGlobalFunction( RecogniseGeneric, | |
| fi; | ||
|
|
||
| # Set up the record and the group object: | ||
| if IsIdenticalObj( methoddb, FindHomDbProjective ) then | ||
| ri := EmptyRecognitionInfoRecord(knowledge,H,true); | ||
| else | ||
| ri := EmptyRecognitionInfoRecord(knowledge,H,false); | ||
| fi; | ||
| ri := RecogNode( | ||
| H, | ||
| IsIdenticalObj( methoddb, FindHomDbProjective ), | ||
| knowledge | ||
| ); | ||
| # was here earlier: Setcalcnicegens(ri,CalcNiceGensGeneric); | ||
| Setmethodsforimage(ri,methoddb); | ||
|
|
||
| # Find a possible homomorphism (or recognise this group as leaf) | ||
| # Combine database of find homomorphism methods with hints | ||
| allmethods := methoddb; | ||
| if IsBound(knowledge.hints) then | ||
| allmethods := Concatenation(allmethods, knowledge.hints); | ||
| SortBy(allmethods, a -> -a.rank); | ||
| fi; | ||
|
|
||
| # verify no rank occurs more than once | ||
| Assert(0, Length(Set(allmethods, m->m.rank)) = Length(allmethods)); | ||
|
|
||
| # Find a possible homomorphism (or recognise this group as leaf) | ||
| Setfhmethsel(ri, CallMethods( allmethods, 10, ri, H )); | ||
| # TODO: extract the value 10 into a named constant, and / or make it | ||
| # an option parameter to the func | ||
|
|
||
| # Reset the pseudo random stamp: | ||
| RECOG.SetPseudoRandomStamp(Grp(ri),"PseudoRandom"); | ||
|
|
||
| # Handle the unfinished case: | ||
| if fhmethsel(ri).result = TemporaryFailure then | ||
| # FIXME: shouldn't we print an error here? at least if the user called us... | ||
| # Perhaps yes: this is an ri which does NOT have IsReady set, and may be useful for debugging... | ||
| SetFilterObj(ri,IsLeaf); | ||
| if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi; | ||
| Info(InfoRecog, 1, | ||
| "RecogNode <ri> could not be recognised,", | ||
| " IsReady(<ri>) is not set, recognition aborts"); | ||
| return ri; | ||
| fi; | ||
|
|
||
|
|
@@ -504,10 +523,9 @@ InstallGlobalFunction( RecogniseGeneric, | |
| SetNiceGens(ri,GeneratorsOfGroup(H)); | ||
| fi; | ||
| fi; | ||
| # these two were set correctly by FindHomomorphism | ||
| if IsLeaf(ri) then SetFilterObj(ri,IsReady); fi; | ||
| if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi; | ||
| # StopStoringRandEls(ri); | ||
| SetFilterObj(ri,IsReady); | ||
| return ri; | ||
| fi; | ||
|
|
||
|
|
@@ -519,8 +537,10 @@ InstallGlobalFunction( RecogniseGeneric, | |
| repeat | ||
| counter := counter + 1; | ||
| if counter > 10 then | ||
| Info(InfoRecog,1,"Giving up desperately..."); | ||
| if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi; | ||
| Info(InfoRecog, 1, | ||
| "ImageRecogNode of RecogNode <ri> could not be recognised,", | ||
| " IsReady(<ri>) is not set, recognition aborts"); | ||
| return ri; | ||
| fi; | ||
|
|
||
|
|
@@ -540,7 +560,7 @@ InstallGlobalFunction( RecogniseGeneric, | |
| Add(depthString,'F'); | ||
| rifac := RecogniseGeneric( | ||
| Group(List(GeneratorsOfGroup(H), x->ImageElm(Homom(ri),x))), | ||
| methodsforimage(ri), depthString, InitialDataForImageRecogNode(ri) ); # TODO: change InitialDataForImageRecogNode to hintsForFactor??) | ||
| methodsforimage(ri), depthString, InitialDataForImageRecogNode(ri) ); | ||
| Remove(depthString); | ||
| PrintTreePos("F",depthString,H); | ||
| SetImageRecogNode(ri,rifac); | ||
|
|
@@ -555,7 +575,7 @@ InstallGlobalFunction( RecogniseGeneric, | |
| fi; | ||
|
|
||
| if not IsReady(rifac) then | ||
| # the recognition of the image failed, also give up here: | ||
| # IsReady was not set, thus abort the whole computation. | ||
| if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi; | ||
| return ri; | ||
| fi; | ||
|
|
@@ -576,8 +596,8 @@ InstallGlobalFunction( RecogniseGeneric, | |
| fi; | ||
|
|
||
| # Do a little bit of preparation for the generators of N: | ||
| l := gensN(ri); | ||
| if not IsBound(ri!.leavegensNuntouched) then | ||
| l := gensN(ri); | ||
| Sort(l,SortFunctionWithMemory); # this favours "shorter" memories! | ||
| # FIXME: For projective groups different matrices might stand | ||
| # for the same element, we might overlook this here! | ||
|
|
@@ -602,9 +622,9 @@ InstallGlobalFunction( RecogniseGeneric, | |
| SetKernelRecogNode(ri,fail); | ||
| # We have to learn from the image, what our nice generators are: | ||
| SetNiceGens(ri,pregensfac(ri)); | ||
| SetFilterObj(ri,IsReady); | ||
| if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi; | ||
| # StopStoringRandEls(ri); | ||
| SetFilterObj(ri,IsReady); | ||
| return ri; | ||
| fi; | ||
|
|
||
|
|
@@ -625,20 +645,22 @@ InstallGlobalFunction( RecogniseGeneric, | |
| SetParentRecogNode(riker,ri); | ||
| Info(InfoRecog,2,"Back from kernel (depth=",depth,")."); | ||
|
|
||
| if not IsReady(riker) then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here the same, maybe we should print something here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to print something here, since we're only "exiting". The warning message was already printed in one of the "failed cases" that is in the "unfinished case" part or in the "recognise the image" part. |
||
| # IsReady is not set, thus the whole computation aborts. | ||
| return ri; | ||
| fi; | ||
| done := true; | ||
| if IsReady(riker) and immediateverification(ri) then | ||
| if immediateverification(ri) then | ||
| Info(InfoRecog,2,"Doing immediate verification (depth=", | ||
| depth,")."); | ||
| done := ImmediateVerification(ri); | ||
| fi; | ||
| until done; | ||
|
|
||
| if IsReady(riker) then # we are only ready when the kernel is | ||
| SetNiceGens(ri,Concatenation(pregensfac(ri), NiceGens(riker))); | ||
| SetFilterObj(ri,IsReady); | ||
| fi; | ||
| SetNiceGens(ri,Concatenation(pregensfac(ri), NiceGens(riker))); | ||
| if InfoLevel(InfoRecog) = 1 and depth = 0 then Print("\n"); fi; | ||
| # StopStoringRandEls(ri); | ||
| SetFilterObj(ri,IsReady); | ||
| return ri; | ||
| end); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we print here some information that the computation is aborted?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll add such an info message to the "unfinished case".
And now that I think about it, we don't need to print anything in the "image" or "kernel" parts of RecogniseGeneric, since the warning message is printed in the "unfinished case" part already.Nvm, I was thinking about the mandarins. I'll update both warning messages.