Goto Chapter: Top 1 2 3 4 5 6 7 8 9 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

9 How to write a recognition method
 9.1 Leaf methods
 9.2 Elements with memory
 9.3 Splitting methods

9 How to write a recognition method

This chapter explains how to integrate a newly developed group recognition method into the framework provided by the recog package.

TODO: Refer to Chapter 4 for an explanation of methods. There are leaf methods and split methods. The next two sections describe how to implement leaf and split methods respectively, and include example code.

9.1 Leaf methods

A leaf method must at the very least do the following, examples will be provided below (TODO: add a reference):

There are further values that can be provided, in particular to speed up computations; we'll come back to that later. Let's first look at an example: The following method is used by recog to recognize trivial groups, as a base case for the recursive group recognition algorithm. It works for arbitrary groups.

TODO: AutoDoc inserts extra paragraph commands here:

BindRecogMethod(FindHomMethodsGeneric, "TrivialGroup",
"go through generators and compare to the identity",
function(ri, G)
  local gens;
  # get the generators of the group
  gens := GeneratorsOfGroup(G);
<P/>
  # check whether all generators are trivial
  # ri!.isone is explained below
  if not ForAll(gens, ri!.isone) then
    # NeverApplicable because it makes
    # no sense to call this method again
    return NeverApplicable;
  fi;
<P/>
  # The group is trivial! Provide required information:
<P/>
  # size of the group
  SetSize(ri, 1);
<P/>
  # explained below
  Setslpforelement(ri, SLPforElementFuncsGeneric.TrivialGroup);
<P/>
  # SLP from given generators to nice generators
  Setslptonice(ri, StraightLineProgramNC([[[1,0]]],
                   Length(gens)));
<P/>
  # We have reached a leaf node.
  SetFilterObj(ri, IsLeaf);
  return Success;
end);

The input is in the format described above (TODO), and the return value is "Success".

Two more comments:

SLPforElementFuncsGeneric.TrivialGroup := function(ri,g)
    if not ri!.isone(g) then
        return fail;
    fi;
    return StraightLineProgramNC( [ [1,0] ], 1 );
end;

Finally, we need to let recog know about this new recognition method. This is done via the AddMethod function. Another example!

AddMethod(FindHomDbPerm, FindHomMethodsGeneric.TrivialGroup, 300);

TODO: refer to the AddMethod documentation instead. Also this is outdated now. The function AddMethod takes four mandatory arguments db, meth, rank, stamp, and an optional fifth argument comment. Their meaning is as follows:

Note that above, we only installed our method into FindHomDbPerm. But in recog, it is actually also installed for matrix and projective groups. We reproduce the corresponding AddMethod calls here. Note that the ranks differ, so the same method can be called with varying priority depending on the type of group.

AddMethod(FindHomDbMatrix, FindHomMethodsGeneric.TrivialGroup, 3100);
AddMethod(FindHomDbProjective, FindHomMethodsGeneric.TrivialGroup, 3000);

9.2 Elements with memory

When using the memory of group elements, one currently has to always access ri!.gensHmem instead of doing GroupWithMemory(Grp(ri)). Namely, many functions for objects with memory assume that, if the elements live in the same group, then their !.slp components are identical.

9.3 Splitting methods

Recall that splitting recognition methods produce an epimorphism \(\phi:G\to H\) and then delegate the work to the image \(H\) and the kernel \(N:=\ker(\phi)\). This means that now \(N\) and \(H\) have to be constructively recognized. Such a splitting recognition method only needs to provide a homomorphism, by calling SetHomom(ri, hom);. However, in practice one will want to provide additional data.

We start with an example, similar to a method used in recog. This refers to permutation groups only!

