You are on page 1of 51

MATH 240: Discrete Structures

Anna Brandenberger, Binyuan Sun


July 6, 2018

This is a transcript of the lectures given by Prof. Ben Seamone during


the winter semester of the 2017-2018 academic year (01-04 2018) for
the Discrete Structures class (math 240). Subjects covered are: math-
ematical foundations of logical thinking and reasoning, mathematical
language and proof techniques, quantifiers, functions and relations,
partially ordered sets and lattices, induction (Section 1); elementary
number theory, modular arithmetic (Section 2); recurrence relations
and asymptotics, combinatorial enumeration (Section 3); introduction
to graphs, digraphs and rooted trees (Section 4).

1 Logic and Fundamentals

1.1 Propositional Logic


Basic Terms

Definition 1.1. A proposition or statement is something which can


Examples of propositions and non
be verified as being either true or false. propositions:
Example
x=5 YES
Definition 1.2. A sentence is a formula consisting of x+y NO
"This statement is false." NO
• atoms: simple propositions

• connectors: operations joining atoms

Sometimes parentheses are used to denote order of operations (if


necessary.)
P Q P∧Q P∨Q ¬P
T T T T F
Definition 1.3. The three connectors are: T F F T F
F T F T T
• and: "P and Q" = P ∧ Q (both are true) F F F F T
Table 1: Basic Truth Table
• or: "P or Q" = P ∨ Q (one or the other is true)

• not: "not P" = ¬ P (takes on the opposite truth value of P) Order of operations:
1. Parentheses
2. ¬
Definition 1.4. A sentence is a: 3. ∨ and ∧
4. etc.
1. Tautology if it is always true.

2. Contradiction if it is always false.

3. Contingency otherwise.
2 anna brandenberger, binyuan sun

Example 1.1. Determine if each sentence is a tautology, contradiction P ¬P P ∧ ¬P


or contingency. T F F
F T F
1. P ∧ ¬ P: Contradiction (c.f. Table 2). Table 2: Table illustrating a Contradic-
tion.
2. ¬( P ∧ Q) ∨ (¬ P ∨ Q): Tautology (c.f. Table 3).
P Q ¬ P P ∧ Q ¬ P ∨ Q Final
T T F T T T
Can we be more efficient in our logic? An identity is a statement T F F F F T
that two sentences have the same truth values for the same truth F T T F T T
values of their atoms. F F T F T T
Table 3: Table illustrating a Tautology.

Some simple ones:1 1


Use T for a statement that is always
 true, F for a statement that is always
P ∧ T ≡ P false.
• Identity:
P ∨ F ≡ P

P ∧ P ≡ P
• Idempotent:
P ∨ P ≡ P

P ∧ ¬P ≡ F
• Complement:
P ∨ ¬P ≡ T

• Double negation: ¬(¬ P) ≡ P



¬(¬ P ∨ ¬ Q) ≡ P ∧ Q
• DeMorgan’s Laws:
¬(¬ P ∧ ¬ Q) ≡ P ∨ Q

 P ∧ ( Q ∧ R) ≡ ( P ∧ Q) ∧ R
• Associative:
 P ∨ ( Q ∨ R) ≡ ( P ∨ Q) ∨ R

 P ∧ ( Q ∨ R) ≡ ( P ∧ Q) ∨ ( P ∧ R)
• Distributive: Equivalent Phrasings to "P implies Q":
 P ∨ ( Q ∧ R) ≡ ( P ∨ Q) ∧ ( P ∨ R)
• "If P, then Q".
• "Q if P".
Conditional Statements
• "P only if Q".
Definition 1.5. "P implies Q" written P =⇒ Q. • "Q whenever P".
• "Whenever Q, then also P."
Example 1.2. P = "the sun is shining", Q = "teeth are purple". The • "P is sufficient for Q."
statement given is P =⇒ Q. To show this is false, you must show P • "Q is necessary for P."
is true and Q false.

¬( P =⇒ Q) ≡ P ∧ ¬ Q P Q ¬P ∨ Q
T T T
( P =⇒ Q) ≡ ¬( P ∧ ¬ Q) double negation T F F
F T T
≡ ¬ P ∨ ¬(¬ Q) DeMorgan’s Law
F F T
≡ ¬P ∨ Q Table 4: Table illustrating Example 1.2.
math 240: discrete structures 3

Examples 1.3. using identities:

1. Verify P ⇒ ( Q ∨ ¬ Q) is a tautology.

P ⇒ ( Q ∨ ¬ Q) ≡ P ⇒ T ("complement")
≡ ¬P ∨ T ("implies")
≡T (identity)

2. Determine if the following sentence is a tautology, contradiction,


or contingency.

[¬ P ∨ (¬ P ∧ Q)] ∧ P ≡ [¬ P ∧ P] ∨ [(¬ P ∧ Q) ∧ P]
≡ F ∨ [¬ P ∧ P ∧ Q]
≡ F ∨ [F ∧ Q ]
≡ F∨F ≡ F

Definition 1.6. The contrapositive of P ⇒ Q is ¬ Q ⇒ ¬ P.


S = this shape is a square
R = this shape is a rectangle
Proof. Show that ( P ⇒ Q) ≡ (¬ Q ⇒ ¬ P). S ⇒ R means if the shape is a square
then it is a rectangle. ¬ R ⇒ ¬S means
P ⇒ Q ≡ ¬P ∨ Q if the shape is not a rectangle then it is
not a square.
≡ Q ∨ ¬P
≡ ¬(¬ Q) ∨ ¬ P
≡ ¬Q ⇒ ¬P

The converse of P ⇒ Q is Q ⇒ P. In general P ⇒ Q & its converse


P Q P⇔Q
need not be related. T T T
T F F
Biconditional Statements F T F
F F T
Definition 1.7. P ⇔ Q ≡ "P and Q are equivalent" Table 5: Table illustrating biconditional
statements.

Two new identities:

• P ⇔ Q ≡ ( P ⇒ Q) ∧ ( Q ⇒ P)

• P ⇔ Q ≡ ( P ∧ Q) ∨ (¬ P ∧ ¬ Q)
Updated order of operations:
1. Parentheses
Ambiguous statements: 2. ¬
3. ∨ and ∧
1. A ∧ B ∨ C
4. =⇒ and ⇔
( A ∧ B) ∨ C ≡ ( A ∨ C ) ∧ ( B ∨ C )
A ∧ ( B ∨ C ) ≡ ( A ∧ B) ∨ ( A ∧ C )
4 anna brandenberger, binyuan sun

2. P ⇒ Q ⇒ R
Check that:
( P ⇒ Q) ⇒ R 6≡ P ⇒ ( Q ⇒ R)
¬(¬ P ∨ Q) ∨ R 6≡ ¬ P ∨ (¬ Q ∨ R)

Phrasing of ⇔:

P ⇔ Q ≡ P if and only if Q
NECC: Q ⇒ P, SUFF: P ⇒ Q
≡ P if Q, and conversely
≡ P precisely when Q A note: P ≡ Q and P ⇔ Q essentially
mean the same thing.
≡ P is necessary and sufficient for Q

Symbolization

Examples 1.4.
1. If you study then, then you will pass 2 : S ⇒ P 2
S: you study
P: you pass
2. The ground gets wet whenever it rains 3 : R ⇒ W 3
W: the ground gets wet
R: it rains
3. The sun is out but it is raining 4 : S ∧ R 4
W: the sun is out
R: it is raining
4. You cannot scuba dive unless you have had lessons 5 : 5
W: can scuba dive
S ⇒ L or ¬ L ⇒ ¬S R: had lessons

5. If you only study under pressure , then you do not learn 6 : 6


S: you study
P: you are under pressure
( P ⇔ S) ⇒ ¬ L L: you learn

1.2 Predicate logic


Predicate logic = 1st order logic
Definition 1.8. We introduce two quantifiers:

1. ∀ = "for all" = universal quantifier Justification:


Consider a statement like: "Every
positive integer is the sum of two
2. ∃ = "there exists" = "existential quantifier"
primes".
To construct a truth table, we would
Predicates need infinitely many columns (since
this statement contains infinitely many
Definition 1.9. A predicate is a sentence containing variables that is atoms). So this can’t be done in propo-
either true or false. sitional logic.

Examples 1.5. of symbolization:


1. Every even integer n greater than 2 can be expressed as the sum of
two primes.

Z (n) = n is a positive integer


P(n) = n is the sum of 2 primes

∀n( Z (n) ⇒ P(n))


math 240: discrete structures 5

2. "Not everything is about you "7 : ¬(∀ xY ( x )) 7


Y ( x ) = "x is about you"

3. "When it rains , everything gets wet 8 ": R ⇒ (∀ xW ( x )) 8


R: "it rains"
W ( x ): "x gets wet"
4. "Every person who wants wine gets asked for ID by the bar-
tender"9 : ∀ x (W ( x ) ⇒ I ( x, b)) 9
W ( x ) = x wants wine;
I ( x, y) = y asks x for ID;
b = the bartender
We can use equality to symbolize:
Example 1.6. "Sue is the only person who knows how this works":
K ( x ) : x knows how this works
∀ x (K ( x ) ⇒ x = Sue)

When using multiple quantifiers, order matters (read L to R):


Example 1.7. F ( x, y) = "x and y are friends":
∀ x ∃yF ( x, y) → every person has a friend
∃ x ∀yF ( x, y) → someone is friends with everyone

Functions, or variables which depend on other variables are al-


lowed.
Example 1.8. "Matt brings a friend":
B( x, y) : x brings y Updated Order of Operations
1. Parentheses
f ( x ) : a friend of x
2. ¬
m : Matt
3. ∀, ∃ (L to R)
Theorem 1.1. Negation of predicates: 4. ∧, ∨
5. ⇒, ⇔
• ¬(∀ xP( x )) ≡ ∃ x ¬ P( x )

• ¬(∃ xP( x )) ≡ ∀ x ¬ P( x )

Examples 1.9.
• "Not everything is about you".10 10
Y ( x ) : x is about you
claim: Everything is about you: ∀ xY ( x )
negation: There is a thing that is not about you: ¬(∀ xY ( x )) ≡
∃ x ¬Y ( x )
• "All cardinals are red".11 11
C ( x ) : x is a cardinal
claim: ∀ x (C ( x ) ⇒ R( x )) R( x ) : x is red

