% This is a TeX file
% It is essentially a programming language for mathematics documents
% You can ignore this first portion of the file, as it is essentially a bunch of "include" statements.
\documentclass[10pt]{article}

\usepackage{pictex, latexsym, graphicx,amsmath,amssymb,amsbsy,amsfonts,amsthm,verbatim}
\usepackage{graphics}
\usepackage{hyperref}
\usepackage{fullpage}
\usepackage{fancyhdr}
\usepackage{array}

\usepackage{algorithm,algorithmic}
\usepackage{multirow}

\setlength{\parskip}{0.5em}
\setlength{\parindent}{0em}
\setlength{\voffset}{-0.5in}
\setlength{\headsep}{0.25in}

% The following denotes a counter for the problems.
\newcounter{problem}
\newcommand{\problem}{\textbf{Problem \refstepcounter{problem}.}}

% These are macro shortcuts! Helpful!
\def\vu{\mathbf{u}}
\def\vx{\mathbf{x}}
\def\vy{\mathbf{y}}
\def\vz{\mathbf{z}}
\def\vb{\mathbf{b}}
\def\vv{\mathbf{v}}
\def\vw{\mathbf{w}}

\renewcommand{\implies}{\rightarrow}
%\newcommand{\lnot}{\neg}
\renewcommand{\lor}{\vee}
\renewcommand{\land}{\wedge}
\newcommand{\xor}{\oplus}
\newcommand{\symmdiff}{\triangle}
\renewcommand{\iff}{\leftrightarrow}
\newcommand{\TRUE}{\mathbf{T}}
\newcommand{\FALSE}{\mathbf{F}}
\newcommand{\universe}{\mathcal{U}}


\def\N{\mathbb{N}}
\def\Q{\mathbb{Q}}
\def\C{\mathbb{C}}
\def\Z{\mathbb{Z}}
\def\R{\mathbb{R}}
\def\cP{\mathcal{P}}



\begin{document}
\pagestyle{fancyplain}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NOW you can start typing your text that will appear in the PDF!!!

% Note that anything after a '%' is a comment!

% Anything immediately after a '\' is a command. 
% Some denote formatting, some are for special characters.
% The '$' symbol starts and ends "math mode". Use this only for mathematical statements
% In math mode, any sequence of letters is meant to be a list of variables, so use "\sin x" for the sine of x, which will look much different from "sin x"

\lhead{}
\rhead{}
\chead{COM S 330 --- Lecture Notes --- Week of Mar 9--11}

\renewcommand{\arraystretch}{1.25}



\section{Monday, March 9}


\subsection{Rosen 6.2: Pigeonhole Principle}

\textbf{Reading:} Rosen 6.2,  Ducks 1.5, LLM 

\begin{quote}
\fbox{
\parbox{4in}{
\textbf{Pigeonhole Principle.}

If $k$ is a positive integer and $k+1$ or more objects are placed into $k$ boxes, then there is at least one box containing two or more objects.
}
}
\end{quote}

\textbf{Note:} The pigeonhole principle does \emph{not} say that if we place $k+1$ or more objects into $k$ boxes that every box has at least one object! We could put all objects into one box!

\textbf{Ex:} Let $f$ be a function from a set $A$ to a set $B$. If $|A| > |B|$, then $f$ is not injective.

\textbf{Ex:} Among a group of 367 people, there must be two with the same birthday, as there are only 366 possible birthdays.

\textbf{Ex:} In any group of 27 English words, there are two that start with the same letter and there are two that end with the same letter.

\textbf{Ex:} In any group of 677 English words, there are two that start with the same letter and end with the same letter.



\textbf{Ex:} Among any $n+1$ positive integers not exceeding $2n$ there must be an integer that divides one of the other integers.

\begin{proof}
Let $\{ a_1,\dots, a_n, a_{n+1}\}$ be integers such that $1 \leq a_i \leq 2n$ for all $i \in \{1,\dots,n\}$.
There exist natural numbers $k_i$ and odd integers $q_i$ such that $a_i = 2^{k_i}q_i$ for each $i$.
Note that $1 \leq q_i \leq 2n-1$ for each odd integer $q_i$, so there are only $n$ possible odd integers in that range.
Thus there are two numbers $a_i$ and $a_j$ where $q_i = q_j$.
Then, either $k_i \leq k_j$, or $k_i > k_j$ (w.l.o.g. assume $k_i \leq k_j$). 
Then $a_j = 2^{k_j}q_j = 2^{k_j-k_i}(2^{k_i}q_i) = 2^{k_j-k_i}a_i$ and hence $a_i$ divides $a_j$.
\end{proof}

\textbf{Ex:} A sociologist studies random groups of $n$ people on Facebook, and studies how many friends each person has within the group of $n$ people. She notices a pattern: there is always a pair of people who have the same number of friends in the group. Why?

