[proofplan]
All four cases flow from the algebraic identity $4a\, f(x,y) = (2ax + by)^2 - d\, y^2$, obtained by completing the square in $x$. For $d < 0$ the right-hand side is a sum of two non-negative terms, so the sign of $f$ is controlled by the sign of $a$; vanishing forces $y = 0$ and then $x = 0$, so $f$ is strictly definite away from the origin. For $d > 0$ the two terms have opposite signs, and the roots $\alpha, \beta$ of $f(x, 1) = 0$ are real and distinct; rational points on either side of the roots produce values of $f$ of both signs. For $d = 0$ the square in the completion has a repeated root, forcing $f$ to be a perfect square times a constant. We handle the degenerate case $a = 0$ separately in (iii) by symmetry in $(x, y)$.
[/proofplan]
[step:Complete the square to obtain the identity $4a\, f(x,y) = (2ax + by)^2 - d\, y^2$]
Assume first that $a \neq 0$. We compute
\begin{align*}
4a\, f(x, y) &= 4a(ax^2 + bxy + cy^2) \\
&= 4a^2 x^2 + 4abxy + 4acy^2 \\
&= (2ax + by)^2 - b^2 y^2 + 4ac y^2 \\
&= (2ax + by)^2 - (b^2 - 4ac)\, y^2 \\
&= (2ax + by)^2 - d\, y^2,
\end{align*}
where the third equality expands $(2ax + by)^2 = 4a^2 x^2 + 4abxy + b^2 y^2$. This identity is the algebraic core of cases (i), (ii), and (iv).
[guided]
To analyse the sign of $f(x, y) = ax^2 + bxy + cy^2$ we complete the square in the variable $x$. The coefficient of $x^2$ is $a$, so we multiply through by $4a$ (the standard "multiply by $4a$" trick used when completing the square over $\mathbb{Z}$, which avoids fractions):
\begin{align*}
4a\, f(x, y) = 4a^2 x^2 + 4ab\, xy + 4ac\, y^2.
\end{align*}
The first two terms are the start of the square $(2ax + by)^2 = 4a^2 x^2 + 4ab\, xy + b^2 y^2$. We subtract and add $b^2 y^2$:
\begin{align*}
4a\, f(x, y) = (2ax + by)^2 - b^2 y^2 + 4ac y^2 = (2ax + by)^2 - (b^2 - 4ac)\, y^2 = (2ax + by)^2 - d\, y^2.
\end{align*}
This identity is valid for every $(x, y) \in \mathbb{R}^2$ and any $a, b, c \in \mathbb{R}$ with $a \neq 0$. The hypothesis $a \neq 0$ is used only so that "multiply by $4a$" does not collapse both sides to zero; when $a = 0$ we handle case (iii) directly in a later step.
[/guided]
[/step]
[step:Deduce positive definiteness in case (i) and negative definiteness in case (ii)]
Assume $d < 0$ and $a \neq 0$. Then $-d > 0$, so both terms $(2ax + by)^2 \geq 0$ and $-d\, y^2 \geq 0$ on the right of the identity are non-negative. Therefore
\begin{align*}
4a\, f(x, y) = (2ax + by)^2 - d\, y^2 \geq 0 \quad \text{for all } (x, y) \in \mathbb{Z}^2.
\end{align*}
We analyse when equality holds. Since both summands are non-negative, $4a\, f(x, y) = 0$ forces each to vanish: $(2ax + by)^2 = 0$ and $-d\, y^2 = 0$. The second equation, combined with $-d > 0$, gives $y = 0$. Substituting $y = 0$ into the first equation yields $(2ax)^2 = 0$, so $x = 0$ (using $a \neq 0$). Hence
\begin{align*}
4a\, f(x, y) > 0 \quad \text{for all } (x, y) \in \mathbb{Z}^2 \setminus \{(0, 0)\}.
\end{align*}
If $a > 0$ (case (i)), dividing by the positive constant $4a$ preserves the inequality, giving $f(x, y) > 0$ for all $(x, y) \neq (0, 0)$. Hence $f$ is positive definite by the [Definition of Definite and Indefinite Forms](/theorems/???).
If $a < 0$ (case (ii)), dividing by the negative constant $4a$ reverses the inequality, giving $f(x, y) < 0$ for all $(x, y) \neq (0, 0)$. Hence $f$ is negative definite.
[/step]
[step:Prove indefiniteness in case (iii) when $a \neq 0$]
Assume $d > 0$ and $a \neq 0$. The polynomial $f(x, 1) = ax^2 + bx + c$ is a real quadratic in $x$ with discriminant $d > 0$, so it has two distinct real roots
\begin{align*}
\alpha = \frac{-b - \sqrt{d}}{2a}, \qquad \beta = \frac{-b + \sqrt{d}}{2a},
\end{align*}
with $\alpha \neq \beta$. We relabel so that $\alpha < \beta$. Over $\mathbb{R}$ the polynomial factors as
\begin{align*}
f(x, 1) = a(x - \alpha)(x - \beta),
\end{align*}
and by homogeneity of $f$ of degree $2$,
\begin{align*}
f(x, y) = y^2 f(x/y, 1) = a\, y^2 (x/y - \alpha)(x/y - \beta) \quad \text{for } y \neq 0.
\end{align*}
We now exhibit integer points $(x, y)$ with $y \neq 0$ on each side of the roots. Since $\mathbb{Q}$ is dense in $\mathbb{R}$, we may pick rationals $p/q$ and $p'/q'$ (with $q, q' \geq 1$) satisfying
\begin{align*}
p/q > \beta \qquad \text{and} \qquad \alpha < p'/q' < \beta.
\end{align*}
Then $(x, y) = (p, q)$ gives
\begin{align*}
f(p, q) = a\, q^2 (p/q - \alpha)(p/q - \beta),
\end{align*}
where both factors $(p/q - \alpha) > 0$ and $(p/q - \beta) > 0$. So $f(p, q)$ has the same sign as $a$. Similarly $(x, y) = (p', q')$ gives
\begin{align*}
f(p', q') = a\, (q')^2 (p'/q' - \alpha)(p'/q' - \beta),
\end{align*}
where $(p'/q' - \alpha) > 0$ and $(p'/q' - \beta) < 0$. So $f(p', q')$ has sign opposite to $a$. Both values are attained at integer arguments, so $f$ takes both strictly positive and strictly negative values on $\mathbb{Z}^2$. Hence $f$ is indefinite.
[guided]
When $d > 0$ the dehomogenised polynomial $f(x, 1) = ax^2 + bx + c$ has positive discriminant and therefore two distinct real roots. Writing $\alpha < \beta$ for these roots, we have the factorisation over $\mathbb{R}$:
\begin{align*}
f(x, 1) = a(x - \alpha)(x - \beta).
\end{align*}
To recover $f(x, y)$ we use the homogeneity of $f$: since each term of $f$ is of degree $2$ in $(x, y)$,
\begin{align*}
f(x, y) = y^2 f(x/y, 1) = a\, y^2 \bigl( \tfrac{x}{y} - \alpha \bigr) \bigl( \tfrac{x}{y} - \beta \bigr), \quad y \neq 0.
\end{align*}
The sign of $f(x, y)$ is therefore governed by the sign of $a$ together with the relative position of $x/y$ and the two roots:
- If $x/y > \beta$ or $x/y < \alpha$: both factors $(x/y - \alpha)$ and $(x/y - \beta)$ have the same sign, so their product is positive, and $f(x, y)$ has the sign of $a$.
- If $\alpha < x/y < \beta$: the factors have opposite signs, their product is negative, and $f(x, y)$ has the sign opposite to $a$.
To finish we must produce such configurations using integer pairs. The rationals are dense in $\mathbb{R}$: the interval $(\beta, \infty)$ contains some rational $p/q$ with $q \geq 1$ and $p \in \mathbb{Z}$, giving the integer pair $(p, q)$ with $p/q > \beta$. Likewise $(\alpha, \beta) \cap \mathbb{Q}$ is nonempty (it is an open interval of positive length), yielding another integer pair $(p', q')$ with $\alpha < p'/q' < \beta$.
Evaluating $f$ at these two integer pairs gives values of opposite sign. By the [Definition of Definite and Indefinite Forms](/theorems/???), $f$ is indefinite.
[/guided]
[/step]
[step:Handle the degenerate subcase $a = 0$ of (iii)]
Suppose $d > 0$ and $a = 0$. Then $d = b^2 - 4ac = b^2$, so $b \neq 0$ (else $d = 0$, contradicting $d > 0$). Also
\begin{align*}
f(x, y) = bxy + cy^2 = y(bx + cy).
\end{align*}
Choose $y = 1$ and then pick any two integers $x_+$ and $x_-$ with
\begin{align*}
bx_+ + c > 0 \quad \text{and} \quad bx_- + c < 0;
\end{align*}
such integers exist because $b \neq 0$, so the affine function $x \mapsto bx + c$ is strictly monotone and surjective onto $b\mathbb{Z} + c$, which contains both positive and negative values for $|x|$ large of appropriate sign. Then $f(x_+, 1) > 0$ and $f(x_-, 1) < 0$. Hence $f$ is indefinite.
[/step]
[step:Prove case (iv): when $d = 0$, the form is a multiple of a perfect square]
Assume $d = 0$, i.e. $b^2 = 4ac$. We consider two cases.
If $a \neq 0$, the identity from the first step gives
\begin{align*}
4a\, f(x, y) = (2ax + by)^2 - 0 \cdot y^2 = (2ax + by)^2.
\end{align*}
So
\begin{align*}
f(x, y) = \frac{(2ax + by)^2}{4a}.
\end{align*}
We want to display $f$ as $l(mx + ny)^2$ with integer $l, m, n$. If $a > 0$, let $g = \gcd(2a, b) \geq 1$ and write $2a = gm$, $b = gn$ with $m, n \in \mathbb{Z}$ and $\gcd(m, n) = 1$. Then $2ax + by = g(mx + ny)$ and
\begin{align*}
f(x, y) = \frac{g^2 (mx + ny)^2}{4a} = \frac{g^2}{4a} (mx + ny)^2.
\end{align*}
Since $f$ has integer values on $\mathbb{Z}^2$ and $(mx + ny)^2$ takes arbitrary non-negative integer values as $(x, y)$ ranges over $\mathbb{Z}^2$ (in particular the value $1$, achieved because $\gcd(m, n) = 1$ implies $\exists (x, y) \in \mathbb{Z}^2$ with $mx + ny = 1$ by [Bezout](/theorems/???)), the rational number $l := g^2/(4a)$ must itself be an integer. Hence $f(x, y) = l(mx + ny)^2$ with $l, m, n \in \mathbb{Z}$. The case $a < 0$ is identical after absorbing a sign into $l$.
If $a = 0$, then $b^2 = 4ac = 0$, so $b = 0$ too, and $f(x, y) = cy^2 = c(0 \cdot x + 1 \cdot y)^2$, which is of the required form with $l = c$, $m = 0$, $n = 1$.
[/step]
[step:Collect the four cases to conclude]
Cases (i) and (ii) were proved together from the completed-square identity, using $d < 0$ to force both summands non-negative and $a \neq 0$ (which holds because $a \neq 0$ is implied by $d < 0$: if $a = 0$ then $d = b^2 \geq 0$). Case (iii) was split into $a \neq 0$ (via the real roots of $f(x, 1)$) and $a = 0$ (via the linear factorisation $f(x, y) = y(bx + cy)$). Case (iv) was handled by the same completed-square identity with $d = 0$, together with a separate argument for $a = 0$. Each case produced the claimed conclusion, completing the proof.
[/step]