negation: ∃ x ¬(C ( x ) ⇒ R( x ))
≡ ∃ x ¬(¬C ( x ) ∨ R( x ))
≡ ∃ x (C ( x ) ∧ ¬ R( x ))
• "There is an even number greater than three which is prime".12 12
E( x ) : x is even
claim: ∃ x ( E( x ) ∧ G ( x ) ∧ P( x )) G ( x ) : x is greater than 3
P( x ) : x is prime
negation: ∀ x ¬(( E( x ) ∧ G ( x ) ∧ P( x ))
≡ ∀ x [¬ E( x ) ∨ ¬ G ( x ) ∨ ¬ P( x )]
6 anna brandenberger, binyuan sun

A sentence of the form ∀ x ( P( x ) ⇒ Q( x )) is called vacuously true


if P( x ) is F ∀ x. This is because P ⇒ Q is true whenever P is false.
The rule holds because its never given a chance to fail.

Example 1.10. Every McGill prof with 200 years of experience is a


great golfer .13 13
M ( x ) : McGill prof
O( x ) : 200 years of experience
G ( x ) : great golfer
Proposition 1.2. To disprove a claim ∀ x ( P( x ) ⇒ Q( x )), we show ∃ x
for which P( x ) ∧ ¬ Q( x ) is true. This x is called a counterexample to the
claim.

Arguments

Definition 1.10 (Rule of inference). An argument is a finite collec-


tion of statements A1 , A2 , . . . , An (called predicate, or hypothesis)
followed by statement B called the conclusion. An argument is valid if
B is true whenever all A1 , A2 , . . . , An are true.
Some Rules of Inference
(more posted on MyCourses)
Proposition 1.3. To validate an argument: 1. Modus ponens
Arguments: p =⇒ q
1. Check a truth table (is B true when A1 , A2 , . . . , An are all true?) p
Conclusion: q
2. Show A1 ∧ A2 ∧ . . . , An =⇒ B is a tautology 2. Modus tollens
P =⇒ Q
¬Q
¬P

1.3 Set Definitions and Operations

Definition 1.11. A set is a collection of distinct objects, called ele-


ments or members. Examples 1.11.
1. Integers from −2 to 2
Notation {−2, −1, 0, 1, 2}
a ∈ S means a is an element of the set S or {0, 1, −1, 2, −2}
or {−2, −1, 0, 0, 1, 2}
a 6∈ S means a is not an element of the set S
2. Integers from 1 to 100
{1, 2, 3, . . . , 100}
Basic sets
3. Natural numbers
N: the natural numbers N = {1, 2, 3, . . . }
Z: the integers 4. Some attributes of John Smith
R: the real numbers {John Smith, 12345678, B.Sc
∅: the empty set john.smith@mail.mcgill.ca, {MATH
240, COMP251, COMP 273}}

Writing down sets:

- list the elements in any order inside {}

- if the elements follow a pattern, we sometimes use ". . . " to denote


that the elements continues
math 240: discrete structures 7

Definition 1.12. Set builder notation: Examples 1.12.


{element | rule the element obeys to be in the set} 1. Q the rational numbers
{ mn |m ∈ Z, n 6= 0}
2. C the complex numbers
{ a + b|a ∈ R, b ∈ R, i2 = −1}
Theorem 1.4. Two sets are equal if and only if they either contain the same
elements or are both empty.

Examples 1.13.
√ √
1. { x ∈ R| x2 − 3 = 0} = { 3, − 3}

2. { x ∈ N| x2 − 3 = 0} = ∅

3. {n ∈ Z|n2 + 1 = 0} = { x | x > 0 ∧ x < 0}


?
4. Q : {∅} = ∅ no! LHS contains an element ∅
Example 1.14. ∅ ⊂ X for every set X
Definition 1.13. We write A ⊆ B and say A is a subset of B if every N⊆R⊆C
{1, 2} ⊆ {1, 2, π }
x ∈ A also obeys x ∈ B.

Proposition 1.5. If A ⊆ B and A 6= B, we can write as above and say A is Notation {1, 2} 6⊆ {1, 2}
a proper subset of B. {1, 2} ⊂ {1, 2, π }

Examples 1.15.
{ a, b} ∈ { a, b, c}? F
{ a, b} ⊆ { a, b, c}? T
{ a, b} ∈ { a, b, { a, b}}? T
{ a, b} ⊆ { a, b, { a, b}}? T

Proposition 1.6. A = B ⇔ A ⊆ B and B ⊆ A

Definition 1.14. U = the universal set = the set containing every-


thing (that we are interested in).

Venn diagrams
Figure 1: A ∪ B Figure 2: A ∩ B

– union: A ∪ B = { x | x ∈ A ∨ x ∈ B}

– intersection: A ∩ B = { x | x ∈ A ∧ x ∈ B}

– difference: A \ B = { x | x ∈ A ∧ x 6∈ B} Figure 3: B \ A Figure 4: A

– complement: A = { x | x 6∈ A} = U \ A

– symmetric difference: A ⊕ B = { x | ( x ∈ A ∨ x ∈ B) ∧ x 6∈ A ∩ B}
= { x | x ∈ A ∪ B ∧ x 6∈ A ∩ B} Figure 5: A ⊕ B
8 anna brandenberger, binyuan sun

Definition 1.15. Power set of A: P ( A) = { B | B ⊆ A} Example 1.16. P ({ a, b, c}) =


{∅, { a}, {b}, {c}, { a, b}, {b, c}, { a, c}, { a, b, c}}

Proof Methods

Most statements to prove are of the form P ⇒ Q or P ⇔ Q.

Proposition 1.7. Proof methods for P ⇒ Q:

1. Direct proof: Assume P is true. Show Q is true, usually with some


application of the transitive rule of inference.

2. Contrapositive proof: Prove the contrapositive (¬ Q ⇒ ¬ P).

Set Identities (to be posted) Examples 1.17. P ⇒ R1 ⇒ R2 ⇒ Q

• complement law: A ∪ A = U, A∩A = ∅

• demorgan: A ∪ B = A ∩ B, A∩B = A∪B

• distributive: A ∩ ( B ∪ C ) = ( A ∩ B) ∪ ( A ∩ C ),
A ∪ ( B ∩ C ) = ( A ∪ B) ∩ ( A ∪ C )

Example 1.18. Prove A ∩ ( B ∪ C ) = ( A ∩ B) ∪ ( A ∩ C )


Recall: X = Y ⇔ X ⊆ Y and Y ⊆ X. 14 14
We must show each of the sets in the
statement is contained in the other as a
Proof. subset.

1. Show A ∩ ( B ∪ C ) ⊆ ( A ∩ B) ∪ ( A ∩ C ):
Let x ∈ A ∩ ( B ∪ C )

⇒ x ∈ A & x ∈ (B ∪ C)
⇒ x ∈ A & ( x ∈ B || x ∈ C )
⇒ ( x ∈ A & x ∈ B) or ( x ∈ A&x ∈ C )
⇒ x ∈ A ∩ B || x ∈ A ∩ C
⇒ x ∈ ( A ∩ B) ∪ ( A ∩ C )

2. Show ( A ∩ B) ∪ ( A ∩ C ) ⊆ A ∩ ( B ∪ C ):
Let y ∈ ( A ∩ B) ∪ ( A ∩ C )
Either y ∈ A ∩ B or y ∈ A ∩ C ⇒ y ∈ A and either y ∈ B or y ∈ C

⇒ y ∈ (B ∪ C)
( A ∩ B) ∪ ( A ∩ C ) ⊆ A ∩ ( B ∪ C )
A ∩ ( B ∪ C ) = ( A ∩ B) ∪ ( A ∩ C )

Definition 1.16. Another operation on sets is the Cartesian product


of A and B denoted A × B = {( a, b) | a ∈ A, b ∈ B}
math 240: discrete structures 9

Proposition 1.8. Two elements in A × B are equal precisely when they are
in both coordinates: ( a1 , b1 ) = ( a2 , b2 ) ⇔ a1 = a2 and b2 = b1
Example 1.19. A = {1, 2}, B = {3, 4}
A × B = {(1, 3), (2, 3), (1, 4), (2, 4)}
Example 1.20. Prove that A × ( B ∪ C ) ⊆ ( A × B) ∪ ( A × C ) B × A = {(3, 1), (3, 2), (4, 1), (4, 2)}

Proof. ⇒ x ∈ A and y ∈ B ∪ C
If y ∈ C, then ( x, y) ∈ A × C; if y ∈ B, then ( x, y) ∈ A × B
So either ( x, y) ∈ A × B or ( x, y) ∈ A × C
⇒ ( x, y) ∈ ( A × B) ∪ ( A × C )
⇒ A × ( B ∪ C ) ⊆ ( A × B) ∪ ( A × C )

1.4 Relations and Equivalence Relations

Definition 1.17. A binary relation R from A to B is a subset of A × B.


Using the example above, R =
{(1, 3), (1, 4)} is a binary relation
from A to B (one of many).
Proposition 1.9. A binary relation on A is a subset of A2 .

Example 1.21.
Definition 1.18. Useful properties: Let R be a binary relation on A. {( x, y)|y = x2 } is a bin. rel. on R.
R is Definition {( x, y)| x = y2 } is a bin. rel. on R.
reflexive ∀ a ∈ A, ( a, a) ∈ R {(m, n)| mn ∈ Z} is a bin rel on Z.

symmetric ( a, b) ∈ R ⇒ (b, a) ∈ R
antisymmetric ( a, b) ∈ R and (b, a) ∈ R ⇒ a = b
transitive ( a, b), (b, c) ∈ R ⇒ ( a, c) ∈ R

Example 1.22. Determine if the relation has any of the 4 properties


defined above: R = {( x, y) ∈ R2 | x ≤ y}

– Reflexive: ∀ x ∈ R, x ≤ x ⇒ ( x, x ) ∈ R

– Symmetric: (1, 2) ∈ R and (2, 1) 6∈ R

– Antisymmetric: If ( x, y) ∈ R and (y, x ) ∈ R, then x ≤ y and


y≤x⇒x=y

– Transitive: If ( x, y), (y, z) ∈ R, then x ≤ y ∩ y ≤ z ⇒ ( x, z) ∈


R 

Definition 1.19. A binary relation on A is a partial order on A is it is


reflexive, antisymmetric, and transitive

Example 1.23. R = {( a, b) ∈ Z2 | a − b is even} Note: n is even ⇔ n = 2k for some


k∈Z
– Reflexive: ∀ x ∈ Z, a − a = 0 is even ⇒ ( a, a) ∈ R

– Symmetric: ( a, b) ∈ R ⇒ a − b even ⇒ b − a even ⇒ (b, a) ∈ R


10 anna brandenberger, binyuan sun

– Antisymmetric: (16, 8) ∈ R & (8, 16) ∈ R but 16 6= 8



 a − b = 2k
– Transitive: If ( a, b) ∈ R and (b, c) ∈ R, then
b − c = 2l
⇒ a − c = 2k + 2l = 2(k + l ) is even.

Definition 1.20. A binary relation on A is an equivalence relation on


A if it is reflexive, symmetric, and transitive.

Definition 1.21. A total order on A is a partial order R where ∀ a, b ∈


A, either ( a, b) or (b, a) is in R. (Linear order.)

Remark 1. Not every partial order is a total order.

Example 1.24. Let A be some set R = {( x, y)| x, y ∈ P( A), x ⊆ y}


Why is this not a total order?
A = {1, 2, 3}, M = {1}, N = {2, 3}
( x, y) 6∈ R ∵ M 6⊆ N ∧ N 6⊆ M
Show it is a partial order.

– Reflexive: ∀ x ⊆ A, is ( x, x ) ∈ R?

– Antisymmetric: ( x, y) ∈ R ∧ (y, x ) ∈ R
⇒ X ⊆ Y∧Y ⊆ X
⇒X=Y

– Transitive: ( X, Y ) ∈ R, (Y, Z ) ∈ R
⇒ X ⊆ Y, Y ⊆ Z
⇒X⊆Z
⇒ ( X, Z ) ∈ R

Equivalence Relations
Recall: Definition 1.20: an equivalence
relation is a relation R which is:
Definition 1.22. We say a is related to b in a equivalent relation R if • Reflexive
( a, b) ∈ R, denoted as follows: • Symmetric
• Transitive
Notation 1.10. a is related to b in a equivalent relation R:

aRb a ∼R b a ∼ b (if R is understood)

Definition 1.23. If R is an equivalence relation, the equivalence class


of an element a ∈ R is denoted [ a] or a, is [ a] = { x | x ∼ a}

Example 1.25. 1. Show R = {( x, y) ∈ Z2 | x − y = 3k for some k ∈ Z}


is an equivalence class.

2. What are [0], [1], [2], [3]?


math 240: discrete structures 11

1. R: x − x = 0 ⇒ ( x, x ) ∈ R
S: x − y = 3k ⇒ y − x = 3k ⇒ ( x, y) ∈ R ⇒ (y, x ) ∈ R
I: ( x, y) ∈ R, (y, z) ∈ R
⇒ x − y = 3k, y − z = 3l ⇒ x − z = 3(k + l ) ∈ Z ⇒ ( x, z) ∈ R

2. [0] = { x | x ∼ 0} = { x | x − 0 = 3k} = { x | x = 3k} =


{. . . , −6, −3, 0, 3, 6, . . . }
[1] = { x | x ∼ 1} = { x | x − 1 = 3k} = { x | x = 3k + 1, k ∈ Z}
[2] = { x | x ∼ 2} = { x | x − 2 = 3k} = { x | x = 3k + 2, k ∈ Z}
[3] = { x | x ∼ 2} = { x | x − 3 = 3k} = { x | x = 3k + 3, k ∈ Z} =
{ x | x = 3(k + 1), k ∈ Z} = { x | x = 3l, l ∈ Z} = [0]

Theorem 1.11. Let a ∈ A, R an equivalence relation to A. For any x ∈ A,


[ x ] = [ a] ⇔ x ∼ a.
To prove P ⇔ Q, prove P ⇒ Q and
Proof. (⇐) Suppose [ x ] = [ a] ∵ x ∈ [ x ] ⇒ x ∈ [ a] ⇒ x ∼ a Q⇒P

(⇒) Suppose x ∼ a, We will show [ x ] ⊆ [ a] and [ a] ⊆ [ x ]


| {z } | {z }
(a) (b)

(a) Let y ∈ [ x ] ⇒ y ∼ x.
Since x ∼ a, by transitivity, y ∼ a ⇒ y ∈ [ a] ⇒ [ x ] ⊆ [ a]
(b) z ∈ [ a]
⇒z∼a
⇒ z ∼ x (since x ∼ a)
⇒ z ∈ [x]
⇒ [ a] ⊆ [ x ]
Together, this gives [ a] = [ x ]

Theorem 1.12. Let a, b ∈ A, R an equivalence relation of A.


[ a] 6= [b] ⇔ [ a] ∩ [b] = ∅

Proof. (⇒) If [ a] ∩ [b] = ∅ then since a ∈ [ a], a 6∈ [b] ⇒ [ a] 6= [b].

(⇐) We will prove the contrapositive: show [ a] ∩ [b] 6= ∅ ⇒ [ a] = [b].


[ a] ∩ [b] 6= ∅ ⇒ ∃ x, x ∈ [ a] ∩ x ∈ [b] ⇒ x ∼ a ∩ x ∼ b ⇒ [ x ] =
[ a] ∩ [ x ] = [b] ⇒ [ a] = [b]

Recap: P ⇒ Q:Direct proof, Contraposi-


tive (direct proof of ¬ Q ⇒ ¬ P)
P ⇔ Q : P ⇒ Q ∧ Q ⇒ P, P ⇒ Q ∧
1.5 Proof by Contradiction ¬ P ⇒ ¬ Q, [¬ Q ⇒ ¬ P ∧ ¬ P ⇒ ¬ Q]

principle: If your assumption leads, by logical steps, to something


false (a contradiction), then the assumption must have been wrong
and thus the opposite statement is right.
Following are some proofs using this method:
12 anna brandenberger, binyuan sun


Theorem 1.13. 2 6∈ Q

Proof. Suppose 2∈Q
m
q
⇒ (2) = , m, n ∈ Q
n
m
We may assume, without loss of generality (WLOG), that n is in
reduced form, i.e they share no common factors.

m m2
q
(2) = ⇒2= 2
n n
⇒ m2 = 2n2
⇒ m is even ⇒ m = 2k for some k ∈ Z
2 2
⇒ (2k) = 2n ⇒ 4k2 = 2n2 ⇒ 2k2 = n2
⇒ n is even

=⇒ m and n have a common factor of 2. ⇒⇐



Thus our assumption 2 ∈ Q was wrong.

Theorem 1.14 (Fundamental Theorem of Arithmetic). Every n ∈ N


can be written as a product of primes that is unique up to order.

Proof. given later (Section 2).

Theorem 1.15. There are infinitely many primes.

Proof. Suppose there are finitely may primes p1 , p2 , . . . , pn


Let q = p1 p2 . . . pn + 1. Theorem 1.14 (Fundamental Theorem of
Arithmetic) states that q is divisible by some prime: wlog, p1 ⇒ q =
p1 k for some k ∈ Z.

q − p1 p2 . . . p n = 1
p1 k − p1 p2 . . . p n = 1
p1 ( k − p2 . . . p n ) = 1 ⇒⇐
|{z} | {z }
≥2 ∈N

Thus our assumption that there are finitely many primes was wrong.

Proposition 1.16. Proving Existential Statements (∃ xP( x ))

1. Give the example.

2. When you can’t give the example, a "non constructive proof" can some-
times be found.

Example 1.26. 1. "There exists an even prime". It’s 2.


math 240: discrete structures 13


1± 5
2. "There is a real solution to x2 − x − 1 = 0". It’s 2 .

Example 1.27. "There are irrational numbers x, y such that x y ∈ Q.



Proof. We know√ 2 6∈ Q.
√ 2
Consider
√ 2 .
√ 2 √ √
If 2√ ∈ Q, then x = 2, y = √2 is our example. √
√ 2 √ 2 √ √ 2 √
If√ √2 6∈ Q, then consider 2 , y = 2 : ( 2 ) 2 =
√ 2∗ 2 √ 2
2 = 2 = 2 ∈ Q.
In either case, we ave an example that proves such x, y exist.
14 anna brandenberger, binyuan sun

2 Number Theory
The study of properties of integers.
2.1 Division

Theorem 2.1 (Division Algorithm).


If a, b ∈ Z, b 6= 0, then ∃q, r ∈ Z such that:
a = qb + r, with 0 ≤ r < |b|.
Furthermore, q and r are unique. t

The proof of this algorithm uses the following as main tool:

Lemma 2.2 (Well Ordering Principle). If A ⊆ N, then A has a smallest


element.

Proof. of the Division Algorithm (Theorem 2.1)


Consider the case where a, b > 0. Look at the following multiples
of b : 0, b, 2b, 3b, 4b, · · · . There is some multiple of b > a. Let B =
{kb|k ∈ N, kb > a} Example 2.1. (2a)b = (2b) a ≥ 2a > a
By the Well Ordering Principle (Lemma 2.2), B has a smallest ele-
ment. Call it (q + 1)b.

qb ≤ a < (q + 1)b
Let r = a − qb, then:
a = qb + r
and:
0 ≤ a − qb < (q + 1)b − qb
0≤r<b

what about uniqueness?


Assume ∃q1 , q2 , r1 , r2 such that a = q1 b + r1 , a = q2 b + r2 . We will
show q1 = q2 and r1 = r2 , and so distinct solutions are impossible.
0 = ( q1 − q2 ) b + (r1 − r2 ), ( q1 − q2 ) b = r2 − r1 .
But

0 ≤ r1 < b
− b < −r2 ≤ 0
⇒ − b < r1 − r2 < b

Since r1 − r2 is a multiple of b, we have r1 − r2 = (0)(b) ⇒ r1 = r2


and (q1 = q2 )b = 0 ⇒ q1 = q2 . Therefore q and r are unique.
A note about proving the remaining
cases: you can use the a > 0, b > 0 case.
Definition 2.1. b divides a ⇔ ∃q such that a = qb. Write b | a if b di-
vides a and b - a if b does not divide a.
math 240: discrete structures 15

Proposition 2.3. g is a divisor of a if g | a and g | b and if g is the largest


such integer, we call g the greatest common divisor or a and b; we write g =
gcd( a, b).

Let’s prove some things about divisors.


Example 2.2. 87 = 4(|{z}
21 ) + 3
|{z} |{z}
Lemma 2.4. If c | a and c | b then, c | xa + yb ∀ x, y ∈ Z.
a b r
gcd( a, b) = 3
gcd(b, r ) = 3
Proof. ∃k, l ∈ Z such that a = kc, b = lc ⇒ xa + yb = x (kc) + y(lc) =
( xk + yl )c ⇒ c | ( xk + yl )c = c | ( xa + yb)

Lemma 2.5. If a = qb + r, then gcd( a, b) = gcd(b, r ).


If a 6= 0 then gcd( a, 0) = a.
Proof. If a = b = 0 or b = r = 0, then the gcd’s are undefined. If
a 6= 0, then gcd( a, 0) = a. Let g1 = gcd( a, b) and g2 = gcd(b, r ). We
have that g1 | a and g1 |b.
⇒ g1 | a − qb
⇒ g1 | r
⇒ g1 divides r and b
⇒ g1 ≤ g2
Similarly, g2 | b and g2 | r
⇒ g2 | qb + r (by lemma above)
⇒ g2 ⇒ g2 ≤ g1 (because g2 | a & g2 | b)
g1 = g2

Proposition 2.6 (Euclidean Algorithm).


Suppose a > b ( a, b ∈ N). Then write:

a = q1 b + r1 (0 ≤ r1 < b ) Example 2.3. Find gcd(630, 196) = 14


b = q1 r1 + r2 (0 ≤ r2 < r1 )
630 = 3(196) + 42
r1 = q2 r2 + r3 (0 ≤ r3 < r2 )
196 = 4(42) + 28

and continue until the remainder becomes 0, rk+1 = 0. Then rk = gcd( a, b) 42 = 1(28) + 14
28 = 2(14) + 0

Proof. As a consequence of the Euclidean


does this terminate? Algorithm, ∃ x, y such that gcd( a, b) =
xa + yb:
This set has a smallest element by W.O.P., this is rk .
does it work?
14 = (42) − 1(28)
By previous lemma, = (42) − 1[196 − 4(42)]
gcd( a, b) = gcd(b, r1 ) = gcd(r1 , r2) = gcd(rk , 0) = rk = 5(42) − 1(196)
= [630 − 3(196)] − 1(196)
⇒ 14 = 5(630) − 16(196)
Definition 2.2. a, b ∈ N are relatively prime if gcd( a, b) = 1.
16 anna brandenberger, binyuan sun

Example 2.4. Show 91 and 8 are relatively prime:

91 = 11(8) + 3
8 = 2(3) + 2
3 = 1(2) + 1
2 = 2(1) + 0

Again, ∃s, t ∈ Z s.t. 91s + 8t = 1

1 = (3) − 1(2)
= 3 − 1(8 − 2(3))
= 3(3) − 1(8)
= 3(91 − 11(8)) − 1(8)
3 (91) − |{z}
= |{z} 34 (8)
s t

Theorem 2.7. If a and b are relatively prime, then ∀n ∈ N, ∃ x, y ∈ Z s.t.

n = xa + yb

Proof.
gcd( a, b) = 1
⇒∃s, t sa + tb = 1
⇒(sn) a + (tn)b = n
⇒ xa + yb = n

Corollary 2.8. If gcd( a, b) = 1 and a | bc, then a | c.

Proof.
∃ x, y such that ax + by = 1
⇒ c = cax + cby
Since a | a and a | bc
a | a( xc) + bc(y) ⇒ a | c( ax + by)
⇒a|c

Definition 2.3. p ∈ N is called prime if d | p ⇒ d = 1 or p

Lemma 2.9. ∀n ∈ N, n ≥ 2, ∃ p | n, p prime.

Proof. Suppose n has no prime divisor. The set of all positive integers
with no prime divisors would be non-empty. By WOP (Lemma 2.2),
it has a smallest element. Call this m.15 . Since m | m, m is not prime. 15
Note: This variation on a proof by
Thus ∃d, 1 < d < m such that d | m. By minimality of m, d has a contradiction uses a minimal counterex-
ample
prime divisor, say p. p | d and d | m
⇒p|m ⇒⇐
math 240: discrete structures 17

Lemma 2.10. If n ∈ N, n composite, n ≥ 2, then ∃ p ∈ N such that p | n,



p prime and p ≤ n.

Proof. n composite ⇒ n = ab for some a, b ∈ N. WLOG, a ≤ b.



Claim: a ≤ n.
√ √ √ √
If not, a > n and b ≥ a > n ⇒ ab > n n = n ⇒⇐

∃ p | a, p prime ⇒ p ≤ a ≤ n (∃ p | a, a | n ⇒ p | n)

Lemma 2.11. p | ab, p prime =⇒ p | a or p | b

Proof. p | a =⇒ done.
p - a =⇒ gcd( a, p) = 1 =⇒ p | b.

Corollary 2.12. p | a1 . . . ak ⇒ p | ai for some i

Theorem 2.13 (Fundamental Theorem of Arithmetic).


For an n ∈ N, n ≥ 2, n = p1 p2 . . . pk for some primes p1 , p2 , . . . , pk .
This representation is unique.

Proof. Suppose n = p1 p2 . . . pk and n = q1 q2 . . . ql (all pi , qi prime).


⇒ p1 p2 . . . pk = q1 q2 . . . ql . Cancel any common prime factors. If
there’s anything left, pi , then pi | qi ⇒ pi = qi . ⇒⇐
The two representations must be identical.

2.2 Congruence and Modular Arithmetic

Definition 2.4. Let n ∈ N. We say a, b ∈ Z are congruent modulo n


iff n | ( a − b). We write a ≡ b (mod n).

Example 2.5.

13 ≡ 83 (mod 10)
736 ≡ −1044 (mod 2)

Theorem 2.14. Rn = {( a, b) ∈ Z2 | n|( a − b)} is an equivalence relation.

Proof. To be proved.

Lemma 2.15. For n ∈ N if a = qn + r for some q ∈ Z, 0 ≤ r < n, then


a ∼ r.

Proof.
a = qn + r
⇒ a − r = qn
⇒n | a = r
⇒( a, r ) ∈ Ri
Example 2.6. Find an integer 0 ≤ k ≤
17 such that
1. 18 ≡ k (mod 17)
18 anna brandenberger, binyuan sun ⇒ k ≡ 1 (mod 17)
2. −18 ≡ (mod 17)
−18 ≡ −1 ≡ 16 (mod 17)

Corollary 2.16. [ a] = [r ] in Rn where r is the remainder of a after division


by n.

Corollary 2.17. The equivalence classes of Rn = {( a, b) ∈ Z2 | n | ( a, b)}


are [0], [1], . . . , [n − 1].

Equivalent statements:

1. a ≡ b (mod n)

2. n | ( a − b)

3. a − b ≡ 0 (mod n)

4. a ∈ [b] ∈ Rn

5. b ∈ [ a] ∈ Rn

6. [ a] = [b] ∈ Rn

Operations

Lemma 2.18. If a ≡ b (mod n) and x ≡ y (mod n) then:

1. ( a ± x ) ≡ (b ± y) (mod n)

2. ax ≡ by (mod n)

Proof.

1. n | ( a − b) and n | ( x − y)
⇒ n | ( a ± x ) − (b ± y)
⇒ ( a ± x ) ≡ (b ± y) (mod n)

2. Note that ax − by = ax − ay + ay − by = a( x − y) + y( x − y)
∵ n | ( x − y) ∧ n | ( a − b)

⇒ n | [ a( x − y) + y( a − b)]
= n | ( ax − by)
= ax ≡ by (mod n)

2x + 3y ≡ 1 (mod 6)
Example 2.7. Solve
 x + 3y ≡ 5 (mod 6)

3x + 6y ≡ 6 (mod 6)
⇒ 3x ≡ 0 (mod 6)
=⇒ x = 0, 2, 4 (mod 6) are the possibilities.
math 240: discrete structures 19

If x ≡ 0 mod 6 ⇒ 3y ≡ 5 (mod 6)
But 3 6 | 3y − 5 ⇒ 6 6 | 3y − 5
So 3y 6≡ 5 mod 6 ∀y ∈ Z

If x ≡ 2 mod 6 ⇒ 2 + 3y ≡ 5 mod 6
⇒ 3y ≡ 3 mod 6
⇒ y ≡ 1 mod 2
Check: y ≡6 0, 1, 6 2, 3, 6 4, 5
ka ≡ kb mod kn ⇔ a ≡ b mod n

If x ≡ 4 mod 6 ⇒ 4 + 3y ≡ 5 mod 6
⇒ 3y ≡ 1 mod 6
But 3 6 | 3y − 1 ⇒ 6 6 | 3y − 1
So no solutions.

 x ≡ 2 mod 6
=⇒ Final Solutions:
y ≡ 1, 3, 5 mod 6(y ≡ 1 mod 2)

Proposition 2.19. If ac ≡ bc mod n and gcd(c, n) ≡ 1, then a ≡ b


mod n.

Proof.

ac ≡ bc mod n Example 2.8. Solve 2x ≡ 1 mod 9


⇒ n | ac − bc 2x ≡ 1 mod 9
⇒ n | c( a − b) ⇒ 2x ≡ 10 mod 9
since gcd(2, 9) = 1
⇒ n | a − b since gcd(c, n) = 1 ⇒ a ≡ b mod n
⇒ x ≡ 5 mod 9

Theorem 2.20. Let n ∈ N, a ∈ Z. Then gcd( a, n) = 1 ⇔ ∃s ∈ Z such


that sa ≡ 1 mod n, where we call s the multiplicative inverse.

Proof.

(⇒) : gcd( a, n) = 1 ⇒ ∃s, t ∈ Z such that sa + tn = 1


⇒ n | (sa − 1)
⇒ sa ≡ 1 mod n

(⇐) : If ∃s, sa ≡ 1 mod n ⇒ ∃q such that sa − 1 = qn


⇒ 1 = sa − qn
If ∃d s.t. d | a and d | n:
⇒ d | 1 ⇒ gcd( a, n) = 1
20 anna brandenberger, binyuan sun

Example 2.9. Find the inverse of 91 mod 190.

190 = 2(91) + 8 Backtracking gives: . . .


91 = 11(8) + 3 1 = (71)(91) − (34)(190)
8 = 2(3) + 2 (71)(91) − 1 = (34)(190)
| {z }
3 = 1(2) + 1 ≡0 mod 190

2 = 2(1) + 0 ⇒ (71)(91) ≡ 1 mod 190


⇒ 91−1 ≡ 71 mod 190
⇔ 71−1 ≡ 91 mod 190
since 190 | (1 − (71)(91))

Example 2.10. Find x such that 2x ≡ 1 mod 9 (cont. Example 2.8),


aka find 2−1 mod 9.

9 = 4(2) + 1 ⇒ 1 = 9 − 4(2)
2 = 2(1) + 0
⇒ (−4)(2) ≡ 1 mod 9
2−1 ≡ − 4 ≡ 5 mod 9

So:
Not using inverse: Why no solutions for g - b? (recall
Using inverse: g = gcd( a, n))
2x ≡ 1 mod 9
2x ≡ 1 mod 9 ax ≡ b mod n
⇒ 10x ≡ 5 mod 9 ⇒ ax − b = kn
⇒ x ≡ (1)(2−1 ) mod 9
⇒ (1) x ≡ 5 mod 9 b = ax − kn
⇒ |{z}
⇒ x ≡ 5 mod 9 g-b
| {z }
divisible by g
⇒ x ≡ 5 mod 9
⇒ no solution.

Solving Algorithm ( ax ≡ b mod n)


1 if gcd( a, n) = 1
2 find a−1 mod n backtracking from Euclidian Algorithm,
3 return x ≡ a−1 b mod n
// simplify to x = z mod n
// all solutions: x = z + nk, k ∈ Z
4 else gcd( a, n) = g 6= 1
5 if g | b  
a b n
6 return Solving Algorithm gx ≡ g mod g
// solution has g equivalence classes mod n
n
// i.e. x ≡ z+ gk mod n where x < n
7 else g - b
8 return no solution.
math 240: discrete structures 21

Example 2.11. Solve if possible:


1. 91x ≡ 10 mod 190
gcd(91, 190) = 1 ⇒ there is a solution. Use 91−1 ≡ 71 mod 190.

91x ≡ 10 mod 190


⇒ x ≡ (10)(91−1 ) mod 190
≡ (10)(71) mod 190
≡ 710 mod 190
≡ 3(190) + 140 mod 190
⇒ x ≡ 140 mod 190

2. 92x ≡ 10 mod 196


gcd(92, 166) = 4 using Euclidian Algorithm.
92 = 22 · 23
4 - 10 =⇒ no solution
196 = 22 · 72

3. 92x ≡ 12 mod 196


gcd(92, 196) = 4: divide both sides of equation and modulus by 4.
23x ≡ 3 mod 49
gcd(23, 49) = 1
⇒ 23−1 exists. Using Euclidian Algorithm:
49 = 2(23) + 3 Backtracking:
23 = 7(2) + 2 1 = 3 − 1(23 − 7(3))
3 = 1(2) + 1 = 8(3) − 1(23)
2 = 2(1) + 0 = 8(49 − 2(23)) − (23)
1 = 3 − 1(2) = 8(49) − 17(23)
1 ≡ 8(49) −17(23) mod 49
| {z }
≡0
1 ≡ (−17)(23) mod 49
−1
⇒ 23 ≡ −17 mod 49
≡ 32 mod 49
So:
What if we wanted all solutions modulo
92x ≡ 12 mod 196 ⇔ 23x ≡ 3 mod 49 196?
Every solution is x = 47 + 49k, k ∈ Z
x ≡ 3(23)−1 mod 49 For k = 0, 1, 2, 3: x = 47, 96, 145, 194.
These correspond to the solution’s
x ≡ 3(32) mod 49 equivalence classes mod 196.
⇔ x ≡ 96 mod 49 x ≡ 47, 96, 145, 194 mod 196

⇔ x ≡ 47 mod 49
22 anna brandenberger, binyuan sun

Theorem 2.21 (Fermat’s Little Theorem). If p is a prime and a is any in-


teger, then a p−1 ≡ 1 mod p. (As a consequence: a p ≡ a mod p.) We can
use this to quickly simplify large powers mod p.

Proof. Later (posted).

Simplifying Algorithm ( a x mod p)


Example 2.12. Find 239674 mod 523 1 if p prime
We can check 523 is prime. 2 Rewrite x = q( p − 1) + r
// q ∈ Z, 0 ≤ r < p
Rewrite 39674 by dividing by 522: 39674 = 76(522) + 2.
3 return a x ≡ aq( p−1)+r
 q
239674 ≡ 2(76)(522)+2 mod 523 ≡ a p−1 ar mod p

2522 )76 ∗ 22
≡ ( |{z} mod 523 ≡ ar mod p

≡1 by FLT

≡ (1)76 4 mod 523 ≡ 4 mod 523

Example 2.13.

47625377 mod 13 ≡ [336(13) + 4]5367


≡ 45367 mod 13
(447)(12)+3
≡4 mod 13
12 447
≡ ( (4) ) ∗ 43 mod 13
| {z }
≡1 by FLT

≡ 64 mod 13
≡ 12 mod 13

Example 2.14. Show x97 − x − 1 ≡ 0 mod 97 has no solution.

x97 ≡ x mod 97 (FLT)


x−x+1 ≡ 0 mod 97 =⇒ 1 ≡ 0 mod 97
1 6≡ 0 mod 97 ⇒⇐
=⇒ no solution
end of material for midterm 1

2.3 RSA Encryption


Notes posted.
math 240: discrete structures 23

3 Combinatorics
Glorified counting. How do we count?
3.1 Proof by Induction

Definition 3.1. Induction is used to prove a statement S(n) is true for


all n ∈ N by proving:

1. Base case: S(1) true,

2. Inductive step: S(n) ⇒ S(n + 1). Example 3.2. Prove that the sum of odd
n
integers ∑ (2i − 1) = n2 .
why does this work — ? S (1) ⇒ S (2) ⇒ S (3) ⇒ . . . i =1

n ( n +1) 1=1
Example 3.1. Prove 1 + 2 + 3 + · · · + (n − 1) + n = 2 for n ∈ N 1+3 = 4
(1)(2) 1+3+5 = 9
Proof. Base Case: n = 1: 1 = 2 X 1 + 3 + 5 + 7 = 16
n ( n +1)
Inductive Step: Assume 1 + 2 + ... + n = 2 (hypothesis). 1
(n+1)(n+2) Proof. Base case: n = 1: ∑ (2i − 1) = 1
Show 1 + 2 + · · · + (n + 1) = 2
i =1
Inductive step :
n
Assume ∑ (2i − 1) = n2
n ( n + 1) i =1
1 + 2 + · · · + ( n ) + ( n + 1) = + ( n + 1) n +1
2 Show =⇒ ∑ (2i − 1) = (n + 1)2
n i =1
= (n + 1)( + 1)
2 n n

(n + 1)(n + 2) ∑ (2i − 1) = n2 = ∑ (2i − 1)


= i =1 i =1
2 = n2 + [2( n + 1) + 1]
= n2 + 2n + 1
n
Example 3.3. Prove ∑ (i )(i!) = (n + 1)! − 1 = ( n + 1)2
i =0
Note: this is a statement taking n ≥ 0 (an integer) as the variable.
Example 3.4. n! ≥ 2n ∀ n ≥ 4.
n
Proof. Base case: n = 0 ∑ (i )(i!) = 0 X Proof. Base case: n = 4: 24 > 16 X
i =0 Inductive step: Assume n! > 2n
n
(n + 1)! = (n!)(n + 1) > (n!)(2)
Inductive step: Assume ∑ (i )(i!) = (n + 1)! − 1
i =0 = (n!)(n + 1) > (2n (2)) = 2n+1
n+!
Show =⇒ ∑ (i )(i!) = (n + 2)! − 1
i =0

n +1 n Example 3.5. Prove 5 | 8n − 3n for all


∑ (i)(i!) = ∑ (i)(i!) + (n + 1)(n + 1)! n ≥ 0.
i =0 i =0
Proof. Base case: n = 0: 5 | 80 − 30 X
= [(n + 1)! − 1] + (n + 1)(n + 1)! Inductive Step: Assume 5 | 8n − 3n
= (n + 1)![1 + (n + 1)] − 1 8n +1 − 3n +1 = 8 (8n ) − 3 (3n )
= ( n + 1) ! ( n + 2) − 1 = (5 + 3)(8n ) − 3(3n )

= ( n + 2) ! − 1 = 5 (8n ) + 3 (8n − 3n )
5 | 5 (8 ) ∧ 5 | 3 (8n − 3n )
n

⇒ 5 | 8n +1 − 3n +1
24 anna brandenberger, binyuan sun

Example 3.6. Call a rotation of a "tromino". Take a (2n × 2n )


checkerboard (n ≥ 1) and delete any tile (square). Prove you can tile
it with trominos.
Figure 6: Base case.
Proof.

Base Case: n = 1:
With a square removed from a (2 × 2) board, the remaining part is
exactly one tromino piece. X 2n +1

Inductive Step: Assume true for n, show true for n + 1: 2n

Consider a (2n+1 × 2n+1 ) board. Place a tromino in the middle


(one block covered - i.e. removed - in 3 of the 4 quadrants). Re- 2n
move one block from the fourth quadrant. Now each of the 4 Figure 7: Inductive step.
2n × 2n boards can be tiled (by Inductive Hypothesis).

Example 3.7. Prove that a set with n elements has 2n subsets.

Proof. Base case: n = 0: ∅ has 1 subset, 1 = 20 . X

Inductive Step: Assume true for n. Let A be a set with n + 1 elements


(write | A| = n + 1). Let x ∈ A, B = A \ { x }. B has 2n subset by IH.
For each X ⊆ B, X and ∪{ x } are distinct subsets of A.
⇒ 2n + 2n = 2(2n ) = 2n+1 subsets.

Common Mistakes

1. Finding incorrect patterns.


claim: n2 + n + 41 is prime for all n ≤ 0. The proof works until
n = 39 but at n = 40, 402 + 40 + 41 = 412

2. Forgetting the base case.


claim: n(n + 1) is odd for all n ≥ 1.
Assume true for n.
(n + 1)(n + 2) = n(n + 1) + 2(n + 1) ∴ odd
| {z } | {z }
odd even
but this is false: We forgot the base case: n = 1 ⇒ (1)(2) =
2 ODD


3. Making an unstated (wrong) assumption.


claim: All cows are the same colour.
Let Cn denote a set of n cows.

Base case: n = 1: Any set of 1 cow has uniform colour.


math 240: discrete structures 25

Inductive Step: Assume true for any Cn . Look at {c1 , c2 , . . . , cn+1 }.


By IH, {c1 , c2 , . . . , cn } all have same colour. By IH, {c1 , c2 , . . . , cn+1 }
all have same colour.

problem: S(1) 6⇒ S(2) because {c1 } ∩ {c2 } = ∅ (the two sets


share no common cow when n = 2).
We have base case n = 1 but the statement is false when n = 2.

Definition 3.2. Strong Induction is a variation of induction in which


we assume that the statement holds for all values preceding n, i.e.
one proves:

1. S(1) true

2. (S(1) ∧ S(2) ∧ · · · ∧ S(n)) ⇒ S(n + 1)

Example 3.8. Prove that any square can be partitioned into n ≥ 6


non-empty squares.

Proof. Example 3.9. Prove that for any n ≥ 18,


∃ x, y, ∈ N ∪ {0} s.t.
n = 4x + 7y

Proof. Base case: n = 18, 19, 20, 21


18 = 4(1) + 7(2)
Base case: n = 6 n=7 n=8 19 = 4(3) + 7(1)
20 = 4(5) + 7(0)
Inductive Step: Assume true for all integers k, 6 ≤ k ≤ n (n ≥ 8).
21 = 4(0) + 7(3)
Show true for n + 1. By I.H., true for n − 2. Take one square and
I.H. Assume true ∀ 18 ≤ k ≤ n,
quarter it, giving (n − 2) − 1 + 4) = n + 1.
(n ≥ 21)
By I.H. ∃ x, y, ∈ N ∪ {0} s.t. n − 3 =
Example 3.10. Prove every n ∈ N can be written as 4 + 7y ⇒ n + 1 = 4( x + 1) + 7y.

