\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=Sunday, December 17, 2023 01:05:49}
%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{\of}{\text{ of }}
\newtheoremstyle{plainsl}
{8pt plus 2pt minus 4pt}
{8pt plus 2pt minus 4pt}
{\slshape}
{0pt}
{\bfseries}
{.}
{5pt plus 1pt minus 1pt}
{}
\theoremstyle{plainsl}
\ihead{Lecture 18, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 221 Winter 2023, Lecture 18: Enumeration}

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

\setcounter{section}{3}

\section{An introduction to enumeration}

\setcounter{subsection}{10}

\subsection{Selections}

We now come back to a class of problems that we have posed at the start of
Chapter 4 (Lecture 12) but haven't fully answered yet: counting the ways to
select a bunch of elements from a given set.

To be more specific, these are problems of the following form: Given an
$n$-element set $S$, how many ways are there to select $k$ elements from $S$
(where $n$ and $k$ are fixed nonnegative integers)?

The words \textquotedblleft$k$ elements\textquotedblright\ in this question
are ambiguous, as they allow for several interpretations:

\begin{enumerate}
\item Do we want $k$ arbitrary elements or $k$ distinct elements?

\item Does the order of these $k$ elements matter or not? (In other words,
would \textquotedblleft$1,2$\textquotedblright\ and \textquotedblleft%
$2,1$\textquotedblright\ count as two different selections?)
\end{enumerate}

In total, these decisions leave you with $4$ options, leading to $4$ different
problems. In this section, we shall address them all.

\subsubsection{Unordered selections without repetition (= without
replacement)}

Let us begin with the case when we want to select $k$ distinct elements, and
the order does not matter. This just means selecting a $k$-element subset of
$S$. We already know how to count these subsets (Theorem 4.7.4 in Lecture 16):

