[1X3 Functionally recursive machines[0X At the core of this package are [13Xfunctionally recursive machines[0m. The internals of machine will be described later, but each machine M has an associated [13Xalphabet[0m X, a [13Xset of states[0m Q, and a [13Xtransition function[0m phi:Q x X -> X x Q. An [13Xelement[0m, as we will see in Section [14X4[0m, is given by a machine and an initial state qin Q. The element (M,q) defines a transformation on the set X^* of strings (finite or infinite) over the alphabet X, as follows: the empty string is always fixed. Given a string x_1x_2dots x_n with nge0, compute phi(q,x_1)=(y_1,r); then compute the action of (M,r) on the string x_2dots x_n, and call the result y_2dots y_n. Then the action of (M,q) on x_1x_2dots x_n yields y_1y_2dots y_n. This can be understood more formally as follows. The transition function phi induces a map phi^n:Qx X^n -> X^n x Q, defined by successively applying phi to move the Q from the left to the right. Similarly, phi can be extended to a map Q^mx X^n -> X^n x Q^m. We see that the action on finite strings preserves their length, and also preserves prefixes: if (M,q) maps x_1dots x_n to y_1dots y_m, then necessarily m=n; and if k<n then T maps x_1dots x_k to y_1dots y_k. The strings over the alphabet X can be naturally organised into a rooted tree. The root represents the empty string, and the strings x_1dots x_n and x_1dots x_n+1 are connected by an edge, for all x_iin X. [1X3.1 Types of machines[0X Machines must be accessible to computation; therefore it is reasonable to assume that their alphabet X is finite. If the stateset Q is also finite, the machine is called a [13XMealy machine[0m, and its transition function phi can be stored as a table. More general machines are obtained if one allows the stateset Q to be a free group/semigroup/monoid generated by a finite set S, and the transition function phi to be specified on Sx X. Its values are then extended naturally by composition. Machines store their transitions (second coordinate of phi), and their output, (first coordinate of phi) in a matrix indexed by state and letter. In particular, [10XPermList(output[state])[0m gives the action on the first level. Because of the way [5XGAP[0m handles permutations and transformations, a permutation is never equal to a transformation, even though both can answer [9Xtrue[0m to IsOne. Therefore, [5XFR[0m introduces a new type of transformation, which can be equal to a permutation, and which is actually represented as a permutation is it is invertible. Like permutations, the new transformations do not have a fixed degree. They are created by [10XTrans(list)[0m. [1X3.2 Products of machines[0X Machines can be combined in different manners. If two machines act on the same alphabet, then their [13Xsum[0m and [13Xproduct[0m are defined as machines acting again on the same alphabet; the statesets are the free products (which is also their sum, in the category of semigroups) of the respective statesets. The sum or product of machines has a stateset of highest possible category, i.e. is a group unless some argument is a monoid, and a monoid unless some argument is a semigroup. The transition and output functions are the union of the respective functions of their arguments. If a non-empty collection of machines have same stateset, then their [13Xtensor sum[0m and [13Xtensor product[0m are machines again with same stateset; the alphabets on which the machines act are the disjoint union, respectively cartesian product, of the arguments' alphabets. The transition and output functions are again the union or composition of the respective functions of their arguments. The [13Xdirect sum[0m and [13Xdirect product[0m of a collection of machines are always defined. Its stateset is generated by the union of the arguments' statesets, as for a sum or a product; its alphabet is the disjoint union, respectively cartesian product of its arguments' alphabets, as for a tensor sum or product. The transition and output functions are again the union of the respective functions of their arguments. [1X3.3 Creators for [10XFRMachine[1Xs[0X [1X3.3-1 FRMachineNC[0m [2X> FRMachineNC( [0X[3Xfam, free, transitions, outputs[0X[2X ) __________________[0Xoperation [6XReturns:[0X A new FR machine. This function constructs a new FR machine, belonging to family [3Xfam[0m. It has stateset the free group/semigroup/monoid [3Xfree[0m, and transitions described by [3Xstates[0m and [3Xoutputs[0m. [3Xtransitions[0m is a list of lists; [3Xtransitions[0m[[3Xs[0m][[3Xx[0m] is a word in [3Xfree[0m, which is the state reached by the machine when started in state [3Xs[0m and fed input [3Xx[0m. [3Xoutputs[0m is also a list of lists; [3Xoutputs[0m[[3Xs[0m][[3Xx[0m] is the output produced by the machine is in state [3Xs[0m and inputs [3Xx[0m. [4X--------------------------- Example ----------------------------[0X [4Xgap> f := FreeGroup(2);[0X [4X<free group on the generators [ f1, f2 ]>[0X [4Xgap> m := FRMachineNC(FRMFamily([1,2]),f,[[One(f),f.1],[One(f),f.2^-1]],[0X [4X [[2,1],[1,2]]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1, f2 ] )>[0X [4X------------------------------------------------------------------[0X [1X3.3-2 FRMachine[0m [2X> FRMachine( [0X[3X[names, ]transitions, outputs[0X[2X ) ______________________[0Xoperation [2X> FRMachine( [0X[3Xfree, transitions, outputs[0X[2X ) _________________________[0Xoperation [6XReturns:[0X A new FR machine. This function constructs a new FR machine. It has stateset a free group/semigroup/monoid, and structure described by [3Xtransitions[0m and [3Xoutputs[0m. If there is an argument [3Xfree[0m, it is the free group/monoid/semigroup to be used as stateset. Otherwise, the stateset will be guessed from the [3Xtransitions[0m and [3Xoutputs[0m; it will be a free group if all states are invertible, and a monoid otherwise. [3Xnames[0m is then an optional list, with at position [3Xs[0m a string naming generator [3Xs[0m of the stateset. If [3Xnames[0m contains too few entries, they are completed by the names [3X__1,__2,...[0m. [3Xtransitions[0m is a list of lists; [10Xtransitions[s][x][0m is either an associative word, or a list of integers describing the state reached by the machine when started in state [3Xs[0m and fed input [3Xx[0m. Positive integers indicate a generator index, negative integers its inverse, the empty list in the identity state, and lists of length greater than one indicate a product of states. If an entry is an FR element, then its machine is incorporated into the newly constructed one. [3Xoutputs[0m is a list; at position [3Xs[0m it contains a permutation, a transformation, or a list of integers (the images of a transformation), describing the activity of state [3Xs[0m. If all states are invertible, the outputs are all converted to permutations, while if there is a non-invertible state then the outputs are all converted to transformations. [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> m=n;[0X [4Xtrue[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> m := FRMachine([[[],[FRElement(n,1)]]],[()]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1, f2, f3 ] )>[0X [4Xgap> Display(m);[0X [4X | 1 2[0X [4X----+--------+---------+[0X [4X f1 | <id>,1 f2,2[0X [4X f2 | <id>,2 f2,1[0X [4X f3 | <id>,2 f1^-1,1[0X [4X----+--------+---------+[0X [4Xgap> f := FreeGroup(2);[0X [4X<free group on the generators [ f1, f2 ]>[0X [4Xgap> p := FRMachine(f,[[One(f),f.1],[One(f),f.2^-1],[(1,2),(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1, f2 ] )>[0X [4Xgap> n=p;[0X [4Xtrue[0X [4X------------------------------------------------------------------[0X [1X3.3-3 UnderlyingFRMachine[0m [2X> UnderlyingFRMachine( [0X[3Xobj[0X[2X ) ______________________________________[0Xattribute [6XReturns:[0X An FR machine underlying [3Xobj[0m. FR elements, FR groups etc. often have an underlying FR machine, which is returned by this command. [4X--------------------------- Example ----------------------------[0X [4Xgap> m := FRMachine(["a","b"],[[[],[2]],[[],[1]]],[(1,2),()]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ a, b ] )>[0X [4Xgap> a := FRElement(m,1); b := FRElement(m,2);[0X [4X<2|a>[0X [4X<2|b>[0X [4Xgap> UnderlyingFRMachine(a)=m;[0X [4Xtrue[0X [4X------------------------------------------------------------------[0X [1X3.3-4 AsGroupFRMachine[0m [2X> AsGroupFRMachine( [0X[3Xm[0X[2X ) ___________________________________________[0Xattribute [2X> AsMonoidFRMachine( [0X[3Xm[0X[2X ) __________________________________________[0Xattribute [2X> AsSemigroupFRMachine( [0X[3Xm[0X[2X ) _______________________________________[0Xattribute [6XReturns:[0X An FR machine isomorphic to [3Xm[0m, on a free group. This function constructs, from the FR machine [3Xm[0m, an isomorphic FR machine [10Xn[0m with a free group/monoid/semigroup as stateset. The attribute [10XCorrespondence(n)[0m is a mapping (homomorphism or list) from the stateset of [3Xm[0m to the stateset of [10Xn[0m. [4X--------------------------- Example ----------------------------[0X [4Xgap> s := FreeSemigroup(1);;[0X [4Xgap> sm := FRMachine(s,[[GeneratorsOfSemigroup(s)[1],[0X [4X GeneratorsOfSemigroup(s)[1]^2]],[(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Semigroup( [ s1 ] )>[0X [4Xgap> m := FreeMonoid(1);;[0X [4Xgap> mm := FRMachine(m,[[One(m),GeneratorsOfMonoid(m)[1]^2]],[(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Monoid( [ m1 ], ... )>[0X [4Xgap> g := FreeGroup(1);;[0X [4Xgap> gm := FRMachine(g,[[One(g),GeneratorsOfGroup(g)[1]^-2]],[(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4Xgap> AsGroupFRMachine(sm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4X | 1 2[0X [4X----+------+--------+[0X [4X f1 | f1,2 f1^2,1[0X [4X----+------+--------+[0X [4Xgap> Correspondence(last);[0X [4XMappingByFunction( <free semigroup on the generators[0X [4X[ s1 ]>, <free group on the generators [ f1 ]>, function( w ) ... end )[0X [4Xgap> AsGroupFRMachine(mm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4X | 1 2[0X [4X----+--------+--------+[0X [4X f1 | <id>,2 f1^2,1[0X [4X----+--------+--------+[0X [4Xgap> AsGroupFRMachine(gm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4X | 1 2[0X [4X----+--------+---------+[0X [4X f1 | <id>,2 f1^-2,1[0X [4X----+--------+---------+[0X [4Xgap> AsMonoidFRMachine(sm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Monoid( [ m1 ], ... )>[0X [4X | 1 2[0X [4X----+------+--------+[0X [4X m1 | m1,2 m1^2,1[0X [4X ----+------+--------+[0X [4Xgap> AsMonoidFRMachine(mm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Monoid( [ m1 ], ... )>[0X [4X | 1 2[0X [4X----+--------+--------+[0X [4X m1 | <id>,2 m1^2,1[0X [4X----+--------+--------+[0X [4Xgap> AsMonoidFRMachine(gm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Monoid( [ m1, m2 ], ... )>[0X [4X | 1 2[0X [4X----+--------+--------+[0X [4X m1 | <id>,2 m2^2,1[0X [4X m2 | m1^2,2 <id>,1[0X [4X----+--------+--------+[0X [4Xgap> AsSemigroupFRMachine(sm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Semigroup( [ s1 ] )>[0X [4X | 1 2[0X [4X----+------+--------+[0X [4X s1 | s1,2 s1^2,1[0X [4X----+------+--------+[0X [4Xgap> AsSemigroupFRMachine(mm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Semigroup( [ s1, s2 ] )>[0X [4X | 1 2[0X [4X----+------+--------+[0X [4X s1 | s2,2 s1^2,1[0X [4X s2 | s2,1 s2,2[0X [4X----+------+--------+[0X [4Xgap> AsSemigroupFRMachine(gm); Display(last);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Semigroup( [ s1, s2, s3 ] )>[0X [4X | 1 2[0X [4X----+--------+--------+[0X [4X s1 | s3,2 s2^2,1[0X [4X s2 | s1^2,2 s3,1[0X [4X s3 | s3,1 s3,2[0X [4X----+--------+--------+[0X [4Xgap>[0X [4Xgap> Display(GuptaSidkiMachines(3));[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> AsGroupFRMachine(GuptaSidkiMachines(3));[0X [4X<FR machine with alphabet [ 1 .. 3 ] on Group( [ f1, f2 ] )>[0X [4Xgap> Display(last);[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 [4Xgap> Correspondence(last);[0X [4X[ <identity ...>, f1, f1^-1, f2 ][0X [4X------------------------------------------------------------------[0X [1X3.3-5 ChangeFRMachineBasis[0m [2X> ChangeFRMachineBasis( [0X[3Xm[, l][0X[2X ) __________________________________[0Xattribute [6XReturns:[0X An equivalent FR machine, in a new basis. This function constructs a new group FR machine, given a group FR machine [3Xm[0m and a list of states [3Xl[0m (as elements of the free object [10XStateSet(m)[0m). The new machine has the following transitions: if alphabet letter [10Xa[0m is mapped to [10Xb[0m by state [10Xs[0m in [3Xm[0m, leading to state [10Xt[0m, then in the new machine the new state is [10Xl[a]^-1*t*l[b][0m. The group generated by the new machine is isomorphic to the group generated by [3Xm[0m. This command amounts to a change of basis of the associated bimodule (see [Nek05, Section 2.2]). It amounts to conjugation by the automorphism [10Xc=FRElement("c",[l[1]*c,...,l[n]*c],[()],1)[0m. If the second argument is absent, this command attempts to choose one that makes many entries of the recursion trivial. [4X--------------------------- Example ----------------------------[0X [4Xgap> n := FRMachine(["tau","mu"],[[[],[1]],[[],[-2]]],[(1,2),(1,2)]);;[0X [4Xgap> Display(n);[0X [4X G | 1 2[0X [4X-----+--------+---------+[0X [4X tau | <id>,2 tau,1[0X [4X mu | <id>,2 mu^-1,1[0X [4X-----+--------+---------+[0X [4Xgap> nt := ChangeFRMachineBasis(n,GeneratorsOfFRMachine(n){[1,1]});;[0X [4Xgap> Display(nt);[0X [4X G | 1 2[0X [4X-----+--------+--------------------+[0X [4X tau | <id>,2 tau,1[0X [4X mu | <id>,2 tau^-1*mu^-1*tau,1[0X [4X-----+--------+--------------------+[0X [4X------------------------------------------------------------------[0X [1X3.4 Attributes for [10XFRMachine[1Xs[0X [1X3.4-1 StateSet[0m [2X> StateSet( [0X[3Xm[0X[2X ) ___________________________________________________[0Xattribute [6XReturns:[0X The set of states associated with [3Xm[0m. This function returns the stateset of [3Xm[0m. It can be either a list (if the machine is of Mealy type), or a free group/semigroup/monoid (in all other cases). [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> StateSet(n);[0X [4X<free group on the generators [ tau, mu ]>[0X [4Xgap> StateSet(AsMealyMachine(n));[0X [4X[ 1 .. 4 ][0X [4X------------------------------------------------------------------[0X [1X3.4-2 GeneratorsOfFRMachine[0m [2X> GeneratorsOfFRMachine( [0X[3Xm[0X[2X ) ______________________________________[0Xattribute [6XReturns:[0X The generating set of the stateset of [3Xm[0m. This function returns the generating set of the stateset of [3Xmachine[0m. If [3Xm[0m is a Mealy machine, it returs the stateset. [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> GeneratorsOfFRMachine(n);[0X [4X[ tau, mu ][0X [4X------------------------------------------------------------------[0X [1X3.4-3 Output[0m [2X> Output( [0X[3Xm, s[0X[2X ) __________________________________________________[0Xoperation [2X> Output( [0X[3Xm, s, x[0X[2X ) _______________________________________________[0Xoperation [6XReturns:[0X A transformation of [3Xm[0m's alphabet. This function returns the transformation of [3Xm[0m's alphabet associated with state [3Xs[0m. This transformation is returned as a list of images. [3Xs[0m is also allowed to be a list, in which case it is interpreted as the corresponding product of states. In the second form, the result is actually the image of [3Xx[0m under [10XOutput(m,s)[0m. [4X--------------------------- Example ----------------------------[0X [4Xgap> n := FRMachine(["a","b"],[[[],[2]],[[],[1]]],[(1,2),()]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ a, b ] )>[0X [4Xgap> Output(n,[1,2]);[0X [4X[2,1][0X [4Xgap> Output(n,Product(GeneratorsOfFRMachine(n)));[0X [4X[2,1][0X [4X------------------------------------------------------------------[0X [1X3.4-4 Transition[0m [2X> Transition( [0X[3Xm, s, i[0X[2X ) ___________________________________________[0Xoperation [6XReturns:[0X An element of [3Xm[0m's stateset. This function returns the state reached by [3Xm[0m when started in state [3Xs[0m and fed input [3Xi[0m. This input may be an alphabet letter or a sequence of alphabet letters. [4X--------------------------- Example ----------------------------[0X [4Xgap> n := FRMachine(["a","b"],[[[],[2]],[[],[1]]],[(1,2),()]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ a, b ] )>[0X [4Xgap> Transition(n,[2,1],2);[0X [4Xa*b[0X [4Xgap> Transition(n,Product(GeneratorsOfFRMachine(n))^2,1);[0X [4Xa*b[0X [4X------------------------------------------------------------------[0X [1X3.4-5 WreathRecursion[0m [2X> WreathRecursion( [0X[3Xmachine[0X[2X ) ______________________________________[0Xattribute [6XReturns:[0X A function on the stateset of [3Xmachine[0m. This function returns a function on [3Xmachine[0m's stateset. This function, on receiving state [3Xq[0m as input, returns a list. Its first entry is a list indexed by [3Xmachine[0m's alphabet, with in position [3Xx[0m the state [3Xmachine[0m would be in if it received input [3Xx[0m when in state [3Xq[0m. The second entry is the list of the permutation of [3Xmachine[0m's alphabet induced by [3Xq[0m. [3XWreathRecursion(machine)(q)[1][a][0m is equal to [3XTransition(machine,q,a)[0m and [3XWreathRecursion(machine)(q)[2][0m is equal to [3XOutput(machine,q)[0m. [4X--------------------------- Example ----------------------------[0X [4Xgap> n := FRMachine(["a","b"],[[[],[2]],[[],[1]]],[(1,2),()]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ a, b ] )>[0X [4Xgap> WreathRecursion(n)(GeneratorsOfFRMachine(n)[1]);[0X [4X[ [ <identity ...>, b ], [2,1] ][0X [4Xgap> WreathRecursion(n)(GeneratorsOfFRMachine(n)[2]);[0X [4X[ [ <identity ...>, a ], [1,2] ][0X [4X------------------------------------------------------------------[0X [1X3.5 Operations for [10XFRMachine[1Xs[0X [1X3.5-1 StructuralGroup[0m [2X> StructuralGroup( [0X[3Xmachine[0X[2X ) ______________________________________[0Xoperation [2X> StructuralMonoid( [0X[3Xmachine[0X[2X ) _____________________________________[0Xoperation [2X> StructuralSemigroup( [0X[3Xmachine[0X[2X ) __________________________________[0Xoperation [6XReturns:[0X A finitely presented group/monoid/semigroup capturing the structure of [3Xmachine[0m. This function returns a finitely presented group/monoid/semigroup, with generators the union of the [2XAlphabetOfFRObject[0m ([14X11.1-3[0m) and [2XGeneratorsOfFRMachine[0m ([14X3.4-2[0m) of [3Xmachine[0m, and relations all qa'=aq' whenever phi(q,a)=(a',q'). [4X--------------------------- Example ----------------------------[0X [4Xgap> n := FRMachine(["a","b","c"],[[[2],[3]],[[3],[2]],[[1],[1]]],[(1,2),(1,2),()]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ a, b, c ] )>[0X [4Xgap> StructuralGroup(n);[0X [4X<fp group on the generators [ a, b, c, 1, 2 ]>[0X [4Xgap> RelatorsOfFpGroup(last);[0X [4X[ a*2*b^-1*1^-1, a*1*c^-1*2^-1, b*2*c^-1*1^-1,[0X [4X b*1*b^-1*2^-1, c*1*a^-1*1^-1, c*2*a^-1*2^-1 ][0X [4Xgap> SimplifiedFpGroup(last2);[0X [4X<fp group on the generators [ a, 1 ]>[0X [4Xgap> RelatorsOfFpGroup(last);[0X [4X[ 1^-1*a^2*1^4*a^-2*1^-1*a*1^-2*a^-1, 1*a*1^-1*a*1^2*a^-1*1*a^-2*1^-3*a,[0X [4X 1^-1*a^2*1^2*a^-1*1^-1*a*1^2*a^-2*1^-2 ][0X [4X------------------------------------------------------------------[0X [1X3.5-2 \+[0m [2X> \+( [0X[3Xmachine1, machine2[0X[2X ) ___________________________________________[0Xmethod [6XReturns:[0X A new FR machine, in the same family as its arguments. This function returns a new FR machine, with stateset generated by the union of the statesets of its arguments. The arguments [3Xmachine1[0m and [3Xmachine2[0m must operate on the same alphabet. If the stateset of [3Xmachine1[0m is free on n_1 letters and the stateset of [3Xmachine2[0m is free on n_2 letters, then the stateset of their sum is free on n_1+n_2 letters, with the first n_1 identified with [3Xmachine1[0m's states and the next n_2 with [3Xmachine2[0m's. The transition and output functions are naturally extended to the sum. The arguments may be free groups, semigroups or monoid machines. The sum is in the weakest containing category: it is a group machine if both arguments are group machines; a monoid if both are either group of monoid machines; and a semigroup machine otherwise. The maps from the stateset of [3Xmachine1[0m or [3Xmachine2[0m to the stateset of the result [10Xr[0m can be recovered as [10XCorrespondence(r)[1][0m and [10XCorrespondence(r)[2][0m; see [2XCorrespondence[0m ([14X3.5-11[0m). [4X--------------------------- Example ----------------------------[0X [4Xgap> tau := FRMachine([[[],[1]]],[(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4Xgap> mu := FRMachine([[[],[-1]]],[(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4Xgap> sum := tau+mu;; Display(sum);[0X [4X | 1 2[0X [4X-----+--------+----------+[0X [4X f11 | <id>,2 f11,1[0X [4X f12 | <id>,2 f12^-1,1[0X [4X-----+--------+----------+[0X [4Xgap> Correspondence(sum)[1];[0X [4X[ f1 ] -> [ f11 ][0X [4Xgap> GeneratorsOfFRMachine(tau)[1]^last;[0X [4Xf11[0X [4X------------------------------------------------------------------[0X [1X3.5-3 \*[0m [2X> \*( [0X[3Xmachine1, machine2[0X[2X ) ___________________________________________[0Xmethod [6XReturns:[0X A new FR machine, in the same family as its arguments. The product of two FR machines coincides with their sum, since the natural free object mapping to the product of the statesets is generated by the union of the statesets. See therefore [2X\+[0m ([14X3.5-2[0m). [1X3.5-4 TensorSumOp[0m [2X> TensorSumOp( [0X[3XFR_machines, machine[0X[2X ) ________________________________[0Xmethod [6XReturns:[0X A new FR machine on the disjoint union of the arguments' alphabets. The tensor sum of FR machines with same stateset is defined as the FR machine acting on the disjoint union of the alphabets; if these alphabets are [10X[1..n1][0m up to [10X[1..nk][0m, then the alphabet of their sum is [10X[1..n1+...+nk][0m and the transition functions are similarly concatenated. The first argument is a list; the second argument is any element of that list, and is used only to improve the method selection algorithm. [4X--------------------------- Example ----------------------------[0X [4Xgap> m := TensorSum(AddingMachine(2),AddingMachine(3),AddingMachine(4));[0X [4XAddingMachine(2)(+)AddingMachine(3)(+)AddingMachine(4)[0X [4Xgap> Display(m);[0X [4X | 1 2 3 4 5 6 7 8 9[0X [4X---+-----+-----+-----+-----+-----+-----+-----+-----+-----+[0X [4X a | a,1 a,2 a,3 a,4 a,5 a,6 a,7 a,8 a,9[0X [4X b | a,2 b,1 a,4 a,5 b,3 a,7 a,8 a,9 b,6[0X [4X---+-----+-----+-----+-----+-----+-----+-----+-----+-----+[0X [4X------------------------------------------------------------------[0X [1X3.5-5 TensorProductOp[0m [2X> TensorProductOp( [0X[3XFR, machines, machine[0X[2X ) ___________________________[0Xmethod [6XReturns:[0X A new FR machine on the cartesian product of the arguments' alphabets. The tensor product of FR machines with same stateset is defined as the FR machine acting on the cartesian product of the alphabets. The transition function and output function behave as if a single letter, in the tensor product's alphabet, were a word (read from left to right) in the machines' alphabets. The first argument is a list; the second argument is any element of that list, and is used only to improve the method selection algorithm. Due to an overloading problem in the GAP library, the user-level command is temporarily renamed [10XTensorProductX[0m. [4X--------------------------- Example ----------------------------[0X [4Xgap> m := TensorProductX(AddingMachine(2),AddingMachine(3));[0X [4XAddingMachine(2)(*)AddingMachine(3)[0X [4Xgap> Display(last);[0X [4X | 1 2 3 4 5 6[0X [4X---+-----+-----+-----+-----+-----+-----+[0X [4X a | a,1 a,2 a,3 a,4 a,5 a,6[0X [4X b | a,4 a,5 a,6 a,2 a,3 b,1[0X [4X---+-----+-----+-----+-----+-----+-----+[0X [4X------------------------------------------------------------------[0X [1X3.5-6 DirectSumOp[0m [2X> DirectSumOp( [0X[3XFR, machines, machine[0X[2X ) _______________________________[0Xmethod [6XReturns:[0X A new FR machine on the disjoint union of the arguments' alphabets. The direct sum of FR machines is defined as the FR machine with stateset generated by the disjoint union of the statesets, acting on the disjoint union of the alphabets; if these alphabets are [10X[1..n1][0m up to [10X[1..nk][0m, then the alphabet of their sum is [10X[1..n1+...+nk][0m and the output and transition functions are similarly concatenated. The first argument is a list; the second argument is any element of that list, and is used only to improve the method selection algorithm. [4X--------------------------- Example ----------------------------[0X [4Xgap> m := DirectSum(AddingMachine(2),AddingMachine(3),AddingMachine(4));[0X [4XAddingMachine(2)#AddingMachine(3)#AddingMachine(4)[0X [4Xgap> Display(m);[0X [4X | 1 2 3 4 5 6 7 8 9[0X [4X---+-----+-----+-----+-----+-----+-----+-----+-----+-----+[0X [4X a | a,1 a,2 a,3 a,4 a,5 a,6 a,7 a,8 a,9[0X [4X b | a,2 b,1 b,3 b,4 b,5 b,6 b,7 b,8 b,9[0X [4X c | c,1 c,2 a,3 a,4 a,5 c,6 c,7 c,8 c,9[0X [4X d | d,1 d,2 a,4 a,5 b,3 d,6 d,7 d,8 d,9[0X [4X e | e,1 e,2 e,3 e,4 e,5 a,6 a,7 a,8 a,9[0X [4X f | f,1 f,2 f,3 f,4 f,5 a,7 a,8 a,9 b,6[0X [4X---+-----+-----+-----+-----+-----+-----+-----+-----+-----+[0X [4X------------------------------------------------------------------[0X [1X3.5-7 DirectProductOp[0m [2X> DirectProductOp( [0X[3XFR, machines, machine[0X[2X ) ___________________________[0Xmethod [6XReturns:[0X A new FR machine on the cartesian product of the arguments' alphabets. The direct product of FR machines is defined as the FR machine with stateset generated by the product of the statesets, acting on the product of the alphabets; if these alphabets are [10X[1..n1][0m up to [10X[1..nk][0m, then the alphabet of their product is [10X[1..n1*...*nk][0m and the output and transition functions act component-wise. The first argument is a list; the second argument is any element of that list, and is used only to improve the method selection algorithm. [4X--------------------------- Example ----------------------------[0X [4Xgap> m := DirectProduct(AddingMachine(2),AddingMachine(3));[0X [4XAddingMachine(2)xAddingMachine(3)[0X [4Xgap> Display(last);[0X [4X | 1 2 3 4 5 6[0X [4X---+-----+-----+-----+-----+-----+-----+[0X [4X a | a,1 a,2 a,3 a,4 a,5 a,6[0X [4X b | a,2 a,3 b,1 a,5 a,6 b,4[0X [4X c | a,4 a,5 a,6 c,1 c,2 c,3[0X [4X d | a,5 a,6 b,4 c,2 c,3 d,1[0X [4X---+-----+-----+-----+-----+-----+-----+[0X [4X------------------------------------------------------------------[0X [1X3.5-8 TreeWreathProduct[0m [2X> TreeWreathProduct( [0X[3Xm, n, x0, y0[0X[2X ) __________________________________[0Xmethod [6XReturns:[0X A new FR machine on the cartesian product of the arguments' alphabets. The [13Xtree-wreath product[0m of two FR machines is a machine acting on the product of its arguments' alphabets X,Y, in such a way that many images of the first machine's states under conjugation by the second commute. It is introduced (in lesser generality, and with small variations) in [Sid05], and may be described as follows: one takes two copies of the stateset of [3Xm[0m, one copy of the stateset of [3Xn[0m, and, if necessary, an extra identity state. The first copy of [3Xm[0m fixes the alphabet Xx Y; its state tilde s has transitions to the identity except tilde s at (x0,y0) and s at (*,y0) for any other *. The second copy of [3Xm[0m is also trivial except that, on input (x,y0), its state s goes to state s' with output (x',y0) whenever s originally went, on input x, to state s' with output x'. This copy of [3Xm[0m therefore acts only in the X direction, on the subtree (Xx{y0})^infty, on subtrees below vertices of the form (x0,y0)^t(x,y0). A state t in the copy of [3Xn[0m maps the input (x,y) to (x,y') and proceeds to state t' if y=y0, and to the identity state otherwise, when on input y the original machine mapped state t to output t' and output y'. [4X--------------------------- Example ----------------------------[0X [4Xgap> m := TreeWreathProduct(AddingMachine(2),AddingMachine(3),1,1);[0X [4XAddingMachine(2)~AddingMachine(3)[0X [4Xgap> Display(last);[0X [4X | 1 2 3 4 5 6[0X [4X---+-----+-----+-----+-----+-----+-----+[0X [4X a | c,2 c,3 a,1 c,5 c,6 c,4[0X [4X b | c,4 c,2 c,3 b,1 c,5 c,6[0X [4X c | c,1 c,2 c,3 c,4 c,5 c,6[0X [4X d | d,1 c,2 c,3 b,4 c,5 c,6[0X [4X---+-----+-----+-----+-----+-----+-----+[0X [4X------------------------------------------------------------------[0X [1X3.5-9 SubFRMachine[0m [2X> SubFRMachine( [0X[3Xmachine1, machine2[0X[2X ) ______________________________[0Xoperation [6XReturns:[0X Either [9Xfail[0m or an embedding of the states of [3Xmachine2[0m in the states of [3Xmachine1[0m. This function attempts to locate a copy of [3Xmachine2[0m in [3Xmachine1[0m. If is succeeds, it returns a homomorphism from the stateset of [3Xmachine2[0m into the stateset of [3Xmachine1[0m; otherwise it returns [9Xfail[0m. [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> tauinv := FRMachine([[[1],[]]],[(1,2)]);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ f1 ] )>[0X [4Xgap> SubFRMachine(n,tauinv);[0X [4X[ f1 ] -> [ tau^-1 ][0X [4X------------------------------------------------------------------[0X [1X3.5-10 Minimized[0m [2X> Minimized( [0X[3Xm[0X[2X ) __________________________________________________[0Xoperation [6XReturns:[0X A minimized machine equivalent to [3Xm[0m. This function attempts to construct a machine equivalent to [3Xm[0m, but with a stateset of smaller rank. Identical generators are collapsed to a single generator of the stateset; if [3Xm[0m is a group or monoid machine then trivial generators are removed; if [3Xm[0m is a group machine then mutually inverse generators are grouped. This function sets as [10XCorrespondence(result)[0m a mapping between the stateset of [3Xm[0m and the stateset of the result; see [2XCorrespondence[0m ([14X3.5-11[0m). [4X--------------------------- Example ----------------------------[0X [4Xgap> n := FRMachine(["tau","mu"],[[[],[1]],[[],[-2]]],[(1,2),(1,2)]);;[0X [4Xgap> m := FRMachine(["tauinv"],[[[1],[]]],[(1,2)]);;[0X [4Xgap> sum := n+m+n;[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ tau1, mu1, tauinv1, tau2, mu2 ] )>[0X [4Xgap> min := Minimized(sum);[0X [4X<FR machine with alphabet [ 1 .. 2 ] on Group( [ tau1, mu1 ] )>[0X [4Xgap> Correspondence(min);[0X [4X[ tau1, mu1, tauinv1, tau2, mu2 ] -> [ tau1, mu1, tau1^-1, tau1, mu1 ][0X [4X------------------------------------------------------------------[0X [1X3.5-11 Correspondence[0m [2X> Correspondence( [0X[3Xm[0X[2X ) _____________________________________________[0Xattribute [6XReturns:[0X A mapping between statesets of FR machines. If a machine [3Xm[0m was created as a minimized group/monoid/semigroup machine, then [10XCorrespondence(m)[0m is a mapping between the stateset of the original machine and the stateset of [3Xm[0m. See [2XMinimized[0m ([14X3.5-10[0m) for an example. If [3Xm[0m was created as a minimized Mealy machine, then [10XCorrespondence(m)[0m is a list identifying, for each state of the original machine, a state of the new machine. If the original state is inaccessible, the corresponding list entry is unbound. See [2XMinimized[0m ([14X5.2-2[0m) for an example. If [3Xm[0m was created using [2XAsGroupFRMachine[0m ([14X3.3-4[0m), [2XAsMonoidFRMachine[0m ([14X3.3-4[0m), [2XAsSemigroupFRMachine[0m ([14X3.3-4[0m), or [2XAsMealyMachine[0m ([14X5.2-18[0m), then [10XCorrespondence(m)[0m is a list or a homomorphism identifying for each generator of the original machine a generator, or word in the generators, of the new machine. It is a list if either the original or the final machine is a Mealy machine, and a homomorphism in other cases. If [3Xm[0m was created as a sum of two machines, then [3Xm[0m has a mapping [10XCorrespondence(m)[i][0m between the stateset of machine [10Xi=1,2[0m and its own stateset. See [2X\+[0m ([14X3.5-2[0m) for an example.