% generated by GAPDoc2LaTeX from XML source (Frank Luebeck)
\documentclass[a4paper,11pt]{report}
\usepackage{a4wide}
\sloppy
\pagestyle{myheadings}
\usepackage{amssymb}
\usepackage[latin1]{inputenc}
\usepackage{makeidx}
\makeindex
\usepackage{color}
\definecolor{DarkOlive}{rgb}{0.1047,0.2412,0.0064}
\definecolor{FireBrick}{rgb}{0.5812,0.0074,0.0083}
\definecolor{RoyalBlue}{rgb}{0.0236,0.0894,0.6179}
\definecolor{RoyalGreen}{rgb}{0.0236,0.6179,0.0894}
\definecolor{RoyalRed}{rgb}{0.6179,0.0236,0.0894}
\definecolor{LightBlue}{rgb}{0.8544,0.9511,1.0000}
\definecolor{Black}{rgb}{0.0,0.0,0.0}
\definecolor{FuncColor}{rgb}{1.0,0.0,0.0}
%% strange name because of pdflatex bug:
\definecolor{Chapter }{rgb}{0.0,0.0,1.0}

\usepackage{fancyvrb}

\usepackage{pslatex}

\usepackage[pdftex=true,
        a4paper=true,bookmarks=false,pdftitle={Written with GAPDoc},
        pdfcreator={LaTeX with hyperref package / GAPDoc},
        colorlinks=true,backref=page,breaklinks=true,linkcolor=RoyalBlue,
        citecolor=RoyalGreen,filecolor=RoyalRed,
        urlcolor=RoyalRed,pagecolor=RoyalBlue]{hyperref}

