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

Theorem wilth 20311
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 20310 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 12778 . . 3  |-  ( N  e.  Prime  ->  N  e.  ( ZZ>= `  2 )
)
2 eqid 2285 . . . 4  |-  (mulGrp ` fld )  =  (mulGrp ` fld )
3 eleq2 2346 . . . . . 6  |-  ( z  =  x  ->  (
( N  -  1 )  e.  z  <->  ( N  -  1 )  e.  x ) )
4 oveq1 5867 . . . . . . . . . 10  |-  ( n  =  y  ->  (
n ^ ( N  -  2 ) )  =  ( y ^
( N  -  2 ) ) )
54oveq1d 5875 . . . . . . . . 9  |-  ( n  =  y  ->  (
( n ^ ( N  -  2 ) )  mod  N )  =  ( ( y ^ ( N  - 
2 ) )  mod 
N ) )
65eleq1d 2351 . . . . . . . 8  |-  ( n  =  y  ->  (
( ( n ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  z ) )
76cbvralv 2766 . . . . . . 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 2346 . . . . . . . 8  |-  ( z  =  x  ->  (
( ( y ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
98raleqbi1dv 2746 . . . . . . 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 2789 . . . 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 20310 . . 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 10796 . . . . . . . . 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 10292 . . . . . . . . 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 10797 . . . . . . . 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 12585 . . . . . . 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 10292 . . . . . . . . . . 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 10007 . . . . . . . . 9  |-  ( N  e.  NN  ->  ( N  -  1 )  e.  NN0 )
29 faccl 11300 . . . . . . . . 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 10118 . . . . . . 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 12610 . . . . . . 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 10118 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  ZZ )
3927nnzd 10118 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  ZZ )
4031peano2zd 10122 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ( ! `
 ( N  - 
1 ) )  +  1 )  e.  ZZ )
41 dvdstr 12564 . . . . . . 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 2628 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N )
46 isprm3 12769 . . 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 1625    e. wcel 1686   A.wral 2545   {crab 2549   ~Pcpw 3627   class class class wbr 4025   ` cfv 5257  (class class class)co 5860   1c1 8740    + caddc 8742    < clt 8869    - cmin 9039   NNcn 9748   2c2 9797   NN0cn0 9967   ZZcz 10026   ZZ>=cuz 10232   ...cfz 10784    mod cmo 10975   ^cexp 11106   !cfa 11290    || cdivides 12533   Primecprime 12760  mulGrpcmgp 15327  ℂfldccnfld 16379
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1535  ax-5 1546  ax-17 1605  ax-9 1637  ax-8 1645  ax-13 1688  ax-14 1690  ax-6 1705  ax-7 1710  ax-11 1717  ax-12 1868  ax-ext 2266  ax-rep 4133  ax-sep 4143  ax-nul 4151  ax-pow 4190  ax-pr 4216  ax-un 4514  ax-inf2 7344  ax-cnex 8795  ax-resscn 8796  ax-1cn 8797  ax-icn 8798  ax-addcl 8799  ax-addrcl 8800  ax-mulcl 8801  ax-mulrcl 8802  ax-mulcom 8803  ax-addass 8804  ax-mulass 8805  ax-distr 8806  ax-i2m1 8807  ax-1ne0 8808  ax-1rid 8809  ax-rnegex 8810  ax-rrecex 8811  ax-cnre 8812  ax-pre-lttri 8813  ax-pre-lttrn 8814  ax-pre-ltadd 8815  ax-pre-mulgt0 8816  ax-pre-sup 8817  ax-addf 8818  ax-mulf 8819
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 1531  df-nf 1534  df-sb 1632  df-eu 2149  df-mo 2150  df-clab 2272  df-cleq 2278  df-clel 2281  df-nfc 2410  df-ne 2450  df-nel 2451  df-ral 2550  df-rex 2551  df-reu 2552  df-rmo 2553  df-rab 2554  df-v 2792  df-sbc 2994  df-csb 3084  df-dif 3157  df-un 3159  df-in 3161  df-ss 3168  df-pss 3170  df-nul 3458  df-if 3568  df-pw 3629  df-sn 3648  df-pr 3649  df-tp 3650  df-op 3651  df-uni 3830  df-int 3865  df-iun 3909  df-iin 3910  df-br 4026  df-opab 4080  df-mpt 4081  df-tr 4116  df-eprel 4307  df-id 4311  df-po 4316  df-so 4317  df-fr 4354  df-se 4355  df-we 4356  df-ord 4397  df-on 4398  df-lim 4399  df-suc 4400  df-om 4659  df-xp 4697  df-rel 4698  df-cnv 4699  df-co 4700  df-dm 4701  df-rn 4702  df-res 4703  df-ima 4704  df-iota 5221  df-fun 5259  df-fn 5260  df-f 5261  df-f1 5262  df-fo 5263  df-f1o 5264  df-fv 5265  df-isom 5266  df-ov 5863  df-oprab 5864  df-mpt2 5865  df-of 6080  df-1st 6124  df-2nd 6125  df-riota 6306  df-recs 6390  df-rdg 6425  df-1o 6481  df-2o 6482  df-oadd 6485  df-er 6662  df-map 6776  df-en 6866  df-dom 6867  df-sdom 6868  df-fin 6869  df-sup 7196  df-oi 7227  df-card 7574  df-cda 7796  df-pnf 8871  df-mnf 8872  df-xr 8873  df-ltxr 8874  df-le 8875  df-sub 9041  df-neg 9042  df-div 9426  df-nn 9749  df-2 9806  df-3 9807  df-4 9808  df-5 9809  df-6 9810  df-7 9811  df-8 9812  df-9 9813  df-10 9814  df-n0 9968  df-z 10027  df-dec 10127  df-uz 10233  df-rp 10357  df-fz 10785  df-fzo 10873  df-fl 10927  df-mod 10976  df-seq 11049  df-exp 11107  df-fac 11291  df-hash 11340  df-cj 11586  df-re 11587  df-im 11588  df-sqr 11722  df-abs 11723  df-dvds 12534  df-gcd 12688  df-prm 12761  df-phi 12836  df-struct 13152  df-ndx 13153  df-slot 13154  df-base 13155  df-sets 13156  df-ress 13157  df-plusg 13223  df-mulr 13224  df-starv 13225  df-tset 13229  df-ple 13230  df-ds 13232  df-0g 13406  df-gsum 13407  df-mre 13490  df-mrc 13491  df-acs 13493  df-mnd 14369  df-submnd 14418  df-grp 14491  df-minusg 14492  df-mulg 14494  df-subg 14620  df-cntz 14795  df-cmn 15093  df-mgp 15328  df-rng 15342  df-cring 15343  df-ur 15344  df-subrg 15545  df-cnfld 16380
  Copyright terms: Public domain W3C validator