File: Mathlib/FieldTheory/Finite/Basic.lean

full_name: _aux_Mathlib_FieldTheory_Finite_Basic___unexpand_Fintype_card_1
code: local notation "q" => Fintype.card K
goal: Lean.PrettyPrinter.Unexpander

full_name: _aux_Mathlib_FieldTheory_Finite_Basic___macroRules_termQ_1
code: local notation "q" => Fintype.card K
goal: Lean.Macro

full_name: FiniteField.card_image_polynomial_eval
code: /-- The cardinality of a field is at most `n` times the cardinality of the image of a degree `n`
  polynomial -/
theorem card_image_polynomial_eval [DecidableEq R] [Fintype R] {p : R[X]} (hp : 0 < p.degree) :
    Fintype.card R ≤ natDegree p * (univ.image fun x => eval x p).card 
goal: Fintype.card R ≤ p.natDegree * (Finset.image (fun x => Polynomial.eval x p) Finset.univ).card

full_name: FiniteField.exists_root_sum_quadratic
code: /-- If `f` and `g` are quadratic polynomials, then the `f.eval a + g.eval b = 0` has a solution. -/
theorem exists_root_sum_quadratic [Fintype R] {f g : R[X]} (hf2 : degree f = 2) (hg2 : degree g = 2)
    (hR : Fintype.card R % 2 = 1) : ∃ a b, f.eval a + g.eval b = 0 
goal: ∃ a b, Polynomial.eval a f + Polynomial.eval b g = 0

full_name: FiniteField.prod_univ_units_id_eq_neg_one
code: theorem prod_univ_units_id_eq_neg_one [CommRing K] [IsDomain K] [Fintype Kˣ] :
    ∏ x : Kˣ, x = (-1 : Kˣ) 
goal: ∏ x : Kˣ, x = -1

full_name: FiniteField.card_cast_subgroup_card_ne_zero
code: theorem card_cast_subgroup_card_ne_zero [Ring K] [NoZeroDivisors K] [Nontrivial K]
    (G : Subgroup Kˣ) [Fintype G] : (Fintype.card G : K) ≠ 0 
goal: ↑(Fintype.card ↥G) ≠ 0

full_name: FiniteField.sum_subgroup_units_eq_zero
code: /-- The sum of a nontrivial subgroup of the units of a field is zero. -/
theorem sum_subgroup_units_eq_zero [Ring K] [NoZeroDivisors K]
    {G : Subgroup Kˣ} [Fintype G] (hg : G ≠ ⊥) :
    ∑ x : G, (x.val : K) = 0 
goal: ∑ x : ↥G, ↑↑x = 0

full_name: FiniteField.sum_subgroup_units
code: /-- The sum of a subgroup of the units of a field is 1 if the subgroup is trivial and 1 otherwise -/
@[simp]
theorem sum_subgroup_units [Ring K] [NoZeroDivisors K]
    {G : Subgroup Kˣ} [Fintype G] [Decidable (G = ⊥)] :
    ∑ x : G, (x.val : K) = if G = ⊥ then 1 else 0 
goal: ∑ x : ↥G, ↑↑x = if G = ⊥ then 1 else 0

full_name: FiniteField.sum_subgroup_pow_eq_zero
code: @[simp]
theorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K]
    {G : Subgroup Kˣ} [Fintype G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) :
    ∑ x : G, ((x : Kˣ) : K) ^ k = 0 
goal: ∑ x : ↥G, ↑↑x ^ k = 0

full_name: FiniteField.pow_card_sub_one_eq_one
code: theorem pow_card_sub_one_eq_one (a : K) (ha : a ≠ 0) : a ^ (q - 1) = 1 
goal: a ^ (q - 1) = 1

full_name: FiniteField.pow_card
code: theorem pow_card (a : K) : a ^ q = a 
goal: a ^ q = a

full_name: FiniteField.pow_card_pow
code: theorem pow_card_pow (n : ℕ) (a : K) : a ^ q ^ n = a 
goal: a ^ q ^ n = a

full_name: FiniteField.card
code: theorem card (p : ℕ) [CharP K p] : ∃ n : ℕ+, Nat.Prime p ∧ q = p ^ (n : ℕ) 
goal: ∃ n, Nat.Prime p ∧ q = p ^ ↑n

full_name: FiniteField.card'
code: theorem card' : ∃ (p : ℕ) (n : ℕ+), Nat.Prime p ∧ Fintype.card K = p ^ (n : ℕ) 
goal: ∃ p n, Nat.Prime p ∧ q = p ^ ↑n