% write page numbers to a .pnr log file for online help
\newwrite\pagenrlog
\immediate\openout\pagenrlog =\jobname.pnr
\immediate\write\pagenrlog{PAGENRS := [}
\newcommand{\logpage}[1]{\protect\write\pagenrlog{#1, \thepage,}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\F}{\mathbb{F}}

\newcommand{\GAP}{\textsf{GAP}}

\begin{document}

\logpage{[ 0, 0, 0 ]}
\begin{titlepage}
\begin{center}{\Huge \textbf{\textsf{ResClasses}\mbox{}}}\\[1cm]
\hypersetup{pdftitle=\textsf{ResClasses}}
\markright{\scriptsize \mbox{}\hfill \textsf{ResClasses} \hfill\mbox{}}
{\Large \textbf{ Set-Theoretic Computations with Residue Classes \mbox{}}}\\[1cm]
{ Version 2.5.1 \mbox{}}\\[1cm]
{June 1, 2007\mbox{}}\\[1cm]
\mbox{}\\[2cm]
{\large \textbf{ Stefan Kohl    \mbox{}}}\\
\hypersetup{pdfauthor= Stefan Kohl    }
\end{center}\vfill

\mbox{}\\
{\mbox{}\\
\small \noindent \textbf{ Stefan Kohl    } --- Email: \href{mailto://kohl@mathematik.uni-stuttgart.de} {\texttt{kohl@mathematik.uni-stuttgart.de}}\\
 --- Homepage: \href{http://www.cip.mathematik.uni-stuttgart.de/~kohlsn} {\texttt{http://www.cip.mathematik.uni-stuttgart.de/\texttt{\symbol{126}}kohlsn}}\\
 --- Address: \begin{minipage}[t]{8cm}\noindent
 Institut f{\"u}r Geometrie und Topologie \\
 Pfaffenwaldring 57 \\
 Universit{\"a}t Stuttgart \\
 70550 Stuttgart \\
 Germany \end{minipage}
}\\
\end{titlepage}

\newpage\setcounter{page}{2}
{\small 
\section*{Abstract}
\logpage{[ 0, 0, 2 ]}
 \textsf{ResClasses} is a package for \textsf{GAP} 4, which provides a fully-featured and easy-to-use implementation of
set-theoretic unions of residue classes of the integers and of a few other
rings. 

 The class of sets which \textsf{ResClasses} can deal with includes the open and the closed sets in the topology on the
respective ring which is induced by taking the set of all residue classes as a
basis, as far as the usual restrictions imposed by the finiteness of computing
resources permit this. 

 The package further provides slightly more specialized functionality for
unions of residue classes with distinguished representatives and signed
moduli. 

 The \textsf{ResClasses} package is used in a group theoretical context by the \textsf{RCWA} package{\nobreakspace}\cite{RCWA}. \mbox{}}\\[1cm]
{\small 
\section*{Copyright}
\logpage{[ 0, 0, 1 ]}
 {\copyright} 2003 - 2007 by Stefan Kohl 

 This package is distributed under the GNU General Public License. \mbox{}}\\[1cm]
\newpage

\def\contentsname{Contents\logpage{[ 0, 0, 3 ]}}

\tableofcontents
\newpage

        
\chapter{\textcolor{Chapter }{Set-Theoretic Unions of Residue Classes}}\label{ch:UnionsOfResidueClasses}
\logpage{[ 1, 0, 0 ]}
\hyperdef{L}{X815A3DDE7C0BC44A}{}
{
   
\section{\textcolor{Chapter }{Entering residue classes and set-theoretic unions thereof}}\label{sec:DefiningUnionsOfResidueClasses}
\logpage{[ 1, 1, 0 ]}
\hyperdef{L}{X7E16A64485A7AB79}{}
{
  

\subsection{\textcolor{Chapter }{ResidueClass (by ring, modulus and residue)}}
\logpage{[ 1, 1, 1 ]}\nobreak
\hyperdef{L}{X8753CC098447BE0D}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClass({\slshape R, m, r})\index{ResidueClass@\texttt{ResidueClass}!by ring, modulus and residue}
\label{ResidueClass:by ring, modulus and residue}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClass({\slshape m, r})\index{ResidueClass@\texttt{ResidueClass}!by modulus and residue}
\label{ResidueClass:by modulus and residue}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClass({\slshape r, m})\index{ResidueClass@\texttt{ResidueClass}!by residue and modulus}
\label{ResidueClass:by residue and modulus}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 In the three-argument form the residue class \mbox{\texttt{\slshape r}}{\nobreakspace}mod{\nobreakspace}\mbox{\texttt{\slshape m}} of the ring{\nobreakspace}\mbox{\texttt{\slshape R}}, and in the two-argument form the residue class \mbox{\texttt{\slshape r}}{\nobreakspace}mod{\nobreakspace}\mbox{\texttt{\slshape m}} of the ``default ring'' ($\rightarrow$ \texttt{DefaultRing} in the \textsf{GAP} Reference Manual) of the arguments. 



 In the two-argument case, \mbox{\texttt{\slshape m}} is taken to be the larger and \mbox{\texttt{\slshape r}} is taken to be the smaller of the arguments. For convenience, it is permitted
to enclose the argument list in list brackets. 

 \index{IsResidueClass@\texttt{IsResidueClass}} \index{Modulus@\texttt{Modulus}!of a residue class} \index{Residue@\texttt{Residue}!of a residue class} Residue classes have the property \texttt{IsResidueClass}. Rings are regarded as residue class 0{\nobreakspace}(mod{\nobreakspace}1),
and therefore have this property. There are operations \texttt{Modulus} and \texttt{Residue} to retrieve the modulus{\nobreakspace}\mbox{\texttt{\slshape m}} resp. residue{\nobreakspace}\mbox{\texttt{\slshape r}} of a residue class. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> ResidueClass(2,3);
  The residue class 2(3) of Z
  gap> ResidueClass(Z_pi([2,5]),2,1);
  The residue class 1(2) of Z_( 2, 5 )
  gap> R := PolynomialRing(GF(2),1);;
  gap> x := Indeterminate(GF(2),1);; SetName(x,"x");
  gap> ResidueClass(R,x+One(R),Zero(R));
  The residue class 0*Z(2) ( mod x+Z(2)^0 ) of GF(2)[x]
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{ResidueClassUnion (by ring, modulus and residues)}}
\logpage{[ 1, 1, 2 ]}\nobreak
\hyperdef{L}{X85327C777F32DA8F}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClassUnion({\slshape R, m, r})\index{ResidueClassUnion@\texttt{ResidueClassUnion}!by ring, modulus and residues}
\label{ResidueClassUnion:by ring, modulus and residues}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClassUnion({\slshape R, m, r, included, excluded})\index{ResidueClassUnion@\texttt{ResidueClassUnion}!dito, plus included / excluded elements}
\label{ResidueClassUnion:dito, plus included / excluded elements}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 The union of the residue classes \mbox{\texttt{\slshape r}}[$i$]{\nobreakspace}mod{\nobreakspace}\mbox{\texttt{\slshape m}} of the ring{\nobreakspace}\mbox{\texttt{\slshape R}}, plus / minus finite sets \mbox{\texttt{\slshape included}} and \mbox{\texttt{\slshape excluded}} of elements of{\nobreakspace}\mbox{\texttt{\slshape R}}. 



 \pagebreak[4] 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> ResidueClassUnion(Integers,5,[1,2],[3,8],[-4,1]);
  (Union of the residue classes 1(5) and 2(5) of Z) U [ 3, 8 ] \ [ -4, 1 ]
  gap> ResidueClassUnion(Z_pi([2,3]),8,[3,5]);
  Union of the residue classes 3(8) and 5(8) of Z_( 2, 3 )
  gap> ResidueClassUnion(R,x^2,[One(R),x],[Zero(R)],[One(R)]);
  <union of 2 residue classes (mod x^2) of GF(2)[x]> U [ 0*Z(2) ] \ [ Z(2)^0 ]
  
\end{Verbatim}
 }

 \index{residue class union@residue class union!definition} When talking about a \emph{residue class union} in this chapter, we always mean an object as it is returned by this function. 

 \index{Modulus@\texttt{Modulus}!of a residue class union} \index{Residues@\texttt{Residues}!of a residue class union} \index{IncludedElements@\texttt{IncludedElements}!of a residue class union} \index{ExcludedElements@\texttt{ExcludedElements}!of a residue class union} There are operations \texttt{Modulus}, \texttt{Residues}, \texttt{IncludedElements} and \texttt{ExcludedElements} to retrieve the components of a residue class union as they have originally
been passed as arguments to \texttt{ResidueClassUnion} (\ref{ResidueClassUnion:by ring, modulus and residues}). 

 \index{ResidueClassUnionViewingFormat@\texttt{ResidueClassUnionViewingFormat}} The user has the choice between a longer and more descriptive and a shorter
and less bulky output format for residue classes and unions thereof: 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> ResidueClassUnionViewingFormat("short");
  gap> ResidueClassUnion(Integers,12,[0,1,4,7,8]);
  0(4) U 1(6)
  gap> ResidueClassUnionViewingFormat("long");
  gap> ResidueClassUnion(Integers,12,[0,1,4,7,8]);
  Union of the residue classes 0(4) and 1(6) of Z
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{AllResidueClassesModulo (of a given ring, modulo a given modulus)}}
\logpage{[ 1, 1, 3 ]}\nobreak
\hyperdef{L}{X8326D6F285081E0F}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{AllResidueClassesModulo({\slshape R, m})\index{AllResidueClassesModulo@\texttt{AllResidueClassesModulo}!of a given ring, modulo a given modulus}
\label{AllResidueClassesModulo:of a given ring, modulo a given modulus}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{AllResidueClassesModulo({\slshape m})\index{AllResidueClassesModulo@\texttt{AllResidueClassesModulo}!by modulus, of the default ring of that modulus}
\label{AllResidueClassesModulo:by modulus, of the default ring of that modulus}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 A sorted list of all residue classes (mod{\nobreakspace}\mbox{\texttt{\slshape m}}) of the ring{\nobreakspace}\mbox{\texttt{\slshape R}}. 



 If the argument \mbox{\texttt{\slshape R}} is omitted it defaults to the default ring of \mbox{\texttt{\slshape m}} -- cp. the documentation of \texttt{DefaultRing} in the \textsf{GAP} reference manual. \index{AllResidues@\texttt{AllResidues}!by ring and modulus} \index{NumberOfResidues@\texttt{NumberOfResidues}!by ring and modulus} A transversal for the residue classes (mod{\nobreakspace}\mbox{\texttt{\slshape m}}) can be obtained by the operation \texttt{AllResidues(\mbox{\texttt{\slshape R}},\mbox{\texttt{\slshape m}})}, and their number can be determined by the operation \texttt{NumberOfResidues(\mbox{\texttt{\slshape R}},\mbox{\texttt{\slshape m}})}. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> AllResidueClassesModulo(Integers,2);
  [ The residue class 0(2) of Z, The residue class 1(2) of Z ]
  gap> AllResidueClassesModulo(Z_pi(2),2);
  [ The residue class 0(2) of Z_( 2 ), The residue class 1(2) of Z_( 2 ) ]
  gap> AllResidueClassesModulo(R,x);
  [ The residue class 0*Z(2) ( mod x ) of GF(2)[x], 
    The residue class Z(2)^0 ( mod x ) of GF(2)[x] ]
  gap> AllResidues(R,x^3);  
  [ 0*Z(2), Z(2)^0, x, x+Z(2)^0, x^2, x^2+Z(2)^0, x^2+x, x^2+x+Z(2)^0 ]
  gap> NumberOfResidues(Z_pi([2,3]),360);
  72
  
\end{Verbatim}
 }

 }

  
\section{\textcolor{Chapter }{Methods for residue class unions}}\label{sec:MethodsForResidueClassUnions}
\logpage{[ 1, 2, 0 ]}
\hyperdef{L}{X7A3FA13187CEADED}{}
{
  \index{Print@\texttt{Print}!for a residue class union} \index{String@\texttt{String}!for a residue class union} \index{Display@\texttt{Display}!for a residue class union} There are methods for \texttt{Print}, \texttt{String} and \texttt{Display} which are applicable to residue class unions. There is a method for \texttt{in} which tests whether some ring element lies in a given residue class union. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> Print(ResidueClass(1,2),"\n");
  ResidueClassUnion( Integers, 2, [ 1 ] )
  gap> 1 in ResidueClass(1,2);
  true
  
\end{Verbatim}
 \index{Union@\texttt{Union}!for residue class unions} \index{Intersection@\texttt{Intersection}!for residue class unions} \index{Difference@\texttt{Difference}!for residue class unions} \index{IsSubset@\texttt{IsSubset}!for residue class unions} There are methods for \texttt{Union}, \texttt{Intersection}, \texttt{Difference} and \texttt{IsSubset} available for residue class unions. They also accept finite subsets of the
base ring as arguments. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> S := Union(ResidueClass(0,2),ResidueClass(0,3));         
  Z \ Union of the residue classes 1(6) and 5(6) of Z
  gap> Intersection(S,ResidueClass(0,7));
  Union of the residue classes 0(14) and 21(42) of Z
  gap> Difference(S,ResidueClass(2,4));
  Union of the residue classes 0(4) and 3(6) of Z
  gap> IsSubset(ResidueClass(0,2),ResidueClass(4,8));
  true
  gap> Union(S,[1..10]);
  (Union of the residue classes 0(2) and 3(6) of Z) U [ 1, 5, 7 ]
  gap> Intersection(S,[1..10]);
  [ 2, 3, 4, 6, 8, 9, 10 ]
  gap> Difference(S,[1..10]);
  (Union of the residue classes 0(2) and 3(6) of Z) \ [ 2, 3, 4, 6, 8, 9, 10 ]
  gap> Difference(Integers,[1..10]);
  Z \ <set of cardinality 10>
  gap> IsSubset(S,[1..10]);
  false
  
\end{Verbatim}
 If the underlying ring has a residue class ring of a given
cardinality{\nobreakspace}$t$, then a residue class can be written as a disjoint union of $t$ residue classes with equal moduli: 

\subsection{\textcolor{Chapter }{SplittedClass (for a residue class and a number of parts)}}
\logpage{[ 1, 2, 1 ]}\nobreak
\hyperdef{L}{X854315A2877B69A7}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{SplittedClass({\slshape cl, t})\index{SplittedClass@\texttt{SplittedClass}!for a residue class and a number of parts}
\label{SplittedClass:for a residue class and a number of parts}
}\hfill{\scriptsize (operation)}}\\
\textbf{\indent Returns:\ }
 A partition of the residue class \mbox{\texttt{\slshape cl}} into \mbox{\texttt{\slshape t}} residue classes with equal moduli, provided that such a partition exists.
Otherwise \texttt{fail}. 



 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> SplittedClass(ResidueClass(1,2),2);
  [ The residue class 1(4) of Z, The residue class 3(4) of Z ]
  gap> SplittedClass(ResidueClass(Z_pi(3),3,0),2);
  fail
  
\end{Verbatim}
 }

 Often one needs a partition of a given residue class union into ``few'' residue classes. The following operation takes care of this: 

\subsection{\textcolor{Chapter }{AsUnionOfFewClasses (for a residue class union)}}
\logpage{[ 1, 2, 2 ]}\nobreak
\hyperdef{L}{X87C166FE7FA17325}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{AsUnionOfFewClasses({\slshape U})\index{AsUnionOfFewClasses@\texttt{AsUnionOfFewClasses}!for a residue class union}
\label{AsUnionOfFewClasses:for a residue class union}
}\hfill{\scriptsize (operation)}}\\
\textbf{\indent Returns:\ }
 A set of disjoint residue classes whose union is equal to{\nobreakspace}\mbox{\texttt{\slshape U}}, up to the finite sets \texttt{IncludedElements(\mbox{\texttt{\slshape U}})} and \texttt{ExcludedElements(\mbox{\texttt{\slshape U}})}. 



 As the name of the operation suggests, it is taken care that the number of
residue classes in the returned list is kept ``reasonably small''. It is not guaranteed that it is minimal. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> ResidueClassUnionViewingFormat("short");
  gap> AsUnionOfFewClasses(Difference(Integers,ResidueClass(0,30)));
  [ 1(2), 2(6), 4(6), 6(30), 12(30), 18(30), 24(30) ]
  gap> Union(last);
  Z \ 0(30)
  
\end{Verbatim}
 }

 One can compute the sets of sums, differences, products and quotients of the
elements of a residue class union and an element of the base ring: 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> ResidueClass(0,2) + 1;
  1(2)
  gap> ResidueClass(0,2) - 2 = ResidueClass(0,2);
  true
  gap> 3 * ResidueClass(0,2);
  0(6)
  gap> ResidueClass(0,2)/2;
  Integers
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{PartitionsIntoResidueClasses (of a given ring, of given length)}}
\logpage{[ 1, 2, 3 ]}\nobreak
\hyperdef{L}{X8079E174813646DA}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{PartitionsIntoResidueClasses({\slshape R, length})\index{PartitionsIntoResidueClasses@\texttt{PartitionsIntoResidueClasses}!of a given ring, of given length}
\label{PartitionsIntoResidueClasses:of a given ring, of given length}
}\hfill{\scriptsize (operation)}}\\
\textbf{\indent Returns:\ }
 A sorted list of all partitions of the ring \mbox{\texttt{\slshape R}} into \mbox{\texttt{\slshape length}} residue classes. 



 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> PartitionsIntoResidueClasses(Integers,4);
  [ [ 0(2), 1(4), 3(8), 7(8) ], [ 0(2), 3(4), 1(8), 5(8) ], 
    [ 0(2), 1(6), 3(6), 5(6) ], [ 1(2), 0(4), 2(8), 6(8) ], 
    [ 1(2), 2(4), 0(8), 4(8) ], [ 1(2), 0(6), 2(6), 4(6) ], 
    [ 0(3), 1(3), 2(6), 5(6) ], [ 0(3), 2(3), 1(6), 4(6) ], 
    [ 1(3), 2(3), 0(6), 3(6) ], [ 0(4), 1(4), 2(4), 3(4) ] ]
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{RandomPartitionIntoResidueClasses (of a given ring, of given length)}}
\logpage{[ 1, 2, 4 ]}\nobreak
\hyperdef{L}{X8653860F7ADA4D38}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{RandomPartitionIntoResidueClasses({\slshape R, length, primes})\index{RandomPartitionIntoResidueClasses@\texttt{RandomPartitionIntoResidueClasses}!of a given ring, of given length}
\label{RandomPartitionIntoResidueClasses:of a given ring, of given length}
}\hfill{\scriptsize (operation)}}\\
\textbf{\indent Returns:\ }
 A ``random'' partition of the ring{\nobreakspace}\mbox{\texttt{\slshape R}} into \mbox{\texttt{\slshape length}} residue classes whose moduli have only prime factors in \mbox{\texttt{\slshape primes}}, respectively \texttt{fail} if no such partition exists. 



 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> RandomPartitionIntoResidueClasses(Integers,30,[2,3,5,7]);
  [ 2(7), 3(7), 4(7), 5(7), 6(7), 1(35), 8(35), 14(35), 21(35), 22(35), 28(35), 
    29(35), 7(105), 15(105), 42(105), 50(105), 77(105), 85(105), 70(175), 
    105(175), 35(350), 210(350), 0(525), 140(525), 315(525), 350(525), 
    490(525), 175(1575), 700(1575), 1225(1575) ]
  gap> Union(last);
  Integers
  gap> Sum(List(last2,Density));
  1
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{Density (of a residue class union)}}
\logpage{[ 1, 2, 5 ]}\nobreak
\hyperdef{L}{X791C16E77BE97FE3}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Density({\slshape U})\index{Density@\texttt{Density}!of a residue class union}
\label{Density:of a residue class union}
}\hfill{\scriptsize (operation)}}\\
\textbf{\indent Returns:\ }
 The natural density of{\nobreakspace}\mbox{\texttt{\slshape U}} as a subset of the underlying ring. 



 The \emph{natural density} of a residue class $r(m)$ of a ring{\nobreakspace}$R$ is defined by $1/|R/mR|$, and the \emph{natural density} of a union{\nobreakspace}$U$ of finitely many residue classes is defined by the sum of the densities of the
