Jacobi Symbol

lean4-proofnumber-theoryvisualization
(an)=i(api)ei\left(\frac{a}{n}\right) = \prod_{i} \left(\frac{a}{p_i}\right)^{e_i}

Statement

Let n=p1e1pkekn = p_1^{e_1} \cdots p_k^{e_k} be an odd positive integer. The Jacobi symbol is defined by

(an)=i=1k(api)ei\left(\frac{a}{n}\right) = \prod_{i=1}^{k} \left(\frac{a}{p_i}\right)^{e_i}

where each factor is a Legendre symbol. In Mathlib this is jacobiSym a n with notation J(a | n).

Key properties:

  • J(a1)=1J(a \mid 1) = 1 for all aa (jacobiSym.one_right).
  • Multiplicativity in both arguments.
  • Quadratic reciprocity: for odd coprime m,nm, n,
(mn)(nm)=(1)m12n12\left(\frac{m}{n}\right)\left(\frac{n}{m}\right) = (-1)^{\frac{m-1}{2}\cdot\frac{n-1}{2}}

Warning: J(an)=1J(a \mid n) = 1 does not imply aa is a QR mod nn when nn is composite.

Visualization

Worked computation of J(215)J(2 \mid 15) via Jacobi reciprocity:

Factorisation: 15=3×515 = 3 \times 5.

Step 1 — split by definition:

J(215)=(23)(25)J(2 \mid 15) = \left(\frac{2}{3}\right)\left(\frac{2}{5}\right)

Step 2 — evaluate each Legendre symbol using Euler's criterion:

(23)=2(31)/2=2121(mod3)    1\left(\frac{2}{3}\right) = 2^{(3-1)/2} = 2^1 \equiv 2 \equiv -1 \pmod{3} \implies -1
(25)=2(51)/2=22=41(mod5)    1\left(\frac{2}{5}\right) = 2^{(5-1)/2} = 2^2 = 4 \equiv -1 \pmod{5} \implies -1

Step 3 — multiply:

J(215)=(1)(1)=+1J(2 \mid 15) = (-1)(-1) = +1

Yet 2 is not a QR mod 15 (no xx with x22(mod15)x^2 \equiv 2 \pmod{15}), illustrating the warning above.

Proof Sketch

  1. The Jacobi symbol is defined as a product of Legendre symbols over the prime factorisation.
  2. jacobiSym.one_right: when n=1n = 1 the product is empty, so the symbol is 11.
  3. Quadratic reciprocity for Jacobi symbols is deduced from the Legendre version by induction on the prime factorisations, tracking the sign (1)m12n12(-1)^{\frac{m-1}{2}\cdot\frac{n-1}{2}}.
  4. Multiplicativity follows from multiplicativity of Legendre symbols.

Connections

The Jacobi symbol is a computational tool for Quadratic ReciprocityQuadratic Reciprocity(pq)(qp)=(1)p12q12\left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2}\cdot\frac{q-1}{2}}Relationship between solvability of quadratic congruences for two odd primesRead more → — testing reciprocity for composite moduli uses it directly. The Legendre SymbolLegendre Symbol(ap)=a(p1)/2modp\left(\frac{a}{p}\right) = a^{(p-1)/2} \bmod pThe Legendre symbol (a|p) encodes whether a is a quadratic residue mod a prime pRead more → is the prime-modulus special case.

Lean4 Proof

open scoped NumberTheorySymbols in
/-- The Jacobi symbol J(a | 1) equals 1 for all integers a.
    Direct alias of `jacobiSym.one_right`. -/
theorem jacobi_one_right (a : ) : J(a | 1) = 1 :=
  jacobiSym.one_right a