\section{Modular Arithmetic} I'm sure you're all familiar with modular arithmetic. In this section, our goal is to meet \textit{equivalence relations}, \textit{equivalence classes}, and use them to formally define arithmetic in mod $n$. \problem{} Compute the following: \begin{itemize} \item $5 + 3 \pmod{4}$ \item $7 \times 4 \pmod{9}$ \item $-4 \pmod{5}$ \item $3^{-1} \pmod{7}$ \end{itemize} \vfill \definition{} An \textit{equivalence relation} on a set $A$ is a symbol that makes a statement about two elements of $A$. For example, $=$ is an equivalence relation on the set of integers. \vspace{2mm} An equivalence relation must satisfy the following properties: \begin{itemize} \item Reflexivity: $x \sim x$ for all $x \in A$ \item Symmetry: if $x \sim y$, $y \sim x$ for any $x, y \in A$ \item Transitivity: if $x \sim y$ and $y \sim z$, then $x \sim z$ \end{itemize} \problem{} Which of the following are equivalence relations on $\mathbb{Z}$? \begin{itemize} \item $>$ \item $\leq$ \item $\Bumpeq$, where $a \Bumpeq b$ if $|a| = |b|$ \item $\neq$ \end{itemize} \vfill \pagebreak \problem{} Consider the relation $\equiv_n$ on $\mathbb{Z}$, where $a \equiv_n b$ holds iff $a \equiv b \pmod{n}$. \par Show that $\equiv_n$ is an equivalence relation. \vfill \definition{} Say we have an equivalence relation $\sim$ on a set $A$. \par The \textit{equivalence class} of $x$ is the set of all elements that are $\sim$ to $x$. \par Here are a few examples: \par \begin{itemize}[itemsep=2mm] \item The equivalence class of $2$ in $\mathbb{Z}$ under the relation $=$ is $\{2\}$, \par since the only $x$ that satisfies $x = 2$ is $2$. \item The equivalence class of $9$ in $\mathbb{Z}$ under the relation $\Bumpeq$ from \ref{abseq} is $\{-9, 9\}$. \end{itemize} \problem{} What is the equivalence class of $3$ in $\mathbb{Z}$ under $\equiv_5$? \par \hint{Remember that $\mathbb{Z}$ contains both positive and negative numbers.} \begin{solution} $\{..., -7, -2, 3, 8, 12, ... \}$ \end{solution} \vfill \problem{} Let $A$ be a set and $\sim$ an equivalence relation. \par Show that every element of $A$ is in \textit{exactly one} equivalence class\footnotemark{}\hspace{-1ex}. \par \hint{What properties does an equivalence relation satisfy?} \footnotetext{ We could also say \say{$A$ is partitioned by $[A ~/ \sim]$} or \say{$A$ is the disjoint union of $[A ~/ \sim]$,} \par where $[A ~/ \sim]$ is the set of equivalence classes of $\sim$. } \vfill We now have a proper definition of \say{mod $n$:} \par it is the equivalence relation $a \equiv_n b$, which is usually written as $a \equiv b \pmod{n}$. \par We will use this definition throughout this handout. \note[Note]{ This is different than the \say{mod} operator $a ~\%~ b $, which is defined as the remainder of $a \div b$. } \pagebreak \definition{} Given any $x \in \mathbb{Z}$, $[x]_n$ is the equivalence class of $x$ under $\equiv_n$. \problem{} Compute the following: \begin{itemize}[itemsep = 1mm] \item $[5]_3 + [4]_3$ \item $[-2]_7 + [9]_7$ \end{itemize} \vfill \problem{} Does $[4]_3 + [7]_5$ make sense? \vfill \problem{} Find all $n$ that satisfy $[5]_n \times [17]_n = [3]_n + [2]_n$ \par \hint{$[a]_n = [b]_n$ iff $n$ divides $a - b$, by definition of mod.} \begin{solution} $[85] = [12] ~\implies~ n ~|~ 85 - 12 ~\implies~ n ~|~ 73 ~\implies~ n \in \{1, 73\}$ \end{solution} \vfill \definition{} $\znz{n}$ (pronounced \say{$\mathbb{Z}$ mod $n \mathbb{Z}$}) is the set of equivalence classes of $\equiv_n$ on $\mathbb{Z}$. \par For example, $\znz{5} = \{~ [0]_5,~ [1]_5,~ [2]_5,~ [3]_5,~ [4]_5 ~\}$. \par \vspace{2mm} This notation may seem a bit odd, but don't let it confuse you. \par One of our goals today is to understand what exactly $\znz{n}$ means. \problem{} What is $\znz{6}$? \vfill \pagebreak