elements of a partition of{\nobreakspace}$U$ into finitely many residue classes. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> Density(ResidueClass(0,2));
  1/2
  gap> Density(Difference(Integers,ResidueClass(0,5)));
  4/5
  
\end{Verbatim}
 }

 \index{Iterator@\texttt{Iterator}!for a residue class union} \index{NextIterator@\texttt{NextIterator}!for an iterator of a residue class union} For looping over residue class unions of the integers, there are methods for
the operations \texttt{Iterator} and \texttt{NextIterator}. }

  
\section{\textcolor{Chapter }{The categories and families of residue class unions}}\label{sec:CategoriesOfUnionsOfResidueClasses}
\logpage{[ 1, 3, 0 ]}
\hyperdef{L}{X7B26BB1C7C8495A5}{}
{
  

\subsection{\textcolor{Chapter }{IsResidueClassUnion}}
\logpage{[ 1, 3, 1 ]}\nobreak
\hyperdef{L}{X7EA29BBD82552352}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{IsResidueClassUnion({\slshape U})\index{IsResidueClassUnion@\texttt{IsResidueClassUnion}}
\label{IsResidueClassUnion}
}\hfill{\scriptsize (filter)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{IsResidueClassUnionOfZ({\slshape U})\index{IsResidueClassUnionOfZ@\texttt{IsResidueClassUnionOfZ}}
\label{IsResidueClassUnionOfZ}
}\hfill{\scriptsize (filter)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{IsResidueClassUnionOfZ{\textunderscore}pi({\slshape U})\index{IsResidueClassUnionOfZpi@\texttt{IsResidue}\-\texttt{Class}\-\texttt{Union}\-\texttt{Of}\-\texttt{Z{\textunderscore}pi}}
\label{IsResidueClassUnionOfZpi}
}\hfill{\scriptsize (filter)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{IsResidueClassUnionOfGFqx({\slshape U})\index{IsResidueClassUnionOfGFqx@\texttt{IsResidueClassUnionOfGFqx}}
\label{IsResidueClassUnionOfGFqx}
}\hfill{\scriptsize (filter)}}\\
\textbf{\indent Returns:\ }
 \texttt{true} if \mbox{\texttt{\slshape U}} is a residue class union, a residue class union of the ring of integers, a
residue class union of a semilocalization of the ring of integers or a residue
class union of a polynomial ring in one variable over a finite field,
respectively, and \texttt{false} otherwise. 



 Often the same methods can be used for residue class unions of the ring of
integers and of its semilocalizations. For this reason, there is a category \texttt{IsResidueClassUnionOfZorZ{\textunderscore}pi} which is the union of \texttt{IsResidueClassUnionOfZ} and \texttt{IsResidueClassUnionOfZ{\textunderscore}pi}. \index{IsResidueClassUnionOfZ_pi@\texttt{IsResidueClassUnionOfZ{\textunderscore}pi}} The internal representation of residue class unions is called \texttt{IsResidueClassUnionResidueListRep}. \index{IsResidueClassUnionResidueListRep@\texttt{IsResidueClassUnionResidueListRep}} There are methods available for \texttt{ExtRepOfObj} and \texttt{ObjByExtRep}. \index{ExtRepOfObj@\texttt{ExtRepOfObj}} \index{ObjByExtRep@\texttt{ObjByExtRep}} }

 

\subsection{\textcolor{Chapter }{ResidueClassUnionsFamily (of a ring)}}
\logpage{[ 1, 3, 2 ]}\nobreak
\hyperdef{L}{X7F9BCB1A797F8F48}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClassUnionsFamily({\slshape R})\index{ResidueClassUnionsFamily@\texttt{ResidueClassUnionsFamily}!of a ring}
\label{ResidueClassUnionsFamily:of a ring}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClassUnionsFamily({\slshape R, fixedreps})\index{ResidueClassUnionsFamily@\texttt{ResidueClassUnionsFamily}!of a ring, with fixed representatives}
\label{ResidueClassUnionsFamily:of a ring, with fixed representatives}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 The family of residue class unions or the family of unions of residue classes
with fixed representatives of the ring{\nobreakspace}\mbox{\texttt{\slshape R}}, depending on whether \mbox{\texttt{\slshape fixedreps}} is present and \texttt{true} or not. 



 The ring \mbox{\texttt{\slshape R}} can be retrieved as \texttt{UnderlyingRing(ResidueClassUnionsFamily(\mbox{\texttt{\slshape R}}))}. \index{residue class union@residue class union!coercion} There is no coercion between residue class unions or unions of residue classes
with fixed representatives which belong to different families. Unions of
residue classes with fixed representatives are described in the next chapter. }

 }

  }

         
