Вы находитесь на странице: 1из 29

Notes for

Math 239

University of Waterloo
Spring 2017
Contents

1 Lecture 1: Intro 3
1.1 Important Syllabus Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 First 5 weeks - Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Second Part of the Course: Graph Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Last 10min Sutff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Lecture 2 4
2.1 Set Theory Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.1 Set Builder Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.2 Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 More Stuff Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.1 Cartesian Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Binomial Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Lecture 3 6
3.1 Announcements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Last Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 First Example of a Combinatorial Proof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4 Bijections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Lecture 4 7
4.1 More Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2 Generating Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2.1 General Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

5 Lecture 5 9
5.1 Last Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.2 More Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.3 More Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.4 Coefficient Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.5 Formal Power Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6 Lecture 6 11
6.1 Formal Power Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.2 Multiplying FPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.3 Justification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

7 Lecture 7 12
7.1 More Binomial Theorem Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.2 Sum and Product Lemmas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

8 Lecture 8 14
8.1 More About the Product Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8.1.1 An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8.2 Study Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8.3 Compositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

9 Lecture 9 15
9.1 Last Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
9.2 Some example of something . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

1
10 Lecture 10 17
10.1 How to Solve Generating Series Problems (in 10 steps) . . . . . . . . . . . . . . . . . . . . . . 17
10.2 Binary Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
10.2.1 String Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.2.2 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
10.2.3 Ambiguous vs Unambiguous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

11 Lecture 11 19
11.1 Set Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11.2 * operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11.3 A Note on Brackets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11.4 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11.5 Generating Series for Sets of Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

12 Lecture 12 20
12.1 Finite String Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
12.2 Standard Decompositions of Binary Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
12.3 Block Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

13 Lecture 13 21
13.1 Chapter 3 - Coefficients of Rational Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

14 Lecture 14 23
14.1 Recurrence Relation and Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
14.2 Another Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
14.3 A Third Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

15 Lecture 15 24
15.1 Things You Can Do to Get Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
15.2 Solution to the Crazy Dice Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

16 Lecture 16 27

17 Lecture 17 27
17.1 Some Graph Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
17.2 Bipartite Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

18 Lecture 18 27
18.1 Paths and Walks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

19 Lecture 20 28

20 Lecture 24 28

21 Lecture 26 28

2
1 Lecture 1: Intro
The prof has green hair, and that’s pretty cool.

Professor Kevin Purbhoo


Office: MC 5122
Email: kpurbhoo@uwaterloo.ca
Office hours for this week are 11am - 12am on Friday

He says that this is a ”less serious” course - a fun introduction to combinatorics. That sounds like low
effort. dope.
Also, proofs in the second half are apparently a thing.

1.1 Important Syllabus Bits


Textbook is a courseware thing. He recommends the electronic version, which is free. He also says the
course notes are somewhat lack-lustre.

In the sixth week of classes, there will be a quiz in tutorials. Make sure you go to the sixth one!

Assignments are due at midnight on Tuesday

Piazza poll for office hours.

We are section 001.

Tutorials are for summary/recap and problems - not mandatory except for sixth week.

1.2 First 5 weeks - Enumeration


Like counting - close to elementary-school math.

As an example, how many sheep? (4x3 grid of sheep on board).


-¿ 12 sheep

The point is that you didn’t count them one-by-one - instead, you multiplied three rows by four columns
to count. It’s a better method of counting, especially as the number of sheep gets bigger.

A more interesting problem, taken from a Google employee as an interview question:

You have a regular icosahedron (20 sides, all the same) and three colours of paint. You want to paint
the icosahedron, not necessarily different colours or anything. How many ways can you paint it? The
thing that makes this interesting is that there isn’t any ordering to the sides, i.e. red on top and yellow
everywhere else is the same as red on the bottom and yellow elsewhere is the same as red on the side and
yellow elsewhere because of symmetry (you could rotate the thing and have it be the same).

The start of this course is all about one thing: generating functions. These are next-level counting tools.
The had part is putting problems in the right form for the tool to act on.

Another cool thing (but not one of the main things) you can do with generating functions is called the
crazy dice problem. Imagine you have two six-sided regular dice, and you roll them, and you’ll get two
outputs, and add them to a number between 2 and 12. You can analyze probabilites, and figure out what
the most likely number to get is. One way to do this (a simple way) is to just draw a table, with one die

3
on each axis. There are 36 outcomes, not all unique, so you can total them together into distinct outputs.
For example, there’s only one way to roll a 2, so it’s probability is 1/36. You’ll find out that a 7 is the most
likely number, with 6/36 (1/6) odds.

That, however is just a regular dice problem. What we’re interested in is the crazy dice problem, which
adds a variation: Is it possible to put different numbers on the dice, and have the same probability table
(i.e. the probability of rolling a 2 is still 1/36, 7 is still 6/36, etc.)? Also, to avoid trivial solutions, we have
to add the restriction that all numbers on the dice must be at least =1.

The Google problem uses Burnside’s Lemma, which we won’t learn about.

