Wilson's theorem. #
This file contains a proof of Wilson's theorem.
The heavy lifting is mostly done by the previous wilsons_lemma,
but here we also prove the other logical direction.
This could be generalized to similar results about finite abelian groups.
Main results #
ZMod.wilsons_lemma: the value of(p - 1)!modulo a primep.Nat.prime_iff_fac_equiv_neg_one: that value characterises primality.ZMod.factorial_eq_neg_one_pow_mul_half_factorial_sqexpresses(p - 1)!using the square of the half-factorial whenpis odd.ZMod.half_factorial_sq_eq_neg_onegives the half-factorial as an explicit square root of-1modulo a prime not congruent to three modulo four.
References #
TODO #
- Give
wilsons_lemmaa descriptive name.
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.
@[simp]