full_name: FiniteField.cast_card_eq_zero
code: theorem cast_card_eq_zero : (q : K) = 0 
goal: ↑q = 0

full_name: FiniteField.forall_pow_eq_one_iff
code: theorem forall_pow_eq_one_iff (i : ℕ) : (∀ x : Kˣ, x ^ i = 1) ↔ q - 1 ∣ i 
goal: (∀ (x : Kˣ), x ^ i = 1) ↔ q - 1 ∣ i

full_name: FiniteField.sum_pow_units
code: /-- The sum of `x ^ i` as `x` ranges over the units of a finite field of cardinality `q`
is equal to `0` unless `(q - 1) ∣ i`, in which case the sum is `q - 1`. -/
theorem sum_pow_units [DecidableEq K] (i : ℕ) :
    (∑ x : Kˣ, (x ^ i : K)) = if q - 1 ∣ i then -1 else 0 
goal: ∑ x : Kˣ, ↑x ^ i = if q - 1 ∣ i then -1 else 0

full_name: FiniteField.sum_pow_lt_card_sub_one
code: /-- The sum of `x ^ i` as `x` ranges over a finite field of cardinality `q`
is equal to `0` if `i < q - 1`. -/
theorem sum_pow_lt_card_sub_one (i : ℕ) (h : i < q - 1) : ∑ x : K, x ^ i = 0 
goal: ∑ x : K, x ^ i = 0

