Metamath Proof Explorer


Theorem 4sqlem10

Description: Lemma for 4sq . (Contributed by Mario Carneiro, 16-Jul-2014)

Ref Expression
Hypotheses 4sqlem5.2
|- ( ph -> A e. ZZ )
4sqlem5.3
|- ( ph -> M e. NN )
4sqlem5.4
|- B = ( ( ( A + ( M / 2 ) ) mod M ) - ( M / 2 ) )
4sqlem10.5
|- ( ( ph /\ ps ) -> ( ( ( ( M ^ 2 ) / 2 ) / 2 ) - ( B ^ 2 ) ) = 0 )
Assertion 4sqlem10
|- ( ( ph /\ ps ) -> ( M ^ 2 ) || ( ( A ^ 2 ) - ( ( ( M ^ 2 ) / 2 ) / 2 ) ) )

Proof

Step Hyp Ref Expression
1 4sqlem5.2
 |-  ( ph -> A e. ZZ )
2 4sqlem5.3
 |-  ( ph -> M e. NN )
3 4sqlem5.4
 |-  B = ( ( ( A + ( M / 2 ) ) mod M ) - ( M / 2 ) )
4 4sqlem10.5
 |-  ( ( ph /\ ps ) -> ( ( ( ( M ^ 2 ) / 2 ) / 2 ) - ( B ^ 2 ) ) = 0 )
5 2 adantr
 |-  ( ( ph /\ ps ) -> M e. NN )
6 5 nnzd
 |-  ( ( ph /\ ps ) -> M e. ZZ )
7 zsqcl
 |-  ( M e. ZZ -> ( M ^ 2 ) e. ZZ )
8 6 7 syl
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) e. ZZ )
9 1 adantr
 |-  ( ( ph /\ ps ) -> A e. ZZ )
10 5 nnred
 |-  ( ( ph /\ ps ) -> M e. RR )
11 10 rehalfcld
 |-  ( ( ph /\ ps ) -> ( M / 2 ) e. RR )
12 11 recnd
 |-  ( ( ph /\ ps ) -> ( M / 2 ) e. CC )
13 12 negnegd
 |-  ( ( ph /\ ps ) -> -u -u ( M / 2 ) = ( M / 2 ) )
14 1 2 3 4sqlem5
 |-  ( ph -> ( B e. ZZ /\ ( ( A - B ) / M ) e. ZZ ) )
15 14 adantr
 |-  ( ( ph /\ ps ) -> ( B e. ZZ /\ ( ( A - B ) / M ) e. ZZ ) )
16 15 simpld
 |-  ( ( ph /\ ps ) -> B e. ZZ )
17 16 zred
 |-  ( ( ph /\ ps ) -> B e. RR )
18 1 2 3 4sqlem6
 |-  ( ph -> ( -u ( M / 2 ) <_ B /\ B < ( M / 2 ) ) )
19 18 adantr
 |-  ( ( ph /\ ps ) -> ( -u ( M / 2 ) <_ B /\ B < ( M / 2 ) ) )
20 19 simprd
 |-  ( ( ph /\ ps ) -> B < ( M / 2 ) )
21 17 20 ltned
 |-  ( ( ph /\ ps ) -> B =/= ( M / 2 ) )
22 21 neneqd
 |-  ( ( ph /\ ps ) -> -. B = ( M / 2 ) )
23 2cnd
 |-  ( ( ph /\ ps ) -> 2 e. CC )
24 23 sqvald
 |-  ( ( ph /\ ps ) -> ( 2 ^ 2 ) = ( 2 x. 2 ) )
25 24 oveq2d
 |-  ( ( ph /\ ps ) -> ( ( M ^ 2 ) / ( 2 ^ 2 ) ) = ( ( M ^ 2 ) / ( 2 x. 2 ) ) )
26 5 nncnd
 |-  ( ( ph /\ ps ) -> M e. CC )
27 2ne0
 |-  2 =/= 0
28 27 a1i
 |-  ( ( ph /\ ps ) -> 2 =/= 0 )
29 26 23 28 sqdivd
 |-  ( ( ph /\ ps ) -> ( ( M / 2 ) ^ 2 ) = ( ( M ^ 2 ) / ( 2 ^ 2 ) ) )
30 26 sqcld
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) e. CC )
31 30 23 23 28 28 divdiv1d
 |-  ( ( ph /\ ps ) -> ( ( ( M ^ 2 ) / 2 ) / 2 ) = ( ( M ^ 2 ) / ( 2 x. 2 ) ) )
32 25 29 31 3eqtr4d
 |-  ( ( ph /\ ps ) -> ( ( M / 2 ) ^ 2 ) = ( ( ( M ^ 2 ) / 2 ) / 2 ) )
