  
  [1X6 [33X[0;0YSemigroups and monoids defined by generating sets[133X[101X
  
  [33X[0;0YIn  this  chapter  we  describe the various ways that semigroups and monoids
  defined  by  generating  sets  can  be  created  in  [5XSemigroups[105X;  where  the
  generators are, for example, those elements described in earlier chapters of
  this manual.[133X
  
  
  [1X6.1 [33X[0;0YUnderlying algorithms[133X[101X
  
  [33X[0;0YComputing  the  Green's  structure of a semigroup or monoid is a fundamental
  step  in  almost  every  algorithm for semigroups. There are two fundamental
  algorithms  in the [5XSemigroups[105X package for computing the Green's structure of
  a  semigroup  defined by a set of generators. In the next two subsections we
  briefly describe these two algorithms.[133X
  
  
  [1X6.1-1 [33X[0;0YActing semigroups[133X[101X
  
  [33X[0;0YThe first of the fundamental algorithms for computing a semigroup defined by
  a  generating  set  is described in [EEMP19]. When applied to a semigroup or
  monoid  with  relatively  large  subgroups, or [13XD[113X-classes, these are the most
  efficient  methods in the [5XSemigroups[105X package. For example, the complexity of
  computing,  say, the size of a transformation semigroup that happens to be a
  group,  is  the  same  as  the  complexity  of  the  Schreier-Sims Algorithm
  (polynomial  in  the number of points acted on by the transformations) for a
  permutation group.[133X
  
  [33X[0;0YIn  theory, these algorithms can be applied to compute any subsemigroup of a
  regular  semigroup;  but  so  far  in  the  [5XSemigroups[105X package they are only
  implemented    for   semigroups   of:   transformations   (see   [14X'Reference:
  Transformations'[114X),    partial    permutations   (see   [14X'Reference:   Partial
  permutations'[114X),  bipartitions  (see Chapter [14X3[114X), matrices over a finite field
  (see  Section  [14X5.4[114X);  subsemigroups of regular Rees 0-matrix semigroups over
  permutation  groups  (see  Chapter [14X'Reference: Rees Matrix Semigroups'[114X), and
  subsemigroups of McAlister triples (see Section [14X8.4[114X).[133X
  
  [33X[0;0YWe refer to semigroups to which the algorithms in [EEMP19] can be applied as
  [13Xacting   semigroups[113X,   and   such   semigroups   belong   to   the  category
  [2XIsActingSemigroup[102X ([14X6.1-2[114X).[133X
  
  [33X[0;0YIf  you  know  [13Xa  priori[113X that the semigroup you want to compute is large and
  [13XJ[113X-trivial,  then  you  can disable the special methods for acting semigroups
  when you create the semigroups; see Section [14X6.3[114X for more details.[133X
  
  [33X[0;0YIt  is  harder for the acting semigroup algorithms to compute Green's [13XL[113X- and
  [13XH[113X-classes of a transformation semigroup and the methods used to compute with
  Green's  [13XR[113X- and [13XD[113X-classes are the most efficient in [5XSemigroups[105X. Thus, if you
  are  computing  with  a  transformation  semigroup, wherever possible, it is
  advisable  to  use  the  commands relating to Green's [13XR[113X- or [13XD[113X-classes rather
  than  those  relating  to  Green's [13XL[113X- or [13XH[113X-classes. No such difficulties are
  present  when  computing  with  the  other  types  of  acting  semigroups in
  [5XSemigroups[105X.[133X
  
  [33X[0;0YThere  are methods in [5XSemigroups[105X for computing individual Green's classes of
  an  acting  semigroup  without  computing  the  entire data structure of the
  underlying  semigroup;  see  [2XGreensRClassOfElementNC[102X  ([14X10.1-3[114X).  It  is also
  possible  to  compute  the  [13XR[113X-classes,  the  number  of  elements  and  test
  membership  in  a  semigroup  without  computing  all the elements; see, for
  example,  [2XGreensRClasses[102X  ([14X10.1-4[114X),  [2XRClassReps[102X ([14X10.1-5[114X), [2XIteratorOfRClasses[102X
  ([14X10.2-2[114X),  or [2XNrRClasses[102X ([14X10.1-9[114X). This may be useful if you want to study a
  very  large  semigroup  where computing all the elements of the semigroup is
  not feasible.[133X
  
  [1X6.1-2 IsActingSemigroup[101X
  
  [33X[1;0Y[29X[2XIsActingSemigroup[102X( [3Xobj[103X ) [32X Category[133X
  [6XReturns:[106X  [33X[0;10Y[9Xtrue[109X or [9Xfalse[109X.[133X
  
  [33X[0;0YEvery  acting  semigroup,  as  defined  in  Section  [14X6.1-1[114X,  belongs to this
  category.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([1, 3, 2]));;[127X[104X
    [4X[25Xgap>[125X [27XIsActingSemigroup(S);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XCanUseFroidurePin(S);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XS := FreeSemigroup(3);;[127X[104X
    [4X[25Xgap>[125X [27XIsActingSemigroup(S);[127X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
  
  [1X6.1-3 [33X[0;0YThe Froidure-Pin Algorithm[133X[101X
  
  [33X[0;0YThe  second  fundamental  algorithm  for  computing finite semigroups is the
  Froidure-Pin   Algorithm   [FP97].   The  [5XSemigroups[105X  package  contains  two
  implementations  of the Froidure-Pin Algorithm: one in the [5Xlibsemigroups[105X C++
  library and the other within the [5XSemigroups[105X package kernel module.[133X
  
  [33X[0;0YBoth  implementations  outperform  the algorithms for acting semigroups when
  applied  to  semigroups  with small (trivial) subgroups. This method is also
  used to determine the structure of a semigroup when the algorithms described
  in  [EEMP19] do not apply. It is possible to specify which methods should be
  applied to a given semigroup; see Section [14X6.3[114X.[133X
  
  [33X[0;0YA semigroup to which the Froidure-Pin Algorithm can be applied in [5XSemigroups[105X
  satisfy  [2XCanUseFroidurePin[102X  ([14X6.1-4[114X).  Every  acting  semigroup in [5XSemigroups[105X
  satisfies  [2XCanUseFroidurePin[102X  ([14X6.1-4[114X) and the Froidure-Pin Algorithm is used
  to compute certain properties or attributes.[133X
  
  [33X[0;0YCurrently,  the  [5Xlibsemigroups[105X  implementation of the Froidure-Pin Algorithm
  can  be applied to semigroups consisting of the following types of elements:
  transformations  (see  [14X'Reference:  Transformations'[114X),  partial permutations
  (see  [14X'Reference:  Partial  permutations'[114X),  bipartitions  (see  Chapter [14X3[114X),
  partitioned  binary  relations  (see  Chapter  [14X4[114X)  as defined in [MM13]; and
  matrices over the following semirings:[133X
  
  [30X    [33X[0;6Ythe  [13XBoolean  semiring[113X [22X{0, 1}[122X where [22X0 + 0 = 0[122X, [22X0 + 1 = 1 + 1 = 1 + 0 =
        1[122X, and [22X1⋅ 0 = 0 ⋅ 0 = 0 ⋅ 1 = 0[122X[133X
  
  [30X    [33X[0;6Yfinite fields;[133X
  
  [30X    [33X[0;6Ythe [13Xmax-plus semiring[113X of natural numbers and negative infinity [22XN∪ {-∞}[122X
        with operations max and plus;[133X
  
  [30X    [33X[0;6Ythe  [13Xmin-plus  semiring[113X  of  natural  numbers and infinity [22XN∪ {∞}[122X with
        operations min and plus;[133X
  
  [30X    [33X[0;6Ythe [13Xtropical max-plus semiring[113X [22X{-∞, 0, 1, ..., t}[122X for some threshold [22Xt[122X
        with operations max and plus;[133X
  
  [30X    [33X[0;6Ythe  [13Xtropical min-plus semiring[113X [22X{0, 1, ..., t, ∞}[122X for some threshold [22Xt[122X
        with operations min and plus;[133X
  
  [30X    [33X[0;6Ythe  semiring  [22XN_t, p = {0, 1, ..., t, t + 1, ..., t + p - 1}[122X for some
        threshold  [22Xt[122X and period [22Xp[122X under addition and multiplication modulo the
        congruence [22Xt = t + p[122X.[133X
  
  [33X[0;0Y(see Chapter [14X5[114X).[133X
  
  [33X[0;0YThe  version  of  the  Froidure-Pin Algorithm [FP97] written in C within the
  [5XSemigroups[105X  package kernel module can be used to compute any other semigroup
  in  [5XGAP[105X  which satisfies [2XCanUseGapFroidurePin[102X ([14X6.1-4[114X). In theory, any finite
  semigroup  can be computed using this algorithm. However, the condition that
  the semigroup has satisfies [2XCanUseGapFroidurePin[102X ([14X6.1-4[114X) is imposed to avoid
  this  method being used when it is inappropriate. If implementing a new type
  of semigroup in [5XGAP[105X, then simply do[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28XInstallTrueMethod(CanUseGapFroidurePin,[128X[104X
    [4X[28X                       MyNewSemigroupType);[128X[104X
  [4X[32X[104X
  
  [33X[0;0Yto  make  your new semigroup type [10XMyNewSemigroupType[110X use this version of the
  Froidure-Pin Algorithm. To make this work efficiently it is necessary that a
  hash  function  is  implemented for the elements of [10XMyNewSemigroupType[110X; more
  details will be included in a future edition of this manual.[133X
  
  [33X[0;0YMostly  due  to  the  way  that  [5XGAP[105X  handles memory, this implementation is
  approximately  4 times slower than the implementation in [5Xlibsemigroups[105X. This
  version  of  the  Froidure-Pin Algorithm is included because it applies to a
  wider  class of semigroups than those currently implemented in [5Xlibsemigroups[105X
  and  it  is more straightforward to extend the classes of semigroup to which
  it applies.[133X
  
  [1X6.1-4 CanUseFroidurePin[101X
  
  [33X[1;0Y[29X[2XCanUseFroidurePin[102X( [3Xobj[103X ) [32X property[133X
  [33X[1;0Y[29X[2XCanUseGapFroidurePin[102X( [3Xobj[103X ) [32X property[133X
  [33X[1;0Y[29X[2XCanUseLibsemigroupsFroidurePin[102X( [3Xobj[103X ) [32X property[133X
  [6XReturns:[106X  [33X[0;10Y[9Xtrue[109X or [9Xfalse[109X.[133X
  
  [33X[0;0YEvery  semigroup  satisfying  [10XCanUseFroidurePin[110X  is  a  valid  input for the
  Froidure-Pin algorithm; see Section [14X6.1-3[114X for more details.[133X
  
  [33X[0;0YBasic   operations   for   semigroups   satisfying   [10XCanUseFroidurePin[110X  are:
  [2XAsListCanonical[102X  ([14X11.1-1[114X),  [2XEnumeratorCanonical[102X  ([14X11.1-1[114X), [2XIteratorCanonical[102X
  ([14X11.1-1[114X),  [2XPositionCanonical[102X  ([14X11.1-2[114X), [2XEnumerate[102X ([14X11.1-3[114X), and [2XIsEnumerated[102X
  ([14X11.1-4[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([1, 3, 2]));;[127X[104X
    [4X[25Xgap>[125X [27XCanUseFroidurePin(S);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XS := FreeSemigroup(3);;[127X[104X
    [4X[25Xgap>[125X [27XCanUseFroidurePin(S);[127X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
  
  [1X6.2 [33X[0;0YSemigroups represented by generators[133X[101X
  
  [1X6.2-1 InverseMonoidByGenerators[101X
  
  [33X[1;0Y[29X[2XInverseMonoidByGenerators[102X( [3Xcoll[103X[, [3Xopts[103X] ) [32X operation[133X
  [33X[1;0Y[29X[2XInverseSemigroupByGenerators[102X( [3Xcoll[103X[, [3Xopts[103X] ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YAn inverse monoid or semigroup.[133X
  
  [33X[0;0YIf  [3Xcoll[103X  is  a  collection  satisfying [10XIsGeneratorsOfInverseSemigroup[110X, then
  [10XInverseMonoidByGenerators[110X   and   [10XInverseSemigroupByGenerators[110X   return  the
  inverse monoid and semigroup generated by [3Xcoll[103X, respectively.[133X
  
  [33X[0;0YIf  present, the optional second argument [3Xopts[103X should be a record containing
  the  values  of the options for the semigroup being created, as described in
  Section [14X6.3[114X.[133X
  
  
  [1X6.3 [33X[0;0YOptions when creating semigroups[133X[101X
  
  [33X[0;0YWhen using any of the functions:[133X
  
  [30X    [33X[0;6Y[2XInverseSemigroup[102X ([14XReference: InverseSemigroup[114X),[133X
  
  [30X    [33X[0;6Y[2XInverseMonoid[102X ([14XReference: InverseMonoid[114X),[133X
  
  [30X    [33X[0;6Y[2XSemigroup[102X ([14XReference: Semigroup[114X),[133X
  
  [30X    [33X[0;6Y[2XMonoid[102X ([14XReference: Monoid[114X),[133X
  
  [30X    [33X[0;6Y[2XSemigroupByGenerators[102X ([14XReference: SemigroupByGenerators[114X),[133X
  
  [30X    [33X[0;6Y[2XMonoidByGenerators[102X ([14XReference: MonoidByGenerators[114X),[133X
  
  [30X    [33X[0;6Y[2XClosureSemigroup[102X ([14X6.4-1[114X),[133X
  
  [30X    [33X[0;6Y[2XClosureMonoid[102X ([14X6.4-1[114X),[133X
  
  [30X    [33X[0;6Y[2XClosureInverseSemigroup[102X ([14X6.4-1[114X),[133X
  
  [30X    [33X[0;6Y[2XClosureInverseMonoid[102X ([14X6.4-1[114X),[133X
  
  [30X    [33X[0;6Y[2XSemigroupIdeal[102X ([14X9.1-1[114X)[133X
  
  [33X[0;0Ya  record can be given as an optional final argument. The components of this
  record  specify  the  values  of  certain  options  for  the semigroup being
  created. A list of these options and their default values is given below.[133X
  
  [33X[0;0YAssume  that  [3XS[103X is the semigroup created by one of the functions given above
  and  that  either:  [3XS[103X is generated by a collection [3Xgens[103X; or [3XS[103X is an ideal of
  such a semigroup.[133X
  
  [8X[10Xacting[110X[8X[108X
        [33X[0;6Ythis  component  should  be [9Xtrue[109X or [9Xfalse[109X. Roughly speaking, there are
        two  types  of methods in the [5XSemigroups[105X package: those for semigroups
        which  have  to  be fully enumerated, and those for semigroups that do
        not;  see  Section  [14X1.1[114X.  In  order  for a semigroup to use the latter
        methods  in  [5XSemigroups[105X  it must satisfy [2XIsActingSemigroup[102X ([14X6.1-2[114X). By
        default   any   semigroup   or   monoid  of  transformations,  partial
        permutations,   Rees  0-matrix  elements,  or  bipartitions  satisfies
        [10XIsActingSemigroup[110X.[133X
  
        [33X[0;6YThere  are cases (such as when it is known [13Xa priori[113X that the semigroup
        is  [13XD[113X-trivial),  when  it  might be preferable to use the methods that
        involve  fully  enumerating  a  semigroup. In other words, it might be
        desirable  to  disable  the  more  sophisticated  methods  for  acting
        semigroups.  If this is the case, then the value of this component can
        be set [9Xfalse[109X when the semigroup is created. Following this none of the
        special  methods for acting semigroup will be used to compute anything
        about the semigroup.[133X
  
  [8X[10Xregular[110X[8X[108X
        [33X[0;6Ythis  component  should be [9Xtrue[109X or [9Xfalse[109X. If it is known [13Xa priori[113X that
        the  semigroup  [10XS[110X  being  created  is  a  regular semigroup, then this
        component  can  be  set to [9Xtrue[109X. In this case, [10XS[110X knows it is a regular
        semigroup and can take advantage of the methods for regular semigroups
        in  [5XSemigroups[105X.  It  is  usually much more efficient to compute with a
        regular semigroup that to compute with a non-regular semigroup.[133X
  
        [33X[0;6YIf  this option is set to [9Xtrue[109X when the semigroup being defined is [12Xnot[112X
        regular, then the results might be unpredictable.[133X
  
        [33X[0;6YThe default value for this option is [9Xfalse[109X.[133X
  
  [8X[10Xhashlen[110X[8X[108X
        [33X[0;6Ythis  component  should be a positive integer, which roughly specifies
        the  lengths  of  the  hash  tables  used  internally  by  [5XSemigroups[105X.
        [5XSemigroups[105X  uses  hash  tables  in  several  fundamental  methods. The
        lengths  of  these  tables  are  a  compromise between performance and
        memory  usage;  larger  tables  provide  better  performance for large
        computations  but  use  more memory. Note that it is unlikely that you
        will  need to specify this option unless you find that [5XGAP[105X runs out of
        memory  unexpectedly  or  that the performance of [5XSemigroups[105X is poorer
        than  expected.  If you find that [5XGAP[105X runs out of memory unexpectedly,
        or you plan to do a large number of computations with relatively small
        semigroups  (say  with  tens of thousands of elements), then you might
        consider  setting  [10Xhashlen[110X  to be less than the default value of [10X12517[110X
        for  each  of  these  semigroups.  If you find that the performance of
        [5XSemigroups[105X  is unexpectedly poor, or you plan to do a computation with
        a  very large semigroup (say, more than 10 million elements), then you
        might consider setting [10Xhashlen[110X to be greater than the default value of
        [10X12517[110X.[133X
  
        [33X[0;6YYou  might  find  it  useful  to  set the info level of the info class
        [10XInfoOrb[110X  to 2 or higher since this will indicate when hash tables used
        by   [5XSemigroups[105X   are   being   grown;  see  [2XSetInfoLevel[102X  ([14XReference:
        InfoLevel[114X).[133X
  
  [8X[10Xsmall[110X[8X[108X
        [33X[0;6Yif this component is set to [9Xtrue[109X, then [5XSemigroups[105X will compute a small
        subset  of  [3Xgens[103X  that generates [3XS[103X at the time that [3XS[103X is created. This
        will  increase  the amount of time required to create [3XS[103X substantially,
        but   may   decrease  the  amount  of  time  required  for  subsequent
        calculations  with  [3XS[103X.  If  this  component  is  set  to  [9Xfalse[109X,  then
        [5XSemigroups[105X  will  return  the  semigroup  generated  by  [3Xgens[103X  without
        modifying [3Xgens[103X. The default value for this component is [9Xfalse[109X.[133X
  
        [33X[0;6YThis  option  is  ignored  when  passed to [2XClosureSemigroup[102X ([14X6.4-1[114X) or
        [2XClosureInverseSemigroup[102X ([14X6.4-1[114X).[133X
  
  [8X[10Xcong_by_ker_trace_threshold[110X[8X[108X
        [33X[0;6Ythis  should  be a positive integer, which specifies a semigroup size.
        If  [3XS[103X is a semigroup with inverse op, and [3XS[103X has a size greater than or
        equal to this threshold, then any congruence defined on it may use the
        "kernel and trace" method to perform calculations. If its size is less
        than  the  threshold,  then  other  methods  will be used instead. The
        "kernel  and  trace"  method  has  better  complexity than the generic
        method,  but has large overheads which make it a poor choice for small
        semigroups.  The  default  value  for  this  component  is [10X10 ^ 5[110X. See
        Section [14X13.7[114X for more information about the "kernel and trace" method.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([1, 2, 3, 3]),[127X[104X
    [4X[25X>[125X [27X                  rec(hashlen := 100003, small := false));[127X[104X
    [4X[28X<commutative transformation semigroup of degree 4 with 1 generator>[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThe  default  values  of  the options described above are stored in a global
  variable  named  [2XSEMIGROUPS.DefaultOptionsRec[102X ([14X6.3-1[114X). If you want to change
  the  default  values of these options for a single [5XGAP[105X session, then you can
  simply  redefine  the  value in [5XGAP[105X. For example, to change the option [10Xsmall[110X
  from the default value of [3Xfalse[103X use:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XSEMIGROUPS.DefaultOptionsRec.small := true;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [33X[0;0YIf  you  want  to  change  the  default  values  of  the  options  stored in
  [2XSEMIGROUPS.DefaultOptionsRec[102X ([14X6.3-1[114X) for all [5XGAP[105X sessions, then you can edit
  these values in the file [11Xsemigroups-5.5.4/gap/options.g[111X.[133X
  
  [1X6.3-1 SEMIGROUPS.DefaultOptionsRec[101X
  
  [33X[1;0Y[29X[2XSEMIGROUPS.DefaultOptionsRec[102X [32X global variable[133X
  
  [33X[0;0YThis global variable is a record whose components contain the default values
  of  certain  options for semigroups. A description of these options is given
  above in Section [14X6.3[114X.[133X
  
  [33X[0;0YThe   value   of   [10XSEMIGROUPS.DefaultOptionsRec[110X   is  defined  in  the  file
  [10Xsemigroups/gap/options.g[110X.[133X
  
  
  [1X6.4 [33X[0;0YSubsemigroups and supersemigroups[133X[101X
  
  [1X6.4-1 ClosureSemigroup[101X
  
  [33X[1;0Y[29X[2XClosureSemigroup[102X( [3XS[103X, [3Xcoll[103X[, [3Xopts[103X] ) [32X operation[133X
  [33X[1;0Y[29X[2XClosureMonoid[102X( [3XS[103X, [3Xcoll[103X[, [3Xopts[103X] ) [32X operation[133X
  [33X[1;0Y[29X[2XClosureInverseSemigroup[102X( [3XS[103X, [3Xcoll[103X[, [3Xopts[103X] ) [32X operation[133X
  [33X[1;0Y[29X[2XClosureInverseMonoid[102X( [3XS[103X, [3Xcoll[103X[, [3Xopts[103X] ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YA semigroup, monoid, inverse semigroup, or inverse monoid.[133X
  
  [33X[0;0YThese  operations return the semigroup, monoid, inverse semigroup or inverse
  monoid generated by the argument [3XS[103X and the collection of elements [3Xcoll[103X after
  removing  duplicates  and  elements from [3Xcoll[103X that are already in [3XS[103X. In most
  cases,  the  new  semigroup  knows  at  least  as much information about its
  structure as was already known about that of [3XS[103X.[133X
  
  [33X[0;0YWhen  [10XX[110X  is  any  of  [2XSemigroup[102X  ([14XReference:  Semigroup[114X), [2XMonoid[102X ([14XReference:
  Monoid[114X),  [2XInverseSemigroup[102X  ([14XReference:  InverseSemigroup[114X), or [2XInverseMonoid[102X
  ([14XReference:  InverseMonoid[114X),  the  argument [3XS[103X of the operation [10XClosureX[110X must
  belong  to  the category [10XIsX[110X, and [10XClosureX([3XS[103X[10X, [3Xcoll[103X[10X)[110X returns an object in the
  category [10XIsX[110X such that[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X        ClosureX(S, coll) = X(S, coll);[128X[104X
  [4X[32X[104X
  
  [33X[0;0Ybut may have fewer generators, if for example, [3Xcoll[103X contains a duplicates or
  elements already known to belong to [3XS[103X.[133X
  
  [33X[0;0YFor  example,  the  argument [3XS[103X of [10XClosureInverseSemigroup[110X must be an inverse
  semigroup     in     the     category     [2XIsInverseSemigroup[102X     ([14XReference:
  IsInverseSemigroup[114X).  [10XClosureInverseSemigroup([3XS[103X[10X,  [3Xcoll[103X[10X)[110X  returns  an inverse
  semigroup which is equal to [10XInverseSemigroup([3XS[103X[10X, [3Xcoll[103X[10X)[110X.[133X
  
  [33X[0;0YIf  present,  the optional third argument [3Xopts[103X should be a record containing
  the  values  of  the options for the semigroup being created as described in
  Section [14X6.3[114X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xgens := [Transformation([2, 6, 7, 2, 6, 1, 1, 5]),[127X[104X
    [4X[25X>[125X [27X            Transformation([3, 8, 1, 4, 5, 6, 7, 1]),[127X[104X
    [4X[25X>[125X [27X            Transformation([4, 3, 2, 7, 7, 6, 6, 5]),[127X[104X
    [4X[25X>[125X [27X            Transformation([7, 1, 7, 4, 2, 5, 6, 3])];;[127X[104X
    [4X[25Xgap>[125X [27XS := Monoid(gens[1]);;[127X[104X
    [4X[25Xgap>[125X [27Xfor x in gens do[127X[104X
    [4X[25X>[125X [27X     S := ClosureSemigroup(S, x);[127X[104X
    [4X[25X>[125X [27X   od;[127X[104X
    [4X[25Xgap>[125X [27XS;[127X[104X
    [4X[28X<transformation monoid of degree 8 with 4 generators>[128X[104X
    [4X[25Xgap>[125X [27XSize(S);[127X[104X
    [4X[28X233606[128X[104X
    [4X[25Xgap>[125X [27XS := Monoid(PartialPerm([1]));[127X[104X
    [4X[28X<trivial partial perm group of rank 1 with 1 generator>[128X[104X
    [4X[25Xgap>[125X [27XT := ClosureMonoid(S, [PartialPerm([2 .. 5])]);[127X[104X
    [4X[28X<partial perm monoid of rank 5 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XOne(T);[127X[104X
    [4X[28X<identity partial perm on [ 1, 2, 3, 4, 5 ]>[128X[104X
    [4X[25Xgap>[125X [27XT := ClosureSemigroup(S, [PartialPerm([2 .. 5])]);[127X[104X
    [4X[28X<partial perm semigroup of rank 4 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XOne(T);[127X[104X
    [4X[28Xfail[128X[104X
    [4X[25Xgap>[125X [27XClosureInverseMonoid(DualSymmetricInverseMonoid(3),[127X[104X
    [4X[25X>[125X [27X                        DClass(DualSymmetricInverseMonoid(3),[127X[104X
    [4X[25X>[125X [27X                               IdentityBipartition(3)));[127X[104X
    [4X[28X<inverse block bijection monoid of degree 3 with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := InverseSemigroup(Bipartition([[1, -1, -3], [2, 3, -2]]),[127X[104X
    [4X[25X>[125X [27X                         Bipartition([[1, -3], [2, -2], [3, -1]]));;[127X[104X
    [4X[25Xgap>[125X [27XT := ClosureInverseSemigroup(S, DClass(PartitionMonoid(3),[127X[104X
    [4X[25X>[125X [27XIdentityBipartition(3)));[127X[104X
    [4X[28X<inverse block bijection semigroup of degree 3 with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XT := ClosureInverseSemigroup(T, [T.1, T.1, T.1]);[127X[104X
    [4X[28X<inverse block bijection semigroup of degree 3 with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := InverseMonoid([[127X[104X
    [4X[25X>[125X [27XPartialPerm([5, 9, 10, 0, 6, 3, 8, 4, 0]),[127X[104X
    [4X[25X>[125X [27XPartialPerm([10, 7, 0, 8, 0, 0, 5, 9, 1])]);;[127X[104X
    [4X[25Xgap>[125X [27Xx := PartialPerm([[127X[104X
    [4X[25X>[125X [27X5, 1, 7, 3, 10, 0, 2, 12, 0, 14, 11, 0, 16, 0, 0, 0, 0, 6, 9, 15]);[127X[104X
    [4X[28X[4,3,7,2,1,5,10,14][8,12][13,16][18,6][19,9][20,15](11)[128X[104X
    [4X[25Xgap>[125X [27XS := ClosureInverseSemigroup(S, x);[127X[104X
    [4X[28X<inverse partial perm semigroup of rank 19 with 4 generators>[128X[104X
    [4X[25Xgap>[125X [27XSize(S);[127X[104X
    [4X[28X9744[128X[104X
    [4X[25Xgap>[125X [27XT := Idempotents(SymmetricInverseSemigroup(10));;[127X[104X
    [4X[25Xgap>[125X [27XS := ClosureInverseSemigroup(S, T);[127X[104X
    [4X[28X<inverse partial perm semigroup of rank 19 with 14 generators>[128X[104X
  [4X[32X[104X
  
  [1X6.4-2 SubsemigroupByProperty[101X
  
  [33X[1;0Y[29X[2XSubsemigroupByProperty[102X( [3XS[103X, [3Xfunc[103X ) [32X operation[133X
  [33X[1;0Y[29X[2XSubsemigroupByProperty[102X( [3XS[103X, [3Xfunc[103X, [3Xlimit[103X ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YA semigroup.[133X
  
  [33X[0;0Y[10XSubsemigroupByProperty[110X returns the subsemigroup of the semigroup [3XS[103X generated
  by those elements of [3XS[103X fulfilling [3Xfunc[103X (which should be a function returning
  [9Xtrue[109X or [9Xfalse[109X).[133X
  
  [33X[0;0YIf no elements of [3XS[103X fulfil [3Xfunc[103X, then [9Xfail[109X is returned.[133X
  
  [33X[0;0YIf the optional third argument [3Xlimit[103X is present and a positive integer, then
  once the subsemigroup has at least [3Xlimit[103X elements the computation stops.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xfunc := function(x)[127X[104X
    [4X[25X>[125X [27X     local n;[127X[104X
    [4X[25X>[125X [27X     n := DegreeOfTransformation(x);[127X[104X
    [4X[25X>[125X [27X     return 1 ^ x <> 1 and ForAll([1 .. n], y -> y = 1 or y ^ x = y);[127X[104X
    [4X[25X>[125X [27X   end;[127X[104X
    [4X[28Xfunction( x ) ... end[128X[104X
    [4X[25Xgap>[125X [27XT := SubsemigroupByProperty(FullTransformationSemigroup(3), func);[127X[104X
    [4X[28X<transformation semigroup of size 2, degree 3 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XT := SubsemigroupByProperty(FullTransformationSemigroup(4), func);[127X[104X
    [4X[28X<transformation semigroup of size 3, degree 4 with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XT := SubsemigroupByProperty(FullTransformationSemigroup(5), func);[127X[104X
    [4X[28X<transformation semigroup of size 4, degree 5 with 4 generators>[128X[104X
  [4X[32X[104X
  
  [1X6.4-3 InverseSubsemigroupByProperty[101X
  
  [33X[1;0Y[29X[2XInverseSubsemigroupByProperty[102X( [3XS[103X, [3Xfunc[103X ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YAn inverse semigroup.[133X
  
  [33X[0;0Y[10XInverseSubsemigroupByProperty[110X   returns  the  inverse  subsemigroup  of  the
  inverse  semigroup [3XS[103X generated by those elements of [3XS[103X fulfilling [3Xfunc[103X (which
  should be a function returning [9Xtrue[109X or [9Xfalse[109X).[133X
  
  [33X[0;0YIf no elements of [3XS[103X fulfil [3Xfunc[103X, then [9Xfail[109X is returned.[133X
  
  [33X[0;0YIf the optional third argument [3Xlimit[103X is present and a positive integer, then
  once the subsemigroup has at least [3Xlimit[103X elements the computation stops.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XIsIsometry := function(f)[127X[104X
    [4X[25X>[125X [27Xlocal n, i, j, k, l;[127X[104X
    [4X[25X>[125X [27X n := RankOfPartialPerm(f);[127X[104X
    [4X[25X>[125X [27X for i in [1 .. n - 1] do[127X[104X
    [4X[25X>[125X [27X   k := DomainOfPartialPerm(f)[i];[127X[104X
    [4X[25X>[125X [27X   for j in [i + 1 .. n] do[127X[104X
    [4X[25X>[125X [27X     l := DomainOfPartialPerm(f)[j];[127X[104X
    [4X[25X>[125X [27X     if not AbsInt(k ^ f - l ^ f) = AbsInt(k - l) then[127X[104X
    [4X[25X>[125X [27X       return false;[127X[104X
    [4X[25X>[125X [27X     fi;[127X[104X
    [4X[25X>[125X [27X   od;[127X[104X
    [4X[25X>[125X [27X od;[127X[104X
    [4X[25X>[125X [27X return true;[127X[104X
    [4X[25X>[125X [27Xend;;[127X[104X
    [4X[25Xgap>[125X [27XS := InverseSubsemigroupByProperty(SymmetricInverseSemigroup(5),[127X[104X
    [4X[25X>[125X [27XIsIsometry);;[127X[104X
    [4X[25Xgap>[125X [27XSize(S);[127X[104X
    [4X[28X142[128X[104X
  [4X[32X[104X
  
  
  [1X6.5 [33X[0;0YChanging the representation of a semigroup[133X[101X
  
  [33X[0;0YThe    [5XSemigroups[105X    package    provides    two    convenient   constructors
  [2XIsomorphismSemigroup[102X  ([14X6.5-1[114X) and [2XIsomorphismMonoid[102X ([14X6.5-2[114X) for changing the
  representation  of a given semigroup or monoid. These methods can be used to
  find  an  isomorphism  from  any semigroup to a semigroup of any other type,
  provided such an isomorphism exists.[133X
  
  [33X[0;0YNote    that   at   present   neither   [2XIsomorphismSemigroup[102X   ([14X6.5-1[114X)   nor
  [2XIsomorphismMonoid[102X  ([14X6.5-2[114X)  can  be  used  to  determine  whether  two given
  semigroups, or monoids, are isomorphic.[133X
  
  [33X[0;0YSome  methods for [2XIsomorphismSemigroup[102X ([14X6.5-1[114X) and [2XIsomorphismMonoid[102X ([14X6.5-2[114X)
  are based on methods for the [5XGAP[105X library operations:[133X
  
  [30X    [33X[0;6Y[2XIsomorphismReesMatrixSemigroup[102X                             ([14XReference:
        IsomorphismReesMatrixSemigroup[114X),[133X
  
  [30X    [33X[0;6Y[2XAntiIsomorphismTransformationSemigroup[102X                     ([14XReference:
        AntiIsomorphismTransformationSemigroup[114X),[133X
  
  [30X    [33X[0;6Y[2XIsomorphismTransformationSemigroup[102X                         ([14XReference:
        IsomorphismTransformationSemigroup[114X)                                and
        [2XIsomorphismTransformationMonoid[102X                            ([14XReference:
        IsomorphismTransformationMonoid[114X),[133X
  
  [30X    [33X[0;6Y[2XIsomorphismPartialPermSemigroup[102X                            ([14XReference:
        IsomorphismPartialPermSemigroup[114X)    and   [2XIsomorphismPartialPermMonoid[102X
        ([14XReference: IsomorphismPartialPermMonoid[114X),[133X
  
  [30X    [33X[0;6Y[2XIsomorphismFpSemigroup[102X    ([14XReference:    IsomorphismFpSemigroup[114X)   and
        [10XIsomorphismFpMonoid[110X.[133X
  
  [33X[0;0YThe operation [2XIsomorphismMonoid[102X ([14X6.5-2[114X) can be used to return an isomorphism
  from a semigroup which is mathematically a monoid (but does not below to the
  category  of  monoids  in [5XGAP[105X [2XIsMonoid[102X ([14XReference: IsMonoid[114X)) into a monoid.
  This  is  the  primary  purpose  of the operation [2XIsomorphismMonoid[102X ([14X6.5-2[114X).
  Either [2XIsomorphismSemigroup[102X ([14X6.5-1[114X) or [2XIsomorphismMonoid[102X ([14X6.5-2[114X) can be used
  to  change the representation of a monoid, but only the latter is guaranteed
  to return an object in the category of monoids.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Monoid(Transformation([1, 4, 6, 2, 5, 3, 7, 8, 9, 9]),[127X[104X
    [4X[25X>[125X [27X               Transformation([6, 3, 2, 7, 5, 1, 8, 8, 9, 9]));;[127X[104X
    [4X[25Xgap>[125X [27XAsSemigroup(IsBooleanMatSemigroup, S);[127X[104X
    [4X[28X<monoid of 10x10 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsMonoid(IsBooleanMatMonoid, S);[127X[104X
    [4X[28X<monoid of 10x10 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([1, 4, 6, 2, 5, 3, 7, 8, 9, 9]),[127X[104X
    [4X[25X>[125X [27X                  Transformation([6, 3, 2, 7, 5, 1, 8, 8, 9, 9]));;[127X[104X
    [4X[25Xgap>[125X [27XAsSemigroup(IsBooleanMatSemigroup, S);[127X[104X
    [4X[28X<semigroup of 10x10 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsMonoid(IsBooleanMatMonoid, S);[127X[104X
    [4X[28X<monoid of 8x8 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XM := Monoid([[127X[104X
    [4X[25X>[125X [27XBipartition([[1, -3], [2, 3, 6], [4, 7, -6], [5, -8], [8, -4, -5],[127X[104X
    [4X[25X>[125X [27X             [-1], [-2], [-7]]),[127X[104X
    [4X[25X>[125X [27XBipartition([[1, 3, -6], [2, -8], [4, 8, -1], [5], [6, -3, -4],[127X[104X
    [4X[25X>[125X [27X             [7], [-2], [-5], [-7]]),[127X[104X
    [4X[25X>[125X [27XBipartition([[1, 2, 4, -3, -7, -8], [3, 5, 6, 8, -4, -6],[127X[104X
    [4X[25X>[125X [27X             [7, -1, -2, -5]])]);;[127X[104X
    [4X[25Xgap>[125X [27XAsMonoid(IsPBRMonoid, M);[127X[104X
    [4X[28X<pbr monoid of size 163, degree 163 with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsSemigroup(IsPBRSemigroup, M);[127X[104X
    [4X[28X<pbr semigroup of size 163, degree 8 with 4 generators>[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThere  are  some  further methods in [5XSemigroups[105X for obtaining an isomorphism
  from  a  Rees  matrix, or 0-matrix, semigroup to another such semigroup with
  particular   properties;   [2XRMSNormalization[102X  ([14X6.5-7[114X)  and  [2XRZMSNormalization[102X
  ([14X6.5-6[114X).[133X
  
  [1X6.5-1 IsomorphismSemigroup[101X
  
  [33X[1;0Y[29X[2XIsomorphismSemigroup[102X( [3Xfilt[103X, [3XS[103X ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YAn isomorphism of semigroups.[133X
  
  [33X[0;0Y[10XIsomorphismSemigroup[110X  can  be  used  to  find  an  isomorphism  from a given
  semigroup  to  a  semigroup  of  another  type, provided such an isomorphism
  exists.[133X
  
  [33X[0;0YThe  first  argument  [3Xfilt[103X  must  be  of the form [10XIsXSemigroup[110X, for example,
  [2XIsTransformationSemigroup[102X       ([14XReference:      IsTransformationSemigroup[114X),
  [2XIsFpSemigroup[102X  ([14XReference:  IsFpSemigroup[114X),  and  [2XIsPBRSemigroup[102X ([14X4.6-1[114X) are
  some  possible  values  for  [3Xfilt[103X.  Note that [3Xfilt[103X should not be of the form
  [10XIsXMonoid[110X;  see [2XIsomorphismMonoid[102X ([14X6.5-2[114X). The second argument [3XS[103X should be a
  semigroup.[133X
  
  [33X[0;0Y[10XIsomorphismSemigroup[110X  returns  an isomorphism from [3XS[103X to a semigroup [3XT[103X of the
  type  described by [3Xfilt[103X, if such an isomorphism exists. More precisely, if [10XT[110X
  is the range of the returned isomorphism, then [10X[3Xfilt[103X[10X(T)[110X will return [9Xtrue[109X. For
  example,  if  [3Xfilt[103X  is  [10XIsTransformationSemigroup[110X,  then  the  range  of the
  returned isomorphism will be a transformation semigroup.[133X
  
  [33X[0;0YAn  error  is  returned  if  there  is  no isomorphism from [3XS[103X to a semigroup
  satisfying  [3Xfilt[103X.  For  example, there is no method for [10XIsomorphismSemigroup[110X
  when  [3Xfilt[103X is, say, [2XIsReesMatrixSemigroup[102X ([14XReference: IsReesMatrixSemigroup[114X)
  and  when  [3XS[103X  is  a non-simple semigroup. Similarly, there is no method when
  [3Xfilt[103X  is [2XIsPartialPermSemigroup[102X ([14XReference: IsPartialPermSemigroup[114X) and when
  [3XS[103X is a non-inverse semigroup.[133X
  
  [33X[0;0YIn  some  cases,  if  no  better  method  is installed, [10XIsomorphismSemigroup[110X
  returns  an  isomorphism  found  by  composing  an  isomorphism  from [3XS[103X to a
  transformation semigroup [10XT[110X, and an isomorphism from [10XT[110X to a semigroup of type
  [3Xfilt[103X.[133X
  
  [33X[0;0YNote  that  if  the  argument  [3XS[103X belongs to the category of monoids [2XIsMonoid[102X
  ([14XReference: IsMonoid[114X), then [10XIsomorphismSemigroup[110X will often, but not always,
  return a monoid isomorphism.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup([[127X[104X
    [4X[25X>[125X [27XBipartition([[127X[104X
    [4X[25X>[125X [27X  [1, 2], [3, 6, -2], [4, 5, -3, -4], [-1, -6], [-5]]),[127X[104X
    [4X[25X>[125X [27XBipartition([[127X[104X
    [4X[25X>[125X [27X  [1, -4], [2, 3, 4, 5], [6], [-1, -6], [-2, -3], [-5]])]);[127X[104X
    [4X[28X<bipartition semigroup of degree 6 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismSemigroup(IsTransformationSemigroup, S);[127X[104X
    [4X[28X<bipartition semigroup of size 11, degree 6 with 2 generators> ->[128X[104X
    [4X[28X<transformation semigroup of size 11, degree 12 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismSemigroup(IsBooleanMatSemigroup, S);[127X[104X
    [4X[28X<bipartition semigroup of size 11, degree 6 with 2 generators> ->[128X[104X
    [4X[28X<semigroup of size 11, 12x12 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismSemigroup(IsFpSemigroup, S);[127X[104X
    [4X[28X<bipartition semigroup of size 11, degree 6 with 2 generators> ->[128X[104X
    [4X[28X<fp semigroup with 2 generators and 5 relations of length 27>[128X[104X
    [4X[25Xgap>[125X [27XS := InverseSemigroup([[127X[104X
    [4X[25X>[125X [27XPartialPerm([1, 2, 3, 6, 8, 10],[127X[104X
    [4X[25X>[125X [27X            [2, 6, 7, 9, 1, 5]),[127X[104X
    [4X[25X>[125X [27XPartialPerm([1, 2, 3, 4, 6, 7, 8, 10],[127X[104X
    [4X[25X>[125X [27X            [3, 8, 1, 9, 4, 10, 5, 6])]);;[127X[104X
    [4X[25Xgap>[125X [27XIsomorphismSemigroup(IsBipartitionSemigroup, S);[127X[104X
    [4X[28X<inverse partial perm semigroup of rank 10 with 2 generators> ->[128X[104X
    [4X[28X<inverse bipartition semigroup of degree 10 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := SymmetricInverseMonoid(4);[127X[104X
    [4X[28X<symmetric inverse monoid of degree 4>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismSemigroup(IsBlockBijectionSemigroup, S);[127X[104X
    [4X[28X<symmetric inverse monoid of degree 4> ->[128X[104X
    [4X[28X<inverse block bijection monoid of degree 5 with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XSize(Range(last));[127X[104X
    [4X[28X209[128X[104X
    [4X[25Xgap>[125X [27XS := Semigroup([[127X[104X
    [4X[25X>[125X [27XPartialPerm([3, 1]), PartialPerm([1, 3, 4])]);;[127X[104X
    [4X[25Xgap>[125X [27XIsomorphismSemigroup(IsBlockBijectionSemigroup, S);[127X[104X
    [4X[28X<partial perm semigroup of rank 3 with 2 generators> ->[128X[104X
    [4X[28X<block bijection semigroup of degree 5 with 2 generators>[128X[104X
  [4X[32X[104X
  
  [1X6.5-2 IsomorphismMonoid[101X
  
  [33X[1;0Y[29X[2XIsomorphismMonoid[102X( [3Xfilt[103X, [3XS[103X ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YAn isomorphism of monoids.[133X
  
  [33X[0;0Y[10XIsomorphismMonoid[110X  can be used to find an isomorphism from a given semigroup
  which  is  mathematically  a monoid (but might not belong to the category of
  monoids in [5XGAP[105X) to a monoid, provided such an isomorphism exists.[133X
  
  [33X[0;0YThe  first  argument  [3Xfilt[103X  must  be  of  the  form  [10XIsXMonoid[110X, for example,
  [2XIsTransformationMonoid[102X   ([14XReference:   IsTransformationMonoid[114X),   [2XIsFpMonoid[102X
  ([14XReference:  IsFpMonoid[114X),  and [2XIsBipartitionMonoid[102X ([14X3.8-1[114X) are some possible
  values  for [3Xfilt[103X. Note that [3Xfilt[103X should not be of the form [10XIsXSemigroup[110X; see
  [2XIsomorphismSemigroup[102X  ([14X6.5-1[114X).  The  second argument [3XS[103X should be a semigroup
  which  is  mathematically  a  monoid  but which may or may not belong to the
  category  [2XIsMonoid[102X  ([14XReference:  IsMonoid[114X)  of  monoids  in [5XGAP[105X, i.e. [3XS[103X must
  satisfy [2XIsMonoidAsSemigroup[102X ([14X12.1-13[114X).[133X
  
  [33X[0;0Y[10XIsomorphismMonoid[110X  returns  a  monoid isomorphism from [3XS[103X to a semigroup [3XT[103X of
  the  type described by [3Xfilt[103X, if such an isomorphism exists. In this context,
  a   [13Xmonoid   isomorphism[113X   is   a   semigroup   isomorphism  that  maps  the
  [2XMultiplicativeNeutralElement[102X  ([14XReference: MultiplicativeNeutralElement[114X) of [3XS[103X
  to  the  [2XOne[102X  ([14XReference:  One[114X)  of  [3XT[103X.  If  [10XT[110X  is the range of the returned
  isomorphism,  then  [10X[3Xfilt[103X[10X(T)[110X  will  return  [9Xtrue[109X.  For  example,  if  [3Xfilt[103X is
  [10XIsTransformationMonoid[110X, then the range of the returned isomorphism will be a
  transformation monoid.[133X
  
  [33X[0;0YAn  error  is  returned  if  there  is  no  isomorphism  from  [3XS[103X to a monoid
  satisfying  [3Xfilt[103X. For example, there is no method for [10XIsomorphismMonoid[110X when
  [3Xfilt[103X        is,       say,       [2XIsReesZeroMatrixSemigroup[102X       ([14XReference:
  IsReesZeroMatrixSemigroup[114X) and when [3XS[103X is a not 0-simple. Similarly, there is
  no  method when [3Xfilt[103X is [2XIsPartialPermMonoid[102X ([14XReference: IsPartialPermMonoid[114X)
  and when [3XS[103X is a non-inverse monoid.[133X
  
  [33X[0;0YIn  some  cases, if no better method is installed, [10XIsomorphismMonoid[110X returns
  an  isomorphism found by composing an isomorphism from [3XS[103X to a transformation
  monoid [10XT[110X, and an isomorphism from [10XT[110X to a monoid of type [3Xfilt[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([1, 4, 6, 2, 5, 3, 7, 8, 9, 9]),[127X[104X
    [4X[25X>[125X [27X                  Transformation([6, 3, 2, 7, 5, 1, 8, 8, 9, 9]));[127X[104X
    [4X[28X<transformation semigroup of degree 10 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismMonoid(IsTransformationMonoid, S);[127X[104X
    [4X[28X<transformation semigroup of degree 10 with 2 generators> ->[128X[104X
    [4X[28X<transformation monoid of degree 8 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismMonoid(IsBooleanMatMonoid, S);[127X[104X
    [4X[28X<transformation semigroup of degree 10 with 2 generators> ->[128X[104X
    [4X[28X<monoid of 8x8 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XIsomorphismMonoid(IsFpMonoid, S);[127X[104X
    [4X[28X<transformation semigroup of degree 10 with 2 generators> ->[128X[104X
    [4X[28X<fp monoid with 2 generators and 17 relations of length 278>[128X[104X
  [4X[32X[104X
  
  [1X6.5-3 AsSemigroup[101X
  
  [33X[1;0Y[29X[2XAsSemigroup[102X( [3Xfilt[103X, [3XS[103X ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YA semigroup.[133X
  
  [33X[0;0Y[10XAsSemigroup([3Xfilt[103X[10X,  [3XS[103X[10X)[110X is just shorthand for [10XRange(IsomorphismSemigroup([3Xfilt[103X[10X,
  [3XS[103X[10X))[110X,  when  [3XS[103X  is  a  semigroup;  see  [2XIsomorphismSemigroup[102X ([14X6.5-1[114X) for more
  details.[133X
  
  [33X[0;0YNote  that  if  the  argument  [3XS[103X belongs to the category of monoids [2XIsMonoid[102X
  ([14XReference: IsMonoid[114X), then [10XAsSemigroup[110X will often, but not always, return a
  monoid.  A  monoid is not returned if there is not a good monoid isomorphism
  from  [3XS[103X  to  a  monoid  of  the required type, but there is a good semigroup
  isomorphism.[133X
  
  [33X[0;0YIf  it  is  not  possible  to convert the semigroup [3XS[103X to a semigroup of type
  [3Xfilt[103X, then an error is given.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup([[127X[104X
    [4X[25X>[125X [27XBipartition([[127X[104X
    [4X[25X>[125X [27X  [1, 2], [3, 6, -2], [4, 5, -3, -4], [-1, -6], [-5]]),[127X[104X
    [4X[25X>[125X [27XBipartition([[127X[104X
    [4X[25X>[125X [27X  [1, -4], [2, 3, 4, 5], [6], [-1, -6], [-2, -3], [-5]])]);[127X[104X
    [4X[28X<bipartition semigroup of degree 6 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsSemigroup(IsTransformationSemigroup, S);[127X[104X
    [4X[28X<transformation semigroup of size 11, degree 12 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := Semigroup([[127X[104X
    [4X[25X>[125X [27XBipartition([[127X[104X
    [4X[25X>[125X [27X  [1, 2], [3, 6, -2], [4, 5, -3, -4], [-1, -6], [-5]]),[127X[104X
    [4X[25X>[125X [27XBipartition([[127X[104X
    [4X[25X>[125X [27X  [1, -4], [2, 3, 4, 5], [6], [-1, -6], [-2, -3], [-5]])]);[127X[104X
    [4X[28X<bipartition semigroup of degree 6 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsSemigroup(IsTransformationSemigroup, S);[127X[104X
    [4X[28X<transformation semigroup of size 11, degree 12 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XT := Semigroup(Transformation([2, 2, 3]),[127X[104X
    [4X[25X>[125X [27X                  Transformation([3, 1, 3]));[127X[104X
    [4X[28X<transformation semigroup of degree 3 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := AsSemigroup(IsMatrixOverFiniteFieldSemigroup, GF(5), T);[127X[104X
    [4X[28X<semigroup of 3x3 matrices over GF(5) with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XSize(S);[127X[104X
    [4X[28X5[128X[104X
  [4X[32X[104X
  
  [1X6.5-4 AsMonoid[101X
  
  [33X[1;0Y[29X[2XAsMonoid[102X( [[3Xfilt[103X, ][3XS[103X ) [32X operation[133X
  [6XReturns:[106X  [33X[0;10YA monoid or [9Xfail[109X.[133X
  
  [33X[0;0Y[10XAsMonoid([3Xfilt[103X[10X,  [3XS[103X[10X)[110X  is just shorthand for [10XRange(IsomorphismMonoid([3Xfilt[103X[10X, [3XS[103X[10X))[110X,
  when  [3XS[103X  is  a  semigroup  or monoid; see [2XIsomorphismMonoid[102X ([14X6.5-2[114X) for more
  details.[133X
  
  [33X[0;0YIf  the first argument [3Xfilt[103X is omitted and the semigroup [3XS[103X is mathematically
  a  monoid  which  does  not  belong  to the category of monoids in [5XGAP[105X, then
  [10XAsMonoid[110X  returns  a monoid (in the category of monoids) isomorphic to [3XS[103X and
  of  the  same  type as [3XS[103X. If [3XS[103X is already in the category of monoids and the
  first argument [3Xfilt[103X is omitted, then [3XS[103X is returned.[133X
  
  [33X[0;0YIf  the  first argument [3Xfilt[103X is omitted and the semigroup [3XS[103X is not a monoid,
  i.e.  it  does  not  satisfy  [2XIsMonoidAsSemigroup[102X  ([14X12.1-13[114X),  then  [9Xfail[109X is
  returned.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([1, 4, 6, 2, 5, 3, 7, 8, 9, 9]),[127X[104X
    [4X[25X>[125X [27X                  Transformation([6, 3, 2, 7, 5, 1, 8, 8, 9, 9]));;[127X[104X
    [4X[25Xgap>[125X [27XAsMonoid(S);[127X[104X
    [4X[28X<transformation monoid of degree 8 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsSemigroup(IsBooleanMatSemigroup, S);[127X[104X
    [4X[28X<semigroup of 10x10 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsMonoid(IsBooleanMatMonoid, S);[127X[104X
    [4X[28X<monoid of 8x8 boolean matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XS := Monoid(Bipartition([[1, -1, -3], [2, 3], [-2]]),[127X[104X
    [4X[25X>[125X [27X               Bipartition([[1, -1], [2, 3, -3], [-2]]));[127X[104X
    [4X[28X<bipartition monoid of degree 3 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsMonoid(IsTransformationMonoid, S);[127X[104X
    [4X[28X<transformation monoid of size 3, degree 3 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XAsMonoid(S);[127X[104X
    [4X[28X<bipartition monoid of size 3, degree 3 with 2 generators>[128X[104X
  [4X[32X[104X
  
  [1X6.5-5 IsomorphismPermGroup[101X
  
  [33X[1;0Y[29X[2XIsomorphismPermGroup[102X( [3XS[103X ) [32X attribute[133X
  [6XReturns:[106X  [33X[0;10YAn isomorphism.[133X
  
  [33X[0;0YIf  the  semigroup  [3XS[103X  is  mathematically  a  group,  so  that  it satisfies
  [2XIsGroupAsSemigroup[102X    ([14X12.1-7[114X),   then   [10XIsomorphismPermGroup[110X   returns   an
  isomorphism to a permutation group.[133X
  
  [33X[0;0YIf [3XS[103X is not a group then an error is given.[133X
  
  [33X[0;0YSee also [2XIsomorphismPermGroup[102X ([14XReference: IsomorphismPermGroup[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(Transformation([2, 2, 3, 4, 6, 8, 5, 5]),[127X[104X
    [4X[25X>[125X [27X                  Transformation([3, 3, 8, 2, 5, 6, 4, 4]));;[127X[104X
    [4X[25Xgap>[125X [27XIsGroupAsSemigroup(S);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xiso := IsomorphismPermGroup(S);;[127X[104X
    [4X[25Xgap>[125X [27XSource(iso) = S and Range(iso) = Group([(5, 6, 8), (2, 3, 8, 4)]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XStructureDescription(Range(IsomorphismPermGroup(S)));[127X[104X
    [4X[28X"S6"[128X[104X
    [4X[25Xgap>[125X [27XS := Range(IsomorphismPartialPermSemigroup(SymmetricGroup(4)));[127X[104X
    [4X[28X<partial perm group of size 24, rank 4 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRange(IsomorphismPermGroup(S));[127X[104X
    [4X[28XGroup([ (1,2,3,4), (1,2) ])[128X[104X
    [4X[25Xgap>[125X [27XG := GroupOfUnits(PartitionMonoid(4));[127X[104X
    [4X[28X<block bijection group of degree 4 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XStructureDescription(G);[127X[104X
    [4X[28X"S4"[128X[104X
    [4X[25Xgap>[125X [27Xiso := IsomorphismPermGroup(G);;[127X[104X
    [4X[25Xgap>[125X [27XRespectsMultiplication(iso);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xinv := InverseGeneralMapping(iso);;[127X[104X
    [4X[25Xgap>[125X [27XForAll(G, x -> (x ^ iso) ^ inv = x);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XForAll(G, x -> ForAll(G, y -> (x * y) ^ iso = x ^ iso * y ^ iso));[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X6.5-6 RZMSNormalization[101X
  
  [33X[1;0Y[29X[2XRZMSNormalization[102X( [3XR[103X ) [32X attribute[133X
  [6XReturns:[106X  [33X[0;10YAn isomorphism.[133X
  
  [33X[0;0YIf  [3XR[103X  is  a  Rees 0-matrix semigroup [22XM^0[I, T, Λ; P][122X then [10XRZMSNormalization[110X
  returns  an  isomorphism  from [3XR[103X to a [13Xnormalized[113X Rees 0-matrix semigroup [22XS =
  M^0[I,  T,  Λ;  Q][122X.  The  structure  matrix [22XQ[122X is obtained by [13Xnormalizing[113X the
  matrix [22XP[122X (see [2XMatrix[102X ([14XReference: Matrix[114X)) and has the following properties:[133X
  
  [30X    [33X[0;6YThe  matrix [22XQ[122X is in block diagonal form, and the blocks are ordered by
        decreasing  size  along  the  leading diagonal (the size of a block is
        defined  to be the number of rows it contains multiplied by the number
        of columns it contains).[133X
  
        [33X[0;6YIf  the  index  sets [22XI[122X and [22XΛ[122X are partitioned into [22Xk[122X parts according to
        the  [2XRZMSConnectedComponents[102X  ([14X11.14-2[114X)  of [22XS[122X, giving a disjoint union
        [22XI=I_1∪...∪  I_k[122X  and  [22XΛ=Λ_1∪...∪Λ_k[122X, then the [22Xr[122Xth block corresponds to
        the sub-matrix [22XQ_r[122X of [22XQ[122X defined by [22XI_r[122X and [22XΛ_r[122X.[133X
  
  [30X    [33X[0;6YThe  first  non-zero  entry  in  a row occurs no sooner than the first
        non-zero entry in any previous row.[133X
  
  [30X    [33X[0;6YThe  first  non-zero entry in a column occurs no sooner than the first
        non-zero entry in any previous column.[133X
  
  [30X    [33X[0;6YThe previous two items imply that if the matrix [22XP[122X has any rows/columns
        consisting  entirely  of  zeroes,  then  these  will  become the final
        rows/columns of [22XQ[122X.[133X
  
  [33X[0;0YFurthermore,  if [22XT[122X is a group (i.e. a semigroup for which [2XIsGroupAsSemigroup[102X
  ([14X12.1-7[114X)  returns [9Xtrue[109X), then the non-zero entries of the structure matrix [22XQ[122X
  are chosen such that the following hold:[133X
  
  [30X    [33X[0;6YThe first non-zero entry of every row and every column is equal to the
        identity of [22XT[122X.[133X
  
  [30X    [33X[0;6YFor  each [22Xr[122X, let [22XQ_r[122X be the sub-matrix of [22XQ[122X defined by [22XI_r[122X and [22XΛ_r[122X (as
        above), and let [22XT_r[122X be the subsemigroup of [22XT[122X generated by the non-zero
        entries  of  [22XQ_r[122X.  Then  the idempotent generated subsemigroup of [22XS[122X is
        equal to:[133X
  
        [30X    [33X[0;12Y[22X⋃_r=1^k  M^0[I_r, T_r, Λ_r, Q_r][122X, where the zeroes of these Rees
              0-matrix semigroups are all identified with the zero of [22XS[122X.[133X
  
  [33X[0;0YThe  normalization  given  by  [10XRZMSNormalization[110X  is  based  on Theorem 2 of
  [Gra68]  and  is  sometimes  called [13XGraham normal form[113X. Note that isomorphic
  Rees 0-matrix semigroups can have normalizations which are not equal.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XR := ReesZeroMatrixSemigroup(Group(()),[127X[104X
    [4X[25X>[125X [27X[[0, (), 0],[127X[104X
    [4X[25X>[125X [27X [(), 0, 0],[127X[104X
    [4X[25X>[125X [27X [0, 0, ()]]);[127X[104X
    [4X[28X<Rees 0-matrix semigroup 3x3 over Group(())>[128X[104X
    [4X[25Xgap>[125X [27Xiso := RZMSNormalization(R);[127X[104X
    [4X[28X<Rees 0-matrix semigroup 3x3 over Group(())> ->[128X[104X
    [4X[28X<Rees 0-matrix semigroup 3x3 over Group(())>[128X[104X
    [4X[25Xgap>[125X [27XS := Range(iso);[127X[104X
    [4X[28X<Rees 0-matrix semigroup 3x3 over Group(())>[128X[104X
    [4X[25Xgap>[125X [27XMatrix(S);[127X[104X
    [4X[28X[ [ (), 0, 0 ], [ 0, (), 0 ], [ 0, 0, () ] ][128X[104X
    [4X[25Xgap>[125X [27XR := ReesZeroMatrixSemigroup(SymmetricGroup(4),[127X[104X
    [4X[25X>[125X [27X[[0, 0, 0, (1, 3, 2)],[127X[104X
    [4X[25X>[125X [27X [(2, 3), 0, 0, 0],[127X[104X
    [4X[25X>[125X [27X [0, 0, (1, 3), (1, 2)],[127X[104X
    [4X[25X>[125X [27X [0, (4, 1, 2, 3), 0, 0]]);[127X[104X
    [4X[28X<Rees 0-matrix semigroup 4x4 over Sym( [ 1 .. 4 ] )>[128X[104X
    [4X[25Xgap>[125X [27XS := Range(RZMSNormalization(R));[127X[104X
    [4X[28X<Rees 0-matrix semigroup 4x4 over Sym( [ 1 .. 4 ] )>[128X[104X
    [4X[25Xgap>[125X [27XMatrix(S);[127X[104X
    [4X[28X[ [ (), (), 0, 0 ], [ 0, (), 0, 0 ], [ 0, 0, (), 0 ], [ 0, 0, 0, () ][128X[104X
    [4X[28X ][128X[104X
  [4X[32X[104X
  
  [1X6.5-7 RMSNormalization[101X
  
  [33X[1;0Y[29X[2XRMSNormalization[102X( [3XR[103X ) [32X attribute[133X
  [6XReturns:[106X  [33X[0;10YAn isomorphism.[133X
  
  [33X[0;0YIf  [3XR[103X  is a Rees matrix semigroup over a group [10XG[110X (i.e. a semigroup for which
  [2XIsGroupAsSemigroup[102X  ([14X12.1-7[114X) returns [9Xtrue[109X), then [10XRMSNormalization[110X returns an
  isomorphism from [3XR[103X to a [13Xnormalized[113X Rees matrix semigroup [10XS[110X over [10XG[110X.[133X
  
  [33X[0;0YThe  semigroup [10XS[110X is normalized in the sense that the first entry of each row
  and column of the [2XMatrix[102X ([14XReference: Matrix[114X) of [10XS[110X is the identity element of
  [10XG[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XR := ReesMatrixSemigroup(SymmetricGroup(4),[127X[104X
    [4X[25X>[125X [27X[[(1, 2), (2, 4, 3), (2, 1, 4)],[127X[104X
    [4X[25X>[125X [27X [(1, 3, 2), (1, 2)(3, 4), ()],[127X[104X
    [4X[25X>[125X [27X [(2, 3), (1, 3, 2, 4), (2, 3)]]);[127X[104X
    [4X[28X<Rees matrix semigroup 3x3 over Sym( [ 1 .. 4 ] )>[128X[104X
    [4X[25Xgap>[125X [27Xiso := RMSNormalization(R);[127X[104X
    [4X[28X<Rees matrix semigroup 3x3 over Sym( [ 1 .. 4 ] )> ->[128X[104X
    [4X[28X<Rees matrix semigroup 3x3 over Sym( [ 1 .. 4 ] )>[128X[104X
    [4X[25Xgap>[125X [27XS := Range(iso);[127X[104X
    [4X[28X<Rees matrix semigroup 3x3 over Sym( [ 1 .. 4 ] )>[128X[104X
    [4X[25Xgap>[125X [27XMatrix(S);[127X[104X
    [4X[28X[ [ (), (), () ], [ (), (1,2), (1,4,2,3) ], [ (), (1,4,2,3), (2,4) ] ][128X[104X
  [4X[32X[104X
  
  [1X6.5-8 IsomorphismReesMatrixSemigroup[101X
  
  [33X[1;0Y[29X[2XIsomorphismReesMatrixSemigroup[102X( [3XS[103X ) [32X attribute[133X
  [33X[1;0Y[29X[2XIsomorphismReesZeroMatrixSemigroup[102X( [3XS[103X ) [32X attribute[133X
  [33X[1;0Y[29X[2XIsomorphismReesMatrixSemigroupOverPermGroup[102X( [3XS[103X ) [32X attribute[133X
  [33X[1;0Y[29X[2XIsomorphismReesZeroMatrixSemigroupOverPermGroup[102X( [3XS[103X ) [32X attribute[133X
  [6XReturns:[106X  [33X[0;10YAn isomorphism.[133X
  
  [33X[0;0YIf the semigroup [3XS[103X is finite and simple, then [10XIsomorphismReesMatrixSemigroup[110X
  returns an isomorphism to a Rees matrix semigroup over some group (usually a
  permutation  group), and [10XIsomorphismReesMatrixSemigroupOverPermGroup[110X returns
  an isomorphism to a Rees matrix semigroup over a permutation group.[133X
  
  [33X[0;0YIf [3XS[103X is finite and 0-simple, then [10XIsomorphismReesZeroMatrixSemigroup[110X returns
  an  isomorphism  to  a  Rees  0-matrix  semigroup over some group (usually a
  permutation   group),   and  [10XIsomorphismReesZeroMatrixSemigroupOverPermGroup[110X
  returns  an  isomorphism  to  a  Rees  0-matrix semigroup over a permutation
  group.[133X
  
  [33X[0;0YSee also [2XInjectionPrincipalFactor[102X ([14X10.4-7[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(PartialPerm([1]));[127X[104X
    [4X[28X<trivial partial perm group of rank 1 with 1 generator>[128X[104X
    [4X[25Xgap>[125X [27Xiso := IsomorphismReesMatrixSemigroup(S);;[127X[104X
    [4X[25Xgap>[125X [27XSource(iso) = S;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XRange(iso);[127X[104X
    [4X[28X<Rees matrix semigroup 1x1 over Group(())>[128X[104X
    [4X[25Xgap>[125X [27XS := Semigroup(PartialPerm([1]), PartialPerm([]));[127X[104X
    [4X[28X<partial perm monoid of rank 1 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRange(IsomorphismReesZeroMatrixSemigroup(S));[127X[104X
    [4X[28X<Rees 0-matrix semigroup 1x1 over Group(())>[128X[104X
  [4X[32X[104X
  
  [1X6.5-9 AntiIsomorphismDualFpSemigroup[101X
  
  [33X[1;0Y[29X[2XAntiIsomorphismDualFpSemigroup[102X( [3XS[103X ) [32X attribute[133X
  [33X[1;0Y[29X[2XAntiIsomorphismDualFpMonoid[102X( [3XS[103X ) [32X attribute[133X
  [6XReturns:[106X  [33X[0;10YA finitely presented semigroup or monoid.[133X
  
  [33X[0;0Y[10XAntiIsomorphismDualFpSemigroup[110X       returns       an       anti-isomorphism
  ([2XMappingByFunction[102X   ([14XReference:   MappingByFunction[114X))   from  the  finitely
  presented  semigroup  [3XS[103X  to  another finitely presented semigroup. The range
  finitely  presented  semigroup is obtained from [3XS[103X by reversing the relations
  of [3XS[103X.[133X
  
  [33X[0;0Y[10XAntiIsomorphismDualFpMonoid[110X works analogously when [3XS[103X is a finitely presented
  monoid,  and  the  range  of  the  returned  anti-isomorphism  is a finitely
  presented monoid.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XF := FreeSemigroup("a", "b");[127X[104X
    [4X[28X<free semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27XAssignGeneratorVariables(F);[127X[104X
    [4X[25Xgap>[125X [27XR := [[a ^ 3, a], [b ^ 2, b], [(a * b) ^ 2, a]];[127X[104X
    [4X[28X[ [ a^3, a ], [ b^2, b ], [ (a*b)^2, a ] ][128X[104X
    [4X[25Xgap>[125X [27XS := F / R;[127X[104X
    [4X[28X<fp semigroup with 2 generators and 3 relations of length 14>[128X[104X
    [4X[25Xgap>[125X [27Xmap := AntiIsomorphismDualFpSemigroup(S);[127X[104X
    [4X[28XMappingByFunction( <fp semigroup with 2 generators and[128X[104X
    [4X[28X  3 relations of length 14>, <fp semigroup with 2 generators and[128X[104X
    [4X[28X  3 relations of length 14>[128X[104X
    [4X[28X , function( x ) ... end, function( x ) ... end )[128X[104X
    [4X[25Xgap>[125X [27XRelationsOfFpSemigroup(Range(map));[127X[104X
    [4X[28X[ [ a^3, a ], [ b^2, b ], [ (b*a)^2, a ] ][128X[104X
  [4X[32X[104X
  
  [1X6.5-10 EmbeddingFpMonoid[101X
  
  [33X[1;0Y[29X[2XEmbeddingFpMonoid[102X( [3XS[103X ) [32X attribute[133X
  [6XReturns:[106X  [33X[0;10YA finitely presented monoid.[133X
  
  [33X[0;0Y[10XEmbeddingFpMonoid[110X   returns   an   embedding  ([2XSemigroupHomomorphismByImages[102X
  ([14X14.1-1[114X))  from the finitely presented semigroup [3XS[103X into a finitely presented
  monoid.  If  [3XS[103X  satisfies  [2XIsMonoidAsSemigroup[102X  ([14X12.1-13[114X),  then the mapping
  returned  by  this  function  is  an  isomorphism  (the  same isomorphism as
  [2XIsomorphismFpMonoid[102X ([14XReference: IsomorphismFpMonoid[114X)). If [3XS[103X is not a monoid,
  then  the  range is isomorphic to [3XS[103X with an identity adjoined (a new element
  not  previously  in [3XS[103X). The embedded copy of [3XS[103X in the range can be recovered
  using [2XImage[102X ([14XReference: Image[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XF := FreeSemigroup("a", "b");[127X[104X
    [4X[28X<free semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27XAssignGeneratorVariables(F);[127X[104X
    [4X[25Xgap>[125X [27XR := [[a ^ 3, a], [b ^ 2, b], [(a * b) ^ 2, a]];[127X[104X
    [4X[28X[ [ a^3, a ], [ b^2, b ], [ (a*b)^2, a ] ][128X[104X
    [4X[25Xgap>[125X [27XS := F / R;[127X[104X
    [4X[28X<fp semigroup with 2 generators and 3 relations of length 14>[128X[104X
    [4X[25Xgap>[125X [27XSize(S);[127X[104X
    [4X[28X3[128X[104X
    [4X[25Xgap>[125X [27XIsMonoidAsSemigroup(S);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xmap := EmbeddingFpMonoid(S);[127X[104X
    [4X[28X<fp semigroup with 2 generators and 3 relations of length 14> ->[128X[104X
    [4X[28X<fp monoid with 2 generators and 3 relations of length 14>[128X[104X
    [4X[25Xgap>[125X [27XSize(Range(map));[127X[104X
    [4X[28X4[128X[104X
  [4X[32X[104X
  
  
  [1X6.6 [33X[0;0YRandom semigroups[133X[101X
  
  [1X6.6-1 RandomSemigroup[101X
  
  [33X[1;0Y[29X[2XRandomSemigroup[102X( [3Xarg...[103X ) [32X function[133X
  [33X[1;0Y[29X[2XRandomMonoid[102X( [3Xarg...[103X ) [32X function[133X
  [33X[1;0Y[29X[2XRandomInverseSemigroup[102X( [3Xarg...[103X ) [32X function[133X
  [33X[1;0Y[29X[2XRandomInverseMonoid[102X( [3Xarg...[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA semigroup.[133X
  
  [33X[0;0YThe operations described in this section can be used to generate semigroups,
  in some sense, at random. There is no guarantee given about the distribution
  of  these  semigroups,  and  this  is only intended as a means of generating
  semigroups for testing and other similar purposes.[133X
  
  [33X[0;0YRoughly  speaking,  the arguments of [10XRandomSemigroup[110X are a filter specifying
  the  type  of  the  semigroup  to  be  returned,  together with some further
  parameters  that  describe  some attributes of the semigroup to be returned.
  For instance, we may want to specify the number of generators, and, say, the
  degree,  or  dimension, of the elements, where appropriate. The arguments of
  [10XRandomMonoid[110X, [10XRandomInverseSemigroup[110X, and [10XRandomInverseMonoid[110X are analogous.[133X
  
  [33X[0;0YIf  no  arguments  are  specified, then they are all chosen at random, for a
  truly random experience.[133X
  
  [33X[0;0YThe   first   argument,   if   present,  should  be  a  filter  [3Xfilter[103X.  For
  [10XRandomSemigroup[110X  and [10XRandomInverseSemigroup[110X the filter [3Xfilter[103X must be of the
  form   [10XIsXSemigroup[110X.   For  example,  [2XIsTransformationSemigroup[102X  ([14XReference:
  IsTransformationSemigroup[114X),  [2XIsFpSemigroup[102X  ([14XReference:  IsFpSemigroup[114X), and
  [2XIsPBRSemigroup[102X ([14X4.6-1[114X) are some possible values for [3Xfilter[103X. For [10XRandomMonoid[110X
  and  [10XRandomInverseMonoid[110X  the argument [3Xfilter[103X must be of the form [10XIsXMonoid[110X;
  such as [2XIsBipartitionMonoid[102X ([14X3.8-1[114X) or [2XIsBooleanMatMonoid[102X ([14X5.7-2[114X).[133X
  
  [33X[0;0YSuppose   that  the  first  argument  [3Xfilter[103X  is  [2XIsFpSemigroup[102X  ([14XReference:
  IsFpSemigroup[114X).  Then the only other arguments that can be specified is (and
  this argument is also optional):[133X
  
  [8Xnumber of generators[108X
        [33X[0;6YThe  second  argument,  if  present,  should  be  a positive integer [3Xm[103X
        indicating the number of generators that the semigroup should have. If
        the  second  argument [3Xm[103X is not specified, then a number is selected at
        random.[133X
  
  [33X[0;0YIf   [3Xfilter[103X  is  a  filter  such  as  [2XIsTransformationSemigroup[102X  ([14XReference:
  IsTransformationSemigroup[114X)   or  [2XIsIntegerMatrixSemigroup[102X  ([14X5.7-1[114X),  then  a
  further argument can be specified:[133X
  
  [8Xdegree / dimension[108X
        [33X[0;6YThe  third argument, if present, should be a positive integer [3Xn[103X, which
        specifies  the  degree or dimension of the generators. For example, if
        the first argument [3Xfilter[103X is [10XIsTransformationSemigroup[110X, then the value
        of  this argument is the degree of the transformations in the returned
        semigroup; or if [3Xfilter[103X is [10XIsMatrixOverFiniteFieldSemigroup[110X, then this
        argument is the dimension of the matrices in the returned semigroup.[133X
  
  [33X[0;0YIf  [3Xfilter[103X  is [2XIsTropicalMaxPlusMatrixSemigroup[102X ([14X5.7-1[114X), for example, then a
  fourth argument can be given (or not!):[133X
  
  [8Xthreshold[108X
        [33X[0;6YThe fourth argument, if present, should be a positive integer [3Xt[103X, which
        specifies the threshold of the semiring over which the matrices in the
        returned semigroup are defined.[133X
  
  [33X[0;0YYou   get   the   idea,   the   error  messages  are  self-explanatory,  and
  [10XRandomSemigroup[110X works for most of the type of semigroups defined in [5XGAP[105X.[133X
  
  [33X[0;0Y[10XRandomMonoid[110X  is  similar  to  [10XRandomSemigroup[110X  except  it returns a monoid.
  Likewise,  [10XRandomInverseSemigroup[110X  and  [10XRandomInverseMonoid[110X  return  inverse
  semigroups and monoids, respectively.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup();[127X[104X
    [4X[28X<semigroup of 10x10 max-plus matrices with 12 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomMonoid(IsTransformationMonoid);[127X[104X
    [4X[28X<transformation monoid of degree 9 with 7 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomMonoid(IsPartialPermMonoid, 2);[127X[104X
    [4X[28X<partial perm monoid of rank 17 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomMonoid(IsPartialPermMonoid, 2, 3);[127X[104X
    [4X[28X<partial perm monoid of rank 3 with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomInverseSemigroup(IsTropicalMinPlusMatrixSemigroup);[127X[104X
    [4X[28X<semigroup of 6x6 tropical min-plus matrices with 14 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomInverseSemigroup(IsTropicalMinPlusMatrixSemigroup, 1);[127X[104X
    [4X[28X<semigroup of 6x6 tropical min-plus matrices with 14 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsTropicalMinPlusMatrixSemigroup, 2);[127X[104X
    [4X[28X<semigroup of 11x11 tropical min-plus matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsTropicalMinPlusMatrixSemigroup, 2, 1);[127X[104X
    [4X[28X<semigroup of 1x1 tropical min-plus matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsTropicalMinPlusMatrixSemigroup, 2, 1, 3);[127X[104X
    [4X[25Xgap>[125X [27Xlast.1;[127X[104X
    [4X[28XMatrix(IsTropicalMinPlusMatrix, [[infinity]], 3)[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsNTPMatrixSemigroup, 2, 1, 3, 4);[127X[104X
    [4X[28X<semigroup of 1x1 ntp matrices with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27Xlast.1;[127X[104X
    [4X[28XMatrix(IsNTPMatrix, [[2]], 3, 4)[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsReesMatrixSemigroup, 2, 2);[127X[104X
    [4X[28X<Rees matrix semigroup 2x2 over[128X[104X
    [4X[28X  <permutation group of size 659 with 1 generator>>[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsReesZeroMatrixSemigroup, 2, 2, Group((1, 2), (3, 4)));[127X[104X
    [4X[28X<Rees 0-matrix semigroup 2x2 over Group([ (1,2), (3,4) ])>[128X[104X
    [4X[25Xgap>[125X [27XRandomInverseMonoid(IsMatrixOverFiniteFieldMonoid, 2, 2);[127X[104X
    [4X[28X<monoid of 3x3 matrices over GF(421^4) with 3 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomInverseMonoid(IsMatrixOverFiniteFieldMonoid, 2, 2, GF(7));[127X[104X
    [4X[28X<monoid of 3x3 matrices over GF(7) with 2 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsBipartitionSemigroup, 5, 5);[127X[104X
    [4X[28X<bipartition semigroup of degree 5 with 5 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomMonoid(IsBipartitionMonoid, 5, 5);[127X[104X
    [4X[28X<bipartition monoid of degree 5 with 5 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomSemigroup(IsBooleanMatSemigroup);[127X[104X
    [4X[28X<semigroup of 3x3 boolean matrices with 18 generators>[128X[104X
    [4X[25Xgap>[125X [27XRandomMonoid(IsBooleanMatMonoid);[127X[104X
    [4X[28X<monoid of 11x11 boolean matrices with 19 generators>[128X[104X
  [4X[32X[104X
  
