The areas / V12. Number theory
Mathlib.NumberTheory.Wilson
6 declarations. Mathlib docs · Source
theorem ZMod.factorial_eq_neg_one_pow_mul_half_factorial_sq E1 #
∀ {p : ℕ}, Odd p → ↑(p - 1).factorial = (-1) ^ ((p - 1) / 2) * ↑((p - 1) / 2).factorial ^ 2
If p is odd, pairing each factor above (p - 1) / 2 with its negative gives
(p - 1)! = (-1) ^ ((p - 1) / 2) * (((p - 1) / 2)!) ^ 2 in ZMod p.
theorem ZMod.wilsons_lemma E3 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)], ↑(p - 1).factorial = -1
Wilson's Lemma: the product of 1, ..., p-1 is -1 modulo p.
theorem ZMod.half_factorial_sq_eq_neg_one E1 #
∀ {p : ℕ} [inst : Fact (Nat.Prime p)], p % 4 ≠ 3 → ↑((p - 1) / 2).factorial ^ 2 = -1
Let p be prime with p % 4 ≠ 3. Then ((p - 1) / 2)! is a specified square root of -1
in ZMod p.
theorem ZMod.prod_Ico_one_prime E0 #
∀ (p : ℕ) [inst : Fact (Nat.Prime p)], ∏ x ∈ Finset.Ico 1 p, ↑x = -1
theorem Nat.prime_of_fac_equiv_neg_one E1 #
∀ {n : ℕ}, ↑(n - 1).factorial = -1 → n ≠ 1 → Nat.Prime n
For n ≠ 1, (n-1)! is congruent to -1 modulo n only if n is prime.
theorem Nat.prime_iff_fac_equiv_neg_one E1 #
∀ {n : ℕ}, n ≠ 1 → (Nat.Prime n ↔ ↑(n - 1).factorial = -1)
Wilson's Theorem: For n ≠ 1, (n-1)! is congruent to -1 modulo n iff n is prime.