\begin{proof}
Let $p_1,\dots,p_n$ be $n$ people on Facebook. 
For $i \in \{1,\dots,n\}$, let $d(p_i)$ be the number of people within the set $\{p_1,\dots,p_n\}$ that are friends with $p_i$.
Note that $0 \leq d(p_i) \leq n - 1$, so there are a total of $n$ options.
\emph{However,} if $d(p_i) = n$ for some $i$, then $p_i$ is friends with everyone in the group!
If $d(p_j) = 0$ for some $i$, then $p_j$ is not friends with anyone in the group!
Thus, we cannot simultaneously have $d(p_i) = n$ and $d(p_j) = 0$ for some $i$ and $j$.
So there really are $n-1$ values that each $d(p_i)$ can take, but that means we have $n$ inputs to the function $d$ and $n-1$ outputs, so two of the inputs, say $p_i$ and $p_j$, must have the same output $d(p_i) = d(p_j)$.
\end{proof}


\begin{quote}
\fbox{
\parbox{4in}{
\textbf{Generalized Pigeonhole Principle.}

If $N$ objects are placed into $k$ boxes, then there is a box containing at least $\lceil N/k\rceil$ objects.
}
}
\end{quote}

\begin{proof}
Let $N$ and $k$ be positive integers.
Let $N = qk-r$ where $0 \leq r < k$, so $\lceil N/k\rceil = q =  (N+r)/k$.
Suppose that we place objects into $k$ boxes and every box contains at most $\lceil N/k\rceil - 1$ objects.
Then, the number of objects we placed was at most 
\[
	k(\lceil N/k\rceil - 1) = k\lceil N/k\rceil - k = k((N+r)/k)-k = (N+r)-k < N+k-k = N.
\]
Therefore, we placed fewer than $N$ objects.
\end{proof}

\textbf{Ex:} If there are 80 students in this class, how many are guaranteed to have their birthday in the same calendar month? (A: $\lceil 80/12\rceil = 7$)



\textbf{Def:} Let $n$ be an integer with $n \geq 2$. 
Let $E_n$ be the set of pairs $\{ i,j\}$ where $1 \leq i < j \leq n$.
A \emph{2-coloring} is an assignment $c : E_n \to \{\text{red}, \text{blue}\}$.
For integers $a,b$ \emph{Ramsey number} $r(a,b)$ is the minimum $n$ such that for every 2-coloring $c : E_n \to \{\text{red}, \text{blue}\}$ there either exists a set $\{ x_1,\dots, x_a\} \subset \{1,\dots,n\}$ where every pair $\{ x_i, x_j\}$ is colored red, or there exists a set $\{y_1,\dots,y_b\} \subset \{1,\dots,n\}$ where every pair $\{ y_i, y_j\}$ is colored blue.

\textbf{Thm:} $r(3,3) = 6$.

\begin{proof}
To prove $r(3,3) > 5$, we demonstrate a coloring. (Shown in class, but not in notes.)

To prove $r(3,3) \leq 6$, we will prove that every 2-coloring of $E_6$ contains a red ``triangle'' or a blue ``triangle''.
Fix a 2-coloring $c : E_6 \to \{\text{red}, \text{blue}\}$.
Consider the element 1.
Among the five pairs $\{1,i\}$ for $2 \leq i \leq 6$, there are three of the same color, by generalized pigeonhole principle.
Let $2 \leq i < j < k \leq 6$ be the value such that $\{1,i\}$, $\{1,j\}$, $\{1,k\}$ have the same color, (w.l.o.g. the color is red).
Among the three pairs $\{i,j\}$, $\{i,k\}$, and $\{j,k\}$, if there is a red pair, then we have a red triangle!
Therefore, they must all be blue, but that forms a blue triangle!
\end{proof}

