Metamath Proof Explorer


Theorem cncongr1

Description: One direction of the bicondition in cncongr . Theorem 5.4 in ApostolNT p. 109. (Contributed by AV, 13-Jul-2021)

Ref Expression
Assertion cncongr1 A B C N M = N C gcd N A C mod N = B C mod N A mod M = B mod M

Proof

Step Hyp Ref Expression
1 zmulcl A C A C
2 1 3adant2 A B C A C
3 zmulcl B C B C
4 3 3adant1 A B C B C
5 simpl N M = N C gcd N N
6 congr A C B C N A C mod N = B C mod N k k N = A C B C
7 2 4 5 6 syl2an3an A B C N M = N C gcd N A C mod N = B C mod N k k N = A C B C
8 simpl C N C
9 nnz N N
10 nnne0 N N 0
11 9 10 jca N N N 0
12 11 adantl C N N N 0
13 eqidd C N C gcd N = C gcd N
14 8 12 13 3jca C N C N N 0 C gcd N = C gcd N
15 14 ex C N C N N 0 C gcd N = C gcd N
16 15 3ad2ant3 A B C N C N N 0 C gcd N = C gcd N
17 16 com12 N A B C C N N 0 C gcd N = C gcd N
18 17 adantr N M = N C gcd N A B C C N N 0 C gcd N = C gcd N
19 18 impcom A B C N M = N C gcd N C N N 0 C gcd N = C gcd N
20 divgcdcoprmex C N N 0 C gcd N = C gcd N r s C = C gcd N r N = C gcd N s r gcd s = 1
21 19 20 syl A B C N M = N C gcd N r s C = C gcd N r N = C gcd N s r gcd s = 1
22 21 adantr A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1
23 oveq2 N = C gcd N s k N = k C gcd N s
24 23 3ad2ant2 C = C gcd N r N = C gcd N s r gcd s = 1 k N = k C gcd N s
25 24 adantl A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k N = k C gcd N s
26 oveq2 C = C gcd N r A C = A C gcd N r
27 oveq2 C = C gcd N r B C = B C gcd N r
28 26 27 oveq12d C = C gcd N r A C B C = A C gcd N r B C gcd N r
29 28 3ad2ant1 C = C gcd N r N = C gcd N s r gcd s = 1 A C B C = A C gcd N r B C gcd N r
30 29 adantl A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 A C B C = A C gcd N r B C gcd N r
31 25 30 eqeq12d A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k N = A C B C k C gcd N s = A C gcd N r B C gcd N r
32 simpr A B C N M = N C gcd N k k
33 32 zcnd A B C N M = N C gcd N k k
34 33 adantr A B C N M = N C gcd N k r s k
35 simp3 A B C C
36 35 adantr A B C N M = N C gcd N C
37 9 adantr N M = N C gcd N N
38 37 adantl A B C N M = N C gcd N N
39 36 38 gcdcld A B C N M = N C gcd N C gcd N 0
40 39 nn0cnd A B C N M = N C gcd N C gcd N
41 40 ad2antrr A B C N M = N C gcd N k r s C gcd N
42 simpr r s s
43 42 zcnd r s s
44 43 adantl A B C N M = N C gcd N k r s s
45 34 41 44 mul12d A B C N M = N C gcd N k r s k C gcd N s = C gcd N k s
46 simp1 A B C A
47 46 zcnd A B C A
48 47 adantr A B C N M = N C gcd N A
49 48 ad2antrr A B C N M = N C gcd N k r s A
50 35 ad2antrr A B C N M = N C gcd N k C
51 5 nnzd N M = N C gcd N N
52 51 adantl A B C N M = N C gcd N N
53 52 adantr A B C N M = N C gcd N k N
54 50 53 gcdcld A B C N M = N C gcd N k C gcd N 0
55 54 nn0cnd A B C N M = N C gcd N k C gcd N
56 55 adantr A B C N M = N C gcd N k r s C gcd N
57 simpl r s r
58 57 zcnd r s r
59 58 adantl A B C N M = N C gcd N k r s r
60 49 56 59 mul12d A B C N M = N C gcd N k r s A C gcd N r = C gcd N A r
61 simp2 A B C B
62 61 zcnd A B C B
63 62 adantr A B C N M = N C gcd N B
64 63 ad2antrr A B C N M = N C gcd N k r s B
65 36 52 gcdcld A B C N M = N C gcd N C gcd N 0
66 65 nn0cnd A B C N M = N C gcd N C gcd N
67 66 ad2antrr A B C N M = N C gcd N k r s C gcd N
68 64 67 59 mul12d A B C N M = N C gcd N k r s B C gcd N r = C gcd N B r
69 60 68 oveq12d A B C N M = N C gcd N k r s A C gcd N r B C gcd N r = C gcd N A r C gcd N B r
70 45 69 eqeq12d A B C N M = N C gcd N k r s k C gcd N s = A C gcd N r B C gcd N r C gcd N k s = C gcd N A r C gcd N B r
71 46 adantr A B C N M = N C gcd N A
72 71 ad2antrr A B C N M = N C gcd N k r s A
73 57 adantl A B C N M = N C gcd N k r s r
74 72 73 zmulcld A B C N M = N C gcd N k r s A r
75 74 zcnd A B C N M = N C gcd N k r s A r
76 61 adantr A B C N M = N C gcd N B
77 76 ad2antrr A B C N M = N C gcd N k r s B
78 77 73 zmulcld A B C N M = N C gcd N k r s B r
79 78 zcnd A B C N M = N C gcd N k r s B r
80 67 75 79 subdid A B C N M = N C gcd N k r s C gcd N A r B r = C gcd N A r C gcd N B r
81 80 eqcomd A B C N M = N C gcd N k r s C gcd N A r C gcd N B r = C gcd N A r B r
82 81 eqeq2d A B C N M = N C gcd N k r s C gcd N k s = C gcd N A r C gcd N B r C gcd N k s = C gcd N A r B r
83 32 adantr A B C N M = N C gcd N k r s k
84 42 adantl A B C N M = N C gcd N k r s s
85 83 84 zmulcld A B C N M = N C gcd N k r s k s
86 85 zcnd A B C N M = N C gcd N k r s k s
87 simpl A B A
88 87 57 anim12i A B r s A r
89 zmulcl A r A r
90 88 89 syl A B r s A r
91 simpr A B B
92 91 57 anim12i A B r s B r
93 zmulcl B r B r
94 92 93 syl A B r s B r
95 90 94 zsubcld A B r s A r B r
96 95 zcnd A B r s A r B r
97 96 ex A B r s A r B r
98 97 3adant3 A B C r s A r B r
99 98 ad2antrr A B C N M = N C gcd N k r s A r B r
100 99 imp A B C N M = N C gcd N k r s A r B r
101 10 adantr N M = N C gcd N N 0
102 101 adantl A B C N M = N C gcd N N 0
103 gcd2n0cl C N N 0 C gcd N
104 36 52 102 103 syl3anc A B C N M = N C gcd N C gcd N
105 nnne0 C gcd N C gcd N 0
106 104 105 syl A B C N M = N C gcd N C gcd N 0
107 106 ad2antrr A B C N M = N C gcd N k r s C gcd N 0
108 86 100 67 107 mulcand A B C N M = N C gcd N k r s C gcd N k s = C gcd N A r B r k s = A r B r
109 70 82 108 3bitrd A B C N M = N C gcd N k r s k C gcd N s = A C gcd N r B C gcd N r k s = A r B r
110 109 adantr A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k C gcd N s = A C gcd N r B C gcd N r k s = A r B r
111 zcn A A
112 zcn B B
113 111 112 anim12i A B A B
114 113 3adant3 A B C A B
115 114 ad2antrr A B C N M = N C gcd N k A B
116 115 58 anim12i A B C N M = N C gcd N k r s A B r
117 df-3an A B r A B r
118 116 117 sylibr A B C N M = N C gcd N k r s A B r
119 subdir A B r A B r = A r B r
120 118 119 syl A B C N M = N C gcd N k r s A B r = A r B r
121 120 eqcomd A B C N M = N C gcd N k r s A r B r = A B r
122 121 adantr A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 A r B r = A B r
123 122 eqeq2d A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k s = A r B r k s = A B r
124 5 nncnd N M = N C gcd N N
125 124 adantl A B C N M = N C gcd N N
126 125 ad2antrr A B C N M = N C gcd N k r s N
127 84 zcnd A B C N M = N C gcd N k r s s
128 66 106 jca A B C N M = N C gcd N C gcd N C gcd N 0
129 128 ad2antrr A B C N M = N C gcd N k r s C gcd N C gcd N 0
130 divmul2 N s C gcd N C gcd N 0 N C gcd N = s N = C gcd N s
131 126 127 129 130 syl3anc A B C N M = N C gcd N k r s N C gcd N = s N = C gcd N s
132 simpll A B C N M = N C gcd N k r s N C gcd N = s A B C N M = N C gcd N k
133 73 adantr A B C N M = N C gcd N k r s N C gcd N = s r
134 5 adantl A B C N M = N C gcd N N
135 134 36 jca A B C N M = N C gcd N N C
136 divgcdnnr N C N C gcd N
137 135 136 syl A B C N M = N C gcd N N C gcd N
138 137 adantr A B C N M = N C gcd N k N C gcd N
139 138 ad2antrr A B C N M = N C gcd N k r s N C gcd N = s N C gcd N
140 eleq1 s = N C gcd N s N C gcd N
141 140 eqcoms N C gcd N = s s N C gcd N
142 141 adantl A B C N M = N C gcd N k r s N C gcd N = s s N C gcd N
143 139 142 mpbird A B C N M = N C gcd N k r s N C gcd N = s s
144 133 143 jca A B C N M = N C gcd N k r s N C gcd N = s r s
145 132 144 jca A B C N M = N C gcd N k r s N C gcd N = s A B C N M = N C gcd N k r s
146 simpr A B C N M = N C gcd N k r s N C gcd N = s N C gcd N = s
147 145 146 jca A B C N M = N C gcd N k r s N C gcd N = s A B C N M = N C gcd N k r s N C gcd N = s
148 nnz s s
149 148 adantl r s s
150 149 anim2i k r s k s
151 150 adantl A B k r s k s
152 dvdsmul2 k s s k s
153 151 152 syl A B k r s s k s
154 breq2 k s = A B r s k s s A B r
155 zsubcl A B A B
156 155 zcnd A B A B
157 156 adantr A B k r s A B
158 zcn r r
159 158 adantr r s r
160 159 adantl k r s r
161 160 adantl A B k r s r
162 157 161 mulcomd A B k r s A B r = r A B
163 162 breq2d A B k r s s A B r s r A B
164 148 anim2i r s r s
165 gcdcom r s r gcd s = s gcd r
166 164 165 syl r s r gcd s = s gcd r
167 166 eqeq1d r s r gcd s = 1 s gcd r = 1
168 167 adantl k r s r gcd s = 1 s gcd r = 1
169 168 adantl A B k r s r gcd s = 1 s gcd r = 1
170 164 adantl k r s r s
171 170 ancomd k r s s r
172 155 171 anim12i A B k r s A B s r
173 172 ancomd A B k r s s r A B
174 df-3an s r A B s r A B
175 173 174 sylibr A B k r s s r A B
176 coprmdvds s r A B s r A B s gcd r = 1 s A B
177 175 176 syl A B k r s s r A B s gcd r = 1 s A B
178 simpr r s s
179 178 adantl k r s s
180 179 anim2i A B k r s A B s
181 180 ancomd A B k r s s A B
182 3anass s A B s A B
183 181 182 sylibr A B k r s s A B
184 moddvds s A B A mod s = B mod s s A B
185 183 184 syl A B k r s A mod s = B mod s s A B
186 177 185 sylibrd A B k r s s r A B s gcd r = 1 A mod s = B mod s
187 186 expcomd A B k r s s gcd r = 1 s r A B A mod s = B mod s
188 169 187 sylbid A B k r s r gcd s = 1 s r A B A mod s = B mod s
189 188 com23 A B k r s s r A B r gcd s = 1 A mod s = B mod s
190 163 189 sylbid A B k r s s A B r r gcd s = 1 A mod s = B mod s
191 190 com3l s A B r r gcd s = 1 A B k r s A mod s = B mod s
192 154 191 syl6bi k s = A B r s k s r gcd s = 1 A B k r s A mod s = B mod s
193 192 com14 A B k r s s k s r gcd s = 1 k s = A B r A mod s = B mod s
194 153 193 mpd A B k r s r gcd s = 1 k s = A B r A mod s = B mod s
195 194 ex A B k r s r gcd s = 1 k s = A B r A mod s = B mod s
196 195 3adant3 A B C k r s r gcd s = 1 k s = A B r A mod s = B mod s
197 196 adantr A B C N M = N C gcd N k r s r gcd s = 1 k s = A B r A mod s = B mod s
198 197 impl A B C N M = N C gcd N k r s r gcd s = 1 k s = A B r A mod s = B mod s
199 198 adantr A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 k s = A B r A mod s = B mod s
200 199 imp A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 k s = A B r A mod s = B mod s
201 eqtr2 N C gcd N = M N C gcd N = s M = s
202 oveq2 M = s A mod M = A mod s
203 oveq2 M = s B mod M = B mod s
204 202 203 eqeq12d M = s A mod M = B mod M A mod s = B mod s
205 201 204 syl N C gcd N = M N C gcd N = s A mod M = B mod M A mod s = B mod s
206 205 ex N C gcd N = M N C gcd N = s A mod M = B mod M A mod s = B mod s
207 206 eqcoms M = N C gcd N N C gcd N = s A mod M = B mod M A mod s = B mod s
208 207 adantl N M = N C gcd N N C gcd N = s A mod M = B mod M A mod s = B mod s
209 208 adantl A B C N M = N C gcd N N C gcd N = s A mod M = B mod M A mod s = B mod s
210 209 ad2antrr A B C N M = N C gcd N k r s N C gcd N = s A mod M = B mod M A mod s = B mod s
211 210 imp A B C N M = N C gcd N k r s N C gcd N = s A mod M = B mod M A mod s = B mod s
212 211 adantr A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 A mod M = B mod M A mod s = B mod s
213 200 212 sylibrd A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 k s = A B r A mod M = B mod M
214 213 ex A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 k s = A B r A mod M = B mod M
215 147 214 syl A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 k s = A B r A mod M = B mod M
216 215 ex A B C N M = N C gcd N k r s N C gcd N = s r gcd s = 1 k s = A B r A mod M = B mod M
217 131 216 sylbird A B C N M = N C gcd N k r s N = C gcd N s r gcd s = 1 k s = A B r A mod M = B mod M
218 217 com3l N = C gcd N s r gcd s = 1 A B C N M = N C gcd N k r s k s = A B r A mod M = B mod M
219 218 a1i C = C gcd N r N = C gcd N s r gcd s = 1 A B C N M = N C gcd N k r s k s = A B r A mod M = B mod M
220 219 3imp C = C gcd N r N = C gcd N s r gcd s = 1 A B C N M = N C gcd N k r s k s = A B r A mod M = B mod M
221 220 impcom A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k s = A B r A mod M = B mod M
222 123 221 sylbid A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k s = A r B r A mod M = B mod M
223 110 222 sylbid A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k C gcd N s = A C gcd N r B C gcd N r A mod M = B mod M
224 31 223 sylbid A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k N = A C B C A mod M = B mod M
225 224 ex A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k N = A C B C A mod M = B mod M
226 225 rexlimdvva A B C N M = N C gcd N k r s C = C gcd N r N = C gcd N s r gcd s = 1 k N = A C B C A mod M = B mod M
227 22 226 mpd A B C N M = N C gcd N k k N = A C B C A mod M = B mod M
228 227 rexlimdva A B C N M = N C gcd N k k N = A C B C A mod M = B mod M
229 7 228 sylbid A B C N M = N C gcd N A C mod N = B C mod N A mod M = B mod M