@@ -394,9 +394,9 @@ NUM_MANDARINS := 100;
394394InstallGlobalFunction( RecogniseGeneric,
395395 function (H, methoddb, depthString, knowledge, mandarins )
396396 # Assume all the generators have no memory!
397- local N,depth,done,i,l,ll,gensNmeth,allmethods,
397+ local oldRandstore, N,depth,done,i,l,ll,gensNmeth,allmethods,
398398 proj1,proj2,ri,rifac,riker,s,x,y,z,succ,counter,
399- kernelMandarins,factorMandarins,tmp ;
399+ kernelMandarins,factorMandarins;
400400
401401 depth := Length(depthString);
402402
@@ -410,13 +410,13 @@ InstallGlobalFunction( RecogniseGeneric,
410410
411411 if mandarins = fail then
412412 Assert (0 , depth = 0 );
413- # Use SetPseudoRandomStamp or RandomElm
414- # FIXME: double-check whether mandarins are not reused. Since
415- # PseudoRandom may use RandomElm as the pseudorandomfunc it could
416- # happen that the mandarins are reused.
417- # I think we have to undo the hack to PseudoRandom or, even worse,
418- # remove the mandarins from ri!.randr manually
413+ # HACK: We don't want the mandarins to be reused by any computation.
414+ # Since PseudoRandom is hacked, if we don't set ri!.randstore := false
415+ # then the mandarins would be reused by RandomElm and RandomElmOrd.
416+ oldRandstore := ri!. randstore;
417+ ri!. randstore := false ;
419418 mandarins := List([ 1 .. NUM_MANDARINS] , i -> PseudoRandom(H));
419+ ri!. randstore := oldRandstore;
420420 fi ;
421421
422422
@@ -471,16 +471,19 @@ InstallGlobalFunction( RecogniseGeneric,
471471 fi ;
472472
473473 # check mandarins now
474- tmp := NiceGens(ri);
475474 for x in mandarins do
476475 s := SLPforElement(ri, x);
477476 if s = fail then
478477 # TODO: should not really happen
479- Error(" Mandarins detected bad leaf" );
478+ # because we verify leaves immediately?
479+ ErrorNoReturn(" Mandarins detected bad leaf" );
480480 fi ;
481481 # TODO: validate the SLP, too?
482482 z := ResultOfStraightLineProgram(s, tmp);
483- Assert (0 , ri!. isequal(x, z));
483+ if not ri!. isequal(x, z) then
484+ # TODO: deal with this properly
485+ ErrorNoReturn(" Mandarins detected bad leaf" );
486+ fi ;
484487 od ;
485488
486489 # these two were set correctly by FindHomomorphism
@@ -498,17 +501,29 @@ InstallGlobalFunction( RecogniseGeneric,
498501 # In that case we know that ri now knows: homom plus additional data.
499502
500503 # map the mandarins
504+ # TODO Can we also put the ValidateHomomInput call with
505+ # GeneratorsOfGroup(H) here? If it fails we'll need to handle it exactly as
506+ # we handle a botched mandarin computation.
507+ for x in mandarins do
508+ if not ValidateHomomInput(ri, x) then
509+ # TODO: deal with this properly, see CompTree's description of what
510+ # it does in a "crisis"
511+ ErrorNoReturn(" Mandarins detected bad factor homom" );
512+ fi ;
513+ od ;
501514 factorMandarins := [] ;
502515 for x in mandarins do
516+ # TODO: magma has separate "test mandarins" and "map mandarins"
517+ # functions. Does that improve performance notably?
503518 y := ImageElm(Homom(ri), x);
504519 if y = fail then
505- # TODO: deal with this properly
506- Error (" Mandarins detected bad factor homom" );
520+ # TODO: deal with this properly, see above
521+ ErrorNoReturn (" Mandarins detected bad factor homom" );
507522 fi ;
508523 Add(factorMandarins, y);
509524 # s := SLPforElement(ri, x);
510525 od ;
511- # sort the factorMandarins and remove duplicates and trivials
526+ # TODO: sort the factorMandarins and remove duplicates and trivials
512527
513528 # Try to recognise the factor a few times, then give up:
514529 counter := 0 ;
@@ -603,8 +618,7 @@ InstallGlobalFunction( RecogniseGeneric,
603618 Add( kernelMandarins, x / z );
604619 fi ;
605620 od ;
606- # sort the kernelMandarins and remove duplicates and trivials
607- # kernelMandarins := rifac!.kernelMandarins
621+ # TODO: sort the kernelMandarins and remove duplicates and trivials
608622
609623 if Length(gensN(ri)) = 0 then
610624 # We found out that N is the trivial group!
@@ -620,7 +634,7 @@ InstallGlobalFunction( RecogniseGeneric,
620634 # we need to
621635 # WARNING: do NOT add the mandarin here, even though it may seem tempting.
622636 # But (a) they don't have memory, and (b) we need them to stay "clean",
623- # if we start using them for computations, this destroys out assumption
637+ # if we start using them for computations, this destroys our assumption
624638 # about their independency
625639 succ := FindKernelFastNormalClosure(ri,5 ,5 );
626640 Info (InfoRecog,2 ," Have now " ,Length(gensN(ri)),
0 commit comments