\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:41: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 11, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 222 Fall 2022, Lecture 11: Introduction}

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

\section{Introduction (cont'd)}

\setcounter{subsection}{4}

\subsection{Counting tuples and maps (cont'd)}

\setcounter{subsubsection}{1}

Recall: In Lecture 10, we proved the formula%
\begin{equation}
\left\vert A^{n}\right\vert =\left\vert A\right\vert ^{n}
\label{eq.count.tuples.main}%
\end{equation}
for any finite set $A$ and any $n\in\mathbb{N}$.

\subsubsection{Counting maps}

\setcounter{theo}{4}

\begin{definition}
Let $A$ and $B$ be two sets. Then, $B^{A}$ shall mean the set of all maps (=
functions) from $A$ to $B$.
\end{definition}

This strange notation is used for a reason:

\begin{theorem}
\label{thm.count-maps}Let $A$ and $B$ be two finite sets. Then, the set
$B^{A}$ is again finite, and has size%
\[
\left\vert B^{A}\right\vert =\left\vert B\right\vert ^{\left\vert A\right\vert
}.
\]

\end{theorem}

\begin{example}
Let us see how this works out for $A=\left[  2\right]  =\left\{  1,2\right\}
$ and $B=\left[  3\right]  =\left\{  1,2,3\right\}  $. Then,%
\[
B^{A}=\left\{  \text{all maps from }A\text{ to }B\right\}  =\left\{  \text{all
maps from }\left[  2\right]  \text{ to }\left[  3\right]  \right\}  .
\]
One way to list these maps is by using \textbf{two-line notation}. The
\textbf{two-line notation} of a map $f:A\rightarrow B$ is a table with two
rows, where the top row lists all elements of $A$, and the bottom row lists
their images under $f$. In other words, it is a table of the form%
\[
\left(
\begin{array}
[c]{cccc}%
a_{1} & a_{2} & \cdots & a_{k}\\
f\left(  a_{1}\right)  & f\left(  a_{2}\right)  & \cdots & f\left(
a_{k}\right)
\end{array}
\right)  ,
\]
where $a_{1},a_{2},\ldots,a_{k}$ are the elements of $A$. The maps from
$A=\left[  2\right]  $ to $B=\left[  3\right]  $ are then (in two-line
notation)%
\begin{align*}
&  \left(
\begin{array}
[c]{cc}%
1 & 2\\
1 & 1
\end{array}
\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{cc}%
1 & 2\\
1 & 2
\end{array}
\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{cc}%
1 & 2\\
1 & 3
\end{array}
\right)  ,\\
&  \left(
\begin{array}
[c]{cc}%
1 & 2\\
2 & 1
\end{array}
\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{cc}%
1 & 2\\
2 & 2
\end{array}
\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{cc}%
1 & 2\\
2 & 3
\end{array}
\right)  ,\\
&  \left(
\begin{array}
[c]{cc}%
1 & 2\\
3 & 1
\end{array}
\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{cc}%
1 & 2\\
3 & 2
\end{array}
\right)  ,\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{cc}%
1 & 2\\
3 & 3
\end{array}
\right)  .
\end{align*}
There are $9$ of these maps, which fits the claim of the theorem, since
$\left\vert B\right\vert ^{\left\vert A\right\vert }=3^{2}=9$.
\end{example}

\begin{proof}
[Proof of Theorem \ref{thm.count-maps} (sketched).]Let $a_{1},a_{2}%
,\ldots,a_{k}$ be all the elements of $A$, listed in some way without
repetition. Then, $k=\left\vert A\right\vert $.

Recall that $B^{A}$ is the set of all maps $f:A\rightarrow B$. Such a map
$f:A\rightarrow B$ is uniquely determined by the values $f\left(
a_{1}\right)  ,f\left(  a_{2}\right)  ,\ldots,f\left(  a_{k}\right)  $, and
these values can be chosen arbitrarily (and independently) from $B$. So
essentially, such a map $f$ is \textquotedblleft the same as\textquotedblright%
\ the $k$-tuple $\left(  f\left(  a_{1}\right)  ,f\left(  a_{2}\right)
,\ldots,f\left(  a_{k}\right)  \right)  \in B^{k}$. Formally speaking, there
is a bijection%
\begin{align*}
B^{A}  &  \rightarrow B^{k},\\
f  &  \mapsto\left(  f\left(  a_{1}\right)  ,f\left(  a_{2}\right)
,\ldots,f\left(  a_{k}\right)  \right)  .
\end{align*}
Thus, by the bijection principle,%
\begin{align*}
\left\vert B^{A}\right\vert  &  =\left\vert B^{k}\right\vert =\left\vert
B\right\vert ^{k}\ \ \ \ \ \ \ \ \ \ \left(  \text{by
(\ref{eq.count.tuples.main})}\right) \\
&  =\left\vert B\right\vert ^{\left\vert A\right\vert }%
\ \ \ \ \ \ \ \ \ \ \left(  \text{since }k=\left\vert A\right\vert \right)  .
\end{align*}
This proves Theorem \ref{thm.count-maps}.
\end{proof}

\subsubsection{Application: Counting subsets bijectively}

Recall:

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

\end{theorem}

We proved this by induction in \S 1.4.1 (Lecture 8). Now, let us reprove this bijectively:

\begin{proof}
[Another proof of Theorem \ref{thm.subsets.all} (sketched).](See \S 1.5.3 in
the 2019 notes for details.)

Let $\mathcal{P}\left(  S\right)  $ denote the powerset of $S$; this is the
set of all subsets of $S$. Thus, we must prove that $\left\vert \mathcal{P}%
\left(  S\right)  \right\vert =2^{n}$.

Let $s_{1},s_{2},\ldots,s_{n}$ be the $n$ elements of $S$, listed in some way
(without repetitions).

We will construct a bijection
\begin{align*}
\text{from the set }\mathcal{P}\left(  S\right)   &  =\left\{  \text{subsets
of }S\right\} \\
\text{to the set }\left\{  0,1\right\}  ^{n}  &  =\left\{  n\text{-tuples of
elements of }\left\{  0,1\right\}  \right\}  .
\end{align*}


To wit, we define a map $A:\mathcal{P}\left(  S\right)  \rightarrow\left\{
0,1\right\}  ^{n}$ as follows:%
\[
A\left(  T\right)  =\left(  \left[  s_{1}\in T\right]  ,\ \left[  s_{2}\in
T\right]  ,\ \ldots,\ \left[  s_{n}\in T\right]  \right)
\ \ \ \ \ \ \ \ \ \ \text{for any }T\subseteq S.
\]
Conversely, we define a map $B:\left\{  0,1\right\}  ^{n}\rightarrow
\mathcal{P}\left(  S\right)  $ as follows:%
\begin{align*}
B\left(  i_{1},i_{2},\ldots,i_{n}\right)   &  =\left\{  s_{k}\ \mid
\ k\in\left[  n\right]  \text{ and }i_{k}=1\right\} \\
&  \ \ \ \ \ \ \ \ \ \ \text{for each }\left(  i_{1},i_{2},\ldots
,i_{n}\right)  \in\left\{  0,1\right\}  ^{n}.
\end{align*}
It is straightforward to see that
\[
A\circ B=\operatorname*{id}\ \ \ \ \ \ \ \ \ \ \text{and}%
\ \ \ \ \ \ \ \ \ \ B\circ A=\operatorname*{id}.
\]
(The notation $\operatorname*{id}$ stands for the identity map of a set, i.e.,
the map that sends each $x$ to $x$. So \textquotedblleft$A\circ
B=\operatorname*{id}$\textquotedblright\ means that $A\left(  B\left(
x\right)  \right)  =x$ for each $x$.)

These two equalities show that the maps $A$ and $B$ are mutually inverse.
Thus, the map $A$ is invertible, i.e., bijective. In other words, $A$ is a
bijection. Hence, by the bijection principle,%
\begin{align*}
\left\vert \mathcal{P}\left(  S\right)  \right\vert  &  =\left\vert \left\{
0,1\right\}  ^{n}\right\vert =\left\vert \left\{  0,1\right\}  \right\vert
^{n}\ \ \ \ \ \ \ \ \ \ \left(  \text{by (\ref{eq.count.tuples.main})}\right)
\\
&  =2^{n},
\end{align*}
so that Theorem \ref{thm.subsets.all} is proved again.
\end{proof}

A few exercises on the subject appear at the end of \S 1.5.3 in the 2019 notes.

\subsection{Interchange of summations}

\subsubsection{The finite Fubini principle}

Now let us return to the properties of finite sums. We have already seen some
rules for manipulating such sums. Here is another:

\begin{theorem}
[finite Fubini principle]\label{thm.fubini.rect}Let $X$ and $Y$ be two finite
sets. Let $a_{\left(  x,y\right)  }$ be a number for each pair $\left(
x,y\right)  \in X\times Y$. Then,%
\[
\sum_{x\in X}\ \ \sum_{y\in Y}a_{\left(  x,y\right)  }=\sum_{\left(
x,y\right)  \in X\times Y}a_{\left(  x,y\right)  }=\sum_{y\in Y}\ \ \sum_{x\in
X}a_{\left(  x,y\right)  }.
\]

\end{theorem}

The idea behind this theorem is that all three sides of this equality are just
the sum of all the numbers $a_{\left(  x,y\right)  }$, organized in three
different ways. This is easiest to see on an example in which $X=\left[
n\right]  $ and $Y=\left[  m\right]  $:

\begin{example}
\label{exa.fubini.rect}Let $n,m\in\mathbb{N}$. Let $a_{\left(  x,y\right)  }$
be a number for each pair $\left(  x,y\right)  \in\left[  n\right]
\times\left[  m\right]  $. Then, the finite Fubini principle (applied to
$X=\left[  n\right]  $ and $Y=\left[  m\right]  $) says that%
\[
\sum_{x\in\left[  n\right]  }\ \ \sum_{y\in\left[  m\right]  }a_{\left(
x,y\right)  }=\sum_{\left(  x,y\right)  \in\left[  n\right]  \times\left[
m\right]  }a_{\left(  x,y\right)  }=\sum_{y\in\left[  m\right]  }%
\ \ \sum_{x\in\left[  n\right]  }a_{\left(  x,y\right)  }.
\]
In other words, it says that%
\begin{equation}
\sum_{x=1}^{n}\ \ \sum_{y=1}^{m}a_{\left(  x,y\right)  }=\sum_{\left(
x,y\right)  \in\left[  n\right]  \times\left[  m\right]  }a_{\left(
x,y\right)  }=\sum_{y=1}^{m}\ \ \sum_{x=1}^{n}a_{\left(  x,y\right)  }.
\label{eq.exa.fubini.rect.2}%
\end{equation}
This equality becomes very intuitive if you arrange the numbers $a_{\left(
x,y\right)  }$ into a rectangular table:%
\[%
\begin{array}
[c]{cccc}%
a_{\left(  1,1\right)  } & a_{\left(  1,2\right)  } & \cdots & a_{\left(
1,m\right)  }\\
a_{\left(  2,1\right)  } & a_{\left(  2,2\right)  } & \cdots & a_{\left(
2,m\right)  }\\
\vdots & \vdots & \ddots & \vdots\\
a_{\left(  n,1\right)  } & a_{\left(  n,2\right)  } & \cdots & a_{\left(
n,m\right)  }%
\end{array}
\ \ .
\]
Then, the equality (\ref{eq.exa.fubini.rect.2}) is simply saying that%
\begin{align*}
&  \sum_{x=1}^{n}\left(  \text{sum of all entries of the }x\text{-th row of
the table}\right) \\
&  =\left(  \text{sum of all entries of the table}\right) \\
&  =\sum_{y=1}^{m}\left(  \text{sum of all entries of the }y\text{-th column
of the table}\right)  .
\end{align*}

\end{example}

This example shows that the finite Fubini principle is intuitively obvious (at
least in the case when $X=\left[  n\right]  $ and $Y=\left[  m\right]  $; but
the general case differs only in the way the numbers $a_{\left(  x,y\right)
}$ are labelled). A rigorous proof can be given by induction on $\left\vert
X\right\vert $ (also, a reference appears in the 2019 notes).

The name \textquotedblleft Fubini principle\textquotedblright\ is a reference
to the (similar-looking, but much subtler) Fubini theorem for double
integrals. Just as the latter makes it possible to interchange two integral
signs, the former allows us to interchange two summation signs. When we use
the Fubini principle to replace a sum of the form $\sum_{x=1}^{n}%
\ \ \sum_{y=1}^{m}a_{\left(  x,y\right)  }$ by $\sum_{y=1}^{m}\ \ \sum
_{x=1}^{n}a_{\left(  x,y\right)  }$ (or vice versa), we say that we are
\textbf{interchanging the summation signs}.

\bigskip

Here is a sample application of the Fubini principle (Exercise 1.6.1 in the
2019 notes):

\begin{exercise}
\label{exe.sum.fubini-exam1}Let $n\in\mathbb{N}$. Let $S$ be an $n$-element
set. Find the sum of the sizes of all subsets of $S$, that is, find
$\sum\limits_{T\subseteq S}\left\vert T\right\vert $.
\end{exercise}

We shall solve this using the following simple (but extremely useful) fact:

\begin{proposition}
[\textquotedblleft Counting by roll call\textquotedblright]%
\label{prop.rolecall}Let $S$ be a finite set.

\textbf{(a)} If $T$ is a subset of $S$, then%
\[
\left\vert T\right\vert =\sum_{s\in S}\left[  s\in T\right]  .
\]


\textbf{(b)} For each $s\in S$, let $\mathcal{A}\left(  s\right)  $ be a
logical statement (for example, \textquotedblleft$s$ is an even
number\textquotedblright\ or \textquotedblleft$s=\varnothing$%
\textquotedblright). Then,%
\[
\left(  \text{\# of all }s\in S\text{ that satisfy }\mathcal{A}\left(
s\right)  \right)  =\sum_{s\in S}\left[  \mathcal{A}\left(  s\right)  \right]
.
\]

\end{proposition}

\begin{proof}
[Proof sketch.](See Proposition 1.6.3 in the 2019 notes for details.)

\textbf{(a)} The truth value $\left[  s\in T\right]  $ equals $1$ for each
$s\in T$ and equals $0$ for each $s\in S\setminus T$. Hence, the sum
$\sum_{s\in S}\left[  s\in T\right]  $ contains $\left\vert T\right\vert $
many addends equal to $1$ (namely, one such addend for each $s\in T$) and
$\left\vert S\setminus T\right\vert $ many addends equal to $0$ (namely, one
such addend for each $s\in S\setminus T$). Thus, this sum equals $\left\vert
T\right\vert \cdot1+\left\vert S\setminus T\right\vert \cdot0=\left\vert
T\right\vert $. This proves part \textbf{(a)}.

\textbf{(b)} Apply part \textbf{(a)} to the subset $T:=\left\{  s\in
S\ \mid\ \mathcal{A}\left(  s\right)  \right\}  $. Then,
\[
\left\vert T\right\vert =\left(  \text{\# of all }s\in S\text{ that satisfy
}\mathcal{A}\left(  s\right)  \right)  ,
\]
and each $s\in S$ satisfies $\left[  s\in T\right]  =\left[  \mathcal{A}%
\left(  s\right)  \right]  $. Thus, part \textbf{(b)} follows from part
\textbf{(a)}.
\end{proof}

\begin{example}
Proposition \ref{prop.rolecall} \textbf{(b)} (applied to $S=\left[  5\right]
$ and $\mathcal{A}\left(  s\right)  =\left(  \text{\textquotedblleft}s\text{
is odd\textquotedblright}\right)  $) yields
\[
\left(  \text{\# of }s\in\left[  5\right]  \text{ that are odd}\right)
=\sum_{s\in\left[  5\right]  }\left[  s\text{ is odd}\right]  =1+0+1+0+1.
\]

\end{example}

Applied in the right situation, Proposition \ref{prop.rolecall} can be very
useful. Let us use it to solve Exercise \ref{exe.sum.fubini-exam1}:

\begin{proof}
[Solution to Exercise \ref{exe.sum.fubini-exam1}.]We have%
\begin{align*}
\sum\limits_{T\subseteq S}\underbrace{\left\vert T\right\vert }%
_{\substack{=\sum_{s\in S}\left[  s\in T\right]  \\\text{(by Proposition
\ref{prop.rolecall} \textbf{(a)})}}} &  =\sum_{T\subseteq S}\ \ \sum_{s\in
S}\left[  s\in T\right]  \\
&  =\sum_{s\in S}\ \ \underbrace{\sum_{T\subseteq S}\left[  s\in T\right]
}_{\substack{=\left(  \text{\# of all subsets }T\subseteq S\text{ such that
}s\in T\right)  \\\text{(by Proposition \ref{prop.rolecall} \textbf{(b)})}}}\\
&  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{here, we have interchanged the}\\
\text{summation signs, using the}\\
\text{finite Fubini principle}%
\end{array}
\right)  \\
&  =\sum_{s\in S}\underbrace{\left(  \text{\# of all subsets }T\subseteq
S\text{ such that }s\in T\right)  }_{\substack{=\left(  \text{\# of all
subsets of }S\setminus\left\{  s\right\}  \right)  \\\text{(since there is a
bijection from }\left\{  T\subseteq S\ \mid\ s\in T\right\}  \\\text{to
}\left\{  \text{subsets of }S\setminus\left\{  s\right\}  \right\}  \text{
sending each }T\text{ to }T\setminus\left\{  s\right\}  \text{)}}}\\
&  =\sum_{s\in S}\underbrace{\left(  \text{\# of all subsets of }%
S\setminus\left\{  s\right\}  \right)  }_{\substack{=2^{n-1}\\\text{(by
Theorem \ref{thm.subsets.all}, since }S\setminus\left\{  s\right\}  \text{ is
an }\left(  n-1\right)  \text{-element set)}}}\\
&  =\sum_{s\in S}2^{n-1}=\underbrace{\left\vert S\right\vert }_{=n}%
\cdot2^{n-1}=n\cdot2^{n-1}.
\end{align*}

\end{proof}

\begin{remark}
In the 2019 notes, I also give a different solution to Exercise
\ref{exe.sum.fubini-exam1}, which proceeds by splitting the sum up according
to the size $\left\vert T\right\vert $ of the subset $T$:%
\[
\sum\limits_{T\subseteq S}\left\vert T\right\vert =\sum_{k=0}^{n}%
\ \ \underbrace{\sum\limits_{\substack{T\subseteq S;\\\left\vert T\right\vert
=k}}\left\vert T\right\vert }_{\substack{=k\dbinom{n}{k}\\\text{(why?)}}%
}=\sum_{k=0}^{n}k\dbinom{n}{k}=n\cdot2^{n-1}%
\]
(by Proposition 1.3.33 in Lecture 8). Note that by confronting the two
solutions against each other, we get a combinatorial proof of $\sum_{k=0}%
^{n}k\dbinom{n}{k}=n\cdot2^{n-1}$.
\end{remark}

\subsubsection{The Fubini principle with a predicate}

When applying the Fubini principle to rewrite a nested sum of the form
$\sum\limits_{x\in X}\ \ \sum\limits_{y\in Y}$ into the form $\sum
\limits_{y\in Y}\ \ \sum\limits_{x\in X}$, we say that we are
\textbf{interchanging the summation signs}. However, this works only if the
ranges of the two sums are independent (i.e., the set $Y$ does not depend on
the choice of $x$). So we can interchange the summation signs in
$\sum\limits_{x=0}^{3}\ \ \sum\limits_{y=0}^{5}$, but not in $\sum
\limits_{x=0}^{3}\ \ \sum\limits_{y=0}^{x}$. To adapt the Fubini principle to
cases like the latter, we need to add a simple tweak. Essentially, we extend
the Fubini principle to \textquotedblleft rectangular tables with
gaps\textquotedblright:

\begin{theorem}
[finite Fubini principle with a predicate]\label{thm.fubini.pred}Let $X$ and
$Y$ be two finite sets. Let $\mathcal{A}\left(  x,y\right)  $ be a logical
statement for each pair $\left(  x,y\right)  \in X\times Y$. Let $a_{\left(
x,y\right)  }$ be a number for each pair $\left(  x,y\right)  \in X\times Y$
that satisfies $\mathcal{A}\left(  x,y\right)  $. Then,%
\[
\sum_{x\in X}\ \ \sum_{\substack{y\in Y;\\\mathcal{A}\left(  x,y\right)
}}a_{\left(  x,y\right)  }=\sum_{\substack{\left(  x,y\right)  \in X\times
Y;\\\mathcal{A}\left(  x,y\right)  }}a_{\left(  x,y\right)  }=\sum_{y\in
Y}\ \ \sum_{\substack{x\in X;\\\mathcal{A}\left(  x,y\right)  }}a_{\left(
x,y\right)  }.
\]

\end{theorem}

For example, if $n,m\in\mathbb{N}$, then Theorem \ref{thm.fubini.pred}
(applied to $X=\left[  n\right]  $ and $Y=\left[  m\right]  $ and
$\mathcal{A}\left(  x,y\right)  =\left(  \text{\textquotedblleft}x+y\text{ is
even\textquotedblright}\right)  $) yields%
\[
\sum_{x\in\left[  n\right]  }\ \ \sum_{\substack{y\in\left[  m\right]
;\\x+y\text{ is even}}}a_{\left(  x,y\right)  }=\sum_{\substack{\left(
x,y\right)  \in\left[  n\right]  \times\left[  m\right]  ;\\x+y\text{ is
even}}}a_{\left(  x,y\right)  }=\sum_{y\in\left[  m\right]  }\ \ \sum
_{\substack{x\in\left[  n\right]  ;\\x+y\text{ is even}}}a_{\left(
x,y\right)  }.
\]


So we are allowed to interchange two summation signs even if the range of the
inner one depends on the index of the outer one; we just have to make sure
that the predicate that describes this dependence remains under the inner sum.

\bigskip

Here are some corollaries you can get by applying the principle to specific predicates:

\begin{corollary}
[triangular Fubini principle I]\label{cor.fubini.triang1}Let $n\in\mathbb{N}$.
For each pair $\left(  x,y\right)  \in\left[  n\right]  \times\left[
n\right]  $ with $x+y\leq n$, let $a_{\left(  x,y\right)  }$ be a number.
Then,%
\[
\sum_{x=1}^{n}\ \ \sum_{y=1}^{n-x}a_{\left(  x,y\right)  }=\sum
_{\substack{\left(  x,y\right)  \in\left[  n\right]  \times\left[  n\right]
;\\x+y\leq n}}a_{\left(  x,y\right)  }=\sum_{y=1}^{n}\ \ \sum_{x=1}%
^{n-y}a_{\left(  x,y\right)  }.
\]

\end{corollary}

\begin{proof}
The left hand side of this equality is%
\[
\sum_{x=1}^{n}\ \ \sum_{y=1}^{n-x}a_{\left(  x,y\right)  }=\sum_{x\in\left[
n\right]  }\ \ \sum_{\substack{y\in\left[  n\right]  ;\\y\leq n-x}}a_{\left(
x,y\right)  }=\sum_{x\in\left[  n\right]  }\ \ \sum_{\substack{y\in\left[
n\right]  ;\\x+y\leq n}}a_{\left(  x,y\right)  },
\]
while the right hand side is%
\[
\sum_{y=1}^{n}\ \ \sum_{x=1}^{n-y}a_{\left(  x,y\right)  }=\sum_{y\in\left[
n\right]  }\ \ \sum_{\substack{x\in\left[  n\right]  ;\\x\leq n-y}}a_{\left(
x,y\right)  }=\sum_{y\in\left[  n\right]  }\ \ \sum_{\substack{x\in\left[
n\right]  ;\\x+y\leq n}}a_{\left(  x,y\right)  }.
\]
Thus, the equality follows from Theorem \ref{thm.fubini.pred} (applied to
$X=\left[  n\right]  $ and $Y=\left[  n\right]  $ and $\mathcal{A}\left(
x,y\right)  =\left(  \text{\textquotedblleft}x+y\leq n\text{\textquotedblright%
}\right)  $).
\end{proof}

Corollary \ref{cor.fubini.triang1} is called a \textquotedblleft triangular
Fubini principle\textquotedblright\ because it is about summing a triangular
table of numbers:%
\[%
\begin{array}
[c]{ccccc}%
a_{\left(  1,1\right)  } & a_{\left(  1,2\right)  } & \cdots & a_{\left(
1,n-2\right)  } & a_{\left(  1,n-1\right)  }\\
a_{\left(  2,1\right)  } & a_{\left(  2,2\right)  } & \cdots & a_{\left(
2,n-2\right)  } & \\
\vdots & \vdots & \rotatebox{70}{$\ddots$} &  & \\
a_{\left(  n-2,1\right)  } & a_{\left(  n-2,2\right)  } &  &  & \\
a_{\left(  n-1,1\right)  } &  &  &  &
\end{array}
\]
(just like the original Fubini principle was about summing a rectangular table
of numbers).

As an example for the use of the triangular Fubini principle, let us solve a
simple exercise in a somewhat artistic way:

\begin{exercise}
Let $n\in\mathbb{N}$. Prove that%
\[
\sum_{k=1}^{n}k\left(  n-k\right)  =\dbinom{n+1}{3}.
\]

\end{exercise}

\begin{proof}
[Solution.]We have%
\begin{align*}
\sum_{k=1}^{n}k\left(  n-k\right)   &  =\sum_{x=1}^{n}x\underbrace{\left(
n-x\right)  }_{\substack{=\sum\limits_{y=1}^{n-x}1\\\text{(since a sum of
}k\\\text{many }1\text{s equals }k\text{)}}}=\sum_{x=1}^{n}x\sum
\limits_{y=1}^{n-x}1=\sum_{x=1}^{n}\ \ \sum\limits_{y=1}^{n-x}%
\underbrace{x\cdot1}_{=x}=\sum_{x=1}^{n}\ \ \sum\limits_{y=1}^{n-x}x\\
&  =\sum_{y=1}^{n}\ \ \underbrace{\sum_{x=1}^{n-y}x}_{\substack{=1+2+\cdots
+\left(  n-y\right)  \\=\dfrac{\left(  n-y\right)  \left(  n-y+1\right)  }%
{2}\\=\dbinom{n-y+1}{2}}}\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{here, we interchanged the}\\
\text{summation signs using}\\
\text{Corollary \ref{cor.fubini.triang1}}%
\end{array}
\right)  \\
&  =\sum_{y=1}^{n}\dbinom{n-y+1}{2}=\dbinom{n}{2}+\dbinom{n-1}{2}%
+\cdots+\dbinom{1}{2}\\
&  =\dbinom{1}{2}+\dbinom{2}{2}+\cdots+\dbinom{n}{2}\\
&  =\dbinom{0}{2}+\dbinom{1}{2}+\cdots+\dbinom{n}{2}%
\ \ \ \ \ \ \ \ \ \ \left(  \text{since }\dbinom{0}{2}=0\right)  \\
&  =\dbinom{n+1}{2+1}\ \ \ \ \ \ \ \ \ \ \left(  \text{by the hockey-stick
identity}\right)  \\
&  =\dbinom{n+1}{3},
\end{align*}
qed.
\end{proof}


\end{document}