\chapter{\textcolor{Chapter }{Unions of Residue Classes with Fixed Representatives}}\label{ch:UnionsOfResidueClassesWithFixedReps}
\logpage{[ 2, 0, 0 ]}
\hyperdef{L}{X87871B5A86254179}{}
{
  \textsf{ResClasses} 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.  
\section{\textcolor{Chapter }{ Entering unions of residue classes with fixed representatives }}\label{sec:DefiningUnionsOfResidueClassesWithFixedReps}
\logpage{[ 2, 1, 0 ]}
\hyperdef{L}{X78BE0FA38691B1B6}{}
{
  

\subsection{\textcolor{Chapter }{ResidueClassWithFixedRepresentative (by ring, modulus and residue)}}
\logpage{[ 2, 1, 1 ]}\nobreak
\hyperdef{L}{X831C976D876FDAD3}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClassWithFixedRepresentative({\slshape R, m, r})\index{ResidueClassWithFixedRepresentative@\texttt{ResidueClassWithFixedRepresentative}!by ring, modulus and residue}
\label{ResidueClassWithFixedRepresentative:by ring, modulus and residue}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResidueClassWithFixedRepresentative({\slshape m, r})\index{ResidueClassWithFixedRepresentative@\texttt{ResidueClassWithFixedRepresentative}!of Z, by modulus and residue}
\label{ResidueClassWithFixedRepresentative:of Z, by modulus and residue}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 The residue class \mbox{\texttt{\slshape r}}{\nobreakspace}mod{\nobreakspace}\mbox{\texttt{\slshape m}} of the ring{\nobreakspace}\mbox{\texttt{\slshape R}}, with the fixed representative{\nobreakspace}\mbox{\texttt{\slshape r}}. 



 If the argument \mbox{\texttt{\slshape R}} is omitted, it defaults to \texttt{Integers}. \index{IsResidueClassWithFixedRep@\texttt{IsResidueClassWithFixedRep}} Residue classes with fixed representatives have the property \texttt{IsResidueClassWithFixedRepresentative}. The fixed representative{\nobreakspace}\mbox{\texttt{\slshape r}} can be retrieved by the operation \texttt{Residue}, and the modulus{\nobreakspace}\mbox{\texttt{\slshape m}} can be retrieved by the operation \texttt{Modulus}. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> ResidueClassWithFixedRepresentative(Integers,2,1);
  [1/2]
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{UnionOfResidueClassesWithFixedReps (by ring and list of classes)}}
\logpage{[ 2, 1, 2 ]}\nobreak
\hyperdef{L}{X871ED1D17AE52A95}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{UnionOfResidueClassesWithFixedReps({\slshape R, classes})\index{UnionOfResidueClassesWithFixedReps@\texttt{UnionOfResidueClassesWithFixedReps}!by ring and list of classes}
\label{UnionOfResidueClassesWithFixedReps:by ring and list of classes}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{UnionOfResidueClassesWithFixedReps({\slshape classes})\index{UnionOfResidueClassesWithFixedReps@\texttt{UnionOfResidueClassesWithFixedReps}!of Z, by list of classes}
\label{UnionOfResidueClassesWithFixedReps:of Z, by list of classes}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 The union of the residue classes \mbox{\texttt{\slshape classes}}[$i$][2] mod \mbox{\texttt{\slshape classes}}[$i$][1] of the ring \mbox{\texttt{\slshape R}}, with fixed representatives \mbox{\texttt{\slshape classes}}[$i$][2]. 



 The argument \mbox{\texttt{\slshape classes}} must be a list of pairs of elements of the ring \mbox{\texttt{\slshape R}}. Their first entries -- the moduli -- must be nonzero. If the argument \mbox{\texttt{\slshape R}} is omitted, it defaults to \texttt{Integers}. \pagebreak[4] 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> UnionOfResidueClassesWithFixedReps(Integers,[[2,4],[3,9]]);
  [4/2] U [9/3]
  
\end{Verbatim}
 }

 \index{Modulus@\texttt{Modulus}!of a union of residue classes with fixed rep's} \index{Classes@\texttt{Classes}!of a union of residue classes with fixed rep's} \index{AsListOfClasses@\texttt{AsListOfClasses}!for a union of residue classes with fixed rep's} There is a method for the operation \texttt{Modulus} which returns the lcm of the moduli of the residue classes forming such a
union. Further there is an operation \texttt{Classes} for retrieving the list of classes which has been passed as an argument to \texttt{UnionOfResidueClassesWithFixedReps}. The operation \texttt{AsListOfClasses} does the same, except that the returned list contains residue classes instead
of pairs \texttt{[\mbox{\texttt{\slshape modulus}},\mbox{\texttt{\slshape residue}}]}. There are methods for \texttt{Print}, \texttt{String} and \texttt{Display} available for unions of residue classes with fixed representatives. 

\subsection{\textcolor{Chapter }{AllResidueClassesWithFixedRepsModulo (by ring and modulus)}}
\logpage{[ 2, 1, 3 ]}\nobreak
\hyperdef{L}{X8198386A809A6B17}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{AllResidueClassesWithFixedRepsModulo({\slshape R, m})\index{AllResidueClassesWithFixedRepsModulo@\texttt{AllResidueClassesWithFixedRepsModulo}!by ring and modulus}
\label{AllResidueClassesWithFixedRepsModulo:by ring and modulus}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{AllResidueClassesWithFixedRepsModulo({\slshape m})\index{AllResidueClassesWithFixedRepsModulo@\texttt{AllResidueClassesWithFixedRepsModulo}!by modulus, of the default ring of that modulus}
\label{AllResidueClassesWithFixedRepsModulo:by modulus, of the default ring of that modulus}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 A sorted list of all residue classes (mod{\nobreakspace}\mbox{\texttt{\slshape m}}) of the ring{\nobreakspace}\mbox{\texttt{\slshape R}}, with fixed representatives. 



 If the argument \mbox{\texttt{\slshape R}} is omitted it defaults to the default ring of{\nobreakspace}\mbox{\texttt{\slshape m}}, cp. the documentation of \texttt{DefaultRing} in the \textsf{GAP} reference manual. The representatives are the same as those chosen by the
operation \texttt{mod}. See also \texttt{AllResidueClassesModulo} (\ref{AllResidueClassesModulo:of a given ring, modulo a given modulus}). 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> AllResidueClassesWithFixedRepsModulo(4);
  [ [0/4], [1/4], [2/4], [3/4] ]
  
\end{Verbatim}
 }

 }

  
\section{\textcolor{Chapter }{ Methods for unions of residue classes with fixed representatives }}\label{sec:MethodsForUnionOfResidueClassesWithFixedReps}
\logpage{[ 2, 2, 0 ]}
\hyperdef{L}{X7C26C7E682C2FD2E}{}
{
  Throughout this chapter, the argument \mbox{\texttt{\slshape R}} denotes the underlying ring, and the arguments \mbox{\texttt{\slshape U}}, \mbox{\texttt{\slshape U1}} and{\nobreakspace}\mbox{\texttt{\slshape U2}} denote unions of residue classes of \mbox{\texttt{\slshape R}} with fixed representatives. 

 Unions of residue classes with fixed representatives are multisets. Elements
and residue classes can be contained with multiplicities: 

\subsection{\textcolor{Chapter }{Multiplicity (of an element in a union of residue classes with fixed rep's)}}
\logpage{[ 2, 2, 1 ]}\nobreak
\hyperdef{L}{X808442EC7F3F5748}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Multiplicity({\slshape x, U})\index{Multiplicity@\texttt{Multiplicity}!of an element in a union of residue classes with fixed rep's}
\label{Multiplicity:of an element in a union of residue classes with fixed rep's}
}\hfill{\scriptsize (method)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Multiplicity({\slshape cl, U})\index{Multiplicity@\texttt{Multiplicity}!of a residue class in a union of residue classes with fixed rep's}
\label{Multiplicity:of a residue class in a union of residue classes with fixed rep's}
}\hfill{\scriptsize (method)}}\\
\textbf{\indent Returns:\ }
 The multiplicity of \mbox{\texttt{\slshape x}} in{\nobreakspace}\mbox{\texttt{\slshape U}} regarded as a multiset of ring elements, resp. the multiplicity of the residue
class \mbox{\texttt{\slshape cl}} in{\nobreakspace}\mbox{\texttt{\slshape U}} regarded as a multiset of residue classes. 



 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> List([0..23],n->Multiplicity(n,U));
  [ 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0 ]
  gap> Multiplicity(ResidueClassWithFixedRep(2,0),U);
  1
  
\end{Verbatim}
 }

 \index{Density@\texttt{Density}!of a union of residue classes with fixed rep's} \index{IsOverlappingFree@\texttt{IsOverlappingFree}!for a union of residue classes with fixed rep's} \index{AsOrdinaryUnionOfResidueClasses@\texttt{AsOrdinaryUnionOfResidueClasses}!for a union of residue classes with fixed rep's} Let \texttt{U} be a union of residue classes with fixed representatives. The multiset \texttt{U} can have an attribute \texttt{Density} which denotes its \emph{natural density} as a multiset, i.e. elements with multiplicity{\nobreakspace}$k$ count $k$-fold. The multiset \texttt{U} has the property \texttt{IsOverlappingFree} if it consists of pairwise disjoint residue classes. The set-theoretic union
of the residue classes forming \texttt{U} can be determined by the operation \texttt{AsOrdinaryUnionOfResidueClasses}. The object returned by this operation is an ``ordinary'' residue class union as described in Chapter{\nobreakspace}\ref{ch:UnionsOfResidueClasses}. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> Density(U);
  5/6
  gap> IsOverlappingFree(U);
  false
  gap> AsOrdinaryUnionOfResidueClasses(U);
  Z \ Union of the residue classes 1(6) and 5(6) of Z
  gap> Density(last);
  2/3
  
\end{Verbatim}
 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 \texttt{+} and \texttt{-} 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{\nobreakspace}$U$. Further there are methods for \texttt{*} and \texttt{/} available for computing the multiset of products $x \cdot u$, $u \in U$ and the multiset of quotients $u/x$, $u \in U$. The division method requires all elements of{\nobreakspace}\texttt{U} to be divisible by{\nobreakspace}$x$. If the underlying ring is the ring of integers, scalar multiplication and
division leave $\delta$ invariant ($\rightarrow${\nobreakspace}\texttt{Delta} (\ref{Delta:for a union of residue classes with fixed representatives})). 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> U + 7;
  [7/2] U [7/3]
  gap> U - 7; 7 - U; -U;
  [-7/2] U [-7/3]
  [7/-3] U [7/-2]
  [0/-3] U [0/-2]
  gap> V := 2 * U;
  [0/4] U [0/6]
  gap> V/2;
  [0/2] U [0/3]
  
\end{Verbatim}
 \pagebreak[4] 

\subsection{\textcolor{Chapter }{Union (for unions of residue classes with fixed representatives)}}
\logpage{[ 2, 2, 2 ]}\nobreak
\hyperdef{L}{X8296A97779FE8B72}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Union({\slshape U1, U2})\index{Union@\texttt{Union}!for unions of residue classes with fixed representatives}
\label{Union:for unions of residue classes with fixed representatives}
}\hfill{\scriptsize (method)}}\\
\textbf{\indent Returns:\ }
 The union of \mbox{\texttt{\slshape U1}} and{\nobreakspace}\mbox{\texttt{\slshape U2}}. 



 The multiplicity of any ring element or residue class in the union is the sum
of its multiplicities in the arguments. It holds that \texttt{Delta(Union(\mbox{\texttt{\slshape U1}},\mbox{\texttt{\slshape U2}})) = Delta(\mbox{\texttt{\slshape U1}}) + Delta(\mbox{\texttt{\slshape U2}})}. ($\rightarrow${\nobreakspace}\texttt{Delta} (\ref{Delta:for a union of residue classes with fixed representatives})). 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> Union(U,U);                                      
  [0/2] U [0/2] U [0/3] U [0/3]
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{Intersection (for unions of residue classes with fixed representatives)}}
\logpage{[ 2, 2, 3 ]}\nobreak
\hyperdef{L}{X7FC166A57F1F5601}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Intersection({\slshape U1, U2})\index{Intersection@\texttt{Intersection}!for unions of residue classes with fixed representatives}
\label{Intersection:for unions of residue classes with fixed representatives}
}\hfill{\scriptsize (method)}}\\
\textbf{\indent Returns:\ }
 The intersection of \mbox{\texttt{\slshape U1}} and{\nobreakspace}\mbox{\texttt{\slshape U2}}. 



 The multiplicity of any residue class in the intersection is the minimum of
its multiplicities in the arguments. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> Intersection(U,ResidueClassWithFixedRep(2,0));
  [0/2]
  gap> Intersection(U,ResidueClassWithFixedRep(6,0));
  Empty union of residue classes of Z with fixed representatives
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{Difference (for unions of residue classes with fixed representatives)}}
\logpage{[ 2, 2, 4 ]}\nobreak
\hyperdef{L}{X82A4EE727E67AB98}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Difference({\slshape U1, U2})\index{Difference@\texttt{Difference}!for unions of residue classes with fixed representatives}
\label{Difference:for unions of residue classes with fixed representatives}
}\hfill{\scriptsize (method)}}\\
\textbf{\indent Returns:\ }
 The difference of \mbox{\texttt{\slshape U1}} and{\nobreakspace}\mbox{\texttt{\slshape U2}}. 



 The multiplicity of any residue class in the difference is its multiplicity
in{\nobreakspace}\mbox{\texttt{\slshape U1}} minus its multiplicity in{\nobreakspace}\mbox{\texttt{\slshape U2}}, 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 that \texttt{Delta(Difference(\mbox{\texttt{\slshape U1}},\mbox{\texttt{\slshape U2}})) = Delta(\mbox{\texttt{\slshape U1}}) - Delta(\mbox{\texttt{\slshape U2}})}. ($\rightarrow${\nobreakspace}\texttt{Delta} (\ref{Delta:for a union of residue classes with fixed representatives})). 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> V := UnionOfResidueClassesWithFixedReps(Integers,[[3,0],[5,2]]);
  [0/3] U [2/5]
  gap> Difference(U,V);
  [0/2] U [3/5]
  
\end{Verbatim}
 }

 }

  
