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 PP1!modP=-1modP

Proof

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