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

Theorem wilth 27444
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 27443 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 16912 . . 3 (𝑁 ∈ ℙ → 𝑁 ∈ (ℤ≥‘2))
2 eqid 2763 . . . 4 (mulGrp‘ℂfld) = (mulGrp‘ℂfld)
3 eleq2w 2848 . . . . . 6 (𝑧 = 𝑥 → ((𝑁 − 1) ∈ 𝑧 ↔ (𝑁 − 1) ∈ 𝑥))
4 oveq1 7456 . . . . . . . . . 10 (𝑛 = 𝑦 → (𝑛↑(𝑁 − 2)) = (𝑦↑(𝑁 − 2)))
54oveq1d 7464 . . . . . . . . 9 (𝑛 = 𝑦 → ((𝑛↑(𝑁 − 2)) mod 𝑁) = ((𝑦↑(𝑁 − 2)) mod 𝑁))
65eleq1d 2849 . . . . . . . 8 (𝑛 = 𝑦 → (((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧))
76cbvralvw 3244 . . . . . . 7 (∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)
8 eleq2w 2848 . . . . . . . 8 (𝑧 = 𝑥 → (((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
98raleqbi1dv 3333 . . . . . . 7 (𝑧 = 𝑥 → (∀𝑦 ∈ 𝑧 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
107, 9bitrid 286 . . . . . 6 (𝑧 = 𝑥 → (∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧 ↔ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥))
113, 10anbi12d 644 . . . . 5 (𝑧 = 𝑥 → (((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧) ↔ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)))
1211cbvrabv 3426 . . . 4 {𝑧 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑧 ∧ ∀𝑛 ∈ 𝑧 ((𝑛↑(𝑁 − 2)) mod 𝑁) ∈ 𝑧)} = {𝑥 ∈ 𝒫 (1...(𝑁 − 1)) ∣ ((𝑁 − 1) ∈ 𝑥 ∧ ∀𝑦 ∈ 𝑥 ((𝑦↑(𝑁 − 2)) mod 𝑁) ∈ 𝑥)}
132, 12wilthlem3 27443 . . 3 (𝑁 ∈ ℙ → 𝑁 ∥ ((!‘(𝑁 − 1)) + 1))
141, 13jca 521 . 2 (𝑁 ∈ ℙ → (𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)))
15 simpl 488 . . 3 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑁 ∈ (ℤ≥‘2))
16 elfzuz 13690 . . . . . . . . 9 (𝑛 ∈ (2...(𝑁 − 1)) → 𝑛 ∈ (ℤ≥‘2))
1716adantl 487 . . . . . . . 8 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ (ℤ≥‘2))
18 eluz2nn 13053 . . . . . . . 8 (𝑛 ∈ (ℤ≥‘2) → 𝑛 ∈ ℕ)
1917, 18syl 18 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℕ)
20 elfzuz3 13691 . . . . . . . 8 (𝑛 ∈ (2...(𝑁 − 1)) → (𝑁 − 1) ∈ (ℤ≥‘𝑛))
2120adantl 487 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (𝑁 − 1) ∈ (ℤ≥‘𝑛))
22 dvdsfac 16537 . . . . . . 7 ((𝑛 ∈ ℕ ∧ (𝑁 − 1) ∈ (ℤ≥‘𝑛)) → 𝑛 ∥ (!‘(𝑁 − 1)))
2319, 21, 22syl2anc 596 . . . . . 6 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∥ (!‘(𝑁 − 1)))
24 eluz2nn 13053 . . . . . . . . . 10 (𝑁 ∈ (ℤ≥‘2) → 𝑁 ∈ ℕ)
2524ad2antrr 739 . . . . . . . . 9 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℕ)
26 nnm1nn0 12685 . . . . . . . . 9 (𝑁 ∈ ℕ → (𝑁 − 1) ∈ ℕ0)
27 faccl 14466 . . . . . . . . 9 ((𝑁 − 1) ∈ ℕ0 → (!‘(𝑁 − 1)) ∈ ℕ)
2825, 26, 273syl 19 . . . . . . . 8 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℕ)
2928nnzd 12757 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → (!‘(𝑁 − 1)) ∈ ℤ)
30 eluz2gt1 13085 . . . . . . . 8 (𝑛 ∈ (ℤ≥‘2) → 1 < 𝑛)
3117, 30syl 18 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 1 < 𝑛)
32 ndvdsp1 16622 . . . . . . 7 (((!‘(𝑁 − 1)) ∈ ℤ ∧ 𝑛 ∈ ℕ ∧ 1 < 𝑛) → (𝑛 ∥ (!‘(𝑁 − 1)) → ¬ 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
3329, 19, 31, 32syl3anc 1399 . . . . . 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 12757 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑛 ∈ ℤ)
3725nnzd 12757 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → 𝑁 ∈ ℤ)
3829peano2zd 12844 . . . . . . 7 (((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) ∧ 𝑛 ∈ (2...(𝑁 − 1))) → ((!‘(𝑁 − 1)) + 1) ∈ ℤ)
39 dvdstr 16505 . . . . . . 7 ((𝑛 ∈ ℤ ∧ 𝑁 ∈ ℤ ∧ ((!‘(𝑁 − 1)) + 1) ∈ ℤ) → ((𝑛 ∥ 𝑁 ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → 𝑛 ∥ ((!‘(𝑁 − 1)) + 1)))
4036, 37, 38, 39syl3anc 1399 . . . . . 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 3158 . . 3 ((𝑁 ∈ (ℤ≥‘2) ∧ 𝑁 ∥ ((!‘(𝑁 − 1)) + 1)) → ∀𝑛 ∈ (2...(𝑁 − 1)) ¬ 𝑛 ∥ 𝑁)
44 isprm3 16899 . . 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 2147  ∀wral 3080  {crab 3416  𝒫 cpw 4560   class class class wbr 5106  ‘cfv 6564  (class class class)co 7449  1c1 11238   + caddc 11240   < clt 11380   − cmin 11578  ℕcn 12373  2c2 12435  ℕ0cn0 12644  ℤcz 12731  ℤ≥cuz 13003  ...cfz 13677   mod cmo 14047  ↑cexp 14242  !cfa 14456   ∥ cdvds 16463  ℙcprime 16887  mulGrpcmgp 20402  ℂfldccnfld 21720
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 1945  ax-6 2002  ax-7 2043  ax-8 2149  ax-9 2157  ax-10 2180  ax-11 2197  ax-12 2216  ax-ext 2735  ax-rep 5236  ax-sep 5253  ax-nul 5264  ax-pow 5332  ax-pr 5396  ax-un 7781  ax-cnex 11293  ax-resscn 11294  ax-1cn 11295  ax-icn 11296  ax-addcl 11297  ax-addrcl 11298  ax-mulcl 11299  ax-mulrcl 11300  ax-mulcom 11301  ax-addass 11302  ax-mulass 11303  ax-distr 11304  ax-i2m1 11305  ax-1ne0 11306  ax-1rid 11307  ax-rnegex 11308  ax-rrecex 11309  ax-cnre 11310  ax-pre-lttri 11311  ax-pre-lttrn 11312  ax-pre-ltadd 11313  ax-pre-mulgt0 11314  ax-pre-sup 11315  ax-addf 11316  ax-mulf 11317
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 2102  df-mo 2567  df-eu 2597  df-clab 2742  df-cleq 2755  df-clel 2839  df-nfc 2913  df-ne 2960  df-nel 3066  df-ral 3081  df-rex 3091  df-rmo 3369  df-reu 3370  df-rab 3417  df-v 3456  df-sbc 3743  df-csb 3852  df-ss 3901  df-pss 4017  df-dif 4050  df-in 4094  df-un 4154  df-nul 4282  df-if 4486  df-pw 4562  df-sn 4589  df-pr 4591  df-tp 4593  df-op 4839  df-uni 4871  df-int 4911  df-iun 4956  df-iin 4957  df-br 5107  df-opab 5172  df-mpt 5191  df-tr 5217  df-id 5551  df-eprel 5556  df-po 5564  df-so 5565  df-fr 5609  df-se 5610  df-we 5611  df-xp 5662  df-rel 5663  df-cnv 5664  df-co 5665  df-dm 5666  df-rn 5667  df-res 5668  df-ima 5669  df-pred 6328  df-ord 6389  df-on 6390  df-lim 6391  df-suc 6392  df-iota 6518  df-fun 6566  df-fn 6567  df-f 6568  df-f1 6569  df-fo 6570  df-f1o 6571  df-fv 6572  df-isom 6573  df-riota 7406  df-ov 7452  df-oprab 7453  df-mpo 7454  df-of 7723  df-om 7910  df-1st 8033  df-2nd 8034  df-supp 8213  df-frecs 8335  df-wrecs 8366  df-recs 8415  df-rdg 8454  df-1o 8512  df-2o 8513  df-oadd 8516  df-er 8753  df-en 9010  df-dom 9011  df-sdom 9012  df-fin 9013  df-fsupp 9390  df-sup 9469  df-inf 9470  df-oi 9539  df-dju 10017  df-card 10055  df-pnf 11382  df-mnf 11383  df-xr 11384  df-ltxr 11385  df-le 11386  df-sub 11580  df-neg 11581  df-div 12012  df-nn 12374  df-2 12443  df-3 12444  df-4 12445  df-5 12446  df-6 12447  df-7 12448  df-8 12449  df-9 12450  df-n0 12645  df-xnn0 12718  df-z 12732  df-dec 12853  df-uz 13004  df-rp 13159  df-fz 13678  df-fzo 13827  df-fl 13970  df-mod 14048  df-seq 14183  df-exp 14243  df-fac 14457  df-hash 14514  df-cj 15307  df-re 15308  df-im 15309  df-sqrt 15443  df-abs 15444  df-dvds 16464  df-gcd 16706  df-prm 16888  df-phi 16984  df-struct 17366  df-sets 17383  df-slot 17401  df-ndx 17413  df-base 17429  df-ress 17450  df-plusg 17482  df-mulr 17483  df-starv 17484  df-tset 17488  df-ple 17489  df-ds 17491  df-unif 17492  df-0g 17653  df-gsum 17654  df-mre 17797  df-mrc 17798  df-acs 17800  df-mgm 18857  df-sgrp 18949  df-mnd 18965  df-submnd 19020  df-grp 19188  df-minusg 19189  df-mulg 19319  df-subg 19374  df-cntz 19573  df-cmn 20038  df-abl 20039  df-mgp 20403  df-rng 20417  df-ur 20450  df-ring 20503  df-cring 20504  df-subrng 20840  df-subrg 20864  df-cnfld 21721
This theorem is used by:  wilthimp  27445  ppivalnnprm  48977
  Copyright terms: Public domain W3C validator