File: Mathlib/NumberTheory/LegendreSymbol/Basic.lean

full_name: ZMod.euler_criterion_units
code: /-- Euler's Criterion: A unit `x` of `ZMod p` is a square if and only if `x ^ (p / 2) = 1`. -/
theorem euler_criterion_units (x : (ZMod p)ˣ) : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ x ^ (p / 2) = 1 
goal: (∃ y, y ^ 2 = x) ↔ x ^ (p / 2) = 1

full_name: ZMod.euler_criterion
code: /-- Euler's Criterion: a nonzero `a : ZMod p` is a square if and only if `x ^ (p / 2) = 1`. -/
theorem euler_criterion {a : ZMod p} (ha : a ≠ 0) : IsSquare (a : ZMod p) ↔ a ^ (p / 2) = 1 
goal: IsSquare a ↔ a ^ (p / 2) = 1

full_name: ZMod.pow_div_two_eq_neg_one_or_one
code: /-- If `a : ZMod p` is nonzero, then `a^(p/2)` is either `1` or `-1`. -/
theorem pow_div_two_eq_neg_one_or_one {a : ZMod p} (ha : a ≠ 0) :
    a ^ (p / 2) = 1 ∨ a ^ (p / 2) = -1 
goal: a ^ (p / 2) = 1 ∨ a ^ (p / 2) = -1

full_name: legendreSym
code: /-- The Legendre symbol of `a : ℤ` and a prime `p`, `legendreSym p a`,
is an integer defined as

* `0` if `a` is `0` modulo `p`;
* `1` if `a` is a nonzero square modulo `p`
* `-1` otherwise.

Note the order of the arguments! The advantage of the order chosen here is
that `legendreSym p` is a multiplicative function `ℤ → ℤ`.
-/
def legendreSym (a : ℤ) : ℤ 
goal: ℤ

full_name: legendreSym.eq_pow
code: /-- We have the congruence `legendreSym p a ≡ a ^ (p / 2) mod p`. -/
theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) 
goal: ↑(legendreSym p a) = ↑a ^ (p / 2)

full_name: legendreSym.eq_one_or_neg_one
code: /-- If `p ∤ a`, then `legendreSym p a` is `1` or `-1`. -/
theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) :
    legendreSym p a = 1 ∨ legendreSym p a = -1 
goal: legendreSym p a = 1 ∨ legendreSym p a = -1

full_name: legendreSym.eq_neg_one_iff_not_one
code: theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) :
    legendreSym p a = -1 ↔ ¬legendreSym p a = 1 
goal: legendreSym p a = -1 ↔ ¬legendreSym p a = 1

full_name: legendreSym.eq_zero_iff
code: /-- The Legendre symbol of `p` and `a` is zero iff `p ∣ a`. -/
theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 
goal: legendreSym p a = 0 ↔ ↑a = 0

full_name: legendreSym.at_zero
code: @[simp]
theorem at_zero : legendreSym p 0 = 0 
goal: legendreSym p 0 = 0

full_name: legendreSym.at_one
code: @[simp]
theorem at_one : legendreSym p 1 = 1 
goal: legendreSym p 1 = 1

full_name: legendreSym.mul
code: /-- The Legendre symbol is multiplicative in `a` for `p` fixed. -/
protected theorem mul (a b : ℤ) : legendreSym p (a * b) = legendreSym p a * legendreSym p b 
goal: legendreSym p (a * b) = legendreSym p a * legendreSym p b

full_name: legendreSym.hom
code: /-- The Legendre symbol is a homomorphism of monoids with zero. -/
@[simps]
def hom : ℤ →*₀ ℤ 
goal: ℤ →*₀ ℤ

full_name: legendreSym.hom_apply
code: /-- The Legendre symbol is a homomorphism of monoids with zero. -/
@[simps]
def hom : ℤ →*₀ ℤ 
goal: (legendreSym.hom p) a = legendreSym p a

full_name: legendreSym.sq_one
code: /-- The square of the symbol is 1 if `p ∤ a`. -/
theorem sq_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a ^ 2 = 1 
goal: legendreSym p a ^ 2 = 1

full_name: legendreSym.sq_one'
code: /-- The Legendre symbol of `a^2` at `p` is 1 if `p ∤ a`. -/
theorem sq_one' {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p (a ^ 2) = 1 
goal: legendreSym p (a ^ 2) = 1

full_name: legendreSym.mod
code: /-- The Legendre symbol depends only on `a` mod `p`. -/
protected theorem mod (a : ℤ) : legendreSym p a = legendreSym p (a % p) 
goal: legendreSym p a = legendreSym p (a % ↑p)

full_name: legendreSym.eq_one_iff
code: /-- When `p ∤ a`, then `legendreSym p a = 1` iff `a` is a square mod `p`. -/
theorem eq_one_iff {a : ℤ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) 
goal: legendreSym p a = 1 ↔ IsSquare ↑a

full_name: legendreSym.eq_one_iff'
code: theorem eq_one_iff' {a : ℕ} (ha0 : (a : ZMod p) ≠ 0) :
    legendreSym p a = 1 ↔ IsSquare (a : ZMod p) 
goal: legendreSym p ↑a = 1 ↔ IsSquare ↑a