n = a0 20 + a1 21 + · · · + ak 2k

for some k ∈ N ∪ {0}, where ai ∈ {0, 1}∀i. i.e. every n can be written in binary.

Proof. Base case: n = 1 ⇒ 1 = (1)20 X

Inductive Step: Assume true for all 1 ≤ k ≤ n − 1, prove true for n:

1. If n is odd, n − 1 is even. Thus n − 1 = (0)20 + a1 21 + · · · + ak 2k


for some k (by I.H.) ⇒ n = 1(2)0 + a1 21 + · · · + ak 2k .
2. If n is even, look at n2 . n2 = a0 20 + · · · + ak 2k by (I.H.)
⇒ n = a 0 21 + · · · + a k 2 k + 1 .
26 anna brandenberger, binyuan sun

3.2 Recursion

Definition 3.3. A sequence { a1 , a2 , . . . } is a recurrence relation if an


is a function of { a1 , a2 , . . . , an−1 }.

notation: The first term can be for any k ≥ 0. A finite number of


initial values must be given. a0 = 1
a1 = (1) a2 = 1
Example 3.11. Let a0 = 1, an = nan−1 , n ≥ 1. Prove an = n! a2 = (2) a1 = 2(1)
a3 = (3) a2 = (3)(2)(1)
Proof. Base case: n = 0 X

