  
  [1m[4m[31mC. Inverse automata and subgroups of the free group[0m
  
  Inverse  automata  with a single initial/accepting state are in a one to one
  correspondence  with finitely generated subgroups of the free group over the
  alphabet  of  the automaton. See [MSW01], [KM02] for details, as well as for
  concepts such as [22m[36mflower automaton[0m and [22m[36mStallings foldings[0m.
  
  
  [1m[4m[31mC.1 From subgroups to inverse automata[0m
  
  A  finitely  generated  subgroup of a finitely generated free group is given
  through  a  list whose first element is the number of generators of the free
  group and the remaining elements are the generators of the subgroup. The set
  of generators of the free group of rank n consists on the n first letters of
  the  set  a,b,c,d,e,f,g.  In  particular, free groups of rank greater than 8
  must  not  be  considered. A formal inverse of a generator is represented by
  the corresponding capital letter.
  
  A  generator  of  the  subgroup  may be given through a string of letters or
  through a list of positive integers as should be clear from the example that
  follows.
  
  For example, [22m[32m[2,"abA","bbabAB"][0m stands for the subgroup of the free group of
  rank  2  on the generators aba^-1 and bbaba^-1b^-1. The same subgroup may be
  given  as  [22m[32m[2,[1,2,3],[2,2,1,2,3,4]][0m.  The  number n+j represents the formal
  inverse   of   the   generator  represented  by  j.  One  can  go  from  one
  representation to another, using the following functions.
  
  [1m[4m[31mC.1-1 GeneratorsToListRepresentation[0m
  
  [1m[34m> GeneratorsToListRepresentation( [0m[22m[34mL[0m[1m[34m ) ______________________________[0mfunction
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L:=[2,"abA","bbabAB"];;[0m
    [22m[35mgap> GeneratorsToListRepresentation(L);[0m
    [22m[35m[ 2, [ 1, 2, 3 ], [ 2, 2, 1, 2, 3, 4 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31mC.1-2 ListToGeneratorsRepresentation[0m
  
  [1m[34m> ListToGeneratorsRepresentation( [0m[22m[34mK[0m[1m[34m ) ______________________________[0mfunction
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> K:=[2,[1,2,3],[2,2,1,2,3,4]];;[0m
    [22m[35mgap> ListToGeneratorsRepresentation(K);[0m
    [22m[35m[ 2, "abA", "bbabAB" ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31mC.1-3 FlowerAutomaton[0m
  
  [1m[34m> FlowerAutomaton( [0m[22m[34mL[0m[1m[34m ) _____________________________________________[0mfunction
  
  The  argument  [22m[32mL[0m  is  a  subgroup of the free group given through any of the
  representations described above. Returns the flower automaton.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> W:=[2,"bbbAB","abAbA"];;[0m
    [22m[35mgap> A:=FlowerAutomaton(W);[0m
    [22m[35m< non deterministic automaton on 2 letters with 9 states >[0m
    [22m[35mgap> Display(A);[0m
    [22m[35m   |  1          2       3       4    5       6       7    8       9[0m
    [22m[35m---------------------------------------------------------------------[0m
    [22m[35m a | [ 6, 9 ]                        [ 4 ]                [ 7 ][0m
    [22m[35m b | [ 2, 5 ]   [ 3 ]   [ 4 ]                [ 7 ]        [ 9 ][0m
    [22m[35mInitial state:   [ 1 ][0m
    [22m[35mAccepting state: [ 1 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31mC.1-4 FoldFlowerAutomaton[0m
  
  [1m[34m> FoldFlowerAutomaton( [0m[22m[34mA[0m[1m[34m ) _________________________________________[0mfunction
  
  Makes  identifications  on  the flower automaton [22m[32mA[0m. In the literature, these
  identifications are called Stallings foldings.
  
  (This  function  may  have  [22m[32mtrue[0m  as  a second argument. WARNING: the second
  argument should only be used when facilities to draw automata are available.
  In that case, one may visualize the identifications that are taking place.)
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> B := FoldFlowerAutomaton(A);[0m
    [22m[35m< deterministic automaton on 2 letters with 7 states >[0m
    [22m[35mgap> Display(B);[0m
    [22m[35m   |  1  2  3  4  5  6  7[0m
    [22m[35m--------------------------[0m
    [22m[35m a |  5  4              6[0m
    [22m[35m b |  2  3  4     6     5[0m
    [22m[35mInitial state:   [ 1 ][0m
    [22m[35mAccepting state: [ 1 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31mC.1-5 SubgroupGenToInvAut[0m
  
  [1m[34m> SubgroupGenToInvAut( [0m[22m[34mL[0m[1m[34m ) _________________________________________[0mfunction
  
  Returns the inverse automaton corresponding to the subgroup given by [22m[34mL[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L:=[2,"bbbAB","AbAbA"];;[0m
    [22m[35mgap> SubgroupGenToInvAut(L);[0m
    [22m[35m< deterministic automaton on 2 letters with 8 states >[0m
    [22m[35mgap> Display(last);[0m
    [22m[35m   |  1  2  3  4  5  6  7  8[0m
    [22m[35m-----------------------------[0m
    [22m[35m a |  8  4        1     6[0m
    [22m[35m b |  2  3  4     6     8[0m
    [22m[35mInitial state:   [ 1 ][0m
    [22m[35mAccepting state: [ 1 ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31mC.2 From inverse automata to subgroups[0m
  
  Given  an  inverse  automaton with a single initial/accepting state, one can
  find  a  set  of  generators  for the subgroup represented by the automaton.
  Moreover,  using  a  geodesic  tree,  one  can find a Nielsen reduced set of
  generators [KM02].
  
  [1m[4m[31mC.2-1 GeodesicTreeOfInverseAutomaton[0m
  
  [1m[34m> GeodesicTreeOfInverseAutomaton( [0m[22m[34mA[0m[1m[34m ) ______________________________[0mfunction
  
  Returns  a subautomaton of [22m[34mA[0mwhose underlying graph is a geodesic tree of the
  underlying graph of the inverse automaton [22m[32mA[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> A:=Automaton("det",4,2,[ [ 3, 4, 0, 0 ], [ 2, 3, 4, 0 ] ],[ 1 ],[ 1 ]);;[0m
    [22m[35mgap> G := GeodesicTreeOfInverseAutomaton(A);[0m
    [22m[35m< deterministic automaton on 2 letters with 4 states >[0m
    [22m[35mgap> Display(G);[0m
    [22m[35m   |  1  2  3  4[0m
    [22m[35m-----------------[0m
    [22m[35m a |  3[0m
    [22m[35m b |  2     4[0m
    [22m[35mInitial state:   [ 1 ][0m
    [22m[35mAccepting state: [ 1 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31mC.2-2 InverseAutomatonToGenerators[0m
  
  [1m[34m> InverseAutomatonToGenerators( [0m[22m[34mA[0m[1m[34m ) ________________________________[0mfunction
  
  Returns  a  set of generators (given trough the representation above) of the
  subgroup of the free group corresponding to the automaton [22m[32mA[0m given.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> NW := InverseAutomatonToGenerators(A);[0m
    [22m[35m[ 2, "baBA", "bbA" ][0m
  [22m[35m------------------------------------------------------------------[0m
  
