Proof. Let
be the characteristic function of
: if
,
if
are both quadratic residues, or if
are both quadratic nonresidues. Then
(if
, and
otherwise.)
Similarly, let
be the characteristic function of the complement
:
if exactly one of the integer
is a residue,
otherwise. Then
, so that
Since
we obtain
To evaluate this sum
, note that
, so
This sum can be written
, since
. As
is a bijection (
is invertible in
),
As
, the evaluation of this last sum is given in Exercise 5.8 :
, so
□