MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  wilth Unicode version

Theorem wilth 20304
Description: Wilson's theorem. A number is prime iff it is greater 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 20303 for the forward implication. (Contributed by Mario Carneiro, 24-Jan-2015.) (Proof shortened by Fan Zheng, 16-Jun-2016.)
Assertion
Ref Expression
wilth  |-  ( N  e.  Prime  <->  ( N  e.  ( ZZ>= `  2 )  /\  N  ||  ( ( ! `  ( N  -  1 ) )  +  1 ) ) )

Proof of Theorem wilth
Dummy variables  x  n  y  z are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 prmuz2 12771 . . 3  |-  ( N  e.  Prime  ->  N  e.  ( ZZ>= `  2 )
)
2 eqid 2283 . . . 4  |-  (mulGrp ` fld )  =  (mulGrp ` fld )
3 eleq2 2344 . . . . . 6  |-  ( z  =  x  ->  (
( N  -  1 )  e.  z  <->  ( N  -  1 )  e.  x ) )
4 oveq1 5826 . . . . . . . . . 10  |-  ( n  =  y  ->  (
n ^ ( N  -  2 ) )  =  ( y ^
( N  -  2 ) ) )
54oveq1d 5834 . . . . . . . . 9  |-  ( n  =  y  ->  (
( n ^ ( N  -  2 ) )  mod  N )  =  ( ( y ^ ( N  - 
2 ) )  mod 
N ) )
65eleq1d 2349 . . . . . . . 8  |-  ( n  =  y  ->  (
( ( n ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  z ) )
76cbvralv 2764 . . . . . . 7  |-  ( A. n  e.  z  (
( n ^ ( N  -  2 ) )  mod  N )  e.  z  <->  A. y  e.  z  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  z )
8 eleq2 2344 . . . . . . . 8  |-  ( z  =  x  ->  (
( ( y ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
98raleqbi1dv 2744 . . . . . . 7  |-  ( z  =  x  ->  ( A. y  e.  z 
( ( y ^
( N  -  2 ) )  mod  N
)  e.  z  <->  A. y  e.  x  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
107, 9syl5bb 248 . . . . . 6  |-  ( z  =  x  ->  ( A. n  e.  z 
( ( n ^
( N  -  2 ) )  mod  N
)  e.  z  <->  A. y  e.  x  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
113, 10anbi12d 691 . . . . 5  |-  ( z  =  x  ->  (
( ( N  - 
1 )  e.  z  /\  A. n  e.  z  ( ( n ^ ( N  - 
2 ) )  mod 
N )  e.  z )  <->  ( ( N  -  1 )  e.  x  /\  A. y  e.  x  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) ) )
1211cbvrabv 2787 . . . 4  |-  { z  e.  ~P ( 1 ... ( N  - 
1 ) )  |  ( ( N  - 
1 )  e.  z  /\  A. n  e.  z  ( ( n ^ ( N  - 
2 ) )  mod 
N )  e.  z ) }  =  {
x  e.  ~P (
1 ... ( N  - 
1 ) )  |  ( ( N  - 
1 )  e.  x  /\  A. y  e.  x  ( ( y ^
( N  -  2 ) )  mod  N
)  e.  x ) }
132, 12wilthlem3 20303 . . 3  |-  ( N  e.  Prime  ->  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )
141, 13jca 518 . 2  |-  ( N  e.  Prime  ->  ( N  e.  ( ZZ>= `  2
)  /\  N  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
15 simpl 443 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  N  e.  ( ZZ>= `  2 )
)
16 elfzuz 10789 . . . . . . . . 9  |-  ( n  e.  ( 2 ... ( N  -  1 ) )  ->  n  e.  ( ZZ>= `  2 )
)
1716adantl 452 . . . . . . . 8  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  (
ZZ>= `  2 ) )
18 eluz2b2 10285 . . . . . . . . 9  |-  ( n  e.  ( ZZ>= `  2
)  <->  ( n  e.  NN  /\  1  < 
n ) )
1918simplbi 446 . . . . . . . 8  |-  ( n  e.  ( ZZ>= `  2
)  ->  n  e.  NN )
2017, 19syl 15 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  NN )
21 elfzuz3 10790 . . . . . . . 8  |-  ( n  e.  ( 2 ... ( N  -  1 ) )  ->  ( N  -  1 )  e.  ( ZZ>= `  n
) )
2221adantl 452 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( N  - 
1 )  e.  (
ZZ>= `  n ) )
23 dvdsfac 12578 . . . . . . 7  |-  ( ( n  e.  NN  /\  ( N  -  1
)  e.  ( ZZ>= `  n ) )  ->  n  ||  ( ! `  ( N  -  1
) ) )
2420, 22, 23syl2anc 642 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  ||  ( ! `  ( N  -  1 ) ) )
25 eluz2b2 10285 . . . . . . . . . . 11  |-  ( N  e.  ( ZZ>= `  2
)  <->  ( N  e.  NN  /\  1  < 
N ) )
2625simplbi 446 . . . . . . . . . 10  |-  ( N  e.  ( ZZ>= `  2
)  ->  N  e.  NN )
2726ad2antrr 706 . . . . . . . . 9  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  NN )
28 nnm1nn0 10000 . . . . . . . . 9  |-  ( N  e.  NN  ->  ( N  -  1 )  e.  NN0 )
29 faccl 11293 . . . . . . . . 9  |-  ( ( N  -  1 )  e.  NN0  ->  ( ! `
 ( N  - 
1 ) )  e.  NN )
3027, 28, 293syl 18 . . . . . . . 8  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ! `  ( N  -  1
) )  e.  NN )
3130nnzd 10111 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ! `  ( N  -  1
) )  e.  ZZ )
3218simprbi 450 . . . . . . . 8  |-  ( n  e.  ( ZZ>= `  2
)  ->  1  <  n )
3317, 32syl 15 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  1  <  n
)
34 ndvdsp1 12603 . . . . . . 7  |-  ( ( ( ! `  ( N  -  1 ) )  e.  ZZ  /\  n  e.  NN  /\  1  <  n )  ->  (
n  ||  ( ! `  ( N  -  1 ) )  ->  -.  n  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) ) )
3531, 20, 33, 34syl3anc 1182 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( n  ||  ( ! `  ( N  -  1 ) )  ->  -.  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
3624, 35mpd 14 . . . . 5  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  -.  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) )
37 simplr 731 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  ||  (
( ! `  ( N  -  1 ) )  +  1 ) )
3820nnzd 10111 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  ZZ )
3927nnzd 10111 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  ZZ )
4031peano2zd 10115 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ( ! `
 ( N  - 
1 ) )  +  1 )  e.  ZZ )
41 dvdstr 12557 . . . . . . 7  |-  ( ( n  e.  ZZ  /\  N  e.  ZZ  /\  (
( ! `  ( N  -  1 ) )  +  1 )  e.  ZZ )  -> 
( ( n  ||  N  /\  N  ||  (
( ! `  ( N  -  1 ) )  +  1 ) )  ->  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
4238, 39, 40, 41syl3anc 1182 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ( n 
||  N  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  n  ||  ( ( ! `  ( N  -  1
) )  +  1 ) ) )
4337, 42mpan2d 655 . . . . 5  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( n  ||  N  ->  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
4436, 43mtod 168 . . . 4  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  -.  n  ||  N
)
4544ralrimiva 2626 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N )
46 isprm3 12762 . . 3  |-  ( N  e.  Prime  <->  ( N  e.  ( ZZ>= `  2 )  /\  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N
) )
4715, 45, 46sylanbrc 645 . 2  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  N  e.  Prime )
4814, 47impbii 180 1  |-  ( N  e.  Prime  <->  ( N  e.  ( ZZ>= `  2 )  /\  N  ||  ( ( ! `  ( N  -  1 ) )  +  1 ) ) )
Colors of variables: wff set class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 176    /\ wa 358    = wceq 1623    e. wcel 1684   A.wral 2543   {crab 2547   ~Pcpw 3625   class class class wbr 4023   ` cfv 5220  (class class class)co 5819   1c1 8733    + caddc 8735    < clt 8862    - cmin 9032   NNcn 9741   2c2 9790   NN0cn0 9960   ZZcz 10019   ZZ>=cuz 10225   ...cfz 10777    mod cmo 10968   ^cexp 11099   !cfa 11283    || cdivides 12526   Primecprime 12753  mulGrpcmgp 15320  ℂfldccnfld 16372
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1533  ax-5 1544  ax-17 1603  ax-9 1635  ax-8 1643  ax-13 1686  ax-14 1688  ax-6 1703  ax-7 1708  ax-11 1715  ax-12 1866  ax-ext 2264  ax-rep 4131  ax-sep 4141  ax-nul 4149  ax-pow 4186  ax-pr 4212  ax-un 4510  ax-inf2 7337  ax-cnex 8788  ax-resscn 8789  ax-1cn 8790  ax-icn 8791  ax-addcl 8792  ax-addrcl 8793  ax-mulcl 8794  ax-mulrcl 8795  ax-mulcom 8796  ax-addass 8797  ax-mulass 8798  ax-distr 8799  ax-i2m1 8800  ax-1ne0 8801  ax-1rid 8802  ax-rnegex 8803  ax-rrecex 8804  ax-cnre 8805  ax-pre-lttri 8806  ax-pre-lttrn 8807  ax-pre-ltadd 8808  ax-pre-mulgt0 8809  ax-pre-sup 8810  ax-addf 8811  ax-mulf 8812
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 935  df-3an 936  df-tru 1310  df-ex 1529  df-nf 1532  df-sb 1630  df-eu 2147  df-mo 2148  df-clab 2270  df-cleq 2276  df-clel 2279  df-nfc 2408  df-ne 2448  df-nel 2449  df-ral 2548  df-rex 2549  df-reu 2550  df-rmo 2551  df-rab 2552  df-v 2790  df-sbc 2992  df-csb 3082  df-dif 3155  df-un 3157  df-in 3159  df-ss 3166  df-pss 3168  df-nul 3456  df-if 3566  df-pw 3627  df-sn 3646  df-pr 3647  df-tp 3648  df-op 3649  df-uni 3828  df-int 3863  df-iun 3907  df-iin 3908  df-br 4024  df-opab 4078  df-mpt 4079  df-tr 4114  df-eprel 4303  df-id 4307  df-po 4312  df-so 4313  df-fr 4350  df-se 4351  df-we 4352  df-ord 4393  df-on 4394  df-lim 4395  df-suc 4396  df-om 4655  df-xp 4693  df-rel 4694  df-cnv 4695  df-co 4696  df-dm 4697  df-rn 4698  df-res 4699  df-ima 4700  df-fun 5222  df-fn 5223  df-f 5224  df-f1 5225  df-fo 5226  df-f1o 5227  df-fv 5228  df-isom 5229  df-ov 5822  df-oprab 5823  df-mpt2 5824  df-of 6039  df-1st 6083  df-2nd 6084  df-iota 6252  df-riota 6299  df-recs 6383  df-rdg 6418  df-1o 6474  df-2o 6475  df-oadd 6478  df-er 6655  df-map 6769  df-en 6859  df-dom 6860  df-sdom 6861  df-fin 6862  df-sup 7189  df-oi 7220  df-card 7567  df-cda 7789  df-pnf 8864  df-mnf 8865  df-xr 8866  df-ltxr 8867  df-le 8868  df-sub 9034  df-neg 9035  df-div 9419  df-nn 9742  df-2 9799  df-3 9800  df-4 9801  df-5 9802  df-6 9803  df-7 9804  df-8 9805  df-9 9806  df-10 9807  df-n0 9961  df-z 10020  df-dec 10120  df-uz 10226  df-rp 10350  df-fz 10778  df-fzo 10866  df-fl 10920  df-mod 10969  df-seq 11042  df-exp 11100  df-fac 11284  df-hash 11333  df-cj 11579  df-re 11580  df-im 11581  df-sqr 11715  df-abs 11716  df-dvds 12527  df-gcd 12681  df-prm 12754  df-phi 12829  df-struct 13145  df-ndx 13146  df-slot 13147  df-base 13148  df-sets 13149  df-ress 13150  df-plusg 13216  df-mulr 13217  df-starv 13218  df-tset 13222  df-ple 13223  df-ds 13225  df-0g 13399  df-gsum 13400  df-mre 13483  df-mrc 13484  df-acs 13486  df-mnd 14362  df-submnd 14411  df-grp 14484  df-minusg 14485  df-mulg 14487  df-subg 14613  df-cntz 14788  df-cmn 15086  df-mgp 15321  df-rng 15335  df-cring 15336  df-ur 15337  df-subrg 15538  df-cnfld 16373
  Copyright terms: Public domain W3C validator