33 30 halfcld
 |-  ( ( ph /\ ps ) -> ( ( M ^ 2 ) / 2 ) e. CC )
34 33 halfcld
 |-  ( ( ph /\ ps ) -> ( ( ( M ^ 2 ) / 2 ) / 2 ) e. CC )
35 16 zcnd
 |-  ( ( ph /\ ps ) -> B e. CC )
36 35 sqcld
 |-  ( ( ph /\ ps ) -> ( B ^ 2 ) e. CC )
37 34 36 4 subeq0d
 |-  ( ( ph /\ ps ) -> ( ( ( M ^ 2 ) / 2 ) / 2 ) = ( B ^ 2 ) )
38 32 37 eqtr2d
 |-  ( ( ph /\ ps ) -> ( B ^ 2 ) = ( ( M / 2 ) ^ 2 ) )
39 sqeqor
 |-  ( ( B e. CC /\ ( M / 2 ) e. CC ) -> ( ( B ^ 2 ) = ( ( M / 2 ) ^ 2 ) <-> ( B = ( M / 2 ) \/ B = -u ( M / 2 ) ) ) )
40 35 12 39 syl2anc
 |-  ( ( ph /\ ps ) -> ( ( B ^ 2 ) = ( ( M / 2 ) ^ 2 ) <-> ( B = ( M / 2 ) \/ B = -u ( M / 2 ) ) ) )
41 38 40 mpbid
 |-  ( ( ph /\ ps ) -> ( B = ( M / 2 ) \/ B = -u ( M / 2 ) ) )
42 41 ord
 |-  ( ( ph /\ ps ) -> ( -. B = ( M / 2 ) -> B = -u ( M / 2 ) ) )
43 22 42 mpd
 |-  ( ( ph /\ ps ) -> B = -u ( M / 2 ) )
44 43 16 eqeltrrd
 |-  ( ( ph /\ ps ) -> -u ( M / 2 ) e. ZZ )
45 44 znegcld
 |-  ( ( ph /\ ps ) -> -u -u ( M / 2 ) e. ZZ )
46 13 45 eqeltrrd
 |-  ( ( ph /\ ps ) -> ( M / 2 ) e. ZZ )
47 9 46 zaddcld
 |-  ( ( ph /\ ps ) -> ( A + ( M / 2 ) ) e. ZZ )
48 zsqcl
 |-  ( ( A + ( M / 2 ) ) e. ZZ -> ( ( A + ( M / 2 ) ) ^ 2 ) e. ZZ )
49 47 48 syl
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) ^ 2 ) e. ZZ )
50 47 6 zmulcld
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) x. M ) e. ZZ )
51 47 zred
 |-  ( ( ph /\ ps ) -> ( A + ( M / 2 ) ) e. RR )
52 5 nnrpd
 |-  ( ( ph /\ ps ) -> M e. RR+ )
53 51 52 modcld
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) mod M ) e. RR )
54 53 recnd
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) mod M ) e. CC )
55 0cnd
 |-  ( ( ph /\ ps ) -> 0 e. CC )
56 df-neg
 |-  -u ( M / 2 ) = ( 0 - ( M / 2 ) )
57 43 3 56 3eqtr3g
 |-  ( ( ph /\ ps ) -> ( ( ( A + ( M / 2 ) ) mod M ) - ( M / 2 ) ) = ( 0 - ( M / 2 ) ) )
58 54 55 12 57 subcan2d
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) mod M ) = 0 )
59 dvdsval3
 |-  ( ( M e. NN /\ ( A + ( M / 2 ) ) e. ZZ ) -> ( M || ( A + ( M / 2 ) ) <-> ( ( A + ( M / 2 ) ) mod M ) = 0 ) )
60 5 47 59 syl2anc
 |-  ( ( ph /\ ps ) -> ( M || ( A + ( M / 2 ) ) <-> ( ( A + ( M / 2 ) ) mod M ) = 0 ) )
61 58 60 mpbird
 |-  ( ( ph /\ ps ) -> M || ( A + ( M / 2 ) ) )
62 dvdssq
 |-  ( ( M e. ZZ /\ ( A + ( M / 2 ) ) e. ZZ ) -> ( M || ( A + ( M / 2 ) ) <-> ( M ^ 2 ) || ( ( A + ( M / 2 ) ) ^ 2 ) ) )
63 6 47 62 syl2anc
 |-  ( ( ph /\ ps ) -> ( M || ( A + ( M / 2 ) ) <-> ( M ^ 2 ) || ( ( A + ( M / 2 ) ) ^ 2 ) ) )
