Metamath Proof Explorer


Theorem mul4sqlem

Description: Lemma for mul4sq : algebraic manipulations. The extra assumptions involving M are for a part of 4sqlem17 which needs to know not just that the product is a sum of squares, but also that it preserves divisibility by M . (Contributed by Mario Carneiro, 14-Jul-2014)

Ref Expression
Hypotheses 4sq.1 S = n | x y z w n = x 2 + y 2 + z 2 + w 2
mul4sq.1 φ A i
mul4sq.2 φ B i
mul4sq.3 φ C i
mul4sq.4 φ D i
mul4sq.5 X = A 2 + B 2
mul4sq.6 Y = C 2 + D 2
mul4sq.7 φ M
mul4sq.8 φ A C M i
mul4sq.9 φ B D M i
mul4sq.10 φ X M 0
Assertion mul4sqlem φ X M Y M S

Proof

Step Hyp Ref Expression
1 4sq.1 S = n | x y z w n = x 2 + y 2 + z 2 + w 2
2 mul4sq.1 φ A i
3 mul4sq.2 φ B i
4 mul4sq.3 φ C i
5 mul4sq.4 φ D i
6 mul4sq.5 X = A 2 + B 2
7 mul4sq.6 Y = C 2 + D 2
8 mul4sq.7 φ M
9 mul4sq.8 φ A C M i
10 mul4sq.9 φ B D M i
11 mul4sq.10 φ X M 0
12 gzcn A i A
13 2 12 syl φ A
14 gzcn C i C
15 4 14 syl φ C
16 13 15 mulcld φ A C
17 16 absvalsqd φ A C 2 = A C A C
18 16 cjcld φ A C
19 16 18 mulcld φ A C A C
20 17 19 eqeltrd φ A C 2
21 gzcn B i B
22 3 21 syl φ B
23 gzcn D i D
24 5 23 syl φ D
25 22 24 mulcld φ B D
26 25 absvalsqd φ B D 2 = B D B D
27 25 cjcld φ B D
28 25 27 mulcld φ B D B D
29 26 28 eqeltrd φ B D 2
30 20 29 addcld φ A C 2 + B D 2
31 13 cjcld φ A
32 31 15 mulcld φ A C
33 22 cjcld φ B
34 33 24 mulcld φ B D
35 32 34 mulcld φ A C B D
36 15 cjcld φ C
37 22 36 mulcld φ B C
38 24 cjcld φ D
39 13 38 mulcld φ A D
40 37 39 mulcld φ B C A D
41 35 40 addcld φ A C B D + B C A D
42 13 24 mulcld φ A D
43 42 absvalsqd φ A D 2 = A D A D
44 42 cjcld φ A D
45 42 44 mulcld φ A D A D
46 43 45 eqeltrd φ A D 2
47 22 15 mulcld φ B C
48 47 absvalsqd φ B C 2 = B C B C
49 47 cjcld φ B C
50 47 49 mulcld φ B C B C
51 48 50 eqeltrd φ B C 2
52 46 51 addcld φ A D 2 + B C 2
53 30 41 52 ppncand φ A C 2 + B D 2 + A C B D + B C A D + A D 2 + B C 2 - A C B D + B C A D = A C 2 + B D 2 + A D 2 + B C 2
54 22 38 mulcld φ B D
55 32 54 addcld φ A C + B D
56 55 absvalsqd φ A C + B D 2 = A C + B D A C + B D
57 32 54 cjaddd φ A C + B D = A C + B D
58 31 15 cjmuld φ A C = A C
59 13 cjcjd φ A = A
60 59 oveq1d φ A C = A C
61 58 60 eqtrd φ A C = A C
62 22 38 cjmuld φ B D = B D
63 24 cjcjd φ D = D
64 63 oveq2d φ B D = B D
65 62 64 eqtrd φ B D = B D
66 61 65 oveq12d φ A C + B D = A C + B D
67 57 66 eqtrd φ A C + B D = A C + B D
68 67 oveq2d φ A C + B D A C + B D = A C + B D A C + B D
69 13 36 mulcld φ A C
70 32 69 34 adddid φ A C A C + B D = A C A C + A C B D
71 15 31 13 36 mul4d φ C A A C = C A A C
72 31 15 mulcomd φ A C = C A
73 72 oveq1d φ A C A C = C A A C
74 13 15 mulcomd φ A C = C A
75 13 15 cjmuld φ A C = A C
76 74 75 oveq12d φ A C A C = C A A C
77 71 73 76 3eqtr4d φ A C A C = A C A C
78 77 17 eqtr4d φ A C A C = A C 2
79 78 oveq1d φ A C A C + A C B D = A C 2 + A C B D
80 70 79 eqtrd φ A C A C + B D = A C 2 + A C B D
81 54 69 34 adddid φ B D A C + B D = B D A C + B D B D
82 13 36 mulcomd φ A C = C A
83 82 oveq2d φ B D A C = B D C A
84 22 38 36 13 mul4d φ B D C A = B C D A
85 38 13 mulcomd φ D A = A D
86 85 oveq2d φ B C D A = B C A D
87 83 84 86 3eqtrd φ B D A C = B C A D
88 22 38 24 33 mul4d φ B D D B = B D D B
89 33 24 mulcomd φ B D = D B
90 89 oveq2d φ B D B D = B D D B
91 22 24 cjmuld φ B D = B D
92 33 38 mulcomd φ B D = D B
93 91 92 eqtrd φ B D = D B
94 93 oveq2d φ B D B D = B D D B
95 88 90 94 3eqtr4d φ B D B D = B D B D
96 95 26 eqtr4d φ B D B D = B D 2
97 87 96 oveq12d φ B D A C + B D B D = B C A D + B D 2
98 81 97 eqtrd φ B D A C + B D = B C A D + B D 2
99 80 98 oveq12d φ A C A C + B D + B D A C + B D = A C 2 + A C B D + B C A D + B D 2
100 69 34 addcld φ A C + B D
101 32 54 100 adddird φ A C + B D A C + B D = A C A C + B D + B D A C + B D
102 20 29 35 40 add42d φ A C 2 + B D 2 + A C B D + B C A D = A C 2 + A C B D + B C A D + B D 2
103 99 101 102 3eqtr4d φ A C + B D A C + B D = A C 2 + B D 2 + A C B D + B C A D
104 56 68 103 3eqtrd φ A C + B D 2 = A C 2 + B D 2 + A C B D + B C A D
105 31 24 mulcld φ A D
106 105 37 subcld φ A D B C
107 106 absvalsqd φ A D B C 2 = A D B C A D B C
108 cjsub A D B C A D B C = A D B C
109 105 37 108 syl2anc φ A D B C = A D B C
110 31 24 cjmuld φ A D = A D
111 59 oveq1d φ A D = A D
112 110 111 eqtrd φ A D = A D
113 22 36 cjmuld φ B C = B C
114 15 cjcjd φ C = C
115 114 oveq2d φ B C = B C
116 113 115 eqtrd φ B C = B C
117 112 116 oveq12d φ A D B C = A D B C
118 109 117 eqtrd φ A D B C = A D B C
119 118 oveq2d φ A D B C A D B C = A D B C A D B C
120 33 15 mulcld φ B C
121 39 120 subcld φ A D B C
122 105 37 121 subdird φ A D B C A D B C = A D A D B C B C A D B C
123 105 39 120 subdid φ A D A D B C = A D A D A D B C
124 24 31 13 38 mul4d φ D A A D = D A A D
125 31 24 mulcomd φ A D = D A
126 125 oveq1d φ A D A D = D A A D
127 13 24 mulcomd φ A D = D A
128 13 24 cjmuld φ A D = A D
129 127 128 oveq12d φ A D A D = D A A D
130 124 126 129 3eqtr4d φ A D A D = A D A D
131 130 43 eqtr4d φ A D A D = A D 2
132 33 15 mulcomd φ B C = C B
133 132 oveq2d φ A D B C = A D C B
134 31 24 15 33 mul4d φ A D C B = A C D B
135 24 33 mulcomd φ D B = B D
136 135 oveq2d φ A C D B = A C B D
137 133 134 136 3eqtrd φ A D B C = A C B D
138 131 137 oveq12d φ A D A D A D B C = A D 2 A C B D
139 123 138 eqtrd φ A D A D B C = A D 2 A C B D
140 37 39 120 subdid φ B C A D B C = B C A D B C B C
141 132 oveq2d φ B C B C = B C C B
142 22 36 15 33 mul4d φ B C C B = B C C B
143 36 33 mulcomd φ C B = B C
144 22 15 cjmuld φ B C = B C
145 143 144 eqtr4d φ C B = B C
146 145 oveq2d φ B C C B = B C B C
147 141 142 146 3eqtrd φ B C B C = B C B C
148 147 48 eqtr4d φ B C B C = B C 2
149 148 oveq2d φ B C A D B C B C = B C A D B C 2
150 140 149 eqtrd φ B C A D B C = B C A D B C 2
151 139 150 oveq12d φ A D A D B C B C A D B C = A D 2 - A C B D - B C A D B C 2
152 46 35 40 51 subadd4d φ A D 2 - A C B D - B C A D B C 2 = A D 2 + B C 2 - A C B D + B C A D
153 122 151 152 3eqtrd φ A D B C A D B C = A D 2 + B C 2 - A C B D + B C A D
154 107 119 153 3eqtrd φ A D B C 2 = A D 2 + B C 2 - A C B D + B C A D
155 104 154 oveq12d φ A C + B D 2 + A D B C 2 = A C 2 + B D 2 + A C B D + B C A D + A D 2 + B C 2 - A C B D + B C A D
156 13 31 mulcld φ A A
157 22 33 mulcld φ B B
158 15 36 mulcld φ C C
159 24 38 mulcld φ D D
160 158 159 addcld φ C C + D D
161 156 157 160 adddird φ A A + B B C C + D D = A A C C + D D + B B C C + D D
162 75 oveq2d φ A C A C = A C A C
163 13 15 31 36 mul4d φ A C A C = A A C C
164 17 162 163 3eqtrd φ A C 2 = A A C C
165 128 oveq2d φ A D A D = A D A D
166 13 24 31 38 mul4d φ A D A D = A A D D
167 43 165 166 3eqtrd φ A D 2 = A A D D
168 164 167 oveq12d φ A C 2 + A D 2 = A A C C + A A D D
169 156 158 159 adddid φ A A C C + D D = A A C C + A A D D
170 168 169 eqtr4d φ A C 2 + A D 2 = A A C C + D D
171 144 oveq2d φ B C B C = B C B C
172 22 15 33 36 mul4d φ B C B C = B B C C
173 48 171 172 3eqtrd φ B C 2 = B B C C
174 91 oveq2d φ B D B D = B D B D
175 22 24 33 38 mul4d φ B D B D = B B D D
176 26 174 175 3eqtrd φ B D 2 = B B D D
177 173 176 oveq12d φ B C 2 + B D 2 = B B C C + B B D D
178 157 158 159 adddid φ B B C C + D D = B B C C + B B D D
179 177 178 eqtr4d φ B C 2 + B D 2 = B B C C + D D
180 170 179 oveq12d φ A C 2 + A D 2 + B C 2 + B D 2 = A A C C + D D + B B C C + D D
181 161 180 eqtr4d φ A A + B B C C + D D = A C 2 + A D 2 + B C 2 + B D 2
182 13 absvalsqd φ A 2 = A A
183 22 absvalsqd φ B 2 = B B
184 182 183 oveq12d φ A 2 + B 2 = A A + B B
185 6 184 syl5eq φ X = A A + B B
186 15 absvalsqd φ C 2 = C C
187 24 absvalsqd φ D 2 = D D
188 186 187 oveq12d φ C 2 + D 2 = C C + D D
189 7 188 syl5eq φ Y = C C + D D
190 185 189 oveq12d φ X Y = A A + B B C C + D D
191 20 29 46 51 add42d φ A C 2 + B D 2 + A D 2 + B C 2 = A C 2 + A D 2 + B C 2 + B D 2
192 181 190 191 3eqtr4d φ X Y = A C 2 + B D 2 + A D 2 + B C 2
193 53 155 192 3eqtr4d φ A C + B D 2 + A D B C 2 = X Y
194 193 oveq1d φ A C + B D 2 + A D B C 2 M 2 = X Y M 2
195 8 nncnd φ M
196 8 nnne0d φ M 0
197 55 195 196 absdivd φ A C + B D M = A C + B D M
198 8 nnred φ M
199 8 nnnn0d φ M 0
200 199 nn0ge0d φ 0 M
201 198 200 absidd φ M = M
202 201 oveq2d φ A C + B D M = A C + B D M
203 197 202 eqtrd φ A C + B D M = A C + B D M
204 203 oveq1d φ A C + B D M 2 = A C + B D M 2
205 55 abscld φ A C + B D
206 205 recnd φ A C + B D
207 206 195 196 sqdivd φ A C + B D M 2 = A C + B D 2 M 2
208 204 207 eqtrd φ A C + B D M 2 = A C + B D 2 M 2
209 106 195 196 absdivd φ A D B C M = A D B C M
210 201 oveq2d φ A D B C M = A D B C M
211 209 210 eqtrd φ A D B C M = A D B C M
212 211 oveq1d φ A D B C M 2 = A D B C M 2
213 106 abscld φ A D B C
214 213 recnd φ A D B C
215 214 195 196 sqdivd φ A D B C M 2 = A D B C 2 M 2
216 212 215 eqtrd φ A D B C M 2 = A D B C 2 M 2
217 208 216 oveq12d φ A C + B D M 2 + A D B C M 2 = A C + B D 2 M 2 + A D B C 2 M 2
218 30 41 addcld φ A C 2 + B D 2 + A C B D + B C A D
219 104 218 eqeltrd φ A C + B D 2
220 52 41 subcld φ A D 2 + B C 2 - A C B D + B C A D
221 154 220 eqeltrd φ A D B C 2
222 8 nnsqcld φ M 2
223 222 nncnd φ M 2
224 222 nnne0d φ M 2 0
225 219 221 223 224 divdird φ A C + B D 2 + A D B C 2 M 2 = A C + B D 2 M 2 + A D B C 2 M 2
226 217 225 eqtr4d φ A C + B D M 2 + A D B C M 2 = A C + B D 2 + A D B C 2 M 2
227 182 156 eqeltrd φ A 2
228 183 157 eqeltrd φ B 2
229 227 228 addcld φ A 2 + B 2
230 6 229 eqeltrid φ X
231 189 160 eqeltrd φ Y
232 230 195 231 195 196 196 divmuldivd φ X M Y M = X Y M M
233 195 sqvald φ M 2 = M M
234 233 oveq2d φ X Y M 2 = X Y M M
235 232 234 eqtr4d φ X M Y M = X Y M 2
236 194 226 235 3eqtr4d φ A C + B D M 2 + A D B C M 2 = X M Y M
237 230 55 nncand φ X X A C + B D = A C + B D
238 156 157 32 54 addsub4d φ A A + B B - A C + B D = A A A C + B B - B D
239 185 oveq1d φ X A C + B D = A A + B B - A C + B D
240 31 13 15 subdid φ A A C = A A A C
241 31 13 mulcomd φ A A = A A
242 241 oveq1d φ A A A C = A A A C
243 240 242 eqtrd φ A A C = A A A C
244 cjsub B D B D = B D
245 22 24 244 syl2anc φ B D = B D
246 245 oveq2d φ B B D = B B D
247 22 33 38 subdid φ B B D = B B B D
248 246 247 eqtrd φ B B D = B B B D
249 243 248 oveq12d φ A A C + B B D = A A A C + B B - B D
250 238 239 249 3eqtr4d φ X A C + B D = A A C + B B D
251 250 oveq2d φ X X A C + B D = X A A C + B B D
252 237 251 eqtr3d φ A C + B D = X A A C + B B D
253 252 oveq1d φ A C + B D M = X A A C + B B D M
254 13 15 subcld φ A C
255 31 254 mulcld φ A A C
256 22 24 subcld φ B D
257 256 cjcld φ B D
258 22 257 mulcld φ B B D
259 255 258 addcld φ A A C + B B D
260 230 259 195 196 divsubdird φ X A A C + B B D M = X M A A C + B B D M
261 255 258 195 196 divdird φ A A C + B B D M = A A C M + B B D M
262 31 254 195 196 divassd φ A A C M = A A C M
263 22 257 195 196 divassd φ B B D M = B B D M
264 256 195 196 cjdivd φ B D M = B D M
265 198 cjred φ M = M
266 265 oveq2d φ B D M = B D M
267 264 266 eqtrd φ B D M = B D M
268 267 oveq2d φ B B D M = B B D M
269 263 268 eqtr4d φ B B D M = B B D M
270 262 269 oveq12d φ A A C M + B B D M = A A C M + B B D M
271 261 270 eqtrd φ A A C + B B D M = A A C M + B B D M
272 271 oveq2d φ X M A A C + B B D M = X M A A C M + B B D M
273 253 260 272 3eqtrd φ A C + B D M = X M A A C M + B B D M
274 11 nn0zd φ X M
275 zgz X M X M i
276 274 275 syl φ X M i
277 gzcjcl A i A i
278 2 277 syl φ A i
279 gzmulcl A i A C M i A A C M i
280 278 9 279 syl2anc φ A A C M i
281 gzcjcl B D M i B D M i
282 10 281 syl φ B D M i
283 gzmulcl B i B D M i B B D M i
284 3 282 283 syl2anc φ B B D M i
285 gzaddcl A A C M i B B D M i A A C M + B B D M i
286 280 284 285 syl2anc φ A A C M + B B D M i
287 gzsubcl X M i A A C M + B B D M i X M A A C M + B B D M i
288 276 286 287 syl2anc φ X M A A C M + B B D M i
289 273 288 eqeltrd φ A C + B D M i
290 254 cjcld φ A C
291 22 290 mulcld φ B A C
292 31 256 mulcld φ A B D
293 291 292 195 196 divsubdird φ B A C A B D M = B A C M A B D M
294 cjsub A C A C = A C
295 13 15 294 syl2anc φ A C = A C
296 295 oveq2d φ B A C = B A C
297 22 31 36 subdid φ B A C = B A B C
298 296 297 eqtrd φ B A C = B A B C
299 31 22 24 subdid φ A B D = A B A D
300 31 22 mulcomd φ A B = B A
301 300 oveq1d φ A B A D = B A A D
302 299 301 eqtrd φ A B D = B A A D
303 298 302 oveq12d φ B A C A B D = B A - B C - B A A D
304 22 31 mulcld φ B A
305 304 37 105 nnncan1d φ B A - B C - B A A D = A D B C
306 303 305 eqtrd φ B A C A B D = A D B C
307 306 oveq1d φ B A C A B D M = A D B C M
308 293 307 eqtr3d φ B A C M A B D M = A D B C M
309 22 290 195 196 divassd φ B A C M = B A C M
310 254 195 196 cjdivd φ A C M = A C M
311 265 oveq2d φ A C M = A C M
312 310 311 eqtrd φ A C M = A C M
313 312 oveq2d φ B A C M = B A C M
314 309 313 eqtr4d φ B A C M = B A C M
315 31 256 195 196 divassd φ A B D M = A B D M
316 314 315 oveq12d φ B A C M A B D M = B A C M A B D M
317 308 316 eqtr3d φ A D B C M = B A C M A B D M
318 gzcjcl A C M i A C M i
319 9 318 syl φ A C M i
320 gzmulcl B i A C M i B A C M i
321 3 319 320 syl2anc φ B A C M i
322 gzmulcl A i B D M i A B D M i
323 278 10 322 syl2anc φ A B D M i
324 gzsubcl B A C M i A B D M i B A C M A B D M i
325 321 323 324 syl2anc φ B A C M A B D M i
326 317 325 eqeltrd φ A D B C M i
327 1 4sqlem4a A C + B D M i A D B C M i A C + B D M 2 + A D B C M 2 S
328 289 326 327 syl2anc φ A C + B D M 2 + A D B C M 2 S
329 236 328 eqeltrrd φ X M Y M S