Metamath Proof Explorer


Theorem 2sqblem

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

Ref Expression
Hypotheses 2sqb.1 φPP2
2sqb.2 φXY
2sqb.3 φP=X2+Y2
2sqb.4 φA
2sqb.5 φB
2sqb.6 φPgcdY=PA+YB
Assertion 2sqblem φPmod4=1

Proof

Step Hyp Ref Expression
1 2sqb.1 φPP2
2 2sqb.2 φXY
3 2sqb.3 φP=X2+Y2
4 2sqb.4 φA
5 2sqb.5 φB
6 2sqb.6 φPgcdY=PA+YB
7 1 simpld φP
8 nprmdvds1 P¬P1
9 7 8 syl φ¬P1
10 prmz PP
11 7 10 syl φP
12 1z 1
13 dvdsnegb P1P1P-1
14 11 12 13 sylancl φP1P-1
15 9 14 mtbid φ¬P-1
16 2 simpld φX
17 16 5 zmulcld φXB
18 zsqcl BB2
19 5 18 syl φB2
20 dvdsmul1 PB2PPB2
21 11 19 20 syl2anc φPPB2
22 2 simprd φY
23 22 5 zmulcld φYB
24 zsqcl YBYB2
25 23 24 syl φYB2
26 peano2zm YB2YB21
27 25 26 syl φYB21
28 27 zcnd φYB21
29 zsqcl XBXB2
30 17 29 syl φXB2
31 30 peano2zd φXB2+1
32 31 zcnd φXB2+1
33 28 32 addcomd φYB21+XB2+1=XB2+1+YB21
34 30 zcnd φXB2
35 ax-1cn 1
36 35 a1i φ1
37 25 zcnd φYB2
38 34 36 37 ppncand φXB2+1+YB21=XB2+YB2
39 zsqcl XX2
40 16 39 syl φX2
41 40 zcnd φX2
42 zsqcl YY2
43 22 42 syl φY2
44 43 zcnd φY2
45 19 zcnd φB2
46 41 44 45 adddird φX2+Y2B2=X2B2+Y2B2
47 3 oveq1d φPB2=X2+Y2B2
48 16 zcnd φX
49 5 zcnd φB
50 48 49 sqmuld φXB2=X2B2
51 22 zcnd φY
52 51 49 sqmuld φYB2=Y2B2
53 50 52 oveq12d φXB2+YB2=X2B2+Y2B2
54 46 47 53 3eqtr4rd φXB2+YB2=PB2
55 33 38 54 3eqtrd φYB21+XB2+1=PB2
56 21 55 breqtrrd φPYB21+XB2+1
57 dvdsmul1 PAPPA
58 11 4 57 syl2anc φPPA
59 11 4 zmulcld φPA
60 dvdsnegb PPAPPAPPA
61 11 59 60 syl2anc φPPAPPA
62 58 61 mpbid φPPA
63 23 zcnd φYB
64 negsubdi2 1YB1YB=YB1
65 35 63 64 sylancr φ1YB=YB1
66 59 zcnd φPA
67 22 zred φY
68 absresq YY2=Y2
69 67 68 syl φY2=Y2
70 67 resqcld φY2
71 prmnn PP
72 7 71 syl φP
73 72 nnred φP
74 73 resqcld φP2
75 zsqcl2 XX20
76 16 75 syl φX20
77 nn0addge2 Y2X20Y2X2+Y2
78 70 76 77 syl2anc φY2X2+Y2
79 78 3 breqtrrd φY2P
80 11 zcnd φP
81 80 exp1d φP1=P
82 12 a1i φ1
83 2z 2
84 83 a1i φ2
85 prmuz2 PP2
86 7 85 syl φP2
87 eluz2gt1 P21<P
88 86 87 syl φ1<P
89 1lt2 1<2
90 89 a1i φ1<2
91 ltexp2a P121<P1<2P1<P2
92 73 82 84 88 90 91 syl32anc φP1<P2
93 81 92 eqbrtrrd φP<P2
94 70 73 74 79 93 lelttrd φY2<P2
95 69 94 eqbrtrd φY2<P2
96 51 abscld φY
97 51 absge0d φ0Y
98 72 nnnn0d φP0
99 98 nn0ge0d φ0P
100 96 73 97 99 lt2sqd φY<PY2<P2
101 95 100 mpbird φY<P
102 11 zred φP
103 96 102 ltnled φY<P¬PY
104 101 103 mpbid φ¬PY
105 sqnprm X¬X2
106 16 105 syl φ¬X2
107 51 abs00ad φY=0Y=0
108 3 7 eqeltrrd φX2+Y2
109 sq0i Y=0Y2=0
110 109 oveq2d Y=0X2+Y2=X2+0
111 110 eleq1d Y=0X2+Y2X2+0
112 108 111 syl5ibcom φY=0X2+0
113 41 addridd φX2+0=X2
114 113 eleq1d φX2+0X2
115 112 114 sylibd φY=0X2
116 107 115 sylbid φY=0X2
117 106 116 mtod φ¬Y=0
118 nn0abscl YY0
119 22 118 syl φY0
120 elnn0 Y0YY=0
121 119 120 sylib φYY=0
122 121 ord φ¬YY=0
123 117 122 mt3d φY
124 dvdsle PYPYPY
125 11 123 124 syl2anc φPYPY
126 104 125 mtod φ¬PY
127 dvdsabsb PYPYPY
128 11 22 127 syl2anc φPYPY
129 126 128 mtbird φ¬PY
130 coprm PY¬PYPgcdY=1
131 7 22 130 syl2anc φ¬PYPgcdY=1
132 129 131 mpbid φPgcdY=1
133 132 6 eqtr3d φ1=PA+YB
134 66 63 133 mvrraddd φ1YB=PA
135 134 negeqd φ1YB=PA
136 65 135 eqtr3d φYB1=PA
137 62 136 breqtrrd φPYB1
138 23 peano2zd φYB+1
139 peano2zm YBYB1
140 23 139 syl φYB1
141 dvdsmultr2 PYB+1YB1PYB1PYB+1YB1
142 11 138 140 141 syl3anc φPYB1PYB+1YB1
143 137 142 mpd φPYB+1YB1
144 sq1 12=1
145 144 oveq2i YB212=YB21
146 subsq YB1YB212=YB+1YB1
147 63 35 146 sylancl φYB212=YB+1YB1
148 145 147 eqtr3id φYB21=YB+1YB1
149 143 148 breqtrrd φPYB21
150 dvdsadd2b PXB2+1YB21PYB21PXB2+1PYB21+XB2+1
151 11 31 27 149 150 syl112anc φPXB2+1PYB21+XB2+1
152 56 151 mpbird φPXB2+1
153 subneg XB21XB2-1=XB2+1
154 34 35 153 sylancl φXB2-1=XB2+1
155 152 154 breqtrrd φPXB2-1
156 oveq1 x=XBx2=XB2
157 156 oveq1d x=XBx2-1=XB2-1
158 157 breq2d x=XBPx2-1PXB2-1
159 158 rspcev XBPXB2-1xPx2-1
160 17 155 159 syl2anc φxPx2-1
161 neg1z 1
162 eldifsn P2PP2
163 1 162 sylibr φP2
164 lgsqr 1P2-1/LP=1¬P-1xPx2-1
165 161 163 164 sylancr φ-1/LP=1¬P-1xPx2-1
166 15 160 165 mpbir2and φ-1/LP=1
167 m1lgs P2-1/LP=1Pmod4=1
168 163 167 syl φ-1/LP=1Pmod4=1
169 166 168 mpbid φPmod4=1