Metamath Proof Explorer


Theorem wilth

Description: Wilson's theorem. A number is prime iff it is greater than or equal to 2 and ( N - 1 ) ! is congruent to -u 1 , mod N , or alternatively if N divides ( N - 1 ) ! + 1 . In this part of the proof we show the relatively simple reverse implication; see wilthlem3 for the forward implication. This is Metamath 100 proof #51. (Contributed by Mario Carneiro, 24-Jan-2015) (Proof shortened by Fan Zheng, 16-Jun-2016)

Ref Expression
Assertion wilth N N 2 N N 1 ! + 1

Proof

Step Hyp Ref Expression
1 prmuz2 N N 2
2 eqid mulGrp fld = mulGrp fld
3 eleq2w z = x N 1 z N 1 x
4 oveq1 n = y n N 2 = y N 2
5 4 oveq1d n = y n N 2 mod N = y N 2 mod N
6 5 eleq1d n = y n N 2 mod N z y N 2 mod N z
7 6 cbvralvw n z n N 2 mod N z y z y N 2 mod N z
8 eleq2w z = x y N 2 mod N z y N 2 mod N x
9 8 raleqbi1dv z = x y z y N 2 mod N z y x y N 2 mod N x
10 7 9 syl5bb z = x n z n N 2 mod N z y x y N 2 mod N x
11 3 10 anbi12d z = x N 1 z n z n N 2 mod N z N 1 x y x y N 2 mod N x
12 11 cbvrabv z 𝒫 1 N 1 | N 1 z n z n N 2 mod N z = x 𝒫 1 N 1 | N 1 x y x y N 2 mod N x
13 2 12 wilthlem3 N N N 1 ! + 1
14 1 13 jca N N 2 N N 1 ! + 1
15 simpl N 2 N N 1 ! + 1 N 2
16 elfzuz n 2 N 1 n 2
17 16 adantl N 2 N N 1 ! + 1 n 2 N 1 n 2
18 eluz2nn n 2 n
19 17 18 syl N 2 N N 1 ! + 1 n 2 N 1 n
20 elfzuz3 n 2 N 1 N 1 n
21 20 adantl N 2 N N 1 ! + 1 n 2 N 1 N 1 n
22 dvdsfac n N 1 n n N 1 !
23 19 21 22 syl2anc N 2 N N 1 ! + 1 n 2 N 1 n N 1 !
24 eluz2nn N 2 N
25 24 ad2antrr N 2 N N 1 ! + 1 n 2 N 1 N
26 nnm1nn0 N N 1 0
27 faccl N 1 0 N 1 !
28 25 26 27 3syl N 2 N N 1 ! + 1 n 2 N 1 N 1 !
29 28 nnzd N 2 N N 1 ! + 1 n 2 N 1 N 1 !
30 eluz2gt1 n 2 1 < n
31 17 30 syl N 2 N N 1 ! + 1 n 2 N 1 1 < n
32 ndvdsp1 N 1 ! n 1 < n n N 1 ! ¬ n N 1 ! + 1
33 29 19 31 32 syl3anc N 2 N N 1 ! + 1 n 2 N 1 n N 1 ! ¬ n N 1 ! + 1
34 23 33 mpd N 2 N N 1 ! + 1 n 2 N 1 ¬ n N 1 ! + 1
35 simplr N 2 N N 1 ! + 1 n 2 N 1 N N 1 ! + 1
36 19 nnzd N 2 N N 1 ! + 1 n 2 N 1 n
37 25 nnzd N 2 N N 1 ! + 1 n 2 N 1 N
38 29 peano2zd N 2 N N 1 ! + 1 n 2 N 1 N 1 ! + 1
39 dvdstr n N N 1 ! + 1 n N N N 1 ! + 1 n N 1 ! + 1
40 36 37 38 39 syl3anc N 2 N N 1 ! + 1 n 2 N 1 n N N N 1 ! + 1 n N 1 ! + 1
41 35 40 mpan2d N 2 N N 1 ! + 1 n 2 N 1 n N n N 1 ! + 1
42 34 41 mtod N 2 N N 1 ! + 1 n 2 N 1 ¬ n N
43 42 ralrimiva N 2 N N 1 ! + 1 n 2 N 1 ¬ n N
44 isprm3 N N 2 n 2 N 1 ¬ n N
45 15 43 44 sylanbrc N 2 N N 1 ! + 1 N
46 14 45 impbii N N 2 N N 1 ! + 1