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

Theorem wilth 26372
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 26371 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 16532 . . 3 (𝑁 ∈ ℙ → 𝑁 ∈ (ℤ‘2))
2 eqid 2738 . . . 4 (mulGrp‘ℂfld) = (mulGrp‘ℂfld)
3 eleq2w 2822 . . . . . 6 (𝑧 = 𝑥 → ((𝑁 − 1) ∈ 𝑧 ↔ (𝑁 − 1) ∈ 𝑥))
4 oveq1 7359 . . . . . . . . . 10 (𝑛 = 𝑦 → (𝑛↑(𝑁 − 2)) = (𝑦↑(𝑁 − 2)))
54oveq1d 7367 . . . . . . . . 9 (𝑛 = 𝑦 → ((𝑛↑(𝑁 − 2)) mod 𝑁) = ((𝑦↑(𝑁 − 2)) mod 𝑁))
65eleq1d 2823 . . . . . . . 8 (𝑛 = 𝑦 → (((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧))
76cbvralvw 3224 . . . . . . 7 (∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)
8 eleq2w 2822 . . . . . . . 8 (𝑧 = 𝑥 → (((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
98raleqbi1dv 3306 . . . . . . 7 (𝑧 = 𝑥 → (∀𝑦𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
107, 9bitrid 283 . . . . . 6 (𝑧 = 𝑥 → (∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
113, 10anbi12d 632 . . . . 5 (𝑧 = 𝑥 → (((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧) ↔ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)))
1211cbvrabv 3416 . . . 4 {𝑧 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)} = {𝑥 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)}
132, 12wilthlem3 26371 . . 3 (𝑁 ∈ ℙ → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
141, 13jca 513 . 2 (𝑁 ∈ ℙ → (𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
15 simpl 484 . . 3 ((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ (ℤ‘2))
16 elfzuz 13392 . . . . . . . . 9 (𝑛 ∈ (2...(𝑁 − 1)) → 𝑛 ∈ (ℤ‘2))
1716adantl 483 . . . . . . . 8 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ (ℤ‘2))
18 eluz2nn 12764 . . . . . . . 8 (𝑛 ∈ (ℤ‘2) → 𝑛 ∈ ℕ)
1917, 18syl 17 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℕ)
20 elfzuz3 13393 . . . . . . . 8 (𝑛 ∈ (2...(𝑁 − 1)) → (𝑁 − 1) ∈ (ℤ𝑛))
2120adantl 483 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑁 − 1) ∈ (ℤ𝑛))
22 dvdsfac 16168 . . . . . . 7 ((𝑛 ∈ ℕ ∧ (𝑁 − 1) ∈ (ℤ𝑛)) → 𝑛 ∥ (!‘(𝑁 − 1)))
2319, 21, 22syl2anc 585 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∥ (!‘(𝑁 − 1)))
24 eluz2nn 12764 . . . . . . . . . 10 (𝑁 ∈ (ℤ‘2) → 𝑁 ∈ ℕ)
2524ad2antrr 725 . . . . . . . . 9 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℕ)
26 nnm1nn0 12413 . . . . . . . . 9 (𝑁 ∈ ℕ → (𝑁 − 1) ∈ ℕ0)
27 faccl 14137 . . . . . . . . 9 ((𝑁 − 1) ∈ ℕ0 → (!‘(𝑁 − 1)) ∈ ℕ)
2825, 26, 273syl 18 . . . . . . . 8 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℕ)
2928nnzd 12485 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℤ)
30 eluz2gt1 12800 . . . . . . . 8 (𝑛 ∈ (ℤ‘2) → 1 < 𝑛)
3117, 30syl 17 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 1 < 𝑛)
32 ndvdsp1 16253 . . . . . . 7 (((!‘(𝑁 − 1)) ∈ ℤ ∧ 𝑛 ∈ ℕ ∧ 1 < 𝑛) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3329, 19, 31, 32syl3anc 1372 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3423, 33mpd 15 . . . . 5 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1))
35 simplr 768 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
3619nnzd 12485 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℤ)
3725nnzd 12485 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℤ)
3829peano2zd 12569 . . . . . . 7 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((!‘(𝑁 − 1)) + 1) ∈ ℤ)
39 dvdstr 16136 . . . . . . 7 ((𝑛 ∈ ℤ ∧ 𝑁 ∈ ℤ ∧ ((!‘(𝑁 − 1)) + 1) ∈ ℤ) → ((𝑛𝑁𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4036, 37, 38, 39syl3anc 1372 . . . . . 6 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((𝑛𝑁𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4135, 40mpan2d 693 . . . . 5 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑛𝑁𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4234, 41mtod 197 . . . 4 (((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ¬ 𝑛𝑁)
4342ralrimiva 3142 . . 3 ((𝑁 ∈ (ℤ‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛𝑁)
44 isprm3 16519 . . 3 (𝑁 ∈ ℙ ↔ (𝑁 ∈ (ℤ‘2) ∧ ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛𝑁))
4515, 43, 44sylanbrc 584 . 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 397  wcel 2107  wral 3063  {crab 3406  𝒫 cpw 4559   class class class wbr 5104  cfv 6494  (class class class)co 7352  1c1 11011   + caddc 11013   < clt 11148  cmin 11344  cn 12112  2c2 12167  0cn0 12372  cz 12458  cuz 12722  ...cfz 13379   mod cmo 13729  cexp 13922  !cfa 14127  cdvds 16096  cprime 16507  mulGrpcmgp 19855  fldccnfld 20749
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1798  ax-4 1812  ax-5 1914  ax-6 1972  ax-7 2012  ax-8 2109  ax-9 2117  ax-10 2138  ax-11 2155  ax-12 2172  ax-ext 2709  ax-rep 5241  ax-sep 5255  ax-nul 5262  ax-pow 5319  ax-pr 5383  ax-un 7665  ax-cnex 11066  ax-resscn 11067  ax-1cn 11068  ax-icn 11069  ax-addcl 11070  ax-addrcl 11071  ax-mulcl 11072  ax-mulrcl 11073  ax-mulcom 11074  ax-addass 11075  ax-mulass 11076  ax-distr 11077  ax-i2m1 11078  ax-1ne0 11079  ax-1rid 11080  ax-rnegex 11081  ax-rrecex 11082  ax-cnre 11083  ax-pre-lttri 11084  ax-pre-lttrn 11085  ax-pre-ltadd 11086  ax-pre-mulgt0 11087  ax-pre-sup 11088  ax-addf 11089  ax-mulf 11090
This theorem depends on definitions:  df-bi 206  df-an 398  df-or 847  df-3or 1089  df-3an 1090  df-tru 1545  df-fal 1555  df-ex 1783  df-nf 1787  df-sb 2069  df-mo 2540  df-eu 2569  df-clab 2716  df-cleq 2730  df-clel 2816  df-nfc 2888  df-ne 2943  df-nel 3049  df-ral 3064  df-rex 3073  df-rmo 3352  df-reu 3353  df-rab 3407  df-v 3446  df-sbc 3739  df-csb 3855  df-dif 3912  df-un 3914  df-in 3916  df-ss 3926  df-pss 3928  df-nul 4282  df-if 4486  df-pw 4561  df-sn 4586  df-pr 4588  df-tp 4590  df-op 4592  df-uni 4865  df-int 4907  df-iun 4955  df-iin 4956  df-br 5105  df-opab 5167  df-mpt 5188  df-tr 5222  df-id 5530  df-eprel 5536  df-po 5544  df-so 5545  df-fr 5587  df-se 5588  df-we 5589  df-xp 5638  df-rel 5639  df-cnv 5640  df-co 5641  df-dm 5642  df-rn 5643  df-res 5644  df-ima 5645  df-pred 6252  df-ord 6319  df-on 6320  df-lim 6321  df-suc 6322  df-iota 6446  df-fun 6496  df-fn 6497  df-f 6498  df-f1 6499  df-fo 6500  df-f1o 6501  df-fv 6502  df-isom 6503  df-riota 7308  df-ov 7355  df-oprab 7356  df-mpo 7357  df-of 7610  df-om 7796  df-1st 7914  df-2nd 7915  df-supp 8086  df-frecs 8205  df-wrecs 8236  df-recs 8310  df-rdg 8349  df-1o 8405  df-2o 8406  df-oadd 8409  df-er 8607  df-en 8843  df-dom 8844  df-sdom 8845  df-fin 8846  df-fsupp 9265  df-sup 9337  df-inf 9338  df-oi 9405  df-dju 9796  df-card 9834  df-pnf 11150  df-mnf 11151  df-xr 11152  df-ltxr 11153  df-le 11154  df-sub 11346  df-neg 11347  df-div 11772  df-nn 12113  df-2 12175  df-3 12176  df-4 12177  df-5 12178  df-6 12179  df-7 12180  df-8 12181  df-9 12182  df-n0 12373  df-xnn0 12445  df-z 12459  df-dec 12578  df-uz 12723  df-rp 12871  df-fz 13380  df-fzo 13523  df-fl 13652  df-mod 13730  df-seq 13862  df-exp 13923  df-fac 14128  df-hash 14185  df-cj 14944  df-re 14945  df-im 14946  df-sqrt 15080  df-abs 15081  df-dvds 16097  df-gcd 16335  df-prm 16508  df-phi 16598  df-struct 16979  df-sets 16996  df-slot 17014  df-ndx 17026  df-base 17044  df-ress 17073  df-plusg 17106  df-mulr 17107  df-starv 17108  df-tset 17112  df-ple 17113  df-ds 17115  df-unif 17116  df-0g 17283  df-gsum 17284  df-mre 17426  df-mrc 17427  df-acs 17429  df-mgm 18457  df-sgrp 18506  df-mnd 18517  df-submnd 18562  df-grp 18711  df-minusg 18712  df-mulg 18832  df-subg 18884  df-cntz 19056  df-cmn 19523  df-mgp 19856  df-ur 19873  df-ring 19920  df-cring 19921  df-subrg 20173  df-cnfld 20750
This theorem is referenced by:  wilthimp  26373
  Copyright terms: Public domain W3C validator