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

Theorem pockthi 13275
Description: Pocklington's theorem, which gives a sufficient criterion for a number  N to be prime. This is the preferred method for verifying large primes, being much more efficient to compute than trial division. This form has been optimized for application to specific large primes; see pockthg 13274 for a more general closed-form version. (Contributed by Mario Carneiro, 2-Mar-2014.)
Hypotheses
Ref Expression
pockthi.p  |-  P  e. 
Prime
pockthi.g  |-  G  e.  NN
pockthi.m  |-  M  =  ( G  x.  P
)
pockthi.n  |-  N  =  ( M  +  1 )
pockthi.d  |-  D  e.  NN
pockthi.e  |-  E  e.  NN
pockthi.a  |-  A  e.  NN
pockthi.fac  |-  M  =  ( D  x.  ( P ^ E ) )
pockthi.gt  |-  D  < 
( P ^ E
)
pockthi.mod  |-  ( ( A ^ M )  mod  N )  =  ( 1  mod  N
)
pockthi.gcd  |-  ( ( ( A ^ G
)  -  1 )  gcd  N )  =  1
Assertion
Ref Expression
pockthi  |-  N  e. 
Prime

Proof of Theorem pockthi
Dummy variables  x  y are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 pockthi.d . 2  |-  D  e.  NN
2 pockthi.p . . . . . 6  |-  P  e. 
Prime
3 prmnn 13082 . . . . . 6  |-  ( P  e.  Prime  ->  P  e.  NN )
42, 3ax-mp 8 . . . . 5  |-  P  e.  NN
5 pockthi.e . . . . . 6  |-  E  e.  NN
65nnnn0i 10229 . . . . 5  |-  E  e. 
NN0
7 nnexpcl 11394 . . . . 5  |-  ( ( P  e.  NN  /\  E  e.  NN0 )  -> 
( P ^ E
)  e.  NN )
84, 6, 7mp2an 654 . . . 4  |-  ( P ^ E )  e.  NN
98a1i 11 . . 3  |-  ( D  e.  NN  ->  ( P ^ E )  e.  NN )
10 id 20 . . 3  |-  ( D  e.  NN  ->  D  e.  NN )
11 pockthi.gt . . . 4  |-  D  < 
( P ^ E
)
1211a1i 11 . . 3  |-  ( D  e.  NN  ->  D  <  ( P ^ E
) )
13 pockthi.n . . . . 5  |-  N  =  ( M  +  1 )
14 pockthi.fac . . . . . . 7  |-  M  =  ( D  x.  ( P ^ E ) )
151nncni 10010 . . . . . . . 8  |-  D  e.  CC
168nncni 10010 . . . . . . . 8  |-  ( P ^ E )  e.  CC
1715, 16mulcomi 9096 . . . . . . 7  |-  ( D  x.  ( P ^ E ) )  =  ( ( P ^ E )  x.  D
)
1814, 17eqtri 2456 . . . . . 6  |-  M  =  ( ( P ^ E )  x.  D
)
1918oveq1i 6091 . . . . 5  |-  ( M  +  1 )  =  ( ( ( P ^ E )  x.  D )  +  1 )
2013, 19eqtri 2456 . . . 4  |-  N  =  ( ( ( P ^ E )  x.  D )  +  1 )
2120a1i 11 . . 3  |-  ( D  e.  NN  ->  N  =  ( ( ( P ^ E )  x.  D )  +  1 ) )
22 prmdvdsexpb 13115 . . . . . . 7  |-  ( ( x  e.  Prime  /\  P  e.  Prime  /\  E  e.  NN )  ->  ( x 
||  ( P ^ E )  <->  x  =  P ) )
232, 5, 22mp3an23 1271 . . . . . 6  |-  ( x  e.  Prime  ->  ( x 
||  ( P ^ E )  <->  x  =  P ) )
2413eqcomi 2440 . . . . . . . . . . 11  |-  ( M  +  1 )  =  N
25 pockthi.m . . . . . . . . . . . . . . . 16  |-  M  =  ( G  x.  P
)
26 pockthi.g . . . . . . . . . . . . . . . . 17  |-  G  e.  NN
2726, 4nnmulcli 10024 . . . . . . . . . . . . . . . 16  |-  ( G  x.  P )  e.  NN
2825, 27eqeltri 2506 . . . . . . . . . . . . . . 15  |-  M  e.  NN
29 peano2nn 10012 . . . . . . . . . . . . . . 15  |-  ( M  e.  NN  ->  ( M  +  1 )  e.  NN )
3028, 29ax-mp 8 . . . . . . . . . . . . . 14  |-  ( M  +  1 )  e.  NN
3113, 30eqeltri 2506 . . . . . . . . . . . . 13  |-  N  e.  NN
3231nncni 10010 . . . . . . . . . . . 12  |-  N  e.  CC
33 ax-1cn 9048 . . . . . . . . . . . 12  |-  1  e.  CC
3428nncni 10010 . . . . . . . . . . . 12  |-  M  e.  CC
3532, 33, 34subadd2i 9388 . . . . . . . . . . 11  |-  ( ( N  -  1 )  =  M  <->  ( M  +  1 )  =  N )
3624, 35mpbir 201 . . . . . . . . . 10  |-  ( N  -  1 )  =  M
3736oveq2i 6092 . . . . . . . . 9  |-  ( A ^ ( N  - 
1 ) )  =  ( A ^ M
)
3837oveq1i 6091 . . . . . . . 8  |-  ( ( A ^ ( N  -  1 ) )  mod  N )  =  ( ( A ^ M )  mod  N
)
39 pockthi.mod . . . . . . . . 9  |-  ( ( A ^ M )  mod  N )  =  ( 1  mod  N
)
4031nnrei 10009 . . . . . . . . . 10  |-  N  e.  RR
4128nngt0i 10033 . . . . . . . . . . . 12  |-  0  <  M
4228nnrei 10009 . . . . . . . . . . . . 13  |-  M  e.  RR
43 1re 9090 . . . . . . . . . . . . 13  |-  1  e.  RR
44 ltaddpos2 9519 . . . . . . . . . . . . 13  |-  ( ( M  e.  RR  /\  1  e.  RR )  ->  ( 0  <  M  <->  1  <  ( M  + 
1 ) ) )
4542, 43, 44mp2an 654 . . . . . . . . . . . 12  |-  ( 0  <  M  <->  1  <  ( M  +  1 ) )
4641, 45mpbi 200 . . . . . . . . . . 11  |-  1  <  ( M  +  1 )
4746, 13breqtrri 4237 . . . . . . . . . 10  |-  1  <  N
48 1mod 11273 . . . . . . . . . 10  |-  ( ( N  e.  RR  /\  1  <  N )  -> 
( 1  mod  N
)  =  1 )
4940, 47, 48mp2an 654 . . . . . . . . 9  |-  ( 1  mod  N )  =  1
5039, 49eqtri 2456 . . . . . . . 8  |-  ( ( A ^ M )  mod  N )  =  1
5138, 50eqtri 2456 . . . . . . 7  |-  ( ( A ^ ( N  -  1 ) )  mod  N )  =  1
52 oveq2 6089 . . . . . . . . . . . 12  |-  ( x  =  P  ->  (
( N  -  1 )  /  x )  =  ( ( N  -  1 )  /  P ) )
5326nncni 10010 . . . . . . . . . . . . . . 15  |-  G  e.  CC
544nncni 10010 . . . . . . . . . . . . . . 15  |-  P  e.  CC
5553, 54mulcomi 9096 . . . . . . . . . . . . . 14  |-  ( G  x.  P )  =  ( P  x.  G
)
5636, 25, 553eqtrri 2461 . . . . . . . . . . . . 13  |-  ( P  x.  G )  =  ( N  -  1 )
5732, 33subcli 9376 . . . . . . . . . . . . . 14  |-  ( N  -  1 )  e.  CC
584nnne0i 10034 . . . . . . . . . . . . . 14  |-  P  =/=  0
5957, 54, 53, 58divmuli 9768 . . . . . . . . . . . . 13  |-  ( ( ( N  -  1 )  /  P )  =  G  <->  ( P  x.  G )  =  ( N  -  1 ) )
6056, 59mpbir 201 . . . . . . . . . . . 12  |-  ( ( N  -  1 )  /  P )  =  G
6152, 60syl6eq 2484 . . . . . . . . . . 11  |-  ( x  =  P  ->  (
( N  -  1 )  /  x )  =  G )
6261oveq2d 6097 . . . . . . . . . 10  |-  ( x  =  P  ->  ( A ^ ( ( N  -  1 )  /  x ) )  =  ( A ^ G
) )
6362oveq1d 6096 . . . . . . . . 9  |-  ( x  =  P  ->  (
( A ^ (
( N  -  1 )  /  x ) )  -  1 )  =  ( ( A ^ G )  - 
1 ) )
6463oveq1d 6096 . . . . . . . 8  |-  ( x  =  P  ->  (
( ( A ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  ( ( ( A ^ G )  -  1 )  gcd 
N ) )
65 pockthi.gcd . . . . . . . 8  |-  ( ( ( A ^ G
)  -  1 )  gcd  N )  =  1
6664, 65syl6eq 2484 . . . . . . 7  |-  ( x  =  P  ->  (
( ( A ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  1 )
67 pockthi.a . . . . . . . . 9  |-  A  e.  NN
6867nnzi 10305 . . . . . . . 8  |-  A  e.  ZZ
69 oveq1 6088 . . . . . . . . . . . 12  |-  ( y  =  A  ->  (
y ^ ( N  -  1 ) )  =  ( A ^
( N  -  1 ) ) )
7069oveq1d 6096 . . . . . . . . . . 11  |-  ( y  =  A  ->  (
( y ^ ( N  -  1 ) )  mod  N )  =  ( ( A ^ ( N  - 
1 ) )  mod 
N ) )
7170eqeq1d 2444 . . . . . . . . . 10  |-  ( y  =  A  ->  (
( ( y ^
( N  -  1 ) )  mod  N
)  =  1  <->  (
( A ^ ( N  -  1 ) )  mod  N )  =  1 ) )
72 oveq1 6088 . . . . . . . . . . . . 13  |-  ( y  =  A  ->  (
y ^ ( ( N  -  1 )  /  x ) )  =  ( A ^
( ( N  - 
1 )  /  x
) ) )
7372oveq1d 6096 . . . . . . . . . . . 12  |-  ( y  =  A  ->  (
( y ^ (
( N  -  1 )  /  x ) )  -  1 )  =  ( ( A ^ ( ( N  -  1 )  /  x ) )  - 
1 ) )
7473oveq1d 6096 . . . . . . . . . . 11  |-  ( y  =  A  ->  (
( ( y ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  ( ( ( A ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N ) )
7574eqeq1d 2444 . . . . . . . . . 10  |-  ( y  =  A  ->  (
( ( ( y ^ ( ( N  -  1 )  /  x ) )  - 
1 )  gcd  N
)  =  1  <->  (
( ( A ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  1 ) )
7671, 75anbi12d 692 . . . . . . . . 9  |-  ( y  =  A  ->  (
( ( ( y ^ ( N  - 
1 ) )  mod 
N )  =  1  /\  ( ( ( y ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N )  =  1 )  <->  ( ( ( A ^ ( N  -  1 ) )  mod  N )  =  1  /\  ( ( ( A ^ (
( N  -  1 )  /  x ) )  -  1 )  gcd  N )  =  1 ) ) )
7776rspcev 3052 . . . . . . . 8  |-  ( ( A  e.  ZZ  /\  ( ( ( A ^ ( N  - 
1 ) )  mod 
N )  =  1  /\  ( ( ( A ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N )  =  1 ) )  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  -  1 ) )  mod  N )  =  1  /\  ( ( ( y ^ (
( N  -  1 )  /  x ) )  -  1 )  gcd  N )  =  1 ) )
7868, 77mpan 652 . . . . . . 7  |-  ( ( ( ( A ^
( N  -  1 ) )  mod  N
)  =  1  /\  ( ( ( A ^ ( ( N  -  1 )  /  x ) )  - 
1 )  gcd  N
)  =  1 )  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  - 
1 ) )  mod 
N )  =  1  /\  ( ( ( y ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N )  =  1 ) )
7951, 66, 78sylancr 645 . . . . . 6  |-  ( x  =  P  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  -  1 ) )  mod  N )  =  1  /\  ( ( ( y ^ (
( N  -  1 )  /  x ) )  -  1 )  gcd  N )  =  1 ) )
8023, 79syl6bi 220 . . . . 5  |-  ( x  e.  Prime  ->  ( x 
||  ( P ^ E )  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  -  1 ) )  mod  N )  =  1  /\  ( ( ( y ^ (
( N  -  1 )  /  x ) )  -  1 )  gcd  N )  =  1 ) ) )
8180rgen 2771 . . . 4  |-  A. x  e.  Prime  ( x  ||  ( P ^ E )  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  - 
1 ) )  mod 
N )  =  1  /\  ( ( ( y ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N )  =  1 ) )
8281a1i 11 . . 3  |-  ( D  e.  NN  ->  A. x  e.  Prime  ( x  ||  ( P ^ E )  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  - 
1 ) )  mod 
N )  =  1  /\  ( ( ( y ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N )  =  1 ) ) )
839, 10, 12, 21, 82pockthg 13274 . 2  |-  ( D  e.  NN  ->  N  e.  Prime )
841, 83ax-mp 8 1  |-  N  e. 
Prime
Colors of variables: wff set class
Syntax hints:    -> wi 4    <-> wb 177    /\ wa 359    = wceq 1652    e. wcel 1725   A.wral 2705   E.wrex 2706   class class class wbr 4212  (class class class)co 6081   RRcr 8989   0cc0 8990   1c1 8991    + caddc 8993    x. cmul 8995    < clt 9120    - cmin 9291    / cdiv 9677   NNcn 10000   NN0cn0 10221   ZZcz 10282    mod cmo 11250   ^cexp 11382    || cdivides 12852    gcd cgcd 13006   Primecprime 13079
This theorem is referenced by:  1259prm  13455  2503prm  13459  4001prm  13464
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1555  ax-5 1566  ax-17 1626  ax-9 1666  ax-8 1687  ax-13 1727  ax-14 1729  ax-6 1744  ax-7 1749  ax-11 1761  ax-12 1950  ax-ext 2417  ax-rep 4320  ax-sep 4330  ax-nul 4338  ax-pow 4377  ax-pr 4403  ax-un 4701  ax-cnex 9046  ax-resscn 9047  ax-1cn 9048  ax-icn 9049  ax-addcl 9050  ax-addrcl 9051  ax-mulcl 9052  ax-mulrcl 9053  ax-mulcom 9054  ax-addass 9055  ax-mulass 9056  ax-distr 9057  ax-i2m1 9058  ax-1ne0 9059  ax-1rid 9060  ax-rnegex 9061  ax-rrecex 9062  ax-cnre 9063  ax-pre-lttri 9064  ax-pre-lttrn 9065  ax-pre-ltadd 9066  ax-pre-mulgt0 9067  ax-pre-sup 9068
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1328  df-ex 1551  df-nf 1554  df-sb 1659  df-eu 2285  df-mo 2286  df-clab 2423  df-cleq 2429  df-clel 2432  df-nfc 2561  df-ne 2601  df-nel 2602  df-ral 2710  df-rex 2711  df-reu 2712  df-rmo 2713  df-rab 2714  df-v 2958  df-sbc 3162  df-csb 3252  df-dif 3323  df-un 3325  df-in 3327  df-ss 3334  df-pss 3336  df-nul 3629  df-if 3740  df-pw 3801  df-sn 3820  df-pr 3821  df-tp 3822  df-op 3823  df-uni 4016  df-int 4051  df-iun 4095  df-br 4213  df-opab 4267  df-mpt 4268  df-tr 4303  df-eprel 4494  df-id 4498  df-po 4503  df-so 4504  df-fr 4541  df-we 4543  df-ord 4584  df-on 4585  df-lim 4586  df-suc 4587  df-om 4846  df-xp 4884  df-rel 4885  df-cnv 4886  df-co 4887  df-dm 4888  df-rn 4889  df-res 4890  df-ima 4891  df-iota 5418  df-fun 5456  df-fn 5457  df-f 5458  df-f1 5459  df-fo 5460  df-f1o 5461  df-fv 5462  df-ov 6084  df-oprab 6085  df-mpt2 6086  df-1st 6349  df-2nd 6350  df-riota 6549  df-recs 6633  df-rdg 6668  df-1o 6724  df-2o 6725  df-oadd 6728  df-er 6905  df-map 7020  df-en 7110  df-dom 7111  df-sdom 7112  df-fin 7113  df-sup 7446  df-card 7826  df-cda 8048  df-pnf 9122  df-mnf 9123  df-xr 9124  df-ltxr 9125  df-le 9126  df-sub 9293  df-neg 9294  df-div 9678  df-nn 10001  df-2 10058  df-3 10059  df-n0 10222  df-z 10283  df-uz 10489  df-q 10575  df-rp 10613  df-fz 11044  df-fzo 11136  df-fl 11202  df-mod 11251  df-seq 11324  df-exp 11383  df-hash 11619  df-cj 11904  df-re 11905  df-im 11906  df-sqr 12040  df-abs 12041  df-dvds 12853  df-gcd 13007  df-prm 13080  df-odz 13154  df-phi 13155  df-pc 13211
  Copyright terms: Public domain W3C validator