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

Theorem reumodprminv 14205
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 457 . . . 4  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  P  e.  Prime )
2 elfzoelz 11809 . . . . 5  |-  ( N  e.  ( 1..^ P )  ->  N  e.  ZZ )
32adantl 466 . . . 4  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  N  e.  ZZ )
4 prmnn 14096 . . . . . . 7  |-  ( P  e.  Prime  ->  P  e.  NN )
54adantr 465 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  P  e.  NN )
6 prmz 14097 . . . . . . . . 9  |-  ( P  e.  Prime  ->  P  e.  ZZ )
7 fzoval 11810 . . . . . . . . 9  |-  ( P  e.  ZZ  ->  (
1..^ P )  =  ( 1 ... ( P  -  1 ) ) )
86, 7syl 16 . . . . . . . 8  |-  ( P  e.  Prime  ->  ( 1..^ P )  =  ( 1 ... ( P  -  1 ) ) )
98eleq2d 2537 . . . . . . 7  |-  ( P  e.  Prime  ->  ( N  e.  ( 1..^ P )  <->  N  e.  (
1 ... ( P  - 
1 ) ) ) )
109biimpa 484 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  N  e.  ( 1 ... ( P  -  1 ) ) )
115, 10jca 532 . . . . 5  |-  ( ( P  e.  Prime  /\  N  e.  ( 1..^ P ) )  ->  ( P  e.  NN  /\  N  e.  ( 1 ... ( P  -  1 ) ) ) )
12 fzm1ndvds 13914 . . . . 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 2467 . . . . . . 7  |-  ( ( N ^ ( P  -  2 ) )  mod  P )  =  ( ( N ^
( P  -  2 ) )  mod  P
)
1514modprminv 14202 . . . . . 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 459 . . . . 5  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( N ^ ( P  -  2 ) )  mod  P )  e.  ( 1 ... ( P  -  1 ) ) )
1715simprd 463 . . . . . 6  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
( N  x.  (
( N ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  1 )
18 1nn0 10823 . . . . . . . . . . . . 13  |-  1  e.  NN0
19 elnn0uz 11131 . . . . . . . . . . . . 13  |-  ( 1  e.  NN0  <->  1  e.  (
ZZ>= `  0 ) )
2018, 19mpbi 208 . . . . . . . . . . . 12  |-  1  e.  ( ZZ>= `  0 )
21 fzss1 11734 . . . . . . . . . . . 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 3508 . . . . . . . . . 10  |-  ( P  e.  Prime  ->  ( s  e.  ( 1 ... ( P  -  1 ) )  ->  s  e.  ( 0 ... ( P  -  1 ) ) ) )
24233ad2ant1 1017 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  N  e.  ZZ  /\  -.  P  ||  N )  ->  (
s  e.  ( 1 ... ( P  - 
1 ) )  -> 
s  e.  ( 0 ... ( P  - 
1 ) ) ) )
2524imdistani 690 . . . . . . . 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 14203 . . . . . . . . . . 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 484 . . . . . . . . . 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 2475 . . . . . . . . 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 615 . . . . . . . 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 2881 . . . . . 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 532 . . . . 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 532 . . . 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 1228 . . 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 6303 . . . . . . 7  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  ( N  x.  i )  =  ( N  x.  ( ( N ^
( P  -  2 ) )  mod  P
) ) )
3635oveq1d 6310 . . . . . 6  |-  ( i  =  ( ( N ^ ( P  - 
2 ) )  mod 
P )  ->  (
( N  x.  i
)  mod  P )  =  ( ( N  x.  ( ( N ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P ) )
3736eqeq1d 2469 . . . . 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 2471 . . . . . . 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 2906 . . . . 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 710 . . . 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 3219 . . 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 6303 . . . . 5  |-  ( i  =  s  ->  ( N  x.  i )  =  ( N  x.  s ) )
4544oveq1d 6310 . . . 4  |-  ( i  =  s  ->  (
( N  x.  i
)  mod  P )  =  ( ( N  x.  s )  mod 
P ) )
4645eqeq1d 2469 . . 3  |-  ( i  =  s  ->  (
( ( N  x.  i )  mod  P
)  =  1  <->  (
( N  x.  s
)  mod  P )  =  1 ) )
4746reu8 3304 . 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 973    = wceq 1379    e. wcel 1767   A.wral 2817   E.wrex 2818   E!wreu 2819    C_ wss 3481   class class class wbr 4453   ` cfv 5594  (class class class)co 6295   0cc0 9504   1c1 9505    x. cmul 9509    - cmin 9817   NNcn 10548   2c2 10597   NN0cn0 10807   ZZcz 10876   ZZ>=cuz 11094   ...cfz 11684  ..^cfzo 11804    mod cmo 11976   ^cexp 12146    || cdivides 13864   Primecprime 14093
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1601  ax-4 1612  ax-5 1680  ax-6 1719  ax-7 1739  ax-8 1769  ax-9 1771  ax-10 1786  ax-11 1791  ax-12 1803  ax-13 1968  ax-ext 2445  ax-rep 4564  ax-sep 4574  ax-nul 4582  ax-pow 4631  ax-pr 4692  ax-un 6587  ax-cnex 9560  ax-resscn 9561  ax-1cn 9562  ax-icn 9563  ax-addcl 9564  ax-addrcl 9565  ax-mulcl 9566  ax-mulrcl 9567  ax-mulcom 9568  ax-addass 9569  ax-mulass 9570  ax-distr 9571  ax-i2m1 9572  ax-1ne0 9573  ax-1rid 9574  ax-rnegex 9575  ax-rrecex 9576  ax-cnre 9577  ax-pre-lttri 9578  ax-pre-lttrn 9579  ax-pre-ltadd 9580  ax-pre-mulgt0 9581  ax-pre-sup 9582
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 974  df-3an 975  df-tru 1382  df-ex 1597  df-nf 1600  df-sb 1712  df-eu 2279  df-mo 2280  df-clab 2453  df-cleq 2459  df-clel 2462  df-nfc 2617  df-ne 2664  df-nel 2665  df-ral 2822  df-rex 2823  df-reu 2824  df-rmo 2825  df-rab 2826  df-v 3120  df-sbc 3337  df-csb 3441  df-dif 3484  df-un 3486  df-in 3488  df-ss 3495  df-pss 3497  df-nul 3791  df-if 3946  df-pw 4018  df-sn 4034  df-pr 4036  df-tp 4038  df-op 4040  df-uni 4252  df-int 4289  df-iun 4333  df-br 4454  df-opab 4512  df-mpt 4513  df-tr 4547  df-eprel 4797  df-id 4801  df-po 4806  df-so 4807  df-fr 4844  df-we 4846  df-ord 4887  df-on 4888  df-lim 4889  df-suc 4890  df-xp 5011  df-rel 5012  df-cnv 5013  df-co 5014  df-dm 5015  df-rn 5016  df-res 5017  df-ima 5018  df-iota 5557  df-fun 5596  df-fn 5597  df-f 5598  df-f1 5599  df-fo 5600  df-f1o 5601  df-fv 5602  df-riota 6256  df-ov 6298  df-oprab 6299  df-mpt2 6300  df-om 6696  df-1st 6795  df-2nd 6796  df-recs 7054  df-rdg 7088  df-1o 7142  df-2o 7143  df-oadd 7146  df-er 7323  df-map 7434  df-en 7529  df-dom 7530  df-sdom 7531  df-fin 7532  df-sup 7913  df-card 8332  df-cda 8560  df-pnf 9642  df-mnf 9643  df-xr 9644  df-ltxr 9645  df-le 9646  df-sub 9819  df-neg 9820  df-div 10219  df-nn 10549  df-2 10606  df-3 10607  df-n0 10808  df-z 10877  df-uz 11095  df-rp 11233  df-fz 11685  df-fzo 11805  df-fl 11909  df-mod 11977  df-seq 12088  df-exp 12147  df-hash 12386  df-cj 12912  df-re 12913  df-im 12914  df-sqrt 13048  df-abs 13049  df-dvds 13865  df-gcd 14021  df-prm 14094  df-phi 14172
This theorem is referenced by:  modprm0  14206
  Copyright terms: Public domain W3C validator