Discrete Mathematics: Haluk Bingol February 21, 2012
Discrete Mathematics: Haluk Bingol February 21, 2012
Discrete Mathematics: Haluk Bingol February 21, 2012
Haluk Bingol
I Preliminaries 1
1 Preliminaries 3
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 On definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Similar statements . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Set of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 6
II Basics 7
2 Logic 9
2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Foundations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.1 Well-formed formula . . . . . . . . . . . . . . . . . . . 10
2.2.2 Logical Axioms . . . . . . . . . . . . . . . . . . . . . . 11
2.2.3 Rules of Inference . . . . . . . . . . . . . . . . . . . . . 11
2.2.4 Equality . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Propositional Logic . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.1 Compound Propositions . . . . . . . . . . . . . . . . . 12
2.3.2 Application . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4 Propositional Equivalence . . . . . . . . . . . . . . . . . . . . 16
iii
iv CONTENTS
3.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4 Relations on a Set 37
4.1 Relations on a Set . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.2 Observations on the Matrix of a Relation . . . . . . . . . . . . 38
4.3 Closure of Relations . . . . . . . . . . . . . . . . . . . . . . . 39
4.4 Compatibility Relation . . . . . . . . . . . . . . . . . . . . . . 39
4.4.1 Application of Compatibility Relation . . . . . . . . . . 41
4.5 Equivalence Relation . . . . . . . . . . . . . . . . . . . . . . . 42
4.5.1 Applications of Equivalence Relations . . . . . . . . . . 43
4.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
III Algebra 57
6 Algebraic Structures 59
6.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6.2 Algebraic Structures . . . . . . . . . . . . . . . . . . . . . . . 61
6.2.1 Binary Operations . . . . . . . . . . . . . . . . . . . . 61
6.2.2 Algebraic Structure . . . . . . . . . . . . . . . . . . . . 62
6.2.3 Sub-Algebraic Structures . . . . . . . . . . . . . . . . . 63
6.3 With One Binary Operation . . . . . . . . . . . . . . . . . . . 65
6.3.1 Semigroup . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.3.2 Monoid . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.3.3 Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.4 With Two Binary Operations . . . . . . . . . . . . . . . . . . 69
6.4.1 Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.4.2 Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.4.3 Lattice . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.4.4 Vector Spaces . . . . . . . . . . . . . . . . . . . . . . . 72
CONTENTS v
6.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7 Boolean Algebras 77
7.1 Reminders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.2 Lattices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.3 Boolean Algebras . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.3.1 Distributive Lattice . . . . . . . . . . . . . . . . . . . . 78
7.3.2 n-cube . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7.3.3 Bounded Lattice . . . . . . . . . . . . . . . . . . . . . 80
7.3.4 Complemented Lattice . . . . . . . . . . . . . . . . . . 80
7.4 Boolean Algebra . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.5 Canonical Expressions in Boolean Algebras . . . . . . . . . . . 82
IV Number Systems 83
8 Number Systems 85
8.1 Natural Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.2 Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9 Division 89
9.1 Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
9.2 Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 91
9.3 Common Divisors and Multiples . . . . . . . . . . . . . . . . . 93
9.4 Modular Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . 94
V Combinatorics 97
10 Counting 99
10.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
10.2 Cardinality: Finite and Infinite Sets . . . . . . . . . . . . . . . 100
10.2.1 Hierarchy of Infinities . . . . . . . . . . . . . . . . . . . 103
10.3 The Number of Ways . . . . . . . . . . . . . . . . . . . . . . . 104
10.3.1 The Product Rule . . . . . . . . . . . . . . . . . . . . . 105
10.3.2 The Sum Rule . . . . . . . . . . . . . . . . . . . . . . . 107
10.3.3 The Inclusion-Exclusion Rule . . . . . . . . . . . . . . 108
10.4 The Pigeonhole Principle . . . . . . . . . . . . . . . . . . . . . 109
vi CONTENTS
11 Recurrence 121
11.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
11.2 Recurrence Equations . . . . . . . . . . . . . . . . . . . . . . . 121
11.3 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
VI Graphs 125
12 Graphs 127
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
12.2 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
12.2.1 Reachability and Strong-Connectedness . . . . . . . . . 129
12.2.2 Application of Multigraphs . . . . . . . . . . . . . . . . 133
12.3 Undirected Graphs . . . . . . . . . . . . . . . . . . . . . . . . 135
12.4 Path Problems . . . . . . . . . . . . . . . . . . . . . . . . . . 137
12.5 Planarity and Coloration . . . . . . . . . . . . . . . . . . . . . 138
12.6 Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
12.6.1 Minimal Spanning Tree Algorithm . . . . . . . . . . . 140
12.6.2 Rooted Tree . . . . . . . . . . . . . . . . . . . . . . . . 140
12.7 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Index 147
The Notation Index . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
The Concepts Index . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Part I
Preliminaries
1
Chapter 1
Preliminaries
1.1 Motivation
This text is not ment to be printed. It is designed to be read electronically.
You will find many hyperlinks to sources in the web. Especially incredible
wikipedia.com, which this book is dedicated to, gets many of them.
1.2 On definitions
Definitions are one of the starting points of mathematics. We should under-
stand them well. By definition what we actually do is to give a “name” to
“something”. To start with, “that something” should be well-defined, that
is, everybody understand the same without any unambiguity. What is in it,
what is not in it should be clearly understood. Once we are all agree on “it”,
we give a “name”.
The given name is not important. It could be some other name. Consider
a text on geometry. Suppose we replace every occurrence of rectangle with
triangle. The entire text would be still perfectly proper geometry text. This
would be obvious if one considers the translation of the text to another
language.
Example 1.2.1. Suppose we all agree on parallelogram and right angle and try
to define rectangle. A parallelogram is called rectangle if it has a right angle.
Here we have an object which satisfies the conditions of both parallegram
and right angle.
3
4 CHAPTER 1. PRELIMINARIES
1 + (1 + 1) = 1 + 2 = 3
the usage of “=” is the regular usage meaning the right hand side of “=”
is obtained from the left hand side by applying some rules. In the case of
defining subtraction as
a − b = a + b−1
where b−1 is the additive inverse of b, a − b is defined in terms of known
binary operation + and unary operation of additive inverse. Therefore these
will be written as
1 + (1 + 1) = 1 + 2 = 3
∆
a−b = a + b−1
in this text.
1.3. SIMILAR STATEMENTS 5
Example 1.2.2. Golden ration is the ratio of the sides of a rectangle which is
presumable the aesthetically best. It is usually represented by φ. This can
be given as: √
∆ 1+ 5
φ = .
2
∆ ∆
As a summary, we exclusively use = and ←→ in the definitions.
∆
Therefore, it does not make sense trying to prove expressions such as A ←→
∆
B or A = B. On the other hand, in the expressions such as A ←→ B or
A = B, the right hand side should be able to obtained from the left hand
side. At the same time, the left hand side also should be able to obtained
from the right hand side. That is, they are “provable”.
In addition to this notation, the concept defined is presented in different
color as in the case of new concept.
∆
Example 1.2.3. Z+ = { z ∈ Z | z > 0 }.
∆
Example 1.2.4. n is even ←→ n is divisible by 2.
Basics
7
Chapter 2
Logic
2.1 Motivation
In the first half of 1900s mathematicians believed that entire mathematics
can be constructed from a set of axioms, inference rules and symbolic logic.
In 1910’s, Bertrand Russell, now known due to his works in philosophy, and
Alfred North Whitehead published Principia Mathematica which provided
carefully designed construction of mathematics. They claim that every true
mathematical statement can be proved by this way. Unfortunately in 1931
Kurt Gödel proved, in his incompleteness theorem, that there are some true
statements that cannot be proven if the axiomatic system is consistent and
sufficiently powerful to express the arithmetic of the natural numbers. The
famous incompleteness theorem becomes one of the important milestones in
Computer Science, too.
The logic is important for Computer Science in many ways. Search in the
web is one of them. When we do search using a search engine in the Internet,
we express ourselves using logic. For example typing
to Google for search means we are looking pages which contains “Bertrand”
and “Russell” words together, either of the words “Mathematica” or “Kurt”
but we do not want word “philosopher” in our search. This can be rewritten
in logic as “Bertrand” AND “Russell” AND *“Mathematica” OR “Kurt”)
AND NOT“philosopher”.
9
10 CHAPTER 2. LOGIC
2.2 Foundations
We use the notation of [TZ82] in defining well-formed logical formula. We
use spaces in order to improve readability as in the case of ∀x φ(x) or φ ∧ ψ
which should formally be written as ∀xφ(x) or φ ∧ ψ.
ii. If φ and ψ are wffs, then ¬φ, [φ ∨ ψ], [φ ∧ ψ], [φ −→ ψ], and [φ ←→ ψ]
are wff.
iii. If φ is a wff and x is a bound variable, then ∀x φ(x) and ∃x φ(x) are
wff, where φ(x) is the formula obtained from the wff φ by replacing
each occurrence of some free variable a by the bound variable x. We
call ∀xφ(x) and ∃xφ(x) respectively, the formula obtained from φ by
universally, or existentially qualifying on the variable a.
Example 2.2.2. Examples of wffs are as follows where p = x0 and q = x1 .
i. p and q are wffs due to Definition 2.2.1(i).
ii. ¬p, p ∨ q, p ∧ q, p −→ q, p ←→ q are wffs due to Definition 2.2.1(ii).
iii. [p ∧ q] ∨ ¬p, [p ∧ q] ∨ ¬[p −→ q] are wffs due to Definition 2.2.1(i)
and (ii) .
iv. ∃x [x ∈ a1 ] is a wff. Since
[a0 ∈ a1 ] by Definition 2.2.1(i)
∃x [x ∈ a1 ] by existential qualifying on a0 .
v. ∃x [x ∈ a1 ] ∧ ∀x [x ∈ a1 ] is a wff.
2.2.4 Equality
Definition 2.2.3 (Equality).
∆
a=b ←→ ∀x [x ∈ a ←→ x ∈ b].
Proposition 2.2.1.
i. a = a.
ii. a = b −→ b = a.
iii. a = b ∧ b = c −→ a = c.
Proof.
i. ∀x[x ∈ a ←→ x ∈ a].
ii. ∀x[x ∈ a ←→ x ∈ b] =⇒ ∀x[x ∈ b ←→ x ∈ a].
iii. ∀x[x ∈ a ←→ x ∈ b] ∧ ∀x[x ∈ b ←→ x ∈ c] =⇒ ∀x[x ∈ a ←→
x ∈ c].
Remark 2.2.1. If a = b and a wff holds for a, then it must hold for b.
a = b =⇒ [φ(a) ←→ φ(b)].
f2 = ¬p
f0 = F
f3 = T
f1 = p
p
F F F T T
T F T F T
f14 = p NAND q
f13 = p −→ q
f9 = p ←→ q
f8 = p NOR q
f7 = p ∨ q
f1 = p ∧ q
f6 = p ⊕ q
f12 = ¬p
f10 = ¬q
f15 = T
f0 = F
f3 = p
f5 = q
f11
f4
p q
F F F F F F F F F F T T T T T T T T
F T F F F F T T T T F F F F T T T T
T F F F T T F F T T F F T T F F T T
T T F T F T F T F T F T F T F T F T
∆
Definition 2.3.2. The set B = { T, F } is called boolean domain where T
and F denotes true and false, respectively. An n-tuple (p1 , p2 , . . . , pn ) where
pi ∈ B is called a boolean n-tuple.
Remark 2.3.1.
i. A boolean n-tuple is an element of Bn , that is, (p1 , p2 , . . . , pn ) ∈ Bn .
ii. There are 2n different binary n-tuples.
iii. A truth table of a predicate p actually defines a function fp : Bn → B.
14 CHAPTER 2. LOGIC
n
iv. There are 22 different truth tables (functions) of binary n-tuples.
1
v. There are 22 = 4 monadic operators, identity, negation, constant-True,
constant-False, as given in Table 2.3.1.
2
vi. There are 22 = 16 dyadic operators as given in Table 2.3.1.
vii. Note that the functions in the Table 2.3.1 have interesting properties:
Firstly, notice the relation between fi and the binary representation of
i if F and T are represented as 0 and 1, respectively. For example f11
corresponds to T F T T = 1011. Secondly, fi = ¬f15−i as in the case of
f3 = ¬f12
viii. NAND and NOR are extensively used in logic design in Computer Engineer-
ing.
∆
ix. p NAND q = ¬(p ∧ q). That is, f14 (p, q) = ¬f1 (p, q).
∆
x. p NOR q = ¬(p ∨ q). That is, f8 (p, q) = ¬f7 (p, q).
Definition 2.3.5. Any wff is a compound propositions.
Remark 2.3.2. In other words, propositions formed from existing propositions
using logical operators are called compound propositions.
Definition 2.3.6. Let p be a proposition. The negation of p, denoted by ¬p
or p̄, is the statement “It is not the case that p”.
Definition 2.3.7. Let p and q be propositions. The conjunction of p and q,
denoted by p ∧ q, is the proposition “p and q”.
(
∆ T, if both p and q are true,
p ∧ q =
F, otherwise.
Definition 2.3.8. Let p and q be propositions. The disjunction of p and q,
denoted by p ∨ q, is the proposition “p or q”.
(
∆ F, if both p and q are false,
p ∨ q =
T, otherwise.
Definition 2.3.9. Let p and q be propositions.
exclusive or of p and q p⊕q
The conditional statement , denoted by p −→ q , is the function
biconditional statement p ←→ q
f6
f13 in the Table 2.3.1.
f9
2.3. PROPOSITIONAL LOGIC 15
Remark 2.3.3.
i. Conditional p −→ q, sometimes called implication.
ii. Some other English usages are “if p, then q”, “p implies q” and many
more.
iii. p is called the hypothesis. q is called the conclusion.
Remark 2.3.4.
i. Biconditional p ←→ q, sometimes called bi-implication or if-and-only-
if , iff in short.
ii. Some other English usages are “p is necessary and sufficient for q”, “p
iff q”.
iii. Note that p ←→ q is equivalent to (p −→ q) ∧ (q −→ p).
Corollary 2.3.1.
implication, p −→ q contrapositive, ¬q −→ ¬p
The is equivalent to .
converse, q −→ p inverse, ¬p −→ ¬q
2.3.2 Application
Logic descriptions is used in all branches of science and engineering. Unam-
biguous, precise, consistent reporting is a must.
System specifications
In engineering precise, formal descriptions are needed. Software develop-
ment is one of them. A typical software life cycle is as follows: A customer
who needs a custom tailored software solution defines what she wants. This
definition will be given to the contracting company. The developers start de-
veloping the software. At the end the software is delivered to the costumer.
The costumer checks if the developed software meets the specification.
In such a scenario the definition should be as precise as possible. Think
about the consequences if the definition is not precise, informal, possibly
ambiguous. It is not that unusual that the definitions have some conflict or
contradicting requirements.
Equivalence Name
p ∧ T ≡p Identity laws
p ∨ F ≡p
p ∧ F ≡F Domination laws
p ∨ T ≡T
p ∧ p≡p Idempotent laws
p ∨ p≡p
p ∧ q≡q ∧ p Commutativity laws
p ∨ q≡q ∨ p
p ∧ (q ∧ r) ≡ (p ∧ q) ∧ r Associativity laws
p ∨ (q ∨ r) ≡ (p ∨ q) ∨ r
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) Distributivity laws
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ p Absorption laws
p ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ F Negation laws
p ∨ ¬p ≡ T
¬(p ∧ q) ≡ ¬p ∨ ¬q De Morgan’s laws
¬(p ∨ q) ≡ ¬p ∧ ¬q
¬(¬p) ≡ p Double negation law
Contradictions: F , ¬T , p ∧ F , p ∧ ¬p.
Contingencies: p, ¬p, p ∨ F , p ∧ T .
Q1 [20 points]
a) Express each of these statements using quantifiers and the following
predicates where the domain consists of all people.
S(x) : x is a student in this class. M(x) : x is a mathematician
L(x) : x likes discrete mathematics course. C(x, y) : x and y are colleagues
K(x, y) : x knows y
i) There are exactly two students in this class who like discrete math-
ematics course.
ii) Every student in this class knows Kurt Gödel or knows a mathe-
matician who is a colleague of Kurt Gödel.
iii) There is no student in this class who knows everybody else in this
class
Solution.
a)
i) ∃x∃y [x 6= y ∧ S(x) ∧ S(y) ∧ L(x) ∧ L(y) ∧ ∀z (S(z) ∧ L(z) → z =
x ∨ z = y)]
ii) ∀x [S(x) → [K(x, Godel) ∨ ∃y (M(y) ∧ C(y, Godel) ∧ K(x, y))]]
iii) ¬∃x∀y [S(x) ∧ ((S(y) ∧ x 6= y) → K(x, y))]
b)
2.4. PROPOSITIONAL EQUIVALENCE 19
Q2 [20 points]
Solution.
20 CHAPTER 2. LOGIC
Chapter 3
3.1 Set
3.1.1 Sets
Definition 3.1.1. A set is unordered collection of objects.
Remark 3.1.2. There is one and only one empty set. ∅ has interesting prop-
erties: Let A = ∅ and B = { ∅ }. Then A ∈ B ∧ A ⊆ B.
Remark 3.1.3. Let P (x) be a property. Then the following two propositions
are true:
21
22 CHAPTER 3. SETS, RELATIONS, AND FUNCTIONS
i) ∀x ∈ ∅ [P (x)]
ii)¬∃x ∈ ∅ [P (x)]
Definition 3.1.3 (Equality of Sets).
∆
A is equal to B: A = B ←→ ∀x [ x ∈ A ←→ x ∈ B ].
∆
A is not equal to B: A 6= B ←→ ∃a (a ∈ A ∧ a ∈
/ B) ∨ ∃b (b ∈
/ A ∧ b ∈ B).
BkCk
Example 3.1.5. For sets A, B, C in A
the figure, A ∪ B = A ∪ C ∧ B 6= C.
&%
∆
Definition 3.1.14. A and B are disjoint ←→ A ∩ B = ∅.
Theorem 3.1.7 (Principle of Inclusion-Exclusion).
(
|A|+ |B| if A ∩ B = ∅,
|A ∪ B| =
| A | + | B | − | A ∩ B | if A ∩ B 6= ∅.
3.2 Relation
Remark 3.2.1. A × B = { (a, b) | a ∈ A ∧ b ∈ B }.
Remark 3.2.2. If sets A and B are finite with |A| = n and |B| = m, the ele-
ments of A and B can be listed in an arbitrary order as A = { a1 , a2 , . . . , an }
and B = { b1 , b2 , . . . , bm }. Then binary relation α ⊆ A × B can be repre-
sented by an n × m (0, 1)-matrix, denoted by Mα , as
(
∆ 1, ai α bj
[Mα ]ij =
0, otherwise.
Note that there are n rows correspond to the ordered elements of A, and
m columns correspond to the ordered elements of B.
Example 3.2.1.
Let α = { (3, b), (3, c), (7, c) } ⊆ A × B where A = { 1, 3, 7 } and B =
{ a, b, c, d }.
Remark 3.2.3. The cartesian and the matrix representations are related. Ro-
tate the cartesian representation by 90◦ clock wise, and compare with the
matrix representation.
Question 3.2.1. How many different binary relations from A to B can be
defined?
3.3 Functions
Remark 3.3.1. Let f be a relation from A to B. Pick an a ∈ A and consider
∆
the corresponding set Ba ⊆ B defined as Ba = { b | (a, b) ∈ f }. Note that
3.3. FUNCTIONS 29
| Ba | could be 0, 1, 2, . . . .
0 not mapped to any b ∈ B
If | Ba | = 1 , then a is mapped to exactly one b ∈ B .
n≥2 mapped to n elements of B
Remark 3.3.2. Any computer program is actually a partial function from its
input space to its output space. For some inputs in its domain it terminates
and produces outputs. For some other inputs it does not terminate. Hence
for those inputs there is no corresponding outputs. That is the reason that
it is a partial function.
-5 -4 -3 -2 -1 0 1 2 3 4 5
-1
-2
A domain
Definition 3.3.3. B is called the codomain of f and written as
f (A) range
dom f
cod f .
ran f
∆
←→ [∀a ∈ A, ∀b ∈ B (a, b) ∈ f1 ←→ (a, b) ∈ f ].
Remark 3.3.4 (The inverse of a function). Note that for any relation α from
A to B, there is a unique inverse relation from B to A. This inverse relation
usually denoted by α−1 . Since a function f from A to B is also a relation,
there is an inverse relation from B to A which is also denoted as f −1 . Note
that f −1 is a relation but not necessarily a function. f −1 becomes a function
if and only if f is a bijection.
Remark 3.3.6.
• f −1 (B) = { a ∈ A } f (a) ∈ B
Example 3.3.2.
Show that any function f : A → B can be represented as the composition
of g and h, f = h ◦ g, where g is a surjection, h is an injection.
Question 3.3.4.
• Are Di ’s disjoint?
• What is f −1 (B)?
• What is f (f −1 (B))?
• What kind of function is f if B\f (A) = ∅?
• What kind of function is f if ∀b ∈ B [| f −1 (b) | = 1]?
3.4. PROBLEMS 33
3.4 Problems
Q3 [20 points]
a) Prove or disprove that set difference distributes over union, that is,
A − (B ∪ C) = (A − B) ∪ (A − C).
34 CHAPTER 3. SETS, RELATIONS, AND FUNCTIONS
Solution.
a) A − (B ∪ C) = (A − B) ∪ (A − C)
Consider the following counter example which disproves the statement.
Let A = {1, 2, 4, 5}, B = {2, 3, 5, 6} and C = {4, 5, 6, 7}.
Then A − (B ∪ C) = {1, 2, 4, 5} − {2, 3, 4, 5, 6, 7} = {1} and
(A−B)∪(A−C) = ({1, 2, 4, 5}−{2, 3, 5, 6})∪({1, 2, 4, 5}−{4, 5, 6, 7}) =
{1, 2, 4}.
Hence, A − (B ∪ C) 6= (A − B) ∪ (A − C).
b) Proof by contradiction: Let f : A → A and g : A → A and
∀a ∈ A f (a) = g(f (f (a))) (I), and g(a) = f (g(f (a))) (II), but f 6= g.
Then ∃s ∈ A f (s) 6= g(s).
f(s) 6= g(s)
⇔ g(f (f (s))) 6= g(s) since f = g(f (f ))
⇔ f (g(f (f (f (s))))) 6= g(s) since g = f (g(f ))
⇔ f (g(f (f (f (s))))) 6= g(s)
| {z }
f
⇔ f (f (f (s))) 6= g(s) since f = g(f (f ))
⇔ f (f ( f ))) 6= g(s)
|{z}
g(f (f (s)))
⇔ f (f (g(f (f (s))))) 6= g(s) since f = g(f (f ))
⇔ f (f (g(f (f (s))))) 6= g(s)
| {z }
g
⇔ f (g(f (s))) 6= g(s) since g = f (g(f ))
⇔ g(s) 6= g(s) since g = f (g(f )). Contradiction!
Hence, f = g.
Q4 [20 points]
Solution.
3.4. PROBLEMS 35
36 CHAPTER 3. SETS, RELATIONS, AND FUNCTIONS
Chapter 4
Relations on a Set
reflexive reflexive
symmetric symmetric
Theorem 4.1.1. If ρ is then ρ−1 is .
antisymmetric antisymmetric
transitive transitive
Example 4.1.1.
a> 0 1 1 0 0 A tree
>>
>>
0 0 0 1 1 RST
>>
> 0 0 0 0 0
b= c 0 0 0 0 0
===
== 0 0 0 0 0
==
d e
1O ^=o 4 0 0 0 0 greater then relation
== 1 0 0 0 RST
==
= 1 1 0 0
=
2 o 3 1 1 1 0
37
38 CHAPTER 4. RELATIONS ON A SET
α1 α7
0 1 0 ∆
•1 i )
•2 i )
•3 aαb ←→ | a − b | = 1
1 0 1 RST
α3 α9
0 1 0
• α
is ordinary −→ No pattern in the matrix.
1 1 0 0
0 0 1 0
1 0 0 1
1 0 1 0
'
• •
•
α is reflexive ←→
The main diagonal is all 1’s.
1 1 0 0
0 1 1 0
1 0 1 1
1 0 1 1
a
• ≡ •
Omit loops.
• α
is both reflexive
and symmetric.
1 0 1 0 . . . .
0 1 1 0 0 . . .
1 1 1 1 1 1 . .
0 0 1 1 0 0 1 .
'
•g • ≡ • •
• α is transitive.
•
' •W
( •
i. γ is reflexive
ii. γ is symmetric
Remark 4.4.1. Note that equivalence relation has one more property, namely
transitivity.
β is an equivalence relation −→ β is a compatibility relation.
∆
Definition 4.4.2. C ⊆ A is called a compatibility class (compatible) ←→
∀c1 , c2 ∈ C [c1 γ c2 ] where γ is a compatibility relation.
∆
Theorem 4.4.3. γ is a compatibility relation on A ←→ ∃ relation ρ from
A to some B ∋ γ = ρρ−1 with ∀a ∈ A [∃b ∈ B [a ρ b]]
Example 4.4.1.
Complete cover
Cγ (A) = {A1 , A2 , A3 , A4 , A5 , A6 } is a complete cover.
′
Cγ (A) = {A1 , A2 , A3 , A4 , A5 , A7 } is not since A4 ⊆ A7 .
4.4. COMPATIBILITY RELATION 41
∆
Definition 4.4.5. States a and b are compatible, aγb, where γ ⊆ S × S ←→
If no applicable input sequence to both a and b produce conflicting outputs.
√
a
√
b c,c e,e
√
c × b,c c,e
√
d b,c c,e b,c c,e ×
√
e × e,e c,e a,a ×
a b c d e
{ a, b } is a compatible.
{ a, b, d } is a maximal compatible.
{ { a, b, d } , { b, c, e } } is a complete cover.
Let A = { a, b, d } , B = { b, c, e }
I1 I2 I3
A B,0 B,1 B,-
B B,0 B,0 A,-
42 CHAPTER 4. RELATIONS ON A SET
α, β I1 I2 Define ≡⊆ Q × Q as follows:
a b, 1 h, 1 a is equivalent to b ←→ a ≡ b
b f, 1 d, 1 ∆
←→ no input sequence can distinguish a from b.
c d, 0 e, 1
d c, 0 f, 1 ≡ is an equivalence relation
e d, 1 c, 1 since ∀a, b, c ∈ S
f c, 1 c, 1 i. a ≡ a
g c, 1 d, 1 ii. a ≡ b −→ b ≡ a
h c, 0 a, 1 iii. a ≡ b, b ≡ c −→ a ≡ c
a b
a
h c
b,f
d,h
b
g d
c f e
c,d complete cover:
e,f { { a } , { b } , { c, d } , { e, f, g } , { h } }
d
b,d d,f
c,h c,d
e
b,c c,f c,d
c,h c,d c,c
f
b,c c,f c,d c,c
d,h d,d c,d c,d
g
c,d c,c
a,e a,f
h
a b c d e f g h
Let A = { a } , B = { b } , C = { c, d } , E = { e, f, g } , H = { h }
4.6. PROBLEMS 45
I1 I2
A B,1 H,1
B E,1 C,1
C C,0 E,1
E C,0 C,1
H C,1 A,1
4.6 Problems
Q5 [20 points]
Let ρ ⊆ A×A, ρ−1 be the inverse relation of ρ, and iA be the identity relation
of A. What kind of relation is ρ if
i) iA ⊆ ρ.
ii) iA ∩ ρ = ∅ .
iii) ρ−1 = ρ.
iv) ρ ∩ ρ−1 ⊆ iA .
v) ρ ∩ ρ−1 = ∅.
vi) ρ = ∪i∈N ρi .
Justify your answers.
Solution.
iA ⊆ ρ reflexive
iA ∩ ρ = ∅ irreflexive
−1
ρ = ρ. symmetric
If , then ρ is .
ρ ∩ ρ−1 ⊆ iA . antisysmmetric
ρ ∩ ρ−1 = ∅. asymmetric
ρ = ∪i∈N ρi . transitive
Justification is left as exercise.
Q6 [20 points]
Solution.
46 CHAPTER 4. RELATIONS ON A SET
Chapter 5
47
48 CHAPTER 5. PARTIAL ORDERING, LATTICE
Remark 5.1.1. Note that some elements of a poset are incomparable but
every two elements in a totally ordered set should be comparable.
Example 5.1.1.
@ a ^== ppp7 b
Let A = { a, b, c, d, e, f, g } and
=p
ppp === b ≤ a represented by b → a.
p p
pp == Note that c ≤ a, f ≤ a. There
ppp
cO _? ? dO should be an arc from f to a, too. In
??
??
?? order to simplify the figure this kind
?
e ^> of arcs are omitted.
>>
>>
>>
> a and b are not comparable. So
f g there is no element that is larger
than all the other elements. Similarly
there is no element that is smaller
than all the other elements.
Example 5.1.2.
{a, b}
A = { a, b } ? O _???
??
2A = { ∅, { a } , { b } , { a, b } }
[ P (A), ⊆ ] is a poset. {a} {b}
_?? ?
??
??
∅
∆
b is an immediate successor of a, denoted by b ≻ a, ←→ a < b and
6 ∃c ∈ A [a < c < b].
Remark 5.2.1.
? aO _?? ? aO _? ? a _?
?? ??? ???
?? ?? ??
1 c _?? ?b c _?? ?b c _?? ?b
?? ?? ??
? ? ?
1d d d
Example 5.2.2.
∆
a | b ←→ ∃c ∈ Z [b = ca]
∆
Let A = { a ∈ N | a | 100 } and define a relation ≤ on A as a ≤ b ←→ a | b.
4 100
=z E M O Q aDDj
zz DD
zz DD
z DD
zz
20 50
~? OP R aDDD z= L NO aBBB
~~~ DD z zz BB
~~ DD zz BB
~~ D zz B
4R _@@ 10
= \ aDD 25
@@ zz DD ||= L
@@ zz DD |
@@ zzzz DD ||
z D |||
2 aDD z= 5
DD zz
DD z
DD zz
D zzz
50 CHAPTER 5. PARTIAL ORDERING, LATTICE
100D
zz DD
z z DD
z DD
Graph of ≤ zz z D
20 DD 50 BB
~~~ DD z zz BB
~~ DDD zz BB
~~ D zz BB
~ z
4 @@ 10 DD 25
@@ zzz DD |||
@@ z DD ||
@@ zzzz DD
D |||
z
2 DD z5
DD zz
DD z
DD zz
D zzz
1
Graph of ≺
• not reflexive
• not symmetric
• not transitive
Hasse diagram.
5.3 Lattice
Definition 5.3.1. Let [ A, ≤ ] be a poset.
maximal ∆ 6 ∃a ∈ A [m < a]
m ∈ A is ←→ .
minimal 6 ∃a ∈ A [a < m]
a maximals: a, b, h.
b
minimals: d,g,j,k.
greatest: none.
c> least: none.
>>
>>
>>
>
d e f
g h
i
j k
Definition 5.3.4. Let [ A, ≤ ] be a poset and a, b ∈ A.
A least upper bound (lub) of a and b is c ∈ A
i. a ≤ c and b ≤ c
ii. 6 ∃x ∈ A [a < x ∧ b < x ∧ x < c]
Remark 5.3.3. Let a, b ∈ A.
i. Least upper bound of a and b may not exist.
ii. There may be more than one lub.
iii. It may be unique. If lub of a and b is unique, then it is denoted as a + b.
Theorem 5.3.1. ∀a, b ∈ A [ lub exists] −→ [ A, ≤ ] has the universal upper
bound I.
Example 5.3.2.
52 CHAPTER 5. PARTIAL ORDERING, LATTICE
Example 5.3.3.
Division relation and divisors of 12 makes a lattice.
12 @
~~
~~ @@
@@ A = { a ∈ N | a | 12 }
~ @@
~~
~ @ = { 1, 2, 3, 6, 4, h12 } i
4 @@ 6= ∆
and ∀a, b ∈ A a ∼ b ←→ a | b
@@ ~~ ==
@@ ~~~ ==
@@ ~ ==
~~
2 @@ 3
@@
@@
@@
1
5.4. APPLICATIONS 53
5.4 Applications
• PageRank of Google.
5.5 Problems
Q7 [20 points]
∆
Definition 5.5.1. Let f, g : Z+ → R. g dominates f ←→ ∃m ∈ R+ and
∃k ∈ Z+ such that |f (n)| ≤ m |g(n)| for all n ∈ Z+ where n ≥ k
∆ +
f βg ←→ f ∈ Θ(g) for f, g ∈ RZ .
+
Prove that β is an equivalence relation on RZ .
54 CHAPTER 5. PARTIAL ORDERING, LATTICE
+
b) Let [f ]β represent the equivalence class of f ∈ RZ for the relation β.
Let E be the set of equivalence classes induced by β. Define the relation
α on E by
+ ∆
[f ]β α [g]β , for f, g ∈ RZ , ←→ f is dominated by g.
f βg ⇒ f ∈ Θ(g)
⇒ mf |g(n)| ≤ |f (n)| ≤ Mf |g(n)| for n ≥ k where mf , Mf ∈ R+ and k ∈ Z+
⇒ |g(n)| ≤ 1/mf |f (n)| and 1/Mf |f (n)| ≤ |g(n)|
⇒ mg |f (n)| ≤ |g(n)| ≤ Mg |f (n)| for n ≥ k with mg = 1/Mf , Mg = 1/mf ∈ R
⇒ g ∈ Θ(f )
⇒ gβf.
So β is symmetric.
iii. Let f, g, h ∈ F with f βg, gβh. Then, f ∈ Θ(g) and g ∈ Θ(h)
⇒ for all n ∈ Z+ , there exist constants mf , Mf , mg , Mg ∈ R+ and
kf , kg ∈ Z+ such that
mf |g(n)| ≤ |f (n)| ≤ Mf |g(n)| for n ≥ kf , and
mg |h(n)| ≤ |g(n)| ≤ Mg |h(n)| for n ≥ kg . Then for n ≥ max{kf , kg },
mf mg |h(n)| ≤ mf |g(n)| ≤ |f (n)| and
|f (n)| ≤ Mf |g(n)| ≤ Mf Mg |h(n)|. Hence for n ≥ k,
m |h(n)| ≤ |f (n)| ≤ M |h(n)|
where m = mf mg , M = Mf Mg ∈ R+ and k = max{kf , kg } ∈ Z+ .
So f βh, that is, β transitive.
b) We need to show that α is reflexive, antisymmetric and transitive. Let
+
f, g, h ∈ RZ .
5.5. PROBLEMS 55
Q8 [20 points]
Let F denote the set of all partial orderings on a set A. Define a relation ≤
∆
on F such that for α, β ∈ F , α ≤ β ←→ ∀a, b ∈ A [aαb → aβb]. Show that
≤ is a partial ordering on F .
Solution.
Algebra
57
Chapter 6
Algebraic Structures
6.1 Motivation
Suppose there are two research labs A and B. Lab A investigates gravitation.
They do test on two masses m1 and m2 . They discover that the attraction
force Fg is given as
m1 m2
Fg = cg 2
r
where r is the distance between them and cg is a constant.
Lab B investigates electrical charges. The force observed is attractive if
the charges are opposite sign, repulsive otherwise. Yet, they measure that
the force Fe between two spheres charged as q1 and q2 is given as
q1 q2
Fe = ce
r2
where r is the distance between them and ce is a constant.
Yet somewhere else, a theoretical physicist works on hypothetical forces.
She assumes that the force between two bodies is proportional to some prop-
erty of the body denoted by b. She also assumes that the force is inversely
proportional to the square of the distance of the bodies. So she summarize
her assumptions as
b1 b2
Fx = cx 2 .
r
She did continue in her investigations. She figure out many properties of this
hypothetical system.
59
60 CHAPTER 6. ALGEBRAIC STRUCTURES
Question 6.1.1. Compare Part a and Part b of Example 6.1.1. What are the
differences and similarities?
Question 6.1.2. Solve A + X = B for X if
i. A, B, X are N × N rational matrices.
ii. A, B, X are N × N integer matrices.
iii. A, B, X are N × N natural number matrices.
iv. A, B, X are polynomials with complex coefficients in y.
v. A, B, X are polynomials with real coefficients in y.
vi. A, B, X are polynomials with rational coefficients in y.
vii. A, B, X are polynomials with integer coefficients in y.
viii. A, B, X ∈ C.
ix. A, B, X ∈ R.
x. A, B, X ∈ Q.
xi. A, B, X ∈ Z.
xii. A, B, X ∈ N.
xiii. A, B, X ∈ R r Q.
xiv. A, B, X are 2D vectors.
xv. A, B, X are 3D vectors.
6.2. ALGEBRAIC STRUCTURES 61
Question 6.1.3.
i. Some of the systems given in Question 6.1.2 have no solution. Can you
find a pattern when there is a solution. What properties of what do you
need in order to solve equation A + X = B?
ii. Reconsider Question 6.1.2 when addition is replaced by multiplication,
that is, A × X = B. Note that multiplication may not be defined in
some concepts.
Question 6.2.2. What is the difference between ⋆((a, b)) and ⋆(a, b)?
⋆ a1 · · · ai · · · aj · · · an
a1 . · · · . ··· . ··· .
.. .. .. .. ..
. . . . .
ai . · · · . · · · ak · · · .
.. .. .. .. ..
. . . . .
aj . · · · am · · · . ··· .
.. .. .. .. ..
. . . . .
an . ··· . ··· . ··· .
∆
Definition 6.2.3. A binary operation ⋆ on A is called associative ←→
∀a, b, c ∈ A [(a ⋆ b) ⋆ c = a ⋆ (b ⋆ c)]
∆
Definition 6.2.4. A binary operation ⋆ on A is called commutative ←→
∀a, b ∈ A [a ⋆ b = b ⋆ a].
Two similar but not exactly the same systems can be investigated. A special
case of similar structures is the case when one set if a subset another.
Suppose B ⊆ A and a binary operation ⋆ on A is defined. Since a binary
operation is a function from A × A, and since B × B ⊆ A × A, we can try to
restrict it to B.
One needs to be very careful at this point. The danger can be better seen
in simpler case: What we have is a function f : A → A. We have B ⊆ A
and we want to restrict function to B. It is perfectly possible that for some
elements of B the image under the function may not be in B at all, that is,
f (b) ∈ A r B for some b ∈ B. Whenever that happens, the function can not
be a binary operation. This concern is called closeness.
-
7 vK 8 ṽ =
K u
v1 , v˜1
v2 , v˜2
Example 6.2.3 (Addition on Reals and Rationals). Consider the set of real
numbers, R. With ordinary addition, + : R×R → R , it makes the algebraic
system, [ R, + ]. Now, consider the set of rational numbers. Depending how
you look at it, a rational number is a real number or not. Here we assume
that a rational number is also a real number. Hence Q ⊆ R. The addition
+ in reals can be restricted to Q. Let +Q : Q × Q → Q be the restriction of
addition in reals to rationals.
Fortunately addition of any two rational numbers is again a rational num-
ber. So we can safely restrict + in R to Q and obtain binary operation +Q
in Q.
Example 6.2.4 (Multiplication on Reals and Negative Integers). Multiplica-
tion on real numbers is a binary operation.
×R : R × R → R.
× : Z− × Z− → Z+
×A : A × A → R.
×A : A × A → A
6.3. WITH ONE BINARY OPERATION 65
√ √ √
since 2 ∈ A but 2 ×A 2 = 2 6∈ A. That is, the restriction of multiplica-
tion in the set of reals to the set of irrationals is not a binary operation in
irrationals. In other words, the restriction is not close.
6.3.2 Monoid
Definition 6.3.2. Let [ A, ⋆ ] be an algebraic structure.
ℓ left-identity ∀a ∈ A [ℓ ⋆ a = a]
∆
r ∈ A is called right-identity ←→ ∀a ∈ A [a ⋆ r = a]
e (two-sided) identity ∀a ∈ A [e ⋆ a = a ⋆ e = a]
.
Remark 6.3.1.
6.3.3 Groups
Definition 6.3.5 (Inverse).
Let G = [ A, ⋆ ] be a monoid with the identity e. Let a ∈ A.
ℓa left inverse ℓa ⋆ a = e
∆
ra ∈ A is called right inverse of a ←→ a ⋆ ra = e .
ba (two-sided) inverse ba ⋆ a = a ⋆ ba = e
6.3. WITH ONE BINARY OPERATION 67
* 1 2 3 4
1 . 1 . .
2 1 2 3 4
3 . 3 3 4
4 . 3 4 4
Theorem 6.3.3. If ℓ and r are left and right inverses of a, respectively, then
ℓ = r in a monoid.
Question 6.3.4. Is it possible that a has two different left-inverses, ℓ1 and ℓ2 ?
Notation 6.3.1. The inverse of a is represented by a−1 .
Definition 6.3.6 (Group).
∆
An algebraic structure G = [ A, ⋆ ] is called group ←→
i. G is a monoid.
ii. ∀a ∈ A, there is a unique inverse of a, denoted by a−1 .
If A is finite, G is said to be a finite group and | A | is called the order of G.
Theorem 6.3.4. Let G = [ A, ⋆ ] be a group and a, b ∈ A. a ⋆ x = b and
y ⋆ a = b have unique solutions, namely, x = a−1 ⋆ b and y = b ⋆ a−1 .
Theorem 6.3.5 (Cancellation). In a group,
i. a ⋆ b = a ⋆ c ⇒ b = c.
ii. b ⋆ a = c ⋆ a ⇒ b = c.
Remark 6.3.3. We know these two theorems in numbers since primary school.
What the theorems say is that they are valid if the system satisfy the group
axioms.
Notation 6.3.2. a ⋆ b is represented by ab when the binary operation ⋆ is clear
in the context.
Theorem 6.3.6 (Cayley). Every finite group can be represented by a group
of permutations.
Definition 6.3.7 (Permutation). Let A be a finite set. A bijection γ : A →
A is called a permutation.
Example 6.3.2 (Group of Permutations).
68 CHAPTER 6. ALGEBRAIC STRUCTURES
∆
Let A = { x1 , x2 , x3 } be a set with Let S3 = { a, b, c, d, e, f } be the
3 elements. set of permutations on A.
Define a binary operation ⊚ on S3 as
∆
the composition, that is, α ⊚ β =
β ◦ α where α, β ∈ S3 . Hence x ∈ A
is mapped to β(α(x)).
b ⊚ c = (132) ⊚ (213)
A permutation onA can be rep- = (213) ◦ (132)
x1 x2 x3 = (213)((132))
resented as: = (213).
x2 x1 x3 = (231) = d
1 / 1= 1
== @
=
==
=
2 == @2 2
==
==
=
3 3 / 3
There are 3! = 6 permutations: ⊚ a b c d e f
a = (123) a a b c d e f
b = (132) b b ? d ? ? ?
c = (213) c c ? ? ? ? ?
d = (231) d d ? ? ? ? ?
e = (312) e e ? ? ? ? ?
f = (321). f f ? ? ? ? ?
Definition 6.3.8. S3 = [ S3 , ⊚ ] is called the symmetric group of order 3, S3 .
Symmetic groups Sn can be extended for any n ∈ N.
Remark 6.3.4. | Sn | = n!
Definition 6.3.9. Let G = [ A, ⋆ ] and H = [ B, ◦ ] be two groups. Group G
∆
is said to be a subgroup of group H ←→
i. A ⊆ B.
ii. ⋆ is the restriction of ◦ to A.
Remark 6.3.5.
6.4. WITH TWO BINARY OPERATIONS 69
i. G is a subgroup of itself.
ii. { e } is a subgroup of G.
Definition 6.3.10. Subgroups G and { e } are called the trivial subgroups.
Any subgroup that is not trivial is called proper subgroup.
Theorem 6.3.7. T 6= ∅ is a subgroup of G
←→ ∀a, b ∈ T [ab−1 ∈ T ].
Theorem 6.3.8. Let H be a subgroup of G. Then the order of H divides
the order of G.
Definition 6.3.11. A group with commutative binary operation is called
abelian group.
Remark 6.4.1. Note that since [ A, + ] is a group, the additive identity and
additive inverse should be there. On the other hand, [ A, · ] is simple a semi-
group. Therefore the multiplicative identity may not exist. Even if the
multiplicative identity exists, multiplicative inverse may not.
70 CHAPTER 6. ALGEBRAIC STRUCTURES
6.4.2 Field
Definition 6.4.5. A field , F = [ A, +, · ], is a ring such that [ A r { 0 } , · ] is
an abelian group. If A is finite, F is called finite field (Galois field ).
Remark 6.4.3. Note that in 0 in A r { 0 } is the additive inverse of group
[ A, + ].
∆
Definition 6.4.6. Let Zn = { 0, · · · , n − 1 } where n ∈ N, n ≥ 2,
∆
a ⊕ b = remainder of a+bn
,
∆ ab
a ⊙ b = remainder of n
.
6.4.3 Lattice
Lattice has two definitions: poset-wise and algebraic.
Definition 6.4.7. A (algebraic) lattice, L = [ A, ⊓, ⊔ ] is a nonempty set L
with binary operations ⊓, ⊔, called meet and join, if
i) x⊓y =y⊓x x⊔y =y⊔x
ii) x ⊓ (y ⊓ z) = (x ⊓ y) ⊓ z x ⊔ (y ⊔ z) = (x ⊔ y) ⊔ z
iii) x ⊓ (x ⊔ y) = x x ⊔ (x ⊓ y) = x
72 CHAPTER 6. ALGEBRAIC STRUCTURES
Remark 6.4.5. Let L = [L, ⊓, ⊔] and [L, +, ·] be lattices algebraic and poset
sense, respectively. Then a ⊓ b = a + b and a ⊔ b = a · b.
Remark 6.4.6. Note that vector spaces are not algebraic structures.
Example 6.4.3. Let Q2×2 be the set of 2 × 2 matrices over rational numbers.
Define the product of a rational number by a 2 × 2 matrix as a 2 × 2 matrix
obtained by multiplying each of the entries by the rational number, i.e. For
a ∈ Q and M ∈ Q2×2 , [a · M]ij = a[Mij ] where [M]ij is the i,j-th entry of the
matrix. Then Q2×2 is a vector space over Q.
Example 6.4.4. Let F [x] be the set of all polynomials in x with coefficients
in F . Multiplication of a polynomial by a scalar is defined by multiplying
each coefficient with that scalar. Then F [x] is a vector space over F .
Question 6.4.5. Prove that 0 · v = v.
6.5. SUMMARY 73
6.5 Summary
Single Binary Operation, [ A, ⊕ ] Two Binary Operations,
• Binary operation [ A, ⊕, ⊗ ]
• Semigroup
• Ring R = [ A, ⊕, ⊗ ]
i. associativity
i. [ A, ⊕ ] is an abelian group
• Monoid ii. [A, ⊗] is a semigroup
i. semigroup iii. ⊗ right and left distributes
ii. identity over ⊕
• Group
i. monoid • Field F = [ A, ⊕, ⊗ ]
ii. inverse i. [ A, ⊕, ⊗ ] is a ring
ii. [ A \ { 0 } , ⊗ ] is an abelian
• Abelian Group group
i. group
ii. commutativity
• Lattice L = [ A, ⊕, ⊗ ]
6.6 Problems
Q9 [20 points]
Prove the following theorem.
Solution.
Use induction on n.
Induction Base. For n = 1, (a)−1 = a−1 .
74 CHAPTER 6. ALGEBRAIC STRUCTURES
−1 −1
Induction Hypotesis. Assume that (a1 a2 · · · an )−1 = a−1
n an−1 · · · a1 for n.
So a−1 −1 −1 −1
n+1 an an−1 · · · a1 is a right inverse of a1 a2 · · · an an+1 .
[a−1 −1 −1 −1 −1 −1 −1 −1 −1
n+1 an an−1 · · · a1 ][a1 a2 · · · an an+1 ] = [an+1 an an−1 · · · a2 ][a1 a1 ][a2 · · · an an+1 ]
= [a−1 −1 −1 −1 −1
n+1 an an−1 · · · a2 ][e][a2 · · · an an+1 ] since a1 a1 = e
= ...
= a−1
n+1 an+1 = e.
So a−1 −1 −1 −1
n+1 an an−1 · · · a1 is a left inverse of a1 a2 · · · an an+1 .
Hence an+1 an · · · a−1
−1 −1
1 is the inverse of a1 a2 · · · an+1 .
76 CHAPTER 6. ALGEBRAIC STRUCTURES
Chapter 7
Boolean Algebras
7.1 Reminders
i. Partial ordering = reflexive + antisysmmetic + transitive
ii. Poset [ S, ≤ ]
iii. Immediate predecessor ≺
iv. Immediate successor ≻
v. Hasse diagram
vi. Maximal and minimal elements
vii. Universal upper bound (greatest element), 1
viii. Universal lower bound (least element), 0
ix. Least upper bound (lub, join, **product), a ⊕ b
x. Greatest lower bound (glb, meet, product), a ⊙ b
xi. Lattice, L = [ L, ⊕, ⊙ ]
7.2 Lattices
∆
Definition 7.2.1. a ∈ L is called an atom ←→ 0 ≺ a.
Remark 7.2.1.
i. The universal lower bound 0 is join-irreducible.
ii. All the atoms are join-irreducible.
77
78 CHAPTER 7. BOOLEAN ALGEBRAS
∆
Definition 7.2.3. A lattice is called finite length ←→ All chains in L are
finite.
Theorem
A 7.3.1. Let A be a set.
i. 2 , ∪, ∩ is a lattice.
ii. ∅ ∈ 2A is the universal lower bound.
iii. A ∈ 2A isthe universal upper bound.
iv. 2A , ∪, ∩ is a distributive lattice.
Notice that
f : 2A → Bn
A A
Aj 7→ (b1 j , b2 j , . . . , bA
n )
j
is a bijection.
Example 7.3.2. Let A = { a, b, c }
b∅ → (0, 0, 0)
b{ a } → (1, 0, 0)
b{ a,c } → (1, 0, 1)
b{ a,b,c } → (1, 1, 1)
7.3.2 n-cube
Definition 7.3.3. Bn is called n-cube where n ∈ N.
Example 7.3.3.
•B
||| BBB
| BB
|| BB
||
• BB • BB • BB •
| BB BB ||| BB |||
|| BB B| |B
||| BB || BBB ||| BBB
|| || |
• • BB • • BB • •
| BB | BB ||
|| BB || BB |
||| BB ||
|
BB |||
|
|| || |
• • • •
B0 B1 B2 B3
Note that
i. The diagram of Bn can be generated by two of diagrams of Bn−1 .
80 CHAPTER 7. BOOLEAN ALGEBRAS
Theorem
A 7.3.2. Let A be a finite set with | A | = n. The Hasse diagram of
2 , ∪, ∩ is the n-cube.
{ a, b, c }
KKK
ss KKK (1, 1, 1)
ssss KKK r KKK
sss
s K rrrrr KKK
KKK
r
{ a, b }K { a, c }K { b, c } rrr K
KKK sss
Ks
KKK ss
K s (1, 1, 0) (1, 0, 1) (0, 1, 1)
sssKKKKK sssKsKKK LLL
LLrLrrrr
KKK
KKsKssss
sss sss K
rr LLL ss KKKK
{a} L {b} {c} rrr L sss
LLL
LLL ssss
s (1, 0, 0) (0, 1, 0) (0, 0, 1)
LLL s LLL s
LL sss LLL sss
sss LLL sss
∅ L sss
(0, 0, 0)
Remark 7.3.1.
i. In general, complement may not exist.
ii. If it exists, it may not be unique. So complement is a relation rather
then a function.
0 1
iii. is a complement of .
1 0
Example 7.3.5.
7.3. BOOLEAN ALGEBRAS 81
1 ==
== b
== is a complement of a
== c
a= b c
==
==
==
=
0
Example 7.3.6.
{4} M
qq MMM The lattice of partitions of 4 is not
qqqq MMM
qqq
qq MMM
M complemented.
{ 1, 3 } { 2, 2 }
MMM q
MMM
MMM qqqqq
q
M qqq
{ 1, 1, 2 }
{ 1, 1, 1, 1 }
Remark 7.3.2. Note that complement of a may not exist. If it exists, then it
is unique.
a ⊕ b = a ⊙ b and a ⊙ b = a ⊕ b
Number Systems
83
Chapter 8
Number Systems
Remark 8.1.1. These axioms are called Peano axioms [Gal89]. Note that s
is a function given as s : N → N.
0 zero 0
s(0) one 1
Remark 8.1.2. is called and represented by
s(s(0)) two 2
··· ··· ···
Question 8.1.1. Does there exist such a set?
Question 8.1.2. Is it unique? That is, if N1 and N2 are sets satisfying the
Peano axioms, then are N1 and N2 isomorphic?
∆
Definition 8.1.2. The predecessor of n, p(n), is p(n) = m ←→ s(m) = n.
85
86 CHAPTER 8. NUMBER SYSTEMS
(
n, m = 0,
n+m=
s(n) + p(m), otherwise.
8.2 Integers
Definition 8.2.1. Consider the relation ∼ on N×N defined as ∀(a, b), (c, d) ∈
N × N [(a, b) ∼ (c, d) ←→ a + d = b + c]
N × N/ ∼= { [ ( n, 0 ) ] | n ∈ N } ∪ { [ ( 0, n ) ] | n ∈ N ∧ n 6= 0 }
8.2. INTEGERS 87
Proof. Let [ ( a, b ) ] , [ ( c, d ) ] , [ ( e, f ) ] ∈ N × N/ ∼.
1. [ ( a, b ) ] ∼ [ ( a, b ) ], since a + b = b + a. So ∼ is reflexive.
2. [ ( a, b ) ] ∼ [ ( c, d ) ] −→ [ ( c, d ) ] ∼ [ ( a, b ) ], since a + d = b + c. So ∼
is symmetric.
3. If [ ( a, b ) ] ∼ [ ( c, d ) ] ∧ [ ( c, d ) ] ∼ [ ( e, f ) ], then a + d = b + c and
c + f = d + e. Adding the two a + d + c + f = b + c + d + e, then
a + f = b + e. Hence [ ( a, b ) ] ∼ [ ( e, f ) ]. So ∼ is transitive.
Therefore ∼ is an equivalence relation on N × N.
Example 8.2.2. Some equivalence classes of N × N/ ∼ are:
···
[ ( 2, 0 ) ] = { ( n + 2, n ) | n ∈ N }
[ ( 1, 0 ) ] = { ( n + 1, n ) | n ∈ N }
[ ( 0, 0 ) ] = { ( n, n ) | n ∈ N }
[ ( 0, 1 ) ] = { ( n, n + 1 ) | n ∈ N }
[ ( 0, 2 ) ] = { ( n, n + 2 ) | n ∈ N }
···
Definition 8.2.2 (Integers). The set N × N/ ∼ is the set of integers and is
denoted by Z.
Definition 8.2.3 (Addition and Multiplication in Z). Let [ ( a, b ) ] , [ ( c, d ) ] ∈
Z. Define + : Z × Z → Z and × : Z × Z → Z
[ ( a, b ) ] + [ ( c, d ) ] = [ ( a + c, b + d ) ]
[ ( a, b ) ] × [ ( c, d ) ] = [ ( ac + bd, ad + bc ) ]
Theorem 8.2.2. ∀x ∈ Z ∃x′ ∈ Z [x + x′ = x′ + x = 0]. Denote x′ by −x.
Remark 8.2.1. x = [ ( a, b ) ] −→ −x = [ ( b, a ) ]
[Z, +]
Question 8.2.1. What kind of algebraic structure is [Z, ×] ?
[Z, +, ×]
Definition 8.2.4. Z+ = { [ ( n, 0 ) ] | n ∈ N \ { 0 } } is called the set of pos-
itive integers. Z− = { [ ( 0, n ) ] | n ∈ N \ { 0 } } is called the set of negative
integers.
88 CHAPTER 8. NUMBER SYSTEMS
Division
9.1 Division
Definition 9.1.1 (Division).
∆
Let d, n ∈ Z. d divides n ←→ ∃c ∈ Z n = cd.
d factor or divisor n
is a of .
n multiple d
Remark 9.1.1.
i. The expression an + bm is called a linear combination of n and m.
89
90 CHAPTER 9. DIVISION
Example 9.2.2.
2=2 6=2·3 30 = 2 · 3 · 5
4 = 2 · 2 = 22 12 = 2 · 2 · 3 = 22 · 3 720 = 2 · 2 · 2 · 2 · 3 · 3 · 5 = 24 · 32 · 51
Remark 9.2.2.
i. Given an integer n > 1, it is not easy to decide whether n is prime.
ii. There is no known formula that generates primes only.
iii. Prime numbers of the form 2p − 1, where p ∈ P, are called Mersenne
primes. As of 2009, there are 47 Mersenne primes known. The largest
is 243,112,609 − 1 [Wik09].
n
iv. Numbers in the form of Fn = 22 + 1 where n ∈ N are called Fermat
numbers. F0 = 3, F1 = 5, F2 = 17, F3 = 257, F4 = 65, 537 are all prime
but Euler (1732) found that F5 = 232 + 1 = 641 × 6, 700, 417 is not
prime. Beyond F5 no Fermat primes have been found [Apo].
+
√ Let n ∈ Z is composite. Then there is a prime divisor p
Theorem 9.2.5.
of n and p ≤ n.
Application 9.4.1.
i. Hashing Functions.
ii. Pseudorandom Numbers.
iii. Cryptology.
Acknowledgment. These notes are based on various books such as
[PY73, Ros07, Gal89] but especially [Apo].
96 CHAPTER 9. DIVISION
Part V
Combinatorics
97
Chapter 10
Counting
10.1 Motivation
Counting the number of different ways of satisfying a condition is important
in science including Probability, Statistical Physics and, of course, Computer
Science. Theory of Algorithms in Computer Science deals with finding an
algorithm which has the minimum number of steps. Then one needs to know
what is the possible number of steps.
Example 10.1.1.
i. How many vertices in a complete binary tree?
ii. How many steps are needed in order to traverse a binary tree?
iii. If you have n items, how many comparisons do you need to make in
order to sort them?
Question 10.1.1.
i. Suppose there are 3 balls looks like the same but one of them is different
in weight only. How many comparisons in weight does it needed to figure
out the different one?
ii. The same question for 12 balls?
Example 10.1.2. Consider a room filled with air. The room divided into two
halves. You are sitting in one of the halves. What is the possibility that all
the molecules would be in the other half. Our every day observations says
that that does not happen frequently. If that happens frequently enough,
you would be suffocated. What is the probability that it happens, if the
number of molecules in the room is n where
i. n = 2?
99
100 CHAPTER 10. COUNTING
ii. n = 8?
iii. n is in the order of Avogadro number, that is n ≈ 1024 ?
iv. What is you estimate of n if the room is 4 × 5 × 3 in meters?
Assume that air is an ideal gas where molecules are free to move without any
interaction from each other.
This chapter deals with finite sets. Let A and B be finite sets. Let
| A | = α and | B | = β. Since A is finite, the elements of A can be listed as
an α-tuple (a1 , a2 , . . . , aα ). This ordering is used for the following proofs.
Definition 10.1.1 (Factorial).
Let n ∈ N.
i. 0! = 1
ii. (n + 1)! = n!(n + 1).
Remark 10.1.1. Use of factorial is quite old. One of the earliest use of fac-
torials is in the proof of prime numbers are infinite given by Euclid around
300BC. The proof is based on the idea that there must be a prime between
n and n! + 1.
Definition 10.1.2 (Factorial Power).
Let n, r ∈ Z+ .
∆
nr = (n + 0) (n + 1)(n + 2) · · · (n + (r − 1)),
∆
nr = (n − (r − 1)) · · · (n − 2)(n − 1) (n − 0).
nr and nr are called rising factorial power and falling factorial power and
are read as n to the r rising and n to the r falling, respectively.
Remark 10.1.2. Notice that
n!
nr = .
(n − r)!
The notation of the rising and falling factorial power is due to [GKP98]
Definition 10.1.3 (The set of bits).
∆
B = { 0, 1 }.
Theorem 10.2.3. | Z− | = ℵ0 .
Theorem 10.2.4. | Z | = ℵ0 .
Since f is a bijection, | Z | =| N | .
Theorem 10.2.5. | Q+ | = ℵ0 .
Proof.
↓q→p 1 2 3 4 5 6 ···
1 1 1 1 1 1
1 1 2 3 4 5 6
···
2 2 2 2 2 2
2 1 2 3 4 5 6
···
3 3 3 3 3 3
3 1 2 3 4 5 6
···
4 4 4 4 4 4
4 1 2 3 4 5 6
···
5 5 5 5 5 5
5 1 2 3 4 5 6
···
6 6 6 6 6 6
6 1 2 3 4 5 6
···
··· ··· ··· ··· ··· ··· ··· ···
Define f : N → Q+ such that f (n) =?1 . Since f is a bijection, | Q+ | =
| N |.
Theorem 10.2.6. | Q | = ℵ0 .
1
How to define this function?
10.2. CARDINALITY: FINITE AND INFINITE SETS 103
Since q is a bijection, | Q | = | Z |.
Summary 10.2.1. ℵ0 = | Z+ | = | N | = | E | = | O | = | Z | = | Z− | = | Q |.
Remark 10.2.1. So far it seems that there is only one kind of infinity, that is
ℵ0 . Note that these sets are countable, that is, there is a bijection from N to
them.
6 |2A |.
Theorem 10.2.8 (Cantor’s Theorem). Let A be a set. Then |A| =
In other words “No set is the same size as its power set”.
We show that mapping f from A to 2A is not a surjection, therefore f is
not a bijection.
104 CHAPTER 10. COUNTING
i) b ∈ B case: By definition of B, b ∈
/ f (b). Since f (b) = B, we have
b∈/ B. Contradiction.
ii) b ∈
/ B case: Since f (b) = B, this means b ∈
/ f (b). This means b ∈ B
since B is defined so. Contradiction.
) ) (
◦ A n1 5 B ◦ ) ) (
5 ◦ C n2 5 D ◦.
5
) ) ( ) ) )
A n1 5 B ◦ C n2 5 D △.
5 5
Proof. There are 2n rows in a truth table of n variables. For each row,
n
one can assign two choices, namely F or T. Hence there are 22 different
assignments.
Remark 10.3.2. IPv4 is the currently used protocol for the Internet in which
every device on the Internet should have a unique ID. IPv4 uses 32-bit IDs
which is usually written as four numbers separated by dots as in the case of
127.0.0.1. Therefore 232 devices can be connected to the Internet at a given
time. Although it is a very big number, it is not big enough for the demand
of the future. IPv6 is planned to use 128-bit ID’s.
f : 2A → Bα
A 7→ (b1 , b2 , . . . , bα )
(
1, ai ∈ A,
where A ∈ 2A and bi = .
0, ai ∈
/ A.
f is a bijection (proof?). Therefore 2A = | Bα | = 2α = 2| A | .
) ) (
8 ◦ A n1 5 B ◦
5
( )
◦ ◦H △
& ) ) (
◦ C n2 5 D ◦
5
108 CHAPTER 10. COUNTING
| A1 ∪ A2 ∪ . . . ∪ An | = | A1 | + | A2 | + . . . + | An | .
P6 = | { all strings of letters and digits of length 6 } | − | { all strings of letters of length 6 } |
= { A, B, . . . , Z, 0, 1, . . . , 9 }6 − { A, B, . . . , Z }6
= (26 + 10)6 − 266
= 366 − 266 .
P = P6 +P7 +P8 = 366 −266 +367 −267 +368 −268 = 366 (1+36+362)−266 (1+26+262).
) ) (
8 ◦ A n1 5 B ◦
5
( ( ( ( ( ( )
◦ ◦ ◦ n3 6
6
◦ ◦ ◦H △
& ) ) (
◦ C n2 5 D ◦
5
10.4. THE PIGEONHOLE PRINCIPLE 109
| A1 ∪ A2 | = | A1 | + | A2 | − | A1 ∩ A2 | .
Example 10.3.3. What is the number of 8-bit strings starting with 1 or ending
with 00. Let A = { (b1 , b2 , . . . , bn ) ∈ B8 | b1 = 1 ∨ (bn−1 = 0 ∧ bn = 0) }.
A is the set of 8-bit strings starting with 1 or ending with 00.
| A | =?
A1... starting with 1
Ans. Let A...00 be the 8-bit strings ending with 00 .
A1...00 starting with 1 and ending with 00
Then | A | = | A1... ∪ A...00 | = | A1... | + | A...00 | − | A1... ∩ A...00 | where A1... ∩
A...00 = A1...00 .
| A1... | = | B8−1 | = 27 , | A...00 | = | B8−2 | = 26 and | A1...00 | = | B8−3 | = 25 .
Therefore | A | = | A1... | + | A...00 | − | A1...00 | = 27 + 26 − 25 = 25 (22 + 21 − 1).
Theorem 10.3.11. Let P be the set of partial functions from A to B. Then
| P | = (β + 1)α .
Proof. Let B = B ∪ { b0 } where b0 ∈ / B. Let p ∈ P. Define set Ap =
{ a ∈ A | p(a) is not defined }. Then define function p∗ : A → B such that
(
p(a), a ∈ A\Ap ,
p∗ (a) =
b0 , a ∈ Ap .
f : P → BA (10.1)
p 7→ p∗ (10.2)
f is a bijection (proof ?). Hence | P | = BA = | B || A | = (β + 1)α
i.
n n
= =1
0 n
ii.
n n−1 n−1
= + for 0 < r < n.
r r r−1
Remark 10.5.2. Note that Theorem 10.5.1 leads to the famous Pascal’s tri-
angle.
1 2 3 4 5 6 7 8 9 10
1 1 1 1 1 1 1 1 1 1 1
2 1 2 3 4 5 6 7 8 9
3 1 3 6 10 15 21 28 36
4 1 4 10 20 35 56 84
5 1 5 15 35 70 126
6 1 6 21 56 126
7 1 7 28 84
8 1 8 36
9 1 9
10 1
The numbers in the first column are the natural numbers. The numbers
in the second and the third columns are called the triangular and tetrahedral
112 CHAPTER 10. COUNTING
numbers, respectively. The nth triangular number is simply the sum of the
first n integers. The tetrahedral numbers are the sums of the triangular
numbers.
History of binomial coefficients and Pascal’s triangle goes way back than
Pascal. The Pythagoreans considered the triangular numbers around 540
BC. The Greek mathematicians investigated tetrahedral numbers at the be-
ginning of 200 BC. The binomial numbers as coefficients of (a + b)n appeared
in the works of mathematicians in China around 1100. Hindu mathemati-
cians began to encounter the binomial coefficients in combinatorial problems
in 1150s. Pascal puts his triangle in 1665.
Theorem 10.5.2. For n, r ∈ N and r ≤ n,
nr
n n!
= = .
r (n − r)!r! r!
Theorem 10.5.3.
n n
= .
r n−r
Example 10.5.1. Let A be a set with n elements. We want to count the
number of distinct subsets of the set A that have exactly r elements.
Example 10.5.2. Consider { a, b, c, d, e }.
i. How many different words of length 3?
Ans. 5 × 5 × 5 = 53 = 125. Note that each f ∈ A{ 1,2,3 } give a different
word.
ii. How many different words of length 3 if no letter is allowed to repeat?
Ans. 5 × 4 × 3 = 53 = 60. Note that each f ∈ A{ 1,2,3 } where f is an
injection gives a different word.
iii. How many different words of length 3 if the order of letters is not im-
portant?
Ans. There are 53 wordswith order. Each letter combination is counter
3
3! = 6 times. So 53! = 53 = 10
iv. How many different words of length 3 if letters are allowed to repeat
but the order of the letters is not important?
Ans.
aaa bbb ccc ddd eee 1234567
3 - - - - 0001111
2 - 1 - - 0011011
- 1 - 1 1 1011010
2 1 - - - 0010111
10.5. COUNTING METHODS 113
men 1 2 3 4 5 6 7 8
women 1 2 3 4 5 6 7 8 9
Example 10.5.5.
i. How many solutions does the equation x1 + x2 + x3 = 11 have, where
x1 , x2 , x3 ∈ N?
Ans. Note that since 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 11 the
pattern 11/1111/11111 which corresponds
to 2+4+5 is a solution. So
11+3−1
the number of solutions is 2
.
ii. The same question with constraint x1 ≥ 1, x2 ≥ 2, x3 ≥ 3?
Ans. Pick 1 of type 1, 2 of type 2, and 3 of type 3. Then there are
5+3−1
additional 5 selections out of 3 item types. So 5
.
Example 10.5.6. How many ways are there to place 10 indistinguishable balls
into 8 distinguishable bins? (Consider atoms. Electrons are indistinguish-
able. The energy levels of an atom are distinguishable.)
Ans. Rephrase the problem as 10 balls and 7 separators. So 10+8−1 7
.
Example 10.5.7. Suppose that S is a set with n elements. How many ordered
pairs (A, B) are there such thatA and B are subsets with A ⊆ B?
Ans. { A, B r A, S r B } is a partition of S. So any a ∈ S should belong
to one of them. Since S is finite, one can list its elements as (s1 , s2 , . . . , sn ).
Let
0, si ∈ A,
bi = 1, si ∈ B r A,
2, si ∈ S r B.
Then for any (b1 , b2 , . . . , bn ) ∈ { 0, 1, 2 }n , define A = { si | bi = 0 } and B =
{ si | bi = 0 ∨ bi = 1 }, hence A ⊆ B. Notice that we define a bijection
114 CHAPTER 10. COUNTING
between the set of ternary n-tuples { 0, 1, 2 }n ) and our set of (A, B) pairs.
So the number is equal to the number of ternary n-tuples, that is 3n .
n
10.6.2 Approximations for n! and r
There is no closed form of n!. Therefore calculating n! for large n is not
easy. It takes to much computation. Some approximations are usually used
instead.
Approximations for n!
Stirling provided an approximation for n! in 1730. Stirling’s approximation
is quite good for n ≫ 1 [Rei67, Mac03]. Even as small values as n = 10, the
error is less than 1%.
n! = 1 × 2 × · · · × n
ln n! = ln 1 + ln 2 + · · · + ln n
Z n
≈ ln xdx = [x ln x − x|n1 = n ln n − n + 1
1
≈ n ln n − n
n
n! ≈ en ln n−n = eln n e−n = nn e−n .
10.6. SUPPLEMENTARY MATERIALS 115
√
n! ≈ nn e−n 2πn
1
ln n! ≈ n ln n − n + ln(2πn).
2
√ n n √ n n
2πn e1/(12n+1) < n! < 2πn e1/12n .
e e
n
Approximations for r
n
Using approximations for n!, r
is obtained:
n n!
=
r (n − r)!r!
n
ln = ln n! − ln(n − r)! − ln r!
r
≈ n ln n − n
− ((n − r) ln(n − r) − (n − r))
− (r ln r − r)
= n ln n − (n − r) ln(n − r) − r ln r
= ln nn ln(n − r)(n−r) ln r r
nn
= ln .
(n − r)(n−r) r r
116 CHAPTER 10. COUNTING
n nn
log2 = log2
r (n − r)(n−r) r r
n(n−r) nr
= log2
(n − r)(n−r) r r
n−r n r
n
= log2 + log2
n−r r
n n
= (n − r) log2 + r log2
n−r r
(n − r) n r n
=n log2 + log2
n n−r n r
!
(n − r) 1 r 1
=n log2 (n−r) + log2 r
n n n
n
!
r 1 r 1
=n 1− log2 r
+ log2 r
n 1− n n n
r
= n H2 .
n
where the binary entropy function, H2 (x), is given as
10.7 Problems
Solution.
10.7. PROBLEMS 117
∀s ∈ S [s ∈ S] tautology
⇔∀s ∈ S [(s ∈ B) ⊕ (s ∈ S − B)] since B ⊆ S ⇒ S = B ∪ (S − B)
and B ∩ (S − B) = ∅
⇔∀s ∈ S [((s ∈ A) ⊕ (s ∈ B − A)) ⊕ (s ∈ S − B)] since A ⊆ B ⇒ B = A ∪ (B − A)
and A ∩ (B − A) = ∅
3| · 3 ·{z· · · · 3} = 3n .
n times
Suppose that S is a set with n elements. How many ordered pairs (A, B)
are there such that A and B are subsets of S with A ⊆ B? [Hint: Show that
each element of S belongs to A, B r A, or S r B.]
Solution.
Let A and B subsets of S with A ⊆ B.
∀s ∈ S [s ∈ S] tautology
⇔∀s ∈ S [(s ∈ B) ⊕ (s ∈ S − B)] since B ⊆ S ⇒ S = B ∪ (S − B)
and B ∩ (S − B) = ∅
⇔∀s ∈ S [((s ∈ A) ⊕ (s ∈ B − A)) ⊕ (s ∈ S − B)] since A ⊆ B ⇒ B = A ∪ (B − A)
and A ∩ (B − A) = ∅
3| · 3 ·{z· · · · 3} = 3n .
n times
118 CHAPTER 10. COUNTING
Solution.
Solution.
The number of one-to-one functions, which have at least one fixed point,
can be computed by subtracting the number of one-to-one functions, which
does not have any fixed points, from the number of all one-to-one functions.
The number of all one-to-one functions f : A → A is n!
A function which does not have any fixed point is a derangement. The
number of derangements of a set with n element is Dn where:
1 1 1 n 1
Dn = n! 1 − + − + .... + (−1) .
1! 2! 3! n!
b1 = f −1 (min{ f (b) | b ∈ B })
b2 = f −1 (min{ f (b) | b ∈ B − {b1 } })
b3 = f −1 (min{ f (b) | b ∈ B − {b1 , b2 } })
... = .......
bn = f −1 (min{ f (b) | b ∈ B − {b1 , b2 , ....., bn−1 } })
This is equivalent to saying that we are listing B’s elements in the same order
as they are listed by f . Hence, B is countable.
Solution.
120 CHAPTER 10. COUNTING
Chapter 11
Recurrence
11.1 Motivation
11.2 Recurrence Equations
11.3 Problems
Q15 [20 points]
Markov chains are powerful models that are often used in Computer Science.
In one application of Markov models is the population dynamics where there
are two types A and B in competition with populations nA and nB where
the total population nA + nB is constant. So if type A increases by one,
type B should decreases by one. Then, the state i of the system can be
represented by the population of A, that is, i = nA . Hence there are N + 1
states represented by 0, 1, · · · , N. If the system is in state i, then it moves
to state i − 1 and i + 1 with probabilities pi,i−1 and pi,i+1 , respectively. Then
with probability 1 − (pi,i−1 + pi,i+1 ) it stays in i. The states 0 and N are
absorbing states. When the system gets in one of these, there is no way to
leave them, i.e. p0,1 = pN −1,N = 0 and p0,0 = pN,N = 1.
Assuming pi,i−1 = pi,i+1 = a, one obtains the following recurrence equa-
tion:
x0 = 0,
xi = axi+1 + (1 − 2a)xi + axi−1 , ∀i 0 < i < N,
xN = 1.
121
122 CHAPTER 11. RECURRENCE
Solution.
The characteristic equation of xi = axi+1 +(1−2a)xi +axi−1 is ar 2 −2ar+a =
0. ar 2 − 2ar + a = a(r 2 − 2r + 1) = a(r − 1)2 . Since r = 1 is the root with
multiplicity 2, the solution would be xi = (β0 + β1 i)r i = β0 + β1 i.
Use boundry conditions to find the values of β0 and β1 .
x0 = 0 = β0 + β1 0 = β0 . So β0 = 0.
xN = 1 = β0 + β1 N = β1 N. So β1 = 1/N.
Finally, the solution is xi = i/N for i = 0, 1, · · · , N.
an+1 = α1 an + β1 bn
bn+1 = α2 an + β2 bn
where α1 , α2 , β1 , β2 ∈ R and ∆ = α1 β2 − α2 β1 6= 0.
Solve an and bn when a0 = C and b0 = D.
Solution.
The degenerated case is when α1 = 0 and β1 = 0. In this case the sequences
are not coupled and they are solved separately. That is, an = c1 α1n and
bn = c1 β2n .
Consider the non-degenarated case. Assume β1 6= 0. Then
1
bn = (an+1 − α1 an ) (11.1)
β1
1
bn+1 = (an+2 − α1 an+1 ). (11.2)
β1
Substituting bn and bn+1 into the second relation, we obtain
0 = bn+1 − α2 an − β2 bn
1 β2
⇒0 = (an+2 − α1 an+1 ) − α2 an − (an+1 − α1 an )
β1 β1
⇒ 0 = (an+2 − α1 an+1 ) − β1 α2 an − β2 (an+1 − α1 an )
⇒ 0 = an+2 + (−α1 − β2 )an+1 + (−α2 β1 + α1 β2 )an
11.3. PROBLEMS 123
Solution.
124 CHAPTER 11. RECURRENCE
Part VI
Graphs
125
Chapter 12
Graphs
12.1 Introduction
Graph is a very powerful representation used in many disciplines including
Computer Science, Management, Physics and of course Mathematics. Inter-
actions, relations of objects are usually represented by a graph.
On the other hand, graphs are used for social entertainment. Remember
questions such as “can you draw this without removing your pencil from the
paper” as in Fig. 12.1.
Example 12.1.1. Consider www, web pages and links. A web page has links
to other web pages. A web page a can have many links to page b but there
may be no link from b to a. Your web page probably have a link to google.com
but you would be very lucky if home page of google.com has a link to your
web page.
127
128 CHAPTER 12. GRAPHS
A web page can have a link to an item in itself. Long web pages have
internal links to headings in it.
12.2 Graphs
Definition 12.2.1 (Multigraph).
A Multigraph G = ( V, A, ϕ ) consists of a nonempty set V of vertices, a set
A of arcs and a function ϕ : A → V × V
Remark 12.2.1.
• V is nonempty but A could be empty. So, a single vertex with no arcs is
the most simple graph.
• arcs will be denoted by Greek letters.
−−−→
• arc −
→
α = (u, v) if ϕ(−
→α ) = (u, v).
• Function ϕ is in general not an injection. So it is possible that ϕ(−
→
αi ) =
ϕ(−
→
αj ) = (u, v) for −
→
αi 6= −
→. Hence, two vertices can be connected more
α j
−−−→
than once, and therefore (u, v) representation of arcs becomes ambiguous.
Example 12.2.1.
α1
path: α1 α3 α2
1 2 1 0 0
v1 gs 0 0 1 0 0 simple path: α4 α2 α1 α5
α6 α2
elementary: α6 α4
1 0 0 0 0
α5
α3 0 0 0 0 1 circuit: α3 α2
v2 w 3
' v3 0 0 0 0 0 loop: α1
α4
v4 α7 + v5
12.2. GRAPHS 129
Definition 12.2.5.
arc a simple path
A path which does not traverse the same twice is called
vertex an elementary path
.
Definition 12.2.6. Circuit is a finite path such that the origin of the first
one coincides with the terminus of the last.
Definition 12.2.8. The number of arcs in a finite path is called the order
of the path.
Remark 12.2.4.
i. Connection array MG∗ of G∗ has only 0s and 1s.
ii. [MG∗ ]ij = 1 means there is an arc from vi to vj .
Remark 12.2.5.
• Mρk+1 = Mρ Mρk = (Mρ )k+1
• ρρk = ρk ρ
Theorem 12.2.1. Let G = ( V, ρ ) be a simple graph describing ρ.
There is a path of order n from u to v ←→ (u, v) ∈ ρn .
Algorithm 2: Reachability
Input: Dividend n > 0 and divisor d > 0
Output: Quotient q and remainder r, 0 ≤ r < d
/* reachability for G∗ = (V, ρ) */
/* where | V | = n */
1 begin
2 M(G) ← Mρ
3 for k = 2 to n − 1 do
4 M(G) = M(G) + Mρk
5 end
6 end
Example 12.2.2.
v1
1 |||
| 3 0 1 0 1
||
8 2
0 0 0 1
~|| MG∗ =
v2X Bs /3' v4 0 1 0 0
BB 4 |
BB 5 9 ||| 0 1 1 0
B |
6 BB |
~|w | 10
7
v3 M(G) = MG∗
132 CHAPTER 12. GRAPHS
0 1 0 1 0 1 0 1 0 1 0 1
0 0 0 1 0 0 0 1 0 0 0 1
MG2 = ∨
0 1 0 0 0 1 0 0 0 1
0 0
0 1 1 0 0 1 1 0 0 1 1 0
0 1 0 1 0 1 1 1 0 1 1 1
0 0 0 1 0
1 1 0 0
1 1 1
=
0 ∨ =
1 0 0 0 0 0 1 0 1 0 1
0 1 1 0 0 1 0 1 0 1 1 1
0 1 1 1 0 1 0 1 0 1 1 1
0 1 1 1 0 0 0 1 0 1 1 0
MG3 = ∨
0 1 0 1 0 1 0 0 0 0
0 1
0 1 1 1 0 1 1 0 0 1 0 1
0 1 1 1 0 1 1 1 0 1 1 1
0 1 1 1 0
1 0 1 0
1 1 1
=
0 ∨ =
1 0 1 0 1 1 0 0 1 1 1
0 1 1 1 0 1 1 1 0 1 1 1
0 1 1 1
0 1 1 1
MG∗ = ... =
0
not strongly connected.
1 1 1
0 1 1 1
b) use V0 = { { v1 , v4 } , { v2 , v3 } } as an example.
Then the cut-set relative to V0 is { α1 , α8 , α9 , α10 }.
Example 12.2.3.
, 0/1
1/0 q0 l
GFED
@ABC q
, GFED
@ABC
1
Y
1/0
1/1 0/0
q2 t
GFED
@ABC
T
0/0
89:;
?>=<
h
Remark 12.3.1.
K3,3 K5
12.6 Tree
Definition 12.6.1. A tree is a connected undirected graph with no cycles.
A tree of an isolated vertex is called degenerated tree.
Definition 12.6.5. An oriented rooted tree is a rooted tree such that the set
of arcs issuing from any vertex is an ordered set.
Representation
12.7 Problems
Q18 [20 points]
P
Suppose d1 , d2 , . . . , dn ∈ Z+ with ni=1 di = 2n − 2. Show that there is a tree
that has n vertices with degree sequence d1 , d2 , . . . , dn .
Solution.
Note that ∀i [di > 0]. Use induction on the number of vertices n.
Case n = 1. Since 2n − 2 = 0, the degree sequence is d1 = 0 only. A
degenerated tree with one vertex satisfies the proposition. Note that d1 = 0
does not actually satisfy the rule that di > 0. So the question should have
one more condition such as n > 1. Hence induction should start from n = 2.
Induction Base. n = 2. Since 2n − 2 = 2, the degree sequence can only
be d1 = 1, d2 = 1. A tree with 2 vertices connected by an edge satisfies it.
Induction. Assume that it is true for n ≥ 2. Then show that is must be
true for n + 1.
Consider a degree sequence d1 , d2 , . . . , , dn , dn+1 . If we can show that
there exist vertices vk of degree dk = 1 and vℓ of degree dℓ > 1, then we
can construct such tree as follows: Reindex d1 , d2 , . . . , dn−1 , dn , dn+1 so that
we have dn > 1 and dn+1 = 1. Hence, dn − 1 > 0. By induction hypotesis,
there exists a corresponding tree T with n vertices for the degree sequence
d1 , d2 , . . . , dn−1 , dn − 1. Obtain a new tree T ′ by add vertex vn+1 to T by
connecting vn+1 to vn . The degree sequence of T ′ becomes d1 , d2, . . . , , dn −
1 + 1, dn+1 = 1.
Existence P
P of dk = 1. Suppose ∀i ∈ { 1, 2, P.n. . , n } [di > 1]. Then di ≥ 2,
n n
so i=1 di ≥ i=1 2 = 2n > 2n − 2. Since i=1 di = 2n − 2, there must be
at lease one vertex with dk < 2, that is dk = 1. Pn
Pn Existence of d ℓ > 1. Suppose
Pn ∀i ∈ { 1, 2, . . . , n } [d i = 1]. Then i=1 di =
i=1 1 = n < 2n − 2. Since i=1 di = 2n − 2, There must be at lease one
vertex with dk > 1.
Solution.
Solution.
Bibliography
[LP98] Rudolf Lidl and Gunter Pilz. Applied Abstract Algebra. Springer,
1998.
[Nes09] Ali Nesin. Mathematige Giris: III. Sayma. Nesin Yayincilik, 2009.
145
146 BIBLIOGRAPHY
.
148 BIBLIOGRAPHY
(a1 , a2 ), 21 { a1 , a2 , . . . }, 19
(a1 , a2 , . . . , an ), 21
A = B, 20 { a , P (a) }19
AΓE30F B, 23 A, 19
A ∩ B, 22
A ∪ B, 22 B, 19
A 6= B, 20
A ⊕ B, 23
A ⊂ B, 20
A ⊆ B, 20
A × B, 21
An , 21
A1 × A2 × · · · × An , 21
∅, 19
| A |, 20
C, 6
N, 6
Q+ , 6
Q− , 6
Q≥0 , 6
Q≤0 , 6
Q, 6
R+ , 6
R− , 6
R≥0 , 6
R, 6
Z+ , 6
Z− , 6
Z≥0 , 6
Z≤0 , 6
Z, 6
A, 23
a ∈ A, 19
a∈ / A, 19
A
2 , 20
THE CONCEPTS INDEX 149
Ba , 26 antisymmetric, 5
F , 12
M ⊤ , 26 bi-implication, 15
Mα , 24 biconditional statement, 14
Mβ ⊙ Mα , 25 bijection, 28
T , 12 binary relation, 24
[M]ij , 24 boolean n-tuple, 13
α−1 , 26 boolean domain, 13
β ◦ α, 25 cardinality, 20
f : A → B, 27 Cartesian product, 21
B A , 27 codomain, 27
∃xφ(x), 11 complement, 23, 26
∀xφ(x), 11 composition, 25
p̄, 14 compound propositions, 14
B, 13 concept, 19
Z+ , 5 conclusion, 15
¬p, 14 conditional statement, 14
α, 26 conjunction, 14
φ ←→ ψ, 12 constant-False, 14
a α b, 24 constant-True, 14
p ⇐⇒ q, 17 contingency, 16
p ←→ q, 14 contradiction, 16
p −→ q, 14 contrapositive, 15
p ∧ q, 14 converse, 15
p ∨ q, 14
p ≡ q, 17 difference, 23
p ⊕ q, 14 disjoint, 23
=, 21 disjunction, 14
cod f , 27 domain, 27
dom f , 27 dyadic, 13
ran f , 27
element, 19
=⇒ , 11 empty set, 19
equal, 20, 21
a=b, 12 equivalent, 15
150 BIBLIOGRAPHY
truth table, 13
truth value, 12
union, 22
universally, 11
unordered n-tuple, 19