Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /usr/share/gap/doc/ref/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : //usr/share/gap/doc/ref/chap37.txt

  
  37 Associative Words
  
  
  37.1 Categories of Associative Words
  
  Associative  words are used to represent elements in free groups, semigroups
  and  monoids  in  GAP  (see 37.2). An associative word is just a sequence of
  letters,  where  each  letter is an element of an alphabet (in the following
  called  a generator) or its inverse. Associative words can be multiplied; in
  free  monoids  also  the  computation  of  an identity is permitted, in free
  groups also the computation of inverses (see 37.4).
  
  Different  alphabets  correspond to different families of associative words.
  There is no relation whatsoever between words in different families.
  
    Example  
    gap> f:= FreeGroup( "a", "b", "c" );
    <free group on the generators [ a, b, c ]>
    gap> gens:= GeneratorsOfGroup(f);
    [ a, b, c ]
    gap> w:= gens[1]*gens[2]/gens[3]*gens[2]*gens[1]/gens[1]*gens[3]/gens[2];
    a*b*c^-1*b*c*b^-1
    gap> w^-1;
    b*c^-1*b^-1*c*b^-1*a^-1
  
  
  Words  are displayed as products of letters. The letters are usually printed
  like  f1,  f2,  ...,  but it is possible to give user defined names to them,
  which  can  be  arbitrary strings. These names do not necessarily identify a
  unique  letter  (generator), it is possible to have several letters –even in
  the same family– that are displayed in the same way. Note also that there is
  no  relation between the names of letters and variable names. In the example
  above, we might have typed
  
    Example  
    gap> a:= f.1;; b:= f.2;; c:= f.3;;
  
  
  (Interactively,  the  function  AssignGeneratorVariables (37.2-3) provides a
  shorthand for this.) This allows us to define w more conveniently:
  
    Example  
    gap> w := a*b/c*b*a/a*c/b;
    a*b*c^-1*b*c*b^-1
  
  
  Using  homomorphisms  it is possible to express elements of a group as words
  in terms of generators, see 39.5.
  
  37.1-1 IsAssocWord
  
  IsAssocWord( obj )  Category
  IsAssocWordWithOne( obj )  Category
  IsAssocWordWithInverse( obj )  Category
  
  IsAssocWord  is  the  category  of  associative  words  in  free semigroups,
  IsAssocWordWithOne  is  the  category  of  associative words in free monoids
  (which   admit   the  operation  One  (31.10-2)  to  compute  an  identity),
  IsAssocWordWithInverse  is  the category of associative words in free groups
  (which  have an inverse). See IsWord (36.1-1) for more general categories of
  words.
  
  
  37.2 Free Groups, Monoids and Semigroups
  
  Usually  a family of associative words will be generated by constructing the
  free  object  generated  by  them.  See  FreeMonoid  (51.2-9), FreeSemigroup
  (51.1-10) for details.
  
  
  37.2-1 FreeGroup
  
  FreeGroup( [wfilt, ]rank[, name] )  function
  FreeGroup( [wfilt, ]name1, name2, ... )  function
  FreeGroup( [wfilt, ]names )  function
  FreeGroup( [wfilt, ]infinity, name, init )  function
  
  Called  with a positive integer rank, FreeGroup returns a free group on rank
  generators.  If  the optional argument name is given then the generators are
  printed as name1, name2 etc., that is, each name is the concatenation of the
  string  name  and  an  integer  from 1 to range. The default for name is the
  string "f".
  
  Called  in  the  second  form,  FreeGroup  returns  a  free group on as many
  generators as arguments, printed as name1, name2 etc.
  
  Called  in  the  third  form,  FreeGroup  returns  a  free  group on as many
  generators as the length of the list names, the i-th generator being printed
  as names[i].
  
  Called in the fourth form, FreeGroup returns a free group on infinitely many
  generators,  where the first generators are printed by the names in the list
  init, and the other generators by name and an appended number.
  
  If    the   extra   argument   wfilt   is   given,   it   must   be   either
  IsSyllableWordsFamily  or  IsLetterWordsFamily  or  IsWLetterWordsFamily  or
  IsBLetterWordsFamily. This filter then specifies the representation used for
  the  elements  of  the  free group (see 37.6). If no such filter is given, a
  letter representation is used.
  
  (For  interfacing to old code that omits the representation flag, use of the
  syllable   representation   is   also   triggered   by  setting  the  option
  FreeGroupFamilyType to the string "syllable".)
  
  37.2-2 IsFreeGroup
  
  IsFreeGroup( obj )  Category
  
  Any  group consisting of elements in IsAssocWordWithInverse (37.1-1) lies in
  the  filter IsFreeGroup; this holds in particular for any group created with
  FreeGroup (37.2-1), or any subgroup of such a group.
  
  Also see Chapter 47.
  
  37.2-3 AssignGeneratorVariables
  
  AssignGeneratorVariables( G )  operation
  
  If  G is a group, whose generators are represented by symbols (for example a
  free  group, a finitely presented group or a pc group) this function assigns
  these generators to global variables with the same names.
  
  The  aim of this function is to make it easy in interactive use to work with
  (for  example) a free group. It is a shorthand for a sequence of assignments
  of the form
  
    Example  
    var1:=GeneratorsOfGroup(G)[1];
    var2:=GeneratorsOfGroup(G)[2];
    ...
    varn:=GeneratorsOfGroup(G)[n];
  
  
  However, since overwriting global variables can be very dangerous, it is not
  permitted to use this function within a function. (If –despite this warning–
  this is done, the result is undefined.)
  
  If  the  assignment overwrites existing variables a warning is given, if any
  of the variables if write protected, or any of the generator names would not
  be a proper variable name, an error is raised.
  
  
  37.3 Comparison of Associative Words
  
  37.3-1 \=
  
  \=( w1, w2 )  operation
  
  Two associative words are equal if they are words over the same alphabet and
  if they are sequences of the same letters. This is equivalent to saying that
  the external representations of the words are equal, see 37.7 and 36.2.
  
  There  is  no universal empty word, every alphabet (that is, every family of
  words) has its own empty word.
  
    Example  
    gap> f:= FreeGroup( "a", "b", "b" );;
    gap> gens:= GeneratorsOfGroup(f);
    [ a, b, b ]
    gap> gens[2] = gens[3];
    false
    gap> x:= gens[1]*gens[2];
    a*b
    gap> y:= gens[2]/gens[2]*gens[1]*gens[2];
    a*b
    gap> x = y;
    true
    gap> z:= gens[2]/gens[2]*gens[1]*gens[3];
    a*b
    gap> x = z;
    false
  
  
  37.3-2 \<
  
  \<( w1, w2 )  operation
  
  The  ordering  of  associative  words  is defined by length and lexicography
  (this  ordering  is  called  short-lex ordering), that is, shorter words are
  smaller  than  longer  words,  and  words  of  the  same length are compared
  w.r.t. the  lexicographical  ordering induced by the ordering of generators.
  Generators  are sorted according to the order in which they were created. If
  the  generators  are  invertible  then  each  generator g is larger than its
  inverse  g^-1,  and g^-1 is larger than every generator that is smaller than
  g.
  
    Example  
    gap> f:= FreeGroup( 2 );;  gens:= GeneratorsOfGroup( f );;
    gap> a:= gens[1];;  b:= gens[2];;
    gap> One(f) < a^-1;  a^-1 < a;  a < b^-1;  b^-1 < b; b < a^2;  a^2 < a*b;
    true
    true
    true
    true
    true
    true
  
  
  37.3-3 IsShortLexLessThanOrEqual
  
  IsShortLexLessThanOrEqual( u, v )  function
  
  returns  IsLessThanOrEqualUnder(ord,  u,  v)  where  ord  is  the short less
  ordering  for  the  family  of u and v. (This is here for compatibility with
  GAP 4.2.)
  
  37.3-4 IsBasicWreathLessThanOrEqual
  
  IsBasicWreathLessThanOrEqual( u, v )  function
  
  returns  IsLessThanOrEqualUnder(ord,  u,  v)  where  ord is the basic wreath
  product  ordering for the family of u and v. (This is here for compatibility
  with GAP 4.2.)
  
  
  37.4 Operations for Associative Words
  
  The  product of two given associative words is defined as the freely reduced
  concatenation  of  the  words.  Besides the multiplication \* (31.12-1), the
  arithmetical  operators  One  (31.10-2)  (if  the word lies in a family with
  identity)  and  (if  the  generators  are  invertible) Inverse (31.10-8), \/
  (31.12-1),\^  (31.12-1),  Comm  (31.12-3),  and  LeftQuotient  (31.12-2) are
  applicable to associative words, see 31.12.
  
  See  also  MappedWord (36.3-1), an operation that is applicable to arbitrary
  words.
  
  See  Section  37.6  for  a  discussion  of  the  internal representations of
  associative words that are supported by GAP. Note that operations to extract
  or  act  on  parts  of  words  (letter or syllables) can carry substantially
  different costs, depending on the representation the words are in.
  
  37.4-1 Length
  
  Length( w )  attribute
  
  For an associative word w, Length returns the number of letters in w.
  
    Example  
    gap> f := FreeGroup("a","b");; gens := GeneratorsOfGroup(f);;
    gap> a := gens[1];; b := gens[2];;w := a^5*b*a^2*b^-4*a;;
    gap>  w; Length( w );  Length( a^17 );  Length( w^0 );
    a^5*b*a^2*b^-4*a
    13
    17
    0
  
  
  37.4-2 ExponentSumWord
  
  ExponentSumWord( w, gen )  operation
  
  For  an  associative word w and a generator gen, ExponentSumWord returns the
  number  of  times  gen  appears  in  w minus the number of times its inverse
  appears  in  w.  If  both  gen  and  its inverse do not occur in w then 0 is
  returned. gen may also be the inverse of a generator.
  
    Example  
    gap> w;  ExponentSumWord( w, a );  ExponentSumWord( w, b );
    a^5*b*a^2*b^-4*a
    8
    -3
    gap> ExponentSumWord( (a*b*a^-1)^3, a );  ExponentSumWord( w, b^-1 );
    0
    3
  
  
  37.4-3 Subword
  
  Subword( w, from, to )  operation
  
  For  an  associative  word  w and two positive integers from and to, Subword
  returns  the  subword of w that begins at position from and ends at position
  to. Indexing is done with origin 1.
  
    Example  
    gap> w;  Subword( w, 3, 7 );
    a^5*b*a^2*b^-4*a
    a^3*b*a
  
  
  37.4-4 PositionWord
  
  PositionWord( w, sub, from )  operation
  
  Let   w  and  sub  be  associative  words,  and  from  a  positive  integer.
  PositionWord  returns  the  position  of  the  first  occurrence of sub as a
  subword  of  w,  starting  at position from. If there is no such occurrence,
  fail is returned. Indexing is done with origin 1.
  
  In  other  words,  PositionWord(  w,  sub,  from ) is the smallest integer i
  larger  than or equal to from such that Subword( w, i, i+Length( sub )-1 ) =
  sub, see Subword (37.4-3).
  
    Example  
    gap> w;  PositionWord( w, a/b, 1 );
    a^5*b*a^2*b^-4*a
    8
    gap> Subword( w, 8, 9 );
    a*b^-1
    gap> PositionWord( w, a^2, 1 );
    1
    gap> PositionWord( w, a^2, 2 );
    2
    gap> PositionWord( w, a^2, 6 );
    7
    gap> PositionWord( w, a^2, 8 );
    fail
  
  
  
  37.4-5 SubstitutedWord
  
  SubstitutedWord( w, from, to, by )  operation
  SubstitutedWord( w, sub, from, by )  operation
  
  Let w be an associative word.
  
  In  the first form, SubstitutedWord returns the associative word obtained by
  replacing the subword of w that begins at position from and ends at position
  to  by  the  associative  word  by.  from  and to must be positive integers,
  indexing  is  done  with origin 1. In other words, SubstitutedWord( w, from,
  to,  by ) is the product of the three words Subword( w, 1, from-1 ), by, and
  Subword( w, to+1, Length( w ) ), see Subword (37.4-3).
  
  In the second form, SubstitutedWord returns the associative word obtained by
  replacing the first occurrence of the associative word sub of w, starting at
  position  from,  by the associative word by; if there is no such occurrence,
  fail is returned.
  
    Example  
    gap> w;  SubstitutedWord( w, 3, 7, a^19 );
    a^5*b*a^2*b^-4*a
    a^22*b^-4*a
    gap> SubstitutedWord( w, a, 6, b^7 );
    a^5*b^8*a*b^-4*a
    gap> SubstitutedWord( w, a*b, 6, b^7 );
    fail
  
  
  37.4-6 EliminatedWord
  
  EliminatedWord( w, gen, by )  operation
  
  For  an  associative  word  w,  a generator gen, and an associative word by,
  EliminatedWord  returns  the  associative  word  obtained  by replacing each
  occurrence of gen in w by by.
  
    Example  
    gap> w;  EliminatedWord( w, a, a^2 );  EliminatedWord( w, a, b^-1 );
    a^5*b*a^2*b^-4*a
    a^10*b*a^4*b^-4*a^2
    b^-11
  
  
  
  37.5 Operations for Associative Words by their Syllables
  
  For an associative word w = x_1^{n_1} x_2^{n_2} ⋯ x_k^{n_k} over an alphabet
  containing  x_1,  x_2,  ...,  x_k, such that x_i ≠ x_{i+1}^{± 1} for 1 ≤ i ≤
  k-1,  the  subwords  x_i^{e_i}  are  uniquely  determined;  these  powers of
  generators are called the syllables of w.
  
  37.5-1 NumberSyllables
  
  NumberSyllables( w )  attribute
  
  NumberSyllables returns the number of syllables of the associative word w.
  
  37.5-2 ExponentSyllable
  
  ExponentSyllable( w, i )  operation
  
  ExponentSyllable   returns   the  exponent  of  the  i-th  syllable  of  the
  associative word w.
  
  37.5-3 GeneratorSyllable
  
  GeneratorSyllable( w, i )  operation
  
  GeneratorSyllable  returns  the  number of the generator that is involved in
  the i-th syllable of the associative word w.
  
  37.5-4 SubSyllables
  
  SubSyllables( w, from, to )  operation
  
  SubSyllables  returns the subword of the associative word w that consists of
  the  syllables from positions from to to, where from and to must be positive
  integers, and indexing is done with origin 1.
  
    Example  
    gap> w;  NumberSyllables( w );
    a^5*b*a^2*b^-4*a
    5
    gap> ExponentSyllable( w, 3 );
    2
    gap> GeneratorSyllable( w, 3 );
    1
    gap> SubSyllables( w, 2, 3 );
    b*a^2
  
  
  
  37.6 Representations for Associative Words
  
  GAP  provides two different internal kinds of representations of associative
  words.  The first one are syllable representations in which words are stored
  in syllable (i.e. generator,exponent) form. (Older versions of GAP only used
  this  representation.)  The  second kind are letter representations in which
  each  letter  in a word is represented by its index number. Negative numbers
  are  used  for  inverses.  Unless  the  syllable representation is specified
  explicitly  when  creating  the  free  group/monoid  or  semigroup, a letter
  representation is used by default.
  
  Depending  on  the  task  in  mind, either of these two representations will
  perform  better in time or in memory use and algorithms that are syllable or
  letter  based  (for example GeneratorSyllable (37.5-3) and Subword (37.4-3))
  perform  substantially  better  in  the  corresponding  representation.  For
  example  when  creating  pc  groups  (see 46),  it  is advantageous to use a
  syllable  representation  while  calculations in free groups usually benefit
  from using a letter representation.
  
  37.6-1 IsLetterAssocWordRep
  
  IsLetterAssocWordRep( obj )  Representation
  
  A  word in letter representation stores a list of generator/inverses numbers
  (as  given  by LetterRepAssocWord (37.6-8)). Letter access is fast, syllable
  access is slow for such words.
  
  37.6-2 IsLetterWordsFamily
  
  IsLetterWordsFamily( obj )  Category
  
  A letter word family stores words by default in letter form.
  
  Internally,  there  are letter representations that use integers (4 Byte) to
  represent  a  generator  and letter representations that use single bytes to
  represent a character. The latter are more memory efficient, but can only be
  used  if  there are less than 128 generators (in which case they are used by
  default).
  
  37.6-3 IsBLetterAssocWordRep
  
  IsBLetterAssocWordRep( obj )  Representation
  IsWLetterAssocWordRep( obj )  Representation
  
  these  two  subrepresentations  of  IsLetterAssocWordRep  (37.6-1)  indicate
  whether  the word is stored as a list of bytes (in a string) or as a list of
  integers).
  
  37.6-4 IsBLetterWordsFamily
  
  IsBLetterWordsFamily( obj )  Category
  IsWLetterWordsFamily( obj )  Category
  
  These  two subcategories of IsLetterWordsFamily (37.6-2) specify the type of
  letter representation to be used.
  
  37.6-5 IsSyllableAssocWordRep
  
  IsSyllableAssocWordRep( obj )  Representation
  
  A word in syllable representation stores generator/exponents pairs (as given
  by ExtRepOfObj (79.16-1). Syllable access is fast, letter access is slow for
  such words.
  
  37.6-6 IsSyllableWordsFamily
  
  IsSyllableWordsFamily( obj )  Category
  
  A  syllable  word family stores words by default in syllable form. There are
  also  different  versions  of  syllable  representations,  which  compress a
  generator  exponent  pair  in  8,  16  or 32 bits or use a pair of integers.
  Internal mechanisms try to make this as memory efficient as possible.
  
  37.6-7 Is16BitsFamily
  
  Is16BitsFamily( obj )  Category
  Is32BitsFamily( obj )  Category
  IsInfBitsFamily( obj )  Category
  
  Regardless  of the internal representation used, it is possible to convert a
  word  in  a  list  of  numbers in letter or syllable representation and vice
  versa.
  
  37.6-8 LetterRepAssocWord
  
  LetterRepAssocWord( w[, gens] )  operation
  
  The  letter  representation  of an associated word is as a list of integers,
  each  entry  corresponding  to a group generator. Inverses of the generators
  are represented by negative numbers. The generator numbers are as associated
  to the family.
  
  This operation returns the letter representation of the associative word w.
  
  In  the  call  with  two  arguments, the generator numbers correspond to the
  generator order given in the list gens.
  
  (For  words  stored  in  syllable  form  the letter representation has to be
  computed.)
  
  37.6-9 AssocWordByLetterRep
  
  AssocWordByLetterRep( Fam, lrep[, gens] )  operation
  
  takes  a  letter  representation  lrep (see LetterRepAssocWord (37.6-8)) and
  returns  an  associative  word  in  family  fam corresponding to this letter
  representation.
  
  If  gens  is  given,  the numbers in the letter representation correspond to
  gens.
  
    Example  
    gap> w:=AssocWordByLetterRep( FamilyObj(a), [-1,2,1,-2,-2,-2,1,1,1,1]);
    a^-1*b*a*b^-3*a^4
    gap> LetterRepAssocWord( w^2 );
    [ -1, 2, 1, -2, -2, -2, 1, 1, 1, 2, 1, -2, -2, -2, 1, 1, 1, 1 ]
  
  
  The  external  representation  (see  section 37.7) can be used if a syllable
  representation is needed.
  
  
  37.7 The External Representation for Associative Words
  
  The external representation of the associative word w is defined as follows.
  If  w = g_{i_1}^{e_1} * g_{i_2}^{e_2} * ⋯ * g_{i_k}^{e_k} is a word over the
  alphabet  g_1,  g_2, ..., i.e., g_i denotes the i-th generator of the family
  of w, then w has external representation [ i_1, e_1, i_2, e_2, ..., i_k, e_k
  ].  The empty list describes the identity element (if exists) of the family.
  Exponents  may  be  negative  if  the  family  allows inverses. The external
  representation  of  an  associative word is guaranteed to be freely reduced;
  for example, g_1 * g_2 * g_2^{-1} * g_1 has the external representation [ 1,
  2 ].
  
  Regardless  of  the family preference for letter or syllable representations
  (see 37.6),  ExtRepOfObj  and  ObjByExtRep can be used and interface to this
  syllable-like representation.
  
    Example  
    gap> w:= ObjByExtRep( FamilyObj(a), [1,5,2,-7,1,3,2,4,1,-2] );
    a^5*b^-7*a^3*b^4*a^-2
    gap> ExtRepOfObj( w^2 );
    [ 1, 5, 2, -7, 1, 3, 2, 4, 1, 3, 2, -7, 1, 3, 2, 4, 1, -2 ]
  
  
  
  37.8 Straight Line Programs
  
  Straight  line programs describe an efficient way for evaluating an abstract
  word  at  concrete  generators, in a more efficient way than with MappedWord
  (36.3-1).  For  example,  the  associative  word  ababbab of length 7 can be
  computed  from  the generators a, b with only four multiplications, by first
  computing  c = ab, then d = cb, and then cdc; Alternatively, one can compute
  c = ab, e = bc, and aee. In each step of these computations, one forms words
  in terms of the words computed in the previous steps.
  
  A  straight  line program in GAP is represented by an object in the category
  IsStraightLineProgram  (37.8-1))  that  stores a list of lines each of which
  has one of the following three forms.
  
  1   a nonempty dense list l of integers,
  
  2   a  pair  [  l,  i  ]  where l is a list of form 1. and i is a positive
        integer,
  
  3   a  list  [  l_1,  l_2, ..., l_k ] where each l_i is a list of form 1.;
        this may occur only for the last line of the program.
  
  The lists of integers that occur are interpreted as external representations
  of  associative  words (see Section  37.7); for example, the list [ 1, 3, 2,
  -1  ]  represents  the  word  g_1^3 g_2^{-1}, with g_1 and g_2 the first and
  second abstract generator, respectively.
  
  For  the  meaning  of  the  list  of  lines, see ResultOfStraightLineProgram
  (37.8-5).
  
  Straight   line   programs  can  be  constructed  using  StraightLineProgram
  (37.8-2).
  
  Defining      attributes      for     straight     line     programs     are
  NrInputsOfStraightLineProgram    (37.8-4)   and   LinesOfStraightLineProgram
  (37.8-3).    Another    operation    for    straight    line   programs   is
  ResultOfStraightLineProgram (37.8-5).
  
  Special  methods  applicable to straight line programs are installed for the
  operations   Display   (6.3-6),  IsInternallyConsistent  (12.8-4),  PrintObj
  (6.3-5), and ViewObj (6.3-5).
  
  For  a straight line program prog, the default Display (6.3-6) method prints
  the  interpretation  of  prog  as  a  sequence of assignments of associative
  words; a record with components gensnames (with value a list of strings) and
  listname (a string) may be entered as second argument of Display (6.3-6), in
  this  case  these names are used, the default for gensnames is [ g1, g2, ...
  ], the default for listname is r.
  
  37.8-1 IsStraightLineProgram
  
  IsStraightLineProgram( obj )  Category
  
  Each    straight    line    program    in   GAP   lies   in   the   category
  IsStraightLineProgram.
  
  37.8-2 StraightLineProgram
  
  StraightLineProgram( lines[, nrgens] )  function
  StraightLineProgram( string, gens )  function
  StraightLineProgramNC( lines[, nrgens] )  function
  StraightLineProgramNC( string, gens )  function
  
  In  the  first  form,  lines  must  be a list of lists that defines a unique
  straight  line  program  (see IsStraightLineProgram  (37.8-1)); in this case
  StraightLineProgram  returns  this program, otherwise an error is signalled.
  The optional argument nrgens specifies the number of input generators of the
  program;  if a line of form 1. (that is, a list of integers) occurs in lines
  except  in  the  last  position,  this number is not determined by lines and
  therefore   must   be   specified  by  the  argument  nrgens;  if  not  then
  StraightLineProgram returns fail.
  
  In  the  second  form,  string  must  be  a  string describing an arithmetic
  expression in terms of the strings in the list gens, where multiplication is
  denoted  by concatenation, powering is denoted by ^, and round brackets (, )
  may  be used. Each entry in gens must consist only of uppercase or lowercase
  letters  (i.e.,  letters  in  IsAlphaChar (27.5-4)) such that no entry is an
  initial  part  of  another  one. Called with this input, StraightLineProgram
  returns  a straight line program that evaluates to the word corresponding to
  string when called with generators corresponding to gens.
  
  The  NC  variant  does the same, except that the internal consistency of the
  program is not checked.
  
  37.8-3 LinesOfStraightLineProgram
  
  LinesOfStraightLineProgram( prog )  attribute
  
  For  a  straight  line  program prog, LinesOfStraightLineProgram returns the
  list  of program lines. There is no default method to compute these lines if
  they are not stored.
  
  37.8-4 NrInputsOfStraightLineProgram
  
  NrInputsOfStraightLineProgram( prog )  attribute
  
  For  a straight line program prog, NrInputsOfStraightLineProgram returns the
  number of generators that are needed as input.
  
  If  a  line  of form 1. (that is, a list of integers) occurs in the lines of
  prog except the last line then the number of generators is not determined by
  the  lines, and must be set in the construction of the straight line program
  (see StraightLineProgram  (37.8-2)).  So  if prog contains a line of form 1.
  other  than  the  last line and does not store the number of generators then
  NrInputsOfStraightLineProgram signals an error.
  
  37.8-5 ResultOfStraightLineProgram
  
  ResultOfStraightLineProgram( prog, gens )  operation
  
  ResultOfStraightLineProgram    evaluates    the    straight   line   program
  (see IsStraightLineProgram  (37.8-1)) prog at the group elements in the list
  gens.
  
  The  result  of  a  straight line program with lines p_1, p_2, ..., p_k when
  applied to gens is defined as follows.
  
  (a)
        First  a  list r of intermediate results is initialized with a shallow
        copy of gens.
  
  (b)
        For  i  < k, before the i-th step, let r be of length n. If p_i is the
        external  representation  of  an  associative  word  in  the  first  n
        generators  then the image of this word under the homomorphism that is
        given  by  mapping r to these first n generators is added to r; if p_i
        is  a  pair [ l, j ], for a list l, then the same element is computed,
        but instead of being added to r, it replaces the j-th entry of r.
  
  (c)
        For  i  =  k,  if p_k is the external representation of an associative
        word  then  the element described in (b) is the result of the program,
        if  p_k  is  a  pair  [  l,  j ], for a list l, then the result is the
        element described by l, and if p_k is a list [ l_1, l_2, ..., l_k ] of
        lists  then  the result is a list of group elements, where each l_i is
        treated as in (b).
  
    Example  
    gap> f:= FreeGroup( "x", "y" );;  gens:= GeneratorsOfGroup( f );;
    gap> x:= gens[1];;  y:= gens[2];;
    gap> prg:= StraightLineProgram( [ [] ] );
    <straight line program>
    gap> ResultOfStraightLineProgram( prg, [] );
    [  ]
  
  
  The  above  straight  line  program  prg  returns  –for  any  list  of input
  generators– an empty list.
  
    Example  
    gap> StraightLineProgram( [ [1,2,2,3], [3,-1] ] );
    fail
    gap> prg:= StraightLineProgram( [ [1,2,2,3], [3,-1] ], 2 );
    <straight line program>
    gap> LinesOfStraightLineProgram( prg );
    [ [ 1, 2, 2, 3 ], [ 3, -1 ] ]
    gap> prg:= StraightLineProgram( "(a^2b^3)^-1", [ "a", "b" ] );
    <straight line program>
    gap> LinesOfStraightLineProgram( prg );
    [ [ [ 1, 2, 2, 3 ], 3 ], [ [ 3, -1 ], 4 ] ]
    gap> res:= ResultOfStraightLineProgram( prg, gens );
    y^-3*x^-2
    gap> res = (x^2 * y^3)^-1;
    true
    gap> NrInputsOfStraightLineProgram( prg );
    2
    gap> Print( prg, "\n" );
    StraightLineProgram( [ [ [ 1, 2, 2, 3 ], 3 ], [ [ 3, -1 ], 4 ] ], 2 )
    gap> Display( prg );
    # input:
    r:= [ g1, g2 ];
    # program:
    r[3]:= r[1]^2*r[2]^3;
    r[4]:= r[3]^-1;
    # return value:
    r[4]
    gap> IsInternallyConsistent( StraightLineProgramNC( [ [1,2] ] ) );
    true
    gap> IsInternallyConsistent( StraightLineProgramNC( [ [1,2,3] ] ) );
    false
    gap> prg1:= StraightLineProgram( [ [1,1,2,2], [3,3,1,1] ], 2 );;
    gap> prg2:= StraightLineProgram( [ [ [1,1,2,2], 2 ], [2,3,1,1] ] );;
    gap> res1:= ResultOfStraightLineProgram( prg1, gens );
    (x*y^2)^3*x
    gap> res1 = (x*y^2)^3*x;
    true
    gap> res2:= ResultOfStraightLineProgram( prg2, gens );
    (x*y^2)^3*x
    gap> res2 = (x*y^2)^3*x;
    true
    gap> prg:= StraightLineProgram( [ [2,3], [ [3,1,1,4], [1,2,3,1] ] ], 2 );;
    gap> res:= ResultOfStraightLineProgram( prg, gens );
    [ y^3*x^4, x^2*y^3 ]
  
  
  37.8-6 StringOfResultOfStraightLineProgram
  
  StringOfResultOfStraightLineProgram( prog, gensnames[, "LaTeX"] )  function
  
  StringOfResultOfStraightLineProgram  returns  a  string  that  describes the
  result  of  the  straight  line program (see IsStraightLineProgram (37.8-1))
  prog as word(s) in terms of the strings in the list gensnames. If the result
  of    prog    is    a    single   element   then   the   return   value   of
  StringOfResultOfStraightLineProgram is a string consisting of the entries of
  gensnames,  opening  and  closing brackets ( and ), and powering by integers
  via  ^. If the result of prog is a list of elements then the return value of
  StringOfResultOfStraightLineProgram  is  a  comma separated concatenation of
  the strings of the single elements, enclosed in square brackets [, ].
  
    Example  
    gap> prg:= StraightLineProgram( [ [ 1, 2, 2, 3 ], [ 3, -1 ] ], 2 );;
    gap> StringOfResultOfStraightLineProgram( prg, [ "a", "b" ] );
    "(a^2b^3)^-1"
    gap> StringOfResultOfStraightLineProgram( prg, [ "a", "b" ], "LaTeX" );
    "(a^{2}b^{3})^{-1}"
  
  
  37.8-7 CompositionOfStraightLinePrograms
  
  CompositionOfStraightLinePrograms( prog2, prog1 )  function
  
  For      two     straight     line     programs     prog1     and     prog2,
  CompositionOfStraightLinePrograms  returns a straight line program prog with
  the  properties  that prog1 and prog have the same number of inputs, and the
  result  of  prog  when applied to given generators gens equals the result of
  prog2 when this is applied to the output of prog1 applied to gens.
  
  (Of  course the number of outputs of prog1 must be the same as the number of
  inputs of prog2.)
  
    Example  
    gap> prg1:= StraightLineProgram( "a^2b", [ "a","b" ] );;
    gap> prg2:= StraightLineProgram( "c^5", [ "c" ] );;
    gap> comp:= CompositionOfStraightLinePrograms( prg2, prg1 );
    <straight line program>
    gap> StringOfResultOfStraightLineProgram( comp, [ "a", "b" ] );
    "(a^2b)^5"
    gap> prg:= StraightLineProgram( [ [2,3], [ [3,1,1,4], [1,2,3,1] ] ], 2 );;
    gap> StringOfResultOfStraightLineProgram( prg, [ "a", "b" ] );
    "[ b^3a^4, a^2b^3 ]"
    gap> comp:= CompositionOfStraightLinePrograms( prg, prg );
    <straight line program>
    gap> StringOfResultOfStraightLineProgram( comp, [ "a", "b" ] );
    "[ (a^2b^3)^3(b^3a^4)^4, (b^3a^4)^2(a^2b^3)^3 ]"
  
  
  37.8-8 IntegratedStraightLineProgram
  
  IntegratedStraightLineProgram( listofprogs )  function
  
  For  a  nonempty  dense list listofprogs of straight line programs that have
  the   same  number  n,  say,  of  inputs  (see NrInputsOfStraightLineProgram
  (37.8-4))   and   for  which  the  results  (see ResultOfStraightLineProgram
  (37.8-5))   are   single   elements   (i.e.,   not   lists   of   elements),
  IntegratedStraightLineProgram  returns  a  straight line program prog with n
  inputs    such    that    for    each    n-tuple    gens    of   generators,
  ResultOfStraightLineProgram(  prog,  gens  )  is  equal  to  the  list List(
  listofprogs, p -> ResultOfStraightLineProgram( p, gens ).
  
    Example  
    gap> f:= FreeGroup( "x", "y" );;  gens:= GeneratorsOfGroup( f );;
    gap> prg1:= StraightLineProgram([ [ [ 1, 2 ], 1 ], [ 1, 2, 2, -1 ] ], 2);;
    gap> prg2:= StraightLineProgram([ [ [ 2, 2 ], 3 ], [ 1, 3, 3, 2 ] ], 2);;
    gap> prg3:= StraightLineProgram([ [ 2, 2 ], [ 1, 3, 3, 2 ] ], 2);;
    gap> prg:= IntegratedStraightLineProgram( [ prg1, prg2, prg3 ] );;
    gap> ResultOfStraightLineProgram( prg, gens );
    [ x^4*y^-1, x^3*y^4, x^3*y^4 ]
    gap> prg:= IntegratedStraightLineProgram( [ prg2, prg3, prg1 ] );;
    gap> ResultOfStraightLineProgram( prg, gens );
    [ x^3*y^4, x^3*y^4, x^4*y^-1 ]
    gap> prg:= IntegratedStraightLineProgram( [ prg3, prg1, prg2 ] );;
    gap> ResultOfStraightLineProgram( prg, gens );
    [ x^3*y^4, x^4*y^-1, x^3*y^4 ]
  
  
  37.8-9 RestrictOutputsOfSLP
  
  RestrictOutputsOfSLP( slp, k )  function
  
  slp  must  be  a  straight  line  program  returning a tuple of values. This
  function  returns  a new slp that calculates only those outputs specified by
  k.  The  argument  k  may  be  an  integer or a list of integers. If k is an
  integer,  the  resulting  slp calculates only the result with that number in
  the  original  output  tuple.  If k is a list of integers, the resulting slp
  calculates  those  results  with  indices k in the original output tuple. In
  both cases the resulting slp does only what is necessary. Obviously, the slp
  must  have  a line with enough expressions (lists) for the supplied k as its
  last  line.  slp  is  either  an slp or a pair where the first entry are the
  lines of the slp and the second is the number of inputs.
  
  37.8-10 IntermediateResultOfSLP
  
  IntermediateResultOfSLP( slp, k )  function
  
  Returns a new slp that calculates only the value of slot k at the end of slp
  doing only what is necessary. slp is either an slp or a pair where the first
  entry  are the lines of the slp and the second is the number of inputs. Note
  that  this assumes a general SLP with possible overwriting. If you know that
  your      SLP      does      not     overwrite     slots,     please     use
  IntermediateResultOfSLPWithoutOverwrite  (37.8-11),  which is much faster in
  this case.
  
  37.8-11 IntermediateResultOfSLPWithoutOverwrite
  
  IntermediateResultOfSLPWithoutOverwrite( slp, k )  function
  
  Returns a new slp that calculates only the value of slot k, which must be an
  integer.  Note  that  slp  must  not  overwrite slots but only append!!! Use
  IntermediateResultOfSLP (37.8-10) in the other case! slp is either an slp or
  a  pair  where the first entry is the lines of the slp and the second is the
  number of inputs.
  
  37.8-12 IntermediateResultsOfSLPWithoutOverwrite
  
  IntermediateResultsOfSLPWithoutOverwrite( slp, k )  function
  
  Returns  a  new slp that calculates only the value of slots contained in the
  list  k.  Note  that  slp  must  not  overwrite slots but only append!!! Use
  IntermediateResultOfSLP  (37.8-10) in the other case! slp is either a slp or
  a  pair  where the first entry is the lines of the slp and the second is the
  number of inputs.
  
  37.8-13 ProductOfStraightLinePrograms
  
  ProductOfStraightLinePrograms( s1, s2 )  function
  
  s1 and s2 must be two slps that return a single element with the same number
  of  inputs.  This function constructs an slp that returns the product of the
  two results the slps s1 and s2 would produce with the same input.
  
  37.8-14 SlotUsagePattern
  
  SlotUsagePattern( s )  attribute
  
  Analyses  the  straight  line  program s for more efficient evaluation. This
  means  in particular two things, when this attribute is known: First of all,
  intermediate results which are not actually needed later on are not computed
  at  all,  and  once an intermediate result is used for the last time in this
  SLP,  it  is  discarded. The latter leads to the fact that the evaluation of
  the SLP needs less memory.
  
  
  37.9 Straight Line Program Elements
  
  When  computing  with  very large (in terms of memory) elements, for example
  permutations  of degree a few hundred thousands, it can be helpful (in terms
  of memory usage) to represent them via straight line programs in terms of an
  original generator set. (So every element takes only small extra storage for
  the straight line program.)
  
  A  straight line program element has a seed (a list of group elements) and a
  straight line program on the same number of generators as the length of this
  seed, its value is the value of the evaluated straight line program.
  
  At  the  moment,  the entries of the straight line program have to be simple
  lists (i.e. of the first form).
  
  Straight  line  program  elements are in the same categories and families as
  the  elements  of  the  seed,  so  they  should  work together with existing
  algorithms.
  
  Note  however,  that  due to the different way of storage some normally very
  cheap  operations  (such  as  testing  for element equality) can become more
  expensive  when  dealing  with  straight  line  program  elements.  This  is
  essentially the tradeoff for using less memory.
  
  See also Section 43.13.
  
  37.9-1 IsStraightLineProgElm
  
  IsStraightLineProgElm( obj )  Representation
  
  A  straight  line  program  element  is  a  group  element given (for memory
  reasons)  as  a  straight  line  program. Straight line program elements are
  positional  objects, the first component is a record with a component seeds,
  the second component the straight line program.
  
  37.9-2 StraightLineProgElm
  
  StraightLineProgElm( seed, prog )  function
  
  Creates a straight line program element for seed seed and program prog.
  
  37.9-3 StraightLineProgGens
  
  StraightLineProgGens( gens[, base] )  function
  
  returns  a  set  of  straight  line  program  elements  corresponding to the
  generators  in gens. If gens is a set of permutations then base can be given
  which  must  be a base for the group generated by gens. (Such a base will be
  used to speed up equality tests.)
  
  37.9-4 EvalStraightLineProgElm
  
  EvalStraightLineProgElm( slpel )  function
  
  evaluates a straight line program element slpel from its seeds.
  
  37.9-5 StretchImportantSLPElement
  
  StretchImportantSLPElement( elm )  operation
  
  If elm is a straight line program element whose straight line representation
  is very long, this operation changes the representation of elm to a straight
  line  program  element,  equal to elm, whose seed contains the evaluation of
  elm and whose straight line program has length 1.
  
  For other objects nothing happens.
  
  This  operation  permits to designate important elements within an algorithm
  (elements  that  will  be  referred  to often), which will be represented by
  guaranteed short straight line program elements.
  
    Example  
    gap> gens:=StraightLineProgGens([(1,2,3,4),(1,2)]);
    [ <[ [ 2, 1 ] ]|(1,2,3,4)>, <[ [ 1, 1 ] ]|(1,2)> ]
    gap> g:=Group(gens);;
    gap> (gens[1]^3)^gens[2];
    <[ [ 1, -1, 2, 3, 1, 1 ] ]|(1,2,4,3)>
    gap> Size(g);
    24
  
  

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net