  
  [1m[4m[31m4. Unions of Residue Classes with Fixed Representatives[0m
  
  
  [1m[4m[31m4.1 About unions of residue classes with fixed representatives[0m
  
  In this chapter, a different kind of unions of residue classes is introduced
  --  namely the one of residue classes which are endowed with a distinguished
  ("fixed")  representative.  These unions of residue classes behave different
  than  the  "ordinary"  residue  class  unions  which  were  described in the
  previous chapter:
  
  [1m[33m-[0m
        In  most  situations  they behave like lists of single residue classes
        with  fixed  representatives  rather  than like sets of ring elements.
        There   are  exceptions  from  this  behaviour,  e.g.  w.r.t.  forming
        differences, in order to ensure "delta-additivity" (-> [1m[34mDelta[0m ([1m4.4-2[0m)).
  
  [1m[33m-[0m
        They  can  be  viewed  as  [22m[36mmultisets[0m  of  ring elements -- the residue
        classes  in  such  a  union are not necessarily disjoint, and not even
        necessarily distinct.
  
  Throughout  this  chapter,  the  argument  [22m[34mR[0m  denotes the ring whose residue
  classes  are  considered,  and  the  arguments [22m[34mU[0m, [22m[34mU1[0m and [22m[34mU2[0m denote unions of
  residue classes of [22m[34mR[0m with fixed representatives.
  
  Some of the functionality described in this chapter makes only sense if [22m[34mR[0m is
  the  ring  of integers -- in particular this holds for everything concerning
  the invariant delta.
  
  
  [1m[4m[31m4.2 Entering unions of residue classes with fixed representatives[0m
  
  [1m[4m[31m4.2-1 ResidueClassWithFixedRepresentative[0m
  
  [1m[34m> ResidueClassWithFixedRepresentative( [0m[22m[34mR, m, r[0m[1m[34m ) ___________________[0mfunction
  [1m[34m> ResidueClassWithFixedRepresentative( [0m[22m[34mm, r[0m[1m[34m ) ______________________[0mfunction
  [1mReturns:[0m  The   residue   class   [22m[34mr[0m mod [22m[34mm[0m   of   the   ring [22m[34mR[0m,   with  fixed
            representative [22m[34mr[0m.
  
  If the argument [22m[34mR[0m is omitted, it defaults to [22m[32mIntegers[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> cl1 := ResidueClassWithFixedRepresentative(Integers,3,2);[0m
    [22m[35m[2/3][0m
    [22m[35mgap> cl2 := ResidueClassWithFixedRepresentative(Integers,2,1);[0m
    [22m[35m[1/2][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  In  all  names of functions described in this chapter, [22m[32mRepresentative[0m can be
  abbreviated  by  [22m[32mRep[0m.  When  entering  a union of residue classes with fixed
  representative,  for  [22m[36many[0m residue class in the union a representative has to
  be specified:
  
  [1m[4m[31m4.2-2 ResidueClassUnionWithFixedRepresentatives[0m
  
  [1m[34m> ResidueClassUnionWithFixedRepresentatives( [0m[22m[34mR, classes[0m[1m[34m ) __________[0mfunction
  [1m[34m> ResidueClassUnionWithFixedRepresentatives( [0m[22m[34mclasses[0m[1m[34m ) _____________[0mfunction
  [1mReturns:[0m  The  union  of the residue classes [22m[34mclasses[0m[i][2] mod [22m[34mclasses[0m[i][1]
            of the ring [22m[34mR[0m, with fixed representatives [22m[34mclasses[0m[i][2].
  
  The  argument  [22m[34mclasses[0m  must  be  a list of pairs of elements of the ring [22m[34mR[0m,
  those  first elements (the moduli) have to be non-zero. If the argument [22m[34mR[0m is
  omitted, it defaults to [22m[32mIntegers[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedRepresentatives(Integers,[[2,1],[7,4]]);[0m
    [22m[35m[1/2] U [4/7][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  There  is  a  method for the operation [22m[32mModulus[0m, which returns the lcm of the
  moduli  of  the  residue  classes  forming  such  a  union,  and there is an
  operation  [22m[32mClasses[0m  for extracting the list of classes which is passed as an
  argument to [22m[32mResidueClassUnionWithFixedRepresentatives[0m.
  
  [1m[4m[31m4.2-3 AllResidueClassesWithFixedRepresentativesModulo[0m
  
  [1m[34m> AllResidueClassesWithFixedRepresentativesModulo( [0m[22m[34mR, m[0m[1m[34m ) __________[0mfunction
  [1m[34m> AllResidueClassesWithFixedRepresentativesModulo( [0m[22m[34mm[0m[1m[34m ) _____________[0mfunction
  [1mReturns:[0m  A  sorted  list of all residue classes (mod [22m[34mm[0m) of the ring [22m[34mR[0m, with
            fixed representatives.
  
  If the argument [22m[34mR[0m is omitted it defaults to the default ring of [22m[34mm[0m -- cp. the
  documentation   of   [22m[32mDefaultRing[0m   in   the   [1mGAP[0m   reference   manual.  The
  representatives  are the same as those chosen by the operation [22m[32mmod[0m. See also
  [1m[34mAllResidueClassesModulo[0m ([1m3.1-4[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> AllResidueClassesWithFixedRepresentativesModulo(Z_pi(2),4);[0m
    [22m[35m[ [0/4], [1/4], [2/4], [3/4] ][0m
    [22m[35mgap> AllResidueClassesWithFixedRepsModulo(9);[0m
    [22m[35m[ [0/9], [1/9], [2/9], [3/9], [4/9], [5/9], [6/9], [7/9], [8/9] ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m4.3 Methods for unions of residue classes with fixed representatives[0m
  
  There  are  methods  for  [22m[32mPrint[0m,  [22m[32mString[0m and [22m[32mDisplay[0m which are applicable to
  unions  of  residue  classes  with  fixed representatives. Unions of residue
  classes  are  multisets,  thus  elements  can  be  contained  with different
  multiplicities:
  
  [1m[4m[31m4.3-1 Multiplicity[0m
  
  [1m[34m> Multiplicity( [0m[22m[34mx, U[0m[1m[34m ) _______________________________________________[0mmethod
  [1mReturns:[0m  The  multiplicity  of  [22m[34mx[0m  in [22m[34mU[0m  regarded  as  a  multiset  of ring
            elements.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> List([1,2,11],n->Multiplicity(n,U));[0m
    [22m[35m[ 1, 0, 2 ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-2 IsOverlappingFree[0m
  
  [1m[34m> IsOverlappingFree( [0m[22m[34mU[0m[1m[34m ) ___________________________________________[0mproperty
  [1mReturns:[0m  [22m[32mtrue[0m if the residue classes in [22m[34mU[0m are pairwisely disjoint and [22m[32mfalse[0m
            otherwise.
  
  We  call a residue class union [22m[34mU[0m with fixed representatives [22m[36moverlapping free[0m
  if and only if it consists of pairwisely disjoint residue classes.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> IsOverlappingFree(cl1);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsOverlappingFree(U);[0m
    [22m[35mfalse[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-3 AsOrdinaryUnionOfResidueClasses[0m
  
  [1m[34m> AsOrdinaryUnionOfResidueClasses( [0m[22m[34mU[0m[1m[34m ) _______________________________[0mmethod
  [1mReturns:[0m  The set-theoretic union of the residue classes in [22m[34mU[0m.
  
  The  returned  object  is  an  ordinary  residue  class  union without fixed
  representatives  as  described  in Chapter [1m3.[0m which behaves like a subset of
  the underlying ring.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> List([cl1,cl2,U],AsOrdinaryUnionOfResidueClasses);[0m
    [22m[35m[ The residue class 2(3) of Z, The residue class 1(2) of Z, [0m
    [22m[35m  Union of the residue classes 1(2) and 4(14) of Z ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-4 \in[0m
  
  [1m[34m> \in( [0m[22m[34mcl, U[0m[1m[34m ) _______________________________________________________[0mmethod
  [1mReturns:[0m  [22m[32mtrue[0m  if  the  residue  class [22m[34mcl[0m with a fixed representative is an
            element of [22m[34mU[0m and [22m[32mfalse[0m otherwise.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> cl1 in U;[0m
    [22m[35mfalse[0m
    [22m[35mgap> cl2 in U;[0m
    [22m[35mtrue[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-5 AsListOfClasses[0m
  
  [1m[34m> AsListOfClasses( [0m[22m[34mU[0m[1m[34m ) _______________________________________________[0mmethod
  [1mReturns:[0m  The sorted list of the residue classes in [22m[34mU[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> AsListOfClasses(U);[0m
    [22m[35m[ [1/2], [4/7] ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-6 IsSubset[0m
  
  [1m[34m> IsSubset( [0m[22m[34mU1, U2[0m[1m[34m ) _________________________________________________[0mmethod
  [1mReturns:[0m  [22m[32mtrue[0m if [22m[34mU2[0m is a subset of [22m[34mU1[0m and [22m[32mfalse[0m otherwise.
  
  We  say  that  [22m[34mU2[0m  is  a  subset  of  [22m[34mU1[0m  if the multiplicity of any residue
  class [r/m] in [22m[34mU1[0m is greater than or equal to its multiplicity in [22m[34mU2[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> IsSubset(U,cl1);[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsSubset(U,cl2);[0m
    [22m[35mtrue[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-7 Density[0m
  
  [1m[34m> Density( [0m[22m[34mU[0m[1m[34m ) ____________________________________________________[0moperation
  [1mReturns:[0m  The   natural   density   of   [22m[34mU[0m  as  a  multiset  (elements  with
            multiplicity k count k-fold).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Density(U);[0m
    [22m[35m9/14[0m
    [22m[35mgap> 1/2+1/7;[0m
    [22m[35m9/14[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-8 Union[0m
  
  [1m[34m> Union( [0m[22m[34mU1, U2[0m[1m[34m ) ____________________________________________________[0mmethod
  [1mReturns:[0m  The union of [22m[34mU1[0m and [22m[34mU2[0m.
  
  It holds [22m[32mDelta(Union([22m[34mU1[0m,[22m[34mU2[0m)) = Delta([22m[34mU1[0m) + Delta([22m[34mU2[0m)[0m. (-> [1m[34mDelta[0m ([1m4.4-2[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Union(U,cl1);[0m
    [22m[35m[1/2] U [2/3] U [4/7][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-9 Intersection[0m
  
  [1m[34m> Intersection( [0m[22m[34mU1, U2[0m[1m[34m ) _____________________________________________[0mmethod
  [1mReturns:[0m  The intersection of [22m[34mU1[0m and [22m[34mU2[0m.
  
  The  multiplicity of any residue class in the intersection is the minimum of
  its multiplicities in the arguments.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Intersection(cl1,cl2);[0m
    [22m[35mEmpty union of residue classes of Z with fixed representatives[0m
    [22m[35mgap> Intersection(List([cl1,cl2],AsOrdinaryUnionOfResidueClasses));[0m
    [22m[35mThe residue class 5(6) of Z[0m
    [22m[35mgap> Intersection(cl2,U);[0m
    [22m[35m[1/2][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-10 Difference[0m
  
  [1m[34m> Difference( [0m[22m[34mU1, U2[0m[1m[34m ) _______________________________________________[0mmethod
  [1mReturns:[0m  The difference of [22m[34mU1[0m and [22m[34mU2[0m.
  
  It   holds  [22m[32mDelta(Difference([22m[34mU1[0m,[22m[34mU2[0m))  =  Delta([22m[34mU1[0m)  -  Delta([22m[34mU2[0m)[0m.  (-> [1m[34mDelta[0m
  ([1m4.4-2[0m)).  This  is  ensured  by setting the difference of the empty residue
  class union with fixed representatives and some residue class [r/m] equal to
  [(m-r)/m].
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Difference(U,cl1);[0m
    [22m[35m[1/2] U [1/3] U [4/7][0m
    [22m[35mgap> Difference(U,cl2);[0m
    [22m[35m[4/7][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  Throughout  the  rest  of  this section, [22m[34mU[0m is regarded as a multiset of ring
  elements.  For  sake  of simplicity, the term "the multiset of ring elements
  endowed  with  the  structure  of  a  union  of  residue  classes with fixed
  representatives" is abbreviated by "the multiset".
  
  [1m[4m[31m4.3-11 \+[0m
  
  [1m[34m> \+( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1m[34m> \+( [0m[22m[34mx, U[0m[1m[34m ) _________________________________________________________[0mmethod
  [1mReturns:[0m  The multiset of sums u + x, u in U.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> cl1 + 1;[0m
    [22m[35m[3/3][0m
    [22m[35mgap> U+23;[0m
    [22m[35m[24/2] U [27/7][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-12 \-[0m
  
  [1m[34m> \-( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1m[34m> \-( [0m[22m[34mx, U[0m[1m[34m ) _________________________________________________________[0mmethod
  [1m[34m> \-( [0m[22m[34mU[0m[1m[34m ) ____________________________________________________________[0mmethod
  [1mReturns:[0m  The  multiset  of  differences  u  -  x,  u  in U resp. the set of
            differences  x  - u, u in U resp. the set of the additive inverses
            of the elements of U.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> cl2 - 1;[0m
    [22m[35m[0/2][0m
    [22m[35mgap> U - 17;[0m
    [22m[35m[-16/2] U [-13/7][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-13 \*[0m
  
  [1m[34m> \*( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1m[34m> \*( [0m[22m[34mx, U[0m[1m[34m ) _________________________________________________________[0mmethod
  [1mReturns:[0m  The multiset of products x * u, u in U.
  
  Scalar multiplication leaves delta invariant (-> [1m[34mDelta[0m ([1m4.4-2[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> 3*cl1;[0m
    [22m[35m[6/9][0m
    [22m[35mgap> 7*U;[0m
    [22m[35m[7/14] U [28/49][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.3-14 \/[0m
  
  [1m[34m> \/( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1mReturns:[0m  The multiset of quotients u/x, u in U.
  
  Scalar  division  leaves  delta  invariant  (-> [1m[34mDelta[0m  ([1m4.4-2[0m)).  If not all
  elements  of  all  residue classes in [22m[34mU[0m are divisible by [22m[34mx[0m, the method gives
  up.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> (2*cl1+2)/3;[0m
    [22m[35m[2/2][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m4.4 The invariant Delta[0m
  
  [1m[4m[31m4.4-1 RepresentativeStabilizingRefinement[0m
  
  [1m[34m> RepresentativeStabilizingRefinement( [0m[22m[34mU, k[0m[1m[34m ) ________________________[0mmethod
  [1mReturns:[0m  The representative stabilizing refinement of [22m[34mU[0m into k parts.
  
  The [22m[36mrepresentative stabilizing refinement[0m of a residue class [r/m] of Z into
  k  parts  is  defined by [r/km] cup [(r+m)/km] cup dots cup [(r+(k-1)m)/km].
  This definition is extended in a natural way to unions of residue classes.
  
  The  method  tries  to  perform a simplification of [22m[34mU[0m by joining appropriate
  residue classes if the argument [22m[34mk[0m is zero.
  
  In  any  case  the  value  of  [22m[32mDelta([22m[34mU[0m)[0m  is  invariant  under this operation
  (-> [1m[34mDelta[0m ([1m4.4-2[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> cl := ResidueClassUnionWithFixedReps(Integers,[[2,1]]);[0m
    [22m[35m[1/2][0m
    [22m[35mgap> S := RepresentativeStabilizingRefinement(cl,3);[0m
    [22m[35m[1/6] U [3/6] U [5/6][0m
    [22m[35mgap> cls := AsListOfClasses(S);[0m
    [22m[35m[ [1/6], [3/6], [5/6] ][0m
    [22m[35mgap> cls := List([1..3],i->RepresentativeStabilizingRefinement(cls[i],i+1));[0m
    [22m[35m[ [1/12] U [7/12], [3/18] U [9/18] U [15/18], [0m
    [22m[35m  [5/24] U [11/24] U [17/24] U [23/24] ][0m
    [22m[35mgap> S := Union(cls);[0m
    [22m[35m<union of 9 residue classes of Z with fixed representatives>[0m
    [22m[35mgap> RepresentativeStabilizingRefinement(S,0);[0m
    [22m[35m[1/2][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.4-2 Delta[0m
  
  [1m[34m> Delta( [0m[22m[34mU[0m[1m[34m ) ______________________________________________________[0mattribute
  [1mReturns:[0m  The value of the invariant delta of the residue class union [22m[34mU[0m.
  
  For  a  residue class [r/m] with fixed representative we set delta([r/m]) :=
  r/m  -  1/2 and extend this additively to unions of such residue classes. If
  no representatives are fixed, this definition is still unique (mod 1).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> [ Delta(U), (1/2-1/2)+(4/7-1/2) ];[0m
    [22m[35m[ 1/14, 1/14 ][0m
    [22m[35mgap> V := RepresentativeStabilizingRefinement(U,3);[0m
    [22m[35m[1/6] U [3/6] U [5/6] U [4/21] U [11/21] U [18/21][0m
    [22m[35mgap> Delta(V) = (1/6-1/2)+(3/6-1/2)+(5/6-1/2)+(4/21-1/2)+(11/21-1/2)+(18/21-1/2);[0m
    [22m[35mtrue[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.4-3 Rho[0m
  
  [1m[34m> Rho( [0m[22m[34mU[0m[1m[34m ) ________________________________________________________[0mattribute
  [1mReturns:[0m  The value of the invariant rho of the residue class union [22m[34mU[0m.
  
  For  a union U subseteq Z of finitely many residue classes, we set rho(U) :=
  e^pi i delta(U).
  
  
  [1m[4m[31m4.5 The categories of unions of residue classes with fixed rep's[0m
  
  The  names  of  the  categories  of  unions  of  residue  classes with fixed
  representatives  can  be  derived  from the names of those of the "ordinary"
  unions    of   residue   classes   given   in   Section [1m3.3[0m   by   appending
  [22m[32mWithFixedRepresentatives[0m.
  
