%! TEX root = NT.tex
% vim: tw=50
% 13/10/2023 10AM

\begin{flashcard}[totient-function-formulae-prop]
\begin{proposition}[totient function formulae]
  \label{totient_function_formulae}
  \phantom{}
  \begin{enumerate}[(1)]
    \item \cloze{If $p$ is a \gls{prime} number, $k \in \NN$,
      $\totient(p^k) = p^k = k^{k - 1}$.}
    \item \cloze{If $N \in \NN$, then
      \[ \totient(N) = N \prod_{\text{$p \divides
      N$ \gls{prime}}}
      \left( 1 - \frac{1}{p} \right) \]}
    \item \cloze{If $N \in \NN$, $\sum_{d \divides
      N} \totient(d)
      = N$.}
  \end{enumerate}
\end{proposition}

\begin{proof}
  \phantom{}
  \begin{enumerate}[(1)]
    \item \cloze{\phantom{}\vspace{-2em}
      \begin{align*}
        \totient(p^k)
        &= \#\{1 \le a \le p^k \mid (a,
        p) = 1\} \\
        &= \#\{1 \le a \le p^k\} - \#\big\{1 \le a \le
        p^k ~\big|~ p \mid a\big\} \\
        &= p^k - p^{k - 1}
      \end{align*}}
    \item \cloze{Assume $N > 1$, and factorise $N =
      \prod_{i = 1}^r p_i a^i$, $a_i \ge 1$, $p_i$
      distinct primes. Since $\totient$ is
      \gls{mult_fn},
      \[ \totient(N)
      = \prod_{i = 1}^r \totient(p_i^{a_i})
      = \prod_{i = 1}^r p_i^{a_i} \left( 1 -
      \frac{2}{p_i} \right)
      = N \prod_{i = 1}^r \left( 1 - \frac{1}{p_i} \right) \]}
    \item \cloze{We know $f(N) = \sum_{d \divides N}
      \totient(d)$ is \gls{mult_fn}. Want to show
      $f(N) = N$. It's enough to check this
      equality when $N = p^k$ is a \gls{prime} power ($k
      \ge 1$).
      \[ f(p^k)
      = \sum_{i = 0}^k \totient(p^i)
      = (p^k - p^{k - 1}) + (p^{k - 1} - p^{k -
      2}) + \cdots + (p - 1) + 1
      = p^k \qedhere \]}
  \end{enumerate}
\end{proof}
\end{flashcard}

\subsubsection*{Polynomial Congruences}

If $N \in \NN$, a polynomial $f(X)$ with
coefficients in $\ZZ / N\ZZ$ is a formal linear
combination
\[ f(X) = a_n X^n + a_{n - 1} X^{n - 1} + \cdots +
a_1 X + a_0 \]
of powers of $X$, $a_i \in \ZZ / N\ZZ$. Two
polynomials are equal if their coefficients are
equal (so for example $X = X + 0 \cdot X^2$).

We write $\ZZ / N\ZZ[X]$ for the set of
polynomials with coefficients in $\ZZ / N\ZZ$. You
can add and multiply these in the usual way, which
gives this a ring structure.

If $a \in \ZZ / N\ZZ$,
\[ f(a) \eqdef a_n a^n + \cdots + a_1 a + a_0 \in
\ZZ / N\ZZ .\]
\glsnoundefn{eq_sol}{solution}{solutions}
The \emph{solutions} to $f(X) = 0$ in $\ZZ / N\ZZ$ are
the $a \in \ZZ / N\ZZ$ such that $f(a) \equiv
\pmod{N}$. For example $X^2 + 2 = 0$ in $\ZZ /
5\ZZ$ has no \glspl{eq_sol}, while $X^3 + 1 = 0$ has
3 \glspl{eq_sol} in $\ZZ / 7\ZZ$: 3, 5 and 6
\gls{modulo} 7.
The equation $X^2 - 1 = 0$ has 4 \glspl{eq_sol} in $\ZZ
/ 8\ZZ$: 1, 3, 5 and 7 \gls{modulo} 8. Note that in this
last case, the congruence has more than the
``expected'' number of solutions (i.e. degree of
$f(X) = 2$ in this case). This can happen only
when the \glsref[modulo]{modulus} is not \gls{prime}.

