\documentclass[12pt]{amsart} % Document type

% There is a lengthy top section...
% Copy and paste this into a new .tex file.
% Begin typing at the bottom of this document.

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Various add-ons that allow for greater customization of the document. Not all are necessary.

%\usepackage[T1]{fontenc} % Output encoding (suggested when text contains accented letters)
%\usepackage[utf8]{inputenc} % Input encoding (important when writing in foreign languages)
\usepackage[margin =.75in]{geometry} % Set page dimensions
\usepackage{parskip} % Custom paragraph spacing
\usepackage{changepage} % Change page layout
\usepackage{setspace} % Allow for double-spacing using \doublespace
\usepackage{multicol} % Allows multiple columns on a page
\usepackage{mathtools,amssymb,amsfonts,amsthm} % Variety of useful things for math
\usepackage{euscript,mathrsfs,bbm} % Some additional fonts
\usepackage{color} % Color
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} % Extra colors

\usepackage{comment} % Customizable comment environments
\usepackage{newverbs} % Customizable verbatim environments
\usepackage{enumitem} % Customizable enumerate environments
\usepackage{tabularx} % Greater flexibility with tables
\usepackage{multirow} % Table elements span multiple rows

\usepackage{graphicx} % For inserting images
\usepackage{wrapfig} % Wrap text around figures
\usepackage{url} % For inserting urls
\usepackage[linktoc=all,colorlinks=true,linkcolor=blue,urlcolor=Purple,citecolor=cyan]{hyperref} % Internal and external links
\usepackage[all]{hypcap} % Image captions (requires hyperref)
\usepackage{pdfpages} % Insert pdfs
\usepackage{tikz} % For drawing pictures
    \usetikzlibrary{petri}
    \usetikzlibrary{trees}
%\usepackage[all]{xy} % Matrix-like diagrams
\raggedbottom
\allowdisplaybreaks

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Custom comment environments and various editing macros
% Comments can be turned off using \excludecomment{ }

