Metamath Proof Explorer


Theorem 2sqlem8

Description: Lemma for 2sq . (Contributed by Mario Carneiro, 20-Jun-2015)

Ref Expression
Hypotheses 2sq.1 S = ran w i w 2
2sqlem7.2 Y = z | x y x gcd y = 1 z = x 2 + y 2
2sqlem9.5 φ b 1 M 1 a Y b a b S
2sqlem9.7 φ M N
2sqlem8.n φ N
2sqlem8.m φ M 2
2sqlem8.1 φ A
2sqlem8.2 φ B
2sqlem8.3 φ A gcd B = 1
2sqlem8.4 φ N = A 2 + B 2
2sqlem8.c C = A + M 2 mod M M 2
2sqlem8.d D = B + M 2 mod M M 2
2sqlem8.e E = C C gcd D
2sqlem8.f F = D C gcd D
Assertion 2sqlem8 φ M S

Proof

Step Hyp Ref Expression
1 2sq.1 S = ran w i w 2
2 2sqlem7.2 Y = z | x y x gcd y = 1 z = x 2 + y 2
3 2sqlem9.5 φ b 1 M 1 a Y b a b S
4 2sqlem9.7 φ M N
5 2sqlem8.n φ N
6 2sqlem8.m φ M 2
7 2sqlem8.1 φ A
8 2sqlem8.2 φ B
9 2sqlem8.3 φ A gcd B = 1
10 2sqlem8.4 φ N = A 2 + B 2
11 2sqlem8.c C = A + M 2 mod M M 2
12 2sqlem8.d D = B + M 2 mod M M 2
13 2sqlem8.e E = C C gcd D
14 2sqlem8.f F = D C gcd D
15 eluz2b3 M 2 M M 1
16 6 15 sylib φ M M 1
17 16 simpld φ M
18 eluzelz M 2 M
19 6 18 syl φ M
20 5 nnzd φ N
21 7 17 11 4sqlem5 φ C A C M
22 21 simpld φ C
23 zsqcl C C 2
24 22 23 syl φ C 2
25 8 17 12 4sqlem5 φ D B D M
26 25 simpld φ D
27 zsqcl D D 2
28 26 27 syl φ D 2
29 24 28 zaddcld φ C 2 + D 2
30 zsqcl A A 2
31 7 30 syl φ A 2
32 31 24 zsubcld φ A 2 C 2
33 zsqcl B B 2
34 8 33 syl φ B 2
35 34 28 zsubcld φ B 2 D 2
36 7 17 11 4sqlem8 φ M A 2 C 2
37 8 17 12 4sqlem8 φ M B 2 D 2
38 19 32 35 36 37 dvds2addd φ M A 2 C 2 + B 2 - D 2
39 10 oveq1d φ N C 2 + D 2 = A 2 + B 2 - C 2 + D 2
40 31 zcnd φ A 2
41 34 zcnd φ B 2
42 24 zcnd φ C 2
43 28 zcnd φ D 2
44 40 41 42 43 addsub4d φ A 2 + B 2 - C 2 + D 2 = A 2 C 2 + B 2 - D 2
45 39 44 eqtrd φ N C 2 + D 2 = A 2 C 2 + B 2 - D 2
46 38 45 breqtrrd φ M N C 2 + D 2
47 dvdssub2 M N C 2 + D 2 M N C 2 + D 2 M N M C 2 + D 2
48 19 20 29 46 47 syl31anc φ M N M C 2 + D 2
49 4 48 mpbid φ M C 2 + D 2
50 1 2 3 4 5 6 7 8 9 10 11 12 2sqlem8a φ C gcd D
51 50 nnzd φ C gcd D
52 zsqcl2 C gcd D C gcd D 2 0
53 51 52 syl φ C gcd D 2 0
54 53 nn0cnd φ C gcd D 2
55 gcddvds C D C gcd D C C gcd D D
56 22 26 55 syl2anc φ C gcd D C C gcd D D
57 56 simpld φ C gcd D C
58 50 nnne0d φ C gcd D 0
59 dvdsval2 C gcd D C gcd D 0 C C gcd D C C C gcd D
60 51 58 22 59 syl3anc φ C gcd D C C C gcd D
61 57 60 mpbid φ C C gcd D
62 13 61 eqeltrid φ E
63 zsqcl2 E E 2 0
64 62 63 syl φ E 2 0
65 64 nn0cnd φ E 2
66 56 simprd φ C gcd D D
67 dvdsval2 C gcd D C gcd D 0 D C gcd D D D C gcd D
68 51 58 26 67 syl3anc φ C gcd D D D C gcd D
69 66 68 mpbid φ D C gcd D
70 14 69 eqeltrid φ F
71 zsqcl2 F F 2 0
72 70 71 syl φ F 2 0
73 72 nn0cnd φ F 2
74 54 65 73 adddid φ C gcd D 2 E 2 + F 2 = C gcd D 2 E 2 + C gcd D 2 F 2
75 51 zcnd φ C gcd D
76 62 zcnd φ E
77 75 76 sqmuld φ C gcd D E 2 = C gcd D 2 E 2
78 13 oveq2i C gcd D E = C gcd D C C gcd D
79 22 zcnd φ C
80 79 75 58 divcan2d φ C gcd D C C gcd D = C
81 78 80 syl5eq φ C gcd D E = C
82 81 oveq1d φ C gcd D E 2 = C 2
83 77 82 eqtr3d φ C gcd D 2 E 2 = C 2
84 70 zcnd φ F
85 75 84 sqmuld φ C gcd D F 2 = C gcd D 2 F 2
86 14 oveq2i C gcd D F = C gcd D D C gcd D
87 26 zcnd φ D
88 87 75 58 divcan2d φ C gcd D D C gcd D = D
89 86 88 syl5eq φ C gcd D F = D
90 89 oveq1d φ C gcd D F 2 = D 2
91 85 90 eqtr3d φ C gcd D 2 F 2 = D 2
92 83 91 oveq12d φ C gcd D 2 E 2 + C gcd D 2 F 2 = C 2 + D 2
93 74 92 eqtrd φ C gcd D 2 E 2 + F 2 = C 2 + D 2
94 49 93 breqtrrd φ M C gcd D 2 E 2 + F 2
95 zsqcl C gcd D C gcd D 2
96 51 95 syl φ C gcd D 2
97 19 96 gcdcomd φ M gcd C gcd D 2 = C gcd D 2 gcd M
98 51 19 gcdcld φ C gcd D gcd M 0
99 98 nn0zd φ C gcd D gcd M
100 gcddvds C gcd D M C gcd D gcd M C gcd D C gcd D gcd M M
101 51 19 100 syl2anc φ C gcd D gcd M C gcd D C gcd D gcd M M
102 101 simpld φ C gcd D gcd M C gcd D
103 99 51 22 102 57 dvdstrd φ C gcd D gcd M C
104 7 22 zsubcld φ A C
105 101 simprd φ C gcd D gcd M M
106 21 simprd φ A C M
107 17 nnne0d φ M 0
108 dvdsval2 M M 0 A C M A C A C M
109 19 107 104 108 syl3anc φ M A C A C M
110 106 109 mpbird φ M A C
111 99 19 104 105 110 dvdstrd φ C gcd D gcd M A C
112 dvdssub2 C gcd D gcd M A C C gcd D gcd M A C C gcd D gcd M A C gcd D gcd M C
113 99 7 22 111 112 syl31anc φ C gcd D gcd M A C gcd D gcd M C
114 103 113 mpbird φ C gcd D gcd M A
115 99 51 26 102 66 dvdstrd φ C gcd D gcd M D
116 8 26 zsubcld φ B D
117 25 simprd φ B D M
118 dvdsval2 M M 0 B D M B D B D M
119 19 107 116 118 syl3anc φ M B D B D M
120 117 119 mpbird φ M B D
121 99 19 116 105 120 dvdstrd φ C gcd D gcd M B D
122 dvdssub2 C gcd D gcd M B D C gcd D gcd M B D C gcd D gcd M B C gcd D gcd M D
123 99 8 26 121 122 syl31anc φ C gcd D gcd M B C gcd D gcd M D
124 115 123 mpbird φ C gcd D gcd M B
125 ax-1ne0 1 0
126 125 a1i φ 1 0
127 9 126 eqnetrd φ A gcd B 0
128 127 neneqd φ ¬ A gcd B = 0
129 gcdeq0 A B A gcd B = 0 A = 0 B = 0
130 7 8 129 syl2anc φ A gcd B = 0 A = 0 B = 0
131 128 130 mtbid φ ¬ A = 0 B = 0
132 dvdslegcd C gcd D gcd M A B ¬ A = 0 B = 0 C gcd D gcd M A C gcd D gcd M B C gcd D gcd M A gcd B
133 99 7 8 131 132 syl31anc φ C gcd D gcd M A C gcd D gcd M B C gcd D gcd M A gcd B
134 114 124 133 mp2and φ C gcd D gcd M A gcd B
135 134 9 breqtrd φ C gcd D gcd M 1
136 simpr C gcd D = 0 M = 0 M = 0
137 136 necon3ai M 0 ¬ C gcd D = 0 M = 0
138 107 137 syl φ ¬ C gcd D = 0 M = 0
139 gcdn0cl C gcd D M ¬ C gcd D = 0 M = 0 C gcd D gcd M
140 51 19 138 139 syl21anc φ C gcd D gcd M
141 nnle1eq1 C gcd D gcd M C gcd D gcd M 1 C gcd D gcd M = 1
142 140 141 syl φ C gcd D gcd M 1 C gcd D gcd M = 1
143 135 142 mpbid φ C gcd D gcd M = 1
144 2nn 2
145 144 a1i φ 2
146 rplpwr C gcd D M 2 C gcd D gcd M = 1 C gcd D 2 gcd M = 1
147 50 17 145 146 syl3anc φ C gcd D gcd M = 1 C gcd D 2 gcd M = 1
148 143 147 mpd φ C gcd D 2 gcd M = 1
149 97 148 eqtrd φ M gcd C gcd D 2 = 1
150 64 72 nn0addcld φ E 2 + F 2 0
151 150 nn0zd φ E 2 + F 2
152 coprmdvds M C gcd D 2 E 2 + F 2 M C gcd D 2 E 2 + F 2 M gcd C gcd D 2 = 1 M E 2 + F 2
153 19 96 151 152 syl3anc φ M C gcd D 2 E 2 + F 2 M gcd C gcd D 2 = 1 M E 2 + F 2
154 94 149 153 mp2and φ M E 2 + F 2
155 dvdsval2 M M 0 E 2 + F 2 M E 2 + F 2 E 2 + F 2 M
156 19 107 151 155 syl3anc φ M E 2 + F 2 E 2 + F 2 M
157 154 156 mpbid φ E 2 + F 2 M
158 64 nn0red φ E 2
159 72 nn0red φ F 2
160 158 159 readdcld φ E 2 + F 2
161 17 nnred φ M
162 1 2 2sqlem7 Y S
163 inss2 S
164 162 163 sstri Y
165 62 70 gcdcld φ E gcd F 0
166 165 nn0cnd φ E gcd F
167 1cnd φ 1
168 75 mulid1d φ C gcd D 1 = C gcd D
169 81 89 oveq12d φ C gcd D E gcd C gcd D F = C gcd D
170 22 26 gcdcld φ C gcd D 0
171 mulgcd C gcd D 0 E F C gcd D E gcd C gcd D F = C gcd D E gcd F
172 170 62 70 171 syl3anc φ C gcd D E gcd C gcd D F = C gcd D E gcd F
173 168 169 172 3eqtr2rd φ C gcd D E gcd F = C gcd D 1
174 166 167 75 58 173 mulcanad φ E gcd F = 1
175 eqidd φ E 2 + F 2 = E 2 + F 2
176 oveq1 x = E x gcd y = E gcd y
177 176 eqeq1d x = E x gcd y = 1 E gcd y = 1
178 oveq1 x = E x 2 = E 2
179 178 oveq1d x = E x 2 + y 2 = E 2 + y 2
180 179 eqeq2d x = E E 2 + F 2 = x 2 + y 2 E 2 + F 2 = E 2 + y 2
181 177 180 anbi12d x = E x gcd y = 1 E 2 + F 2 = x 2 + y 2 E gcd y = 1 E 2 + F 2 = E 2 + y 2
182 oveq2 y = F E gcd y = E gcd F
183 182 eqeq1d y = F E gcd y = 1 E gcd F = 1
184 oveq1 y = F y 2 = F 2
185 184 oveq2d y = F E 2 + y 2 = E 2 + F 2
186 185 eqeq2d y = F E 2 + F 2 = E 2 + y 2 E 2 + F 2 = E 2 + F 2
187 183 186 anbi12d y = F E gcd y = 1 E 2 + F 2 = E 2 + y 2 E gcd F = 1 E 2 + F 2 = E 2 + F 2
188 181 187 rspc2ev E F E gcd F = 1 E 2 + F 2 = E 2 + F 2 x y x gcd y = 1 E 2 + F 2 = x 2 + y 2
189 62 70 174 175 188 syl112anc φ x y x gcd y = 1 E 2 + F 2 = x 2 + y 2
190 ovex E 2 + F 2 V
191 eqeq1 z = E 2 + F 2 z = x 2 + y 2 E 2 + F 2 = x 2 + y 2
192 191 anbi2d z = E 2 + F 2 x gcd y = 1 z = x 2 + y 2 x gcd y = 1 E 2 + F 2 = x 2 + y 2
193 192 2rexbidv z = E 2 + F 2 x y x gcd y = 1 z = x 2 + y 2 x y x gcd y = 1 E 2 + F 2 = x 2 + y 2
194 190 193 2 elab2 E 2 + F 2 Y x y x gcd y = 1 E 2 + F 2 = x 2 + y 2
195 189 194 sylibr φ E 2 + F 2 Y
196 164 195 sselid φ E 2 + F 2
197 196 nngt0d φ 0 < E 2 + F 2
198 17 nngt0d φ 0 < M
199 160 161 197 198 divgt0d φ 0 < E 2 + F 2 M
200 elnnz E 2 + F 2 M E 2 + F 2 M 0 < E 2 + F 2 M
201 157 199 200 sylanbrc φ E 2 + F 2 M
202 prmnn p p
203 202 ad2antrl φ p p E 2 + F 2 M p
204 203 nnred φ p p E 2 + F 2 M p
205 157 adantr φ p p E 2 + F 2 M E 2 + F 2 M
206 205 zred φ p p E 2 + F 2 M E 2 + F 2 M
207 peano2zm M M 1
208 19 207 syl φ M 1
209 208 zred φ M 1
210 209 adantr φ p p E 2 + F 2 M M 1
211 simprr φ p p E 2 + F 2 M p E 2 + F 2 M
212 prmz p p
213 212 ad2antrl φ p p E 2 + F 2 M p
214 201 adantr φ p p E 2 + F 2 M E 2 + F 2 M
215 dvdsle p E 2 + F 2 M p E 2 + F 2 M p E 2 + F 2 M
216 213 214 215 syl2anc φ p p E 2 + F 2 M p E 2 + F 2 M p E 2 + F 2 M
217 211 216 mpd φ p p E 2 + F 2 M p E 2 + F 2 M
218 zsqcl M M 2
219 19 218 syl φ M 2
220 219 zred φ M 2
221 220 rehalfcld φ M 2 2
222 24 zred φ C 2
223 28 zred φ D 2
224 222 223 readdcld φ C 2 + D 2
225 1red φ 1
226 50 nnsqcld φ C gcd D 2
227 226 nnred φ C gcd D 2
228 150 nn0ge0d φ 0 E 2 + F 2
229 226 nnge1d φ 1 C gcd D 2
230 225 227 160 228 229 lemul1ad φ 1 E 2 + F 2 C gcd D 2 E 2 + F 2
231 150 nn0cnd φ E 2 + F 2
232 231 mulid2d φ 1 E 2 + F 2 = E 2 + F 2
233 230 232 93 3brtr3d φ E 2 + F 2 C 2 + D 2
234 221 rehalfcld φ M 2 2 2
235 7 17 11 4sqlem7 φ C 2 M 2 2 2
236 8 17 12 4sqlem7 φ D 2 M 2 2 2
237 222 223 234 234 235 236 le2addd φ C 2 + D 2 M 2 2 2 + M 2 2 2
238 221 recnd φ M 2 2
239 238 2halvesd φ M 2 2 2 + M 2 2 2 = M 2 2
240 237 239 breqtrd φ C 2 + D 2 M 2 2
241 160 224 221 233 240 letrd φ E 2 + F 2 M 2 2
242 17 nnsqcld φ M 2
243 242 nnrpd φ M 2 +
244 rphalflt M 2 + M 2 2 < M 2
245 243 244 syl φ M 2 2 < M 2
246 160 221 220 241 245 lelttrd φ E 2 + F 2 < M 2
247 19 zcnd φ M
248 247 sqvald φ M 2 = M M
249 246 248 breqtrd φ E 2 + F 2 < M M
250 ltdivmul E 2 + F 2 M M 0 < M E 2 + F 2 M < M E 2 + F 2 < M M
251 160 161 161 198 250 syl112anc φ E 2 + F 2 M < M E 2 + F 2 < M M
252 249 251 mpbird φ E 2 + F 2 M < M
253 zltlem1 E 2 + F 2 M M E 2 + F 2 M < M E 2 + F 2 M M 1
254 157 19 253 syl2anc φ E 2 + F 2 M < M E 2 + F 2 M M 1
255 252 254 mpbid φ E 2 + F 2 M M 1
256 255 adantr φ p p E 2 + F 2 M E 2 + F 2 M M 1
257 204 206 210 217 256 letrd φ p p E 2 + F 2 M p M 1
258 208 adantr φ p p E 2 + F 2 M M 1
259 fznn M 1 p 1 M 1 p p M 1
260 258 259 syl φ p p E 2 + F 2 M p 1 M 1 p p M 1
261 203 257 260 mpbir2and φ p p E 2 + F 2 M p 1 M 1
262 195 adantr φ p p E 2 + F 2 M E 2 + F 2 Y
263 261 262 jca φ p p E 2 + F 2 M p 1 M 1 E 2 + F 2 Y
264 3 adantr φ p p E 2 + F 2 M b 1 M 1 a Y b a b S
265 151 adantr φ p p E 2 + F 2 M E 2 + F 2
266 dvdsmul2 M E 2 + F 2 M E 2 + F 2 M M E 2 + F 2 M
267 19 157 266 syl2anc φ E 2 + F 2 M M E 2 + F 2 M
268 231 247 107 divcan2d φ M E 2 + F 2 M = E 2 + F 2
269 267 268 breqtrd φ E 2 + F 2 M E 2 + F 2
270 269 adantr φ p p E 2 + F 2 M E 2 + F 2 M E 2 + F 2
271 213 205 265 211 270 dvdstrd φ p p E 2 + F 2 M p E 2 + F 2
272 breq1 b = p b a p a
273 eleq1w b = p b S p S
274 272 273 imbi12d b = p b a b S p a p S
275 breq2 a = E 2 + F 2 p a p E 2 + F 2
276 275 imbi1d a = E 2 + F 2 p a p S p E 2 + F 2 p S
277 274 276 rspc2v p 1 M 1 E 2 + F 2 Y b 1 M 1 a Y b a b S p E 2 + F 2 p S
278 263 264 271 277 syl3c φ p p E 2 + F 2 M p S
279 278 expr φ p p E 2 + F 2 M p S
280 279 ralrimiva φ p p E 2 + F 2 M p S
281 inss1 S S
282 162 281 sstri Y S
283 282 195 sselid φ E 2 + F 2 S
284 268 283 eqeltrd φ M E 2 + F 2 M S
285 1 17 201 280 284 2sqlem6 φ M S