1.3 Second Part of the Course: Graph Theory


Here’s another elementary-school problem: (there’s a super simple maze drawn on the board, with a
mouse at one end and some cheese at the other) help Sergey find the cheese. The grown-up version of this
question is: find the best route from A to B, taking traffic into account. The basic concept is simply: get
from A to B. A graph is, simply, a relation. We’ll get a proper definition when we get to graph theory, but
for now, this definition is fine. They describe connections between different objects (computer networks,
roads, etc.).

1.4 Last 10min Sutff


Fundamental question: given a finite set, how many elements are in it?

Example: how many ways are there to put the elements of 1, 2, ..., n in an ordered list of length n with
no repeats? If n=3, we are counting the elements in the set of lists 1, 2, 3, 1, 3, 2, 2, 3, 1, 2, 1, 3, 3, 1, 2, and
3, 2, 1. Thus, the answer is 6 for n=3, and the general answer is n! for n ¿ 0. For n=0, it’s important to
realize that the basic operation is multiplication, and by convention, multiplication with 0 inputs (and thus
0!) is defined to be 1.

2 Lecture 2
2.1 Set Theory Review
A set is a collection of (usually) mathematical objects. Fundamentally, all we are about is: is some
element in the set? (a ∈ A ?).

Important: ∈ and ⊆ are not interchangeable (because apparently that’s a common error).
1, 2, 3 ∈
/ 1, 2, 3, 4. 1, 2, 3 ⊂ 1, 2, 3, 4.

2.1.1 Set Builder Notation


description of elements (usually in terms of some variables) — restrictions on the variables on the left
how do we build the set — what do we build it out of

Example:

Take {2n + 1|n ∈ Z}


{..., −3, −1, 1, 3, 5, ...}

4
2.1.2 Basic Operations
Union:

A ∪ B = {a|a ∈ A ∨ a ∈ B}

Intersection:

A ∩ B = {a|a ∈ A ∧ a ∈ B}

Disjoint Union:

A∪B =∅

Number of Elements:

|A| = number of elements in A (as long as A is a finite set)

Fact: If A and B are disjoint, then |A| + |B| = |A ∪ B|

Cartesian Product:

A × B = {(a, b)|a ∈ A, b ∈ B}

Fact: |A × B| = |A| · |B|

2.2 More Stuff Now


Example: How many different outcomes are there from rolling 2 dice?

Answer: Let A be the set of outcomes from the first die. Let B be the set of outcomes from the second
die. Then, the set of all possible outcomes must be A × B. |A| = 6 and |B| = 6, so |A × B| = 6 · 6 = 36.

The point of this example is that we took a problem, and reframed it as finding the cardinality of a set.
We also made an assumption to solve this problem (other than that the dice are six-sided): what different
means. For example, is rolling (1, 2) different than rolling (2, 1)? In other words, are the dice distinguishable?

If the dice are distinguishable, the answer is 36. If the dice are indistinguishable, the answer is 21.

2.2.1 Cartesian Power


Ak = {(a1 , ..., ak )|a1 , ..., ak ∈ A}

What if k=0? What is A0 ?

A0 6= ∅

A0 = {()}

A0 is a set with a single element, and that element is called the empty list, denoted ().

Fact: |Ak | = |A|k


If k = 0, |A0 = |A|0 = 1, so this makes sense.

5
2.2.2 Binomial Coefficients
One thing that you might want to count are subsets. Example:

Subsets of {1, 2, 3}. There are 8 sets, as each element can either be in or out of the set, and there are
two elements, so 2 · 2 · 2 = 23 = 8. Its subsets are:

∅, {1}, {2}, etc.

Question: How many k-element subsets of {1, ..., n} are there?


(n

We’ll cheat, and define the operator k)
, ‘n choose x’.
(n 
We could, though, use the formula: k)=
n(n−1)(n−2)...(n−k+1) n!
= (n−k)!k!
k(k−1)(k−2)...(1)

3 Lecture 3
3.1 Announcements
Office hours: Fri. 10:45-12:15, Monday 3-4, MC 5122 (or by appointment)

Assignment 1 will be posted on Learn later today and on Crowdmark by Wednesday. It’s due Tues, May
16.

3.2 Last Time


n

k = number of k-element subsets of 1, ..., n. Formula:
 
n n!
=
k (n − k)!k!
The full truth, however is that this is not correct for all cases. It only works for 0 ≤ k ≤ n. The full
answer includes nk = 0∀(k > n ∨ k < 0).

3.3 First Example of a Combinatorial Proof


Combinatorial proof: a proof where we establish an identity by counting something in two ways, or
using other combinatorial arguments. (e.g. bijections - to be discussed later).

We will prove:
 
n n(n − 1)(n − 2)...(n − k + 1)
=
k k!
Let S of [sic] ordered lists of length k, of distinct elements from 1, ..., n. We will count the elements in
two ways.

First: form a list in S by:


• Choosing a first element (n ways)
• Choose a second elemnt (n − 1 ways)

