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

\begin{flashcard}[prop-rep-pdbqf-iff-lemma]
\begin{lemma}
  \label{prop_rep_pdbqf_iff_lemma}
  Let $f(x, y)$ be a \gls{pdbqf}, $N \in \NN$.
  Then $f$ \glspl{prop_rep} $N$ if and only if
  \cloze{$f$
  is \gls{equiv_bqf} to a \glsref[bqf]{form} $g =
  \bqfb(a, b, c)$ where $a = N$.}
\end{lemma}

\begin{proof}
  \phantom{}
  \begin{enumerate}[$\Rightarrow$]
    \item[$\Leftarrow$]
      \cloze{\Gls{equiv_bqf}
      \glsref[bqf]{forms} \gls{prop_rep} the same
      integers. Since $g(1, 0) = N$, $f$
      \glspl{prop_rep} $N$.}
    \item[$\Rightarrow$] \cloze{Suppose $A \in
      \SL_2(\ZZ)$ such that $g(x, y) = f((x, y)A)
      = \bqfb(a, b, c)$. Then $g(1, 0) = a$. By
      assumption, $\exists m, n \in \ZZ$ with
      $\gcd(m, n) = 1$, $f(m, n) = N$. $a = g(1, 0) =
      f((1, 0) A)$. If we can choose $A$ so that
      $(1, 0) = (m, n)$, then we will have $a =
      g(1, 0) = f(m, n) = N$. Since $\gcd(m, n) =
      1$, $\exists r, s \in \ZZ$ such that $rm +
      sn = 1$. If
      \[ A =
      \begin{pmatrix}
        m & n \\
        -s & r
      \end{pmatrix} ,\]
      then $\det(A) = 1$, so $A \in \SL_2(\ZZ)$,
      and $(1, 0) A = (m, n)$.} \qedhere
  \end{enumerate}
\end{proof}
\end{flashcard}

\begin{flashcard}[disc-prop-rep-iff-thm]
\begin{theorem}
  \label{disc_prop_rep_iff_thm}
  Let $d \in \ZZ$, $d < 0$, $d \equiv 0 \text{ or
  } 1 \pmod{4}$. Let $N \in \NN$. Then the
  following are equivalent:
  \begin{enumerate}[(i)]
    \item \cloze{$N$ is \gls{prop_rep} by some
      \gls{pdbqf} of \gls{disc_bqf} $d$.}
    \item \cloze{The congruence $X^2 \equiv d \pmod{4N}$
      has a \gls{eq_sol}.}
  \end{enumerate}
\end{theorem}

\begin{proof}
  \phantom{}
  \begin{enumerate}[(1) $\implies$ (2)]
    \item[(1) $\implies$ (2)] \cloze{By
      \cref{prop_rep_pdbqf_iff_lemma}, (1) holds
      if and only if $\exists$ \gls{pdbqf}
      $\bqfb(N, b, c)$ of \gls{disc_bqf} $d$. Then
      $d = b^2 - 4Nc$ so $b$ is a \gls{eq_sol} to $X^2
      \equiv d \pmod{4N}$.}
    \item[(2) $\implies$ (1)] \cloze{Suppose there is a
      \gls{eq_sol} $b \in \ZZ$. Then $b^2 \equiv d
      \pmod{4N}$, so there exists $c \in \ZZ$ such
      that $b^2 = d + 4Nc$. Then $f(x, y) =
      \bqfb(N, b, c)$ has \gls{disc_bqf} $b^2 -
      4Nc = d$. So $f$ is a \gls{pdbqf} of
      \gls{disc_bqf} $d$ which \glspl{prop_rep}
      $N$.}
  \end{enumerate}
\end{proof}
\end{flashcard}

