  
  [1X5 Mealy machines and elements[0X
  
  [13XMealy  machines[0m form a special class of FR machines. They have as stateset a
  finite  set,  as  opposed  to  a  free  group/monoid/semigroup. All commands
  available  for  FR  machines  are also available for Mealy machines, but the
  latter have added functionality.
  
  There  are  currently  two  types  of Mealy machines; one has as stateset an
  interval  of  integers of the form [10X[1..m][0m and as alphabet a set of integers;
  the  other  has  an  arbitrary  domain  as  stateset and alphabet. Almost no
  functionality  is  implemented  for the latter type, but there is a function
  converting it to the former type (see [2XAsMealyMachine[0m ([14X5.2-18[0m)).
  
  The  internal  representation  of a Mealy machine of the first kind is quite
  different  from  that  of  FR  machines.  The  alphabet  is assumed to be an
  interval  [10X[1..n][0m,  and the stateset is assumed to be an interval [10X[1..m][0m. The
  transitions  are  stored  as a m x n matrix, and the outputs are stored in a
  list of length m, consisting of permutations or transformations.
  
  Mealy  machines  have  additional  properties, in particular they can act on
  periodic  sequences  (see  [2XPeriodicList[0m ([14X12.1-6[0m)). For example, the periodic
  sequence  [10XPeriodicList([1],[1,2])[0m  describes the infinite ray [10X[1,1,2,1,2,..][0m
  in the tree. In principle, Mealy machines could act on sequences accepted by
  an automaton, although this is not yet implemented.
  
  Mealy  elements  are  Mealy  machines  with an initial state. For efficiency
  reasons,  Mealy  elements are always minimized, and their states are ordered
  in  a  canonical  top-down, left-to-right order of traversal of the tree. In
  particular,  their  initial  state  is  always  1.  In  this implementation,
  multiplication  of  Mealy elements is slower than multiplication of group FR
  elements,  while  comparison  of Mealy elements is faster than comparison of
  group  FR elements. In practise, it is better to work with Mealy elements as
  often as possible.
  
  Products  of Mealy machines behave in the same way as products of general FR
  machines,  see  [14X3.2[0m. The only difference is that now the sum and products of
  statesets are distinct; the sum of statesets being their disjoint union, and
  their product being their cartesian product.
  
  
  [1X5.1 Creators for [10XMealyMachine[1Xs and [10XMealyElement[1Xs[0X
  
  [1X5.1-1 MealyMachine[0m
  
  [2X> MealyMachine( [0X[3X[alphabet, ]transitions, output[0X[2X ) _________________[0Xoperation
  [2X> MealyElement( [0X[3X[alphabet, ]transitions, output, init[0X[2X ) ___________[0Xoperation
  [6XReturns:[0X  A new Mealy machine/element.
  
  This function constructs a new Mealy machine or element, of integer type.
  
  [3Xtransitions[0m  is  a  list of lists; [10Xtransitions[s][x][0m is an integer, which is
  the state reached by the machine when started in state [3Xs[0m and fed input [3Xx[0m.
  
  [3Xoutput[0m  is a list; at position [3Xs[0m it contains a permutation, a transformation
  describing  the  activity of state [3Xs[0m, or a list describing the images of the
  transformation.
  
  [3Xalphabet[0m  is an optional domain given as first argument; When present, it is
  assumed  to  be  a  finite  domain,  mapped  bijectively  to  [10X[1..n][0m  by its
  enumerator. The indices "[10X[s][0m" above are then understood with respect to this
  enumeration.
  
  [3Xinit[0m  is  an  integer  describing  the initial state the newly created Mealy
  element should be in.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> b := MealyMachine([[3,2],[3,1],[3,3]],[(1,2),(),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> Display(b);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | c,2   b,1[0X
    [4X b | c,1   a,2[0X
    [4X c | c,1   c,2[0X
    [4X---+-----+-----+[0X
    [4Xgap> n := MealyMachine(Domain([11,12]),[[3,2],[3,1],[3,3]],[(1,2),(),()]);[0X
    [4X<Mealy machine on alphabet [ 11, 12 ] with states [ 1 .. 3 ]>[0X
    [4Xgap> Display(n);[0X
    [4X   |  11     12[0X
    [4X---+------+------+[0X
    [4X a | c,12   b,11[0X
    [4X b | c,11   a,12[0X
    [4X c | c,11   c,12[0X
    [4X---+------+------+[0X
  [4X------------------------------------------------------------------[0X
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> tau := MealyElement([[2,1],[2,2]],[(1,2),()],1);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states, initial state 1>[0X
    [4Xgap> Display(tau);[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
    [4Xgap> [1,1]^tau; [[1]]^tau; [[2]]^tau;[0X
    [4X[ 2, 1 ][0X
    [4X[ 2, [ 1 ] ][0X
    [4X[ [ 1 ] ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.1-2 MealyMachine[0m
  
  [2X> MealyMachine( [0X[3Xstateset, alphabet, transitions, output[0X[2X ) _________[0Xoperation
  [2X> MealyElement( [0X[3Xstateset, alphabet, transitions, output, init[0X[2X ) ___[0Xoperation
  [6XReturns:[0X  A new Mealy machine/element.
  
  This function constructs a new Mealy machine or element, of domain type.
  
  [3Xstateset[0m and [3Xalphabet[0m are domains; they are not necessarily finite.
  
  [3Xtransitions[0m  is  a  function;  it takes as arguments a state and an alphabet
  letter, and returns a state.
  
  [3Xoutput[0m  is  either  a function, accepting as arguments a state and a letter,
  and returning a letter.
  
  [3Xinit[0m  is  an  element  of  [3Xstateset[0m  describing  the initial state the newly
  created Mealy element should be in.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> g := Group((1,2));; n := MealyMachine(g,g,\*,\*);[0X
    [4X<Mealy machine on alphabet [ (), (1,2) ] with states Group( [ (1,2) ] )>[0X
    [4Xgap> [(1,2),()]^FRElement(n,());[0X
    [4X[ (1,2), (1,2) ][0X
    [4Xgap> a := MealyElement(g,g,\*,\*,());[0X
    [4X<Mealy machine on alphabet [ (), (1,2) ] with states Group([0X
    [4X[ (1,2) ] ), initial state ()>[0X
    [4Xgap> [(1,2),()]^a;[0X
    [4X[ (1,2), (1,2) ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.1-3 MealyMachineNC[0m
  
  [2X> MealyMachineNC( [0X[3Xfam, transitions, output[0X[2X ) ______________________[0Xoperation
  [2X> MealyElementNC( [0X[3Xfam, transitions, output, init[0X[2X ) ________________[0Xoperation
  [6XReturns:[0X  A new Mealy machine/element.
  
  This function constructs a new Mealy machine or element, of integer type. No
  tests  are  performed  to  check  that  the  arguments contain values within
  bounds,  or  even of the right type (beyond the simple checking performed by
  [5XGAP[0m's method selection algorithms). In particular, Mealy elements are always
  assumed to be minimized, but these functions leave this task to the user.
  
  [3Xfam[0m is the family to which the newly created Mealy machine will belong.
  
  [3Xtransitions[0m  is  a  list of lists; [10Xtransitions[s][x][0m is an integer, which is
  the state reached by the machine when started in state [3Xs[0m and fed input [3Xx[0m.
  
  [3Xoutput[0m   is   a  list;  at  position  [3Xs[0m  it  contains  a  permutation  or  a
  transformation describing the activity of state [3Xs[0m.
  
  [3Xinit[0m  is  an  integer  describing  the initial state the newly created Mealy
  element should be in.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> taum := MealyMachine([[2,1],[2,2]],[(1,2),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states>[0X
    [4Xgap> tauminv := MealyMachineNC(FamilyObj(taum),[[1,2],[2,2]],[(1,2),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states>[0X
    [4Xgap> tau := MealyElement([[2,1],[2,2]],[(1,2),()],1);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states, initial state 1>[0X
    [4Xgap> tauinv := MealyElementNC(FamilyObj(n),[[1,2],[2,2]],[(1,2),()],1);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states, initial state 1>[0X
    [4Xgap> tau=FRElement(taum,1); tauinv=FRElement(tauminv,1);[0X
    [4Xtrue[0X
    [4Xtrue[0X
    [4Xgap> IsOne(tau*tauinv);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.1-4 AllMealyMachines[0m
  
  [2X> AllMealyMachines( [0X[3Xm, n[, filters][0X[2X ) ______________________________[0Xfunction
  [6XReturns:[0X  A list of all Mealy machines with specified properties.
  
  This function constructs all mealy with alphabet [10X[1..m][0m, stateset [10X[1..n][0m and
  specified properties.
  
  These  properties  are  specified  as additional arguments. They can include
  [2XIsInvertible[0m  ([14X11.2-14[0m),  [2XIsReversible[0m  ([14X5.2-4[0m), [2XIsBireversible[0m ([14X5.2-7[0m), and
  [2XIsMinimized[0m ([14X5.2-5[0m) to specify that the machines should have that property.
  
  A  group/monoid/semigroup  [10Xp[0m  may also be passed as argument; this specifies
  the   allowable   vertex  transformations  of  the  machines.  The  property
  [10XIsTransitive[0m  requires  that  the state-closed group/monoid/semigroup of the
  machine act transitively on its alphabet, and [10XIsSurjective[0m requires that its
  [2XVertexTransformationsFRMachine[0m ([14X5.2-15[0m) be precisely equal to [10Xp[0m.
  
  The  argument  [10XEquivalenceClasses[0m  returns  one  isomorphism  class of Mealy
  machine, under the permutations of the stateset and alphabet.
  
  The  following  example  constructs  the  two  Mealy machines [2XAleshinMachine[0m
  ([14X10.1-14[0m) and [2XBabyAleshinMachine[0m ([14X10.1-15[0m):
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> l := AllMealyMachines(2,3,IsBireversible,IsSurjective,EquivalenceClasses);;[0X
    [4Xgap> Length(l);[0X
    [4X20[0X
    [4Xgap> Filtered(l,x->VertexTransformationsFRMachine(DualMachine(x))=SymmetricGroup(3)[0X
    [4X>                     and Size(StateSet(Minimized(x)))=3);[0X
    [4X[ <Mealy machine on alphabet [ 1, 2 ] with 3 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 3 states> ][0X
    [4X gap> Display(last[1]);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | a,1   b,2[0X
    [4X b | c,2   c,1[0X
    [4X c | b,1   a,2[0X
    [4X---+-----+-----+[0X
    [4Xgap> Display(last[2]);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | a,2   b,1[0X
    [4X b | c,1   c,2[0X
    [4X c | b,2   a,1[0X
    [4X---+-----+-----+[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.2 Operations and Attributes for [10XMealyMachine[1Xs and [10XMealyElement[1Xs[0X
  
  [1X5.2-1 Draw[0m
  
  [2X> Draw( [0X[3Xm[, filename][0X[2X ) ___________________________________________[0Xoperation
  
  This function creates a graph description of the Mealy machine/element [3Xm[0m. If
  a  second  argument  [3Xfilename[0m is present, the graph is saved, in [9Xdot[0m format,
  under  that  filename;  otherwise  it  is  converted to Postscript using the
  program  [9Xdot[0m  from  the  [5Xgraphviz[0m  package, and is displayed in a separate X
  window using the program [5Xdisplay[0m. This works on UNIX systems.
  
  A  circle  is displayed for every state of [3Xm[0m, and there is an edge for every
  transition  in  [3Xm[0m. It has label of the form x/y, where x is the input symbol
  and y is the corresponding output. Edges are coloured according to the input
  symbol,  in  the  order  "red",  "blue",  "green", "gray", "yellow", "cyan",
  "orange",  "purple".  If [3Xm[0m has an initial state, it is indicated as a doubly
  circled state.
  
  If  [3Xm[0m  is a FR machine, [10XDraw[0m first attempts to convert it to a Mealy machine
  (see [2XAsMealyMachine[0m ([14X5.2-18[0m)).
  
  It  is  assumed,  but  not  checked,  that [5Xgraphviz[0m and [5Xdisplay[0m are properly
  installed on the system.
  
  [1X5.2-2 Minimized[0m
  
  [2X> Minimized( [0X[3Xm[0X[2X ) __________________________________________________[0Xoperation
  [6XReturns:[0X  A minimized machine equivalent to [3Xm[0m.
  
  This function contructs the minimized Mealy machine [10Xr[0m corresponding to [3Xm[0m, by
  identifying   isomorphic   states;   and,  if  [3Xm[0m  is  initial,  by  removing
  inaccessible states.
  
  If  [3Xm[0m  is  initial,  the  minimized  automaton  is  such that its states are
  numbered  first by distance to the initial state, and then lexicographically
  by  input  letter.  (in  particular,  the  initial  state  is 1). This makes
  comparison of minimized automata efficient.
  
  Furthermore,  [10XCorrespondence(r)[0m  is a list describing, for each (accessible)
  state of [3Xm[0m, its corresponding state in [10Xr[0m; see [2XCorrespondence[0m ([14X3.5-11[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> GrigorchukMachine := MealyMachine([[2,3],[4,4],[2,5],[4,4],[4,1]],[0X
    [4X                                       [(),(1,2),(),(),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 5 states>[0X
    [4Xgap> g2 := GrigorchukMachine^2;[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 25 states>[0X
    [4Xgap> Minimized(g2);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 11 states, minimized>[0X
    [4Xgap> Correspondence(last);[0X
    [4X[ 2, 1, 4, 11, 9, 1, 2, 5, 7, 6, 4, 3, 2, 9, 11, 11, 10, 9, 2, 4, 9, 8, 11, 4, 2 ][0X
    [4Xgap> e := FRElement(g2,11);[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 25 states, initial state 11>[0X
    [4Xgap> Minimized(e);[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 5 states, initial state 1, minimized>[0X
    [4Xgap> Correspondence(last);[0X
    [4X[ 3, 2, 1, 4, 5, 2, 3,,,, 1,, 3, 5, 4, 4,, 5, 3, 1, 5,, 4, 1, 3 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-3 DualMachine[0m
  
  [2X> DualMachine( [0X[3Xm[0X[2X ) ________________________________________________[0Xoperation
  [6XReturns:[0X  The dual Mealy machine of [3Xm[0m.
  
  This  function  constructs  the  [13Xdual[0m  machine  of  [3Xm[0m, i.e. the machine with
  stateset  the  alphabet of [3Xm[0m, with alphabet the stateset of [3Xm[0m, and similarly
  with transitions and output switched.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> b := MealyMachine([[3,2],[3,1],[3,3]],[(1,2),(),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> d := DualMachine(b)^4);[0X
    [4X<Mealy machine on alphabet [ 1, 2, 3 ] with 16 states>[0X
    [4Xgap> Draw(d); # action on 2^4 points[0X
    [4Xgap> DualMachine(d);[0X
    [4X<Mealy machine on alphabet [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16[0X
    [4X ] with 3 states>[0X
    [4Xgap> Output(last,1)=Activity(FRElement(b,1),4);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-4 IsReversible[0m
  
  [2X> IsReversible( [0X[3Xm[0X[2X ) ________________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xm[0m is a reversible Mealy machine.
  
  This  function  tests  whether [3Xm[0m is [13Xreversible[0m, i.e. whether the [2XDualMachine[0m
  ([14X5.2-3[0m) of [3Xm[0m is invertible. See [MNS00] for more details.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsReversible(MealyMachine([[1,2],[2,2]],[(1,2),()]));[0X
    [4Xfalse[0X
    [4Xgap> IsReversible(MealyMachine([[1,2],[2,1]],[(),(1,2)]));[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-5 IsMinimized[0m
  
  [2X> IsMinimized( [0X[3Xm[0X[2X ) _________________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xm[0m is a minimized Mealy machine.
  
  This  function tests whether [3Xm[0m is [13Xminimized[0m, i.e. whether nono of its states
  can be removed or coalesced. All Mealy elements are automatically minimized.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> AllMealyMachines(2, 2, IsBireversible,EquivalenceClasses);[0X
    [4X[ <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states>,[0X
    [4X  <Mealy machine on alphabet [ 1, 2 ] with 2 states> ][0X
    [4Xgap> List(last,IsMinimized);[0X
    [4X[ false, true, false, false, false, false, true, false ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-6 AlphabetInvolution[0m
  
  [2X> AlphabetInvolution( [0X[3Xm[0X[2X ) _________________________________________[0Xattribute
  [6XReturns:[0X  A list giving, for each alphabet letter, its inverse.
  
  If  [3Xm[0m is a bireversible machine, it may happen that the stateset of the dual
  of  [3Xm[0m  (see  [2XDualMachine[0m  ([14X5.2-3[0m))  is closed under taking inverses. If this
  happens,  then this list records the mapping from an alphabet letter of [3Xm[0m to
  its inverse.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := GammaPQMachine(3,5);; AlphabetOfFRObject(m);[0X
    [4X[ 1 .. 6 ][0X
    [4Xgap> IsBireversible(m); AlphabetInvolution(GammaPQMachine(3,5));[0X
    [4Xtrue[0X
    [4X[ 6, 5, 4, 3, 2, 1 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-7 IsBireversible[0m
  
  [2X> IsBireversible( [0X[3Xm[0X[2X ) ______________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xm[0m is a bireversible Mealy machine.
  
  This  function  tests  whether  [3Xm[0m  is  [13Xbireversible[0m,  i.e. whether all eight
  machines   obtained  from  [3Xm[0m  using  [2XDualMachine[0m  ([14X5.2-3[0m)  and  [10XInverse[0m  are
  well-defined. See [MNS00] for more details.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsBireversible(MealyMachine([[1,2],[2,1]],[(),(1,2)]));[0X
    [4Xfalse[0X
    [4Xgap> IsBireversible(MealyMachine([[1,1],[2,2]],[(),(1,2)]));[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-8 StateGrowth[0m
  
  [2X> StateGrowth( [0X[3Xm[, x][0X[2X ) ___________________________________________[0Xoperation
  [6XReturns:[0X  The state growth of the Mealy machine or element [3Xm[0m.
  
  This  function computes, as a rational function, the power series in [3Xx[0m whose
  coefficient  of  degree  n is the number of non-trivial states at level n of
  the tree.
  
  If [3Xx[0m is absent, it is assumed to be [10XIndeterminate(Rationals)[0m.
  
  If  [3Xm[0m  is  a  Mealy  machine,  this function is computed with respect to all
  possible starting states. If [3Xm[0m is a Mealy element, this function is computed
  with respect to the initial state of [3Xm[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> b := MealyMachine([[3,2],[3,1],[3,3]],[(1,2),(),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> StateGrowth(b,Indeterminate(Rationals));[0X
    [4X(2)/(-x_1+1)[0X
    [4Xgap> StateGrowth(FRElement(b,1),Indeterminate(Rationals));[0X
    [4X(1)/(-x_1+1)[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-9 Degree[0m
  
  [2X> Degree( [0X[3Xm[0X[2X ) _____________________________________________________[0Xoperation
  [2X> DegreeOfFRMachine( [0X[3Xm[0X[2X ) __________________________________________[0Xoperation
  [2X> DegreeOfFRElement( [0X[3Xm[0X[2X ) __________________________________________[0Xoperation
  [6XReturns:[0X  The growth degree of the Mealy machine or element [3Xm[0m.
  
  This  function computes the order of the pole at x=1 of [10XStateGrowth(m,x)[0m, in
  case  its  denominator  is  a  product  of cyclotomics; and returns [9Xinfinity[0m
  otherwise.
  
  This attribute of Mealy machines was studied inter alia in [Sid00].
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := MealyMachine([[2,1],[3,2],[3,3]],[(),(1,2),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> StateGrowth(m,Indeterminate(Rationals));[0X
    [4X(-x_1+2)/(x_1^2-2*x_1+1)[0X
    [4Xgap> List(StateSet(m),i->Degree(FRElement(m,i)));[0X
    [4X[ 2, 1, -1 ][0X
    [4Xgap> a := MealyMachine(Group((1,2)),Group((1,2)),\*,\*);[0X
    [4X<Mealy machine on alphabet [ (), (1,2) ] with states Group( [ (1,2) ] )>[0X
    [4Xgap> Degree(a);[0X
    [4Xinfinity[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-10 IsFinitaryFRElement[0m
  
  [2X> IsFinitaryFRElement( [0X[3Xe[0X[2X ) _________________________________________[0Xproperty
  [2X> IsFinitaryFRMachine( [0X[3Xe[0X[2X ) _________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xe[0m is a finitary element.
  
  This function tests whether [3Xe[0m is a finitary element. These are by definition
  the elements of growth degree at most 0.
  
  When  applied  to  a  Mealy  machine, it returns [9Xtrue[0m if all states of [3Xe[0m are
  finitary.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := GuptaSidkiMachines(3);; Display(m);[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
    [4Xgap> Filtered(StateSet(m),i->IsFinitaryFRElement(FRElement(m,i)));[0X
    [4X[ 1, 2, 3 ][0X
    [4Xgap> IsFinitaryFRElement(m);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-11 Depth[0m
  
  [2X> Depth( [0X[3Xm[0X[2X ) ______________________________________________________[0Xattribute
  [2X> DepthOfFRMachine( [0X[3Xm[0X[2X ) ___________________________________________[0Xattribute
  [2X> DepthOfFRElement( [0X[3Xm[0X[2X ) ___________________________________________[0Xattribute
  [6XReturns:[0X  The depth of the finitary Mealy machine or element [3Xm[0m.
  
  This  function  computes the maximal level at which the [3Xm[0m has an non-trivial
  state.  In  particular the identity has depth 0, and FR elements acting only
  at  the root vertex have depth 1. The value [9Xinfinity[0m is returned if [3Xm[0m is not
  finitary (see [2XIsFinitaryFRElement[0m ([14X5.2-10[0m)).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := MealyMachine([[2,1],[3,3],[4,4],[4,4]],[(),(),(1,2),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 4 states>[0X
    [4Xgap> DepthOfFRMachine(m);[0X
    [4Xinfinity[0X
    [4Xgap> List(StateSet(m),i->DepthOfFRElement(FRElement(m,i)));[0X
    [4X[ infinity, 2, 1, 0 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-12 IsBoundedFRElement[0m
  
  [2X> IsBoundedFRElement( [0X[3Xe[0X[2X ) __________________________________________[0Xproperty
  [2X> IsBoundedFRMachine( [0X[3Xe[0X[2X ) __________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xe[0m is a finitary element.
  
  This  function tests whether [3Xe[0m is a bounded element. These are by definition
  the elements of growth degree at most 1.
  
  When  applied  to  a  Mealy  machine, it returns [9Xtrue[0m if all states of [3Xe[0m are
  bounded.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := GuptaSidkiMachines(3);; Display(m);[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
    [4Xgap> Filtered(StateSet(m),i->IsBoundedFRElement(FRElement(m,i)));[0X
    [4X[ 1, 2, 3, 4 ][0X
    [4Xgap> IsBoundedFRMachine(m);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-13 IsPolynomialGrowthFRElement[0m
  
  [2X> IsPolynomialGrowthFRElement( [0X[3Xe[0X[2X ) _________________________________[0Xproperty
  [2X> IsPolynomialGrowthFRMachine( [0X[3Xe[0X[2X ) _________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xe[0m is an element of polynomial growth.
  
  This  function  tests  whether  [3Xe[0m  is  a  polynomial  element.  These are by
  definition the elements of polynomial growth degree.
  
  When  applied  to a Mealy machine, it returns [9Xtrue[0m if all states of [3Xe[0m are of
  polynomial growth.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := GuptaSidkiMachines(3);; Display(m);[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
    [4Xgap> Filtered(StateSet(m),i->IsPolynomialGrowthFRElement(FRElement(m,i)));[0X
    [4X[ 1, 2, 3, 4 ][0X
    [4Xgap> IsPolynomialGrowthFRMachine(m);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-14 Signatures[0m
  
  [2X> Signatures( [0X[3Xe[0X[2X ) _________________________________________________[0Xoperation
  [6XReturns:[0X  A list describing the product of the activities on each level.
  
  This function computes the product of the activities of [3Xe[0m on each level, and
  returns a periodic list describing it (see [2XPeriodicList[0m ([14X12.1-6[0m)).
  
  The  entries  [10Xpi[0m are permutations, and their values are meaningful only when
  projected in the abelianization of [10XVertexTransformationsFRElement(e)[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Signatures(GrigorchukGroup.1);[0X
    [4X[ (1,2), / () ][0X
    [4Xgap> Signatures(GrigorchukGroup.2);[0X
    [4X[/ (), (1,2), (1,2) ][0X
    [4Xgap> last[50];[0X
    [4X(1,2)[0X
    [4Xgap> Signatures(AddingMachine(3)[2]);[0X
    [4X[/ (1,2,3) ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-15 VertexTransformationsFRMachine[0m
  
  [2X> VertexTransformationsFRMachine( [0X[3Xm[0X[2X ) _____________________________[0Xoperation
  [2X> VertexTransformationsFRElement( [0X[3Xe[0X[2X ) _____________________________[0Xoperation
  [6XReturns:[0X  The group/monoid generated by all vertex transformations of states
            of [3Xm[0m.
  
  The  first  function  computes the finite permutation group / transformation
  monoid generated by all outputs of states of [3Xm[0m.
  
  The        second        command       is       a       short-hand       for
  [10XVertexTransformationsFRMachine(UnderlyingFRMachine(e))[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := MealyMachine([[1,3,2],[3,2,1],[2,1,3]],[(2,3),(1,3),(1,2)]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> VertexTransformationsFRMachine(m);[0X
    [4XGroup([ (2,3), (1,3), (1,2) ])[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-16 FixedRay[0m
  
  [2X> FixedRay( [0X[3Xe[0X[2X ) ___________________________________________________[0Xoperation
  [6XReturns:[0X  The lexicographically first ray fixed by [3Xe[0m.
  
  This function computes the lexicographically first infinite sequence that is
  fixed  by  the  FR  element  [3Xe[0m,  and  returns  it  as  a  periodic list (see
  [2XPeriodicList[0m ([14X12.1-6[0m)). It returns [9Xfail[0m if no such ray exists.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := MealyMachine([[1,3,2],[3,2,1],[2,1,3]],[(2,3),(1,3),(1,2)]);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> FixedRay(FRElement(m,1));[0X
    [4X[/ 1 ][0X
    [4Xgap> last^FRElement(m,1);[0X
    [4X[/ 1 ][0X
    [4Xgap> FixedRay(FRElement(m,[1,2]));[0X
    [4Xfail[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-17 IsLevelTransitive[0m
  
  [2X> IsLevelTransitive( [0X[3Xe[0X[2X ) ___________________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xe[0m acts transitively on each level of the tree.
  
  This  function  tests whether [3Xe[0m acts transitively on each level of the tree.
  It is implemented only if [10XVertexTransformationsFRElement(e)[0m is abelian.
  
  This  function  is  used  as  a simple test to detect whether an element has
  infinite  order:  if  [3Xe[0m  has  a  fixed  vertex v such that the [10XState(e,v)[0m is
  level-transitive, then [3Xe[0m has infinite order.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := AddingMachine(3);; Display(m);[0X
    [4X   |  1     2     3[0X
    [4X---+-----+-----+-----+[0X
    [4X a | a,1   a,2   a,3[0X
    [4X b | a,2   a,3   b,1[0X
    [4X---+-----+-----+-----+[0X
    [4XInitial state:  b[0X
    [4Xgap> IsLevelTransitive(m);[0X
    [4Xtrue[0X
    [4Xgap> IsLevelTransitive(Product(UnderlyingFRMachine(GrigorchukOverGroup){[2..5]}));[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-18 AsMealyMachine[0m
  
  [2X> AsMealyMachine( [0X[3Xm[0X[2X ) _____________________________________________[0Xattribute
  [6XReturns:[0X  A Mealy machine isomorphic to [3Xm[0m.
  
  This function constructs a Mealy machine [10Xr[0m, which is as close as possible to
  the  FR machine [3Xm[0m. Furthermore, [10XCorrespondence(r)[0m is a list identifying, for
  every generator of the stateset of [3Xm[0m, a corresponding state in the new Mealy
  machine; see [2XCorrespondence[0m ([14X3.5-11[0m).
  
  [3Xm[0m  may  be a group/monoid/semigroup FR machine, or a Mealy machine; in which
  case the result is returned unchanged.
  
  In  particular, [10XFRElement(m,s)[0m and [10XFRElement(AsMealyMachine(m),s)[0m return the
  same tree automorphism, for any FR machine [10Xm[0m and any state [10Xs[0m.
  
  This function is not guaranteed to return; if [3Xm[0m does not have finite states,
  then it will loop forever.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> n := FRMachine(["tau","mu"],[[[],[1]],[[],[-2]]],[(1,2),(1,2)]);[0X
    [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ tau, mu ] )>[0X
    [4Xgap> Display(n);[0X
    [4X     |     1         2[0X
    [4X-----+--------+---------+[0X
    [4X tau | <id>,2     tau,1[0X
    [4X  mu | <id>,2   mu^-1,1[0X
    [4X-----+--------+---------+[0X
    [4Xgap> AsMealyMachine(n);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 4 states>[0X
    [4Xgap> Display(last);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | c,2   a,1[0X
    [4X b | c,2   d,1[0X
    [4X c | c,1   c,2[0X
    [4X d | b,2   c,1[0X
    [4X---+-----+-----+[0X
    [4Xgap> Correspondence(last);[0X
    [4X[ 1, 2 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-19 AsMealyMachine[0m
  
  [2X> AsMealyMachine( [0X[3Xl[0X[2X ) _____________________________________________[0Xattribute
  [6XReturns:[0X  A Mealy machine constructed out of the FR elements in [3Xl[0m.
  
  This  function  constructs a Mealy machine [10Xr[0m, with states [3Xl[0m (which must be a
  state-closed  set).  Its  outputs  are  the outputs of its elements, and its
  transitions   are   the   transitions   of   its  elements;  in  particular,
  [10XFRElement(r,i)[0m is equal to [10Xl[i][0m as an FR element.
  
  [10XCorrespondence(r)[0m records the argument [3Xl[0m.
  
  This function returns [9Xfail[0m if [3Xl[0m is not state-closed.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap>  mu := FRElement([[[],[-1]]],[(1,2)],[1]);[0X
    [4X<2|f1>[0X
    [4Xgap>[0X
    [4Xgap> States(mu);[0X
    [4X[ <2|f1>, <2|identity ...>, <2|f1^-1> ][0X
    [4Xgap> AsMealyMachine(last);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states>[0X
    [4Xgap> Display(last);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | b,2   c,1[0X
    [4X b | b,1   b,2[0X
    [4X c | a,2   b,1[0X
    [4X---+-----+-----+[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-20 AsMealyElement[0m
  
  [2X> AsMealyElement( [0X[3Xm[0X[2X ) _____________________________________________[0Xattribute
  [6XReturns:[0X  A Mealy element isomorphic to [3Xm[0m.
  
  This  function  constructs  a  Mealy  element,  which  induces the same tree
  automorphism as the FR element [3Xm[0m.
  
  [3Xm[0m  may  be a group/monoid/semigroup FR element, or a Mealy element; in which
  case the result is returned unchanged.
  
  This function is not guaranteed to return; if [3Xm[0m does not have finite states,
  then it will loop forever.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> mu := FRElement([[[],[-1]]],[(1,2)],[1]);[0X
    [4X<2|f1>[0X
    [4Xgap> AsMealyElement(mu);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 3 states, initial state 1>[0X
    [4Xgap> [[2,1]]^last;[0X
    [4X[ [ 1, 2 ] ][0X
    [4Xgap> [2,1,2,1]^mu;[0X
    [4X[ 1, 2, 1, 2 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-21 AsIntMealyMachine[0m
  
  [2X> AsIntMealyMachine( [0X[3Xm[0X[2X ) __________________________________________[0Xattribute
  [2X> AsIntMealyElement( [0X[3Xm[0X[2X ) __________________________________________[0Xattribute
  [6XReturns:[0X  A Mealy machine in integer format, isomorphic to [3Xm[0m.
  
  This function constructs a Mealy machine [10Xr[0m, which has similar behaviour as [3Xm[0m
  while  having  stateset  [10X[1..n][0m for some natural [10Xn[0m. Most [5XFR[0m commands operate
  efficiently only on Mealy machines of this type.
  
  This function is not guaranteed to return; if [3Xm[0m does not have finite states,
  then it will loop forever.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> g := Group((1,2));; n := MealyMachine(g,g,\*,\*);[0X
    [4X<Mealy machine on alphabet [ (), (1,2) ] with states Group( [ (1,2) ] )>[0X
    [4Xgap> Display(n);[0X
    [4X       |      ()            (1,2)[0X
    [4X-------+-------------+-------------+[0X
    [4X    () |    (),()      (1,2),(1,2)[0X
    [4X (1,2) | (1,2),(1,2)      (),()[0X
    [4X-------+-------------+-------------+[0X
    [4Xgap> AsIntMealyMachine(n);[0X
    [4X<Mealy machine on alphabet [ 1, 2 ] with 2 states>[0X
    [4Xgap> Display(last);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | a,1   b,2[0X
    [4X b | b,2   a,1[0X
    [4X---+-----+-----+[0X
    [4Xgap> Correspondence(last);[0X
    [4X[ 1, 2 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-22 TopElement[0m
  
  [2X> TopElement( [0X[3Xp[, n][0X[2X ) ____________________________________________[0Xattribute
  [6XReturns:[0X  A  Mealy  machine in integer format, acting on the first symbol of
            sequences.
  
  This  function  constructs  a  Mealy machine [10Xr[0m, which acts as [3Xp[0m on the first
  letter  of sequences and fixes the other letters. The argument [3Xn[0m is the size
  of the alphabet of [10Xr[0m; if it is ommitted, then it is assumed to be the degree
  of  the  transformation  [3Xp[0m, or the largest moved point of the permutation or
  trans [3Xp[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> a := TopElement((1,2));[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 2 states>[0X
    [4Xgap> last=GrigorchukGroup.1;[0X
    [4Xtrue[0X
    [4Xgap> a := TopElement((1,2),3);[0X
    [4X<Mealy element on alphabet [ 1, 2, 3 ] with 2 states>[0X
    [4Xgap> last in GuptaSidkiGroup;[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-23 ConfinalityClasses[0m
  
  [2X> ConfinalityClasses( [0X[3Xe[0X[2X ) _________________________________________[0Xattribute
  [2X> IsWeaklyFinitaryFRElement( [0X[3Xe[0X[2X ) __________________________________[0Xattribute
  [6XReturns:[0X  A list describing the non-trivial confinality classes of [3Xe[0m.
  
  If  [3Xe[0m  is  a  bounded  element  (see [2XIsBoundedFRElement[0m ([14X5.2-12[0m)), there are
  finitely  many  infinite  sequences  that have confinality class larger that
  one;  i.e.  ultimately periodic sequences that are mapped by [3Xe[0m to a sequence
  with  different  period. This function returns a list of equivalence classes
  of periodic lists, see [2XPeriodicList[0m ([14X12.1-6[0m), which are related under [3Xe[0m.
  
  By  definition,  an  element  is  [13Xweakly finitary[0m if it has no non-singleton
  confinality classes.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> g := FRGroup("t=<,,t>(2,3)","u=<u,,>(1,2)","v=<u,t,>");;[0X
    [4Xgap> ConfinalityClasses(g.1);[0X
    [4X[ {PeriodicList([  ],[ 2 ])} ][0X
    [4Xgap> List(GeneratorsOfGroup(g),x->Elements(ConfinalityClasses(x)[1]));[0X
    [4X[ [ [/ 2 ], [/ 3 ] ],[0X
    [4X  [ [/ 1 ], [/ 2 ] ],[0X
    [4X  [ [/ 1 ], [/ 2 ], [/ 3 ] ] ][0X
    [4Xgap> IsWeaklyFinitaryFRElement(BinaryAddingElement);[0X
    [4Xfalse[0X
    [4Xgap> IsWeaklyFinitaryFRElement(GuptaSidkiGroup.2);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-24 Germs[0m
  
  [2X> Germs( [0X[3Xe[0X[2X ) ______________________________________________________[0Xattribute
  [2X> NormOfBoundedFRElement( [0X[3Xe[0X[2X ) _____________________________________[0Xattribute
  [6XReturns:[0X  The germs of the bounded element [3Xe[0m.
  
  The  [13Xgerms[0m  of  a  bounded element are the finitely many ultimately periodic
  sequences on which the state of [3Xe[0m does not vanish. This function returns the
  germs  of  [3Xe[0m,  as  a  list of pairs; the first entry is a ray described as a
  periodic  sequence  of  integers (see [2XPeriodicList[0m ([14X12.1-6[0m)), and the second
  entry is the periodic sequence of states that appear along that ray.
  
  The [13Xnorm[0m of a bounded element is the length of its list of germs.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Germs(BinaryAddingElement);[0X
    [4X[ [ [/ 2 ], [/ 1 ] ] ][0X
    [4Xgap> Germs(GrigorchukGroup.1);[0X
    [4X[  ][0X
    [4Xgap> Germs(GrigorchukGroup.2);[0X
    [4X[ [ [/ 2 ], [/ 1, 3, 5 ] ] ][0X
    [4Xgap> Display(GrigorchukGroup.2);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | b,1   c,2[0X
    [4X b | d,2   d,1[0X
    [4X c | b,1   e,2[0X
    [4X d | d,1   d,2[0X
    [4X e | d,1   a,2[0X
    [4X---+-----+-----+[0X
    [4XInitial state: a[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-25 HasOpenSetConditionFRElement[0m
  
  [2X> HasOpenSetConditionFRElement( [0X[3Xe[0X[2X ) ________________________________[0Xproperty
  [6XReturns:[0X  [9Xtrue[0m if [3Xe[0m has the open set condition.
  
  An  FR element [3Xe[0m has the [13Xopen set condition[0m if for every infinite ray in the
  tree which is fixed by [3Xe[0m, there is an open set around that ray which is also
  fixed  by  [3Xe[0m.  This  function tests for [3Xe[0m to have the open set condition. It
  currently is implemented only for bounded elements.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> HasOpenSetConditionFRElement(GrigorchukGroup.1);[0X
    [4Xtrue[0X
    [4Xgap> HasOpenSetConditionFRElement(GrigorchukGroup.2);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-26 LimitMachine[0m
  
  [2X> LimitMachine( [0X[3Xm[0X[2X ) _______________________________________________[0Xattribute
  [6XReturns:[0X  The submachine of [3Xm[0m on all recurrent states.
  
  This  command creates a new Mealy machine, with stateset the limit states of
  [3Xm[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := MealyMachine([[2,2,3],[2,3,3],[3,3,3]],[(),(),(1,2,3)]);[0X
    [4X<Mealy machine on alphabet [ 1 .. 3 ] with 3 states>[0X
    [4Xgap> Display(m);[0X
    [4X   |  1     2     3[0X
    [4X---+-----+-----+-----+[0X
    [4X a | b,1   b,2   c,3[0X
    [4X b | b,1   c,2   c,3[0X
    [4X c | c,2   c,3   c,1[0X
    [4X---+-----+-----+-----+[0X
    [4Xgap> LimitStates(m);[0X
    [4X[ <Mealy element on alphabet [ 1 .. 3 ] with 2 states>,[0X
    [4X  <Mealy element on alphabet [ 1 .. 3 ] with 1 state> ][0X
    [4Xgap> LimitMachine(m);[0X
    [4X<Mealy machine on alphabet [ 1 .. 3 ] with 2 states>[0X
    [4Xgap> Display(last);[0X
    [4X   |  1     2     3[0X
    [4X---+-----+-----+-----+[0X
    [4X a | a,1   b,2   b,3[0X
    [4X b | b,2   b,3   b,1[0X
    [4X---+-----+-----+-----+[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-27 NucleusMachine[0m
  
  [2X> NucleusMachine( [0X[3Xm[0X[2X ) _____________________________________________[0Xattribute
  [6XReturns:[0X  The nucleus of [3Xm[0m.
  
  This   command   creates   a  new  Mealy  machine  [10Xn[0m,  which  is  such  that
  [10XLimitMachine(m*n)[0m  is  isomorphic  to  [10Xn[0m,  after  minimisation.  It  is also
  isomorphic  to  the  [2XNucleusMachine[0m  ([14X7.2-18[0m)  of  the  state closure of the
  [2XSCSemigroup[0m  ([14X7.1-2[0m)  of  [3Xm[0m.  (Note  that  the ordering of the states in the
  resulting  machine  is not necessarily the same as in [3Xm[0m; however, if [3Xm[0m and [10Xn[0m
  are isomorphic, then this command returns [3Xm[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> m := MealyMachine([[2,1,1],[2,2,2]],[(1,2,3),()]);[0X
    [4X<Mealy machine on alphabet [ 1, 2, 3 ] with 2 states>[0X
    [4Xgap> Display(m);[0X
    [4X   |  1     2     3[0X
    [4X---+-----+-----+-----+[0X
    [4X a | b,2   a,3   a,1[0X
    [4X b | b,1   b,2   b,3[0X
    [4X---+-----+-----+-----+[0X
    [4Xgap> NucleusMachine(m);[0X
    [4X<Mealy machine on alphabet [ 1, 2, 3 ] with 3 states>[0X
    [4Xgap> Display(last);[0X
    [4X   |  1     2     3[0X
    [4X---+-----+-----+-----+[0X
    [4X a | a,1   a,2   a,3[0X
    [4X b | c,3   b,1   c,2[0X
    [4X c | a,2   c,3   c,1[0X
    [4X---+-----+-----+-----+[0X
  [4X------------------------------------------------------------------[0X
  
  [1X5.2-28 GuessMealyElement[0m
  
  [2X> GuessMealyElement( [0X[3Xp, d, n[0X[2X ) ____________________________________[0Xoperation
  [6XReturns:[0X  A Mealy element that probably has the same activity as [3Xp[0m.
  
  This  function  receives a permutation or transformation [3Xp[0m, a degree [3Xd[0m and a
  level  [3Xn[0m,  and attempts to find a Mealy element on the alphabet [10X[1..d][0m whose
  activity on level [3Xn[0m is [3Xp[0m.
  
  This  function  returns  [10Xfail[0m if it thinks that the given level is not large
  enough  to  make  a  reasonable  guess.  In  all  cases, the function is not
  guaranteed to return the correct Mealy machine.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> GuessMealyElement(Activity(GrigorchukGroup.2,6),2,6);[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 5 states>[0X
    [4Xgap> last=GrigorchukGroup.2;[0X
    [4Xtrue[0X
    [4Xgap> GuessMealyElement(Activity(GrigorchukGroup.2,5),2,5);[0X
    [4Xfail[0X
    [4Xgap> ComposeElement([GrigorchukGroup.2,One(GrigorchukGroup)],());[0X
    [4X<Mealy element on alphabet [ 1, 2 ] with 6 states>[0X
    [4Xgap> last=GuessMealyElement(Activity(GrigorchukGroup.2,6),2,7);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
