  
  [1X6 [33X[0;0YPattern Classes[133X[101X
  
  [33X[0;0YPermutation  pattern  classes  can  be  determined using their corresponding
  basis.  The  basis  of a pattern class is the anti-chain of the class, under
  the order of containment. A permutation [22Xπ[122X contains another permutation [22Xσ[122X (of
  shorter length) if there is a subsequence in [22Xπ[122X, which is isomorphic to [22Xσ[122X.[133X
  
  [33X[0;0YWith the rational language of the rank encoded class, it is also possible to
  find  the  rational  language  of the basis and vice versa. Several specific
  kinds of transducers are used in this process. [2][133X
  
  
  [1X6.1 [33X[0;0YTransducers[133X[101X
  
  [1X6.1-1 Transducer[101X
  
  [33X[1;0Y[29X[2XTransducer[102X( [3Xstates[103X, [3Xinit[103X, [3Xtransitions[103X, [3Xaccepting[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA record that represents a transducer.[133X
  
  [33X[0;0YA  transducer is essentially an automaton, where running through the process
  does  not  determine  whether  the  input  is  accepted,  but  the  input is
  translated to another language, over a different alphabet.[133X
  
  [33X[0;0YFormally  a transducer is a six-tuple with: [22XQ[122X being the set of states, [22XS[122X the
  input  alphabet, [22XG[122X the output alphabet, [22XI ∈ Q[122X the start state, [22XA ⊆ Q[122X the set
  of accept states, and with the transition function [22Xf: Q × (S ∪ {e}) → Q × (G
  ∪ {e})[122X, where [22Xe[122X is the empty word.[133X
  
  [33X[0;0YIn  this function the transducer is stored by defining how many states there
  are, which one (by index) is the start or initial state, the transitions are
  of  the  form  [10X[inputletter,outputletter,fromstate,tostate][110X  and  a  list of
  accept states. The input and output alphabet are determined by the input and
  output letters on the transitions.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xtrans:=Transducer(3,1,[[1,2,1,2],[1,2,2,2],[2,2,1,3],[2,2,2,3],[127X[104X
    [4X[25X>[125X [27X[1,1,3,3],[2,2,3,3]],[2]);[127X[104X
    [4X[28Xrec( accepting := [ 2 ], initial := 1, states := 3, [128X[104X
    [4X[28X  transitions := [ [ 1, 2, 1, 2 ], [ 1, 2, 2, 2 ], [ 2, 2, 1, 3 ], [128X[104X
    [4X[28X      [ 2, 2, 2, 3 ], [ 1, 1, 3, 3 ], [ 2, 2, 3, 3 ] ] )[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.1-2 DeletionTransducer[101X
  
  [33X[1;0Y[29X[2XDeletionTransducer[102X( [3Xk[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA transducer over [10Xk[110X+1 states.[133X
  
  [33X[0;0YA  deletion  transducer  is  a  transducer that deletes one letter of a rank
  encoded  permutation  and  returns  the  correct  rank  encoding  of the new
  permutation.  The deletion transducer over [10Xk[110X deletes letters over the set of
  all  rank  encoded  permutations  with highest rank [10Xk[110X. Specifically, running
  through  a  deletion  transducer with a rank encoded permutation, of highest
  rank  [10Xk[110X, will lead to the set of all rank encoded permutations that have one
  letter  of  the  initial  permutation  removed. It is important to note that
  computing these shorter permutations with the transducer, is done by reading
  the  input  permutation  from  right  to  left.  For  example  the  deletion
  transducer with [10Xk[110X=3, looks as follows:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XDeletionTransducer(3);[127X[104X
    [4X[28Xrec( accepting := [ 1 .. 3 ], initial := 4, states := 4, [128X[104X
    [4X[28X  transitions := [ [ 1, 1, 4, 4 ], [ 1, 0, 4, 1 ], [ 2, 1, 1, 1 ], [128X[104X
    [4X[28X      [ 1, 1, 1, 2 ], [ 3, 2, 1, 1 ], [ 1, 1, 2, 3 ], [ 1, 1, 3, 3 ], [128X[104X
    [4X[28X      [ 2, 2, 4, 4 ], [ 2, 0, 4, 2 ], [ 3, 2, 2, 2 ], [ 2, 2, 2, 3 ], [128X[104X
    [4X[28X      [ 2, 2, 3, 3 ], [ 3, 3, 4, 4 ], [ 3, 0, 4, 3 ], [ 3, 3, 3, 3 ] ] )[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.1-3 TransposedTransducer[101X
  
  [33X[1;0Y[29X[2XTransposedTransducer[102X( [3Xt[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  new  transducer  with  interchanged input and output letters on
            each transition.[133X
  
  [33X[0;0YA  transducer is transposed when all origins and destinations of transitions
  are  left  the  same  as  before  but  the  input and output letters on each
  transition  are interchanged. Taking the deletion transducer from above, its
  transpose looks as follows:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XTransposedTransducer(DeletionTransducer(3));[127X[104X
    [4X[28Xrec( accepting := [ 1 .. 3 ], initial := 4, states := 4, [128X[104X
    [4X[28X  transitions := [ [ 1, 1, 4, 4 ], [ 0, 1, 4, 1 ], [ 1, 2, 1, 1 ], [128X[104X
    [4X[28X      [ 1, 1, 1, 2 ], [ 2, 3, 1, 1 ], [ 1, 1, 2, 3 ], [ 1, 1, 3, 3 ], [128X[104X
    [4X[28X      [ 2, 2, 4, 4 ], [ 0, 2, 4, 2 ], [ 2, 3, 2, 2 ], [ 2, 2, 2, 3 ], [128X[104X
    [4X[28X      [ 2, 2, 3, 3 ], [ 3, 3, 4, 4 ], [ 0, 3, 4, 3 ], [ 3, 3, 3, 3 ] ] )[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.1-4 InvolvementTransducer[101X
  
  [33X[1;0Y[29X[2XInvolvementTransducer[102X( [3Xk[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA transducer over [10Xk[110X+1 states, with a [10Xk[110X sized alphabet.[133X
  
  [33X[0;0YAn  involvement  transducer is a transducer over [10Xk[110X+1 states, and deletes any
  number of letters in a rank encoded permutation, of rank at most [10Xk[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XInvolvementTransducer(3);[127X[104X
    [4X[28Xrec( accepting := [ 1 .. 4 ], initial := 4, states := 4, [128X[104X
    [4X[28X  transitions := [ [ 1, 1, 1, 2 ], [ 1, 0, 1, 3 ], [ 2, 1, 1, 1 ], [128X[104X
    [4X[28X      [ 2, 0, 1, 3 ], [ 3, 2, 1, 1 ], [ 3, 0, 1, 1 ], [ 1, 1, 2, 4 ], [128X[104X
    [4X[28X      [ 1, 0, 2, 1 ], [ 2, 2, 2, 4 ], [ 2, 0, 2, 2 ], [ 3, 2, 2, 2 ], [128X[104X
    [4X[28X      [ 3, 0, 2, 2 ], [ 1, 1, 3, 2 ], [ 1, 0, 3, 3 ], [ 2, 1, 3, 1 ], [128X[104X
    [4X[28X      [ 2, 0, 3, 3 ], [ 3, 1, 3, 3 ], [ 3, 0, 3, 3 ], [ 1, 1, 4, 4 ], [128X[104X
    [4X[28X      [ 1, 0, 4, 1 ], [ 2, 2, 4, 4 ], [ 2, 0, 4, 2 ], [ 3, 3, 4, 4 ], [128X[104X
    [4X[28X      [ 3, 0, 4, 4 ] ] )[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.1-5 CombineAutTransducer[101X
  
  [33X[1;0Y[29X[2XCombineAutTransducer[102X( [3Xaut[103X, [3Xtrans[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YAn automaton consisting of a combination of [10Xaut[110X and [10Xtrans[110X.[133X
  
  [33X[0;0YCombining automata and transducers is done over the natural "translation" of
  the  by  the  automaton  accepted  language  through the transducer and then
  building  a  new  automaton  that  accepts  the  new  language. The function
  [10XCombineAutTransducer[110X does this process and returns the new non-deterministic
  automaton.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xa:=Automaton("det",1,1,[[1]],[1],[1]);[127X[104X
    [4X[28X< deterministic automaton on 1 letters with 1 states >[128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(a);[127X[104X
    [4X[28Xa*[128X[104X
    [4X[25Xgap>[125X [27Xt:=Transducer(2,1,[[1,2,1,2],[2,1,1,2],[127X[104X
    [4X[25X>[125X [27X[1,1,2,1],[2,2,2,1]],[1]);[127X[104X
    [4X[28Xrec( accepting := [ 1 ], initial := 1, states := 2, [128X[104X
    [4X[28X  transitions := [ [ 1, 2, 1, 2 ], [ 2, 1, 1, 2 ], [ 1, 1, 2, 1 ], [128X[104X
    [4X[28X      [ 2, 2, 2, 1 ] ] )[128X[104X
    [4X[25Xgap>[125X [27Xres:=CombineAutTransducer(a,t);[127X[104X
    [4X[28X< non deterministic automaton on 2 letters with 2 states >[128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(res);[127X[104X
    [4X[28X(ba)*[128X[104X
    [4X[25Xgap>[125X [27XDisplay(res);[127X[104X
    [4X[28X   |  1       2[128X[104X
    [4X[28X-------------------[128X[104X
    [4X[28X a |         [ 1 ]   [128X[104X
    [4X[28X b | [ 2 ]           [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X6.2 [33X[0;0YFrom Class to Basis and vice versa[133X[101X
  
  [1X6.2-1 BasisAutomaton[101X
  
  [33X[1;0Y[29X[2XBasisAutomaton[102X( [3Xa[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YAn  automaton  that  accepts  the rank encoded permutations of the
            basis of the input automaton [10Xa[110X.[133X
  
  [33X[0;0YEvery  pattern  class  has  a  basis  that  consists  of the smallest set of
  permutations which do not belong to the class. Using[133X
  
  
  [24X[33X[0;6YB(L)=(L^r D^t)^r ∩ L^c[133X[124X
  
  [33X[0;0Yit  is  possible  using  the  deletion transducer [22XD[122X and the language of rank
  encoded permutations [22XL[122X to find the language of the rank encoded permutations
  of the basis [22XB(L)[122X, and thus the basis.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=Parstacks(2,2);[127X[104X
    [4X[28X[ [ 2, 4 ], [ 3, 6 ], [ 2 ], [ 5, 6 ], [ 4 ], [  ] ][128X[104X
    [4X[25Xgap>[125X [27Xxa:=GraphToAut(x,1,6);[127X[104X
    [4X[28X< epsilon automaton on 5 letters with 66 states >[128X[104X
    [4X[25Xgap>[125X [27Xma:=MinimalAutomaton(xa);[127X[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(ma);[127X[104X
    [4X[28X   |  1  2  3  4  5  6  7  8  9  [128X[104X
    [4X[28X--------------------------------[128X[104X
    [4X[28X a |  1  2  1  3  2  2  6  6  3  [128X[104X
    [4X[28X b |  3  2  3  3  4  3  6  9  3  [128X[104X
    [4X[28X c |  9  2  9  4  6  6  4  9  9  [128X[104X
    [4X[28X d |  8  2  8  7  5  5  7  8  8  [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
    [4X[25Xgap>[125X [27Xba:=BasisAutomaton(ma);[127X[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(ba);[127X[104X
    [4X[28X   |  1  2  3  4  5  6  7  8  9  [128X[104X
    [4X[28X--------------------------------[128X[104X
    [4X[28X a |  2  2  1  3  4  2  2  2  2  [128X[104X
    [4X[28X b |  2  2  2  2  2  4  1  2  8  [128X[104X
    [4X[28X c |  2  2  2  2  2  2  1  2  2  [128X[104X
    [4X[28X d |  2  2  2  9  2  2  5  6  2  [128X[104X
    [4X[28XInitial state:    [ 7 ][128X[104X
    [4X[28XAccepting states: [ 1, 5 ][128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(ba);[127X[104X
    [4X[28Xd(a(dbdb)*aaU@)UbUc[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [33X[0;0YIgnoring  the  trailing  [10XUbUc[110X  which essentially are noise, the basis of the
  pattern  class  indicates  which permutations are avoided in this particular
  class.  The  shortest  permutation  in  the  basis,  looking at the rational
  expression,  is  [22Xdaaa[122X,  which  can  be translated to 4111 and decoded to the
  permutation 4123.[133X
  
  [1X6.2-2 ClassAutomaton[101X
  
  [33X[1;0Y[29X[2XClassAutomaton[102X( [3Xa[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe automaton that accepts permutations of the class in their rank
            encoding.[133X
  
  [33X[0;0YThe  function  [10XClassAutomaton[110X  does  the  reverse process of [10XBasisAutomaton[110X.
  Namely  it  takes  the  automaton  that  represents the language of the rank
  encoded basis of a permutation class, and using the formula[133X
  
  
  [24X[33X[0;6YL=B_k ∩ ((B(L)^r I^t)^c )^r[133X[124X
  
  [33X[0;0Yreturns  the  automaton  that  accepts  the rank encoded permutations of the
  class. In the formula, [22XB_k[122X is the automaton that accepts all permutations of
  any  length  with  highest rank [22Xk[122X, [22XB(L)[122X is the automaton that represents the
  basis and [22XI[122X is the involement transducer.[133X
  
  [4X[32X  Example  [32X[104X
    [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[104X
    [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[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27Xca:=ClassAutomaton(xa); [127X[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(ca);[127X[104X
    [4X[28X   |  1  2  3  4  5  6  7  8  9  [128X[104X
    [4X[28X--------------------------------[128X[104X
    [4X[28X a |  1  2  1  3  2  2  6  6  3  [128X[104X
    [4X[28X b |  3  2  3  3  4  3  6  9  3  [128X[104X
    [4X[28X c |  9  2  9  4  6  6  4  9  9  [128X[104X
    [4X[28X d |  8  2  8  7  5  5  7  8  8  [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
    [4X[25Xgap>[125X [27XIsPossibleGraphAut(ca);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.2-3 BoundedClassAutomaton[101X
  
  [33X[1;0Y[29X[2XBoundedClassAutomaton[102X( [3Xk[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YAn  automaton  that  accepts  all  rank encoded permutations, with
            highest rank being [10Xk[110X.[133X
  
  [33X[0;0YThe  bounded  class automaton, is an automaton that accepts all rank encoded
  permutations, of any length, with highest rank [10Xk[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XBoundedClassAutomaton(3);[127X[104X
    [4X[28X< deterministic automaton on 3 letters with 3 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(last);[127X[104X
    [4X[28X   |  1  2  3  [128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  1  1  2  [128X[104X
    [4X[28X b |  2  2  2  [128X[104X
    [4X[28X c |  3  3  3  [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.2-4 ClassAutFromBaseEncoding[101X
  
  [33X[1;0Y[29X[2XClassAutFromBaseEncoding[102X( [3Xbase[103X, [3Xk[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe   class   automaton   from   a  list  of  rank  encoded  basis
            permutations.[133X
  
  [33X[0;0YGiven  the  permutations  in  the basis, in their rank encoded form, and the
  bound of the rank of the permutations of the class, [10XClassAutFromBaseEncoding[110X
  builds the automaton that accepts rank encoded permutations of the class.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XClassAutFromBaseEncoding([[4,1,1,1]],4); [127X[104X
    [4X[28X< deterministic automaton on 4 letters with 7 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(last);[127X[104X
    [4X[28X   |  1  2  3  4  5  6  7  [128X[104X
    [4X[28X--------------------------[128X[104X
    [4X[28X a |  1  2  1  3  2  2  6  [128X[104X
    [4X[28X b |  3  2  3  3  4  3  4  [128X[104X
    [4X[28X c |  4  2  4  4  6  6  4  [128X[104X
    [4X[28X d |  7  2  7  7  5  5  7  [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.2-5 ClassAutFromBase[101X
  
  [33X[1;0Y[29X[2XClassAutFromBase[102X( [3Xperms[103X, [3Xk[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe class automaton from a list of permutations of the basis.[133X
  
  [33X[0;0YTaking [10Xperms[110X which is the list of permutations in the basis and [10Xk[110X an integer
  which  indicates  the highest rank in the encoded permutations of the class,
  [10XClassAutFromBase[110X  constructs the automaton that accepts the language of rank
  encoded permutations of the class.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XClassAutFromBase([[4,1,2,3]],4);[127X[104X
    [4X[28X< deterministic automaton on 4 letters with 7 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(last);[127X[104X
    [4X[28X   |  1  2  3  4  5  6  7  [128X[104X
    [4X[28X--------------------------[128X[104X
    [4X[28X a |  1  2  1  3  2  2  6  [128X[104X
    [4X[28X b |  3  2  3  3  4  3  4  [128X[104X
    [4X[28X c |  4  2  4  4  6  6  4  [128X[104X
    [4X[28X d |  7  2  7  7  5  5  7  [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.2-6 ExpandAlphabet[101X
  
  [33X[1;0Y[29X[2XExpandAlphabet[102X( [3Xa[103X, [3XnewAlphabet[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe automaton [10Xa[110X, over the alphabet of size [10XnewAlphabet[110X.[133X
  
  [33X[0;0YGiven  an automaton and the size of the new alphabet, which has to be bigger
  than  the size of the alphabet in [10Xa[110X , [10XExpandAlphabet[110X changes the automaton [10Xa[110X
  to  contain  an  alphabet  of  size  [10XnewAlphabet[110X.  The  new  letters have no
  transitions within the automaton.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xaut:=Automaton("det",3,2,[[2,2,3],[3,3,3]],[1],[3]);[127X[104X
    [4X[28X< deterministic automaton on 2 letters with 3 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(aut);[127X[104X
    [4X[28X   |  1  2  3  [128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  2  2  3  [128X[104X
    [4X[28X b |  3  3  3  [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 3 ][128X[104X
    [4X[25Xgap>[125X [27XExpandAlphabet(aut,4);[127X[104X
    [4X[28X< deterministic automaton on 4 letters with 3 states >[128X[104X
    [4X[25Xgap>[125X [27XDisplay(last);[127X[104X
    [4X[28X   |  1  2  3  [128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  2  2  3  [128X[104X
    [4X[28X b |  3  3  3  [128X[104X
    [4X[28X c |           [128X[104X
    [4X[28X d |           [128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 3 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X6.3 [33X[0;0YDirect Sum of Regular Classes[133X[101X
  
  [33X[0;0YIt  is  obvious  that the direct sum of two rational pattern classes is also
  rational.  But  the  skew sum of two rational pattern classes does not imply
  that the resulting pattern class is rational, because if the second class in
  the sum has infinitely many permutations, the alphabet of the skew sum class
  will be infinite and thusly the resulting class will not be rational.[133X
  
  [1X6.3-1 ClassDirectSum[101X
  
  [33X[1;0Y[29X[2XClassDirectSum[102X( [3Xaut1[103X, [3Xaut2[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YAn automaton that corresponds to the direct sum of [10Xaut1[110X with [10Xaut2[110X.[133X
  
  [33X[0;0Y[10XClassDirectSum[110X  builds  the concatenation automaton of [10Xaut1[110X with [10Xaut2[110X, which
  corresponds to the pattern class [10Xaut1[110X [22X⊕[122X [10Xaut2[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xa:=BasisAutomaton(GraphToAut(Parstacks(2,2),1,6));  [127X[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(a);                                     [127X[104X
    [4X[28Xd(a(dbdb)*aaU@)UbUc[128X[104X
    [4X[25Xgap>[125X [27Xb:=MinimalAutomaton(GraphToAut(Seqstacks(2,2),1,6));[127X[104X
    [4X[28X< deterministic automaton on 3 letters with 3 states >[128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(b);                                     [127X[104X
    [4X[28X((cc*(aUb)Ub)(cc*(aUb)Ub)*aUa)*[128X[104X
    [4X[25Xgap>[125X [27Xab:=ClassDirectSum(a,b);                            [127X[104X
    [4X[28X< deterministic automaton on 4 letters with 11 states >[128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(ab);                                    [127X[104X
    [4X[28X((d(acUc)c*(aUb)Ud(abUb))(cc*(aUb)Ub)*aUda(d(bdbd)*bdbaaUa)UbUc)((cc*(aUb)U\[128X[104X
    [4X[28Xb)(cc*(aUb)Ub)*aUa)*Ud(aU@)[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X6.4 [33X[0;0YStatistical Inspections[133X[101X
  
  [33X[0;0YIt  is of interest to see what permutations and how many of different length
  are accepted by the class, respectively the basis.[133X
  
  [33X[0;0YIn  this section, the examples will be inspecting the basis automaton of the
  token  passing network containing 2 stacks of capacity 2, which are situated
  in parallel to each other.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=Parstacks(2,2);[127X[104X
    [4X[28X[ [ 2, 4 ], [ 3, 6 ], [ 2 ], [ 5, 6 ], [ 4 ], [  ] ][128X[104X
    [4X[25Xgap>[125X [27Xxa:=GraphToAut(x,1,6);[127X[104X
    [4X[28X< epsilon automaton on 5 letters with 66 states >[128X[104X
    [4X[25Xgap>[125X [27Xma:=MinimalAutomaton(xa);[127X[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27Xba:=BasisAutomaton(ma);[127X[104X
    [4X[28X< deterministic automaton on 4 letters with 9 states >[128X[104X
    [4X[25Xgap>[125X [27XAutToRatExp(ba);[127X[104X
    [4X[28Xd(a(dbdb)*aaU@)UbUc[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.4-1 Spectrum[101X
  
  [33X[1;0Y[29X[2XSpectrum[102X( [3Xaut[103X[, [3Xint[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list  indicating how many words of each length from 1 to [10Xint[110X or
            15 (default) are accepted by the automaton.[133X
  
  [33X[0;0YEach entry in the returned list indicates how many words of length the index
  of the entry are accepted by the automaton [10Xaut[110X. The length of the list is by
  default  15,  but  if  this  is  too  much or too little the second optional
  argument regulates the length of the list.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XSpectrum(ba);[127X[104X
    [4X[28X[ 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ][128X[104X
    [4X[25Xgap>[125X [27XSpectrum(ba,20);[127X[104X
    [4X[28X[ 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.4-2 NumberAcceptedWords[101X
  
  [33X[1;0Y[29X[2XNumberAcceptedWords[102X( [3Xaut[103X, [3Xlen[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe number of words of length [10Xlen[110X accepted by the automaton [10Xaut[110X.[133X
  
  [33X[0;0YGiven  the automaton [10Xaut[110X and the integer [10Xlen[110X, [10XNumberAcceptedWords[110X determines
  how many words of length [10Xlen[110X are accepted by the automaton.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XNumberAcceptedWords(ba,1);[127X[104X
    [4X[28X3[128X[104X
    [4X[25Xgap>[125X [27XNumberAcceptedWords(ba,16);[127X[104X
    [4X[28X1[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.4-3 AutStateTransitionMatrix[101X
  
  [33X[1;0Y[29X[2XAutStateTransitionMatrix[102X( [3Xaut[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  matrix  containing  the number of transitions between states of
            the automaton [10Xaut[110X.[133X
  
  [33X[0;0YIn  the  matrix computed by [10XAutStateTransitionMatrix[110X the rows are indexed by
  the  state the transitions are originating from, the columnns are indexed by
  the  states  the  transitions  are ending at. Each entry [22Xa_i,j[122X of the matrix
  represents the number of transitions from the state [22Xi[122X to the state [22Xj[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XAutStateTransitionMatrix(ba);[127X[104X
    [4X[28X[ [ 0, 4, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 4, 0, 0, 0, 0, 0, 0, 0 ], [128X[104X
    [4X[28X  [ 1, 3, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 2, 1, 0, 0, 0, 0, 0, 1 ], [128X[104X
    [4X[28X  [ 0, 3, 0, 1, 0, 0, 0, 0, 0 ], [ 0, 3, 0, 1, 0, 0, 0, 0, 0 ], [128X[104X
    [4X[28X  [ 2, 1, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 3, 0, 0, 0, 1, 0, 0, 0 ], [128X[104X
    [4X[28X  [ 0, 3, 0, 0, 0, 0, 0, 1, 0 ] ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.4-4 AcceptedWords[101X
  
  [33X[1;0Y[29X[2XAcceptedWords[102X( [3Xaut[103X, [3Xint[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YAll words of length [10Xint[110X that are accepted by the automaton [10Xaut[110X.[133X
  
  [33X[0;0Y[10XAcceptedWords[110X  outputs all permutations accepted by the automaton [10Xaut[110X, which
  have  length  [10Xint[110X,  in  a  list.  The  permutations are output in their rank
  encoding.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XAcceptedWords(ba,1);[127X[104X
    [4X[28X[ [ 2 ], [ 3 ], [ 4 ] ][128X[104X
    [4X[25Xgap>[125X [27XAcceptedWords(ba,16);[127X[104X
    [4X[28X[ [ 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 1, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X6.4-5 AcceptedWordsR[101X
  
  [33X[1;0Y[29X[2XAcceptedWordsR[102X( [3Xaut[103X, [3Xint1[103X[, [3Xint2[103X] ) [32X function[133X
  [33X[1;0Y[29X[2XAcceptedWordsReversed[102X( [3Xaut[103X, [3Xint1[103X[, [3Xint2[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  list  of  all by the automaton accepted words of length [10Xint1[110X,
            where each word is written in reverse.[133X
  
  [33X[0;0YThe  functions  [10XAcceptedWordsR[110X  and [10XAcceptedWordsReversed[110X are synonymous and
  take  the  following  arguments;  an  automaton  [10Xaut[110X,  an integer [10Xint1[110X which
  indicates  the  length of the words that are accepted by the [10Xaut[110X and another
  integer  [10Xint2[110X which is optional and represents the initial state of [10Xaut[110X. The
  return  value  of these functions is the list containing all permutations of
  length  [10Xint1[110X that are accepted by [10Xaut[110X. The permutations are rank encoded and
  written in reverse.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XAcceptedWordsR(ba,1);[127X[104X
    [4X[28X[ [ 2 ], [ 3 ], [ 4 ] ][128X[104X
    [4X[25Xgap>[125X [27XAcceptedWordsReversed(ba,16); [127X[104X
    [4X[28X[ [ 1, 1, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 1, 4 ] ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