full_name: legendreSym.eq_neg_one_iff
code: /-- `legendreSym p a = -1` iff `a` is a nonsquare mod `p`. -/
theorem eq_neg_one_iff {a : ℤ} : legendreSym p a = -1 ↔ ¬IsSquare (a : ZMod p) 
goal: legendreSym p a = -1 ↔ ¬IsSquare ↑a

full_name: legendreSym.eq_neg_one_iff'
code: theorem eq_neg_one_iff' {a : ℕ} : legendreSym p a = -1 ↔ ¬IsSquare (a : ZMod p) 
goal: legendreSym p ↑a = -1 ↔ ¬IsSquare ↑a

full_name: legendreSym.card_sqrts
code: /-- The number of square roots of `a` modulo `p` is determined by the Legendre symbol. -/
theorem card_sqrts (hp : p ≠ 2) (a : ℤ) :
    ↑{x : ZMod p | x ^ 2 = a}.toFinset.card = legendreSym p a + 1 
goal: ↑{x | x ^ 2 = ↑a}.toFinset.card = legendreSym p a + 1

full_name: legendreSym.eq_one_of_sq_sub_mul_sq_eq_zero
code: /-- The Legendre symbol `legendreSym p a = 1` if there is a solution in `ℤ/pℤ`
of the equation `x^2 - a*y^2 = 0` with `y ≠ 0`. -/
theorem eq_one_of_sq_sub_mul_sq_eq_zero {p : ℕ} [Fact p.Prime] {a : ℤ} (ha : (a : ZMod p) ≠ 0)
    {x y : ZMod p} (hy : y ≠ 0) (hxy : x ^ 2 - a * y ^ 2 = 0) : legendreSym p a = 1 
goal: legendreSym p a = 1

full_name: legendreSym.eq_one_of_sq_sub_mul_sq_eq_zero'
code: /-- The Legendre symbol `legendreSym p a = 1` if there is a solution in `ℤ/pℤ`
of the equation `x^2 - a*y^2 = 0` with `x ≠ 0`. -/
theorem eq_one_of_sq_sub_mul_sq_eq_zero' {p : ℕ} [Fact p.Prime] {a : ℤ} (ha : (a : ZMod p) ≠ 0)
    {x y : ZMod p} (hx : x ≠ 0) (hxy : x ^ 2 - a * y ^ 2 = 0) : legendreSym p a = 1 
goal: legendreSym p a = 1

full_name: legendreSym.eq_zero_mod_of_eq_neg_one
code: /-- If `legendreSym p a = -1`, then the only solution of `x^2 - a*y^2 = 0` in `ℤ/pℤ`
is the trivial one. -/
theorem eq_zero_mod_of_eq_neg_one {p : ℕ} [Fact p.Prime] {a : ℤ} (h : legendreSym p a = -1)
    {x y : ZMod p} (hxy : x ^ 2 - a * y ^ 2 = 0) : x = 0 ∧ y = 0 
goal: x = 0 ∧ y = 0

full_name: legendreSym.prime_dvd_of_eq_neg_one
code: /-- If `legendreSym p a = -1` and `p` divides `x^2 - a*y^2`, then `p` must divide `x` and `y`. -/
theorem prime_dvd_of_eq_neg_one {p : ℕ} [Fact p.Prime] {a : ℤ} (h : legendreSym p a = -1) {x y : ℤ}
    (hxy : (p : ℤ) ∣ x ^ 2 - a * y ^ 2) : ↑p ∣ x ∧ ↑p ∣ y 
goal: ↑p ∣ x ∧ ↑p ∣ y

full_name: legendreSym.at_neg_one
code: /-- `legendreSym p (-1)` is given by `χ₄ p`. -/
theorem legendreSym.at_neg_one (hp : p ≠ 2) : legendreSym p (-1) = χ₄ p 
goal: legendreSym p (-1) = ZMod.χ₄ ↑p

full_name: ZMod.exists_sq_eq_neg_one_iff
code: /-- `-1` is a square in `ZMod p` iff `p` is not congruent to `3` mod `4`. -/
theorem exists_sq_eq_neg_one_iff : IsSquare (-1 : ZMod p) ↔ p % 4 ≠ 3 
goal: IsSquare (-1) ↔ p % 4 ≠ 3

full_name: ZMod.mod_four_ne_three_of_sq_eq_neg_one
code: theorem mod_four_ne_three_of_sq_eq_neg_one {y : ZMod p} (hy : y ^ 2 = -1) : p % 4 ≠ 3 
goal: p % 4 ≠ 3

full_name: ZMod.mod_four_ne_three_of_sq_eq_neg_sq'
code: /-- If two nonzero squares are negatives of each other in `ZMod p`, then `p % 4 ≠ 3`. -/
theorem mod_four_ne_three_of_sq_eq_neg_sq' {x y : ZMod p} (hy : y ≠ 0) (hxy : x ^ 2 = -y ^ 2) :
    p % 4 ≠ 3 
goal: p % 4 ≠ 3

full_name: ZMod.mod_four_ne_three_of_sq_eq_neg_sq
code: theorem mod_four_ne_three_of_sq_eq_neg_sq {x y : ZMod p} (hx : x ≠ 0) (hxy : x ^ 2 = -y ^ 2) :
    p % 4 ≠ 3 
goal: p % 4 ≠ 3