@@ -423,9 +423,9 @@ NUM_MANDARINS := 100;
423423InstallGlobalFunction( RecogniseGeneric,
424424 function (H, methoddb, depthString, knowledge, mandarins )
425425 # Assume all the generators have no memory!
426- local N,depth,done,i,l,ll,gensNmeth,allmethods,
426+ local oldRandstore, N,depth,done,i,l,ll,gensNmeth,allmethods,
427427 proj1,proj2,ri,rifac,riker,s,x,y,z,succ,counter,
428- kernelMandarins,factorMandarins,tmp ;
428+ kernelMandarins,factorMandarins;
429429
430430 depth := Length(depthString);
431431
@@ -439,12 +439,10 @@ InstallGlobalFunction( RecogniseGeneric,
439439
440440 if mandarins = fail then
441441 Assert (0 , depth = 0 );
442- # Use SetPseudoRandomStamp or RandomElm
443- # FIXME: double-check whether mandarins are not reused. Since
444- # PseudoRandom may use RandomElm as the pseudorandomfunc it could
445- # happen that the mandarins are reused.
446- # I think we have to undo the hack to PseudoRandom or, even worse,
447- # remove the mandarins from ri!.randr manually
442+ # HACK: We don't want the mandarins to be reused by any computation.
443+ # Since PseudoRandom is hacked, it is important that we generate the
444+ # mandarins before calling EmptyRecognitionInfoRecord. Otherwise the
445+ # mandarins would be reused by RandomElm and RandomElmOrd.
448446 mandarins := List([ 1 .. NUM_MANDARINS] , i -> PseudoRandom(H));
449447 fi ;
450448
@@ -499,17 +497,25 @@ InstallGlobalFunction( RecogniseGeneric,
499497 fi ;
500498 fi ;
501499
500+ # TODO: In magma the RecogniseGroup analogue creates the mandarins
501+ # _and_ stores their SLPs. Why does it store their SLPs? Are these
502+ # used?
502503 # check mandarins now
503- tmp := NiceGens(ri);
504504 for x in mandarins do
505+ # TODO: Do we need these SLPs later when we check the mandarins of
506+ # the parent node? If so, then store these SLPs.
505507 s := SLPforElement(ri, x);
506508 if s = fail then
507509 # TODO: should not really happen
508- Error(" Mandarins detected bad leaf" );
510+ # because we verify leaves immediately?
511+ ErrorNoReturn(" Mandarins detected bad leaf" );
509512 fi ;
510513 # TODO: validate the SLP, too?
511- z := ResultOfStraightLineProgram(s, tmp);
512- Assert (0 , ri!. isequal(x, z));
514+ z := ResultOfStraightLineProgram(s, NiceGens(ri));
515+ if not ri!. isequal(x, z) then
516+ # TODO: deal with this properly
517+ ErrorNoReturn(" Mandarins detected bad leaf" );
518+ fi ;
513519 od ;
514520
515521 # these two were set correctly by FindHomomorphism
@@ -527,17 +533,29 @@ InstallGlobalFunction( RecogniseGeneric,
527533 # In that case we know that ri now knows: homom plus additional data.
528534
529535 # map the mandarins
536+ # TODO Can we also put the ValidateHomomInput call with
537+ # GeneratorsOfGroup(H) here? If it fails we'll need to handle it exactly as
538+ # we handle a botched mandarin computation.
539+ for x in mandarins do
540+ if not ValidateHomomInput(ri, x) then
541+ # TODO: deal with this properly, see CompTree's description of what
542+ # it does in a "crisis"
543+ ErrorNoReturn(" Mandarins detected bad factor homom" );
544+ fi ;
545+ od ;
530546 factorMandarins := [] ;
531547 for x in mandarins do
548+ # TODO: magma has separate "test mandarins" and "map mandarins"
549+ # functions. Does that improve performance notably?
532550 y := ImageElm(Homom(ri), x);
533551 if y = fail then
534- # TODO: deal with this properly
535- Error (" Mandarins detected bad factor homom" );
552+ # TODO: deal with this properly, see above
553+ ErrorNoReturn (" Mandarins detected bad factor homom" );
536554 fi ;
537555 Add(factorMandarins, y);
538556 # s := SLPforElement(ri, x);
539557 od ;
540- # sort the factorMandarins and remove duplicates and trivials
558+ # TODO: sort the factorMandarins and remove duplicates and trivials
541559
542560 # Try to recognise the factor a few times, then give up:
543561 counter := 0 ;
@@ -546,6 +564,7 @@ InstallGlobalFunction( RecogniseGeneric,
546564 if counter > 10 then
547565 Info (InfoRecog,1 ," Giving up desperately..." );
548566 if InfoLevel(InfoRecog) = 1 and depth = 0 then Print(" \n " ); fi ;
567+ # FIXME For debugging Error instead.
549568 return ri;
550569 fi ;
551570
@@ -619,6 +638,12 @@ InstallGlobalFunction( RecogniseGeneric,
619638 fi ;
620639
621640 # evaluate mandarins to get kernel mandarins
641+ # TODO: something is suuper iffy about the method BlocksModScalars, which
642+ # is called by BlockDiagonal.
643+ # Apparently its input is neither to be understood as a projective nor as a
644+ # matrix group, but rather as a "all block-scalars being trivial" group.
645+ # That ofc completely wrecks the mandarins, since they assume the group to
646+ # be projective.
622647 kernelMandarins := [] ;
623648 for i in [ 1 .. Length(mandarins)] do
624649 x := mandarins[ i] ;
@@ -632,8 +657,7 @@ InstallGlobalFunction( RecogniseGeneric,
632657 Add( kernelMandarins, x / z );
633658 fi ;
634659 od ;
635- # sort the kernelMandarins and remove duplicates and trivials
636- # kernelMandarins := rifac!.kernelMandarins
660+ # TODO: sort the kernelMandarins and remove duplicates and trivials
637661
638662 if Length(gensN(ri)) = 0 then
639663 # We found out that N is the trivial group!
@@ -642,14 +666,16 @@ InstallGlobalFunction( RecogniseGeneric,
642666 if Length(kernelMandarins) <> 0 then
643667 # ooops, mandarins disagree
644668 if gensNmeth.method = FindKernelDoNothing then
669+ # TODO deal with this properly
645670 Error(" Mandarins detected bad kernel, but gensNmeth is FindKernelDoNothing" );
646671 elif IsBound (ri!. leavegensNuntouched) then
672+ # TODO deal with this properly
647673 Error(" Mandarins detected bad kernel, but leavegensNuntouched is set" );
648674 else
649675 # we need to
650676 # WARNING: do NOT add the mandarin here, even though it may seem tempting.
651677 # But (a) they don't have memory, and (b) we need them to stay "clean",
652- # if we start using them for computations, this destroys out assumption
678+ # if we start using them for computations, this destroys our assumption
653679 # about their independency
654680 succ := FindKernelFastNormalClosure(ri,5 ,5 );
655681 Info (InfoRecog,2 ," Have now " ,Length(gensN(ri)),
0 commit comments