Metamath Proof Explorer


Theorem sticksstones11

Description: Establish bijective mapping between strictly monotone functions and functions that sum to a fixed non-negative integer. (Contributed by metakunt, 6-Oct-2024)

Ref Expression
Hypotheses sticksstones11.1 φ N 0
sticksstones11.2 φ K = 0
sticksstones11.3 F = a A j 1 K j + l = 1 j a l
sticksstones11.4 G = b B if K = 0 1 N k 1 K + 1 if k = K + 1 N + K - b K if k = 1 b 1 1 b k - b k 1 - 1
sticksstones11.5 A = g | g : 1 K + 1 0 i = 1 K + 1 g i = N
sticksstones11.6 B = f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
Assertion sticksstones11 φ F : A 1-1 onto B

Proof

Step Hyp Ref Expression
1 sticksstones11.1 φ N 0
2 sticksstones11.2 φ K = 0
3 sticksstones11.3 F = a A j 1 K j + l = 1 j a l
4 sticksstones11.4 G = b B if K = 0 1 N k 1 K + 1 if k = K + 1 N + K - b K if k = 1 b 1 1 b k - b k 1 - 1
5 sticksstones11.5 A = g | g : 1 K + 1 0 i = 1 K + 1 g i = N
6 sticksstones11.6 B = f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
7 0nn0 0 0
8 7 a1i φ 0 0
9 2 8 eqeltrd φ K 0
10 1 9 3 5 6 sticksstones8 φ F : A B
11 1 2 4 5 6 sticksstones9 φ G : B A
12 5 a1i φ A = g | g : 1 K + 1 0 i = 1 K + 1 g i = N
13 nfv u φ
14 nfcv _ u g | g : 1 K + 1 0 i = 1 K + 1 g i = N
15 nfcv _ u 1 N
16 ffn u : 1 0 u Fn 1
17 16 ad2antrl φ u : 1 0 i 1 u i = N u Fn 1
18 1nn 1
19 18 a1i φ u : 1 0 i 1 u i = N 1
20 1 adantr φ u : 1 0 i 1 u i = N N 0
21 fnsng 1 N 0 1 N Fn 1
22 19 20 21 syl2anc φ u : 1 0 i 1 u i = N 1 N Fn 1
23 elsni p 1 p = 1
24 23 adantl φ u : 1 0 i 1 u i = N p 1 p = 1
25 simpr φ u : 1 0 i 1 u i = N p 1 p = 1 p = 1
26 25 fveq2d φ u : 1 0 i 1 u i = N p 1 p = 1 u p = u 1
27 simprl φ u : 1 0 i 1 u i = N u : 1 0
28 1ex 1 V
29 28 snid 1 1
30 29 a1i φ u : 1 0 i 1 u i = N 1 1
31 27 30 ffvelrnd φ u : 1 0 i 1 u i = N u 1 0
32 31 nn0cnd φ u : 1 0 i 1 u i = N u 1
33 fveq2 i = 1 u i = u 1
34 33 sumsn 1 u 1 i 1 u i = u 1
35 19 32 34 syl2anc φ u : 1 0 i 1 u i = N i 1 u i = u 1
36 35 adantr φ u : 1 0 i 1 u i = N i 1 u i = u 1 i 1 u i = u 1
37 36 eqcomd φ u : 1 0 i 1 u i = N i 1 u i = u 1 u 1 = i 1 u i
38 simplrr φ u : 1 0 i 1 u i = N i 1 u i = u 1 i 1 u i = N
39 37 38 eqtrd φ u : 1 0 i 1 u i = N i 1 u i = u 1 u 1 = N
40 39 ex φ u : 1 0 i 1 u i = N i 1 u i = u 1 u 1 = N
41 35 40 mpd φ u : 1 0 i 1 u i = N u 1 = N
42 41 adantr φ u : 1 0 i 1 u i = N p 1 u 1 = N
43 18 a1i φ u : 1 0 i 1 u i = N p 1 1
44 20 adantr φ u : 1 0 i 1 u i = N p 1 N 0
45 fvsng 1 N 0 1 N 1 = N
46 43 44 45 syl2anc φ u : 1 0 i 1 u i = N p 1 1 N 1 = N
47 46 eqcomd φ u : 1 0 i 1 u i = N p 1 N = 1 N 1
48 42 47 eqtrd φ u : 1 0 i 1 u i = N p 1 u 1 = 1 N 1
49 48 adantr φ u : 1 0 i 1 u i = N p 1 p = 1 u 1 = 1 N 1
50 25 eqcomd φ u : 1 0 i 1 u i = N p 1 p = 1 1 = p
51 50 fveq2d φ u : 1 0 i 1 u i = N p 1 p = 1 1 N 1 = 1 N p
52 26 49 51 3eqtrd φ u : 1 0 i 1 u i = N p 1 p = 1 u p = 1 N p
53 24 52 mpdan φ u : 1 0 i 1 u i = N p 1 u p = 1 N p
54 17 22 53 eqfnfvd φ u : 1 0 i 1 u i = N u = 1 N
55 fsng 1 N 0 u : 1 N u = 1 N
56 19 20 55 syl2anc φ u : 1 0 i 1 u i = N u : 1 N u = 1 N
57 54 56 mpbird φ u : 1 0 i 1 u i = N u : 1 N
58 ssidd φ u : 1 0 i 1 u i = N N N
59 fss u : 1 N N N u : 1 N
60 57 58 59 syl2anc φ u : 1 0 i 1 u i = N u : 1 N
61 60 58 59 syl2anc φ u : 1 0 i 1 u i = N u : 1 N
62 61 56 mpbid φ u : 1 0 i 1 u i = N u = 1 N
63 vex u V
64 63 elsn u 1 N u = 1 N
65 62 64 sylibr φ u : 1 0 i 1 u i = N u 1 N
66 65 ex φ u : 1 0 i 1 u i = N u 1 N
67 1zzd φ 1
68 fzsn 1 1 1 = 1
69 67 68 syl φ 1 1 = 1
70 69 eqcomd φ 1 = 1 1
71 1e0p1 1 = 0 + 1
72 71 a1i φ 1 = 0 + 1
73 72 oveq2d φ 1 1 = 1 0 + 1
74 70 73 eqtrd φ 1 = 1 0 + 1
75 2 eqcomd φ 0 = K
76 75 oveq1d φ 0 + 1 = K + 1
77 76 oveq2d φ 1 0 + 1 = 1 K + 1
78 74 77 eqtrd φ 1 = 1 K + 1
79 78 feq2d φ u : 1 0 u : 1 K + 1 0
80 78 sumeq1d φ i 1 u i = i = 1 K + 1 u i
81 80 eqeq1d φ i 1 u i = N i = 1 K + 1 u i = N
82 79 81 anbi12d φ u : 1 0 i 1 u i = N u : 1 K + 1 0 i = 1 K + 1 u i = N
83 82 imbi1d φ u : 1 0 i 1 u i = N u 1 N u : 1 K + 1 0 i = 1 K + 1 u i = N u 1 N
84 66 83 mpbid φ u : 1 K + 1 0 i = 1 K + 1 u i = N u 1 N
85 feq1 g = u g : 1 K + 1 0 u : 1 K + 1 0
86 simpl g = u i 1 K + 1 g = u
87 86 fveq1d g = u i 1 K + 1 g i = u i
88 87 sumeq2dv g = u i = 1 K + 1 g i = i = 1 K + 1 u i
89 88 eqeq1d g = u i = 1 K + 1 g i = N i = 1 K + 1 u i = N
90 85 89 anbi12d g = u g : 1 K + 1 0 i = 1 K + 1 g i = N u : 1 K + 1 0 i = 1 K + 1 u i = N
91 63 90 elab u g | g : 1 K + 1 0 i = 1 K + 1 g i = N u : 1 K + 1 0 i = 1 K + 1 u i = N
92 91 a1i φ u g | g : 1 K + 1 0 i = 1 K + 1 g i = N u : 1 K + 1 0 i = 1 K + 1 u i = N
93 92 imbi1d φ u g | g : 1 K + 1 0 i = 1 K + 1 g i = N u 1 N u : 1 K + 1 0 i = 1 K + 1 u i = N u 1 N
94 84 93 mpbird φ u g | g : 1 K + 1 0 i = 1 K + 1 g i = N u 1 N
95 94 imp φ u g | g : 1 K + 1 0 i = 1 K + 1 g i = N u 1 N
96 95 ex φ u g | g : 1 K + 1 0 i = 1 K + 1 g i = N u 1 N
97 13 14 15 96 ssrd φ g | g : 1 K + 1 0 i = 1 K + 1 g i = N 1 N
98 18 a1i φ 1
99 98 1 55 syl2anc φ u : 1 N u = 1 N
100 99 bicomd φ u = 1 N u : 1 N
101 100 biimpd φ u = 1 N u : 1 N
102 elsni u 1 N u = 1 N
103 101 102 impel φ u 1 N u : 1 N
104 1 snssd φ N 0
105 104 adantr φ u 1 N N 0
106 fss u : 1 N N 0 u : 1 0
107 103 105 106 syl2anc φ u 1 N u : 1 0
108 79 adantr φ u 1 N u : 1 0 u : 1 K + 1 0
109 107 108 mpbid φ u 1 N u : 1 K + 1 0
110 102 adantl φ u 1 N u = 1 N
111 78 3ad2ant1 φ u 1 N u = 1 N 1 = 1 K + 1
112 111 eqcomd φ u 1 N u = 1 N 1 K + 1 = 1
113 112 sumeq1d φ u 1 N u = 1 N i = 1 K + 1 u i = i 1 u i
114 18 a1i φ u 1 N u = 1 N 1
115 1 3ad2ant1 φ u 1 N u = 1 N N 0
116 115 nn0cnd φ u 1 N u = 1 N N
117 114 115 45 syl2anc φ u 1 N u = 1 N 1 N 1 = N
118 117 eqcomd φ u 1 N u = 1 N N = 1 N 1
119 110 3adant3 φ u 1 N u = 1 N u = 1 N
120 119 fveq1d φ u 1 N u = 1 N u 1 = 1 N 1
121 118 120 eqtr4d φ u 1 N u = 1 N N = u 1
122 121 eleq1d φ u 1 N u = 1 N N u 1
123 116 122 mpbid φ u 1 N u = 1 N u 1
124 114 123 34 syl2anc φ u 1 N u = 1 N i 1 u i = u 1
125 120 117 eqtrd φ u 1 N u = 1 N u 1 = N
126 124 125 eqtrd φ u 1 N u = 1 N i 1 u i = N
127 113 126 eqtrd φ u 1 N u = 1 N i = 1 K + 1 u i = N
128 127 3expa φ u 1 N u = 1 N i = 1 K + 1 u i = N
129 110 128 mpdan φ u 1 N i = 1 K + 1 u i = N
130 109 129 jca φ u 1 N u : 1 K + 1 0 i = 1 K + 1 u i = N
131 130 91 sylibr φ u 1 N u g | g : 1 K + 1 0 i = 1 K + 1 g i = N
132 131 ex φ u 1 N u g | g : 1 K + 1 0 i = 1 K + 1 g i = N
133 13 15 14 132 ssrd φ 1 N g | g : 1 K + 1 0 i = 1 K + 1 g i = N
134 97 133 eqssd φ g | g : 1 K + 1 0 i = 1 K + 1 g i = N = 1 N
135 12 134 eqtrd φ A = 1 N
136 eqss A = 1 N A 1 N 1 N A
137 136 biimpi A = 1 N A 1 N 1 N A
138 137 simpld A = 1 N A 1 N
139 135 138 syl φ A 1 N
140 fss G : B A A 1 N G : B 1 N
141 11 139 140 syl2anc φ G : B 1 N
142 141 adantr φ c A G : B 1 N
143 10 ffvelrnda φ c A F c B
144 fvconst G : B 1 N F c B G F c = 1 N
145 142 143 144 syl2anc φ c A G F c = 1 N
146 135 eleq2d φ c A c 1 N
147 146 biimpd φ c A c 1 N
148 147 imp φ c A c 1 N
149 vex c V
150 149 elsn c 1 N c = 1 N
151 148 150 sylib φ c A c = 1 N
152 151 eqcomd φ c A 1 N = c
153 145 152 eqtrd φ c A G F c = c
154 153 ralrimiva φ c A G F c = c
155 simpr φ d B d B
156 nfv d φ
157 nfcv _ d B
158 nfcv _ d
159 6 a1i φ d B B = f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
160 159 eleq2d φ d B d B d f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
161 160 biimpd φ d B d B d f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
162 161 syldbl2 φ d B d f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
163 vex d V
164 feq1 f = d f : 1 K 1 N + K d : 1 K 1 N + K
165 fveq1 f = d f x = d x
166 fveq1 f = d f y = d y
167 165 166 breq12d f = d f x < f y d x < d y
168 167 imbi2d f = d x < y f x < f y x < y d x < d y
169 168 2ralbidv f = d x 1 K y 1 K x < y f x < f y x 1 K y 1 K x < y d x < d y
170 164 169 anbi12d f = d f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y d : 1 K 1 N + K x 1 K y 1 K x < y d x < d y
171 163 170 elab d f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y d : 1 K 1 N + K x 1 K y 1 K x < y d x < d y
172 162 171 sylib φ d B d : 1 K 1 N + K x 1 K y 1 K x < y d x < d y
173 172 simpld φ d B d : 1 K 1 N + K
174 0lt1 0 < 1
175 174 a1i φ 0 < 1
176 2 175 eqbrtrd φ K < 1
177 9 nn0zd φ K
178 fzn 1 K K < 1 1 K =
179 67 177 178 syl2anc φ K < 1 1 K =
180 176 179 mpbid φ 1 K =
181 180 feq2d φ d : 1 K 1 N + K d : 1 N + K
182 181 adantr φ d B d : 1 K 1 N + K d : 1 N + K
183 173 182 mpbid φ d B d : 1 N + K
184 f0bi d : 1 N + K d =
185 183 184 sylib φ d B d =
186 velsn d d =
187 185 186 sylibr φ d B d
188 187 ex φ d B d
189 f0 : 1 N + K
190 189 a1i φ : 1 N + K
191 180 feq2d φ : 1 K 1 N + K : 1 N + K
192 190 191 mpbird φ : 1 K 1 N + K
193 ral0 x y 1 K x < y x < y
194 193 a1i φ x y 1 K x < y x < y
195 biidd φ x 1 K y 1 K x < y x < y y 1 K x < y x < y
196 180 195 raleqbidva φ x 1 K y 1 K x < y x < y x y 1 K x < y x < y
197 194 196 mpbird φ x 1 K y 1 K x < y x < y
198 192 197 jca φ : 1 K 1 N + K x 1 K y 1 K x < y x < y
199 0ex V
200 feq1 f = f : 1 K 1 N + K : 1 K 1 N + K
201 fveq1 f = f x = x
202 fveq1 f = f y = y
203 201 202 breq12d f = f x < f y x < y
204 203 imbi2d f = x < y f x < f y x < y x < y
205 204 2ralbidv f = x 1 K y 1 K x < y f x < f y x 1 K y 1 K x < y x < y
206 200 205 anbi12d f = f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y : 1 K 1 N + K x 1 K y 1 K x < y x < y
207 206 elabg V f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y : 1 K 1 N + K x 1 K y 1 K x < y x < y
208 199 207 ax-mp f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y : 1 K 1 N + K x 1 K y 1 K x < y x < y
209 198 208 sylibr φ f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
210 6 a1i φ B = f | f : 1 K 1 N + K x 1 K y 1 K x < y f x < f y
211 209 210 eleqtrrd φ B
212 211 adantr φ d B
213 elsni d d =
214 213 adantl φ d d =
215 214 eleq1d φ d d B B
216 212 215 mpbird φ d d B
217 216 ex φ d d B
218 188 217 impbid φ d B d
219 156 157 158 218 eqrd φ B =
220 219 adantr φ d B B =
221 155 220 eleqtrd φ d B d
222 163 elsn d d =
223 221 222 sylib φ d B d =
224 223 fveq2d φ d B G d = G
225 224 fveq2d φ d B F G d = F G
226 180 adantr φ a A 1 K =
227 226 mpteq1d φ a A j 1 K j + l = 1 j a l = j j + l = 1 j a l
228 mpt0 j j + l = 1 j a l =
229 228 a1i φ a A j j + l = 1 j a l =
230 227 229 eqtrd φ a A j 1 K j + l = 1 j a l =
231 fzfid φ 1 K Fin
232 231 mptexd φ j 1 K j + l = 1 j a l V
233 elsng j 1 K j + l = 1 j a l V j 1 K j + l = 1 j a l j 1 K j + l = 1 j a l =
234 232 233 syl φ j 1 K j + l = 1 j a l j 1 K j + l = 1 j a l =
235 234 adantr φ a A j 1 K j + l = 1 j a l j 1 K j + l = 1 j a l =
236 230 235 mpbird φ a A j 1 K j + l = 1 j a l
237 236 3 fmptd φ F : A
238 237 adantr φ d B F : A
239 ffvelrn G : B A B G A
240 11 211 239 syl2anc φ G A
241 240 adantr φ d B G A
242 fvconst F : A G A F G =
243 238 241 242 syl2anc φ d B F G =
244 225 243 eqtrd φ d B F G d =
245 223 eqcomd φ d B = d
246 244 245 eqtrd φ d B F G d = d
247 246 ralrimiva φ d B F G d = d
248 10 11 154 247 2fvidf1od φ F : A 1-1 onto B