\begin{theorem}
\label{thm.count.select.subset}Let $n\in\mathbb{N}$, and let $k$ be any
number. Let $S$ be an $n$-element set. Then,%
\[
\left(  \text{\# of }k\text{-element subsets of }S\right)  =\dbinom{n}{k}.
\]

\end{theorem}

In other words, the \# of ways to choose $k$ distinct elements from a given
$n$-element set $S$, if the order does not matter, is $\dbinom{n}{k}$.

\subsubsection{Ordered selections without repetition (= without replacement)}

Now, let us consider the case when the order does matter. Thus, we are looking
not for subsets, but for $k$-tuples. But these $k$-tuples are not arbitrary
$k$-tuples; they are $k$-tuples of \textbf{distinct} elements. We shall call
such $k$-tuples \textbf{injective} (in analogy to injective functions):

\begin{definition}
\label{def.count.select.inj-k-tuple}Let $k\in\mathbb{N}$. A $k$-tuple $\left(
i_{1},i_{2},\ldots,i_{k}\right)  $ is said to be \textbf{injective} if its $k$
entries $i_{1},i_{2},\ldots,i_{k}$ are distinct (i.e., if we have $i_{a}\neq
i_{b}$ for all $a\neq b$).
\end{definition}

For example, the $3$-tuple $\left(  6,1,2\right)  $ is injective, but $\left(
2,1,2\right)  $ is not.

Note that injective $k$-tuples and injective functions are closely related: A
function $f:\left[  k\right]  \rightarrow S$ (for a set $S$ and a number
$k\in\mathbb{N}$) is injective if and only if the $k$-tuple $\left(  f\left(
1\right)  ,\ f\left(  2\right)  ,\ \ldots,\ f\left(  k\right)  \right)  $ is injective.

Next, we introduce another convenient notation:

\begin{definition}
Let $S$ be any set, and let $k\in\mathbb{N}$. Then, $S^{k}$ shall mean the
Cartesian product%
\begin{align*}
\underbrace{S\times S\times\cdots\times S}_{k\text{ times}}  &  =\left\{
\left(  a_{1},a_{2},\ldots,a_{k}\right)  \ \mid\ a_{1},a_{2},\ldots,a_{k}\in
S\right\} \\
&  =\left\{  k\text{-tuples whose all entries belong to }S\right\}  .
\end{align*}

\end{definition}

For example, $\left\{  5,6\right\}  ^{3}$ is the set
\begin{align*}
&  \left\{  5,6\right\}  \times\left\{  5,6\right\}  \times\left\{
5,6\right\} \\
&  =\left\{  \left(  5,5,5\right)  ,\ \left(  5,5,6\right)  ,\ \left(
5,6,5\right)  ,\ \left(  5,6,6\right)  ,\ \left(  6,5,5\right)  ,\ \left(
6,5,6\right)  ,\ \left(  6,6,5\right)  ,\ \left(  6,6,6\right)  \right\}  .
\end{align*}
None of the $3$-tuples (i.e., triples) in this set is injective, but it is
easy to find an example where injective $k$-tuples do appear: For instance,
the set $\left\{  1,2,3,4\right\}  ^{3}$ contains both injective $3$-tuples
such as $\left(  1,4,3\right)  $ and non-injective $3$-tuples such as $\left(
3,3,1\right)  $.

Now, we can define rigorously what we are looking for: A way to select $k$
distinct elements from a given set $S$, if the order matters, is the same as
an injective $k$-tuple in $S^{k}$. We shall now count such ways:

\begin{theorem}
\label{thm.count.select.injtup}Let $n\in\mathbb{N}$ and $k\in\mathbb{N}$. Let
$S$ be an $n$-element set. Then,%
\[
\left(  \text{\# of injective }k\text{-tuples in }S^{k}\right)  =n\left(
n-1\right)  \left(  n-2\right)  \cdots\left(  n-k+1\right)  .
\]

\end{theorem}

\begin{example}
Applying Theorem \ref{thm.count.select.injtup} to $n=5$, $k=3$ and $S=\left\{
1,2,3,4,5\right\}  $, we find that%
\[
\left(  \text{\# of injective }3\text{-tuples in }\left\{  1,2,3,4,5\right\}
^{3}\right)  =5\left(  5-1\right)  \left(  5-2\right)  =5\cdot4\cdot3=60.
\]
And indeed, there are $60$ injective $3$-tuples in $\left\{
1,2,3,4,5\right\}  ^{3}$. For example, $\left(  2,5,4\right)  $ and $\left(
5,3,2\right)  $ are two of them.
\end{example}

Note that the right hand side in Theorem \ref{thm.count.select.injtup} is
precisely the numerator in the definition of the binomial coefficient
$\dbinom{n}{k}$ (Definition 2.4.1 in Lecture 5), and thus can be rewritten as
$k!\cdot\dbinom{n}{k}$ (since $k!$ is the denominator). Thus, the claim of
Theorem \ref{thm.count.select.injtup} can be restated as
\[
\left(  \text{\# of injective }k\text{-tuples in }S^{k}\right)  =k!\cdot
\dbinom{n}{k}.
\]


Now, how do we prove the theorem? Let us first give an informal proof:

\begin{proof}
[Informal proof of Theorem \ref{thm.count.select.injtup}.]Let us look at an
example (which is representative of the general case): We let $n=5$ and $k=3$
and $S=\left\{  a,b,c,d,e\right\}  $. How many injective $k$-tuples are there
in $S^{k}$ ? In other words (since $k=3$): How many injective $3$-tuples are
there in $S^{3}$ ?

Such a $3$-tuple has the form $\left(  x,y,z\right)  $, where $x,y,z$ are
three distinct elements of $S$. Let us see how such a $3$-tuple can be chosen:

\begin{enumerate}
\item First, we choose its first entry $x$. There are $5$ options for this,
since $S$ has $5$ elements (and $x$ can be any of these $5$).

\item Then, we choose its second entry $y$. There are $4$ options for it,
since $y$ can be any of the $5$ elements of $S$ except for $x$ (because the
injectivity of $\left(  x,y,z\right)  $ demands $y$ to be distinct from $x$).

\item Finally, we choose its third entry $z$. There are $3$ options for it,
since $z$ can be any of the $5$ elements of $S$ except for $x$ and $y$
(because the injectivity of $\left(  x,y,z\right)  $ demands $z$ to be
distinct from $x$ and $y$) and since $x$ and $y$ are already distinct.
\end{enumerate}

Altogether, we have $5$ options at the first step, then $4$ options at the
second step (no matter which option has been chosen at the first step), and
finally $3$ options at the third step. Altogether, we can therefore choose our
$3$-tuple in $5\cdot4\cdot3$ many different ways, because the numbers of
options multiply. Here, we have used a counting rule called \textquotedblleft%
\textbf{dependent product rule}\textquotedblright, which informally says that
if we perform a multi-step construction, and we have

\begin{itemize}
\item exactly $n_{1}$ options in step $1$,

\item exactly $n_{2}$ options in step $2$,

\item $\ldots$,

\item exactly $n_{k}$ options in step $k$,
\end{itemize}

\noindent then the entire construction can be performed in $n_{1}n_{2}\cdots
n_{k}$ many different ways. We shall not formalize this rule (let alone prove
it); the reader can find rigorous versions of this rule in \cite[\S 1.8]%
{Loehr-BC} and in \cite[Theorem 8.1.19]{Newste22}. However, we shall next give
a more rigorous proof of Theorem \ref{thm.count.select.injtup}, which uses
induction on $k$ instead of this \textquotedblleft dependent product
rule\textquotedblright\ (although the underlying idea is the same).
\end{proof}

\begin{proof}
[Rigorous proof of Theorem \ref{thm.count.select.injtup}.]Forget that we fixed
$S$ and $n$. We thus must prove the statement%
\[
P\left(  k\right)  :=\left(
\begin{array}
[c]{c}%
\text{\textquotedblleft for all }n\in\mathbb{N}\text{ and all }n\text{-element
sets }S\text{, we have}\\
\left(  \text{\# of injective }k\text{-tuples in }S^{k}\right)  =n\left(
n-1\right)  \left(  n-2\right)  \cdots\left(  n-k+1\right)
\text{\textquotedblright}%
\end{array}
\right)
\]
for each $k\in\mathbb{N}$. We shall prove this by induction on $k$.

\textit{Base case:} We must prove that $P\left(  0\right)  $ holds. In other
words, we must prove that for all $n\in\mathbb{N}$ and all $n$-element sets
$S$, we have%
\[
\left(  \text{\# of injective }0\text{-tuples in }S^{0}\right)  =n\left(
n-1\right)  \left(  n-2\right)  \cdots\left(  n-0+1\right)  .
\]
But this is an easy exercise in understanding emptiness: Let $n\in\mathbb{N}$,
and let $S$ be an $n$-element set. The only $0$-tuple in $S^{0}$ is $\left(
{}\right)  $, and this $0$-tuple is injective. Thus,%
\[
\left(  \text{\# of injective }0\text{-tuples in }S^{0}\right)  =1\text{.}%
\]
Comparing this with%
\[
n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-0+1\right)  =\left(
\text{empty product}\right)  =1,
\]
we obtain $\left(  \text{\# of injective }0\text{-tuples in }S^{0}\right)
=n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-0+1\right)  $. Thus,
$P\left(  0\right)  $ is proved. This completes the base case.

\textit{Induction step:} Let $k$ be a positive integer. Assume (as the
induction hypothesis) that $P\left(  k-1\right)  $ holds. Our goal is to prove
$P\left(  k\right)  $.

We have assumed that $P\left(  k-1\right)  $ holds. In other words, for all
$n\in\mathbb{N}$ and all $n$-element sets $S$, we have%
\begin{align}
&  \left(  \text{\# of injective }\left(  k-1\right)  \text{-tuples in
}S^{k-1}\right) \nonumber\\
&  =n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-\left(
k-1\right)  +1\right)  . \label{pf.thm.count.select.injtup.IH}%
\end{align}


Now, let us focus on proving $P\left(  k\right)  $. Thus, we fix an
$n\in\mathbb{N}$ and an $n$-element set $S$. Our goal is then to prove that%
\[
\left(  \text{\# of injective }k\text{-tuples in }S^{k}\right)  \overset{?}{=}%
n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-k+1\right)  .
\]
(Again, the question mark atop the equality sign reminds us that this is not
proved yet.)

Let $s_{1},s_{2},\ldots,s_{n}$ be the $n$ elements of $S$ (listed without
repetition). Then, any $k$-tuple in $S^{k}$ ends\footnote{We say that a
$k$-tuple \textbf{ends} with a given element $b$ if $b$ is the last entry of
this $k$-tuple. Note that every $k$-tuple does indeed have a last entry, since
$k$ is positive.} with exactly one of $s_{1},s_{2},\ldots,s_{n}$. Hence, by
the sum rule, we have%
\begin{align}
&  \left(  \text{\# of injective }k\text{-tuples in }S^{k}\right) \nonumber\\
&  =\left(  \text{\# of injective }k\text{-tuples in }S^{k}\text{ that end
with }s_{1}\right) \nonumber\\
&  \ \ \ \ \ \ \ \ \ \ +\left(  \text{\# of injective }k\text{-tuples in
}S^{k}\text{ that end with }s_{2}\right) \nonumber\\
&  \ \ \ \ \ \ \ \ \ \ +\cdots\nonumber\\
&  \ \ \ \ \ \ \ \ \ \ +\left(  \text{\# of injective }k\text{-tuples in
}S^{k}\text{ that end with }s_{n}\right) \nonumber\\
&  =\sum_{i=1}^{n}\left(  \text{\# of injective }k\text{-tuples in }%
S^{k}\text{ that end with }s_{i}\right)  .
\label{pf.thm.count.select.injtup.sum}%
\end{align}
Now, we shall compute the addends in this sum.

Fix any $i\in\left[  n\right]  $. An injective $k$-tuple in $S^{k}$ that ends
with $s_{i}$ must have the form%
\[
\left(  \ldots,s_{i}\right)  ,
\]
where the \textquotedblleft$\ldots$\textquotedblright\ are $k-1$ distinct
elements of $S\setminus\left\{  s_{i}\right\}  $ (not merely of $S$, but
actually of $S\setminus\left\{  s_{i}\right\}  $, because if any of them was
$s_{i}$, then our $k$-tuple would contain the entry $s_{i}$ twice and thus
fail to be injective). In other words, an injective $k$-tuple in $S^{k}$ that
ends with $s_{i}$ is an injective $\left(  k-1\right)  $-tuple in $\left(
S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}$ followed by the entry
$s_{i}$. Thus, we obtain a map%
\begin{align*}
\left\{  \text{injective }k\text{-tuples in }S^{k}\text{ that end with }%
s_{i}\right\}   &  \rightarrow\left\{  \text{injective }\left(  k-1\right)
\text{-tuples in }\left(  S\setminus\left\{  s_{i}\right\}  \right)
^{k-1}\right\}  ,\\
\left(  \ldots,s_{i}\right)   &  \mapsto\left(  \ldots\right)
\end{align*}
(which removes the last entry from our $k$-tuple and leaves the other entries
as they are)\footnote{For example, if $k=4$, then this map sends a $k$-tuple
$\left(  a,b,c,s_{i}\right)  $ to $\left(  a,b,c\right)  $.}. Conversely, we
have a map%
\begin{align*}
\left\{  \text{injective }\left(  k-1\right)  \text{-tuples in }\left(
S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}\right\}   &  \rightarrow
\left\{  \text{injective }k\text{-tuples in }S^{k}\text{ that end with }%
s_{i}\right\}  ,\\
\left(  \ldots\right)   &  \mapsto\left(  \ldots,s_{i}\right)
\end{align*}
(which inserts an $s_{i}$ after the end of a $\left(  k-1\right)  $-tuple; the
result is still injective\footnote{\textit{Proof.} We must show that if we
insert an $s_{i}$ after the end of an injective $\left(  k-1\right)  $-tuple
in $\left(  S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}$, then the
result is still injective.
\par
Indeed, the only way this could fail is if the newly inserted entry $s_{i}$
would already appear in the original $\left(  k-1\right)  $-tuple. However,
this is impossible, since the original $\left(  k-1\right)  $-tuple belongs to
$\left(  S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}$ and thus cannot
contain the entry $s_{i}$.})\footnote{For example, if $k=4$, then this map
sends a $\left(  k-1\right)  $-tuple $\left(  a,b,c\right)  $ to $\left(
a,b,c,s_{i}\right)  $.}. These two maps are clearly inverses of each
other\footnote{because a $k$-tuple that ends with $s_{i}$ stays unchanged if
we replace its last entry with $s_{i}$}, and thus are bijections. Hence, the
bijection principle yields%
\begin{align*}
&  \left(  \text{\# of injective }k\text{-tuples in }S^{k}\text{ that end with
}s_{i}\right) \\
&  =\left(  \text{\# of injective }\left(  k-1\right)  \text{-tuples in
}\left(  S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}\right)  .
\end{align*}


However, recall our induction hypothesis (\ref{pf.thm.count.select.injtup.IH}%
). We have $\left\vert S\right\vert =n$ (since $S$ is an $n$-element set).
Since $s_{i}$ is an element of $S$, the set $\left\{  s_{i}\right\}  $ is a
subset of $S$. Thus, the difference rule (Theorem 4.6.7 \textbf{(b)} in
Lecture 16) yields%
\[
\left\vert S\setminus\left\{  s_{i}\right\}  \right\vert
=\underbrace{\left\vert S\right\vert }_{=n}-\underbrace{\left\vert \left\{
s_{i}\right\}  \right\vert }_{=1}=n-1,
\]
so that $S\setminus\left\{  s_{i}\right\}  $ is an $\left(  n-1\right)
$-element set, and we have $n-1=\left\vert S\setminus\left\{  s_{i}\right\}
\right\vert \in\mathbb{N}$. Hence, we can apply
(\ref{pf.thm.count.select.injtup.IH}) to $n-1$ and $S\setminus\left\{
s_{i}\right\}  $ instead of $n$ and $S$ (because
(\ref{pf.thm.count.select.injtup.IH}) is a \textquotedblleft for all
$n\in\mathbb{N}$\textquotedblright\ statement, not just a statement about the
specific $n$ that we have fixed right now!). As a result, we obtain%
\begin{align*}
&  \left(  \text{\# of injective }\left(  k-1\right)  \text{-tuples in
}\left(  S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}\right) \\
&  =\left(  n-1\right)  \underbrace{\left(  \left(  n-1\right)  -1\right)
}_{=n-2}\underbrace{\left(  \left(  n-1\right)  -2\right)  }_{=n-3}%
\cdots\underbrace{\left(  \left(  n-1\right)  -\left(  k-1\right)  +1\right)
}_{=n-k+1}\\
&  =\left(  n-1\right)  \left(  n-2\right)  \left(  n-3\right)  \cdots\left(
n-k+1\right)  .
\end{align*}
Combining what we have found, we obtain%
\begin{align*}
&  \left(  \text{\# of injective }k\text{-tuples in }S^{k}\text{ that end with
}s_{i}\right) \\
&  =\left(  \text{\# of injective }\left(  k-1\right)  \text{-tuples in
}\left(  S\setminus\left\{  s_{i}\right\}  \right)  ^{k-1}\right) \\
&  =\left(  n-1\right)  \left(  n-2\right)  \left(  n-3\right)  \cdots\left(
n-k+1\right)  .
\end{align*}


Now, forget that we fixed $i$. We have thus proved that%
\begin{align}
&  \left(  \text{\# of injective }k\text{-tuples in }S^{k}\text{ that end with
}s_{i}\right) \nonumber\\
&  =\left(  n-1\right)  \left(  n-2\right)  \left(  n-3\right)  \cdots\left(
n-k+1\right)  \label{pf.thm.count.select.injtup.si}%
\end{align}
for \textbf{every} $i\in\left[  n\right]  $. Therefore,
(\ref{pf.thm.count.select.injtup.sum}) becomes%
\begin{align*}
&  \left(  \text{\# of injective }k\text{-tuples in }S^{k}\right) \\
&  =\sum_{i=1}^{n}\underbrace{\left(  \text{\# of injective }k\text{-tuples in
}S^{k}\text{ that end with }s_{i}\right)  }_{\substack{=\left(  n-1\right)
\left(  n-2\right)  \left(  n-3\right)  \cdots\left(  n-k+1\right)
\\\text{(by (\ref{pf.thm.count.select.injtup.si}))}}}\\
&  =\sum_{i=1}^{n}\left(  n-1\right)  \left(  n-2\right)  \left(  n-3\right)
\cdots\left(  n-k+1\right) \\
&  =n\cdot\left(  n-1\right)  \left(  n-2\right)  \left(  n-3\right)
\cdots\left(  n-k+1\right) \\
&  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(  \text{since }\sum_{i=1}%
^{n}a=na\text{ for any number }a\right) \\
&  =n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-k+1\right)  .
\end{align*}


Forget that we fixed $n$ and $S$. We thus have proved that for all
$n\in\mathbb{N}$ and all $n$-element sets $S$, we have%
\[
\left(  \text{\# of injective }k\text{-tuples in }S^{k}\right)  =n\left(
n-1\right)  \left(  n-2\right)  \cdots\left(  n-k+1\right)  .
\]
In other words, we have proved $P\left(  k\right)  $. Thus, the induction step
is complete, and Theorem \ref{thm.count.select.injtup} is proved.
\end{proof}

\subsubsection{Intermezzo: Listing $n$ elements}

Theorem \ref{thm.count.select.injtup} tells us that if $S$ is an $n$-element
set, then the \# of ways to choose $k$ distinct elements from $S$, if the
order matters, is%
\[
n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-k+1\right)
=k!\cdot\dbinom{n}{k}.
\]


In particular, applying this to $k=n$, we conclude that the \# of ways to
choose $n$ distinct elements from $S$, if the order matters, is%
\[
n\left(  n-1\right)  \left(  n-2\right)  \cdots\left(  n-n+1\right)
=n!\cdot\underbrace{\dbinom{n}{n}}_{\substack{=1\\\text{(by Corollary
2.5.9}\\\text{in Lecture 6)}}}=n!.
\]


Of course, when we are choosing $n$ distinct elements from an $n$-element set,
we are not actually choosing the elements (since all elements have to be
chosen\footnote{This follows from Theorem 4.6.7 \textbf{(c)} in Lecture 16.});
we are only choosing the order in which we list them. So what we have just
shown (if somewhat informally) is the following result:

\begin{corollary}
\label{cor.count.select.order-n!}Let $n\in\mathbb{N}$. Let $S$ be an
$n$-element set. Then, the \# of ways to list the $n$ elements of $S$ in some
order (that is, the \# of $n$-tuples that contain each element of $S$ exactly
once) is $n!$.
\end{corollary}

\begin{example}
Applying Corollary \ref{cor.count.select.order-n!} to $n=3$ and $S=\left\{
1,2,3\right\}  $, we see that the \# of ways to list the $3$ numbers $1,2,3$
in some order (i.e., the \# of $3$-tuples that contain each of the numbers
$1,2,3$ exactly once) is $3!=6$. And indeed, here are these $6$ ways:%
\[
\left(  1,2,3\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  1,3,2\right)
,\ \ \ \ \ \ \ \ \ \ \left(  2,1,3\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
2,3,1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  3,1,2\right)
,\ \ \ \ \ \ \ \ \ \ \left(  3,2,1\right)  .
\]

\end{example}

Corollary \ref{cor.count.select.order-n!} is one of the reasons why factorials
are ubiquitous in combinatorics. The $n!$ ways to list the $n$ elements of a
given $n$-element set $S$ are sometimes called the \textquotedblleft
permutations\textquotedblright\ of $S$, but this name is more frequently used
for the bijective maps from $S$ to $S$. (The \# of the latter maps is also
$n!$, and the two concepts are closely related. For details, see
\cite[\S 1.7.4 in Lecture 13]{Math222}. See also \cite[Lectures 26--28]%
{Math222} for much more about permutations.)

\subsubsection{Ordered selections with repetition (= with replacement)}

We have now solved two variants of our \textquotedblleft select $k$ out of
$n$\textquotedblright\ counting question. We have two more variants to go: the
ones where the $k$ elements are arbitrary (not necessarily distinct). Again,
we have the choice of caring or not caring about their order.

If we care about their order, then we are just counting all $k$-tuples in
$S^{k}$. The answer to this question is simple:

\begin{theorem}
\label{thm.count.select.tup}Let $n\in\mathbb{N}$ and $k\in\mathbb{N}$. Let $S$
be an $n$-element set. Then,%
\[
\left(  \text{\# of all }k\text{-tuples in }S^{k}\right)  =n^{k}.
\]

\end{theorem}

\begin{proof}
The set $S$ is an $n$-element set; in other words, $\left\vert S\right\vert
=n$. Now,%
\begin{align*}
&  \left(  \text{\# of all }k\text{-tuples in }S^{k}\right) \\
&  =\left\vert S^{k}\right\vert =\left\vert \underbrace{S\times S\times
\cdots\times S}_{k\text{ times}}\right\vert \ \ \ \ \ \ \ \ \ \ \left(
\text{since }S^{k}\text{ is defined to be }\underbrace{S\times S\times
\cdots\times S}_{k\text{ times}}\right) \\
&  =\underbrace{\left\vert S\right\vert \cdot\left\vert S\right\vert
\cdot\cdots\cdot\left\vert S\right\vert }_{k\text{ times}}%
\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{by the product rule for }k\text{ sets}\\
\text{(Theorem 4.6.9 in Lecture 16)}%
\end{array}
\right) \\
&  =\left\vert S\right\vert ^{k}=n^{k}\ \ \ \ \ \ \ \ \ \ \left(  \text{since
}\left\vert S\right\vert =n\right)  .
\end{align*}
This proves Theorem \ref{thm.count.select.tup}.
\end{proof}

\subsubsection{Unordered selections with repetition (= with replacement)}

Now only one question remains: What is the \# of ways to choose $k$ arbitrary
elements from an $n$-element set $S$ if we \textbf{don't} care about their order?

There are several equivalent ways to rigorously define what this means:

\begin{enumerate}
\item We can define the notion of a \textbf{multiset}, which is
\textquotedblleft like a finite set but allowing an element to be contained
multiple times\textquotedblright. This is done, e.g., in \cite[\S 2.9
(Lectures 21--22)]{Math222} or (in more detail) in \cite[\S 2.11]{19fco}.
Then, a selection of $k$ arbitrary elements from a set $S$, disregarding the
order, can be formalized as a size-$k$ multisubset of the set $S$.

\item Alternatively, we can define the notion of an \textbf{unordered }%
$k$\textbf{-tuple}, which is \textquotedblleft a $k$-tuple up to reordering
its entries\textquotedblright. Formally, these unordered $k$-tuples are
defined as the equivalence classes of usual (i.e., ordered) $k$-tuples with
respect to a certain equivalence relation. (See, e.g., \cite[Example
3.3.24]{19fco} for the details.) Then, a selection of $k$ arbitrary elements
from a set $S$, disregarding the order, can be formalized as an unordered
$k$-tuple of elements of $S$.

\item Finally, if we restrict ourselves to the case when $S=\left[  n\right]
$ (which case is sufficient for all practical purposes, since we can otherwise
rename the elements of $S$ as $1,2,\ldots,n$), then the following
\textquotedblleft low-tech\textquotedblright\ solution becomes available: We
say that a $k$-tuple $\left(  i_{1},i_{2},\ldots,i_{k}\right)  \in S^{k}$ is
\textbf{weakly increasing} (aka \textbf{sorted in weakly increasing order}) if
it satisfies $i_{1}\leq i_{2}\leq\cdots\leq i_{k}$. Now, a selection of $k$
arbitrary elements from $S=\left[  n\right]  $, disregarding the order, can be
defined as a weakly increasing $k$-tuple in $S^{k}$ (because if we don't care
about the order of our $k$ elements, then we can just as well sort them in
increasing order, and the result of such a sorting operation is clearly
unique\footnote{Clearly if you believe in common sense. Not so clearly if you
want a formal proof. See, e.g., \cite[Exercise 2.11.2]{19fco} for such a
proof.}).
\end{enumerate}

These three definitions yield different objects, but these objects are
equivalent, in the sense that there are bijections from each one to each
other. In particular, the \# of selections of $k$ arbitrary elements from $S$
(without regard for their order) does not depend on which way we define these
selections. Thus, when it comes to counting them, we can pick whatever
definition we prefer.

\begin{noncompile}
Now, instead of choosing $k$ elements of $S$ up to order, we shall choose a
\textbf{weakly increasing} (aka \textbf{sorted}) $k$-tuple in $S^{k}$: that
is, a $k$-tuple $\left(  i_{1},i_{2},\ldots,i_{k}\right)  \in S^{k}$ such that
$i_{1}\leq i_{2}\leq\cdots\leq i_{k}$. This is equivalent, because if you
don't care about the order of the entries of a $k$-tuple, then you can just
assume that they are arranged in increasing order. Any $k$-tuple of elements
of $S$ can be sorted into weakly increasing order, and two $k$-tuples are
equal up to order if and only if sorting makes them literally equal.
\end{noncompile}

Now that all the requisite warnings and disclaimers have been said, we can
finally count these selections:

\begin{theorem}
\label{thm.count.select.uotup-mulset}Let $n\in\mathbb{N}$ and $k\in\mathbb{N}%
$. Let $S$ be an $n$-element set. Then,%
\begin{align*}
&  \left(  \text{\# of all ways to select }k\text{ elements from }S\text{ (if
order does not matter)}\right) \\
&  =\dbinom{k+n-1}{k}%
\end{align*}
(where our $k$ elements don't have to be distinct).
\end{theorem}

\begin{example}
Applying Theorem \ref{thm.count.select.uotup-mulset} to $n=5$ and $k=2$ and
$S=\left[  5\right]  =\left\{  1,2,3,4,5\right\}  $, we obtain%
\begin{align*}
&  \left(  \text{\# of all ways to select }2\text{ elements from }\left[
5\right]  \text{ (if order does not matter)}\right) \\
&  =\dbinom{2+5-1}{2}=\dbinom{6}{2}=15.
\end{align*}
And indeed, here are these $15$ ways:%
\[%
\begin{array}
[c]{ccccc}%
\left(  1,1\right)  , & \left(  1,2\right)  , & \left(  1,3\right)  , &
\left(  1,4\right)  , & \left(  1,5\right)  ,\\
& \left(  2,2\right)  , & \left(  2,3\right)  , & \left(  2,4\right)  , &
\left(  2,5\right)  ,\\
&  & \left(  3,3\right)  , & \left(  3,4\right)  , & \left(  3,5\right)  ,\\
&  &  & \left(  4,4\right)  , & \left(  4,5\right)  ,\\
&  &  &  & \left(  5,5\right)  .
\end{array}
\]
Here, we have represented each of these selections as a weakly increasing
$k$-tuple in $S^{k}$ (as explained above).
\end{example}

\begin{proof}
[Informal proof of Theorem \ref{thm.count.select.uotup-mulset} (sketched).]For
the sake of simplicity, we assume that $S=\left[  n\right]  $ (since
otherwise, we can rename the $n$ elements of $S$ as $1,2,\ldots,n$). Then, as
we said above, a selection of $k$ arbitrary elements from $S=\left[  n\right]
$ (disregarding the order) can be defined as a weakly increasing $k$-tuple in
$S^{k}$. But a weakly increasing $k$-tuple in $S^{k}$ must always look as
follows:%
\[
\left(  \underbrace{1,1,\ldots,1}_{a_{1}\text{ many }1\text{'s}}%
,\underbrace{2,2,\ldots,2}_{a_{2}\text{ many }2\text{'s}},\ldots
,\underbrace{n,n,\ldots,n}_{a_{n}\text{ many }n\text{'s}}\right)
\]
for some numbers $a_{1},a_{2},\ldots,a_{n}\in\mathbb{N}$ (in particular, each
$a_{i}$ can be $0$, which means that $i$ does not appear in our $k$-tuple)
that satisfy $a_{1}+a_{2}+\cdots+a_{n}=k$ (because we want a $k$-tuple). Such
a $k$-tuple is uniquely determined by these numbers $a_{1},a_{2},\ldots,a_{n}%
$, and conversely, any choice of these numbers $a_{1},a_{2},\ldots,a_{n}$
leads to a different $k$-tuple.

Thus, there is a bijection
\begin{align*}
&  \text{from }\left\{  \text{weakly increasing }k\text{-tuples in }%
S^{k}\right\} \\
&  \text{to }\left\{  n\text{-tuples }\left(  a_{1},a_{2},\ldots,a_{n}\right)
\in\mathbb{N}^{n}\text{ satisfying }a_{1}+a_{2}+\cdots+a_{n}=k\right\}  .
\end{align*}
Hence, the bijection principle yields%
\begin{align*}
&  \left(  \text{\# of weakly increasing }k\text{-tuples in }S^{k}\right) \\
&  =\left(  \text{\# of }n\text{-tuples }\left(  a_{1},a_{2},\ldots
,a_{n}\right)  \in\mathbb{N}^{n}\text{ satisfying }a_{1}+a_{2}+\cdots
+a_{n}=k\right) \\
&  =\left(  \text{\# of weak compositions of }k\text{ into }n\text{
parts}\right) \\
&  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{since the }n\text{-tuples }\left(  a_{1},a_{2},\ldots,a_{n}\right)
\in\mathbb{N}^{n}\\
\text{satisfying }a_{1}+a_{2}+\cdots+a_{n}=k\\
\text{are precisely the weak compositions of }k\text{ into }n\text{ parts}%
\end{array}
\right) \\
&  =\dbinom{k+n-1}{k}\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{by Theorem 4.10.6 in Lecture 17,}\\
\text{applied to }k\text{ and }n\text{ instead of }n\text{ and }k
\end{array}
\right)  .
\end{align*}
This proves Theorem \ref{thm.count.select.uotup-mulset} (because these weakly
increasing $k$-tuples in $S^{k}$ are the ways to select $k$ elements from $S$
(if order does not matter)).

For a rigorous proof, see \cite[Corollary 2.11.3]{19fco} (but note that the
meanings of the letters $n$ and $k$ are switched in \cite[Corollary
2.11.3]{19fco}).
\end{proof}

Theorem \ref{thm.count.select.uotup-mulset} is our fifth combinatorial
interpretation of binomial coefficients so far! Previously, we have seen that
they count subsets (Theorem 4.7.4 in Lecture 16), lacunar subsets (Theorem
4.9.5 in Lecture 17), compositions (Theorem 4.10.3 in Lecture 17) and weak
compositions (Theorem 4.10.6 in Lecture 17). This all is not too surprising,
since we proved four of these five theorems using the bijection principle
(reducing them to previously proved theorems), but it is impressive to see so
many counting problems answered by the same family of numbers. \medskip

We have now solved all our four selection problems. We now come to a different
counting problem.

\subsection{Anagrams and multinomial coefficients}

\subsubsection{Counting anagrams}

An \textbf{anagram} of a given word $w$ means a word that consists of the same
letters as $w$ but possibly in a different order. For example:

\begin{itemize}
\item The anagrams of the word \textquotedblleft cat\textquotedblright\ are
\textquotedblleft act\textquotedblright, \textquotedblleft
atc\textquotedblright, \textquotedblleft cat\textquotedblright,
\textquotedblleft cta\textquotedblright, \textquotedblleft
tac\textquotedblright\ and \textquotedblleft tca\textquotedblright.

\item The word \textquotedblleft labl\textquotedblright\ is an anagram of
\textquotedblleft ball\textquotedblright\ (and so are several others).
\end{itemize}

As you see here, we make no distinction between meaningful and meaningless
words. (Also, being logically coherent at the expense of common sense, we
consider each word $w$ to be an anagram of itself.) \medskip

Now, we can take a given word $w$ and ask how many anagrams $w$ has. For instance:

\begin{itemize}
\item How many anagrams does the word \textquotedblleft cat\textquotedblright\ have?

It has six (and we have just listed them above). In fact, we can put the three
letters in any order, and there are $6$ possible orders (by Corollary
\ref{cor.count.select.order-n!}).

\item How many anagrams does the word \textquotedblleft dud\textquotedblright\ have?

It has three (\textquotedblleft dud\textquotedblright, \textquotedblleft
ddu\textquotedblright, \textquotedblleft udd\textquotedblright). Note that the
answer does not directly follow from Corollary \ref{cor.count.select.order-n!}%
, since two of the three letters are equal.

\item How many anagrams does the word \textquotedblleft ball\textquotedblright\ have?

It has $12$ of them: In fact, if the two \textquotedblleft l\textquotedblright
s were two different letters, then it would have $24$ anagrams (again by
Corollary \ref{cor.count.select.order-n!}), but since the two
\textquotedblleft l\textquotedblright s are the same, these $24$ anagrams
merge into pairs of equal words (you get \textquotedblleft
ball\textquotedblright\ twice, you get \textquotedblleft
blal\textquotedblright\ twice, etc.), so the answer is $\dfrac{24}{2}=12$.

(Not convinced? Good; it's worth to be skeptical about arguments like this.
Still, this argument can be made precise and rigorous. See \cite[first proof
of Theorem 1.46]{Loehr-BC} for this.)

\item How many anagrams does the word \textquotedblleft
bookkeeper\textquotedblright\ have?

Too many to list by brute force, and the \textquotedblleft divide by
$2$\textquotedblright\ technique from the previous example gets muddled
somewhat as there are several equal letters\footnote{Actually, the technique
can be salvaged, but this requires some carefulness that I am too lazy for
right now. (Once again, see \cite[first proof of Theorem 1.46]{Loehr-BC}.)}.

Thus, let us try a new strategy. The word \textquotedblleft
bookkeeper\textquotedblright\ has $10$ letters. Hence, any anagram of it is a
$10$-letter word as well. Its letters are%
\[
1\text{ \textquotedblleft b\textquotedblright,}\ \ \ \ \ \ \ \ \ \ 3\text{
\textquotedblleft e\textquotedblright s,}\ \ \ \ \ \ \ \ \ \ 2\text{
\textquotedblleft k\textquotedblright s,}\ \ \ \ \ \ \ \ \ \ 2\text{
\textquotedblleft o\textquotedblright s,}\ \ \ \ \ \ \ \ \ \ 1\text{
\textquotedblleft p\textquotedblright}\ \ \ \ \ \ \ \ \ \ \text{and }1\text{
\textquotedblleft r\textquotedblright.}%
\]
In order to choose an anagram of \textquotedblleft
bookkeeper\textquotedblright, we have to distribute all these letters into
$10$ positions. In other words, we have to choose which position the $1$
\textquotedblleft b\textquotedblright\ will occupy, which positions the $3$
\textquotedblleft e\textquotedblright s will occupy, and so on. Let us do this
step by step:

\begin{itemize}
\item We first choose the position of the $1$ \textquotedblleft
b\textquotedblright. There are $\dbinom{10}{1}$ many options for this, since
we need to choose a $1$-element subset of the set of all $10$ positions.

\item We then choose the positions of the $3$ \textquotedblleft
e\textquotedblright s. There are $\dbinom{9}{3}$ many options for this, since
we need to choose a $3$-element subset of the set of all $9$ positions not
already occupied.

\item We then choose the positions of the $2$ \textquotedblleft
k\textquotedblright s. There are $\dbinom{6}{2}$ many options for this, since
we need to choose a $2$-element subset of the set of all $6$ positions not
already occupied.

\item We then choose the positions of the $2$ \textquotedblleft
o\textquotedblright s. There are $\dbinom{4}{2}$ many options for this, since
we need to choose a $2$-element subset of the set of all $4$ positions not
already occupied.

\item We then choose the positions of the $1$ \textquotedblleft
p\textquotedblright. There are $\dbinom{2}{1}$ many options for this, since we
need to choose a $1$-element subset of the set of all $2$ positions not
already occupied.

\item We then choose the positions of the $1$ \textquotedblleft
r\textquotedblright. There are $\dbinom{1}{1}$ many options for this, since we
need to choose a $1$-element subset of the set of all $1$ positions not
already occupied.
\end{itemize}

By the dependent product rule (see the informal proof of Theorem
\ref{thm.count.select.injtup} above), the total \# of ways to perform this
construction is therefore%
\begin{align*}
&  \dbinom{10}{1}\cdot\dbinom{9}{3}\cdot\dbinom{6}{2}\cdot\dbinom{4}{2}%
\cdot\dbinom{2}{1}\cdot\dbinom{1}{1}\\
&  =\dfrac{10!}{1!\cdot9!}\cdot\dfrac{9!}{3!\cdot6!}\cdot\dfrac{6!}{2!\cdot
4!}\cdot\dfrac{4!}{2!\cdot2!}\cdot\dfrac{2!}{1!\cdot1!}\cdot\dfrac{1!}%
{1!\cdot0!}\\
&  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(  \text{by the factorial
formula (Theorem 2.5.5 in Lecture 6)}\right) \\
&  =\dfrac{10!}{1!\cdot3!\cdot2!\cdot2!\cdot1!\cdot1!\cdot0!}%
\ \ \ \ \ \ \ \ \ \ \left(  \text{by cancellations}\right) \\
&  =\dfrac{10!}{1!\cdot3!\cdot2!\cdot2!\cdot1!\cdot1!}%
\ \ \ \ \ \ \ \ \ \ \left(  \text{since }0!=1\right) \\
&  =151\,200.
\end{align*}
Thus, the word \textquotedblleft bookkeeper\textquotedblright\ has
$151\ 200=\dfrac{10!}{1!\cdot3!\cdot2!\cdot2!\cdot1!\cdot1!}$ anagrams.

\item How many anagrams does the word \textquotedblleft
anteater\textquotedblright\ have?

By the same logic as we just used, it has%
\[
\dfrac{8!}{2!\cdot2!\cdot1!\cdot1!\cdot2!}=5\ 040\text{ anagrams.}%
\]

\end{itemize}

The same argument works in the general case:

\begin{theorem}
\label{thm.count.anagrams}Let $s_{1},s_{2},\ldots,s_{n}$ be $n$ distinct
objects, and let $a_{1},a_{2},\ldots,a_{n}$ be $n$ nonnegative integers. Then,
the \# of tuples that consist of%
\begin{align*}
&  a_{1}\text{ copies of }s_{1},\\
&  a_{2}\text{ copies of }s_{2},\\
&  \ldots,\\
&  a_{n}\text{ copies of }s_{n}%
\end{align*}
is%
\[
\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{a_{1}!\cdot a_{2}%
!\cdot\cdots\cdot a_{n}!}=\prod_{k=1}^{n}\dbinom{a_{k}+a_{k+1}+\cdots+a_{n}%
}{a_{k}}.
\]

\end{theorem}

\begin{proof}
[Informal proof (sketched).]Follow the same logic as we used for
\textquotedblleft bookkeeper\textquotedblright\ above. To construct such a
tuple, we

\begin{itemize}
\item first choose the positions for the $a_{1}$ many $s_{1}$'s among its
entries (there are $\dbinom{a_{1}+a_{2}+\cdots+a_{n}}{a_{1}}$ many options for this);

\item then choose the positions for the $a_{2}$ many $s_{2}$'s among its
entries (there are $\dbinom{a_{2}+a_{3}+\cdots+a_{n}}{a_{2}}$ many options for this);

\item then choose the positions for the $a_{3}$ many $s_{3}$'s among its
entries (there are $\dbinom{a_{3}+a_{4}+\cdots+a_{n}}{a_{3}}$ many options for this);

\item and so on, until finally choosing the positions for the $a_{n}$ many
$s_{n}$'s among its entries (there are $\dbinom{a_{n}}{a_{n}}$ many options
for this).
\end{itemize}

By the dependent product rule, the total \# of such tuples is therefore%
\begin{align*}
&  \dbinom{a_{1}+a_{2}+\cdots+a_{n}}{a_{1}}\dbinom{a_{2}+a_{3}+\cdots+a_{n}%
}{a_{2}}\dbinom{a_{3}+a_{4}+\cdots+a_{n}}{a_{3}}\cdots\dbinom{a_{n}}{a_{n}}\\
&  =\prod_{k=1}^{n}\dbinom{a_{k}+a_{k+1}+\cdots+a_{n}}{a_{k}}\\
&  =\prod_{k=1}^{n}\dfrac{\left(  a_{k}+a_{k+1}+\cdots+a_{n}\right)  !}%
{a_{k}!\left(  \left(  a_{k}+a_{k+1}+\cdots+a_{n}\right)  -a_{k}\right)
!}\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{by the factorial formula}\\
\text{(Theorem 2.5.5 in Lecture 6)}%
\end{array}
\right) \\
&  =\prod_{k=1}^{n}\dfrac{\left(  a_{k}+a_{k+1}+\cdots+a_{n}\right)  !}%
{a_{k}!\left(  a_{k+1}+a_{k+2}+\cdots+a_{n}\right)  !}\\
&  =\dfrac{\prod_{k=1}^{n}\left(  a_{k}+a_{k+1}+\cdots+a_{n}\right)
!}{\left(  \prod_{k=1}^{n}a_{k}!\right)  \left(  \prod_{k=1}^{n}\left(
a_{k+1}+a_{k+2}+\cdots+a_{n}\right)  !\right)  }\\
&  =\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !\cdot\left(  a_{2}%
+a_{3}+\cdots+a_{n}\right)  !\cdot\cdots\cdot a_{n}!}{\left(  \prod_{k=1}%
^{n}a_{k}!\right)  \left(  \left(  a_{2}+a_{3}+\cdots+a_{n}\right)
!\cdot\left(  a_{3}+a_{4}+\cdots+a_{n}\right)  !\cdot\cdots\cdot a_{n}%
!\cdot0!\right)  }\\
&  =\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{\left(  \prod_{k=1}%
^{n}a_{k}!\right)  \cdot0!}\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{here, we have cancelled factors that appear}\\
\text{both in the numerator and the denominator}%
\end{array}
\right) \\
&  =\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{\prod_{k=1}^{n}a_{k}%
!}\ \ \ \ \ \ \ \ \ \ \left(  \text{since }0!=1\right) \\
&  =\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{a_{1}!\cdot a_{2}%
!\cdot\cdots\cdot a_{n}!}.
\end{align*}
This proves Theorem \ref{thm.count.anagrams}.

(For a rigorous proof, see \cite[Proposition 2.12.13]{19fco}. Note that the
objects $s_{1},s_{2},\ldots,s_{n}$ are required to be $1,2,\ldots,n$ in
\cite[Proposition 2.12.13]{19fco}, but this makes no serious difference, since
we can always rename them at will.)
\end{proof}

\begin{remark}
We can now answer the question \textquotedblleft how many prime factorizations
does a given number have?\textquotedblright\ from Lecture 12. For example,
consider the number $600=2^{3}\cdot3\cdot5^{2}$. A prime factorization of
$600$ is a tuple that consists of three $2$'s, one $3$ and two $5$'s, in an
arbitrary order. Thus, the \# of such prime factorizations is $\dfrac
{6!}{3!\cdot1!\cdot2!}$ (by Theorem \ref{thm.count.anagrams}). Similarly, we
can proceed for any positive integer instead of $600$.
\end{remark}

\subsubsection{Multinomial coefficients}

The number%
\[
\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{a_{1}!\cdot a_{2}%
!\cdot\cdots\cdot a_{n}!}%
\]
in Theorem \ref{thm.count.anagrams} has a name: It is called a
\textbf{multinomial coefficient}. By Theorem \ref{thm.count.anagrams}, it is
an integer (since it counts something), and can be rewritten as $\prod
_{k=1}^{n}\dbinom{a_{k}+a_{k+1}+\cdots+a_{n}}{a_{k}}$. Note that for $n=2$, it
becomes a binomial coefficient:%
\[
\dfrac{\left(  a+b\right)  !}{a!\cdot b!}=\dbinom{a+b}{a}.
\]


Multinomial coefficients have some further properties. There is a standard
notation for them: Namely, if $a_{1},a_{2},\ldots,a_{n}\in\mathbb{N}$ are any
nonnegative integers, and if we set $b=a_{1}+a_{2}+\cdots+a_{n}$, then the
multinomial coefficient%
\[
\dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{a_{1}!\cdot a_{2}%
!\cdot\cdots\cdot a_{n}!}=\dfrac{b!}{a_{1}!\cdot a_{2}!\cdot\cdots\cdot
a_{n}!}%
\]
is denoted by%
\[
\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}.
\]


As already mentioned, multinomial coefficients generalize the binomial
coefficients that are found in Pascal's triangle: With our new notation, a
binomial coefficient $\dbinom{n}{k}$ with $n\in\mathbb{N}$ and $k\in\left\{
0,1,\ldots,n\right\}  $ equals the multinomial coefficient $\dbinom
{n}{k,\ n-k}$. Pascal's identity (Theorem 2.5.3 in Lecture 6, at least for
$n>0$ and $k\in\left\{  0,1,\ldots,n\right\}  $) thus can be rewritten as%
\begin{align*}
\dbinom{b}{a_{1},a_{2}}  &  =\dbinom{b-1}{a_{1}-1,\ a_{2}}+\dbinom{b-1}%
{a_{1},\ a_{2}-1}\\
&  \ \ \ \ \ \ \ \ \ \ \text{for }b>0\text{ and }a_{1},a_{2}\in\mathbb{N}%
\text{ with }a_{1}+a_{2}=b,
\end{align*}
where we agree to interpret a multinomial coefficient with a negative number
at the bottom to mean $0$. An analogue of this identity holds for multinomial
coefficients with more parameters:

\begin{theorem}
[Recurrence of the multinomial coefficients]\label{thm.multinom.rec}Let
$b\in\mathbb{N}$ and $a_{1},a_{2},\ldots,a_{n}\in\mathbb{N}$ be such that
$a_{1}+a_{2}+\cdots+a_{n}=b>0$. Then,%
\[
\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}=\sum_{i=1}^{n}\underbrace{\dbinom
{b-1}{a_{1},\ldots,a_{i-1},a_{i}-1,a_{i+1},\ldots,a_{n}}}_{\text{This should
be interpreted as }0\text{ if }a_{i}=0}.
\]

\end{theorem}

\begin{proof}
Nice and fairly easy exercise! (See \cite[Exercise 2.12.6]{19fco} for a proof.)
\end{proof}

Just like the binomial coefficients $\dbinom{n}{k}$ with $n\in\mathbb{N}$ and
$k\in\left\{  0,1,\ldots,n\right\}  $ can be arranged into Pascal's triangle,
the multinomial coefficients $\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}$ (for a
given $n$) can be arranged into an $n$-dimensional analogue of Pascal's
triangle, called \textbf{Pascal's simplex} (or, for $n=3$, \textbf{Pascal's
pyramid}). Theorem \ref{thm.multinom.rec} then says that each entry in this
simplex (except for the $1$ at the apex) is the sum of its $n$ adjacent
entries just above it.

Multinomial coefficients owe their name to another fundamental property they
satisfy: a generalization of the binomial formula, called the
\textbf{multinomial formula}:

\begin{theorem}
[the multinomial formula]\label{thm.multinom.mulfor}Let $x_{1},x_{2}%
,\ldots,x_{n}$ be $n$ numbers. Let $b\in\mathbb{N}$. Then,%
\[
\left(  x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}=\sum_{\substack{\left(
a_{1},a_{2},\ldots,a_{n}\right)  \in\mathbb{N}^{n};\\a_{1}+a_{2}+\cdots
+a_{n}=b}}\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}x_{1}^{a_{1}}x_{2}^{a_{2}}\cdots
x_{n}^{a_{n}}.
\]

\end{theorem}

\begin{proof}
See \cite[Theorem 2.12.17]{19fco} (which gives two references). Here is the
simplest proof in a nutshell:

We expand $\left(  x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}$ and collect equal
terms. For instance, if $n=2$ and $b=3$, then%
\begin{align*}
&  \left(  x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}\\
&  =\left(  x_{1}+x_{2}\right)  ^{3}\\
&  =\left(  x_{1}+x_{2}\right)  \left(  x_{1}+x_{2}\right)  \left(
x_{1}+x_{2}\right)  \\
&  =x_{1}x_{1}x_{1}+x_{1}x_{1}x_{2}+x_{1}x_{2}x_{1}+x_{1}x_{2}x_{2}+x_{2}%
x_{1}x_{1}+x_{2}x_{1}x_{2}+x_{2}x_{2}x_{1}+x_{2}x_{2}x_{2}\\
&  =x_{1}^{3}+3x_{1}^{2}x_{2}+3x_{1}x_{2}^{2}+x_{2}^{3}.
\end{align*}


What terms do we get for general $n$ and $b$ ? Well, if we expand the product%
\begin{align*}
&  \left(  x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}\\
&  =\underbrace{\left(  x_{1}+x_{2}+\cdots+x_{n}\right)  \left(  x_{1}%
+x_{2}+\cdots+x_{n}\right)  \cdots\left(  x_{1}+x_{2}+\cdots+x_{n}\right)
}_{b\text{ times}},
\end{align*}
then we obtain the sum of all $n^{b}$ possible products of the form%
\[
x_{i_{1}}x_{i_{2}}\cdots x_{i_{b}}\text{ with }i_{1},i_{2},\ldots,i_{b}%
\in\left[  n\right]  .
\]
Each such product can be rewritten as the monomial $x_{1}^{a_{1}}x_{2}^{a_{2}%
}\cdots x_{n}^{a_{n}}$, where $a_{1}$ is the \# of $1$'s in the $b$-tuple
$\left(  i_{1},i_{2},\ldots,i_{b}\right)  $, where $a_{2}$ is the \# of $2$'s
in this $b$-tuple, and so on. Moreover, this monomial satisfies $a_{1}%
+a_{2}+\cdots+a_{n}=b$, since the total \# of entries of the $b$-tuple
$\left(  i_{1},i_{2},\ldots,i_{b}\right)  $ is $b$.

Thus, expanding $\left(  x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}$, we obtain a
sum of monomials of the form $x_{1}^{a_{1}}x_{2}^{a_{2}}\cdots x_{n}^{a_{n}}$
with $a_{1}+a_{2}+\cdots+a_{n}=b$, but each such monomial can appear several
times in this sum. The total \# of copies of a given monomial $x_{1}^{a_{1}%
}x_{2}^{a_{2}}\cdots x_{n}^{a_{n}}$ that appear in this sum equals the \# of
all $b$-tuples that consist of%
\begin{align*}
&  a_{1}\text{ copies of }1,\\
&  a_{2}\text{ copies of }2,\\
&  \ldots,\\
&  a_{n}\text{ copies of }n
\end{align*}
(because of the previous paragraph). But this latter \# equals
\begin{align*}
&  \dfrac{\left(  a_{1}+a_{2}+\cdots+a_{n}\right)  !}{a_{1}!\cdot a_{2}%
!\cdot\cdots\cdot a_{n}!}\ \ \ \ \ \ \ \ \ \ \left(  \text{by Theorem
\ref{thm.count.anagrams}}\right) \\
&  =\dfrac{b!}{a_{1}!\cdot a_{2}!\cdot\cdots\cdot a_{n}!}%
\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{since }a_{1}+a_{2}+\cdots+a_{n}=b\text{ (because}\\
\text{our }b\text{-tuple }\left(  i_{1},i_{2},\ldots,i_{b}\right)  \text{ has
}b\text{ entries in total)}%
\end{array}
\right) \\
&  =\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}\ \ \ \ \ \ \ \ \ \ \left(  \text{by
the definition of }\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}\right)  .
\end{align*}
Thus, each monomial $x_{1}^{a_{1}}x_{2}^{a_{2}}\cdots x_{n}^{a_{n}}$ with
$a_{1}+a_{2}+\cdots+a_{n}=b$ appears exactly $\dbinom{b}{a_{1},a_{2}%
,\ldots,a_{n}}$ times in the sum that we obtain by expanding $\left(
x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}$. Collecting all copies of each monomial
in this expansion, we thus obtain%
\[
\left(  x_{1}+x_{2}+\cdots+x_{n}\right)  ^{b}=\sum_{\substack{\left(
a_{1},a_{2},\ldots,a_{n}\right)  \in\mathbb{N}^{n};\\a_{1}+a_{2}+\cdots
+a_{n}=b}}\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}x_{1}^{a_{1}}x_{2}^{a_{2}}\cdots
x_{n}^{a_{n}}.
\]
This proves Theorem \ref{thm.multinom.mulfor}.
\end{proof}

We note that this yields a new proof of the binomial formula (Theorem 2.6.1 in
Lecture 6), since the latter formula is the particular case of Theorem
\ref{thm.multinom.mulfor} for $n=2$.

\begin{fineprint}
\begin{remark}
We note that Theorem \ref{thm.multinom.rec} can be used to give a second proof
of Theorem \ref{thm.count.anagrams}. Here is a rough outline of this proof:

A tuple that consists of%
\begin{align*}
&  a_{1}\text{ copies of }s_{1},\\
&  a_{2}\text{ copies of }s_{2},\\
&  \ldots,\\
&  a_{n}\text{ copies of }s_{n}%
\end{align*}
will be called an $\left(
\begin{array}
[c]{cccc}%
s_{1} & s_{2} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{n}%
\end{array}
\right)  $\textbf{-tuple}. Thus, Theorem \ref{thm.multinom.rec} is claiming
that the \# of $\left(
\begin{array}
[c]{cccc}%
s_{1} & s_{2} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{n}%
\end{array}
\right)  $-tuples is $\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}$, where
$b:=a_{1}+a_{2}+\cdots+a_{n}$. We shall now prove this by induction on $b$.
The base case ($b=0$) is trivial (since $b=0$ entails $a_{1}=a_{2}%
=\cdots=a_{n}=0$, so we are counting $0$-tuples). In the induction step (from
$b-1$ to $b$), we separate the $\left(
\begin{array}
[c]{cccc}%
s_{1} & s_{2} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{n}%
\end{array}
\right)  $-tuples according to their last entry (just as in our above rigorous
proof of Theorem \ref{thm.count.select.injtup}). This last entry is either
$s_{1}$ or $s_{2}$ or $\cdots$ or $s_{n}$. Hence, the sum rule yields%
\begin{align*}
&  \left(  \text{\# of }\left(
\begin{array}
[c]{cccc}%
s_{1} & s_{2} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{n}%
\end{array}
\right)  \text{-tuples}\right) \\
&  =\sum_{i=1}^{n}\underbrace{\left(  \text{\# of }\left(
\begin{array}
[c]{cccc}%
s_{1} & s_{2} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{n}%
\end{array}
\right)  \text{-tuples that end with }s_{i}\right)  }_{\substack{=\left(
\text{\# of }\left(
\begin{array}
[c]{cccccccc}%
s_{1} & s_{2} & \cdots & s_{i-1} & s_{i} & s_{i+1} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{i-1} & a_{i}-1 & a_{i+1} & \cdots & a_{n}%
\end{array}
\right)  \text{-tuples}\right)  \\\text{(by a bijection argument, just as in
the proof of Theorem \ref{thm.count.select.injtup},}\\\text{using the
bijection that removes the last entry from a tuple)}}}\\
&  =\sum_{i=1}^{n}\underbrace{\left(  \text{\# of }\left(
\begin{array}
[c]{cccccccc}%
s_{1} & s_{2} & \cdots & s_{i-1} & s_{i} & s_{i+1} & \cdots & s_{n}\\
a_{1} & a_{2} & \cdots & a_{i-1} & a_{i}-1 & a_{i+1} & \cdots & a_{n}%
\end{array}
\right)  \text{-tuples}\right)  }_{\substack{=\dbinom{b-1}{a_{1}%
,\ldots,a_{i-1},a_{i}-1,a_{i+1},\ldots,a_{n}}\\\text{(by the induction
hypothesis if }a_{i}>0\text{, and for obvious reasons if }a_{i}=0\text{)}}}\\
&  =\sum_{i=1}^{n}\dbinom{b-1}{a_{1},\ldots,a_{i-1},a_{i}-1,a_{i+1}%
,\ldots,a_{n}}\\
&  =\dbinom{b}{a_{1},a_{2},\ldots,a_{n}}\ \ \ \ \ \ \ \ \ \ \left(  \text{by
Theorem \ref{thm.multinom.rec}}\right)  ,
\end{align*}
which completes the induction step. This proof is less conceptual than the
proof we sketched above, but it is easier to formalize, since it does not use
the dependent product rule.
\end{remark}
\end{fineprint}

\begin{thebibliography}{99999999}                                                                                         %


\bibitem[19fco]{19fco}Darij Grinberg, \textit{Enumerative Combinatorics: class
notes (Drexel Fall 2019 Math 222 notes)}, 11 September 2022.\newline\url{http://www.cip.ifi.lmu.de/~grinberg/t/19fco/n/n.pdf}

\bibitem[Loehr11]{Loehr-BC}%
\href{http://www.math.vt.edu/people/nloehr/bijbook.html}{Nicholas A. Loehr,
\textit{Bijective Combinatorics}, Chapman \& Hall/CRC 2011.}

\bibitem[Math222]{Math222}Darij Grinberg, \textit{Math 222: Enumerative
Combinatorics, Fall 2022}.\newline\url{https://www.cip.ifi.lmu.de/~grinberg/t/22fco/}

\bibitem[Newste22]{Newste22}Clive Newstead, \textit{An Infinite Descent into
Pure Mathematics}, version 1.0 preview, 26 December 2022.\newline\url{https://infinitedescent.xyz}
\end{thebibliography}


\end{document}