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

Theorem wilth 20236
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 20235 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
StepHypRef Expression
1 prmuz2 12703 . . 3  |-  ( N  e.  Prime  ->  N  e.  ( ZZ>= `  2 )
)
2 eqid 2256 . . . 4  |-  (mulGrp ` fld )  =  (mulGrp ` fld )
3 eleq2 2317 . . . . . 6  |-  ( z  =  x  ->  (
( N  -  1 )  e.  z  <->  ( N  -  1 )  e.  x ) )
4 oveq1 5764 . . . . . . . . . 10  |-  ( n  =  y  ->  (
n ^ ( N  -  2 ) )  =  ( y ^
( N  -  2 ) ) )
54oveq1d 5772 . . . . . . . . 9  |-  ( n  =  y  ->  (
( n ^ ( N  -  2 ) )  mod  N )  =  ( ( y ^ ( N  - 
2 ) )  mod 
N ) )
65eleq1d 2322 . . . . . . . 8  |-  ( n  =  y  ->  (
( ( n ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  z ) )
76cbvralv 2717 . . . . . . 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 2317 . . . . . . . 8  |-  ( z  =  x  ->  (
( ( y ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
98raleqbi1dv 2705 . . . . . . 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 250 . . . . . 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 694 . . . . 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 2739 . . . 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 20235 . . 3  |-  ( N  e.  Prime  ->  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )
141, 13jca 520 . 2  |-  ( N  e.  Prime  ->  ( N  e.  ( ZZ>= `  2
)  /\  N  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
15 simpl 445 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  N  e.  ( ZZ>= `  2 )
)
16 elfzuz 10725 . . . . . . . . 9  |-  ( n  e.  ( 2 ... ( N  -  1 ) )  ->  n  e.  ( ZZ>= `  2 )
)
1716adantl 454 . . . . . . . 8  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  (
ZZ>= `  2 ) )
18 eluz2b2 10222 . . . . . . . . 9  |-  ( n  e.  ( ZZ>= `  2
)  <->  ( n  e.  NN  /\  1  < 
n ) )
1918simplbi 448 . . . . . . . 8  |-  ( n  e.  ( ZZ>= `  2
)  ->  n  e.  NN )
2017, 19syl 17 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  NN )
21 elfzuz3 10726 . . . . . . . 8  |-  ( n  e.  ( 2 ... ( N  -  1 ) )  ->  ( N  -  1 )  e.  ( ZZ>= `  n
) )
2221adantl 454 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( N  - 
1 )  e.  (
ZZ>= `  n ) )
23 dvdsfac 12510 . . . . . . 7  |-  ( ( n  e.  NN  /\  ( N  -  1
)  e.  ( ZZ>= `  n ) )  ->  n  ||  ( ! `  ( N  -  1
) ) )
2420, 22, 23syl2anc 645 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  ||  ( ! `  ( N  -  1 ) ) )
25 eluz2b2 10222 . . . . . . . . . . 11  |-  ( N  e.  ( ZZ>= `  2
)  <->  ( N  e.  NN  /\  1  < 
N ) )
2625simplbi 448 . . . . . . . . . 10  |-  ( N  e.  ( ZZ>= `  2
)  ->  N  e.  NN )
2726ad2antrr 709 . . . . . . . . 9  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  NN )
28 nnm1nn0 9937 . . . . . . . . 9  |-  ( N  e.  NN  ->  ( N  -  1 )  e.  NN0 )
29 faccl 11229 . . . . . . . . 9  |-  ( ( N  -  1 )  e.  NN0  ->  ( ! `
 ( N  - 
1 ) )  e.  NN )
3027, 28, 293syl 20 . . . . . . . 8  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ! `  ( N  -  1
) )  e.  NN )
3130nnzd 10048 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ! `  ( N  -  1
) )  e.  ZZ )
3218simprbi 452 . . . . . . . 8  |-  ( n  e.  ( ZZ>= `  2
)  ->  1  <  n )
3317, 32syl 17 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  1  <  n
)
34 ndvdsp1 12535 . . . . . . 7  |-  ( ( ( ! `  ( N  -  1 ) )  e.  ZZ  /\  n  e.  NN  /\  1  <  n )  ->  (
n  ||  ( ! `  ( N  -  1 ) )  ->  -.  n  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) ) )
3531, 20, 33, 34syl3anc 1187 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( n  ||  ( ! `  ( N  -  1 ) )  ->  -.  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
3624, 35mpd 16 . . . . 5  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  -.  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) )
37 simplr 734 . . . . . 6  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  ||  (
( ! `  ( N  -  1 ) )  +  1 ) )
3820nnzd 10048 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  ZZ )
3927nnzd 10048 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  ZZ )
4031peano2zd 10052 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ( ! `
 ( N  - 
1 ) )  +  1 )  e.  ZZ )
41 dvdstr 12489 . . . . . . 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 1187 . . . . . 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 658 . . . . 5  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( n  ||  N  ->  n  ||  (
( ! `  ( N  -  1 ) )  +  1 ) ) )
4436, 43mtod 170 . . . 4  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  -.  n  ||  N
)
4544ralrimiva 2597 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N )
46 isprm3 12694 . . 3  |-  ( N  e.  Prime  <->  ( N  e.  ( ZZ>= `  2 )  /\  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N
) )
4715, 45, 46sylanbrc 648 . 2  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  N  e.  Prime )
4814, 47impbii 182 1  |-  ( N  e.  Prime  <->  ( N  e.  ( ZZ>= `  2 )  /\  N  ||  ( ( ! `  ( N  -  1 ) )  +  1 ) ) )
Colors of variables: wff set class
Syntax hints:   -. wn 5    -> wi 6    <-> wb 178    /\ wa 360    = wceq 1619    e. wcel 1621   A.wral 2516   {crab 2519   ~Pcpw 3566   class class class wbr 3963   ` cfv 4638  (class class class)co 5757   1c1 8671    + caddc 8673    < clt 8800    - cmin 8970   NNcn 9679   2c2 9728   NN0cn0 9897   ZZcz 9956   ZZ>=cuz 10162   ...cfz 10713    mod cmo 10904   ^cexp 11035   !cfa 11219    || cdivides 12458   Primecprime 12685  mulGrpcmgp 15252  ℂfldccnfld 16304
This theorem was proved from axioms:  ax-1 7  ax-2 8  ax-3 9  ax-mp 10  ax-5 1533  ax-6 1534  ax-7 1535  ax-gen 1536  ax-8 1623  ax-11 1624  ax-13 1625  ax-14 1626  ax-17 1628  ax-12o 1664  ax-10 1678  ax-9 1684  ax-4 1692  ax-16 1927  ax-ext 2237  ax-rep 4071  ax-sep 4081  ax-nul 4089  ax-pow 4126  ax-pr 4152  ax-un 4449  ax-inf2 7275  ax-cnex 8726  ax-resscn 8727  ax-1cn 8728  ax-icn 8729  ax-addcl 8730  ax-addrcl 8731  ax-mulcl 8732  ax-mulrcl 8733  ax-mulcom 8734  ax-addass 8735  ax-mulass 8736  ax-distr 8737  ax-i2m1 8738  ax-1ne0 8739  ax-1rid 8740  ax-rnegex 8741  ax-rrecex 8742  ax-cnre 8743  ax-pre-lttri 8744  ax-pre-lttrn 8745  ax-pre-ltadd 8746  ax-pre-mulgt0 8747  ax-pre-sup 8748  ax-addf 8749  ax-mulf 8750
This theorem depends on definitions:  df-bi 179  df-or 361  df-an 362  df-3or 940  df-3an 941  df-tru 1315  df-ex 1538  df-nf 1540  df-sb 1884  df-eu 2121  df-mo 2122  df-clab 2243  df-cleq 2249  df-clel 2252  df-nfc 2381  df-ne 2421  df-nel 2422  df-ral 2520  df-rex 2521  df-reu 2522  df-rab 2523  df-v 2742  df-sbc 2936  df-csb 3024  df-dif 3097  df-un 3099  df-in 3101  df-ss 3108  df-pss 3110  df-nul 3398  df-if 3507  df-pw 3568  df-sn 3587  df-pr 3588  df-tp 3589  df-op 3590  df-uni 3769  df-int 3804  df-iun 3848  df-iin 3849  df-br 3964  df-opab 4018  df-mpt 4019  df-tr 4054  df-eprel 4242  df-id 4246  df-po 4251  df-so 4252  df-fr 4289  df-se 4290  df-we 4291  df-ord 4332  df-on 4333  df-lim 4334  df-suc 4335  df-om 4594  df-xp 4640  df-rel 4641  df-cnv 4642  df-co 4643  df-dm 4644  df-rn 4645  df-res 4646  df-ima 4647  df-fun 4648  df-fn 4649  df-f 4650  df-f1 4651  df-fo 4652  df-f1o 4653  df-fv 4654  df-isom 4655  df-ov 5760  df-oprab 5761  df-mpt2 5762  df-of 5977  df-1st 6021  df-2nd 6022  df-iota 6190  df-riota 6237  df-recs 6321  df-rdg 6356  df-1o 6412  df-2o 6413  df-oadd 6416  df-er 6593  df-map 6707  df-en 6797  df-dom 6798  df-sdom 6799  df-fin 6800  df-sup 7127  df-oi 7158  df-card 7505  df-cda 7727  df-pnf 8802  df-mnf 8803  df-xr 8804  df-ltxr 8805  df-le 8806  df-sub 8972  df-neg 8973  df-div 9357  df-n 9680  df-2 9737  df-3 9738  df-4 9739  df-5 9740  df-6 9741  df-7 9742  df-8 9743  df-9 9744  df-10 9745  df-n0 9898  df-z 9957  df-dec 10057  df-uz 10163  df-rp 10287  df-fz 10714  df-fzo 10802  df-fl 10856  df-mod 10905  df-seq 10978  df-exp 11036  df-fac 11220  df-hash 11269  df-cj 11514  df-re 11515  df-im 11516  df-sqr 11650  df-abs 11651  df-divides 12459  df-gcd 12613  df-prime 12686  df-phi 12761  df-struct 13077  df-ndx 13078  df-slot 13079  df-base 13080  df-sets 13081  df-ress 13082  df-plusg 13148  df-mulr 13149  df-starv 13150  df-tset 13154  df-ple 13155  df-ds 13157  df-0g 13331  df-gsum 13332  df-mre 13415  df-mrc 13416  df-acs 13418  df-mnd 14294  df-submnd 14343  df-grp 14416  df-minusg 14417  df-mulg 14419  df-subg 14545  df-cntz 14720  df-cmn 15018  df-mgp 15253  df-ring 15267  df-cring 15268  df-ur 15269  df-subrg 15470  df-cnfld 16305
  Copyright terms: Public domain W3C validator