Metamath Proof Explorer


Theorem 4sqlem16

Description: Lemma for 4sq . (Contributed by Mario Carneiro, 16-Jul-2014) (Revised by AV, 14-Sep-2020)

Ref Expression
Hypotheses 4sq.1 S = n | x y z w n = x 2 + y 2 + z 2 + w 2
4sq.2 φ N
4sq.3 φ P = 2 N + 1
4sq.4 φ P
4sq.5 φ 0 2 N S
4sq.6 T = i | i P S
4sq.7 M = sup T <
4sq.m φ M 2
4sq.a φ A
4sq.b φ B
4sq.c φ C
4sq.d φ D
4sq.e E = A + M 2 mod M M 2
4sq.f F = B + M 2 mod M M 2
4sq.g G = C + M 2 mod M M 2
4sq.h H = D + M 2 mod M M 2
4sq.r R = E 2 + F 2 + G 2 + H 2 M
4sq.p φ M P = A 2 + B 2 + C 2 + D 2
Assertion 4sqlem16 φ R M R = 0 R = M M 2 M P

Proof

Step Hyp Ref Expression
1 4sq.1 S = n | x y z w n = x 2 + y 2 + z 2 + w 2
2 4sq.2 φ N
3 4sq.3 φ P = 2 N + 1
4 4sq.4 φ P
5 4sq.5 φ 0 2 N S
6 4sq.6 T = i | i P S
7 4sq.7 M = sup T <
8 4sq.m φ M 2
9 4sq.a φ A
10 4sq.b φ B
11 4sq.c φ C
12 4sq.d φ D
13 4sq.e E = A + M 2 mod M M 2
14 4sq.f F = B + M 2 mod M M 2
15 4sq.g G = C + M 2 mod M M 2
16 4sq.h H = D + M 2 mod M M 2
17 4sq.r R = E 2 + F 2 + G 2 + H 2 M
18 4sq.p φ M P = A 2 + B 2 + C 2 + D 2
19 eluz2nn M 2 M
20 8 19 syl φ M
21 9 20 13 4sqlem5 φ E A E M
22 21 simpld φ E
23 zsqcl E E 2
24 22 23 syl φ E 2
25 24 zred φ E 2
26 10 20 14 4sqlem5 φ F B F M
27 26 simpld φ F
28 zsqcl F F 2
29 27 28 syl φ F 2
30 29 zred φ F 2
31 25 30 readdcld φ E 2 + F 2
32 11 20 15 4sqlem5 φ G C G M
33 32 simpld φ G
34 zsqcl G G 2
35 33 34 syl φ G 2
36 35 zred φ G 2
37 12 20 16 4sqlem5 φ H D H M
38 37 simpld φ H
39 zsqcl H H 2
40 38 39 syl φ H 2
41 40 zred φ H 2
42 36 41 readdcld φ G 2 + H 2
43 20 nnred φ M
44 43 resqcld φ M 2
45 44 rehalfcld φ M 2 2
46 45 rehalfcld φ M 2 2 2
47 9 20 13 4sqlem7 φ E 2 M 2 2 2
48 10 20 14 4sqlem7 φ F 2 M 2 2 2
49 25 30 46 46 47 48 le2addd φ E 2 + F 2 M 2 2 2 + M 2 2 2
50 45 recnd φ M 2 2
51 50 2halvesd φ M 2 2 2 + M 2 2 2 = M 2 2
52 49 51 breqtrd φ E 2 + F 2 M 2 2
53 11 20 15 4sqlem7 φ G 2 M 2 2 2
54 12 20 16 4sqlem7 φ H 2 M 2 2 2
55 36 41 46 46 53 54 le2addd φ G 2 + H 2 M 2 2 2 + M 2 2 2
56 55 51 breqtrd φ G 2 + H 2 M 2 2
57 31 42 45 45 52 56 le2addd φ E 2 + F 2 + G 2 + H 2 M 2 2 + M 2 2
58 44 recnd φ M 2
59 58 2halvesd φ M 2 2 + M 2 2 = M 2
60 57 59 breqtrd φ E 2 + F 2 + G 2 + H 2 M 2
61 43 recnd φ M
62 61 sqvald φ M 2 = M M
63 60 62 breqtrd φ E 2 + F 2 + G 2 + H 2 M M
64 31 42 readdcld φ E 2 + F 2 + G 2 + H 2
65 20 nngt0d φ 0 < M
66 ledivmul E 2 + F 2 + G 2 + H 2 M M 0 < M E 2 + F 2 + G 2 + H 2 M M E 2 + F 2 + G 2 + H 2 M M
67 64 43 43 65 66 syl112anc φ E 2 + F 2 + G 2 + H 2 M M E 2 + F 2 + G 2 + H 2 M M
68 63 67 mpbird φ E 2 + F 2 + G 2 + H 2 M M
69 17 68 eqbrtrid φ R M
70 simpr φ R = 0 R = 0
71 17 70 eqtr3id φ R = 0 E 2 + F 2 + G 2 + H 2 M = 0
72 64 recnd φ E 2 + F 2 + G 2 + H 2
73 20 nnne0d φ M 0
74 72 61 73 diveq0ad φ E 2 + F 2 + G 2 + H 2 M = 0 E 2 + F 2 + G 2 + H 2 = 0
75 zsqcl2 E E 2 0
76 22 75 syl φ E 2 0
77 zsqcl2 F F 2 0
78 27 77 syl φ F 2 0
79 76 78 nn0addcld φ E 2 + F 2 0
80 79 nn0ge0d φ 0 E 2 + F 2
81 zsqcl2 G G 2 0
82 33 81 syl φ G 2 0
83 zsqcl2 H H 2 0
84 38 83 syl φ H 2 0
85 82 84 nn0addcld φ G 2 + H 2 0
86 85 nn0ge0d φ 0 G 2 + H 2
87 add20 E 2 + F 2 0 E 2 + F 2 G 2 + H 2 0 G 2 + H 2 E 2 + F 2 + G 2 + H 2 = 0 E 2 + F 2 = 0 G 2 + H 2 = 0
88 31 80 42 86 87 syl22anc φ E 2 + F 2 + G 2 + H 2 = 0 E 2 + F 2 = 0 G 2 + H 2 = 0
89 74 88 bitrd φ E 2 + F 2 + G 2 + H 2 M = 0 E 2 + F 2 = 0 G 2 + H 2 = 0
90 89 biimpa φ E 2 + F 2 + G 2 + H 2 M = 0 E 2 + F 2 = 0 G 2 + H 2 = 0
91 71 90 syldan φ R = 0 E 2 + F 2 = 0 G 2 + H 2 = 0
92 91 simpld φ R = 0 E 2 + F 2 = 0
93 76 nn0ge0d φ 0 E 2
94 78 nn0ge0d φ 0 F 2
95 add20 E 2 0 E 2 F 2 0 F 2 E 2 + F 2 = 0 E 2 = 0 F 2 = 0
96 25 93 30 94 95 syl22anc φ E 2 + F 2 = 0 E 2 = 0 F 2 = 0
97 96 biimpa φ E 2 + F 2 = 0 E 2 = 0 F 2 = 0
98 92 97 syldan φ R = 0 E 2 = 0 F 2 = 0
99 98 simpld φ R = 0 E 2 = 0
100 9 20 13 99 4sqlem9 φ R = 0 M 2 A 2
101 98 simprd φ R = 0 F 2 = 0
102 10 20 14 101 4sqlem9 φ R = 0 M 2 B 2
103 20 nnsqcld φ M 2
104 103 nnzd φ M 2
105 zsqcl A A 2
106 9 105 syl φ A 2
107 zsqcl B B 2
108 10 107 syl φ B 2
109 dvds2add M 2 A 2 B 2 M 2 A 2 M 2 B 2 M 2 A 2 + B 2
110 104 106 108 109 syl3anc φ M 2 A 2 M 2 B 2 M 2 A 2 + B 2
111 110 adantr φ R = 0 M 2 A 2 M 2 B 2 M 2 A 2 + B 2
112 100 102 111 mp2and φ R = 0 M 2 A 2 + B 2
113 91 simprd φ R = 0 G 2 + H 2 = 0
114 82 nn0ge0d φ 0 G 2
115 84 nn0ge0d φ 0 H 2
116 add20 G 2 0 G 2 H 2 0 H 2 G 2 + H 2 = 0 G 2 = 0 H 2 = 0
117 36 114 41 115 116 syl22anc φ G 2 + H 2 = 0 G 2 = 0 H 2 = 0
118 117 biimpa φ G 2 + H 2 = 0 G 2 = 0 H 2 = 0
119 113 118 syldan φ R = 0 G 2 = 0 H 2 = 0
120 119 simpld φ R = 0 G 2 = 0
121 11 20 15 120 4sqlem9 φ R = 0 M 2 C 2
122 119 simprd φ R = 0 H 2 = 0
123 12 20 16 122 4sqlem9 φ R = 0 M 2 D 2
124 zsqcl C C 2
125 11 124 syl φ C 2
126 zsqcl D D 2
127 12 126 syl φ D 2
128 dvds2add M 2 C 2 D 2 M 2 C 2 M 2 D 2 M 2 C 2 + D 2
129 104 125 127 128 syl3anc φ M 2 C 2 M 2 D 2 M 2 C 2 + D 2
130 129 adantr φ R = 0 M 2 C 2 M 2 D 2 M 2 C 2 + D 2
131 121 123 130 mp2and φ R = 0 M 2 C 2 + D 2
132 106 108 zaddcld φ A 2 + B 2
133 125 127 zaddcld φ C 2 + D 2
134 dvds2add M 2 A 2 + B 2 C 2 + D 2 M 2 A 2 + B 2 M 2 C 2 + D 2 M 2 A 2 + B 2 + C 2 + D 2
135 104 132 133 134 syl3anc φ M 2 A 2 + B 2 M 2 C 2 + D 2 M 2 A 2 + B 2 + C 2 + D 2
136 135 adantr φ R = 0 M 2 A 2 + B 2 M 2 C 2 + D 2 M 2 A 2 + B 2 + C 2 + D 2
137 112 131 136 mp2and φ R = 0 M 2 A 2 + B 2 + C 2 + D 2
138 104 adantr φ R = M M 2
139 132 adantr φ R = M A 2 + B 2
140 51 adantr φ R = M M 2 2 2 + M 2 2 2 = M 2 2
141 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4sqlem15 φ R = M M 2 2 2 E 2 = 0 M 2 2 2 F 2 = 0 M 2 2 2 G 2 = 0 M 2 2 2 H 2 = 0
142 141 simpld φ R = M M 2 2 2 E 2 = 0 M 2 2 2 F 2 = 0
143 142 simpld φ R = M M 2 2 2 E 2 = 0
144 46 recnd φ M 2 2 2
145 24 zcnd φ E 2
146 144 145 subeq0ad φ M 2 2 2 E 2 = 0 M 2 2 2 = E 2
147 146 adantr φ R = M M 2 2 2 E 2 = 0 M 2 2 2 = E 2
148 143 147 mpbid φ R = M M 2 2 2 = E 2
149 24 adantr φ R = M E 2
150 148 149 eqeltrd φ R = M M 2 2 2
151 150 150 zaddcld φ R = M M 2 2 2 + M 2 2 2
152 140 151 eqeltrrd φ R = M M 2 2
153 139 152 zsubcld φ R = M A 2 + B 2 - M 2 2
154 133 adantr φ R = M C 2 + D 2
155 154 152 zsubcld φ R = M C 2 + D 2 - M 2 2
156 106 adantr φ R = M A 2
157 156 150 zsubcld φ R = M A 2 M 2 2 2
158 108 adantr φ R = M B 2
159 158 150 zsubcld φ R = M B 2 M 2 2 2
160 9 20 13 143 4sqlem10 φ R = M M 2 A 2 M 2 2 2
161 142 simprd φ R = M M 2 2 2 F 2 = 0
162 10 20 14 161 4sqlem10 φ R = M M 2 B 2 M 2 2 2
163 138 157 159 160 162 dvds2addd φ R = M M 2 A 2 M 2 2 2 + B 2 - M 2 2 2
164 106 zcnd φ A 2
165 108 zcnd φ B 2
166 164 165 144 144 addsub4d φ A 2 + B 2 - M 2 2 2 + M 2 2 2 = A 2 M 2 2 2 + B 2 - M 2 2 2
167 51 oveq2d φ A 2 + B 2 - M 2 2 2 + M 2 2 2 = A 2 + B 2 - M 2 2
168 166 167 eqtr3d φ A 2 M 2 2 2 + B 2 - M 2 2 2 = A 2 + B 2 - M 2 2
169 168 adantr φ R = M A 2 M 2 2 2 + B 2 - M 2 2 2 = A 2 + B 2 - M 2 2
170 163 169 breqtrd φ R = M M 2 A 2 + B 2 - M 2 2
171 125 adantr φ R = M C 2
172 171 150 zsubcld φ R = M C 2 M 2 2 2
173 127 adantr φ R = M D 2
174 173 150 zsubcld φ R = M D 2 M 2 2 2
175 141 simprd φ R = M M 2 2 2 G 2 = 0 M 2 2 2 H 2 = 0
176 175 simpld φ R = M M 2 2 2 G 2 = 0
177 11 20 15 176 4sqlem10 φ R = M M 2 C 2 M 2 2 2
178 175 simprd φ R = M M 2 2 2 H 2 = 0
179 12 20 16 178 4sqlem10 φ R = M M 2 D 2 M 2 2 2
180 138 172 174 177 179 dvds2addd φ R = M M 2 C 2 M 2 2 2 + D 2 - M 2 2 2
181 125 zcnd φ C 2
182 127 zcnd φ D 2
183 181 182 144 144 addsub4d φ C 2 + D 2 - M 2 2 2 + M 2 2 2 = C 2 M 2 2 2 + D 2 - M 2 2 2
184 51 oveq2d φ C 2 + D 2 - M 2 2 2 + M 2 2 2 = C 2 + D 2 - M 2 2
185 183 184 eqtr3d φ C 2 M 2 2 2 + D 2 - M 2 2 2 = C 2 + D 2 - M 2 2
186 185 adantr φ R = M C 2 M 2 2 2 + D 2 - M 2 2 2 = C 2 + D 2 - M 2 2
187 180 186 breqtrd φ R = M M 2 C 2 + D 2 - M 2 2
188 138 153 155 170 187 dvds2addd φ R = M M 2 A 2 + B 2 - M 2 2 + C 2 + D 2 - M 2 2
189 132 zcnd φ A 2 + B 2
190 133 zcnd φ C 2 + D 2
191 189 190 50 50 addsub4d φ A 2 + B 2 + C 2 + D 2 - M 2 2 + M 2 2 = A 2 + B 2 - M 2 2 + C 2 + D 2 - M 2 2
192 59 oveq2d φ A 2 + B 2 + C 2 + D 2 - M 2 2 + M 2 2 = A 2 + B 2 + C 2 + D 2 - M 2
193 191 192 eqtr3d φ A 2 + B 2 - M 2 2 + C 2 + D 2 - M 2 2 = A 2 + B 2 + C 2 + D 2 - M 2
194 193 adantr φ R = M A 2 + B 2 - M 2 2 + C 2 + D 2 - M 2 2 = A 2 + B 2 + C 2 + D 2 - M 2
195 188 194 breqtrd φ R = M M 2 A 2 + B 2 + C 2 + D 2 - M 2
196 132 133 zaddcld φ A 2 + B 2 + C 2 + D 2
197 196 adantr φ R = M A 2 + B 2 + C 2 + D 2
198 dvdssubr M 2 A 2 + B 2 + C 2 + D 2 M 2 A 2 + B 2 + C 2 + D 2 M 2 A 2 + B 2 + C 2 + D 2 - M 2
199 138 197 198 syl2anc φ R = M M 2 A 2 + B 2 + C 2 + D 2 M 2 A 2 + B 2 + C 2 + D 2 - M 2
200 195 199 mpbird φ R = M M 2 A 2 + B 2 + C 2 + D 2
201 137 200 jaodan φ R = 0 R = M M 2 A 2 + B 2 + C 2 + D 2
202 18 adantr φ R = 0 R = M M P = A 2 + B 2 + C 2 + D 2
203 201 202 breqtrrd φ R = 0 R = M M 2 M P
204 203 ex φ R = 0 R = M M 2 M P
205 69 204 jca φ R M R = 0 R = M M 2 M P