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

Theorem wilth 20272
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 20271 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 12739 . . 3  |-  ( N  e.  Prime  ->  N  e.  ( ZZ>= `  2 )
)
2 eqid 2258 . . . 4  |-  (mulGrp ` fld )  =  (mulGrp ` fld )
3 eleq2 2319 . . . . . 6  |-  ( z  =  x  ->  (
( N  -  1 )  e.  z  <->  ( N  -  1 )  e.  x ) )
4 oveq1 5799 . . . . . . . . . 10  |-  ( n  =  y  ->  (
n ^ ( N  -  2 ) )  =  ( y ^
( N  -  2 ) ) )
54oveq1d 5807 . . . . . . . . 9  |-  ( n  =  y  ->  (
( n ^ ( N  -  2 ) )  mod  N )  =  ( ( y ^ ( N  - 
2 ) )  mod 
N ) )
65eleq1d 2324 . . . . . . . 8  |-  ( n  =  y  ->  (
( ( n ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  z ) )
76cbvralv 2739 . . . . . . 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 2319 . . . . . . . 8  |-  ( z  =  x  ->  (
( ( y ^
( N  -  2 ) )  mod  N
)  e.  z  <->  ( (
y ^ ( N  -  2 ) )  mod  N )  e.  x ) )
98raleqbi1dv 2719 . . . . . . 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 2762 . . . 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 20271 . . 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 10761 . . . . . . . . 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 10258 . . . . . . . . 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 10762 . . . . . . . 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 12546 . . . . . . 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 10258 . . . . . . . . . . 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 9973 . . . . . . . . 9  |-  ( N  e.  NN  ->  ( N  -  1 )  e.  NN0 )
29 faccl 11265 . . . . . . . . 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 10084 . . . . . . 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 12571 . . . . . . 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 10084 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  n  e.  ZZ )
3927nnzd 10084 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  N  e.  ZZ )
4031peano2zd 10088 . . . . . . 7  |-  ( ( ( N  e.  (
ZZ>= `  2 )  /\  N  ||  ( ( ! `
 ( N  - 
1 ) )  +  1 ) )  /\  n  e.  ( 2 ... ( N  - 
1 ) ) )  ->  ( ( ! `
 ( N  - 
1 ) )  +  1 )  e.  ZZ )
41 dvdstr 12525 . . . . . . 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 2601 . . 3  |-  ( ( N  e.  ( ZZ>= ` 
2 )  /\  N  ||  ( ( ! `  ( N  -  1
) )  +  1 ) )  ->  A. n  e.  ( 2 ... ( N  -  1 ) )  -.  n  ||  N )
46 isprm3 12730 . . 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 2518   {crab 2522   ~Pcpw 3599   class class class wbr 3997   ` cfv 4673  (class class class)co 5792   1c1 8706    + caddc 8708    < clt 8835    - cmin 9005   NNcn 9714   2c2 9763   NN0cn0 9933   ZZcz 9992   ZZ>=cuz 10198   ...cfz 10749    mod cmo 10940   ^cexp 11071   !cfa 11255    || cdivides 12494   Primecprime 12721  mulGrpcmgp 15288  ℂfldccnfld 16340
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 2239  ax-rep 4105  ax-sep 4115  ax-nul 4123  ax-pow 4160  ax-pr 4186  ax-un 4484  ax-inf2 7310  ax-cnex 8761  ax-resscn 8762  ax-1cn 8763  ax-icn 8764  ax-addcl 8765  ax-addrcl 8766  ax-mulcl 8767  ax-mulrcl 8768  ax-mulcom 8769  ax-addass 8770  ax-mulass 8771  ax-distr 8772  ax-i2m1 8773  ax-1ne0 8774  ax-1rid 8775  ax-rnegex 8776  ax-rrecex 8777  ax-cnre 8778  ax-pre-lttri 8779  ax-pre-lttrn 8780  ax-pre-ltadd 8781  ax-pre-mulgt0 8782  ax-pre-sup 8783  ax-addf 8784  ax-mulf 8785
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 2122  df-mo 2123  df-clab 2245  df-cleq 2251  df-clel 2254  df-nfc 2383  df-ne 2423  df-nel 2424  df-ral 2523  df-rex 2524  df-reu 2525  df-rmo 2526  df-rab 2527  df-v 2765  df-sbc 2967  df-csb 3057  df-dif 3130  df-un 3132  df-in 3134  df-ss 3141  df-pss 3143  df-nul 3431  df-if 3540  df-pw 3601  df-sn 3620  df-pr 3621  df-tp 3622  df-op 3623  df-uni 3802  df-int 3837  df-iun 3881  df-iin 3882  df-br 3998  df-opab 4052  df-mpt 4053  df-tr 4088  df-eprel 4277  df-id 4281  df-po 4286  df-so 4287  df-fr 4324  df-se 4325  df-we 4326  df-ord 4367  df-on 4368  df-lim 4369  df-suc 4370  df-om 4629  df-xp 4675  df-rel 4676  df-cnv 4677  df-co 4678  df-dm 4679  df-rn 4680  df-res 4681  df-ima 4682  df-fun 4683  df-fn 4684  df-f 4685  df-f1 4686  df-fo 4687  df-f1o 4688  df-fv 4689  df-isom 4690  df-ov 5795  df-oprab 5796  df-mpt2 5797  df-of 6012  df-1st 6056  df-2nd 6057  df-iota 6225  df-riota 6272  df-recs 6356  df-rdg 6391  df-1o 6447  df-2o 6448  df-oadd 6451  df-er 6628  df-map 6742  df-en 6832  df-dom 6833  df-sdom 6834  df-fin 6835  df-sup 7162  df-oi 7193  df-card 7540  df-cda 7762  df-pnf 8837  df-mnf 8838  df-xr 8839  df-ltxr 8840  df-le 8841  df-sub 9007  df-neg 9008  df-div 9392  df-n 9715  df-2 9772  df-3 9773  df-4 9774  df-5 9775  df-6 9776  df-7 9777  df-8 9778  df-9 9779  df-10 9780  df-n0 9934  df-z 9993  df-dec 10093  df-uz 10199  df-rp 10323  df-fz 10750  df-fzo 10838  df-fl 10892  df-mod 10941  df-seq 11014  df-exp 11072  df-fac 11256  df-hash 11305  df-cj 11550  df-re 11551  df-im 11552  df-sqr 11686  df-abs 11687  df-divides 12495  df-gcd 12649  df-prime 12722  df-phi 12797  df-struct 13113  df-ndx 13114  df-slot 13115  df-base 13116  df-sets 13117  df-ress 13118  df-plusg 13184  df-mulr 13185  df-starv 13186  df-tset 13190  df-ple 13191  df-ds 13193  df-0g 13367  df-gsum 13368  df-mre 13451  df-mrc 13452  df-acs 13454  df-mnd 14330  df-submnd 14379  df-grp 14452  df-minusg 14453  df-mulg 14455  df-subg 14581  df-cntz 14756  df-cmn 15054  df-mgp 15289  df-ring 15303  df-cring 15304  df-ur 15305  df-subrg 15506  df-cnfld 16341
  Copyright terms: Public domain W3C validator