Metamath Proof Explorer


Theorem hashf1

Description: The permutation number | A | ! x. ( | B | _C | A | ) = | B | ! / ( | B | - | A | ) ! counts the number of injections from A to B . (Contributed by Mario Carneiro, 21-Jan-2015)

Ref Expression
Assertion hashf1 AFinBFinf|f:A1-1B=A!(BA)

Proof

Step Hyp Ref Expression
1 f1eq2 x=f:x1-1Bf:1-1B
2 f1fn f:1-1BfFn
3 fn0 fFnf=
4 2 3 sylib f:1-1Bf=
5 f10 :1-1B
6 f1eq1 f=f:1-1B:1-1B
7 5 6 mpbiri f=f:1-1B
8 4 7 impbii f:1-1Bf=
9 velsn ff=
10 8 9 bitr4i f:1-1Bf
11 1 10 bitrdi x=f:x1-1Bf
12 11 eqabcdv x=f|f:x1-1B=
13 12 fveq2d x=f|f:x1-1B=
14 0ex V
15 hashsng V=1
16 14 15 ax-mp =1
17 13 16 eqtrdi x=f|f:x1-1B=1
18 fveq2 x=x=
19 hash0 =0
20 18 19 eqtrdi x=x=0
21 20 fveq2d x=x!=0!
22 fac0 0!=1
23 21 22 eqtrdi x=x!=1
24 20 oveq2d x=(Bx)=(B0)
25 23 24 oveq12d x=x!(Bx)=1(B0)
26 17 25 eqeq12d x=f|f:x1-1B=x!(Bx)1=1(B0)
27 26 imbi2d x=BFinf|f:x1-1B=x!(Bx)BFin1=1(B0)
28 f1eq2 x=yf:x1-1Bf:y1-1B
29 28 abbidv x=yf|f:x1-1B=f|f:y1-1B
30 29 fveq2d x=yf|f:x1-1B=f|f:y1-1B
31 2fveq3 x=yx!=y!
32 fveq2 x=yx=y
33 32 oveq2d x=y(Bx)=(By)
34 31 33 oveq12d x=yx!(Bx)=y!(By)
35 30 34 eqeq12d x=yf|f:x1-1B=x!(Bx)f|f:y1-1B=y!(By)
36 35 imbi2d x=yBFinf|f:x1-1B=x!(Bx)BFinf|f:y1-1B=y!(By)
37 f1eq2 x=yzf:x1-1Bf:yz1-1B
38 37 abbidv x=yzf|f:x1-1B=f|f:yz1-1B
39 38 fveq2d x=yzf|f:x1-1B=f|f:yz1-1B
40 2fveq3 x=yzx!=yz!
41 fveq2 x=yzx=yz
42 41 oveq2d x=yz(Bx)=(Byz)
43 40 42 oveq12d x=yzx!(Bx)=yz!(Byz)
44 39 43 eqeq12d x=yzf|f:x1-1B=x!(Bx)f|f:yz1-1B=yz!(Byz)
45 44 imbi2d x=yzBFinf|f:x1-1B=x!(Bx)BFinf|f:yz1-1B=yz!(Byz)
46 f1eq2 x=Af:x1-1Bf:A1-1B
47 46 abbidv x=Af|f:x1-1B=f|f:A1-1B
48 47 fveq2d x=Af|f:x1-1B=f|f:A1-1B
49 2fveq3 x=Ax!=A!
50 fveq2 x=Ax=A
51 50 oveq2d x=A(Bx)=(BA)
52 49 51 oveq12d x=Ax!(Bx)=A!(BA)
53 48 52 eqeq12d x=Af|f:x1-1B=x!(Bx)f|f:A1-1B=A!(BA)
54 53 imbi2d x=ABFinf|f:x1-1B=x!(Bx)BFinf|f:A1-1B=A!(BA)
55 hashcl BFinB0
56 bcn0 B0(B0)=1
57 55 56 syl BFin(B0)=1
58 57 oveq2d BFin1(B0)=11
59 1t1e1 11=1
60 58 59 eqtr2di BFin1=1(B0)
61 abn0 f|f:yz1-1Bff:yz1-1B
62 f1domg BFinf:yz1-1ByzB
63 62 adantr BFinyFin¬zyf:yz1-1ByzB
64 hashunsng zVyFin¬zyyz=y+1
65 64 elv yFin¬zyyz=y+1
66 65 adantl BFinyFin¬zyyz=y+1
67 66 breq1d BFinyFin¬zyyzBy+1B
68 simprl BFinyFin¬zyyFin
69 snfi zFin
70 unfi yFinzFinyzFin
71 68 69 70 sylancl BFinyFin¬zyyzFin
72 simpl BFinyFin¬zyBFin
73 hashdom yzFinBFinyzByzB
74 71 72 73 syl2anc BFinyFin¬zyyzByzB
75 hashcl yFiny0
76 75 ad2antrl BFinyFin¬zyy0
77 nn0p1nn y0y+1
78 76 77 syl BFinyFin¬zyy+1
79 78 nnred BFinyFin¬zyy+1
80 55 adantr BFinyFin¬zyB0
81 80 nn0red BFinyFin¬zyB
82 79 81 lenltd BFinyFin¬zyy+1B¬B<y+1
83 67 74 82 3bitr3d BFinyFin¬zyyzB¬B<y+1
84 63 83 sylibd BFinyFin¬zyf:yz1-1B¬B<y+1
85 84 exlimdv BFinyFin¬zyff:yz1-1B¬B<y+1
86 61 85 biimtrid BFinyFin¬zyf|f:yz1-1B¬B<y+1
87 86 necon4ad BFinyFin¬zyB<y+1f|f:yz1-1B=
88 87 imp BFinyFin¬zyB<y+1f|f:yz1-1B=
89 88 fveq2d BFinyFin¬zyB<y+1f|f:yz1-1B=
90 hashcl yzFinyz0
91 71 90 syl BFinyFin¬zyyz0
92 91 faccld BFinyFin¬zyyz!
93 92 nncnd BFinyFin¬zyyz!
94 93 adantr BFinyFin¬zyB<y+1yz!
95 94 mul01d BFinyFin¬zyB<y+1yz!0=0
96 19 89 95 3eqtr4a BFinyFin¬zyB<y+1f|f:yz1-1B=yz!0
97 66 adantr BFinyFin¬zyB<y+1yz=y+1
98 97 oveq2d BFinyFin¬zyB<y+1(Byz)=(By+1)
99 80 adantr BFinyFin¬zyB<y+1B0
100 78 adantr BFinyFin¬zyB<y+1y+1
101 100 nnzd BFinyFin¬zyB<y+1y+1
102 animorr BFinyFin¬zyB<y+1y+1<0B<y+1
103 bcval4 B0y+1y+1<0B<y+1(By+1)=0
104 99 101 102 103 syl3anc BFinyFin¬zyB<y+1(By+1)=0
105 98 104 eqtrd BFinyFin¬zyB<y+1(Byz)=0
106 105 oveq2d BFinyFin¬zyB<y+1yz!(Byz)=yz!0
107 96 106 eqtr4d BFinyFin¬zyB<y+1f|f:yz1-1B=yz!(Byz)
108 107 a1d BFinyFin¬zyB<y+1f|f:y1-1B=y!(By)f|f:yz1-1B=yz!(Byz)
109 oveq2 f|f:y1-1B=y!(By)Byf|f:y1-1B=Byy!(By)
110 68 adantr BFinyFin¬zyy+1ByFin
111 72 adantr BFinyFin¬zyy+1BBFin
112 simplrr BFinyFin¬zyy+1B¬zy
113 simpr BFinyFin¬zyy+1By+1B
114 110 111 112 113 hashf1lem2 BFinyFin¬zyy+1Bf|f:yz1-1B=Byf|f:y1-1B
115 80 adantr BFinyFin¬zyy+1BB0
116 115 faccld BFinyFin¬zyy+1BB!
117 116 nncnd BFinyFin¬zyy+1BB!
118 76 adantr BFinyFin¬zyy+1By0
119 peano2nn0 y0y+10
120 118 119 syl BFinyFin¬zyy+1By+10
121 nn0sub2 y+10B0y+1BBy+10
122 120 115 113 121 syl3anc BFinyFin¬zyy+1BBy+10
123 122 faccld BFinyFin¬zyy+1BBy+1!
124 123 nncnd BFinyFin¬zyy+1BBy+1!
125 123 nnne0d BFinyFin¬zyy+1BBy+1!0
126 117 124 125 divcld BFinyFin¬zyy+1BB!By+1!
127 120 faccld BFinyFin¬zyy+1By+1!
128 127 nncnd BFinyFin¬zyy+1By+1!
129 127 nnne0d BFinyFin¬zyy+1By+1!0
130 126 128 129 divcan2d BFinyFin¬zyy+1By+1!B!By+1!y+1!=B!By+1!
131 115 nn0cnd BFinyFin¬zyy+1BB
132 118 nn0cnd BFinyFin¬zyy+1By
133 131 132 subcld BFinyFin¬zyy+1BBy
134 ax-1cn 1
135 npcan By1By-1+1=By
136 133 134 135 sylancl BFinyFin¬zyy+1BBy-1+1=By
137 1cnd BFinyFin¬zyy+1B1
138 131 132 137 subsub4d BFinyFin¬zyy+1BB-y-1=By+1
139 138 122 eqeltrd BFinyFin¬zyy+1BB-y-10
140 nn0p1nn B-y-10By-1+1
141 139 140 syl BFinyFin¬zyy+1BBy-1+1
142 136 141 eqeltrrd BFinyFin¬zyy+1BBy
143 142 nnne0d BFinyFin¬zyy+1BBy0
144 126 133 143 divcan2d BFinyFin¬zyy+1BByB!By+1!By=B!By+1!
145 130 144 eqtr4d BFinyFin¬zyy+1By+1!B!By+1!y+1!=ByB!By+1!By
146 66 adantr BFinyFin¬zyy+1Byz=y+1
147 146 fveq2d BFinyFin¬zyy+1Byz!=y+1!
148 nn0uz 0=0
149 120 148 eleqtrdi BFinyFin¬zyy+1By+10
150 115 nn0zd BFinyFin¬zyy+1BB
151 elfz5 y+10By+10By+1B
152 149 150 151 syl2anc BFinyFin¬zyy+1By+10By+1B
153 113 152 mpbird BFinyFin¬zyy+1By+10B
154 bcval2 y+10B(By+1)=B!By+1!y+1!
155 153 154 syl BFinyFin¬zyy+1B(By+1)=B!By+1!y+1!
156 146 oveq2d BFinyFin¬zyy+1B(Byz)=(By+1)
157 117 124 128 125 129 divdiv1d BFinyFin¬zyy+1BB!By+1!y+1!=B!By+1!y+1!
158 155 156 157 3eqtr4d BFinyFin¬zyy+1B(Byz)=B!By+1!y+1!
159 147 158 oveq12d BFinyFin¬zyy+1Byz!(Byz)=y+1!B!By+1!y+1!
160 118 148 eleqtrdi BFinyFin¬zyy+1By0
161 peano2fzr y0y+10By0B
162 160 153 161 syl2anc BFinyFin¬zyy+1By0B
163 bcval2 y0B(By)=B!By!y!
164 162 163 syl BFinyFin¬zyy+1B(By)=B!By!y!
165 elfzle2 y0ByB
166 162 165 syl BFinyFin¬zyy+1ByB
167 nn0sub2 y0B0yBBy0
168 118 115 166 167 syl3anc BFinyFin¬zyy+1BBy0
169 168 faccld BFinyFin¬zyy+1BBy!
170 169 nncnd BFinyFin¬zyy+1BBy!
171 118 faccld BFinyFin¬zyy+1By!
172 171 nncnd BFinyFin¬zyy+1By!
173 169 nnne0d BFinyFin¬zyy+1BBy!0
174 171 nnne0d BFinyFin¬zyy+1By!0
175 117 170 172 173 174 divdiv1d BFinyFin¬zyy+1BB!By!y!=B!By!y!
176 164 175 eqtr4d BFinyFin¬zyy+1B(By)=B!By!y!
177 176 oveq2d BFinyFin¬zyy+1By!(By)=y!B!By!y!
178 facnn2 ByBy!=B-y-1!By
179 142 178 syl BFinyFin¬zyy+1BBy!=B-y-1!By
180 138 fveq2d BFinyFin¬zyy+1BB-y-1!=By+1!
181 180 oveq1d BFinyFin¬zyy+1BB-y-1!By=By+1!By
182 179 181 eqtrd BFinyFin¬zyy+1BBy!=By+1!By
183 182 oveq2d BFinyFin¬zyy+1BB!By!=B!By+1!By
184 117 170 173 divcld BFinyFin¬zyy+1BB!By!
185 184 172 174 divcan2d BFinyFin¬zyy+1By!B!By!y!=B!By!
186 117 124 133 125 143 divdiv1d BFinyFin¬zyy+1BB!By+1!By=B!By+1!By
187 183 185 186 3eqtr4d BFinyFin¬zyy+1By!B!By!y!=B!By+1!By
188 177 187 eqtrd BFinyFin¬zyy+1By!(By)=B!By+1!By
189 188 oveq2d BFinyFin¬zyy+1BByy!(By)=ByB!By+1!By
190 145 159 189 3eqtr4d BFinyFin¬zyy+1Byz!(Byz)=Byy!(By)
191 114 190 eqeq12d BFinyFin¬zyy+1Bf|f:yz1-1B=yz!(Byz)Byf|f:y1-1B=Byy!(By)
192 109 191 imbitrrid BFinyFin¬zyy+1Bf|f:y1-1B=y!(By)f|f:yz1-1B=yz!(Byz)
193 108 192 81 79 ltlecasei BFinyFin¬zyf|f:y1-1B=y!(By)f|f:yz1-1B=yz!(Byz)
194 193 expcom yFin¬zyBFinf|f:y1-1B=y!(By)f|f:yz1-1B=yz!(Byz)
195 194 a2d yFin¬zyBFinf|f:y1-1B=y!(By)BFinf|f:yz1-1B=yz!(Byz)
196 27 36 45 54 60 195 findcard2s AFinBFinf|f:A1-1B=A!(BA)
197 196 imp AFinBFinf|f:A1-1B=A!(BA)