  
  [1X6 Linear machines and elements[0X
  
  [13XLinear[0m  machines are a special class of FR machines, in which the stateset Q
  and  the  alphabet X are vector spaces over a field Bbbk, and the transition
  map  phi:  Qotimes  X->  Xotimes  Q is a linear map; furthermore, there is a
  functional pi:Q->Bbbk called the [13Xoutput[0m.
  
  As  before,  a  choice  of initial state qin Q induces a linear map q:T(X)->
  T(X),  where  T(X)=bigoplus X^otimes n is the tensor algebra generated by X.
  This  map  is  defined  as  follows: given x=x_1otimesdotsotimes x_nin T(X),
  rewrite  qotimes  x  as  a sum of expressions of the form yotimes r with yin
  T(X) and rin Q; then q, by definition, maps x to the sum of the pi(r)y.
  
  There are two sorts of linear machines: [13Xvector machines[0m, for which the state
  space  is  a  finite-dimensional  vector  space  over  a  field; and [13Xalgebra
  machines[0m,  for  which  the  state space is a free algebra in a finite set of
  variables.
  
  In  a  vector machine, the transition and output maps are stored as a matrix
  and  a  vector respectively. Minimization algorithms are implemented, as for
  Mealy machines.
  
  In an algebra machine, the transition and output maps are stored as words in
  the algebra. These machines are natural extensions of group/monoid/semigroup
  machines.
  
  Linear elements are given by a linear machine and an initial state. They can
  be  added  and  multiplied,  and  act on the tensor algebra of the alphabet,
  admitting natural representations as matrices.
  
  
  [1X6.1 Methods and operations for [10XLinearFRMachine[1Xs and [10XLinearFRElement[1Xs[0X
  
  [1X6.1-1 VectorMachine[0m
  
  [2X> VectorMachine( [0X[3Xdomain, transitions, output[0X[2X ) ____________________[0Xoperation
  [2X> VectorElement( [0X[3Xdomain, transitions, output, init[0X[2X ) ______________[0Xoperation
  [2X> VectorMachineNC( [0X[3Xfam, transitions, output[0X[2X ) _____________________[0Xoperation
  [2X> VectorElementNC( [0X[3Xfam, transitions, output, init[0X[2X ) _______________[0Xoperation
  [6XReturns:[0X  A new vector machine/element.
  
  This function constructs a new linear machine or element, of vector type.
  
  [3Xtransitions[0m is a matrix of matrices; for [10Xa,b[0m indices of basis vectors of the
  alphabet,  [10Xtransitions[a][b][0m  is  a  square  matrix indexed by the stateset,
  which  is  the transition to be effected on the stateset upon the output a->
  b.
  
  [3Xoutput[0m and [3Xinit[0m are vectors in the stateset.
  
  In  the  "NC"  version,  no  tests are performed to check that the arguments
  contain  values  within bounds, or even of the right type (beyond the simple
  checking performed by [5XGAP[0m's method selection algorithms). The first argument
  should  be the family of the resulting object. These "NC" methods are mainly
  used internally by the package.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> M := VectorMachine(Rationals,[[[[1]],[[2]]],[[[3]],[[4]]]],[1]);[0X
    [4X<Linear machine on alphabet Rationals^2 with 1-dimensional stateset>[0X
    [4Xgap> Display(M);[0X
    [4X Rationals | 1 | 2 |[0X
    [4X-----------+---+---+[0X
    [4X         1 | 1 | 2 |[0X
    [4X-----------+---+---+[0X
    [4X         2 | 3 | 4 |[0X
    [4X-----------+---+---+[0X
    [4XOutput: 1[0X
    [4Xgap> A := VectorElement(Rationals,[[[[1]],[[2]]],[[[3]],[[4]]]],[1],[1]);[0X
    [4X<Linear element on alphabet Rationals^2 with 1-dimensional stateset>[0X
    [4Xgap> Display(Activity(A,2));[0X
    [4X[ [   1,   2,   2,   4 ],[0X
    [4X  [   3,   4,   6,   8 ],[0X
    [4X  [   3,   6,   4,   8 ],[0X
    [4X  [   9,  12,  12,  16 ] ][0X
    [4Xgap> DecompositionOfFRElement(A);[0X
    [4X[ [ <Linear element on alphabet Rationals^2 with 1-dimensional stateset>,[0X
    [4X      <Linear element on alphabet Rationals^2 with 1-dimensional stateset> ],[0X
    [4X  [ <Linear element on alphabet Rationals^2 with 1-dimensional stateset>,[0X
    [4X      <Linear element on alphabet Rationals^2 with 1-dimensional stateset> ] ][0X
    [4Xgap> last=[[A,2*A],[3*A,4*A]];[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-2 AlgebraMachine[0m
  
  [2X> AlgebraMachine( [0X[3X[domain, ]ring, transitions, output[0X[2X ) ___________[0Xoperation
  [2X> AlgebraElement( [0X[3X[domain, ]ring, transitions, output, init[0X[2X ) _____[0Xoperation
  [2X> AlgebraMachineNC( [0X[3Xfam, ring, transitions, output[0X[2X ) ______________[0Xoperation
  [2X> AlgebraElementNC( [0X[3Xfam, ring, transitions, output, init[0X[2X ) ________[0Xoperation
  [6XReturns:[0X  A new algebra machine/element.
  
  This function constructs a new linear machine or element, of algebra type.
  
  [3Xring[0m  is  a  free  associative  algebra,  optionally with one. [3Xdomain[0m is the
  vector  space  on  which  the  alphabet is defined. If absent, this argument
  defaults to the [2XLeftActingDomain[0m ([14XReference: LeftActingDomain[0m) of [3Xring[0m.
  
  [3Xtransitions[0m  is a list of matrices; for each generator number i of [3Xring[0m, the
  matrix  [10Xtransitions[i][0m, with entries in [3Xring[0m, describes the decomposition of
  generator i as a matrix.
  
  [3Xoutput[0m is a vector over [3Xdomain[0m, and [3Xinit[0m is a vector over [3Xring[0m.
  
  In  the  "NC"  version,  no  tests are performed to check that the arguments
  contain  values  within bounds, or even of the right type (beyond the simple
  checking performed by [5XGAP[0m's method selection algorithms). The first argument
  should  be the family of the resulting object. These "NC" methods are mainly
  used internally by the package.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> F := FreeAssociativeAlgebraWithOne(Rationals,1);;[0X
    [4Xgap> A := AlgebraMachine(F,[[[F.1,F.1^2+F.1],[One(F),Zero(F)]]],[1]);[0X
    [4X<Linear machine on alphabet Rationals^2 with generators [ (1)*x.1 ]>[0X
    [4Xgap> Display(A);[0X
    [4X Rationals |     1     |     2     |[0X
    [4X-----------+-----------+-----------+[0X
    [4X         1 |       x.1 | x.1+x.1^2 |[0X
    [4X-----------+-----------+-----------+[0X
    [4X         2 |         1 |         0 |[0X
    [4X-----------+-----------+-----------+[0X
    [4XOutput: 1[0X
    [4Xgap> M := AlgebraElement(F,[[[F.1,F.1^2+F.1],[One(F),Zero(F)]]],[1],F.1);[0X
    [4X<Rationals^2|(1)*x.1>[0X
    [4Xgap> Display(Activity(M,2));[0X
    [4X[ [  1,  2,  4,  4 ],[0X
    [4X  [  1,  0,  2,  2 ],[0X
    [4X  [  1,  0,  0,  0 ],[0X
    [4X  [  0,  1,  0,  0 ] ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-3 Transition[0m
  
  [2X> Transition( [0X[3Xm, s, a, b[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
  performing output a-> b.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> M := AsVectorMachine(Rationals,FRMachine(GuptaSidkiGroup.2));[0X
    [4X<Linear machine on alphabet Rationals^3 with 4-dimensional stateset>[0X
    [4Xgap> Transition(M,[1,0,0,0],[1,0,0],[1,0,0]);[0X
    [4X[ 0, 1, 0, 0 ][0X
    [4Xgap> Transition(M,[1,0,0,0],[0,1,0],[0,1,0]);[0X
    [4X[ 0, 0, 1, 0 ][0X
    [4Xgap> Transition(M,[1,0,0,0],[0,0,1],[0,0,1]);[0X
    [4X[ 1, 0, 0, 0 ][0X
    [4Xgap> A := AsVectorElement(Rationals,GuptaSidkiGroup.2);[0X
    [4X<Linear element on alphabet Rationals^3 with 4-dimensional stateset>[0X
    [4Xgap> Transition(A,[1,0,0],[1,0,0]);[0X
    [4X[ 0, 1, 0, 0 ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-4 Transitions[0m
  
  [2X> Transitions( [0X[3Xm, s, a[0X[2X ) __________________________________________[0Xoperation
  [6XReturns:[0X  An vector of elements of [3Xm[0m's stateset.
  
  This  function  returns  the  state reached by [3Xm[0m when started in state [3Xs[0m and
  receiving  input [3Xa[0m. The output is a vector, indexed by the alphabet's basis,
  of output states.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> M := AsVectorMachine(Rationals,FRMachine(GuptaSidkiGroup.2));[0X
    [4X<Linear machine on alphabet Rationals^3 with 4-dimensional stateset>[0X
    [4Xgap> Transitions(M,[1,0,0,0],[1,0,0]);[0X
    [4X[ [ 0, 1, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ][0X
    [4Xgap> A := AsVectorElement(Rationals,GuptaSidkiGroup.2);[0X
    [4X<Linear element on alphabet Rationals^3 with 4-dimensional stateset>[0X
    [4Xgap> Transitions(A,[1,0,0]);[0X
    [4X[ [ 0, 1, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-5 NestedMatrixState[0m
  
  [2X> NestedMatrixState( [0X[3Xe, i, j[0X[2X ) ____________________________________[0Xoperation
  [2X> NestedMatrixCoefficient( [0X[3Xe, i, j[0X[2X ) ______________________________[0Xoperation
  [6XReturns:[0X  A coefficent of an iterated decomposition of [3Xe[0m.
  
  The  first  form  returns  the entry at position (i,j) of [3Xe[0m's decomposition.
  Both of [3Xi,j[0m are lists. The second form returns the output of the state.
  
  In           particular,          [10XNestedMatrixState(e,[],[])=e[0m,          and
  [10XActivity(e,1)[i][j]=NestedMatrixCoefficient(e,[i],[j])[0m,                  and
  [10XDecompositionOfFRElement(e,1)[i][j]=NestedMatrixState(e,[i],[j])[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> A := AsVectorElement(Rationals,GuptaSidkiGroup.2);;[0X
    [4Xgap> A=NestedMatrixState(A,[3,3],[3,3]);[0X
    [4Xtrue[0X
    [4Xgap> IsOne(NestedMatrixState(A,[3,3,3,3,1,1],[3,3,3,3,1,2]));[0X
    [4Xtrue[0X
    [4Xgap> List([1..3],i->List([1..3],j->NestedMatrixCoefficient(A,[i],[j])))=Activity(A,1);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-6 ActivitySparse[0m
  
  [2X> ActivitySparse( [0X[3Xm, i[0X[2X ) __________________________________________[0Xoperation
  [6XReturns:[0X  A sparse matrix.
  
  [10XActivity(m,i)[0m returns an n^ix n^i matrix describing the action on the i-fold
  tensor  power  of the alphabet. This matrix can also be returned as a sparse
  matrix,  and this is performed by this command. A sparse matrix is described
  as  a list of expressions of the form [10X[[i,j],c][0m, representing the elementary
  matrix  with  entry c at position (i,j). The activity matrix is then the sum
  of these elementary matrices.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> A := AsVectorElement(Rationals,GuptaSidkiGroup.2);;[0X
    [4Xgap> Display(Activity(A,2));[0X
    [4X[ [  0,  1,  0,  0,  0,  0,  0,  0,  0 ],[0X
    [4X  [  0,  0,  1,  0,  0,  0,  0,  0,  0 ],[0X
    [4X  [  1,  0,  0,  0,  0,  0,  0,  0,  0 ],[0X
    [4X  [  0,  0,  0,  0,  0,  1,  0,  0,  0 ],[0X
    [4X  [  0,  0,  0,  1,  0,  0,  0,  0,  0 ],[0X
    [4X  [  0,  0,  0,  0,  1,  0,  0,  0,  0 ],[0X
    [4X  [  0,  0,  0,  0,  0,  0,  1,  0,  0 ],[0X
    [4X  [  0,  0,  0,  0,  0,  0,  0,  1,  0 ],[0X
    [4X  [  0,  0,  0,  0,  0,  0,  0,  0,  1 ] ][0X
    [4Xgap> ActivitySparse(A,2);[0X
    [4X[ [ [ 1, 2 ], 1 ], [ [ 2, 3 ], 1 ], [ [ 3, 1 ], 1 ], [ [ 4, 6 ], 1 ],[0X
    [4X[ [ 5, 4 ], 1 ], [ [ 6, 5 ], 1 ], [ [ 7, 7 ], 1 ], [ [ 8, 8 ], 1 ],[0X
    [4X[ [ 9, 9 ], 1 ] ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-7 Activities[0m
  
  [2X> Activities( [0X[3Xm, i[0X[2X ) ______________________________________________[0Xoperation
  [6XReturns:[0X  Activities of [3Xm[0m on the first [3Xi[0m levels.
  
  [10XActivity(m,i)[0m returns an n^ix n^i matrix describing the action on the i-fold
  tensor     power     of     the     alphabet.     This    command    returns
  [10XList([0..i-1],j->Activity(m,j))[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> A := AsVectorElement(Rationals,GrigorchukGroup.2);;[0X
    [4Xgap> Activities(A,3);[0X
    [4X[ [ [ 1 ] ],[0X
    [4X  [ [ 1, 0 ], [ 0, 1 ] ],[0X
    [4X  [ [ 0, 1, 0, 0 ], [ 1, 0, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ] ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-8 IsConvergent[0m
  
  [2X> IsConvergent( [0X[3Xe[0X[2X ) ________________________________________________[0Xproperty
  [6XReturns:[0X  Whether the linear element [3Xe[0m is convergent.
  
  A  linear  element  is [13Xconvergent[0m if its state at position (1,1) is equal to
  itself.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> n := 3;;[0X
    [4Xgap> shift := VectorElement(CyclotomicField(n), [[[[1,0],[0,0]],[0X
    [4X     [[0,0],[0,1]]],[[[0,1],[0,0]],[[1,0],[0,0]]]],[1,E(n)],[1,0]);[0X
    [4X<Linear element on alphabet CF(3)^2 with 2-dimensional stateset>[0X
    [4Xgap> IsConvergent(shift);[0X
    [4Xtrue[0X
    [4Xgap> Display(Activity(shift,2));[0X
    [4X[ [     1,     0,     0,     0 ],[0X
    [4X  [  E(3),     1,     0,     0 ],[0X
    [4X  [     0,  E(3),     1,     0 ],[0X
    [4X  [     0,     0,  E(3),     1 ] ][0X
    [4Xgap> Display(Activity(shift,3));[0X
    [4X[ [     1,     0,     0,     0,     0,     0,     0,     0 ],[0X
    [4X  [  E(3),     1,     0,     0,     0,     0,     0,     0 ],[0X
    [4X  [     0,  E(3),     1,     0,     0,     0,     0,     0 ],[0X
    [4X  [     0,     0,  E(3),     1,     0,     0,     0,     0 ],[0X
    [4X  [     0,     0,     0,  E(3),     1,     0,     0,     0 ],[0X
    [4X  [     0,     0,     0,     0,  E(3),     1,     0,     0 ],[0X
    [4X  [     0,     0,     0,     0,     0,  E(3),     1,     0 ],[0X
    [4X  [     0,     0,     0,     0,     0,     0,  E(3),     1 ] ][0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-9 TransposedFRElement[0m
  
  [2X> TransposedFRElement( [0X[3Xe[0X[2X ) ________________________________________[0Xoperation
  [2X> IsSymmetricFRElement( [0X[3Xe[0X[2X ) ________________________________________[0Xproperty
  [2X> IsAntisymmetricFRElement( [0X[3Xe[0X[2X ) ____________________________________[0Xproperty
  [2X> IsLowerTriangularFRElement( [0X[3Xe[0X[2X ) __________________________________[0Xproperty
  [2X> IsUpperTriangularFRElement( [0X[3Xe[0X[2X ) __________________________________[0Xproperty
  [2X> IsDiagonalFRElement( [0X[3Xe[0X[2X ) _________________________________________[0Xproperty
  [6XReturns:[0X  The elementary matrix operation/property.
  
  Since  linear  FR elements may be interpreted as infinite matrices, it makes
  sense  to  transpose  them,  test  whether they're symmetric, antisymmetric,
  diagonal, or triangular.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> n := 3;;[0X
    [4Xgap> shift := VectorElement(CyclotomicField(n), [[[[1,0],[0,0]],[0X
    [4X     [[0,0],[0,1]]],[[[0,1],[0,0]],[[1,0],[0,0]]]],[1,E(n)],[1,0]);[0X
    [4X<Linear element on alphabet CF(3)^2 with 2-dimensional stateset>[0X
    [4Xgap> Display(Activity(shift,2));[0X
    [4X[ [     1,     0,     0,     0 ],[0X
    [4X  [  E(3),     1,     0,     0 ],[0X
    [4X  [     0,  E(3),     1,     0 ],[0X
    [4X  [     0,     0,  E(3),     1 ] ][0X
    [4Xgap> Display(Activity(TransposedFRElement(shift),2));[0X
    [4X[ [     1,  E(3),     0,     0 ],[0X
    [4X  [     0,     1,  E(3),     0 ],[0X
    [4X  [     0,     0,     1,  E(3) ],[0X
    [4X  [     0,     0,     0,     1 ] ][0X
    [4Xgap> IsSymmetricFRElement(shift);[0X
    [4Xfalse[0X
    [4Xgap> IsSymmetricFRElement(shift+TransposedFRElement(shift));[0X
    [4Xtrue[0X
    [4Xgap> IsLowerTriangularFRElement(shift);[0X
    [4Xtrue[0X
    [4Xgap> IsUpperTriangularFRElement(shift);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-10 LDUDecompositionFRElement[0m
  
  [2X> LDUDecompositionFRElement( [0X[3Xe[0X[2X ) __________________________________[0Xoperation
  [6XReturns:[0X  A factorization e=LDU.
  
  Given  a  linear element [3Xe[0m, this command attempts to find a decomposition of
  the  form  e=LDU, where L is lower triangular, D is diagonal, and U is upper
  triangular (see [2XIsLowerTriangularFRElement[0m ([14X6.1-9[0m) etc.).
  
  The  result  is returned thas a list with entries L,D,U. Note that it is not
  guaranteed to succeed. For more examples, see Section [14X10.4[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> List([0..7],s->List([0..7],t->E(4)^ValuationInt(Binomial(s+t,s),2)));;[0X
    [4Xgap> A := GuessVectorElement(last);[0X
    [4X<Linear element on alphabet GaussianRationals^2 with 2-dimensional stateset>[0X
    [4Xgap> LDU := LDUDecompositionFRElement(A);[0X
    [4X[ <Linear element on alphabet GaussianRationals^2 with 4-dimensional stateset>,[0X
    [4X  <Linear element on alphabet GaussianRationals^2 with 3-dimensional stateset>,[0X
    [4X  <Linear element on alphabet GaussianRationals^2 with 4-dimensional stateset> ][0X
    [4Xgap> IsLowerTriangularFRElement(LDU[1]); IsDiagonalFRElement(LDU[2]);[0X
    [4Xtrue[0X
    [4Xtrue[0X
    [4Xgap> TransposedFRElement(LDU[1])=LDU[3];[0X
    [4Xtrue[0X
    [4Xgap> Product(LDU)=A;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-11 GuessVectorElement[0m
  
  [2X> GuessVectorElement( [0X[3Xm[0X[2X ) __________________________________________[0Xfunction
  [6XReturns:[0X  A vector element that acts like [3Xm[0m.
  
  The  arguments to this function include a matrix or list of matrices, and an
  optional ring. The return value is a vector element, over the ring if it was
  specified, that acts like the sequence of matrices.
  
  If  a  single  matrix  is  specified,  then  it  is  assumed  to represent a
  convergent element (see [2XIsConvergent[0m ([14X6.1-8[0m)).
  
  This  function  returns  [9Xfail[0m  if  it  believes that it does not have enough
  information to make a reasonable guess.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> n := 3;;[0X
    [4Xgap> shift := VectorElement(CyclotomicField(n), [[[[1,0],[0,0]],[0X
    [4X     [[0,0],[0,1]]],[[[0,1],[0,0]],,[[1,0],[0,0]]]],[1,E(n)],[1,0]);;[0X
    [4X<Linear element on alphabet CF(3)^2 with 2-dimensional stateset>[0X
    [4Xgap> GuessVectorElement(Activity(shift,3)); last=shift;[0X
    [4X<Linear element on alphabet CF(3)^2 with 2-dimensional stateset>[0X
    [4Xtrue[0X
    [4Xgap> GuessVectorElement(Inverse(Activity(shift,4)));[0X
    [4Xfail[0X
    [4Xgap> GuessVectorElement(Inverse(Activity(shift,5)));[0X
    [4X<Linear element on alphabet CF(3)^2 with 4-dimensional stateset>[0X
    [4Xgap> IsOne(last*shift);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-12 AsLinearMachine[0m
  
  [2X> AsLinearMachine( [0X[3Xr, m[0X[2X ) _________________________________________[0Xoperation
  [2X> AsLinearElement( [0X[3Xr, m[0X[2X ) _________________________________________[0Xoperation
  [6XReturns:[0X  The linear machine/element associated with [3Xm[0m.
  
  This   command  accepts  a  domain  and  an  ordinary  machine/element,  and
  constructs  the  corresponding  linear machine/element, defined by extending
  linearly the action on [1..d] to an action on r^d.
  
  If  [3Xm[0m is a Mealy machine/element, the result is a vector machine/element. If
  [3Xm[0m  is  a  group/monoid/semigroup  machine/element,  the result is an algebra
  machine/element.  To  obtain explicitly a vector or algebra machine/element,
  see [2XAsVectorMachine[0m ([14X6.1-13[0m) and [2XAsAlgebraMachine[0m ([14X6.1-14[0m).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> Display(I4Machine);[0X
    [4X   |  1     2[0X
    [4X---+-----+-----+[0X
    [4X a | c,2   c,1[0X
    [4X b | a,1   b,1[0X
    [4X c | c,1   c,2[0X
    [4X---+-----+-----+[0X
    [4Xgap> A := AsLinearMachine(Rationals,I4Machine);[0X
    [4X<Linear machine on alphabet Rationals^2 with 3-dimensional stateset>[0X
    [4XCorrespondence(A);[0X
    [4X[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ][0X
    [4Xgap> Display(A);[0X
    [4X Rationals |   1   |   2   |[0X
    [4X-----------+-------+-------+[0X
    [4X         1 | 0 0 0 | 0 0 1 |[0X
    [4X           | 1 0 0 | 0 0 0 |[0X
    [4X           | 0 0 1 | 0 0 0 |[0X
    [4X-----------+-------+-------+[0X
    [4X         2 | 0 0 1 | 0 0 0 |[0X
    [4X           | 0 1 0 | 0 0 0 |[0X
    [4X           | 0 0 0 | 0 0 1 |[0X
    [4X-----------+-------+-------+[0X
    [4XOutput: 1 1 1[0X
    [4Xgap> B := AsLinearMachine(Rationals,AsMonoidFRMachine(I4Machine));[0X
    [4X<Linear machine on alphabet Rationals^2 with generators [ (1)*m1, (1)*m2 ]>[0X
    [4Xgap> Correspondence(B);[0X
    [4XMappingByFunction( <free monoid on the generators [ m1, m2 ]>,[0X
    [4X<algebra-with-one over Rationals, with 2 generators>, function( w ) ... end )[0X
    [4Xgap> Display(B);[0X
    [4X Rationals | 1  | 2  |[0X
    [4X-----------+----+----+[0X
    [4X         1 |  0 |  1 |[0X
    [4X           | m1 |  0 |[0X
    [4X-----------+----+----+[0X
    [4X         2 |  1 |  0 |[0X
    [4X           | m2 |  0 |[0X
    [4X-----------+----+----+[0X
    [4XOutput: 1 1[0X
    [4Xgap> AsLinearElement(Rationals,I4Monoid.1)*AsLinearElement(Rationals,I4Monoid.2);[0X
    [4X<Linear element on alphabet Rationals^2 with 4-dimensional stateset>[0X
    [4Xgap> last=AsLinearElement(Rationals,I4Monoid.1*I4Monoid.2);[0X
    [4Xtrue  [0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-13 AsVectorMachine[0m
  
  [2X> AsVectorMachine( [0X[3Xr, m[0X[2X ) _________________________________________[0Xoperation
  [2X> AsVectorElement( [0X[3Xr, m[0X[2X ) _________________________________________[0Xoperation
  [6XReturns:[0X  The vector machine/element associated with [3Xm[0m.
  
  This   command  accepts  a  domain  and  an  ordinary  machine/element,  and
  constructs  the  corresponding  linear machine/element, defined by extending
  linearly  the  action  on  [1..d]  to  an action on r^d. For this command to
  succeed,  the  machine/element  [3Xm[0m  must  be  finite  state. For examples see
  [2XAsLinearMachine[0m ([14X6.1-12[0m).
  
  [1X6.1-14 AsAlgebraMachine[0m
  
  [2X> AsAlgebraMachine( [0X[3Xr, m[0X[2X ) ________________________________________[0Xoperation
  [2X> AsAlgebraElement( [0X[3Xr, m[0X[2X ) ________________________________________[0Xoperation
  [6XReturns:[0X  The algebra machine/element associated with [3Xm[0m.
  
  This   command  accepts  a  domain  and  an  ordinary  machine/element,  and
  constructs  the  corresponding  linear machine/element, defined by extending
  linearly  the  action  on  [1..d]  to  an  action  on  r^d. For examples see
  [2XAsLinearMachine[0m ([14X6.1-12[0m).
  
  [1X6.1-15 AsVectorMachine[0m
  
  [2X> AsVectorMachine( [0X[3Xm[0X[2X ) ____________________________________________[0Xoperation
  [2X> AsVectorElement( [0X[3Xm[0X[2X ) ____________________________________________[0Xoperation
  [6XReturns:[0X  The machine/element [3Xm[0m in vector form.
  
  This  command accepts a linear machine, and converts it to vector form. This
  command is not guaranteed to terminate.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> A := AsLinearElement(Rationals,I4Monoid.1);[0X
    [4X<Linear element on alphabet Rationals^2 with 2-dimensional stateset>[0X
    [4Xgap> B := AsAlgebraElement(A);[0X
    [4X<Rationals^2|(1)*x.1>[0X
    [4Xgap> C := AsVectorElement(B);[0X
    [4Xgap> A=B; B=C;[0X
    [4Xtrue[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X6.1-16 AsAlgebraMachine[0m
  
  [2X> AsAlgebraMachine( [0X[3Xm[0X[2X ) ___________________________________________[0Xoperation
  [2X> AsAlgebraElement( [0X[3Xm[0X[2X ) ___________________________________________[0Xoperation
  [6XReturns:[0X  The machine/element [3Xm[0m in algebra form.
  
  This command accepts a linear machine, and converts it to algebra form.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> A := AsLinearElement(Rationals,I4Monoid.1);[0X
    [4X<Linear element on alphabet Rationals^2 with 2-dimensional stateset>[0X
    [4Xgap> AsAlgebraElement(A)=AsAlgebraElement(Rationals,I4Monoid.1);[0X
    [4Xtrue[0X
    [4Xgap> A=AsAlgebraElement(A);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
