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

Theorem wilth 27391
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 27390 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 16864 . . 3 (𝑁 ∈ ℙ → 𝑁 ∈ (ℤ≥‘2))
2 eqid 2761 . . . 4 (mulGrp‘ℂfld) = (mulGrp‘ℂfld)
3 eleq2w 2845 . . . . . 6 (𝑧 = 𝑥 → ((𝑁 − 1) ∈ 𝑧 ↔ (𝑁 − 1) ∈ 𝑥))
4 oveq1 7425 . . . . . . . . . 10 (𝑛 = 𝑦 → (𝑛↑(𝑁 − 2)) = (𝑦↑(𝑁 − 2)))
54oveq1d 7433 . . . . . . . . 9 (𝑛 = 𝑦 → ((𝑛↑(𝑁 − 2)) mod 𝑁) = ((𝑦↑(𝑁 − 2)) mod 𝑁))
65eleq1d 2846 . . . . . . . 8 (𝑛 = 𝑦 → (((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧))
76cbvralvw 3241 . . . . . . 7 (∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)
8 eleq2w 2845 . . . . . . . 8 (𝑧 = 𝑥 → (((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
98raleqbi1dv 3330 . . . . . . 7 (𝑧 = 𝑥 → (∀𝑦 ∈ 𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
107, 9bitrid 286 . . . . . 6 (𝑧 = 𝑥 → (∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
113, 10anbi12d 644 . . . . 5 (𝑧 = 𝑥 → (((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧) ↔ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)))
1211cbvrabv 3423 . . . 4 {𝑧 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)} = {𝑥 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)}
132, 12wilthlem3 27390 . . 3 (𝑁 ∈ ℙ → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
141, 13jca 521 . 2 (𝑁 ∈ ℙ → (𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
15 simpl 488 . . 3 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ (ℤ≥‘2))
16 elfzuz 13645 . . . . . . . . 9 (𝑛 ∈ (2...(𝑁 − 1)) → 𝑛 ∈ (ℤ≥‘2))
1716adantl 487 . . . . . . . 8 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ (ℤ≥‘2))
18 eluz2nn 13008 . . . . . . . 8 (𝑛 ∈ (ℤ≥‘2) → 𝑛 ∈ ℕ)
1917, 18syl 18 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℕ)
20 elfzuz3 13646 . . . . . . . 8 (𝑛 ∈ (2...(𝑁 − 1)) → (𝑁 − 1) ∈ (ℤ≥‘𝑛))
2120adantl 487 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑁 − 1) ∈ (ℤ≥‘𝑛))
22 dvdsfac 16489 . . . . . . 7 ((𝑛 ∈ ℕ ∧ (𝑁 − 1) ∈ (ℤ≥‘𝑛)) → 𝑛 ∥ (!‘(𝑁 − 1)))
2319, 21, 22syl2anc 596 . . . . . 6 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∥ (!‘(𝑁 − 1)))
24 eluz2nn 13008 . . . . . . . . . 10 (𝑁 ∈ (ℤ≥‘2) → 𝑁 ∈ ℕ)
2524ad2antrr 739 . . . . . . . . 9 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℕ)
26 nnm1nn0 12640 . . . . . . . . 9 (𝑁 ∈ ℕ → (𝑁 − 1) ∈ ℕ0)
27 faccl 14420 . . . . . . . . 9 ((𝑁 − 1) ∈ ℕ0 → (!‘(𝑁 − 1)) ∈ ℕ)
2825, 26, 273syl 19 . . . . . . . 8 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℕ)
2928nnzd 12712 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℤ)
30 eluz2gt1 13040 . . . . . . . 8 (𝑛 ∈ (ℤ≥‘2) → 1 < 𝑛)
3117, 30syl 18 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 1 < 𝑛)
32 ndvdsp1 16574 . . . . . . 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 12712 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℤ)
3725nnzd 12712 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℤ)
3829peano2zd 12799 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((!‘(𝑁 − 1)) + 1) ∈ ℤ)
39 dvdstr 16457 . . . . . . 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 3155 . . 3 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛 ∥ 𝑁)
44 isprm3 16851 . . 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 2145  ∀wral 3077  {crab 3413  𝒫 cpw 4557   class class class wbr 5103  ‘cfv 6537  (class class class)co 7418  1c1 11194   + caddc 11196   < clt 11336   − cmin 11534  ℕcn 12328  2c2 12390  ℕ0cn0 12599  ℤcz 12686  ℤ≥cuz 12958  ...cfz 13632   mod cmo 14002  ↑cexp 14197  !cfa 14410   ∥ cdvds 16415  ℙcprime 16839  mulGrpcmgp 20353  ℂfldccnfld 21671
This proof depends on axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1828  ax-4 1842  ax-5 1943  ax-6 2000  ax-7 2041  ax-8 2147  ax-9 2155  ax-10 2178  ax-11 2194  ax-12 2213  ax-ext 2733  ax-rep 5232  ax-sep 5249  ax-nul 5260  ax-pow 5327  ax-pr 5391  ax-un 7749  ax-cnex 11249  ax-resscn 11250  ax-1cn 11251  ax-icn 11252  ax-addcl 11253  ax-addrcl 11254  ax-mulcl 11255  ax-mulrcl 11256  ax-mulcom 11257  ax-addass 11258  ax-mulass 11259  ax-distr 11260  ax-i2m1 11261  ax-1ne0 11262  ax-1rid 11263  ax-rnegex 11264  ax-rrecex 11265  ax-cnre 11266  ax-pre-lttri 11267  ax-pre-lttrn 11268  ax-pre-ltadd 11269  ax-pre-mulgt0 11270  ax-pre-sup 11271  ax-addf 11272  ax-mulf 11273
This proof depends on definitions:  df-bi 210  df-an 402  df-or 862  df-3or 1104  df-3an 1105  df-tru 1573  df-fal 1583  df-ex 1813  df-nf 1817  df-sb 2100  df-mo 2565  df-eu 2595  df-clab 2740  df-cleq 2753  df-clel 2836  df-nfc 2910  df-ne 2957  df-nel 3063  df-ral 3078  df-rex 3088  df-rmo 3366  df-reu 3367  df-rab 3414  df-v 3453  df-sbc 3740  df-csb 3848  df-dif 3902  df-un 3904  df-in 3906  df-ss 3916  df-pss 3919  df-nul 4280  df-if 4483  df-pw 4559  df-sn 4585  df-pr 4587  df-tp 4589  df-op 4591  df-uni 4868  df-int 4908  df-iun 4953  df-iin 4954  df-br 5104  df-opab 5168  df-mpt 5187  df-tr 5213  df-id 5546  df-eprel 5551  df-po 5559  df-so 5560  df-fr 5604  df-se 5605  df-we 5606  df-xp 5657  df-rel 5658  df-cnv 5659  df-co 5660  df-dm 5661  df-rn 5662  df-res 5663  df-ima 5664  df-pred 6303  df-ord 6364  df-on 6365  df-lim 6366  df-suc 6367  df-iota 6493  df-fun 6539  df-fn 6540  df-f 6541  df-f1 6542  df-fo 6543  df-f1o 6544  df-fv 6545  df-isom 6546  df-riota 7375  df-ov 7421  df-oprab 7422  df-mpo 7423  df-of 7691  df-om 7876  df-1st 7999  df-2nd 8000  df-supp 8171  df-frecs 8292  df-wrecs 8323  df-recs 8372  df-rdg 8411  df-1o 8469  df-2o 8470  df-oadd 8473  df-er 8710  df-en 8967  df-dom 8968  df-sdom 8969  df-fin 8970  df-fsupp 9347  df-sup 9427  df-inf 9428  df-oi 9497  df-dju 9975  df-card 10013  df-pnf 11338  df-mnf 11339  df-xr 11340  df-ltxr 11341  df-le 11342  df-sub 11536  df-neg 11537  df-div 11967  df-nn 12329  df-2 12398  df-3 12399  df-4 12400  df-5 12401  df-6 12402  df-7 12403  df-8 12404  df-9 12405  df-n0 12600  df-xnn0 12673  df-z 12687  df-dec 12808  df-uz 12959  df-rp 13114  df-fz 13633  df-fzo 13782  df-fl 13925  df-mod 14003  df-seq 14138  df-exp 14198  df-fac 14411  df-hash 14468  df-cj 15259  df-re 15260  df-im 15261  df-sqrt 15395  df-abs 15396  df-dvds 16416  df-gcd 16658  df-prm 16840  df-phi 16936  df-struct 17318  df-sets 17335  df-slot 17353  df-ndx 17365  df-base 17381  df-ress 17402  df-plusg 17434  df-mulr 17435  df-starv 17436  df-tset 17440  df-ple 17441  df-ds 17443  df-unif 17444  df-0g 17605  df-gsum 17606  df-mre 17749  df-mrc 17750  df-acs 17752  df-mgm 18809  df-sgrp 18901  df-mnd 18917  df-submnd 18972  df-grp 19140  df-minusg 19141  df-mulg 19271  df-subg 19326  df-cntz 19524  df-cmn 19989  df-abl 19990  df-mgp 20354  df-rng 20368  df-ur 20401  df-ring 20454  df-cring 20455  df-subrng 20791  df-subrg 20815  df-cnfld 21672
This theorem is used by:  wilthimp  27392  ppivalnnprm  48679
  Copyright terms: Public domain W3C validator