Discrete Structures Notes
Discrete Structures Notes
Lecture Note
CONTENTS
1 Sets and N o t a t i o n 1
1.1 Defining sets .......................................................................................................................................
1
1.2 Set operations ....................................................................................................................................
3
1.3 More sets .............................................................................................................................................
4
2 Induction 5
2.1 Introducing induction ........................................................................................................................
5
2.2 Strong induction .................................................................................................................................
7
2.3 Why is the induction principle true? ..............................................................................................
8
3 More P r o o f Techniques 11
3.1 Proofs by contradiction ....................................................................................................................
11
3.2 Direct proofs .......................................................................................................................................
12
4 Divisibility 15
4.1 The division algorithm ......................................................................................................................
15
4.2 Remainders .........................................................................................................................................
16
4.3 Greatest common divisors ...............................................................................................................
17
4.4 Greatest common divisors and linear combinations .................................................................. 18
5 Prime Numbers 21
5.1 The fundamental theorem of arithmetic ........................................................................................
21
5.2 The infinity of primes ........................................................................................................................
22
6 Modular Arithmetic 25
6.1 Congruences ......................................................................................................................................
25
6.2 Modular division .................................................................................................................................
27
7 Relations and F u n c t i o n s 31
7.1 Ordered pairs ......................................................................................................................................
31
7.2 Relations ..............................................................................................................................................
32
7.3 Kinds of relations ...............................................................................................................................
32
7.4 Creating relations ..............................................................................................................................
34
7.5 Functions .............................................................................................................................................
35
8 M a t h e m a t i c a l Logic 37
8.1 Propositions and predicates ............................................................................................................
37
8.2 Quantifiers ...........................................................................................................................................
37
8.3 Negations ....................................................................................................................... 38
8.4 Logical connectives ...................................................................................................... 39
8.5 Tautologies and logical inference .............................................................................41
9 Counting 43
9.1 Fundamental principles ............................................................................................... 43
9.2 Basic counting problems ............................................................................................. 44
10 B i n o m i a l Coefficients 49
10.1 Basic properties ......................................................................................................... 49
10.2 Binomial theorem ....................................................................................................... 50
1 1 The I n c l u s i o n - E x c l u s i o n P r i n c i p l e 53
11.1 Statement and proof of the principle ...................................................................... 53
11.2 Derangements ............................................................................................................ 54
12 The Pigeonhole P r i n c i p l e 57
12.1 Statements of the principle ...................................................................................... 57
12.2 Simple applications ................................................................................................... 57
12.3 Advanced applications .............................................................................................. 58
13 A s y m p t o t i c N o t a t i o n 61
13.1 Definitions ................................................................................................................... 61
13.2 Examples and properties .......................................................................................... 62
14 Graphs 65
14.1 Introduction ................................................................................................................. 65
14.2 Common graphs ......................................................................................................... 65
14.3 Some important concepts ......................................................................................... 66
14.4 Kinds of graphs .......................................................................................................... 67
15 M o r e G r a p h s — E u l e r i a n , B i p a r t i t e , and Colored 69
15.1 Eulerian graphs .......................................................................................................... 69
15.2 Graph coloring ............................................................................................................ 70
15.3 Bipartite graphs and matchings ............................................................................... 71
16 Trees 75
16.1 Basic properties of trees ..........................................................................................
................................................................................................................................................ 75
16.2 Spanning trees ........................................................................................................... 77
17 P l a n a r Graphs 79
17.1 Drawing graphs in the plane .................................................................................... 79
17.2 Euler’s formula ........................................................................................................... 80
17.3 Coloring planar graphs ............................................................................................. 83
17.4 Concluding remarks ................................................................................................... 84
Chapt er 1
A set can be defined by simply listing its members inside curly braces. For example,
the set {2, 4, 17, 23} is the same as the set {17, 4, 23, 2}. To denote membership we
use the 2 symbol, as in 4 2 {2, 4, 17, 23}. On the other hand, non-membership is
denoted as in 5 26 {2, 4, 17, 23}.
If we want to specify a long sequence that follows a pattern, we can use the ellipsis
notation, meaning “fill in, using the same pattern”. The ellipsis is often used after two
or more members of the sequence, and before the last one, as follows: {1, 2, . . . , n}.
The pattern denoted by the ellipsis should be apparent at first sight! For instance, { 1,
. . . , n} is generally regarded as underspecified (that is, too ambiguous). Of course,
even { 1, 2,. . . , n} is still ambiguous—did we mean all integers between 1 and n, all
powers of two up to n, or perhaps the set {1, 2, 25, n}?—but is generally sufficient,
unless you really do mean all powers of two up to n, in which case {20, 21, 22, . . . , 2k}
for an appropriate k is a better choice. The ellipsis can also be used to define an
infinite set, as in the following.
To avoid ambiguities it is often useful to use the set builder notation, which lists on
the right side of the colon the property that any set element, specified on the left side
of the colon, has to satisfy. Let’s define the positive integers using the set builder
notation:
N+ = {x : x 2 N and x > 0}. We
N+ = {x 2 N: x> 0}.
1
This is a matter of taste. In general, use the form that will be easiest for the reader of
your work to understand. Often it is the least “cluttered” one.
Ok, now onto the integers:
Z= { x : x 2 Nor - x 2 N}.
Z= { . . . , - 2 , - 1 , 0 , 1 , 2 , . . . } .
Remember, when you write mathematics, you should keep your readers’ perspective
in mind. For now, we—the staff of this course—are your readers. In the future it
might be your colleagues, supervisors, or the readers of your published work. In
addition to being reasonably formal and unambiguous, your mathematical writing
should be as clear and understandable to your intended readership as possible.
Here are the rational numbers:
o
na
.
Q= b : a 2 Z, b 2 Z,b6= 0
On being formal. Were the above definitions formal enough? The answer is: it
depends. For example, defining the natural numbers is an important and non-trivial
accomplishment of mathematics. After all, what do these symbols “1”, “2”, “3”,
actually mean? These numbers can be formally defined in terms of sets. Even more
involved is the formal definition of the reals, usually covered in a first mathematical
analysis course.
Here we cannot afford to cover everything in complete detail, which would have to
include, among other things, basic algebra and trigonometry. Furthermore, the vast
majority of mathematical works, while considered to be “formal”, gloss over details all
the time. For example, you’ll be hard-pressed to find a mathematical paper that goes
through the trouble of justifying the equation a 2 - b2 = (a - b)(a + b). In effect, every
mathematical paper or lecture assumes a shared knowledge base with its readers or
listeners. It is extremely important for an author of mathematics, such as yourself
during this course, to estimate this shared knowledge base correctly!
In CS103X we will assume most of high-school mathematics, including perhaps
some AP math like single-variable calculus, as our shared knowledge base. Thus
notions and techniques from this base will generally not be justified in lecture, and
can be used freely in your homework and exams. Furthermore, once we develop certain
2
notation or prove some theorem in class, you can use these freely in your homework
and exams, provided that you clearly cite the appropriate theorems. In writing and
speaking mathematics, a delicate balance is maintained between being formal and
not getting bogged down in minutia.1 This balance usually becomes second-nature
with experience. You should all get the hang of it by the end of the quarter.
3
A[ B ={x : x 2 A or x 2 B} {x :
A\ B =x 2 A and x 2 B} {x : x 2
A\B = A and x 26 B}
4
The [ and \ notation can be extended to the union and intersection of multiple sets.
Given n sets A1 , A2 , . . . , An , we can write
n [
Ai
i=1
for their intersection. In fact, this notation is pretty flexible and the same union can be
written as
n
[ [ [
Ai = Ai = Ai .
i=1 1~i~n i2{x: 1~x~n}
Given a set A, the cardinality of A, also known as the size of A, is simply the number
of elements in A. The cardinality of A is denoted by |A|. For example, if A = {2, 4, 17,
23}, then |A| = 4.
5
1.3 More sets
The empty set is denoted by ;. It is the unique set without elements. It holds that ; ~
A for any set A. Why? By definition, this holds if every element of ; is also an
element of A. Since ; has no elements, all possible statements about the elements of
; are true! In particular, all elements of ; are also elements of A. If this is confusing
don’t worry, we will go into such matters more rigorously when we get to logic. (For
now, you can ponder the following: If we know for a fact that there are no unicorns
<Gasp!>, then it is definitely true that all unicorns have soft light-blue fur.)
A set can contain sets as its elements. For example, {{2, 4}, {17}, 23} is a per-
fectly valid set with three elements, two of them sets. (The second element is a
singleton, a set with one element.) Note that {2, 4} 2 {{2, 4}, {17}, 23}, but {2,4} ~
{2,4,17,23}, and that 1726 {{2,4},{17},23}, but {17} 2 {{2,4},{17},23}. Also, {;} is not
the empty set. (Think about it.)
The power set of a set A is the set of all subsets of A, and is denoted by 2A. That
is,
2A= { S : S ~ A}.
For example, for A = {2, 4, 17, 23}, we have
~
2A = ;, {2}, {4}, {17}, {23}, {2, 4}, {2, 17}, {2, 23}, {4, 17}, {4, 23}, {17, 23},
~
{2, 4, 17}, {2, 4, 23}, {2, 17, 23}, {4, 17, 23}, {2, 4, 17, 2 3 } .
The cardinality of this set is 16, and 16 = 24. This is not a coincidence: As we shall
see when we get to combinatorics and counting, for a set A with n elements, the
cardinality of 2A is 2n. This is in fact the reason for the power set notation.
6
Chapter 2
Induction
Induction Principle: Given a set A of positive integers, suppose the following hold:
· 1 2 A.
· I f k 2 A t h e n k + 1 2 A.
Then all positive integers belong to A. (That is, A = N+.) Here
Proof. By definition, we are required to prove that for every n 2 N+, there exists some
l 2 N, such that either n = 2l or n = 2l + 1. The proof proceeds by induction. The
claim holds for n = 1, since 1 = 2 · 0 + 1. Suppose the claim holds for n = k. That is,
there exists l 2 N, such that k = 2l or k = 2l + 1. We prove that the claim holds for n =
k + 1. Indeed, if k = 2l then k + 1 = 2l + 1, and if k = 2l + 1 then k + 1 = 2(l + 1). Thus
the claim holds for n = k + 1 and the proof by induction is complete.
Theorem 2.1.2. Every positive integer power of 3 is odd.
7
Proof. By definition, we are required to prove that for every n 2 N+ , it holds that 3n =
2l + 1, for some l 2 N. The proof proceeds by induction. For n = 1, we have 3 = 2· 1 +
1, so the claim holds. Suppose the claim holds for k, so 3k = 2l + 1, for some l 2 N.
Then
3k + 1 = 3 · 3k = 3(2l + 1) = 2(3l + 1) + 1,
and the claim also holds for k + 1. The proof by induction is complete.
Proof t i p : If you don’t know how to get a proof started, look to the definitions, and
state formally and precisely what it is that you need to prove. It might not be obvious
how to prove that “Every positive integer power of 3 is odd”, but a bit easier to proceed
with proving that “for every n 2 N+ , it holds that 3n = 2l + 1, for some l 2 N.” If you
need to prove an implication (that is, a claim of the form “if... then . . .”), then formally
state all the assumptions as well as what you need to prove that they imply.
Comparing the two might lead to some insight.
Proof technique: Induction. The induction principle is often used when we are trying
to prove that some claim holds for all positive integers. As the above two proofs
illustrate, when we use induction we do not need to explicitly refer to the set A from
the statement of the induction principle. Generally, this set is the set of numbers for
which the claim that we are trying to prove holds. In the first proof, it was the set of
numbers n that are either even or odd. In the second proof, it was the set of numbers
n for which 3n is odd. Suppose we want to show that some claim holds for all positive
integers. Here is a general template for proving this by induction:
(a) State the method of proof. For example, “The proof proceeds by induction.”
(b) Prove the “induction basis”. That is, prove that the number 1 satisfies the claim.
(This step is often easy, but is crucially important, and should never be
omitted!)
(c) Assume the “induction hypothesis”. That is, state the assumption that the claim
holds for some positive integer k.
(d) Prove, using the induction hypothesis, that the claim holds for k + 1. The proof
should consist of a chain of clear statements, each logically following from the
previous ones combined with our shared knowledge base. The final statement in
the chain should state that the claim holds for k + 1.
(e) Conclude the proof. For example, “This completes the proof by induction.”
n(n + 1 )
1+2+· ··+n = 2.
8
k ( k + 1 ) k ( k + 1 ) + 2 ( k + 1 ) 1+2+· · · +k+(k+1) = ( k + 1)(k+2) =
,
__________________________ 2 _______________________+ 2
(k+1) =_____________________2
which proves the claim for k + 1 and completes the proof by induction.
Sigma and Pi notations. Just as the S symbol can be used to compactly express
the union of many sets, the P symbol can be used to express summations. For example,
n
1+2+· · X
X
X
You should not assume just because P appears that there is an actual summation,
or that there are any summands at all. For example, when n = 1, Pn i = 1 i = 1, and
when n ~ 0, Pn i = 1 i = 0 !
Similarly, products can be expressed using the Q symbol, as in
n
Y 20 ·
21 · 22 · ... · 2n = 2i .
i=0
9
Y
i = 1.
i 2 {2,4,10,14}
i is odd
1
Y i =
i=3
10
A single P or Q symbol can also be used to describe the sum or product over
more than one variable. For example,
n n
X
X X
( i + j ) = ( i + j ) .
1~i,j~n i=1 j=1
11
Strong Induction Principle: Given a set A of positive integers, suppose the following
hold:
· 1 2 A.
· I f { 1 , 2 , . . . , k } ~ A t h e n k + 1 2 A.
Then all positive integers belong to A.
Definition. An integer p > 1 is said to be prime if the only positive divisors of p are
1 and p itself.
Theorem 2.2.1. Every positive integer greater than 1 can be expressed as a product
of primes.
Pro of. The proof proceeds by strong induction. Since 2 is a prime, the claim holds for
2. (Note how the induction basis in this case is 2, not 1, since we are proving a claim
concerning all integers equal to or greater than 2.) Now assume the claim holds for all
integers between 2 and k. If k + 1 is a prime then the claim trivially holds. Otherwise
it has a positive divisor a other than 1 and k + 1 itself. Thus, k + 1 = a· b, with 2 ~ a,
b ~ k. Both a and b can be expressed as products of primes by the induction
hypothesis. Their product can therefore also be thus expressed. This completes
the proof by strong induction.
The versatility of induction. We have seen in the proof of Theorem 2.2.1 that if we
want to prove a statement concerning all positive integers equal to or greater than 2,
we can use induction (or strong induction) with 2 as the base case. This holds for any
positive integer in the place of 2. In fact, induction is an extremely versatile
technique. For example, if we want to prove a property of all even positive integers,
we can use 2 as the base case, and then prove that if the property holds for k, it will
also hold for k + 2. Generally we will just assume that such variations are ok, there is
no need to state a separate induction principle for each of these cases.
Fairly subtle variations of induction are often used. For example, if we can prove
that a statement holds for 1 and 2, and that if it holds for k it will also hold for k + 2,
we can safely conclude that the statement holds for all the positive integers.
However, don’t get carried away with variations that are simply incorrect, like using 1
as a base case, proving that if a statement holds for k then it also holds for k + 2, and
then claiming its validity for all positive integers.
13
14
Chapter 3
p2 = 2q2.
This shows that p2 is even, and consequently p must be even; that is, p = 2k for some
k 2 Z. Then
p2 = 4k2 = 2q2,
15
so
2k2 = q2 .
This shows that q 2 is even, and consequently that q is even. Thus both p and q are
even, contradicting the fact that p and q have no common divisor. We have reached a
contradiction, which completes the proof.
(a) State the method of proof. For example, “The proof proceeds by contradiction.”
(b) State the assumption that should lead to the contradiction. For example, “As -
sume statement A does not hold.”
(c) Proceed with a chain of clear statements, each logically following from the
previous ones combined with our shared knowledge base. The final statement in
the chain should be a contradiction, either of itself (as in, 0 =6 0), or of some
previous statement in the chain, or of part of our shared knowledge base.
(d) Conclude the proof. For example, “We have reached a contradiction, which
completes the proof.”
Pro of. The proof proceeds by contradiction. Assume that log 2 3 is rational. By
definition, there exist two numbers p, q 2 Z, with q =6 0, such that
log2 3 = p , q
which means that
2 = 3, and thus
pq
2p = 3 q .
We can assume that p, q > 0. (Indeed, if p / q > 0 then we can just work with |p| and |
q|, and if p/q ~ 0 we reach a contradiction of the form 3 = 2 p / q ~ 20 = 1.) Now, any
positive integer power of 2 is even, because it has 2 as a divisor, so 2p is even. On the
other hand, a positive integer power of 3 is odd, as we’ve seen previously. We have
reached a contradiction.
16
Consider the following well-known puzzle question. Take the usual 8×8 chessboard
and cut out two diagonally opposite corner squares. Can the remaining 62 squares be
tiled by domino-shaped 2 ×1 tiles, each covering two adjacent squares of the board?
(That is, each tile can be placed either horizontally or vertically, so as to precisely
cover two squares of the board.)
Pro of. Every tile covers one white square and one black square. Thus in any tiling as
above, the number of white squares covered is the same as the number of black ones.
The two removed squares have the same color, hence the number of white squares left
on the board is not the same as the number of black ones. So the remaining squares
cannot be tiled.
The above proof can also be phrased as a proof by contradiction, or even in terms of
induction. However, even though such a phrasing might appear more formal, it is
rather unnecessary, as the above proof is already logically sound (which is critical!),
and better conveys the power (and dare I say, the beauty) of the argument.
Proof Technique: Direct proof. Here is a common template for direct proofs:
(a) Provide a chain of clear statements, each logically following from our shared
knowledge base and the previous ones. The final statement in the chain should be
the claim we need to prove.
(b) (Optional.) Conclude the proof. For example, “This completes the proof.”
17
18
Chapter 4
Divisibility
Theorem 4.1.1. I f a and b are integers and b =6 0, then there is a unique pair of
integersq andr, such t h a t a = q b + r and0 ~ r < |b|.
Pro of. We need to prove two things: that there is some such pair q, r (existence) and
that this pair is unique (uniqueness).
Let’s begin with existence. First we show that there is a pair q, r 2 Z that satisfies a
= qb + r for some r ~ 0. This is easy after some playing around: Take q = -|ab|/b and r
= a + |ab|. Since |b| ~ 1, it holds that r ~ 0. Now we need to show that such q, r 2 Z
exist with r in addition being smaller than |b|. For this, consider the set S of all r 2 N
that satisfy a = qb + r for some q 2 Z. We’ve just shown that S is nonempty, so it must
have a smallest element, call it r0. We have a = q0b + r0. If r0 < |b| we’re done.
Otherwise, we have a = (q0b+ |b|) + (r0 - |b|), which means that r0 - |b| is a smaller
element of S than r0, leading to a contradiction. This completes the existence proof.
To prove uniqueness, suppose that a = qb + r = sb + t, with 0 ~ r, t < |b|. Thus ( q - s ) b +
( r - t ) = 0. Since 0 ~ r,t < |b|, we have | r - t | < |b|, hence |(q-s)b| < |b| and|q-s|<[Link]
qandsareintegers,thisimpliesq=[Link] r = t and the uniqueness proof is complete.
Proof t i p : When we need to prove that some mathematical object exists and is
unique, it is useful to approach in two stages. First prove that at least one such object
exists. This can be done either by directly constructing an object and demonstrating
19
that it fulfills the requirements, or by assuming that no such object exists and reaching
a contradiction. Then show that any two such objects must be the same.
4.2 Remainders
A more algorithmic view of Theorem 4.1.1 is as follows: If we divide the equation a
= qb + r
by b we get
a r
b = q + b.
Since 0 ~ r < |b|, we get that if b> 0, then 0 ~ r b < 1 and thus q = ~ba ~, the greatest
integer less than or equal to a b . If b < 0, then 0 ~ r b > -1 and thus q = ~ab ~, the
least integer greater or equal to a b . This can be used to calculate q, from which we
can derive r .
In Theorem 4.1.1, we call q the quotient and r the remainder. We use the notation r
= a rem b to denote that r is the remainder when a is divided by b. There is no need
for a special notation for quotient, since we can just use ~a ~ andb ~a ~, depending
b
on the sign of b.
Definition: If a and b are such that a rem b = 0 we say that a is a multiple of b, or that
b divides a (or is a divisor of a). Note that this holds when there exists some integer
q, such that a = qb. In particular, every integer divides 0, and every integer is a
multiple of 1. When b divides a we write b|a, and when b does not divide a we write
b6 |a.
X
u= c
i ai .
i = 1
20
(b) I f b|a and a =6 0 then |b| ~ |a|.
Since b|a, there exists an integer q, such that a = qb. Similarly, there exists an integer
r , such that b = rc. Thus a = qb = qrc. Since qr is an integer, it holds that c|a.
Since b|a, there exists an integer q, such that a = qb. This implies |a| = |q| · |b|.
Assume for the sake of contradiction that a =6 0 but |b| > |a|. Then |q|·|b| < |b|. Since |
b| > |a| > 0, we can divide by |b| to get |q| < 1, implying q = 0. Thus
a = qb = 0, which is a contradiction.
Consider a linear combination u = Pn i = 1 i i Since b|ai , there exists an integer qi ,
c a .
X
X X
u= c a
i i = c
i i b = b·
q c
i qi .
i = 1 i = 1 i = 1
Since Pn i = 1 c
i qi is an integer, we have b|u.
For the “if” statement, note that if a = ±b then b = qa and a = qb, for q = ±1, so a|b
and b|a. To prove the “only if” statement, assume that a|b and b|a. This implies the
existence of integers q and r, such that b = qa and a = rb. Thus
b = qrb. If b = 0 then a = 0 and the claim that a = ±b holds. Otherwise we can divide
by b to get qr = 1. Note that in this case q, r =6 0. Part (b) of the theorem implies that
|q| ~ 1 and |r| ~ 1. Thus q, r = ±1 and the claim that a = ±b follows.
Proof t i p : Often we need to prove that a proposition A holds if and only if some other
proposition B holds. Such an “if and only if” (sometimes abbreviated as “iff”)
statement is really composed of two implications, each of which needs to be proved. It
is often useful to decouple these and prove them separately. First prove that “If A
then B,” and then prove that “If B then A.” Another strategy is to prove that “If A then
B” and “If not A then not B.”
21
common divisor of a and b is not greater than max(|a|, |b|). Thus the set of common
divisors of a and b has a largest element, called the greatest common divisor of a and
b, or gcd(a, b). This is the integer d that satisfies the following two criteria:
Note that when a = b = 0, there is no greatest common divisor, since any integer
divides 0. When a and b are not both 0, we often want to compute gcd(a, b) efficiently.
Note that the set of divisors of a and - a is the same, and similarly for b and -b.
Furthermore, if a = 0 then gcd(a, b) = b, and if a = b then gcd(a, b) = a = b. Thus it
suffices to concentrate on the case a > b> 0, without loss of generality.
Since 1 ~ gcd(a, b) ~ b, we can just test all integers between 1 and b and choose
the largest one that divides both a and b. However, there is a much more efficient
way to find greatest common divisors, called Euclid’s algorithm. This algorithm, one
of the earliest in recorded history, is based on the following lemma.
Proof. By Theorem 4.2.1(c), all common divisors of b and r also divide a, since a is a
linear combination of b and r. Thus a common divisor of b and r is also a common
divisor of a and b. Similarly, since r = a - qb, a common divisor of a and b also divides
r , so it is a common divisor of b and r. Thus a, b and b, r have the same set of
common divisors, and in particular the same greatest common divisor.
With this lemma in our toolbelt, Euclid’s algorithm is easy to describe. To find
gcd(a, b), use the division algorithm (Theorem 4.1.1) to represent a = qb + r, where 0
~ r < b. (Remember that we are assuming that a > b > 0.) If r = 0 then b|a and
gcd(a, b) = b. Otherwise gcd(a, b) = gcd(b, r) and b > r > 0. We can thus repeat the
above procedure recursively with the pair b, r . Every recursive call strictly reduces
both numbers in the pair, so after at most b steps the algorithm will terminate with a
valid greatest common divisor of a and b. You will formally prove the correctness of
the algorithm in the homework.
Theorem 4.4.1. For two integers a and b that are not both 0, gcd(a, b) is a linear
combination of a and b.
22
Proof. As above, we can concentrate on the case a > b > 0. The proof proceeds by
strong induction on the value of a. In the base case, a = 2, b = 1, and gcd(a, b) = 1 =
0 · a + 1 · b. Assume that the theorem holds for all pairs a, b with 0 < b < a ~ k.
Consider a pair a , b with 0 < b < a = k + 1. If b 0|a0 then gcd(a0, b ) = b and the
0 0 0 0 0 0
where 0 < r < b . By the induction hypothesis, there exist coefficients u and v, such
0
that gcd(b0, r) = ub + vr. Lemma 4.3.1 shows that gcd(a0, b ) = gcd(b0, r), therefore
0 0
Bezout’s identity implies that the set of linear combinations of a and b is the same
as the set of multiples of their greatest common divisor (!):
Proof. By Theorem 4.2.1(c), since gcd(a, b) divides both a and b, it divides any linear
combination z of a and b, and thus z is a multiple of gcd(a, b). On the other hand, we
know by Bezout’s identity that there are coefficients u and v, such that gcd(a, b) = ua
+ vb, so if z = c· gcd(a, b), then z = c(ua + vb) = (cu)a + (cu)v.
23
24
Chapter 5
Prime Numbers
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.
(a) If p|a we are done. Otherwise gcd(p, a) = 1 and by Bezout’s identity there exist
linear coefficients u and v for which 1 = ua + vp. Multiplying both sides by b we
get b = uab + vpb. Since p divides ab, p divides the whole sum uab + vpb.
Therefore p|b.
(b) The proof proceeds by induction. The case k = 1 is trivial and k = 2 is handled in
part (a). So we assume that the claim holds for some k > 1 and prove that it
also holds for k + 1. Given that p| Qk + 1 p ba
i = 1 ai , we put b = Qk i = 1 ai . Since | k + 1 ,
part (a) implies that either p|ak+1 or p|b. In both cases the claim holds, in the latter
case by the induction hypothesis. This completes the proof by induction.
25
Theorem 5.1.1 can be used to derive a fundamental theorem of number theory. It
is so fundamental it has “fundamental” in its name.
n= 1 2·
p p
· · pk (p1 ~ p2 ~ ... ~ pk).
Proof. We first prove existence and then uniqueness. Actually, we already proved
existence in one of the previous lectures as an illustration of strong induction, but
give the prove here again for completeness. So, to prove that every integer can be
represented as a product of primes we use strong induction. The base case n = 1
holds because the empty product, as we previously discussed, is defined to equal 1.
The induction hypothesis assumes that for some n > 1, all positive integers k < n can
be represented as a product of primes. If n is prime, then it is trivially a product of
primes. Otherwise it can be written as n = ab, for 1 < a, b < n. By the induction
hypothesis, both a and b are products of primes, so their product n is also a product of
primes. This proves existence.
The proof that the above representation is unique proceeds by contradiction. As-
sume then that there exists some positive integer that can be represented as a product
of primes in (at least) two ways. By the well-ordering principle, there is a smallest
such integer n. It holds that n = 1 2 · · · pk = 1 2 · · · ql, where p1 ~ p2 ~ ... ~ pk, q1 ~ q2
p p q q
~ ... ~ ql, and pi =6 qi for some i. By Theorem 5.1.1(b), since i| 1 2 · · · ql, there must
p q q
exist some qj for which pi|qj. Since qj is prime and pi > 1, this can only occur when p i
= qj. Thus we can eliminate pi and qj from the equation 1 2 · · · pk = 1 2 · · · ql and get
p p q q
Pro of. Assume for the sake of contradiction that there is only a finite set of primes,
p1, p2, . . . , pn. Consider the number
p = p1p2...pn+1.
By Theorem 5.1.2, p has a prime divisor, which has to be pi, for some 1 ~ i ~ n.
Since pi divides both p and 1 2 . . . pn, it also divides p - 1 2 . . . pn = 1. However, this is
p p p p
Let’s get some more mileage out of Euclid’s proof. The results below show that
not only do the primes never stop, but the number of primes p ~ x is at least a certain
natural function of x, namely at least log log x. (Here the base of the logarithm is 2.)
26
Theorem 5.2.2. The n-th prime pn satisfies pn ~ 22 n - 1 for all n ~ 1.
Pro of. We proceed using strong induction. For the base case, the first prime is 2 = 220.
Assume that the claim holds for all primes p1 through pk . Consider p = p1 p2 . . . pk +1.
As in the above proof, p has a prime factor that is not one of the first k primes. This
prime factor is thus at least as large as pk+1, which implies
p
k + 1 ~ p = p1 p2 ...pk +1 ~ 220221· · · 22k-1+1
= 21 + 2 + 4 + . . . + 2 k - 1 + 1
= 22k-1+1
1 222k+ 1 =
~ 22k.
This is precisely the induction step we needed, and concludes the proof by strong
induction.
Denote by π(x) the number of primes p ~ x.
Pro of. Plugging n = blog log xc + 1 into Theorem 5.2.2 implies that the n-th prime is
at most x. Thus there are at least n primes below x.
For general education, you should know that this is by far not the best possible
estimate. A celebrated achievement in number theory is the Prime Number Theorem
due to Hadamard and de la Vall´ee Poussin, which states that x/ ln x (here we use the
natural logarithm) is the “right” bound, in the sense that
π(x) lim_____________________________! 1.
x ! 1 x/ ln x
27
28
Chapter 6
Modular Arithmetic
6 . 1 Congruences
We usually associate arithmetic with the infinite set of integer numbers. However,
modular arithmetic on finite sets is commonly used in our daily life. As an example, if
it is now 1 am and we let 1000 hours pass, what time will it be? We can use the
division algorithm to see that 1000 = 41 × 24 + 16 and conclude that adding 1000
hours is like adding 16 hours, since the clock returns to the same position every 24
hours. So after 1000 hours it will be 5 pm (17 hours after midnight).
There are many examples in which it is natural and useful to limit our number
system to a finite range of integers, such as 0 through n - 1, for some n. This number
system is denoted by Zn. Days of the week, hours of the day, minutes in an hour are
all familiar examples of finite number systems, as are numbers in microprocessor
registers, commonly limited to 32 binary digits.
Modular arithmetic allows us to add, subtract, multiply, and sometimes divide
numbers while staying within the finite set Zn. The number n is called the modulus. A
central notion in modular arithmetic is congruence. We say that two integers are
congruent modulo n if they leave the same remainder when divided by n. Here is the
formal definition:
29
that a = q1 n + r1 and b = q2 n + r2 . Thus (q1 - q2 )n + (r1 - r2 ) = nd, and r1 - r2 = (q2
- q1 + d)n. Thus n|(r1 - r2 ). However, |r1 - r2 | < n, so necessarily r1 - r2 = 0, which
implies that a rem n = b rem n, and a ~n b.
· If a ~n b then b ~n a. (Symmetry.)
· If a ~n b and b ~n c then a ~n c. (Transitivity.)
(a + b) rem n
(a - b) rem n
(ab) rem n
Exponentiation is defined through repeated multiplication.
Lemma 6.1.2. Properties of congruence:
(a) (aremn)remn = a r e m n
(b) (a rem n) ~n a
a 1 + b 1 ~n a2 + b2
a 1 - b 1 ~n a2 - b2
a
1 b 1 ~n a 2 b2
Proof. (b) is just a restatement of (a). To prove these we need to show that n|(a - (a
rem n)). Put r = a rem n. By the division algorithm, there exists q 2 Z, such that a =
qn + r. Thus a - r = qn, which implies that n|a - r and concludes the proof.
(d) is a restatement of (c), and (e) can be proved from (d) by induction. To prove
(c) we need to show that n|(ab - (a rem n)(b rem n)). Use the division algorithm to
represent a = q1 n + r1 and b = q2 n + r2 . Then
30
which implies the claim.
We now prove (f). We know that n|(a 1 - a2) and n|(b1 - b2). That is, there exist
integers q and s, such that a1-a2 = qn and b1 -b2 = sn. Adding these equations gives
(a1 + b1) - (a2 + b2) = (q + s)n, which yields the first part of the claim. Subtracting
similarly gives the second part. Writing a1 = a2 +qn and b1 = b2 +sn and multiplying
the equations gives
a
1 b1 = a2b2 + b2qn + a2sn + qsn2 =
a b a b
1 1- 2 2 (b2q + a2s + qsn)n,
which yields the third part.
Digression (notions from abstract algebra): There is a way to precisely state what
we mean by “well-behaved” above. Jumping the gun, I’ll say that Zp is a field, not just
a ring. Now let me tell you what this means. The notion of a ring in algebra is meant
to abstract our intuition concerning the essential properties of the integers. Given a
set S equipped with two operations, + (addition) and · (multiplication), we say that
S is a ring if the following all hold for any a, b, c 2 S:
· a + b 2 Sanda· b2 S.
· a + ( b + c ) = ( a + b ) + c and a· (b· c) = ( a · b)· c.
· a + b = b + a and a· b = b · a.
· a· ( b + c ) = a · b + a · c.
· There exists an additive identity element 0 2 S that satisfies a + 0 = a and a
multiplicative identity element 1 2 S that satisfies a· 1 = a for all a 2 S.
31
· For every a 2 S there exists an additive inverse - a 2 S for which a + (-a) = 0.
All the number systems we have encountered so far are rings, including Z, Q, R,
and Zn . However, some of them possess additional structure that allows the division
operation. Namely, a ring is said to be a field if, in addition to the above, the following
holds
The number systems R and Q, as well as Zp when p is prime, are fields. In fields
the division operation is well-defined, and b/a = b·a-1, as can be verified by plugging x
= b· a- 1 into the equation ax = b. A field with a finite number of elements is called
a Galois field, after the French mathematician Evariste Galois. (A feisty young man
who died in a duel at the age of 20, after making significant enough contributions to
mathematics to have a whole field (sic) named in his honor!) Anyway, now that we
know what fields are, let’s see why Zp is one. In fact, we prove something more
general:
Theorem 6.2.1. I f a and n are coprime then there exists exactly one x 2 Zn for which
ax ~n b, for any b 2 Z.
Pro of. We need to prove existence and uniqueness of x as described in the theorem.
ax ~n b if and only if there exists q 2 Z, such that ax - b = nq, or ax - nq = b. Now,
since gcd(a, n) = 1, any integer, including b, is a linear combination of a and n. This
proves existence.
To prove uniqueness, assume that for x, y 2 Zn it holds that ax ~n b and ay ~n b.
Thus ax - ay ~n 0, or n|a(x - y). As you proved in one of the homework assignments,
since n and a are coprime, this implies that n|(x - y), and therefore that x - y ~ n 0.
Thus x ~n y, which proves uniqueness.
Corollary 6.2.2. For a prime p and any a, b 2 Z, such that a 6~p 0, there exists
exactly one x 2 Zp for which ax ~p b.
The fact that division is well-defined in Zp when p is prime also means that
cancelations become valid. Thus if a 6~p 0 and ab ~p ac we can safely conclude that
b ~p c.
We now know that b/a is well-defined in Zp , but how do we find it? That is, how do
we find x 2 Zp , for which ax ~p b. This question is particularly important when p is
large and it takes too long to simply enumerate all the elements of Zp . Fortunately, the
following result, known as Fermat’s Little Theorem, can help us:
ap - 1 ~p 1.
32
However, each element of S is congruent to some element of Zp . Since there are p - 1
elements in S and p - 1 nonzero elements in Zp , the elements of S must be congruent
to each of 1, 2,. . . , (p - 1) in some order. Therefore,
· (p - 1) ~p 1a· 2a · · · · · (p-1)a,
33
or
p-1
1· 2 · · · · · (p - 1) ~p 1 · 2 · · · · · ( p - 1 ) · a .
34
We can cancel each of 1, 2, . . . , (p - 1) from both sides of the congruence, obtaining
ap - 1 ~p 1.
35
36
Chapter 7
This notion can be extended naturally to define an ordered n-tuple as the ordered
counterpart of a set with n elements.
Give two sets A and B, their cartesian product A ×B is the set of all ordered pairs
(x,y), such that x 2 A andy 2 B:
A× B = {(x,y) : x2 A,y 2 B}. Here is
For example, R2 is the familiar cartesian plane, and Rn is often referred to as the n-
dimensional Euclidean space. If we omit the parentheses and the commas, {a, b}4 is
comprised of child babble and a 70s pop band:
{ aaaa, baba, abab, baaa, baab, aaab, aaba, abaa, abba, bbaa, bbba, bbbb, aabb, abbb, babb, bbab}.
Proposition 7.1.1. ( A [ B) × C = (A × C) [ (B × C)
Proof. Recall that for two sets X and Y, X = Y if and only if X ~ Y and Y ~ X. Consider
any element (u, v) 2 (A [ B) × C. By definition, u 2 A [ B and v 2 C. Thus, u 2 A or u 2 B.
If u 2 A then (u, v) 2 A ×C and if u 2 B then (u, v) 2 B ×C.
37
Thus (u,v) is in A × C or in B × C, and (u,v) 2 (A× C ) [ (B × C). This proves that
( A [ B) × C ~ (A× C ) [ (B × C).
Now consider any element (u, v) 2 (A × C) [ (B × C). This implies that (u, v) 2
A× Cor (u,v) 2 B × C. Inthefirst caseu 2 Aandv 2 Candinthesecondcase u 2 B and v
2 C. Thus u 2 A [ B and v 2 C, which implies (u, v) 2 (A[B) ×C.
7.2 Relations
Given a set A, a relation on A is some property that is either true or false for any
ordered pair (x, y) 2 A2. For example, “greater than” is a relation on Z, denoted by >.
It is true for the pair (3, 2), but false for the pairs (2, 2) and (2, 3). In more
generality,
Definition 7.2.1. Given sets A and B, a relation between A and B is a subset of A ×
B.
By this definition, a relation R is simply a specification of which pairs are related
by R, that is, which pairs the relation R is true for. For the relation > on the set
{1,2,3},
> = {(2, 1), (3, 1), (3, 2)}.
This notation might look weird because we do not often regard the symbol “>” as a
meaningful entity in itself. It is, at least from the vantage point of the foundations of
mathematics: This symbol is a particular relation.
The common usage of the symbol “>” (as in 3 > 2) is an instance of a useful
notational convention: For a relation R, (a, b) 2 R can also be specified as aRb.
Thus, in the above example, (2, 1) 2 > can be written as 2 > 1. How convenient!
Common mathematical relations that will concern us include <, >, ~, ~, =, 6=, |,
~n, ~, ~, etc. For example, the relation = on the set Z is precisely the set {(n, n) : n 2
Z} and the relation ~ on R is the set {(x, x + |y|) : x, y 2 R}.
The concept of a relation is as general as the concept of a set, and is not limited to
strictly mathematical settings. For instance, we can define the relation likes between
the set {Anna,Britney,Caitlyn} and the set {Austin,Brian,Carlos}, such that
likes = ~(Britney,Austin) , (Caitlyn ,Austin) , (Britney, Carlos) , (Anna,Austin) , (Caitlyn,Brian) ~.
In this setting we can write Britney likes Austin.
38
Equivalence relations. A relation that is reflexive, symmetric, and transitive is called
an equivalence relation. Clearly, the common relation = on the set R, say, is an
equivalence relation. Also, we have seen earlier that the congruence relation ~ n on
the set Z is reflexive, symmetric, and transitive, thus it is also an equivalence relation.
The similarity relation on the set of triangles in the plane is another example.
Equivalence relations are special in that they naturally partition the underlying set
into equivalence classes. For example, the relation ~2 partitions the integers into even
and odd ones. These are, respectively, the integers that are related (by ~ 2) to 0, and
the ones related to 1. Let’s formalize these concepts.
Definition 7.3.1. A partition of a set A is a set X ~ 2A \ {;}, such that (a) Each
a 2 A belongs to some S 2 X.
(b)IfS,T2 X,eitherS=TorS\ T = ; .
Stated differently, this definition says that the set A is the union of the members
of X, and these members are disjoint. Now, given an equivalence relation R on A,
the equivalence class of a 2 A is defined as
R[a] = {b 2 A : aRb}.
39
· For all a, b, c 2 A, aRb and bRc implies aRc. (Transitivity.)
· Given a, b 2 A, exactly one of the following holds (and not the other two): aRb,
bRa, a = b.
The familiar < and > relations (on R, say) are examples of strict orders.
(a) T is transitive.
(b) T is the smallest transitive relation that contains R. (That is, if U is a transitive
relation on A and R ~ U, then T ~ U.)
(c) I f | A | = n then
n [
T = Ri .
i = 1
40
7.5 Functions
The general concept of a function in mathematics is defined very similarly to relations.
In fact, as far as the definitions go, functions are relations, of a special type:
A function is sometimes called a map or mapping. The set A in the above definition
is the domain and B is the codomain of f .
A function f : A ! B is effectively a special kind of relation between A and B, which
relates every x 2 A to exactly one element of B. That element is denoted by f(x).
If the above definition is followed rigidly, particular functions should be defined
by specifying all the pairs (x, f(x)). This is often cumbersome and unnecessary, and
we will mostly continue describing a function from A to B as we did before: as a rule
for picking an element f(x) 2 B for every element x 2 A. As in, “Consider a function f :
R ! R, where f(x) = x2 for all x 2 R.”
Kinds of Functions. For a function f : A ! B, the set f(A) = {f(x) : x 2 A} is called the
range of f . The range is a subset of the codomain but may be different from it. If
f(A) = B then we say that f is onto. More precisely, a function f : A ! B is a surjection
(or surjective), or onto if each element of B is of the form f(x) for at least one x 2 A.
Today is the day of weird names, so: A function f : A ! B is an injection (or injective),
or one-to-one if for all x, y 2 A, f(x) = f(y) implies x = y. Put differently,
f : A ! B is one-to-one if each element of B is of the form f(x) for at most one x 2 A.
As if this wasn’t enough: A function f : A ! B is a bijection (or bijective), or a one-
to-one correspondence if it is both one-to-one and onto. Alternatively, f : A ! B is a
bijection if each element of B is of the form f(x) for exactly one x 2 A.
41
Another result that is sometimes used is the following: If f : A ! B and g: B ! C are
bijections then g ~ f : A ! C is a bijection, and
(g~ f ) -1 = f- 1 ~ g-1.
Bijections and cardinality. Bijections allow us to rigorously define when two sets are
of the same cardinality:
Definition 7.5.2. Two sets A and B have the same number of elements if and only if
there exists a bijection f : A ! B.
42
Chapt er 8
8.2 Quantifiers
Given a predicate P(x) that is defined for all elements in a set A, we can reason about
whether P(x) is true for all x 2 A, or if it’s at least true for some x 2 A. We can state
propositions to this effect using the universal quantifier 8 and the existential quantifier
9.
• 8x 2 A : P(x) is true if and only if P(x) is true for all x 2 A. This proposition can be
read “For all x 2 A, P(x).”
43
• 9x 2 A : P(x) is true if and only if P(x) is true for at least one x 2 A. This
proposition can be read “There exists x 2 A such that P(x).”
Given a predicate in more than one variable we can quantify each (or some) of
the variables. For example, the statement “For every real x and y, it holds that x 2 -
y2 = (x - y)(x + y)” can be formalized as
8x,y 2 R : x2 - y 2 = ( x - y ) ( x + y ) .
8.3 Negations
Given a proposition P , the negation of P is the proposition “P is false”. It is true if P
is false, and false if P is true. The negation of P is denoted by ¬P, read as “not P.” If
we know the meaning of P , such as when P stands for “It will rain tomorrow,” the
proposition ¬P can be stated more naturally than “not P ,” as in “It will not rain
tomorrow.” The truth-value of ¬P can be represented by the following truth table:
P ¬P true
false false
true
A truth table simply lists the truth values of particular statements in all possible
cases. Something interesting can be observed in we consider the truth values of ¬¬Q,
which can be obtained by using the above table once with P = Q and once with
P=¬Q:
Q ¬Q¬
true false ¬true
Q
false true false
44
We see that the statements Q and ¬¬Q have the same truth values. In this case
we say that the two statements are equivalent, and write Q , ¬¬Q. If A , B we can
freely use B in the place of A, or A instead of B in our logical derivations.
Negation gets really interesting when the negated proposition is quantified. Then
we can assert that
This can be read as “There exists an integer that is greater or equal to any other
integer,” which is the proper negation of the original statement.
45
P Q P^Q P_ Q P~ Q P ! Q P $ Q
TT T T F T T
TF F T T F F
FT F T T T F
FF F F F T T
P is false, then P ! Q is true. One way this can be justified is by remembering that
we expect a proposition to be either false or true. Now, P ! Q being false says that P
does not imply Q, which means precisely that P is true but Q is still false. In all
other cases we expect P ! Q to be true. (Did I succeed in turning something obvious
into a confusing mess? Well, we all know what is paved with good intentions...)
Now, there is another statement involving P and Q that is false precisely when P
is true and Q is false. It is, of course, ¬P _ Q. As the following truth table demonstrates, the
proposition ¬P _ Q is equivalent to P ! Q:
P Q P! Q ¬P_ Q
TT T T
TF F F
FT T T
FF T T
This means something rather interesting: We can replace a proposition that in-
volves implication by an equivalent one that instead has negation (¬) and disjunction
(_). Also, since P ! Q is false only when P is true and Q is false, the proposition ¬(P
! Q) is equivalent to P ^ ¬Q:
¬ ( P ! Q) , P ^ ¬Q.
This means that in a negated implication, the negation can be “pushed inside”,
somewhat like with quantifiers. In fact, similar equivalences exist for other negated
compound statements, as can be verified using truth tables (do it!):
These are the famous DeMorgan’s laws. What they mean is that we can eliminate
negated compounds (sounds like a military operation, doesn’t it?) just as we can
eliminate negated quantifiers.
Here is another important logical equivalence: The implication P ! Q is equiva-
lent to the contrapositive implication ¬Q ! ¬P :
( P ! Q ) , ( ¬ Q ! ¬P).
This is demonstrated by the following truth table:
46
P Q P ! Q ¬Q ¬P ¬ Q ! ¬P
TT T F F T
TF F T F F
FT T F T T
FF T T T T
Indeed, an implication of the form “If P then Q” is sometimes proved by assuming
that Q does not hold and showing that under this assumption P does not hold. This is
called a proof by contrapositive. (Despite the similarity, it is different from a proof by
contradiction.)
P ¬P P_ ¬P P^ ¬P
T F T F
FT T F
Note that by our definition of logical equivalence, all tautologies are equivalent. I t
is sometimes useful to keep a “special” proposition T that is always true, and a
proposition F that is always false. Thus any tautology is equivalent to T and any
contradiction is equivalent to F .
Here is another tautology: (P ^ Q) ! P :
P Q P^Q (P^ Q ) ! P
TT T T
TF F T
FT F T
FF F T
47
In general, any tautology of the form A ! B can be used to “manufacture” the
inference rule A B that says that if we know A we can conclude B. Similarly, a
tautology of the form A $ B can be converted into the equivalence A , B, which
can be regarded as two inference rules, A B and B A. A particularly important
inference rule is called modus ponens, and says that if we know that P and P ! Q
are both true, we can conclude that Q is true. It follows from the tautology (P^ (P!
Q))! Q:
P Q P ! Q P^ ( P ! Q) ( P ^ ( P ! Q))! Q
TT T T T
TF F F T
FT T F T
FF T F T
(¬P! F) , P
( P $ Q) , ( P ! Q)^ ( Q ! P)
( P $ Q) , ( P ! Q)^ ( ¬ P ! ¬Q)
These three rules are of particular importance. The first formally establishes the
validity of proofs by contradiction, and the second and third provide two means for
proving “if and only if” statements. We’ve been using these all along, but now we
know why they are justified.
48
Chapt er 9
Count ing
· How many ways are there to seat n couples at a round table, such that each
couple sits together?
· How many ways are there to express a positive integer n as a sum of positive
integers?
There are a number of basic principles that we can use to solve such problems.
The sum principle: Consider n sets Ai , for 1 ~ i ~ n, that are pairwise disjoint, namely
Ai \ Aj = ; for all i =6 j . Then
n
X= |
A i|.
i = 1
For example, if there are n ways to pick an object from the first pile and m ways to
pick on object from the second pile, there are n+m ways to pick an object altogether.
The product principle: If we need to do n things one after the other, and there are c 1
ways to do the first, c2 ways to do the second, and so on, the number of possible
courses of action is Qn i = 1 ci . For example, the number of possible three-letter
words in which a letter appears at most once that can be constructed using the
English alphabet is 26 · 25 · 24: There are 26 possibilities for the first letter, then 25
possibilities for the second, and finally 24 possibilities for the third.
The bijection principle: As we have seen, there exists a bijection from A to B if and
only if the size of A equals the size of B. Thus, one way to count the number of
elements in a set A is to show that there is a bijection from A to some other set B
49
and to count the number of elements in B. Often there is no need to explicitly specify
the bijection and prove that it is such: At this point in the course, you can omit some
low-level details from the written proofs in your homework solutions, as long as you
are certain that you could reproduce these details if asked to do so. For example, you
can simply state and use the observation that the number of ways to seat n people in
a row is the same as the number of ways to order the integers 1, 2, . . . , n, which is
the same as the number of n-element sequences that can be constructed from the
integers 1, 2, . . . , n (without repetition), which is the same as the number of bijections
f : A ! A, for A = {1, 2,. . . , n}. You should always make sure that you yourself fully
understand why such equalities hold whenever you use them! Obviously, if you don’t,
you’ll end up relying on equalities that are simply not true, which is not such a great
idea. If in doubt, write down a complete proof to make sure your reasoning is correct.
Theorem 9.2.1. Given sets A and B, such that |A| = k and |B| = n, the number of
functions f : A ! B is nk.
Proof. Induction on k. If k = 0 the set A has no elements and there is only one
mapping from A to B, the empty mapping. (Recall that a function f : A ! B is a subset
of A × B, and if A = ; then A × B = ;.) We suppose the claim holds for |A| = m and
treat the case |A| = m + 1. Consider some element a 2 A. To specify a function f : A !
B we can specify f(a) 2 B and a mapping f 0 : A \ {a} ! B. There are n possible values
of f(a) 2 B, and for each of these there are nm f0 by the induction hypothesis. This
mappings
50
and so on. Overall we get that the desired quantity is
k - 1
n(n - 1 ) · · · (n - k + 1 ) =Y ( n -i).
i = 0
This is called a falling factorial and denoted by (n)k or nk . We again provide a more
formal proof by induction, observing that the number of ways to pick an ordered
sequence of k objects from a collection of n distinct ones without replacement is
equal to the number of one-to-one functions f : A ! B, where |A| = k and |B| = n.
Theorem 9.2.2. Given sets A and B, such that |A| = k and |B| = n, the number of one-
to-one functions f : A ! B is (n)k .
Pro of. Induction on k. When |A| = 0, there is one mapping f as described, the empty
mapping, and (n)k is the empty product, equal to 1. Suppose the claim holds for |A| =
m and consider the case |A| = m + 1. Fix an element a 2 A. To specify f we specify
f(a) and a mapping f0 : A \ {a} ! B. There are n possible values for f(a) 2 B. Consider
a specific such value f(a) = b. Since f is one-to-one, no element of A \ {a} can be
mapped to b. Thus f0 has to be a one-to-one-mapping from A \ {a} to B \ {b}. By the
induction hypothesis, the number of such mappings is (n - 1) m . The number of
possible mappings f is thus n · (n - 1)m = ( n) m + 1 .
Permutations. How many ways are there to arrange n people in a row? How many
ordered n-tuples are there of integers from the set {1, 2,. . . , n}? Haw many distinct
rearrangements are there of the integers 1, 2, . . . , n? How many bijections are there
from the set {1, 2, . .. , n} to itself? The answer to these questions is the same, and
follows from Theorem 9.2.2. A bijection from a set A to itself is called a permutation
of A. The number of permutations of the set {1, 2, . .. , n} is precisely the number of
one-to-one functions from this set to itself, and this number is (n)n = n·(n-1) · · · 2·1.
This quantity is called “n factorial” and is denoted by n!. We can now observe that
n!
(n)k = (n -k)!.
Seating at a round table. We’ve arranged n people in a row, now it’s time to sit them
down. So how many ways are there to seat n people at a round table? Let’s be
precise about what we mean: Two seating arrangements are considered identical if
every person has the same neighbor to her right. In other words, rotations around the
table do not matter. Here is how this problem can be tackled: Fix one person a and
sit her down anywhere. This now fixes n - 1 possible positions for the others: “first
person to the right of a”, “second person to the right of a”, and so on until “(n - 1)-st
person to the right of a”. The number of ways to arrange the others in these n - 1
positions is (n - 1)!, which is also the answer to the original question.
51
Choosing an u n o r d e r e d collection of distinct objects w i t h o u t repetition. How
many ways are there to pick a set of k objects from a set of n objects? Since we are
picking a set, we do not care about order, and there are no repetitions. Notice that
every such set can be ordered in k! ways. That is, each set corresponds to k! distinct
ordered k-tuples. Now, we know that the number of ordered k-tuples that can be
picked from a collection of n distinct objects is (n) k . Thus if we denote by X the
number of sets of cardinality k that can be picked from a collection of n distinct
objects, we get
X · k! = (n)k
X = (n)k
k!
X= n!
k!(n - k)!.
This quantity X is denoted by ~kn ~, read “n choose k”. This is such an important
quantity that we emphasize it again: The number of k-element subsets of an n-element
set is ~kn ~, defined as
~ Qk - 1
~n =______n!________i = 0 (n - i)
k k ! ( n - k)! =_______ k! __.
We can see that ~n ~ = ~ n
~ = 1, and we define ~n ~ = 0 when k > n or k < 0.
0 n k
The number of subsets. We have seen that the number of k-element subsets of an
n-element set is k~n ~. How many subsets of an n-element set are there overall, of
any size? Yes, it is time to prove the neat formula we’ve been using all along:
~ ~2A ~~ = 2|A|.
Proof. By induction. When |A| = 0, A = ;. Hence, A has only one subset (itself) and
the formula holds since 20 = 1. Assume the formula holds when |A| = k and consider
the case |A| = k + 1. Fix an element a 2 A. A subset of A either contains a or not. The
subsets of A that do not contain a are simply subsets of A \ {a} and their number is 2k
by the induction hypothesis. On the other hand, each subset of A that does contain a
is of the form {a} [ X, for X ~ A \ {a}. Thus there is a bijective mapping between
subsets of A that contain a and subsets of A \ {a}. The number of such subsets is
again 2k . Overall we get that the number of subsets of A is 2k + 2k = 2k+1, which
completes the proof by induction.
Here is another instructive way to prove Theorem 9.2.3: Consider the set of
functions f : A ! {0, 1}. These functions assign a value of 0 or 1 to every element of A.
In this way, such a function f uniquely specifies a subset of A. Namely, the elements x
for which f(x) = 1 are the elements that belong to the subset of A specified by f . This
defines a bijection between such functions f and subsets of A. By Theorem 9.2.1, the
number of functions f from A to {0, 1} is 2|A|, which proves Theorem 9.2.3.
52
We can use Theorem 9.2.3 to derive an interesting identity. We now know that the
overall number of subsets of an n-element set is 2n . Previously we have seen that the
number of k-element subsets of an n-element set is ~n ~. kBy the sum principle, we
get
n ~n ~
X =2n. i i = 0
Choosing an u n o r d e r e d collection of distinct objects w i t h repetition. How many
ways are there to pick a collection of k objects from a pool with n types of objects,
when repetitions are allowed? We can reason as follows: The number of ways to pick k
objects from a pool with n types of objects is the same as the number of ways to put k
balls into n bins. Imagine these bins aligned in a row. A “configuration” of k balls in n
bins can be specified as a sequence of n - 1 “|” symbols and k “*” symbols, as in
~ ~ || ~ | ~ ~ ~ |
This sequence encodes the configuration where k = 6 and n = 5, and there are two
balls in bin number 1, one ball in bin number 3, and three balls in bin number 4. How
many such configurations are there? A configuration is uniquely specified by the
positions of the k “*” symbols. Thus specifying a configuration amounts to choosing
which of the n + k - 1 symbols are going to be “*”. This simply means we need to
choose a k-element subset from a set of size n + k - 1. The number of ways to pick a
collection of k objects from a pool of n types of objects with repetitions is thus
~
~n + k - 1
.k
53
54
Chapter 10
Binomial Coefficients
~
.
~n Qk - 1
= n! i = 0 (n - i)
k k ! ( n - k)! =_____k!
The quantities ~kn ~ are called binomial coefficients because of their role in the Binomial
Theorem, apparently known to the 11th century Persian scholar Omar Khayyam.
Before we state and prove the theorem let us consider some important identities
that involve binomial coefficients. One that follows immediately from the algebraic
definition is
~ ~n ~ n ~
= .
k n-k
~ ~ ~
~n ~ n ~ n + 1
+ = .
k-1 k k
55
This can be easily proved algebraically:
56
n! n! ( k -
1 ) ! ( n + 1 - k ) ! + k!(n-k)!
~ ~
~n ~n n!k n!(n + 1 - k) k !
+ (n+1-k)! +k!(n+1-k)!
n!k+n!(n+1 - k )
k ! ( n + 1-k)!
(n+1)!
k ! ( n + 1 -k)! ~n + 1
k
57
Pascal’s rule also has a combinatorial interpretation: ~n+1~
k
is the number of k-element
subsets of an n-element set A. Fix an element a 2 A. A subset of A either contains a
or it doesn’t. k-element subsets of A that do not contain a are in fact k-element
subsets of A \ {a} and their number is ~nk ~. k-element subsets of A that do contain a
bijectively correspond to (k - 1)-element subsets of A \ {a}, the number of which is ~
n ~. The identity follows.
k - 1
Another illuminating identity is the Vandermonde convolution:
~m + n ~ ~ Xl m ~~ n ~
.=
l kl-k
k = 0
We only give a combinatorial argument for this one. We are counting the number of
ways to choose an l-element subset of an (m + n)-element set A. Fix an m-element
subset B ~ A. Any l-element subset S of A has k elements from B and l - k elements
from A \ B, for some 0 ~ k ~ l. For a particular value of k, the number of k-element
subsets of B that can be part of S is ~mk ~ and the number of (l - k)-element subsets
of A \ B is ~ l n- k ~. We can now use the sum principle to sum over the possible values
of k and obtain the identity. An interesting special case is ~
~2
X ~n
n
~2n
= .
k n
k = 0
58
Proof. By induction on n. When n = 0 both sides evaluate to 1. Assume the claim
holds for n = m and consider the case n = m + 1.
59
m+1 m
(x+y) = (x+y)· (x+y)
m ~mk X
~
= (x + y ) · k = 0 x ym - k k
=x· m ~m ~ Xm ~m ~
X xk ym - k + y · k m-k k
x
k=0 y k k=0
60
Xm ~m ~ Xm ~m~
xk + 1 ym - k + xk ym + 1 - k
= k k
k=0 k=0
(10.1)
m+1 ~m ~ Xm ~m ~
X (10.2)
xk ym + 1 - k + xk ym + 1 - k
= k-1 k
k=1 k=0
(10.3)
(10.4)
(10.5)
61
! X ~ !
X
xm + 1 + xk ym + 1 - k + ym + 1 + xk ym + 1 - k
(10.6) k
-1 k
k=1 k=1
m ~~ m ~m~X ~~
+ xk ym + 1 - k +
k-1 k
k=1
~m+ ~k
1
m X m+1-k
+ x y
k
k=1
~ k m+1-k
= m+1 X ~m+ 1 x y k.
k=0
= XX
f(k) = f(k - 1)
m+1 k=0
= xm + 1 +y k=1
m+1
= xm + 1 +y
62
and (8) follows from (7) by Pascal’s rule. The other steps are simple algebraic ma-
nipulation. This completes the proof by induction.
The binomial theorem can be used to immediately derive an identity we have
seen before: By substituting x = y = 1 into the theorem we get
n ~n
~
X = 2n . k k = 0
Here is another interesting calculation: Putting x = - 1 and y = 1 yields
n
~
k~n
X (-1) = 0. k k = 0
63
This implies
~ ~
X X =2n-1. ~= k n k k~o d d nk e v e n
This means that the number of odd-size subsets of an n-element set A is the same
as the number of even-size subsets, and equals 2 n-1. This can be proved by a com-
binatorial argument as follows: Fix an element a 2 A and note that the number of
subsets of A \ {a} is 2n-1. There is a bijective map between subsets of A \ {a} and odd-
size subsets of A, as follows: Map an odd-sized subset of A \ {a} to itself, and map
an even-sized subset B ~ A \ {a} to B [ {a}. Observe that this is a bijection and
conclude that the number of odd-sized subsets of A is 2n-1. Even-size subsets can be
treated similarly, or by noting that their number is 2n minus the number of odd-size
ones.
64
Chapter 11
n
X =|Ai| .
i = 1
What happens when the sets are not pairwise disjoint? We can still say something.
Namely, the sum Pn i = 1 |Ai | counts every element of Sn i = 1 Ai at least once, and thus
even with no information about the sets we can still assert that
n
X
~ |
Ai | .
However, with more information we can do better. For a concrete example, con-
sider a group of people, 10 of whom speak English, 8 speak French, and 6 speak both
languages. How many people are in the group? We can sum the number of English-
and French-speakers, getting 10+ 8 = 18. Clearly, the bilinguals were counted twice,
so we need to subtract their number, getting the final answer 1 8 - 6 = 12. This argu-
ment can be carried out essentially verbatim in a completely general setting, yielding
the following formula:
|A [ B| = |A| + |B| - |A \ B|.
What if there are three sets? Suppose in addition to the above English and French
speakers, we have 14 German-language enthusiasts, among which 8 also speak English,
5 speak French, and 2 speak all three languages. How many people are there now?
We can reason as follows: The sum 10 + 8 + 14 = 32 counts the people speaking two
languages twice, so we should subtract their number, getting 32 - 6 - 8 - 5 = 13. But
now the trilinguals have not been counted: They were counted three times in the first
sum, and then subtracted three times as part of the bilinguals. So the final answer is
obtained by adding their number: 13+ 2 = 15. In general,
65
I n the case of arbitrarily many sets we obtain the inclusion-exclusion principle:
n
X (-1)k-1 X
= |Ai \ Ai \ ...Ai | .
1 2 k
Proof. Each element in Sn i = 1 Ai is counted exactly once on the left side of the formula.
Consider such an element a and let the number of sets Ai that contain a be j. Then
a is counted
~j~ ~j~ ~j~
j-1
+ . . . + (-1)
-
1 2 j
times on the right side. But recall from our exploration of binomial coefficients that ~
~ ~
j ~j ~jj ~j X j
X X
(-1)i = (-1)i-1 (-1)i-1
i i = -1 + i = 0,
i=0 i=0 i=1
which implies
~j ~ ~j ~ ~j ~
j-1
- + ... + (-1) = 1,
1 2 j
meaning that a is counted exactly once on the right side as well. This establishes the
inclusion-exclusion principle.
11.2 Derangements
Given a set A = {a1 , a2 .. . , an }, we know that the number of bijections from A to
itself is n!. How many such bijections are there that map no element a 2 A to itself?
That is, how many bijections are there of the form f : A ! A, such that f(a) 6= a for all
a 2 A. These are called derangements, or bijections with no fixed points.
We can reason as follows: Let Si be the set of bijections that map the i-th element
of A to itself. We are the looking for the quantity
n! - .
Consider an intersection Si \ Si \ ... \ Si . Its elements are the permutations that map
1 2 k
a a
1i , i , . . . , ai to themselves. The number of such permutations is ( n - k)!, hence |Si \
2 k 1
66
as
n
X ~
n! -(-1)k-1 n ~n
k = 1 1 ~ i 1< i 2< · · · < i k~ n XX
~
n ~n
X (-1)k (n - k)!
= k
k = 0
n X ( - 1 ) k n!
= k!
k = 0
n X (-1)k
= n! k! .
k = 0
(-1)k
Now, Pn k ! is the beginning of the Maclaurin series of e-1. (No, you are not
_
k = 0
required to know this for the exam.) This means that as n gets larger, the number
of derangements rapidly approaches n!/e. In particular, if we just pick a random
permutation of a large set, the chance that it will have no fixed points is about 1/e.
Quite remarkable, isn’t it!?
67
68
Chapter 12
Basic form. If m objects are put in n boxes and n < m, then at least one box contains
at least two objects. The one-line proof is by contradiction: If every box contains at
most one object, there are at most n · 1 = n objects. A more rigorous formulation of
the principle is as follows: Given two sets A and B, with |A| = m > n = |B|, for any
function f : A ! B there exists b 2 B such that
General form. If m objects are put in n boxes, then at least one box contains at least
dm/ne objects. The proof is again by contradiction: If every box contains at most
dm/ne - 1 < m/n objects, there are less than n(m/n) = m objects. The more rigorous
formulation is: Given two sets A and B, for any function f : A ! B there
exists b 2 B such that
~ ~{x2 A:f(x)=b}~~ ~ lm m
.
n
Dijkstra’s form. For a nonempty finite collection of integers (not necessarily distinct),
the maximum value is at least the average value. It is a good exercise to verify that
this is equivalent to the general form above.
57
F i r s t application. There are two San Franciscans with the exact same number of
hairs on their heads. Indeed, according to P&G Hair Facts, the average person’s
head has about 100,000 hairs, while “some people have as many as 150,000.” So it
seems safe to bet that every San Franciscan has at most 700,000 hairs on his or her
head. On the other hand, the year 2000 US Census counted 776,733 San Francisco
residents. The pigeonhole principle implies that at least two of them have the exact
same number of hairs.
Second application. At a cocktail party with six or more people, there are three
mutual acquaintances or three mutual strangers. Indeed, pick an arbitrary person a. By
the pigeonhole principle, among the other five or more people, either there are three
of a’s acquaintances, or three people who are strangers to a. Let’s say there are
three that are a’s acquaintances, the other case is analogous. If those three are
mutual strangers we are done. Otherwise there are two among them, call them b and
c, who know each other. Then a, b and c are mutual acquaintances and we are done.
F o u r t h application. Consider the numbers 1,2, . .. , 2n, and take any n + 1 of them;
then there are two numbers in this sample that are coprime. Indeed, consider the pairs
{1, 2}, {3, 4},. . . , {2n - 1, 2n}. By the pigeonhole principle, both numbers from one of
these pairs are in the sample. These numbers differ by 1 and are thus coprime. (This
follows from the same argument as in Euclid’s proof of the infinity of primes.)
Pro of. For 1 ~ i ~ n 2 + 1, let η i be the length of the longest monotone increasing
subsequence that starts at a i . If some ηi > n, we are done. Otherwise, by the
pigeonhole principle, there exists 1 ~ j ~ n, and some set i 1 < i2 < · · · < im of size m
~ d(n2 + 1)/ne = n + 1, such that η i 1 = ηi 2 = · · · = η i m = j. Now, consider two
numbers ai k and aik+1. If ai k < ai k + 1 , we get an increasing subsequence starting at a i k
of length j + 1, which is a contradiction. Hence a i k > ai k + 1 in particular, and
70
ai > ai > · · · > ai in general, giving us a decreasing subsequence of length at least n
1 2 m
+1.
Here is another pigeonhole gem, the last one for today:
Proposition 12.3.2. Given a sequence of n not necessarily distinct integers a1 , a2 , . . . , an ,
there is a nonempty consecutive subsequence ai , ai + 1 , . . . , aj whose sum Pj m = i am is a
multiple of n. (The subsequence might consist of a single element.)
Proof. Consider the collection
!
X
0 1 2 n
X X X . ai , ai , ai , . .
., ai i = 1 i=1 i=1
i=1
This collection has size n+ 1 and its first element is the empty sum P0 i = 1 ai = 0. There
are only n possible remainders modulo n, thus by the pigeonhole principle, there are
two numbers in the above collection of size n + 1 that leave the same remainder. Let
these be Pl i = 1 ai and Pk i = 1 ai , with l < k. By a lemma we once proved, it follows that
!
Xk ai - X l ai ,
i=1 i=1
which implies
k
n X ~~ai .
i=l+1
71
72
Chapter 13
Asymptotic Notation
13.1 Definitions
Analysis of algorithms is concerned with estimating how many steps various algo-
rithms make while solving problems of various sizes. In particular, given an algorithm,
we want to make statements like “For input of size n, the algorithm will terminate in
at most f(n) steps.” If we try to accurately estimate the number of steps, a cumber-
some bound like
f(n) = 11n3+12n2+151
1 2n +log3n +17
might arise. Such precision only complicates matters and does not add to our under-
standing of the algorithm’s efficiency. The following notational convention allows to
simplify bounds by concentrating on their “main terms.”
Definition 13.1.1. For two functions f , g : N+ ! R,
· f(n) = O(g(n)) if and only if there exists a positive constant c 2 R and a
constant n0 2 N, such that |f(n)| ~ c|g(n)| for all n ~ n0.
· f(n) = Ω(g(n)) if and only if g(n) = O(f(n)).
· f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = Ω(g(n)).
Asymptotic notation does wonders to the above ugly bound: We can now say that
f(n) = Θ(n3), which makes it easier to see how the number of steps performed by
the algorithm grows as n gets larger and larger. Notice how the asymptotic notation
swallowed all the constants and lower-order terms! To prove that f(n) = Θ(n 3) we
need to show that there exist positive constants c 1, c2 2 R and a constant n0 2 N,
such that c1n3 ~ f(n) ~ c2n3 for all n ~ n0. (We dropped the absolute values that come
from Definition 13.1.1 since f(n) and n 3 are nonnegative for n 2 N+.) We can take n0
= 1, c1 = 1 11, and c2 = 45.6. For the lower bound, clearly f(n) ~ 1 11n3 when n 2 N+. For
the upper bound, note that in this range n 3 ~ n2 ~ n ~ log3 n, and n3 ~ 1. All these
inequalities can be proved by elementary algebraic manipulation. Thus we get
1
f(n) ~ 11n3 + 12n3 + 151 2n3 + n3 + 17n3 ~ 45.6n3.
73
We can also perfectly well say that f(n) = O(n 4) or that f(n) = O(n 25); these
bounds are considerably less informative but correct. On the other hand, the bound
f(n) = O(n2) (or even f(n) = O(n2.99)) is not correct. Indeed, we have seen that f(n) ~
1 1 1 n3. On the other hand, for any positive constant c 2 R, 1 1 1 n3 ~ cn2 for all n ~ 11c.
Thus there is no positive constant c 2 R and a constant n0 2 N so that f(n) ~ cn2 for
all n ~ n0.
Asymptotic notation is asymmetric, so we never write a statement like O(g(n)) =
f(n); the O, Ω, and Θ are always present on the right side of the equality sign.
(However, we can write n2 + O(n) = Θ(n2), for example.) The right way to think of
statements like f(n) = O(g(n)) and f(n) = Ω(g(n)) is as inequalities; always
remember what the notation means according to Definition 13.1.1.
· For any real constants b > 1 and p, np = O(bn). (“An exponential swallows a
power.”)
· For any real constants q > 0 and p, (ln n)p = O(nq). (“A power swallows a
logarithm.”)
· For any real constants a, b > 1, log a n = Θ(logb n). This implies that we can
write bounds like O(logn), O(n logn), etc., without specifying the base of the
logarithm. (“Asymptotic notation swallows bases of logarithms.”)
74
(c) I f f(n) = O(h(n)) andg(n) = O(w(n)) then f(n) · g(n) = O(h(n) · w(n)).
Pro of. We prove each claim individually.
(a) If f(n) = O(g(n)) then there exists a positive constant c 2 R and a constant
n0 2 N, such that |f(n)| ~ c|g(n)| for all n ~ n 0. Thus for p 2 N, |p· f(n)| = p|
f(n)| ~ (pc)|g(n)| for all n ~ n0, and by Definition 13.1.1, p · f(n) = O(g(n)).
(b) If f(n) = O(h(n)) and g(n) = O(w(n)) then there exist two positive constants
c
1, 2 2 R and constants n 1, n 2 2 N, such that |f(n)| ~ c 1|h(n)| for all n ~ n 1 and |
c
for all n ~ max(n1, n2), and by Definition 13.1.1, f(n)+g(n) = O(max(|h(n)|, |w(n)|)).
(c) If f(n) = O(h(n)) and g(n) = O(w(n)) then there exist two positive constants
c
1, 2 2 R and constants n 1, n 2 2 N, such that |f(n)| ~ c 1|h(n)| for all n ~ n 1 and |
c
for all n ~ max(n 1, n2), and by Definition 13.1.1, f(n) · g(n) = O(h(n) · w(n)).
75
76
Chapter 14
Graphs
14.1 Introduction
A graph G is an ordered pair (V, E), where V is a set and E is a set of two-element
subsets of V. That is,
E ~ ~{x,y} : x,y 2 V,x =6 y~.
Elements of V are the vertices (sometimes called nodes) of the graph and elements of E
are the edges. If e = {x, y} 2 E we say that x and y are adjacent in the graph G, that y is
a neighbor of x in G and vice versa, and that the edge e is incident to x and y.
What are graphs good for? Graphs are perhaps the most pervasive abstraction in
computer science. It is hard to appreciate their tremendous usefulness at first, because
the concept itself is so elementary. This appreciation comes through uncovering the
deep and fascinating theory of graphs and its applications.
Graphs are used to model and study transportation networks, such as the net-work
of highways, the London Underground, the worldwide airline network, or the European
railway network; the ‘connectivity’ properties of such networks are of great interest.
Graphs can also be used to model the World Wide Web, with edges corresponding to
hyperlinks; Google uses sophisticated ideas from graph theory to assign a PageRank to
every vertex of this graph as a function of the graph’s global properties. In this course
we will introduce the basic concepts and results in graph theory, which will allow you to
study and understand more advanced techniques and applications in the future.
77
Paths. A path on n vertices, denoted by Pn, is the graph Pn = (V, E), where V = {1, 2, .
. . , n} and E = {{i, i + 1} : 1 ~ i ~ n - 1}. The number of edges in P n is n - 1. The
vertices 1 and n are called the endpoints of Pn.
Definition 14.3.1. Two graphs G = (V, E) and G0 = (V0, E0) are said to be isomorphic if
there exists a bijection f : V ! V0 such that
{x, y} 2 E if and only if {f(x), f(y)} 2 E0.
G0.
Size. The number of edges of a graph is called it size. The size of an n-vertex graph is
at most ~n ~, achieved by the n-clique.
2
Degree. The degree (or valency) of a vertex v in a graph G = (V, E), denoted by
dG(v), is the number of neighbors of v in G. More formally, this degree is
A graph in which every vertex has degree k is called k-regular and a graph is said to
be regular if it is k-regular for some k.
The following is sometimes called the Handshake lemma. It can be interpreted as
saying that the number of people at a cocktail party who shake hands with an odd
number of others is even.
78
Proof. For a graph G = (V, E), consider the sum of the degrees of its vertices:
X
s= dG (v).
v 2 V
Observe that this sum counts every edge e twice, once for each of the vertices incident
to e. Thus s = 2|E|, and, in particular, s is even. Subtracting from s the degrees of
even-degree vertices of G, we see that the resulting quantity is the sum of the degrees
of odd-degree vertices and is still even. This implies the proposition.
Directed graphs are suitable for modeling one-way streets, non-reflexive relations,
hyperlinks in the World Wide Web, and so on. The notion of degree as defined above
79
is no longer applicable to a directed graph. Instead, we speak of the indegree and the
outdegree of a vertex v in G, defined as |{u 2 V : (u, v) 2 E}| and |{u 2 V : (v, u) 2 E}|,
respectively.
A graph that is not simple can have multi-edges and self-loops. Multi-edges are
multiple edges between the same pair of vertices. (Their presence means that the
collection of edges is no longer a set, but a so-called multiset.) A self-loop is an edge
to and from a single vertex v.
Finally, a graph can also be weighted, in the sense that numerical weights are
associated with edges. Such weights are extremely useful for modeling distances in
transportation networks, congestion in computer networks, etc. We will not dwell on
weighted graphs in this course. In fact, unless specified otherwise, the word “graph”
will continue to refer to undirected, unweighted, simple graphs.
80
Chapt er 15
More G raphs—Eulerian, B i p a r t i t e ,
and Colored
81
( a ) v1 = vn + 1
(b) n = | E |
Proof of (a). Assume for the sake of contradiction that v 1 =6 vn+1. Then the number of
edges of T incident to v1 is odd. (After T first leaves v1 , it enters and leaves it an
even number of times.) Since the degree of v1 in G is even, there is an edge e
of G that is incident to v1 but not part of T. We can extend T by this edge,
obtaining a contradiction.
T0 = (v0, e0 , vi , ei , .. . , vn , en , v1 , e1 , . . . , vi - 1 , e
i - 1 , vi ).
We have reached a contradiction and can therefore assume that V(T) = V. That
is, T visits all the vertices of G. Assume for the sake of contradiction that E(T)
=6 E, so there exists an edge e 0 = {vi , vj } of G, for some 1 ~ i < j ~ n, that is
not part of T. Then we can augment T by the edge e 0 , and obtain a longer tour
T0 , namely
T 0 = (vi , e0 , vj , ej , vj + 1 , e
j+1, . . . , vn , en , v1 , e1 , . . . , vi , ei , . . . , vj - 1 , e
j-1,
vj ).
T0 is longer than T by one edge, which is a contradiction that proves the theo-
rem.
Proposition 15.2.1. I f the degree of every vertex in a graph G is at most k, then the
chromatic number of G is at most k + 1.
Pro of. By induction on the number of vertices in G. (The degree bound k is fixed
throughout the proof.) If G has a single vertex, then the maximal degree is 0 and the
graph is 1-colorable. Since 1 ~ k + 1, the proposition holds. Suppose every graph with
at most n vertices and all vertex degrees at most k is (k + 1)-colorable. Consider a
particular graph G = (V, E) with n + 1 vertices, and all degrees at most k. Let G 0 be
the graph obtained from G by deleting a particular vertex v and all the edges incident
to v. That is, G0 is the incident subgraph of G on the vertices V \ {v}. G0 has n
vertices, all of degree at most k, and is thus (k + 1)-colorable. Let c0 be such a
coloring of G0 . We extend it to a coloring c of G as follows. For every vertex u 2 G
such that u =6 v we define c(u) = c 0(u). The vertex v has at most k neighbors in G
and there is at least one color i among {1, 2, . . . , k + 1} that has not been assigned to
any of them. We define c(u) = i. This is a (k + 1)-coloring, and the proposition
follows.
The sets U and V \ U are called the classes of G. A complete bipartite graph Km,n is a
graph in which all the edges between the two classes are present. Namely, Km , n =
(V,E),whereV={1,2,...,m+n}andE={{i,j}: 1 ~ i ~ m , m + 1 ~ j ~ m+n}.
The number of edges in Kn is mn. From the definition of coloring, it follows that a
graph is bipartite if and only if it is 2-colorable. (Check!) Here is another useful
characterization of bipartite graphs:
83
Proposition 15.3.1. A graph is bipartite if and only if i t contains no cycle of odd
length.
Pro of. For one direction of the claim, let G be a bipartite graph and let C = (v 1 ,
v2 , . . . , vn , v1 ) be a cycle in G. Suppose without loss of generality that v 1 2 U,
where U is as in the definition of bipartiteness. Then by simple induction that we
omit, vi 2 U for every odd 1 ~ i ~ n. Since {vn ,v1 } 2 E, vn 2 V\ U and thus n is even. It
follows that the number of edges in C is even.
Before proving the other direction, we need a simple lemma.
Lemma 15.3.2. Given a graph G = (V, E), let P = (v1 , v2 , . . . , vn ) be a shortest path
between two verticesv1 andvn inG. Then for all1 ~ i < j ~ n, Pi = (vi ,vi + 1 , . .. ,vj ) is a
shortest path between vi and vj .
Q = (v1 , v2 , . . . , vi , u1 , u2 , . . . , ul , vj , vj + 1 , . . . , vn ).
Since Qi is shorter than Pi , Q is shorter than P. Now consider the graph G 0 = (V(Q),
E(Q)). This graph is connected, and thus there is a shortest path P0 between v1 and
vn in G0 . The number of edges in this shortest path cannot exceed the total number
of edges in G0 , and thus P0 is shorter than P. Since P0 is also a path between v1 and
vn in G, we have reached a contradiction.
We now turn to the other direction of the proposition. Assume that G = (V, E)
has no odd cycle. If G has more than one connected component we look at every
component separately. Clearly, if every component is bipartite, G as a whole is
bipartite. Thus assume that G is connected. Pick an arbitrary vertex v 2 V and define
a set U ~ V as
U = {x 2 V: the shortest paths from v to x have even length}.
2are shortest paths between v and w and thus have the same length,
which we denote by l(w). Consider the vertex w~ shared by P1 and P2 that maximizes
l(w) among all such w. The paths P1w , u a n d P w , u
~
~
0
84
both even, the lengths of P w1~, u a n d P w ~, u 0
2 have the same parity (that is, they
are
eitherbothevenorbothodd).NowconsiderthecycleC
composedof Pw ~, u 1 , the edge
{u, u0}, and P w ~, u 0
2 . Since P1w ~, u a n d P w ~, u 0
2 share no vertex in common other than
w~ , C really is a cycle in G. Moreover, since the lengths of P1w ~, u a n d P w ~, u 0
2 have the same parity, the number of edges in C is odd! We have reached a
contradiction that completes the proof.
Bipartite graphs are particularly useful to model symmetric relations from one
set to another. For example, given a collection of boys and girls, we could model
the relation “wants to go to the prom with” by a bipartite graph. Given such
preferences, an interesting question is whether we can pair the boys up with the girls,
so that they all end up going to the prom with someone they actually want to go with.
It turns out that this question has a very precise answer. To state the theorem we
need to define the notion of matching:
Definition 15.3.3. Given a bipartite graph G = (V, E), a matching B in G is a set of
disjoint edges. Namely, B ~ E and e1 \ e2 = ; for any e1 , e2 2 B. A matching is said to
be perfect if S e 2 B e = V.
Consider now a set B of boys, a set G of girls, and a symmetric relation P from B
to G. Define a graph W = (B [ G, {{b, g} : (b, g) 2 P}). The above question simply
asks to characterize when there exists a perfect matching in W. The below result,
known as Hall’s theorem, provides such a characterization. To state the theorem, we
use another piece of notation: Given a subset S of the vertices of W, we let Γ(S) be
the set of vertices of W adjacent to at least one of the vertices of S.
Theorem 15.3.4. A bipartite graph W = (V, E) with classes B and G has a perfect
matching if and only if |B| = |G| and |Γ(S)| ~ |S| for all S ~ B.
Proof. One direction is easy: Assume W has a perfect matching and consider a set
S ~ B. Every element of S is matched to a distinct element of G and hence |Γ(S)| ~ |
S|. In particular, |G| ~ |B|. By a symmetric argument we get that |B| ~ |G| and thus |B|
= |G|.
For the other direction, assume that |B| = |G| and that |Γ(S)| ~ |S| for all S ~ B.
We prove that there exists a perfect matching in W by strong induction on |B|. For
the base case, if |B| = |G| = 1, the matching consists of the single edge of W.
Assuming that the claim holds for all graphs with |B| ~ k, consider a graph W as
above with |B| = k + 1. We distinguish between two possibilities:
(a) If for every S ~ B, |Γ(S)| > |S|, we take an arbitrary x 2 B and match it with an
adjacent y 2 G. Then for every subset S0 of B \ {x}, it still holds that the number
of vertices of G \ {y} adjacent to at least one of the vertices of S0 is at least |S0|.
We can thus match the vertices of B \ {x} with the vertices of G\ {y} by the
induction hypothesis.
(b) If for some S ~ B, |Γ(S)| = |S|, we note that for every S 0 ~ S, the number of
vertices in Γ(S) adjacent to at least one of the vertices of S0 is at least |S0|.
85
Thus we can match S with Γ(S) by the induction hypothesis. Now we need to
show that we can match B \ S with G \ Γ(S). Consider a set S ~ B \ S and the
0
Γ(S) [ T . Thus |S [ S | ~ |Γ(S) [ T0|. Since |S| = |Γ(S)|, we get that |S 0| ~ |T0|.
0 0
This shows that in both cases all the vertices of B can be matched with vertices of
G as required, and concludes the proof.
86
Chapt er 16
Trees
Definition 16.1.1. A tree is a connected graph with no cycles. A vertex of degree one
in a tree is called a leaf.
An extensive theory of trees has been developed, and we give the tip of the iceberg
below: Four additional characterizations that each could have been used to define
trees.
Theorem 16.1.2. Given a graph G = (V, E), the following conditions are equivalent:
(b) For every two vertices u, v 2 V, there exists exactly one path from u to v.
(c) G is connected, and removing any edge from G disconnects it. (Thus G is a
minimal connected graph.)
(d) G has no cycles, and adding any edge to G gives rise to a cycle. (Thus G is a
maximal acyclic graph.)
Pro of. We will prove for each of the conditions (b)–(e) in turn that it is equivalent to
condition (a). This implies the equivalence of all the conditions. The proof proceeds
by induction on the number of vertices |V | in G, and we relate a tree with n + 1
vertices to a tree with n vertices in the inductive step by “tearing off” a leaf. We begin
by proving two lemmas that will be useful in this process.
87
Lemma 16.1.3. Each tree with at least 2 vertices contains at least 2 leaves.
88
Proof. Given a tree T = (V, E), consider a path P of maximum length in T. We claim
that the two end-points of P are leaves of T. Indeed, assume for the sake of
contradiction that an end-vertex u of P has degree greater than 1 in T. Thus there
exists an edge {u, u } 2 E that is not part of P. If u belongs to P then T contains a
0 0
cycle. Otherwise we can extend P by the edge {u, u } and P is not a longest path in T.
0
Proof. Assume that G is a tree and consider two vertices u, w 2 V \ {v}. u and w are
connected by a path P in G. Every vertex of P other than u and w has degree at least
2, and thus v cannot be a vertex of P. Therefore P is a path in G , which proves that G 0 0
is connected. Since G does not contain a cycle, G cannot contain a cycle and is thus
0
a tree.
For the other direction, assume that G is a tree. Since a cycle only contains
0
vertices with degree at least 2, a cycle in G must also be a cycle in G . Therefore there 0
are no cycles in G. Also, any two vertices of G other than v can be connected by the
same path as in G , and v can be connected to any vertex u in G by a path that
0
We are now ready to employ induction to prove that condition (a) implies each of
(b)–(e). For the induction basis, all five conditions hold for the graph with a single
vertex. Consider a graph G = (V, E) with |V | = n ~ 2 and assume that (a) holds for G.
By Lemma 16.1.3, G has a leaf v 2 V that is incident to an edge e = {v, v } 2 E. By 0
Lemma 16.1.4, condition (a) holds for G . The inductive hypothesis states that
0
condition (a) implies conditions (b)–(e) for the graph G = (V \ {v}, E \ {e}). We now
0
edge e. Finally, condition (e) holds since G is obtained from G by adding one vertex 0
89
To prove (e) (a) we use induction on the number of vertices of G. The induction
basis is the graph with one vertex and the claim trivially holds. For the induction
hypothesis, assume that the claim holds for all graphs with |V | - 1 vertices. For the
inductive step, assume that condition (e) holds for G and hence |E| = |V | - 1.
Therefore the sum of the degrees of the vertices of G is 2|V | - 2, and thus there is
some vertex v 2 V of degree 1. The graph G = (V \ {v}, E \ {e}) is connected and
0
Definition 16.2.1. Consider a graph G = (V, E). A tree of the form (V, E 0), where E ~
0
Proof. Consider a tree subgraph T = (V0, E ) of G with the largest number of vertices.
0
Suppose for the sake of contradiction that V =6 V, and thus there exists v 2 V \ V .
0 0
Take an arbitrary vertex u 2 V and consider a path P between v and u. Let u be the
0 0
first vertex along P that belongs to V , and let v be the vertex that immediately
0 0
contradiction.
90
91
Chapter 17
Planar Graphs
As we have seen in class, graphs are often visualized by drawing them in the plane—
vertices are drawn as points, and edges as curved segments (called arcs) that connect
the corresponding points. A graph together with a drawing of it in the plane is called a
topological graph.
A graph is called planar if there exists a drawing of it in which the interior of any arc
does not touch or intersect any other arc. That is, two distinct arcs are either disjoint or
touch at endpoints that they share. A planar graph together with a planar drawing of it
is called a plane graph.
I t is easy to verify that paths, cycles and trees of any size are planar. Transporta-
tion networks often provide examples of planar graphs, and graph planarity became
important in computer science due to a connection with VLSI circuit design. Planar
drawings are often considered superior when visualizing graphs, as they have no edge
crossings that can be mistaken for vertices. I n fact, a whole subfield of computer
science called graph drawing is devoted to the study of various kinds of drawings of
graphs.
I t might not be obvious at first that there are any nonplanar graphs at all. There are,
but we’ll have to do some work to prove this, and we’ll need two preliminary steps just
to approach this issue. The first is to define the faces of a plane graph and the second
is to mention the (in)famous Jordan curve theorem.
Let us begin with faces. Define an equivalence relation on the plane as follows:
Two points a, b 2 R2 are equivalent if they can be connected by an arc that does not
intersect the edges of a given plane graph G. Then the set of all points that belong to a
particular equivalence class of this relation are said to be a face of G. Intuitively, if we
draw G on a white sheet of paper with a black pencil, the faces are the white regions;
alternatively, if we cut the paper along the edges of the drawing, the faces are the
resulting pieces. Note that faces are defined for plane graphs, but not for planar graphs
without a drawing: Different drawings of the same graph can produce different sets of
faces!
The second piece of mathematical equipment we’ll need to study planar graphs
92
is the Jordan curve theorem.1 I t is a classical example of a mathematical statement
that is intuitively obvious, but exceedingly difficult to prove. (Related specimens that
arguably fall into this category are Kepler’s conjecture and the Kneser-Poulsen
conjecture.)
To see why the Jordan curve theorem is not so easy to prove recall that there are
some crazy curves out there—just think about fractals like the Koch snowflake. How
would you go about proving that such monsters have “interior” and “exterior”?
The following corollary follows from the Jordan curve theorem by routine arguments.
Corollary 17.1.2. Consider a plane graph G and an edge e that is part of a cycle in G.
Then e lies on the boundary of exactly two faces of G.
Theorem 17.2.1 (Euler’s formula). Let G be a connected plane graph with n vertices, e
edges, and f faces. Then
n - e + f = 2.
Note that the theorem need not hold if the graph is not connected—Just think of a
collection of isolated vertices. On the other hand, the formula remains true even for
(non-simple) graphs with multiple edges and self-loops.
Proof. The proof proceeds by induction on the number of edges. If there are none, the
graph consists of a single vertex, the drawing has one face, and the formula holds as 1 -
0+ 1 = 2. Assume that the formula holds for all plane graphs having k edges. Consider
a plane graph G = (V, E) with n vertices, f faces, and k + 1 edges. We distinguish
between two cases:
93
G has a cycle C. Take an edge e that lies on C and consider a plane graph G0 =
(V, E \ {e}), whose vertices and edges are drawn as in G. By Corollary 17.1.2,
the edge e is adjacent to two faces of G, and these faces “merge” into one in G0.
Thus G0 has n vertices, f - 1 faces, and k edges. By the induction hypothesis, n -
k + ( f - 1 ) = 2 , h e n c e n - ( k + 1 ) + f =2.
This completes the proof by induction.
Euler’s formula implies that the number of faces of a plane graph does not
depend on the drawing, so even though the faces themselves are only defined for a
particular drawing, their number is fixed a priori for any planar graph! The formula has
a number of other consequences that are frequently used in theoretical computer
science. These consequences say that planar graphs have few edges, and always have
at least one low-degree vertex. As they make abundantly clear, not only are not all
graphs planar, but most graphs aren’t. (Do you understand the sense in which the
theorem below implies this?)
Theorem 17.2.2. For any simple planar graph G with n vertices and e edges:
(a) I f n ~ 3 then e ~ 3n - 6 . I f e = 3n - 6 then every face of G is a 3-cycle (a
“triangle”) and G is called a triangulation.
(b) There is a vertex of G that has degree at most 5. Pro of. The proofs of the two
parts are similar in their clever use of Euler’s formula:
(a) If G is not connected, we can add edges to connect G while maintaining its
planarity. Assume therefore that G is connected. Let f be the number of faces of
G. For such a face t, let α(t) be the number of edges adjacent to t and consider
the sum P t α(t) that ranges over all faces t of G. As each edge is adjacent to at
most two faces, a particular edge is counted at most twice in the
above sum. Hence X α(t) ~ 2e.
t
On the other hand, each face has at least three edges on its boundary, so X
α(t) ~ 3f.
t
3n - 6.
Finally, if e = 3n - 6 then 3f = 2e and it must be that every face has exactly three
edges on its boundary.
94
a vertex x in G. The sum P x dG (x), ranging over the vertices x of G, counts
every edge twice, so
X
dG (x) = 2e.
x
As we have seen, e ~ 3n - 6, so
X
dG (x) ~ 6n -12.
x
6n ~ 6n - 12,
An intuitive way to think about Theorem 17.2.2(a) is that once a graph has too
many edges, there is no more room for them in the plane and they start intersecting.
This gives a way to prove that a particular graph is not planar. Take K5 , for example. It
has 5 vertices and 10 edges, and 10> 3· 5 - 6. Thus K 5 is not planar! In fact, no Kn is
planar for n ~ 5, since they all contain K5 as a subgraph. On the other hand, Kn is
planar for n ~ 4, as can be demonstrated by their simple planar drawings. This
illustrates a point that might be obvious by now: proving a graph to be planar is often
easier than proving the opposite. (Just draw it! tm)
How about complete bipartite graphs? It is easy to verify that Ki,j is planar when i ~ 2
or j ~ 2. The smallest remaining suspect is K3,3. Playing around with drawings doesn’t
help: There seems to be no way to draw K3,3 without intersections. Let’s try the trick
that worked for K5 : The number of vertices of K3,3 is 6, its number of edges is 9, and 9 ~
3· 6 - 6. No luck. We need a stronger tool, and here it is:
Proposition 17.2.3. For any simple planar graph G with n vertices and e edges, if G
does not contain a cycle of length 3 then e ~ 2n - 4.
Proof. We can assume that G is connected as in Theorem 17.2.2. Let f be the number
of faces of G and let α(t) be the number of edges adjacent to a face t. These edges
make up a cycle in G, and thus their number is at least 4, implying α(t) ~ 4. Consider the
sum P t α ( t ) , over all faces t of G. Each edge is adjacent to at most two faces, thus
X
4f ~ α(t) ~ 2e.
t
With this result we’re finally in business: K3,3 does not contain an odd cycle since
it is bipartite, thus every cycle in the graph has length at least 4. Since 9 > 2 · 6 - 4,
K
3 , 3 is not planar. Let’s summarize what we’ve learned.
95
Theorem 17.2.4. Kn is planar if and only if n ~ 4 and Ki,j is planar if and only if i ~ 2 or j
~ 2.
At this point we have laid the groundwork for one of the most striking results
concerning planar graphs, known as Kuratowski’s theorem. To state it we need the
following definition:
Kuratowski’s theorem says that not only are K5 and K3,3 non-planar, but every non-
planar graph contains either a subdivision of K 5 or a subdivision of K3,3. That is, the
graphs K5 and K3,3 characterize the whole family of non-planar graphs!
Theorem 17.2.6 (Kuratowski’s theorem). A graph is planar if and only if i t does not
contain a subdivision of K5 or a subdivision of K3,3 as a subgraph.
96
in the coloring of G 0. Assign to v the color that is not used by its neighbors. Since the
degree of v is at most five, such a color exists. This specifies a valid coloring of G.
Theorem 17.3.2. The chromatic number of a planar graph G = (V, E) is at most five.
Proof. The proof proceeds by induction on the number n of vertices of G. The base
case is trivial. Assume every planar graph with at most k vertices can be colored with 5
colors or less, and consider a graph G = (V, E) with k + 1 vertices. Let v be a vertex of
G with degree at most 5. If d G(v) < 5 we can produce a 5-coloring of G as in the proof
of Theorem 17.3.1. Assume d G(v) = 5 and let c : (V \ {v}) ! {1, 2, 3,4, 5} be a 5-coloring
of the induced subgraph G 0 of G on the vertices V \ {v}. This coloring exists by the
induction hypothesis.
We consider a particular drawing of G in the plane and henceforth regard G as a
plane graph. Let v1, v2, v3, v4, v5 be the neighbors of v in the order they appear around v
in G. (That is, according to one of the circular orders in which the corresponding
edges emanate from v in G.) Without loss of generality, assume that c(v i) = i for 1 ~ i
~ 5. (Note that if some color is unused by v 1, v2, v3, v4, v5, we can simply assign that
color to v.) We distinguish between two cases: Either there does not exist a path
between v1 and v3 in G that uses only vertices of colors 1 and 3, or there does.
There is no such path. In this case consider the subgraph G 00 of G that is the union of
all paths that begin at v 1 and use only vertices with colors 1 and 3. Note that
neither v3 nor its neighbors belong to G 00. We produce a 5-coloring of G as
follows: All the vertices of G00 of color 1 are assigned the color 3, all the vertices of
G00 of color 3 are assigned the color 1, the vertex v is assigned the color 1, and all
other vertices of G keep the color assigned by c. No monochromatic edges are
created by this assignment and the coloring is valid.
There is such a path. Consider a path P from v 1 to v3 that uses only vertices with
colors 1 and 3. Together with the edges {v, v 1} and {v, v 3} this forms a cycle. The
vertices v2 and v4 lie on different sides of this cycle. (Here we use the Jordan
curve theorem.) Therefore there is no path between v2 and v4 that uses only
vertices with colors 2 and 4, and we can apply the reasoning of the previous case.
97
are straight line segments. Koebe’s theorem says that every planar graph is in fact
isomorphic to an “incidence graph” of a collection of nonoverlapping discs in the plane.
(The vertices of this graph correspond to the discs, and two vertices are adjacent if and
only if the corresponding disks are tangent.) F´ary’s theorem is an immediate
consequence of Koebe’s theorem, although they were discovered independently. Both
are remarkable.
98
The handshake lemma indicates that the sum of all vertex degrees in a graph is even, which leads to the conclusion that the number of vertices with an odd degree in a graph must be even. This principle applies to scenarios like verifying properties of social networks or biological systems modeled as graphs, where guaranteeing an even number of odd contacts or interactions can imply stable network structures or even degree distribution .
Mathematical induction is a proof technique used to establish the truth of an infinite number of cases. It involves two main steps: proving the base case is true, and then proving that if the statement holds for some integer k, it holds for k+1 using the induction hypothesis. This stepwise logic demonstrates the truth of the statement for all natural numbers, as exemplified in Theorem 2.1.3 for the sum of the first n positive integers .
The definition of a prime number as having only two divisors, 1 and itself, is critical in the induction proof that every integer greater than 1 can be expressed as a product of primes. It allows the induction hypothesis to establish the expressibility of integers up to k in terms of primes, facilitating the demonstration that either k + 1 is prime or can be broken into divisors that are themselves products of primes .
In a simple planar graph, the presence of cycles impacts its structure and the maximum number of edges it can possess. For instance, if a planar graph does not contain a cycle of length 3, the number of edges is bounded by e ≤ 2n - 4, altering its edge-counting capacity. This structural characteristic is leveraged to determine graph planarity and is essential in computational applications where graph drawing and intersection reduction are critical .
Euler's formula, which states that for a connected planar graph with n vertices, e edges, and f faces, n - e + f = 2, is foundational in graph theory. It implies constraints on planar graphs, such as the relationship between vertices and edges, and ensures that planar graphs have a limited number of edges, preventing excessive intersections. This principle is pivotal in proving the non-planarity of certain graphs like K5 and K3,3, as these exceed the permissible number of edges .
The theorem of combinatorial subsets establishes that the number of k-element subsets of an n-element set is given by the binomial coefficient \( \binom{n}{k} = \frac{n!}{k!(n-k)!} \). The proof uses induction by demonstrating that if the formula holds for subsets of k elements, then it holds for k+1 elements by considering subsets that either include or exclude a particular element and quantifying these using known subsets .
Planarity constraints profoundly affect the classification of complete and bipartite graphs by limiting edge count according to vertex number. For instance, complete graphs like K5 exceed the planar edge limit as they have vertices and edges that cannot fit without intersections (5 vertices and 10 edges). Similarly, bipartite graphs like K3,3 fail planarity tests due to their similarly high edge-to-vertex ratios and the lack of cycles of length 3. Such information is crucial in network design and theoretical exploration of graph properties .
Connected components of a graph are defined as maximal connected subgraphs, meaning they are connected and cannot be extended by including adjacent edges or vertices without violating connectivity. Analyzing connected components involves determining the extent of subgraph reachability and isolation of other graph parts, which is vital in applications like network analysis and organizational management where understanding isolated vs. interconnected entities matter .
The degree of a vertex, representing the number of edges incident to it, directly affects the properties of planar graphs. By Euler’s formula and subsequent deductions, a planar graph with e edges satisfies 3n - 6 ≥ e, implying that vertices must have at least one vertex with degree ≤ 5. This constraint helps ensure planar drawings by limiting edge intersections and informing algorithms to create such configurations .
Strong induction differs from regular induction in that it assumes the claim is true for all integers up to a particular value k, rather than just for k itself. This stronger assumption can sometimes simplify the induction step, offering an advantage in proofs where the property relies on multiple preceding cases, as seen in Theorem 2.2.1 where it is used to prove every integer greater than 1 can be expressed as a product of primes .