  
  [1m[4m[31m2. Unions of Residue Classes with Fixed Representatives[0m
  
  [1mResClasses[0m  supports  computations  with unions of residue classes which are
  endowed  with  distinguished  ("fixed")  representatives.  These  unions  of
  residue  classes  can  be  viewed as multisets of ring elements. The residue
  classes  forming  such  a  union  do  not  need  to be disjoint or even only
  distinct.
  
  
  [1m[4m[31m2.1 Entering unions of residue classes with fixed representatives[0m
  
  [1m[4m[31m2.1-1 ResidueClassWithFixedRep[0m
  
  [1m[34m> ResidueClassWithFixedRep( [0m[22m[34mR, m, r[0m[1m[34m ) ______________________________[0mfunction
  [1m[34m> ResidueClassWithFixedRep( [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  the  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> ResidueClassWithFixedRep(Integers,2,1);[0m
    [22m[35m[1/2][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.1-2 ResidueClassUnionWithFixedReps[0m
  
  [1m[34m> ResidueClassUnionWithFixedReps( [0m[22m[34mR, classes[0m[1m[34m ) _____________________[0mfunction
  [1m[34m> ResidueClassUnionWithFixedReps( [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.
  Their  first  entries -- the moduli -- must be nonzero. If the argument [22m[34mR[0m is
  omitted, it defaults to [22m[32mIntegers[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> ResidueClassUnionWithFixedReps(Integers,[[2,4],[3,9]]);[0m
    [22m[35m[4/2] U [9/3][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. Further there is an
  operation  [22m[32mClasses[0m  for retrieving the list of classes which has been passed
  as    an   argument   to   [22m[32mResidueClassUnionWithFixedReps[0m.   The   operation
  [22m[32mAsListOfClasses[0m does the same except that the returned list contains residue
  classes  instead  of  pairs  [22m[32m[[22m[34mmodulus[0m,[22m[34mresidue[0m][0m. There are methods for [22m[32mPrint[0m,
  [22m[32mString[0m  and  [22m[32mDisplay[0m  available  for  unions  of  residue classes with fixed
  representatives.
  
  [1m[4m[31m2.1-3 AllResidueClassesWithFixedRepsModulo[0m
  
  [1m[34m> AllResidueClassesWithFixedRepsModulo( [0m[22m[34mR, m[0m[1m[34m ) _____________________[0mfunction
  [1m[34m> AllResidueClassesWithFixedRepsModulo( [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 ([1m1.1-3[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> AllResidueClassesWithFixedRepsModulo(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[31m2.2 Methods for unions of residue classes with fixed representatives[0m
  
  Throughout this chapter, the argument [22m[34mR[0m denotes the underlying ring, 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.
  
  Unions of residue classes with fixed representatives are multisets. Elements
  and residue classes can be contained with multiplicities:
  
  [1m[4m[31m2.2-1 Multiplicity[0m
  
  [1m[34m> Multiplicity( [0m[22m[34mx, U[0m[1m[34m ) _______________________________________________[0mmethod
  [1m[34m> Multiplicity( [0m[22m[34mcl, U[0m[1m[34m ) ______________________________________________[0mmethod
  [1mReturns:[0m  The  multiplicity  of  [22m[34mx[0m  in [22m[34mU[0m  regarded  as  a  multiset  of ring
            elements,  resp.  the  multiplicity  of  the residue class [22m[34mcl[0m in [22m[34mU[0m
            regarded as a multiset of residue classes.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> List([0..23],n->Multiplicity(n,U));[0m
    [22m[35m[ 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0 ][0m
    [22m[35mgap> Multiplicity(ResidueClassWithFixedRep(2,0),U);[0m
    [22m[35m1[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  Let [22m[32mU[0m be a union of residue classes with fixed representatives. The multiset
  [22m[32mU[0m  can  have  an  attribute  [22m[32mDensity[0m  which denotes its [22m[36mnatural density[0m as a
  multiset, i.e. elements with multiplicity k count k-fold. The multiset [22m[32mU[0m has
  the  property  [22m[32mIsOverlappingFree[0m if it consists of pairwise disjoint residue
  classes.  The  set-theoretic  union  of the residue classes forming [22m[32mU[0m can be
  determined  by  the  operation  [22m[32mAsOrdinaryUnionOfResidueClasses[0m.  The object
  returned by this operation is an "ordinary" residue class union as described
  in Chapter [1m1.[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> Density(U);[0m
    [22m[35m5/6[0m
    [22m[35mgap> IsOverlappingFree(U);[0m
    [22m[35mfalse[0m
    [22m[35mgap> AsOrdinaryUnionOfResidueClasses(U);[0m
    [22m[35mZ \ Union of the residue classes 1(6) and 5(6) of Z[0m
    [22m[35mgap> Density(last);[0m
    [22m[35m2/3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  In  the sequel we abbreviate the term "the multiset of ring elements endowed
  with the structure of a union of residue classes with fixed representatives"
  by "the multiset".
  
  There are methods for [22m[32m+[0m and [22m[32m-[0m available for computing the multiset of sums u
  +  x,  u in U, the multiset of differences u - x resp. x - u, u in U and the
  multiset  of  the  additive inverses of the elements of U. Further there are
  methods  for [22m[32m*[0m and [22m[32m/[0m available for computing the multiset of products x * u,
  u  in  U  and  the  multiset  of  quotients u/x, u in U. The division method
  requires  all  elements of [22m[32mU[0m to be divisible by x. If the underlying ring is
  the  ring  of  integers,  scalar  multiplication  and  division  leave delta
  invariant (-> [1m[34mDelta[0m ([1m2.3-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> U + 7;[0m
    [22m[35m[7/2] U [7/3][0m
    [22m[35mgap> U - 7; 7 - U; -U;[0m
    [22m[35m[-7/2] U [-7/3][0m
    [22m[35m[7/-3] U [7/-2][0m
    [22m[35m[0/-3] U [0/-2][0m
    [22m[35mgap> V := 2 * U;[0m
    [22m[35m[0/4] U [0/6][0m
    [22m[35mgap> V/2;[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-2 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.
  
  The multiplicity of any ring element resp. residue class in the union is the
  sum  of  its multiplicities in the arguments. It holds [22m[32mDelta(Union([22m[34mU1[0m,[22m[34mU2[0m)) =
  Delta([22m[34mU1[0m) + Delta([22m[34mU2[0m)[0m. (-> [1m[34mDelta[0m ([1m2.3-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> Union(U,U);                                      [0m
    [22m[35m[0/2] U [0/2] U [0/3] U [0/3][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-3 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> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> Intersection(U,ResidueClassWithFixedRep(2,0));[0m
    [22m[35m[0/2][0m
    [22m[35mgap> Intersection(U,ResidueClassWithFixedRep(6,0));[0m
    [22m[35mEmpty union of residue classes of Z with fixed representatives[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-4 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.
  
  The  multiplicity of any residue class in the difference is its multiplicity
  in [22m[34mU1[0m  minus  its  multiplicity  in [22m[34mU2[0m,  if  this  value is nonnegative. The
  difference  of  the empty residue class union with fixed representatives and
  some   residue   class   [r/m]   is   set   equal  to  [(m-r)/m].  It  holds
  [22m[32mDelta(Difference([22m[34mU1[0m,[22m[34mU2[0m)) = Delta([22m[34mU1[0m) - Delta([22m[34mU2[0m)[0m. (-> [1m[34mDelta[0m ([1m2.3-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> V := ResidueClassUnionWithFixedReps(Integers,[[3,0],[5,2]]);[0m
    [22m[35m[0/3] U [2/5][0m
    [22m[35mgap> Difference(U,V);[0m
    [22m[35m[0/2] U [3/5][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m2.3 The invariant Delta[0m
  
  [1m[4m[31m2.3-1 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 definition additively to unions of such residue
  classes.  If  no  representatives are fixed, this definition is still unique
  (mod 1).  There  is  a  related  invariant rho  which  is  defined by e^pi i
  delta(U). The corresponding attribute is called [22m[32mRho[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,3],[3,4]]);[0m
    [22m[35m[3/2] U [4/3][0m
    [22m[35mgap> Delta(U) = (3/2-1/2) + (4/3-1/2);[0m
    [22m[35mtrue[0m
    [22m[35mgap> V := RepresentativeStabilizingRefinement(U,3);[0m
    [22m[35m[3/6] U [5/6] U [7/6] U [4/9] U [7/9] U [10/9][0m
    [22m[35mgap> Delta(V) = Delta(U);[0m
    [22m[35mtrue[0m
    [22m[35mgap> Rho(V);[0m
    [22m[35mE(12)^11[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.3-2 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 the obvious way to unions of residue classes.
  
  If  the  argument  [22m[34mk[0m  is  zero, the method performs a simplification of [22m[34mU[0m by
  joining appropriate residue classes, if this is possible.
  
  In  any  case  the  value  of  [22m[32mDelta([22m[34mU[0m)[0m  is  invariant  under this operation
  (-> [1m[34mDelta[0m ([1m2.3-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> U := ResidueClassUnionWithFixedReps(Integers,[[2,0],[3,0]]);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35mgap> RepresentativeStabilizingRefinement(U,4);   [0m
    [22m[35m[0/8] U [2/8] U [4/8] U [6/8] U [0/12] U [3/12] U [6/12] U [9/12][0m
    [22m[35mgap> RepresentativeStabilizingRefinement(last,0);[0m
    [22m[35m[0/2] U [0/3][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m2.4 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 are derived from the names of those of the "ordinary" unions
  of     residue     classes     given    in    Section [1m1.3[0m    by    appending
  [22m[32mWithFixedRepresentatives[0m.
  