\section{\textcolor{Chapter }{ The invariant Delta }}\label{sec:DeltaAndRho}
\logpage{[ 2, 3, 0 ]}
\hyperdef{L}{X7A1CBA1B7E6B93D0}{}
{
  

\subsection{\textcolor{Chapter }{Delta (for a union of residue classes with fixed representatives)}}
\logpage{[ 2, 3, 1 ]}\nobreak
\hyperdef{L}{X78DCAB2C7C4E37E8}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Delta({\slshape U})\index{Delta@\texttt{Delta}!for a union of residue classes with fixed representatives}
\label{Delta:for a union of residue classes with fixed representatives}
}\hfill{\scriptsize (attribute)}}\\
\textbf{\indent Returns:\ }
 The value of the invariant $\delta$ of the residue class union{\nobreakspace}\mbox{\texttt{\slshape U}}. 



 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{\nobreakspace}1). There is a related invariant{\nobreakspace}$\rho$ which is defined by $e^{\delta(U) \pi i}$. The corresponding attribute is called \texttt{Rho}. \index{Rho@\texttt{Rho}!for a union of residue classes with fixed rep's} 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,3],[3,4]]);
  [3/2] U [4/3]
  gap> Delta(U) = (3/2-1/2) + (4/3-1/2);
  true
  gap> V := RepresentativeStabilizingRefinement(U,3);
  [3/6] U [5/6] U [7/6] U [4/9] U [7/9] U [10/9]
  gap> Delta(V) = Delta(U);
  true
  gap> Rho(V);
  E(12)^11
  
\end{Verbatim}
 }

 

