1

Let $A, B$ be two finite sets with $|A| = n$ and $|B| = k$. How many injective mappings $f : A \rightarrow B$ are there? Furthermore, show that the number of surjective mappings $f: A \rightarrow B$ equals $k!S_{n,k}$.

I guess this has to do with Stirling numbers and something with the following identity $x^n = \sum^{n}_{k=0}S_{n,k}(x)_k$, but I don't know how can I proceed or let alone count this kind of functions. How can I solve this problem?

2 Answers2

2

As shown in Counting surjective functions, the number of surjections $A \stackrel{onto}\longrightarrow B$, with $\lvert A\rvert = n, \lvert B\rvert = k$, is: $$ \sum_{j=0}^{k}(-1)^{k-j}\binom{k}{j}j^n = k!\, S_{n,k} \tag{# of surjections $n\to k$} $$ See that answer for why this is so.

Counting injections $A\stackrel{1-1}\longrightarrow B$ is simpler. Assume $A=\{1,\dotsc,n\}, B=\{1,\dotsc, k\}$. Each subset $Y\subseteq B$ of size $n$ corresponds to $n!$ many injections: there's the canonical order-preserving bijection $A\stackrel{\sim}\to Y$, and then $n!$ many others which arise from permuting the elements of $A$ (or, equivalently, the elements of $Y$). Moreover, every injection arises in this way. So the number of injections $A\stackrel{1-1}\longrightarrow B$ is: $$ n! \binom k n = \frac {k!} {(k-n)!} $$

BrianO
  • 16,579
  • Thanks for the answer. I checked the other answer that you have linked, but I didn't understand from where the explicit formula about Stirling number of the second kind came. And I also didn't understand what happened to $\frac{1}{n!}$. Can you elaborate on these? –  Nov 15 '15 at 20:59
  • The explicit formula for the Stirling number of the second kind can be found later in the wikipedia article linked to in the other answer: https://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind#Explicit_formula. Notice that it has a factor of $1/k!$, which goes away on multiplying by $k!$. (The answer concerns $r, n$ which in the notation of the article are $n,k$ respectively — which can't help but be confusing :). Your $n,k$ are the same as in the article.) Compare the 2nd to last and the 3rd to last displayed formulas in the answer: the $n!$ factors out. – BrianO Nov 15 '15 at 21:08
  • Yes, the notation confused me a bit. I now see that you delete that $\frac{1}{k!}$ by multiplying with $k!$, which comes from the possible permutations of the range in the surjection. Though, if you see in my problem, it asks me to prove that the number will be $k!S_{n,k}$, but you have given a sum, which clearly has some kind of inclusion-exclusion inside it, which uses the explicit formula of the Stirling numbers of the second kind. I guess I only need the first part, which calculated $k!S_{n,k}$. Can you tell me why we need that sum actually? For injections, $k \geq n$, by definition? –  Nov 16 '15 at 10:20
  • The number of surjections is $k! S_{n,k}$, yes. If you actually wanted to calculate the number, the sum is useful: few of us have the table of $S_{n,k}$ values memorized :) For injections, you don't need $S_{n,k}$ at all: the number of them is as stated in the answer. – BrianO Nov 16 '15 at 10:31
  • I just meant that $|A| = n \leq |B| = k$, we need this in order to have injection, cause otherwise domain will map to at least one same element in the range, which will be a surjection. On the other hand, when you say $Y \subseteq B$ of size $n$, and that it corresponds to $n!$, it again means the permutations in the range? I don't get what you mean by canonical order-preserving bijection. Also for the $\binom{k}{n}$ part, I'm also confused for it a bit, it means that we choose $n$ elements of of $k$ elements in the range to map to? –  Nov 16 '15 at 10:39
  • I rephrased my answer to bring it more in line with your question, & hopefully I succeeded at that. – BrianO Nov 16 '15 at 10:39
  • $\binom k n$ is 0 for $k<n$ so assume $k\ge n$. It counts the number of $n$-element subsets of a set of size $k$. Assume $B={1,\dotsc,k}$ and similarly for $A$ as in the answer, so both have an ordering. If $Y\subseteq B$ has size $n$, there's a natural (canonical) bijection from $A$ to $Y$: the one that enumerates $Y$ in increasing order. Every other injection with range $Y$ is a variation on this one, and arises by a permutation of $Y$... or equivalently, of $A = {1,\dotsc,n}$ — it doesn't matter: there are $n!$ of them, given $Y$. – BrianO Nov 16 '15 at 10:46
  • Thanks, I think I got your answer. One more question, isn't the canonical bijection also included in $n!$? –  Nov 16 '15 at 19:09
  • 1
    Sure, it is. But that's good! otherwise it would be omitted. For each $Y\subset B$ of size $n$, there are $n!$ bijections from $A\to Y$, including that one. – BrianO Nov 16 '15 at 19:16
  • Thanks for helping me understand. If you have time can you take a look at this problem, there seems to be answer, but it seems like a complicated answer, I cannot seem to understand it. http://math.stackexchange.com/questions/1528709/proving-recurrence-relation-on-the-cardinal-of-the-derangements –  Nov 16 '15 at 19:18
0

Hint: think of the elements of $A$ as balls and the elements of $B$ as boxes. You want to put the balls into the boxes such that each box contains at least one ball. What do the Stirling numbers (of the second kind) count?

rogerl
  • 22,399
  • Stirling numbers of second kind count the number of $k$-partitions of an $n$-element set. So in our case, we have $|A| = n$ balls, and we want to partitions them into $k$ blocks (boxes)? –  Nov 14 '15 at 18:41
  • Yes, exactly. (Also, I assume you figured out yourself how to count injective mappings, since you didn't mention that in your question.) – rogerl Nov 14 '15 at 19:11
  • The problem asks both for the injective and surjective mappings. I mention both of them in the problem, I need to somehow count both of them. I just wrote the problem as it is stated. I need to find some way to count the injective mappings too. –  Nov 14 '15 at 22:50