64 61 63 mpbid
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) || ( ( A + ( M / 2 ) ) ^ 2 ) )
65 26 sqvald
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) = ( M x. M ) )
66 5 nnne0d
 |-  ( ( ph /\ ps ) -> M =/= 0 )
67 dvdsmulcr
 |-  ( ( M e. ZZ /\ ( A + ( M / 2 ) ) e. ZZ /\ ( M e. ZZ /\ M =/= 0 ) ) -> ( ( M x. M ) || ( ( A + ( M / 2 ) ) x. M ) <-> M || ( A + ( M / 2 ) ) ) )
68 6 47 6 66 67 syl112anc
 |-  ( ( ph /\ ps ) -> ( ( M x. M ) || ( ( A + ( M / 2 ) ) x. M ) <-> M || ( A + ( M / 2 ) ) ) )
69 61 68 mpbird
 |-  ( ( ph /\ ps ) -> ( M x. M ) || ( ( A + ( M / 2 ) ) x. M ) )
70 65 69 eqbrtrd
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) || ( ( A + ( M / 2 ) ) x. M ) )
71 8 49 50 64 70 dvds2subd
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) || ( ( ( A + ( M / 2 ) ) ^ 2 ) - ( ( A + ( M / 2 ) ) x. M ) ) )
72 47 zcnd
 |-  ( ( ph /\ ps ) -> ( A + ( M / 2 ) ) e. CC )
73 72 sqvald
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) ^ 2 ) = ( ( A + ( M / 2 ) ) x. ( A + ( M / 2 ) ) ) )
74 73 oveq1d
 |-  ( ( ph /\ ps ) -> ( ( ( A + ( M / 2 ) ) ^ 2 ) - ( ( A + ( M / 2 ) ) x. M ) ) = ( ( ( A + ( M / 2 ) ) x. ( A + ( M / 2 ) ) ) - ( ( A + ( M / 2 ) ) x. M ) ) )
75 72 72 26 subdid
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) x. ( ( A + ( M / 2 ) ) - M ) ) = ( ( ( A + ( M / 2 ) ) x. ( A + ( M / 2 ) ) ) - ( ( A + ( M / 2 ) ) x. M ) ) )
76 26 2halvesd
 |-  ( ( ph /\ ps ) -> ( ( M / 2 ) + ( M / 2 ) ) = M )
77 76 oveq2d
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) - ( ( M / 2 ) + ( M / 2 ) ) ) = ( ( A + ( M / 2 ) ) - M ) )
78 9 zcnd
 |-  ( ( ph /\ ps ) -> A e. CC )
79 78 12 12 pnpcan2d
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) - ( ( M / 2 ) + ( M / 2 ) ) ) = ( A - ( M / 2 ) ) )
80 77 79 eqtr3d
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) - M ) = ( A - ( M / 2 ) ) )
81 80 oveq2d
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) x. ( ( A + ( M / 2 ) ) - M ) ) = ( ( A + ( M / 2 ) ) x. ( A - ( M / 2 ) ) ) )
82 subsq
 |-  ( ( A e. CC /\ ( M / 2 ) e. CC ) -> ( ( A ^ 2 ) - ( ( M / 2 ) ^ 2 ) ) = ( ( A + ( M / 2 ) ) x. ( A - ( M / 2 ) ) ) )
83 78 12 82 syl2anc
 |-  ( ( ph /\ ps ) -> ( ( A ^ 2 ) - ( ( M / 2 ) ^ 2 ) ) = ( ( A + ( M / 2 ) ) x. ( A - ( M / 2 ) ) ) )
84 32 oveq2d
 |-  ( ( ph /\ ps ) -> ( ( A ^ 2 ) - ( ( M / 2 ) ^ 2 ) ) = ( ( A ^ 2 ) - ( ( ( M ^ 2 ) / 2 ) / 2 ) ) )
85 81 83 84 3eqtr2d
 |-  ( ( ph /\ ps ) -> ( ( A + ( M / 2 ) ) x. ( ( A + ( M / 2 ) ) - M ) ) = ( ( A ^ 2 ) - ( ( ( M ^ 2 ) / 2 ) / 2 ) ) )
86 74 75 85 3eqtr2d
 |-  ( ( ph /\ ps ) -> ( ( ( A + ( M / 2 ) ) ^ 2 ) - ( ( A + ( M / 2 ) ) x. M ) ) = ( ( A ^ 2 ) - ( ( ( M ^ 2 ) / 2 ) / 2 ) ) )
87 71 86 breqtrd
 |-  ( ( ph /\ ps ) -> ( M ^ 2 ) || ( ( A ^ 2 ) - ( ( ( M ^ 2 ) / 2 ) / 2 ) ) )