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

Theorem pockthi 14087
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 14086 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 13885 . . . . . 6  |-  ( P  e.  Prime  ->  P  e.  NN )
42, 3ax-mp 5 . . . . 5  |-  P  e.  NN
5 pockthi.e . . . . . 6  |-  E  e.  NN
65nnnn0i 10699 . . . . 5  |-  E  e. 
NN0
7 nnexpcl 11996 . . . . 5  |-  ( ( P  e.  NN  /\  E  e.  NN0 )  -> 
( P ^ E
)  e.  NN )
84, 6, 7mp2an 672 . . . 4  |-  ( P ^ E )  e.  NN
98a1i 11 . . 3  |-  ( D  e.  NN  ->  ( P ^ E )  e.  NN )
10 id 22 . . 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 10444 . . . . . . . 8  |-  D  e.  CC
168nncni 10444 . . . . . . . 8  |-  ( P ^ E )  e.  CC
1715, 16mulcomi 9504 . . . . . . 7  |-  ( D  x.  ( P ^ E ) )  =  ( ( P ^ E )  x.  D
)
1814, 17eqtri 2483 . . . . . 6  |-  M  =  ( ( P ^ E )  x.  D
)
1918oveq1i 6211 . . . . 5  |-  ( M  +  1 )  =  ( ( ( P ^ E )  x.  D )  +  1 )
2013, 19eqtri 2483 . . . 4  |-  N  =  ( ( ( P ^ E )  x.  D )  +  1 )
2120a1i 11 . . 3  |-  ( D  e.  NN  ->  N  =  ( ( ( P ^ E )  x.  D )  +  1 ) )
22 prmdvdsexpb 13920 . . . . . . 7  |-  ( ( x  e.  Prime  /\  P  e.  Prime  /\  E  e.  NN )  ->  ( x 
||  ( P ^ E )  <->  x  =  P ) )
232, 5, 22mp3an23 1307 . . . . . 6  |-  ( x  e.  Prime  ->  ( x 
||  ( P ^ E )  <->  x  =  P ) )
2413eqcomi 2467 . . . . . . . . . . 11  |-  ( M  +  1 )  =  N
25 pockthi.m . . . . . . . . . . . . . . . 16  |-  M  =  ( G  x.  P
)
26 pockthi.g . . . . . . . . . . . . . . . . 17  |-  G  e.  NN
2726, 4nnmulcli 10458 . . . . . . . . . . . . . . . 16  |-  ( G  x.  P )  e.  NN
2825, 27eqeltri 2538 . . . . . . . . . . . . . . 15  |-  M  e.  NN
29 peano2nn 10446 . . . . . . . . . . . . . . 15  |-  ( M  e.  NN  ->  ( M  +  1 )  e.  NN )
3028, 29ax-mp 5 . . . . . . . . . . . . . 14  |-  ( M  +  1 )  e.  NN
3113, 30eqeltri 2538 . . . . . . . . . . . . 13  |-  N  e.  NN
3231nncni 10444 . . . . . . . . . . . 12  |-  N  e.  CC
33 ax-1cn 9452 . . . . . . . . . . . 12  |-  1  e.  CC
3428nncni 10444 . . . . . . . . . . . 12  |-  M  e.  CC
3532, 33, 34subadd2i 9808 . . . . . . . . . . 11  |-  ( ( N  -  1 )  =  M  <->  ( M  +  1 )  =  N )
3624, 35mpbir 209 . . . . . . . . . 10  |-  ( N  -  1 )  =  M
3736oveq2i 6212 . . . . . . . . 9  |-  ( A ^ ( N  - 
1 ) )  =  ( A ^ M
)
3837oveq1i 6211 . . . . . . . 8  |-  ( ( A ^ ( N  -  1 ) )  mod  N )  =  ( ( A ^ M )  mod  N
)
39 pockthi.mod . . . . . . . . 9  |-  ( ( A ^ M )  mod  N )  =  ( 1  mod  N
)
4031nnrei 10443 . . . . . . . . . 10  |-  N  e.  RR
4128nngt0i 10467 . . . . . . . . . . . 12  |-  0  <  M
4228nnrei 10443 . . . . . . . . . . . . 13  |-  M  e.  RR
43 1re 9497 . . . . . . . . . . . . 13  |-  1  e.  RR
44 ltaddpos2 9942 . . . . . . . . . . . . 13  |-  ( ( M  e.  RR  /\  1  e.  RR )  ->  ( 0  <  M  <->  1  <  ( M  + 
1 ) ) )
4542, 43, 44mp2an 672 . . . . . . . . . . . 12  |-  ( 0  <  M  <->  1  <  ( M  +  1 ) )
4641, 45mpbi 208 . . . . . . . . . . 11  |-  1  <  ( M  +  1 )
4746, 13breqtrri 4426 . . . . . . . . . 10  |-  1  <  N
48 1mod 11858 . . . . . . . . . 10  |-  ( ( N  e.  RR  /\  1  <  N )  -> 
( 1  mod  N
)  =  1 )
4940, 47, 48mp2an 672 . . . . . . . . 9  |-  ( 1  mod  N )  =  1
5039, 49eqtri 2483 . . . . . . . 8  |-  ( ( A ^ M )  mod  N )  =  1
5138, 50eqtri 2483 . . . . . . 7  |-  ( ( A ^ ( N  -  1 ) )  mod  N )  =  1
52 oveq2 6209 . . . . . . . . . . . 12  |-  ( x  =  P  ->  (
( N  -  1 )  /  x )  =  ( ( N  -  1 )  /  P ) )
5326nncni 10444 . . . . . . . . . . . . . . 15  |-  G  e.  CC
544nncni 10444 . . . . . . . . . . . . . . 15  |-  P  e.  CC
5553, 54mulcomi 9504 . . . . . . . . . . . . . 14  |-  ( G  x.  P )  =  ( P  x.  G
)
5636, 25, 553eqtrri 2488 . . . . . . . . . . . . 13  |-  ( P  x.  G )  =  ( N  -  1 )
5732, 33subcli 9796 . . . . . . . . . . . . . 14  |-  ( N  -  1 )  e.  CC
584nnne0i 10468 . . . . . . . . . . . . . 14  |-  P  =/=  0
5957, 54, 53, 58divmuli 10197 . . . . . . . . . . . . 13  |-  ( ( ( N  -  1 )  /  P )  =  G  <->  ( P  x.  G )  =  ( N  -  1 ) )
6056, 59mpbir 209 . . . . . . . . . . . 12  |-  ( ( N  -  1 )  /  P )  =  G
6152, 60syl6eq 2511 . . . . . . . . . . 11  |-  ( x  =  P  ->  (
( N  -  1 )  /  x )  =  G )
6261oveq2d 6217 . . . . . . . . . 10  |-  ( x  =  P  ->  ( A ^ ( ( N  -  1 )  /  x ) )  =  ( A ^ G
) )
6362oveq1d 6216 . . . . . . . . 9  |-  ( x  =  P  ->  (
( A ^ (
( N  -  1 )  /  x ) )  -  1 )  =  ( ( A ^ G )  - 
1 ) )
6463oveq1d 6216 . . . . . . . 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 2511 . . . . . . 7  |-  ( x  =  P  ->  (
( ( A ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  1 )
67 pockthi.a . . . . . . . . 9  |-  A  e.  NN
6867nnzi 10782 . . . . . . . 8  |-  A  e.  ZZ
69 oveq1 6208 . . . . . . . . . . . 12  |-  ( y  =  A  ->  (
y ^ ( N  -  1 ) )  =  ( A ^
( N  -  1 ) ) )
7069oveq1d 6216 . . . . . . . . . . 11  |-  ( y  =  A  ->  (
( y ^ ( N  -  1 ) )  mod  N )  =  ( ( A ^ ( N  - 
1 ) )  mod 
N ) )
7170eqeq1d 2456 . . . . . . . . . 10  |-  ( y  =  A  ->  (
( ( y ^
( N  -  1 ) )  mod  N
)  =  1  <->  (
( A ^ ( N  -  1 ) )  mod  N )  =  1 ) )
72 oveq1 6208 . . . . . . . . . . . . 13  |-  ( y  =  A  ->  (
y ^ ( ( N  -  1 )  /  x ) )  =  ( A ^
( ( N  - 
1 )  /  x
) ) )
7372oveq1d 6216 . . . . . . . . . . . 12  |-  ( y  =  A  ->  (
( y ^ (
( N  -  1 )  /  x ) )  -  1 )  =  ( ( A ^ ( ( N  -  1 )  /  x ) )  - 
1 ) )
7473oveq1d 6216 . . . . . . . . . . 11  |-  ( y  =  A  ->  (
( ( y ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  ( ( ( A ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N ) )
7574eqeq1d 2456 . . . . . . . . . 10  |-  ( y  =  A  ->  (
( ( ( y ^ ( ( N  -  1 )  /  x ) )  - 
1 )  gcd  N
)  =  1  <->  (
( ( A ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  1 ) )
7671, 75anbi12d 710 . . . . . . . . 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 3179 . . . . . . . 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 670 . . . . . . 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 663 . . . . . 6  |-  ( x  =  P  ->  E. y  e.  ZZ  ( ( ( y ^ ( N  -  1 ) )  mod  N )  =  1  /\  ( ( ( y ^ (
( N  -  1 )  /  x ) )  -  1 )  gcd  N )  =  1 ) )
8023, 79syl6bi 228 . . . . 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 2899 . . . 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 14086 . 2  |-  ( D  e.  NN  ->  N  e.  Prime )
841, 83ax-mp 5 1  |-  N  e. 
Prime
Colors of variables: wff setvar class
Syntax hints:    -> wi 4    <-> wb 184    /\ wa 369    = wceq 1370    e. wcel 1758   A.wral 2799   E.wrex 2800   class class class wbr 4401  (class class class)co 6201   RRcr 9393   0cc0 9394   1c1 9395    + caddc 9397    x. cmul 9399    < clt 9530    - cmin 9707    / cdiv 10105   NNcn 10434   NN0cn0 10691   ZZcz 10758    mod cmo 11826   ^cexp 11983    || cdivides 13654    gcd cgcd 13809   Primecprime 13882
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1592  ax-4 1603  ax-5 1671  ax-6 1710  ax-7 1730  ax-8 1760  ax-9 1762  ax-10 1777  ax-11 1782  ax-12 1794  ax-13 1955  ax-ext 2432  ax-rep 4512  ax-sep 4522  ax-nul 4530  ax-pow 4579  ax-pr 4640  ax-un 6483  ax-cnex 9450  ax-resscn 9451  ax-1cn 9452  ax-icn 9453  ax-addcl 9454  ax-addrcl 9455  ax-mulcl 9456  ax-mulrcl 9457  ax-mulcom 9458  ax-addass 9459  ax-mulass 9460  ax-distr 9461  ax-i2m1 9462  ax-1ne0 9463  ax-1rid 9464  ax-rnegex 9465  ax-rrecex 9466  ax-cnre 9467  ax-pre-lttri 9468  ax-pre-lttrn 9469  ax-pre-ltadd 9470  ax-pre-mulgt0 9471  ax-pre-sup 9472
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-tru 1373  df-ex 1588  df-nf 1591  df-sb 1703  df-eu 2266  df-mo 2267  df-clab 2440  df-cleq 2446  df-clel 2449  df-nfc 2604  df-ne 2650  df-nel 2651  df-ral 2804  df-rex 2805  df-reu 2806  df-rmo 2807  df-rab 2808  df-v 3080  df-sbc 3295  df-csb 3397  df-dif 3440  df-un 3442  df-in 3444  df-ss 3451  df-pss 3453  df-nul 3747  df-if 3901  df-pw 3971  df-sn 3987  df-pr 3989  df-tp 3991  df-op 3993  df-uni 4201  df-int 4238  df-iun 4282  df-br 4402  df-opab 4460  df-mpt 4461  df-tr 4495  df-eprel 4741  df-id 4745  df-po 4750  df-so 4751  df-fr 4788  df-we 4790  df-ord 4831  df-on 4832  df-lim 4833  df-suc 4834  df-xp 4955  df-rel 4956  df-cnv 4957  df-co 4958  df-dm 4959  df-rn 4960  df-res 4961  df-ima 4962  df-iota 5490  df-fun 5529  df-fn 5530  df-f 5531  df-f1 5532  df-fo 5533  df-f1o 5534  df-fv 5535  df-riota 6162  df-ov 6204  df-oprab 6205  df-mpt2 6206  df-om 6588  df-1st 6688  df-2nd 6689  df-recs 6943  df-rdg 6977  df-1o 7031  df-2o 7032  df-oadd 7035  df-er 7212  df-map 7327  df-en 7422  df-dom 7423  df-sdom 7424  df-fin 7425  df-sup 7803  df-card 8221  df-cda 8449  df-pnf 9532  df-mnf 9533  df-xr 9534  df-ltxr 9535  df-le 9536  df-sub 9709  df-neg 9710  df-div 10106  df-nn 10435  df-2 10492  df-3 10493  df-n0 10692  df-z 10759  df-uz 10974  df-q 11066  df-rp 11104  df-fz 11556  df-fzo 11667  df-fl 11760  df-mod 11827  df-seq 11925  df-exp 11984  df-hash 12222  df-cj 12707  df-re 12708  df-im 12709  df-sqr 12843  df-abs 12844  df-dvds 13655  df-gcd 13810  df-prm 13883  df-odz 13959  df-phi 13960  df-pc 14023
This theorem is referenced by:  1259prm  14279  2503prm  14283  4001prm  14288
  Copyright terms: Public domain W3C validator