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

Theorem fermltl 13093
Description: Fermat's little theorem. When  P is prime,  A ^ P  ==  A, mod  P for any  A. (Contributed by Mario Carneiro, 28-Feb-2014.)
Assertion
Ref Expression
fermltl  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )

Proof of Theorem fermltl
StepHypRef Expression
1 prmnn 13002 . . . 4  |-  ( P  e.  Prime  ->  P  e.  NN )
2 dvdsval3 12776 . . . 4  |-  ( ( P  e.  NN  /\  A  e.  ZZ )  ->  ( P  ||  A  <->  ( A  mod  P )  =  0 ) )
31, 2sylan 458 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  A  <->  ( A  mod  P )  =  0 ) )
4 simp2 958 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  A  e.  ZZ )
5 0z 10218 . . . . . . 7  |-  0  e.  ZZ
65a1i 11 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  0  e.  ZZ )
713ad2ant1 978 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  P  e.  NN )
87nnnn0d 10199 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  P  e.  NN0 )
97nnrpd 10572 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  P  e.  RR+ )
10 simp3 959 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  ( A  mod  P )  =  0 )
11 0mod 11192 . . . . . . . 8  |-  ( P  e.  RR+  ->  ( 0  mod  P )  =  0 )
129, 11syl 16 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
0  mod  P )  =  0 )
1310, 12eqtr4d 2415 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  ( A  mod  P )  =  ( 0  mod  P
) )
14 modexp 11434 . . . . . 6  |-  ( ( ( A  e.  ZZ  /\  0  e.  ZZ )  /\  ( P  e. 
NN0  /\  P  e.  RR+ )  /\  ( A  mod  P )  =  ( 0  mod  P
) )  ->  (
( A ^ P
)  mod  P )  =  ( ( 0 ^ P )  mod 
P ) )
154, 6, 8, 9, 13, 14syl221anc 1195 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
( A ^ P
)  mod  P )  =  ( ( 0 ^ P )  mod 
P ) )
1670expd 11459 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
0 ^ P )  =  0 )
1716oveq1d 6028 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
( 0 ^ P
)  mod  P )  =  ( 0  mod 
P ) )
1813, 17eqtr4d 2415 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  ( A  mod  P )  =  ( ( 0 ^ P )  mod  P
) )
1915, 18eqtr4d 2415 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )
20193expia 1155 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A  mod  P
)  =  0  -> 
( ( A ^ P )  mod  P
)  =  ( A  mod  P ) ) )
213, 20sylbid 207 . 2  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  A  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) ) )
22 coprm 13020 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( -.  P  ||  A  <->  ( P  gcd  A )  =  1 ) )
23 prmz 13003 . . . . . 6  |-  ( P  e.  Prime  ->  P  e.  ZZ )
24 gcdcom 12940 . . . . . 6  |-  ( ( P  e.  ZZ  /\  A  e.  ZZ )  ->  ( P  gcd  A
)  =  ( A  gcd  P ) )
2523, 24sylan 458 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  gcd  A )  =  ( A  gcd  P
) )
2625eqeq1d 2388 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( P  gcd  A
)  =  1  <->  ( A  gcd  P )  =  1 ) )
2722, 26bitrd 245 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( -.  P  ||  A  <->  ( A  gcd  P )  =  1 ) )
28 simp2 958 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  A  e.  ZZ )
2913ad2ant1 978 . . . . . . . . . 10  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  P  e.  NN )
3029phicld 13081 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( phi `  P )  e.  NN )
3130nnnn0d 10199 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( phi `  P )  e. 
NN0 )
32 zexpcl 11316 . . . . . . . 8  |-  ( ( A  e.  ZZ  /\  ( phi `  P )  e.  NN0 )  -> 
( A ^ ( phi `  P ) )  e.  ZZ )
3328, 31, 32syl2anc 643 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ ( phi `  P ) )  e.  ZZ )
3433zred 10300 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ ( phi `  P ) )  e.  RR )
35 1re 9016 . . . . . . 7  |-  1  e.  RR
3635a1i 11 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  1  e.  RR )
3729nnrpd 10572 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  P  e.  RR+ )
38 eulerth 13092 . . . . . . 7  |-  ( ( P  e.  NN  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  mod  P )  =  ( 1  mod  P
) )
391, 38syl3an1 1217 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  mod  P )  =  ( 1  mod  P
) )
40 modmul1 11199 . . . . . 6  |-  ( ( ( ( A ^
( phi `  P
) )  e.  RR  /\  1  e.  RR )  /\  ( A  e.  ZZ  /\  P  e.  RR+ )  /\  (
( A ^ ( phi `  P ) )  mod  P )  =  ( 1  mod  P
) )  ->  (
( ( A ^
( phi `  P
) )  x.  A
)  mod  P )  =  ( ( 1  x.  A )  mod 
P ) )
4134, 36, 28, 37, 39, 40syl221anc 1195 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( ( A ^
( phi `  P
) )  x.  A
)  mod  P )  =  ( ( 1  x.  A )  mod 
P ) )
42 phiprm 13086 . . . . . . . . . 10  |-  ( P  e.  Prime  ->  ( phi `  P )  =  ( P  -  1 ) )
43423ad2ant1 978 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( phi `  P )  =  ( P  -  1 ) )
4443oveq2d 6029 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ ( phi `  P ) )  =  ( A ^ ( P  -  1 ) ) )
4544oveq1d 6028 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  x.  A )  =  ( ( A ^
( P  -  1 ) )  x.  A
) )
4628zcnd 10301 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  A  e.  CC )
47 expm1t 11328 . . . . . . . 8  |-  ( ( A  e.  CC  /\  P  e.  NN )  ->  ( A ^ P
)  =  ( ( A ^ ( P  -  1 ) )  x.  A ) )
4846, 29, 47syl2anc 643 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ P )  =  ( ( A ^
( P  -  1 ) )  x.  A
) )
4945, 48eqtr4d 2415 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  x.  A )  =  ( A ^ P
) )
5049oveq1d 6028 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( ( A ^
( phi `  P
) )  x.  A
)  mod  P )  =  ( ( A ^ P )  mod 
P ) )
5146mulid2d 9032 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
1  x.  A )  =  A )
5251oveq1d 6028 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( 1  x.  A
)  mod  P )  =  ( A  mod  P ) )
5341, 50, 523eqtr3d 2420 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )
54533expia 1155 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A  gcd  P
)  =  1  -> 
( ( A ^ P )  mod  P
)  =  ( A  mod  P ) ) )
5527, 54sylbid 207 . 2  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( -.  P  ||  A  -> 
( ( A ^ P )  mod  P
)  =  ( A  mod  P ) ) )
5621, 55pm2.61d 152 1  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )
Colors of variables: wff set class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 177    /\ wa 359    /\ w3a 936    = wceq 1649    e. wcel 1717   class class class wbr 4146   ` cfv 5387  (class class class)co 6013   CCcc 8914   RRcr 8915   0cc0 8916   1c1 8917    x. cmul 8921    - cmin 9216   NNcn 9925   NN0cn0 10146   ZZcz 10207   RR+crp 10537    mod cmo 11170   ^cexp 11302    || cdivides 12772    gcd cgcd 12926   Primecprime 12999   phicphi 13073
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1552  ax-5 1563  ax-17 1623  ax-9 1661  ax-8 1682  ax-13 1719  ax-14 1721  ax-6 1736  ax-7 1741  ax-11 1753  ax-12 1939  ax-ext 2361  ax-rep 4254  ax-sep 4264  ax-nul 4272  ax-pow 4311  ax-pr 4337  ax-un 4634  ax-cnex 8972  ax-resscn 8973  ax-1cn 8974  ax-icn 8975  ax-addcl 8976  ax-addrcl 8977  ax-mulcl 8978  ax-mulrcl 8979  ax-mulcom 8980  ax-addass 8981  ax-mulass 8982  ax-distr 8983  ax-i2m1 8984  ax-1ne0 8985  ax-1rid 8986  ax-rnegex 8987  ax-rrecex 8988  ax-cnre 8989  ax-pre-lttri 8990  ax-pre-lttrn 8991  ax-pre-ltadd 8992  ax-pre-mulgt0 8993  ax-pre-sup 8994
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1325  df-ex 1548  df-nf 1551  df-sb 1656  df-eu 2235  df-mo 2236  df-clab 2367  df-cleq 2373  df-clel 2376  df-nfc 2505  df-ne 2545  df-nel 2546  df-ral 2647  df-rex 2648  df-reu 2649  df-rmo 2650  df-rab 2651  df-v 2894  df-sbc 3098  df-csb 3188  df-dif 3259  df-un 3261  df-in 3263  df-ss 3270  df-pss 3272  df-nul 3565  df-if 3676  df-pw 3737  df-sn 3756  df-pr 3757  df-tp 3758  df-op 3759  df-uni 3951  df-int 3986  df-iun 4030  df-br 4147  df-opab 4201  df-mpt 4202  df-tr 4237  df-eprel 4428  df-id 4432  df-po 4437  df-so 4438  df-fr 4475  df-we 4477  df-ord 4518  df-on 4519  df-lim 4520  df-suc 4521  df-om 4779  df-xp 4817  df-rel 4818  df-cnv 4819  df-co 4820  df-dm 4821  df-rn 4822  df-res 4823  df-ima 4824  df-iota 5351  df-fun 5389  df-fn 5390  df-f 5391  df-f1 5392  df-fo 5393  df-f1o 5394  df-fv 5395  df-ov 6016  df-oprab 6017  df-mpt2 6018  df-1st 6281  df-2nd 6282  df-riota 6478  df-recs 6562  df-rdg 6597  df-1o 6653  df-2o 6654  df-oadd 6657  df-er 6834  df-map 6949  df-en 7039  df-dom 7040  df-sdom 7041  df-fin 7042  df-sup 7374  df-card 7752  df-cda 7974  df-pnf 9048  df-mnf 9049  df-xr 9050  df-ltxr 9051  df-le 9052  df-sub 9218  df-neg 9219  df-div 9603  df-nn 9926  df-2 9983  df-3 9984  df-n0 10147  df-z 10208  df-uz 10414  df-rp 10538  df-fz 10969  df-fzo 11059  df-fl 11122  df-mod 11171  df-seq 11244  df-exp 11303  df-hash 11539  df-cj 11824  df-re 11825  df-im 11826  df-sqr 11960  df-abs 11961  df-dvds 12773  df-gcd 12927  df-prm 13000  df-phi 13075
  Copyright terms: Public domain W3C validator