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

Theorem fermltl 14325
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 14231 . . . 4  |-  ( P  e.  Prime  ->  P  e.  NN )
2 dvdsval3 14001 . . . 4  |-  ( ( P  e.  NN  /\  A  e.  ZZ )  ->  ( P  ||  A  <->  ( A  mod  P )  =  0 ) )
31, 2sylan 471 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  A  <->  ( A  mod  P )  =  0 ) )
4 simp2 997 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  A  e.  ZZ )
5 0zd 10897 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  0  e.  ZZ )
613ad2ant1 1017 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  P  e.  NN )
76nnnn0d 10873 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  P  e.  NN0 )
86nnrpd 11280 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  P  e.  RR+ )
9 simp3 998 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  ( A  mod  P )  =  0 )
10 0mod 12029 . . . . . . . 8  |-  ( P  e.  RR+  ->  ( 0  mod  P )  =  0 )
118, 10syl 16 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
0  mod  P )  =  0 )
129, 11eqtr4d 2501 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  ( A  mod  P )  =  ( 0  mod  P
) )
13 modexp 12303 . . . . . 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 ) )
144, 5, 7, 8, 12, 13syl221anc 1239 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
( A ^ P
)  mod  P )  =  ( ( 0 ^ P )  mod 
P ) )
1560expd 12328 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
0 ^ P )  =  0 )
1615oveq1d 6311 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
( 0 ^ P
)  mod  P )  =  ( 0  mod 
P ) )
1712, 16eqtr4d 2501 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  ( A  mod  P )  =  ( ( 0 ^ P )  mod  P
) )
1814, 17eqtr4d 2501 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  mod  P )  =  0 )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )
19183expia 1198 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A  mod  P
)  =  0  -> 
( ( A ^ P )  mod  P
)  =  ( A  mod  P ) ) )
203, 19sylbid 215 . 2  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  ||  A  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) ) )
21 coprm 14252 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( -.  P  ||  A  <->  ( P  gcd  A )  =  1 ) )
22 prmz 14232 . . . . . 6  |-  ( P  e.  Prime  ->  P  e.  ZZ )
23 gcdcom 14169 . . . . . 6  |-  ( ( P  e.  ZZ  /\  A  e.  ZZ )  ->  ( P  gcd  A
)  =  ( A  gcd  P ) )
2422, 23sylan 471 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( P  gcd  A )  =  ( A  gcd  P
) )
2524eqeq1d 2459 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( P  gcd  A
)  =  1  <->  ( A  gcd  P )  =  1 ) )
2621, 25bitrd 253 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( -.  P  ||  A  <->  ( A  gcd  P )  =  1 ) )
27 simp2 997 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  A  e.  ZZ )
2813ad2ant1 1017 . . . . . . . . . 10  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  P  e.  NN )
2928phicld 14313 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( phi `  P )  e.  NN )
3029nnnn0d 10873 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( phi `  P )  e. 
NN0 )
31 zexpcl 12183 . . . . . . . 8  |-  ( ( A  e.  ZZ  /\  ( phi `  P )  e.  NN0 )  -> 
( A ^ ( phi `  P ) )  e.  ZZ )
3227, 30, 31syl2anc 661 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ ( phi `  P ) )  e.  ZZ )
3332zred 10990 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ ( phi `  P ) )  e.  RR )
34 1red 9628 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  1  e.  RR )
3528nnrpd 11280 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  P  e.  RR+ )
36 eulerth 14324 . . . . . . 7  |-  ( ( P  e.  NN  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  mod  P )  =  ( 1  mod  P
) )
371, 36syl3an1 1261 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  mod  P )  =  ( 1  mod  P
) )
38 modmul1 12042 . . . . . 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 ) )
3933, 34, 27, 35, 37, 38syl221anc 1239 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( ( A ^
( phi `  P
) )  x.  A
)  mod  P )  =  ( ( 1  x.  A )  mod 
P ) )
40 phiprm 14318 . . . . . . . . . 10  |-  ( P  e.  Prime  ->  ( phi `  P )  =  ( P  -  1 ) )
41403ad2ant1 1017 . . . . . . . . 9  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( phi `  P )  =  ( P  -  1 ) )
4241oveq2d 6312 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ ( phi `  P ) )  =  ( A ^ ( P  -  1 ) ) )
4342oveq1d 6311 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  x.  A )  =  ( ( A ^
( P  -  1 ) )  x.  A
) )
4427zcnd 10991 . . . . . . . 8  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  A  e.  CC )
45 expm1t 12196 . . . . . . . 8  |-  ( ( A  e.  CC  /\  P  e.  NN )  ->  ( A ^ P
)  =  ( ( A ^ ( P  -  1 ) )  x.  A ) )
4644, 28, 45syl2anc 661 . . . . . . 7  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  ( A ^ P )  =  ( ( A ^
( P  -  1 ) )  x.  A
) )
4743, 46eqtr4d 2501 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ ( phi `  P ) )  x.  A )  =  ( A ^ P
) )
4847oveq1d 6311 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( ( A ^
( phi `  P
) )  x.  A
)  mod  P )  =  ( ( A ^ P )  mod 
P ) )
4944mulid2d 9631 . . . . . 6  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
1  x.  A )  =  A )
5049oveq1d 6311 . . . . 5  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( 1  x.  A
)  mod  P )  =  ( A  mod  P ) )
5139, 48, 503eqtr3d 2506 . . . 4  |-  ( ( P  e.  Prime  /\  A  e.  ZZ  /\  ( A  gcd  P )  =  1 )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )
52513expia 1198 . . 3  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A  gcd  P
)  =  1  -> 
( ( A ^ P )  mod  P
)  =  ( A  mod  P ) ) )
5326, 52sylbid 215 . 2  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  ( -.  P  ||  A  -> 
( ( A ^ P )  mod  P
)  =  ( A  mod  P ) ) )
5420, 53pm2.61d 158 1  |-  ( ( P  e.  Prime  /\  A  e.  ZZ )  ->  (
( A ^ P
)  mod  P )  =  ( A  mod  P ) )
Colors of variables: wff setvar class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 184    /\ wa 369    /\ w3a 973    = wceq 1395    e. wcel 1819   class class class wbr 4456   ` cfv 5594  (class class class)co 6296   CCcc 9507   RRcr 9508   0cc0 9509   1c1 9510    x. cmul 9514    - cmin 9824   NNcn 10556   NN0cn0 10816   ZZcz 10885   RR+crp 11245    mod cmo 11998   ^cexp 12168    || cdvds 13997    gcd cgcd 14155   Primecprime 14228   phicphi 14305
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1619  ax-4 1632  ax-5 1705  ax-6 1748  ax-7 1791  ax-8 1821  ax-9 1823  ax-10 1838  ax-11 1843  ax-12 1855  ax-13 2000  ax-ext 2435  ax-rep 4568  ax-sep 4578  ax-nul 4586  ax-pow 4634  ax-pr 4695  ax-un 6591  ax-cnex 9565  ax-resscn 9566  ax-1cn 9567  ax-icn 9568  ax-addcl 9569  ax-addrcl 9570  ax-mulcl 9571  ax-mulrcl 9572  ax-mulcom 9573  ax-addass 9574  ax-mulass 9575  ax-distr 9576  ax-i2m1 9577  ax-1ne0 9578  ax-1rid 9579  ax-rnegex 9580  ax-rrecex 9581  ax-cnre 9582  ax-pre-lttri 9583  ax-pre-lttrn 9584  ax-pre-ltadd 9585  ax-pre-mulgt0 9586  ax-pre-sup 9587
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 974  df-3an 975  df-tru 1398  df-ex 1614  df-nf 1618  df-sb 1741  df-eu 2287  df-mo 2288  df-clab 2443  df-cleq 2449  df-clel 2452  df-nfc 2607  df-ne 2654  df-nel 2655  df-ral 2812  df-rex 2813  df-reu 2814  df-rmo 2815  df-rab 2816  df-v 3111  df-sbc 3328  df-csb 3431  df-dif 3474  df-un 3476  df-in 3478  df-ss 3485  df-pss 3487  df-nul 3794  df-if 3945  df-pw 4017  df-sn 4033  df-pr 4035  df-tp 4037  df-op 4039  df-uni 4252  df-int 4289  df-iun 4334  df-br 4457  df-opab 4516  df-mpt 4517  df-tr 4551  df-eprel 4800  df-id 4804  df-po 4809  df-so 4810  df-fr 4847  df-we 4849  df-ord 4890  df-on 4891  df-lim 4892  df-suc 4893  df-xp 5014  df-rel 5015  df-cnv 5016  df-co 5017  df-dm 5018  df-rn 5019  df-res 5020  df-ima 5021  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 6258  df-ov 6299  df-oprab 6300  df-mpt2 6301  df-om 6700  df-1st 6799  df-2nd 6800  df-recs 7060  df-rdg 7094  df-1o 7148  df-2o 7149  df-oadd 7152  df-er 7329  df-map 7440  df-en 7536  df-dom 7537  df-sdom 7538  df-fin 7539  df-sup 7919  df-card 8337  df-cda 8565  df-pnf 9647  df-mnf 9648  df-xr 9649  df-ltxr 9650  df-le 9651  df-sub 9826  df-neg 9827  df-div 10228  df-nn 10557  df-2 10615  df-3 10616  df-n0 10817  df-z 10886  df-uz 11107  df-rp 11246  df-fz 11698  df-fzo 11821  df-fl 11931  df-mod 11999  df-seq 12110  df-exp 12169  df-hash 12408  df-cj 12943  df-re 12944  df-im 12945  df-sqrt 13079  df-abs 13080  df-dvds 13998  df-gcd 14156  df-prm 14229  df-phi 14307
This theorem is referenced by: (None)
  Copyright terms: Public domain W3C validator