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

Theorem wilth 27404
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 27403 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 16877 . . 3 (𝑁 ∈ ℙ → 𝑁 ∈ (ℤ≥‘2))
2 eqid 2760 . . . 4 (mulGrp‘ℂfld) = (mulGrp‘ℂfld)
3 eleq2w 2844 . . . . . 6 (𝑧 = 𝑥 → ((𝑁 − 1) ∈ 𝑧 ↔ (𝑁 − 1) ∈ 𝑥))
4 oveq1 7428 . . . . . . . . . 10 (𝑛 = 𝑦 → (𝑛↑(𝑁 − 2)) = (𝑦↑(𝑁 − 2)))
54oveq1d 7436 . . . . . . . . 9 (𝑛 = 𝑦 → ((𝑛↑(𝑁 − 2)) mod 𝑁) = ((𝑦↑(𝑁 − 2)) mod 𝑁))
65eleq1d 2845 . . . . . . . 8 (𝑛 = 𝑦 → (((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧))
76cbvralvw 3240 . . . . . . 7 (∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)
8 eleq2w 2844 . . . . . . . 8 (𝑧 = 𝑥 → (((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
98raleqbi1dv 3329 . . . . . . 7 (𝑧 = 𝑥 → (∀𝑦 ∈ 𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
107, 9bitrid 286 . . . . . 6 (𝑧 = 𝑥 → (∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
113, 10anbi12d 644 . . . . 5 (𝑧 = 𝑥 → (((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧) ↔ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)))
1211cbvrabv 3422 . . . 4 {𝑧 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)} = {𝑥 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)}
132, 12wilthlem3 27403 . . 3 (𝑁 ∈ ℙ → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
141, 13jca 521 . 2 (𝑁 ∈ ℙ → (𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
15 simpl 488 . . 3 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ (ℤ≥‘2))
16 elfzuz 13656 . . . . . . . . 9 (𝑛 ∈ (2...(𝑁 − 1)) → 𝑛 ∈ (ℤ≥‘2))
1716adantl 487 . . . . . . . 8 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ (ℤ≥‘2))
18 eluz2nn 13019 . . . . . . . 8 (𝑛 ∈ (ℤ≥‘2) → 𝑛 ∈ ℕ)
1917, 18syl 18 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℕ)
20 elfzuz3 13657 . . . . . . . 8 (𝑛 ∈ (2...(𝑁 − 1)) → (𝑁 − 1) ∈ (ℤ≥‘𝑛))
2120adantl 487 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑁 − 1) ∈ (ℤ≥‘𝑛))
22 dvdsfac 16502 . . . . . . 7 ((𝑛 ∈ ℕ ∧ (𝑁 − 1) ∈ (ℤ≥‘𝑛)) → 𝑛 ∥ (!‘(𝑁 − 1)))
2319, 21, 22syl2anc 596 . . . . . 6 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∥ (!‘(𝑁 − 1)))
24 eluz2nn 13019 . . . . . . . . . 10 (𝑁 ∈ (ℤ≥‘2) → 𝑁 ∈ ℕ)
2524ad2antrr 739 . . . . . . . . 9 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℕ)
26 nnm1nn0 12651 . . . . . . . . 9 (𝑁 ∈ ℕ → (𝑁 − 1) ∈ ℕ0)
27 faccl 14431 . . . . . . . . 9 ((𝑁 − 1) ∈ ℕ0 → (!‘(𝑁 − 1)) ∈ ℕ)
2825, 26, 273syl 19 . . . . . . . 8 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℕ)
2928nnzd 12723 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℤ)
30 eluz2gt1 13051 . . . . . . . 8 (𝑛 ∈ (ℤ≥‘2) → 1 < 𝑛)
3117, 30syl 18 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 1 < 𝑛)
32 ndvdsp1 16587 . . . . . . 7 (((!‘(𝑁 − 1)) ∈ ℤ ∧ 𝑛 ∈ ℕ ∧ 1 < 𝑛) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3329, 19, 31, 32syl3anc 1398 . . . . . 6 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3423, 33mpd 16 . . . . 5 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1))
35 simplr 781 . . . . . 6 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
3619nnzd 12723 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℤ)
3725nnzd 12723 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℤ)
3829peano2zd 12810 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((!‘(𝑁 − 1)) + 1) ∈ ℤ)
39 dvdstr 16470 . . . . . . 7 ((𝑛 ∈ ℤ ∧ 𝑁 ∈ ℤ ∧ ((!‘(𝑁 − 1)) + 1) ∈ ℤ) → ((𝑛 ∥ 𝑁 ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4036, 37, 38, 39syl3anc 1398 . . . . . 6 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((𝑛 ∥ 𝑁 ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4135, 40mpan2d 707 . . . . 5 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑛 ∥ 𝑁 → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4234, 41mtod 201 . . . 4 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ¬ 𝑛 ∥ 𝑁)
4342ralrimiva 3154 . . 3 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛 ∥ 𝑁)
44 isprm3 16864 . . 3 (𝑁 ∈ ℙ ↔ (𝑁 ∈ (ℤ≥‘2) ∧ ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛 ∥ 𝑁))
4515, 43, 44sylanbrc 595 . 2 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ ℙ)
4614, 45impbii 212 1 (𝑁 ∈ ℙ ↔ (𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
Colors of variables:    wff setvar class
This proof depends on syntax axioms:  ¬ wn 3   → wi 4   ↔ wb 209   ∧ wa 401   ∈ wcel 2144  ∀wral 3076  {crab 3412  𝒫 cpw 4556   class class class wbr 5102  ‘cfv 6539  (class class class)co 7421  1c1 11205   + caddc 11207   < clt 11347   − cmin 11545  ℕcn 12339  2c2 12401  ℕ0cn0 12610  ℤcz 12697  ℤ≥cuz 12969  ...cfz 13643   mod cmo 14013  ↑cexp 14208  !cfa 14421   ∥ cdvds 16428  ℙcprime 16852  mulGrpcmgp 20366  ℂfldccnfld 21684
This proof depends on axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1827  ax-4 1841  ax-5 1942  ax-6 1999  ax-7 2040  ax-8 2146  ax-9 2154  ax-10 2177  ax-11 2193  ax-12 2212  ax-ext 2732  ax-rep 5231  ax-sep 5248  ax-nul 5259  ax-pow 5326  ax-pr 5390  ax-un 7752  ax-cnex 11260  ax-resscn 11261  ax-1cn 11262  ax-icn 11263  ax-addcl 11264  ax-addrcl 11265  ax-mulcl 11266  ax-mulrcl 11267  ax-mulcom 11268  ax-addass 11269  ax-mulass 11270  ax-distr 11271  ax-i2m1 11272  ax-1ne0 11273  ax-1rid 11274  ax-rnegex 11275  ax-rrecex 11276  ax-cnre 11277  ax-pre-lttri 11278  ax-pre-lttrn 11279  ax-pre-ltadd 11280  ax-pre-mulgt0 11281  ax-pre-sup 11282  ax-addf 11283  ax-mulf 11284
This proof depends on definitions:  df-bi 210  df-an 402  df-or 862  df-3or 1104  df-3an 1105  df-tru 1572  df-fal 1582  df-ex 1812  df-nf 1816  df-sb 2099  df-mo 2564  df-eu 2594  df-clab 2739  df-cleq 2752  df-clel 2835  df-nfc 2909  df-ne 2956  df-nel 3062  df-ral 3077  df-rex 3087  df-rmo 3365  df-reu 3366  df-rab 3413  df-v 3452  df-sbc 3739  df-csb 3847  df-ss 3896  df-pss 4014  df-dif 4047  df-in 4091  df-un 4151  df-nul 4279  df-if 4482  df-pw 4558  df-sn 4585  df-pr 4587  df-tp 4589  df-op 4835  df-uni 4867  df-int 4907  df-iun 4952  df-iin 4953  df-br 5103  df-opab 5167  df-mpt 5186  df-tr 5212  df-id 5545  df-eprel 5550  df-po 5558  df-so 5559  df-fr 5603  df-se 5604  df-we 5605  df-xp 5656  df-rel 5657  df-cnv 5658  df-co 5659  df-dm 5660  df-rn 5661  df-res 5662  df-ima 5663  df-pred 6304  df-ord 6365  df-on 6366  df-lim 6367  df-suc 6368  df-iota 6494  df-fun 6541  df-fn 6542  df-f 6543  df-f1 6544  df-fo 6545  df-f1o 6546  df-fv 6547  df-isom 6548  df-riota 7378  df-ov 7424  df-oprab 7425  df-mpo 7426  df-of 7694  df-om 7879  df-1st 8002  df-2nd 8003  df-supp 8181  df-frecs 8303  df-wrecs 8334  df-recs 8383  df-rdg 8422  df-1o 8480  df-2o 8481  df-oadd 8484  df-er 8721  df-en 8978  df-dom 8979  df-sdom 8980  df-fin 8981  df-fsupp 9358  df-sup 9438  df-inf 9439  df-oi 9508  df-dju 9986  df-card 10024  df-pnf 11349  df-mnf 11350  df-xr 11351  df-ltxr 11352  df-le 11353  df-sub 11547  df-neg 11548  df-div 11978  df-nn 12340  df-2 12409  df-3 12410  df-4 12411  df-5 12412  df-6 12413  df-7 12414  df-8 12415  df-9 12416  df-n0 12611  df-xnn0 12684  df-z 12698  df-dec 12819  df-uz 12970  df-rp 13125  df-fz 13644  df-fzo 13793  df-fl 13936  df-mod 14014  df-seq 14149  df-exp 14209  df-fac 14422  df-hash 14479  df-cj 15272  df-re 15273  df-im 15274  df-sqrt 15408  df-abs 15409  df-dvds 16429  df-gcd 16671  df-prm 16853  df-phi 16949  df-struct 17331  df-sets 17348  df-slot 17366  df-ndx 17378  df-base 17394  df-ress 17415  df-plusg 17447  df-mulr 17448  df-starv 17449  df-tset 17453  df-ple 17454  df-ds 17456  df-unif 17457  df-0g 17618  df-gsum 17619  df-mre 17762  df-mrc 17763  df-acs 17765  df-mgm 18822  df-sgrp 18914  df-mnd 18930  df-submnd 18985  df-grp 19153  df-minusg 19154  df-mulg 19284  df-subg 19339  df-cntz 19537  df-cmn 20002  df-abl 20003  df-mgp 20367  df-rng 20381  df-ur 20414  df-ring 20467  df-cring 20468  df-subrng 20804  df-subrg 20828  df-cnfld 21685
This theorem is used by:  wilthimp  27405  ppivalnnprm  48804
  Copyright terms: Public domain W3C validator