\specialcomment{lecturenotes}{}{}\excludecomment{lecturenotes}
\specialcomment{answers}{ \textsc{Answer: }}{}
\specialcomment{remarks}{

\vspace{2mm}\noindent
\begin{adjustwidth}{5mm}{0mm}
\begingroup\color{blue}
}
{
\endgroup
\end{adjustwidth}

\vspace{2mm}
}
\specialcomment{inremarks}{\begingroup\color{blue}}{\endgroup}
\newcommand{\ctypo}[1]{\colorbox{yellow}{#1}\hspace{-1mm}}
\newcommand{\ctex}[1]{\colorbox{Gold}{#1}}
\newcommand{\period}{\colorbox{cyan!50}{.}}
\newcommand{\comma}{\colorbox{cyan!50}{,}}

\newverbcommand{\cverb}{\small\color{purple}}{}
\newverbcommand{\everb}{\small\color{blue}}{}

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Custom column types for tabularx

\newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\arraybackslash}X}
\newcolumntype{R}[1]{>{\hsize=#1\hsize\raggedleft\arraybackslash}X}
\newcolumntype{C}[1]{>{\hsize=#1\hsize\centering\arraybackslash}X}

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Custom spacing commands

\begingroup
    \makeatletter
    \@for\theoremstyle:=definition,remark,plain\do{%
        \expandafter\g@addto@macro\csname th@\theoremstyle\endcsname{%
            \addtolength\thm@preskip\parskip
            }%
        }
\endgroup

\newcommand{\sss}{\vspace{2 mm}\noindent}
\newcommand{\lss}{\vspace{5 mm}\noindent}
\newcommand{\lls}{\vspace{7 mm}\noindent}
\newcommand{\ds}{\displaystyle}
\newcommand{\HR}{\vspace{5pt}\hrule height 1pt \vspace{5pt}}
\newcommand{\atext}[1]{\text{\quad #1\quad}}
%\newcommand\Tstrut{\rule{0pt}{2.6ex}}         % = `top' strut
%\newcommand\Bstrut{\rule[-1ex]{0pt}{0pt}}   % = `bottom' strut

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Shortcuts for commonly used symbols

\newcommand{\ca}{\mathcal}
\newcommand{\fr}{\mathfrak}
\newcommand{\eucal}{\EuScript}
\newcommand{\scr}{\mathscr}
\newcommand{\bbf}{\mathbb{F}}
\newcommand{\bbn}{\mathbb{N}}
\newcommand{\bbr}{\mathbb{R}}
\newcommand{\bbq}{\mathbb{Q}}
\newcommand{\bbc}{\mathbb{C}}
\newcommand{\bbz}{\mathbb{Z}}
\newcommand{\bbp}{\mathbb{P}}
\newcommand{\bfa}{\mathbf{a}}
\newcommand{\bfb}{\mathbf{b}}
\newcommand{\bfc}{\mathbf{c}}
\newcommand{\bfu}{\mathbf{u}}
\newcommand{\bfv}{\mathbf{v}}
\newcommand{\bfx}{\mathbf{x}}
\newcommand{\ring}{\ca O}

\newcommand{\inv}{^{-1}}
\newcommand{\into}{\hookrightarrow}
\newcommand{\onto}{\twoheadrightarrow}
\newcommand{\isom}{\overset{\sim}{\to}}
\renewcommand{\iff}{\Leftrightarrow}
\renewcommand{\implies}{\Rightarrow}
\renewcommand{\impliedby}{\Leftarrow}
\newcommand{\contradiction}{\Rightarrow\Leftarrow}

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Shortcuts for matrices and vectors

\newcommand{\bmat}[1]{\begin{bmatrix}#1\end{bmatrix}}
\newcommand{\pmat}[1]{\begin{pmatrix}#1\end{pmatrix}}
\newcommand{\vmat}[1]{\begin{vmatrix}#1\end{vmatrix}}
\newcommand{\floor}[1]{\lfloor #1 \rfloor}
\newcommand{\Floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\vect}[1]{\langle #1 \rangle}

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%
% Custom function names

\newcommand{\Ad}{\operatorname{Ad}}
\newcommand{\ad}{\operatorname{ad}}
\newcommand{\disc}{\operatorname{disc}}
\newcommand{\domain}{\operatorname{domain}}
\newcommand{\Id}{\operatorname{Id}}
\newcommand{\im}{\operatorname{im}}
\newcommand{\ind}{\operatorname{ind}}
\newcommand{\nul}{\operatorname{Nul}}
\newcommand{\nullity}{\operatorname{nullity}}
\newcommand{\ord}{\operatorname{ord}}
\newcommand{\proj}{\operatorname{proj}}
\newcommand{\rank}{\operatorname{rank}}
\newcommand{\red}{\operatorname{red}}
\newcommand{\bbref}{\operatorname{rref}}
\newcommand{\tr}{\operatorname{tr}}
\newcommand{\trunc}{\operatorname{Trunc}}
\newcommand{\vspan}{\operatorname{span}}

%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%
% Environment styles

\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem*{prop*}{Proposition}
\newtheorem*{cor*}{Corollary}
\newtheorem*{lem*}{Lemma}
\newtheorem*{thm*}{Theorem}

\theoremstyle{definition}
\newtheorem{conj}[thm]{Conjecture}
\newtheorem{defn}[thm]{Definition}
\newtheorem{claim}[thm]{Claim}
\newtheorem{example}[thm]{Example}
\newtheorem*{conj*}{Conjecture}
\newtheorem*{defn*}{Definition}
\newtheorem*{rd}{Read from the text}
\newenvironment{answer}{\noindent\textsc{Answer:}}{\hfill $\square$}

\newcounter{homework}
\newtheorem{hw}[homework]{Homework}
\newcounter{exercise}[homework]
\newtheorem{exer}[exercise]{Exercise}
\renewcommand{\theexercise}{\arabic{homework}.\arabic{exercise}}

\theoremstyle{remark}
\newtheorem{remark}[thm]{Remark}
\newtheorem*{remark*}{Remark}
\newtheorem{notation}[thm]{Notation}

\renewcommand{\theexercise}{\arabic{exercise}}

\title{Math 2001 \\ Modular arithmetic}

\begin{document}
\maketitle

Due Wednesday, April 20.

\textbf{Book exercises:} Section 11.4: 6, 7.

\textbf{Proofs:} Final draft of Proof 14 and first draft of Proof 15.

\HR

\begin{defn*}
Let $a$, $b$, and $n$ be integers. We say that $a$ is \emph{congruent to $b$ modulo $n$} if $n \mid (a-b)$, and we write $a \equiv b \pmod n$. (TeX: \cverb;a \equiv b \pmod n;)
\end{defn*}

\begin{exer}
Prove that \emph{congruence modulo $n$} is an equivalence relation.

\vspace{3in}
\end{exer}

\begin{exer}
The \emph{division algorithm} states that if $a$ and $n$ are integers, then there exist unique integers $q$ and $r$ such that $a = qn + r$ and $0 \le r < n$.

Prove that $a \equiv r \pmod n$.

\vspace{1in}
\end{exer}

As a consequence, $a$ and $b$ have the same remainders when divided by $n$ if and only if $a \equiv b \pmod n$. Since there are exactly $n$ remainders when dividing by $n$ (they are: $0,1,2,3,\dotsc,n-1$), there are exactly $n$ equivalence classes modulo $n$: $[0], [1], [2], \dotsc, [n-1]$.

\begin{exer}
Write out the equivalence classes modulo $4$ explicitly.
\begin{align*}
&[0] = \{\hspace{2.5in}\} && [1] = \{\hspace{2.5in}\} \\
&[2] = \{\hspace{2.5in}\} && [3] = \{\hspace{2.5in}\} \\
\end{align*}
\end{exer}

\begin{exer}
We define the sum of equivalence classes as follows:
\begin{align*}\label{eq:sum}
[a]+[b] = \{x + y : x \in [a], y \in [b]\}.
\end{align*}
At the moment, there is no reason that the set on the left should be an equivalence class, but it turns out that is it. 

Working modulo $3$, write out the following sets explicitly.
\begin{align*}
& [0] + [0] = \{ \hspace{2.5in}\} && [0] + [1] = \{ \hspace{2.5in}\} \\
& [1] + [1] = \{ \hspace{2.5in}\} && [1] + [2] = \{ \hspace{2.5in}\}
\end{align*}
\end{exer}

\begin{exer}
Write out the addition table for the integers modulo 4 and modulo 5. (Put the appropriate class in each box.)
\begin{align*}
\begin{tikzpicture}[scale=.8]
\draw (0,0) grid (5,5)
	++(7,-5) grid (6,6);
\draw (.5,4.5) node {$+$}
	++(6,1) node {$+$};
\foreach \x in {0,1,2,3}{
	\node at (\x+1.5,4.5) {$[\x]$};
	\node at (.5,3.5-\x) {$[\x]$};
	}
\foreach \x in {0,1,2,3,4}{
	\node at (\x+7.5,5.5) {$[\x]$};
	\node at (6.5,4.5-\x) {$[\x]$};
	}
\end{tikzpicture}
\end{align*}
Give a conjecture: $[a] + [b] =  [\hspace{1in}]$ (what class?) Can you prove your conjecture?\end{exer}

\begin{exer}
We can do the same for multiplication. In this case, we will simply define $[a] \cdot [b] = [a\cdot b]$. Fill out the multiplication tables for 4 and 5.
\begin{center}
\begin{tikzpicture}[scale=.8]
\draw (0,0) grid (5,5)
	++(7,-5) grid (6,6);
\draw (.5,4.5) node {$\cdot$}
	++(6,1) node {$\cdot$};
\foreach \x in {0,1,2,3}{
	\node at (\x+1.5,4.5) {$[\x]$};
	\node at (.5,3.5-\x) {$[\x]$};
	}
\foreach \x in {0,1,2,3,4}{
	\node at (\x+7.5,5.5) {$[\x]$};
	\node at (6.5,4.5-\x) {$[\x]$};
	}
\end{tikzpicture}
\end{center}
\end{exer}

\begin{exer}
We all know that $x^2 = 1$ has two solutions in $\bbr$ (they are $x = 1$ and $x = -1$). How many solutions are there to $x^2 \equiv 1 \pmod n$ when $n = 4$? $n=5$? $n = 8$? $n = 16$? $n = 24$? 
\end{exer}
\end{document}