full_name: FiniteField.X_pow_card_sub_X_natDegree_eq
code: theorem X_pow_card_sub_X_natDegree_eq (hp : 1 < p) : (X ^ p - X : K'[X]).natDegree = p 
goal: (Polynomial.X ^ p - Polynomial.X).natDegree = p

full_name: FiniteField.X_pow_card_pow_sub_X_natDegree_eq
code: theorem X_pow_card_pow_sub_X_natDegree_eq (hn : n ≠ 0) (hp : 1 < p) :
    (X ^ p ^ n - X : K'[X]).natDegree = p ^ n 
goal: (Polynomial.X ^ p ^ n - Polynomial.X).natDegree = p ^ n

full_name: FiniteField.X_pow_card_sub_X_ne_zero
code: theorem X_pow_card_sub_X_ne_zero (hp : 1 < p) : (X ^ p - X : K'[X]) ≠ 0 
goal: Polynomial.X ^ p - Polynomial.X ≠ 0

full_name: FiniteField.X_pow_card_pow_sub_X_ne_zero
code: theorem X_pow_card_pow_sub_X_ne_zero (hn : n ≠ 0) (hp : 1 < p) : (X ^ p ^ n - X : K'[X]) ≠ 0 
goal: Polynomial.X ^ p ^ n - Polynomial.X ≠ 0

full_name: FiniteField.roots_X_pow_card_sub_X
code: theorem roots_X_pow_card_sub_X : roots (X ^ q - X : K[X]) = Finset.univ.val 
goal: (Polynomial.X ^ q - Polynomial.X).roots = Finset.univ.val

full_name: FiniteField.frobenius_pow
code: theorem frobenius_pow {p : ℕ} [Fact p.Prime] [CharP K p] {n : ℕ} (hcard : q = p ^ n) :
    frobenius K p ^ n = 1 
goal: frobenius K p ^ n = 1

full_name: FiniteField.expand_card
code: theorem expand_card (f : K[X]) : expand K q f = f ^ q 
goal: (Polynomial.expand K q) f = f ^ q

full_name: ZMod.sq_add_sq
code: theorem sq_add_sq (p : ℕ) [hp : Fact p.Prime] (x : ZMod p) : ∃ a b : ZMod p, a ^ 2 + b ^ 2 = x 
goal: ∃ a b, a ^ 2 + b ^ 2 = x

full_name: Nat.sq_add_sq_zmodEq
code: /-- If `p` is a prime natural number and `x` is an integer number, then there exist natural numbers
`a ≤ p / 2` and `b ≤ p / 2` such that `a ^ 2 + b ^ 2 ≡ x [ZMOD p]`. This is a version of
`ZMod.sq_add_sq` with estimates on `a` and `b`. -/
theorem Nat.sq_add_sq_zmodEq (p : ℕ) [Fact p.Prime] (x : ℤ) :
    ∃ a b : ℕ, a ≤ p / 2 ∧ b ≤ p / 2 ∧ (a : ℤ) ^ 2 + (b : ℤ) ^ 2 ≡ x [ZMOD p] 
goal: ∃ a b, a ≤ p / 2 ∧ b ≤ p / 2 ∧ ↑a ^ 2 + ↑b ^ 2 ≡ x [ZMOD ↑p]

full_name: Nat.sq_add_sq_modEq
code: /-- If `p` is a prime natural number and `x` is a natural number, then there exist natural numbers
`a ≤ p / 2` and `b ≤ p / 2` such that `a ^ 2 + b ^ 2 ≡ x [MOD p]`. This is a version of
`ZMod.sq_add_sq` with estimates on `a` and `b`. -/
theorem Nat.sq_add_sq_modEq (p : ℕ) [Fact p.Prime] (x : ℕ) :
    ∃ a b : ℕ, a ≤ p / 2 ∧ b ≤ p / 2 ∧ a ^ 2 + b ^ 2 ≡ x [MOD p] 
goal: ∃ a b, a ≤ p / 2 ∧ b ≤ p / 2 ∧ a ^ 2 + b ^ 2 ≡ x [MOD p]

full_name: CharP.sq_add_sq
code: theorem sq_add_sq (R : Type*) [CommRing R] [IsDomain R] (p : ℕ) [NeZero p] [CharP R p] (x : ℤ) :
    ∃ a b : ℕ, ((a : R) ^ 2 + (b : R) ^ 2) = x 
goal: ∃ a b, ↑a ^ 2 + ↑b ^ 2 = ↑x

full_name: ZMod.pow_totient
code: /-- The **Fermat-Euler totient theorem**. `Nat.ModEq.pow_totient` is an alternative statement
  of the same theorem. -/
@[simp]
theorem ZMod.pow_totient {n : ℕ} (x : (ZMod n)ˣ) : x ^ φ n = 1 
goal: x ^ φ n = 1

full_name: Nat.ModEq.pow_totient
code: /-- The **Fermat-Euler totient theorem**. `ZMod.pow_totient` is an alternative statement
  of the same theorem. -/
theorem Nat.ModEq.pow_totient {x n : ℕ} (h : Nat.Coprime x n) : x ^ φ n ≡ 1 [MOD n] 
goal: x ^ φ n ≡ 1 [MOD n]

full_name: instFiniteZModUnits
code: /-- For each `n ≥ 0`, the unit group of `ZMod n` is finite. -/
instance instFiniteZModUnits : (n : ℕ) → Finite (ZMod n)ˣ

goal: Finite (ZMod n)ˣ

full_name: card_eq_pow_finrank
code: theorem card_eq_pow_finrank [Fintype V] : Fintype.card V = q ^ FiniteDimensional.finrank K V 
goal: Fintype.card V = q ^ FiniteDimensional.finrank K V

full_name: ZMod.pow_card
code: /-- A variation on Fermat's little theorem. See `ZMod.pow_card_sub_one_eq_one` -/
@[simp]
theorem pow_card {p : ℕ} [Fact p.Prime] (x : ZMod p) : x ^ p = x 
goal: x ^ p = x

full_name: ZMod.pow_card_pow
code: @[simp]
theorem pow_card_pow {n p : ℕ} [Fact p.Prime] (x : ZMod p) : x ^ p ^ n = x 
goal: x ^ p ^ n = x

full_name: ZMod.frobenius_zmod
code: @[simp]
theorem frobenius_zmod (p : ℕ) [Fact p.Prime] : frobenius (ZMod p) p = RingHom.id _ 
goal: frobenius (ZMod p) p = RingHom.id (ZMod p)

full_name: ZMod.card_units
code: theorem card_units (p : ℕ) [Fact p.Prime] : Fintype.card (ZMod p)ˣ = p - 1 
goal: Fintype.card (ZMod p)ˣ = p - 1

full_name: ZMod.units_pow_card_sub_one_eq_one
code: /-- **Fermat's Little Theorem**: for every unit `a` of `ZMod p`, we have `a ^ (p - 1) = 1`. -/
theorem units_pow_card_sub_one_eq_one (p : ℕ) [Fact p.Prime] (a : (ZMod p)ˣ) : a ^ (p - 1) = 1 
goal: a ^ (p - 1) = 1

full_name: ZMod.pow_card_sub_one_eq_one
code: /-- **Fermat's Little Theorem**: for all nonzero `a : ZMod p`, we have `a ^ (p - 1) = 1`. -/
theorem pow_card_sub_one_eq_one {p : ℕ} [Fact p.Prime] {a : ZMod p} (ha : a ≠ 0) :
    a ^ (p - 1) = 1 
goal: a ^ (p - 1) = 1

full_name: ZMod.pow_card_sub_one
code: lemma pow_card_sub_one {p : ℕ} [Fact p.Prime] (a : ZMod p) :
    a ^ (p - 1) = if a ≠ 0 then 1 else 0 
goal: a ^ (p - 1) = if a ≠ 0 then 1 else 0

full_name: ZMod.orderOf_units_dvd_card_sub_one
code: theorem orderOf_units_dvd_card_sub_one {p : ℕ} [Fact p.Prime] (u : (ZMod p)ˣ) : orderOf u ∣ p - 1 
goal: orderOf u ∣ p - 1

full_name: ZMod.orderOf_dvd_card_sub_one
code: theorem orderOf_dvd_card_sub_one {p : ℕ} [Fact p.Prime] {a : ZMod p} (ha : a ≠ 0) :
    orderOf a ∣ p - 1 
goal: orderOf a ∣ p - 1

full_name: ZMod.expand_card
code: theorem expand_card {p : ℕ} [Fact p.Prime] (f : Polynomial (ZMod p)) :
    expand (ZMod p) p f = f ^ p 
goal: (Polynomial.expand (ZMod p) p) f = f ^ p

full_name: Int.ModEq.pow_card_sub_one_eq_one
code: /-- **Fermat's Little Theorem**: for all `a : ℤ` coprime to `p`, we have
`a ^ (p - 1) ≡ 1 [ZMOD p]`. -/
theorem Int.ModEq.pow_card_sub_one_eq_one {p : ℕ} (hp : Nat.Prime p) {n : ℤ} (hpn : IsCoprime n p) :
    n ^ (p - 1) ≡ 1 [ZMOD p] 
goal: n ^ (p - 1) ≡ 1 [ZMOD ↑p]

full_name: FiniteField.isSquare_of_char_two
code: /-- In a finite field of characteristic `2`, all elements are squares. -/
theorem isSquare_of_char_two (hF : ringChar F = 2) (a : F) : IsSquare a 
goal: IsSquare a

full_name: FiniteField.exists_nonsquare
code: /-- In a finite field of odd characteristic, not every element is a square. -/
theorem exists_nonsquare (hF : ringChar F ≠ 2) : ∃ a : F, ¬IsSquare a 
goal: ∃ a, ¬IsSquare a

full_name: FiniteField.even_card_iff_char_two
code: /-- The finite field `F` has even cardinality iff it has characteristic `2`. -/
theorem even_card_iff_char_two : ringChar F = 2 ↔ Fintype.card F % 2 = 0 
goal: ringChar F = 2 ↔ Fintype.card F % 2 = 0

full_name: FiniteField.even_card_of_char_two
code: theorem even_card_of_char_two (hF : ringChar F = 2) : Fintype.card F % 2 = 0 
goal: Fintype.card F % 2 = 0

full_name: FiniteField.odd_card_of_char_ne_two
code: theorem odd_card_of_char_ne_two (hF : ringChar F ≠ 2) : Fintype.card F % 2 = 1 
goal: Fintype.card F % 2 = 1

full_name: FiniteField.pow_dichotomy
code: /-- If `F` has odd characteristic, then for nonzero `a : F`, we have that `a ^ (#F / 2) = ±1`. -/
theorem pow_dichotomy (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :
    a ^ (Fintype.card F / 2) = 1 ∨ a ^ (Fintype.card F / 2) = -1 
goal: a ^ (Fintype.card F / 2) = 1 ∨ a ^ (Fintype.card F / 2) = -1

full_name: FiniteField.unit_isSquare_iff
code: /-- A unit `a` of a finite field `F` of odd characteristic is a square
if and only if `a ^ (#F / 2) = 1`. -/
theorem unit_isSquare_iff (hF : ringChar F ≠ 2) (a : Fˣ) :
    IsSquare a ↔ a ^ (Fintype.card F / 2) = 1 
goal: IsSquare a ↔ a ^ (Fintype.card F / 2) = 1

full_name: FiniteField.isSquare_iff
code: /-- A non-zero `a : F` is a square if and only if `a ^ (#F / 2) = 1`. -/
theorem isSquare_iff (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :
    IsSquare a ↔ a ^ (Fintype.card F / 2) = 1 
goal: IsSquare a ↔ a ^ (Fintype.card F / 2) = 1