Metamath Proof Explorer


Theorem sfprmdvdsmersenne

Description: If Q is a safe prime (i.e. Q = ( ( 2 x. P ) + 1 ) for a prime P ) with Q == 7 (mod 8 ), then Q divides the P-th Mersenne number M_P. (Contributed by AV, 20-Aug-2021)

Ref Expression
Assertion sfprmdvdsmersenne P Q Q mod 8 = 7 Q = 2 P + 1 Q 2 P 1

Proof

Step Hyp Ref Expression
1 olc Q mod 8 = 7 Q mod 8 = 1 Q mod 8 = 7
2 ovex Q mod 8 V
3 elprg Q mod 8 V Q mod 8 1 7 Q mod 8 = 1 Q mod 8 = 7
4 2 3 mp1i Q mod 8 = 7 Q mod 8 1 7 Q mod 8 = 1 Q mod 8 = 7
5 1 4 mpbird Q mod 8 = 7 Q mod 8 1 7
6 2lgs Q 2 / L Q = 1 Q mod 8 1 7
7 6 ad2antlr P Q Q = 2 P + 1 2 / L Q = 1 Q mod 8 1 7
8 2z 2
9 simpr P Q Q
10 9 adantr P Q Q = 2 P + 1 Q
11 2re 2
12 11 a1i P Q Q = 2 P + 1 2
13 2m1e1 2 1 = 1
14 11 a1i P 2
15 prmnn P P
16 15 nnred P P
17 1lt2 1 < 2
18 17 a1i P 1 < 2
19 prmgt1 P 1 < P
20 14 16 18 19 mulgt1d P 1 < 2 P
21 13 20 eqbrtrid P 2 1 < 2 P
22 1red P 1
23 2nn 2
24 23 a1i P 2
25 24 15 nnmulcld P 2 P
26 25 nnred P 2 P
27 14 22 26 ltsubaddd P 2 1 < 2 P 2 < 2 P + 1
28 21 27 mpbid P 2 < 2 P + 1
29 28 ad2antrr P Q Q = 2 P + 1 2 < 2 P + 1
30 breq2 Q = 2 P + 1 2 < Q 2 < 2 P + 1
31 30 adantl P Q Q = 2 P + 1 2 < Q 2 < 2 P + 1
32 29 31 mpbird P Q Q = 2 P + 1 2 < Q
33 12 32 gtned P Q Q = 2 P + 1 Q 2
34 eldifsn Q 2 Q Q 2
35 10 33 34 sylanbrc P Q Q = 2 P + 1 Q 2
36 lgsqrmodndvds 2 Q 2 2 / L Q = 1 m m 2 mod Q = 2 mod Q ¬ Q m
37 8 35 36 sylancr P Q Q = 2 P + 1 2 / L Q = 1 m m 2 mod Q = 2 mod Q ¬ Q m
38 prmnn Q Q
39 38 nncnd Q Q
40 39 adantl P Q Q
41 1cnd P Q 1
42 2cnd P 2
43 15 nncnd P P
44 42 43 mulcld P 2 P
45 44 adantr P Q 2 P
46 40 41 45 subadd2d P Q Q 1 = 2 P 2 P + 1 = Q
47 prmz Q Q
48 peano2zm Q Q 1
49 47 48 syl Q Q 1
50 49 zcnd Q Q 1
51 50 adantl P Q Q 1
52 43 adantr P Q P
53 2cnne0 2 2 0
54 53 a1i P Q 2 2 0
55 divmul2 Q 1 P 2 2 0 Q 1 2 = P Q 1 = 2 P
56 51 52 54 55 syl3anc P Q Q 1 2 = P Q 1 = 2 P
57 eqcom Q = 2 P + 1 2 P + 1 = Q
58 57 a1i P Q Q = 2 P + 1 2 P + 1 = Q
59 46 56 58 3bitr4rd P Q Q = 2 P + 1 Q 1 2 = P
60 59 biimpa P Q Q = 2 P + 1 Q 1 2 = P
61 oveq2 Q 1 2 = P 2 Q 1 2 = 2 P
62 zsqcl m m 2
63 62 ad2antlr P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q m 2
64 8 a1i P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q 2
65 oveq1 Q = 2 P + 1 Q 1 = 2 P + 1 - 1
66 65 adantl P Q Q = 2 P + 1 Q 1 = 2 P + 1 - 1
67 66 oveq1d P Q Q = 2 P + 1 Q 1 2 = 2 P + 1 - 1 2
68 pncan1 2 P 2 P + 1 - 1 = 2 P
69 44 68 syl P 2 P + 1 - 1 = 2 P
70 69 oveq1d P 2 P + 1 - 1 2 = 2 P 2
71 2ne0 2 0
72 71 a1i P 2 0
73 43 42 72 divcan3d P 2 P 2 = P
74 70 73 eqtrd P 2 P + 1 - 1 2 = P
75 74 ad2antrr P Q Q = 2 P + 1 2 P + 1 - 1 2 = P
76 67 75 eqtrd P Q Q = 2 P + 1 Q 1 2 = P
77 15 nnnn0d P P 0
78 77 ad2antrr P Q Q = 2 P + 1 P 0
79 76 78 eqeltrd P Q Q = 2 P + 1 Q 1 2 0
80 38 nnrpd Q Q +
81 80 ad2antlr P Q Q = 2 P + 1 Q +
82 79 81 jca P Q Q = 2 P + 1 Q 1 2 0 Q +
83 82 ad2antrr P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q Q 1 2 0 Q +
84 simpr P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q m 2 mod Q = 2 mod Q
85 modexp m 2 2 Q 1 2 0 Q + m 2 mod Q = 2 mod Q m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q
86 63 64 83 84 85 syl211anc P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q
87 86 ex P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q
88 87 adantr P Q Q = 2 P + 1 m ¬ Q m m 2 mod Q = 2 mod Q m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q
89 2cnd Q 2
90 71 a1i Q 2 0
91 50 89 90 divcan2d Q 2 Q 1 2 = Q 1
92 91 eqcomd Q Q 1 = 2 Q 1 2
93 92 oveq2d Q m Q 1 = m 2 Q 1 2
94 93 ad3antlr P Q Q = 2 P + 1 m m Q 1 = m 2 Q 1 2
95 zcn m m
96 95 adantl P Q Q = 2 P + 1 m m
97 79 adantr P Q Q = 2 P + 1 m Q 1 2 0
98 2nn0 2 0
99 98 a1i P Q Q = 2 P + 1 m 2 0
100 96 97 99 expmuld P Q Q = 2 P + 1 m m 2 Q 1 2 = m 2 Q 1 2
101 94 100 eqtr2d P Q Q = 2 P + 1 m m 2 Q 1 2 = m Q 1
102 101 oveq1d P Q Q = 2 P + 1 m m 2 Q 1 2 mod Q = m Q 1 mod Q
103 102 adantr P Q Q = 2 P + 1 m ¬ Q m m 2 Q 1 2 mod Q = m Q 1 mod Q
104 vfermltl Q m ¬ Q m m Q 1 mod Q = 1
105 104 ad5ant245 P Q Q = 2 P + 1 m ¬ Q m m Q 1 mod Q = 1
106 103 105 eqtrd P Q Q = 2 P + 1 m ¬ Q m m 2 Q 1 2 mod Q = 1
107 oveq1 2 Q 1 2 = 2 P 2 Q 1 2 mod Q = 2 P mod Q
108 106 107 eqeqan12d P Q Q = 2 P + 1 m ¬ Q m 2 Q 1 2 = 2 P m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q 1 = 2 P mod Q
109 id 1 = 2 P mod Q 1 = 2 P mod Q
110 109 eqcomd 1 = 2 P mod Q 2 P mod Q = 1
111 38 nnred Q Q
112 prmgt1 Q 1 < Q
113 1mod Q 1 < Q 1 mod Q = 1
114 111 112 113 syl2anc Q 1 mod Q = 1
115 114 eqcomd Q 1 = 1 mod Q
116 115 ad3antlr P Q Q = 2 P + 1 m 1 = 1 mod Q
117 110 116 sylan9eqr P Q Q = 2 P + 1 m 1 = 2 P mod Q 2 P mod Q = 1 mod Q
118 38 ad4antlr P Q Q = 2 P + 1 m 1 = 2 P mod Q Q
119 zexpcl 2 P 0 2 P
120 8 77 119 sylancr P 2 P
121 120 ad4antr P Q Q = 2 P + 1 m 1 = 2 P mod Q 2 P
122 1zzd P Q Q = 2 P + 1 m 1 = 2 P mod Q 1
123 moddvds Q 2 P 1 2 P mod Q = 1 mod Q Q 2 P 1
124 118 121 122 123 syl3anc P Q Q = 2 P + 1 m 1 = 2 P mod Q 2 P mod Q = 1 mod Q Q 2 P 1
125 117 124 mpbid P Q Q = 2 P + 1 m 1 = 2 P mod Q Q 2 P 1
126 125 ex P Q Q = 2 P + 1 m 1 = 2 P mod Q Q 2 P 1
127 126 ad2antrr P Q Q = 2 P + 1 m ¬ Q m 2 Q 1 2 = 2 P 1 = 2 P mod Q Q 2 P 1
128 108 127 sylbid P Q Q = 2 P + 1 m ¬ Q m 2 Q 1 2 = 2 P m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q Q 2 P 1
129 128 ex P Q Q = 2 P + 1 m ¬ Q m 2 Q 1 2 = 2 P m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q Q 2 P 1
130 129 com23 P Q Q = 2 P + 1 m ¬ Q m m 2 Q 1 2 mod Q = 2 Q 1 2 mod Q 2 Q 1 2 = 2 P Q 2 P 1
131 88 130 syld P Q Q = 2 P + 1 m ¬ Q m m 2 mod Q = 2 mod Q 2 Q 1 2 = 2 P Q 2 P 1
132 131 ex P Q Q = 2 P + 1 m ¬ Q m m 2 mod Q = 2 mod Q 2 Q 1 2 = 2 P Q 2 P 1
133 132 com23 P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q ¬ Q m 2 Q 1 2 = 2 P Q 2 P 1
134 133 impd P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q ¬ Q m 2 Q 1 2 = 2 P Q 2 P 1
135 134 com23 P Q Q = 2 P + 1 m 2 Q 1 2 = 2 P m 2 mod Q = 2 mod Q ¬ Q m Q 2 P 1
136 135 ex P Q Q = 2 P + 1 m 2 Q 1 2 = 2 P m 2 mod Q = 2 mod Q ¬ Q m Q 2 P 1
137 136 com23 P Q Q = 2 P + 1 2 Q 1 2 = 2 P m m 2 mod Q = 2 mod Q ¬ Q m Q 2 P 1
138 61 137 syl5 P Q Q = 2 P + 1 Q 1 2 = P m m 2 mod Q = 2 mod Q ¬ Q m Q 2 P 1
139 60 138 mpd P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q ¬ Q m Q 2 P 1
140 139 rexlimdv P Q Q = 2 P + 1 m m 2 mod Q = 2 mod Q ¬ Q m Q 2 P 1
141 37 140 syld P Q Q = 2 P + 1 2 / L Q = 1 Q 2 P 1
142 7 141 sylbird P Q Q = 2 P + 1 Q mod 8 1 7 Q 2 P 1
143 5 142 syl5 P Q Q = 2 P + 1 Q mod 8 = 7 Q 2 P 1
144 143 ex P Q Q = 2 P + 1 Q mod 8 = 7 Q 2 P 1
145 144 com23 P Q Q mod 8 = 7 Q = 2 P + 1 Q 2 P 1
146 145 ex P Q Q mod 8 = 7 Q = 2 P + 1 Q 2 P 1
147 146 3imp2 P Q Q mod 8 = 7 Q = 2 P + 1 Q 2 P 1