Quadratic Reciprocity

lean4-proofnumber-theorymodular-arithmeticvisualization
(pq)(qp)=(1)p12q12\left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2}\cdot\frac{q-1}{2}}

Statement

For distinct odd primes pp and qq:

(pq)(qp)=(1)p12q12\left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2}\cdot\frac{q-1}{2}}

where (ap)\left(\frac{a}{p}\right) is the Legendre symbol — equal to 11 if aa is a quadratic residue mod pp, and 1-1 otherwise.

In words: pp is a square mod qq and qq is a square mod pp, unless both pq3(mod4)p \equiv q \equiv 3 \pmod{4}, in which case exactly one is a square mod the other.

Supplements

The first supplement states:

(1p)=(1)p12\left(\frac{-1}{p}\right) = (-1)^{\frac{p-1}{2}}

The second supplement states:

(2p)=(1)p218\left(\frac{2}{p}\right) = (-1)^{\frac{p^2 - 1}{8}}

Historical Note

Gauss called this the "golden theorem" (theorema aureum) and published six different proofs during his lifetime. Over 240 proofs are now known, using techniques from combinatorics, algebra, analysis, and algebraic geometry.

Connections

The proof relies on Fermat's Little TheoremFermat's Little Theoremapa(modp)a^p \equiv a \pmod{p}For prime p, a^p is congruent to a mod pRead more →. Some modern proofs use ideas from Galois theoryFundamental Theorem of Galois Theory{intermediate fields}{subgroups of Gal(K/F)}\{\text{intermediate fields}\} \longleftrightarrow \{\text{subgroups of } \text{Gal}(K/F)\}Bijection between intermediate fields and subgroups of the Galois groupRead more →.

Lean4 Proof

/-- Quadratic reciprocity for distinct odd primes. The Legendre symbol
    `legendreSym p q` is Mathlib's `(a/p)` defined via Euler's
    criterion. For odd `p`, the integer division `p / 2` equals
    `(p-1) / 2`, so the exponent matches the textbook form
    `((p-1)/2) · ((q-1)/2)`. -/
theorem quadratic_reciprocity {p q : } [Fact p.Prime] [Fact q.Prime]
    (hp : p  2) (hq : q  2) (hpq : p  q) :
    legendreSym q p * legendreSym p q = (-1) ^ (p / 2 * (q / 2)) :=
  legendreSym.quadratic_reciprocity hp hq hpq