  
  [1m[4m[31m3. Unions of Residue Classes[0m
  
  
  [1m[4m[31m3.1 Defining unions of residue classes[0m
  
  [1m[4m[31m3.1-1 ResidueClass[0m
  
  [1m[34m> ResidueClass( [0m[22m[34mR, m, r[0m[1m[34m ) __________________________________________[0mfunction
  
  The residue class [22m[34mr[0m mod [22m[34mm[0m of the ring [22m[34mR[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> A := ResidueClass(Integers,3,2);[0m
    [22m[35mThe residue class 2(3) of Z[0m
    [22m[35mgap> B := ResidueClass(Z_pi([2,5]),2,1);[0m
    [22m[35mThe residue class 1(2) of Z_( 2, 5 )[0m
    [22m[35mgap> B = ResidueClass(Integers,2,1);[0m
    [22m[35mfalse[0m
    [22m[35mgap> R := PolynomialRing(GF(7),1);;[0m
    [22m[35mgap> x := Indeterminate(GF(7),1);; SetName(x,"x");[0m
    [22m[35mgap> C := ResidueClass(R,x+One(R),3*One(R));[0m
    [22m[35mThe residue class Z(7) ( mod x+Z(7)^0 ) of GF(7)[x][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.1-2 ResidueClassUnion[0m
  
  [1m[34m> ResidueClassUnion( [0m[22m[34mR, m, r[0m[1m[34m ) _____________________________________[0mfunction
  [1m[34m> ResidueClassUnion( [0m[22m[34mR, m, r, included, excluded[0m[1m[34m ) _________________[0mfunction
  
  The  union  of  the  residue  classes  [22m[34mr[0m[  i  ]  mod [22m[34mm[0m of the ring [22m[34mR[0m. If the
  arguments  [22m[34mincluded[0m and [22m[34mexcluded[0m are given, they denote lists of elements to
  be added to resp. to be taken away from the union.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> D := ResidueClassUnion(Integers,6,[2,4]);[0m
    [22m[35mUnion of the residue classes 2(6) and 4(6) of Z[0m
    [22m[35mgap> F := ResidueClassUnion(Integers,5,[1,2],[3,8],[-4,1]);[0m
    [22m[35m(Union of the residue classes 1(5) and 2(5) of Z) U [ 3, 8 ] \ [ -4, 1 ][0m
    [22m[35mgap> G := ResidueClassUnion(R,x,[One(R),5*One(R),6*One(R)],[Zero(R)],[One(R)]);[0m
    [22m[35m<union of 3 residue classes (mod x) of GF(7)[x]> U [ 0*Z(7) ] \ [ Z(7)^0 ][0m
    [22m[35mgap> H := ResidueClassUnion(Z_pi([2,3]),8,[3,5]);[0m
    [22m[35m<union of 2 residue classes (mod 8) of Z_( 2, 3 )>[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  The   components  of  a  residue  class  union  as  given  as  arguments  in
  [1m[34mResidueClassUnion[0m can be extracted as follows.
  
  [1m[4m[31m3.1-3 Modulus[0m
  
  [1m[34m> Modulus( [0m[22m[34mU[0m[1m[34m ) _______________________________________________________[0mmethod
  [1mReturns:[0m  the modulus [22m[34mm[0m of [22m[34mU[0m.
  
  [1m[4m[31m3.1-4 Residues[0m
  
  [1m[34m> Residues( [0m[22m[34mU[0m[1m[34m ) ___________________________________________________[0moperation
  [1mReturns:[0m  the set of residues [22m[34mr[0m of [22m[34mU[0m.
  
  If  an  element  [22m[34mel[0m  of  the underlying ring of [22m[34mU[0m is congruent to one of the
  residues  of  [22m[34mU[0m modulo the modulus of [22m[34mU[0m, it is contained in [22m[34mU[0m, provided that
  it is not excluded explicitly ( see [1m[34mExcludedElements[0m ([1m3.1-6[0m) ).
  
  [1m[4m[31m3.1-5 IncludedElements[0m
  
  [1m[34m> IncludedElements( [0m[22m[34mU[0m[1m[34m ) ___________________________________________[0moperation
  [1mReturns:[0m  the set [22m[34mincluded[0m of single elements of [22m[34mU[0m.
  
  [1m[4m[31m3.1-6 ExcludedElements[0m
  
  [1m[34m> ExcludedElements( [0m[22m[34mU[0m[1m[34m ) ___________________________________________[0moperation
  [1mReturns:[0m  the set [22m[34mexcluded[0m of single elements explicitly not contained in [22m[34mU[0m.
  
  
  [1m[4m[31m3.2 Methods for unions of residue classes[0m
  
  [1m[4m[31m3.2-1 String[0m
  
  [1m[34m> String( [0m[22m[34mU[0m[1m[34m ) ________________________________________________________[0mmethod
  [1m[34m> String( [0m[22m[34mU, lng[0m[1m[34m ) ___________________________________________________[0mmethod
  [1mReturns:[0m  a string representation of the residue class union [22m[34mU[0m.
  
  If  the  argument  [22m[34mlng[0m is given its absolute value denotes the length of the
  returned  string;  if [22m[34mlng[0m is negative, the result is flushed left, otherwise
  it is flushed right.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> String(C);[0m
    [22m[35m"ResidueClassUnion( GF(7)[x], x+Z(7)^0, [ Z(7) ] )"[0m
    [22m[35mgap> String(F);[0m
    [22m[35m"ResidueClassUnion( Integers, 5, [ 1, 2 ], [ 3, 8 ], [ -4, 1 ] )"[0m
    [22m[35mgap> String(H);[0m
    [22m[35m"ResidueClassUnion( Z_( 2, 3 ), 8, [ 3, 5 ] )"[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-2 Print[0m
  
  [1m[34m> Print( [0m[22m[34mU[0m[1m[34m ) _________________________________________________________[0mmethod
  
  Prints  the  residue  class  union  [22m[34mU[0m in a way similar to what a user has to
  write in order to create this object.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Print(C,"\n");[0m
    [22m[35mResidueClassUnion( GF(7)[x], x+Z(7)^0, [ Z(7) ] )[0m
    [22m[35mgap> Print(F,"\n");[0m
    [22m[35mResidueClassUnion( Integers, 5, [ 1, 2 ], [ 3, 8 ], [ -4, 1 ] )[0m
    [22m[35mgap> Print(H,"\n");[0m
    [22m[35mResidueClassUnion( Z_( 2, 3 ), 8, [ 3, 5 ] )[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-3 Display[0m
  
  [1m[34m> Display( [0m[22m[34mU[0m[1m[34m ) _______________________________________________________[0mmethod
  
  Displays the residue class union [22m[34mU[0m in a nice, human-readable form.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Display(F);[0m
    [22m[35m[0m
    [22m[35mThe union of the residue classes r ( mod 5 ) of Z for r =[0m
    [22m[35m[0m
    [22m[35m 1 2[0m
    [22m[35m[0m
    [22m[35mand the elements[0m
    [22m[35m[0m
    [22m[35m 3 8[0m
    [22m[35m[0m
    [22m[35mwithout the elements[0m
    [22m[35m[0m
    [22m[35m -4  1[0m
    [22m[35m[0m
    [22m[35mgap> Display(G);[0m
    [22m[35m[0m
    [22m[35mThe union of the residue classes r ( mod x ) of GF(7)[x] for r =[0m
    [22m[35m[0m
    [22m[35mZ(7)^0  -Z(7)^0 Z(7)^5  [0m
    [22m[35m[0m
    [22m[35mand the element[0m
    [22m[35m[0m
    [22m[35m0*Z(7) [0m
    [22m[35m[0m
    [22m[35mwithout the element[0m
    [22m[35m[0m
    [22m[35mZ(7)^0 [0m
    [22m[35m[0m
    [22m[35mgap> Display(H);[0m
    [22m[35m[0m
    [22m[35mThe union of the residue classes r ( mod 8 ) of Z_( 2, 3 ) for r =[0m
    [22m[35m[0m
    [22m[35m 3 5[0m
    [22m[35m[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-4 \in[0m
  
  [1m[34m> \in( [0m[22m[34mel, U[0m[1m[34m ) _______________________________________________________[0mmethod
  
  Tests whether [22m[34mel[0m is an element of the residue class union [22m[34mU[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> 20 in A;[0m
    [22m[35mtrue[0m
    [22m[35mgap> -20 in A;[0m
    [22m[35mfalse[0m
    [22m[35mgap> 1/3 in B;[0m
    [22m[35mtrue[0m
    [22m[35mgap> 1/5 in B;[0m
    [22m[35mfalse[0m
    [22m[35mgap> x in G;[0m
    [22m[35mfalse[0m
    [22m[35mgap> Zero(R) in G;[0m
    [22m[35mtrue[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-5 IsSubset[0m
  
  [1m[34m> IsSubset( [0m[22m[34mU1, U2[0m[1m[34m ) _________________________________________________[0mmethod
  
  Checks  whether  the residue class union [22m[34mU2[0m is a subset of the residue class
  union [22m[34mU1[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> IsSubset(A,D);[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsSubset(H,ResidueClass(Z_pi([2,3]),16,11));[0m
    [22m[35mtrue[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-6 Density[0m
  
  [1m[34m> Density( [0m[22m[34mU[0m[1m[34m ) ____________________________________________________[0moperation
  [1mReturns:[0m  the natural density of [22m[34mU[0m as a subset of the underlying ring.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> G;[0m
    [22m[35m<union of 3 residue classes (mod x) of GF(7)[x]> U [ 0*Z(7) ] \ [ Z(7)^0 ][0m
    [22m[35mgap> Density(G);[0m
    [22m[35m3/7[0m
    [22m[35mgap> ResidueClassUnion(Integers,12,[3,5,9]);[0m
    [22m[35mUnion of the residue classes 3(6) and 5(12) of Z[0m
    [22m[35mgap> Density(last);[0m
    [22m[35m1/4[0m
    [22m[35mgap> 2*last2;[0m
    [22m[35mUnion of the residue classes 6(12) and 10(24) of Z[0m
    [22m[35mgap> Density(last);[0m
    [22m[35m1/8[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-7 Union[0m
  
  [1m[34m> Union( [0m[22m[34mU1, U2[0m[1m[34m ) ____________________________________________________[0mmethod
  [1m[34m> Union( [0m[22m[34mU, S[0m[1m[34m ) ______________________________________________________[0mmethod
  [1mReturns:[0m  the  union  of  two  residue  class  unions [22m[34mU1[0m and [22m[34mU2[0m resp. of the
            residue class union [22m[34mU[0m and the finite set [22m[34mS[0m of elements of the ring
            [22m[34mU[0m is defined over.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> I := ResidueClassUnion(Integers,6,[1,5]);[0m
    [22m[35mUnion of the residue classes 1(6) and 5(6) of Z[0m
    [22m[35mgap> J := ResidueClassUnion(Integers,5,[1,2,3,4]);[0m
    [22m[35mUnion of the residue classes 1(5), 2(5), 3(5) and 4(5) of Z[0m
    [22m[35mgap> K := Union(I,J);[0m
    [22m[35m<union of 26 residue classes (mod 30) of Z>[0m
    [22m[35mgap> Residues(K);[0m
    [22m[35m[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, [0m
    [22m[35m  25, 26, 27, 28, 29 ][0m
    [22m[35mgap> Union(K,[0]);[0m
    [22m[35m<union of 26 residue classes (mod 30) of Z> U [ 0 ][0m
    [22m[35mgap> Union(D,I);[0m
    [22m[35mUnion of the residue classes 1(3) and 2(3) of Z[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-8 Intersection[0m
  
  [1m[34m> Intersection( [0m[22m[34mU1, U2[0m[1m[34m ) _____________________________________________[0mmethod
  [1m[34m> Intersection( [0m[22m[34mU, S[0m[1m[34m ) _______________________________________________[0mmethod
  [1mReturns:[0m  the  intersection  of  two residue class unions [22m[34mU1[0m and [22m[34mU2[0m resp. of
            the  residue class union [22m[34mU[0m and the finite set [22m[34mS[0m of elements of the
            ring [22m[34mU[0m is defined over.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> L := Intersection(I,J);[0m
    [22m[35m<union of 8 residue classes (mod 30) of Z>[0m
    [22m[35mgap> Display(L);[0m
    [22m[35m[0m
    [22m[35mThe union of the residue classes r ( mod 30 ) of Z for r =[0m
    [22m[35m[0m
    [22m[35m  1  7 11 13 17 19 23 29[0m
    [22m[35m[0m
    [22m[35mgap> cl := List([1..25],i->ResidueClass(Integers,Primes[i],i));;[0m
    [22m[35mgap> cl_int := Intersection(cl);[0m
    [22m[35mThe residue class 941584379775558526136539054851975983([0m
    [22m[35m2305567963945518424753102147331756070) of Z[0m
    [22m[35mgap> List(Primes{[1..25]},p->Representative(cl_int) mod p);[0m
    [22m[35m[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, [0m
    [22m[35m  22, 23, 24, 25 ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-9 Difference[0m
  
  [1m[34m> Difference( [0m[22m[34mU1, U2[0m[1m[34m ) _______________________________________________[0mmethod
  [1m[34m> Difference( [0m[22m[34mU, S[0m[1m[34m ) _________________________________________________[0mmethod
  [1mReturns:[0m  the  difference of two residue class unions [22m[34mU1[0m and [22m[34mU2[0m resp. of the
            residue class union [22m[34mU[0m and the finite set [22m[34mS[0m of elements of the ring
            [22m[34mU[0m is defined over.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> M := Difference(I,J);[0m
    [22m[35mUnion of the residue classes 5(30) and 25(30) of Z[0m
    [22m[35mgap> N := Difference(J,I);[0m
    [22m[35m<union of 16 residue classes (mod 30) of Z>[0m
    [22m[35mgap> Display(N);[0m
    [22m[35m[0m
    [22m[35mThe union of the residue classes r ( mod 30 ) of Z for r =[0m
    [22m[35m[0m
    [22m[35m  2  3  4  6  8  9 12 14 16 18 21 22 24 26 27 28[0m
    [22m[35m[0m
    [22m[35mgap> Difference(Integers,[1,2,3]);[0m
    [22m[35mZ \ [ 1, 2, 3 ][0m
    [22m[35mgap> Difference(Z_pi([2,3,7]),[1/5,1/55]);[0m
    [22m[35mZ_( 2, 3, 7 ) \ [ 1/55, 1/5 ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-10 Iterator[0m
  
  [1m[34m> Iterator( [0m[22m[34mU[0m[1m[34m ) ______________________________________________________[0mmethod
  [1mReturns:[0m  an iterator of the residue class union [22m[34mU[0m.
  
  Currently,  iterators  are  only implemented for residue class unions of the
  integers.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> it := Iterator(F);[0m
    [22m[35m<iterator of a residue class union of Z>[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-11 NextIterator[0m
  
  [1m[34m> NextIterator( [0m[22m[34miter[0m[1m[34m ) _______________________________________________[0mmethod
  [1mReturns:[0m  the  next  element  delivered by the iterator [22m[34miter[0m of some residue
            class union.
  
  Currently,  iterators  are  only implemented for residue class unions of the
  integers.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> l := List([1..16],i->NextIterator(it));[0m
    [22m[35m[ 3, 8, 2, -3, 6, -9, 7, -8, 11, -14, 12, -13, 16, -19, 17, -18 ][0m
    [22m[35mgap> Difference(l,Intersection(F,[-20..20]));[0m
    [22m[35m[  ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-12 \+[0m
  
  [1m[34m> \+( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1m[34m> \+( [0m[22m[34mx, U[0m[1m[34m ) _________________________________________________________[0mmethod
  [1mReturns:[0m  the set of sums u + x, u in U.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> Display(L+1);[0m
    [22m[35m[0m
    [22m[35mThe union of the residue classes r ( mod 30 ) of Z for r =[0m
    [22m[35m[0m
    [22m[35m  0  2  8 12 14 18 20 24[0m
    [22m[35m[0m
    [22m[35mgap> L+30 = L;[0m
    [22m[35mtrue[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-13 \-[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  set 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> F-7;[0m
    [22m[35m(Union of the residue classes 0(5) and 4(5) of Z) U [ -4, 1 ] \ [ -11, -6 ][0m
    [22m[35mgap> -L = L;[0m
    [22m[35mtrue[0m
    [22m[35mgap> -C;[0m
    [22m[35mThe residue class Z(7)^4 ( mod x+Z(7)^0 ) of GF(7)[x][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-14 \*[0m
  
  [1m[34m> \*( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1m[34m> \*( [0m[22m[34mx, U[0m[1m[34m ) _________________________________________________________[0mmethod
  [1mReturns:[0m  the set of products x * u, u in U.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> 2*A;[0m
    [22m[35mThe residue class 4(6) of Z[0m
    [22m[35mgap> D*17;[0m
    [22m[35mUnion of the residue classes 34(102) and 68(102) of Z[0m
    [22m[35mgap> x^3*C;[0m
    [22m[35mThe residue class Z(7)*x^3 ( mod x^4+x^3 ) of GF(7)[x][0m
    [22m[35mgap> 2*Difference(Integers,[1,2,3]);[0m
    [22m[35m(The residue class 0(2) of Z) \ [ 2, 4, 6 ][0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.2-15 \/[0m
  
  [1m[34m> \/( [0m[22m[34mU, x[0m[1m[34m ) _________________________________________________________[0mmethod
  [1mReturns:[0m  the set of quotients u/x, u in U.
  
  If the result is not a subset of the underlying ring, the method gives up.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m[0m
    [22m[35mgap> D/2;[0m
    [22m[35mUnion of the residue classes 1(3) and 2(3) of Z[0m
    [22m[35mgap> M/5;[0m
    [22m[35mUnion of the residue classes 1(6) and 5(6) of Z[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m3.3 The categories and families of unions of residue classes[0m
  
  [1m[4m[31m3.3-1 IsUnionOfResidueClasses[0m
  
  [1m[34m> IsUnionOfResidueClasses( [0m[22m[34mU[0m[1m[34m ) _______________________________________[0mfilter
  
  The category of all unions of residue classes.
  
  [1m[4m[31m3.3-2 IsUnionOfResidueClassesOfZ[0m
  
  [1m[34m> IsUnionOfResidueClassesOfZ( [0m[22m[34mU[0m[1m[34m ) ____________________________________[0mfilter
  
  The category of all unions of residue classes of Z.
  
  [1m[4m[31m3.3-3 IsUnionOfResidueClassesOfZ_pi[0m
  
  [1m[34m> IsUnionOfResidueClassesOfZ_pi( [0m[22m[34mU[0m[1m[34m ) _________________________________[0mfilter
  
  The  category  of  all  unions  of  residue classes of some semilocalization
  Z_(pi) of the integers.
  
  [1m[4m[31m3.3-4 IsUnionOfResidueClassesOfZorZ_pi[0m
  
  [1m[34m> IsUnionOfResidueClassesOfZorZ_pi( [0m[22m[34mU[0m[1m[34m ) ______________________________[0mfilter
  
  The category of all unions of residue classes of Z or Z_(pi).
  
  [1m[4m[31m3.3-5 IsUnionOfResidueClassesOfGFqx[0m
  
  [1m[34m> IsUnionOfResidueClassesOfGFqx( [0m[22m[34mU[0m[1m[34m ) _________________________________[0mfilter
  
  The  category of all unions of residue classes of some polynomial ring GF( q
  )[ x ].
  
  [1m[4m[31m3.3-6 ResidueClassUnionsFamily[0m
  
  [1m[34m> ResidueClassUnionsFamily( [0m[22m[34mR[0m[1m[34m ) ____________________________________[0mfunction
  
  The family of unions of residue classes of the ring [22m[34mR[0m.
  
  The  ring [22m[34mR[0m can be accessed as [22m[32mUnderlyingRing( ResidueClassUnionsFamily( [22m[34mR[0m )
  )[0m.
  
