\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=Thursday, November 24, 2022 14:45:56}
%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 }}
\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 21, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 222 Fall 2022, Lecture 21: Binomial coefficients}

\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}{1}

\section{Binomial coefficients (cont'd)}

\setcounter{subsection}{7}

\subsection{Compositions}

Next, we shall count various types of tuples of positive integers. BCs (=
binomial coefficients) will appear as answers rather often.

\subsubsection{Compositions}

How many ways are there to write the number $5$ as a sum of $3$ positive
integers, if the order matters? There are $6$ of them:%
\begin{align*}
5  &  =2+2+1=2+1+2=1+2+2\\
&  =1+1+3=1+3+1=3+1+1.
\end{align*}


What if we replace $5$ and $3$ by two arbitrary nonnegative integers $n$ and
$k$ ? So we want to count the $k$-tuples $\left(  x_{1},x_{2},\ldots
,x_{k}\right)  $ of positive integers whose sum is $x_{1}+x_{2}+\cdots
+x_{k}=n$. The following theorem answers this question:

\begin{theorem}
\label{thm.compos.comp-n-k}Let $\mathbb{P}=\left\{  1,2,3,\ldots\right\}  $ be
the set of all positive integers.

Let $n\in\mathbb{N}$ and $k\in\mathbb{N}$. Then,%
\begin{align}
&  \left(  \text{\# of }\left(  x_{1},x_{2},\ldots,x_{k}\right)  \in
\mathbb{P}^{k}\text{ satisfying }x_{1}+x_{2}+\cdots+x_{k}=n\right) \nonumber\\
&  =\dbinom{n-1}{n-k}\label{eq.thm.compos.comp-n-k.1}\\
&  =%
\begin{cases}
\dbinom{n-1}{k-1}, & \text{if }n>0;\\
\left[  k=0\right]  , & \text{if }n=0.
\end{cases}
\label{eq.thm.compos.comp-n-k.2}%
\end{align}

\end{theorem}

Before we prove this, let us introduce some terminology for these tuples that
we are counting:

\begin{definition}
\textbf{(a)} A \textbf{composition} shall mean a tuple (i.e., finite list) of
positive integers. (This has nothing to do with the composition $f\circ g$ of
two maps $f$ and $g$.)

\textbf{(b)} If $k\in\mathbb{N}$, then a \textbf{composition into }$k$
\textbf{parts} shall mean a $k$-tuple of positive integers\textbf{.}

\textbf{(c)} If $n\in\mathbb{N}$, then a \textbf{composition of }$n$ shall
mean a tuple of positive integers whose sum is $n$.

\textbf{(d)} If $n,k\in\mathbb{N}$, then a \textbf{composition of }$n$
\textbf{into }$k$ \textbf{parts} shall mean a $k$-tuple of positive integers
whose sum is $n$.
\end{definition}

\begin{example}
\textbf{(a)} The compositions of $5$ into $3$ parts are%
\begin{align*}
&  \left(  2,2,1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  2,1,2\right)
,\ \ \ \ \ \ \ \ \ \ \left(  1,2,2\right)  ,\\
&  \left(  1,1,3\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  1,3,1\right)
,\ \ \ \ \ \ \ \ \ \ \left(  3,1,1\right)
\end{align*}
(as we saw above).

\textbf{(b)} The compositions of $3$ are%
\[
\left(  1,1,1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  1,2\right)
,\ \ \ \ \ \ \ \ \ \ \left(  2,1\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
3\right)  .
\]
These are compositions into $3$, $2$, $2$ and $1$ parts, respectively.

\textbf{(c)} The only composition of $0$ is the $0$-tuple $\left(  {}\right)
$; it is a composition into $0$ parts.
\end{example}

Theorem \ref{thm.compos.comp-n-k} can now be restated as follows: For any
$n,k\in\mathbb{N}$, we have%
\begin{align*}
&  \left(  \text{\# of compositions of }n\text{ into }k\text{ parts}\right) \\
&  =\dbinom{n-1}{n-k}\\
&  =%
\begin{cases}
\dbinom{n-1}{k-1}, & \text{if }n>0;\\
\left[  k=0\right]  , & \text{if }n=0.
\end{cases}
\end{align*}


\begin{proof}
[Proof of Theorem \ref{thm.compos.comp-n-k}.](See Theorem 2.10.1 in the 2019
notes for details.)

First, we WLOG assume that $n>0$, since the $n=0$ case is pretty trivial.
Thus, $n\geq1$, so that $n-1\in\mathbb{N}$.

We shall now prove that
\[
\left(  \text{\# of compositions of }n\text{ into }k\text{ parts}\right)
=\dbinom{n-1}{k-1}.
\]
To do so, we construct a bijection%
\[
C:\left\{  \text{compositions of }n\text{ into }k\text{ parts}\right\}
\rightarrow\left\{  \left(  k-1\right)  \text{-element subsets of }\left[
n-1\right]  \right\}  .
\]
We define this bijection as follows: For any composition $\left(  a_{1}%
,a_{2},\ldots,a_{k}\right)  $ of $n$ into $k$ parts, we set%
\begin{align*}
C\left(  a_{1},a_{2},\ldots,a_{k}\right)  :=  &  \ \left\{  a_{1}%
,\ \ a_{1}+a_{2},\ \ a_{1}+a_{2}+a_{3},\ \ \ldots,\ \ a_{1}+a_{2}%
+\cdots+a_{k-1}\right\} \\
=  &  \ \left\{  a_{1}+a_{2}+\cdots+a_{i}\ \mid\ i\in\left[  k-1\right]
\right\}  .
\end{align*}
\footnote{Here is a geometric way to think of the map $C$:
\par
Given a composition $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ of $n$, we can
subdivide the interval $\left[  0,n\right]  $ on the real line into $k$ blocks
(i.e., subintervals) of lengths $a_{1},a_{2},\ldots,a_{k}$ (from left to
right), as follows:%
\[%
%TCIMACRO{\TeXButton{tikz composition from intervals}{\begin{tikzpicture}%
%[scale=1.5]
%\draw[->, gray] (-0.3,0) -- (7.3,0);
%\node(0) at (0 cm, 0 cm) {};
%\node(3) at (3 cm, 0 cm) {};
%\node(4) at (4 cm, 0 cm) {};
%\node(6) at (6 cm, 0 cm) {};
%\node(7) at (7 cm, 0 cm) {};
%\node[blue] (a) at (1.5 cm, 0.5 cm) {$a_1$};
%\node[blue] (b) at (3.5 cm, 0.5 cm) {$a_2$};
%\node[blue] (c) at (5.0 cm, 0.5 cm) {$\cdots$};
%\node[blue] (d) at (6.5 cm, 0.5 cm) {$a_k$};
%\fill(0) circle (1pt) node[below] {$0$};
%\fill(3) circle (1pt) node[below] {$s_1$};
%\fill(4) circle (1pt) node[below] {$s_2$};
%\node(u) at (5 cm, -0.2 cm) {$\cdots$};
%\fill(6) circle (1pt) node[below] {$s_{k-1}$};
%\fill(7) circle (1pt) node[below] {$n$};
%\draw[->, blue] (0.1,0.5) -- (1.35,0.5);
%\draw[->, blue] (2.9,0.5) -- (1.65,0.5);
%\draw[->, blue] (3.1,0.5) -- (3.35,0.5);
%\draw[->, blue] (3.9,0.5) -- (3.65,0.5);
%\draw[->, blue] (4.1,0.5) -- (4.75,0.5);
%\draw[->, blue] (5.9,0.5) -- (5.25,0.5);
%\draw[->, blue] (6.1,0.5) -- (6.35,0.5);
%\draw[->, blue] (6.9,0.5) -- (6.65,0.5);
%\draw[very thick, red] (0,0) -- (0,1);
%\draw[very thick, red] (3,0) -- (3,1);
%\draw[very thick, red] (4,0) -- (4,1);
%\draw[very thick, red] (6,0) -- (6,1);
%\draw[very thick, red] (7,0) -- (7,1);
%\end{tikzpicture}}}%
%BeginExpansion
\begin{tikzpicture}[scale=1.5]
\draw[->, gray] (-0.3,0) -- (7.3,0);
\node(0) at (0 cm, 0 cm) {};
\node(3) at (3 cm, 0 cm) {};
\node(4) at (4 cm, 0 cm) {};
\node(6) at (6 cm, 0 cm) {};
\node(7) at (7 cm, 0 cm) {};
\node[blue] (a) at (1.5 cm, 0.5 cm) {$a_1$};
\node[blue] (b) at (3.5 cm, 0.5 cm) {$a_2$};
\node[blue] (c) at (5.0 cm, 0.5 cm) {$\cdots$};
\node[blue] (d) at (6.5 cm, 0.5 cm) {$a_k$};
\fill(0) circle (1pt) node[below] {$0$};
\fill(3) circle (1pt) node[below] {$s_1$};
\fill(4) circle (1pt) node[below] {$s_2$};
\node(u) at (5 cm, -0.2 cm) {$\cdots$};
\fill(6) circle (1pt) node[below] {$s_{k-1}$};
\fill(7) circle (1pt) node[below] {$n$};
\draw[->, blue] (0.1,0.5) -- (1.35,0.5);
\draw[->, blue] (2.9,0.5) -- (1.65,0.5);
\draw[->, blue] (3.1,0.5) -- (3.35,0.5);
\draw[->, blue] (3.9,0.5) -- (3.65,0.5);
\draw[->, blue] (4.1,0.5) -- (4.75,0.5);
\draw[->, blue] (5.9,0.5) -- (5.25,0.5);
\draw[->, blue] (6.1,0.5) -- (6.35,0.5);
\draw[->, blue] (6.9,0.5) -- (6.65,0.5);
\draw[very thick, red] (0,0) -- (0,1);
\draw[very thick, red] (3,0) -- (3,1);
\draw[very thick, red] (4,0) -- (4,1);
\draw[very thick, red] (6,0) -- (6,1);
\draw[very thick, red] (7,0) -- (7,1);
\end{tikzpicture}%
%EndExpansion
\ \ .
\]
The set $C\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ then consists of the
$k-1$ points $s_{1},s_{2},\ldots,s_{k-1}$ at which these blocks begin and end
(not counting the endpoints $0$ and $n$ of the big interval). Explicitly, it
is easy to see that $s_{i}=a_{1}+a_{2}+\cdots+a_{i}$ for each $i\in\left[
k-1\right]  $, so that we obtain the formula%
\[
C\left(  a_{1},a_{2},\ldots,a_{k}\right)  =\left\{  a_{1}+a_{2}+\cdots
+a_{i}\ \mid\ i\in\left[  k-1\right]  \right\}
\]
by which we have defined $C$. Most properties of the map $C$ become clear by
looking at this geometric interpretation.} This set $C\left(  a_{1}%
,a_{2},\ldots,a_{k}\right)  $ is called the \textbf{partial sum set} of
$\left(  a_{1},a_{2},\ldots,a_{k}\right)  $.

It is not hard to see that the map $C$ is well-defined (indeed, if $\left(
a_{1},a_{2},\ldots,a_{k}\right)  $ is a composition of $n$ into $k$ parts,
then the positivity of its entries $a_{1},a_{2},\ldots,a_{k}$ yields%
\begin{align*}
0  &  <a_{1}<a_{1}+a_{2}<a_{1}+a_{2}+a_{3}<\cdots<a_{1}+a_{2}+\cdots+a_{k-1}\\
&  <a_{1}+a_{2}+\cdots+a_{k}=n,
\end{align*}
which shows that $C\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ is a $\left(
k-1\right)  $-element subset of $\left[  n-1\right]  $). Now, how do we see
that this map $C$ is really a bijection? The easiest way is to construct an
inverse map. Explicitly, this inverse map $C^{-1}$ sends every $\left(
k-1\right)  $-element subset $\left\{  i_{1}<i_{2}<\cdots<i_{k-1}\right\}  $
of $\left[  n-1\right]  $ to the composition%
\[
\left(  i_{1}-i_{0},\ i_{2}-i_{1},\ i_{3}-i_{2},\ \ldots,\ i_{k-1}%
-i_{k-2},\ i_{k}-i_{k-1}\right)  ,
\]
where we set $i_{0}:=0$ and $i_{k}:=n$.

For a formal proof that all of this works, see \S 2.10.1 in the 2019 notes
(which in turn refer to solved homework).

Anyway, we now know that $C$ is a bijection. Thus, the bijection principle
yields that%
\[
\left\vert \left\{  \text{compositions of }n\text{ into }k\text{
parts}\right\}  \right\vert =\left\vert \left\{  \left(  k-1\right)
\text{-element subsets of }\left[  n-1\right]  \right\}  \right\vert .
\]
In other words,%
\begin{align*}
&  \left(  \text{\# of compositions of }n\text{ into }k\text{ parts}\right) \\
&  =\left(  \text{\# of }\left(  k-1\right)  \text{-element subsets of
}\left[  n-1\right]  \right) \\
&  =\dbinom{n-1}{k-1}\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{by the combinatorial interpretation of BCs,}\\
\text{since }n-1\in\mathbb{N}%
\end{array}
\right) \\
&  =\dbinom{n-1}{\left(  n-1\right)  -\left(  k-1\right)  }%
\ \ \ \ \ \ \ \ \ \ \left(  \text{by the symmetry of BCs, since }%
n-1\in\mathbb{N}\right) \\
&  =\dbinom{n-1}{n-k}.
\end{align*}
Thus, we have proved Theorem \ref{thm.compos.comp-n-k}.
\end{proof}

\subsubsection{Binary compositions}

Here is a variant of Theorem \ref{thm.compos.comp-n-k} in which the entries of
the tuples are supposed to be $0$'s and $1$'s instead of being positive integers:

\begin{theorem}
\label{thm.compos.bcomp-n-k}Let $n\in\mathbb{Z}$ and $k\in\mathbb{N}$. Then,%
\begin{align*}
&  \left(  \text{\# of }\left(  x_{1},x_{2},\ldots,x_{k}\right)  \in\left\{
0,1\right\}  ^{k}\text{ satisfying }x_{1}+x_{2}+\cdots+x_{k}=n\right) \\
&  =\dbinom{k}{n}.
\end{align*}

\end{theorem}

\begin{proof}
(See Theorem 2.10.4 in the 2019 notes for details.)

A $k$-tuple $\left(  x_{1},x_{2},\ldots,x_{k}\right)  \in\left\{  0,1\right\}
^{k}$ satisfies $x_{1}+x_{2}+\cdots+x_{k}=n$ if and only if it consists of $n$
many $1$'s and $k-n$ many $0$'s (because $x_{1}+x_{2}+\cdots+x_{k}$ is just
the \# of $1$'s in $\left(  x_{1},x_{2},\ldots,x_{k}\right)  $). Thus, we can
construct such a $k$-tuple by choosing the positions in which its $n$ many
$1$'s will be placed. This amounts to choosing an $n$-element subset of
$\left[  k\right]  $, and this can be done in $\dbinom{k}{n}$ many ways.
\end{proof}

\subsubsection{Weak compositions}

One particularly useful variant of compositions are the so-called \textbf{weak
compositions}. These are defined as tuples of nonnegative integers (i.e., they
differ from compositions in that $0$ is allowed as an entry). For example, the
weak compositions of $2$ into $3$ parts are%
\begin{align*}
&  \left(  1,1,0\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  1,0,1\right)
,\ \ \ \ \ \ \ \ \ \ \left(  0,1,1\right)  ,\\
&  \left(  0,0,2\right)  ,\ \ \ \ \ \ \ \ \ \ \left(  0,2,0\right)
,\ \ \ \ \ \ \ \ \ \ \left(  2,0,0\right)  .
\end{align*}


Let us count weak compositions of $n$ into $k$ parts:

\begin{theorem}
\label{thm.compos.wcomp-n-k}Let $n\in\mathbb{N}$ and $k\in\mathbb{N}$. Then,%
\begin{align}
&  \left(  \text{\# of }\left(  x_{1},x_{2},\ldots,x_{k}\right)  \in
\mathbb{N}^{k}\text{ satisfying }x_{1}+x_{2}+\cdots+x_{k}=n\right) \nonumber\\
&  =\dbinom{n+k-1}{n}\label{eq.thm.compos.wcomp-n-k.1}\\
&  =%
\begin{cases}
\dbinom{n+k-1}{k-1}, & \text{if }k>0;\\
\left[  n=0\right]  , & \text{if }k=0.
\end{cases}
\nonumber
\end{align}

\end{theorem}

\begin{proof}
[Proof of Theorem \ref{thm.compos.wcomp-n-k}.]Let $\mathbb{P}=\left\{
1,2,3,\ldots\right\}  $. There is a bijection%
\begin{align*}
&  \text{from }\left\{  \left(  x_{1},x_{2},\ldots,x_{k}\right)  \in
\mathbb{N}^{k}\ \mid\ x_{1}+x_{2}+\cdots+x_{k}=n\right\} \\
&  \text{to }\left\{  \left(  x_{1},x_{2},\ldots,x_{k}\right)  \in
\mathbb{P}^{k}\ \mid\ x_{1}+x_{2}+\cdots+x_{k}=n+k\right\}
\end{align*}
which sends
\begin{align*}
&  \text{each weak composition }\left(  x_{1},x_{2},\ldots,x_{k}\right) \\
&  \text{to the composition }\left(  x_{1}+1,x_{2}+1,\ldots,x_{k}+1\right)
\end{align*}
(that is, which adds $1$ to each entry). Thus, by the bijection principle, we
have%
\begin{align*}
&  \left(  \text{\# of }\left(  x_{1},x_{2},\ldots,x_{k}\right)  \in
\mathbb{N}^{k}\text{ satisfying }x_{1}+x_{2}+\cdots+x_{k}=n\right) \\
&  =\left(  \text{\# of }\left(  x_{1},x_{2},\ldots,x_{k}\right)
\in\mathbb{P}^{k}\text{ satisfying }x_{1}+x_{2}+\cdots+x_{k}=n+k\right) \\
&  =\dbinom{n+k-1}{n+k-k}\ \ \ \ \ \ \ \ \ \ \left(  \text{by
(\ref{eq.thm.compos.comp-n-k.1}), applied to }n+k\text{ instead of }k\right)
\\
&  =\dbinom{n+k-1}{n}.
\end{align*}
Using the symmetry of BCs (and a bit of case analysis to deal with the case of
$k=0$), we can furthermore rewrite this as%
\[%
\begin{cases}
\dbinom{n+k-1}{k-1}, & \text{if }k>0;\\
\left[  n=0\right]  , & \text{if }k=0.
\end{cases}
\]
Thus, Theorem \ref{thm.compos.wcomp-n-k} is proved.
\end{proof}

\begin{remark}
Note that weak compositions appear in abstract algebra.

Indeed, consider the polynomial ring $\mathbb{R}\left[  x_{1},x_{2}%
,\ldots,x_{k}\right]  $ in $k$ indeterminates. The degree-$n$ part of this
polynomial ring (i.e., the vector space of polynomials that are homogeneous of
degree $n$) is spanned by all monomials of degree $n$ in the indeterminates
$x_{1},x_{2},\ldots,x_{k}$. These monomials have the form%
\[
x_{1}^{a_{1}}x_{2}^{a_{2}}\cdots x_{k}^{a_{k}},\ \ \ \ \ \ \ \ \ \ \text{where
}a_{1},a_{2},\ldots,a_{k}\in\mathbb{N}\text{ and }a_{1}+a_{2}+\cdots+a_{k}=n.
\]
So these monomials are in one-to-one correspondence with the weak compositions
of $n$ into $k$ parts. Thus, the dimension of the degree-$n$ part of the
polynomial ring is the \# of these weak compositions. According to
(\ref{eq.thm.compos.wcomp-n-k.1}), this \# is $\dbinom{n+k-1}{n}$.
\end{remark}

\subsubsection{Some other composition counting problems}

Here is an assortment of other results about counting compositions. (See
\S 2.10.4 in the 2019 notes for proofs.)

First, let us count \textbf{all} compositions of a number $n$ (as opposed to
just those having a given length $k$):

\begin{proposition}
Let $n\in\mathbb{N}$. Then,%
\[
\left(  \text{\# of compositions of }n\right)  =%
\begin{cases}
2^{n-1}, & \text{if }n>0;\\
1, & \text{if }n=0.
\end{cases}
\]

\end{proposition}

Now, let us count compositions whose entries are $1$'s and $2$'s:

\begin{proposition}
Let $n\in\mathbb{N}$. A $\left\{  1,2\right\}  $\textbf{-composition of }$n$
shall mean a composition $\left(  x_{1},x_{2},\ldots,x_{k}\right)  $ of $n$
such that $x_{1},x_{2},\ldots,x_{k}\in\left\{  1,2\right\}  $. Then:

\textbf{(a)} The \# of $\left\{  1,2\right\}  $-compositions of $n$ is the
Fibonacci number $f_{n+1}$.

\textbf{(b)} For any $k\in\mathbb{N}$, the \# of $\left\{  1,2\right\}
$-compositions of $n$ into $k$ parts is $\dbinom{k}{n-k}$.
\end{proposition}

Next, we can try to count weak compositions of $n$ into $k$ parts whose
entries all belong to $\left\{  0,1,\ldots,p-1\right\}  $ for a given number
$p$. When $p=2$, this has already been done (see Theorem
\ref{thm.compos.bcomp-n-k} above), and the answer was $\dbinom{k}{n}$.
Unfortunately, no such simple answer exists for general $p$, but at least we
can write it as a finite sum:

\begin{proposition}
Let $p\in\mathbb{N}$. Let $n\in\mathbb{Z}$ and $k\in\mathbb{N}$. Then,%
\begin{align*}
&  \left(  \text{\# of }\left(  x_{1},x_{2},\ldots,x_{k}\right)  \in\left\{
0,1,\ldots,p-1\right\}  ^{k}\text{ such that }x_{1}+x_{2}+\cdots
+x_{k}=n\right) \\
&  =\sum_{j=0}^{k}\left(  -1\right)  ^{j}\dbinom{k}{j}\dbinom{n-pj+k-1}{n-pj}.
\end{align*}

\end{proposition}

Finally, instead of counting compositions of $n$, let us sum their lengths:

\begin{proposition}
Let $n$ be a positive integer. Then, the sum of the lengths of all
compositions of $n$ is $\left(  n+1\right)  2^{n-2}$.
\end{proposition}

See the 2019 notes for proofs of all of these propositions (they make nice exercises).

\bigskip

A much harder problem is counting \textbf{partitions}: compositions whose
entries are arranged in weakly decreasing order (i.e., from highest to
lowest). For instance, 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*}
There are $7$ of them, which is not a very simple number! In general, there is
no explicit formula for the \# of partitions of $n$, but there is at least one
beautiful recurrence and a whole lot of interesting identities. Partition
identities are a subject of their own. We will learn more about partitions in
\S 3.7 (Lecture 25).

\bigskip

\subsection{Multisubsets}

Another counting problem that naturally leads to BCs is to count
\textbf{multisubsets} of a given set having a given size. Let us introduce the
notion of a multisubset.

\subsubsection{Definitions}

Sets in mathematics are rather binary objects: A set either contains an
element or does not. It cannot \textquotedblleft contain this element
twice\textquotedblright. This is useful in some situations and limiting in
others. For the latter situations, the notion of a \textbf{multiset} has been
invented. Essentially, a multiset is \textquotedblleft a set that can contain
some elements multiple times\textquotedblright.

Instead of defining multisets per se, we will here only define the notion of a
\textbf{multisubset}, which is essentially a multiset whose elements come from
a given set $T$. Our multisubsets shall always be finite, so they can only
contain finitely many elements, and each element is contained only finitely
many times. Formally speaking, a multisubset of a set $T$ is determined by
specifying how often it contains each given element of $T$. In other words, it
is determined by the function $f:T\rightarrow\mathbb{N}$ which sends each
$t\in T$ to the multiplicity of $t$ in this multisubset (i.e., the number of
times that $t$ is contained in the multisubset).

For a rigorous definition, we simply define a multisubset to be such a function:

\begin{definition}
Let $T$ be a set.

A \textbf{multisubset} of $T$ is formally defined as a map $f:T\rightarrow
\mathbb{N}$ such that only finitely many $t\in T$ satisfy $f\left(  t\right)
\neq0$.\ \ \ \ \footnotemark

Informally, we regard such a map $f:T\rightarrow\mathbb{N}$ as a way to encode
a \textquotedblleft set with multiplicities\textquotedblright\ -- namely, the
\textquotedblleft set\textquotedblright\ in which each $t\in T$ appears
$f\left(  t\right)  $ many times. Accordingly, we will use the notation
$\left\{  a_{1},a_{2},\ldots,a_{k}\right\}  _{\operatorname*{multi}}$ for this
multisubset $f$, where $\left(  a_{1},a_{2},\ldots,a_{k}\right)  $ is a list
of elements of $T$ such that each $t\in T$ appears in this list exactly
$f\left(  t\right)  $ many times.
\end{definition}

\footnotetext{The latter condition is meant to ensure that our multisubset is
finite even if $T$ itself might be infinite.}For example, if $T=\left[
8\right]  $, then the map from $\left[  8\right]  $ to $\mathbb{N}$ that is
given in two-line notation as%
\[
\left(
\begin{array}
[c]{cccccccc}%
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8\\
1 & 0 & 0 & 3 & 2 & 1 & 0 & 1
\end{array}
\right)
\]
is a multisubset of $\left[  8\right]  $, and it can be written as%
\[
\left\{  1,4,4,4,5,5,6,8\right\}  _{\operatorname*{multi}}%
\]
(or as $\left\{  4,5,4,4,5,6,1,8\right\}  _{\operatorname*{multi}}$, or in
many other ways). It contains the element $1$ once, the element $4$ thrice,
the element $5$ twice, the element $6$ once and the element $8$ once.

Note that $\left\{  1,1\right\}  _{\operatorname*{multi}}\neq\left\{
1\right\}  _{\operatorname*{multi}}$, even though $\left\{  1,1\right\}
=\left\{  1\right\}  $. Thus, multisubsets are basically \textquotedblleft
subsets with multiplicities\textquotedblright. However, $\left\{  1,2\right\}
_{\operatorname*{multi}}=\left\{  2,1\right\}  _{\operatorname*{multi}}$,
since multisets don't come with an ordering of their elements.

The \textbf{size} of a multisubset is easily defined:

\begin{definition}
Let $T$ be a set. Let $f$ be a multisubset of $T$. Then, the \textbf{size} of
$f$ is defined to be the number $\sum_{t\in T}f\left(  t\right)  \in
\mathbb{N}$.
\end{definition}

This means that the size of a multisubset $f$ is the number of elements of
$f$, counted with multiplicities (i.e., the sum of the multiplicities of all
elements of $f$). Equivalently, any multisubset that has the form $\left\{
a_{1},a_{2},\ldots,a_{k}\right\}  _{\operatorname*{multi}}$ has size $k$ (no
matter whether the elements $a_{1},a_{2},\ldots,a_{k}$ are distinct or not).

Next time, we will answer the following question: How many \textbf{multi}%
subsets of a given set $T$ have a given size $k$ ? (The analogous question
about subsets has been answered back in Lecture 6.)
\end{document}