\documentclass[numbers=enddot,12pt,final,onecolumn,notitlepage]{scrartcl}%
\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\usepackage[all,cmtip]{xy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{framed}
\usepackage{comment}
\usepackage{color}
\usepackage[breaklinks=True]{hyperref}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{needspace}
\usepackage{tabls}
\usepackage{tikz}
\usepackage{bbding}
%TCIDATA{OutputFilter=latex2.dll}
%TCIDATA{Version=5.50.0.2960}
%TCIDATA{LastRevised=Monday, December 26, 2022 13:53:06}
%TCIDATA{SuppressPackageManagement}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="SaveForMode" CONTENT="1">}
%TCIDATA{BibliographyScheme=Manual}
%TCIDATA{Language=American English}
%BeginMSIPreambleData
\providecommand{\U}[1]{\protect\rule{.1in}{.1in}}
%EndMSIPreambleData
\usetikzlibrary{arrows.meta}
\usetikzlibrary{chains}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing}
\newcounter{exer}
\newcounter{exera}
\theoremstyle{definition}
\newtheorem{theo}{Theorem}[subsection]
\newenvironment{theorem}[1][]
{\begin{theo}[#1]\begin{leftbar}}
{\end{leftbar}\end{theo}}
\newtheorem{lem}[theo]{Lemma}
\newenvironment{lemma}[1][]
{\begin{lem}[#1]\begin{leftbar}}
{\end{leftbar}\end{lem}}
\newtheorem{prop}[theo]{Proposition}
\newenvironment{proposition}[1][]
{\begin{prop}[#1]\begin{leftbar}}
{\end{leftbar}\end{prop}}
\newtheorem{defi}[theo]{Definition}
\newenvironment{definition}[1][]
{\begin{defi}[#1]\begin{leftbar}}
{\end{leftbar}\end{defi}}
\newtheorem{remk}[theo]{Remark}
\newenvironment{remark}[1][]
{\begin{remk}[#1]\begin{leftbar}}
{\end{leftbar}\end{remk}}
\newtheorem{coro}[theo]{Corollary}
\newenvironment{corollary}[1][]
{\begin{coro}[#1]\begin{leftbar}}
{\end{leftbar}\end{coro}}
\newtheorem{conv}[theo]{Convention}
\newenvironment{convention}[1][]
{\begin{conv}[#1]\begin{leftbar}}
{\end{leftbar}\end{conv}}
\newtheorem{quest}[theo]{Question}
\newenvironment{question}[1][]
{\begin{quest}[#1]\begin{leftbar}}
{\end{leftbar}\end{quest}}
\newtheorem{warn}[theo]{Warning}
\newenvironment{warning}[1][]
{\begin{warn}[#1]\begin{leftbar}}
{\end{leftbar}\end{warn}}
\newtheorem{conj}[theo]{Conjecture}
\newenvironment{conjecture}[1][]
{\begin{conj}[#1]\begin{leftbar}}
{\end{leftbar}\end{conj}}
\newtheorem{exam}[theo]{Example}
\newenvironment{example}[1][]
{\begin{exam}[#1]\begin{leftbar}}
{\end{leftbar}\end{exam}}
\newtheorem{exmp}[exer]{Exercise}
\newenvironment{exercise}[1][]
{\begin{exmp}[#1]\begin{leftbar}}
{\end{leftbar}\end{exmp}}
\newenvironment{statement}{\begin{quote}}{\end{quote}}
\newenvironment{fineprint}{\begin{small}}{\end{small}}
\iffalse
\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newenvironment{convention}[1][Convention]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newenvironment{question}[1][Question]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\fi
\let\sumnonlimits\sum
\let\prodnonlimits\prod
\let\cupnonlimits\bigcup
\let\capnonlimits\bigcap
\renewcommand{\sum}{\sumnonlimits\limits}
\renewcommand{\prod}{\prodnonlimits\limits}
\renewcommand{\bigcup}{\cupnonlimits\limits}
\renewcommand{\bigcap}{\capnonlimits\limits}
\newcommand\arxiv[1]{\href{http://www.arxiv.org/abs/#1}{\texttt{arXiv:#1}}}
\setlength\tablinesep{3pt}
\setlength\arraylinesep{3pt}
\setlength\extrarulesep{3pt}
\setlength\textheight{22.5cm}
\setlength\textwidth{14.8cm}
\newenvironment{verlong}{}{}
\newenvironment{vershort}{}{}
\newenvironment{noncompile}{}{}
\excludecomment{verlong}
\includecomment{vershort}
\excludecomment{noncompile}
\newcommand{\defn}[1]{{\color{darkred}\emph{#1}}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\KK}{\mathbb{K}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\tup}[1]{\left( #1 \right)}
\newcommand{\ive}[1]{\left[ #1 \right]}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\are}{\ar@{-}}
\newcommand{\arebi}[1][]{\ar@{<-}@/_/[#1] \ar@/^/[#1]}
\newcommand{\numboxed}[2]{\underbrace{\boxed{#1}}_{\text{box } #2}}
\newcommand{\of}{\text{ of }}
\definecolor{darkgreen}{rgb}{0,.5,0}
\newtheoremstyle{plainsl}
{8pt plus 2pt minus 4pt}
{8pt plus 2pt minus 4pt}
{\slshape}
{0pt}
{\bfseries}
{.}
{5pt plus 1pt minus 1pt}
{}
\theoremstyle{plainsl}
\ihead{Lecture 25, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 222 Fall 2022, Lecture 25: The twelvefold way}

\textbf{website:}
\texttt{\href{https://www.cip.ifi.lmu.de/~grinberg/t/22fco}{\texttt{https://www.cip.ifi.lmu.de/\symbol{126}%
grinberg/t/22fco}}}

\setcounter{section}{2}

\section{\label{chap.12way}The twelvefold way}

\setcounter{subsection}{4}

\subsection{$L\rightarrow U$ placements (cont'd)}

\setcounter{theo}{1}

We continue the study of $L\rightarrow U$ placements. Last time (Proposition
3.5.1 in Lecture 24), we proved that
\[
\left(  \text{\# of injective }L\rightarrow U\text{ placements }A\rightarrow
X\right)  =\left[  \left\vert A\right\vert \leq\left\vert X\right\vert
\right]
\]
(where, as we recall, $A$ is the set of balls and $X$ is the set of boxes).

To count arbitrary and surjective $L\rightarrow U$ placements, we need a
definition that we already mentioned in Lecture 17 (Remark 2.4.14):

\begin{definition}
Let $n\in\mathbb{N}$ and $k\in\mathbb{N}$. Then, we define the
\textbf{Stirling number of the second kind} $%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{k}%
%EndExpansion
$ to be $\dfrac{\operatorname*{sur}\left(  n,k\right)  }{k!}$.
\end{definition}

Now we claim:

\begin{proposition}
\label{prop.12way.LtoU.sur}We have%
\begin{align*}
&  \left(  \text{\# of surjective }L\rightarrow U\text{ placements
}A\rightarrow X\right) \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
=\dfrac{\operatorname*{sur}\left(  \left\vert A\right\vert ,\left\vert
X\right\vert \right)  }{\left\vert X\right\vert !}.
\end{align*}

\end{proposition}

\begin{proof}
First, we recall that $L\rightarrow U$ placements are
$\overset{\operatorname*{box}}{\sim}$-equivalence classes of maps from $A$ to
$X$. Each $\overset{\operatorname*{box}}{\sim}$-equivalence class either
consists entirely of surjections, or contains no surjection at all. (This is
because two box-equivalent maps are either both surjective or both non-surjective.)

Every surjection\footnote{Throughout this proof, \textquotedblleft
surjection\textquotedblright\ means \textquotedblleft surjection from $A$ to
$X$\textquotedblright.} (and, more generally, every map from $A$ to
$X$)\textsl{ }lies in exactly one $\overset{\operatorname*{box}}{\sim}%
$-equivalence class (since $\overset{\operatorname*{box}}{\sim}$ is an
equivalence relation).

Now, the crux of our proof will be the following claim:

\begin{statement}
\textit{Claim 1:} Each $\overset{\operatorname*{box}}{\sim}$-equivalence class
of surjections (i.e., each surjective $L\rightarrow U$ placement) contains
exactly $\left\vert X\right\vert !$ many maps from $A$ to $X$.
\end{statement}

[\textit{Proof of Claim 1:} Consider the $\overset{\operatorname*{box}}{\sim}%
$-equivalence class of some surjection $g:A\rightarrow X$. The elements of
this class are all the maps that are box-equivalent to $g$. In other words,
the elements of this class are all the maps of the form $\xi\circ g$ with
$\xi$ being a permutation of $X$. There are $\left\vert X\right\vert !$ many
permutations $\xi$ of $X$, and they all lead to \textbf{distinct} maps
$\xi\circ g$\ \ \ \ \footnote{\textit{Proof.} Let $\xi_{1}$ and $\xi_{2}$ be
two distinct permutations of $X$. We must show that the maps $\xi_{1}\circ g$
and $\xi_{2}\circ g$ are distinct.
\par
Indeed, there exists some box $x\in X$ such that $\xi_{1}\left(  x\right)
\neq\xi_{2}\left(  x\right)  $ (since $\xi_{1}$ and $\xi_{2}$ are distinct).
Consider such an $x$. Since $g$ is surjective, there exists a ball $a\in A$
such that $g\left(  a\right)  =x$. Consider such an $a$. Now,
\[
\left(  \xi_{1}\circ g\right)  \left(  a\right)  =\xi_{1}\left(
\underbrace{g\left(  a\right)  }_{=x}\right)  =\xi_{1}\left(  x\right)
\neq\xi_{2}\left(  \underbrace{x}_{=g\left(  a\right)  }\right)  =\xi
_{2}\left(  g\left(  a\right)  \right)  =\left(  \xi_{2}\circ g\right)
\left(  a\right)  .
\]
This shows that $\xi_{1}\circ g$ and $\xi_{2}\circ g$ are distinct, qed.}.
Thus, there are exactly $\left\vert X\right\vert !$ many distinct maps
$\xi\circ g$ in the class of $g$. This proves Claim 1.] \medskip

Now, Proposition 2.4.9 in Lecture 16 yields%
\[
\left(  \text{\# of surjections from }A\text{ to }X\right)
=\operatorname*{sur}\left(  \left\vert A\right\vert ,\left\vert X\right\vert
\right)  .
\]
Hence,
\begin{align*}
\operatorname*{sur}\left(  \left\vert A\right\vert ,\left\vert X\right\vert
\right)   &  =\left(  \text{\# of surjections from }A\text{ to }X\right) \\
&  =\sum_{\substack{C\text{ is a }\overset{\operatorname*{box}}{\sim
}\text{-equivalence}\\\text{class of surjections}}}\underbrace{\left(
\text{\# of surjections in }C\right)  }_{\substack{=\left\vert X\right\vert
!\\\text{(by Claim 1)}}}\\
&  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{by the sum rule, since each surjection}\\
\text{lies in exactly one }\overset{\operatorname*{box}}{\sim}%
\text{-equivalence class}%
\end{array}
\right) \\
&  =\sum_{\substack{C\text{ is a }\overset{\operatorname*{box}}{\sim
}\text{-equivalence}\\\text{class of surjections }}}\left\vert X\right\vert
!\\
&  =\left(  \text{\# of }\overset{\operatorname*{box}}{\sim}\text{-equivalence
classes of surjections}\right)  \cdot\left\vert X\right\vert !.
\end{align*}
Dividing this by $\left\vert X\right\vert !$, we obtain%
\[
\left(  \text{\# of }\overset{\operatorname*{box}}{\sim}\text{-equivalence
classes of surjections}\right)  =\dfrac{\operatorname*{sur}\left(  \left\vert
A\right\vert ,\left\vert X\right\vert \right)  }{\left\vert X\right\vert !}=%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
\]
(by the definition of $%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
$). Since the $\overset{\operatorname*{box}}{\sim}$-equivalence classes of
surjections are precisely the surjective $L\rightarrow U$ placements, we thus
have proved that%
\[
\left(  \text{\# of surjective }L\rightarrow U\text{ placements}\right)  =%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
.
\]
This proves Proposition \ref{prop.12way.LtoU.sur}.
\end{proof}

The above proof is an instance of what is often called the \textquotedblleft
shepherd's principle\textquotedblright: To count the sheep in a flock, count
the legs and divide by $4$. (In our case, the surjective $L\rightarrow U$
placements are the sheep; the actual surjections inside them are their legs;
and each sheep has $\left\vert X\right\vert !$ many legs. This works well when
each sheep has the same \# of legs.)

\bigskip

It remains to count \textbf{all} $L\rightarrow U$ placements (as opposed to
just the injective or surjective ones). This isn't very hard any more:

\begin{proposition}
\label{prop.12way.LtoU.all}We have%
\begin{align*}
&  \left(  \text{\# of }L\rightarrow U\text{ placements from }A\text{ to
}X\right) \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{0}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{0}%
%EndExpansion
+%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{1}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{1}%
%EndExpansion
+\cdots+%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
=\sum_{k=0}^{\left\vert X\right\vert }%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
.
\end{align*}

\end{proposition}

\begin{proof}
The main step is to prove the following:

\begin{statement}
\textit{Claim 1:} Let $k\in\left\{  0,1,\ldots,\left\vert X\right\vert
\right\}  $. Then,%
\begin{align*}
&  \left(  \text{\# of }L\rightarrow U\text{ placements from }A\text{ to
}X\text{ with exactly }k\text{ nonempty boxes}\right) \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
.
\end{align*}

\end{statement}

[\textit{Proof of Claim 1:} The empty boxes in an $L\rightarrow U$ placement
are indistinguishable (since the boxes are unlabelled) and can always be moved
to the end of the placement. Hence, an $L\rightarrow U$ placement from $A$ to
$X$ with exactly $k$ nonempty boxes can be viewed as a surjective
$L\rightarrow U$ placement from $A$ to $\left[  k\right]  $ (since we can
simply remove the empty boxes and rename the $k$ nonempty boxes as
$1,2,\ldots,k$). Therefore,%
\begin{align*}
&  \left(  \text{\# of }L\rightarrow U\text{ placements from }A\text{ to
}X\text{ with exactly }k\text{ nonempty boxes}\right)  \\
&  =\left(  \text{\# of surjective }L\rightarrow U\text{ placements from
}A\text{ to }\left[  k\right]  \right)  \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
\ \ \ \ \ \ \ \ \ \ \left(  \text{by Proposition \ref{prop.12way.LtoU.sur},
applied to }\left[  k\right]  \text{ instead of }X\right)  .
\end{align*}
This proves Claim 1.] \medskip

Now, note that any $L\rightarrow U$ placement from $A$ to $X$ has exactly $k$
nonempty boxes for a unique $k\in\left\{  0,1,\ldots,\left\vert X\right\vert
\right\}  $ (indeed, it cannot have more than $\left\vert X\right\vert $
nonempty boxes, since we have only $\left\vert X\right\vert $ boxes). Thus, by
the sum rule, we find%
\begin{align*}
&  \left(  \text{\# of }L\rightarrow U\text{ placements from }A\text{ to
}X\right)  \\
&  =\sum_{k=0}^{\left\vert X\right\vert }\underbrace{\left(  \text{\# of
}L\rightarrow U\text{ placements from }A\text{ to }X\text{ with exactly
}k\text{ nonempty boxes}\right)  }_{\substack{=%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
\\\text{(by Claim 1)}}}\\
&  =\sum_{k=0}^{\left\vert X\right\vert }%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
=%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{0}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{0}%
%EndExpansion
+%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{1}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{1}%
%EndExpansion
+\cdots+%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
.
\end{align*}
This proves Proposition \ref{prop.12way.LtoU.all}.
\end{proof}

\bigskip

With the above three results proved, our twelvefold way table now looks as
follows:%
\[%
\begin{tabular}
[c]{|c||c|c|c|}\hline
& arbitrary & injective & surjective\\\hline
$L\rightarrow L$ & $\left\vert X\right\vert ^{\left\vert A\right\vert }$ &
$\left\vert X\right\vert ^{\underline{\left\vert A\right\vert }}$ &
$\operatorname*{sur}\left(  \left\vert X\right\vert ,\left\vert A\right\vert
\right)  $\\\hline
$U\rightarrow L$ & $\dbinom{\left\vert A\right\vert +\left\vert X\right\vert
-1}{\left\vert A\right\vert }$ & $\dbinom{\left\vert X\right\vert }{\left\vert
A\right\vert }$ & $\dbinom{\left\vert A\right\vert -1}{\left\vert A\right\vert
-\left\vert X\right\vert }$\\\hline
$L\rightarrow U$ & $\sum\limits_{k=0}^{\left\vert X\right\vert }%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
$ & $\left[  \left\vert A\right\vert \leq\left\vert X\right\vert \right]  $ &
$%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
$\\\hline
$U\rightarrow U$ &  &  & \\\hline
\end{tabular}
\ \ \ \ \ \ \ .
\]


\subsection{Set partitions}

Proposition \ref{prop.12way.LtoU.sur} gave us an example of a combinatorial
object (surjective $L\rightarrow U$ placements) that is counted by Stirling
numbers of the second kind. Let us mention another such object: the
\textbf{set partitions}. In truth, these set partitions are in an easy
bijection with surjective $L\rightarrow U$ placements, so they won't be of
much novelty to us, but they have a tendency to appear in various places in
mathematics, so it is worth introducing them anyway.

\begin{definition}
\label{def.setpar.setpar}Let $S$ be a set.

\textbf{(a)} A \textbf{set partition} of $S$ is a set $\mathcal{F}$ of
disjoint nonempty subsets of $S$ such that the union of these subsets is $S$.

In other words, a set partition of $S$ is a set $\left\{  S_{1},S_{2}%
,\ldots,S_{k}\right\}  $ of nonempty subsets of $S$ such that each element of
$S$ lies in exactly one of $S_{1},S_{2},\ldots,S_{k}$. (Here, we are assuming
that $S$ is finite; otherwise, we would have to allow \textquotedblleft
infinite\textquotedblright\ values of $k$.)

\textbf{(b)} If $\mathcal{F}$ is a set partition of $S$, then the elements of
$\mathcal{F}$ are called the \textbf{parts} (or the \textbf{blocks}) of
$\mathcal{F}$. Keep in mind that they are subsets of $S$.

\textbf{(c)} If a set partition $\mathcal{F}$ of $S$ has $k$ blocks, then we
say that $\mathcal{F}$ is a \textbf{set partition of }$S$ \textbf{into }$k$
\textbf{parts}.
\end{definition}

\begin{example}
\label{exa.setpar.3}Here are all set partitions of the set $\left[  3\right]
=\left\{  1,2,3\right\}  $:
\begin{align*}
&  \left\{  \left\{  1,2,3\right\}  \right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{
\left\{  1,2\right\}  ,\left\{  3\right\}  \right\}
,\ \ \ \ \ \ \ \ \ \ \left\{  \left\{  1,3\right\}  ,\left\{  2\right\}
\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{  \left\{  2,3\right\}  ,\left\{
1\right\}  \right\}  ,\\
&  \left\{  \left\{  1\right\}  ,\left\{  2\right\}  ,\left\{  3\right\}
\right\}  .
\end{align*}
And here are the same set partitions, drawn as pictures (each part of the set
partition corresponds to a blob):%
\[%
\begin{array}
[c]{c|c|c|c|c}%
\begin{tikzpicture} \draw (0.7, 0.5) ellipse (1.3 and 1.3); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture} &
\begin{tikzpicture} \draw (0.75, 0) ellipse (1.4 and .5); \draw (0.8, 1.3) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture} &
\begin{tikzpicture} \draw[rotate=-30] (0, 0.6) ellipse (.5 and 1.4); \draw (1.5, 0) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture} &
\begin{tikzpicture} \draw[rotate=30] (1.3, -0.1) ellipse (.5 and 1.4); \draw (0, 0) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture} &
\begin{tikzpicture} \draw (0, 0) ellipse (0.5 and 0.5); \draw (1.5, 0) ellipse (0.5 and 0.5); \draw (0.75, 1.3) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture}
\end{array}
\]
The first of these five set partitions has $1$ part; the second, third and
fourth have $2$ parts each; the last has $3$ parts.
\end{example}

\begin{proposition}
\label{prop.setpar.count-k}Let $n\in\mathbb{N}$ and $k\in\mathbb{N}$. Let $A$
be an $n$-element set. Then,%
\[
\left(  \text{\# of set partitions of }A\text{ into }k\text{ parts}\right)  =%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{k}%
%EndExpansion
.
\]

\end{proposition}

\begin{proof}
Let $X=\left[  k\right]  $. Let us regard the $n$ elements of $A$ as balls,
and the $k$ elements of $X$ as boxes. Thus, any surjective $L\rightarrow U$
placement from $A$ to $X$ can be viewed as a set partition of $A$ (namely,
each box is a part of the set partition, or, more precisely, the balls in this
box form a part). To make this rigorous: If $p$ is a surjective map from $A$
to $X$, then we can construct a set partition $\mathfrak{s}\left(  p\right)  $
of $A$ by setting $\mathfrak{s}\left(  p\right)  =\left\{  A_{1},A_{2}%
,\ldots,A_{k}\right\}  $, where we set
\[
A_{i}=\left\{  \text{all balls in box }i\text{ of }p\right\}  =\left\{  a\in
A\ \mid\ p\left(  a\right)  =i\right\}  \ \ \ \ \ \ \ \ \ \ \text{for each
}i\in\left[  k\right]  .
\]
Box-equivalent surjections $p:A\rightarrow X$ lead to the \textbf{same} set
partition $\mathfrak{s}\left(  p\right)  $, and therefore $\mathfrak{s}\left(
p\right)  $ depends not on the surjection $p:A\rightarrow X$ but only on its
$\overset{\operatorname*{box}}{\sim}$-equivalence class. Therefore, we can
define $\mathfrak{s}\left(  p\right)  $ not just for a surjection
$p:A\rightarrow X$ but also for a surjective $L\rightarrow U$ placement $p$
(simply by picking an arbitrary surjection $p^{\prime}$ in $p$ and setting
$\mathfrak{s}\left(  p\right)  :=\mathfrak{s}\left(  p^{\prime}\right)  $).
This gives us a map%
\begin{align*}
\mathfrak{s}:\left\{  \text{surjective }L\rightarrow U\text{ placements}%
\right\}   &  \rightarrow\left\{  \text{set partitions of }A\text{ into
}k\text{ parts}\right\}  ,\\
p  &  \mapsto\mathfrak{s}\left(  p\right)  .
\end{align*}
It is easy to see that this map $\mathfrak{s}$ is bijective (indeed, the
inverse map sends each set partition $\left\{  A_{1},A_{2},\ldots
,A_{k}\right\}  $ to the surjective $L\rightarrow U$ placement that puts all
elements of $A_{1}$ into box $1$, all elements of $A_{2}$ into box $2$, and so
on).\footnote{For the sake of illustration, here is a table of values of
$\mathfrak{s}$ for $A=\left[  3\right]  $ and $k=2$:%
\[%
\begin{tabular}
[c]{|c||c|c|c|}\hline
$p$ & $\underline{[12]\ [3]}$ & $\underline{[13]\ [2]}$ &
$\underline{[23]\ [1]}$\\\hline
$\mathfrak{s}\left(  p\right)  $ &
$\begin{tikzpicture} \draw (0.75, 0) ellipse (1.4 and .5); \draw (0.8, 1.3) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture}$
&
$\begin{tikzpicture} \draw[rotate=-30] (0, 0.6) ellipse (.5 and 1.4); \draw (1.5, 0) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture}$
&
$\begin{tikzpicture} \draw[rotate=30] (1.3, -0.1) ellipse (.5 and 1.4); \draw (0, 0) ellipse (0.5 and 0.5); \tikzstyle{every node} = [circle] \node (a) at (0, 0) {1}; \node (b) at +(0: 1.5) {2}; \node (c) at +(60: 1.5) {3}; \end{tikzpicture}$%
\\\hline
\end{tabular}
\]
}

Hence, the bijection principle yields%
\begin{align*}
&  \left(  \text{\# of set partitions of }A\text{ into }k\text{ parts}\right)
\\
&  =\left(  \text{\# of surjective }L\rightarrow U\text{ placements}\right) \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
\ \ \ \ \ \ \ \ \ \ \left(  \text{by Proposition \ref{prop.12way.LtoU.sur}%
}\right) \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{k}%
%EndExpansion
\ \ \ \ \ \ \ \ \ \ \left(  \text{since }\left\vert A\right\vert =n\text{ and
}\left\vert X\right\vert =k\right)  .
\end{align*}
This proves Proposition \ref{prop.setpar.count-k}. (See \cite[Proposition
0.12]{18s-hw3s} for a somewhat different proof.)
\end{proof}

\begin{remark}
Let $n\in\mathbb{N}$. Let $A$ be an $n$-element set. Then, a set partition of
$A$ cannot have more than $n$ parts (why?). Hence, by the sum rule,%
\begin{align*}
&  \left(  \text{\# of set partitions of }A\right) \\
&  =\sum_{k=0}^{n}\left(  \text{\# of set partitions of }A\text{ into }k\text{
parts}\right) \\
&  =\sum_{k=0}^{n}%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{k}%
%EndExpansion
\ \ \ \ \ \ \ \ \ \ \left(  \text{by Proposition \ref{prop.setpar.count-k}%
}\right) \\
&  =%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{0}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{0}%
%EndExpansion
+%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{1}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{1}%
%EndExpansion
+\cdots+%
%TCIMACRO{\QDATOPD{\{}{\}}{n}{n}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{n}{n}%
%EndExpansion
.
\end{align*}
This number is called the $n$\textbf{-th Bell number} $B\left(  n\right)  $.
For example, $B\left(  3\right)  =5$, as we see from Example
\ref{exa.setpar.3}.

There is no explicit formula for $B\left(  n\right)  $, but there is a
recursive one:%
\[
B\left(  n+1\right)  =\sum_{i=0}^{n}\dbinom{n}{i}B\left(  i\right)  .
\]
This is not hard to prove (nice exercise!). (For a proof, see \cite[Theorem
1.4.3]{Guicha20}.)
\end{remark}

\begin{remark}
Using set partitions, one can generalize the chain rule from analysis to the
$n$-th derivative. To wit, let $f$ and $g$ be two functions from $\mathbb{R}$
to $\mathbb{R}$ that have sufficiently many derivatives. Let $n\in\mathbb{N}$.
Then, the $n$-th derivative $\left(  f\circ g\right)  ^{\left(  n\right)  }$
of the composite function $f\circ g$ is given by%
\[
\left(  f\circ g\right)  ^{\left(  n\right)  }\left(  x\right)  =\sum
_{\mathcal{F}\text{ is a set partition of }\left[  n\right]  }f^{\left(
\left\vert \mathcal{F}\right\vert \right)  }\left(  g\left(  x\right)
\right)  \cdot\prod_{B\text{ is a part of }\mathcal{F}}g^{\left(  \left\vert
B\right\vert \right)  }\left(  x\right)  .
\]
Here, $\left\vert \mathcal{F}\right\vert $ and $\left\vert B\right\vert $ are
sizes of sets, understood in the usual way (so $\left\vert \mathcal{F}%
\right\vert $ is the \# of parts of $\mathcal{F}$, and $\left\vert
B\right\vert $ is the \# of elements in $B$). For example, for $n=3$, this is
saying that%
\[
\left(  f\circ g\right)  ^{\left(  3\right)  }\left(  x\right)  =f^{\prime
}\left(  g\left(  x\right)  \right)  \cdot g^{\prime\prime\prime}\left(
x\right)  +3f^{\prime\prime}\left(  g\left(  x\right)  \right)  \cdot
g^{\prime\prime}\left(  x\right)  \cdot g^{\prime}\left(  x\right)
+f^{\prime\prime\prime}\left(  g\left(  x\right)  \right)  \cdot\left(
g^{\prime}\left(  x\right)  \right)  ^{3}.
\]
Here, the $f^{\prime}\left(  g\left(  x\right)  \right)  \cdot g^{\prime
\prime\prime}\left(  x\right)  $ addend comes from the set partition
$\mathcal{F}=\left\{  \left\{  1,2,3\right\}  \right\}  $; the $3f^{\prime
\prime}\left(  g\left(  x\right)  \right)  \cdot g^{\prime\prime}\left(
x\right)  \cdot g^{\prime}\left(  x\right)  $ addend comes from the three set
partitions into $2$ parts (they all contribute equal terms, thus the factor of
$3$); and the $f^{\prime\prime\prime}\left(  g\left(  x\right)  \right)
\cdot\left(  g^{\prime}\left(  x\right)  \right)  ^{3}$ addend comes from the
set partition $\mathcal{F}=\left\{  \left\{  1\right\}  ,\left\{  2\right\}
,\left\{  3\right\}  \right\}  $.

The above formula for $\left(  f\circ g\right)  ^{\left(  n\right)  }$ is
known as the \textbf{Faa di Bruno formula}. Various proofs can be found in the
literature (as can applications, generalizations and equivalent versions). See
\cite[\S 2]{Johnso02} for the simplest proof.
\end{remark}

\subsection{$U\rightarrow U$ and integer partitions}

\subsubsection{Introduction}

To complete the twelvefold way, it remains to count $U\rightarrow U$ placements.

A $U\rightarrow U$ placement can look, for example, as follows:%
\[
\underline{\lbrack\bullet\bullet\bullet]\ \ [\ ]\ \ [\bullet]\ \ [\bullet
\,\bullet]\ \ [\ ]\ \ [\ ]\ \ [\bullet]},
\]
with the understanding that the boxes are interchangeable. Thus, we can order
the boxes by decreasing number of balls:%
\[
\underline{\lbrack\bullet\bullet\bullet]\ \ [\bullet\,\bullet]\ \ [\bullet
]\ \ [\bullet]\ \ [\ ]\ \ [\ ]\ \ [\ ]}.
\]
You can encode this $U\rightarrow U$ placement by a sequence of numbers, which
say how many balls lie in each box:%
\[
\left(  3,2,1,1,0,0,0\right)  .
\]
If the \# of boxes is known, we can omit the $0$'s and just write this as
$\left(  3,2,1,1\right)  $. The decreasing order of its entries makes this
sequence unique.

\subsubsection{Partitions}

Let us introduce a name for such sequences:

\begin{definition}
\label{def.intpar.intpar}A \textbf{partition} (or, to be very precise, an
\textbf{integer partition}) of an integer $n$ is a weakly decreasing list
$\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ of positive integers whose sum is
$n$ (that is, $a_{1}\geq a_{2}\geq\cdots\geq a_{k}>0$ and $a_{1}+a_{2}%
+\cdots+a_{k}=n$).

The entries $a_{1},a_{2},\ldots,a_{k}$ of this list are called the
\textbf{parts} of the partition $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $.

If a partition of $n$ has $k$ parts, then we say that it is a
\textbf{partition of }$n$ \textbf{into }$k$ \textbf{parts}.
\end{definition}

\begin{example}
The partitions of $5$ are%
\begin{align*}
&  \left(  5\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  4,1\right)
,\ \ \ \ \ \ \ \ \ \ \left(  3,2\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
3,1,1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  2,2,1\right)  ,\\
&  \left(  2,1,1,1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  1,1,1,1,1\right)
\end{align*}
For instance, $\left(  2,1,1,1\right)  $ is a partition of $5$ into $4$ parts.
\end{example}

\begin{remark}
A partition of $n$ is the same as a weakly decreasing composition of $n$.
\end{remark}

\begin{definition}
Let $n\in\mathbb{Z}$ and $k\in\mathbb{Z}$. Then, we set%
\[
p_{k}\left(  n\right)  :=\left(  \text{\# of partitions of }n\text{ into
}k\text{ parts}\right)  .
\]

\end{definition}

\begin{example}
We have%
\begin{align*}
p_{0}\left(  5\right)   &  =0,\ \ \ \ \ \ \ \ \ \ p_{1}\left(  5\right)
=1,\ \ \ \ \ \ \ \ \ \ p_{2}\left(  5\right)  =2,\ \ \ \ \ \ \ \ \ \ p_{3}%
\left(  5\right)  =2,\\
p_{4}\left(  5\right)   &  =1,\ \ \ \ \ \ \ \ \ \ p_{5}\left(  5\right)
=1,\ \ \ \ \ \ \ \ \ \ p_{k}\left(  5\right)  =0\text{ for all }k>5.
\end{align*}

\end{example}

There is no explicit formula for $p_{k}\left(  n\right)  $, but the
computation of $p_{k}\left(  n\right)  $ can still be made fairly painless
using the following recursive formula (and base cases):

\begin{proposition}
\label{prop.intpar.basics}Let $n\in\mathbb{Z}$ and $k\in\mathbb{N}$.

\textbf{(a)} We have $p_{k}\left(  n\right)  =0$ when $k<0$ or $n<0$.

\textbf{(b)} We have $p_{k}\left(  n\right)  =0$ when $k>n$.

\textbf{(c)} We have $p_{0}\left(  n\right)  =\left[  n=0\right]  $.

\textbf{(d)} We have $p_{1}\left(  n\right)  =\left[  n>0\right]  $.

\textbf{(e)} We have $p_{2}\left(  n\right)  =\left\lfloor n/2\right\rfloor $
if $n\in\mathbb{N}$.

\textbf{(f)} We have $p_{k}\left(  n\right)  =p_{k}\left(  n-k\right)
+p_{k-1}\left(  n-1\right)  $.
\end{proposition}

\begin{proof}
\textbf{(a)} A partition has positive entries, so the sum of its entries
cannot be negative. Thus, $p_{k}\left(  n\right)  =0$ when $n<0$.

Also, the number of its entries cannot be negative. Thus, $p_{k}\left(
n\right)  =0$ when $k<0$. Proposition \ref{prop.intpar.basics} \textbf{(a)} is
thus proved. \medskip

\textbf{(b)} Let $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ be a partition of
$n$ into $k$ parts. Then, $a_{1},a_{2},\ldots,a_{k}$ are positive integers (by
the definition of a partition), and thus are $\geq1$ each. Hence,
$\underbrace{a_{1}}_{\geq1}+\underbrace{a_{2}}_{\geq1}+\cdots
+\underbrace{a_{k}}_{\geq1}\geq\underbrace{1+1+\cdots+1}_{k\text{ times}}=k$.
However, $a_{1}+a_{2}+\cdots+a_{k}=n$ (since $\left(  a_{1},a_{2},\ldots
,a_{k}\right)  $ is a partition of $n$). Thus, $n=a_{1}+a_{2}+\cdots+a_{k}\geq
k$.

Forget that we fixed $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $. We thus have
shown that if $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ is a partition of
$n$ into $k$ parts, then $n\geq k$. Hence, there exists no partition of $n$
into $k$ parts if $n<k$. In other words, $p_{k}\left(  n\right)  =0$ when
$n<k$. This proves Proposition \ref{prop.intpar.basics} \textbf{(b)}. \medskip

\textbf{(c)} A partition of $n$ into $0$ parts must necessarily be the
$0$-tuple $\left(  {}\right)  $. But the sum of all entries of this $0$-tuple
is $0$ (since an empty sum is $0$). Hence, a partition of $n$ into $0$ parts
exists only if $n=0$, and in this case it is unique. In other words, the \# of
partitions of $n$ into $0$ parts is $\left[  n=0\right]  $. In other words,
$p_{0}\left(  n\right)  =\left[  n=0\right]  $. This proves Proposition
\ref{prop.intpar.basics} \textbf{(c)}. \medskip

\textbf{(d)} A partition of $n$ into $1$ part must necessarily be the
$1$-tuple $\left(  n\right)  $ (since the sum of its parts has to be $n$). But
this $1$-tuple $\left(  n\right)  $ is a partition only when $n>0$ (since the
entries of a partition have to be positive integers). Thus, a partition of $n$
into $1$ part exists only when $n>0$, and in this case it is unique. In other
words, the \# of partitions of $n$ into $1$ part is $\left[  n>0\right]  $. In
other words, $p_{1}\left(  n\right)  =\left[  n>0\right]  $. This proves
Proposition \ref{prop.intpar.basics} \textbf{(d)}. \medskip

\textbf{(e)} Assume that $n\in\mathbb{N}$. Then, any partition of $n$ into $2$
parts must have the form $\left(  k,\ n-k\right)  $ for some positive integer
$k$ (since the sum of its parts must be $n$). However, $\left(
k,\ n-k\right)  $ is not a partition unless $k\geq n-k$ (because a partition
has to be weakly decreasing), i.e., unless $k\geq n/2$. Thus, the partitions
of $n$ into $2$ parts are%
\[
\left(  n-1,\ 1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  n-2,\ 2\right)
,\ \ \ \ \ \ \ \ \ \ \left(  n-3,\ 3\right)  ,\ \ \ \ \ \ \ \ \ \ \ldots
,\ \ \ \ \ \ \ \ \ \ \left(  \left\lceil n/2\right\rceil ,\ n-\left\lceil
n/2\right\rceil \right)  .
\]
There are clearly $n-\left\lceil n/2\right\rceil =\left\lfloor
n/2\right\rfloor $ of these partitions. This proves Proposition
\ref{prop.intpar.basics} \textbf{(e)}. \medskip

\textbf{(f)} Let us call a partition

\begin{itemize}
\item \textbf{red} if $1$ is a part of it;

\item \textbf{green} if $1$ is not a part of it.
\end{itemize}

Recall that a partition must be weakly decreasing (by definition). Thus, the
last part of a partition must be its smallest part. Consequently, if $1$ is a
part of a partition, then the last part of this partition must be $1$
(although, of course, some other parts may also be $1$). In other words, if a
partition is red, then its last part must be $1$. Thus, any red partition of
$n$ into $k$ parts must necessarily have the form $\left(  a_{1},a_{2}%
,\ldots,a_{k-1},1\right)  $. Removing the last entry from such a red partition
yields the $\left(  k-1\right)  $-tuple $\left(  a_{1},a_{2},\ldots
,a_{k-1}\right)  $, which is a partition of $n-1$ into $k-1$ parts.

Thus, we obtain a map%
\begin{align*}
\left\{  \text{red partitions of }n\text{ into }k\text{ parts}\right\}   &
\rightarrow\left\{  \text{partitions of }n-1\text{ into }k-1\text{
parts}\right\}  ,\\
\left(  a_{1},a_{2},\ldots,a_{k-1},1\right)   &  \mapsto\left(  a_{1}%
,a_{2},\ldots,a_{k-1}\right)  .
\end{align*}
Conversely, we have a map%
\begin{align*}
\left\{  \text{partitions of }n-1\text{ into }k-1\text{ parts}\right\}   &
\rightarrow\left\{  \text{red partitions of }n\text{ into }k\text{
parts}\right\}  ,\\
\left(  a_{1},a_{2},\ldots,a_{k-1}\right)   &  \mapsto\left(  a_{1}%
,a_{2},\ldots,a_{k-1},1\right)  .
\end{align*}
These two maps are mutually inverse and thus are bijections. Hence, the
bijection principle yields%
\begin{align*}
&  \left(  \text{\# of red partitions of }n\text{ into }k\text{ parts}\right)
\\
&  =\left(  \text{\# of partitions of }n-1\text{ into }k-1\text{ parts}\right)
\\
&  =p_{k-1}\left(  n-1\right)  \ \ \ \ \ \ \ \ \ \ \left(  \text{by definition
of }p_{k-1}\left(  n-1\right)  \right)  .
\end{align*}


On the other hand, if a partition $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $
of $n$ is green, then all its parts $a_{1},a_{2},\ldots,a_{k}$ are distinct
from $1$ and therefore larger than $1$ (since they are positive integers).
Subtracting $1$ from each part thus leaves us again with a partition, although
this new partition $\left(  a_{1}-1,\ a_{2}-1,\ \ldots,\ a_{k}-1\right)  $
will be a partition of $n-k$ (since $\left(  a_{1}-1\right)  +\left(
a_{2}-1\right)  +\cdots+\left(  a_{k}-1\right)  =\underbrace{\left(
a_{1}+a_{2}+\cdots+a_{k}\right)  }_{=n}-k=n-k$). Hence, we obtain a map%
\begin{align*}
\left\{  \text{green partitions of }n\text{ into }k\text{ parts}\right\}   &
\rightarrow\left\{  \text{partitions of }n-k\text{ into }k\text{
parts}\right\}  ,\\
\left(  a_{1},a_{2},\ldots,a_{k}\right)   &  \mapsto\left(  a_{1}%
-1,\ a_{2}-1,\ \ldots,\ a_{k}-1\right)  .
\end{align*}
Conversely, we have a map%
\begin{align*}
\left\{  \text{partitions of }n-k\text{ into }k\text{ parts}\right\}   &
\rightarrow\left\{  \text{green partitions of }n\text{ into }k\text{
parts}\right\}  ,\\
\left(  a_{1},a_{2},\ldots,a_{k}\right)   &  \mapsto\left(  a_{1}%
+1,\ a_{2}+1,\ \ldots,\ a_{k}+1\right)
\end{align*}
(this is well-defined, because $a_{1}+1,\ a_{2}+1,\ \ldots,\ a_{k}+1$ will
always be distinct from $1$ because $a_{1},a_{2},\ldots,a_{k}$ are positive).
These two maps are mutually inverse and thus are bijections. Hence, the
bijection principle yields%
\begin{align*}
&  \left(  \text{\# of green partitions of }n\text{ into }k\text{
parts}\right) \\
&  =\left(  \text{\# of partitions of }n-k\text{ into }k\text{ parts}\right)
\\
&  =p_{k}\left(  n-k\right)  \ \ \ \ \ \ \ \ \ \ \left(  \text{by definition
of }p_{k}\left(  n-k\right)  \right)  .
\end{align*}


Finally, every partition is either red or green (but not both). Hence, by the
sum rule,%
\begin{align*}
&  \left(  \text{\# of partitions of }n\text{ into }k\text{ parts}\right) \\
&  =\underbrace{\left(  \text{\# of red partitions of }n\text{ into }k\text{
parts}\right)  }_{=p_{k-1}\left(  n-1\right)  }+\underbrace{\left(  \text{\#
of green partitions of }n\text{ into }k\text{ parts}\right)  }_{=p_{k}\left(
n-k\right)  }\\
&  =p_{k-1}\left(  n-1\right)  +p_{k}\left(  n-k\right)  .
\end{align*}
Since the left hand side of this equality is $p_{k}\left(  n\right)  $, we
thus have proved Proposition \ref{prop.intpar.basics} \textbf{(f)}.
\end{proof}

Here is a table of the numbers $p_{k}\left(  n\right)  $ for small values of
$k$ and $n$:%
\[%
\begin{tabular}
[c]{|c||c|c|c|c|c|c|c|c|c|c|}\hline
$p_{k}\left(  n\right)  $ & $n=0$ & $n=1$ & $n=2$ & $n=3$ & $n=4$ & $n=5$ &
$n=6$ & $n=7$ & $n=8$ & $n=9$\\\hline\hline
$k=0$ & $1$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\\hline
$k=1$ & $0$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$\\\hline
$k=2$ & $0$ & $0$ & $1$ & $1$ & $2$ & $2$ & $3$ & $3$ & $4$ & $4$\\\hline
$k=3$ & $0$ & $0$ & $0$ & $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $7$\\\hline
$k=4$ & $0$ & $0$ & $0$ & $0$ & $1$ & $1$ & $2$ & $3$ & $5$ & $6$\\\hline
$k=5$ & $0$ & $0$ & $0$ & $0$ & $0$ & $1$ & $1$ & $2$ & $3$ & $5$\\\hline
$k=6$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $1$ & $1$ & $2$ & $3$\\\hline
$k=7$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $1$ & $1$ & $2$\\\hline
$k=8$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $1$ & $1$\\\hline
$k=9$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $1$\\\hline
\end{tabular}
\]


You may spot a few more properties of $p_{k}\left(  n\right)  $ in this table,
such as the following:

\begin{exercise}
Show that $p_{n-1}\left(  n\right)  =1$ for each $n\geq2$.
\end{exercise}

\begin{exercise}
More generally, show that $p_{n-k}\left(  n\right)  =p_{k}\left(  2k\right)  $
for each $k\in\mathbb{N}$ and each $n\geq2k$.
\end{exercise}

\begin{exercise}
[(harder)]Let $n\in\mathbb{N}$. Show that $p_{3}\left(  n\right)
=\operatorname*{round}\dfrac{n^{2}}{12}$, where $\operatorname*{round}x$
denotes the closest integer to $x$.
\end{exercise}

See \href{https://oeis.org/A008284}{Sequence A008284 in the OEIS} for more
about the numbers $p_{k}\left(  n\right)  $.

\subsubsection{Counting $U\rightarrow U$ placements}

Now, back to the boxes and the balls. We can at last count $U\rightarrow U$ placements:

\begin{proposition}
\label{prop.12way.UtoU.sur}We have%
\[
\left(  \text{\# of surjective }U\rightarrow U\text{ placements }A\rightarrow
X\right)  =p_{\left\vert X\right\vert }\left(  \left\vert A\right\vert
\right)  .
\]

\end{proposition}

\begin{proof}
In a surjective $U\rightarrow U$ placement, any given box has a positive \# of
balls. However, the boxes are unlabelled, so we don't know which box is the
$1$-st box, which is the $2$-nd, and so on. However, we can order the boxes by
decreasing \# of balls, and then there is a well-defined \textquotedblleft%
$1$-st box\textquotedblright, a well-defined \textquotedblleft$2$-nd
box\textquotedblright, etc..

Thus, we can encode a surjective $U\rightarrow U$ placement $A\rightarrow X$
by the $\left\vert X\right\vert $-tuple $\left(  a_{1},a_{2},\ldots
,a_{\left\vert X\right\vert }\right)  $, where%
\[
a_{i}=\left(  \text{\# of balls in the }i\text{-th box}\right)
\]
(where the boxes are ordered by decreasing \# of balls). This $\left\vert
X\right\vert $-tuple $\left(  a_{1},a_{2},\ldots,a_{\left\vert X\right\vert
}\right)  $ is weakly decreasing (because of how we ordered the boxes), and
its entries are positive integers (since our placement is surjective), and the
sum of its entries is $\left\vert A\right\vert $ (since we have a total of
$\left\vert A\right\vert $ many balls). Thus, this $\left\vert X\right\vert
$-tuple is a partition of $\left\vert A\right\vert $ into $\left\vert
X\right\vert $ parts.

This allows us to define a map%
\[
\left\{  \text{surjective }U\rightarrow U\text{ placements }A\rightarrow
X\right\}  \rightarrow\left\{  \text{partitions of }\left\vert A\right\vert
\text{ into }\left\vert X\right\vert \text{ parts}\right\}  ,
\]
which sends a placement to the $\left\vert X\right\vert $-tuple $\left(
a_{1},a_{2},\ldots,a_{\left\vert X\right\vert }\right)  $ we just defined. It
is easy to see that this map is bijective. Thus, by the bijection principle,%
\begin{align*}
&  \left(  \text{\# of surjective }U\rightarrow U\text{ placements
}A\rightarrow X\right) \\
&  =\left(  \text{\# of partitions of }\left\vert A\right\vert \text{ into
}\left\vert X\right\vert \text{ parts}\right)  =p_{\left\vert X\right\vert
}\left(  \left\vert A\right\vert \right)  .
\end{align*}

\end{proof}

\begin{proposition}
\label{prop.12way.UtoU.inj}We have%
\[
\left(  \text{\# of injective }U\rightarrow U\text{ placements }A\rightarrow
X\right)  =\left[  \left\vert A\right\vert \leq\left\vert X\right\vert
\right]  .
\]

\end{proposition}

\begin{proof}
Easy exercise.
\end{proof}

\begin{proposition}
\label{prop.12way.UtoU.all}We have%
\begin{align*}
&  \left(  \text{\# of }U\rightarrow U\text{ placements }A\rightarrow X\right)
\\
&  =p_{0}\left(  \left\vert A\right\vert \right)  +p_{1}\left(  \left\vert
A\right\vert \right)  +\cdots+p_{\left\vert X\right\vert }\left(  \left\vert
A\right\vert \right) \\
&  =\sum\limits_{k=0}^{\left\vert X\right\vert }p_{k}\left(  \left\vert
A\right\vert \right)  .
\end{align*}

\end{proposition}

\begin{proof}
[Proof sketch.]As in the proof of Proposition \ref{prop.12way.LtoU.all}, we
break the sum up according to the \# of nonempty boxes. (Details left to the reader.)
\end{proof}

\begin{exercise}
Prove that the \# in Proposition \ref{prop.12way.UtoU.all} is also equal to
$p_{\left\vert X\right\vert }\left(  \left\vert X\right\vert +\left\vert
A\right\vert \right)  $.
\end{exercise}

We can now fill in the twelvefold way table completely:%
\[%
\begin{tabular}
[c]{|c||c|c|c|}\hline
& arbitrary & injective & surjective\\\hline
$L\rightarrow L$ & $\left\vert X\right\vert ^{\left\vert A\right\vert }$ &
$\left\vert X\right\vert ^{\underline{\left\vert A\right\vert }}$ &
$\operatorname*{sur}\left(  \left\vert X\right\vert ,\left\vert A\right\vert
\right)  $\\\hline
$U\rightarrow L$ & $\dbinom{\left\vert A\right\vert +\left\vert X\right\vert
-1}{\left\vert A\right\vert }$ & $\dbinom{\left\vert X\right\vert }{\left\vert
A\right\vert }$ & $\dbinom{\left\vert A\right\vert -1}{\left\vert A\right\vert
-\left\vert X\right\vert }$\\\hline
$L\rightarrow U$ & $\sum\limits_{k=0}^{\left\vert X\right\vert }%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{k}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{k}%
%EndExpansion
$ & $\left[  \left\vert A\right\vert \leq\left\vert X\right\vert \right]  $ &
$%
%TCIMACRO{\QDATOPD{\{}{\}}{\left\vert A\right\vert }{\left\vert X\right\vert
%}}%
%BeginExpansion
\genfrac{\{}{\}}{0pt}{0}{\left\vert A\right\vert }{\left\vert X\right\vert }%
%EndExpansion
$\\\hline
$U\rightarrow U$ & $\sum\limits_{k=0}^{\left\vert X\right\vert }p_{k}\left(
\left\vert A\right\vert \right)  $ & $\left[  \left\vert A\right\vert
\leq\left\vert X\right\vert \right]  $ & $p_{\left\vert X\right\vert }\left(
\left\vert A\right\vert \right)  $\\\hline
\end{tabular}
\ \ \ \ \ \ \ .
\]


\subsubsection{More about partition numbers}

The numbers $p_{k}\left(  n\right)  $ have many interesting properties. Yet
more mysterious are the numbers%
\[
p\left(  n\right)  :=\left(  \text{\# of all partitions of }n\right)
=\sum_{k=0}^{n}p_{k}\left(  n\right)  .
\]
These numbers $p\left(  n\right)  $ are called the \textbf{partition numbers};
here is a little table of some of them:%
\[%
\begin{tabular}
[c]{|c||c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}\hline
$n$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $9$ & $10$ & $11$
& $12$ & $13$ & $14$\\\hline
$p\left(  n\right)  $ & $1$ & $1$ & $2$ & $3$ & $5$ & $7$ & $11$ & $15$ & $22$
& $30$ & $42$ & $56$ & $77$ & $101$ & $135$\\\hline
\end{tabular}
\ \ \ .
\]
One of their most famous properties is the following recursion formula found
by Euler:

\begin{theorem}
[Euler's recursion for the partition numbers]\label{thm.pars.euler-rec}For
each $n>0$, we have%
\begin{equation}
p\left(  n\right)  =\sum_{\substack{k\in\mathbb{Z};\\k\neq0}}\left(
-1\right)  ^{k-1}p\left(  n-w_{k}\right)  . \label{eq.thm.pars.euler-rec.eq}%
\end{equation}
Here, the numbers $w_{k}$ are the so-called \textbf{pentagonal numbers},
defined by%
\[
w_{k}:=\dfrac{\left(  3k-1\right)  k}{2}\ \ \ \ \ \ \ \ \ \ \text{for each
}k\in\mathbb{Z}.
\]
Here is a little table of the smallest few of them:%
\[%
\begin{tabular}
[c]{|c||c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}\hline
$k$ & $-7$ & $-6$ & $-5$ & $-4$ & $-3$ & $-2$ & $-1$ & $0$ & $1$ & $2$ & $3$ &
$4$ & $5$ & $6$ & $7$\\\hline
$w_{k}$ & $77$ & $57$ & $40$ & $26$ & $15$ & $7$ & $2$ & $0$ & $1$ & $5$ &
$12$ & $22$ & $35$ & $51$ & $70$\\\hline
\end{tabular}
\ \ \ \ .
\]
Note that they decrease for $k\leq0$ and increase for $k\geq0$. For each given
$n$, only finitely many addends on the right hand side of
(\ref{eq.thm.pars.euler-rec.eq}) are nonzero (because if $\left\vert
k\right\vert $ is sufficiently large, we have $w_{k}>n$ and thus $p\left(
n-w_{k}\right)  =p\left(  \text{something negative}\right)  =0$), and
therefore the infinite sum in (\ref{eq.thm.pars.euler-rec.eq}) is
well-defined. \textquotedblleft Explicitly\textquotedblright,
(\ref{eq.thm.pars.euler-rec.eq}) takes the form%
\begin{align*}
p\left(  n\right)   &  =p\left(  n-1\right)  +p\left(  n-2\right)  -p\left(
n-5\right)  -p\left(  n-7\right)  +p\left(  n-12\right)  +p\left(  n-15\right)
\\
&  \ \ \ \ \ \ \ \ \ \ -p\left(  n-22\right)  -p\left(  n-26\right)  \pm
\cdots.
\end{align*}

\end{theorem}

For a proof of Theorem \ref{thm.pars.euler-rec}, see a graduate course on
combinatorics (e.g., \cite[Corollary 4.2.3]{21s}). Readers familiar with power
series should take a look at
\href{https://en.wikipedia.org/wiki/Pentagonal_number_theorem}{the Wikipedia
page for Euler's Pentagonal Number Theorem}, of which Theorem
\ref{thm.pars.euler-rec} is an easy corollary. (Self-contained proofs of
Euler's Pentagonal Number Theorem can also be found in \cite[\S 3]{Bell06},
\cite[\S 10]{Koch16}, \cite{Zabroc03} or \cite[\S 2.6--\S 2.7]{Sills12}.)

Interested in more? A book-length introduction to the vast and deep theory of
partitions is \cite{AndEri04} (although it is not always fully rigorous, but
it gives a good idea of how results in this subject look like). My notes
\cite[Chapter 4]{21s} give an introduction as well (more detailed but also
much more modest in coverage). Most advanced courses in enumerative (or
algebraic) combinatorics contain at least some material on partitions.

\begin{thebibliography}{99999999}                                                                                         %


\bibitem[18s-hw3s]{18s-hw3s}Darij Grinberg, \textit{UMN Spring 2018 Math 4707
homework set \#3 with solutions}, \url{http://www.cip.ifi.lmu.de/~grinberg/t/18s/hw3s.pdf}

\bibitem[21s]{21s}Darij Grinberg, \textit{Algebraic Combinatorics (Drexel
Spring 2021 Math 701 lecture notes)}, 4 May 2021.\newline\url{https://www.cip.ifi.lmu.de/~grinberg/t/21s/lecs.pdf}

\bibitem[AndEri04]{AndEri04}%
\href{https://doi.org/10.1017/CBO9781139167239}{George E. Andrews, Kimmo
Eriksson, \textit{Integer Partitions}, Cambridge University Press 2004}.

\bibitem[Bell06]{Bell06}\href{https://arxiv.org/abs/math/0510054v2}{Jordan
Bell, \textit{Euler and the pentagonal number theorem}, arXiv:math/0510054v2}.

\bibitem[Guicha20]{Guicha20}David Guichard, \textit{An Introduction to
Combinatorics and Graph Theory}, 11 August 2022.\newline\url{https://www.whitman.edu/mathematics/cgt_online/book/}

\bibitem[Johnso02]{Johnso02}%
\href{https://www.maa.org/sites/default/files/pdf/upload_library/22/Ford/Johnson217-234.pdf}{Warren
P. Johnson, \textit{The Curious History of Fa\`{a} di Bruno's Formula},
American Mathematical Monthly \textbf{109} (2002), March, pp. 217--234.}

\bibitem[Koch16]{Koch16}Dick Koch, \textit{The Pentagonal Number Theorem and
All That}, 26 August 2016.\newline\url{https://darkwing.uoregon.edu/~koch/PentagonalNumbers.pdf}

\bibitem[Sills12]{Sills12}Andrew V. Sills, \textit{Supplemental Notes for
Number Theory}, 29 January 2012.\newline\url{http://home.dimacs.rutgers.edu/~asills/teach/spr12/NumberTheoryCopy.pdf}

\bibitem[Zabroc03]{Zabroc03}Mike Zabrocki, \textit{F. Franklin's proof of
Euler's pentagonal number theorem}, 28 February 2003.\newline\url{https://garsia.math.yorku.ca/~zabrocki/math4160w03/eulerpnt.pdf}
\end{thebibliography}


\end{document}