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

\begin{corollary}
  Let $d \in \ZZ$, $d < 0$, $d \equiv 0 \text{ or
  } 1 \pmod{4}$. Then the number of
  \glsref[equiv_bqf]{equivalence classes} of
  \gls{pdbqf} of \gls{disc_bqf} $d$ is finite.
\end{corollary}

\begin{proof}
  Every \gls{bqf_equiv_class} contains a reduced
  form. Therefore it is enough to show that there
  are finitely many \gls{red_pdbqf} $\bqfb(a, b, c)$ of
  $\disc$ $d$. If $\bqfb(a, b, c)$ is
  \gls{red_pdbqf}, then $|b| \le a \le
  \sqrt{\frac{|d|}{3}}$, so there are finitely
  many choices for $a$ and $b$. But we also know
  $c = \frac{b^2 - d}{4a}$, so $a$ and $b$
  determine $c$.
\end{proof}

\begin{definition}
  \glsnoundefn{prop_rep}{properly
  represent}{properly represents}
  \glsadjdefn[prop_rep]{prop_reped}{properly
  represented}{integers}
  Let $f = \bqfb(a, b, c)$ be a \gls{bqform},
  $N \in \ZZ$. We say $N$ is \emph{properly
  represented} by $f$ if $\exists m, n \in \ZZ$
  with $f(m, n) = N$ with $\gcd(m, n) = 1$.
\end{definition}

\begin{note*}
  If $f, g$ are \gls{equiv_bqf}, then they
  \gls{prop_rep} the same integers. Why? By
  symmetry, enough to show that if $f$
  \glspl{prop_rep} $N$, then so does $g$. Suppose
  $f(m, n) = N$, $\gcd(m, n) = 1$. Let $f(x, y) =
  g((x, y)A)$,
  \[ A =
  \begin{pmatrix}
    \alpha & \beta \\
    \gamma & \delta
  \end{pmatrix} \in \SL_2(\ZZ) \]
  Then $f(m, n) = N = g((m, n)A) = g(\alpha m +
  \gamma n, \beta m + \delta n)$. We need to check
  $\gcd(\alpha m + \gamma n, \beta m + \delta n) =
  1$.

  We have $\gcd(m, n) \divides \alpha m + \gamma n,
  \beta m + \delta n$, so $\gcd(m, n) \divides
  \gcd(\alpha m + \gamma n, \beta m + \delta n)$.
  Since $(\alpha m + \gamma n, \beta m + \delta n)
  = (m, n)A$, we have $(m ,n) = (\alpha m + \gamma
  n, \beta m + \delta n)A^{-1}$, $A^{-1} \in
  \SL_2(\ZZ)$. So the same argument gives
  $\gcd(\alpha m + \gamma n, \beta m + \delta n)
  \divides \gcd(m, n)$, so equality holds. So $g$
  \glspl{prop_rep} $N$.
\end{note*}

\begin{flashcard}[red-pdbqf-smallest-nums]
\begin{lemma}
  \label{pdbqf_values_lemma}
  Let $f = \bqfb(a, b, c)$ be a \gls{red_pdbqf}
  \gls{pdbqf}. Then
  \begin{enumerate}[(1)]
    \item \cloze{$a \le c \le a + c - |b|$.}
    \item \cloze{$f(1, 0) = a$, $f(0, 1) = c$, $\exists
      \eps \in \{\pm 1\}$ with $f(1, \eps) = a + c
      - |b|$.}
    \item \cloze{If $m, n \in \ZZ, \gcd(m, n) = 1$, and
      $(m, n) \neq \pm (1, 0)$ or $\pm (0, 1)$
      then $f(m, n) \ge a + c - |b|$.}
  \end{enumerate}
  \cloze{Informally: the smallest $3$ \gls{prop_reped}
  values of $f$ are $a$, $c$, $a + c - |b|$.}
\end{lemma}

\begin{proof}
  \phantom{}
  \begin{enumerate}[(1)]
    \item \cloze{Since $f$ is \gls{red_pdbqf}, $c \ge a
      \ge |b| \ge 0$. So $a - |b| \ge 0$, $c + a -
      |b| \ge c$.}
    \item \cloze{$f(x, y) = ax^2 + bxy + cy^2$
      $\implies$ $f(1, 0) = a$, $f(0, 1) = c$,
      $f(1, \eps) = a + \eps + c$, $\eps \in
      \{\pm 1\}$. Choose $\eps$ so that $\eps b =
      -|b|$. Then $f(1, \eps) = a + c - |b|$.}
    \item \cloze{If $m, n \in \ZZ$, $\gcd(m, n) =
      1$, and $(m, n) \neq \pm (1, 0)$ or $\pm (0,
      1)$, then $m, n$ are both non-zero. First
      assume $|m| \ge |n| \ge 1$. Then $f(m, n) =
      am^2 + bmn + cn^2 \ge am^2 - |b| m^2 + cn^2
      \ge (a - |b|)m^2 + cn^2$. Since $f$ is
      \gls{red_pdbqf}, $a - |b| \ge 0$. Then since
      $m^2, n^2 \ge 1$, $f(m, n) \ge a + c - |b|$.
      Next assume $|n| \ge |m| \ge 1$. Then
      \[ f(m, n) = am^2 + bmn + cn^2 \ge am^2 -
      |b|n^2 + cn^2 \ge am^2 + (c - |b|)n^2 \ge a
      + c - |b| \qedhere \]}
  \end{enumerate}
