  
  [1X3 [33X[0;0YGroupoids[133X[101X
  
  [33X[0;0YA   [13Xgroupoid[113X  is  a  (mathematical)  category  in  which  every  element  is
  invertible.  It  consists  of  a set of [13Xpieces[113X, each of which is a connected
  groupoid.  (The  usual  terminology  is  `connected  component',  but in [5XGAP[105X
  `component' is used for `record component'.)[133X
  
  [33X[0;0YA  [13Xsingle piece groupoid[113X is determined by a set of [13Xobjects[113X [10Xobs[110X and an [13Xobject
  group[113X [10Xgrp[110X. The objects of a single piece groupoid are generally chosen to be
  consecutive  negative  integers, but any suitable ordered set is acceptable,
  and  `consecutive'  is  not a requirement. The object groups will usually be
  taken  to  be  permutation  groups,  but  pc-groups  and  fp-groups are also
  supported.[133X
  
  [33X[0;0YA [13Xgroup[113X is a single piece groupoid with one object.[133X
  
  [33X[0;0YA  [13Xgroupoid[113X  is a set of one or more single piece groupoids, its [13Xpieces[113X, and
  is represented as [10XIsGroupoidRep[110X, with attribute [10XPiecesOfGroupoid[110X.[133X
  
  [33X[0;0YA  groupoid  is  [13Xhomogeneous[113X  if  it has two of more isomorphic pieces, with
  identical groups. The special case of [13Xhomogeneous, discrete[113X groupoids, where
  each  piece  has  a  single  object,  is given its own representation. These
  groupoids are used in the [5XXMod[105X package as the source of many crossed modules
  of groupoids.[133X
  
  [33X[0;0YFor  the  definitions of the standard properties of groupoids we refer to R.
  Brown's   book  ``Topology''  [Bro88],  recently  revised  and  reissued  as
  ``Topology and Groupoids'' [Bro06].[133X
  
  
  [1X3.1 [33X[0;0YGroupoids: their properties and attributes[133X[101X
  
  [1X3.1-1 SinglePieceGroupoid[101X
  
  [29X[2XSinglePieceGroupoid[102X( [3Xgrp[103X, [3Xobs[103X ) [32X operation
  [29X[2XGroupoid[102X( [3Xargs[103X ) [32X function
  
  [33X[0;0YAs  for  magmas  with objects, the simplest construction of a groupoid is as
  the direct product of a group and a complete graph. Some subgroups of such a
  groupoid  do  not  have  this simple form, and will be considered in a later
  section.  The  global  function  [10XGroupoid[110X will normally find the appropriate
  constructor to call, the options being:[133X
  
  [30X    [33X[0;6Ythe object group, a list of objects;[133X
  
  [30X    [33X[0;6Ya group being converted to a groupoid, a single object;[133X
  
  [30X    [33X[0;6Ya list of groupoids which have already been constructed.[133X
  
  [33X[0;0YMethods for [10XViewObj[110X, [10XPrintObj[110X and [10XDisplay[110X are provided for groupoids and the
  other types of object in this package. Users are advised to supply names for
  all the groups and groupoids they construct.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xs4 := Group( (1,2,3,4), (3,4) );; [127X[104X
    [4X[25Xgap>[125X [27Xd8 := Subgroup( s4, [ (1,2,3,4), (1,3) ] );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( s4, "s4" );  SetName( d8, "d8" ); [127X[104X
    [4X[25Xgap>[125X [27XGs4 := SinglePieceGroupoid( s4, [-15 .. -11] ); [127X[104X
    [4X[28Xsingle piece groupoid: < s4, [ -15 .. -11 ] >[128X[104X
    [4X[25Xgap>[125X [27XGd8 := Groupoid( d8, [-9,-8,-7] );[127X[104X
    [4X[28Xsingle piece groupoid: < d8, [ -9, -8, -7 ] >[128X[104X
    [4X[25Xgap>[125X [27Xc6 := Group( (5,6,7)(8,9) );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( c6, "c6" );[127X[104X
    [4X[25Xgap>[125X [27XGc6 := DomainWithSingleObject( c6, -6 );[127X[104X
    [4X[28Xsingle piece groupoid: < c6, [ -6 ] >[128X[104X
    [4X[25Xgap>[125X [27XSetName( Gs4, "Gs4" );  SetName( Gd8, "Gd8" );  SetName( Gc6, "Gc6" );  [127X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.1-2 IsPermGroupoid[101X
  
  [29X[2XIsPermGroupoid[102X( [3Xgpd[103X ) [32X property
  [29X[2XIsPcGroupoid[102X( [3Xgpd[103X ) [32X property
  [29X[2XIsFpGroupoid[102X( [3Xgpd[103X ) [32X property
  
  [33X[0;0YA  groupoid  is  a  permutation  groupoid if all its pieces have permutation
  groups.  Most of the examples in this chapter are permutation groupoids, but
  in  principle  any  type of group known to [5XGAP[105X may be used. In the following
  example [10XGf2[110X is an fp-groupoid, while [10XGq8[110X is a pc-groupoid.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xf2 := FreeGroup( 2 );;[127X[104X
    [4X[25Xgap>[125X [27XGf2 := Groupoid( f2, -22 );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( f2, "f2" );  SetName( Gf2, "Gf2" ); [127X[104X
    [4X[25Xgap>[125X [27Xq8 := SmallGroup( 8, 4 );;[127X[104X
    [4X[25Xgap>[125X [27XGq8 := Groupoid( q8, [ -28, -27 ] );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( q8, "q8" );  SetName( Gq8, "Gq8" );[127X[104X
    [4X[25Xgap>[125X [27X[ IsFpGroupoid( Gf2 ), IsPcGroupoid( Gq8 ), IsPermGroupoid( Gs4 ) ]; [127X[104X
    [4X[28X[ true, true, true ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.1-3 UnionOfPieces[101X
  
  [29X[2XUnionOfPieces[102X( [3Xpieces[103X ) [32X operation
  [29X[2XReplaceOnePieceInUnion[102X( [3Xgpd[103X, [3Xold_piece[103X, [3Xnew_piece[103X ) [32X operation
  
  [33X[0;0YWhen  a  groupoid  consists  of  two or more pieces, we require their object
  lists  to  be  disjoint.  [10XUnionOfPieces[110X  from  section  [14X1.4[114X is also used for
  groupoids.  The pieces are sorted by the first object in their object lists.
  The [10XObjectList[110X is the sorted concatenation of the objects in the pieces.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XU3 := UnionOfPieces( [ Gs4, Gd8, Gc6 ] );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( U3, "Gs4+Gd8+Gc6" );[127X[104X
    [4X[25Xgap>[125X [27XDisplay( U3 );[127X[104X
    [4X[28Xgroupoid with 3 pieces:[128X[104X
    [4X[28X< objects: [ -15 .. -11 ][128X[104X
    [4X[28X    group: s4 = <[ (1,2,3,4), (3,4) ]> >[128X[104X
    [4X[28X< objects: [ -9, -8, -7 ][128X[104X
    [4X[28X    group: d8 = <[ (1,2,3,4), (1,3) ]> >[128X[104X
    [4X[28X< objects: [ -6 ][128X[104X
    [4X[28X    group: c6 = <[ (5,6,7)(8,9) ]> >[128X[104X
    [4X[25Xgap>[125X [27XPieces( U3 );[127X[104X
    [4X[28X[ Gs4, Gd8, Gc6 ][128X[104X
    [4X[25Xgap>[125X [27XObjectList( U3 );[127X[104X
    [4X[28X[ -15, -14, -13, -12, -11, -9, -8, -7, -6 ][128X[104X
    [4X[25Xgap>[125X [27XU2 := Groupoid( [ Gf2, Gq8 ] );;[127X[104X
    [4X[25Xgap>[125X [27X[ Size(Gs4), Size(Gd8), Size(Gc6), Size(U3), Size(U2) ];[127X[104X
    [4X[28X[ 600, 72, 6, 678, infinity ][128X[104X
    [4X[25Xgap>[125X [27XU5 := UnionOfPieces( [ U3, Gf2, Gq8 ] );[127X[104X
    [4X[28Xgroupoid with 5 pieces:[128X[104X
    [4X[28X[ Gq8, Gf2, Gs4, Gd8, Gc6 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay( U5 );[127X[104X
    [4X[28Xgroupoid with 5 pieces:[128X[104X
    [4X[28X< objects: [ -28, -27 ][128X[104X
    [4X[28X    group: q8 = <[ f1, f2, f3 ]> >[128X[104X
    [4X[28X< objects: [ -22 ][128X[104X
    [4X[28X    group: f2 = <[ f1, f2 ]> >[128X[104X
    [4X[28X< objects: [ -15, -14, -13, -12, -11 ][128X[104X
    [4X[28X    group: s4 = <[ (1,2,3,4), (3,4) ]> >[128X[104X
    [4X[28X< objects: [ -9, -8, -7 ][128X[104X
    [4X[28X    group: d8 = <[ (1,2,3,4), (1,3) ]> >[128X[104X
    [4X[28X< objects: [ -6 ][128X[104X
    [4X[28X    group: c6 = <[ (5,6,7)(8,9) ]> >[128X[104X
    [4X[25Xgap>[125X [27XV5 := Groupoid( [ Gq8, Gf2, U3 ] );;[127X[104X
    [4X[25Xgap>[125X [27XU5 = V5;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XRs4 := Groupoid( s4, [-20,-19] );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( Rs4, "Rs4" ); [127X[104X
    [4X[25Xgap>[125X [27XW5 := ReplaceOnePieceInUnion( U5, Gs4, Groupoid( s4, [-20,-19] ) ); [127X[104X
    [4X[28Xgroupoid with 5 pieces:[128X[104X
    [4X[28X[ Gq8, Gf2, Rs4, Gd8, Gc6 ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.1-4 HomogeneousGroupoid[101X
  
  [29X[2XHomogeneousGroupoid[102X( [3Xgpd[103X, [3Xoblist[103X ) [32X operation
  [29X[2XHomogeneousDiscreteGroupoid[102X( [3Xgp[103X, [3Xobs[103X ) [32X operation
  
  [33X[0;0YSpecial  functions  are  provided  for the case where a groupoid consists of
  identical  connected  components.  We  call these groupoids [13Xhomogeneous[113X. The
  operation  [10XHomogeneousGroupoid[110X is used when the components each contain more
  than  one  object,  while  the operation [10XHomogeneousDiscreteGroupoid[110X is used
  when  the  components each have a single object. Both types of groupoid have
  the  property  [10XIsHomogeneousDomainWithObjects[110X,  and  in  the  latter  case a
  separate representation [10XIsHomogeneousDiscreteGroupoidRep[110X is used.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XHd8 := HomogeneousGroupoid( Gd8, [ [-12,-11,-10], [-16,-15,-14] ] ); [127X[104X
    [4X[28Xhomogeneous groupoid with 2 pieces:[128X[104X
    [4X[28X1:  single piece groupoid: < d8, [ -16, -15, -14 ] >[128X[104X
    [4X[28X2:  single piece groupoid: < d8, [ -12, -11, -10 ] >[128X[104X
    [4X[25Xgap>[125X [27XHc6 := HomogeneousDiscreteGroupoid( c6, [-7..-4] );[127X[104X
    [4X[28Xhomogeneous, discrete groupoid: < c6, [ -7 .. -4 ] >[128X[104X
    [4X[25Xgap>[125X [27XRepresentationsOfObject(Gd8);[127X[104X
    [4X[28X[ "IsComponentObjectRep", "IsAttributeStoringRep", "IsMWOSinglePieceRep" ][128X[104X
    [4X[25Xgap>[125X [27XRepresentationsOfObject(Hd8);[127X[104X
    [4X[28X[ "IsComponentObjectRep", "IsAttributeStoringRep", "IsPiecesRep" ][128X[104X
    [4X[25Xgap>[125X [27XRepresentationsOfObject(Hc6);[127X[104X
    [4X[28X[ "IsComponentObjectRep", "IsAttributeStoringRep", [128X[104X
    [4X[28X  "IsHomogeneousDiscreteGroupoidRep" ][128X[104X
    [4X[25Xgap>[125X [27XKnownTruePropertiesOfObject(Hc6); [127X[104X
    [4X[28X[ "CanEasilyCompareElements", "CanEasilySortElements", "IsDuplicateFree", [128X[104X
    [4X[28X  "IsAssociative", "IsCommutative", "IsDiscreteDomainWithObjects", [128X[104X
    [4X[28X  "IsHomogeneousDomainWithObjects" ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X3.2 [33X[0;0YGroupoid elements; stars; costars and homsets[133X[101X
  
  [1X3.2-1 GroupoidElement[101X
  
  [29X[2XGroupoidElement[102X( [3Xgpd[103X, [3Xelt[103X, [3Xtail[103X, [3Xhead[103X ) [32X operation
  [29X[2XIsElementOfGroupoid[102X( [3Xelt[103X ) [32X property
  [29X[2XSize[102X( [3Xgpd[103X ) [32X attribute
  
  [33X[0;0YA  [13Xgroupoid element[113X [10Xe[110X is a triple consisting of a group element, [10XArrowelt(e)[110X
  or  [10Xe![1][110X;  the  tail  (source)  object, [10XArrowtail(e)[110X or [10Xe![2][110X; and the head
  (target)  object,  [10XArrowhead(e)[110X  or  [10Xe![3][110X.  Note  that  [10XGroupoidElement[110X  is
  essentially     a     synonym,     in     the     groupoid     case,     for
  [10XMultiplicativeElementWithObjects[110X.[133X
  
  [33X[0;0YThe  [10XSize[110X  of  a  groupoid is the number of its elements which, for a single
  piece  groupoid,  is the product of the size of the group with the square of
  the number of objects.[133X
  
  [33X[0;0YAs  for elements in any magma with objects, groupoid elements have a [13Xpartial
  composition[113X:  two  elements  may  be  multiplied  when the head of the first
  coincides with the tail of the second.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xe1 := GroupoidElement( Gd8, (1,2,3,4), -9, -8 );[127X[104X
    [4X[28X[(1,2,3,4) : -9 -> -8][128X[104X
    [4X[25Xgap>[125X [27Xe2 := GroupoidElement( Gd8, (1,3), -8, -7 );;[127X[104X
    [4X[25Xgap>[125X [27XPrint( [ Arrowelt(e2), Arrowtail(e2), Arrowhead(e2) ], "\n" );[127X[104X
    [4X[28X[ (1,3), -8, -7 ][128X[104X
    [4X[25Xgap>[125X [27Xprod := e1*e2;[127X[104X
    [4X[28X[(1,2)(3,4) : -9 -> -7][128X[104X
    [4X[25Xgap>[125X [27Xe3 := GroupoidElement( Gd8, (2,4), -7, -9 );;[127X[104X
    [4X[25Xgap>[125X [27Xcycle := prod*e3;[127X[104X
    [4X[28X[(1,4,3,2) : -9 -> -9][128X[104X
    [4X[25Xgap>[125X [27Xcycle^2;[127X[104X
    [4X[28X[(1,3)(2,4) : -9 -> -9][128X[104X
    [4X[25Xgap>[125X [27XOrder(cycle);[127X[104X
    [4X[28X4[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.2-2 IdentityElement[101X
  
  [29X[2XIdentityElement[102X( [3Xgpd[103X, [3Xobj[103X ) [32X operation
  
  [33X[0;0YThe  identity groupoid element [22X1_o[122X of [22XG[122X at object [22Xo[122X is [22X(e:o -> o)[122X where [22Xe[122X is
  the  identity element in the object group. The inverse [22Xe^-1[122X of [22Xe = (c : p ->
  q)[122X is [22X(c^-1 : q -> p)[122X, so that [22Xe*e^-1=1_p[122X and [22Xe^-1*e = 1_q[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xi8 := IdentityElement( Gd8, -8 );[127X[104X
    [4X[28X[() : -8 -> -8][128X[104X
    [4X[25Xgap>[125X [27X[ e1*i8, i8*e1, e1^-1]; [127X[104X
    [4X[28X[ [(1,2,3,4) : -9 -> -8], fail, [(1,4,3,2) : -8 -> -9] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.2-3 ObjectStar[101X
  
  [29X[2XObjectStar[102X( [3Xgpd[103X, [3Xobj[103X ) [32X operation
  [29X[2XObjectCostar[102X( [3Xgpd[103X, [3Xobj[103X ) [32X operation
  [29X[2XHomset[102X( [3Xgpd[103X, [3Xtail[103X, [3Xhead[103X ) [32X operation
  
  [33X[0;0YThe  [13Xstar[113X  at  [10Xobj[110X  is  the set of groupoid elements which have [10Xobj[110X as tail,
  while  the  [13Xcostar[113X is the set of elements which have [10Xobj[110X as head. The [13Xhomset[113X
  from  [10Xobj1[110X  to [10Xobj2[110X is the set of elements with the specified tail and head,
  and  so  is  bijective  with  the elements of the group. Thus every star and
  every  costar  is a union of homsets. The identity element at an object is a
  left  identity  for  the  star  and  a right identity for the costar at that
  object.[133X
  
  [33X[0;0YIn  order  not  to  create  unneccessary long lists, these operations return
  objects  of  type  [10XIsHomsetCosetsRep[110X  for which an [10XIterator[110X is provided. (An
  [10XEnumerator[110X is not yet implemented.)[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xstar9 := ObjectStar( Gd8, -9 );[127X[104X
    [4X[28X<star at [ -9 ] with group d8>[128X[104X
    [4X[25Xgap>[125X [27XSize( star9 ); [127X[104X
    [4X[28X24[128X[104X
    [4X[25Xgap>[125X [27Xfor e in star9 do[127X[104X
    [4X[25X>[125X [27X     if ( Order( e![1] ) = 4 ) then Print( e, "\n" ); fi;[127X[104X
    [4X[25X>[125X [27X   od;[127X[104X
    [4X[28X[(1,4,3,2) : -9 -> -9][128X[104X
    [4X[28X[(1,4,3,2) : -9 -> -8][128X[104X
    [4X[28X[(1,4,3,2) : -9 -> -7][128X[104X
    [4X[28X[(1,2,3,4) : -9 -> -9][128X[104X
    [4X[28X[(1,2,3,4) : -9 -> -8][128X[104X
    [4X[28X[(1,2,3,4) : -9 -> -7][128X[104X
    [4X[25Xgap>[125X [27Xcostar6 := ObjectCostar( Gc6, -6 );[127X[104X
    [4X[28X<costar at [ -6 ] with group c6>[128X[104X
    [4X[25Xgap>[125X [27XSize( costar6 ); [127X[104X
    [4X[28X6[128X[104X
    [4X[25Xgap>[125X [27Xhsetq8 := Homset( Gq8, -28, -27 );[127X[104X
    [4X[28X<homset -28 -> -27 with group q8>[128X[104X
    [4X[25Xgap>[125X [27Xfor e in hsetq8 do Print(e,"\n"); od;[127X[104X
    [4X[28X[<identity> of ... : -28 -> -27][128X[104X
    [4X[28X[f3 : -28 -> -27][128X[104X
    [4X[28X[f2 : -28 -> -27][128X[104X
    [4X[28X[f2*f3 : -28 -> -27][128X[104X
    [4X[28X[f1 : -28 -> -27][128X[104X
    [4X[28X[f1*f3 : -28 -> -27][128X[104X
    [4X[28X[f1*f2 : -28 -> -27][128X[104X
    [4X[28X[f1*f2*f3 : -28 -> -27][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X3.3 [33X[0;0YSubgroupoids[133X[101X
  
  [1X3.3-1 Subgroupoid[101X
  
  [29X[2XSubgroupoid[102X( [3Xargs[103X ) [32X function
  [29X[2XSubgroupoidByPieces[102X( [3Xgpd[103X, [3Xobhoms[103X ) [32X operation
  [29X[2XIsSubgroupoid[102X( [3Xgpd[103X, [3Xsgpd[103X ) [32X operation
  [29X[2XFullSubgroupoid[102X( [3Xgpd[103X, [3Xobs[103X ) [32X operation
  [29X[2XMaximalDiscreteSubgroupoid[102X( [3Xgpd[103X ) [32X attribute
  [29X[2XDiscreteSubgroupoid[102X( [3Xgpd[103X, [3Xsgps[103X, [3Xobs[103X ) [32X operation
  [29X[2XFullTrivialSubgroupoid[102X( [3Xgpd[103X ) [32X attribute
  [29X[2XDiscreteTrivialSubgroupoid[102X( [3Xgpd[103X ) [32X attribute
  [29X[2XIsWide[102X( [3Xgpd[103X, [3Xsgpd[103X ) [32X operation
  
  [33X[0;0YA  [13Xsubgroupoid[113X [10Xsgpd[110X of [10Xgpd[110X has as objects some subset of the objects of [10Xgpd[110X.
  It  is  [13Xwide[113X  if  all  the  objects are included. It is [13Xfull[113X if, for any two
  objects in [10Xsgpd[110X, the [10XHomset[110X is the same as that in [10Xgpd[110X. The elements of [10Xsgpd[110X
  are  a subset of those of [10Xgpd[110X, closed under multiplication and with tail and
  head in the chosen object set.[133X
  
  [33X[0;0YThere are a variety of constructors for a subgroupoid of a groupoid, and the
  most  general is the operation [10XSubgroupoidByPieces[110X. Its two parameters are a
  groupoid  and  a  list  of  pieces,  each  piece  being  specified as a list
  [10X[sgp,obs][110X,  where [10Xsgp[110X is a subgroup of the group in that piece, and [10Xobs[110X is a
  subset  of the objects in one of the pieces of [10Xgpd[110X. The [10XFullSubgroupoid[110X of a
  groupoid [10Xgpd[110X on a subset [10Xobs[110X of its objects contains all the elements of [10Xgpd[110X
  with  tail  and  head  in [10Xobs[110X. A subgroupoid is [13Xdiscrete[113X if it is a union of
  groups.  The  [10XMaximalDiscreteSubgroupoid[110X  of  [10Xgpd[110X  is  the  union of all the
  single-object  full  subgroupoids  of [10Xgpd[110X. A [13Xtrivial subgroupoid[113X has trivial
  object  groups, but need not be discrete. A single piece trivial groupoid is
  sometimes called a [13Xtree groupoid[113X. (The term [13Xidentity subgroupoid[113X was used in
  versions  up  to  1.14.)  The  global  function  [10XSubgroupoid[110X should call the
  appropriate operation.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xc4 := Subgroup( d8, [ (1,2,3,4) ] );;[127X[104X
    [4X[25Xgap>[125X [27Xk4 := Subgroup( d8, [ (1,2)(3,4), (1,3)(2,4) ] );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( c4, "c4" );  SetName( k4, "k4" );[127X[104X
    [4X[25Xgap>[125X [27XUd8 := Subgroupoid( Gd8, [ [ k4,[-9] ], [ c4, [-7,-5] ] ] );;[127X[104X
    [4X[25Xgap>[125X [27XSetName( Ud8, "Ud8" );[127X[104X
    [4X[25Xgap>[125X [27XDisplay( Ud8 );[127X[104X
    [4X[28XPerm Groupoid with 2 pieces:[128X[104X
    [4X[28X< objects: [ -9 ][128X[104X
    [4X[28X    group: k4 = <[ (1,2)(3,4), (1,3)(2,4) ]> >[128X[104X
    [4X[28X< objects: [ -7, -5 ][128X[104X
    [4X[28X    group: c4 = <[ (1,2,3,4) ]> >[128X[104X
    [4X[25Xgap>[125X [27X[ Parent( Ud8 ), IsWide( Gd8, Ud8 ) ]; [127X[104X
    [4X[28X[ Gd8, true ][128X[104X
    [4X[25Xgap>[125X [27Xgenf2b := List( GeneratorsOfGroup(f2), g -> g^2 );[127X[104X
    [4X[28X[ f1^2, f2^2 ][128X[104X
    [4X[25Xgap>[125X [27Xf2b := Subgroup( f2, genf2b );;[127X[104X
    [4X[25Xgap>[125X [27XSubgroupoidByPieces( U2, [ [q8,[-27]], [f2b,[-22]] ] );[127X[104X
    [4X[28Xgroupoid with 2 pieces:[128X[104X
    [4X[28X1:  single piece groupoid: < q8, [ -27 ] >[128X[104X
    [4X[28X2:  single piece groupoid: < Group( [ f1^2, f2^2 ] ), [ -22 ] >[128X[104X
    [4X[25Xgap>[125X [27XIsSubgroupoid( Gf2, Groupoid( f2b, [-22] ) );[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XFullSubgroupoid( U3, [-7,-6] );[127X[104X
    [4X[28Xgroupoid with 2 pieces:[128X[104X
    [4X[28X1:  single piece groupoid: < d8, [ -7 ] >[128X[104X
    [4X[28X2:  single piece groupoid: < c6, [ -6 ] >[128X[104X
    [4X[25Xgap>[125X [27XDiscreteSubgroupoid( U3, [ c4, k4 ], [-9,-7] );[127X[104X
    [4X[28Xgroupoid with 2 pieces:[128X[104X
    [4X[28X1:  single piece groupoid: < c4, [ -9 ] >[128X[104X
    [4X[28X2:  single piece groupoid: < k4, [ -7 ] >[128X[104X
    [4X[25Xgap>[125X [27XFullTrivialSubgroupoid( Ud8 );[127X[104X
    [4X[28Xgroupoid with 2 pieces:[128X[104X
    [4X[28X1:  single piece groupoid: < id(k4), [ -9 ] >[128X[104X
    [4X[28X2:  single piece groupoid: < id(c4), [ -8, -7 ] >[128X[104X
    [4X[25Xgap>[125X [27XMaximalDiscreteSubgroupoid(U2);[127X[104X
    [4X[28Xgroupoid with 3 pieces:[128X[104X
    [4X[28X1:  single piece groupoid: < q8, [ -28 ] >[128X[104X
    [4X[28X2:  single piece groupoid: < q8, [ -27 ] >[128X[104X
    [4X[28X3:  single piece groupoid: < f2, [ -22 ] >[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.3-2 SubgroupoidWithRays[101X
  
  [29X[2XSubgroupoidWithRays[102X( [3Xgpd[103X, [3Xsgp[103X, [3Xrays[103X ) [32X operation
  [29X[2XRaysOfGroupoid[102X( [3Xgpd[103X ) [32X operation
  
  [33X[0;0YIf groupoid [22XG[122X is of type [10XIsDirectProductWithCompleteGraph[110X with group [22Xg[122X and [22Xn[122X
  objects,  then  a  typical  wide  subgroupoid [22XH[122X of [22XG[122X is formed by choosing a
  subgroup  [22Xh[122X of [22Xg[122X to be the object group at the root object [22Xq[122X, and an element
  [22Xr  :  q -> p[122X for each of the objects [22Xp[122X. The chosen loop element at [22Xq[122X must be
  the  identity  element.  These  [22Xn[122X  elements  are  called  the  [13Xrays[113X  of  the
  subgroupoid.  The  elements in the homset from [22Xp[122X to [22Xp'[122X have the form [22Xr^-1xr'[122X
  for all [22Xx[122X in [22Xh[122X.[133X
  
  [33X[0;0YIn  the  following  example  a subgroupoid with rays is to be constructed on
  four  of  the  five objects. It is therefore necessary to construct the full
  subgroupoid on these four objects first.[133X
  
  [33X[0;0YIt  is  also  possible to construct a subgroupoid with rays of a subgroupoid
  with rays.[133X
  
  [33X[0;0YNote that the function [10XAncestor[110X provides an iteration of [10XParent[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XHs4 := FullSubgroupoid( Gs4, [-14,-13,-12] );; [127X[104X
    [4X[25Xgap>[125X [27XSetName( Hs4, "Hs4" ); [127X[104X
    [4X[25Xgap>[125X [27XHd8a := SubgroupoidWithRays( Hs4, d8, [(),(2,3),(3,4)] );[127X[104X
    [4X[28Xsingle piece groupoid with rays: < d8, [ -14, -13, -12 ], [ (), (2,3), (3,4)[128X[104X
    [4X[28X ] >[128X[104X
    [4X[25Xgap>[125X [27Xhs1413 := Homset( Hd8a, -14, -13 );[127X[104X
    [4X[28X<homset -14 -> -13 with group d8>[128X[104X
    [4X[25Xgap>[125X [27Xfor e in hs1413 do  Print(e,", "); od;  Print( "\n");[127X[104X
    [4X[28X[(2,3) : -14 -> -13], [(1,2,4,3) : -14 -> -13], [(1,4,2) : -14 -> -13], [[128X[104X
    [4X[28X(1,3,4) : -14 -> -13], [(2,4,3) : -14 -> -13], [(1,2,3) : -14 -> -13], [[128X[104X
    [4X[28X(1,4) : -14 -> -13], [(1,3,4,2) : -14 -> -13], [128X[104X
    [4X[25Xgap>[125X [27XHd8b := SubgroupoidWithRays( Hs4, d8, [(),(1,2,3),(1,2,4)] );[127X[104X
    [4X[28Xsingle piece groupoid with rays: < d8, [ -14, -13, -12 ],[128X[104X
    [4X[28X[ (), (1,2,3), (1,2,4) ] >[128X[104X
    [4X[25Xgap>[125X [27XHd8a = Hd8b; [127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XRaysOfGroupoid( Hd8b ); [127X[104X
    [4X[28X[ (), (1,2,3), (1,2,4) ][128X[104X
    [4X[25Xgap>[125X [27XParent( Hd8a );[127X[104X
    [4X[28XHs4[128X[104X
    [4X[25Xgap>[125X [27XAncestor( Hd8a ); [127X[104X
    [4X[28XGs4[128X[104X
    [4X[25Xgap>[125X [27XFd8a := FullSubgroupoid( Hd8a, [-14,-13]);[127X[104X
    [4X[28Xsingle piece groupoid with rays: < d8, [ -14, -13 ], [ (), (2,3) ] >[128X[104X
    [4X[25Xgap>[125X [27XFd8b := FullSubgroupoid( Hd8a, [-13,-12]);[127X[104X
    [4X[28Xsingle piece groupoid with rays: < Group( [ (1,3,2,4), (1,2) ] ), [128X[104X
    [4X[28X[ -13, -12 ], [ (), (2,4,3) ] >[128X[104X
    [4X[25Xgap>[125X [27XFd8a := FullSubgroupoid( Hd8a, [-13,-12] );            [127X[104X
    [4X[28Xsingle piece groupoid with rays: < Group( [ (1,3,2,4), (1,2) ] ), [128X[104X
    [4X[28X[ -13, -12 ], [ (), (2,4,3) ] >[128X[104X
    [4X[25Xgap>[125X [27XKd8a := SubgroupoidWithRays( Fd8a, k4, [ (), (1,3) ] ); [127X[104X
    [4X[28Xsingle piece groupoid with rays: < k4, [ -13, -12 ], [ (), (1,3) ] >[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X3.4 [33X[0;0YLeft, right and double cosets[133X[101X
  
  [1X3.4-1 RightCoset[101X
  
  [29X[2XRightCoset[102X( [3XG[103X, [3XU[103X, [3Xelt[103X ) [32X operation
  [29X[2XRightCosetRepresentatives[102X( [3XG[103X, [3XU[103X ) [32X operation
  [29X[2XLeftCoset[102X( [3XG[103X, [3XU[103X, [3Xelt[103X ) [32X operation
  [29X[2XLeftCosetRepresentatives[102X( [3XG[103X, [3XU[103X ) [32X operation
  [29X[2XLeftCosetRepresentativesFromObject[102X( [3XG[103X, [3XU[103X, [3Xobj[103X ) [32X operation
  [29X[2XDoubleCoset[102X( [3XG[103X, [3XU[103X, [3Xelt[103X, [3XV[103X ) [32X operation
  [29X[2XDoubleCosetRepresentatives[102X( [3XG[103X, [3XU[103X, [3XV[103X ) [32X operation
  
  [33X[0;0YIf  [10XU[110X  is  a  wide  subgroupoid  of [22XG[122X, the [13Xright cosets[113X [22XUg[122X of [22XU[122X in [22XG[122X are the
  equivalence  classes  for  the  relation  on  the  elements of [22XG[122X where [22Xg1[122X is
  related  to  [22Xg2[122X  if and only if [22Xg2 = u*g1[122X for some element [22Xu[122X of [22XU[122X. The right
  coset  containing  [22Xg[122X is written [22XUg[122X. These right cosets partition the costars
  of  [22XG[122X and, in particular, the costar [22XU1_o[122X of [22XU[122X at [22Xo[122X, so that (unlike groups)
  [22XU[122X is itself a coset only when [22XG[122X has a single object.[133X
  
  [33X[0;0YThe  [13Xright  coset  representatives[113X  for  [22XU[122X  in  [22XG[122X form a list containing one
  groupoid element for each coset where, in a particular piece of [22XU[122X, the group
  element  chosen  is  the right coset representative of the group of [22XU[122X in the
  group of [22XG[122X.[133X
  
  [33X[0;0YSimilarly, the [13Xleft cosets[113X [22XgU[122X refine the stars of [22XG[122X, while [13Xdouble cosets[113X are
  unions    of    left   cosets   and   of   right   cosets.   The   operation
  [10XLeftCosetRepresentativesFromObject(  G,  U,  obj )[110X is used in Chapter 4, and
  returns only those representatives which have tail at [10Xobj[110X.[133X
  
  [33X[0;0YAs  with stars and homsets, these cosets are implemented with representation
  [10XIsHomsetCosetsRep[110X  and provided with an iterator. Note that, when [22XU[122X has more
  than one piece, cosets may have differing lengths.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xre2 := RightCoset( Gd8, Ud8, e2 );[127X[104X
    [4X[28XRightCoset(single piece groupoid: < c4, [ -8, -7 ] >,[(1,3) : -8 -> -7])[128X[104X
    [4X[25Xgap>[125X [27Xfor x in re2 do Print( x, "\n" ); od;[127X[104X
    [4X[28X[(1,3) : -8 -> -7][128X[104X
    [4X[28X[(1,3) : -7 -> -7][128X[104X
    [4X[28X[(2,4) : -8 -> -7][128X[104X
    [4X[28X[(2,4) : -7 -> -7][128X[104X
    [4X[28X[(1,4)(2,3) : -8 -> -7][128X[104X
    [4X[28X[(1,4)(2,3) : -7 -> -7][128X[104X
    [4X[28X[(1,2)(3,4) : -8 -> -7][128X[104X
    [4X[28X[(1,2)(3,4) : -7 -> -7][128X[104X
    [4X[25Xgap>[125X [27Xrcrd8 := RightCosetRepresentatives( Gd8, Ud8 );[127X[104X
    [4X[28X[ [() : -9 -> -9], [() : -9 -> -8], [() : -9 -> -7], [(2,4) : -9 -> -9],[128X[104X
    [4X[28X  [(2,4) : -9 -> -8], [(2,4) : -9 -> -7], [() : -8 -> -9], [() : -8 -> -8],[128X[104X
    [4X[28X  [() : -8 -> -7], [(2,4) : -8 -> -9], [(2,4) : -8 -> -8], [(2,4) : -8 -> -7][128X[104X
    [4X[28X ][128X[104X
    [4X[25Xgap>[125X [27Xlcr7 := LeftCosetRepresentativesFromObject( Gd8, Ud8, -7 );[127X[104X
    [4X[28X[ [() : -7 -> -9], [(2,4) : -7 -> -9], [() : -7 -> -8], [(2,4) : -7 -> -8] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X3.5 [33X[0;0YConjugation[133X[101X
  
  [1X3.5-1 ConjugateGroupoidElement[101X
  
  [29X[2XConjugateGroupoidElement[102X( [3Xe1[103X, [3Xe2[103X ) [32X operation
  
  [33X[0;0YWhen  [22Xe2  = c : p -> q[122X and [22Xe1[122X has group element [22Xb[122X, the conjugate [22Xe1^e2[122X has a
  complicated  definition,  but  may be remembered as follows. All objects are
  fixed  except  [22Xp,q[122X, which are interchanged. For [22Xp,q[122X as source, multiply [22Xb[122X on
  the  left  by  [22Xc^-1,c[122X respectively; and for [22Xp,q[122X as target, multiply [22Xb[122X on the
  right  by [22Xc,c^-1[122X. This product gives the group element of the conjugate. The
  details of this construction may be found in [AW10].[133X
  
  [33X[0;0Y(Note that it is more desirable to use the command [10Xe1^e2[110X, but it has not yet
  been possible to get this to work!)[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xx := GroupoidElement( Gd8, (1,3), -9, -9 );; [127X[104X
    [4X[25Xgap>[125X [27Xy := GroupoidElement( Gd8, (1,2,3,4), -8, -9 );; [127X[104X
    [4X[25Xgap>[125X [27Xz := GroupoidElement( Gd8, (1,2)(3,4), -9, -7 );; [127X[104X
    [4X[25Xgap>[125X [27X##  conjugation with elements x, y, and z in Gd8: [127X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoidElement(x,y);[127X[104X
    [4X[28X[(2,4) : -8 -> -8][128X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoidElement(x,z);[127X[104X
    [4X[28X[(2,4) : -7 -> -7][128X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoidElement(y,x);[127X[104X
    [4X[28X[() : -8 -> -9][128X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoidElement(y,z);[127X[104X
    [4X[28X[(2,4) : -8 -> -7][128X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoidElement(z,x);[127X[104X
    [4X[28X[(1,4,3,2) : -9 -> -7][128X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoidElement(z,y);[127X[104X
    [4X[28X[(2,4) : -8 -> -7][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.5-2 SinglePieceGroupoidByGenerators[101X
  
  [29X[2XSinglePieceGroupoidByGenerators[102X( [3Xparent[103X, [3Xgens[103X ) [32X operation
  
  [33X[0;0YA  set  of  groupoid  elements  generates  a groupoid by taking all possible
  products  and  inverses.  So far, the only implementation is for the case of
  loops  generating  a group at an object [22Xo[122X andf a set of rays from [22Xo[122X, where [22Xo[122X
  is  [13Xnot[113X  the  least  object. A suitably large supergroupoid, which must be a
  direct  product  with a complete graph, should be provided. This is the case
  needed  for  [10XConjugateGroupoid[110X in the following section. Other cases will be
  added as time permits.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xu := GroupoidElement( Gs4, (1,2,3), -15, -13 ); [127X[104X
    [4X[28X[(1,2,3) : -15 -> -13][128X[104X
    [4X[25Xgap>[125X [27Xgensa := GeneratorsOfGroupoid( Hd8a );[127X[104X
    [4X[28X[ [(1,2,3,4) : -14 -> -14], [(1,3) : -14 -> -14], [(2,3) : -14 -> -13], [128X[104X
    [4X[28X  [(3,4) : -14 -> -12] ][128X[104X
    [4X[25Xgap>[125X [27Ximsa := List( gensa, g -> ConjugateGroupoidElement( g, u ) ); [127X[104X
    [4X[28X[ [(1,2,3,4) : -14 -> -14], [(1,3) : -14 -> -14], [(1,3) : -14 -> -15], [128X[104X
    [4X[28X  [(3,4) : -14 -> -12] ][128X[104X
    [4X[25Xgap>[125X [27XC := SinglePieceGroupoidByGenerators( Gs4, imsa ); [127X[104X
    [4X[28Xsingle piece groupoid with rays: < Group( [ (1,4,3,2), (1,3) ] ), [128X[104X
    [4X[28X[ -15, -14, -12 ], [ (), (1,3), (1,4,3) ] >[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.5-3 ConjugateGroupoid[101X
  
  [29X[2XConjugateGroupoid[102X( [3Xgpd[103X, [3Xe[103X ) [32X operation
  
  [33X[0;0YWhen  [22XH[122X  is a subgroupoid of a groupoid [22XG[122X and [22Xe[122X is an element of [22XG[122X, then the
  conjugate  of  [22XH[122X by [22Xe[122X is th4e subgroupoid generated by the conjugates of the
  generators of [22XH[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XConjugateGroupoid( Hd8a, u^-1 ); [127X[104X
    [4X[28Xsingle piece groupoid with rays: < Group( [ (1,4,3,2), (1,3) ] ), [128X[104X
    [4X[28X[ -15, -14, -12 ], [ (), (1,3), (1,4,3) ] >[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [33X[0;0YMore  examples  of  all  these  operations  may be found in the example file
  [11Xgpd/examples/gpd.g[111X.[133X
  
