The areas / V12. Number theory
Mathlib.NumberTheory.LegendreSymbol.Basic
20 declarations. Mathlib docs · Source
Legendre symbol
This file contains results about Legendre symbols.
We define the Legendre symbol $\Bigl(\frac{a}{p}\Bigr)$ as legendreSym p a.
Note the order of arguments! The advantage of this form is that then legendreSym p
is a multiplicative map.
The Legendre symbol is used to define the Jacobi symbol, jacobiSym a b, for integers a
and (odd) natural numbers b, which extends the Legendre symbol.
Main results
We also prove the supplementary laws that give conditions for when -1
is a square modulo a prime p:
legendreSym.at_neg_one and ZMod.exists_sq_eq_neg_one_iff for -1.
See NumberTheory.LegendreSymbol.QuadraticReciprocity for the conditions when 2 and -2
are squares:
legendreSym.at_two and ZMod.exists_sq_eq_two_iff for 2,
legendreSym.at_neg_two and ZMod.exists_sq_eq_neg_two_iff for -2.
Tags
quadratic residue, quadratic nonresidue, Legendre symbol
Definition of the Legendre symbol and basic properties
Applications to binary quadratic forms
The value of the Legendre symbol at -1
See jacobiSym.at_neg_one for the corresponding statement for the Jacobi symbol.
theorem ZMod.euler_criterion_units E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] (x : (ZMod p)ˣ), (∃ y, y ^ 2 = x) ↔ x ^ (p / 2) = 1
Euler's Criterion: A unit x of ZMod p is a square if and only if x ^ (p / 2) = 1.
theorem ZMod.euler_criterion E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] {a : ZMod p}, a ≠ 0 → (IsSquare a ↔ a ^ (p / 2) = 1)
Euler's Criterion: a nonzero a : ZMod p is a square if and only if x ^ (p / 2) = 1.
theorem ZMod.pow_div_two_eq_neg_one_or_one E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] {a : ZMod p}, a ≠ 0 → a ^ (p / 2) = 1 ∨ a ^ (p / 2) = -1
If a : ZMod p is nonzero, then a^(p/2) is either 1 or -1.
def legendreSym E3 #
(p : ℕ) → [Fact (Nat.Prime p)] → ℤ → ℤ
The Legendre symbol of a : ℤ and a prime p, legendreSym p a,
is an integer defined as
0ifais0modulop;1ifais a nonzero square modulop-1otherwise.
Note the order of the arguments! The advantage of the order chosen here is
that legendreSym p is a multiplicative function ℤ → ℤ.
theorem legendreSym.at_zero E0 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)], legendreSym p 0 = 0
theorem legendreSym.at_one E0 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)], legendreSym p 1 = 1
theorem legendreSym.mul E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] (a b : ℤ), legendreSym p (a * b) = legendreSym p a * legendreSym p b
The Legendre symbol is multiplicative in a for p fixed.
def legendreSym.hom E1 #
(p : ℕ) → [Fact (Nat.Prime p)] → ℤ →*₀ ℤ
The Legendre symbol is a homomorphism of monoids with zero.
theorem legendreSym.hom_apply E0 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] (a : ℤ), (legendreSym.hom p) a = legendreSym p a
theorem legendreSym.sq_one E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] {a : ℤ}, ↑a ≠ 0 → legendreSym p a ^ 2 = 1
The square of the symbol is 1 if p ∤ a.
theorem legendreSym.sq_one' E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] {a : ℤ}, ↑a ≠ 0 → legendreSym p (a ^ 2) = 1
The Legendre symbol of a^2 at p is 1 if p ∤ a.
theorem legendreSym.mod E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)] (a : ℤ), legendreSym p a = legendreSym p (a % ↑p)
The Legendre symbol depends only on a mod p.
theorem legendreSym.card_sqrts E1 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)], p ≠ 2 → ∀ (a : ℤ), ↑{x | x ^ 2 = ↑a}.toFinset.card = legendreSym p a + 1
The number of square roots of a modulo p is determined by the Legendre symbol.
theorem legendreSym.prime_dvd_of_eq_neg_one E1 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)] {a : ℤ},
legendreSym p a = -1 → ∀ {x y : ℤ}, ↑p ∣ x ^ 2 - a * y ^ 2 → ↑p ∣ x ∧ ↑p ∣ y
If legendreSym p a = -1 and p divides x^2 - a*y^2, then p must divide x and y.
theorem legendreSym.at_neg_one E3 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)], p ≠ 2 → legendreSym p (-1) = ZMod.χ₄ ↑p
legendreSym p (-1) is given by χ₄ p.
theorem legendreSym.at_neg E1 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)], p ≠ 2 → ∀ (a : ℤ), legendreSym p (-a) = ZMod.χ₄ ↑p * legendreSym p a
The value of the Legendre symbol at -a is χ₄ p times the value at a.
theorem ZMod.exists_sq_eq_neg_one_iff E3 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)], IsSquare (-1) ↔ p % 4 ≠ 3
-1 is a square in ZMod p iff p is not congruent to 3 mod 4.
theorem ZMod.mod_four_ne_three_of_sq_eq_neg_one E1 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)] {y : ZMod p}, y ^ 2 = -1 → p % 4 ≠ 3
theorem ZMod.mod_four_ne_three_of_sq_eq_neg_sq' E1 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)] {x y : ZMod p}, y ≠ 0 → x ^ 2 = -y ^ 2 → p % 4 ≠ 3
If two nonzero squares are negatives of each other in ZMod p, then p % 4 ≠ 3.
theorem ZMod.mod_four_ne_three_of_sq_eq_neg_sq E1 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)] {x y : ZMod p}, x ≠ 0 → x ^ 2 = -y ^ 2 → p % 4 ≠ 3