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 PQQmod8=7Q=2P+1Q2P1

Proof

Step Hyp Ref Expression
1 olc Qmod8=7Qmod8=1Qmod8=7
2 ovex Qmod8V
3 elprg Qmod8VQmod817Qmod8=1Qmod8=7
4 2 3 mp1i Qmod8=7Qmod817Qmod8=1Qmod8=7
5 1 4 mpbird Qmod8=7Qmod817
6 2lgs Q2/LQ=1Qmod817
7 6 ad2antlr PQQ=2P+12/LQ=1Qmod817
8 2z 2
9 simpr PQQ
10 9 adantr PQQ=2P+1Q
11 2re 2
12 11 a1i PQQ=2P+12
13 2m1e1 21=1
14 11 a1i P2
15 prmnn PP
16 15 nnred PP
17 1lt2 1<2
18 17 a1i P1<2
19 prmgt1 P1<P
20 14 16 18 19 mulgt1d P1<2P
21 13 20 eqbrtrid P21<2P
22 1red P1
23 2nn 2
24 23 a1i P2
25 24 15 nnmulcld P2P
26 25 nnred P2P
27 14 22 26 ltsubaddd P21<2P2<2P+1
28 21 27 mpbid P2<2P+1
29 28 ad2antrr PQQ=2P+12<2P+1
30 breq2 Q=2P+12<Q2<2P+1
31 30 adantl PQQ=2P+12<Q2<2P+1
32 29 31 mpbird PQQ=2P+12<Q
33 12 32 gtned PQQ=2P+1Q2
34 eldifsn Q2QQ2
35 10 33 34 sylanbrc PQQ=2P+1Q2
36 lgsqrmodndvds 2Q22/LQ=1mm2modQ=2modQ¬Qm
37 8 35 36 sylancr PQQ=2P+12/LQ=1mm2modQ=2modQ¬Qm
38 prmnn QQ
39 38 nncnd QQ
40 39 adantl PQQ
41 1cnd PQ1
42 2cnd P2
43 15 nncnd PP
44 42 43 mulcld P2P
45 44 adantr PQ2P
46 40 41 45 subadd2d PQQ1=2P2P+1=Q
47 prmz QQ
48 peano2zm QQ1
49 47 48 syl QQ1
50 49 zcnd QQ1
51 50 adantl PQQ1
52 43 adantr PQP
53 2cnne0 220
54 53 a1i PQ220
55 divmul2 Q1P220Q12=PQ1=2P
56 51 52 54 55 syl3anc PQQ12=PQ1=2P
57 eqcom Q=2P+12P+1=Q
58 57 a1i PQQ=2P+12P+1=Q
59 46 56 58 3bitr4rd PQQ=2P+1Q12=P
60 59 biimpa PQQ=2P+1Q12=P
61 oveq2 Q12=P2Q12=2P
62 zsqcl mm2
63 62 ad2antlr PQQ=2P+1mm2modQ=2modQm2
64 8 a1i PQQ=2P+1mm2modQ=2modQ2
65 oveq1 Q=2P+1Q1=2P+1-1
66 65 adantl PQQ=2P+1Q1=2P+1-1
67 66 oveq1d PQQ=2P+1Q12=2P+1-12
68 pncan1 2P2P+1-1=2P
69 44 68 syl P2P+1-1=2P
70 69 oveq1d P2P+1-12=2P2
71 2ne0 20
72 71 a1i P20
73 43 42 72 divcan3d P2P2=P
74 70 73 eqtrd P2P+1-12=P
75 74 ad2antrr PQQ=2P+12P+1-12=P
76 67 75 eqtrd PQQ=2P+1Q12=P
77 15 nnnn0d PP0
78 77 ad2antrr PQQ=2P+1P0
79 76 78 eqeltrd PQQ=2P+1Q120
80 38 nnrpd QQ+
81 80 ad2antlr PQQ=2P+1Q+
82 79 81 jca PQQ=2P+1Q120Q+
83 82 ad2antrr PQQ=2P+1mm2modQ=2modQQ120Q+
84 simpr PQQ=2P+1mm2modQ=2modQm2modQ=2modQ
85 modexp m22Q120Q+m2modQ=2modQm2Q12modQ=2Q12modQ
86 63 64 83 84 85 syl211anc PQQ=2P+1mm2modQ=2modQm2Q12modQ=2Q12modQ
87 86 ex PQQ=2P+1mm2modQ=2modQm2Q12modQ=2Q12modQ
88 87 adantr PQQ=2P+1m¬Qmm2modQ=2modQm2Q12modQ=2Q12modQ
89 2cnd Q2
90 71 a1i Q20
91 50 89 90 divcan2d Q2Q12=Q1
92 91 eqcomd QQ1=2Q12
93 92 oveq2d QmQ1=m2Q12
94 93 ad3antlr PQQ=2P+1mmQ1=m2Q12
95 zcn mm
96 95 adantl PQQ=2P+1mm
97 79 adantr PQQ=2P+1mQ120
98 2nn0 20
99 98 a1i PQQ=2P+1m20
100 96 97 99 expmuld PQQ=2P+1mm2Q12=m2Q12
101 94 100 eqtr2d PQQ=2P+1mm2Q12=mQ1
102 101 oveq1d PQQ=2P+1mm2Q12modQ=mQ1modQ
103 102 adantr PQQ=2P+1m¬Qmm2Q12modQ=mQ1modQ
104 vfermltl Qm¬QmmQ1modQ=1
105 104 ad5ant245 PQQ=2P+1m¬QmmQ1modQ=1
106 103 105 eqtrd PQQ=2P+1m¬Qmm2Q12modQ=1
107 oveq1 2Q12=2P2Q12modQ=2PmodQ
108 106 107 eqeqan12d PQQ=2P+1m¬Qm2Q12=2Pm2Q12modQ=2Q12modQ1=2PmodQ
109 id 1=2PmodQ1=2PmodQ
110 109 eqcomd 1=2PmodQ2PmodQ=1
111 38 nnred QQ
112 prmgt1 Q1<Q
113 1mod Q1<Q1modQ=1
114 111 112 113 syl2anc Q1modQ=1
115 114 eqcomd Q1=1modQ
116 115 ad3antlr PQQ=2P+1m1=1modQ
117 110 116 sylan9eqr PQQ=2P+1m1=2PmodQ2PmodQ=1modQ
118 38 ad4antlr PQQ=2P+1m1=2PmodQQ
119 zexpcl 2P02P
120 8 77 119 sylancr P2P
121 120 ad4antr PQQ=2P+1m1=2PmodQ2P
122 1zzd PQQ=2P+1m1=2PmodQ1
123 moddvds Q2P12PmodQ=1modQQ2P1
124 118 121 122 123 syl3anc PQQ=2P+1m1=2PmodQ2PmodQ=1modQQ2P1
125 117 124 mpbid PQQ=2P+1m1=2PmodQQ2P1
126 125 ex PQQ=2P+1m1=2PmodQQ2P1
127 126 ad2antrr PQQ=2P+1m¬Qm2Q12=2P1=2PmodQQ2P1
128 108 127 sylbid PQQ=2P+1m¬Qm2Q12=2Pm2Q12modQ=2Q12modQQ2P1
129 128 ex PQQ=2P+1m¬Qm2Q12=2Pm2Q12modQ=2Q12modQQ2P1
130 129 com23 PQQ=2P+1m¬Qmm2Q12modQ=2Q12modQ2Q12=2PQ2P1
131 88 130 syld PQQ=2P+1m¬Qmm2modQ=2modQ2Q12=2PQ2P1
132 131 ex PQQ=2P+1m¬Qmm2modQ=2modQ2Q12=2PQ2P1
133 132 com23 PQQ=2P+1mm2modQ=2modQ¬Qm2Q12=2PQ2P1
134 133 impd PQQ=2P+1mm2modQ=2modQ¬Qm2Q12=2PQ2P1
135 134 com23 PQQ=2P+1m2Q12=2Pm2modQ=2modQ¬QmQ2P1
136 135 ex PQQ=2P+1m2Q12=2Pm2modQ=2modQ¬QmQ2P1
137 136 com23 PQQ=2P+12Q12=2Pmm2modQ=2modQ¬QmQ2P1
138 61 137 syl5 PQQ=2P+1Q12=Pmm2modQ=2modQ¬QmQ2P1
139 60 138 mpd PQQ=2P+1mm2modQ=2modQ¬QmQ2P1
140 139 rexlimdv PQQ=2P+1mm2modQ=2modQ¬QmQ2P1
141 37 140 syld PQQ=2P+12/LQ=1Q2P1
142 7 141 sylbird PQQ=2P+1Qmod817Q2P1
143 5 142 syl5 PQQ=2P+1Qmod8=7Q2P1
144 143 ex PQQ=2P+1Qmod8=7Q2P1
145 144 com23 PQQmod8=7Q=2P+1Q2P1
146 145 ex PQQmod8=7Q=2P+1Q2P1
147 146 3imp2 PQQmod8=7Q=2P+1Q2P1