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

Theorem wilth 20141
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 20140 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 12650 . . 3  |-  ( N  e.  Prime  ->  N  e.  ( ZZ>= `  2 )
)
2 eqid 2253 . . . 4  |-  (mulGrp ` fld )  =  (mulGrp ` fld )
3 eleq2 2314 . . . . . 6  |-  ( z  =  x  ->  (
( N  -  1 )  e.  z  <->  ( N  -  1 )  e.  x ) )
4 oveq1 5717 . . . . . . . . . 10  |-  ( n  =  y  ->  (
n ^ ( N  -  2 ) )  =  ( y ^
( N  -  2 ) ) )
54oveq1d 5725 . . . . . . . . 9  |-  ( n  =  y  ->  (
( n ^ ( N  -  2 ) )  mod  N )  =  ( ( y ^ ( N  - 
2 ) )  mod 
N ) )
65eleq1d 2319 . . . . . . . 8  |-  ( n  =  y  ->  (
( ( n ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  z ) )
76cbvralv 2708 . . . . . . 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 2314 . . . . . . . 8  |-  ( z  =  x  ->  (
( ( y ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
98raleqbi1dv 2696 . . . . . . 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 2726 . . . 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 20140 . . 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 10672 . . . . . . . . 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 10169 . . . . . . . . 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 10673 . . . . . . . 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 12457 . . . . . . 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 10169 . . . . . . . . . . 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 9884 . . . . . . . . 9  |-  ( N  e.  NN  ->  ( N  -  1 )  e.  NN0 )
29 faccl 11176 . . . . . . . . 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 9995 . . . . . . 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 12482 . . . . . . 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 9995 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  ZZ )
3927nnzd 9995 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  ZZ )
4031peano2zd 9999 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ( ! `
 ( N  - 
1 ) )  +  1 )  e.  ZZ )
41 dvdstr 12436 . . . . . . 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 2588 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N )
46 isprm3 12641 . . 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 2509   {crab 2512   ~Pcpw 3530   class class class wbr 3920   ` cfv 4592  (class class class)co 5710   1c1 8618    + caddc 8620    < clt 8747    - cmin 8917   NNcn 9626   2c2 9675   NN0cn0 9844   ZZcz 9903   ZZ>=cuz 10109   ...cfz 10660    mod cmo 10851   ^cexp 10982   !cfa 11166    || cdivides 12405   Primecprime 12632  mulGrpcmgp 15160  ℂfldccnfld 16209
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 1926  ax-ext 2234  ax-rep 4028  ax-sep 4038  ax-nul 4046  ax-pow 4082  ax-pr 4108  ax-un 4403  ax-inf2 7226  ax-cnex 8673  ax-resscn 8674  ax-1cn 8675  ax-icn 8676  ax-addcl 8677  ax-addrcl 8678  ax-mulcl 8679  ax-mulrcl 8680  ax-mulcom 8681  ax-addass 8682  ax-mulass 8683  ax-distr 8684  ax-i2m1 8685  ax-1ne0 8686  ax-1rid 8687  ax-rnegex 8688  ax-rrecex 8689  ax-cnre 8690  ax-pre-lttri 8691  ax-pre-lttrn 8692  ax-pre-ltadd 8693  ax-pre-mulgt0 8694  ax-pre-sup 8695  ax-addf 8696  ax-mulf 8697
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 1883  df-eu 2118  df-mo 2119  df-clab 2240  df-cleq 2246  df-clel 2249  df-nfc 2374  df-ne 2414  df-nel 2415  df-ral 2513  df-rex 2514  df-reu 2515  df-rab 2516  df-v 2729  df-sbc 2922  df-csb 3010  df-dif 3081  df-un 3083  df-in 3085  df-ss 3089  df-pss 3091  df-nul 3363  df-if 3471  df-pw 3532  df-sn 3550  df-pr 3551  df-tp 3552  df-op 3553  df-uni 3728  df-int 3761  df-iun 3805  df-iin 3806  df-br 3921  df-opab 3975  df-mpt 3976  df-tr 4011  df-eprel 4198  df-id 4202  df-po 4207  df-so 4208  df-fr 4245  df-se 4246  df-we 4247  df-ord 4288  df-on 4289  df-lim 4290  df-suc 4291  df-om 4548  df-xp 4594  df-rel 4595  df-cnv 4596  df-co 4597  df-dm 4598  df-rn 4599  df-res 4600  df-ima 4601  df-fun 4602  df-fn 4603  df-f 4604  df-f1 4605  df-fo 4606  df-f1o 4607  df-fv 4608  df-isom 4609  df-ov 5713  df-oprab 5714  df-mpt2 5715  df-of 5930  df-1st 5974  df-2nd 5975  df-iota 6143  df-riota 6190  df-recs 6274  df-rdg 6309  df-1o 6365  df-2o 6366  df-oadd 6369  df-er 6546  df-map 6660  df-en 6750  df-dom 6751  df-sdom 6752  df-fin 6753  df-sup 7078  df-oi 7109  df-card 7456  df-cda 7678  df-pnf 8749  df-mnf 8750  df-xr 8751  df-ltxr 8752  df-le 8753  df-sub 8919  df-neg 8920  df-div 9304  df-n 9627  df-2 9684  df-3 9685  df-4 9686  df-5 9687  df-6 9688  df-7 9689  df-8 9690  df-9 9691  df-10 9692  df-n0 9845  df-z 9904  df-dec 10004  df-uz 10110  df-rp 10234  df-fz 10661  df-fzo 10749  df-fl 10803  df-mod 10852  df-seq 10925  df-exp 10983  df-fac 11167  df-hash 11216  df-cj 11461  df-re 11462  df-im 11463  df-sqr 11597  df-abs 11598  df-divides 12406  df-gcd 12560  df-prime 12633  df-phi 12708  df-struct 13024  df-ndx 13025  df-slot 13026  df-base 13027  df-sets 13028  df-ress 13029  df-plusg 13095  df-mulr 13096  df-starv 13097  df-tset 13101  df-ple 13102  df-ds 13104  df-0g 13278  df-gsum 13279  df-mre 13361  df-mrc 13362  df-acs 13363  df-mnd 14202  df-submnd 14251  df-grp 14324  df-minusg 14325  df-mulg 14327  df-subg 14453  df-cntz 14628  df-cmn 14926  df-mgp 15161  df-ring 15175  df-cring 15176  df-ur 15177  df-subrg 15378  df-cnfld 16210
  Copyright terms: Public domain W3C validator