Inverse automata and subgroups of the free group 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 , for details, as well as for concepts such as flower automaton and Stallings foldings.
From subgroups to inverse automata 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, [2,"abA","bbabAB"] stands for the subgroup of the free group of rank 2 on the generators aba^{-1} and bbaba^{-1}b^{-1}. The same subgroup may be given as [2,[1,2,3],[2,2,1,2,3,4]]. 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.
gap> L:=[2,"abA","bbabAB"];; gap> GeneratorsToListRepresentation(L); [ 2, [ 1, 2, 3 ], [ 2, 2, 1, 2, 3, 4 ] ]
gap> K:=[2,[1,2,3],[2,2,1,2,3,4]];; gap> ListToGeneratorsRepresentation(K); [ 2, "abA", "bbabAB" ]
The argument L is a subgroup of the free group given through any of the representations described above. Returns the flower automaton.
gap> W:=[2,"bbbAB","abAbA"];; gap> A:=FlowerAutomaton(W); < non deterministic automaton on 2 letters with 9 states > gap> Display(A); | 1 2 3 4 5 6 7 8 9 --------------------------------------------------------------------- a | [ 6, 9 ] [ 4 ] [ 7 ] b | [ 2, 5 ] [ 3 ] [ 4 ] [ 7 ] [ 9 ] Initial state: [ 1 ] Accepting state: [ 1 ]
Makes identifications on the flower automaton A. In the literature, these identifications are called Stallings foldings.

(This function may have true 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.)
gap> B := FoldFlowerAutomaton(A); < deterministic automaton on 2 letters with 7 states > gap> Display(B); | 1 2 3 4 5 6 7 -------------------------- a | 5 4 6 b | 2 3 4 6 5 Initial state: [ 1 ] Accepting state: [ 1 ]
Returns the inverse automaton corresponding to the subgroup given by L.
gap> L:=[2,"bbbAB","AbAbA"];; gap> SubgroupGenToInvAut(L); < deterministic automaton on 2 letters with 8 states > gap> Display(last); | 1 2 3 4 5 6 7 8 ----------------------------- a | 8 4 1 6 b | 2 3 4 6 8 Initial state: [ 1 ] Accepting state: [ 1 ]
From inverse automata to subgroups 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 . Returns a subautomaton of Awhose underlying graph is a geodesic tree of the underlying graph of the inverse automaton A.
gap> A:=Automaton("det",4,2,[ [ 3, 4, 0, 0 ], [ 2, 3, 4, 0 ] ],[ 1 ],[ 1 ]);; gap> G := GeodesicTreeOfInverseAutomaton(A); < deterministic automaton on 2 letters with 4 states > gap> Display(G); | 1 2 3 4 ----------------- a | 3 b | 2 4 Initial state: [ 1 ] Accepting state: [ 1 ]
Returns a set of generators (given trough the representation above) of the subgroup of the free group corresponding to the automaton A given.
gap> NW := InverseAutomatonToGenerators(A); [ 2, "baBA", "bbA" ]