Metamath Proof Explorer


Theorem addmodlteq

Description: Two nonnegative integers less than the modulus are equal iff the sums of these integer with another integer are equal modulo the modulus. A much shorter proof exists if the "divides" relation || can be used, see addmodlteqALT . (Contributed by AV, 20-Mar-2021)

Ref Expression
Assertion addmodlteq I 0 ..^ N J 0 ..^ N S I + S mod N = J + S mod N I = J

Proof

Step Hyp Ref Expression
1 elfzoelz I 0 ..^ N I
2 1 zred I 0 ..^ N I
3 2 3ad2ant1 I 0 ..^ N J 0 ..^ N S I
4 simp3 I 0 ..^ N J 0 ..^ N S S
5 4 zred I 0 ..^ N J 0 ..^ N S S
6 elfzo0 I 0 ..^ N I 0 N I < N
7 6 simp2bi I 0 ..^ N N
8 7 nnrpd I 0 ..^ N N +
9 8 3ad2ant1 I 0 ..^ N J 0 ..^ N S N +
10 modaddmod I S N + I mod N + S mod N = I + S mod N
11 3 5 9 10 syl3anc I 0 ..^ N J 0 ..^ N S I mod N + S mod N = I + S mod N
12 11 eqcomd I 0 ..^ N J 0 ..^ N S I + S mod N = I mod N + S mod N
13 elfzoelz J 0 ..^ N J
14 13 zred J 0 ..^ N J
15 14 3ad2ant2 I 0 ..^ N J 0 ..^ N S J
16 modaddmod J S N + J mod N + S mod N = J + S mod N
17 15 5 9 16 syl3anc I 0 ..^ N J 0 ..^ N S J mod N + S mod N = J + S mod N
18 17 eqcomd I 0 ..^ N J 0 ..^ N S J + S mod N = J mod N + S mod N
19 12 18 eqeq12d I 0 ..^ N J 0 ..^ N S I + S mod N = J + S mod N I mod N + S mod N = J mod N + S mod N
20 nn0re I 0 I
21 nnrp N N +
22 20 21 anim12i I 0 N I N +
23 22 3adant3 I 0 N I < N I N +
24 modcl I N + I mod N
25 23 24 syl I 0 N I < N I mod N
26 6 25 sylbi I 0 ..^ N I mod N
27 26 3ad2ant1 I 0 ..^ N J 0 ..^ N S I mod N
28 27 5 readdcld I 0 ..^ N J 0 ..^ N S I mod N + S
29 modcl I mod N + S N + I mod N + S mod N
30 29 recnd I mod N + S N + I mod N + S mod N
31 28 9 30 syl2anc I 0 ..^ N J 0 ..^ N S I mod N + S mod N
32 elfzo0 J 0 ..^ N J 0 N J < N
33 nn0re J 0 J
34 33 21 anim12i J 0 N J N +
35 34 3adant3 J 0 N J < N J N +
36 modcl J N + J mod N
37 35 36 syl J 0 N J < N J mod N
38 32 37 sylbi J 0 ..^ N J mod N
39 38 3ad2ant2 I 0 ..^ N J 0 ..^ N S J mod N
40 39 5 readdcld I 0 ..^ N J 0 ..^ N S J mod N + S
41 modcl J mod N + S N + J mod N + S mod N
42 41 recnd J mod N + S N + J mod N + S mod N
43 40 9 42 syl2anc I 0 ..^ N J 0 ..^ N S J mod N + S mod N
44 31 43 subeq0ad I 0 ..^ N J 0 ..^ N S I mod N + S mod N J mod N + S mod N = 0 I mod N + S mod N = J mod N + S mod N
45 oveq1 I mod N + S mod N J mod N + S mod N = 0 I mod N + S mod N J mod N + S mod N mod N = 0 mod N
46 modsubmodmod I mod N + S J mod N + S N + I mod N + S mod N J mod N + S mod N mod N = I mod N + S - J mod N + S mod N
47 28 40 9 46 syl3anc I 0 ..^ N J 0 ..^ N S I mod N + S mod N J mod N + S mod N mod N = I mod N + S - J mod N + S mod N
48 26 recnd I 0 ..^ N I mod N
49 48 3ad2ant1 I 0 ..^ N J 0 ..^ N S I mod N
50 38 recnd J 0 ..^ N J mod N
51 50 3ad2ant2 I 0 ..^ N J 0 ..^ N S J mod N
52 4 zcnd I 0 ..^ N J 0 ..^ N S S
53 49 51 52 pnpcan2d I 0 ..^ N J 0 ..^ N S I mod N + S - J mod N + S = I mod N J mod N
54 53 oveq1d I 0 ..^ N J 0 ..^ N S I mod N + S - J mod N + S mod N = I mod N J mod N mod N
55 47 54 eqtrd I 0 ..^ N J 0 ..^ N S I mod N + S mod N J mod N + S mod N mod N = I mod N J mod N mod N
56 32 simp2bi J 0 ..^ N N
57 56 nnrpd J 0 ..^ N N +
58 0mod N + 0 mod N = 0
59 57 58 syl J 0 ..^ N 0 mod N = 0
60 59 3ad2ant2 I 0 ..^ N J 0 ..^ N S 0 mod N = 0
61 55 60 eqeq12d I 0 ..^ N J 0 ..^ N S I mod N + S mod N J mod N + S mod N mod N = 0 mod N I mod N J mod N mod N = 0
62 zmodidfzoimp I 0 ..^ N I mod N = I
63 62 3ad2ant1 I 0 ..^ N J 0 ..^ N S I mod N = I
64 zmodidfzoimp J 0 ..^ N J mod N = J
65 64 3ad2ant2 I 0 ..^ N J 0 ..^ N S J mod N = J
66 63 65 oveq12d I 0 ..^ N J 0 ..^ N S I mod N J mod N = I J
67 66 oveq1d I 0 ..^ N J 0 ..^ N S I mod N J mod N mod N = I J mod N
68 67 eqeq1d I 0 ..^ N J 0 ..^ N S I mod N J mod N mod N = 0 I J mod N = 0
69 zsubcl I J I J
70 1 13 69 syl2an I 0 ..^ N J 0 ..^ N I J
71 70 zred I 0 ..^ N J 0 ..^ N I J
72 8 adantr I 0 ..^ N J 0 ..^ N N +
73 mod0 I J N + I J mod N = 0 I J N
74 71 72 73 syl2anc I 0 ..^ N J 0 ..^ N I J mod N = 0 I J N
75 zdiv N I J k N k = I J I J N
76 7 70 75 syl2an2r I 0 ..^ N J 0 ..^ N k N k = I J I J N
77 oveq2 k = 0 N k = N 0
78 elfzoel2 I 0 ..^ N N
79 78 zcnd I 0 ..^ N N
80 79 mul01d I 0 ..^ N N 0 = 0
81 80 adantr I 0 ..^ N J 0 ..^ N N 0 = 0
82 81 adantr I 0 ..^ N J 0 ..^ N k N 0 = 0
83 77 82 sylan9eq k = 0 I 0 ..^ N J 0 ..^ N k N k = 0
84 83 eqeq1d k = 0 I 0 ..^ N J 0 ..^ N k N k = I J 0 = I J
85 eqcom 0 = I J I J = 0
86 1 zcnd I 0 ..^ N I
87 13 zcnd J 0 ..^ N J
88 subeq0 I J I J = 0 I = J
89 86 87 88 syl2an I 0 ..^ N J 0 ..^ N I J = 0 I = J
90 89 biimpd I 0 ..^ N J 0 ..^ N I J = 0 I = J
91 85 90 syl5bi I 0 ..^ N J 0 ..^ N 0 = I J I = J
92 91 adantr I 0 ..^ N J 0 ..^ N k 0 = I J I = J
93 92 adantl k = 0 I 0 ..^ N J 0 ..^ N k 0 = I J I = J
94 84 93 sylbid k = 0 I 0 ..^ N J 0 ..^ N k N k = I J I = J
95 94 ex k = 0 I 0 ..^ N J 0 ..^ N k N k = I J I = J
96 subfzo0 I 0 ..^ N J 0 ..^ N N < I J I J < N
97 96 adantr I 0 ..^ N J 0 ..^ N k N < I J I J < N
98 elz k k k = 0 k k
99 pm2.24 k = 0 ¬ k = 0 N k = I J I = J
100 99 a1d k = 0 N < I J I J < N ¬ k = 0 N k = I J I = J
101 100 2a1d k = 0 k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
102 breq1 N k = I J N k < N I J < N
103 nncn N N
104 103 mulid1d N N 1 = N
105 104 adantr N k N 1 = N
106 105 eqcomd N k N = N 1
107 106 breq2d N k N k < N N k < N 1
108 nnre k k
109 108 adantl N k k
110 1red N k 1
111 21 adantr N k N +
112 109 110 111 ltmul2d N k k < 1 N k < N 1
113 nnge1 k 1 k
114 1red k 1
115 114 108 lenltd k 1 k ¬ k < 1
116 pm2.21 ¬ k < 1 k < 1 I = J
117 115 116 syl6bi k 1 k k < 1 I = J
118 113 117 mpd k k < 1 I = J
119 118 adantl N k k < 1 I = J
120 112 119 sylbird N k N k < N 1 I = J
121 107 120 sylbid N k N k < N I = J
122 121 ex N k N k < N I = J
123 122 3ad2ant2 J 0 N J < N k N k < N I = J
124 32 123 sylbi J 0 ..^ N k N k < N I = J
125 124 adantl I 0 ..^ N J 0 ..^ N k N k < N I = J
126 125 com13 N k < N k I 0 ..^ N J 0 ..^ N I = J
127 126 a1dd N k < N k ¬ k = 0 I 0 ..^ N J 0 ..^ N I = J
128 102 127 syl6bir N k = I J I J < N k ¬ k = 0 I 0 ..^ N J 0 ..^ N I = J
129 128 com15 I 0 ..^ N J 0 ..^ N I J < N k ¬ k = 0 N k = I J I = J
130 129 com12 I J < N I 0 ..^ N J 0 ..^ N k ¬ k = 0 N k = I J I = J
131 130 adantl N < I J I J < N I 0 ..^ N J 0 ..^ N k ¬ k = 0 N k = I J I = J
132 131 com13 k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
133 132 a1d k k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
134 breq2 N k = I J N < N k N < I J
135 nnre N N
136 simpr k k k
137 remulcl N k N k
138 135 136 137 syl2an N k k N k
139 135 adantr N k k N
140 138 139 possumd N k k 0 < N k + N N < N k
141 103 adantr N k k N
142 141 mulid1d N k k N 1 = N
143 142 eqcomd N k k N = N 1
144 143 oveq2d N k k N k + N = N k + N 1
145 recn k k
146 145 adantl k k k
147 146 adantl N k k k
148 1cnd N k k 1
149 141 147 148 adddid N k k N k + 1 = N k + N 1
150 144 149 eqtr4d N k k N k + N = N k + 1
151 150 breq2d N k k 0 < N k + N 0 < N k + 1
152 peano2re k k + 1
153 152 adantl k k k + 1
154 153 adantl N k k k + 1
155 139 154 remulcld N k k N k + 1
156 0red N k k 0
157 nnnn0 N N 0
158 157 nn0ge0d N 0 N
159 nnge1 k 1 k
160 id k k
161 1cnd k 1
162 160 161 addcomd k k + 1 = 1 + k
163 161 160 subnegd k 1 k = 1 + k
164 162 163 eqtr4d k k + 1 = 1 k
165 145 164 syl k k + 1 = 1 k
166 165 adantl 1 k k k + 1 = 1 k
167 1red k 1
168 renegcl k k
169 167 168 suble0d k 1 k 0 1 k
170 169 biimparc 1 k k 1 k 0
171 166 170 eqbrtrd 1 k k k + 1 0
172 159 171 sylan k k k + 1 0
173 158 172 anim12i N k k 0 N k + 1 0
174 173 olcd N k k N 0 0 k + 1 0 N k + 1 0
175 mulle0b N k + 1 N k + 1 0 N 0 0 k + 1 0 N k + 1 0
176 135 153 175 syl2an N k k N k + 1 0 N 0 0 k + 1 0 N k + 1 0
177 174 176 mpbird N k k N k + 1 0
178 155 156 177 lensymd N k k ¬ 0 < N k + 1
179 178 pm2.21d N k k 0 < N k + 1 I = J
180 151 179 sylbid N k k 0 < N k + N I = J
181 140 180 sylbird N k k N < N k I = J
182 181 a1d N k k ¬ k = 0 N < N k I = J
183 182 ex N k k ¬ k = 0 N < N k I = J
184 183 3ad2ant2 I 0 N I < N k k ¬ k = 0 N < N k I = J
185 6 184 sylbi I 0 ..^ N k k ¬ k = 0 N < N k I = J
186 185 adantr I 0 ..^ N J 0 ..^ N k k ¬ k = 0 N < N k I = J
187 186 com14 N < N k k k ¬ k = 0 I 0 ..^ N J 0 ..^ N I = J
188 134 187 syl6bir N k = I J N < I J k k ¬ k = 0 I 0 ..^ N J 0 ..^ N I = J
189 188 com15 I 0 ..^ N J 0 ..^ N N < I J k k ¬ k = 0 N k = I J I = J
190 189 com12 N < I J I 0 ..^ N J 0 ..^ N k k ¬ k = 0 N k = I J I = J
191 190 adantr N < I J I J < N I 0 ..^ N J 0 ..^ N k k ¬ k = 0 N k = I J I = J
192 191 com13 k k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
193 192 ex k k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
194 101 133 193 3jaoi k = 0 k k k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
195 194 impcom k k = 0 k k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
196 98 195 sylbi k I 0 ..^ N J 0 ..^ N N < I J I J < N ¬ k = 0 N k = I J I = J
197 196 impcom I 0 ..^ N J 0 ..^ N k N < I J I J < N ¬ k = 0 N k = I J I = J
198 97 197 mpd I 0 ..^ N J 0 ..^ N k ¬ k = 0 N k = I J I = J
199 198 com12 ¬ k = 0 I 0 ..^ N J 0 ..^ N k N k = I J I = J
200 95 199 pm2.61i I 0 ..^ N J 0 ..^ N k N k = I J I = J
201 200 rexlimdva I 0 ..^ N J 0 ..^ N k N k = I J I = J
202 76 201 sylbird I 0 ..^ N J 0 ..^ N I J N I = J
203 74 202 sylbid I 0 ..^ N J 0 ..^ N I J mod N = 0 I = J
204 203 3adant3 I 0 ..^ N J 0 ..^ N S I J mod N = 0 I = J
205 68 204 sylbid I 0 ..^ N J 0 ..^ N S I mod N J mod N mod N = 0 I = J
206 61 205 sylbid I 0 ..^ N J 0 ..^ N S I mod N + S mod N J mod N + S mod N mod N = 0 mod N I = J
207 45 206 syl5 I 0 ..^ N J 0 ..^ N S I mod N + S mod N J mod N + S mod N = 0 I = J
208 44 207 sylbird I 0 ..^ N J 0 ..^ N S I mod N + S mod N = J mod N + S mod N I = J
209 19 208 sylbid I 0 ..^ N J 0 ..^ N S I + S mod N = J + S mod N I = J
210 oveq1 I = J I + S = J + S
211 210 oveq1d I = J I + S mod N = J + S mod N
212 209 211 impbid1 I 0 ..^ N J 0 ..^ N S I + S mod N = J + S mod N I = J