Metamath Proof Explorer


Theorem wilthimp

Description: The forward implication of Wilson's theorem wilth (see wilthlem3 ), expressed using the modulo operation: For any prime p we have ( p - 1 ) ! == - 1 (mod p ), see theorem 5.24 in ApostolNT p. 116. (Contributed by AV, 21-Jul-2021)

Ref Expression
Assertion wilthimp P P 1 ! mod P = -1 mod P

Proof

Step Hyp Ref Expression
1 wilth P P 2 P P 1 ! + 1
2 eluz2nn P 2 P
3 nnm1nn0 P P 1 0
4 2 3 syl P 2 P 1 0
5 4 faccld P 2 P 1 !
6 5 nnzd P 2 P 1 !
7 6 peano2zd P 2 P 1 ! + 1
8 dvdsval3 P P 1 ! + 1 P P 1 ! + 1 P 1 ! + 1 mod P = 0
9 2 7 8 syl2anc P 2 P P 1 ! + 1 P 1 ! + 1 mod P = 0
10 9 biimpar P 2 P 1 ! + 1 mod P = 0 P P 1 ! + 1
11 5 nncnd P 2 P 1 !
12 1cnd P 2 1
13 11 12 jca P 2 P 1 ! 1
14 13 adantr P 2 P 1 ! + 1 mod P = 0 P 1 ! 1
15 subneg P 1 ! 1 P 1 ! -1 = P 1 ! + 1
16 14 15 syl P 2 P 1 ! + 1 mod P = 0 P 1 ! -1 = P 1 ! + 1
17 10 16 breqtrrd P 2 P 1 ! + 1 mod P = 0 P P 1 ! -1
18 neg1z 1
19 18 a1i P 2 1
20 2 6 19 3jca P 2 P P 1 ! 1
21 20 adantr P 2 P 1 ! + 1 mod P = 0 P P 1 ! 1
22 moddvds P P 1 ! 1 P 1 ! mod P = -1 mod P P P 1 ! -1
23 21 22 syl P 2 P 1 ! + 1 mod P = 0 P 1 ! mod P = -1 mod P P P 1 ! -1
24 17 23 mpbird P 2 P 1 ! + 1 mod P = 0 P 1 ! mod P = -1 mod P
25 24 ex P 2 P 1 ! + 1 mod P = 0 P 1 ! mod P = -1 mod P
26 9 25 sylbid P 2 P P 1 ! + 1 P 1 ! mod P = -1 mod P
27 26 imp P 2 P P 1 ! + 1 P 1 ! mod P = -1 mod P
28 1 27 sylbi P P 1 ! mod P = -1 mod P