Metamath Proof Explorer


Theorem modfzo0difsn

Description: For a number within a half-open range of nonnegative integers with one excluded integer there is a positive integer so that the number is equal to the sum of the positive integer and the excluded integer modulo the upper bound of the range. (Contributed by AV, 19-Mar-2021)

Ref Expression
Assertion modfzo0difsn J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N

Proof

Step Hyp Ref Expression
1 eldifi K 0 ..^ N J K 0 ..^ N
2 elfzoelz K 0 ..^ N K
3 2 zred K 0 ..^ N K
4 1 3 syl K 0 ..^ N J K
5 elfzoelz J 0 ..^ N J
6 5 zred J 0 ..^ N J
7 leloe K J K J K < J K = J
8 4 6 7 syl2anr J 0 ..^ N K 0 ..^ N J K J K < J K = J
9 elfzo0 K 0 ..^ N K 0 N K < N
10 elfzo0 J 0 ..^ N J 0 N J < N
11 nn0cn K 0 K
12 11 adantr K 0 K < N K
13 12 adantl J 0 N J < N K 0 K < N K
14 nn0cn J 0 J
15 14 3ad2ant1 J 0 N J < N J
16 15 adantr J 0 N J < N K 0 K < N J
17 nncn N N
18 17 3ad2ant2 J 0 N J < N N
19 18 adantr J 0 N J < N K 0 K < N N
20 13 16 19 subadd23d J 0 N J < N K 0 K < N K - J + N = K + N - J
21 simpl K 0 K < N K 0
22 nn0z J 0 J
23 nnz N N
24 znnsub J N J < N N J
25 22 23 24 syl2an J 0 N J < N N J
26 25 biimp3a J 0 N J < N N J
27 nn0nnaddcl K 0 N J K + N - J
28 21 26 27 syl2anr J 0 N J < N K 0 K < N K + N - J
29 20 28 eqeltrd J 0 N J < N K 0 K < N K - J + N
30 29 adantr J 0 N J < N K 0 K < N K < J K - J + N
31 simp2 J 0 N J < N N
32 31 adantr J 0 N J < N K 0 K < N N
33 32 adantr J 0 N J < N K 0 K < N K < J N
34 nn0re K 0 K
35 34 adantr K 0 K < N K
36 35 adantl J 0 N J < N K 0 K < N K
37 nn0re J 0 J
38 37 3ad2ant1 J 0 N J < N J
39 38 adantr J 0 N J < N K 0 K < N J
40 36 39 sublt0d J 0 N J < N K 0 K < N K J < 0 K < J
41 40 bicomd J 0 N J < N K 0 K < N K < J K J < 0
42 41 biimpa J 0 N J < N K 0 K < N K < J K J < 0
43 resubcl K J K J
44 35 38 43 syl2anr J 0 N J < N K 0 K < N K J
45 nnre N N
46 45 3ad2ant2 J 0 N J < N N
47 46 adantr J 0 N J < N K 0 K < N N
48 44 47 jca J 0 N J < N K 0 K < N K J N
49 48 adantr J 0 N J < N K 0 K < N K < J K J N
50 ltaddnegr K J N K J < 0 K - J + N < N
51 49 50 syl J 0 N J < N K 0 K < N K < J K J < 0 K - J + N < N
52 42 51 mpbid J 0 N J < N K 0 K < N K < J K - J + N < N
53 elfzo1 K - J + N 1 ..^ N K - J + N N K - J + N < N
54 30 33 52 53 syl3anbrc J 0 N J < N K 0 K < N K < J K - J + N 1 ..^ N
55 54 exp31 J 0 N J < N K 0 K < N K < J K - J + N 1 ..^ N
56 10 55 sylbi J 0 ..^ N K 0 K < N K < J K - J + N 1 ..^ N
57 56 com12 K 0 K < N J 0 ..^ N K < J K - J + N 1 ..^ N
58 57 3adant2 K 0 N K < N J 0 ..^ N K < J K - J + N 1 ..^ N
59 9 58 sylbi K 0 ..^ N J 0 ..^ N K < J K - J + N 1 ..^ N
60 1 59 syl K 0 ..^ N J J 0 ..^ N K < J K - J + N 1 ..^ N
61 60 impcom J 0 ..^ N K 0 ..^ N J K < J K - J + N 1 ..^ N
62 61 impcom K < J J 0 ..^ N K 0 ..^ N J K - J + N 1 ..^ N
63 oveq1 i = K - J + N i + J = K J + N + J
64 2 zcnd K 0 ..^ N K
65 64 adantr K 0 ..^ N J 0 N K
66 14 adantr J 0 N J
67 66 adantl K 0 ..^ N J 0 N J
68 17 adantl J 0 N N
69 68 adantl K 0 ..^ N J 0 N N
70 65 67 69 3jca K 0 ..^ N J 0 N K J N
71 70 ex K 0 ..^ N J 0 N K J N
72 1 71 syl K 0 ..^ N J J 0 N K J N
73 72 com12 J 0 N K 0 ..^ N J K J N
74 73 3adant3 J 0 N J < N K 0 ..^ N J K J N
75 10 74 sylbi J 0 ..^ N K 0 ..^ N J K J N
76 75 imp J 0 ..^ N K 0 ..^ N J K J N
77 76 adantl K < J J 0 ..^ N K 0 ..^ N J K J N
78 nppcan K J N K J + N + J = K + N
79 77 78 syl K < J J 0 ..^ N K 0 ..^ N J K J + N + J = K + N
80 63 79 sylan9eqr K < J J 0 ..^ N K 0 ..^ N J i = K - J + N i + J = K + N
81 80 oveq1d K < J J 0 ..^ N K 0 ..^ N J i = K - J + N i + J mod N = K + N mod N
82 81 eqeq2d K < J J 0 ..^ N K 0 ..^ N J i = K - J + N K = i + J mod N K = K + N mod N
83 9 biimpi K 0 ..^ N K 0 N K < N
84 83 a1d K 0 ..^ N J 0 ..^ N K 0 N K < N
85 1 84 syl K 0 ..^ N J J 0 ..^ N K 0 N K < N
86 85 impcom J 0 ..^ N K 0 ..^ N J K 0 N K < N
87 86 adantl K < J J 0 ..^ N K 0 ..^ N J K 0 N K < N
88 addmodidr K 0 N K < N K + N mod N = K
89 88 eqcomd K 0 N K < N K = K + N mod N
90 87 89 syl K < J J 0 ..^ N K 0 ..^ N J K = K + N mod N
91 62 82 90 rspcedvd K < J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
92 91 ex K < J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
93 eldifsn K 0 ..^ N J K 0 ..^ N K J
94 eqneqall K = J K J i 1 ..^ N K = i + J mod N
95 94 com12 K J K = J i 1 ..^ N K = i + J mod N
96 95 adantl K 0 ..^ N K J K = J i 1 ..^ N K = i + J mod N
97 93 96 sylbi K 0 ..^ N J K = J i 1 ..^ N K = i + J mod N
98 97 adantl J 0 ..^ N K 0 ..^ N J K = J i 1 ..^ N K = i + J mod N
99 98 com12 K = J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
100 92 99 jaoi K < J K = J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
101 100 com12 J 0 ..^ N K 0 ..^ N J K < J K = J i 1 ..^ N K = i + J mod N
102 8 101 sylbid J 0 ..^ N K 0 ..^ N J K J i 1 ..^ N K = i + J mod N
103 102 com12 K J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
104 ltnle J K J < K ¬ K J
105 6 4 104 syl2an J 0 ..^ N K 0 ..^ N J J < K ¬ K J
106 105 bicomd J 0 ..^ N K 0 ..^ N J ¬ K J J < K
107 22 3ad2ant1 J 0 N J < N J
108 nn0z K 0 K
109 108 adantr K 0 K < N K
110 znnsub J K J < K K J
111 107 109 110 syl2anr K 0 K < N J 0 N J < N J < K K J
112 111 biimpa K 0 K < N J 0 N J < N J < K K J
113 31 adantl K 0 K < N J 0 N J < N N
114 113 adantr K 0 K < N J 0 N J < N J < K N
115 nn0ge0 J 0 0 J
116 115 3ad2ant1 J 0 N J < N 0 J
117 116 adantl K 0 J 0 N J < N 0 J
118 subge02 K J 0 J K J K
119 34 38 118 syl2an K 0 J 0 N J < N 0 J K J K
120 117 119 mpbid K 0 J 0 N J < N K J K
121 38 adantl K 0 J 0 N J < N J
122 34 adantr K 0 J 0 N J < N K
123 46 adantl K 0 J 0 N J < N N
124 121 122 123 3jca K 0 J 0 N J < N J K N
125 43 ancoms J K K J
126 125 3adant3 J K N K J
127 simp2 J K N K
128 simp3 J K N N
129 126 127 128 3jca J K N K J K N
130 124 129 syl K 0 J 0 N J < N K J K N
131 lelttr K J K N K J K K < N K J < N
132 130 131 syl K 0 J 0 N J < N K J K K < N K J < N
133 120 132 mpand K 0 J 0 N J < N K < N K J < N
134 133 impancom K 0 K < N J 0 N J < N K J < N
135 134 imp K 0 K < N J 0 N J < N K J < N
136 135 adantr K 0 K < N J 0 N J < N J < K K J < N
137 112 114 136 3jca K 0 K < N J 0 N J < N J < K K J N K J < N
138 137 exp31 K 0 K < N J 0 N J < N J < K K J N K J < N
139 138 3adant2 K 0 N K < N J 0 N J < N J < K K J N K J < N
140 9 139 sylbi K 0 ..^ N J 0 N J < N J < K K J N K J < N
141 1 140 syl K 0 ..^ N J J 0 N J < N J < K K J N K J < N
142 141 com12 J 0 N J < N K 0 ..^ N J J < K K J N K J < N
143 10 142 sylbi J 0 ..^ N K 0 ..^ N J J < K K J N K J < N
144 143 imp J 0 ..^ N K 0 ..^ N J J < K K J N K J < N
145 106 144 sylbid J 0 ..^ N K 0 ..^ N J ¬ K J K J N K J < N
146 145 impcom ¬ K J J 0 ..^ N K 0 ..^ N J K J N K J < N
147 elfzo1 K J 1 ..^ N K J N K J < N
148 146 147 sylibr ¬ K J J 0 ..^ N K 0 ..^ N J K J 1 ..^ N
149 oveq1 i = K J i + J = K - J + J
150 1 64 syl K 0 ..^ N J K
151 5 zcnd J 0 ..^ N J
152 npcan K J K - J + J = K
153 150 151 152 syl2anr J 0 ..^ N K 0 ..^ N J K - J + J = K
154 153 adantl ¬ K J J 0 ..^ N K 0 ..^ N J K - J + J = K
155 149 154 sylan9eqr ¬ K J J 0 ..^ N K 0 ..^ N J i = K J i + J = K
156 155 oveq1d ¬ K J J 0 ..^ N K 0 ..^ N J i = K J i + J mod N = K mod N
157 156 eqeq2d ¬ K J J 0 ..^ N K 0 ..^ N J i = K J K = i + J mod N K = K mod N
158 zmodidfzoimp K 0 ..^ N K mod N = K
159 1 158 syl K 0 ..^ N J K mod N = K
160 159 adantl J 0 ..^ N K 0 ..^ N J K mod N = K
161 160 adantl ¬ K J J 0 ..^ N K 0 ..^ N J K mod N = K
162 161 eqcomd ¬ K J J 0 ..^ N K 0 ..^ N J K = K mod N
163 148 157 162 rspcedvd ¬ K J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
164 163 ex ¬ K J J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N
165 103 164 pm2.61i J 0 ..^ N K 0 ..^ N J i 1 ..^ N K = i + J mod N