\end{proof}
\end{flashcard}

\begin{flashcard}[pdbqf-equiv-unique-red-thm]
\begin{theorem}
  Every \gls{pdbqf} is \gls{equiv_bqf} to a unique
  \gls{red_pdbqf} form.
\end{theorem}

\begin{proof}
  \cloze{
  Every \gls{pdbqf} is equivalent to some
  \gls{red_pdbqf} \glsref[bqf]{form}, so it's
  enough to show that if $f = \bqfb(a, b, c)$, $g
  = \bqfb(a', b',
  c')$ are \gls{equiv_bqf} \gls{red_pdbqf}
  \glsref[bqf]{forms}, then they're equal.

  We know that \glsref[equiv_bqf]{equivalent}
  \glsref[bqf]{forms} \gls{prop_rep} the same
  values, the same number of times. We know that
  the $3$ smallest values represented by $f$ are
  $a \le c \le a + c - |b|$, and the ones for $g$
  are $a' \le c' \le a' + c' - |b'|$. So $a = a'$,
  $c = c'$, $a + c - |b| = a' + c' - |b'|$, so
  $|b| = |b'|$, $b' = \pm b$. Assume for
  contradiction that $b \neq b'$, then without
  loss of generality we can assume $b > 0$. So $f
  = (a, b, c)$, $g = (a, -b, c)$. Recall to say
  $f$ is \gls{red_pdbqf} means $c \ge a \ge |b|$,
  and if $c = a$ or $a = |b|$, then $b \ge 0$.

  We're assuming $b > 0$, and $g = \bqfb(a, -b,
  c)$ is also \gls{red_pdbqf}. Therefore we must
  have $c > a$, $a > b$, so $a < c < a + c - b$.
  Suppose $f(x, y) = g((x, y) A)$, $A \in
  \SL_2(\ZZ)$,
  \[ A =
  \begin{pmatrix}
    \alpha & \beta \\
    \gamma & \delta
  \end{pmatrix} \]
  Then $a = f(1, 0) = g((1, 0) A) = g(\alpha,
  \beta)$ and $c = f(0, 1) = g(\gamma, \delta)$.
  We have $\gcd(\alpha, \beta) = 1$, $\gcd(\gamma,
  \delta) = 1$. By \cref{pdbqf_values_lemma}(3),
  we know that if $m, n \in \ZZ$, $\gcd(m, n) =
  1$, $(m, n) \neq \pm (1, 0)$ or $\pm (0, 1)$,
  then $g(m, n) \ge a + c - |b| > c$. The only
  possibilities are $(\alpha, \beta) = \pm (1,
  0)$, $\gamma, \delta) = \pm (0, 1)$. Hence
  \[ A =
  \begin{pmatrix}
    \pm 1 & 0 \\
    0 & \pm 1
  \end{pmatrix} \]
  Since $\det(A) = 1$, we must have both signs the
  same, so $A = \pm I_2$. Hence $g((x, y)A) =
  g(\pm (x, y)) = g(x, y)$ (since $g$ is
  homogeneous of degree 2). But $f(x, y) = g((x,
  y)A) = f(x, y)$, so $g(x, y) = f(x, y)$,
  contradicting our assumption that they were
  non-equal.
  }
\end{proof}
\end{flashcard}

\begin{flashcard}[class-number-of-d-defn]
\begin{definition}
  \glsnoundefn{cls_num}{class number}{class
  numbers}
  \glssymboldefn{cls_num}{$h$}{$h$}
  Let $d \in \ZZ$, $d < 0$, $d \equiv 0, 1
  \pmod{4}$. Then we write
  \begin{align*}
    h(d)
    &= \cloze{\#\{\text{\glspl{bqf_equiv_class} of
    \gls{pdbqf} of \gls{disc_bqf} $d$}\}} \\
    &= \cloze{\#\{\text{\gls{red_pdbqf}
    \glspl{pdbqf} of \gls{disc_bqf} $d$}\}}
  \end{align*}
  \cloze{``Class number of $d$''}
\end{definition}
\end{flashcard}

\begin{example*}
  $\clsnum(-4) = 1$. Let's compute $\clsnum(-24)$ by
  enumerating \gls{red_pdbqf} \glsref[bqf]{forms}.
  TODO???
\end{example*}
