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

Theorem pockthi 14297
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 14296 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 14092 . . . . . 6  |-  ( P  e.  Prime  ->  P  e.  NN )
42, 3ax-mp 5 . . . . 5  |-  P  e.  NN
5 pockthi.e . . . . . 6  |-  E  e.  NN
65nnnn0i 10804 . . . . 5  |-  E  e. 
NN0
7 nnexpcl 12153 . . . . 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 10547 . . . . . . . 8  |-  D  e.  CC
168nncni 10547 . . . . . . . 8  |-  ( P ^ E )  e.  CC
1715, 16mulcomi 9600 . . . . . . 7  |-  ( D  x.  ( P ^ E ) )  =  ( ( P ^ E )  x.  D
)
1814, 17eqtri 2470 . . . . . 6  |-  M  =  ( ( P ^ E )  x.  D
)
1918oveq1i 6287 . . . . 5  |-  ( M  +  1 )  =  ( ( ( P ^ E )  x.  D )  +  1 )
2013, 19eqtri 2470 . . . 4  |-  N  =  ( ( ( P ^ E )  x.  D )  +  1 )
2120a1i 11 . . 3  |-  ( D  e.  NN  ->  N  =  ( ( ( P ^ E )  x.  D )  +  1 ) )
22 prmdvdsexpb 14128 . . . . . . 7  |-  ( ( x  e.  Prime  /\  P  e.  Prime  /\  E  e.  NN )  ->  ( x 
||  ( P ^ E )  <->  x  =  P ) )
232, 5, 22mp3an23 1315 . . . . . 6  |-  ( x  e.  Prime  ->  ( x 
||  ( P ^ E )  <->  x  =  P ) )
2413eqcomi 2454 . . . . . . . . . . 11  |-  ( M  +  1 )  =  N
25 pockthi.m . . . . . . . . . . . . . . . 16  |-  M  =  ( G  x.  P
)
26 pockthi.g . . . . . . . . . . . . . . . . 17  |-  G  e.  NN
2726, 4nnmulcli 10561 . . . . . . . . . . . . . . . 16  |-  ( G  x.  P )  e.  NN
2825, 27eqeltri 2525 . . . . . . . . . . . . . . 15  |-  M  e.  NN
29 peano2nn 10549 . . . . . . . . . . . . . . 15  |-  ( M  e.  NN  ->  ( M  +  1 )  e.  NN )
3028, 29ax-mp 5 . . . . . . . . . . . . . 14  |-  ( M  +  1 )  e.  NN
3113, 30eqeltri 2525 . . . . . . . . . . . . 13  |-  N  e.  NN
3231nncni 10547 . . . . . . . . . . . 12  |-  N  e.  CC
33 ax-1cn 9548 . . . . . . . . . . . 12  |-  1  e.  CC
3428nncni 10547 . . . . . . . . . . . 12  |-  M  e.  CC
3532, 33, 34subadd2i 9908 . . . . . . . . . . 11  |-  ( ( N  -  1 )  =  M  <->  ( M  +  1 )  =  N )
3624, 35mpbir 209 . . . . . . . . . 10  |-  ( N  -  1 )  =  M
3736oveq2i 6288 . . . . . . . . 9  |-  ( A ^ ( N  - 
1 ) )  =  ( A ^ M
)
3837oveq1i 6287 . . . . . . . 8  |-  ( ( A ^ ( N  -  1 ) )  mod  N )  =  ( ( A ^ M )  mod  N
)
39 pockthi.mod . . . . . . . . 9  |-  ( ( A ^ M )  mod  N )  =  ( 1  mod  N
)
4031nnrei 10546 . . . . . . . . . 10  |-  N  e.  RR
4128nngt0i 10570 . . . . . . . . . . . 12  |-  0  <  M
4228nnrei 10546 . . . . . . . . . . . . 13  |-  M  e.  RR
43 1re 9593 . . . . . . . . . . . . 13  |-  1  e.  RR
44 ltaddpos2 10044 . . . . . . . . . . . . 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 4458 . . . . . . . . . 10  |-  1  <  N
48 1mod 12002 . . . . . . . . . 10  |-  ( ( N  e.  RR  /\  1  <  N )  -> 
( 1  mod  N
)  =  1 )
4940, 47, 48mp2an 672 . . . . . . . . 9  |-  ( 1  mod  N )  =  1
5039, 49eqtri 2470 . . . . . . . 8  |-  ( ( A ^ M )  mod  N )  =  1
5138, 50eqtri 2470 . . . . . . 7  |-  ( ( A ^ ( N  -  1 ) )  mod  N )  =  1
52 oveq2 6285 . . . . . . . . . . . 12  |-  ( x  =  P  ->  (
( N  -  1 )  /  x )  =  ( ( N  -  1 )  /  P ) )
5326nncni 10547 . . . . . . . . . . . . . . 15  |-  G  e.  CC
544nncni 10547 . . . . . . . . . . . . . . 15  |-  P  e.  CC
5553, 54mulcomi 9600 . . . . . . . . . . . . . 14  |-  ( G  x.  P )  =  ( P  x.  G
)
5636, 25, 553eqtrri 2475 . . . . . . . . . . . . 13  |-  ( P  x.  G )  =  ( N  -  1 )
5732, 33subcli 9895 . . . . . . . . . . . . . 14  |-  ( N  -  1 )  e.  CC
584nnne0i 10571 . . . . . . . . . . . . . 14  |-  P  =/=  0
5957, 54, 53, 58divmuli 10299 . . . . . . . . . . . . 13  |-  ( ( ( N  -  1 )  /  P )  =  G  <->  ( P  x.  G )  =  ( N  -  1 ) )
6056, 59mpbir 209 . . . . . . . . . . . 12  |-  ( ( N  -  1 )  /  P )  =  G
6152, 60syl6eq 2498 . . . . . . . . . . 11  |-  ( x  =  P  ->  (
( N  -  1 )  /  x )  =  G )
6261oveq2d 6293 . . . . . . . . . 10  |-  ( x  =  P  ->  ( A ^ ( ( N  -  1 )  /  x ) )  =  ( A ^ G
) )
6362oveq1d 6292 . . . . . . . . 9  |-  ( x  =  P  ->  (
( A ^ (
( N  -  1 )  /  x ) )  -  1 )  =  ( ( A ^ G )  - 
1 ) )
6463oveq1d 6292 . . . . . . . 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 2498 . . . . . . 7  |-  ( x  =  P  ->  (
( ( A ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  1 )
67 pockthi.a . . . . . . . . 9  |-  A  e.  NN
6867nnzi 10889 . . . . . . . 8  |-  A  e.  ZZ
69 oveq1 6284 . . . . . . . . . . . 12  |-  ( y  =  A  ->  (
y ^ ( N  -  1 ) )  =  ( A ^
( N  -  1 ) ) )
7069oveq1d 6292 . . . . . . . . . . 11  |-  ( y  =  A  ->  (
( y ^ ( N  -  1 ) )  mod  N )  =  ( ( A ^ ( N  - 
1 ) )  mod 
N ) )
7170eqeq1d 2443 . . . . . . . . . 10  |-  ( y  =  A  ->  (
( ( y ^
( N  -  1 ) )  mod  N
)  =  1  <->  (
( A ^ ( N  -  1 ) )  mod  N )  =  1 ) )
72 oveq1 6284 . . . . . . . . . . . . 13  |-  ( y  =  A  ->  (
y ^ ( ( N  -  1 )  /  x ) )  =  ( A ^
( ( N  - 
1 )  /  x
) ) )
7372oveq1d 6292 . . . . . . . . . . . 12  |-  ( y  =  A  ->  (
( y ^ (
( N  -  1 )  /  x ) )  -  1 )  =  ( ( A ^ ( ( N  -  1 )  /  x ) )  - 
1 ) )
7473oveq1d 6292 . . . . . . . . . . 11  |-  ( y  =  A  ->  (
( ( y ^
( ( N  - 
1 )  /  x
) )  -  1 )  gcd  N )  =  ( ( ( A ^ ( ( N  -  1 )  /  x ) )  -  1 )  gcd 
N ) )
7574eqeq1d 2443 . . . . . . . . . 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 3194 . . . . . . . 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 2801 . . . 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 14296 . 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 1381    e. wcel 1802   A.wral 2791   E.wrex 2792   class class class wbr 4433  (class class class)co 6277   RRcr 9489   0cc0 9490   1c1 9491    + caddc 9493    x. cmul 9495    < clt 9626    - cmin 9805    / cdiv 10207   NNcn 10537   NN0cn0 10796   ZZcz 10865    mod cmo 11970   ^cexp 12140    || cdvds 13858    gcd cgcd 14016   Primecprime 14089
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 4544  ax-sep 4554  ax-nul 4562  ax-pow 4611  ax-pr 4672  ax-un 6573  ax-cnex 9546  ax-resscn 9547  ax-1cn 9548  ax-icn 9549  ax-addcl 9550  ax-addrcl 9551  ax-mulcl 9552  ax-mulrcl 9553  ax-mulcom 9554  ax-addass 9555  ax-mulass 9556  ax-distr 9557  ax-i2m1 9558  ax-1ne0 9559  ax-1rid 9560  ax-rnegex 9561  ax-rrecex 9562  ax-cnre 9563  ax-pre-lttri 9564  ax-pre-lttrn 9565  ax-pre-ltadd 9566  ax-pre-mulgt0 9567  ax-pre-sup 9568
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 3418  df-dif 3461  df-un 3463  df-in 3465  df-ss 3472  df-pss 3474  df-nul 3768  df-if 3923  df-pw 3995  df-sn 4011  df-pr 4013  df-tp 4015  df-op 4017  df-uni 4231  df-int 4268  df-iun 4313  df-br 4434  df-opab 4492  df-mpt 4493  df-tr 4527  df-eprel 4777  df-id 4781  df-po 4786  df-so 4787  df-fr 4824  df-we 4826  df-ord 4867  df-on 4868  df-lim 4869  df-suc 4870  df-xp 4991  df-rel 4992  df-cnv 4993  df-co 4994  df-dm 4995  df-rn 4996  df-res 4997  df-ima 4998  df-iota 5537  df-fun 5576  df-fn 5577  df-f 5578  df-f1 5579  df-fo 5580  df-f1o 5581  df-fv 5582  df-riota 6238  df-ov 6280  df-oprab 6281  df-mpt2 6282  df-om 6682  df-1st 6781  df-2nd 6782  df-recs 7040  df-rdg 7074  df-1o 7128  df-2o 7129  df-oadd 7132  df-er 7309  df-map 7420  df-en 7515  df-dom 7516  df-sdom 7517  df-fin 7518  df-sup 7899  df-card 8318  df-cda 8546  df-pnf 9628  df-mnf 9629  df-xr 9630  df-ltxr 9631  df-le 9632  df-sub 9807  df-neg 9808  df-div 10208  df-nn 10538  df-2 10595  df-3 10596  df-n0 10797  df-z 10866  df-uz 11086  df-q 11187  df-rp 11225  df-fz 11677  df-fzo 11799  df-fl 11903  df-mod 11971  df-seq 12082  df-exp 12141  df-hash 12380  df-cj 12906  df-re 12907  df-im 12908  df-sqrt 13042  df-abs 13043  df-dvds 13859  df-gcd 14017  df-prm 14090  df-odz 14167  df-phi 14168  df-pc 14233
This theorem is referenced by:  1259prm  14490  2503prm  14494  4001prm  14499
  Copyright terms: Public domain W3C validator