Metamath Proof Explorer


Theorem 4sqlem4

Description: Lemma for 4sq . We can express the four-square property more compactly in terms of gaussian integers, because the norms of gaussian integers are exactly sums of two squares. (Contributed by Mario Carneiro, 14-Jul-2014)

Ref Expression
Hypothesis 4sq.1 S = n | x y z w n = x 2 + y 2 + z 2 + w 2
Assertion 4sqlem4 A S u i v i A = u 2 + v 2

Proof

Step Hyp Ref Expression
1 4sq.1 S = n | x y z w n = x 2 + y 2 + z 2 + w 2
2 1 4sqlem2 A S a b c d A = a 2 + b 2 + c 2 + d 2
3 gzreim a b a + i b i
4 3 adantr a b c d a + i b i
5 gzreim c d c + i d i
6 5 adantl a b c d c + i d i
7 gzcn a + i b i a + i b
8 3 7 syl a b a + i b
9 8 absvalsq2d a b a + i b 2 = a + i b 2 + a + i b 2
10 zre a a
11 zre b b
12 crre a b a + i b = a
13 10 11 12 syl2an a b a + i b = a
14 13 oveq1d a b a + i b 2 = a 2
15 crim a b a + i b = b
16 10 11 15 syl2an a b a + i b = b
17 16 oveq1d a b a + i b 2 = b 2
18 14 17 oveq12d a b a + i b 2 + a + i b 2 = a 2 + b 2
19 9 18 eqtrd a b a + i b 2 = a 2 + b 2
20 gzcn c + i d i c + i d
21 5 20 syl c d c + i d
22 21 absvalsq2d c d c + i d 2 = c + i d 2 + c + i d 2
23 zre c c
24 zre d d
25 crre c d c + i d = c
26 23 24 25 syl2an c d c + i d = c
27 26 oveq1d c d c + i d 2 = c 2
28 crim c d c + i d = d
29 23 24 28 syl2an c d c + i d = d
30 29 oveq1d c d c + i d 2 = d 2
31 27 30 oveq12d c d c + i d 2 + c + i d 2 = c 2 + d 2
32 22 31 eqtrd c d c + i d 2 = c 2 + d 2
33 19 32 oveqan12d a b c d a + i b 2 + c + i d 2 = a 2 + b 2 + c 2 + d 2
34 33 eqcomd a b c d a 2 + b 2 + c 2 + d 2 = a + i b 2 + c + i d 2
35 fveq2 u = a + i b u = a + i b
36 35 oveq1d u = a + i b u 2 = a + i b 2
37 36 oveq1d u = a + i b u 2 + v 2 = a + i b 2 + v 2
38 37 eqeq2d u = a + i b a 2 + b 2 + c 2 + d 2 = u 2 + v 2 a 2 + b 2 + c 2 + d 2 = a + i b 2 + v 2
39 fveq2 v = c + i d v = c + i d
40 39 oveq1d v = c + i d v 2 = c + i d 2
41 40 oveq2d v = c + i d a + i b 2 + v 2 = a + i b 2 + c + i d 2
42 41 eqeq2d v = c + i d a 2 + b 2 + c 2 + d 2 = a + i b 2 + v 2 a 2 + b 2 + c 2 + d 2 = a + i b 2 + c + i d 2
43 38 42 rspc2ev a + i b i c + i d i a 2 + b 2 + c 2 + d 2 = a + i b 2 + c + i d 2 u i v i a 2 + b 2 + c 2 + d 2 = u 2 + v 2
44 4 6 34 43 syl3anc a b c d u i v i a 2 + b 2 + c 2 + d 2 = u 2 + v 2
45 eqeq1 A = a 2 + b 2 + c 2 + d 2 A = u 2 + v 2 a 2 + b 2 + c 2 + d 2 = u 2 + v 2
46 45 2rexbidv A = a 2 + b 2 + c 2 + d 2 u i v i A = u 2 + v 2 u i v i a 2 + b 2 + c 2 + d 2 = u 2 + v 2
47 44 46 syl5ibrcom a b c d A = a 2 + b 2 + c 2 + d 2 u i v i A = u 2 + v 2
48 47 rexlimdvva a b c d A = a 2 + b 2 + c 2 + d 2 u i v i A = u 2 + v 2
49 48 rexlimivv a b c d A = a 2 + b 2 + c 2 + d 2 u i v i A = u 2 + v 2
50 2 49 sylbi A S u i v i A = u 2 + v 2
51 1 4sqlem4a u i v i u 2 + v 2 S
52 eleq1a u 2 + v 2 S A = u 2 + v 2 A S
53 51 52 syl u i v i A = u 2 + v 2 A S
54 53 rexlimivv u i v i A = u 2 + v 2 A S
55 50 54 impbii A S u i v i A = u 2 + v 2