Metamath Proof Explorer


Theorem proththd

Description: Proth's theorem (1878). If P is aProth number, i.e. a number of the form k2^n+1 with k less than 2^n, and if there exists an integer x for which x^((P-1)/2) is -1 modulo P, then P is prime. Such a prime is called aProth prime. Like Pocklington's theorem (see pockthg ), Proth's theorem allows for a convenient method for verifying large primes. (Contributed by AV, 5-Jul-2020)

Ref Expression
Hypotheses proththd.n φ N
proththd.k φ K
proththd.p φ P = K 2 N + 1
proththd.l φ K < 2 N
proththd.x φ x x P 1 2 mod P = -1 mod P
Assertion proththd φ P

Proof

Step Hyp Ref Expression
1 proththd.n φ N
2 proththd.k φ K
3 proththd.p φ P = K 2 N + 1
4 proththd.l φ K < 2 N
5 proththd.x φ x x P 1 2 mod P = -1 mod P
6 2nn 2
7 6 a1i φ 2
8 1 nnnn0d φ N 0
9 7 8 nnexpcld φ 2 N
10 2 nncnd φ K
11 9 nncnd φ 2 N
12 10 11 mulcomd φ K 2 N = 2 N K
13 12 oveq1d φ K 2 N + 1 = 2 N K + 1
14 3 13 eqtrd φ P = 2 N K + 1
15 simpr φ p p
16 2prm 2
17 16 a1i φ p 2
18 1 adantr φ p N
19 prmdvdsexpb p 2 N p 2 N p = 2
20 15 17 18 19 syl3anc φ p p 2 N p = 2
21 1 2 3 proththdlem φ P 1 < P P 1 2
22 21 simp1d φ P
23 22 nncnd φ P
24 peano2cnm P P 1
25 23 24 syl φ P 1
26 25 adantr φ x P 1
27 2cnd φ x 2
28 2ne0 2 0
29 28 a1i φ x 2 0
30 26 27 29 divcan1d φ x P 1 2 2 = P 1
31 30 eqcomd φ x P 1 = P 1 2 2
32 31 oveq2d φ x x P 1 = x P 1 2 2
33 zcn x x
34 33 adantl φ x x
35 2nn0 2 0
36 35 a1i φ x 2 0
37 21 simp3d φ P 1 2
38 37 nnnn0d φ P 1 2 0
39 38 adantr φ x P 1 2 0
40 34 36 39 expmuld φ x x P 1 2 2 = x P 1 2 2
41 32 40 eqtrd φ x x P 1 = x P 1 2 2
42 41 ad4ant13 φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 = x P 1 2 2
43 42 oveq1d φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 mod P = x P 1 2 2 mod P
44 38 adantr φ p = 2 P 1 2 0
45 44 anim1i φ p = 2 x P 1 2 0 x
46 45 ancomd φ p = 2 x x P 1 2 0
47 zexpcl x P 1 2 0 x P 1 2
48 46 47 syl φ p = 2 x x P 1 2
49 48 adantr φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 2
50 22 nnrpd φ P +
51 50 ad3antrrr φ p = 2 x x P 1 2 mod P = -1 mod P P +
52 21 simp2d φ 1 < P
53 52 ad3antrrr φ p = 2 x x P 1 2 mod P = -1 mod P 1 < P
54 simpr φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 2 mod P = -1 mod P
55 49 51 53 54 modexp2m1d φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 2 2 mod P = 1
56 43 55 eqtrd φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 mod P = 1
57 oveq2 p = 2 P 1 p = P 1 2
58 57 eleq1d p = 2 P 1 p 0 P 1 2 0
59 58 adantl φ p = 2 P 1 p 0 P 1 2 0
60 44 59 mpbird φ p = 2 P 1 p 0
61 60 anim2i x φ p = 2 x P 1 p 0
62 61 ancoms φ p = 2 x x P 1 p 0
63 zexpcl x P 1 p 0 x P 1 p
64 62 63 syl φ p = 2 x x P 1 p
65 64 zred φ p = 2 x x P 1 p
66 65 adantr φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p
67 1red φ p = 2 x x P 1 2 mod P = -1 mod P 1
68 67 renegcld φ p = 2 x x P 1 2 mod P = -1 mod P 1
69 oveq2 2 = p P 1 2 = P 1 p
70 69 eqcoms p = 2 P 1 2 = P 1 p
71 70 oveq2d p = 2 x P 1 2 = x P 1 p
72 71 oveq1d p = 2 x P 1 2 mod P = x P 1 p mod P
73 72 eqeq1d p = 2 x P 1 2 mod P = -1 mod P x P 1 p mod P = -1 mod P
74 73 adantl φ p = 2 x P 1 2 mod P = -1 mod P x P 1 p mod P = -1 mod P
75 74 adantr φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p mod P = -1 mod P
76 75 biimpa φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p mod P = -1 mod P
77 eqidd φ p = 2 x x P 1 2 mod P = -1 mod P 1 mod P = 1 mod P
78 66 68 67 67 51 76 77 modsub12d φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p 1 mod P = - 1 - 1 mod P
79 78 oveq1d φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p 1 mod P gcd P = - 1 - 1 mod P gcd P
80 peano2zm x P 1 p x P 1 p 1
81 64 80 syl φ p = 2 x x P 1 p 1
82 22 ad2antrr φ p = 2 x P
83 modgcd x P 1 p 1 P x P 1 p 1 mod P gcd P = x P 1 p 1 gcd P
84 81 82 83 syl2anc φ p = 2 x x P 1 p 1 mod P gcd P = x P 1 p 1 gcd P
85 84 adantr φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p 1 mod P gcd P = x P 1 p 1 gcd P
86 ax-1cn 1
87 negdi2 1 1 1 + 1 = - 1 - 1
88 87 eqcomd 1 1 - 1 - 1 = 1 + 1
89 86 86 88 mp2an - 1 - 1 = 1 + 1
90 1p1e2 1 + 1 = 2
91 90 negeqi 1 + 1 = 2
92 89 91 eqtri - 1 - 1 = 2
93 92 a1i φ - 1 - 1 = 2
94 93 oveq1d φ - 1 - 1 mod P = -2 mod P
95 94 oveq1d φ - 1 - 1 mod P gcd P = -2 mod P gcd P
96 nnnegz 2 2
97 7 96 syl φ 2
98 modgcd 2 P -2 mod P gcd P = -2 gcd P
99 97 22 98 syl2anc φ -2 mod P gcd P = -2 gcd P
100 2z 2
101 22 nnzd φ P
102 neggcd 2 P -2 gcd P = 2 gcd P
103 100 101 102 sylancr φ -2 gcd P = 2 gcd P
104 nnz P P
105 oddm1d2 P ¬ 2 P P 1 2
106 104 105 syl P ¬ 2 P P 1 2
107 106 biimprd P P 1 2 ¬ 2 P
108 nnz P 1 2 P 1 2
109 107 108 impel P P 1 2 ¬ 2 P
110 isoddgcd1 P ¬ 2 P 2 gcd P = 1
111 104 110 syl P ¬ 2 P 2 gcd P = 1
112 111 adantr P P 1 2 ¬ 2 P 2 gcd P = 1
113 109 112 mpbid P P 1 2 2 gcd P = 1
114 113 3adant2 P 1 < P P 1 2 2 gcd P = 1
115 21 114 syl φ 2 gcd P = 1
116 103 115 eqtrd φ -2 gcd P = 1
117 99 116 eqtrd φ -2 mod P gcd P = 1
118 95 117 eqtrd φ - 1 - 1 mod P gcd P = 1
119 118 ad3antrrr φ p = 2 x x P 1 2 mod P = -1 mod P - 1 - 1 mod P gcd P = 1
120 79 85 119 3eqtr3d φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 p 1 gcd P = 1
121 56 120 jca φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 mod P = 1 x P 1 p 1 gcd P = 1
122 121 ex φ p = 2 x x P 1 2 mod P = -1 mod P x P 1 mod P = 1 x P 1 p 1 gcd P = 1
123 122 reximdva φ p = 2 x x P 1 2 mod P = -1 mod P x x P 1 mod P = 1 x P 1 p 1 gcd P = 1
124 123 ex φ p = 2 x x P 1 2 mod P = -1 mod P x x P 1 mod P = 1 x P 1 p 1 gcd P = 1
125 5 124 mpid φ p = 2 x x P 1 mod P = 1 x P 1 p 1 gcd P = 1
126 125 adantr φ p p = 2 x x P 1 mod P = 1 x P 1 p 1 gcd P = 1
127 20 126 sylbid φ p p 2 N x x P 1 mod P = 1 x P 1 p 1 gcd P = 1
128 127 ralrimiva φ p p 2 N x x P 1 mod P = 1 x P 1 p 1 gcd P = 1
129 9 2 4 14 128 pockthg φ P