Inductive Step: Assume an = n!

⇒ an+1 = (n + 1) an = (n + 1)n! = (n + 1)! Example 3.13. Prove an = (n + 1)2n



√  a0 = 1

Example 3.12. Let a1 = 1, an = 6 + an−1 , n ≥ 2. Prove an < 3. where a1 = 4

an = 4an−1 − 4a−2 , n ≥ 2

Proof. Base case : n = 1 ⇒ a1 = 1 < 3.
Proof. Base cases: n = 0, 1.
Inductive Step: Assume true for n ( a n < 3 ) X.
n = 0: (1) = (0 + 1)20

a n +1 = 6 + an n = 1: (4) = (1 + 1)21

< 6+3 = 3 Inductive Step: Assume true for all
k, 1 ≤ k ≤ n.

an+1 = 4an − 4nn−1


Definition 3.4. Fibonacci numbers. = 4 ( n + 1 )2n − 4 ( n )2n −1
= 4 · 2n −1 [ 2 ( n + 1 ) − n ]
f 1 = 1, f 2 = 1, f n = f n −1 + f n −2 , ( n ≥ 3)
= 2n +1 ( n + 2 )

Example 3.14. How many subsets of {1, 2, 3, . . . , n} contain no con-


secutive integers? Let S denote the number of such subsets from
{1, . . . , n}.

