  
  [1X7 Self-similar groups, monoids and semigroups[0X
  
  Self-similar groups, monoids and semigroups (below [13XFR semigroups[0m) are simply
  groups,  monoids  and  semigroups  whose  elements  are  FR  machines.  They
  naturally  act on the alphabet of their elements, and on sequences over that
  alphabet.
  
  Most  non-trivial  calculations  in  FR groups are performed as follows: [5XGAP[0m
  searches  through  words of short length in the generating set of a FR group
  to  find  a  solution  to  a  group-theoretic question, and at the same time
  searches  through  the  finite  quotients  to  prove  the  inexistence  of a
  solution.  Usually  the  calculation ends with the answer [9Xmaybe[0m, which means
  that  no  definite  answer,  neither  positive nor negative, could be found;
  however,  the cases where the calculation actually terminates have been most
  useful.
  
  The  maximal  length of words to consider in the search is controlled by the
  variable  [10XFR_SEARCH.radius[0m (initially 10), and the maximal depth of the tree
  in  which to search is controlled by the variable [10XFR_SEARCH.depth[0m (initially
  6).  These  limits  can be modified in any function call using [5XGAP[0m's options
  mechanism, e.g. in [10XIndex(G,H:FRdepth:=5,FRradius:=5)[0m.
  
  
  [1X7.1 Creators for FR semigroups[0X
  
  The  most  straightforward creation method for FR groups is [10XGroup()[0m, applied
  with  FR elements as arguments. There are shortcuts to this somewhat tedious
  method:
  
  [1X7.1-1 FRGroup[0m
  
  [2X> FRGroup( [0X[3X{definition, }[0X[2X ) _______________________________________[0Xoperation
  [2X> FRMonoid( [0X[3X{definition, }[0X[2X ) ______________________________________[0Xoperation
  [2X> FRSemigroup( [0X[3X{definition, }[0X[2X ) ___________________________________[0Xoperation
  [6XReturns:[0X  A new self-similar group/monoid/semigroup.
  
  This function constructs a new FR group/monoid/semigroup, generated by group
  FR  elements.  It  receives as argument any number of strings, each of which
  represents a generator of the object to be constructed.
  
  Each  [3Xdefinition[0m  is  of  the  form [10X"name=projtrans"[0m, where each of [10Xproj[0m and
  [10Xtrans[0m  is  optional.  [10Xproj[0m  is  of  the form [10X<w1,...,wd>[0m, where each [10Xwi[0m is a
  (possibly empty) word in the [10Xname[0ms or is 1. [10Xtrans[0m is either a permutation in
  disjoint   cycle   notation,  or  a  list,  representing  the  images  of  a
  permutation.
  
  The       option       [10XIsMealyElement[0m,      passed      e.g.      as      in
  [10XFRGroup("a=(1,2)":IsMealyElement)[0m,  asks  for  the  resulting  group  to  be
  generated  by Mealy elements. The generators must of course be finite-state.
  Their  names ("a",...) are not remembered in the constructing group (but can
  be set using [2XSetName[0m ([14XReference: SetName[0m)).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> FRGroup("a=(1,2)","b=(1,2,3,4,5)"); Size(last);[0X
    [4X<self-similar group over [ 1 .. 5 ] with 2 generators>[0X
    [4X120[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> AssignGeneratorVariables(Dinfinity);[0X
    [4X#I  Assigned the global variables [ a, b ][0X
    [4Xgap> Order(a); Order(b); Order(a*b);[0X
    [4X2[0X
    [4X2[0X
    [4Xinfinity[0X
    [4Xgap> ZZ := FRGroup("t=<,t>[2,1]");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xtau := FRElement([[[b,1],[1]]],[()],[1]);[0X
    [4X<2|f3>[0X
    [4Xgap> IsSubgroup(Dinfinity,ZZ);[0X
    [4Xfalse[0X
    [4Xgap> IsSubgroup(Dinfinity^tau,ZZ);[0X
    [4Xtrue[0X
    [4Xgap> Index(Dinfinity^tau,ZZ);[0X
    [4X2[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> i4 := FRMonoid("s=(1,2)","f=<s,f>[1,1]");[0X
    [4X<self-similar monoid over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> f := GeneratorsOfMonoid(i4){[1,2]};;[0X
    [4Xgap> for i in [1..10] do Add(f,f[i]*f[i+1]); od;[0X
    [4Xgap> f[1]^2=One(m);[0X
    [4Xtrue[0X
    [4Xgap> f[2]^3=f[2];[0X
    [4Xtrue[0X
    [4Xgap> f[11]*f[10]^2=f[1]*Product(f{[5,7..11]})*f[10];[0X
    [4Xtrue[0X
    [4Xgap> f[12]*f[11]^2=f[2]*Product(f{[6,8..12]})*f[11];[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> i2 := FRSemigroup("f0=<f0,f0>(1,2)","f1=<f1,f0>[2,2]");[0X
    [4X<self-similar semigroup over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> AssignGeneratorVariables(i2);[0X
    [4X#I  Assigned the global variables [ "f0", "f1" ][0X
    [4Xgap> f0^2=One(i2);[0X
    [4Xtrue[0X
    [4Xgap> ForAll([0..10],p->(f0*f1)^p*(f1*f0)^p*f1=f1^2*(f0*f1)^p*(f1*f0)^p*f1);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-2 SCGroup[0m
  
  [2X> SCGroup( [0X[3Xm[0X[2X ) ____________________________________________________[0Xoperation
  [2X> SCGroupNC( [0X[3Xm[0X[2X ) __________________________________________________[0Xoperation
  [2X> SCMonoid( [0X[3Xm[0X[2X ) ___________________________________________________[0Xoperation
  [2X> SCMonoidNC( [0X[3Xm[0X[2X ) _________________________________________________[0Xoperation
  [2X> SCSemigroup( [0X[3Xm[0X[2X ) ________________________________________________[0Xoperation
  [2X> SCSemigroupNC( [0X[3Xm[0X[2X ) ______________________________________________[0Xoperation
  [6XReturns:[0X  The  state-closed  group/monoid/semigroup generated by the machine
            [3Xm[0m.
  
  This function constructs a new FR group/monoid/semigroup [10Xg[0m, generated by all
  the  states of the FR machine [3Xm[0m. There is a bijective correspondence between
  [10XGeneratorsOfFRMachine(m)[0m  and  the  generators of [10Xg[0m, which is accessible via
  [10XCorrespondence(g)[0m  (See  [2XCorrespondence[0m  ([14X7.1-3[0m)); it is a homomorphism from
  the  stateset  of  [3Xm[0m  to  [10Xg[0m,  or  a  list  indicating  for each state of [3Xm[0m a
  corresponding  generator  index  in  the generators of [10Xg[0m (with negatives for
  inverses, and 0 for identity).
  
  In  the  non-[10XNC[0m forms, redundant (equal, trivial or mutually inverse) states
  are removed from the generating set of [10Xg[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> b := MealyMachine([[3,2],[3,1],[3,3]],[(1,2),(),()]);; g := SCGroupNC(b);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 3 generators>[0X
    [4Xgap> Size(g);[0X
    [4Xinfinity[0X
    [4Xgap> IsOne(Comm(g.2,g.2^g.1));[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> i4machine := MealyMachine([[3,3],[1,2],[3,3]],[(1,2),[1,1],()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> IsInvertible(i4machine);[0X
    [4Xfalse[0X
    [4Xgap> i4 := SCMonoidNC(i4machine);[0X
    [4X<self-similar monoid over [ 1 .. 2 ] with 3 generators>[0X
    [4Xgap> f := GeneratorsOfMonoid(i4){[1,2]};;[0X
    [4Xgap> for i in [1..10] do Add(f,f[i]*f[i+1]); od;[0X
    [4Xgap> f[1]^2=One(m);[0X
    [4Xtrue[0X
    [4Xgap> f[2]^3=f[2];[0X
    [4Xtrue[0X
    [4Xgap> f[11]*f[10]^2=f[1]*Product(f{[5,7..11]})*f[10];[0X
    [4Xtrue[0X
    [4Xgap> f[12]*f[11]^2=f[2]*Product(f{[6,8..12]})*f[11];[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> i2machine := MealyMachine([[1,1],[2,1]],[(1,2),[2,2]]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states>[0X
    [4Xgap> i2 := SCSemigroupNC(i2machine);[0X
    [4X<self-similar semigroup over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> f0 := GeneratorsOfSemigroup(i2)[1];; f1 := GeneratorsOfSemigroup(i2)[2];;[0X
    [4Xgap> f0^2=One(i2);[0X
    [4Xtrue[0X
    [4Xgap> ForAll([0..10],p->(f0*f1)^p*(f1*f0)^p*f1=f1^2*(f0*f1)^p*(f1*f0)^p*f1);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-3 Correspondence[0m
  
  [2X> Correspondence( [0X[3Xg[0X[2X ) _____________________________________________[0Xattribute
  [6XReturns:[0X  A  correspondence  between  the  generators  of  the underlying FR
            machine of [3Xg[0m and [3Xg[0m.
  
  If  [3Xg[0m  was  created  as the state closure of an FR machine [10Xm[0m, this attribute
  records the correspondence between [10Xm[0m and [3Xg[0m.
  
  If  [10Xm[0m is a group/monoid/semigroup/algebra FR machine, then [10XCorrespondence(g)[0m
  is a homomorphism from the stateset of [10Xm[0m to [3Xg[0m.
  
  If [10Xm[0m is a Mealy or vector machine, then [10XCorrespondence(g)[0m is a list, with in
  position  i  the  index  in  the generating set of [3Xg[0m of state number i. This
  index  is  0  if  there  is  no corresponding generator because the state is
  trivial,  and is negative if there is no corresponding generator because the
  inverse of state number i is a generator.
  
  See   [2XSCGroupNC[0m  ([14X7.1-2[0m),  [2XSCGroup[0m  ([14X7.1-2[0m),  [2XSCMonoidNC[0m  ([14X7.1-2[0m),  [2XSCMonoid[0m
  ([14X7.1-2[0m),  [2XSCSemigroupNC[0m  ([14X7.1-2[0m),  [2XSCSemigroup[0m ([14X7.1-2[0m), [2XSCAlgebraNC[0m ([14X8.1-2[0m),
  [2XSCAlgebra[0m  ([14X8.1-2[0m), [2XSCAlgebraWithOneNC[0m ([14X8.1-2[0m), and [2XSCAlgebraWithOne[0m ([14X8.1-2[0m)
  for examples.
  
  [1X7.1-4 FullSCGroup[0m
  
  [2X> FullSCGroup( [0X[3X...[0X[2X ) _______________________________________________[0Xfunction
  [2X> FullSCMonoid( [0X[3X...[0X[2X ) ______________________________________________[0Xfunction
  [2X> FullSCSemigroup( [0X[3X...[0X[2X ) ___________________________________________[0Xfunction
  [6XReturns:[0X  A maximal state-closed group/monoid/semigroup on the alphabet [3Xa[0m.
  
  This function constructs a new FR group, monoid or semigroup, which contains
  all transformations with given properties of the tree with given alphabet.
  
  The  arguments  can  be,  in any order: a semigroup, specifying which vertex
  actions  are  allowed; a set or domain, specifying the alphabet of the tree;
  an  integer,  specifying  the  maximal depth of elements; and a filter among
  [2XIsFinitaryFRElement[0m       ([14X5.2-10[0m),       [2XIsBoundedFRElement[0m       ([14X5.2-12[0m),
  [2XIsPolynomialGrowthFRElement[0m ([14X5.2-13[0m) and [2XIsFiniteStateFRElement[0m ([14X4.2-11[0m).
  
  This  object  serves  as  a  container  for all FR elements with alphabet [3Xa[0m.
  Random  elements can be drawn from it; they are Mealy elements with a random
  number of states, and with the required properties.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> g := FullSCGroup([1..3]);[0X
    [4XFullSCGroup([ 1 .. 3 ]);[0X
    [4Xgap> IsSubgroup(g,GuptaSidkiGroup);[0X
    [4Xtrue[0X
    [4Xgap> g := FullSCGroup([1..3],Group((1,2,3)));[0X
    [4XFullSCGroup([ 1 .. 3 ], Group( [ (1,2,3) ] ))[0X
    [4Xgap> IsSubgroup(g,GuptaSidkiGroup);[0X
    [4Xtrue[0X
    [4Xgap> IsSubgroup(g,GrigorchukGroup);[0X
    [4Xfalse[0X
    [4Xgap> Random(g);[0X
    [4X<Mealy element on alphabet [ 1, 2, 3 ] with 2 states, initial state 1>[0X
    [4Xgap> Size(FullSCGroup([1,2],3));[0X
    [4X128[0X
    [4Xgap> g := FullSCMonoid([1..2]);[0X
    [4XFullSCMonoid([ 1 .. 2 ])[0X
    [4Xgap> IsSubset(g,AsTrans(FullSCGroup([1..2])));[0X
    [4Xtrue[0X
    [4Xgap> IsSubset(g,AsTrans(GrigorchukGroup));[0X
    [4Xtrue[0X
    [4Xgap> g := FullSCSemigroup([1..3]);[0X
    [4XFullSCSemigroup([ 1 .. 3 ])[0X
    [4Xgap> h := FullSCSemigroup([1..3],Semigroup(Trans([1,1,1])));[0X
    [4XFullSCSemigroup([ 1 .. 3 ], Semigroup( [ Trans( [ 1, 1, 1 ] ) ] ))[0X
    [4Xgap> Size(h);[0X
    [4X1[0X
    [4Xgap> IsSubset(g,h);[0X
    [4Xtrue[0X
    [4Xgap> g=FullSCMonoid([1..3]);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-5 FRMachineFRGroup[0m
  
  [2X> FRMachineFRGroup( [0X[3Xg[0X[2X ) ___________________________________________[0Xoperation
  [2X> FRMachineFRMonoid( [0X[3Xg[0X[2X ) __________________________________________[0Xoperation
  [2X> FRMachineFRSemigroup( [0X[3Xg[0X[2X ) _______________________________________[0Xoperation
  [2X> MealyMachineFRGroup( [0X[3Xg[0X[2X ) ________________________________________[0Xoperation
  [2X> MealyMachineFRMonoid( [0X[3Xg[0X[2X ) _______________________________________[0Xoperation
  [2X> MealyMachineFRSemigroup( [0X[3Xg[0X[2X ) ____________________________________[0Xoperation
  [6XReturns:[0X  A machine describing all generators of [3Xg[0m.
  
  This function constructs a new group/monoid/semigroup/Mealy FR machine, with
  (at  least)  one  generator  per  generator of [3Xg[0m. This is done by adding all
  machines of all generators of [3Xg[0m, and minimizing.
  
  In particular, if [3Xg[0m is state-closed, then [10XSCGroup(FRMachineFRGroup(g))[0m gives
  a group isomorphic to [3Xg[0m, and similarly for monoids and semigroups.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> FRMachineFRGroup(GuptaSidkiGroup);[0X
    [4X<FR machine with alphabet [ 1 .. 3 ] on Group( [ f11, f12 ] )>[0X
    [4Xgap> Display(last);[0X
    [4X G   |     1          2        3[0X
    [4X-----+--------+----------+--------+[0X
    [4X f11 | <id>,2     <id>,3   <id>,1[0X
    [4X f12 |  f11,1   f11^-1,2    f12,3[0X
    [4X-----+--------+----------+--------+[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> FRMachineFRMonoid(I4Monoid);[0X
    [4X<FR machine with alphabet [ 1 .. 2 ] on Monoid( [ m11, m12 ], ... )>[0X
    [4Xgap> Display(last);[0X
    [4X M   |     1        2[0X
    [4X-----+--------+--------+[0X
    [4X m11 | <id>,2   <id>,1[0X
    [4X m12 |  m11,1    m12,1[0X
    [4X-----+--------+--------+[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> FRMachineFRSemigroup(I2Monoid);[0X
    [4X<FR machine with alphabet [ 1 .. 2 ] on Semigroup( [ s11, s12, s1 ] )>[0X
    [4Xgap> Display(last);[0X
    [4X S   |    1       2[0X
    [4X-----+-------+-------+[0X
    [4X s11 | s11,1   s11,2[0X
    [4X s12 | s12,2   s12,1[0X
    [4X  s1 |  s1,2   s12,2[0X
    [4X-----+-------+-------+[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-6 IsomorphismFRGroup[0m
  
  [2X> IsomorphismFRGroup( [0X[3Xg[0X[2X ) _________________________________________[0Xoperation
  [2X> IsomorphismFRMonoid( [0X[3Xg[0X[2X ) ________________________________________[0Xoperation
  [2X> IsomorphismFRSemigroup( [0X[3Xg[0X[2X ) _____________________________________[0Xoperation
  [6XReturns:[0X  An  isomorphism  towards  a  group/monoid/semigroup on a single FR
            machine.
  
  This  function  constructs  a  new  FR group/monoid/semigroup, such that all
  elements    of    the    resulting   object   have   the   same   underlying
  group/monoid/semigroup FR machine.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> phi := IsomorphismFRGroup(GuptaSidkiGroup);[0X
    [4X[ <Mealy element on alphabet [ 1, 2, 3 ] with 2 states, initial state 1>,[0X
    [4X  <Mealy element on alphabet [ 1, 2, 3 ] with 4 states, initial state 1> ] ->[0X
    [4X[ <3|identity ...>, <3|f1>, <3|f1^-1>, <3|f2> ][0X
    [4Xgap> Display(GuptaSidkiGroup.2);[0X
    [4X   |  1     2     3[0X
    [4X---+-----+-----+-----+[0X
    [4X a | a,1   a,2   a,3[0X
    [4X b | a,2   a,3   a,1[0X
    [4X c | a,3   a,1   a,2[0X
    [4X d | b,1   c,2   d,3[0X
    [4X---+-----+-----+-----+[0X
    [4XInitial state: d[0X
    [4Xgap> Display(GuptaSidkiGroup.2^phi);[0X
    [4X    |     1         2        3[0X
    [4X----+--------+---------+--------+[0X
    [4X f1 | <id>,2    <id>,3   <id>,1[0X
    [4X f2 |   f1,1   f1^-1,2     f2,3[0X
    [4X----+--------+---------+--------+[0X
    [4XInitial state: f2[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> phi := IsomorphismFRSemigroup(I2Monoid);[0X
    [4XMappingByFunction( I2, <self-similar semigroup over [ 1 .. 2 ] with[0X
    [4X3 generators>, <Operation "AsSemigroupFRElement"> )[0X
    [4Xgap> Display(GeneratorsOfSemigroup(I2Monoid)[3]);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | a,2   b,2[0X
    [4X b | b,2   b,1[0X
    [4X---+-----+-----+[0X
    [4XInitial state: a[0X
    [4Xgap> Display(GeneratorsOfSemigroup(I2Monoid)[3]^phi);[0X
    [4X S  |   1      2[0X
    [4X----+------+------+[0X
    [4X s1 | s1,2   s2,2[0X
    [4X s2 | s2,2   s2,1[0X
    [4X----+------+------+[0X
    [4XInitial state: s1[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> phi := IsomorphismFRMonoid(I4Monoid);[0X
    [4XMappingByFunction( I4, <self-similar monoid over [ 1 .. 2 ] with[0X
    [4X2 generators>, <Operation "AsMonoidFRElement"> )[0X
    [4Xgap> Display(GeneratorsOfMonoid(I4Monoid)[1]);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | b,2   b,1[0X
    [4X b | b,1   b,2[0X
    [4X---+-----+-----+[0X
    [4XInitial state: a[0X
    [4Xgap> Display(GeneratorsOfMonoid(I4Monoid)[1]^phi);[0X
    [4X M  |     1        2[0X
    [4X----+--------+--------+[0X
    [4X m1 | <id>,2   <id>,1[0X
    [4X----+--------+--------+[0X
    [4XInitial state: m1[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-7 IsomorphismMealyGroup[0m
  
  [2X> IsomorphismMealyGroup( [0X[3Xg[0X[2X ) ______________________________________[0Xoperation
  [2X> IsomorphismMealyMonoid( [0X[3Xg[0X[2X ) _____________________________________[0Xoperation
  [2X> IsomorphismMealySemigroup( [0X[3Xg[0X[2X ) __________________________________[0Xoperation
  [6XReturns:[0X  An  isomorphism  towards  a  group/monoid/semigroup  all  of whose
            elements are Mealy machines.
  
  This  function  constructs  a  new  FR group/monoid/semigroup, such that all
  elements of the resulting object are Mealy machines.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> G := FRGroup("a=(1,2)","b=<a,b>","c=<c,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 3 generators>[0X
    [4Xgap> phi := IsomorphismMealyGroup(G);[0X
    [4X[ <2|a>, <2|b>, <2|c> ] ->[0X
    [4X[ <Mealy element on alphabet [ 1, 2 ] with 2 states, initial state 1>,[0X
    [4X  <Mealy element on alphabet [ 1, 2 ] with 3 states, initial state 1>,[0X
    [4X  <Mealy element on alphabet [ 1, 2 ] with 4 states, initial state 1> ][0X
    [4Xgap> Display(G.3);[0X
    [4X   |     1        2[0X
    [4X---+--------+--------+[0X
    [4X a | <id>,2   <id>,1[0X
    [4X b |    a,1      b,2[0X
    [4X c |    c,1      b,2[0X
    [4X---+--------+--------+[0X
    [4XInitial state: c[0X
    [4Xgap> Display(G.3^phi);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | a,1   b,2[0X
    [4X b | c,1   b,2[0X
    [4X c | d,2   d,1[0X
    [4X d | d,1   d,2[0X
    [4X---+-----+-----+[0X
    [4XInitial state: a[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-8 FRGroupByVirtualEndomorphism[0m
  
  [2X> FRGroupByVirtualEndomorphism( [0X[3Xhom[, transversal][0X[2X ) ______________[0Xoperation
  [6XReturns:[0X  A new self-similar group.
  
  This  function  constructs a new FR group [10XP[0m, generated by group FR elements.
  Its  first  argument  is  a  virtual  endomorphism  of  a  group  [10XG[0m,  i.e. a
  homomorphism from a subgroup [10XH[0m to [10XG[0m. The constructed FR group acts on a tree
  with  alphabet  a  transversal  of  [10XH[0m in [10XG[0m (represented as [10X[1..d][0m), and is a
  homomorphic   image   of   [10XG[0m.  The  stabilizer  of  the  first-level  vertex
  corresponding  to  the  trivial  coset  is  the image of [10XH[0m. This function is
  loosely speaking an inverse of [2XVirtualEndomorphism[0m ([14X7.2-25[0m).
  
  The  optional  second  argument  is  a transversal of [10XH[0m in [10XG[0m, either of type
  [10XIsRightTransversal[0m or a list.
  
  Furthermore,  an  option  "MealyElement"  can  be passed to the function, as
  [10XFRGroupByVirtualEndomorphism(f:MealyElement)[0m, to require the resulting group
  to  be  generated  by  Mealy  elements  and  not  FR elements. The call will
  succeed, of course, only if the representation of [10XG[0m is finite-state.
  
  The  resulting  FR  group  has an attribute [10XCorrespondence(P)[0m that records a
  homomorphism from [10XG[0m to [10XP[0m.
  
  The  example  below constructs the binary adding machine, and a non-standard
  representation of it.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> G := FreeGroup(1);[0X
    [4X<free group on the generators [ f1 ]>[0X
    [4Xgap> f := GroupHomomorphismByImages(Group(G.1^2),G,[G.1^2],[G.1]);[0X
    [4X[ f1^2 ] -> [ f1 ][0X
    [4Xgap> H := FRGroupByVirtualEndomorphism(f);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xgap> Display(H.1);[0X
    [4X    |     1      2[0X
    [4X----+--------+------+[0X
    [4X x1 | <id>,2   x1,1[0X
    [4X----+--------+------+[0X
    [4XInitial state: x1[0X
    [4Xgap> Correspondence(H);[0X
    [4X[ f1 ] -> [ <2|x1> ][0X
    [4Xgap> H := FRGroupByVirtualEndomorphism(f,[G.1^0,G.1^3]);;[0X
    [4Xgap> Display(H.1);[0X
    [4X    |      1        2[0X
    [4X----+---------+--------+[0X
    [4X x1 | x1^-1,2   x1^2,1[0X
    [4X----+---------+--------+[0X
    [4XInitial state: x1[0X
    [4Xgap> H := FRGroupByVirtualEndomorphism(f:MealyElement);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xgap> Display(H.1);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | b,2   a,1[0X
    [4X b | b,1   b,2[0X
    [4X---+-----+-----+[0X
    [4XInitial state: a[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.1-9 TreeWreathProduct[0m
  
  [2X> TreeWreathProduct( [0X[3Xg, h, x0, y0[0X[2X ) _______________________________[0Xoperation
  [6XReturns:[0X  The tree-wreath product of groups [3Xg,h[0m.
  
  The tree-wreath product of two FR groups is a group generated by a copy of [3Xg[0m
  and of [3Xh[0m, in such a way that many conjugates of [3Xg[0m commute.
  
  More  formally,  assume  without loss of generality that all generators of [3Xg[0m
  are  states  of  a  machine  [10Xm[0m, and that all generators of [3Xh[0m are states of a
  machine  [10Xn[0m.  Then  the  tree-wreath  product  is  generated by the images of
  generators of [3Xg,h[0m in [10XTreeWreathProduct(m,n,x0,y0)[0m.
  
  For  the  operation  on  FR  machines  see [2XTreeWreathProduct[0m ([14X3.5-8[0m)). It is
  described  (with small variations, and in lesser generality) in [Sid05]. For
  example, in
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> w := TreeWreathProduct(AddingGroup(2),AddingGroup(2),1,1);[0X
    [4X<recursive group over [ 1 .. 4 ] with 2 generators>[0X
    [4Xgap> a := w.1; b := w.2;[0X
    [4X<Mealy element on alphabet [ 1 .. 4 ] with 3 states>[0X
    [4X<Mealy element on alphabet [ 1 .. 4 ] with 2 states>[0X
    [4Xgap> Order(a); Order(b);[0X
    [4Xinfinity[0X
    [4Xinfinity[0X
    [4Xgap> ForAll([-100..100],i->IsOne(Comm(a,a^(b^i))));[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  the group [10Xw[0m is the wreath product Zwr Z.
  
  [1X7.1-10 WeaklyBranchedEmbedding[0m
  
  [2X> WeaklyBranchedEmbedding( [0X[3Xg[0X[2X ) ____________________________________[0Xoperation
  [6XReturns:[0X  A embedding of [3Xg[0m in a weakly branched group.
  
  This  function  constructs  a  new  FR  group, on alphabet the square of the
  alphabet  of  [3Xg[0m.  It  is  generated  by  the  canonical copy of [3Xg[0m and by the
  tree-wreath  product  of  [3Xg[0m with an adding machine on the same alphabet as [3Xg[0m
  (see  [2XTreeWreathProduct[0m  ([14X7.1-9[0m)). The function returns a group homomorphism
  into this new FR group.
  
  The  main result of [SW03] is that the resulting group h is weakly branched.
  More   precisely,   h'   contains  |X|^2  copies  of  itself.  [10X  gap>  f  :=
  WeaklyBranchedEmbedding(BabyAleshinGroup);;  gap> Range(f); <recursive group
  over [ 1 .. 4 ] with 8 generators> [0m constructs a finitely generated branched
  group containing a free subgroup.
  
  
  [1X7.2 Operations for FR semigroups[0X
  
  [1X7.2-1 PermGroup[0m
  
  [2X> PermGroup( [0X[3Xg, l[0X[2X ) _______________________________________________[0Xoperation
  [2X> EpimorphismPermGroup( [0X[3Xg, l[0X[2X ) ____________________________________[0Xoperation
  [6XReturns:[0X  [An  epimorphism  to] the permutation group of [3Xg[0m's action on level
            [3Xl[0m.
  
  The first function returns a permutation group on d^l points, where d is the
  size  of  [3Xg[0m's  alphabet.  It has as many generators as [3Xg[0m, and represents the
  action of [3Xg[0m on the [3Xl[0mth layer of the tree.
  
  The second function returns a homomorphism from [3Xg[0m to this permutation group.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> g := FRGroup("a=(1,2)","b=<a,>"); Size(g);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4X8[0X
    [4Xgap> PermGroup(g,2);[0X
    [4XGroup([ (1,3)(2,4), (1,2) ])[0X
    [4Xgap> PermGroup(g,3);[0X
    [4XGroup([ (1,5)(2,6)(3,7)(4,8), (1,3)(2,4) ])[0X
    [4Xgap> List([1..6],i->LogInt(Size(PermGroup(GrigorchukGroup,i)),2));[0X
    [4X[ 1, 3, 7, 12, 22, 42 ][0X
    [4Xgap> g := FRGroup("t=<,t>(1,2)"); Size(g);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xinfinity[0X
    [4Xgap> pi := EpimorphismPermGroup(g,5);[0X
    [4XMappingByFunction( <self-similar group over [ 1 .. 2 ] with 1 generator,[0X
    [4Xof size infinity>, Group([ (1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,[0X
    [4X2,18,10,26,6,22,14,30,4,20,12,28,8,24,16,32) ]), function( w ) ... end )[0X
    [4Xgap> Order(g.1);[0X
    [4Xinfinity[0X
    [4Xgap> Order(g.1^pi);[0X
    [4X32[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-2 PcGroup[0m
  
  [2X> PcGroup( [0X[3Xg, l[0X[2X ) _________________________________________________[0Xoperation
  [2X> EpimorphismPcGroup( [0X[3Xg, l[0X[2X ) ______________________________________[0Xoperation
  [6XReturns:[0X  [An epimorphism to] the pc group of [3Xg[0m's action on level [3Xl[0m.
  
  The  first  function returns a polycyclic group representing the action of [3Xg[0m
  on   the   [3Xl[0mth  layer  of  the  tree.  It  converts  the  permutation  group
  [10XPermGroup(g,l)[0m to a Pc group, in which computations are often faster.
  
  The second function returns a homomorphism from [3Xg[0m to this pc group.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> g := PcGroup(GrigorchukGroup,7); time;[0X
    [4X<pc group with 5 generators>[0X
    [4X3370[0X
    [4Xgap> NormalClosure(g,Group(g.3)); time;[0X
    [4X<pc group with 79 generators>[0X
    [4X240[0X
    [4Xgap> g := PermGroup(GrigorchukGroup,7); time;[0X
    [4X<permutation group with 5 generators>[0X
    [4X3[0X
    [4Xgap> NormalClosure(g,Group(g.3)); time;[0X
    [4X<permutation group with 5 generators>[0X
    [4X5344[0X
    [4Xgap> g := FRGroup("t=<,t>(1,2)"); Size(g);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xinfinity[0X
    [4Xgap> pi := EpimorphismPcGroup(g,5);[0X
    [4XMappingByFunction( <self-similar group over [ 1 .. 2 ] with[0X
    [4X1 generator, of size infinity>, Group([ f1, f2, f3, f4, f5 ]), function( w ) ... end )[0X
    [4Xgap> Order(g.1);[0X
    [4Xinfinity[0X
    [4Xgap> Order(g.1^pi);[0X
    [4X32[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-3 TransMonoid[0m
  
  [2X> TransMonoid( [0X[3Xg, l[0X[2X ) _____________________________________________[0Xoperation
  [2X> TransformationMonoid( [0X[3Xg, l[0X[2X ) ____________________________________[0Xoperation
  [2X> EpimorphismTransMonoid( [0X[3Xg, l[0X[2X ) __________________________________[0Xoperation
  [2X> EpimorphismTransformationMonoid( [0X[3Xg, l[0X[2X ) _________________________[0Xoperation
  [6XReturns:[0X  [An  epimorphism  to]  the  transformation monoid of [3Xg[0m's action on
            level [3Xl[0m.
  
  The first function returns a transformation monoid on d^l points, where d is
  the size of [3Xg[0m's alphabet. It has as many generators as [3Xg[0m, and represents the
  action of [3Xg[0m on the [3Xl[0mth layer of the tree.
  
  The  second  function  returns  a homomorphism from [3Xg[0m to this transformation
  monoid.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> i4 := SCMonoid(MealyMachine([[3,3],[1,2],[3,3]],[(1,2),[1,1],()]));[0X
    [4X<self-similar monoid over [ 1 .. 2 ] with 3 generators>[0X
    [4Xgap> g := TransMonoid(i4,6);[0X
    [4X<monoid with 3 generators>[0X
    [4Xgap> List([1..6],i->Size(TransMonoid(i4,i)));[0X
    [4X[ 4, 14, 50, 170, 570, 1882 ][0X
    [4Xgap> Collected(List(g,RankOfTrans));[0X
    [4X[ [ 1, 64 ], [ 2, 1280 ], [ 4, 384 ], [ 8, 112 ], [ 16, 32 ], [ 32, 8 ], [ 64, 2 ] ][0X
    [4Xgap> pi := EpimorphismTransMonoid(i4,9);[0X
    [4XMappingByFunction( <self-similar monoid over [ 1 .. 2 ] with 3 generators>,[0X
    [4X<monoid with 3 generators>, function( w ) ... end )[0X
    [4Xgap> f := GeneratorsOfMonoid(i4){[1,2]};;[0X
    [4Xgap> for i in [1..10] do Add(f,f[i]*f[i+1]); od;[0X
    [4Xgap> Product(f{[3,5,7,9,11]})=f[11]*f[10];[0X
    [4Xfalse[0X
    [4Xgap> Product(f{[3,5,7,9,11]})^pi=(f[11]*f[10])^pi;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-4 TransSemigroup[0m
  
  [2X> TransSemigroup( [0X[3Xg, l[0X[2X ) __________________________________________[0Xoperation
  [2X> TransformationSemigroup( [0X[3Xg, l[0X[2X ) _________________________________[0Xoperation
  [2X> EpimorphismTransSemigroup( [0X[3Xg, l[0X[2X ) _______________________________[0Xoperation
  [2X> EpimorphismTransformationSemigroup( [0X[3Xg, l[0X[2X ) ______________________[0Xoperation
  [6XReturns:[0X  [An  epimorphism to] the transformation semigroup of [3Xg[0m's action on
            level [3Xl[0m.
  
  The first function returns a transformation semigroup on d^l points, where d
  is  the size of [3Xg[0m's alphabet. It has as many generators as [3Xg[0m, and represents
  the action of [3Xg[0m on the [3Xl[0mth layer of the tree.
  
  The  second  function  returns  a homomorphism from [3Xg[0m to this transformation
  semigroup.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> i2 := SCSemigroup(MealyMachine([[1,1],[2,1]],[(1,2),[2,2]]));[0X
    [4X<self-similar semigroup over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> g := TransSemigroup(i2,6);[0X
    [4X<semigroup with 2 generators>[0X
    [4Xgap> List([1..6],i->Size(TransSemigroup(i2,i)));[0X
    [4X[ 4, 14, 42, 114, 290, 706 ][0X
    [4Xgap> Collected(List(g,RankOfTrans));[0X
    [4X[ [ 1, 64 ], [ 2, 384 ], [ 4, 160 ], [ 8, 64 ], [ 16, 24 ], [ 32, 8 ], [ 64, 2 ] ][0X
    [4Xgap> f0 := GeneratorsOfSemigroup(i2)[1];; f1 := GeneratorsOfSemigroup(i2)[2];;[0X
    [4Xgap> pi := EpimorphismTransSemigroup(i2,10);[0X
    [4XMappingByFunction( <self-similar semigroup over [ 1 .. 2 ] with[0X
    [4X2 generators>, <semigroup with 2 generators>, function( w ) ... end )[0X
    [4Xgap> (f1*(f1*f0)^10)=((f1*f0)^10);[0X
    [4Xfalse[0X
    [4Xgap> (f1*(f1*f0)^10)^pi=((f1*f0)^10)^pi;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-5 EpimorphismGermGroup[0m
  
  [2X> EpimorphismGermGroup( [0X[3Xg, l[0X[2X ) ____________________________________[0Xoperation
  [2X> EpimorphismGermGroup( [0X[3Xg[0X[2X ) _______________________________________[0Xoperation
  [6XReturns:[0X  A homomorphism to a polycyclic group.
  
  This  function  returns  an  epimorphism to a polycyclic group, encoding the
  action  on  the  first  [3Xl[0m levels of the tree and on the germs below. If [3Xl[0m is
  omitted, it is assumed to be 0.
  
  Since  the elements of [3Xg[0m are finite automata, they map periodic sequences to
  periodic sequences. The action on the periods, and in the immediate vicinity
  of  them,  is called the [13Xgerm action[0m of [3Xg[0m. This function returns the natural
  homomorphism  from  [3Xg[0m  to  the  wreath  product  of this germ group with the
  quotient of [3Xg[0m acting on the [3Xl[0mth layer of the tree.
  
  The  germ  group,  by  default,  is  abelian. If it is finite, this function
  returns  a  homomorphism  to  a  Pc  group;  otherwise,  a homomorphism to a
  polycyclic group.
  
  The  [2XGrigorchukEvilTwin[0m  ([14X10.1-11[0m)  is,  for  now,  the  only example with a
  hand-coded, non-abelian germ group.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> EpimorphismGermGroup(GrigorchukGroup,0);[0X
    [4XMappingByFunction( GrigorchukGroup, <pc group of size 4 with 2 generators>,[0X
    [4X  function( g ) ... end )[0X
    [4Xgap> List(GeneratorsOfGroup(GrigorchukGroup),x->x^last);[0X
    [4X[ <identity> of ..., f1, f1*f2, f2 ][0X
    [4Xgap> StructureDescription(Image(last2));[0X
    [4X"C2 x C2"[0X
    [4Xgap> g := FRGroup("t=<,t>(1,2)","m=<,m^-1>(1,2)");;[0X
    [4Xgap> EpimorphismGermGroup(g,0);[0X
    [4XMappingByFunction( <state-closed, bounded group over [ 1, 2 ] with 2[0X
    [4X  generators>, Pcp-group with orders [ 0, 0 ], function( x ) ... end )[0X
    [4Xgap> EpimorphismGermGroup(g,1);; Range(last); Image(last2);[0X
    [4XPcp-group with orders [ 2, 0, 0, 0, 0 ][0X
    [4XPcp-group with orders [ 2, 0, 0, 0 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-6 StabilizerImage[0m
  
  [2X> StabilizerImage( [0X[3Xg, v[0X[2X ) _________________________________________[0Xoperation
  [6XReturns:[0X  The group of all states at [3Xv[0m of elements of [3Xg[0m.
  
  This  function  constructs a new FR group, containing all states at vertex [3Xv[0m
  (which can be an integer or a list) of elements of [3Xg[0m.
  
  The    result   is   [3Xg[0m   itself   precisely   if   [3Xg[0m   is   recurrent   (see
  [2XIsRecurrentFRSemigroup[0m ([14X7.2-10[0m)).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> G := FRGroup("t=<,t>(1,2)","u=<,u^-1>(1,2)","b=<u,t>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 3 generators>[0X
    [4Xgap> Stabilizer(G,1);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 5 generators>[0X
    [4Xgap> GeneratorsOfGroup(last);[0X
    [4X[ <2|u*t^-1>, <2|b>, <2|t^2>, <2|t*u>, <2|t*b*t^-1> ][0X
    [4Xgap> StabilizerImage(G,1);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 5 generators>[0X
    [4Xgap> GeneratorsOfGroup(last);[0X
    [4X[ <2|identity ...>, <2|u>, <2|t>, <2|u^-1>, <2|t> ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-7 LevelStabilizer[0m
  
  [2X> LevelStabilizer( [0X[3Xg, n[0X[2X ) _________________________________________[0Xoperation
  [6XReturns:[0X  The fixator of the [3Xn[0mth level of the tree.
  
  This  function  constructs the normal subgroup of [3Xg[0m that fixes the [3Xn[0mth level
  of the tree.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> G := FRGroup("t=<,t>(1,2)","a=(1,2)");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> LevelStabilizer(G,2);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 9 generators>[0X
    [4Xgap> Index(G,last);[0X
    [4X8[0X
    [4Xgap> IsNormal(G,last2);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-8 IsStateClosedFRSemigroup[0m
  
  [2X> IsStateClosedFRSemigroup( [0X[3Xg[0X[2X ) ____________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if all states of elements of [3Xg[0m belong to [3Xg[0m.
  
  This  function  tests  whether  [3Xg[0m is a [13Xstate-closed[0m group, i.e. a group such
  that all states of all elements of [3Xg[0m belong to [3Xg[0m.
  
  The  smallest  state-closed group containing [3Xg[0m is computed with [2XStateClosure[0m
  ([14X7.2-9[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> AssignGeneratorVariables(Dinfinity);[0X
    [4X#I  Assigned the global variables [ a, b ][0X
    [4Xgap> IsStateClosedFRSemigroup(Group(a));[0X
    [4X     IsStateClosedFRSemigroup(Group(b));[0X
    [4X     IsStateClosedFRSemigroup(Dinfinity);[0X
    [4Xtrue[0X
    [4Xfalse[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-9 StateClosure[0m
  
  [2X> StateClosure( [0X[3Xg[0X[2X ) _______________________________________________[0Xoperation
  [6XReturns:[0X  The smallest state-closed group containing [3Xg[0m.
  
  This  function  computes  the  smallest  group  containing all states of all
  elements  of  [3Xg[0m,  i.e.  the  smallest  group  containing  [3Xg[0m  and  for  which
  [2XIsStateClosedFRSemigroup[0m ([14X7.2-8[0m) returns [9Xtrue[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> AssignGeneratorVariables(Dinfinity);[0X
    [4X#I  Assigned the global variables [ a, b ][0X
    [4Xgap> StateStateClosure(Group(a))=Dinfinity; StateClosure(Group(b))=Dinfinity;[0X
    [4Xfalse[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-10 IsRecurrentFRSemigroup[0m
  
  [2X> IsRecurrentFRSemigroup( [0X[3Xg[0X[2X ) ______________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is a recurrent group.
  
  This  function  returns  [9Xtrue[0m  if [3Xg[0m is a [13Xrecurrent[0m group, i.e. if, for every
  vertex [10Xv[0m, all elements of [3Xg[0m appear as states at [10Xv[0m of elements fixing [10Xv[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> AssignGeneratorVariables(Dinfinity);[0X
    [4X#I  Assigned the global variables [ a, b ][0X
    [4Xgap> IsRecurrentFRSemigroup(Group(a)); IsRecurrentFRSemigroup(Group(b));[0X
    [4Xfalse[0X
    [4Xfalse[0X
    [4Xgap> IsRecurrentFRSemigroup(Dinfinity);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-11 IsLevelTransitive[0m
  
  [2X> IsLevelTransitive( [0X[3Xg[0X[2X ) ___________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is a level-transitive group.
  
  This  function  returns  [9Xtrue[0m  if [3Xg[0m is a [13Xlevel-transitive[0m group, i.e. if the
  action of [3Xg[0m is transitive at every level of the tree on which it acts.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> AssignGeneratorVariables(Dinfinity);[0X
    [4X#I  Assigned the global variables [ a, b ][0X
    [4Xgap> IsLevelTransitive(Group(a)); IsLevelTransitive(Group(b));[0X
    [4X     IsLevelTransitive(Dinfinity);[0X
    [4Xfalse[0X
    [4Xfalse[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-12 IsInfinitelyTransitive[0m
  
  [2X> IsInfinitelyTransitive( [0X[3Xg[0X[2X ) ______________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is infinitely transitive.
  
  This  function  returns  [9Xtrue[0m  if  [3Xg[0m is an [13Xinfinitely transitive[0m group. This
  means  that [3Xg[0m is the state-closed group of a bireversible Mealy machine (see
  [2XIsBireversible[0m  ([14X5.2-7[0m)),  that  this Mealy machine has an involution on its
  alphabet (see [2XAlphabetInvolution[0m ([14X5.2-6[0m)), and that the action of the set of
  reduced  words  of any given length over the alphabet (where "reduced" means
  no successive letters related by the involution) is transitive.
  
  This  notion  is  of  fundamental  importance for the study of lattices in a
  product of trees.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> !!![0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-13 IsFinitaryFRSemigroup[0m
  
  [2X> IsFinitaryFRSemigroup( [0X[3Xg[0X[2X ) _______________________________________[0Xproperty
  [2X> IsWeaklyFinitaryFRSemigroup( [0X[3Xg[0X[2X ) _________________________________[0Xproperty
  [2X> IsBoundedFRSemigroup( [0X[3Xg[0X[2X ) ________________________________________[0Xproperty
  [2X> IsPolynomialGrowthFRSemigroup( [0X[3Xg[0X[2X ) _______________________________[0Xproperty
  [2X> IsFiniteStateFRSemigroup( [0X[3Xg[0X[2X ) ____________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if all elements of [3Xg[0m have the required property.
  
  This  function returns [9Xtrue[0m if all elements of [3Xg[0m have the required property,
  as  FR elements; see [2XIsFinitaryFRElement[0m ([14X5.2-10[0m), [2XIsWeaklyFinitaryFRElement[0m
  ([14X5.2-23[0m),  [2XIsBoundedFRElement[0m ([14X5.2-12[0m), [2XIsPolynomialGrowthFRElement[0m ([14X5.2-13[0m)
  and [2XIsFiniteStateFRElement[0m ([14X4.2-11[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> G := FRGroup("a=(1,2)","b=<a,b>","c=<c,b>","d=<d,d>(1,2)");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 4 generators>[0X
    [4Xgap> L := [Group(G.1),Group(G.1,G.2),Group(G.1,G.2,G.3),G];;[0X
    [4Xgap> List(L,IsFinitaryFRSemigroup);[0X
    [4X[ true, false, false, false ][0X
    [4Xgap> List(L,IsBoundedFRSemigroup);[0X
    [4X[ true, true, false, false ][0X
    [4Xgap> List(L,IsPolynomialGrowthFRSemigroup);[0X
    [4X[ true, true, true, false ][0X
    [4Xgap> List(L,IsFiniteStateFRSemigroup);[0X
    [4X[ true, true, true, true ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-14 Degree[0m
  
  [2X> Degree( [0X[3Xg[0X[2X ) _____________________________________________________[0Xattribute
  [2X> DegreeOfFRSemigroup( [0X[3Xg[0X[2X ) ________________________________________[0Xattribute
  [2X> Depth( [0X[3Xg[0X[2X ) ______________________________________________________[0Xattribute
  [2X> DepthOfFRSemigroup( [0X[3Xg[0X[2X ) _________________________________________[0Xattribute
  [6XReturns:[0X  The maximal degree/depth of elements of [3Xg[0m.
  
  This  function returns the maximal degree/depth of elements of [3Xg[0m; see [2XDegree[0m
  ([14X5.2-9[0m) and [2XDepth[0m ([14X5.2-11[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> G := FRGroup("a=(1,2)","b=<a,b>","c=<c,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> Degree(Group(G.1)); Degree(Group(G.1,G.2)); Degree(G);[0X
    [4X0[0X
    [4X1[0X
    [4X2[0X
    [4Xgap> Depth(Group(G.1)); Depth(Group(G.1,G.2)); Depth(G);[0X
    [4X1[0X
    [4Xinfinity[0X
    [4Xinfinity[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-15 HasOpenSetConditionFRSemigroup[0m
  
  [2X> HasOpenSetConditionFRSemigroup( [0X[3Xe[0X[2X ) ______________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m has the open set condition.
  
  This function returns [9Xtrue[0m if all elements of [3Xg[0m have the [13Xopen set condition[0m,
  see [2XHasOpenSetConditionFRElement[0m ([14X5.2-25[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> HasOpenSetConditionFRSemigroup(GrigorchukGroup);[0X
    [4Xfalse[0X
    [4Xgap> HasOpenSetConditionFRSemigroup(BinaryAddingGroup);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-16 IsContracting[0m
  
  [2X> IsContracting( [0X[3Xg[0X[2X ) _______________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is a contracting semigroup.
  
  This  function  returns  [9Xtrue[0m if [3Xg[0m is a [13Xcontracting[0m semigroup, i.e. if there
  exists  a  finite  subset [10Xn[0m of [3Xg[0m such that the [2XLimitStates[0m ([14X4.2-10[0m) of every
  element of [3Xg[0m belong to [3Xn[0m.
  
  The minimal such [10Xn[0m can be computed with [2XNucleusOfFRSemigroup[0m ([14X7.2-17[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> IsContracting(Dinfinity);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-17 NucleusOfFRSemigroup[0m
  
  [2X> NucleusOfFRSemigroup( [0X[3Xg[0X[2X ) _______________________________________[0Xattribute
  [6XReturns:[0X  The nucleus of the contracting semigroup [3Xg[0m.
  
  This  function  returns the [13Xnucleus[0m of the contracting semigroup [3Xg[0m, i.e. the
  smallest  subset  [10Xn[0m of [3Xg[0m such that the [2XLimitStates[0m ([14X4.2-10[0m) of every element
  of [3Xg[0m belong to [10Xn[0m.
  
  This  function  returns  [9Xfail[0m if no such [10Xn[0m exists. Usually, it loops forever
  without  being  able  to decide whether [10Xn[0m is finite or infinite. It succeeds
  precisely when [10XIsContracting(g)[0m succeeds.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> NucleusOfFRSemigroup(Dinfinity);[0X
    [4X[ <2|identity ...>, <2|b>, <2|a> ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-18 NucleusMachine[0m
  
  [2X> NucleusMachine( [0X[3Xg[0X[2X ) _____________________________________________[0Xattribute
  [6XReturns:[0X  The nucleus machine of the contracting semigroup [3Xg[0m.
  
  This  function  returns  the  [13Xnucleus[0m  of  the  contracting semigroup [3Xg[0m, see
  [2XNucleusOfFRSemigroup[0m ([14X7.2-17[0m), in the form of a Mealy machine.
  
  Since  all states of the nucleus are elements of the nucleus, the transition
  and  output  function  may  be  restricted  to the nucleus, defining a Mealy
  machine.  Finitely generated recurrent groups are generated by their nucleus
  machine.
  
  This  function  returns  [9Xfail[0m if no such [10Xn[0m exists. Usually, it loops forever
  without  being  able  to decide whether [10Xn[0m is finite or infinite. It succeeds
  precisely when [10XIsContracting(g)[0m succeeds.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>");[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> M := NucleusMachine(Dinfinity);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> Display(M);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | a,1   a,2[0X
    [4X b | c,1   b,2[0X
    [4X c | a,2   a,1[0X
    [4X---+-----+-----+[0X
    [4Xgap> Dinfinity=SCGroup(M);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-19 BranchingSubgroup[0m
  
  [2X> BranchingSubgroup( [0X[3Xg[0X[2X ) __________________________________________[0Xoperation
  [6XReturns:[0X  A branching subgroup of [3Xg[0m.
  
  This function searches for a subgroup k of [3Xg[0m, such that k contains k x cdots
  x k.
  
  It  searches  for  elements  in  larger  and  larger  balls  in  [3Xg[0m,  calling
  [2XFindBranchingSubgroup[0m ([14X7.2-20[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> K := BranchingSubgroup(GrigorchukGroup);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 9 generators>[0X
    [4Xgap> IsBranchingSubgroup(K);[0X
    [4Xtrue[0X
    [4Xgap> IsBranched(GrigorchukGroup);[0X
    [4Xtrue[0X
    [4Xgap> Index(GrigorchukGroup,K);[0X
    [4X16[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-20 FindBranchingSubgroup[0m
  
  [2X> FindBranchingSubgroup( [0X[3Xg, l, r[0X[2X ) ________________________________[0Xoperation
  [6XReturns:[0X  A branching subgroup of [3Xg[0m.
  
  This function searches for a subgroup k of [3Xg[0m, such that k contains k x cdots
  x k.
  
  The  second  argument  [3Xl[0m  specifies the level at which branching must occur;
  i.e.  asks  to search for a subgroup k such that [3Xg[0m contains k^d^l where d is
  the size of the alphabet. If [10Xl=infinity[0m, the resulting k will be a regularly
  branched subgroup.
  
  The  third argument [3Xr[0m specifies the radius to explore in [3Xg[0m and all branching
  subgroups  at  levels  smaller  than  [3Xl[0m for elements with all level-1 states
  trivial except one.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> FindBranchingSubgroup(GrigorchukGroup,1,4);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 8 generators>[0X
    [4Xgap> Index(GrigorchukGroup,last);[0X
    [4X8[0X
    [4Xgap> FindBranchingSubgroup(GrigorchukGroup,2,4);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 6 generators>[0X
    [4Xgap> Index(GrigorchukGroup,last);[0X
    [4X16[0X
    [4Xgap> FindBranchingSubgroup(GrigorchukGroup,3,4);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 9 generators>[0X
    [4Xgap> Index(GrigorchukGroup,last);[0X
    [4X16[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-21 IsBranched[0m
  
  [2X> IsBranched( [0X[3Xg[0X[2X ) __________________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m has a finite-index branching subgroup.
  
  This  function  returns [9Xtrue[0m if [3Xg[0m has a finite-index subgroup k, such that k
  contains k x cdots x k.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X<Example><![CDATA[[0X
    [4Xgap> K := BranchingSubgroup(GrigorchukGroup);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 9 generators>[0X
    [4Xgap> IsBranchingSubgroup(K);[0X
    [4Xtrue[0X
    [4Xgap> IsBranched(GrigorchukGroup);[0X
    [4Xtrue[0X
    [4Xgap> Index(GrigorchukGroup,K);[0X
    [4X16[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-22 IsBranchingSubgroup[0m
  
  [2X> IsBranchingSubgroup( [0X[3Xk[0X[2X ) _________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xk[0m is a branching subgroup.
  
  This function returns [9Xtrue[0m if [3Xk[0m contains k x cdots x k.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> K := BranchingSubgroup(GrigorchukGroup);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 9 generators>[0X
    [4Xgap> IsBranchingSubgroup(K);[0X
    [4Xtrue[0X
    [4Xgap> IsBranched(GrigorchukGroup);[0X
    [4Xtrue[0X
    [4Xgap> Index(GrigorchukGroup,K);[0X
    [4X16[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-23 TopVertexTransformations[0m
  
  [2X> TopVertexTransformations( [0X[3Xg[0X[2X ) ___________________________________[0Xattribute
  [6XReturns:[0X  The transformations at the root under the action of [3Xg[0m.
  
  This   function   returns  the  permutation  group,  or  the  transformation
  group/semigroup/monoid,  of  all  activities  of all elements under the root
  vertex of the tree on which [3Xg[0m acts.
  
  It    is    a    synonym   for   [10XPermGroup(g,1)[0m   or   [10XTransMonoid(g,1)[0m   or
  [10XTransSemigroup(g,1)[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> TopVertexTransformations(GrigorchukGroup);[0X
    [4XGroup([ (), (1,2) ])[0X
    [4Xgap> IsTransitive(last,AlphabetOfFRSemigroup(GrigorchukGroup));[0X
    [4Xtrue[0X
    [4Xgap> TopVertexTransformations(FullSCMonoid([1..3]));[0X
    [4X<monoid with 3 generators>[0X
    [4Xgap> Size(last);[0X
    [4X27[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-24 VertexTransformations[0m
  
  [2X> VertexTransformations( [0X[3Xg[0X[2X ) ______________________________________[0Xattribute
  [6XReturns:[0X  The transformations at all vertices under the action of [3Xg[0m.
  
  This   function   returns  the  permutation  group,  or  the  transformation
  group/monoid/semigroup, of all activities of all elements under all vertices
  of the tree on which [3Xg[0m acts.
  
  This  is  the  smallest  group/monoid/semigroup [10XP[0m such that [3Xg[0m is a subset of
  [10XFullSCGroup(AlphabetOfFRSemigroup(g),P)[0m                                   or
  [10XFullSCMonoid(AlphabetOfFRSemigroup(g),P)[0m                                  or
  [10XFullSCSemigroup(AlphabetOfFRSemigroup(g),P)[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> VertexTransformations(GuptaSidkiGroup);[0X
    [4XGroup([ (), (1,2,3), (1,3,2) ])[0X
    [4Xgap> TopVertexTransformations(Group(GuptaSidkiGroup.2));[0X
    [4XGroup(())[0X
    [4Xgap> VertexTransformations(Group(GuptaSidkiGroup.2));[0X
    [4XGroup([ (), (1,2,3), (1,3,2) ])[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-25 VirtualEndomorphism[0m
  
  [2X> VirtualEndomorphism( [0X[3Xg, v[0X[2X ) _____________________________________[0Xoperation
  [6XReturns:[0X  The virtual endomorphism at vertex [3Xv[0m.
  
  This function returns the homomorphism from [10XStabilizer(g,v)[0m to [3Xg[0m, defined by
  computing   the   state   at  [3Xv[0m.  It  is  loosely  speaking  an  inverse  of
  [2XFRGroupByVirtualEndomorphism[0m ([14X7.1-8[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> A := SCGroup(MealyMachine([[2,1],[2,2]],[(1,2),()]));[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xgap> f := VirtualEndomorphism(A,1);[0X
    [4XMappingByFunction( <self-similar group over [ 1 .. 2 ] with[0X
    [4X1 generator>, <self-similar group over [ 1 .. 2 ] with[0X
    [4X1 generator>, function( g ) ... end )[0X
    [4Xgap> ((A.1)^2)^f=A.1;[0X
    [4Xtrue[0X
    [4Xgap> B := FRGroupByVirtualEndomorphism(f);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 1 generator>[0X
    [4Xgap> A=B;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-26 EpimorphismFromFpGroup[0m
  
  [2X> EpimorphismFromFpGroup( [0X[3Xg, l[0X[2X ) __________________________________[0Xoperation
  [6XReturns:[0X  An epimorphism from a finitely presented group to [3Xg[0m.
  
  For  some  examples  of self-similar groups, a recursive presentation of the
  group  is coded into [5XFR[0m, and an approximate presentation is returned by this
  command,  together with a map onto the group [3Xg[0m. The argument [3Xl[0m roughly means
  the  number  of  iterates of an endomorphism were applied to a finite set of
  relators.  An  isomorphic group would be obtained by setting [10Xl=infinity[0m; for
  that purpose, see [2XIsomorphismSubgroupFpGroup[0m ([14X7.2-27[0m).
  
  Preimages  can  be  computed, with [10XPreImagesRepresentative[0m. They are usually
  reasonably  short  words,  though  by  no  means guaranteed to be of minimal
  length.
  
  Currently  this  command  is  implemented  through  an  ad  hoc  method  for
  [2XBinaryKneadingGroup[0m      ([14X10.1-2[0m),      [2XGrigorchukGroup[0m     ([14X10.1-9[0m)     and
  [2XGrigorchukOverGroup[0m ([14X10.1-10[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> f := EpimorphismFromFpGroup(GrigorchukGroup,1);[0X
    [4XMappingByFunction( <fp group on the generators[0X
    [4X[ a, b, c, d ]>, GrigorchukGroup, function( w ) ... end )[0X
    [4X4 gap> RelatorsOfFpGroup(Source(f));[0X
    [4X[ a^2, b^2, c^2, d^2, b*c*d, a*d*a*d*a*d*a*d, a^-1*c*a*c*a^-1*c*a*c*a^-1*c*a*c*a^[0X
    [4X    -1*c*a*c, a^-1*c^-1*a*b*a^-1*c*a*b*a^-1*c^-1*a*b*a^-1*c*a*b*a^-1*c^-1*a*b*a^-1*[0X
    [4X    c*a*b*a^-1*c^-1*a*b*a^-1*c*a*b, a*d*a*c*a*c*a*d*a*c*a*c*a*d*a*c*a*c*a*d*a*c*a*c,[0X
    [4X  a^-1*c*a*c*a^-1*c*a*b*a^-1*c*a*b*a^-1*c*a*c*a^-1*c*a*b*a^-1*c*a*b*a^-1*c*a*c*a^[0X
    [4X    -1*c*a*b*a^-1*c*a*b*a^-1*c*a*c*a^-1*c*a*b*a^-1*c*a*b ][0X
    [4Xgap> PreImagesRepresentative(f,Comm(GrigorchukGroup.1,GrigorchukGroup.2));[0X
    [4Xa*c*a*d*a*d*a*c[0X
    [4Xgap> Source(f).4^f=GrigorchukGroup.4;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.2-27 IsomorphismSubgroupFpGroup[0m
  
  [2X> IsomorphismSubgroupFpGroup( [0X[3Xg[0X[2X ) _________________________________[0Xoperation
  [2X> AsSubgroupFpGroup( [0X[3Xg[0X[2X ) __________________________________________[0Xoperation
  [2X> IsomorphismLpGroup( [0X[3Xg[0X[2X ) _________________________________________[0Xoperation
  [2X> AsLpGroup( [0X[3Xg[0X[2X ) __________________________________________________[0Xoperation
  [6XReturns:[0X  An  isomorphism to a subgroup of a finitely presented group, or an
            L-presented group.
  
  For  some  examples  of self-similar groups, a recursive presentation of the
  group  is coded into [5XFR[0m, and is returned by this command. The group [3Xg[0m itself
  sits  as  a  subgroup  of  a  finitely presented group. To obtain a finitely
  presented   group  approximating  [3Xg[0m,  see  [2XEpimorphismFromFpGroup[0m  ([14X7.2-26[0m).
  PreImages  can  also  be  computed; it is usually better to use [10XPreImageElm[0m,
  since the word problem may not be solvable by [5XGAP[0m in the f.p. group.
  
  Currently  this  command  is  implemented  through  an  ad  hoc  method  for
  [2XBinaryKneadingGroup[0m  ([14X10.1-2[0m), [2XGrigorchukGroup[0m ([14X10.1-9[0m), [2XGrigorchukOverGroup[0m
  ([14X10.1-10[0m),    generalized   [2XGuptaSidkiGroups[0m   ([14X10.1-17[0m)   and   generalized
  [2XFabrykowskiGuptaGroups[0m ([14X10.1-20[0m).
  
  The second form returns an isomorphism to an L-presented group (see [Bar03b]
  and [EH07]. It requires the package [5XNQL[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> f := IsomorphismSubgroupFpGroup(BasilicaGroup);[0X
    [4XMappingByFunction( BasilicaGroup, Group([ a^-1, a*t^-1*a^-1*t*a^-1[0X
    [4X ]), function( g ) ... end, function( w ) ... end )[0X
    [4Xgap> Range(f);[0X
    [4XGroup([ a^-1, a*t^-1*a^-1*t*a^-1 ])[0X
    [4Xgap> c := Comm(BasilicaGroup.1,BasilicaGroup.2);[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 9 states, initial state 1>[0X
    [4Xgap> c^f;[0X
    [4Xt^-2*a*t^-1*a*t*a^-2*t*a*t^-2*a*t^-1*a*t*a^-1*t*a*t^-1*a*t^-2*[0X
    [4Xa^-1*t*a*t^-1*a*t^-1*a^-1*t*a^-1*t^5*a*t^-1*a^-1*t*a^-1[0X
    [4Xgap> PreImageElm(f,last);[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 9 states, initial state 1>[0X
    [4Xgap> last=c;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X7.3 Properties for infinite groups[0X
  
  [1X7.3-1 IsTorsionGroup[0m
  
  [2X> IsTorsionGroup( [0X[3Xg[0X[2X ) ______________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is a torsion group.
  
  This function returns [9Xtrue[0m if [3Xg[0m is a torsion group, i.e. if every element in
  [3Xg[0m has finite order; and [9Xfalse[0m if [3Xg[0m contains an element of infinite order.
  
  This method is quite rudimentary, and is not guaranteed to terminate. At the
  minimum,  [3Xg[0m should be a group in which [10XOrder()[0m succeeds in computing element
  orders; e.g. a bounded group in Mealy machine format.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>":IsMealyElement);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> IsTorsionGroup(Dinfinity);[0X
    [4Xfalse[0X
    [4Xgap> IsTorsionGroup(GrigorchukGroup); IsTorsionGroup(GuptaSidkiGroup);[0X
    [4Xtrue[0X
    [4Xtrue[0X
    [4Xgap> IsTorsionGroup(FabrykowskiGuptaGroup);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.3-2 IsTorsionFreeGroup[0m
  
  [2X> IsTorsionFreeGroup( [0X[3Xg[0X[2X ) __________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is a torsion-free group.
  
  This  function returns [9Xtrue[0m if [3Xg[0m is a torsion-free group, i.e. if no element
  in [3Xg[0m has finite order; and [9Xfalse[0m if [3Xg[0m contains an element of finite order.
  
  This method is quite rudimentary, and is not guaranteed to terminate. At the
  minimum,  [3Xg[0m should be a group in which [10XOrder()[0m succeeds in computing element
  orders; e.g. a bounded group in Mealy machine format.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Dinfinity := FRGroup("a=(1,2)","b=<a,b>":IsMealyElement);[0X
    [4X<self-similar group over [ 1 .. 2 ] with 2 generators>[0X
    [4Xgap> IsTorsionFreeGroup(Dinfinity);[0X
    [4Xfalse[0X
    [4Xgap> IsTorsionFreeGroup(BasilicaGroup);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.3-3 IsAmenableGroup[0m
  
  [2X> IsAmenableGroup( [0X[3Xg[0X[2X ) _____________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m is an amenable group.
  
  Amenable  groups,  introduced  by  von Neumann [vN29], are those groups that
  admit a finitely additive, translation-invariant measure.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsAmenableGroup(FreeGroup(2));[0X
    [4Xfalse[0X
    [4Xgap> IsAmenableGroup(BasilicaGroup);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.3-4 IsVirtuallySimpleGroup[0m
  
  [2X> IsVirtuallySimpleGroup( [0X[3Xg[0X[2X ) ______________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xg[0m admits a finite-index simple subgroup.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.3-5 IsResiduallyFinite[0m
  
  [2X> IsResiduallyFinite( [0X[3Xobj[0X[2X ) ________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xobj[0m is residually finite.
  
  A  object is [13Xresidually finite[0m if it can be approximated arbitrarily well by
  finite quotients; i.e. if for every g<> hin X there exists a finite quotient
  pi:X-> Q such that g^pi<> h^pi.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsResiduallyFinite(FreeGroup(2));[0X
    [4Xtrue[0X
    [4Xgap> IsResiduallyFinite(BasilicaGroup);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.3-6 IsSQUniversal[0m
  
  [2X> IsSQUniversal( [0X[3Xobj[0X[2X ) _____________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xobj[0m is SQ-universal.
  
  An object [3Xobj[0m is [13XSQ-universal[0m if every countable object of the same category
  as [3Xobj[0m is a subobject of a quotient of [3Xobj[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsSQUniversal(FreeGroup(2));[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X7.3-7 IsJustInfinite[0m
  
  [2X> IsJustInfinite( [0X[3Xobj[0X[2X ) ____________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xobj[0m is just-infinite.
  
  An object [3Xobj[0m is [13Xjust-infinite[0m if [3Xobj[0m is infinite, but every quotient of [3Xobj[0m
  is finite.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsJustInfinite(FreeGroup(2));[0X
    [4Xfalse[0X
    [4Xgap> IsJustInfinite(FreeGroup(1));[0X
    [4Xtrue[0X
    [4Xgap> IsJustInfinite(GrigorchukGroup); time[0X
    [4Xtrue[0X
    [4X8284[0X
  [4X------------------------------------------------------------------[0X
  