\begin{flashcard}[lagranges-thm]
\begin{theorem}[Lagrange's Theorem]
  \label{lagranges_thm}
  \cloze{Let $p$ be a \gls{prime} number,
  \[ f(X) = a_n X^n + \cdots + a_1 X + a_0 \in \ZZ
  / p\ZZ[X] \]
  with $a_n \not\equiv 0 \pmod{p}$. Then the
  equation $f(X) = 0$ has at most $n$
  \glspl{eq_sol} in
  $\ZZ / p\ZZ$.}
\end{theorem}

\begin{proof}
  \cloze{
  Induction on $n \ge 0$. If $n = 0$, $f(X) = a_0
  \not\equiv \pmod{p}$. Want to solve $a_0 \equiv
  \pmod{p}$. This has 0 \glspl{eq_sol} as desired.

  Suppose $n > 0$. Assume that $f(X) = 0$ has at
  least 1 \gls{eq_sol}, say $a \in \ZZ / p\ZZ$ (and if
  there are no \glspl{eq_sol}, then we are already
  done). Note if $j > 0$, then
  \[ X^j - a^j = (X - a)(X^{j - 1} + a X^{j - 2} +
  \cdots + a^{j - 1}) \]
  so
  \[ f(X) = f(X) - f(A) = \sum_{j = 1}^n a_j (X^j
  - a^j) = (X - a) \ub{\sum_{j = 1}^n a_j (X^{j - 1} +
  a X^{j - 2} + \cdots + a^{j - 1})}_{\eqdef g(X)} \]
  Note that $g(X)$ has leading term $a_n X^{n -
  1}$. Suppose $b \in \ZZ / p\ZZ$ is a
  \gls{eq_sol} to
  $f(X) = 0$ distinct from $a$. Then $0 \equiv
  f(b) \equiv (b - a) g(b) \pmod{p}$. Since $p$ is
  \gls{prime} and $a \not\equiv b \pmod{p}$, $b - a$ has
  a multiplicative inverse \gls{modulo} $p$. So $g(b)
  \equiv 0 \pmod{p}$. By induction, we know $g(X)
  = 0$ has at most $n - 1$ \glspl{eq_sol} in $\ZZ /
  p\ZZ$. Hence $f(X) = 0$ has at most $n$
  \glspl{eq_sol}.
  }
\end{proof}
\end{flashcard}

\begin{flashcard}[Zpx-is-cyclic-thm]
\begin{theorem}
  \cloze{Let $p$ be a \gls{prime} number. Then
  $\multbrack(\ZZ / p\ZZ)$ is a cyclic group of order $p -
  1$.}
\end{theorem}

\begin{proof}
  \cloze{We know $\#\multbrack(\ZZ / p\ZZ) =
  \totient(p) = p -
  1$. From \cref{totient_function_formulae}, we know
  \[ p - 1 = \sum_{d \divides p - 1} \totient(d) .\]
  We know that if $a \in \multbrack(\ZZ / p\ZZ)$ then
  order of $a$ divides $p - 1$ (Lagrange's theorem
  from group theory). If $N_d$ denotes the number
  of elements in $\multbrack(\ZZ / p\ZZ)$ of order
  $d$, then
  \[ \sum_{d \divides p - 1} N_d = p - 1 \]
  We want to show $N_{p - 1} > 0$. Suppose for
  contradiction that $N_{p - 1} = 0$. Note
  \[ \sum_{d \divides p - 1} N_d = p - 1 = \sum_{d
  \divides p - 1} \totient(d) .\]
  We know $\totient(p - 1) > 0$. If $N_{p - 1} = 0$,
  then we must have $N_d > \totient(d)$ for some $d
  \divides p - 1$. Let $a \in \multbrack(\ZZ / p\ZZ))$ be
  some element of this order $d$. Consider the
  cyclic subgroup $\langle a \rangle = \{1, a,
  \ldots, a^{d - 1}\} = \multbrack(\ZZ / p\ZZ)$. It's
  cyclic of order $d$, so has $\totient(d)$ elements
  of order $d$ (\cref{generators_of_C_n_coro}). We
  know $N_d > \totient(d)$, so there must exist $b \in
  \multbrack(\ZZ / p\ZZ)$ of order $d$, not contained
  in this subgroup. Claim: $\{1, a, \ldots, a^{d -
  1}, b\}$ are $d + 1$ solutions to $X^d - 1 = 0$
  in $\ZZ / p\ZZ$. This is clearly true for $b$,
  and for the powers of $a$, note $(a^{i})^d
  \equiv a^{id} \equiv (a^d)^i \equiv 1^i \equiv
  1 \pmod{p}$. But this contradicts
  \cref{lagranges_thm} (\nameref{lagranges_thm}).
  }
\end{proof}
\end{flashcard}

\begin{flashcard}[primitive-root-defn]
\begin{definition}[primitive root]
  \glsnoundefn{prim_root}{primitive root}{primitive roots}
  \cloze{
  Let $p$ be a \gls{prime} number, $a \in \ZZ$. We say
  that $a$ is a \emph{primitive root modulo $p$} if $a
  + N\ZZ \in \multbrack(\ZZ / p\ZZ)$ generates the
  group.
  }
\end{definition}
\end{flashcard}
\vspace{-1em}
The theorem says that primitive roots always
exist.

\begin{example*}
  For $p = 7$, one can check that $2$ is not a
  \gls{prim_root}, while $3$ is.
\end{example*}
