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

Theorem wilth 26564
Description: Wilson's theorem. A number is prime iff it is greater than or equal to 2 and (𝑁 − 1)! is congruent to -1, mod 𝑁, or alternatively if 𝑁 divides (𝑁 − 1)! + 1. In this part of the proof we show the relatively simple reverse implication; see wilthlem3 26563 for the forward implication. This is Metamath 100 proof #51. (Contributed by Mario Carneiro, 24-Jan-2015.) (Proof shortened by Fan Zheng, 16-Jun-2016.)
Assertion
Ref Expression
wilth (𝑁 ∈ ℙ ↔ (𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))

Proof of Theorem wilth
Dummy variables 𝑥 𝑛 𝑦 𝑧 are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 prmuz2 16629 . . 3 (𝑁 ∈ ℙ → 𝑁 ∈ (ℤ‘2))
2 eqid 2732 . . . 4 (mulGrp‘ℂfld) = (mulGrp‘ℂfld)
3 eleq2w 2817 . . . . . 6 (𝑧 = 𝑥 → ((𝑁 − 1) ∈ 𝑧 ↔ (𝑁 − 1) ∈ 𝑥))
4 oveq1 7412 . . . . . . . . . 10 (𝑛 = 𝑦 → (𝑛↑(𝑁 − 2)) = (𝑦↑(𝑁 − 2)))
54oveq1d 7420 . . . . . . . . 9 (𝑛 = 𝑦 → ((𝑛↑(𝑁 − 2)) mod 𝑁) = ((𝑦↑(𝑁 − 2)) mod 𝑁))
65eleq1d 2818 . . . . . . . 8 (𝑛 = 𝑦 → (((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧))
76cbvralvw 3234 . . . . . . 7 (∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)
8 eleq2w 2817 . . . . . . . 8 (𝑧 = 𝑥 → (((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
98raleqbi1dv 3333 . . . . . . 7 (𝑧 = 𝑥 → (∀𝑦𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
107, 9bitrid 282 . . . . . 6 (𝑧 = 𝑥 → (∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
113, 10anbi12d 631 . . . . 5 (𝑧 = 𝑥 → (((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧) ↔ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)))
1211cbvrabv 3442 . . . 4 {𝑧 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)} = {𝑥 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)}
132, 12wilthlem3 26563 . . 3 (𝑁 ∈ ℙ → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
141, 13jca 512 . 2 (𝑁 ∈ ℙ → (𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
15 simpl 483 . . 3 ((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ (ℤ‘2))
16 elfzuz 13493 . . . . . . . . 9 (𝑛 ∈ (2...(𝑁 − 1)) → 𝑛 ∈ (ℤ‘2))
1716adantl 482 . . . . . . . 8 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ (ℤ‘2))
18 eluz2nn 12864 . . . . . . . 8 (𝑛 ∈ (ℤ‘2) → 𝑛 ∈ ℕ)
1917, 18syl 17 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℕ)
20 elfzuz3 13494 . . . . . . . 8 (𝑛 ∈ (2...(𝑁 − 1)) → (𝑁 − 1) ∈ (ℤ𝑛))
2120adantl 482 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑁 − 1) ∈ (ℤ𝑛))
22 dvdsfac 16265 . . . . . . 7 ((𝑛 ∈ ℕ ∧ (𝑁 − 1) ∈ (ℤ𝑛)) → 𝑛 ∥ (!‘(𝑁 − 1)))
2319, 21, 22syl2anc 584 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∥ (!‘(𝑁 − 1)))
24 eluz2nn 12864 . . . . . . . . . 10 (𝑁 ∈ (ℤ‘2) → 𝑁 ∈ ℕ)
2524ad2antrr 724 . . . . . . . . 9 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℕ)
26 nnm1nn0 12509 . . . . . . . . 9 (𝑁 ∈ ℕ → (𝑁 − 1) ∈ ℕ0)
27 faccl 14239 . . . . . . . . 9 ((𝑁 − 1) ∈ ℕ0 → (!‘(𝑁 − 1)) ∈ ℕ)
2825, 26, 273syl 18 . . . . . . . 8 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℕ)
2928nnzd 12581 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℤ)
30 eluz2gt1 12900 . . . . . . . 8 (𝑛 ∈ (ℤ‘2) → 1 < 𝑛)
3117, 30syl 17 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 1 < 𝑛)
32 ndvdsp1 16350 . . . . . . 7 (((!‘(𝑁 − 1)) ∈ ℤ ∧ 𝑛 ∈ ℕ ∧ 1 < 𝑛) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3329, 19, 31, 32syl3anc 1371 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3423, 33mpd 15 . . . . 5 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1))
35 simplr 767 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
3619nnzd 12581 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℤ)
3725nnzd 12581 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℤ)
3829peano2zd 12665 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((!‘(𝑁 − 1)) + 1) ∈ ℤ)
39 dvdstr 16233 . . . . . . 7 ((𝑛 ∈ ℤ ∧ 𝑁 ∈ ℤ ∧ ((!‘(𝑁 − 1)) + 1) ∈ ℤ) → ((𝑛𝑁𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4036, 37, 38, 39syl3anc 1371 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((𝑛𝑁𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4135, 40mpan2d 692 . . . . 5 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑛𝑁𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4234, 41mtod 197 . . . 4 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ¬ 𝑛𝑁)
4342ralrimiva 3146 . . 3 ((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛𝑁)
44 isprm3 16616 . . 3 (𝑁 ∈ ℙ ↔ (𝑁 ∈ (ℤ‘2) ∧ ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛𝑁))
4515, 43, 44sylanbrc 583 . 2 ((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ ℙ)
4614, 45impbii 208 1 (𝑁 ∈ ℙ ↔ (𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
Colors of variables: wff setvar class
Syntax hints:  ¬ wn 3  wi 4  wb 205  wa 396  wcel 2106  wral 3061  {crab 3432  𝒫 cpw 4601   class class class wbr 5147  cfv 6540  (class class class)co 7405  1c1 11107   + caddc 11109   < clt 11244  cmin 11440  cn 12208  2c2 12263  0cn0 12468  cz 12554  cuz 12818  ...cfz 13480   mod cmo 13830  cexp 14023  !cfa 14229  cdvds 16193  cprime 16604  mulGrpcmgp 19981  fldccnfld 20936
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1797  ax-4 1811  ax-5 1913  ax-6 1971  ax-7 2011  ax-8 2108  ax-9 2116  ax-10 2137  ax-11 2154  ax-12 2171  ax-ext 2703  ax-rep 5284  ax-sep 5298  ax-nul 5305  ax-pow 5362  ax-pr 5426  ax-un 7721  ax-cnex 11162  ax-resscn 11163  ax-1cn 11164  ax-icn 11165  ax-addcl 11166  ax-addrcl 11167  ax-mulcl 11168  ax-mulrcl 11169  ax-mulcom 11170  ax-addass 11171  ax-mulass 11172  ax-distr 11173  ax-i2m1 11174  ax-1ne0 11175  ax-1rid 11176  ax-rnegex 11177  ax-rrecex 11178  ax-cnre 11179  ax-pre-lttri 11180  ax-pre-lttrn 11181  ax-pre-ltadd 11182  ax-pre-mulgt0 11183  ax-pre-sup 11184  ax-addf 11185  ax-mulf 11186
This theorem depends on definitions:  df-bi 206  df-an 397  df-or 846  df-3or 1088  df-3an 1089  df-tru 1544  df-fal 1554  df-ex 1782  df-nf 1786  df-sb 2068  df-mo 2534  df-eu 2563  df-clab 2710  df-cleq 2724  df-clel 2810  df-nfc 2885  df-ne 2941  df-nel 3047  df-ral 3062  df-rex 3071  df-rmo 3376  df-reu 3377  df-rab 3433  df-v 3476  df-sbc 3777  df-csb 3893  df-dif 3950  df-un 3952  df-in 3954  df-ss 3964  df-pss 3966  df-nul 4322  df-if 4528  df-pw 4603  df-sn 4628  df-pr 4630  df-tp 4632  df-op 4634  df-uni 4908  df-int 4950  df-iun 4998  df-iin 4999  df-br 5148  df-opab 5210  df-mpt 5231  df-tr 5265  df-id 5573  df-eprel 5579  df-po 5587  df-so 5588  df-fr 5630  df-se 5631  df-we 5632  df-xp 5681  df-rel 5682  df-cnv 5683  df-co 5684  df-dm 5685  df-rn 5686  df-res 5687  df-ima 5688  df-pred 6297  df-ord 6364  df-on 6365  df-lim 6366  df-suc 6367  df-iota 6492  df-fun 6542  df-fn 6543  df-f 6544  df-f1 6545  df-fo 6546  df-f1o 6547  df-fv 6548  df-isom 6549  df-riota 7361  df-ov 7408  df-oprab 7409  df-mpo 7410  df-of 7666  df-om 7852  df-1st 7971  df-2nd 7972  df-supp 8143  df-frecs 8262  df-wrecs 8293  df-recs 8367  df-rdg 8406  df-1o 8462  df-2o 8463  df-oadd 8466  df-er 8699  df-en 8936  df-dom 8937  df-sdom 8938  df-fin 8939  df-fsupp 9358  df-sup 9433  df-inf 9434  df-oi 9501  df-dju 9892  df-card 9930  df-pnf 11246  df-mnf 11247  df-xr 11248  df-ltxr 11249  df-le 11250  df-sub 11442  df-neg 11443  df-div 11868  df-nn 12209  df-2 12271  df-3 12272  df-4 12273  df-5 12274  df-6 12275  df-7 12276  df-8 12277  df-9 12278  df-n0 12469  df-xnn0 12541  df-z 12555  df-dec 12674  df-uz 12819  df-rp 12971  df-fz 13481  df-fzo 13624  df-fl 13753  df-mod 13831  df-seq 13963  df-exp 14024  df-fac 14230  df-hash 14287  df-cj 15042  df-re 15043  df-im 15044  df-sqrt 15178  df-abs 15179  df-dvds 16194  df-gcd 16432  df-prm 16605  df-phi 16695  df-struct 17076  df-sets 17093  df-slot 17111  df-ndx 17123  df-base 17141  df-ress 17170  df-plusg 17206  df-mulr 17207  df-starv 17208  df-tset 17212  df-ple 17213  df-ds 17215  df-unif 17216  df-0g 17383  df-gsum 17384  df-mre 17526  df-mrc 17527  df-acs 17529  df-mgm 18557  df-sgrp 18606  df-mnd 18622  df-submnd 18668  df-grp 18818  df-minusg 18819  df-mulg 18945  df-subg 18997  df-cntz 19175  df-cmn 19644  df-mgp 19982  df-ur 19999  df-ring 20051  df-cring 20052  df-subrg 20353  df-cnfld 20937
This theorem is referenced by:  wilthimp  26565
  Copyright terms: Public domain W3C validator