\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=Friday, March 01, 2024 20:51:22}
%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 16, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 221 Winter 2023, Lecture 16: 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}{5}

\subsection{Counting, formally (cont'd)}

\setcounter{subsubsection}{1}

\subsubsection{Rules for sizes of finite sets}

We have defined the size $\left\vert S\right\vert $ of a finite set $S$ in
\S 4.6.1 (Lecture 15). Let us now state some rules for these sizes that make
them easier to compute. We will not prove these rules, as they are all obvious
from common sense and their rigorous proofs would reasonably belong into a
text on formalized foundations of mathematics.

The most important rule is the following:

\begin{theorem}
[Bijection Principle]\label{thm.count.rules.bij}Let $A$ and $B$ be two finite
sets. Then, $\left\vert A\right\vert =\left\vert B\right\vert $ if and only if
there exists a bijection from $A$ to $B$.
\end{theorem}

(As we recall, a \textquotedblleft bijection\textquotedblright\ means a
bijective map, and this is the same as a map that has an inverse.)

The next rule is obvious from one of our definitions of size:

\begin{theorem}
\label{thm.count.rules.n}For each $n\in\mathbb{N}$, we have $\left\vert
\left[  n\right]  \right\vert =n$.
\end{theorem}

Here, we recall that $\left[  n\right]  $ means the set $\left\{
1,2,\ldots,n\right\}  $ consisting of the first $n$ positive integers.

The next rule classifies sets of small size:

\begin{theorem}
\label{thm.count.rules.012}Let $S$ be a set. Then:

\textbf{(a)} We have $\left\vert S\right\vert =0$ if and only if
$S=\varnothing$ (that is, if $S$ is empty).

\textbf{(b)} We have $\left\vert S\right\vert =1$ if and only if $S=\left\{
s\right\}  $ for a single element $s$.

\textbf{(c)} We have $\left\vert S\right\vert =2$ if and only if $S=\left\{
s,t\right\}  $ for two distinct elements $s$ and $t$.
\end{theorem}

The next rule says that inserting a new element into a finite set increases
the size of this set by $1$:

\begin{theorem}
\label{thm.count.rules.+1}Let $S$ be a finite set. Let $t$ be an object such
that $t\notin S$ (that is, $t$ does not belong to $S$). Then,%
\[
\left\vert S\cup\left\{  t\right\}  \right\vert =\left\vert S\right\vert +1.
\]

\end{theorem}

Here are some more substantial facts:

\begin{theorem}
[Sum rule for two sets]\label{thm.count.rules.sum-2}Let $A$ and $B$ be two
disjoint finite sets. (Recall that \textquotedblleft
disjoint\textquotedblright\ means $A\cap B=\varnothing$.) Then, the set $A\cup
B$ is again finite, and has size%
\[
\left\vert A\cup B\right\vert =\left\vert A\right\vert +\left\vert
B\right\vert .
\]

\end{theorem}

\begin{theorem}
[Sum rule for $k$ sets]\label{thm.count.rules.sum-k}Let $A_{1},A_{2}%
,\ldots,A_{k}$ be $k$ disjoint finite sets. (Recall that \textquotedblleft
disjoint\textquotedblright\ for $k$ sets\ means that any two of them are
disjoint, i.e., that $A_{i}\cap A_{j}=\varnothing$ for any $i<j$.) Then, the
set $A_{1}\cup A_{2}\cup\cdots\cup A_{k}$ is finite, and has size%
\[
\left\vert A_{1}\cup A_{2}\cup\cdots\cup A_{k}\right\vert =\left\vert
A_{1}\right\vert +\left\vert A_{2}\right\vert +\cdots+\left\vert
A_{k}\right\vert .
\]

\end{theorem}

\begin{theorem}
[Difference rule]\label{thm.count.rules.diff}Let $T$ be a subset of a finite
set $S$. Then:

\textbf{(a)} The set $T$ is finite, and its size $\left\vert T\right\vert $
satisfies $\left\vert T\right\vert \leq\left\vert S\right\vert $.

\textbf{(b)} We have $\left\vert S\setminus T\right\vert =\left\vert
S\right\vert -\left\vert T\right\vert $.

\textbf{(c)} If $\left\vert T\right\vert =\left\vert S\right\vert $, then
$T=S$.
\end{theorem}

The following theorem has been previously stated (without using the
\textquotedblleft size\textquotedblright\ terminology) as Theorem 4.4.8 in
Lecture 13:

\begin{theorem}
[Product rule for two sets]\label{thm.count.rules.prod-2}Let $A$ and $B$ be
any finite sets. Then, the set%
\[
A\times B=\left\{  \text{all pairs }\left(  a,b\right)  \text{ with }a\in
A\text{ and }b\in B\right\}
\]
is again finite and has size%
\[
\left\vert A\times B\right\vert =\left\vert A\right\vert \cdot\left\vert
B\right\vert .
\]

\end{theorem}

Likewise, the following theorem was Theorem 4.4.9 in Lecture 13:

\begin{theorem}
[Product rule for $k$ sets]\label{thm.count.rules.prod-k}Let $A_{1}%
,A_{2},\ldots,A_{k}$ be any $k$ finite sets. Then, the set%
\[
A_{1}\times A_{2}\times\cdots\times A_{k}=\left\{  \text{all }k\text{-tuples
}\left(  a_{1},a_{2},\ldots,a_{k}\right)  \text{ with }a_{i}\in A_{i}\text{
for each }i\in\left[  k\right]  \right\}
\]
is again finite and has size%
\[
\left\vert A_{1}\times A_{2}\times\cdots\times A_{k}\right\vert =\left\vert
A_{1}\right\vert \cdot\left\vert A_{2}\right\vert \cdot\cdots\cdot\left\vert
A_{k}\right\vert .
\]

\end{theorem}

All the above theorems are foundational, and are perhaps the reason why the
arithmetic operations $+$, $-$ and $\cdot$ on nonnegative integers have been
introduced some millennia ago. Nevertheless, they can be rigorously proved,
but this is not something we will do here.\footnote{For instance, Theorem
\ref{thm.count.rules.prod-2} can be proved by induction on $\left\vert
B\right\vert $ using Theorem \ref{thm.count.rules.sum-k} and Theorem
\ref{thm.count.rules.bij}, whereas Theorem \ref{thm.count.rules.prod-k} can be
proved by induction on $k$ using Theorem \ref{thm.count.rules.prod-2}.}

The above theorems are known as \textquotedblleft basic counting
rules\textquotedblright\ or \textquotedblleft counting
principles\textquotedblright. There are a few more counting principles, which
we might state later on.

\subsubsection{$A\cup B$ and $A\cap B$ revisited}

As a first application of these rules, let us derive the following
\textquotedblleft generalized sum rule for two sets\textquotedblright:

\begin{theorem}
\label{thm.count.rules.AuB-AnB}Let $A$ and $B$ be two finite sets (not
necessarily disjoint). Then,
\[
\left\vert A\cup B\right\vert =\left\vert A\right\vert +\left\vert
B\right\vert -\left\vert A\cap B\right\vert .
\]

\end{theorem}

\begin{proof}
We first claim that%
\begin{equation}
\left(  A\cup B\right)  \setminus A=B\setminus\left(  A\cap B\right)  .
\label{pf.thm.count.rules.AuB-AnB.1}%
\end{equation}


This equality is obvious using Venn diagrams, but let us prove it rigorously
using \textquotedblleft element chasing\textquotedblright:\footnote{It is
worth noting that both sides of (\ref{pf.thm.count.rules.AuB-AnB.1}) are equal
to $B\setminus A$. However, we will not need this fact.}

\begin{proof}
[Proof of (\ref{pf.thm.count.rules.AuB-AnB.1}).]Let us first prove $\left(
A\cup B\right)  \setminus A\subseteq B\setminus\left(  A\cap B\right)  $. In
order to do so, we must show that each $x\in\left(  A\cup B\right)  \setminus
A$ belongs to $B\setminus\left(  A\cap B\right)  $. Let us do this: Let
$x\in\left(  A\cup B\right)  \setminus A$. Thus, $x\in A\cup B$ but $x\notin
A$. From $x\in A\cup B$, we see that $x\in A$ or $x\in B$. But the first of
these two possibilities is impossible (since $x\notin A$). Thus, the second
possibility must hold. In other words, we have $x\in B$. Furthermore, we have
$x\notin A\cap B$ (since $x\in A\cap B$ would entail $x\in A\cap B\subseteq
A$, which would contradict $x\notin A$). Combining $x\in B$ with $x\notin
A\cap B$, we obtain $x\in B\setminus\left(  A\cap B\right)  $.

Forget that we fixed $x$. We thus have shown that each $x\in\left(  A\cup
B\right)  \setminus A$ belongs to $B\setminus\left(  A\cap B\right)  $. In
other words, $\left(  A\cup B\right)  \setminus A\subseteq B\setminus\left(
A\cap B\right)  $.

Next, let us prove that $B\setminus\left(  A\cap B\right)  \subseteq\left(
A\cup B\right)  \setminus A$. To do so, we must show that each $x\in
B\setminus\left(  A\cap B\right)  $ belongs to $\left(  A\cup B\right)
\setminus A$. We do this as follows: Let $x\in B\setminus\left(  A\cap
B\right)  $. Thus, $x\in B$ but $x\notin A\cap B$. If we had $x\in A$, then we
would have $x\in A\cap B$ (since $x\in A$ and $x\in B$), which would
contradict $x\notin A\cap B$. Hence, we cannot have $x\in A$. Thus, $x\notin
A$. Also, $x\in B\subseteq A\cup B$. Combining this with $x\notin A$, we find
$x\in\left(  A\cup B\right)  \setminus A$.

Forget that we fixed $x$. We thus have shown that each $x\in B\setminus\left(
A\cap B\right)  $ belongs to $\left(  A\cup B\right)  \setminus A$. In other
words, $B\setminus\left(  A\cap B\right)  \subseteq\left(  A\cup B\right)
\setminus A$.

Now, combining the two inclusions%
\[
\left(  A\cup B\right)  \setminus A\subseteq B\setminus\left(  A\cap B\right)
\ \ \ \ \ \ \ \ \ \ \text{and}\ \ \ \ \ \ \ \ \ \ B\setminus\left(  A\cap
B\right)  \subseteq\left(  A\cup B\right)  \setminus A,
\]
we obtain $\left(  A\cup B\right)  \setminus A=B\setminus\left(  A\cap
B\right)  $. Thus, (\ref{pf.thm.count.rules.AuB-AnB.1}) is proved.]
\end{proof}

We now step to the counting. Taking sizes on both sides of
(\ref{pf.thm.count.rules.AuB-AnB.1}), we obtain%
\begin{equation}
\left\vert \left(  A\cup B\right)  \setminus A\right\vert =\left\vert
B\setminus\left(  A\cap B\right)  \right\vert .
\label{pf.thm.count.rules.AuB-AnB.2}%
\end{equation}


But $A$ is a subset of $A\cup B$. Thus, the difference rule (Theorem
\ref{thm.count.rules.diff} \textbf{(b)}, applied to $S=A\cup B$ and $T=A$)
yields%
\begin{equation}
\left\vert \left(  A\cup B\right)  \setminus A\right\vert =\left\vert A\cup
B\right\vert -\left\vert A\right\vert . \label{pf.thm.count.rules.AuB-AnB.3}%
\end{equation}


Also, $A\cap B$ is a subset of $B$. Thus, the difference rule (Theorem
\ref{thm.count.rules.diff} \textbf{(b)}, applied to $S=B$ and $T=A\cap B$)
yields%
\begin{equation}
\left\vert B\setminus\left(  A\cap B\right)  \right\vert =\left\vert
B\right\vert -\left\vert A\cap B\right\vert .
\label{pf.thm.count.rules.AuB-AnB.4}%
\end{equation}


But we know from (\ref{pf.thm.count.rules.AuB-AnB.2}) that the left hand sides
of the two equalities (\ref{pf.thm.count.rules.AuB-AnB.3}) and
(\ref{pf.thm.count.rules.AuB-AnB.4}) are equal. Thus, their right hand sides
are also equal. In other words,%
\[
\left\vert A\cup B\right\vert -\left\vert A\right\vert =\left\vert
B\right\vert -\left\vert A\cap B\right\vert .
\]
Solving this for $\left\vert A\cup B\right\vert $, we find%
\[
\left\vert A\cup B\right\vert =\left\vert A\right\vert +\left\vert
B\right\vert -\left\vert A\cap B\right\vert .
\]
This proves Theorem \ref{thm.count.rules.AuB-AnB}.

(A nicer proof can be given using finite sums; this is done, e.g., in
\cite[Lecture 19, \S 2.7]{Math222}.)
\end{proof}

Note that Theorem \ref{thm.count.rules.AuB-AnB} has an analogue for three
sets: If $A,B,C$ are three finite sets, then%
\[
\left\vert A\cup B\cup C\right\vert =\left\vert A\right\vert +\left\vert
B\right\vert +\left\vert C\right\vert -\left\vert A\cap B\right\vert
-\left\vert A\cap C\right\vert -\left\vert B\cap C\right\vert +\left\vert
A\cap B\cap C\right\vert .
\]
More generally, such a formula can be stated for any $k$ finite sets, and is
known as the \textquotedblleft principle of inclusion and
exclusion\textquotedblright\ or \textquotedblleft Sylvester's sieve
formula\textquotedblright. See \cite[Lecture 19, \S 2.7]{Math222} or any
textbook on combinatorics.

\subsection{Redoing some proofs rigorously}

Previously (in Lectures 12 and 13), we have proved some results using informal
counting arguments. Let us now revisit these results and make these arguments rigorous.

\subsubsection{Integers in an interval}

We recall that the notation $\left[  a,b\right]  $ means the set%
\[
\left\{  a,\ a+1,\ a+2,\ \ldots,\ b\right\}  =\left\{  x\in\mathbb{Z}%
\ \mid\ a\leq x\leq b\right\}
\]
whenever $a$ and $b$ are two integers. In particular, $\left[  n\right]
=\left[  1,n\right]  $ for every $n\in\mathbb{N}$.

We begin with Proposition 4.2.2 in Lecture 12 (rewritten using the notation
$\left[  a,b\right]  $):

\begin{proposition}
\label{prop.count.fencepost-repeat}Let $a,b\in\mathbb{Z}$ be such that $a\leq
b+1$.

Then, there are exactly $b-a+1$ numbers in the set $\left[  a,b\right]  $. In
other words, there are exactly $b-a+1$ integers between $a$ and $b$ (inclusive).
\end{proposition}

In Lecture 12, we proved this informally by inducting on $b$. This proof can
be trivially made rigorous; the induction step relies on Theorem
\ref{thm.count.rules.+1} (because $\left[  a,b+1\right]  =\left[  a,b\right]
\cup\left\{  b+1\right\}  $ and $b+1\notin\left[  a,b\right]  $).

But there is also a more direct proof:

\begin{proof}
[Second proof of Proposition \ref{prop.count.fencepost-repeat}.]Consider the
map%
\begin{align*}
f:\underbrace{\left[  b-a+1\right]  }_{=\left\{  1,2,\ldots,b-a+1\right\}  }
&  \rightarrow\underbrace{\left[  a,b\right]  }_{=\left\{  a,a+1,\ldots
,b\right\}  },\\
i  &  \mapsto i+\left(  a-1\right)  .
\end{align*}
This map $f$ just adds $a-1$ to its input. (Informally, we can view it as
moving numbers to the right by $a-1$ units on the number line.)

It is easy to see that this map $f$ has an inverse: Namely, the map%
\begin{align*}
\left[  a,b\right]   &  \rightarrow\left[  b-a+1\right]  ,\\
j  &  \mapsto j-\left(  a-1\right)
\end{align*}
is an inverse of $f$ (since subtraction undoes addition). Thus, the map $f$ is
bijective (by Theorem 4.5.7 in Lecture 15), i.e., is a bijection. Hence, there
is a bijection from $\left[  b-a+1\right]  $ to $\left[  a,b\right]  $
(namely, $f$). The bijection principle (Theorem \ref{thm.count.rules.bij},
applied to $A=\left[  b-a+1\right]  $ and $B=\left[  a,b\right]  $) thus
yields
\[
\left\vert \left[  b-a+1\right]  \right\vert =\left\vert \left[  a,b\right]
\right\vert .
\]
Hence,%
\[
\left\vert \left[  a,b\right]  \right\vert =\left\vert \left[  b-a+1\right]
\right\vert =b-a+1
\]
(by Theorem \ref{thm.count.rules.n}, since $a\leq b+1$ yields $b-a+1\in
\mathbb{N}$). In other words, there are exactly $b-a+1$ numbers in the set
$\left[  a,b\right]  $. This proves Proposition
\ref{prop.count.fencepost-repeat} again.
\end{proof}

We could also reprove Proposition 4.2.1 in Lecture 12 rigorously, but (again)
the proof we gave was already rigorous enough; we just need to rewrite it
using Theorem \ref{thm.count.rules.+1}.

\subsubsection{Counting all subsets}

Now, we recall Theorem 4.3.1 in Lecture 12 (but shorten it using the notation
$\left[  n\right]  $ for $\left\{  1,2,\ldots,n\right\}  $):

\begin{theorem}
\label{thm.count.subsets.all.n-repeat}Let $n\in\mathbb{N}$. Then,%
\[
\left(  \text{\# of subsets of }\left[  n\right]  \right)  =2^{n}.
\]

\end{theorem}

The proof we gave in Lecture 12 had some informal steps; let us now make it
rigorous:\footnote{Most of the proof below is copied verbatim from Lecture
12.}

\begin{proof}
[Rigorous proof of Theorem \ref{thm.count.subsets.all.n-repeat}.]We induct on
$n$.

The \textit{base case} ($n=0$) is easy: The set $\left[  0\right]  $ is empty,
and thus its only subset is $\left\{  {}\right\}  $ itself; hence, the \# of
subsets of $\left[  0\right]  $ is $1=2^{0}$. In other words, Theorem
\ref{thm.count.subsets.all.n-repeat} holds for $n=0$.

\textit{Induction step:} We proceed from $n-1$ to $n$. Thus, let $n$ be a
positive integer. We assume (as the induction hypothesis) that Theorem
\ref{thm.count.subsets.all.n-repeat} holds for $n-1$ instead of $n$, and we
set out to prove that it holds for $n$.

So our induction hypothesis says that%
\[
\left(  \text{\# of subsets of }\left[  n-1\right]  \right)  =2^{n-1}.
\]
Our goal is to prove that%
\[
\left(  \text{\# of subsets of }\left[  n\right]  \right)  =2^{n}.
\]


We define

\begin{itemize}
\item a \textbf{red set} to be a subset of $\left[  n\right]  $ that contains
$n$;

\item a \textbf{green set} to be a subset of $\left[  n\right]  $ that does
not contain $n$.
\end{itemize}

For example, if $n=3$, then the red sets are%
\[
\left\{  3\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{  1,3\right\}
,\ \ \ \ \ \ \ \ \ \ \left\{  2,3\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{
1,2,3\right\}  ,
\]
whereas the green sets are%
\[
\left\{  {}\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{  1\right\}
,\ \ \ \ \ \ \ \ \ \ \left\{  2\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{
1,2\right\}  .
\]


A set cannot be red and green at the same time. In other words, the sets%
\[
\left\{  \text{red sets}\right\}  \ \ \ \ \ \ \ \ \ \ \text{and}%
\ \ \ \ \ \ \ \ \ \ \left\{  \text{green sets}\right\}
\]
are disjoint\footnote{Keep in mind: The notation \textquotedblleft$\left\{
\text{red sets}\right\}  $\textquotedblright\ stands for \textbf{the set of}
all red sets. For example, if $n=3$, then%
\[
\left\{  \text{red sets}\right\}  =\left\{  \left\{  3\right\}  ,\ \ \left\{
1,3\right\}  ,\ \ \left\{  2,3\right\}  ,\ \ \left\{  1,2,3\right\}  \right\}
.
\]
}. Hence, the sum rule for two sets (Theorem \ref{thm.count.rules.sum-2},
applied to $A=\left\{  \text{red sets}\right\}  $ and $B=\left\{  \text{green
sets}\right\}  $) yields%
\[
\left\vert \left\{  \text{red sets}\right\}  \cup\left\{  \text{green
sets}\right\}  \right\vert =\left\vert \left\{  \text{red sets}\right\}
\right\vert +\left\vert \left\{  \text{green sets}\right\}  \right\vert .
\]
(This is just a formal way to say \textquotedblleft the \# of all sets that
are red or green equals the \# of red sets plus the \# of green
sets\textquotedblright. Indeed, the notation $\left\{  \text{red
sets}\right\}  $ means the \textbf{set} of all red sets, and thus the
expression $\left\vert \left\{  \text{red sets}\right\}  \right\vert $ means
the \textbf{size} of the set of all red sets, i.e., the \# of all red sets.)

Furthermore, each subset of $\left[  n\right]  $ is either red or green (and
conversely, each red or green set is a subset of $\left[  n\right]  $). Hence,%
\[
\left\{  \text{subsets of }\left[  n\right]  \right\}  =\left\{  \text{red
sets}\right\}  \cup\left\{  \text{green sets}\right\}  .
\]
Therefore,%
\begin{align*}
\left\vert \left\{  \text{subsets of }\left[  n\right]  \right\}  \right\vert
&  =\left\vert \left\{  \text{red sets}\right\}  \cup\left\{  \text{green
sets}\right\}  \right\vert \\
&  =\left\vert \left\{  \text{red sets}\right\}  \right\vert +\left\vert
\left\{  \text{green sets}\right\}  \right\vert
\end{align*}
(as we have proved above). In other words,%
\begin{equation}
\left(  \text{\# of subsets of }\left[  n\right]  \right)  =\left(  \text{\#
of red sets}\right)  +\left(  \text{\# of green sets}\right)  .
\label{pf.thm.count.subsets.all.n-repeat.sum}%
\end{equation}


Thus it remains to count the red sets and the green sets separately.

The green sets are easy: They are just the subsets of $\left[  n-1\right]  $.
Hence,%
\[
\left(  \text{\# of green sets}\right)  =\left(  \text{\# of subsets of
}\left[  n-1\right]  \right)  =2^{n-1}%
\]
(by the induction hypothesis).

Counting the red sets is trickier. In Lecture 12, we did this by setting up a
one-to-one correspondence between the red sets and the green sets. Formally, a
one-to-one correspondence is just a bijection. Thus, our one-to-one
correspondence should become a bijection from $\left\{  \text{green
sets}\right\}  $ to $\left\{  \text{red sets}\right\}  $ (i.e., from the set
of all green sets to the set of all red sets).

As we recall, we obtained this correspondence as follows: To turn a green set
red, we insert $n$ into it; conversely, to turn a red set green, we remove $n$
from it. Rigorously, this means that we define two maps%
\begin{align*}
\operatorname*{ins}\nolimits_{n}:\left\{  \text{green sets}\right\}   &
\rightarrow\left\{  \text{red sets}\right\}  ,\\
G  &  \mapsto G\cup\left\{  n\right\}
\end{align*}
and%
\begin{align*}
\operatorname*{rem}\nolimits_{n}:\left\{  \text{red sets}\right\}   &
\rightarrow\left\{  \text{green sets}\right\}  ,\\
R  &  \mapsto R\setminus\left\{  n\right\}  .
\end{align*}
It is easy to see that both of these maps $\operatorname*{ins}\nolimits_{n}$
and $\operatorname*{rem}\nolimits_{n}$ are well-defined\footnote{Indeed, we
need to show that
\par
\begin{itemize}
\item if $G$ is a green set, then $G\cup\left\{  n\right\}  $ is a red set;
\par
\item if $R$ is a red set, then $R\setminus\left\{  n\right\}  $ is a green
set.
\end{itemize}
\par
Both of these claims are very easy. For instance, if $G$ is a green set, then
$G$ is a subset of $\left[  n\right]  $, and thus $G\cup\left\{  n\right\}  $
is a subset of $\left[  n\right]  $ as well (since $n\in\left[  n\right]  $),
and furthermore is red (since $n\in\left\{  n\right\}  \subseteq G\cup\left\{
n\right\}  $).}. A little bit of set-theoretic computation shows that%
\[
\operatorname*{ins}\nolimits_{n}\left(  \operatorname*{rem}\nolimits_{n}%
\left(  R\right)  \right)  =R\ \ \ \ \ \ \ \ \ \ \text{for every red set }R
\]
(because if $R$ is a red set, then%
\begin{align*}
\operatorname*{ins}\nolimits_{n}\left(  \operatorname*{rem}\nolimits_{n}%
\left(  R\right)  \right)   &  =\underbrace{\operatorname*{rem}\nolimits_{n}%
\left(  R\right)  }_{\substack{=R\setminus\left\{  n\right\}  \\\text{(by the
definition of }\operatorname*{rem}\nolimits_{n}\text{)}}}\cup\left\{
n\right\}  \ \ \ \ \ \ \ \ \ \ \left(  \text{by the definition of
}\operatorname*{ins}\nolimits_{n}\right) \\
&  =\left(  R\setminus\left\{  n\right\}  \right)  \cup\left\{  n\right\}
=R\ \ \ \ \ \ \ \ \ \ \left(  \text{since }n\in R\text{ (because }R\text{ is
red)}\right)
\end{align*}
). Similarly,%
\[
\operatorname*{rem}\nolimits_{n}\left(  \operatorname*{ins}\nolimits_{n}%
\left(  G\right)  \right)  =G\ \ \ \ \ \ \ \ \ \ \text{for every green set
}G.
\]
These two equalities show that the map $\operatorname*{rem}\nolimits_{n}$ is
an inverse of $\operatorname*{ins}\nolimits_{n}$. Hence, the map
$\operatorname*{ins}\nolimits_{n}$ has an inverse, i.e., is bijective (by
Theorem 4.5.7 in Lecture 15). In other words, $\operatorname*{ins}%
\nolimits_{n}$ is a bijection. Hence, there exists a bijection from $\left\{
\text{green sets}\right\}  $ to $\left\{  \text{red sets}\right\}  $ (namely,
$\operatorname*{ins}\nolimits_{n}$). Thus, the bijection principle yields%
\[
\left\vert \left\{  \text{green sets}\right\}  \right\vert =\left\vert
\left\{  \text{red sets}\right\}  \right\vert .
\]
In other words,%
\[
\left(  \text{\# of green sets}\right)  =\left(  \text{\# of red sets}\right)
,
\]
and thus%
\[
\left(  \text{\# of red sets}\right)  =\left(  \text{\# of green sets}\right)
=2^{n-1}.
\]


Combining what we have shown, we now obtain
\begin{align*}
\left(  \text{\# of subsets of }\left[  n\right]  \right)   &
=\underbrace{\left(  \text{\# of red sets}\right)  }_{=2^{n-1}}%
+\underbrace{\left(  \text{\# of green sets}\right)  }_{=2^{n-1}}\\
&  =2^{n-1}+2^{n-1}=2\cdot2^{n-1}=2^{n}.
\end{align*}
This is precisely what we needed to prove. This completes the induction step,
and thus Theorem \ref{thm.count.subsets.all.n-repeat} is proved.
\end{proof}

Theorem 4.3.2 in Lecture 13 says:

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

\end{theorem}

\begin{proof}
[Rigorous proof.]Informally, we derived this from Theorem
\ref{thm.count.subsets.all.n-repeat} by renaming the elements of $S$ as
$1,2,\ldots,n$ (so that $S$ became the set $\left[  n\right]  $).

Rigorously, this means setting up a one-to-one correspondence between the
subsets of $S$ and the subsets of $\left[  n\right]  $, and then using the
bijection principle to argue that the \# of the former equals the \# of the latter.

How do we get this correspondence? First, we set up a one-to-one
correspondence between the \textbf{elements} of $S$ and the elements of
$\left[  n\right]  $. (This is what the \textquotedblleft
renaming\textquotedblright\ in our informal proof was secretly doing.)
Formally, this can be done as follows:

The set $S$ is an $n$-element set, i.e., has size $n$. Hence, by the
definition of size, the set $S$ is isomorphic to $\left[  n\right]  $. In
other words, there is a bijection $\alpha:S\rightarrow\left[  n\right]  $.
Consider this $\alpha$. Being a bijection, the map $\alpha$ has an inverse
$\alpha^{-1}$ (by Theorem 4.5.7 in Lecture 15).

Now, define a map%
\begin{align*}
\alpha_{\ast}:\left\{  \text{subsets of }S\right\}   &  \rightarrow\left\{
\text{subsets of }\left[  n\right]  \right\}  ,\\
T  &  \mapsto\left\{  \alpha\left(  t\right)  \ \mid\ t\in T\right\}  .
\end{align*}
Explicitly, this map $\alpha_{\ast}$ sends every subset $\left\{  s_{1}%
,s_{2},\ldots,s_{k}\right\}  $ of $S$ to the subset $\left\{  \alpha\left(
s_{1}\right)  ,\alpha\left(  s_{2}\right)  ,\ldots,\alpha\left(  s_{k}\right)
\right\}  $ of $\left[  n\right]  $; that is, it applies $\alpha$ to every
element of the input subset. (For example, if $n=3$ and $S=\left\{
\text{\textquotedblleft cat\textquotedblright},\ \text{\textquotedblleft
dog\textquotedblright},\text{ \textquotedblleft rat\textquotedblright%
}\right\}  $ and if $\alpha\left(  \text{\textquotedblleft
cat\textquotedblright}\right)  =1$ and $\alpha\left(  \text{\textquotedblleft
dog\textquotedblright}\right)  =2$ and $\alpha\left(  \text{\textquotedblleft
rat\textquotedblright}\right)  =3$, then $\alpha_{\ast}\left(  \left\{
\text{\textquotedblleft cat\textquotedblright},\ \text{\textquotedblleft
rat\textquotedblright}\right\}  \right)  =\left\{  1,3\right\}  $.)

Conversely, we can define a map%
\begin{align*}
\left(  \alpha^{-1}\right)  _{\ast}:\left\{  \text{subsets of }\left[
n\right]  \right\}   &  \rightarrow\left\{  \text{subsets of }S\right\}  ,\\
T  &  \mapsto\left\{  \alpha^{-1}\left(  t\right)  \ \mid\ t\in T\right\}  .
\end{align*}
(This map $\left(  \alpha^{-1}\right)  _{\ast}$ is defined in the same way as
$\alpha_{\ast}$, but using the map $\alpha^{-1}$ instead of $\alpha$. For
example, if $n=3$ and $S=\left\{  \text{\textquotedblleft
cat\textquotedblright},\ \text{\textquotedblleft dog\textquotedblright},\text{
\textquotedblleft rat\textquotedblright}\right\}  $ and if $\alpha\left(
\text{\textquotedblleft cat\textquotedblright}\right)  =1$ and $\alpha\left(
\text{\textquotedblleft dog\textquotedblright}\right)  =2$ and $\alpha\left(
\text{\textquotedblleft rat\textquotedblright}\right)  =3$, then $\left(
\alpha^{-1}\right)  _{\ast}\left(  \left\{  2,3\right\}  \right)  =\left\{
\text{\textquotedblleft dog\textquotedblright},\text{ \textquotedblleft
rat\textquotedblright}\right\}  $.)

It is easy to see that the map $\left(  \alpha^{-1}\right)  _{\ast}$ is an
inverse of $\alpha_{\ast}$ (because applying $\alpha$ to each element of a
given set and then applying $\alpha^{-1}$ to the results will recover the
original set, and likewise if you apply $\alpha^{-1}$ first and then $\alpha
$). Thus, the map $\alpha_{\ast}$ has an inverse, i.e., is a bijection (by
Theorem 4.5.7 in Lecture 15). Thus, we have found a bijection from $\left\{
\text{subsets of }S\right\}  $ to $\left\{  \text{subsets of }\left[
n\right]  \right\}  $ (namely, $\alpha_{\ast}$). Hence, the bijection
principle (Theorem \ref{thm.count.rules.bij}) yields
\[
\left\vert \left\{  \text{subsets of }S\right\}  \right\vert =\left\vert
\left\{  \text{subsets of }\left[  n\right]  \right\}  \right\vert .
\]
In other words,%
\[
\left(  \text{\# of subsets of }S\right)  =\left(  \text{\# of subsets of
}\left[  n\right]  \right)  =2^{n}%
\]
(by Theorem \ref{thm.count.subsets.all.n-repeat}).
\end{proof}

\subsubsection{Counting all $k$-element subsets}

We move on to counting subsets of a given size.

Theorem 4.3.3 in Lecture 13 says:

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

\end{theorem}

\begin{proof}
[Rigorous proof.]We induct on $n$ (without fixing $k$). That is, we use
induction on $n$ to prove the statement%
\[
P\left(  n\right)  :=\left(
\begin{array}
[c]{c}%
\text{\textquotedblleft for any number }k\text{ and any }n\text{-element set
}S,\\
\text{we have }\left(  \text{\# of }k\text{-element subsets of }S\right)
=\dbinom{n}{k}\text{\textquotedblright}%
\end{array}
\right)
\]
for each $n\in\mathbb{N}$.

\textit{Base case:} Let $k$ be any number. The only $0$-element set is
$\varnothing$, and its only subset is $\varnothing$. Thus, a $0$-element set
$S$ necessarily has one $0$-element subset ($\varnothing$) and no other
subsets. Hence, it satisfies%
\[
\left(  \text{\# of }k\text{-element subsets of }S\right)  =%
\begin{cases}
1, & \text{if }k=0;\\
0, & \text{else.}%
\end{cases}
\]
However, we also have%
\[
\dbinom{0}{k}=%
\begin{cases}
1, & \text{if }k=0;\\
0, & \text{else}%
\end{cases}
\]
(this follows easily from the definition of binomial coefficients). By
comparing these two equalities, we see that any $0$-element set $S$ satisfies
\[
\left(  \text{\# of }k\text{-element subsets of }S\right)  =\dbinom{0}{k}.
\]
In other words, $P\left(  0\right)  $ holds.

\textit{Induction step:} Let $n$ be a positive integer. Assume (as the
induction hypothesis) that $P\left(  n-1\right)  $ holds. We must prove that
$P\left(  n\right)  $ holds.

So we consider any number $k$ and any $n$-element set $S$. We must prove that%
\[
\left(  \text{\# of }k\text{-element subsets of }S\right)  =\dbinom{n}{k}.
\]


We rename the $n$ elements of $S$ as $1,2,\ldots,n$ (this corresponds formally
to constructing a bijection $\alpha:S\rightarrow\left[  n\right]  $ and
applying it elementwise to subsets of $S$, as we did in the proof of Theorem
\ref{thm.count.subsets.all.S-repeat}), so we must prove that%
\[
\left(  \text{\# of }k\text{-element subsets of }\left[  n\right]  \right)
=\dbinom{n}{k}.
\]


To prove this, we define

\begin{itemize}
\item a \textbf{red set} to be a $k$-element subset of $\left[  n\right]  $
that contains $n$;

\item a \textbf{green set} to be a $k$-element subset of $\left[  n\right]  $
that does not contain $n$.
\end{itemize}

For instance, for $n=4$ and $k=2$, the red sets are%
\[
\left\{  1,4\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{  2,4\right\}
,\ \ \ \ \ \ \ \ \ \ \left\{  3,4\right\}  ,
\]
while the green sets are%
\[
\left\{  1,2\right\}  ,\ \ \ \ \ \ \ \ \ \ \left\{  1,3\right\}
,\ \ \ \ \ \ \ \ \ \ \left\{  2,3\right\}  .
\]


Each $k$-element subset of $\left[  n\right]  $ is either red or green (but
not both). Hence, using the sum rule for two sets, we find%
\begin{align}
&  \left(  \text{\# of }k\text{-element subsets of }\left[  n\right]  \right)
\nonumber\\
&  =\left(  \text{\# of red sets}\right)  +\left(  \text{\# of green
sets}\right)  . \label{pf.thm.count.subsets.size.S-repeat.sum}%
\end{align}
(This is proved just as we proved (\ref{pf.thm.count.subsets.all.n-repeat.sum}%
) in the rigorous proof of Theorem \ref{thm.count.subsets.all.n-repeat}.)

The green sets are just the $k$-element subsets of $\left[  n-1\right]  $.
Thus,%
\begin{align*}
\left(  \text{\# of green sets}\right)   &  =\left(  \text{\# of
}k\text{-element subsets of }\left[  n-1\right]  \right) \\
&  =\dbinom{n-1}{k}%
\end{align*}
(by the statement $P\left(  n-1\right)  $, which we have assumed to hold).

Now, let's try to count the red sets.

Let us refer to the $\left(  k-1\right)  $-element subsets of $\left[
n-1\right]  $ as \textbf{blue sets}. If $R$ is a red set, then $R\setminus
\left\{  n\right\}  $ is a blue set\footnote{\textit{Proof.} Let $R$ be a red
set. Then, $R$ is a $k$-element set (by the definition of a red set), so that
$\left\vert R\right\vert =k$. Moreover, $n\in R$ (by the definition of a red
set), so that $\left\{  n\right\}  \subseteq R$. Hence, the difference rule
(Theorem \ref{thm.count.rules.diff} \textbf{(b)}, applied to $S=R$ and
$T=\left\{  n\right\}  $) yields $\left\vert R\setminus\left\{  n\right\}
\right\vert =\underbrace{\left\vert R\right\vert }_{=k}-\underbrace{\left\vert
\left\{  n\right\}  \right\vert }_{=1}=k-1$. Hence, $R\setminus\left\{
n\right\}  $ is a $\left(  k-1\right)  $-element set. Since $R\setminus
\left\{  n\right\}  $ is furthermore a subset of $\left[  n-1\right]  $
(because $R$ is a subset of $\left[  n\right]  $, and we are removing $n$ from
it), we thus conclude that $R\setminus\left\{  n\right\}  $ is a $\left(
k-1\right)  $-element subset of $\left[  n-1\right]  $, that is, a blue set.}.
Thus, we obtain a map%
\begin{align*}
\operatorname*{rem}\nolimits_{n}:\left\{  \text{red sets}\right\}   &
\rightarrow\left\{  \text{blue sets}\right\}  ,\\
R &  \mapsto R\setminus\left\{  n\right\}  .
\end{align*}
Conversely, if $B$ is a blue set, then $B\cup\left\{  n\right\}  $ is a red
set\footnote{\textit{Proof.} Let $B$ be a blue set. Then, $B$ is a $\left(
k-1\right)  $-element subset of $\left[  n-1\right]  $ (by the definition of
\textquotedblleft blue set\textquotedblright). In other words, $\left\vert
B\right\vert =k-1$ and $B\subseteq\left[  n-1\right]  $. From $B\subseteq
\left[  n-1\right]  $, we obtain $n\notin B$ (since $n\notin\left[
n-1\right]  $). Hence, Theorem \ref{thm.count.rules.+1} (applied to $S=B$ and
$t=n$) yields $\left\vert B\cup\left\{  n\right\}  \right\vert =\left\vert
B\right\vert +1=k$ (since $\left\vert B\right\vert =k-1$). Hence,
$B\cup\left\{  n\right\}  $ is a $k$-element set. Furthermore, $B\cup\left\{
n\right\}  $ is a subset of $\left[  n\right]  $ (since $B\subseteq\left[
n-1\right]  \subseteq\left[  n\right]  $ and $\left\{  n\right\}
\subseteq\left[  n\right]  $) that contains $n$ (since $n\in\left\{
n\right\}  \subseteq B\cup\left\{  n\right\}  $). Thus, $B\cup\left\{
n\right\}  $ is a $k$-element subset of $\left[  n\right]  $ that contains
$n$. In other words, $B\cup\left\{  n\right\}  $ is a red set (by the
definition of \textquotedblleft red set\textquotedblright).}. Thus, we obtain
a map%
\begin{align*}
\operatorname*{ins}\nolimits_{n}:\left\{  \text{blue sets}\right\}   &
\rightarrow\left\{  \text{red sets}\right\}  ,\\
B &  \mapsto B\cup\left\{  n\right\}  .
\end{align*}
These two maps $\operatorname*{rem}\nolimits_{n}$ and $\operatorname*{ins}%
\nolimits_{n}$ are mutually inverse\footnote{This can be proved just as in our
above proof of Theorem \ref{thm.count.subsets.all.n-repeat}.}. Thus, the map
$\operatorname*{rem}\nolimits_{n}$ has an inverse, i.e., is bijective (by
Theorem 4.5.7 in Lecture 15). Hence, we have found a bijection from $\left\{
\text{red sets}\right\}  $ to $\left\{  \text{blue sets}\right\}  $ (namely,
$\operatorname*{rem}\nolimits_{n}$). The bijection principle therefore yields%
\[
\left\vert \left\{  \text{red sets}\right\}  \right\vert =\left\vert \left\{
\text{blue sets}\right\}  \right\vert .
\]
In other words,%
\begin{align*}
\left(  \text{\# of red sets}\right)   &  =\left(  \text{\# of blue
sets}\right)  \\
&  =\left(  \text{\# of }\left(  k-1\right)  \text{-element subsets of
}\left[  n-1\right]  \right)  \\
&  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(  \text{since this is how the
blue sets were defined}\right)  \\
&  =\dbinom{n-1}{k-1}%
\end{align*}
(again by the statement $P\left(  n-1\right)  $, but now applied to $k-1$
instead of $k$). Note that we deliberately formulated $P\left(  n\right)  $ as
a \textquotedblleft for any $k$\textquotedblright\ statement (rather than
fixing $k$ at the onset of our proof), so that we were now able to apply
$P\left(  n-1\right)  $ to $k-1$ instead of $k$.

Now, (\ref{pf.thm.count.subsets.size.S-repeat.sum}) becomes%
\begin{align*}
\left(  \text{\# of }k\text{-element subsets of }\left[  n\right]  \right)
&  =\underbrace{\left(  \text{\# of red sets}\right)  }_{=\dbinom{n-1}{k-1}%
}+\underbrace{\left(  \text{\# of green sets}\right)  }_{=\dbinom{n-1}{k}}\\
&  =\dbinom{n-1}{k-1}+\dbinom{n-1}{k}=\dbinom{n}{k}%
\end{align*}
by Pascal's recurrence (Theorem 2.5.3 in Lecture 6). But this is precisely the
equality that we have to prove. This completes the induction step, and thus
Theorem \ref{thm.count.subsets.size.S-repeat} is proved.
\end{proof}

\begin{remark}
Our above proof of Theorem \ref{thm.count.subsets.size.S-repeat} can be
simplified: There is no need to \textquotedblleft rename\textquotedblright%
\ the elements of $S$ as $1,2,\ldots,n$ in the induction step. Instead, we
could have just as well picked an arbitrary element $t$ of $S$ (such an
element exists, since $\left\vert S\right\vert =n>0$ entails that $S$ is
nonempty) and defined

\begin{itemize}
\item a \textbf{red set} to be a $k$-element subset of $S$ that contains $t$;

\item a \textbf{green set} to be a $k$-element subset of $S$ that does not
contain $t$.
\end{itemize}

Then, a simple application of Theorem \ref{thm.count.rules.diff} \textbf{(b)}
would have shown that $S\setminus\left\{  t\right\}  $ is an $\left(
n-1\right)  $-element set, so we could apply our induction hypothesis
$P\left(  n-1\right)  $ to it. Thus, the above argument could be made using
$S$, $t$ and $S\setminus\left\{  t\right\}  $ instead of $\left[  n\right]  $,
$n$ and $\left[  n-1\right]  $. In particular, the green sets would be
precisely the $k$-element subsets of $S\setminus\left\{  t\right\}  $, whereas
the red sets would be in one-to-one correspondence (i.e., bijection) with the
$\left(  k-1\right)  $-element subsets of $S\setminus\left\{  t\right\}  $
(and the bijection would be given by removing/inserting $t$). This argument
would be not only shorter but also more conceptual than the one we gave above.

However, I chose to give the proof I gave because it has the advantage of
familiarity (the set $\left[  n\right]  =\left\{  1,2,\ldots,n\right\}  $ is
easier to visualize than an arbitrary $n$-element set), and in order to
illustrate how the bijection principle can be used to rename the elements of a
given set in a convenient way.

Likewise, Theorem \ref{thm.count.subsets.all.S-repeat} could also be proved
more directly: Instead of deducing it from Theorem
\ref{thm.count.subsets.all.n-repeat} via \textquotedblleft
renaming\textquotedblright, we could have proved it by induction, again
picking an element $t$ of $S$ in the induction step, defining red and green
sets, and counting both kinds of sets using the induction hypothesis (applied
to the $\left(  n-1\right)  $-element set $S\setminus\left\{  t\right\}  $).
\end{remark}

Let us derive a nice, if simple, corollary from our last few theorems:

\begin{corollary}
\label{cor.count.subsets.2n=}Let $n\in\mathbb{N}$. Then,%
\[
\sum_{k=0}^{n}\dbinom{n}{k}=2^{n}.
\]

\end{corollary}

\begin{proof}
Consider the $n$-element set $\left[  n\right]  =\left\{  1,2,\ldots
,n\right\}  $. This set has size $n$, so each subset of $\left[  n\right]  $
must have size $\leq n$ (by Theorem \ref{thm.count.rules.diff} \textbf{(a)}).
Hence, each subset of $\left[  n\right]  $ has size $0$ or size $1$ or size
$2$ or $\cdots$ or size $n$. Thus, we can write the set%
\[
\left\{  \text{subsets of }\left[  n\right]  \right\}
\]
as a union%
\begin{align*}
&  \left\{  0\text{-element subsets of }\left[  n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \cup\left\{  1\text{-element subsets of }\left[
n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \cup\left\{  2\text{-element subsets of }\left[
n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \cup\cdots\\
&  \ \ \ \ \ \ \ \ \ \ \cup\left\{  n\text{-element subsets of }\left[
n\right]  \right\}  .
\end{align*}
Furthermore, this union is a union of disjoint sets (since a subset of
$\left[  n\right]  $ cannot have several distinct sizes at once). Therefore,
the sum rule for $k$ sets (Theorem \ref{thm.count.rules.sum-k}) yields%
\begin{align*}
&  \left\vert \left\{  \text{subsets of }\left[  n\right]  \right\}
\right\vert \\
&  =\left\vert \left\{  0\text{-element subsets of }\left[  n\right]
\right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  1\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  2\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\cdots\\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  n\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert .
\end{align*}
\footnote{In more details:
\par
The $n+1$ sets%
\begin{align*}
&  \left\{  0\text{-element subsets of }\left[  n\right]  \right\}  ,\\
&  \left\{  1\text{-element subsets of }\left[  n\right]  \right\}  ,\\
&  \left\{  2\text{-element subsets of }\left[  n\right]  \right\}  ,\\
&  \ldots,\\
&  \left\{  n\text{-element subsets of }\left[  n\right]  \right\}
\end{align*}
are finite (since $\left[  n\right]  $ has only finitely many subsets) and
disjoint (since a subset of $\left[  n\right]  $ cannot have several distinct
sizes at once). Thus, the sum rule for $k$ sets (Theorem
\ref{thm.count.rules.sum-k}) yields%
\begin{align*}
&  \Big|\ \left\{  0\text{-element subsets of }\left[  n\right]  \right\}
\cup\left\{  1\text{-element subsets of }\left[  n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \left\{  2\text{-element subsets of }\left[  n\right]
\right\}  \cup\cdots\cup\left\{  n\text{-element subsets of }\left[  n\right]
\right\}  \Big|\\
&  =\left\vert \left\{  0\text{-element subsets of }\left[  n\right]
\right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  1\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  2\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\cdots\\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  n\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert .
\end{align*}
\par
Since
\[
\left\{  \text{subsets of }\left[  n\right]  \right\}
\]
is the union%
\begin{align*}
&  \left\{  0\text{-element subsets of }\left[  n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \cup\left\{  1\text{-element subsets of }\left[
n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \cup\left\{  2\text{-element subsets of }\left[
n\right]  \right\} \\
&  \ \ \ \ \ \ \ \ \ \ \cup\cdots\\
&  \ \ \ \ \ \ \ \ \ \ \cup\left\{  n\text{-element subsets of }\left[
n\right]  \right\}  ,
\end{align*}
we can rewrite this equality as
\begin{align*}
&  \left\vert \left\{  \text{subsets of }\left[  n\right]  \right\}
\right\vert \\
&  =\left\vert \left\{  0\text{-element subsets of }\left[  n\right]
\right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  1\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  2\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert \\
&  \ \ \ \ \ \ \ \ \ \ +\cdots\\
&  \ \ \ \ \ \ \ \ \ \ +\left\vert \left\{  n\text{-element subsets of
}\left[  n\right]  \right\}  \right\vert .
\end{align*}
}

In other words,%
\begin{align*}
&  \left(  \text{\# of subsets of }\left[  n\right]  \right) \\
&  =\left(  \text{\# of }0\text{-element subsets of }\left[  n\right]  \right)
\\
&  \ \ \ \ \ \ \ \ \ \ +\left(  \text{\# of }1\text{-element subsets of
}\left[  n\right]  \right) \\
&  \ \ \ \ \ \ \ \ \ \ +\left(  \text{\# of }2\text{-element subsets of
}\left[  n\right]  \right) \\
&  \ \ \ \ \ \ \ \ \ \ +\cdots\\
&  \ \ \ \ \ \ \ \ \ \ +\left(  \text{\# of }n\text{-element subsets of
}\left[  n\right]  \right) \\
&  =\sum_{k=0}^{n}\underbrace{\left(  \text{\# of }k\text{-element subsets of
}\left[  n\right]  \right)  }_{\substack{=\dbinom{n}{k}\\\text{(by Theorem
\ref{thm.count.subsets.size.S-repeat}, applied to }S=\left[  n\right]
\text{)}}}\\
&  =\sum_{k=0}^{n}\dbinom{n}{k}.
\end{align*}
Thus,%
\[
\sum_{k=0}^{n}\dbinom{n}{k}=\left(  \text{\# of subsets of }\left[  n\right]
\right)  =2^{n}%
\]
(by Theorem \ref{thm.count.subsets.all.n-repeat}).
\end{proof}

Corollary \ref{cor.count.subsets.2n=} can also be easily obtained from the
binomial formula (exercise!).

\subsubsection{Recounting pairs}

Proposition 4.4.3 in Lecture 13 says:

\begin{proposition}
\label{prop.count.pairs.nn-repeat}Let $n\in\mathbb{N}$. Then:

\textbf{(a)} The \# of pairs $\left(  a,b\right)  $ with $a,b\in\left[
n\right]  $ is $n^{2}$.

\textbf{(b)} The \# of pairs $\left(  a,b\right)  $ with $a,b\in\left[
n\right]  $ and $a<b$ is $1+2+\cdots+\left(  n-1\right)  $.

\textbf{(c)} The \# of pairs $\left(  a,b\right)  $ with $a,b\in\left[
n\right]  $ and $a=b$ is $n$.

\textbf{(d)} The \# of pairs $\left(  a,b\right)  $ with $a,b\in\left[
n\right]  $ and $a>b$ is $1+2+\cdots+\left(  n-1\right)  $.
\end{proposition}

Let us reprove part \textbf{(b)} of this proposition rigorously:

\begin{proof}
[Rigorous proof of Proposition \ref{prop.count.pairs.nn-repeat} \textbf{(b)}
(sketched).]If $\left(  a,b\right)  $ is a pair with $a,b\in\left[  n\right]
$ and $a<b$, then the first entry of this pair (that is, the number $a$) must
be one of the numbers $1,2,\ldots,n-1$ (because $a<b\leq n$ forces $a$ to be
$\leq n-1$). Thus, by the sum rule for $k$ sets (Theorem
\ref{thm.count.rules.sum-k}), we have%
\begin{align*}
&  \left(  \text{\# of pairs }\left(  a,b\right)  \text{ with }a,b\in\left[
n\right]  \text{ and }a<b\right) \\
&  =\sum_{k=1}^{n-1}\underbrace{\left(  \text{\# of pairs }\left(  a,b\right)
\text{ with }a,b\in\left[  n\right]  \text{ and }a<b\text{ and }a=k\right)
}_{\substack{=n-k\\\text{(because these pairs are }\left(  k,\ k+1\right)
,\ \left(  k,\ k+2\right)  ,\ \ldots,\ \left(  k,n\right)  \\\text{(strictly
speaking, this argument is an application of}\\\text{the bijection
principle))}}}\\
&  =\sum_{k=1}^{n-1}\left(  n-k\right)  =\left(  n-1\right)  +\left(
n-2\right)  +\cdots+\left(  n-\left(  n-1\right)  \right) \\
&  =\left(  n-1\right)  +\left(  n-2\right)  +\cdots+1\\
&  =1+2+\cdots+\left(  n-1\right)  ,
\end{align*}
and thus Proposition \ref{prop.count.pairs.nn-repeat} \textbf{(b)} is proven.
\end{proof}

\subsection{Where do we stand now?}

Recall the introductory counting problems from the start of Chapter 4 (Lecture
12). We can now answer some of these:

\begin{itemize}
\item How many ways are there to choose $3$ odd integers between $0$ and $20$,
if the order matters (i.e., we count the choice $1,3,5$ as different from the
choice $3,1,5$)? (The answer is $1000$.)

\textbf{We can solve this now:} To choose $3$ odd integers between $0$ and
$20$, if the order matters, amounts to choosing a $3$-tuple $\left(
a,b,c\right)  $ where $a,b,c\in\left\{  1,3,5,\ldots,19\right\}  $. Since this
set $\left\{  1,3,5,\ldots,19\right\}  $ is a $10$-element set (because
Proposition 4.2.1 from Lecture 12 yields that the \# of odd integers between
$0$ and $20$ is $\left(  20+1\right)  //2=10$), the \# of these $3$-tuples is
$10\cdot10\cdot10=1000$ (by Theorem 4.4.5 in Lecture 13).

\item How many ways are there to choose $3$ odd integers between $0$ and $20$,
if the order does not matter? (The answer is $220$.)

\textbf{We cannot solve this yet}, at least not if the values $3$ and $20$ are
generalized to $k$ and $n$. This will be done next week.

\item How many ways are there to choose $3$ distinct odd integers between $0$
and $20$, if the order matters? (The answer is $720$.)

\textbf{We cannot solve this yet}, at least not if the values $3$ and $20$ are
generalized to $k$ and $n$. This will be done next week.

\item How many ways are there to choose $3$ distinct odd integers between $0$
and $20$, if the order does not matter? (The answer is $120$.)

\textbf{We can solve this now:} This amounts to counting the $3$-element
subsets of $\left\{  1,3,5,\ldots,19\right\}  $; but Theorem
\ref{thm.count.subsets.size.S-repeat} answers such questions. Since the set
$\left\{  1,3,5,\ldots,19\right\}  $ has size $10$, its number of $3$-element
subsets is $\dbinom{10}{3}=\dfrac{10\cdot9\cdot8}{3!}=120$.

\item How many prime factorizations does $200$ have (where we count different
orderings as distinct)? (The answer is $10$. This is a mix between a number
theory problem and a counting problem.)

\textbf{We can solve this now, at least for }$200$\textbf{:} We know that
$200=2\cdot2\cdot2\cdot5\cdot5$. Thus, by the fundamental theorem of
arithmetic, all prime factorizations of $200$ consist of five factors, three
of which are $2$'s and two of which are $5$'s. The only freedom is in choosing
where to place the three $2$'s among the five positions (of course, the two
$5$'s will then have to occupy the remaining positions). There are $5$ factors
in total, so $5$ positions, and we have to choose $3$ of these $5$ positions
to put our three $2$'s in. This is tantamount to choosing a $3$-element subset
of $\left[  5\right]  $ (the subset of the positions in which we put the
$2$'s), and the \# of ways to do this is $\dbinom{5}{3}=10$ (by Theorem
\ref{thm.count.subsets.size.S-repeat}). Thus, $200$ has $10$ prime
factorizations (if we count different orderings as distinct).

However, it is trickier to extend this reasoning to prime factorizations of
$150$. Indeed, $150=2\cdot3\cdot5\cdot5$, so a prime factorization of $150$
has one $2$, one $3$ and two $5$'s. How many ways are there to place one $2$,
one $3$ and two $5$'s in altogether four positions? I'll leave this one to you
for now, but we will come back to this later.

\item How many ways are there to tile a $2\times15$-rectangle with dominos
(i.e., rectangles of size $1\times2$ or $2\times1$) ? (The answer is $987$.)

\textbf{We cannot solve this yet.}

\item How many addends do you get when you expand the product \newline$\left(
a+b\right)  \left(  c+d+e\right)  \left(  f+g\right)  $ ? (The answer is $12$.)

\textbf{We can solve this now:} Each addend consists of exactly one of $a$ and
$b$, exactly one of $c$, $d$ and $e$, and exactly one of $f$ and $g$. So the
addends are in one-to-one correspondence with the triples $\left(
x,y,z\right)  $ where $x\in\left\{  a,b\right\}  $ and $y\in\left\{
c,d,e\right\}  $ and $z\in\left\{  f,g\right\}  $. Thus, their \# is
$2\cdot3\cdot2$ (since $\left\{  a,b\right\}  $ is a $2$-element set,
$\left\{  c,d,e\right\}  $ is a $3$-element set, and $\left\{  f,g\right\}  $
is a $2$-element set).

Note that we are using the fact that the addends all end up distinct, so they
don't cancel or combine.

\item How many different monomials do you get when you expand the product
$\left(  a-b\right)  \left(  a^{2}+ab+b^{2}\right)  $ ? (This one is more of
an algebra problem, but I wanted to list it because it is connected to
counting. The answer is $2$, because $\left(  a-b\right)  \left(
a^{2}+ab+b^{2}\right)  =a^{3}-b^{3}$.)

\textbf{This is not a combinatorics problem:} The answer is $2$, because we
have $\left(  a-b\right)  \left(  a^{2}+ab+b^{2}\right)  =a^{3}-b^{3}$. The
other addends all cancel out, so you get an answer much less than $6$.

In general, problems like this (where you count addends after cancellation and
combination) cannot be solved combinatorially; you have to actually expand and collect.

\item How many positive divisors does $24$ have? (We can actually list them:
$1,\ 2,\ 3,\ 4,\ 6,\ 8,\ 12,\ 24$. This one is again a mix of a counting
problem and a number theory problem.)

\textbf{We cannot solve this yet.}
\end{itemize}

\begin{thebibliography}{9999999}                                                                                          %


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


\end{document}