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

Theorem powm2modprm 14202
Description: If an integer minus 1 is divisible by a prime number, then the integer to the power of the prime number minus 2 is 1 modulo the prime number. (Contributed by Alexander van der Vekens, 30-Aug-2018.)
Assertion
Ref Expression
powm2modprm  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  ( A  - 
1 )  ->  (
( A ^ ( P  -  2 ) )  mod  P )  =  1 ) )

Proof of Theorem powm2modprm
StepHypRef Expression
1 simpll 753 . . . 4  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  P  e.  Prime )
2 simpr 461 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  A  e.  ZZ )
32adantr 465 . . . 4  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  A  e.  ZZ )
4 m1dvdsndvds 14199 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  ( A  - 
1 )  ->  -.  P  ||  A ) )
54imp 429 . . . 4  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  -.  P  ||  A )
6 eqid 2441 . . . . . 6  |-  ( ( A ^ ( P  -  2 ) )  mod  P )  =  ( ( A ^
( P  -  2 ) )  mod  P
)
76modprminv 14200 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  -.  P  ||  A )  ->  (
( ( A ^
( P  -  2 ) )  mod  P
)  e.  ( 1 ... ( P  - 
1 ) )  /\  ( ( A  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  1 ) )
8 simpr 461 . . . . . 6  |-  ( ( ( ( A ^
( P  -  2 ) )  mod  P
)  e.  ( 1 ... ( P  - 
1 ) )  /\  ( ( A  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  1 )  ->  ( ( A  x.  ( ( A ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P )  =  1 )
98eqcomd 2449 . . . . 5  |-  ( ( ( ( A ^
( P  -  2 ) )  mod  P
)  e.  ( 1 ... ( P  - 
1 ) )  /\  ( ( A  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  1 )  ->  1  =  ( ( A  x.  (
( A ^ ( P  -  2 ) )  mod  P ) )  mod  P ) )
107, 9syl 16 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  -.  P  ||  A )  ->  1  =  ( ( A  x.  ( ( A ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P ) )
111, 3, 5, 10syl3anc 1227 . . 3  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  1  =  ( ( A  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
) )
12 modprm1div 14198 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A  mod  P
)  =  1  <->  P  ||  ( A  -  1 ) ) )
1312biimpar 485 . . . . . 6  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( A  mod  P )  =  1 )
1413oveq1d 6293 . . . . 5  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( ( A  mod  P )  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  =  ( 1  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) ) )
1514oveq1d 6293 . . . 4  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( (
( A  mod  P
)  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  ( ( 1  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
) )
16 zre 10871 . . . . . 6  |-  ( A  e.  ZZ  ->  A  e.  RR )
1716ad2antlr 726 . . . . 5  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  A  e.  RR )
18 prmm2nn0 14112 . . . . . . . . . . 11  |-  ( P  e.  Prime  ->  ( P  -  2 )  e. 
NN0 )
1918anim2i 569 . . . . . . . . . 10  |-  ( ( A  e.  ZZ  /\  P  e.  Prime )  -> 
( A  e.  ZZ  /\  ( P  -  2 )  e.  NN0 )
)
2019ancoms 453 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( A  e.  ZZ  /\  ( P  -  2 )  e.  NN0 ) )
2120adantr 465 . . . . . . . 8  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( A  e.  ZZ  /\  ( P  -  2 )  e. 
NN0 ) )
22 zexpcl 12157 . . . . . . . 8  |-  ( ( A  e.  ZZ  /\  ( P  -  2
)  e.  NN0 )  ->  ( A ^ ( P  -  2 ) )  e.  ZZ )
2321, 22syl 16 . . . . . . 7  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( A ^ ( P  - 
2 ) )  e.  ZZ )
24 prmnn 14094 . . . . . . . . 9  |-  ( P  e.  Prime  ->  P  e.  NN )
2524adantr 465 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  P  e.  NN )
2625adantr 465 . . . . . . 7  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  P  e.  NN )
2723, 26zmodcld 11992 . . . . . 6  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( ( A ^ ( P  - 
2 ) )  mod 
P )  e.  NN0 )
2827nn0zd 10969 . . . . 5  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( ( A ^ ( P  - 
2 ) )  mod 
P )  e.  ZZ )
2924nnrpd 11261 . . . . . . 7  |-  ( P  e.  Prime  ->  P  e.  RR+ )
3029adantr 465 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  P  e.  RR+ )
3130adantr 465 . . . . 5  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  P  e.  RR+ )
32 modmulmod 12028 . . . . 5  |-  ( ( A  e.  RR  /\  ( ( A ^
( P  -  2 ) )  mod  P
)  e.  ZZ  /\  P  e.  RR+ )  -> 
( ( ( A  mod  P )  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
)  =  ( ( A  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) )  mod  P ) )
3317, 28, 31, 32syl3anc 1227 . . . 4  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( (
( A  mod  P
)  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  ( ( A  x.  ( ( A ^
( P  -  2 ) )  mod  P
) )  mod  P
) )
3420, 22syl 16 . . . . . . . . . 10  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( A ^ ( P  - 
2 ) )  e.  ZZ )
3534, 25zmodcld 11992 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A ^ ( P  -  2 ) )  mod  P )  e.  NN0 )
3635nn0cnd 10857 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A ^ ( P  -  2 ) )  mod  P )  e.  CC )
3736mulid2d 9614 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
1  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) )  =  ( ( A ^ ( P  - 
2 ) )  mod 
P ) )
3837oveq1d 6293 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( 1  x.  (
( A ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  ( ( ( A ^ ( P  -  2 ) )  mod  P )  mod 
P ) )
3938adantr 465 . . . . 5  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( (
1  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  ( ( ( A ^ ( P  - 
2 ) )  mod 
P )  mod  P
) )
40 reexpcl 12159 . . . . . . . . 9  |-  ( ( A  e.  RR  /\  ( P  -  2
)  e.  NN0 )  ->  ( A ^ ( P  -  2 ) )  e.  RR )
4116, 18, 40syl2anr 478 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( A ^ ( P  - 
2 ) )  e.  RR )
4241, 30jca 532 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A ^ ( P  -  2 ) )  e.  RR  /\  P  e.  RR+ ) )
4342adantr 465 . . . . . 6  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( ( A ^ ( P  - 
2 ) )  e.  RR  /\  P  e.  RR+ ) )
44 modabs2 12006 . . . . . 6  |-  ( ( ( A ^ ( P  -  2 ) )  e.  RR  /\  P  e.  RR+ )  -> 
( ( ( A ^ ( P  - 
2 ) )  mod 
P )  mod  P
)  =  ( ( A ^ ( P  -  2 ) )  mod  P ) )
4543, 44syl 16 . . . . 5  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( (
( A ^ ( P  -  2 ) )  mod  P )  mod  P )  =  ( ( A ^
( P  -  2 ) )  mod  P
) )
4639, 45eqtrd 2482 . . . 4  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( (
1  x.  ( ( A ^ ( P  -  2 ) )  mod  P ) )  mod  P )  =  ( ( A ^
( P  -  2 ) )  mod  P
) )
4715, 33, 463eqtr3d 2490 . . 3  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( ( A  x.  ( ( A ^ ( P  - 
2 ) )  mod 
P ) )  mod 
P )  =  ( ( A ^ ( P  -  2 ) )  mod  P ) )
4811, 47eqtr2d 2483 . 2  |-  ( ( ( P  e.  Prime  /\  A  e.  ZZ )  /\  P  ||  ( A  -  1 ) )  ->  ( ( A ^ ( P  - 
2 ) )  mod 
P )  =  1 )
4948ex 434 1  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  ( A  - 
1 )  ->  (
( A ^ ( P  -  2 ) )  mod  P )  =  1 ) )
Colors of variables: wff setvar class
Syntax hints:   -. wn 3    -> wi 4    /\ wa 369    /\ w3a 972    = wceq 1381    e. wcel 1802   class class class wbr 4434  (class class class)co 6278   RRcr 9491   1c1 9493    x. cmul 9497    - cmin 9807   NNcn 10539   2c2 10588   NN0cn0 10798   ZZcz 10867   RR+crp 11226   ...cfz 11678    mod cmo 11972   ^cexp 12142    || cdvds 13860   Primecprime 14091
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1603  ax-4 1616  ax-5 1689  ax-6 1732  ax-7 1774  ax-8 1804  ax-9 1806  ax-10 1821  ax-11 1826  ax-12 1838  ax-13 1983  ax-ext 2419  ax-rep 4545  ax-sep 4555  ax-nul 4563  ax-pow 4612  ax-pr 4673  ax-un 6574  ax-cnex 9548  ax-resscn 9549  ax-1cn 9550  ax-icn 9551  ax-addcl 9552  ax-addrcl 9553  ax-mulcl 9554  ax-mulrcl 9555  ax-mulcom 9556  ax-addass 9557  ax-mulass 9558  ax-distr 9559  ax-i2m1 9560  ax-1ne0 9561  ax-1rid 9562  ax-rnegex 9563  ax-rrecex 9564  ax-cnre 9565  ax-pre-lttri 9566  ax-pre-lttrn 9567  ax-pre-ltadd 9568  ax-pre-mulgt0 9569  ax-pre-sup 9570
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 973  df-3an 974  df-tru 1384  df-ex 1598  df-nf 1602  df-sb 1725  df-eu 2270  df-mo 2271  df-clab 2427  df-cleq 2433  df-clel 2436  df-nfc 2591  df-ne 2638  df-nel 2639  df-ral 2796  df-rex 2797  df-reu 2798  df-rmo 2799  df-rab 2800  df-v 3095  df-sbc 3312  df-csb 3419  df-dif 3462  df-un 3464  df-in 3466  df-ss 3473  df-pss 3475  df-nul 3769  df-if 3924  df-pw 3996  df-sn 4012  df-pr 4014  df-tp 4016  df-op 4018  df-uni 4232  df-int 4269  df-iun 4314  df-br 4435  df-opab 4493  df-mpt 4494  df-tr 4528  df-eprel 4778  df-id 4782  df-po 4787  df-so 4788  df-fr 4825  df-we 4827  df-ord 4868  df-on 4869  df-lim 4870  df-suc 4871  df-xp 4992  df-rel 4993  df-cnv 4994  df-co 4995  df-dm 4996  df-rn 4997  df-res 4998  df-ima 4999  df-iota 5538  df-fun 5577  df-fn 5578  df-f 5579  df-f1 5580  df-fo 5581  df-f1o 5582  df-fv 5583  df-riota 6239  df-ov 6281  df-oprab 6282  df-mpt2 6283  df-om 6683  df-1st 6782  df-2nd 6783  df-recs 7041  df-rdg 7075  df-1o 7129  df-2o 7130  df-oadd 7133  df-er 7310  df-map 7421  df-en 7516  df-dom 7517  df-sdom 7518  df-fin 7519  df-sup 7900  df-card 8320  df-cda 8548  df-pnf 9630  df-mnf 9631  df-xr 9632  df-ltxr 9633  df-le 9634  df-sub 9809  df-neg 9810  df-div 10210  df-nn 10540  df-2 10597  df-3 10598  df-n0 10799  df-z 10868  df-uz 11088  df-rp 11227  df-fz 11679  df-fzo 11801  df-fl 11905  df-mod 11973  df-seq 12084  df-exp 12143  df-hash 12382  df-cj 12908  df-re 12909  df-im 12910  df-sqrt 13044  df-abs 13045  df-dvds 13861  df-gcd 14019  df-prm 14092  df-phi 14170
This theorem is referenced by:  numclwwlk5  24981
  Copyright terms: Public domain W3C validator