MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  reumodprminv Structured version   Unicode version

Theorem reumodprminv 13868
Description: For any prime number and for any positive integer less than this prime number, there is a unique modular inverse of this positive integer. (Contributed by Alexander van der Vekens, 12-May-2018.)
Assertion
Ref Expression
reumodprminv  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  E! i  e.  ( 1 ... ( P  -  1 ) ) ( ( N  x.  i )  mod 
P )  =  1 )
Distinct variable groups:    i, N    P, i

Proof of Theorem reumodprminv
Dummy variable  s is distinct from all other variables.
StepHypRef Expression
1 simpl 454 . . . 4  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  P  e.  Prime )
2 elfzoelz 11549 . . . . 5  |-  ( N  e.  ( 1..^ P )  ->  N  e.  ZZ )
32adantl 463 . . . 4  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  N  e.  ZZ )
4 prmnn 13762 . . . . . . 7  |-  ( P  e.  Prime  ->  P  e.  NN )
54adantr 462 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  P  e.  NN )
6 prmz 13763 . . . . . . . . 9  |-  ( P  e.  Prime  ->  P  e.  ZZ )
7 fzoval 11550 . . . . . . . . 9  |-  ( P  e.  ZZ  ->  (
1..^ P )  =  ( 1 ... ( P  -  1 ) ) )
86, 7syl 16 . . . . . . . 8  |-  ( P  e.  Prime  ->  ( 1..^ P )  =  ( 1 ... ( P  -  1 ) ) )
98eleq2d 2508 . . . . . . 7  |-  ( P  e.  Prime  ->  ( N  e.  ( 1..^ P )  <->  N  e.  (
1 ... ( P  - 
1 ) ) ) )
109biimpa 481 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  N  e.  ( 1 ... ( P  -  1 ) ) )
115, 10jca 529 . . . . 5  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  ( P  e.  NN  /\  N  e.  ( 1 ... ( P  -  1 ) ) ) )
12 fzm1ndvds 13581 . . . . 5  |-  ( ( P  e.  NN  /\  N  e.  ( 1 ... ( P  - 
1 ) ) )  ->  -.  P  ||  N
)
1311, 12syl 16 . . . 4  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  -.  P  ||  N )
14 eqid 2441 . . . . . . 7  |-  ( ( N ^ ( P  -  2 ) )  mod  P )  =  ( ( N ^
( P  -  2 ) )  mod  P
)
1514modprminv 13866 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( ( N ^
( P  -  2 ) )  mod  P
)  e.  ( 1 ... ( P  - 
1 ) )  /\  ( ( N  x.  ( ( N ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  1 ) )
1615simpld 456 . . . . 5  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( N ^ ( P  -  2 ) )  mod  P )  e.  ( 1 ... ( P  -  1 ) ) )
1715simprd 460 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( N  x.  (
( N ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  1 )
18 1nn0 10591 . . . . . . . . . . . . 13  |-  1  e.  NN0
19 elnn0uz 10894 . . . . . . . . . . . . 13  |-  ( 1  e.  NN0  <->  1  e.  (
ZZ>= `  0 ) )
2018, 19mpbi 208 . . . . . . . . . . . 12  |-  1  e.  ( ZZ>= `  0 )
21 fzss1 11493 . . . . . . . . . . . 12  |-  ( 1  e.  ( ZZ>= `  0
)  ->  ( 1 ... ( P  - 
1 ) )  C_  ( 0 ... ( P  -  1 ) ) )
2220, 21mp1i 12 . . . . . . . . . . 11  |-  ( P  e.  Prime  ->  ( 1 ... ( P  - 
1 ) )  C_  ( 0 ... ( P  -  1 ) ) )
2322sseld 3352 . . . . . . . . . 10  |-  ( P  e.  Prime  ->  ( s  e.  ( 1 ... ( P  -  1 ) )  ->  s  e.  ( 0 ... ( P  -  1 ) ) ) )
24233ad2ant1 1004 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
s  e.  ( 1 ... ( P  - 
1 ) )  -> 
s  e.  ( 0 ... ( P  - 
1 ) ) ) )
2524imdistani 685 . . . . . . . 8  |-  ( ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  /\  s  e.  ( 1 ... ( P  -  1 ) ) )  ->  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  /\  s  e.  ( 0 ... ( P  -  1 ) ) ) )
2614modprminveq 13867 . . . . . . . . . . 11  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( s  e.  ( 0 ... ( P  -  1 ) )  /\  ( ( N  x.  s )  mod 
P )  =  1 )  <->  s  =  ( ( N ^ ( P  -  2 ) )  mod  P ) ) )
2726biimpa 481 . . . . . . . . . 10  |-  ( ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  /\  ( s  e.  ( 0 ... ( P  -  1 ) )  /\  ( ( N  x.  s )  mod  P )  =  1 ) )  -> 
s  =  ( ( N ^ ( P  -  2 ) )  mod  P ) )
2827eqcomd 2446 . . . . . . . . 9  |-  ( ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  /\  ( s  e.  ( 0 ... ( P  -  1 ) )  /\  ( ( N  x.  s )  mod  P )  =  1 ) )  -> 
( ( N ^
( P  -  2 ) )  mod  P
)  =  s )
2928expr 612 . . . . . . . 8  |-  ( ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  /\  s  e.  ( 0 ... ( P  -  1 ) ) )  ->  ( (
( N  x.  s
)  mod  P )  =  1  ->  (
( N ^ ( P  -  2 ) )  mod  P )  =  s ) )
3025, 29syl 16 . . . . . . 7  |-  ( ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  /\  s  e.  ( 1 ... ( P  -  1 ) ) )  ->  ( (
( N  x.  s
)  mod  P )  =  1  ->  (
( N ^ ( P  -  2 ) )  mod  P )  =  s ) )
3130ralrimiva 2797 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod  P )  =  1  ->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) )
3217, 31jca 529 . . . . 5  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( ( N  x.  ( ( N ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  1  /\ 
A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod 
P )  =  1  ->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) ) )
3316, 32jca 529 . . . 4  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( ( N ^
( P  -  2 ) )  mod  P
)  e.  ( 1 ... ( P  - 
1 ) )  /\  ( ( ( N  x.  ( ( N ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P )  =  1  /\  A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod  P )  =  1  ->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) ) ) )
341, 3, 13, 33syl3anc 1213 . . 3  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  ( (
( N ^ ( P  -  2 ) )  mod  P )  e.  ( 1 ... ( P  -  1 ) )  /\  (
( ( N  x.  ( ( N ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  1  /\ 
A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod 
P )  =  1  ->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) ) ) )
35 oveq2 6098 . . . . . . 7  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  ( N  x.  i )  =  ( N  x.  ( ( N ^
( P  -  2 ) )  mod  P
) ) )
3635oveq1d 6105 . . . . . 6  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  (
( N  x.  i
)  mod  P )  =  ( ( N  x.  ( ( N ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P ) )
3736eqeq1d 2449 . . . . 5  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  (
( ( N  x.  i )  mod  P
)  =  1  <->  (
( N  x.  (
( N ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  1 ) )
38 eqeq1 2447 . . . . . . 7  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  (
i  =  s  <->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) )
3938imbi2d 316 . . . . . 6  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  (
( ( ( N  x.  s )  mod 
P )  =  1  ->  i  =  s )  <->  ( ( ( N  x.  s )  mod  P )  =  1  ->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) ) )
4039ralbidv 2733 . . . . 5  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  ( A. s  e.  (
1 ... ( P  - 
1 ) ) ( ( ( N  x.  s )  mod  P
)  =  1  -> 
i  =  s )  <->  A. s  e.  (
1 ... ( P  - 
1 ) ) ( ( ( N  x.  s )  mod  P
)  =  1  -> 
( ( N ^
( P  -  2 ) )  mod  P
)  =  s ) ) )
4137, 40anbi12d 705 . . . 4  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  (
( ( ( N  x.  i )  mod 
P )  =  1  /\  A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod  P )  =  1  ->  i  =  s ) )  <->  ( (
( N  x.  (
( N ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  1  /\  A. s  e.  ( 1 ... ( P  - 
1 ) ) ( ( ( N  x.  s )  mod  P
)  =  1  -> 
( ( N ^
( P  -  2 ) )  mod  P
)  =  s ) ) ) )
4241rspcev 3070 . . 3  |-  ( ( ( ( N ^
( P  -  2 ) )  mod  P
)  e.  ( 1 ... ( P  - 
1 ) )  /\  ( ( ( N  x.  ( ( N ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P )  =  1  /\  A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod  P )  =  1  ->  ( ( N ^ ( P  - 
2 ) )  mod 
P )  =  s ) ) )  ->  E. i  e.  (
1 ... ( P  - 
1 ) ) ( ( ( N  x.  i )  mod  P
)  =  1  /\ 
A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod 
P )  =  1  ->  i  =  s ) ) )
4334, 42syl 16 . 2  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  E. i  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  i )  mod  P )  =  1  /\  A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod  P )  =  1  ->  i  =  s ) ) )
44 oveq2 6098 . . . . 5  |-  ( i  =  s  ->  ( N  x.  i )  =  ( N  x.  s ) )
4544oveq1d 6105 . . . 4  |-  ( i  =  s  ->  (
( N  x.  i
)  mod  P )  =  ( ( N  x.  s )  mod 
P ) )
4645eqeq1d 2449 . . 3  |-  ( i  =  s  ->  (
( ( N  x.  i )  mod  P
)  =  1  <->  (
( N  x.  s
)  mod  P )  =  1 ) )
4746reu8 3152 . 2  |-  ( E! i  e.  ( 1 ... ( P  - 
1 ) ) ( ( N  x.  i
)  mod  P )  =  1  <->  E. i  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  i )  mod  P )  =  1  /\  A. s  e.  ( 1 ... ( P  -  1 ) ) ( ( ( N  x.  s )  mod  P )  =  1  ->  i  =  s ) ) )
4843, 47sylibr 212 1  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  E! i  e.  ( 1 ... ( P  -  1 ) ) ( ( N  x.  i )  mod 
P )  =  1 )
Colors of variables: wff setvar class
Syntax hints:   -. wn 3    -> wi 4    /\ wa 369    /\ w3a 960    = wceq 1364    e. wcel 1761   A.wral 2713   E.wrex 2714   E!wreu 2715    C_ wss 3325   class class class wbr 4289   ` cfv 5415  (class class class)co 6090   0cc0 9278   1c1 9279    x. cmul 9283    - cmin 9591   NNcn 10318   2c2 10367   NN0cn0 10575   ZZcz 10642   ZZ>=cuz 10857   ...cfz 11433  ..^cfzo 11544    mod cmo 11704   ^cexp 11861    || cdivides 13531   Primecprime 13759
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1596  ax-4 1607  ax-5 1675  ax-6 1713  ax-7 1733  ax-8 1763  ax-9 1765  ax-10 1780  ax-11 1785  ax-12 1797  ax-13 1948  ax-ext 2422  ax-rep 4400  ax-sep 4410  ax-nul 4418  ax-pow 4467  ax-pr 4528  ax-un 6371  ax-cnex 9334  ax-resscn 9335  ax-1cn 9336  ax-icn 9337  ax-addcl 9338  ax-addrcl 9339  ax-mulcl 9340  ax-mulrcl 9341  ax-mulcom 9342  ax-addass 9343  ax-mulass 9344  ax-distr 9345  ax-i2m1 9346  ax-1ne0 9347  ax-1rid 9348  ax-rnegex 9349  ax-rrecex 9350  ax-cnre 9351  ax-pre-lttri 9352  ax-pre-lttrn 9353  ax-pre-ltadd 9354  ax-pre-mulgt0 9355  ax-pre-sup 9356
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 961  df-3an 962  df-tru 1367  df-ex 1592  df-nf 1595  df-sb 1706  df-eu 2263  df-mo 2264  df-clab 2428  df-cleq 2434  df-clel 2437  df-nfc 2566  df-ne 2606  df-nel 2607  df-ral 2718  df-rex 2719  df-reu 2720  df-rmo 2721  df-rab 2722  df-v 2972  df-sbc 3184  df-csb 3286  df-dif 3328  df-un 3330  df-in 3332  df-ss 3339  df-pss 3341  df-nul 3635  df-if 3789  df-pw 3859  df-sn 3875  df-pr 3877  df-tp 3879  df-op 3881  df-uni 4089  df-int 4126  df-iun 4170  df-br 4290  df-opab 4348  df-mpt 4349  df-tr 4383  df-eprel 4628  df-id 4632  df-po 4637  df-so 4638  df-fr 4675  df-we 4677  df-ord 4718  df-on 4719  df-lim 4720  df-suc 4721  df-xp 4842  df-rel 4843  df-cnv 4844  df-co 4845  df-dm 4846  df-rn 4847  df-res 4848  df-ima 4849  df-iota 5378  df-fun 5417  df-fn 5418  df-f 5419  df-f1 5420  df-fo 5421  df-f1o 5422  df-fv 5423  df-riota 6049  df-ov 6093  df-oprab 6094  df-mpt2 6095  df-om 6476  df-1st 6576  df-2nd 6577  df-recs 6828  df-rdg 6862  df-1o 6916  df-2o 6917  df-oadd 6920  df-er 7097  df-map 7212  df-en 7307  df-dom 7308  df-sdom 7309  df-fin 7310  df-sup 7687  df-card 8105  df-cda 8333  df-pnf 9416  df-mnf 9417  df-xr 9418  df-ltxr 9419  df-le 9420  df-sub 9593  df-neg 9594  df-div 9990  df-nn 10319  df-2 10376  df-3 10377  df-n0 10576  df-z 10643  df-uz 10858  df-rp 10988  df-fz 11434  df-fzo 11545  df-fl 11638  df-mod 11705  df-seq 11803  df-exp 11862  df-hash 12100  df-cj 12584  df-re 12585  df-im 12586  df-sqr 12720  df-abs 12721  df-dvds 13532  df-gcd 13687  df-prm 13760  df-phi 13837
This theorem is referenced by:  modprm0  13869
  Copyright terms: Public domain W3C validator