\subsection{\textcolor{Chapter }{RepresentativeStabilizingRefinement (of a union of res.-classes with fixed rep's)}}
\logpage{[ 2, 3, 2 ]}\nobreak
\hyperdef{L}{X7E109A6E81A0465C}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{RepresentativeStabilizingRefinement({\slshape U, k})\index{RepresentativeStabilizingRefinement@\texttt{RepresentativeStabilizingRefinement}!of a union of res.-classes with fixed rep's}
\label{RepresentativeStabilizingRefinement:of a union of res.-classes with fixed rep's}
}\hfill{\scriptsize (method)}}\\
\textbf{\indent Returns:\ }
 The representative stabilizing refinement of \mbox{\texttt{\slshape U}} into \mbox{\texttt{\slshape k}}{\nobreakspace}parts. 



 The \emph{representative stabilizing refinement} 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 \mbox{\texttt{\slshape k}} is zero, the method performs a simplification of \mbox{\texttt{\slshape U}} by joining appropriate residue classes, if this is possible. 

 In any case the value of \texttt{Delta(\mbox{\texttt{\slshape U}})} is invariant under this operation ($\rightarrow${\nobreakspace}\texttt{Delta} (\ref{Delta:for a union of residue classes with fixed representatives})). 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> U := UnionOfResidueClassesWithFixedReps(Integers,[[2,0],[3,0]]);
  [0/2] U [0/3]
  gap> RepresentativeStabilizingRefinement(U,4);   
  [0/8] U [2/8] U [4/8] U [6/8] U [0/12] U [3/12] U [6/12] U [9/12]
  gap> RepresentativeStabilizingRefinement(last,0);
  [0/2] U [0/3]
  
\end{Verbatim}
 }

 }

  
\section{\textcolor{Chapter }{ The categories of unions of residue classes with fixed rep's }}\label{sec:CategoriesOfUnionsOfResidueClassesWithFixedReps}
\logpage{[ 2, 4, 0 ]}
\hyperdef{L}{X7BA9DE337DF742E9}{}
{
  The names of the categories of unions of residue classes with fixed
representatives are \texttt{IsUnionOfResidueClasses[OfZ|OfZ{\textunderscore}pi|OfZorZ{\textunderscore}pi|OfGFqx]WithFixedRepresentatives}. }

  }

         
\chapter{\textcolor{Chapter }{Semilocalizations of the Integers}}\label{ch:Z_pi}
\logpage{[ 3, 0, 0 ]}
\hyperdef{L}{X80CB0518869B1818}{}
{
  This package implements residue class unions of the semilocalizations $\Z_{(\pi)}$ of the ring of integers. It also provides the underlying \textsf{GAP} implementation of these rings themselves.  
\section{\textcolor{Chapter }{Entering semilocalizations of the integers}}\label{sec:DefiningZ_pi}
\logpage{[ 3, 1, 0 ]}
\hyperdef{L}{X7B3B22AC7E6247A4}{}
{
  

\subsection{\textcolor{Chapter }{Z{\textunderscore}pi (by set of noninvertible primes)}}
\logpage{[ 3, 1, 1 ]}\nobreak
\hyperdef{L}{X835483D2834D1F60}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Z{\textunderscore}pi({\slshape pi})\index{Zpi@\texttt{Z{\textunderscore}pi}!by set of noninvertible primes}
\label{Zpi:by set of noninvertible primes}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{Z{\textunderscore}pi({\slshape p})\index{Zpi@\texttt{Z{\textunderscore}pi}!by noninvertible prime}
\label{Zpi:by noninvertible prime}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 The ring $\Z_{(\pi)}$ or the ring $\Z_{(p)}$, respectively. 



 The returned ring has the property \texttt{IsZ{\textunderscore}pi}. The set \mbox{\texttt{\slshape pi}} of noninvertible primes can be retrieved by the operation \texttt{NoninvertiblePrimes}. \index{IsZ_pi@\texttt{IsZ{\textunderscore}pi}} \index{NoninvertiblePrimes@\texttt{NoninvertiblePrimes}!of a semilocalization of Z} 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> R := Z_pi(2);
  Z_( 2 )
  gap> S := Z_pi([2,5,7]);
  Z_( 2, 5, 7 )
  
\end{Verbatim}
 }

 }

  
\section{\textcolor{Chapter }{Methods for semilocalizations of the integers}}\label{sec:MethodsForZ_pi}
\logpage{[ 3, 2, 0 ]}
\hyperdef{L}{X7E75C4217DCA45D0}{}
{
  \index{StandardAssociate@\texttt{StandardAssociate}!of an element of a semilocalization of Z} \index{Gcd@\texttt{Gcd}!of elements of a semilocalization of Z} \index{Lcm@\texttt{Lcm}!of elements of a semilocalization of Z} \index{Factors@\texttt{Factors}!of an element of a semilocalization of Z} \index{IsUnit@\texttt{IsUnit}!for an element of a semilocalization of Z} There are methods for the operations \texttt{in}, \texttt{Intersection}, \texttt{IsSubset}, \texttt{StandardAssociate}, \texttt{Gcd}, \texttt{Lcm}, \texttt{Factors} and \texttt{IsUnit} available for semilocalizations of the integers. For the documentation of
these operations, see the \textsf{GAP} reference manual. The standard associate of an element of a ring $\Z_{(\pi)}$ is defined by the product of the noninvertible prime factors of its numerator. 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> 4/7 in R; 3/2 in R;
  true
  false
  gap> Intersection(R,Z_pi([3,11])); IsSubset(R,S);
  Z_( 2, 3, 11 )
  true
  
\end{Verbatim}
 
\begin{Verbatim}[fontsize=\small,frame=single,label=Example]
  
  gap> StandardAssociate(R,-6/7);
  2
  gap> Gcd(S,90/3,60/17,120/33);
  10
  gap> Lcm(S,90/3,60/17,120/33);
  40
  gap> Factors(R,840);
  [ 105, 2, 2, 2 ]
  gap> Factors(R,-2/3);
  [ -1/3, 2 ]
  gap> IsUnit(S,3/11);
  true
  
\end{Verbatim}
  }

  }

         
\chapter{\textcolor{Chapter }{Installation and auxiliary functions}}\label{ch:InstallationAndAuxiliaryFunctions}
\logpage{[ 4, 0, 0 ]}
\hyperdef{L}{X859F6BF88754E5CC}{}
{
   
\section{\textcolor{Chapter }{Requirements}}\label{sec:Requirements}
\logpage{[ 4, 1, 0 ]}
\hyperdef{L}{X85A08CF187A6D986}{}
{
  The \textsf{ResClasses} package needs at least \textsf{GAP}{\nobreakspace}4.4.7 and \textsf{GAPDoc}{\nobreakspace}0.99999{\nobreakspace}\cite{GAPDoc}. It can be used under UNIX, under Windows and on the MacIntosh. \textsf{ResClasses} is completely written in the \textsf{GAP} language and does neither contain nor require external binaries. }

  
\section{\textcolor{Chapter }{Installation}}\label{sec:Installation}
\logpage{[ 4, 2, 0 ]}
\hyperdef{L}{X8360C04082558A12}{}
{
  Like any other \textsf{GAP} package, \textsf{ResClasses} must be installed in the \texttt{pkg} subdirectory of the \textsf{GAP} distribution. This is accomplished by extracting the distribution file in this
directory. By default, the package \textsf{ResClasses} is autoloaded. If you have switched autoloading of packages off, you can load \textsf{ResClasses} via \texttt{LoadPackage( "resclasses" );}. }

  
\section{\textcolor{Chapter }{The testing routine}}\label{sec:TheTestingRoutine}
\logpage{[ 4, 3, 0 ]}
\hyperdef{L}{X8667D5027AC3DE8E}{}
{
  

\subsection{\textcolor{Chapter }{ResClassesTest}}
\logpage{[ 4, 3, 1 ]}\nobreak
\hyperdef{L}{X8733F00082901C2C}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResClassesTest({\slshape })\index{ResClassesTest@\texttt{ResClassesTest}}
\label{ResClassesTest}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 Nothing. 



 Performs tests of the \textsf{ResClasses} package. Errors, i.e. differences to the correct results of the test
computations, are reported. The processed test files are in the directory \texttt{pkg/resclasses/tst}. }

 }

  
\section{\textcolor{Chapter }{Building the manual}}\label{sec:BuildingTheManual}
\logpage{[ 4, 4, 0 ]}
\hyperdef{L}{X854E65D281B80D3B}{}
{
  

\subsection{\textcolor{Chapter }{ResClassesBuildManual}}
\logpage{[ 4, 4, 1 ]}\nobreak
\hyperdef{L}{X7B4E650D828174F7}{}
{\noindent\textcolor{FuncColor}{$\Diamond$\ \texttt{ResClassesBuildManual({\slshape })\index{ResClassesBuildManual@\texttt{ResClassesBuildManual}}
\label{ResClassesBuildManual}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 Nothing. 



 This function is a development tool which builds the manual of the \textsf{ResClasses} package in the file formats {\LaTeX}, PDF, HTML and ASCII text. This is accomplished using the \textsf{GAPDoc} package by Frank L{\"u}beck and Max Neunh{\"o}ffer. Building the manual is
possible only on UNIX systems and requires PDF{\LaTeX}. As all files generated by this function are included in the distribution
file anyway, users will not need it. }

 }

  }

  \def\bibname{References\logpage{[ "Bib", 0, 0 ]}
\hyperdef{L}{X7A6F98FD85F02BFE}{}
}

\bibliographystyle{alpha}
\bibliography{resclassesbib.xml}

\def\indexname{Index\logpage{[ "Ind", 0, 0 ]}
\hyperdef{L}{X83A0356F839C696F}{}
}


\printindex

\newpage
\immediate\write\pagenrlog{["End"], \arabic{page}];}
\immediate\closeout\pagenrlog
\end{document}
