GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
1[1X6 [33X[0;0YPattern Classes[133X[101X23[33X[0;0YPermutation pattern classes can be determined using their corresponding4basis. The basis of a pattern class is the anti-chain of the class, under5the order of containment. A permutation [22Xπ[122X contains another permutation [22Xσ[122X (of6shorter length) if there is a subsequence in [22Xπ[122X, which is isomorphic to [22Xσ[122X.[133X78[33X[0;0YWith the rational language of the rank encoded class, it is also possible to9find the rational language of the basis and vice versa. Several specific10kinds of transducers are used in this process. [2][133X111213[1X6.1 [33X[0;0YTransducers[133X[101X1415[1X6.1-1 Transducer[101X1617[29X[2XTransducer[102X( [3Xstates[103X, [3Xinit[103X, [3Xtransitions[103X, [3Xaccepting[103X ) [32X function18[6XReturns:[106X [33X[0;10YA record that represents a transducer.[133X1920[33X[0;0YA transducer is essentially an automaton, where running through the process21does not determine whether the input is accepted, but the input is22translated to another language, over a different alphabet.[133X2324[33X[0;0YFormally a transducer is a six-tuple with: [22XQ[122X being the set of states, [22XS[122X the25input alphabet, [22XG[122X the output alphabet, [22XI ∈ Q[122X the start state, [22XA ⊆ Q[122X the set26of accept states, and with the transition function [22Xf: Q × (S ∪ {e}) → Q × (G27∪ {e})[122X, where [22Xe[122X is the empty word.[133X2829[33X[0;0YIn this function the transducer is stored by defining how many states there30are, which one (by index) is the start or initial state, the transitions are31of the form [10X[inputletter,outputletter,fromstate,tostate][110X and a list of32accept states. The input and output alphabet are determined by the input and33output letters on the transitions.[133X3435[4X[32X Example [32X[104X36[4X[25Xgap>[125X [27Xtrans:=Transducer(3,1,[[1,2,1,2],[1,2,2,2],[2,2,1,3],[2,2,2,3],[127X[104X37[4X[25X>[125X [27X[1,1,3,3],[2,2,3,3]],[2]);[127X[104X38[4X[28Xrec( accepting := [ 2 ], initial := 1, states := 3, [128X[104X39[4X[28X transitions := [ [ 1, 2, 1, 2 ], [ 1, 2, 2, 2 ], [ 2, 2, 1, 3 ], [128X[104X40[4X[28X [ 2, 2, 2, 3 ], [ 1, 1, 3, 3 ], [ 2, 2, 3, 3 ] ] )[128X[104X41[4X[25Xgap>[125X [27X[127X[104X42[4X[32X[104X4344[1X6.1-2 DeletionTransducer[101X4546[29X[2XDeletionTransducer[102X( [3Xk[103X ) [32X function47[6XReturns:[106X [33X[0;10YA transducer over [10Xk[110X+1 states.[133X4849[33X[0;0YA deletion transducer is a transducer that deletes one letter of a rank50encoded permutation and returns the correct rank encoding of the new51permutation. The deletion transducer over [10Xk[110X deletes letters over the set of52all rank encoded permutations with highest rank [10Xk[110X. Specifically, running53through a deletion transducer with a rank encoded permutation, of highest54rank [10Xk[110X, will lead to the set of all rank encoded permutations that have one55letter of the initial permutation removed. It is important to note that56computing these shorter permutations with the transducer, is done by reading57the input permutation from right to left. For example the deletion58transducer with [10Xk[110X=3, looks as follows:[133X5960[4X[32X Example [32X[104X61[4X[25Xgap>[125X [27XDeletionTransducer(3);[127X[104X62[4X[28Xrec( accepting := [ 1 .. 3 ], initial := 4, states := 4, [128X[104X63[4X[28X transitions := [ [ 1, 1, 4, 4 ], [ 1, 0, 4, 1 ], [ 2, 1, 1, 1 ], [128X[104X64[4X[28X [ 1, 1, 1, 2 ], [ 3, 2, 1, 1 ], [ 1, 1, 2, 3 ], [ 1, 1, 3, 3 ], [128X[104X65[4X[28X [ 2, 2, 4, 4 ], [ 2, 0, 4, 2 ], [ 3, 2, 2, 2 ], [ 2, 2, 2, 3 ], [128X[104X66[4X[28X [ 2, 2, 3, 3 ], [ 3, 3, 4, 4 ], [ 3, 0, 4, 3 ], [ 3, 3, 3, 3 ] ] )[128X[104X67[4X[25Xgap>[125X [27X[127X[104X68[4X[32X[104X6970[1X6.1-3 TransposedTransducer[101X7172[29X[2XTransposedTransducer[102X( [3Xt[103X ) [32X function73[6XReturns:[106X [33X[0;10YA new transducer with interchanged input and output letters on74each transition.[133X7576[33X[0;0YA transducer is transposed when all origins and destinations of transitions77are left the same as before but the input and output letters on each78transition are interchanged. Taking the deletion transducer from above, its79transpose looks as follows:[133X8081[4X[32X Example [32X[104X82[4X[25Xgap>[125X [27XTransposedTransducer(DeletionTransducer(3));[127X[104X83[4X[28Xrec( accepting := [ 1 .. 3 ], initial := 4, states := 4, [128X[104X84[4X[28X transitions := [ [ 1, 1, 4, 4 ], [ 0, 1, 4, 1 ], [ 1, 2, 1, 1 ], [128X[104X85[4X[28X [ 1, 1, 1, 2 ], [ 2, 3, 1, 1 ], [ 1, 1, 2, 3 ], [ 1, 1, 3, 3 ], [128X[104X86[4X[28X [ 2, 2, 4, 4 ], [ 0, 2, 4, 2 ], [ 2, 3, 2, 2 ], [ 2, 2, 2, 3 ], [128X[104X87[4X[28X [ 2, 2, 3, 3 ], [ 3, 3, 4, 4 ], [ 0, 3, 4, 3 ], [ 3, 3, 3, 3 ] ] )[128X[104X88[4X[25Xgap>[125X [27X[127X[104X89[4X[32X[104X9091[1X6.1-4 InvolvementTransducer[101X9293[29X[2XInvolvementTransducer[102X( [3Xk[103X ) [32X function94[6XReturns:[106X [33X[0;10YA transducer over [10Xk[110X+1 states, with a [10Xk[110X sized alphabet.[133X9596[33X[0;0YAn involvement transducer is a transducer over [10Xk[110X+1 states, and deletes any97number of letters in a rank encoded permutation, of rank at most [10Xk[110X.[133X9899[4X[32X Example [32X[104X100[4X[25Xgap>[125X [27XInvolvementTransducer(3);[127X[104X101[4X[28Xrec( accepting := [ 1 .. 4 ], initial := 4, states := 4, [128X[104X102[4X[28X transitions := [ [ 1, 1, 1, 2 ], [ 1, 0, 1, 3 ], [ 2, 1, 1, 1 ], [128X[104X103[4X[28X [ 2, 0, 1, 3 ], [ 3, 2, 1, 1 ], [ 3, 0, 1, 1 ], [ 1, 1, 2, 4 ], [128X[104X104[4X[28X [ 1, 0, 2, 1 ], [ 2, 2, 2, 4 ], [ 2, 0, 2, 2 ], [ 3, 2, 2, 2 ], [128X[104X105[4X[28X [ 3, 0, 2, 2 ], [ 1, 1, 3, 2 ], [ 1, 0, 3, 3 ], [ 2, 1, 3, 1 ], [128X[104X106[4X[28X [ 2, 0, 3, 3 ], [ 3, 1, 3, 3 ], [ 3, 0, 3, 3 ], [ 1, 1, 4, 4 ], [128X[104X107[4X[28X [ 1, 0, 4, 1 ], [ 2, 2, 4, 4 ], [ 2, 0, 4, 2 ], [ 3, 3, 4, 4 ], [128X[104X108[4X[28X [ 3, 0, 4, 4 ] ] )[128X[104X109[4X[25Xgap>[125X [27X[127X[104X110[4X[32X[104X111112[1X6.1-5 CombineAutTransducer[101X113114[29X[2XCombineAutTransducer[102X( [3Xaut[103X, [3Xtrans[103X ) [32X function115[6XReturns:[106X [33X[0;10YAn automaton consisting of a combination of [10Xaut[110X and [10Xtrans[110X.[133X116117[33X[0;0YCombining automata and transducers is done over the natural "translation" of118the by the automaton accepted language through the transducer and then119building a new automaton that accepts the new language. The function120[10XCombineAutTransducer[110X does this process and returns the new non-deterministic121automaton.[133X122123[4X[32X Example [32X[104X124[4X[25Xgap>[125X [27Xa:=Automaton("det",1,1,[[1]],[1],[1]);[127X[104X125[4X[28X< deterministic automaton on 1 letters with 1 states >[128X[104X126[4X[25Xgap>[125X [27XAutToRatExp(a);[127X[104X127[4X[28Xa*[128X[104X128[4X[25Xgap>[125X [27Xt:=Transducer(2,1,[[1,2,1,2],[2,1,1,2],[127X[104X129[4X[25X>[125X [27X[1,1,2,1],[2,2,2,1]],[1]);[127X[104X130[4X[28Xrec( accepting := [ 1 ], initial := 1, states := 2, [128X[104X131[4X[28X transitions := [ [ 1, 2, 1, 2 ], [ 2, 1, 1, 2 ], [ 1, 1, 2, 1 ], [128X[104X132[4X[28X [ 2, 2, 2, 1 ] ] )[128X[104X133[4X[25Xgap>[125X [27Xres:=CombineAutTransducer(a,t);[127X[104X134[4X[28X< non deterministic automaton on 2 letters with 2 states >[128X[104X135[4X[25Xgap>[125X [27XAutToRatExp(res);[127X[104X136[4X[28X(ba)*[128X[104X137[4X[25Xgap>[125X [27XDisplay(res);[127X[104X138[4X[28X | 1 2[128X[104X139[4X[28X-------------------[128X[104X140[4X[28X a | [ 1 ] [128X[104X141[4X[28X b | [ 2 ] [128X[104X142[4X[28XInitial state: [ 1 ][128X[104X143[4X[28XAccepting state: [ 1 ][128X[104X144[4X[25Xgap>[125X [27X[127X[104X145[4X[32X[104X146147148[1X6.2 [33X[0;0YFrom Class to Basis and vice versa[133X[101X149150[1X6.2-1 BasisAutomaton[101X151152[29X[2XBasisAutomaton[102X( [3Xa[103X ) [32X function153[6XReturns:[106X [33X[0;10YAn automaton that accepts the rank encoded permutations of the154basis of the input automaton [10Xa[110X.[133X155156[33X[0;0YEvery pattern class has a basis that consists of the smallest set of157permutations which do not belong to the class. Using[133X158159160[24X[33X[0;6YB(L)=(L^r D^t)^r ∩ L^c[133X[124X161162[33X[0;0Yit is possible using the deletion transducer [22XD[122X and the language of rank163encoded permutations [22XL[122X to find the language of the rank encoded permutations164of the basis [22XB(L)[122X, and thus the basis.[133X165166[4X[32X Example [32X[104X167[4X[25Xgap>[125X [27Xx:=Parstacks(2,2);[127X[104X168[4X[28X[ [ 2, 4 ], [ 3, 6 ], [ 2 ], [ 5, 6 ], [ 4 ], [ ] ][128X[104X169[4X[25Xgap>[125X [27Xxa:=GraphToAut(x,1,6);[127X[104X170[4X[28X< epsilon automaton on 5 letters with 66 states >[128X[104X171[4X[25Xgap>[125X [27Xma:=MinimalAutomaton(xa);[127X[104X172[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X173[4X[25Xgap>[125X [27XDisplay(ma);[127X[104X174[4X[28X | 1 2 3 4 5 6 7 8 9 [128X[104X175[4X[28X--------------------------------[128X[104X176[4X[28X a | 1 2 1 3 2 2 6 6 3 [128X[104X177[4X[28X b | 3 2 3 3 4 3 6 9 3 [128X[104X178[4X[28X c | 9 2 9 4 6 6 4 9 9 [128X[104X179[4X[28X d | 8 2 8 7 5 5 7 8 8 [128X[104X180[4X[28XInitial state: [ 1 ][128X[104X181[4X[28XAccepting state: [ 1 ][128X[104X182[4X[25Xgap>[125X [27Xba:=BasisAutomaton(ma);[127X[104X183[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X184[4X[25Xgap>[125X [27XDisplay(ba);[127X[104X185[4X[28X | 1 2 3 4 5 6 7 8 9 [128X[104X186[4X[28X--------------------------------[128X[104X187[4X[28X a | 2 2 1 3 4 2 2 2 2 [128X[104X188[4X[28X b | 2 2 2 2 2 4 1 2 8 [128X[104X189[4X[28X c | 2 2 2 2 2 2 1 2 2 [128X[104X190[4X[28X d | 2 2 2 9 2 2 5 6 2 [128X[104X191[4X[28XInitial state: [ 7 ][128X[104X192[4X[28XAccepting states: [ 1, 5 ][128X[104X193[4X[25Xgap>[125X [27XAutToRatExp(ba);[127X[104X194[4X[28Xd(a(dbdb)*aaU@)UbUc[128X[104X195[4X[25Xgap>[125X [27X[127X[104X196[4X[32X[104X197198[33X[0;0YIgnoring the trailing [10XUbUc[110X which essentially are noise, the basis of the199pattern class indicates which permutations are avoided in this particular200class. The shortest permutation in the basis, looking at the rational201expression, is [22Xdaaa[122X, which can be translated to 4111 and decoded to the202permutation 4123.[133X203204[1X6.2-2 ClassAutomaton[101X205206[29X[2XClassAutomaton[102X( [3Xa[103X ) [32X function207[6XReturns:[106X [33X[0;10YThe automaton that accepts permutations of the class in their rank208encoding.[133X209210[33X[0;0YThe function [10XClassAutomaton[110X does the reverse process of [10XBasisAutomaton[110X.211Namely it takes the automaton that represents the language of the rank212encoded basis of a permutation class, and using the formula[133X213214215[24X[33X[0;6YL=B_k ∩ ((B(L)^r I^t)^c )^r[133X[124X216217[33X[0;0Yreturns the automaton that accepts the rank encoded permutations of the218class. In the formula, [22XB_k[122X is the automaton that accepts all permutations of219any length with highest rank [22Xk[122X, [22XB(L)[122X is the automaton that represents the220basis and [22XI[122X is the involement transducer.[133X221222[4X[32X Example [32X[104X223[4X[25Xgap>[125X [27Xxa:=Automaton("det",9,4,[[2,2,1,3,4,2,2,2,2],[2,2,2,2,2,4,1,2,8],[127X[104X224[4X[25X>[125X [27X[2,2,2,2,2,2,1,2,2],[2,2,2,9,2,2,5,6,2]],[7],[1,5]); [127X[104X225[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X226[4X[25Xgap>[125X [27Xca:=ClassAutomaton(xa); [127X[104X227[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X228[4X[25Xgap>[125X [27XDisplay(ca);[127X[104X229[4X[28X | 1 2 3 4 5 6 7 8 9 [128X[104X230[4X[28X--------------------------------[128X[104X231[4X[28X a | 1 2 1 3 2 2 6 6 3 [128X[104X232[4X[28X b | 3 2 3 3 4 3 6 9 3 [128X[104X233[4X[28X c | 9 2 9 4 6 6 4 9 9 [128X[104X234[4X[28X d | 8 2 8 7 5 5 7 8 8 [128X[104X235[4X[28XInitial state: [ 1 ][128X[104X236[4X[28XAccepting state: [ 1 ][128X[104X237[4X[25Xgap>[125X [27XIsPossibleGraphAut(ca);[127X[104X238[4X[28Xtrue[128X[104X239[4X[25Xgap>[125X [27X[127X[104X240[4X[32X[104X241242[1X6.2-3 BoundedClassAutomaton[101X243244[29X[2XBoundedClassAutomaton[102X( [3Xk[103X ) [32X function245[6XReturns:[106X [33X[0;10YAn automaton that accepts all rank encoded permutations, with246highest rank being [10Xk[110X.[133X247248[33X[0;0YThe bounded class automaton, is an automaton that accepts all rank encoded249permutations, of any length, with highest rank [10Xk[110X.[133X250251[4X[32X Example [32X[104X252[4X[25Xgap>[125X [27XBoundedClassAutomaton(3);[127X[104X253[4X[28X< deterministic automaton on 3 letters with 3 states >[128X[104X254[4X[25Xgap>[125X [27XDisplay(last);[127X[104X255[4X[28X | 1 2 3 [128X[104X256[4X[28X--------------[128X[104X257[4X[28X a | 1 1 2 [128X[104X258[4X[28X b | 2 2 2 [128X[104X259[4X[28X c | 3 3 3 [128X[104X260[4X[28XInitial state: [ 1 ][128X[104X261[4X[28XAccepting state: [ 1 ][128X[104X262[4X[25Xgap>[125X [27X[127X[104X263[4X[32X[104X264265[1X6.2-4 ClassAutFromBaseEncoding[101X266267[29X[2XClassAutFromBaseEncoding[102X( [3Xbase[103X, [3Xk[103X ) [32X function268[6XReturns:[106X [33X[0;10YThe class automaton from a list of rank encoded basis269permutations.[133X270271[33X[0;0YGiven the permutations in the basis, in their rank encoded form, and the272bound of the rank of the permutations of the class, [10XClassAutFromBaseEncoding[110X273builds the automaton that accepts rank encoded permutations of the class.[133X274275[4X[32X Example [32X[104X276[4X[25Xgap>[125X [27XClassAutFromBaseEncoding([[4,1,1,1]],4); [127X[104X277[4X[28X< deterministic automaton on 4 letters with 7 states >[128X[104X278[4X[25Xgap>[125X [27XDisplay(last);[127X[104X279[4X[28X | 1 2 3 4 5 6 7 [128X[104X280[4X[28X--------------------------[128X[104X281[4X[28X a | 1 2 1 3 2 2 6 [128X[104X282[4X[28X b | 3 2 3 3 4 3 4 [128X[104X283[4X[28X c | 4 2 4 4 6 6 4 [128X[104X284[4X[28X d | 7 2 7 7 5 5 7 [128X[104X285[4X[28XInitial state: [ 1 ][128X[104X286[4X[28XAccepting state: [ 1 ][128X[104X287[4X[25Xgap>[125X [27X[127X[104X288[4X[32X[104X289290[1X6.2-5 ClassAutFromBase[101X291292[29X[2XClassAutFromBase[102X( [3Xperms[103X, [3Xk[103X ) [32X function293[6XReturns:[106X [33X[0;10YThe class automaton from a list of permutations of the basis.[133X294295[33X[0;0YTaking [10Xperms[110X which is the list of permutations in the basis and [10Xk[110X an integer296which indicates the highest rank in the encoded permutations of the class,297[10XClassAutFromBase[110X constructs the automaton that accepts the language of rank298encoded permutations of the class.[133X299300[4X[32X Example [32X[104X301[4X[25Xgap>[125X [27XClassAutFromBase([[4,1,2,3]],4);[127X[104X302[4X[28X< deterministic automaton on 4 letters with 7 states >[128X[104X303[4X[25Xgap>[125X [27XDisplay(last);[127X[104X304[4X[28X | 1 2 3 4 5 6 7 [128X[104X305[4X[28X--------------------------[128X[104X306[4X[28X a | 1 2 1 3 2 2 6 [128X[104X307[4X[28X b | 3 2 3 3 4 3 4 [128X[104X308[4X[28X c | 4 2 4 4 6 6 4 [128X[104X309[4X[28X d | 7 2 7 7 5 5 7 [128X[104X310[4X[28XInitial state: [ 1 ][128X[104X311[4X[28XAccepting state: [ 1 ][128X[104X312[4X[25Xgap>[125X [27X[127X[104X313[4X[32X[104X314315[1X6.2-6 ExpandAlphabet[101X316317[29X[2XExpandAlphabet[102X( [3Xa[103X, [3XnewAlphabet[103X ) [32X function318[6XReturns:[106X [33X[0;10YThe automaton [10Xa[110X, over the alphabet of size [10XnewAlphabet[110X.[133X319320[33X[0;0YGiven an automaton and the size of the new alphabet, which has to be bigger321than the size of the alphabet in [10Xa[110X , [10XExpandAlphabet[110X changes the automaton [10Xa[110X322to contain an alphabet of size [10XnewAlphabet[110X. The new letters have no323transitions within the automaton.[133X324325[4X[32X Example [32X[104X326[4X[25Xgap>[125X [27Xaut:=Automaton("det",3,2,[[2,2,3],[3,3,3]],[1],[3]);[127X[104X327[4X[28X< deterministic automaton on 2 letters with 3 states >[128X[104X328[4X[25Xgap>[125X [27XDisplay(aut);[127X[104X329[4X[28X | 1 2 3 [128X[104X330[4X[28X--------------[128X[104X331[4X[28X a | 2 2 3 [128X[104X332[4X[28X b | 3 3 3 [128X[104X333[4X[28XInitial state: [ 1 ][128X[104X334[4X[28XAccepting state: [ 3 ][128X[104X335[4X[25Xgap>[125X [27XExpandAlphabet(aut,4);[127X[104X336[4X[28X< deterministic automaton on 4 letters with 3 states >[128X[104X337[4X[25Xgap>[125X [27XDisplay(last);[127X[104X338[4X[28X | 1 2 3 [128X[104X339[4X[28X--------------[128X[104X340[4X[28X a | 2 2 3 [128X[104X341[4X[28X b | 3 3 3 [128X[104X342[4X[28X c | [128X[104X343[4X[28X d | [128X[104X344[4X[28XInitial state: [ 1 ][128X[104X345[4X[28XAccepting state: [ 3 ][128X[104X346[4X[25Xgap>[125X [27X[127X[104X347[4X[32X[104X348349350[1X6.3 [33X[0;0YDirect Sum of Regular Classes[133X[101X351352[33X[0;0YIt is obvious that the direct sum of two rational pattern classes is also353rational. But the skew sum of two rational pattern classes does not imply354that the resulting pattern class is rational, because if the second class in355the sum has infinitely many permutations, the alphabet of the skew sum class356will be infinite and thusly the resulting class will not be rational.[133X357358[1X6.3-1 ClassDirectSum[101X359360[29X[2XClassDirectSum[102X( [3Xaut1[103X, [3Xaut2[103X ) [32X function361[6XReturns:[106X [33X[0;10YAn automaton that corresponds to the direct sum of [10Xaut1[110X with [10Xaut2[110X.[133X362363[33X[0;0Y[10XClassDirectSum[110X builds the concatenation automaton of [10Xaut1[110X with [10Xaut2[110X, which364corresponds to the pattern class [10Xaut1[110X [22X⊕[122X [10Xaut2[110X.[133X365366[4X[32X Example [32X[104X367[4X[25Xgap>[125X [27Xa:=BasisAutomaton(GraphToAut(Parstacks(2,2),1,6)); [127X[104X368[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X369[4X[25Xgap>[125X [27XAutToRatExp(a); [127X[104X370[4X[28Xd(a(dbdb)*aaU@)UbUc[128X[104X371[4X[25Xgap>[125X [27Xb:=MinimalAutomaton(GraphToAut(Seqstacks(2,2),1,6));[127X[104X372[4X[28X< deterministic automaton on 3 letters with 3 states >[128X[104X373[4X[25Xgap>[125X [27XAutToRatExp(b); [127X[104X374[4X[28X((cc*(aUb)Ub)(cc*(aUb)Ub)*aUa)*[128X[104X375[4X[25Xgap>[125X [27Xab:=ClassDirectSum(a,b); [127X[104X376[4X[28X< deterministic automaton on 4 letters with 11 states >[128X[104X377[4X[25Xgap>[125X [27XAutToRatExp(ab); [127X[104X378[4X[28X((d(acUc)c*(aUb)Ud(abUb))(cc*(aUb)Ub)*aUda(d(bdbd)*bdbaaUa)UbUc)((cc*(aUb)U\[128X[104X379[4X[28Xb)(cc*(aUb)Ub)*aUa)*Ud(aU@)[128X[104X380[4X[25Xgap>[125X [27X[127X[104X381[4X[32X[104X382383384[1X6.4 [33X[0;0YStatistical Inspections[133X[101X385386[33X[0;0YIt is of interest to see what permutations and how many of different length387are accepted by the class, respectively the basis.[133X388389[33X[0;0YIn this section, the examples will be inspecting the basis automaton of the390token passing network containing 2 stacks of capacity 2, which are situated391in parallel to each other.[133X392393[4X[32X Example [32X[104X394[4X[25Xgap>[125X [27Xx:=Parstacks(2,2);[127X[104X395[4X[28X[ [ 2, 4 ], [ 3, 6 ], [ 2 ], [ 5, 6 ], [ 4 ], [ ] ][128X[104X396[4X[25Xgap>[125X [27Xxa:=GraphToAut(x,1,6);[127X[104X397[4X[28X< epsilon automaton on 5 letters with 66 states >[128X[104X398[4X[25Xgap>[125X [27Xma:=MinimalAutomaton(xa);[127X[104X399[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X400[4X[25Xgap>[125X [27Xba:=BasisAutomaton(ma);[127X[104X401[4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X402[4X[25Xgap>[125X [27XAutToRatExp(ba);[127X[104X403[4X[28Xd(a(dbdb)*aaU@)UbUc[128X[104X404[4X[25Xgap>[125X [27X[127X[104X405[4X[32X[104X406407[1X6.4-1 Spectrum[101X408409[29X[2XSpectrum[102X( [3Xaut[103X[, [3Xint[103X] ) [32X function410[6XReturns:[106X [33X[0;10YA list indicating how many words of each length from 1 to [10Xint[110X or41115 (default) are accepted by the automaton.[133X412413[33X[0;0YEach entry in the returned list indicates how many words of length the index414of the entry are accepted by the automaton [10Xaut[110X. The length of the list is by415default 15, but if this is too much or too little the second optional416argument regulates the length of the list.[133X417418[4X[32X Example [32X[104X419[4X[25Xgap>[125X [27XSpectrum(ba);[127X[104X420[4X[28X[ 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ][128X[104X421[4X[25Xgap>[125X [27XSpectrum(ba,20);[127X[104X422[4X[28X[ 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 ][128X[104X423[4X[25Xgap>[125X [27X[127X[104X424[4X[32X[104X425426[1X6.4-2 NumberAcceptedWords[101X427428[29X[2XNumberAcceptedWords[102X( [3Xaut[103X, [3Xlen[103X ) [32X function429[6XReturns:[106X [33X[0;10YThe number of words of length [10Xlen[110X accepted by the automaton [10Xaut[110X.[133X430431[33X[0;0YGiven the automaton [10Xaut[110X and the integer [10Xlen[110X, [10XNumberAcceptedWords[110X determines432how many words of length [10Xlen[110X are accepted by the automaton.[133X433434[4X[32X Example [32X[104X435[4X[25Xgap>[125X [27XNumberAcceptedWords(ba,1);[127X[104X436[4X[28X3[128X[104X437[4X[25Xgap>[125X [27XNumberAcceptedWords(ba,16);[127X[104X438[4X[28X1[128X[104X439[4X[25Xgap>[125X [27X[127X[104X440[4X[32X[104X441442[1X6.4-3 AutStateTransitionMatrix[101X443444[29X[2XAutStateTransitionMatrix[102X( [3Xaut[103X ) [32X function445[6XReturns:[106X [33X[0;10YA matrix containing the number of transitions between states of446the automaton [10Xaut[110X.[133X447448[33X[0;0YIn the matrix computed by [10XAutStateTransitionMatrix[110X the rows are indexed by449the state the transitions are originating from, the columnns are indexed by450the states the transitions are ending at. Each entry [22Xa_i,j[122X of the matrix451represents the number of transitions from the state [22Xi[122X to the state [22Xj[122X.[133X452453[4X[32X Example [32X[104X454[4X[25Xgap>[125X [27XAutStateTransitionMatrix(ba);[127X[104X455[4X[28X[ [ 0, 4, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 4, 0, 0, 0, 0, 0, 0, 0 ], [128X[104X456[4X[28X [ 1, 3, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 2, 1, 0, 0, 0, 0, 0, 1 ], [128X[104X457[4X[28X [ 0, 3, 0, 1, 0, 0, 0, 0, 0 ], [ 0, 3, 0, 1, 0, 0, 0, 0, 0 ], [128X[104X458[4X[28X [ 2, 1, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 3, 0, 0, 0, 1, 0, 0, 0 ], [128X[104X459[4X[28X [ 0, 3, 0, 0, 0, 0, 0, 1, 0 ] ][128X[104X460[4X[25Xgap>[125X [27X[127X[104X461[4X[32X[104X462463[1X6.4-4 AcceptedWords[101X464465[29X[2XAcceptedWords[102X( [3Xaut[103X, [3Xint[103X ) [32X function466[6XReturns:[106X [33X[0;10YAll words of length [10Xint[110X that are accepted by the automaton [10Xaut[110X.[133X467468[33X[0;0Y[10XAcceptedWords[110X outputs all permutations accepted by the automaton [10Xaut[110X, which469have length [10Xint[110X, in a list. The permutations are output in their rank470encoding.[133X471472[4X[32X Example [32X[104X473[4X[25Xgap>[125X [27XAcceptedWords(ba,1);[127X[104X474[4X[28X[ [ 2 ], [ 3 ], [ 4 ] ][128X[104X475[4X[25Xgap>[125X [27XAcceptedWords(ba,16);[127X[104X476[4X[28X[ [ 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 1, 1 ] ][128X[104X477[4X[25Xgap>[125X [27X[127X[104X478[4X[32X[104X479480[1X6.4-5 AcceptedWordsR[101X481482[29X[2XAcceptedWordsR[102X( [3Xaut[103X, [3Xint1[103X[, [3Xint2[103X] ) [32X function483[29X[2XAcceptedWordsReversed[102X( [3Xaut[103X, [3Xint1[103X[, [3Xint2[103X] ) [32X function484[6XReturns:[106X [33X[0;10YThe list of all by the automaton accepted words of length [10Xint1[110X,485where each word is written in reverse.[133X486487[33X[0;0YThe functions [10XAcceptedWordsR[110X and [10XAcceptedWordsReversed[110X are synonymous and488take the following arguments; an automaton [10Xaut[110X, an integer [10Xint1[110X which489indicates the length of the words that are accepted by the [10Xaut[110X and another490integer [10Xint2[110X which is optional and represents the initial state of [10Xaut[110X. The491return value of these functions is the list containing all permutations of492length [10Xint1[110X that are accepted by [10Xaut[110X. The permutations are rank encoded and493written in reverse.[133X494495[4X[32X Example [32X[104X496[4X[25Xgap>[125X [27XAcceptedWordsR(ba,1);[127X[104X497[4X[28X[ [ 2 ], [ 3 ], [ 4 ] ][128X[104X498[4X[25Xgap>[125X [27XAcceptedWordsReversed(ba,16); [127X[104X499[4X[28X[ [ 1, 1, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 1, 4 ] ][128X[104X500[4X[25Xgap>[125X [27X[127X[104X501[4X[32X[104X502503504505