\begin{example*}
  $f(x, y) = x^2 + xy + 2y^2$, a \gls{pdbqf} of
  \gls{disc_bqf} $d = -7$. Which integers are
  \gls{bqf_rep} by $f$?

  First decide which $N \in \NN$ are
  \gls{prop_rep} by $f(x, y)$. Claim: $\clsnum(-7) = 1$.
  If $\bqfb(a, b, c)$ is a \gls{red_pdbqf}
  \glsref[bqf]{form} of \gls{disc_bqf} $-7$, then
  $|b| \le a \le \sqrt{7/3} < 2$ so $|b| \le a \le
  1$. Also, $b$ is odd. So $a = 1$, $b = 1$, $c=
  2$ and $\bqfb(a, b, c) = \bqfb(1, 1, 2)$. By
  \cref{disc_prop_rep_iff_thm}, $N$ is
  \gls{prop_rep} by some form of \gls{disc_bqf}
  $-7$ if and only if $X^2 \equiv -7 \pmod{4N}$
  has a \gls{eq_sol}. Hence $N$ is \gls{prop_rep}
  by $f(x, y)$ if and only if $X^2 \equiv -7
  \pmod{4N}$ has a \gls{eq_sol}. Let's analyse the
  congruence condition $X^2 \equiv -7 \pmod{4N}$
  first when $N = p$ \gls{prime}. If $N = p = 2$:
  want $X^2 \equiv -7 \equiv 1 \pmod{8}$ to have a
  \gls{eq_sol} (which it does).

  If $p$ is odd: by \nameref{CRT}, want the two
  congruences
  \[ \begin{cases}
    X^2 \equiv -7 \equiv 1 \pmod{4} \\
    X^2 \equiv -7 \equiv \pmod{p}
  \end{cases} \]
  to both be solvable. If $p = 7$, this is
  solvable. If $p \neq 2, 7$, this is solvable
  \[ \iff \legendre{-7}{p} = 1
  \stackrel{\text{QR}}{\iff} \legendre{p}{7} = 1
  \iff p \equiv 1, 2, \text{ or } 4 \pmod{7} .\]
  So a \gls{prime} number $p$ is \gls{prop_reped} by
  $f(x, y)$ $\iff p \equiv 0, 1, 2 \text{ or } 4
  \pmod{7}$. Now suppose $N$ is not necessarily
  \gls{prime}, and write $N = \prod_p p^{e_p}$,
  $p$ \gls{prime}, $e_p \ge 0$. Then $N$ is
  \gls{prop_reped} by $f$ $\iff$ $X^2 \equiv -7
  \pmod{4N}$ has a solution
  \[ \stackrel{\text{\nameref{CRT}}}{\iff} \begin{cases}
    X^2 \equiv -7 \pmod{2^{e_2 + 2}} \\
    X^2 \equiv -7 \pmod{p^{e_p}} & \text{$p$ odd}
  \end{cases} \]
  are all solvable.
\end{example*}

\begin{lemma}
  Let $a \in \ZZ$. Then
  \begin{enumerate}[(1)]
    \item If $p$ is an odd \gls{prime} and
      $\legendre{a}{p} = 1$, then the congruence
      $X^2 \equiv a \pmod{p^k}$ is solvable
      $\forall k \ge 1$.
    \item If $a \equiv 1 \pmod{8}$, then $X^2
      \equiv a \pmod{2^k}$ is solvable $\forall k
      \ge 1$.
  \end{enumerate}
\end{lemma}

\begin{proof}
  \phantom{}
  \begin{enumerate}[(1)]
    \item Use induction on $k \ge 1$, $k = 1$
      holding by assumption. Suppose $\exists x, y
      \in \ZZ$ such that $x^2 = a + yp^k$.
      Consider for $z \in \ZZ$
      \[ (x + p^k z)^2 = x^2 + 2p^k xz + p^{2k}
      z^2 \equiv a + p^k(y + 2xz) \pmod{p^{k + 1}} \]
      This is congruend to $a \pmod{p^{k + 1}}$
      $\iff$ $y \equiv -2 xz \pmod{p}$. Since $p$
      is odd, $p \nmid a \implies p \nmid x$, so
      $\gcdbrack(2x, p) = 1$, so we can find $z
      \in \ZZ$ such that $-2xz \equiv y \pmod{p}$.
    \item We show $X^2 \equiv a \pmod{2^k}$ has a
      \gls{eq_sol} for all $k \ge 3$ by induction
      on $k \ge 3$. $k = 3$ holds by assumption.
      Suppose $\exists x, y \in \ZZ$ such that
      $x^2 = a + 2^k y$, $k \ge 3$. If $y$ is
      even, then $x^2 \equiv a \pmod{2^{k + 1}}$.
      So assume $y$ is odd. Then
      \[ (x + 2^{k - 1})^2
      = x^2 + 2^k x + 2^{2k - 2}
      = a + a^k(x + y) + 2^{2k - 2} \]
      so $x + y$ is even (since both $x$ and $y$
      are odd). So
      \[ (x + 2^{k - 1})^2 \equiv a + 2^{2k - 2}
      \pmod{2^{k + 1}} \]
      This is congruent to $a \pmod{2^{k + 1}}$
      if and only if $2k -2  \ge k + 1$, which is
      true if and only if $k \ge 3$. \qedhere
  \end{enumerate}
\end{proof}

Conclusion: $N \in NN$ is \gls{prop_reped} by $x^2
+ xy + 2y^2$ if and only if the congruences $X^2
\equiv -7 \pmod{2^{e_2 + 2}}$, $X^2 \equiv -7
\pmod{p^{e_p}}$ ($p$ odd, $e_p \ge 1$) are all
solvable. The first is always solvable, so this is
true:
\begin{align*}
  &\iff \text{if $p \mid N$, $p \neq 2, 7$, then $p
  \equiv 1, 2 \text{ or } 4 \pmod{7}$ and } \\
  &\phantom{\iff}~~\text{if $7
  \mid N$, then $X^2 \equiv -7 \pmod{7^{e_7}}$ has
  a solution} \\
  &\iff \text{if $p \mid N$, $p \neq 2, 7$, then $p
  \equiv 1, 2, \text{ or } 4 \pmod{7}$. If $7 \mid
  N$ then $7^2 \nmid N$}
\end{align*}