BindRecogMethod(FindHomMethodsPerm, "NonTransitive",
"try to find non-transitivity and restrict to orbit",
rec(validatesOrAlwaysValidInput := true),
function(ri, G)
    local hom,la,o;
<P/>
    # test whether we can do something:
    if IsTransitive(G) then
        return NeverApplicable;
    fi;
<P/>
    # compute orbit of the largest moved point
    la := LargestMovedPoint(G);
    o := Orb(G,la,OnPoints);
    Enumerate(o);
    # compute homomorphism into Sym(o), i.e, restrict
    # the permutation action of G to the orbit o
    hom := OrbActionHomomorphism(G,o);
    # TODO: explanation
    Setvalidatehomominput(ri, {ri,p} -> ForAll(o, x -> (x^p in o)));
    # store the homomorphism into the recognition node
    SetHomom(ri,hom);
<P/>
    # TODO: explanation
    Setimmediateverification(ri, true);
<P/>
    # indicate success
    return Success;
end);

TODO Alternatively use this:

FindHomMethodsPerm.NonTransitive := function(ri, G)
  local hom, la, o;

  # test whether we can do something:
  if IsTransitive(G) then
    # the action is transitive, so we can't do
    # anything, and there is no point in calling us again.
    return NeverApplicable;
  fi;

  # compute orbit of the largest moved point
  la := LargestMovedPoint(G);
  o := Orbit(G, la, OnPoints);

  # compute homomorphism into Sym(o), i.e, restrict
  # the permutation action of G to the orbit o
  hom := ActionHomomorphism(G, o);

  # store the homomorphism into the recognition node
  SetHomom(ri, hom);

  # indicate success
  return Success;
end;
AddMethod(FindHomDbPerm, FindHomMethodsPerm.NonTransitive, 90);

TODO: More complex example:

FindHomMethodsMatrix.BlockLowerTriangular := function(ri, G)
  # This is only used coming from a hint, we know what to do:
  # A base change was done to get block lower triangular shape.
  # We first do the diagonal blocks, then the lower p-part:
  local H, data, hom, newgens;

  # we need to construct a homomorphism, but to defined it,
  # we need the image, but of course the image is defined in
  # terms of the homomorphism... to break this cycle, we do
  # the following: we first map the input generators using
  # the helper function RECOG.HomOntoBlockDiagonal; this
  # function is later also used as the underlying mapping
  # of the homomorphism.
  data := rec( blocks := ri!.blocks );
  newgens := List(GeneratorsOfGroup(G),
                  x -> RECOG.HomOntoBlockDiagonal(data, x));
  Assert(0, not fail in newgens);

  # now that we have the images of the generators, we can
  # defined the image group
  H := Group(newgens);

  # finally, we define the homomorphism
  hom := GroupHomByFuncWithData(G, H, RECOG.HomOntoBlockDiagonal, data);

  # ... and store it in the recognition node
  SetHomom(ri, hom);

  # since we know exactly what kind of group we are looking
  # at, we don't want to run generic recognition on the
  # image group and the kernel. So we provide "hints" to
  # ensure more appropriate recognition methods are applied
  # first.

  # Give hint to image
  InitialDataForImageRecogNode(ri).blocks := ri!.blocks;
  Add(InitialDataForImageRecogNode(ri).hints,
      rec( method := FindHomMethodsMatrix.BlockDiagonal,
           rank := 2000,
           stamp := "BlockDiagonal" ) );

  # Tell recog that we have a better method for finding kernel
  findgensNmeth(ri).method := FindKernelLowerLeftPGroup;
  findgensNmeth(ri).args := [];

  # Give hint to kernel N
  Add(InitialDataForKernelRecogNode(ri).hints,
      rec( method := FindHomMethodsMatrix.LowerLeftPGroup,
           rank := 2000,
           stamp := “LowerLeftPGroup" ));
  InitialDataForKernelRecogNode(ri).blocks := ri!.blocks;

  # This function always succeeds, because it is only
  # called for inputs for which it is known to apply.
  return Success;
end;
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 Bib Ind

generated by GAPDoc2HTML