• ith element (n − i + 1 ways

6
In total: |S| = n(n − 1)(n − 2)...(n − k + 1) ways.

Second way:
n

• Choose a k-element subset of 1, ..., n ( k ways)
• Choose a first element from the subset to be the first elemtn of the list (k ways)
• Choose a second (k − 1 ways)
|S| = nk k(k − 1)(k − 2)...(2)(1)


In conclusion, these two numbers must be the same.

3.4 Bijections
3.4.1 Functions
Consist of three parts:

1. Domain (Set)
2. Codomain (Another set)
3. Rule (Maps domain to codomain)

f (x) = x2 is not a function. It is a rule. To make this a function, you must add a domain and codomain.
So, f : R− > R, f (x) = x2 . The range is a subset of the codomain which represents all actually achievable
outputs.
Bijections are one-to-one and onto, and imply that the two spaces they map between must have the same
number of elements.

4 Lecture 4
First, we gonna do one more example of the concept of combinatorial proofs.

Example: Give a combinatorial proof for


  k  
n+k X n+i−1
=
n i=0
n−1

Soln :

So, either we want to count this thing in two different ways, or define a bijection. First, we need to
introduce a set of objects that this expression counts.

Let S be the set of all n-element subsets of 1, 2, 3, ..., n+k. We know:


 
n+k
|S| =
n

let Si = {A ∈ S|largest element in A is(i + n)}

e.g. S0 = {1, 2, ..., n}, S1 = {{1, 2, ..., n − 1, n + 1}, {1, 2, .., n − 2, n, n + 1}, ...}

7
S = S0 ∪ S1 ∪ ... ∪ Sk

and this is a disjoint union, therefore:


Pk
|S| = |S0 | + |S1 | + ... + |Sk | = i=0 |Si |
n+i−1

Finally, |Si | = n−1

Why? To specify a n-element subset of {1, ..., n + k} with largest element = (n + i), put n + i in the set
and choose n − 1 other elements from {1, 2, ..., n + i − 1} to go in the set.

X n + i − 1
|S| = k
i=0
n−1

4.1 More Stuff


When you’re doing a union of more than two things, if they are all disjoint, it’s a ‘pairwise disjoint’
union - this is the formal term meaning that, if you pick any two of the sets, they are disjoint. i.e.:

Si ∩ Sj = ∅ ∀i 6= j (1)

4.2 Generating Series


What we’ve talked about so far is called ‘elementary counting’. There are other things we’d like to do
that require other tools, so in the next four weeks, we’ll learn about that tool: generating series.

Recall: if s is a finite set, then |S| is the number of elements in S. Furthermore:


X
|S| = 1 = 1 + 1 + ... + 1 = one 1 for each element of S (2)
α∈S

4.2.1 General Framework


Before we can have the hammer, we need to learn what a nail looks like.

Problem (General Abstract Counting Problem):

Let S be a set of “configurations”.

Let w : S → N be a “weight function” which assigns to each configuration σ ∈ S a weight w(σ) ∈ N.

How many elements f S have weight n?

Given such a setup, the generating series for S (with respect to w can be defined as:

X
ΦS (x) = xw(σ) (3)
σ∈S

8
Example: Suppose S is the set of binary strings of length 4 and w : S → N is the weight function:
w(σ) = number of 1s inσ.

Question: How many binary strings of length 4 have n 1s?

In this case, the generating series is:

[Here we list all the elements in a table]

Φs (x) = 1 + 4x + 6x2 + 4x3 + x4 (4)

So we see that the coefficient of xn is the number of elements of weight n. In general,

5 Lecture 5
Assignment 1 is now on Crowdmark.

5.1 Last Time


S = set of binary strings of length 4.
w(σ) = number of 1s σ (w is the weight function)
ΦS (x) = 1 + 4x + 6x2 + 4x3 + 1x3
Coefficient of xn is the number of elements of S with weight n.

5.2 More Stuff


Another way to get ΦS (x) is to ask the question: How many binary strings of length 4 with n 1s are
there? The answer, we know, is:
 
4
n
So, we know the generating function is:
X 4
ΦS (x) = xn
n
n≥0

Which is just a particular case of the Binomial Theorem:


m  
X m
(1 + x)m = xk
k
k=0

So, we see that:

ΦS (x) = (1 + x)4

9
5.3 More Stuff
How many elements is S? We can get this from ΦS (1).

Another readily available quantity is the sum of the weights of S. It is:



(1)
dx
Example: Let S be the set of all binary strings:

S = {(the empty string with length 0), 0, 1, 00, 11, 01, 10, ...}
Now, let’s define the weight function w : S → N as w(σ) = length ofσ.

Counting problem: how many binary strings of length n?

The set is infinite, so we can’t make a table. We can, however, get the generating function by solving
the counting problem. The answer to the question is 2n , so the generating function is:

X
ΣS (x) = 2 n xn
n≥0

5.4 Coefficient Notation


If we have a series A(X) = n≥0 an xn then we write [xn ]A(X) = An , where the square bracketed thing
P
means “the coefficient of xn in A(x)”

Example:

By the binomial theorem:

m    
X m k X m k
(1 + x)m = x = x
k k
k=0 k≥0

Which is the same as:

 
m
[xn ](1 + x)m =
n
which was the point of this example.

5.5 Formal Power Series


Power series:

X
A(x) = an xn
n≥0

Example: is it correct?

10
1 − x2
=1+x
1−x
The Formal Interpretation says yes, because it only uses algebra to check.
The Analytic Interpretation says no, because plugging in x = 1 gives an undefined number.

6 Lecture 6
6.1 Formal Power Series
We will only do algebra, never plug in numbers.

Fundamental question is: what kinds of algebraic manipulations am I allowed to perform?

Short answer:

• collect like terms


• distributive laws and other standard algebraic laws

What isn’t allowed:

• taking limits

Example: Adding FPS

X X X
( an xn ) + ( bn x n ) = (an + bn )xn
n≥0 n≥0 n≥0
e.g.
X X 1
( nxn ) + ( xn+1 )
n+1
n≥0 n≥0
X X 1
= (0x0 + mxm ) + ( xm )
m
m≥1 m≥1
X 1 m
= (m + )x
m
m≥1

Sigma notation tricks:

• Pull out expressions that don’t involve dummy variable


• rewrite the sum (change dummy variable, break into multiple sums, change order of summation, etc.)

6.2 Multiplying FPS


X X
( an xn )( bn xn )
n≥0 n≥0

X n
X
= ( ak bn−k )xn
n≥0 k=0

By multiplying out and inspecting. To use the sigma notation tricks, however:

11
X X
( an xn )( bn xn )
n≥0 n≥0

We need to change one of the dummy variables so that they are distinct:
X X
( ak xk )( bl xl )
k≥0 l≥0

Because one sum does not use the dummy variable of the other, one can be put inside the other:
XX XX
( ak xk )bl xl = bl xl ak xk
l≥0 k≥0 l≥0 k≥0
XX
= ak bl xk+l
l≥0 k≥0

n
XX
= ak bn−k xn
n≥0 k=0

6.3 Justification
How do we justify:
X 1
2 n xn =
1 − 2x
n≥0
1
We write A(X) = B(x)
Let’s do it.

7 Lecture 7
Assignment 1 is due tomorrow!

7.1 More Binomial Theorem Stuff


Three versions:

1.
n  
X n k n−k
n
(x + y) = x y ,n ∈ N
k
k=0

2.
X n
(1 + x)h = xk
k
k≥0

3.
X n + k − 1
(1 − x)−n = xk
k
k≥0

Example: Compute:

[xn (2 + x2 + x3 )m

12
Solution:

X m
2 3 m m 2 3 m m
∗(2 + x + x ) = 2 (1 + 0.5(x + x )) =2 (0.5(x2 + x3 ))k
k
k≥0

X m X m X k 
m 2 k k m −k 2k
=2 (0.5x ) (1 + x) = 2 2 x xj
k k j
k≥0 k≥0 j≥0

     
XX m k 2k+j X X m−k m k
= 2m−k x = 2 xn
k j k n − 2k
k≥0 j≥0 n≥0 k

b0.5n???c   
n 2 3 n
X
m−k m k
= x (2 + x + x ) = 2
k n − 2k
k=0

7.2 Sum and Product Lemmas


Sum Lemma: Suppose S = A ∪ B, where A ∩ B = ∅.and we have a weight function S.

Then:

ΦS (x) = ΦA (x) + ΦB (x)

Product Lemma:

Let A be a set with weight function α, and B be a aset with weight function β. Let S = A × B, and
defined weight function.

ω : S → N, ω((a, b)) = α(a) + β(b)

Then:

ΦS (X) = ΦA (x)ΦB (x)

Key condition: the weight of a composite configuration must be the sum of the weights of its compo-
nents.
Example: you have 5 loonies & 4 toonies. How many ways to make $9? $10?

Solution:

Let S be the set of all combinations we can make with 5 loonies and 4 toonies.

13
8 Lecture 8
8.1 More About the Product Lemma
Let A and B be sets of configurations.
Let α be a weight function on A, and β be a wave function on B.

Let S = A × B

Let ω : S → N be the weight function:

ω((a, b)) = α(a) + β(b)


Then:

sΦS (x) = ΦA (x)ΦB (x)

8.1.1 An Example
You have 5 loonies and 4 toonies. I have 8 loonies and 3 toonies. How many ways can we make $20
together?

Solution:

Let S be the set of all combinations of loonies and toonies we can produce together.

Let L1 be the set of ways you can contribute loonies. Let T1 be the set of ways you can contribute toonies.

Let L2 be the set of ways I can contribute loonies. Let T2 be the set of ways I can contribute toonies.

e.g. L1 = {0loonies, 1loonie, 2loonies, 3loonies, 4loonies, 5loonies}

For each set, define the weight of a configuration to be a dollar amount.

S = L1 × T1 × L2 × T2

This means that, to specify an element of S, we need to specify an element of each of L1 , L2 , T1 , andT2 .

The condition on the weights is satisfied, so we can use the product lemma.

∴ ΦS (x) = Product of individual ones.

8.2 Study Tips


Definitely go home and review the notes. Specifically, pay attention to how the solutions are presented.

8.3 Compositions
Definition: A composition of n with k (called the number of parts) parts is a sequence (c1 , ..., ck of positive
integers (called the parts) such that:

14
k
X
ca = n
a=0

For example, there are 6 compositions of 5 with three parts:


(3, 1, 1), (1, 3, 1), (1, 1, 3), (2, 2, 1), (2, 1, 2), (1, 2, 2)

So the point is: order matters.

The first question we will ask is: how many compositions of n with k parts?

Let S be the set of compositions (c1 , ..., ck ) with k parts.

Define the weight of the composition (c1 , ..., ck ) to be ω((c1 , ..., ck )) = c1 + ... + ck .

With this, the number of elements in S with weight n is the answer to our question. (this is a remark,
not part of the answer).

Let N≥1 = {1, 2, 3, 4, 5, ...} (the positive integers)

Then S = (N≥1 × N≥1 × ... = (Nk≥1 ).

Define a weight function on N≥1 ’


α : N≥1 → N
α(i) = i

Then:

ω((c1 , ..., ck )) = α(c1 + ... + α(ck )


so we can use the Product Lemma.

By the Product Lemma:

ΦS (x) = (ΦN≥1 (x))k

9 Lecture 9
Assignment 3 is on Learn later today (... fuck).
Remember, next Tuesday is a Monday.

9.1 Last Time


Determine the number of compositions of n with k parts.

Solution:

Let S = set of compositions with k parts so that S = (N?≥1 )k


Go back and look for the rest.

15
9.2 Some example of something
x
ΦS (x) = ( ))k
1−x
Answer is:
x
[xn ]Φs (x) = [xn ]( ))k = [xn ]xk (1 − x)k = [xn−k ](1 − x)k
1−x
Then continue with some more stuff.

9.3 Notes
• There are a variety of ways to ask the same question

For example: How many positive integer solutions to the eq. x1 + x2 + ... + xk = n?

• We can ask a variety of related questions by putting different restrictions on the parts of the
composition and/or the number of parts

Example:

Determine the number of compositions of n with k parts (k ≥ 1), where the first part is odd and all
other parts are ≥ 2.

(3, 3, 2, 5) is a composition of 13 with 4 parts satisfying this condition.

Highlights of the Solution (this is not written up properly):

Set of configurations: S = set of compositions with k parts such that the first part is odd and the
subsequent parts are at least 2.

Weight function: ω((c1 , ..., ck )) = c1 + ... + ck

Let Nodd = {1, 3, 5, 7, ...}


Let N≥2 = {2, 3, 4, 5, ...}

S = Nodd × N≥2 × N≥2 × ... × N≥2 = Nodd × (N≥2 )k−1

x
ΦNodd (x) = x + x3 + ... =
1 − x2

x2
ΦN≥2 (x) = x2 + x3 + ... =
1−x
Then use product lemma and multiply them together.

16
10 Lecture 10
10.1 How to Solve Generating Series Problems (in 10 steps)
Note: these steps will not always come in exactly this order (although they usually do)

Extra step 0: do you really need generating series to solve this problem?

If no, then skip the next 10 steps and just answer the question.

Else, continue with the steps.

Example to have in mind: how many compositions of n with k parts?

1. Identify the parameters in the problem, as well as any constants to be treated as parameters

In our example, there are two parameters: n and k

2. Create a set of configurations, S, by removing one of the parameters

In our example, we can remove n, and just look at compositions with k parts.

3. Give a mathematical description of the set S, in terms of unions and Cartesian products based on
simpler sets (A1 , A2 , etc.)

4. Reintroduce the missing parameter as the weight function, so that the problem can be stated as “How
many elements of S with weight n?”

5. Define weight functions on the simpler sets (A1 , A2 , etc.)

6. Check that weight functions behave correctly for the product lemma

7. Compute the generating series ΦA1 (x), ΦA2 (x), ... (usually by first principles)

8. Use the description in step 3 and the product & sum lemmas to get the generating series for S

9. Simplify (geometric series formula often useful)


10. Answer is [xn ]ΦS (x)

10.2 Binary Strings


Example: how many binary strings are there of length n in which every 0 is followed by exactly 1, 2,
or 3 1s?

17
10.2.1 String Theory

• Concatenation of Strings
If a, b are binary strings, then ab is the string whose digits are the digits of a followed by the
digits of b.
e.g. a = 0110, b = 11010, ab = 011011010, aa = 01100110

Let A, B be sets of strings.

Define:

AB = ab|a ∈ A, b ∈ B
e.g. A = {1, 01}, B = {1, 10}

AB = {11, 110, 011, 0110}

AB is unambiguous, because all elements are different. BA, however, would be ambiguous, as
101 would appear twice.

Empty string:  (string of length 0)

Note: a = a = a

10.2.2 Blocks

0011111000000001011111110
This string has 7 blocks:
00|11111|00000000|1|0|1111111|0

A block is defined as: a maximal non-empty substring using only one digit.

Maximal, in this case, means can’t be extended in length in either direction.

10.2.3 Ambiguous vs Unambiguous

Recall: AB = {ab|a ∈ A, b ∈ B}

Looks very much like the definition of the Cartesian product:

A × B = {(a, b)|a ∈ A, b ∈ B}
They differ by only a comma. However, if we compare the Cartesian product of A and B to
the concatenation product, the Cartesian product removes the ambiguity with 101. So, we can
define ambiguity as - do the Cartesian product and the concatenation product match up (have
the same number of elements)?

Formal definition: If the function f : A × B → AB defined by f ((a, b)) = ab is a bijection, we say


that AB is unambiguous.

18
11 Lecture 11
Assignment 2 is now on Crowdmark.

11.1 Set Stuff


A ∪ B is unambiguous if A ∩ B = ∅

For more complex expressions built out of ∪ and concatenation, we say that the expression is unambigu-
ous iff each individual operation is unambiguous.

11.2 * operation
If A is a set of strings:

A∗ = {} ∪ A ∪ AA ∪ AAA ∪ AAAA ∪ ... = ∪k≥0 Ak


This works because we define the Cartesian power differently than the concatenation power.

Examples:

{0, 1}∗ = the set of all binary strings

{0}∗ = the set of all binary strings with only zeros

{1}∗ = the set of all binary strings with only ones

{0}{0}∗ = {0, 00, 000, 0000, ...} = all possible blocks of zeros

These are all unambiguous.

{0, 01, 10}∗, for example, would be ambiguous.

11.3 A Note on Brackets


Round brackets - () - control order of operations.
Curly brackets - - construct a set
Do not mix them up.

11.4 Regular Expressions


What is a regular expression? It’s an expression for a set of strings involving only:

• finite sets

• finite unions
• finite concatenation
• the * operator

19
11.5 Generating Series for Sets of Strings
If A and B are sets of strings and A ∪ B is unambiguous, then:

ΦA∪B (x) = ΦA (x) + ΦB (x)


If AB is unambiguous then:

ΦAB (x) = ΦA (x) + ΦB (x)

12 Lecture 12
Assignment 4 has been posted on learn, but it doesn’t matter, because I still need to finish Assignment
3.

Extra problem set #1 is also up there.

Quiz (midterm) is on June 9 and covers assignments 1-4. Seating will be on Odyssey.

12.1 Finite String Lemma


If A is a set of strings, and A* is unambiguous, then:

ΦA∗ (x) = (1 − ΦA (x))−1


Remember the geometric series formula, it’s important.

In summary:

• If A ∪ B unambiguous, ΦA∪B (x) = ΦA (x) + Φ + B(x)

• If AB unambiguous, ΦAB (x) = ΦA (x)ΦB (x)


• If A∗ unambiguous, ΦA∗ (x) = (1 − ΦA (x))−1

Example: determine the number of binary strings of length n, in which every 0 is followed by exactly 1,
2, or 3 1s.

Solution:

We saw that the set of binary strings of this type is S = {1} ∗ ({0}{1, 11, 111})∗

This is unambiguous (more about why later)

∴ ΦS (x) = Φ{1}∗ (x)Φ({0}{1,11,111})∗ (x)

1 1
= ·
1 − Φ{1} (x) 1 − Φ({0}{1,11,111}) (x)
1 1
= ·
1 − x 1 − Φ{0} (x)Φ{1,11,111} (x)

20
1 1 1
= · =
1 − x 1 − (x)(x + x2 + x3 ) (1 − x)(x + x2 + x3 )
1
Answer: [xn ] (1−x)(x+x 2 +x3 )

12.2 Standard Decompositions of Binary Strings


{0, 1}∗ can represent the set of all binary strings unambiguously.

Here’s another, called 0-decomposition.

{1}∗ ({0}∗ {1}∗ )∗

This essentially says, every so often we have a zero, and between each two zeros there are some num-
ber of 1s. We can also write the same thing, but with the numbers flipped. That’s called the 1-decomposition.

We can replace any part of the 0-decomposition with a subset of that part, and it remains unambiguous.
That’s why that thing from before was unambiguous. This is a pretty common type of argument, apparently.

12.3 Block Decomposition


Recall: {0}{0}∗ is the set of all blocks of zeros, and similarly for 1s.

Standard block decomposition:

{0, 1}∗ = {0}∗ ({1}{1}∗ {0}{0}∗ )∗ {1}∗


Example

Determine the number of binary strings of length n in which all blocks are odd-length.

Solution: Let S be the set of all binary strings in which all blocks are odd.

S = ({} ∪ {1}{11}∗)({0}{00} ∗ {1}{11}∗) ∗ ({} ∪ {0}{00}∗)


This is a restriction of block decomposition, so it’s unambiguous.

13 Lecture 13
Nishad is teaching us today.

13.1 Chapter 3 - Coefficients of Rational Functions


In the last two weeks, we have solved several enumeration problems and often obtained an answer of the
form:

f (x)
[xn ]
g(x)

21
where f (x) and g(x) are polynomials.

Today, we’ll use partial fractions.


f (x)
An expression of the form g(x) where f and g are polynomials is called a rational function.

We are interested in finding the coefficient of [xn ] in such a rational function.

Remark: if the degree of f is ≥ the degree of g, then f (x) = q(x)g(x) + r(x) for some uniquely deteer-
mined qandr (the quotient and remainder polynomials), such that the degree of r is less than the degree of g.

You can find q and r using long division.

So:

f (x) r(x) r(x)


[xn ] = [xn ](q(x) + ) = [xn ]q(x) + [xn ]
g(x) g(x) g(x)
Example 1:
4 3 2
Find [xn ] 6x6x−5x −5x
2 −5x+1

We will use partial fraction expansion to get an explicit formula.

Do long division to get:

q(x) = x2 − 1, r(x) = 1 − 5x
Now we have:

1 − 5x 1 − 5x
[xn ](x2 + 1) + [xn ] = [xn ](x2 + 1) + [xn ]
1 − 5x + 6x2 (1 − 2x)(1 − 3x)
By partial fraction expansion,

1 − 5x A B
= +
(1 − 2x)(1 − 3x) 1 − 2x 1 − 3x
So:

3 −2
[xn ](x2 + 1) +
+
1 − 2x 1 − 3x
Apply the geometric series formula to the second two terms:

[xn ](x2 + 1) + 3(1 + 2x + (2x)2 + ...) − 2(1 + (3x) + (3x)2 + ...)


Generalization:

We want [xn ] fg(x)


(x)
where degree of f is less than degree of g and g(x) has all k distinct roots.

f (x) c1 c2 ck
= + + ... +
g(x) 1 − a1 x 1 − a2 x 1 − ak x

22
However, (1 − ax)−1 = 1 + ax + a2 x2 + ...

So:

f (x)
[xn ] = c1 an1 + c2 an2 + ... + ck ank
g(x)
Example 2: what if the roots aren’t all distinct?
2
−4x+6
Find [xn ] x2x
3 −x2 −x−1

x3 − x2 − x + 1 = x(x2 − 1) − 1(x2 − 1) = (x − 1)2 (x + 1) = (x + 1)(1 − x)2


So, the partial fraction decomposition is:

A B C
+ +
x + 1 1 − x (1 − x)2
Which becomes:

3 1 2 X X X
+ + 2
=3 (−x)i + xj + (m + 1)xm
x + 1 1 − x (1 − x)
i≥0 j≥0 m≥0

The last term (with the m) is obtained from the negative binomial expansion thing.

= 3(−1)n + 1 + 2(n − 1) = 3(−1)n + 2n + 3

14 Lecture 14
Assignment 4 is now on Crowdmark. Solutions to assignment 3 and some of the extra problem sets have
been posted on Learn.

14.1 Recurrence Relation and Initial Conditions


Example:

6x4 − 5x3 − 5x2


an = [xn ] =
6x2 − 5x + 1
an (xn
P
Let A(x) = n≥0

6x4 − 5x3 − 5x2


A(x) =
6x2 − 5x + 1
So,

(6x2 − 5x + 1)A(x) = 6x4 − 5x3 − 5x2


Draw multiplication table for all terms of the multiplying thing and A(x).

23
From this, we build the recurrence relation:

an − 5an−1 + 6an−2 = 0 ∀n ≥ 5
The recurrence relation comes from the thing on the side of the multiplication table.

14.2 Another Example


Let c0 = 1, c1 = 0, c2 = 2

Also: cn = 7cn−1 − 16cn−2 = 12cn−3 for n ≥ 3.


p(x)
Find a rational function q(x) such that cn = [xn ] p(x)
q(x) .

Do the thing from the last example in reverse to solve.

14.3 A Third Example


Factor: 1 − 7x + 16x2 − 12x3 = (1 − 2x)2 (1 − 3x):
Key numbers: 2 (coefficient on x in (1 − 2x)), 2 (again because squared) and 3 (coefficient in other
term).

Thus, cn = α + βn)2n + γ3n .

This is called the general solution to the recurrence:

cn = 7cn−1 − 16cn−2 + 12cn−3)


(equation taken from the first part of the previous equation). This means that every sequence that
satisfies this recurrence is of this form, and every sequence of this form satisfies the recurrence.//
The original problem had initial conditions: c0 = 1, c1 = 0, c2 = 2. Comparing with cn = α+βn)2n +γ3n ,
we can use the initial conditions to solve (3 equations, 3 unknowns).

15 Lecture 15
Assignment 5 is posted on Learn (fuck).

Quiz next Friday in tutorial, seating via Odyssey, material from assignments 2-4.

15.1 Things You Can Do to Get Coefficients


1. Leave it as-is

2. Use the method of partial fractions to get a formula for an


3. Derive a recurrence for an and solve it
4. The thing we’re about to learn, I guess

Question: how many initial conditions are needed in the recurrence?

Theorem: Suppose

24
X p(x)
ai x∗ =
q(x)
i≥0

is a rational function and


k
X
q(x) = 1 + q i xi
i=1

then {an } satisfies the recurrence:

k
X
an = − qj an−j
j=1

for n ≥ max(deg(q(x)), 1 + degp(x)).

The initial conditions are determined by p(x).

Another question: how to present a solution to solving a recurrence?

Definition: For the recurrence


k
X
an = − qj an−j
j=1

the characteristic polynomial is:


X
xn + kgj xk−j
j=1

This was obtained by moving the first equation all to one side and swapping out as for xs.

Example: solve the recurrence:

cn = 7cn−1 − 16cn−2 + 12cn−3


with initial conditions:

c0 = 1, c1 = 0, c2 = 2
Solution:

The characteristic polynomial is:

x3 − 7x2 + 16x − 12 = (x − 2)2 (x − 3)


Roots are: 2, 2, 3

∴ the general solution to the recurrence is:

cn = (α + βn)2n + γ3n
plug in n = 0, 1, 2 (the inital conditions) to solve for the three unknowns.

25
15.2 Solution to the Crazy Dice Problem
Find 2 dice that give the same probability table as 2 ordinary dice.

Solution:

Let S be the set of sides of an ordinary die (1, 2, 3, 4, 5, 6)

Let A be the set of sides on the first crazy die

Let B be the second crazy die

In each case, define the weight of a side to be the number written on it.

For S:

ΦS (x) = x1 + x2 + x3 + x4 + x5 + x6
Point: the total number of ways to roll and n on crazy dice should be equal to the total number of ways
to roll n on the ordinary dice.

Thus, the generating functions should be the same.

ΦS×S (x) = ΦA×B (x)


By the product lemma:

ΦS (x)2 = ΦA (x)ΦB (x)


By some series formula (probably geometric):

x − x7
ΦS (x) =
1−x
So,

x − x7 2
( ) = ΦA (x)ΦB (x)
1−x
To find the ΦA (x) and ΦB (x), we factor the RHS and distribute the factors in such a way that we get a
reasonable answer.

Factoring RHS:

x − x7 1 − x6 x(1 − x3 )(1 + x3 )
=x =
1−x 1−x 1−x
We’ve taken the difference of squares and turned it into a difference of cubes. Using the difference of
cubes equation, we can turn this into:

= −x(1 + x + x2 )(1 + x)(1 − x + x2 )


∴ ΦA (x)ΦB (x) =

ΦA (x)ΦB (x) = (−x(1+x+x2 )(1+x)(1−x+x2 ))2 = x·x(1+x)(1+x)(1+x+x2 )(1+x+x2 )(1−x−x2 )(1−x−x2 )

26
Note that the numbers on each die must all be ≥ 1.

ΦA (1) = ΦB (1) = 6
So, we can distribute the factors into the two generating series. Thus, we can get:

A has 1, 3, 4, 5, 6, 8.
B has 1, 2, 2, 3, 4, 4.

16 Lecture 16
Now we doin’ Graph Theory.

Definition: a graph G consists of a finite set V (G) called the vertices and another finite set E(G) called
the edges.

An edge is an unordered pair of distinct vertices.

The set of all neighbours of a vertex u ∈ V (G) is denoted N (u)

The degree of u ∈ V (G) is deg(u) = |N (u)|

17 Lecture 17
Reminder: quiz Friday

17.1 Some Graph Stuff


Definition: A graph is k-regular if every vertex has degree k.

Examples:

• Compete graph Kp
A graph with p vertices, where they are all joined.

17.2 Bipartite Graphs


A graph G is bipartite if V (G) can be partitioned into two sets (A, B) such that every edge of G joins a
vertex in A to a vertex in B.

18 Lecture 18
something something Graph Theory something something

27
18.1 Paths and Walks
Definition: Walk

Let x and y be two vertices (potentially x = y) in a graph G. A walk in G from x to y is an alternating


sequence of vertices and edges that starts with x and ends with y.

Often, when writing it down, we’ll omit listing the edges, as they’re kind of redundant (although still
part of it).

19 Lecture 20
There’s a second extra problem set on Learn.

20 Lecture 24
Reminder: Assignment 7 is due next week, and the midterm is next Thursday.

The midterm covers material up to and including assignment 7.

21 Lecture 26
The midterm is tomorrow at 4:30; don’t forget.

ama

28

Вам также может понравиться