gap-packages / recog

The GAP package recog to collect methods for constructive recognition
https://gap-packages.github.io/recog/
GNU General Public License v3.0
6 stars 14 forks source link

Multiple evalutions of similar SLPs #329

Closed danielrademacher closed 4 months ago

danielrademacher commented 4 months ago

In gap/base/kernel.gi a function GenerateRandomKernelElementsAndOptionallyVerifyThem is implemented. This function includes the following code:

local gens, verificationSuccess, x, s, y, z, i;
    gens := gensN(ri);
    verificationSuccess := true;
    # We generate a random element of the kernel as the quotient of a random
    # element and the preimage of its image under the homomorphism.
    for i in [1 .. n] do
        # Finding kernel generators and immediate verification must use
        # different random elements! This is ensured by using the same stamp
        # in both situations.
        x := RandomElm(ri, "GenerateRandomKernelElementsAndOptionallyVerifyThem", true).el;
        Assert(2, ValidateHomomInput(ri, x));
        s := SLPforElement(ImageRecogNode(ri),
                                 ImageElm(Homom(ri), x!.el));
        if s = fail then
            return fail;
        fi;
        y := ResultOfStraightLineProgram(s, ri!.pregensfacwithmem);
        z := x^-1*y;
        if isone(ri)(z) or ForAny(gens, x -> isequal(ri)(x, z)) then
            continue;
        fi;
        if not doVerification or SLPforElement(KernelRecogNode(ri), z!.el) = fail then
            Add(gens, z);
            verificationSuccess := not doVerification;
        fi;
    od;
    return verificationSuccess;

I believe that

  s := SLPforElement(ImageRecogNode(ri),
                                 ImageElm(Homom(ri), x!.el));

uses the SLP which has been computed for nice generators of the ImageRecogNode(ri) to compute an SLP for the image of x. Afterwards, this SLP is evaluated in pregensfacwithmem. I believe that by this a very long SLP is evaluated multiple times. For this let slp_1 be the slp evaluating to nice gens in the image. Then we only need to evaluate this slp once in pregensfacwithmem. Afterwards, we compute the slp for the image of x starting from the nice gens and evaluate this slp in the preimages of the nice gens. This should avoid evaluating the same slp multiple times.

danielrademacher commented 4 months ago

I believe that this is already done by using pregensfacwithmem. So I close this issue.