[1X7 Searching in groups and orbits[0X [1X7.1 Searching using orbit enumeration[0X As described in Subsection [14X3.1-4[0m the standard orbit enumeration routines can perform search operations during orbit enumeration. If one is looking for a shortest word in the generators of a group to express a group element with a certain property, then this natural breadth-first search can be used, for example by letting the group act on its own elements, either by multiplication or by conjugation. All technical instructions to do this are already given in Subsection [14X3.1-4[0m, so we are content to provide an example here. Assume you want to find the shortest way to express some 7-cycle in the symmetric group S_{10} as a product of generators a :=[10X(1,2,3,4,5,6,7,8,9,10)[0m and b :=[10X(1,2)[0m. Then you could do this in the following way: [4X--------------------------- Example ----------------------------[0X [4Xgap> gens := [(1,2,3,4,5,6,7,8,9,10),(1,2)];[0X [4X[ (1,2,3,4,5,6,7,8,9,10), (1,2) ][0X [4Xgap> o := Orb(gens,(),OnRight,rec( report := 2000,[0X [4X> lookingfor := [0X [4X> function(o,x) return NrMovedPoints(x) = 7 and Order(x)=7; end,[0X [4X> schreier := true ));[0X [4X<open orbit, 1 points with Schreier tree looking for sth.>[0X [4Xgap> Enumerate(o);[0X [4X<open orbit, 614 points with Schreier tree looking for sth.>[0X [4Xgap> w := TraceSchreierTreeForward(o,PositionOfFound(o));[0X [4X[ 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ][0X [4Xgap> ActWithWord(o!.gens,w,o!.op,o[1]); [0X [4X(1,10,9,8,7,6,5)[0X [4Xgap> o[PositionOfFound(o)] = ActWithWord(o!.gens,w,o!.op,o[1]);[0X [4Xtrue[0X [4Xgap> EvaluateWord(o!.gens,w);[0X [4X(1,10,9,8,7,6,5)[0X [4X------------------------------------------------------------------[0X The result shows that a^6 * (a* b)^3 is a 7-cycle and that there is no word in a and b with fewer than 12 letters expressing a 7-cycle. Note that we can go on with the above orbit enumeration to find further words to express 7-cycles. [1X7.2 Random searches in groups[0X Another possibility to look for elements in a group satisfying certain properties is to look at random elements, usually obtained by doing product replacement (see Section [14X6.2[0m). Although this can lead to very long expressions as words in the generators, one can cope with this problem by using the [10Xmaxdepth[0m option of the product replacer objects, which just reinitialises the product replacement table after a certain number of product replacements has been performed. To organise all this conveniently, there is the concept of "random searcher objects" described here. [1X7.2-1 RandomSearcher[0m [2X> RandomSearcher( [0X[3Xgens, testfunc[, opt][0X[2X ) _________________________[0Xoperation [6XReturns:[0X a random searcher object [3Xgens[0m must be a list of group generators, [3Xtestfunc[0m a function taking as argument one group element and returning [9Xtrue[0m or [9Xfalse[0m. [3Xopt[0m is an optional options record. For possible options see below. At first, the random searcher object is just initialised but no random searching is performed. The actual search is triggered by the [2XSearch[0m ([14X7.2-2[0m) operation (see below). The idea of random searcher objects is that a product replacer object is created and during a search random elements are produced using this product replacer object, and for each group element produced the function [3Xtestfunc[0m is called. If this function returns [9Xtrue[0m, the search stops and the group element found is returned. The following options can be bound in the options record [3Xopt[0m: [8X[10Xexceptions[0m[8X[0m This component can be a list to initialise the exception list in the random searcher object. Group elements in this list are not considered as successful searches. This list is also used to continue search operations to found more suitable group elements as every group element considered "found" is added to that list before returning it. Thus every element will only be found once. [8X[10Xmaxdepth[0m[8X[0m Sets the [10Xmaxdepth[0m option of the created product replacer object. This limits the length of the expression as product of the generators of the found group elements. [8X[10Xaddslots[0m[8X[0m Sets the [10Xaddslots[0m option of the created product replacer object. [8X[10Xscramble[0m[8X[0m If this component is bound at all, then the created product replacer object is created with options [10Xscramble=100[0m and [10Xscramblefactor=10[0m (the default values), otherwise the options [10Xscramble=0[0m and [10Xscramblefactor=0[0m are used, leading to no scrambling at all. See [2XProductReplacer[0m ([14X6.2-1[0m) for details on the product replacement algorithm. Note that of course the generators in [3Xgens[0m may have memory. However, the function [3Xtestfunc[0m is called with the group element with memory stripped off. [1X7.2-2 Search[0m [2X> Search( [0X[3Xrs[0X[2X ) ____________________________________________________[0Xoperation [6XReturns:[0X a group element Runs the search with the random searcher object [3Xrs[0m and returns with the first group element found. [1X7.3 The dihedral trick and applications[0X With the "dihedral" trick we mean the following: Two involutions a and b in a group always generate a dihedral group. Thus, to find a pseudo-random element in the centraliser of an involution a, we can proceed as follows: Create a pseudo-random element c, then b := a^c is another involution. If then ab has order 2o, we can use (ab)^o. Otherwise, if the order of ab is 2o-1, then (ab)^o * c^{-1} centralises a. This trick allows to efficiently produce elements in the centraliser of an involution and thus, with high probability, generators for the full centraliser. There are the following functions: [1X7.3-1 FindInvolution[0m [2X> FindInvolution( [0X[3Xpr[0X[2X ) _____________________________________________[0Xfunction [6XReturns:[0X an involution [3Xpr[0m must be a product replacer object (see Section [14X6.2[0m). Searches an involution by finding a random element of even order and powering up. Returns the involution. [1X7.3-2 FindCentralisingElementOfInvolution[0m [2X> FindCentralisingElementOfInvolution( [0X[3Xpr, a[0X[2X ) _____________________[0Xfunction [6XReturns:[0X a group element [3Xpr[0m must be a product replacer object (see Section [14X6.2[0m). Produces one random element and builds an element the centralises the involution [3Xa[0m using the dihedral trick described above. [1X7.3-3 FindInvolutionCentralizer[0m [2X> FindInvolutionCentralizer( [0X[3Xpr, a, nr[0X[2X ) ___________________________[0Xfunction [6XReturns:[0X a list of [3Xnr[0m group elements [3Xpr[0m must be a product replacer object (see Section [14X6.2[0m) and [3Xa[0m and involution. This function uses [2XFindCentralisingElementOfInvolution[0m ([14X7.3-2[0m) [3Xnr[0m times to produce an element centralising the involution [3Xa[0m and returns the list of results. [1X7.4 Orbit statistics on vector spaces[0X The following two functions are tools to get a rough and quick estimate about the average orbit length of a group acting on a vector space. [1X7.4-1 OrbitStatisticOnVectorSpace[0m [2X> OrbitStatisticOnVectorSpace( [0X[3Xgens, size, ti[0X[2X ) ____________________[0Xfunction [6XReturns:[0X nothing [3Xgens[0m must be a list of matrix group generators and [3Xsize[0m an integer giving the order of the group generated by [3Xgens[0m. [3Xti[0m is an integer specifying the number of seconds to run. This function enumerates orbits of random vectors in the natural space the group is acting on. The average length and some other information is printed on the screen. [1X7.4-2 OrbitStatisticOnVectorSpaceLines[0m [2X> OrbitStatisticOnVectorSpaceLines( [0X[3Xgens, size, ti[0X[2X ) _______________[0Xfunction [6XReturns:[0X nothing [3Xgens[0m must be a list of matrix group generators and [3Xsize[0m an integer giving the order of the group generated by [3Xgens[0m. [3Xti[0m is an integer specifying the number of seconds to run. This function enumerates orbits of random one-dimensional subspaces in the natural space the group is acting on. The average length and some other information is printed on the screen. [1X7.5 Finding generating sets of subgroups[0X The following function can be used to find generators of a subgroup of a group G, expressed as a straight line program in the generators of G. [1X7.5-1 FindShortGeneratorsOfSubgroup[0m [2X> FindShortGeneratorsOfSubgroup( [0X[3XG, U, membershiptest[0X[2X ) ____________[0Xfunction [6XReturns:[0X a record described below The arguments [3XU[0m and [3XG[0m must be [5XGAP[0m group objects with [3XU[0m being a subgroup of [3XG[0m. The argument [3Xmembershiptest[0m must be a function taking two arguments, namely a group element and a group, that checks, whether the group element lies in the group or not, returning [9Xtrue[0m or [9Xfalse[0m accordingly. You can usually just use the function [10X\in[0m as third argument. This function does a breadth-first search to find elements in [3XU[0m using the generators of [3XG[0m. It then uses calculates the size of the group generated and proceeds in this way, until a generating system for [3XU[0m is found in terms of the generators of [3XG[0m. Those generators are guaranteed to be shortest words in the generators of [3XG[0m lying in [3XU[0m. The function returns a record with two components bound: [10Xgens[0m is a list of generators for [3XU[0m and [10Xslp[0m is a [5XGAP[0m straight line program expressing exactly those generators in the generators of [3XG[0m. Note that this function only performs satisfactorily when the index of [3XU[0m in [3XG[0m is not to huge. It also helps if the groups come in a representation in which [5XGAP[0m can compute efficiently for example as permutation groups.