Quadratic reciprocity. #
This file contains results about quadratic residues modulo a prime number.
We define the Legendre symbol (a / p) as legendre_sym p a.
Note the order of arguments! The advantage of this form is that then legendre_sym p
is a multiplicative map.
The main results are the law of quadratic reciprocity, quadratic_reciprocity, as well as the
interpretations in terms of existence of square roots depending on the congruence mod 4,
exists_sq_eq_prime_iff_of_mod_four_eq_one, and
exists_sq_eq_prime_iff_of_mod_four_eq_three.
Also proven are conditions for -1 and 2 to be a square modulo a prime,
exists_sq_eq_neg_one_iff_mod_four_ne_three and
exists_sq_eq_two_iff
Implementation notes #
The proof of quadratic reciprocity implemented uses Gauss' lemma and Eisenstein's lemma
The Legendre symbol of a and p, legendre_sym p a, is an integer defined as
0ifais0modulop;1ifa ^ (p / 2)is1modulop(byeuler_criterionthis is equivalent to “ais a square modulop”);-1otherwise.
Note the order of the arguments! The advantage of the order chosen here is
that legendre_sym p is a multiplicative function ℤ → ℤ.
Gauss' lemma. The legendre symbol can be computed by considering the number of naturals less
than p/2 such that (a * x) % p > p / 2