# Lecture 026

## Combinatorics - Basic Counting Principles

Let A be a finite set. $\{A_i\}_{i \in \mathbb{I}}$ is called a partition iff $U_{i\in \mathbb{I}} = A \land A_i \cap A_j = \emptyset \text{for} i\neq j$

• this definition allow empty set to be a partition

### Rule of Sum (ROS)

For finite partition of A $\mathbb{F}=\{A_1, ..., A_m\}$, then $|A|=\sum_{i=1}^m {|A_i|} = |A_1|+ ...+|A_m|$

• Prove by induction with three bijection and prove that the new one is a bijection

### Rule of Product (ROP)

For finite partition of A $A = A_1 \times ... \times A_n$, then $|A|=\prod_{i=1}^m {|A_i|} = |A_1|\times ...\times |A_m|$

• again, induction with bijection

### The Pigeonhole Principle (PHP)

Story: If a lot of pigeons fly into not too many pigeonholes, then at least 1 pigeonhole will be occupied by multiple pigeons.

Let A be a finite set partitioned into $A_1, ... A_k$. $|A|=n \implies (\exists i \in [k])(|A_1|\geq \lceil \frac{n}{k} \rceil)$.

• in particular, $n>k \implies (\exists i \in [k])(|A_i|>1)$.

### Counting in 2 Ways

Principle: if we count the size of a set in two different ways, then both expressions for the cardinality of the set must be equal.

The Handshake Lemma: $\frac{(n(n-1))}{2} = \sum_{i=1}^{n-1}i$

## Combinatorial Methods

Combinatorial Methods:

• arrangements without repetition

• arrangements with repetition

• selection without repetition

• selection with repetition

### Permutations & Arrangements (without Repetition)

k-arrangements of X: a (number of possible) injection $f: [k] \hookrightarrow X$ with $k \leq |X|$

• we view positions(k) as domain, choice as codomain

• Theorem: $|X|\times(|X|-1)\times,..., \times(|X|-k+1) = \sum_{i=0}^{k-1}(n-i)=\frac{n!}{(n-k)!}$

• Example: possible arrangements for 1st, 2nd, 3rd prizes TODO: proof

permutation of X: a (number of possible) bijection $f: [|X|] \to X$.

• Example: arrangements of seats for classmates can be viewed as a (set of) ordered |X|-tuple: (a, b, c), (b, a, c), (c, b, a)

• a special type of arrangements when k=|X|.

• Corollary: There are |X|! many permutations on X

### Permutations & Arrangements with Repetition

k-arrangements with repetition: a (number of possible) functions $f:[k]\to X$ or an ordered k-tuple from X.

• T(n, k) be a set of k-arrangements with repetition from [n], then $|T(n, k)| = |\{a_1, ..., a_k)|a_i \in [n]\}|[n]^k|=n^k$ (n is choice, k is space)

### Selections & Combinations

selections: arrangements without order k-selection: a (number of possible) subset of X of size k with $k \leq |X|$.

• binomial coefficient (n choose k) ${n\choose k} \text{or} \binom{n}{k}$

• $k < 0 \lor k > n \implies {n\choose k} = 0$

• otherwise: ${n\choose k} = \frac{n!}{k!(n-k)!}$.

• because there are k! ways to order k-many elements, $|P(n, k)| = k! {n \choose k}$

• note: {n\choose k} = {n\choose n-k}

• Example: 5 cards dealt from 52 cards. Since order doesn't matter ${52 \choose 5}$ distinct hands.

### The Binomial theorem

The Binomial theorem: Let $x, y \in \mathbb{R} \land n \in \mathbb{N}$, then $(x+y)^n = \sum_{k=0}^n {n \choose k} x^ky^{n-k}$

### The Poker Problem

Poker: 52 cards, 4 suits, 13 ranks, Ace, Jack, King, Queen.

• 3-of-a-kind: 5 card with 3 cards of one rank, and others are different ranks. (三带两单张)

• one-pair: (二带三单张)

### Principle of Inclusion / Exclusion

$2^n = \sum_{i=0}^{n} {n \choose i}$.

• $T(2, n) = \{0, 1\}^n$ Proof: TODO

### Selection with Repetition

| OO | OOO | O | | Flavor 1 | Flavor 2 | Flavor 3 |

Can be viewed as (00100010) and asking how many repeated way to buy 6 donuts with 3 flavors is the same as how to arrange binary strings with exactly 6 0's and 2 1's.

There are ${n+k-1 \choose k-1} = {n+k-1 \choose n}$ ways to select n-many objects from k-many types with repetition.

• this equal to the number of nonnegative integer solution to $x_1+x_2+...+x_k=n$.

### The Anagram Problem

Example: anagrams of LIMITING ROP Procedure:

• choose 3 of 8 positions for I's -> ${8 \choose 3}$

• remaining 5 positions, choose a permutation of 5 letters -> 5!

Table of Content