Skip to content

Document and consistently use RandomElm, RandomElmOrd, SetPseudoRandomStamp, ... #462

Description

@fingolfin

Roughly the idea there is to re-use random elements for different purposes: if a random element was generated and used by naming, there is no reason why later on it should not be used again for constructive recognition. To handle this, recog maintains a stream of random elements, plus a bunch of "pointers" or "indices" into this stream, for different purposes. The challenge is to properly document this, and then use it.

Some more details are in this code comment:

# RandomElm and RandomElmOrd take a recog record, a string, and a
# bool as inputs.
# The string is used as a stamp to request a random element or order for a
# specific computation. RandomElm and RandomElmOrd will first try to reuse
# random elements and orders generated with different stamps.
# For example, if a computation which used stamp := "A" has already computed
# random elements or orders, then RandomElm and RandomElmOrd will reuse these
# if called with stamp := "B".
#
# The components of the recog record involved are explained in
# RecogNode.
#
# 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).

Once all this is done, we could perhaps also get rid of the PseudoRandom hack we have in place to get existing code to at least somewhat use these helpers:

InstallMethod( PseudoRandom, "for a group object with generators, use func",
  [ IsGroup and HasGeneratorsOfGroup ], 1,
  function( g )
    local l;
    # FIXME: get rid of this hackish override of PseudoRandom,
    # and define our own operation instead (say, RECOG_PseuoRandom)?!
    # Or at least change pseudorandomfunc to an attribute, so that
    # the filter of this method can be turned into something like
    #  IsGroup and HasPseudoRandomFunc
    if IsBound(g!.pseudorandomfunc) and Length(g!.pseudorandomfunc) > 0 then
        l := Length(g!.pseudorandomfunc);
        return CallFuncList(g!.pseudorandomfunc[l].func,
                            g!.pseudorandomfunc[l].args);
    fi;
    TryNextMethod();
  end );

See also #129, #237

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions