File: Mathlib/NumberTheory/LegendreSymbol/QuadraticChar/Basic.lean

full_name: quadraticCharFun
code: /-- Define the quadratic character with values in ℤ on a monoid with zero `α`.
It takes the value zero at zero; for non-zero argument `a : α`, it is `1`
if `a` is a square, otherwise it is `-1`.

This only deserves the name "character" when it is multiplicative,
e.g., when `α` is a finite field. See `quadraticCharFun_mul`.

We will later define `quadraticChar` to be a multiplicative character
of type `MulChar F ℤ`, when the domain is a finite field `F`.
-/
def quadraticCharFun (α : Type*) [MonoidWithZero α] [DecidableEq α]
    [DecidablePred (IsSquare : α → Prop)] (a : α) : ℤ 
goal: ℤ

full_name: quadraticCharFun_eq_zero_iff
code: /-- Some basic API lemmas -/
theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a = 0 
goal: quadraticCharFun F a = 0 ↔ a = 0

full_name: quadraticCharFun_zero
code: @[simp]
theorem quadraticCharFun_zero : quadraticCharFun F 0 = 0 
goal: quadraticCharFun F 0 = 0

full_name: quadraticCharFun_one
code: @[simp]
theorem quadraticCharFun_one : quadraticCharFun F 1 = 1 
goal: quadraticCharFun F 1 = 1

full_name: quadraticCharFun_eq_one_of_char_two
code: /-- If `ringChar F = 2`, then `quadraticCharFun F` takes the value `1` on nonzero elements. -/
theorem quadraticCharFun_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha : a ≠ 0) :
    quadraticCharFun F a = 1 
goal: quadraticCharFun F a = 1

full_name: quadraticCharFun_eq_pow_of_char_ne_two
code: /-- If `ringChar F` is odd, then `quadraticCharFun F a` can be computed in
terms of `a ^ (Fintype.card F / 2)`. -/
theorem quadraticCharFun_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :
    quadraticCharFun F a = if a ^ (Fintype.card F / 2) = 1 then 1 else -1 
goal: quadraticCharFun F a = if a ^ (Fintype.card F / 2) = 1 then 1 else -1

full_name: quadraticCharFun_mul
code: /-- The quadratic character is multiplicative. -/
theorem quadraticCharFun_mul (a b : F) :
    quadraticCharFun F (a * b) = quadraticCharFun F a * quadraticCharFun F b 
goal: quadraticCharFun F (a * b) = quadraticCharFun F a * quadraticCharFun F b

full_name: quadraticChar_apply
code: /-- The quadratic character as a multiplicative character. -/
@[simps]
def quadraticChar : MulChar F ℤ 
goal: (quadraticChar F) a = quadraticCharFun F a

full_name: quadraticChar
code: /-- The quadratic character as a multiplicative character. -/
@[simps]
def quadraticChar : MulChar F ℤ 
goal: MulChar F ℤ

full_name: quadraticChar_eq_zero_iff
code: /-- The value of the quadratic character on `a` is zero iff `a = 0`. -/
theorem quadraticChar_eq_zero_iff {a : F} : quadraticChar F a = 0 ↔ a = 0 
goal: (quadraticChar F) a = 0 ↔ a = 0

full_name: quadraticChar_zero
code: theorem quadraticChar_zero : quadraticChar F 0 = 0 
goal: (quadraticChar F) 0 = 0

full_name: quadraticChar_one_iff_isSquare
code: /-- For nonzero `a : F`, `quadraticChar F a = 1 ↔ IsSquare a`. -/
theorem quadraticChar_one_iff_isSquare {a : F} (ha : a ≠ 0) :
    quadraticChar F a = 1 ↔ IsSquare a 
goal: (quadraticChar F) a = 1 ↔ IsSquare a

full_name: quadraticChar_sq_one'
code: /-- The quadratic character takes the value `1` on nonzero squares. -/
theorem quadraticChar_sq_one' {a : F} (ha : a ≠ 0) : quadraticChar F (a ^ 2) = 1 
goal: (quadraticChar F) (a ^ 2) = 1

full_name: quadraticChar_sq_one
code: /-- The square of the quadratic character on nonzero arguments is `1`. -/
theorem quadraticChar_sq_one {a : F} (ha : a ≠ 0) : quadraticChar F a ^ 2 = 1 
goal: (quadraticChar F) a ^ 2 = 1

full_name: quadraticChar_dichotomy
code: /-- The quadratic character is `1` or `-1` on nonzero arguments. -/
theorem quadraticChar_dichotomy {a : F} (ha : a ≠ 0) :
    quadraticChar F a = 1 ∨ quadraticChar F a = -1 
goal: (quadraticChar F) a = 1 ∨ (quadraticChar F) a = -1

full_name: quadraticChar_eq_neg_one_iff_not_one
code: /-- The quadratic character is `1` or `-1` on nonzero arguments. -/
theorem quadraticChar_eq_neg_one_iff_not_one {a : F} (ha : a ≠ 0) :
    quadraticChar F a = -1 ↔ ¬quadraticChar F a = 1 
goal: (quadraticChar F) a = -1 ↔ ¬(quadraticChar F) a = 1

full_name: quadraticChar_neg_one_iff_not_isSquare
code: /-- For `a : F`, `quadraticChar F a = -1 ↔ ¬ IsSquare a`. -/
theorem quadraticChar_neg_one_iff_not_isSquare {a : F} : quadraticChar F a = -1 ↔ ¬IsSquare a 
goal: (quadraticChar F) a = -1 ↔ ¬IsSquare a

full_name: quadraticChar_exists_neg_one
code: /-- If `F` has odd characteristic, then `quadraticChar F` takes the value `-1`. -/
theorem quadraticChar_exists_neg_one (hF : ringChar F ≠ 2) : ∃ a, quadraticChar F a = -1 
goal: ∃ a, (quadraticChar F) a = -1

full_name: quadraticChar_exists_neg_one'
code: /-- If `F` has odd characteristic, then `quadraticChar F` takes the value `-1` on some unit. -/
lemma quadraticChar_exists_neg_one' (hF : ringChar F ≠ 2) : ∃ a : Fˣ, quadraticChar F a = -1 
goal: ∃ a, (quadraticChar F) ↑a = -1

full_name: quadraticChar_eq_one_of_char_two
code: /-- If `ringChar F = 2`, then `quadraticChar F` takes the value `1` on nonzero elements. -/
theorem quadraticChar_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha : a ≠ 0) :
    quadraticChar F a = 1 
goal: (quadraticChar F) a = 1

full_name: quadraticChar_eq_pow_of_char_ne_two
code: /-- If `ringChar F` is odd, then `quadraticChar F a` can be computed in
terms of `a ^ (Fintype.card F / 2)`. -/
theorem quadraticChar_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :
    quadraticChar F a = if a ^ (Fintype.card F / 2) = 1 then 1 else -1 
goal: (quadraticChar F) a = if a ^ (Fintype.card F / 2) = 1 then 1 else -1

full_name: quadraticChar_eq_pow_of_char_ne_two'
code: theorem quadraticChar_eq_pow_of_char_ne_two' (hF : ringChar F ≠ 2) (a : F) :
    (quadraticChar F a : F) = a ^ (Fintype.card F / 2) 
goal: ↑((quadraticChar F) a) = a ^ (Fintype.card F / 2)

full_name: quadraticChar_isQuadratic
code: /-- The quadratic character is quadratic as a multiplicative character. -/
theorem quadraticChar_isQuadratic : (quadraticChar F).IsQuadratic 
goal: (quadraticChar F).IsQuadratic

full_name: quadraticChar_ne_one
code: /-- The quadratic character is nontrivial as a multiplicative character
when the domain has odd characteristic. -/
theorem quadraticChar_ne_one (hF : ringChar F ≠ 2) : quadraticChar F ≠ 1 
goal: quadraticChar F ≠ 1

full_name: quadraticChar_isNontrivial
code: @[deprecated quadraticChar_ne_one (since := "2024-06-16")]
theorem quadraticChar_isNontrivial (hF : ringChar F ≠ 2) : (quadraticChar F).IsNontrivial 
goal: (quadraticChar F).IsNontrivial

full_name: quadraticChar_card_sqrts
code: /-- The number of solutions to `x^2 = a` is determined by the quadratic character. -/
theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
    ↑{x : F | x ^ 2 = a}.toFinset.card = quadraticChar F a + 1 
goal: ↑{x | x ^ 2 = a}.toFinset.card = (quadraticChar F) a + 1

full_name: quadraticChar_sum_zero
code: /-- The sum over the values of the quadratic character is zero when the characteristic is odd. -/
theorem quadraticChar_sum_zero (hF : ringChar F ≠ 2) : ∑ a : F, quadraticChar F a = 0 
goal: ∑ a : F, (quadraticChar F) a = 0

full_name: quadraticChar_neg_one
code: /-- The value of the quadratic character at `-1` -/
theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
    quadraticChar F (-1) = χ₄ (Fintype.card F) 
goal: (quadraticChar F) (-1) = ZMod.χ₄ ↑(Fintype.card F)

full_name: FiniteField.isSquare_neg_one_iff
code: /-- `-1` is a square in `F` iff `#F` is not congruent to `3` mod `4`. -/
theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F % 4 ≠ 3 
goal: IsSquare (-1) ↔ Fintype.card F % 4 ≠ 3