For more information, see \url{http://en.wikipedia.org/wiki/Ramsey%27s_theorem}

\textbf{Def:} Given a list $a_1,\dots,a_n$ of $n$ distinct real numbers, an \emph{increasing subsequence} is a list $a_{i_1},\dots,a_{i_k}$ where $i_1 < i_2 < \cdots < i_k$ and $a_{i_1} < a_{i_2} < \cdots < a_{i_k}$; a \emph{decreasing subsequence} is a list $a_{i_1},\dots,a_{i_k}$ where $i_1 < i_2 < \cdots < i_k$ and $a_{i_1} > a_{i_2} > \cdots > a_{i_k}$. 
In these subsequences, $k$ is the \emph{length}.

\textbf{Erd\H{o}s-Szekeres Theorem:} Every sequence of $n^2+1$ distinct real numbers contains a subsequence of length $n+1$ that is either strictly increasing or strictly decreasing.

\begin{proof}
Let $a_1,\dots,a_{n^2+1}$ be a list of $n^2+1$ distinct real numbers and suppose for the sake of contradiction that the list contains no increasing subsequence of length $n+1$ or decreasing subsequence of length $n+1$.
For each $k \in \{1,\dots, n^2+1\}$, let $(i_k,d_k)$ be the pair where $i_k$ is the maximum length of an increasing subsequence ending at $a_k$ and $d_k$ is the maximum length of a decreasing subsequence ending at $a_k$.
Since each number by itself is an increasing or decreasing subsequence, $i_k \geq 1$ and $d_k \geq 1$.
Since no increasing or decreasing subsequence of length $n+1$ exists, $i_k \leq n$ and $d_k \leq n$.
Thus, each of these pairs $(i_k,d_k)$ is in the set $\{1,\dots, n\} \times\{1,\dots,n\}$ of size $n^2$.
By the pigeonhole principle, there exist two distinct values $k < \ell$ where $(i_k,d_k) = (i_\ell,d_\ell)$.
However, $a_k \neq a_\ell$, so either $a_k < a_\ell$ or $a_k > a_\ell$.

If $a_k < a_\ell$, then there is an increasing subsequence of length $i_k$ ending at $a_k$, and that subsequence has all previous terms smaller than $a_k$.
These terms are all smaller than $a_\ell$, so there is an increasing subsequence of length $i_k + 1$ ending at $a_\ell$, contradicting the definition of $i_\ell = i_k$.



If $a_k > a_\ell$, then there is a decreasing subsequence of length $d_k$ ending at $a_k$, and that subsequence has all previous terms larger than $a_k$.
These terms are all larger than $a_\ell$, so there is a decreasing subsequence of length $d_k + 1$ ending at $a_\ell$, contradicting the definition of $d_\ell = d_k$.

Thus, we have found a contradiction in all cases, so the assumption that $a_1,\dots,a_{n^2+1}$ contains no increasing or decreasing subsequence of length $n+1$ is false.
\end{proof}

\clearpage
\section{Wednesday, March 11}


\subsection{Rosen 6.4: Binomial Coefficients and Identities}

\textbf{Reading:} Rosen 6.4,  Ducks , LLM 


Recall our definition of the \emph{binomial coefficient} $\binom{n}{k}$, stated as ``$n$ choose $k$,'' to be the number of $k$-combinations among a set of $n$ distinct objects. 

\textbf{Binomial Theorem:} Consider the polynomial $p_n(x,y) = (x+y)^n$. The coefficient of $x^ky^{n-k}$ in $p(x,y)$ is $\binom{n}{k}$. That is, $(x+y)^n = \sum_{k=0}^n \binom{n}{k}x^ky^{n-k}$.

\begin{proof}
When distributing the product $\underbrace{(x+y)(x+y)\cdots (x+y)}_{\text{$n$ terms}}$, we can produce the $x^ky^{n-k}$ term by multiplying $k$ of the ``$x$ side'' and $n-k$ of the ``$y$ side.'' 
There are $\binom{n}{k}$ ways to select which terms we will use the ``$x$ side'' and each $x^ky^{n-k}$ term is added resulting in a coefficient of $\binom{n}{k}$.
\end{proof}

Don't like the proof above? Try another one!

\begin{proof}
We prove by induction on $n\geq 0$ that for all $k$, the $k$th term of $p_n(x,y) = (x+y)^n$ is $\binom{n}{k}x^ky^{n-k}$.

Case $n = 0$: $p_0(x,y) = 1$, so the coefficient of $x^0y^0$ is $1$.

(Induction Hypothesis) Let $n \geq 0$ and suppose that $(x+y)^n = \sum_{k=0}^n \binom{n}{k}x^ky^{n-k}$.

Case $n+1$: Consider how the term $x^ky^{n+1-k}$ can appear in $p_{n+1}(x,y)$.
But first realize that $p_{n+1}(x,y) = (x+y)^{n+1} = (x+y)p_n(x) = xp_n(x,y) + yp_n(x,y)$.
Therefore, $x^kn^{n+1-k}$ can appear as a term on the left or right of the sum.
On the right, the coefficient of $x^ky^{n-k}$ in $p_n(x,y)$ is $\binom{n}{k}$ by the Induction Hypothesis, and thus the coefficient of $x^ky^{(n+1)-k} = y\cdot x^{k}y^{n-k}$ of $yp_n(x,y)$ is $\binom{n}{k}$.
On the left, the coefficient of $x^{k-1}y^{n-(k-1)}$ in $p_n(x,y)$ is $\binom{n}{k-1}$ by the Induction Hypothesis, and thus the coefficient of $x^ky^{n-(k-1)} = x\cdot x^{k-1}y^{(n+1)-k}$ of $xp_n(x,y)$ is $\binom{n}{k-1}$.
Therefore, the coefficient of $x^ky^{(n+1)-k}$ in $p_{n+1}(x)$ is $\binom{n}{k} + \binom{n}{k-1}$. 
By Pascal's Identity, $\binom{n}{k} + \binom{n}{k-1} = \binom{n+1}{k}$.
\end{proof}

\textbf{Thm:} $\sum_{k=0}^n \binom{n}{k} = 2^n$.

\begin{proof}[Proof 1.]
By the Binomial Theorem, $2^n = (1+1)^n = \sum_{k=0}^n \binom{n}{k}1^k1^{n-k} = \sum_{k=0}^n \binom{n}{k}$.
\end{proof}

\begin{proof}[Proof 2.]
Let $A$ be a set of size $n$.
There are $2^n$ subsets of $A$ (by product rule, selecting a subset by deciding containment of each element of $A$ in order).
There are $\binom{n}{k}$ $k$-subsets of $A$, so there are $\sum_{k=0}^n \binom{n}{k}$ subsets of $A$.
\end{proof}


\textbf{Thm:} $\sum_{k=0}^n (-1)^k\binom{n}{k} = 0$.

\begin{proof}[Proof 1.]
By the Binomial Theorem, $0^n = ((-1)+1)^n = \sum_{k=0}^n \binom{n}{k}(-1)^k1^{n-k} = \sum_{k=0}^n (-1)^k\binom{n}{k}$.
\end{proof}

\begin{proof}[Proof 2.]
(Note: 
This proof holds only when $n$ is odd, so $k$ and $n-k$ have opposite parities.
The last equality is subtle.)

Since $\binom{n}{k} = \binom{n}{n-k}$, we have $\binom{n}{k} - \binom{n}{n-k} = 0$.
Therefore, $0 = \sum_{k=0}^{\lfloor n/2\rfloor} (-1)^k(\binom{n}{k} - \binom{n}{n-k}) = \sum_{k=0}^n (-1)^k \binom{n}{k}$.
\end{proof}

\textbf{Thm:} $\sum_{k=0}^n 2^k\binom{n}{k} = 3^n$.

\begin{proof}[Proof 1.]
By the Binomial Theorem, $3^n = (2+1)^n = \sum_{k=0}^n \binom{n}{k}2^k1^{n-k} = \sum_{k=0}^n 2^k\binom{n}{k}$.
\end{proof}

\begin{proof}[Proof 2.]
Let $A$ be a set of size $n$.
We will count the number of sets $B, C$ where $C \subseteq B \subseteq A$.

For each element $a$ of $A$, we can decide three options: $a$ is not in $B$ or $C$, $a$ is in $B$, or $a$ is in $B$ and $C$. 
(Note, we cannot have $a$ in $C$ and $a$ not in $B$, or else $C \not\subseteq B$.)
Thus, there are $3^n$ situations.

For each subset $B$ of size $k$, there are $2^k$ subsets $C \subseteq B$.
Thus, there are $\sum_{k=0}^n 2^k\binom{n}{k}$ pairs $C \subseteq B$.
\end{proof}


\textbf{Vandermonde's Identity:} Let $m$, $n$, and $r$ be nonnegative integers with $r \leq \min\{n,m\}$.
\[
	\binom{m+n}{r} = \sum_{k=0}^n \binom{m}{r-k}\binom{n}{k}.
\]

\begin{proof}
Let $A$ be a set of $n$ Cyclone fanes and $B$ a set of $m$ Hawkeye fans.
\textbf{Obviously} no one is both a Cyclone fan and a Hawkeye fan.

There are $\binom{m+n}{r}$ ways to invite $r$ people from $A \cup B$ to a tailgating party.

In designing my tailgating party, I could first specify that I want $k$ Cyclone fans and $r-k$ Hawkeye fans.
There are $\binom{n}{k}\binom{m}{r-k}$ ways to invite $k$ Cyclone fans and $r-k$ Hawkeye fans to my tailgating party.
By the sum rule, there are $\sum_{k=0}^r \binom{m}{r-k}\binom{n}{k}$ ways to invite people from $A \cup B$ to my party.
\end{proof}

\textbf{Cor:} $\binom{2n}{n} = \sum_{k=0}^n \binom{n}{k}^2$.

\begin{proof}
By Vandermonde's identity with $r = m = n$, we have
$\binom{2n}{n} = \binom{n+n}{n} = \sum_{k=0}^n \binom{n}{n-k}\binom{n}{k}$
but by Pascal's identity ($\binom{n}{n-k} = \binom{n}{k}$) we complete the proof.
\end{proof}



\clearpage
\section{Friday, March 13}

\textbf{EXAM 2.}


\end{document} 