Sn = (# with n) + (# without n) = Sn−2 + Sn−1 n = 1: {1}, 2 : ∅, {1}


n = 2: {1, 2}, 3 : ∅, {1}, {2}
Sn−2 because because if n is in the set, n − 1 is not and we are count- n = 3: {1, 2, 3}, 5 : ∅, {1}, {2}, {1, 3}
ing subsets from {1, . . . , n − 2}; and Sn−1 because if n is not in, then
we count subsets from {1, . . . , n − 1}. =⇒ Sn is f n+2 .

Some proofs about { f n }∞


n =1

Theorem 3.1. f 1 + f 2 + · · · + f n = f n+2 − 1

Proof. Base case: n = 1 ⇒ f 1 = f 3 − 1 = 2 − 1 X

Inductive Step: Assume true for n. Want f 1 + f 2 + · · · + f n + f n+1 =


f n +3 − 1

f 1 + f 2 + · · · + f n + f n +1 = f n +2 − 1 + f n +1
= f n +3 − 1
math 240: discrete structures 27

P(n) : f n+1 f n + f n f n−1 = f 2n


Theorem 3.2.
Q(n) : f n2 + f n2−1 = f 2n−1

Proof. For now, omit base cases: computation.


Assume P(n) and Q(n) true, =⇒ Prove Q(n + 1) true.

f n2+1 + f n2 = ( f n + f n−1 )2 + f n2
= f n2 + 2 f n f n−1 + f n2−1 + f n2
= ( f n2 + f n2−1 ) + f n f n−1 + f n f n−1 + f n2
= f 2n−1 + f n f n−1 + f n ( f n−1 + f n )
= f 2n−1 + f n f n−1 + f n f n+1
= f 2n−1 + f 2n = f 2n+1
P(n + 1) true?
f n +2 f n +1 + f n +1 f n = ( f n +1 + f n ) f n +1 + ( f n + f n −1 ) f n
= f n2+1 + f n f n+1 + f n2 + f n f n−1
= f n2+1 + f n2 + f n f n+1 + f n f n−1
| {z } | {z }
Q ( n +1) P(n)

= f 2n+1 + f 2n
= f 2n+2

3.3 Solving Recurrence Relations

Definition 3.5. The characteristic polynomial of an = ran−1 + san−2 Example 3.15. Consider an = an−1 +
is x2 − rx − s. Its roots α, β are the characteristic roots of the relation. 2an−2 , a0 = 2, a1 = 1

a0 = 2 a1 = 1 a2 = 5 a3 = 7 a4 = 17
Theorem 3.3. Consider an = ran−1 + san−2 with specified a0 , a1 . If x2 − a5 = 31 a6 = 65 a7 = 127

rx − s has 2 distinct roots α, β then ···


an = 2 + (−1)n ?
n

n n
a n = c1 α + c2 β We could prove this by induction, but
we would rather have a method more
where c1 and c2 solve a0 = c1 + c2 , a1 = c1 α + c2 β. rigorous than "guess and check".

Proof. Show an = c1 αn + c2 βn solves the relation an = ran−1 + san−2

c 1 α n + c 2 β n = r [ c 1 α n −1 + c 2 β n −1 ] + s [ c 1 α n −2 + c 2 β n −2 ]
c1 αn − rc1 αn−1 − sc1 αn−2 = −c2 βn − rc2 βn−1 − sβn−2
c1 αn−2 [α2 − rα − s] = −c2 βn−2 [ β2 − rβ − s]
0=0X
a n = c1 α n + c2 β n
n=0: a0 = c1 + c2
n=1: a1 = c1 α + c2 β
28 anna brandenberger, binyuan sun

Example 3.16. (Back to Example 3.15) an = an−1 + 2an−2


⇒ x2 − x − 2 = 0 = ( x + 1)( x − 2) ⇒ let α = 2, β = −1
an = c1 2n + c2 (−1)n
n=0: a0 = c1 + c2 ⇒ 2 = c1 + c2
n=1: a1 = 2c1 − c2 ⇒ 1 = 2c1 − c2 Example 3.17. Fibonacci sequence
f n = f n−1 + f n−2 , f 0 = 0, f 1 = 1
Characteristic polynomial: x2 − x − 1
⇒ c1 = 1, c2 = 1 ⇒ an = 2n + (−1)n
√ p
1± 1+4 1 ± (5)
x= =
2 2
√ √
What about relations of the form an = ran−1 + san−2 + tan−2 ( or 1+ 5 1− 5
⇒α = ,β =
higher "order")? — Look at a characteristic polynomial whose degree 2

2

is equal to the order of the recurrence. 1+ 5 n 1− 5 n
f n = c1 ( ) + c2 ( )
2 2
Example 3.18. an = 6an−1 − 11an−2 + 6an−3 , a0 = 2, a1 = 5, a2 = 15 1
⇒ c1 = √ , c2 = − √
1
C.P. x3 − 6x2 + 11x − 6 has three roots: α = 1, β = 2, γ = 3 5 5
√ √
1 1+ 5 n 1 1− 5 n
⇒ an = c1n + c2 (2)n + c3 (3)n ⇒ fn = √ ( ) −√ ( )
5 2 5 2
n=0: 2 = c1 + c2 + c3
n=1: 5 = c1 + 2c2 + 3c3
n=2: 15 = c1 + 4c2 + 9c3
    
1 1 1 2 1 0 0 1  c1 = 1


Solve 1 2 3 5  ∼ 0 1 0 −1 ⇒ c2 = −1
   

1 4 9 15 0 0 1 2 

c =2 3

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

Theorem 3.4. The recurrence relation an = ran−1 + san−2 + f (n) has so- Note: the method for finding pn is the
equivalent of the constant coefficient
lution pn + qn where pn is a particular solution of the recurrence (ignoring method for finding a particular solution
initial conditions) and qn is the general solution to an = ran−1 + san−2 , to a homogeneous second order ODE,
i.e. guess a solution.
where constants c1 , c2 in qn are found from initial conditions.

Example 3.19. an = 2an−1 + 3an−2 + 5n ⇒ guess pn = c5n


c5n = 2c5n−1 + 3c5n−2 + 5n
25c = 10c + 3c + 25 25 n
⇒ pn = (5 )
25 12
12c = 25 ⇒ c =
12

an = 2an−1 + 3an−2
x2 − 2x − 3 = 0
( x − 3)( x + 1) = 0
α = 3, β = −1
qn = c1 3n + c2 (−1)n
25 n
⇒ pn + qn = (5 ) + c1 3n + c2 (−1)n
12
math 240: discrete structures 29

Solve for c1 and c2 :


25 
n=0: −2 = + c1 + c2 c = − 27
12 ⇒
1 8
125 c2 = − 17
n=1: 1= + 3c1 − c2 24
12
25 n 27 17
an = (5 ) − (3n ) − (−1)n
12 8 24
Example 3.20. an = 2an−1 + 3an−2 + 5n, a0 = 0, a1 = 1
As above, qn = c1 3n + c2 (−1)n
Guess pn = An + B

An + B = 2A(n − 1) + 2B + 3A(n − 2) + 3B + 5n
0 = (−2 − 6) A + (−1 + 2 + 3) B + (−n + 2n + 3n) A + 5n
= 4B − 8A + 4An + 5n = (4B − 8A) + (4A + 5)n
5
4A + 5 = 0 ⇒ A = −
4
5
4B − 8A = 0 ⇒ B = −
2
5 5
pn = − n −
4 2
5 5
an = − n − + c1 3n + c2 (−1)n
4 2
5 
n = 0 : 0 = − + c1 + c2 c = 29
2 ⇒
1 16
5 5 c2 = 11
n = 1 : 1 = − − + 3c − c 2 16
2 4
5 5 29 11
⇒ an = − n − + 3n + (−1)n
4 2 16 16

3.4 Functions
A function f from X to Y, written f : X → Y is a binary relation
Figure 8: Surjective (non injective) map.
f ⊂ X × Y such that for every x ∈ X, there is at most one y ∈ Y such
that ( x, y) ∈ f . Since y is unique for x we can write y = f ( x ).

Definition 3.6. A surjection is a relation where ∀y ∈ Y ∃ x ∈ X s.t.


y = f ( x ). ( f is "onto".)

Figure 9: Injective (non surjective) map.


Definition 3.7. A injection is a relation where ∀y ∈ Y ∃ at most one
x ∈ X s.t. y = f ( x ). ( f is "one to one".)

Definition 3.8. A bijection is a relation where ∀y ∈ Y ∃!x ∈ X s.t. y =


f ( x ). ( f is both surjective and injective.)

Figure 10: Bijective map.


30 anna brandenberger, binyuan sun

Relation to counting: Recall | x | denotes the cardinality of X (the


number of elements)

1. ∃ a surjection, f : X → Y ⇔ | X | ≥ |Y |

2. ∃ an injection, f : X → Y using every element of X ⇔ | X | ≤ |Y |

3. ∃ a bijection, f : X → Y ⇔ | X | = |Y |

3.5 Counting
Counting objects/structures.
Principles of counting:
n Translated Princips of Counting:
1. | A1 ∪ A2 ∪ · · · ∪ An | = ∑ | Ai | Ai : ways in which a task can be done.
i =1
1. The number of ways which a collec-
if each pair ( Ai , A j ) is disjoint (Ai ∩ A j = ∅)
tion of tasks can be done if no two
n sets of ways of completing the tasks
2. | A1 × A2 × · · · × An | = ∏ | Ai | overlap is the sum of ways of the
i =1 numbers of ways each task can be
done.

Example 3.21. How many 4 digits number have no repeated digits? 2. The number of ways a sequence of
tasks can be done is the product of
the number of ways each task can be
Answer. The tasks are to choose each digit: 9 × 9 × 8 × 7 = 4536. done.
Since the first digit can’t be 0.

Example 3.22. How many 4 digit even numbers have no repeated


digits?

Answer. We split into 2 cases:

1. Last digit is 0: 9 × 8 × 7 × 1 = 504

2. Last digit is not 0: 8 × 8 × 7 × 4 = 1792

Total: 2296.

Some Questions:

1. How many functions are there from an n-set to a k-set? ("m-set" =


set with m elements)
Sequence of events: let | X | = n, |Y | = k. For each x ∈ X, choose
y ∈ Y such that y = f ( x ).
Number of functions: k × k × · · · × k = kn .
| {z }
n times

2. How many subsets of an n-set are there?


Sequence of events: take each element and decide to put it in the
subset or not: n tasks with 2 possibilities each.
Number of subsets: 2 × 2 × · · · × 2 = 2n .
| {z }
n times
math 240: discrete structures 31

3. How many bijections are there from an n-set to itself?


1st element has n possible functions values. 2nd element has n − 1
(since it’s a bijection). Etc.
Number of bijections: (n)(n − 1)(n − 1) . . . (2)(1) = n!

Definition 3.9. A permutation of an n-set is an ordering of its ele- X = {1, 2, 3, 4}


ments. This is precisely the same as a bijection, so there are n! per- BIJ: {(1, 4), (2, 1), (3, 2), (4, 3)}
PERM: 4123
mutations of an n-set.

Example 3.23. How many ways can you choose a president, vice
president, treasurer, secretary from a group of 7 people?
7!
P(7, 4) = 3! = 840

Definition 3.10. A k-permutation of an n-set X is a choice of k ele-


ments of X in some order. There are P(n, k) such k-permutations:

n!
4. P(n, k) = (n)(n − 1) · · · (n − k + 1) = (n−k)!

5. How many subset of size k does an n-set have?


Count the number of k-permutations again = (# of k-subsets)(k!)
n!
P(n, k ) = (n− k)!
= (# of k-subsets)(k!)
n!
⇒ number of k-subsets = k!(n−k )!

Definition 3.11. C (n, k) = (nk) = n!


k!(n−k )!
pronounced "n choose k"

n
Proposition 3.5. (nk) = (n− k)

n
Proof. 1. (n− k) =
n!
(n−k)!(n−(n−k))!
= n!
(n−k)!k!
= (nk)
2. Choosing k elements to be in your set is equivalent to choosing the
n − k elements in its complement.

3.6 The Binomial Theorem

Theorem 3.6. The Binomial Theorem says that if n ≥ 1 is an integer,


n  
n
( x + y)n = ∑ k x k yn−k
k =0

where (nk) are called binomial coefficients.

Proof. For a positive integer n, what is the coefficient of x k yn−k in


( x + y)n ? ( x + y)( x + y) · · · ( x + y)
How many ways can we choose k x’s from the n factors and n − k
y’s, choosing one variable from each factor? We only need to count
the number of ways to choose x’s (get y’s for free). Thus the coeffi-
cient of x k yn−k is (nk).
32 anna brandenberger, binyuan sun

n
Lemma 3.7. ∑ (nk) = 2n .
k =0

Proof. Two methods:

Binomial Theorem: Let x = y = 1:


n  
n
( x + y ) n = 2n = ∑ k (1)(1)
k =0

Combinatorially:
       
n
n n n n
2 = + +···+ +
0 1 n−1 n

where 2n is the number of subsets of an n-set, and (ni) is the num-


ber of subsets with cardinality i.

Lemma 3.8. An n-set, n ≥ 1, has the same number of even subsets as odd
subsets.

Proof. Combinatorially: Fix some element x.

# odd subsets with x = # even without x


# odd subsets without x = # even with x

# odd = # even

Binomial Theorem: Pick x = −1, y = 1.


n
(−1 + 1)n = ∑ (−1)k (1)n−k
k =0

         
n n n n n
− + 0= − + +...
0 1 2 3 4
         
n n n n n
+ +... = + + +...
1 3 0 2 4

Lemma 3.9. (nk) = (n− 1 n −1


k ) + ( k −1 )

Proof. (nk) is the number of subsets of size k. Define some k. (n− 1


k ) is
−1
the number of such subsets without x, and (nk− 1 ) is the number of
such subsets including x.
n
2
Lemma 3.10. ∑ (nk) = (2n
n)
k =0
math 240: discrete structures 33

Proof. Rewrite what we want to prove:


          
2n n n n n n n
= + + +···
n 0 0 1 1 2 2
          
2n n n n n n n
= = + +···+ +···
n 0 n 1 n−1 k n−k

{1, . . . , 2n} = {1, . . . , n} ∪ {1, . . . , n}

(2n
n ): number of n-subsets

(nk)(n−
n
k ): number of ways to choose k elements from {1, . . . , n } and
the rest from {n + 1, . . . , 2n}.

Repetitions

1. If order matters:

Proposition 3.11. Let a1 , a2 , · · · , an be a set of elements that can be decom-


posed into K subsets of elements that are repeated ik times (1 ≤ k ≤ K), i.e.
each subset has size ik , ∑ ik = n. The number of permutations is Kn! .
∏ k =1 i k !

Example 3.24. How many anagrams of EASY are there? 4!


What about CHEESE? Not 6! since we have repetition.
If we take C1 H1 E1 E2 S1 E3 we get 6! = (# of anagrams of CHEESE)(3!),
6!
⇒ # of anagrams of CHEESE = 3!
Visualize "Balls & Boxes" as choosing
For MISSISSIPPI, # of anagrams = (1!)(4!11!)(4!)(2!) the positions for the n − 1 separations
between boxes, between n − 1 + k
2. If order doesn’t matter: possible positions (positions include
elements and separation lines).
Proposition 3.12. "Balls & Boxes": The number of ways one can distribute
k identical balls between n boxes corresponds to a binary string of length
k −1 n + k −1
n + k − 1 with n − 1 1’s & k 0’s, i.e. (n+
n −1 ) = ( k ). Example 3.26. A sandwich shop offers
3 kinds of bread, 4 kinds of meat and 10
kinds of toppings.
Example 3.25. Jim’s Morton’s offers 30 kinds of Jimbits. How many (a) How many possibilities are there if
each sandwich has 1 bread, 1 meat
ways can you choose a dozen? and 3 toppings ?
12−1 Answer. Number of possible
Answer. (30+29 )
sandwiches: (31) × (41) × (10
3 ) = 1440

How many platters?


Example 3.27. How many non-negative integers solutions are there Answer. 1440 boxes, 20 balls.
20−1
to the equation: x1 + x2 + x3 = 48 ? (1440+
20 ) ≈ 6.89 × 1044
(b) What if you may now use at
Answer. 48 balls, 3 boxes: (48+33−1) = 1225 most 1 bread, 2 meats and any of
toppings?
What if we impose x1 ≥ 2 and x3 ≥ 5? Answer. Number of possible
sandwiches: (31) × [(40) + (41) + (42)] ×
Answer. Let y1 = x1 − 2, y2 = x2 , y3 = x3 − 5 210 = 33972
(41+23−1) = 903 Number of platters: (3378220 +20−1
)≈
1.55 × 1072
34 anna brandenberger, binyuan sun

Example 3.28. How many (non-negative) solutions are there to the


equation: x1 x2 x3 = 48 ?

Answer. Notice 48 = 2 × 2 × 2 × 2 × 3. So we distribute four 2’s to


three boxes, and distribute one 3 to three boxes. (4+32−1) × 3 = 45.

Counting Elements in Sets


Example 3.29. 40 students: where 10 in
ANTH, 22 in BIOL, 16 in COMP; 6 in
i.e. How to count the amount of elements in sets | A1 ∪ A2 ∪ · · · ∪ An | A&B, 8 in B&C, 4 in A&C; and 2 in all.
if these sets are not disjoint? How many students are not enrolled in
any of the 3 courses?
n = 2: | A1 ∪ A2 | = | A1 | + | A2 | − | A1 ∩ A2 | i.e. first find how many in at least one:
| A1 ∪ A2 ∪ A3 | = | A1 | + | A2 | + | A3 | −
n = 3: | A1 ∪ A2 ∪ A3 | = | A1 | + | A2 | + | A3 | − | A1 ∩ A2 | − | A2 ∩ A3 |
| A1 ∩ A2 | − | A2 ∩ A3 | − | A1 ∩ A3 | +
− | A1 ∩ A3 | + | A1 ∩ A2 ∩ A3 | | A1 ∩ A2 ∩ A3 | = (10 + 22 + 16) − (6 +
8 + 4) + 2 = 32
∴ There are 40 − 32 = 8 students in
Theorem 3.13. Principle of Inclusion-Exclusion (PIE). none of the courses.
If A1 , A2 , . . . , An are finite sets, then:

∑ (−1)|S|−1 |
\
| A1 ∪ A2 ∪ · · · ∪ A n | = Ai |
S⊆[n] i ∈S
Here [n] represents [1, . . . , n].
S6=∅

Proof. Must show every x ∈ A1 ∪ · · · ∪ An is counted exactly once on


the RHS. Say x appears in k of the sets A1 ∪ · · · ∪ An . x is counted in
collections of 1 set k times, of 2 sets (2k ) times, of 3 sets (3k ) times, ...
So x counted (1k ) − (2k ) + (3k ) − (4k ) + · · · + (−1)k−1 (kk) times in total.
Recall
         
n n n n n
− + − + +··· = 0
0 1 2 3 4
Therefore we take
         
k k k k k −1 k
− + − + · · · + (−1) =1
1 2 3 4 k
so each x is counted once.

Example 3.30. n people put their phones in a box. If every person


takes a phone out, how likely is it that no one gets their phone back?
The number of permutations of [n] (or bijections from [n] → [n])
where no element is mapped to itself is denoted Dn , they are called
derangements.
Let Ai = Set of permuttions which map i to itself.

Dn = | A 1 ∩ A 2 ∩ · · · ∩ A n |
= | A1 ∪ A2 ∪ · · · ∪ A n |
= n! − A1 ∪ A2 ∪ · · · ∪ An
math 240: discrete structures 35

However,

| S | = A1 ∪ A2 ∪ · · · ∪ A n
= (| A1 | + | A2 | + . . . ) − (| A1 ∩ A2 | + | A1 ∩ A3 | + . . . ) + . . .
     
n n n −1 n
= n · ( n − 1) ! − ( n − 2) ! + (n − 3)! + · · · + (−1) (n − n)!
2 3 n
n! n! n!
= n! − + + · · · + (−1)n−1
2! 3! n!
(−1) −1
n
 
1 1
= n! 1 − + + · · · +
2! 3! n!
(−1)n−1
 
1 1
Dn = n! − n! 1 − + + · · · +
2! 3! n!
(−1)n
 
1 1
= n! 1 − 1 + − + · · · +
2! 3! n!
(−1)n
 
1 1 1 1
= n! − + − +···+
0! 1! 2! 3! n!
n
(−1)k
= n! ∑ k!
k =0

So calculating the probability: Recall e x = ∑ xk
k! x∈R
k =0
Dn Dn
P(a permutation is a derangement) = =
# permutations n!
n
(−1)k
= ∑ k!
= e −1
k =0

So, as n → ∞, P ≈ e−1 ≈ 0.36788, and Dn ≈ n!


e .

Theorem 3.14. Pigeon Hole Principle (PHP). If one distributes > n ob-
jects to n boxes, some box has more than one object.

Example 3.31. 22 soccer players on a field measuring 42m × 98m.


Show there are two players no more than 20m apart.

Answer. Cut the field into 21 boxes of size 14 × 14 m. There are 21


boxes and 22 players, therefore 2 players must be in the same square
√ √ √ √
by PHP. d ≤ 142 + 142 = 196 + 196 < 400 = 400 = 20.

Example 3.32. Let S be a set of 9 points in R3 each with integer


coordinates. Show ∃ pi , pi ∈ S such that the midpoint of p1 p2 has
integer coordinates.
x y z
E E E
Answer. Let pi = ( xi , yi , zi ), p j = ( x j , y j , z j ). E E O
x +x y +y z +z
Want i 2 j , i 2 j , i 2 j ∈ Z ⇔ xi + x j , yi + y j , zi + z j even. E O E
O E E
The possible parity combinations are shown in Table 6. E O O
O E O
O O E
O O O
Table 6: Table for Example 3.32
36 anna brandenberger, binyuan sun

8 parity combinations, 9 points ⇒ 2 have same parity, i.e.

xi ≡ x j mod 2 yi ≡ y j mod 2 zi ≡ z j mod 2

Therefore xi + x j , yi + y j , zi + z j are all even.

Example 3.33. Show that if n + 1 numbers are chosen from [2n], then
there are

(a) 2 which differ by 1:

Answer. Boxes: {1, 2}, {3, 4}, {5, 6}, . . . , {2n − 1, 2n}
n boxes, n + 1 choices, therefore 2 integers in same box by PHP
which differ by 1.

(b) 2 which sum to 2n + 1:

Answer. Boxes: {1, 2n}, {2, 2n − 1}, {3, 2n − 2}, . . .


Each pair sums to 2n + 1. 2 of the n + 1 choices lie in one box by
PHP.

Proposition 3.15. Strong version of PHP: If one has m > n, m objects, n


boxes, then some box receives ≥ d m
n e objects.

Example 3.34. 16 students, in 18 chairs. Show there are 6 consecutive


occupied seats.

Answer. Split into 3 blocks of 6 chairs. Distribute 16 people across 3


boxes therefore the same box must gets ≥ d 16 3 e = 6 people.

Example 3.35. A student has 37 days to prepare for an exam. If she


studies no more than 60 hours, but at least 1 hour each day, show
there is some set of consecutive days over which she studied exactly
13 hours (whole hours each day).

Answer. Let si = number of hours studied n day i. Let ai = s1 + s2 +


· · · + si (number of hours studied from day 1 to day i).

1 ≤ a1 < a2 < · · · < a37 ≤ 60

14 ≤ a1 + 13 < a2 + 13 < · · · < a37 + 13 ≤ 73

Consider the list a1 , a2 , . . . , a37 , a1 + 13, a2 + 13, . . . , a37 + 13. There are
74 integers between 1 and 73 therefore 2 must be the same. ⇒ i, j s.t.
ai = a j + 13 ⇔ ai − a j = 13 ⇔ s j+1 + s j+2 + · · · + si = 13
math 240: discrete structures 37

4 Graph Theory

4.1 Introduction

Definition 4.1. A graph G is a pair (V, E) where V is a set (whose


elements are the vertices of the graph) and E is a set of unordered
pairs of elements of V (called the edges of G). Figure 11: Bridges of Königsberg: can
you start anywhere in the city, cross
every bridge exactly once and finish
We often write V ( G ) and E( G ) for the vertices/edges if G = (V, E). where you started?
Also, for brevity, we write uv ∈ E( G ) for the edge {u, v}. v1
v1 v2
v4
Example 4.1. V = {v1 , v2 , v3 , v4 }
E = { v1 v2 , v1 v3 , v1 v4 , v2 v3 , v2 v4 , v3 v4 } v3 v2 v4 v3
Figure 12: These two figures represent
Uses of Graphs: identical graphs (the one in Exer-
cise 4.1).
1. Routing problems: V = locations, E = direct passage between Graphs are often represented pictorially
where V ( G ) is a set of points or dots,
locations.
and each edge is a segment or curve
between points; but a drawing of a
2. Social networks: V = users, E = friends. graph is not the graph itself.

3. Scheduling: V = events, E = pairs of events which cannot coin-


cide.

Definition 4.2. Given v ∈ V ( G ) and e ∈ E( G ), if v ∈ e, then we say


that e is incident to v. If uv ∈ E( G ), we say that u and v are adjacent
(neighbours).

Definition 4.3. The neighbourhood of v ∈ V ( G ) is:


N (v) = {u | uv ∈ E( G )}

Definition 4.4. The degree of v ∈ V ( G ) in G is d(v) = | N (v)|. We


can also write this as deg(v), or NG (v), dG (v) which make it clear to
which graph one is referring. In general, 0 ≤ degG (v) ≤ |V ( G )| − 1

Definition 4.5. The degree sequence of G is a list of the degrees (in


increasing order).

Theorem 4.1. If G is a graph, then ∃u, v ∈ V ( G ) s.t. d(u) = d(v).

Proof. Case 1: Suppose deg(u) 6= 0 ∀u ∈ V ( G ). Let |V ( G )| = n.


Then 1 ≤ deg(n) ≤ n − 1. There are n vertices and n − 1 possible
degrees. By PHP, two vertices have the same degree.

Case 2: ∃u s.t. deg(n) = 0. Then 0 ≤ deg(n) ≤ n − 2. n − 1 possible


degrees & n vertices, so 2 must have the same degree by PHP.
38 anna brandenberger, binyuan sun

Lemma 4.2 (Handshaking Lemma). In any graph G, there is an even


number of vertices with odd degree.

Theorem 4.3. If G is a graph, then ∑v∈V (G) deg(v) = 2| E( G )|

Proof. Count the number of pairs (v, e) such that e is incident to v.


Each vertex v appears deg(v) times in the set of pairs. Each edge
appears exactly twice.

∑ deg(v) = ∑ 2 = 2| E( G )|
v ∈V ( G ) e∈ E( G )

Proof. of Handshaking Lemma (Lemma 4.2).

∑ deg(v) + ∑ deg(v) = 2| E( G )|
v ∈V ( G ) v ∈V ( G )
| {z }
even
deg(v) odd deg(v) even
| {z }
even

Special graphs:

• empty graph: E( G ) = ∅

• complete graph: E( G ) = all possible pairs: Figure 13: Complete Graphs.

– denoted Kn if |V ( G )| = n
– | E(Kn )| = (n2 ) [in general, 0 ≤ | E( G )| ≤ (n2 )]

• complete bipartite graph Km,n where :

– V (Km,n ) = {u1 , . . . , um , v1 , . . . , vn }
– E(Km,n ) = {ui v j |1 ≤ i ≤ m, 1 ≤ j ≤ n}
=⇒ |V (Km,n )| = m + n
=⇒ | E(Km,n )| = m · n

• Path Pn : V ( Pn ) = {v1 , . . . , vn }, E( Pn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn }


⇒ | E( Pn )| = n − 1

• Cycle Cn : V (Cn ) = {v1 , . . . , vn } Figure 14: K2,3 . Figure 15: K3,3 .


E(Cn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn , vn v1 }
⇒ | E(Cn )| = n

Definition 4.6. We say H is a subgraph of G if V ( H ) ⊆ V ( G ) and


E( H ) ⊆ E( G ). Equivalent: obtain H from G by deleting edges and/or
vertices. Note that when we delete v ∈ V ( G ), we delete all incident
edges as well. If V ( H ) = V ( G ) we say that H is a spanning sub-
Figure 16: The red part is a subgraph of
graph. the entire graph.
math 240: discrete structures 39

Definition 4.7. A walk in G is a sequence of vertices v0 , v1 , v2 , . . . , vk


where vi−1 vi ∈ E( G ) ∀1 ≤ i ≤ k.
A path in a graph is a walk with no repeated vertices. A closed
walk is a walk where v0 = vk : v0 and vk are the ends of a walk.
A closed path is a cycle.

Definition 4.8. A graph is connected if ∀u, v ∈ V ( G ) there is a walk


with ends u and v. The maximal connected subgraphs of G are called
its connected components.

Figure 17: Connected components.


Definition 4.9. A multigraph M is a set (of vertices) V ( M) and a Note that a single vertex is a connected
list of unordered pairs of vertices where repetition is allowed (i.e. component.

vv ∈ E( M)).

Definition 4.10. An Eulerian walk in a graph (or multigraph M) is a


closed walk which uses every edge exactly once. If G has an Eulerian
walk, we call G Eulerian.

Figure 18: We can recall the Königsberg


Theorem 4.4 (Euler, 1736). G is Eulerian if and only if it is connected and problem: V are land masses and E are
all vertices have even degree. bridges.

Proof.
(⇒) ∀ v ∈ V ( G ), the number of times an Eulerian walk enters v
equals the number of times it exits v. =⇒ deg(v) = k + k = 2k for
some k.
(⇐) Suppose G is connected and deg(v) even ∀ v ∈ V ( G ). Let W
be a longest walk in G with no repeated edges W = v0 , v1 , . . . , vk .
Suppose W is not Eulerian.
Claim: W is closed.

Proof. Suppose it is not.


⇒ we used odd number of edges incident to vk
⇒ ∃ an unused edge incident vk
⇒ we can extend W by 1. ⇒⇐ with maximality of W.

So there is some edge in E( G ) not used by W. Because G is con-


nected, there must be an edge uvi not used by W for some 0 ≤ i ≤ k.
This contradicts maximality of W: u, vi , vi+1 , . . . , vk = v0 , v1 , . . . , vi is
longer. ⇒⇐. So G is Eulerian.
This result (Theorem 4.4) holds for
multigraphs as well. Note that deg(v)
Definition 4.11. A path in G is Hamiltonian if it has |V ( G )| ver- counts a "loop" (edge between the same
node) w ∈ E( M) twice.
tices (it "spans" G). A Hamiltonian cycle is a cycle in G with |V ( G )|
vertices. A graph is Hamiltonian if it has a Hamiltonian cycle.
40 anna brandenberger, binyuan sun

Finding Hamiltonian cycles, as a rule, is difficult (unless P = NP :’).


Are there sufficient conditions for G to be Hamiltonian?

Theorem 4.5 (Bondy & Chvátal, 1972). If deg(u) + deg(v) ≥ |V ( G )|


∀ u, v ∈ V ( G ), then G is Hamiltonian ⇔ G + uv is Hamiltonian where
uv 6∈ E( G ).

Proof. Show G is Hamiltonian ⇔ G + uv is Hamiltonian where


uv 6∈ E( G ).
(⇒) Trivial.
(⇐) If G is Hamiltonian, then done. Now suppose G is not Hamil-
tonian. ⇒ ∃ a Hamiltonian path from u to v in G, say P (Figure 19). ···
u v1 v
Let S be the neighbors of u which lie on P. Let T be the vertices
which follow neighbors of v on P. |S| + | T | ≥ |V ( G )| Figure 19: Hamiltonian path P.

By PHP, there must be some vertex in S ∩ T, say vi .


=⇒ vi , vi+1 , · · · , v, vi−1 , vi−2 , · · · , v1 , u, vi is a Hamiltonian cycle ··· ···
of G. u vi v

Theorem 4.6 (Ore, 1960). If d(u) + d(u) ≥ |V ( G )| ∀u, v ∈ V ( G )


nonadjacent, then G is Hamiltonian. This leads straightforwardly to (Dirac,
|V ( G )|
1952): If degG (v) ≥ 2 then G is Hamiltonian.

Proof. By adding edges to the graph and applying Theorem 4.5 re-
peatedly, we get a complete graph, which is Hamiltonian. By the "iff"
statements, G is Hamiltonian as well.

4.2 Trees

Definition 4.12. A graph is a tree if it is connected and has no cycles. Figure 20: Figure 21: Any
Binary tree. path Pn is a
A leaf of a graph is a vertex of degree 1. (Any k-ary K1,t tree.
is also a tree.)

Theorem 4.7. If deg(v) ≥ 2 ∀ v ∈ V ( G ), then G contains a cycle.

Proof. Let P be a maximal path in G: P = v0 , v1 , v2 , . . . , vk , v


Since it has deg(v) ≥ 2, it has some neighbor other than vk .
By the maximality of P, this neighbor must be in P, say vi . Thus
Figure 22: A general tree.
vi vi+1 . . . vk vvi is a cycle.

Corollary 4.8. Every tree has a leaf.

Proof. Contrapositive proof. Left to the reader.

Theorem 4.9. A connected graph is a tree if and only if there is a unique


path between any 2 vertices.
math 240: discrete structures 41

Proof. (⇒) Since it is connected, there is at least one path between


any two vertices. To prove uniqueness, suppose P1 and P2 are dis-
tinct uv-paths. Let vi be the last vertex P1 and P2 have in common
aside from v. Let v j be the next vertex in P1 shared with P2 . The
subpaths of P1 and P2 from vi to v j together thus form a cycle.
⇒⇐

(⇐) Let G be a connected graph that is not a tree. The G has a cycle,
C. If u, v ∈ V (C ), then there are ≥ 2 uv-paths.

Theorem 4.10. Every tree on ≥ 2 vertices has at least 2 leaves.

Proof. by induction, on the number of vertices.

Base: n = 2: the tree on two nodes has 2 leaves.

I.H.: Assume true for n − 1 vertices. Let T be an arbitrary tree with n


vertices. Let x be a leaf of Ti , let T 0 = T − x. T 0 has n − 1 vertices,
and is a tree because we are removing one node from T, a tree.
If u, v ∈ V ( T 0 ), then there exists a unique path in T 0 between them
(the unique path in T could not contain x since deg( x ) = 1).
Then T 0 has ≥ 2 leaves, say y, z. Since deg( x ) = 1, x is adjacent to
at most one of y and z.
Then x and at least one of y, z are leaves in T.

Theorem 4.11. A connected graph is a tree ⇔ the deletion of any edge dis-
connects the graph.

Proof. c.f. textbook (LPV).

Theorem 4.12. An n-vertex tree has n − 1 edges.

Proof. Base: n = 1: one node, zero edges.

I.H.: Assume true for n − 1 vertices. Let T be an n-vertex tree, and


let x be a leaf. By the I.H., T − x has n − 2 edges (because it is an
(n − 1)-vertex tree). Then T must have n − 1 edges.

Theorem 4.13. Adding an edge to a tree creates exactly one cycle.

Proof. Let u, v be non-adjacent vertices. There exists a uv-path, say


P = uv1 . . . vk v. Thus adding uv creates a cycle. Now we must prove Added clarification: we can let the al-
that it creates exactly one. Suppose there are more than one. leged two cycles created by adding
uv be (u, v, · · · , a, b, · · · , u) and
Any cycle created must contain the edge uv. (Otherwise there is (u, v, · · · , x, y, · · · , u).
a cycle in the original tree ⇒⇐). But then deleting uv from these Removing uv, we get two paths
from v to u: (v, · · · , a, b, · · · , u) and
cycles gives distinct uv-paths in the tree, contradicting uniqueness (v, · · · , x, y, · · · , u). ⇒⇐ with path
(Theorem 4.9.) uniqueness.
42 anna brandenberger, binyuan sun

Definition 4.13. A spanning tree of a graph G is a subgraph T such


that V ( T ) = V ( G ) and T is a tree.

Theorem 4.14. Every connected graph has a spanning tree.

Proof. Base: Trivially true for n = 1.

I.H.: Assume true for |V ( G )| = n − 1.

Delete any vertex v from our graph, which does not disconnect
it.16 The resulting (n − 1)-vertex graph has a spanning tree. Add 16
Exercise: Prove that any connected
the edge vx to the tree for any x ∈ N (v). The resulting subgraph: graph has a vertex whose deletion does
not disconnect the graph.
– uses every vertex
– is connected
– contains no cycles (any cycle would contain v which has degree
1 in the subgraph).

Counting Trees

Theorem 4.15 (Cayley). ∃ nn−2 different trees on n labelled vertices.

Proof.

- See LPV for proof using bijection between trees and "Prufer codes".

- c.f. Kirchhoff’s Theorem, using linear algebra.

There is no theorem for the number of unlabelled trees on n ver-


tices. However, we can find bounds.
Let Tn denote the number of unlabelled n-vertex trees.

nn−2 ≤ n!Tn (1)


n n −2
≤ Tn
n!
2n − 2
 
Tn ≤ (2)
n−1

Start at root, draw the tree so that no edges cross and vertices at
distance i from root are at level i. Walk around the edges and record
D if you move down 1 edge and U if you move up one edge. Thus
the code has length 2| E( T )| = 2(n − 1) and has n − 1 U ’s and n − 1
D ’s, yielding a code that looks like UUDUDDUU . . . .
−2
Thus the number of combinations of codes is (2n n −1 ).
Some trees are counted more than once, but each tree is counted at
least once.
2n − 2
 
=⇒ Tn ≤
n−1
math 240: discrete structures 43

Using Stirling’s Approximation, we can say that for large n, Stirling’s Approximation:
√  n n
en 4n −1 lim n! = 2πn
n→∞
√ ≤ Tn ≤ √ e
2πn5/2 2πn − 1

4.3 Graph Colouring


Cliques and Independent Sets

Definition 4.14. Some more terminology:


∆( G ) = maximum degree of vertices in G
δ( G ) = minimum degree of vertices in G
G is d-regular if degG (v) = d ∀ v ∈ V ( G )
(G is regular if it is d-regular for some d.)

Definition 4.15. A clique in a graph G is a set X ⊆ V ( G ) such that


uv ∈ E( G ) ∀ u, v ∈ X, u 6= v, i.e. X is a complete subgraph of G.
The clique number of G is W ( G ) = size of largest clique in G.

Definition 4.16. An independent set (or stable set) is a set X ⊆ V ( G )


such that uv 6∈ E( G ) ∀u, v ∈ X, i.e. X is an empty subgraph of G.
The independence number of G is α( G ) = size of largest indepen-
dent set in G.

Definition 4.17. A proper vertex k-colouring is a map c : V ( G ) → [k]


such that if uv ∈ E( G ) then c(u) 6= c(v). The chromatic number of G
is X ( G ) = the smallest k for which a proper vertex k-colouring exists.

Example 4.2.

G δ ∆ W α X
Pn 1 2 2 d n2 e 2
3 if n = 3 2 if n even
Cn 2 2 b n2 c
2 otherw. 3 if n odd
Kn n−1 n−1 n 1 n
Km,n m n 2 n 2

Definition 4.18. A graph is bipartite if V ( G ) can be partitioned into


two independent sets.

Proper vertex k-colourings partition V ( G ) into k independent sets.


G is bipartite ⇔ X ( G ) ≤ 2

Theorem 4.16. G is bipartite ⇔ G contains no odd cycles.


44 anna brandenberger, binyuan sun

Lemma 4.17. If H is a subgraph of G, then X ( H ) ≤ X ( G ).

Proof. If c is a proper k-coloring of G, then ∀u, v ∈ V ( H ) which are


adjacent, c(u) 6= c(v), so c is a proper k-colouring of H.

Lemma 4.18. Every closed odd walk of a graph contains an odd cycle where
length is defined as the number of edges.

Proof. by strong induction on the length of the walk r.

Base: r = 3
The only closed walk of length 3 is a cycle of length 3.

I.H. Assume true for all odd integers less than r = 2t + 1.

Take a close walk of length r: v0 , v1 , . . . , vr−1 , vr = v0


If there are no repeated vertices (other than v0 = vr ), then this is an
odd cycle.
If there are repeated vertices, i.e. ∃i, j such that vi = v j and 0 ≤ i < vr
j < r. Let W1 = v0 , v1 , . . . , vi , v j+1 , . . . , vr and W2 = vi , vi+1 , . . . , v j . v1 vi /v j

W1 and W2 together form the original odd closed walk. Since


|W1 | < |W | and |W2 | < |W | and each of the two walks is a closed
walk, the induction hypothesis guarantees that whichever of W1 or
W2 has odd length contains an odd cycle. This must be a cycle of
W as well.

Proof. of Theorem 4.16: G is bipartite ⇔ G contains no odd cycles.

(⇒) If G has an odd cycle C, then 3 = X (C ) ≤ X ( G ) ⇒ G is not


bipartite. ⇒⇐

(⇐) Suppose G has no odd cycles. Let u ∈ V ( G ). Now define


"distance" is the length of the shortest
X = { x ∈ V ( G ) | u and x have even distance} path between vertices.
Note: u ∈ X since u is at distance 0
Y = {y ∈ V ( G ) | u and y have odd distance} from itself.

We must show any two vertices in X (or in Y) are nonadjacent.


Suppose not. Let x, x 0 ∈ X and xx 0 ∈ E( G ). By construction there
is an even length path from u to x say P and from u to x 0 say P0 .
Then P with xx 0 with P0 is a closed walk of odd length in G, ⇒ G
has an odd cycle. ⇒⇐
Similarly, if y, y0 ∈ Y and yy0 ∈ E( G ), then we get a closed odd
walk from the odd uy-path, yy0 and the odd uy-path. ⇒⇐

General colorings
Lower bounds on G
math 240: discrete structures 45

Recall that X ( G ) ≥ X ( H ) ∀ subgraph H of G. If H is the largest


complete subgraph, then:

X (G) ≥ W (G)

Since a proper k-colouring partitions V ( G ) into independent sets,

| V ( G )|
X (G) ≥
αG
To see this, let Ci = {v ∈ V ( G )|c(v) = i } for some proper X ( G )-
colouring, then:
X (G) X (G)
|V ( G )| = ∑ |Ci | ≤ ∑ α( G ) = X ( G )α( G )
i =1 i =1

Upper bounds on X ( G )

Greedy Colouring Algorithm ( G = ( V , E )) v1 v1


1 order V ( G ) arbitrarily v 1 , v 2 , . . . , v n
1 1
2 colour V ( G ) in this order assigning c ( v i ) the smallest colour not v6 2 2 v2 v5 2 3 v4

yet assigned to its neighbours.


v3 1 1 v5 v6 3 2 v3
2 1
This algorithm doesn’t guarantee the optimal colouring. At any
vertex, the max number of forbidden colours is its degree. So the v4 v2

greedy algorithm gives: X ( G ) ≤ ∆( G ) + 1. Figure 23: Left is an optimal coloring,


right is non optimal. So the output
depends on node ordering.
Theorem 4.19 (Brook, 1941). If G is not complete or an odd cycle, then
X ( G ) ≤ ∆ ( G ).

Proof. Beyond the scope of this course.

Theorem 4.20. If G is not regular, then X ( G ) ≤ ∆( G ).

Proof. by algorithm:

BFS (Breadth First Search) Algorithm ( G = (V, E))


1 Insert any vertex into a first-in-first-out (fifo) queue Q.
2 while Q 6= ∅
3 Remove the next vertex x from Q and mark it "visited".
4 Place any neighbors of x which are not yet marked "visited"
into the queue (and ignore other neighbors).

Output: ordering of V ( G ) in the order they are marked visited. We can build a "BFS" tree, but we don’t
need it here.
Choose a vertex v1 whose degree is not ∆( G ): deg(v1 ) ≤ ∆( G ) − 1.
(We can do this since the graph is not regular.)
Now run BFS with v1 as the initial vertex, yielding an ordering of
V ( G ): v 1 , v 2 , . . . , v n −1 , v n .
46 anna brandenberger, binyuan sun

Every vi , i ≥ 2 has a neighbour v j with j < i because for vi to get


placed in the queue, we must have already visited some neighbour
v j . We then colour the vertices in reverse order vn , . . . , v1 .
For 2 ≤ i ≤ n, when we colour vi , at least one of its neighbours
has yet to be coloured (v j from discussion above), which means that
at most deg(vi ) − 1 colours have been used on the neighbours of vi
while greedily colouring, ⇒ at most ∆( G ) − 1 forbidden colours at
every step, since deg(v1 ) ≤ ∆( G ) − 1. ⇒ if we have ∆( G ) colours,
there will always be an available colour: ∴ X ( G ) ≤ ∆( G )

4.4 Planar Graphs

Definition 4.19. A graph is planar if it can be drawn in the Euclidian


plane so that the edges do not cross (only meet at vertices).

K5 seems like it cannot be planar since there are vertices that cannot
be joined without crossing other edges. But proofs along these lines
require the Jordan Curve Theorem which will not be touched in Math Figure 24: K2,3 and K4 have planar
240. We will use an alternate proof. representations. K5 seems like it does
not.
Definition 4.20. Given a plane drawing G ∗ of a planar graph G, we
define a face to be a maximal region bounded by edges.
2 5
3 4 6
Theorem 4.21 (Euler’s Formula). 1
If G ∗ is a plane drawing of a connected planar graph G with M vertices,
Figure 25: Example of a planar graph.
| E| edges, and | F | faces, then: |V | − | E| + | F | = 2. Every drawing has an unbounded face
called the outer face.
Proof. By induction on | E|.

Base: | F | = 1. If | F | = 1, then G ∗ has no cycles ⇒ G is a tree ⇒ | E| = Note: The vertices of any face in a
|V | − 1 and |V | − | E| + | F | = |V | − (|V | − 1) + 1 = 2 drawing can be made to be the vertices
of the outer face.
I.H.: Suppose true for | F | = k − 1. Note: Each edge touches at most 2
faces. If an edge touches exactly one
Let G ∗ have k ≥ 2 faces. Since G is not a tree, it has a cycle C. face, deleting it disconnects the graph.
Let e be an edge of C. Consider G − e. It is still planar. It is also Proofs are omitted since they use topology.
still connected any walk that used e can be modified by replacing
e with C − e. Thus e touches 2 faces since its deletion doesn’t
disconnect G ∗ (or G). Therefore deleting e merges the 2 faces into
1. By induction, the new graph with |V 0 |, | E0 |, | F 0 | satisfies

|V 0 | − | E 0 | + | F 0 | = 2
⇒ |V | − (| E| − 1) + (| F | − 1) = 2
⇒ |V | − | E | + | F | = 2

This means that | F | is invariant for a graph G: the number of faces


does not depend on its drawing.
math 240: discrete structures 47

Theorem 4.22. If G is a connected planar graph, with |V | ≥ 3, then

| E | ≤ 3|V | − 6

Proof. Count the number of pairs (e, f ) where e touches f . Call this
number T. Since each edge touches at most 2 faces, T ≤ 2| E|. But
every face touches at least 3 edges (no self-touching edge or 2 edges
with 2 vertices).

T ≥ 3| F |
3| F | ≤ T ≤ 2| E |
2
| F| ≤ | E| Example 4.3. Show K5 is non-planar:
3
2 |V | = 5
⇒ 2 = |V | − | E | + | F | ≤ |V | − | E | + | E |
3
 
5
| E| = = 10
1 2
⇒ | E | ≤ |V | − 2
3 10 6≤ 3(5) − 6 = 9
| E | ≤ 3|V | − 6

Note: K3,3 is also non-planar. But it satisfies the above property.

Theorem 4.23 (Kuratowski, 1930). G planar ⇔ G has no K5 or K3,3 sub-


division.

Definition 4.21. A minor of G is a graph obtained by deleting ver-


tices, deleting edges or contracting edges (Figure 26).
Figure 26: Edge contraction.

Theorem 4.24 (Wagner, 1937). G planar ⇔ G has no K5 or K3,3 minor.

Proof. Beyond the scope of this course. ;-;

Theorem 4.25. If G is planar with no triangles ⇒ | E( G )| ≤ 2|V ( G )| − 4.

Proof. Count pairs (e, f ) where edge e touches face f . Let T be the
number of such pairs.

4| F | ≤ T ≤ 2| E |
1
| F| ≤ | E|
2
1
=⇒ 2 = |V | − | E| + | F | ≤ |V | − | E| + | E|
2
=⇒ | E| ≤ 2|V | − 4

Example 4.4. K3,3 is bipartite =⇒ no odd cycles =⇒ no triangles.


K3,3 planar =⇒ 9 ≤ 2(6) − 4 = 8.
Contradiction, implying K3,3 non-planar.
48 anna brandenberger, binyuan sun

Theorem 4.26. Every planar graph is 4-colourable (X ( G ) ≤ 4).

Proof. Appel and Haken, 1976. No human readable proof exists.

Theorem 4.27. Every planar graph is 5-colourable.

Lemma 4.28. If G is planar, then δ( G ) ≤ 5.

Proof. Suppose δ( G ) ≥ 6, so deg(v) ≥ 6 ∀v ∈ V ( G ).

∑ deg(v) = 2| E|
v ∈V ( G )

⇒ 6|V | ≤ 2| E |
⇒ | E | ≥ 3|V | ⇒⇐ since | E| ≤ 3|V | − 6
Proof. of Theorem 4.27, by induction on |V ( G )|.
Base: Trivial if |V ( G )| ≤ 5.

I.H.: Assume true for |V ( G )| = n − 1 and let G be a planar graph


with n vertices. We know ∃v ∈ V ( G ) with deg(v) ≤ 5 (by
Lemma 4.28).

Case 1: deg(v) ≤ 4. Delete v and 5-colour V ( G − v) by induction.


At most 4 colours are used on the neighbours. of v, so there is
an available colour for v.
Case 2: deg(5) = 5. Delete v and 5-colour V ( G − v) If 4 or fewer
colours are used on the neighbours of v then we have a colour
available for v.
If each neighbour of v got a distinct colour:
Let N (v) = { x1 , x2 , x3 , x4 , x5 }. Say c( xi ) = i. Let G13 be the
subgraph of G consisting of all vertices coloured 1 or 3 and all
edges of G between them.
If x1 and x3 are not in the same connected component of G13 ,
then we take the component of G13 containing x1 and "flip" the
colours of its vertices (3 to 1 and 1 to 3: Figure 27). This is still a
proper colouring of G − v and now we can colour v with 1.
If x1 and x3 are in the same connected component: then there is Figure 27: If x1 and x3 are not in the
same connected component, flip all
a path P13 in G13 from x1 to x3 (whose vertices are all coloured
vertices coloured 1 and 3.
1 or 3). P13 ∪ { x1 v, x3 v} form a closed curve. One of x2 and x4
lies inside and one lies outside. Look at the subgraph of G − v
with vertices coloured 2 and 4. x2 and x4 cannot be in the same
connected component, or else there is an x2 x4 -path with vertices
coloured 2 and 4 which intersects P13 ∪ { x1 v, x3 v}. So we take
the component of G24 containing x2 and swap colours 2 and 4.
This leaves the colour 2 available for v. Figure 28: If x1 and x3 are in the same
connected component, flip the colour of
Proof. Alternate: see LPV p. 208-209. x2 (and connected components).
math 240: discrete structures 49

4.5 Weighted Graphs

Definition 4.22. A weighted graph is a graph G and a function


w : E( G ) → R where w(e) is the weight of e.

Notation 4.29. If H is a subgraph of G, we use w( H ) = ∑e∈E( H ) w(e).

Types of problems we might wish to solve:


1. Find a uv-path P where w( P) is minimum.
c.f. Dijkstra’s Algorithm.

2. Find a spanning tree T with w( T ) minimum.


c.f. Kruskal’s Algorithm and Prim’s Algorithm.

3. Find a spanning closed walk W such that w(W ) is minimum.


c.f. Traveling Salesman Problem (difficult, but one can find W such
that w(W ) ≤ 32 w(Woptimal )).

Dijkstra’s Algorithm( G ): find minimum weight uv-path.


1 Assign label (−, 0) to u
// The elements in the tuple ( a, b) are a: the preceding vertex;
// b: the weight of the minimum path from u.
2 if v is unlabelled
3 if ∃ no unlabelled vertex adjacent to a labelled vertex
4 return no path.
5 else for each xy ∈ E( G ) s.t. x labelled (t, W ) and y unlabelled
6 compute W + w( xy)
7 choose xy pair with minimum W + w( xy)
8 label y ( x, W + w( xy))
9 else (v is labelled)
10 return the path iteratively obtained by taking v, the vertex
from its label, the vertex from that vertex label, etc. (i.e. by
backtracking)

A brief intro to complexity analysis: here we have two types


of steps - comparison and addition. At the kth iteration, we have
Figure 29: Minimum weight path for
labelled k vertices. Thus there are ≤ k(n − k ) additions. this graph is AGFE.
Fact: to find the smallest (or largest) element from a set of size t,
we need ≤ t − 1 comparisons. Therefore, ≤ k (n − k) − 1 comparisons
to chose xy. The worst case number of steps:
n −1 n −1 n −1 n −1 Recall:
∑ [k(n − k) + k(n − k) − 1] = ∑ 2nk − ∑ 2k2 − ∑ 1
k =1 k =1 k =1 k =1 t
t ( t + 1)
n ( n − 1) (n − 1)(n)(2n − 1) ∑k= 2
= 2n −2 − ( n − 1) k =1
2 6 t
t(t + 1)(2t + 1)
1 4 ∑ k2 =
= n3 − n + 1 k =1
6
3 3
50 anna brandenberger, binyuan sun

Kruskal’s Algorithm( G ): find minimum weight spanning tree.


G is a connected weight graph.
1 Find edge with minimum weight e1 .
2 k←1
3 while k < n
4 if ∃e ∈ E( G ) such that {e} ∪ {e1 , · · · , ek } has no cycle
5 Set ek+1 as the unused edge having least weight
which does not make a cycle.
6 k ← k+1
7 else return e1 , e2 , . . . , ek and exit.

Proof. Let Tk be the output. Tk = {e1 , · · · , ek } satisfies the following:


- has no cycle: by construction.

- is spanning: if v 6∈ V ( Tk ) then any edge incident to v could still be


added (and the algorithm would not have stopped).

- is connected: let v, w ∈ V ( G ). Since G is connected, ∃ vw-path in G,


say Pvw . If Pw is in Tk , then done.
Else, let e ∈ E( Pvw ) \ E( Tk ). Adding e to Tk creates a cycle. If
e = xy, then Tk has an xy-path, Pxy . Take the path and replace the
edge xy with Pxy (contained in Tk to get a new vw-walk with fewer
edges not in Tk ).
By iterating a finite number of times, we get a vw-walk in G, all of
whose edges are in Tk , therefore Tk is connected.
We must now prove that the algorithm outputs the minimum weight
spanning tree: Let Topt = MWST (and suppose w( Tk ) > w( Topt ))17 . 17
No need, we didn’t end up using
Tk = e1 , e2 , . . . , en−1 in the order added. Let ek be the first edge contradiction.

which is in Tk and Topt . Claim: There is an edge in Topt , say e, such


that T = ( Topt − e) + ek is a spanning tree. (To be proved in an
assignment.)
=⇒ w( T ) ≥ w( Topt )
=⇒  Topt ) − w(e) + w(ek ) ≥ 
w(  w(
Topt
 )
=⇒ w(ek ) ≥ w(e)
If k = 1, then w(e1 ) was edge with minimum weight: w(e1 ) = w(e).
If k > 1, by choice of k, e1 , e2 , . . . , ek−1 ∈ E( Topt ), so the tree
{e1 , e2 , . . . , ek−1 } ∪ {e} ⊆ E( Topt ) ⇒ forms no cycles.
Since the algorithm chose ek over e, w(ek ) ≤ w(e) ⇒ w(ek ) =
w(e) ⇒ w( T ) − w( Topt ). And T shares more edges with Tk than Topt
did. Call T = Topt 0 . If T − T 0 . If T = T 0 , done. If not, repeat
k opt k opt
argument to get Topt 00 which has minimum weight and more edges in

common with Tk than Topt 0 did, and so on. Eventually we stop when

we get to Tk , ⇒ w( Topt ) = w( Topt 0 ) = w ( T 00 ) = · · · = w ( T ).


opt k
math 240: discrete structures 51

Traveling Salesperson Problem: given n points (vertices) to


visit and a weight to each pair, i.e. a weighted complete graph, find a
minimum weight Hamiltonian cycle Copt .
If the Triangle-Inequality is satisfied: w( xy)w (yz) ≥ w( xz) ∀ x, y, z,
then we can find a spanning closed walk W with w(W ) ≤ 2w(Copt ).

TSP Algorithm( G )
1 Take a mwst.
2 Make a walk by starting at a root and walking down, then up
until you can walk down again, etc. Call the walk W.

Proof. As seen in Figure 30, w(W ) = 2w( Topt ). Also notice that
removing any edge from Copt gives a spanning tree (Hamiltonian
path).

w(W ) = 2w( Topt )


≤ 2w(Copt − e) Figure 30: Example of the walk W in
gray on the mwst.
≤ 2w(Copt )

Notes

- LPV stands for the textbook by L. Lovász, J. Pelikán and K. Veszter-


gombi: Discrete Mathematics: Elementary and Beyond.

- Thanks to Suleman Malik for Figures 27 to 30.

You might also like