Are you sure?
This action might not be possible to undo. Are you sure you want to continue?
Marcel B. Finan
Arkansas Tech University
c (All Rights Reserved
2
Preface
This book is designed for a one semester course in discrete mathematics
for sophomore or junior level students. The text covers the mathematical
concepts that students will encounter in many disciplines such as computer
science, engineering, Business, and the sciences.
Besides reading the book, students are strongly encouraged to do all the
excercises. Mathematics is a discipline in which working the problems is es
sential to the understanding of the material contained in this book. Students
are encouraged ﬁrst to do the problems without referring to the solutions.
Solutions to problems found at the end of this book can only be used when
you are stuck. Exert a reasonable amount of eﬀorts towards solving a prob
lem before you look up the answer, and rework any problem you miss.
Students are strongly encouraged to keep up with the exercises and the se
quel of concepts as they are going along, for mathematics builds on itself.
Solution Manual for the text can be requested from the author through
email:mﬁnan@atu.edu
Marcel B. Finan
May 2001
3
4 PREFACE
Contents
Preface 3
Fundamentals of Mathematical Logic 7
1 Propositions and Related Concepts . . . . . . . . . . . . . . . . . 8
2 Conditional and Biconditional Propositions . . . . . . . . . . . . 18
3 Rules of Inferential Logic . . . . . . . . . . . . . . . . . . . . . . . 24
4 Propositions and Quantiﬁers . . . . . . . . . . . . . . . . . . . . . 33
5 Arguments with Quantiﬁed Premises . . . . . . . . . . . . . . . . 41
6 Project I: Digital Logic Design . . . . . . . . . . . . . . . . . . . 45
7 Project II: Number Systems . . . . . . . . . . . . . . . . . . . . . 50
Fundamentals of Mathematical Proofs 53
8 Methods of Direct Proof I . . . . . . . . . . . . . . . . . . . . . . 53
9 More Methods of Proof . . . . . . . . . . . . . . . . . . . . . . . 59
10 Methods of Indirect Proofs: Contradiction and Contraposition . 64
11 Method of Proof by Induction . . . . . . . . . . . . . . . . . . . 67
12 Project III: Elementary Number Theory and Mathematical Proofs 74
13 Project IV: The Euclidean Algorithm . . . . . . . . . . . . . . . 76
14 Project V: Induction and the Algebra of Matrices . . . . . . . . 78
Fundamentals of Set Theory 81
15 Basic Deﬁnitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
16 Properties of Sets . . . . . . . . . . . . . . . . . . . . . . . . . . 90
17 Project VI: Boolean Algebra . . . . . . . . . . . . . . . . . . . . 98
Relations and Functions 99
18 Equivalence Relations . . . . . . . . . . . . . . . . . . . . . . . . 99
19 Partial Order Relations . . . . . . . . . . . . . . . . . . . . . . . 110
5
6 CONTENTS
20 Functions: Deﬁnitions and Examples . . . . . . . . . . . . . . . 116
21 Bijective and Inverse Functions . . . . . . . . . . . . . . . . . . . 124
22 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
23 Project VII: Applications to Relations . . . . . . . . . . . . . . . 145
24 Project VIII: WellOrdered Sets and Lattices . . . . . . . . . . . 148
25 Project IX: The Pigeonhole Principle . . . . . . . . . . . . . . . 149
26 Project X: Countable Sets . . . . . . . . . . . . . . . . . . . . . 150
27 Project XI: FiniteState Automaton . . . . . . . . . . . . . . . . 152
Introduction to the Analysis of Algorithms 157
28 Time Complexity and ONotation . . . . . . . . . . . . . . . . . 157
29 Logarithmic and Exponential Complexities . . . . . . . . . . . . 165
30 Θ and ΩNotations . . . . . . . . . . . . . . . . . . . . . . . . . 169
Fundamentals of Counting and Probability Theory 173
31 Elements of Counting . . . . . . . . . . . . . . . . . . . . . . . . 173
32 Basic Probability Terms and Rules . . . . . . . . . . . . . . . . . 180
33 Binomial Random Variables . . . . . . . . . . . . . . . . . . . . 191
Elements of Graph Theory 197
34 Graphs, Paths, and Circuits . . . . . . . . . . . . . . . . . . . . 197
35 Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Fundamentals of Mathematical
Logic
Logic is commonly known as the science of reasoning. The emphasis here
will be on logic as a working tool. We will develop some of the symbolic
techniques required for computer logic. Some of the reasons to study logic
are the following:
• At the hardware level the design of ’logic’ circuits to implement in
structions is greatly simpliﬁed by the use of symbolic logic.
• At the software level a knowledge of symbolic logic is helpful in the
design of programs.
7
8 FUNDAMENTALS OF MATHEMATICAL LOGIC
1 Propositions and Related Concepts
A proposition is any meaningful statement that is either true or false, but
not both. We will use lowercase letters, such as p, q, r, , to represent
propositions. We will also use the notation
p : 1 + 1 = 3
to deﬁne p to be the proposition 1+1 = 3. The truth value of a proposition
is true, denoted by T, if it is a true statement and false, denoted by F, if it
is a false statement. Statements that are not propositions include questions
and commands.
Example 1.1
Which of the following are propositions? Give the truth value of the propo
sitions.
a. 2 + 3 = 7.
b. Julius Ceasar was president of the United States.
c. What time is it?
d. Be quiet !
Solution.
a. A proposition with truth value (F).
b. A proposition wiht truth value (F).
c. Not a proposition since no truth value can be assigned to this statement.
d. Not a proposition
Example 1.2
Which of the following are propositions? Give the truth value of the propo
sitions.
a. The diﬀerence of two primes.
b. 2 + 2 = 4.
c. Washington D.C. is the capital of New York.
d. How are you?
Solution.
a. Not a proposition.
b. A proposition with truth value (T).
c. A proposition with truth value (F).
1 PROPOSITIONS AND RELATED CONCEPTS 9
d. Not a proposition
New propositions called compound propositions or propositional func
tions can be obtained from old ones by using symbolic connectives which
we discuss next. The propositions that form a propositional function are
called the propositional variables.
Let p and q be propositions. The conjunction of p and q, denoted p ∧ q, is
the proposition: p and q. This proposition is deﬁned to be true only when
both p and q are true and it is false otherwise. The disjunction of p and
q, denoted p ∨ q, is the proposition: p or q. The ’or’ is used in an inclusive
way. This proposition is false only when both p and q are false, otherwise it
is true.
Example 1.3
Let
p : 5 < 9
q : 9 < 7.
Construct the propositions p ∧ q and p ∨ q.
Solution.
The conjunction of the propositions p and q is the proposition
p ∧ q : 5 < 9 and 9 < 7.
The disjunction of the propositions p and q is the proposition
p ∨ q : 5 < 9 or 9 < 7
Example 1.4
Consider the following propositions
p : It is Friday
q : It is raining.
Construct the propositions p ∧ q and p ∨ q.
10 FUNDAMENTALS OF MATHEMATICAL LOGIC
Solution.
The conjunction of the propositions p and q is the proposition
p ∧ q : It is Friday and it is raining.
The disjunction of the propositions p and q is the proposition
p ∨ q : It is Friday or It is raining
A truth table displays the relationships between the truth values of propo
sitions. Next, we display the truth tables of p ∧ q and p ∨ q.
p q p ∧ q
T T T
T F F
F T F
F F F
p q p ∨ q
T T T
T F T
F T T
F F F
Let p and q be two propositions. The exclusive or of p and q, denoted p⊕q,
is the proposition that is true when exactly one of p and q is true and is false
otherwise. The truth table of the exclusive ’or’ is displayed below
p q p ⊕q
T T F
T F T
F T T
F F F
Example 1.5
a. Construct a truth table for (p ⊕q) ⊕r.
b. Construct a truth table for p ⊕p.
Solution.
a.
1 PROPOSITIONS AND RELATED CONCEPTS 11
p q r p ⊕q (p ⊕ q) ⊕ r
T T T F T
T T F F F
T F T T F
T F F T T
F T T T F
F T F T T
F F T F T
F F F F F
b.
p p ⊕ p
T F
F F
The ﬁnal operation on a proposition p that we discuss is the negation of p.
The negation of p, denoted ∼ p, is the proposition not p. The truth table of
∼ p is displayed below
p ∼ p
T F
F T
Example 1.6
Consider the following propositions:
p: Today is Thursday.
q: 2 + 1 = 3.
r: There is no pollution in New Jersey.
Construct the truth table of [∼ (p ∧ q)] ∨ r.
Solution.
p q r p ∧q ∼ (p ∧ q) [∼ (p ∧ q)] ∨ r
T T T T F T
T T F T F F
F T T F T T
F T F F T T
12 FUNDAMENTALS OF MATHEMATICAL LOGIC
Example 1.7
Find the negation of the proposition p : −5 < x ≤ 0.
Solution.
The negation of p is the proposition ∼ p : x > 0 or x ≤ −5
A compound proposition is called a tautology if it is always true, regardless
of the truth values of the basic propositions which comprise it.
Example 1.8
a. Construct the truth table of the proposition (p∧q)∨(∼ p∨ ∼ q). Determine
if this proposition is a tautology.
b. Show that p∨ ∼ p is a tautology.
Solution.
a.
p q ∼ p ∼ q ∼ p∨ ∼ q p ∧ q (p ∧ q) ∨ (∼ p∧ ∼ q)
T T F F F T T
T F F T T F T
F T T F T F T
F F T T T F T
Thus, the given proposition is a tautology.
b.
p ∼ p p∨ ∼ p
T F T
F T T
Again, this proposition is a tautology.
Two propositions are equivalent if they have exactly the same truth values
under all circumstances. We write p ≡ q.
Example 1.9
a. Show that ∼ (p ∨ q) ≡∼ p∧ ∼ q.
b. Show that ∼ (p ∧ q) ≡∼ p∨ ∼ q.
c. Show that ∼ (∼ p) ≡ p.
a. and b. are known as DeMorgan’s laws.
1 PROPOSITIONS AND RELATED CONCEPTS 13
Solution.
a.
p q ∼ p ∼ q p ∨ q ∼ (p ∨ q) ∼ p∧ ∼ q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
b.
p q ∼ p ∼ q p ∧ q ∼ (p ∧ q) ∼ p∨ ∼ q
T T F F T F F
T F F T F T T
F T T F F T T
F F T T F T T
c.
p ∼ p ∼ (∼ p)
T F T
F T F
Example 1.10
a. Show that p ∧ q ≡ q ∧ p and p ∨ q ≡ q ∨ p.
b. Show that (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) and (p ∧ q) ∧ r ≡ p ∧ (q ∧ r).
c. Show that (p ∧q) ∨r ≡ (p ∨r) ∧(q ∨r) and (p ∨q) ∧r ≡ (p ∧r) ∨(q ∧r).
Solution.
a.
p q p ∧ q q ∧ p
T T T T
T F F F
F T F F
F F F F
p q p ∨ q q ∨ p
T T T T
T F T T
F T T T
F F F F
14 FUNDAMENTALS OF MATHEMATICAL LOGIC
b.
p q r p ∨ q q ∨ r (p ∨ q) ∨ r p ∨ (q ∨ r)
T T T T T T T
T T F T T T T
T F T T T T T
T F F T F T T
F T T T T T T
F T F T T T T
F F T F T T T
F F F F F F F
p q r p ∧ q q ∧ r (p ∧ q) ∧ r p ∧ (q ∧ r)
T T T T T T T
T T F T F F F
T F T F F F F
T F F F F F F
F T T F T F F
F T F F F F F
F F T F F F F
F F F F F F F
c.
p q r p ∧ q p ∨ r q ∨ r (p ∧ q) ∨ r (p ∨ r) ∧ (q ∨ r)
T T T T T T T T
T T F T T T T T
T F T F T T T T
T F F F T F F F
F T T F T T T T
F T F F F T F F
F F T F T T T T
F F F F F F F F
1 PROPOSITIONS AND RELATED CONCEPTS 15
p q r p ∨ q p ∧ r q ∧ r (p ∨ q) ∧ r (p ∧ r) ∨ (q ∧ r)
T T T T T T T T
T T F T F F F F
T F T T T F T T
T F F T F F F F
F T T T F T T T
F T F T F F F F
F F T F F F F F
F F F F F F F F
Example 1.11
Show that ∼ (p ∧ q) ≡∼ p∧ ∼ q
Solution.
We will use truth tables to prove the claim.
p q ∼ p ∼ q p ∧ q ∼ (p ∧ q) ∼ p∧ ∼ q
T T F F T F F
T F F T F T = F
F T T F F T = F
F F T T F T T
A compound proposition that has the value F for all possible values of the
propositions in it is called a contradiction.
Example 1.12
Show that the proposition p∧ ∼ p is a contradiction.
Solution.
p ∼ p p∧ ∼ p
T F F
F T F
In propositional functions, the order of operations is that ∼ is performed
ﬁrst. The operations ∨ and ∧ are executed in any order.
16 FUNDAMENTALS OF MATHEMATICAL LOGIC
Review Problems
Problem 1.1
Indicate which of the following sentences are propositions.
a. 1,024 is the smallest fourdigit number that is perfect square.
b. She is a mathematics major.
c. 128 = 2
6
d. x = 2
6
.
Problem 1.2
Consider the propositions:
p: Juan is a math major.
q: Juan is a computer science major.
Use symbolic connectives to represent the proposition ”Juan is a math major
but not a computer science major.”
Problem 1.3
In the following sentence is the word ”or” used in its inclusive or exclusive
sense? ”A team wins the playoﬀs if it wins two games in a row or a total of
three games.”
Problem 1.4
Write the truth table for the proposition: (p ∨ (∼ p ∨ q))∧ ∼ (q∧ ∼ r).
Problem 1.5
Let t be a tautology. Show that p ∨ t ≡ t.
Problem 1.6
Let c be a contradiction. Show that p ∨ c ≡ p.
Problem 1.7
Show that (r ∨ p) ∧ [(∼ r ∨ (p ∧ q)) ∧ (r ∨ q)] ≡ p ∧ q.
Problem 1.8
Use De Morgan’s laws to write the negation for the proposition:”This com
puter program has a logical error in the ﬁrst ten lines or it is being run with
an incomplete data set.”
1 PROPOSITIONS AND RELATED CONCEPTS 17
Problem 1.9
Use De Morgan’s laws to write the negation for the proposition:”The dollar
is at an alltime high and the stock market is at a record low.”
Problem 1.10
Assume x ∈ IR. Use De Morgan’s laws to write the negation for the proposition:0 ≥
x > −5.
Problem 1.11
Show that the proposition s = (p ∧ q) ∨ (∼ p ∨ (p∧ ∼ q)) is a tautology.
Problem 1.12
Show that the proposition s = (p∧ ∼ q) ∧ (∼ p ∨ q) is a contradiction.
Problem 1.13
a. Find simpler proposition forms that are logically equivalent to p ⊕p and
p ⊕(p ⊕p).
b. Is (p ⊕q) ⊕r ≡ p ⊕(q ⊕r)? Justify your answer.
c. Is (p ⊕q) ∧ r ≡ (p ∧ r) ⊕(q ∧ r)? Justify your answer.
Problem 1.14
Show the following:
a. p ∧ t ≡ p, where t is a tautology.
b. p ∧ c ≡ c, where c is a contradiction.
c. ∼ t ≡ c and ∼ c ≡ t.
d. p ∨ p ≡ p and p ∧ p ≡ p.
18 FUNDAMENTALS OF MATHEMATICAL LOGIC
2 Conditional and Biconditional Propositions
Let p and q be propositions. The implication p → q is the the proposition
that is false only when p is true and q is false; otherwise it is true. p is called
the hypothesis and q is called the conclusion. The connective → is called
the conditional connective.
Example 2.1
Construct the truth table of the implication p →q.
Solution.
The truth table is
p q p →q
T T T
T F F
F T T
F F T
Example 2.2
Show that p →q ≡∼ p ∨ q.
Solution.
p q ∼ p p →q ∼ p ∨ q
T T F T T
T F F F F
F T T T T
F F T T T
It follows from the previous example that the proposition p → q is always
true if the hypothesis p is false, regardless of the truth value of q. We say
that p →q is true by default or vacuously true.
In terms of words the proposition p →q also reads:
(a) if p then q.
(b) p implies q.
(c) p is a suﬃcient condition for q.
(d) q is a necessary condition for p.
(e) p only if q.
2 CONDITIONAL AND BICONDITIONAL PROPOSITIONS 19
Example 2.3
Use the ifthen form to rewrite the statement ”I am on time for work if I
catch the 8:05 bus.”
Solution.
If I catch the 8:05 bus then I am on time for work
In propositional functions that invlove the connectives ∼, ∧, ∨, and → the
order of operations is that ∼ is performed ﬁrst and → is performed last.
Example 2.4
a. Show that ∼ (p →q) ≡ p∧ ∼ q.
b. Find the negation of the statement ” If my car in the repair shop, then I
cannot go to class.”
Solution.
a. We use De Morgan’s laws as follows.
∼ (p →q) ≡ ∼ (∼ p ∨ q)
≡ ∼ (∼ p)∧ ∼ q
≡ p∧ ∼ q.
b. ”My car in the repair shop and I can get to class.”
The converse of p → q is the proposition q → p. The opposite or in
verse of p →q is the proposition ∼ p →∼ q. The contrapositive of p →q
is the proposition ∼ q →∼ p.
Example 2.5
Find the converse, opposite, and the contrapositive of the implication: ” If
today is Thursday, then I have a test today.”
Solution.
The converse: If I have a test today then today is Thursday.
The opposite: If today is not Thursday then I don’t have a test today.
The contrapositive: If I don’t have a test today then today in not Thursday
Example 2.6
Show that p →q ≡∼ q →∼ p.
20 FUNDAMENTALS OF MATHEMATICAL LOGIC
Solution.
We use De Morgan’s laws as follows.
p →q ≡ ∼ p ∨ q
≡ ∼ (p∧ ∼ q)
≡ ∼ (∼ q ∧ p)
≡ ∼∼ q∨ ∼ p
≡ q∨ ∼ p
≡ ∼ q →∼ p
Example 2.7
Using truth tables show the following:
a. p →q ≡ q →p
b. p →q ≡∼ p →∼ q
Solution.
a. It suﬃces to show that ∼ p ∨ q ≡∼ q ∨ p.
p q ∼ p ∼ q ∼ p ∨ q ∼ q ∨ p
T T F F T T
T F F T F = T
F T T F T = F
F F T T T T
b. We will show that ∼ p ∨ q ≡ p∨ ∼ q.
p q ∼ p ∼ q ∼ p ∨ q p∨ ∼ q
T T F F T T
T F F T F = T
F T T F T = F
F F T T T T
Example 2.8
Show that ∼ q →∼ p ≡ p →q
Solution.
We use De Morgan’s laws as follows.
∼ q →∼ p ≡ q∨ ∼ p
≡ ∼ (∼ q ∧ p)
≡ ∼ (p∧ ∼ q)
≡ ∼ p∨ ∼∼ q
≡ ∼ p ∨ q
≡ p →q
2 CONDITIONAL AND BICONDITIONAL PROPOSITIONS 21
The biconditional proposition of p and q, denoted by p ↔q, is the propo
sitional function that is true when both p and q have the same truth values
and false if p and q have opposite truth values. Also reads, ”p if and only if
q” or ”p is a necessary and suﬃcient condition for q.”
Example 2.9
Construct the truth table for p ↔q.
Solution.
p q p ↔q
T T T
T F F
F T F
F F T
Example 2.10
Show that the biconditional proposition of p and q is logically equivalent to
the conjunction of the conditional propositions p →q and q →p.
Solution.
p q p →q q →p p ↔q (p →q) ∧ (q →p)
T T T T T T
T F F T F F
F T T F F F
F F T T T T
The order of operations for the ﬁve logical connectives is as follows:
1. ∼
2. ∧, ∨ in any order.
3. →, ↔ in any order.
22 FUNDAMENTALS OF MATHEMATICAL LOGIC
Review Problems
Problem 2.1
Rewrite the following proposition in ifthen form: ” This loop will repeat
exactly N times if it does not contain a stop or a go to.”
Problem 2.2
Construct the truth table for the proposition: ∼ p ∨ q →r.
Problem 2.3
Construct the truth table for the proposition: (p →r) ↔(q →r).
Problem 2.4
Write negations for each of the following propositions. (Assume that all vari
ables represent ﬁxed quantities or entities, as appropriate.)
a. If P is a square, then P is a rectangle.
b. If today is Thanksgiving, then tomorrow is Friday.
c. If r is rational, then the decimal expansion of r is repeating.
d. If n is prime, then n is odd or n is 2.
e. If x ≥ 0, then x > 0 or x = 0.
f. If Tom is Ann’s father, then Jim is her uncle and Sue is her aunt.
g. If n is divisible by 6, then n is divisible by 2 and n is divisible by 3.
Problem 2.5
Write the contrapositives for the propositions of Exercise 40.
Problem 2.6
Write the converse and inverse for the propositions of Exercise 40.
Problem 2.7
Use the contrapositive to rewrite the proposition ” The Cubs will win the
penant only if they win tomorrow’s game” in ifthen form in two ways.
Problem 2.8
Rewrite the proposition :” Catching the 8:05 bus is suﬃcient condition for
my being on time for work” in ifthen form.
2 CONDITIONAL AND BICONDITIONAL PROPOSITIONS 23
Problem 2.9
Use the contrapositive to rewrite the proposition ” being divisible by 3 is a
necessary condition for this number to be divisible by 9” in ifthen form in
two ways.
Problem 2.10
Rewrite the proposition ”A suﬃcient condition for Hal’s team to win the
championship is that it wins the rest of the games” in ifthen form.
Problem 2.11
Rewrite the proposition ”A necessary condition for this computer program
to be correct is that it not produce error messages during translation” in
ifthen form.
24 FUNDAMENTALS OF MATHEMATICAL LOGIC
3 Rules of Inferential Logic
The main concern of logic is how the truth of some propositions is connected
with the truth of another. Thus, we will usually consider a group of related
propositions.
An argument is a set of two or more propositions related to each other in
such a way that all but one of them (the premises) are supposed to provide
support for the remaining one (the conclusion).
The transition from premises to conclusion is the inference upon which the
argument relies.
Example 3.1
Show that the propositions ”The star is made of milk, and strawberries are
red. My dog has ﬂeas.” do not form an argument.
Solution.
Indeed, the truth or falsity of each of the propositions has no bearing on that
of the others
Example 3.2
Show that the propositions:”Mark is a lawyer. So Mark went to law school
since all lawyers have gone to law school” form an argument.
Solution.
This is an argument. The truth of the conclusion, ”Mark went to law school,”
is inferred or deduced from its premises, ”Mark is a lawyer” and ”all lawyers
have gone to law school.”
The above argument can be represented as follows: Let
p: Mark is a lawyer.
q: All lawyers have gone to law school.
r: Mark went to law school.
Then
p ∧ q
˙ .. r
The symbol ˙ .. is to indicate the inferrenced conclusion.
Now, suppose that the premises of an argument are all true. Then the
3 RULES OF INFERENTIAL LOGIC 25
conclusion may be either true or false. When the conclusion is true then the
argument is said to be valid. When the conclusion is false then the argument
is said to be invalid.
To test an argument for validity one proceeds as follows:
(1) Identify the premises and the conclusion of the argument.
(2) Construct a truth table including the premises and the conclusion.
(3) Find rows in which all premises are true.
(4) In each row of Step (3), if the conclusion is true then the argument is
valid; otherwise the argument is invalid.
Example 3.3
Show that the argument
p → q
q → p
˙ .. p ∨ q
is invalid
Solution.
We construct the truth table as follows.
p q p →q q →p p ∨ q
T T T T T
T F F T T
F T T F T
F F T T F
From the last row we see that the premises are true but the conclusion is
false. The argument is then invalid
Example 3.4 (Modus Ponens or the method of aﬃrming)
a. Show that the argument
p → q
p
˙ .. q
is valid.
b. Show that the argument
∼ p ∨ q → r
∼ p ∨ q
˙ .. r
is valid.
26 FUNDAMENTALS OF MATHEMATICAL LOGIC
Solution.
a. The truth table is as follows.
p q p →q
T T T
T F F
F T T
F F T
The ﬁrst row shows that the argument is valid.
b. Follows from by replacing p with ∼ ∨q and q with r
Example 3.5
Show that the argument
p → q
q
˙ .. p
is invalid.
Solution.
The truth table is as follows.
p q p →q
T T T
T F F
F T T
F F T
Because of the third row the argument is invalid. An argument of this form is
referred to as converse error because the conclusion of the argument would
follows from the premises if p →q is replaced by its converse q →p
Example 3.6 (Modus Tollens or the method of denial)
Show that the argument
p → q
∼ q
˙ .. ∼ p
is valid.
3 RULES OF INFERENTIAL LOGIC 27
Solution.
The truth table is as follows.
p q p →q ∼ q ∼ p
T T T F F
T F F T F
F T T F T
F F T T T
The last row shows that the argument is valid
Example 3.7
Show that the argument
p → q
∼ p
˙ .. ∼ q
is invalid.
Solution.
The truth table is as follows.
p q p →q ∼ q ∼ p
T T T F F
T F F T F
F T T F T
F F T T T
The third row shows that the argument is invalid. This is known as inverse
error because the conclusion of the argument would follow from the premises
if p →q is replaced by the inverse q →p
Example 3.8 (Disjunctive Addition)
a. Show that the argument
p
˙ .. p ∨ q
is valid.
b. Show that the argument
q
˙ .. p ∨ q
is valid.
28 FUNDAMENTALS OF MATHEMATICAL LOGIC
Solution.
a. The truth table is as follows.
p q p ∨ q
T T T
T F T
F T T
F F F
The ﬁrst and second rows show that the argument is valid.
b. The ﬁrst and third rows show that the argument is valid
Example 3.9 (Conjunctive Simpliﬁcation)
a. Show that the argument
p ∧ q
˙ .. p
is valid.
b. Show that the argument
p ∧ q
˙ .. q
is valid.
Solution.
a. The truth table is as follows.
p q p ∧ q
T T T
T F F
F T F
F F F
The ﬁrst row shows that the argument is valid.
b. The ﬁrst row shows that the argument is valid
Example 3.10 (Disjunctive Syllogism)
a. Show that the argument
p ∨ q
∼ q
˙ .. p
3 RULES OF INFERENTIAL LOGIC 29
is valid.
b. Show that the argument
p ∨ q
∼ p
˙ .. q
is valid.
Solution.
a. The truth table is as follows.
p q ∼ p ∼ q p ∨ q
T T F F T
T F F T T
F T T F T
F F T T F
The second row shows that the argument is valid.
b. The third row shows that the argument is valid
Example 3.11 (Hypothetical Syllogism)
Show that the argument
p →q
q →r
˙ .. p →r
is valid.
Solution.
The truth table is as follows.
p q r p →q q →r p →r
T T T T T T
T T F T F F
T F T F T T
T F F F T F
F T T T T T
F T F T F T
F F T T T T
F F F T T T
The ﬁrst , ﬁfth, seventh, and eighth rows show that the argument is valid
30 FUNDAMENTALS OF MATHEMATICAL LOGIC
Example 3.12 (Rule of contradiction)
Show that if c is a contradiction then the following argument is valid for any
p.
∼ p →c
˙ .. p
Solution.
Constructing the truth table we ﬁnd
c p ∼ p →c
F T T
F F F
The ﬁrst row shows that the argument is valid
3 RULES OF INFERENTIAL LOGIC 31
Review Problems
Problem 3.1
Use modus ponens or modus tollens to ﬁll in the blanks in the argument
below so as to produce valid inferences.
If
√
2 is rational, then
√
2 =
a
b
for some integers a and b.
It is not true that
√
2 =
a
b
for some integers a and b.
˙ ..
Problem 3.2
Use modus ponens or modus tollens to ﬁll in the blanks in the argument
below so as to produce valid inferences.
If logic is easy, then I am a monkey’s uncle.
I am not a monkey’s uncle.
˙ ..
Problem 3.3
Use truth table to determine whether the argument below is valid.
p →q
q →p
˙ .. p ∨ q
Problem 3.4
Use truth table to determine whether the argument below is valid.
p
p →q
∼ q ∨ r
˙ .. r
Problem 3.5
Use symbols to write the logical form of the given argument and then use a
truth table to test the argument for validity.
If Tom is not on team A, then Hua is on team B.
If Hua is not on team B, then Tom is on team A.
˙ .. Tom is not on team A or Hua is not on team B.
32 FUNDAMENTALS OF MATHEMATICAL LOGIC
Problem 3.6
Use symbols to write the logical form of the given argument. If the argument
is valid, identify the rule of inference that guarantees its validity. Otherwise
state whether the converse or the inverse error is made.
If Jules solved this problem correctly, then Jules obtained the answer 2.
Jules obtained the answer 2.
˙ .. Jules solved this problem correctly.
Problem 3.7
Use symbols to write the logical form of the given argument. If the argument
is valid, identify the rule of inference that guarantees its validity. Otherwise
state whether the converse or the inverse error is made.
If this number is larger than 2, then its square is larger than 4.
This number is not larger than 2.
˙ .. The square of this number is not larger than 4.
Problem 3.8
Use the valid argument forms of this section to deduce the conclusion from
the premises.
∼ p ∨ q →r
s∨ ∼ q
∼ t
p →t
∼ p ∧ r →∼ s
˙ .. ∼ q
Problem 3.9
Use the valid argument forms of this section to deduce the conclusion from
the premises.
∼ p →r∧ ∼ s
t →s
u →∼ p
∼ w
u ∨ w
˙ .. ∼ t ∨ w
4 PROPOSITIONS AND QUANTIFIERS 33
4 Propositions and Quantiﬁers
Statements such as ”x > 3” are often found in mathematical assertions and
in computer programs. These statements are not propositions when the
variables are not speciﬁed. However, one can produce propositions from
such statements.
A predicate is an expression involving one or more variables deﬁned on some
domain, called the domain of discourse. Substitution of a particular value
for the variable(s) produces a proposition which is either true or false. For
instance, P(n) : n is prime is a predicate on the natural numbers. Observe
that P(1) is false, P(2) is true. In the expression P(x), x is called a free
variable. As x varies the truth value of P(x) varies as well. The set of true
values of a predicate P(x) is called the truth set and will be denoted by T
P
.
Example 4.1
Let Q(x, y) : x = y+3 with domain the collection of natural numbers (i.e. the
numbers 0, 1, 2, ). What are the truth values of the propositions Q(1, 2)
and Q(3, 0)?
Solution.
By substitution in the expression of Q we ﬁnd: Q(1, 2) is false since 1 = x =
y + 3 = 5. On the contrary, Q(3, 0) is true since x = 3 = 0 + 3 = y + 3
If P(x) and Q(x) are two predicates with a common domain D then the
notation P(x) ⇒Q(x) means that every element in the truth set of P(x) is
also an element in the truth set of Q(x).
Example 4.2
Consider the two predicates P(x) : x is a factor of 4 and Q(x) : x is a factor
of 8. Show that P(x) ⇒Q(x).
Solution.
Finding the truth set of each predicate we have: T
P
= ¦1, 2, 4¦ and T
Q
=
¦1, 2, 4, 8¦. Since every number appearing in T
P
also appears in T
Q
then
P(x) ⇒Q(x)
If two predicates P(x) and Q(x) with a common domain D are such that
T
P
= T
Q
then we use the notation P(x) ⇔Q(x).
34 FUNDAMENTALS OF MATHEMATICAL LOGIC
Example 4.3
Let D = IR. Consider the two predicates P(x) : −2 ≤ x ≤ 2 and Q(x) :
[x[ ≤ 2. Show that P(x) ⇔Q(x).
Solution.
Indeed, if x in T
P
then the distance from x to the origin is at most 2. That
is, [x[ ≤ 2 and hence x belongs to T
Q
. Now, if x is an element in T
Q
then
[x[ ≤ 2,i.e. (x−2)(x+2) ≤ 0. Solving this inequality we ﬁnd that −2 ≤ x ≤ 2.
That is, x ∈ T
P
Another way to generate propositions is by means of quantiﬁers. For exam
ple ∀x ∈ D, P(x) is a proposition which is true if P(x) is true for all values
of x in the domain D of P. For example, if k is an nonnegative integer, then
the predicate P(k) : 2k is even is true for all k ∈ IN. We write,
∀k ∈ IN, (2k is even).
The symbol ∀ is called the universal quantiﬁer.
The proposition ∀x ∈ D, P(x) is false if P(x) is false for at least one value
of x. In this case x is called a counterexample.
Example 4.4
Show that the proposition ∀x ∈ IR, x >
1
x
is false.
Solution.
A counterexample is x =
1
2
. Clearly,
1
2
< 2 =
1
1
2
.
Example 4.5
Write in the form ∀x ∈ D, P(x) the proposition :” every real number is either
positive, negative or 0.”
Solution.
∀x ∈ IR, x > 0, x < 0, or x = 0.
The notation ∃x ∈ D, P(x) is a proposition that is true if there is at least
one value of x ∈ D where P(x) is true; otherwise it is false. The symbol ∃ is
called the existential quantiﬁer.
4 PROPOSITIONS AND QUANTIFIERS 35
Example 4.6
Let P(x) denote the statement ”x > 3.” What is the truth value of the
proposition ∃x ∈ IR, P(x).
Solution.
Since 4 ∈ IR and 4 > 3, the given proposition is true
The proposition ∀x ∈ D, P(x) →Q(x) is called the universal conditional
proposition. For example, the proposition ∀x ∈ IR, if x > 2 then x
2
> 4 is
a universal conditional proposition.
Example 4.7
Rewrite the proposition ”if a real number is an integer then it is a rational
number” as a universal conditional proposition.
Solution.
∀x ∈ IR, if x is an interger then x is a rational number
Example 4.8
a. What is the negation of the proposition ∀x ∈ D, P(x)?
b. What is the negation of the proposition ∃x ∈ D, P(x)?
c. What is the negation of the proposition ∀x ∈ D, P(x) →Q(x)?
Solution.
a. ∃x ∈ D, ∼ P(x).
b. ∀x ∈ D, ∼ P(x).
c. Since P(x) →Q(x) ≡ (∼ P(x)) ∨Q(x) then ∼ (∀x ∈ D, P(x) →Q(x)) ≡
∃x ∈ D, P(x) and ∼ Q(x)
Example 4.9
Consider the universal conditional proposition
∀x ∈ D, if P(x) then Q(x).
a. Find the contrapositive.
b. Find the converse.
c. Find the inverse.
36 FUNDAMENTALS OF MATHEMATICAL LOGIC
Solution.
a. ∀x ∈ D, if ∼ Q(x) then ∼ P(x).
b. ∀x ∈ D, if Q(x) then P(x).
c. ∀x ∈ D, if ∼ P(x) then ∼ Q(x)
Example 4.10
Write the negation of each of the following propositions:
a. ∀x ∈ IR, x > 3 →x
2
> 9.
b. Every polynomial function is continuous.
c. There exists a triangle with the property that the sum of angles is greater
than 180
◦
.
Solution.
a. ∃x ∈ IR, x > 3 and x
2
≤ 9.
b. There exists a polynomial that is not continuous everywhere.
c. For any triangle, the sum of the angles is less than or equal to 180
◦
Next, we discuss predicates that contain multiple quantiﬁers. A typical ex
ample is the deﬁnition of a limit. We say that L = lim
x→a
f(x) if and only if
∀ > 0, ∃ a positive number δ such that if [x −a[ ≤ δ then [f(x) −L[ < .
Example 4.11
a. Let P(x, y) denote the statement ”x+y = y +x.” What is the truth value
of the proposition (∀x ∈ IR)(∀y ∈ IR), P(x, y)?
b. Let Q(x, y) denote the statement ”x +y = 0.” What is the truth value of
the proposition (∃y ∈ IR)(∀x ∈ IR), Q(x, y)?
Solution.
a. The given proposition is always true.
b. The proposition is false. For otherwise, one can choose x = −y to obtain
0 = x +y = 0 which is impossible
Example 4.12
Find the negation of the following propositions:
a. ∀x∃y, P(x, y).
b. ∃x∀y, P(x, y).
4 PROPOSITIONS AND QUANTIFIERS 37
Solution.
a. ∃x∀y, ∼ P(x, y).
b. ∀x∃y, ∼ P(x, y)
Example 4.13
The symbol ∃! stands for the phrase ”there exists a unique”. Which of the
following statements are true and which are false.
a. ∃!x ∈ IR, ∀y ∈ IR, xy = y.
b. ∃! integer x such that
1
x
is an integer.
Solution.
a. True. Let x = 1.
b. False since 1 and −1 are both integers with integer reciprocals
38 FUNDAMENTALS OF MATHEMATICAL LOGIC
Review Problems
Problem 4.1
By ﬁnding a counterexample, show that the proposition:” For all positive
integers n and m, m.n ≥ m+n” is false.
Problem 4.2
Consider the statement
∃x ∈ IR such that x
2
= 2.
Which of the following are equivalent ways of expressing this statement?
a. The square of each real number is 2.
b. Some real numbers have square 2.
c. The number x has square 2, for some real number x.
d. If x is a real number, then x
2
= 2.
e. Some real number has square 2.
f. There is at least one real number whose square is 2.
Problem 4.3
Rewrite the following propositions informally in at least two diﬀerent ways
without using the symbols ∃ and ∀ :
a. ∀ squares x, x is a rectangle.
b. ∃ a set A such that A has 16 subsets.
Problem 4.4
Rewrite each of the following statements in the form ”∃ x such that ”:
a. Some exercises have answers.
b. Some real numbers are rational.
Problem 4.5
Rewrite each of the following statements in the form ”∀ , if then .”:
a. All COBOL programs have at least 20 lines.
b. Any valid argument with true premises has a true conclusion.
c. The sum of any two even integers is even.
d. The product of any two odd integers is odd.
4 PROPOSITIONS AND QUANTIFIERS 39
Problem 4.6
Which of the following is a negation for ”Every polynomial function is con
tinuous”?
a. No polynomial function is continuous.
b. Some polynomial functions are continuous.
c. Every polynomial function fails to be continuous.
d. There is a noncontinuous polynomial function.
Problem 4.7
Determine whether the proposed negation is correct. If it is not, write a
correct negation.
Proposition : For all integers n, if n
2
is even then n is even.
Proposed negation : For all integer n, if n
2
is even then n is not even.
Problem 4.8
Let D = ¦−48, −14, −8, 0, 1, 3, 16, 23, 26, 32, 36¦. Determine which of the fol
lowing propositions are true and which are false. Provide counterexamples
for those propositions that are false.
a. ∀x ∈ D, if x is odd then x > 0.
b. ∀x ∈ D, if x is less than 0 then x is even.
c. ∀x ∈ D, if x is even then x ≤ 0.
d. ∀x ∈ D, if the ones digit of x is 2, then the tens digit is 3 or 4.
e. ∀x ∈ D, if the ones digit of x is 6, then the tens digit is 1 or 2
Problem 4.9
Write the negation of the proposition :∀x ∈ IR, if x(x +1) > 0 then x > 0 or
x < −1.
Problem 4.10
Write the negation of the proposition : If an integer is divisible by 2, then it
is even.
Problem 4.11
Given the following true propostion:” ∀ real numbers x, ∃ an integer n such
that n > x.” For each x given below, ﬁnd an n to make the predicate n > x
true.
a. x = 15.83 b. x = 10
8
c. x = 10
10
10
.
40 FUNDAMENTALS OF MATHEMATICAL LOGIC
Problem 4.12
Given the proposition: ∀x ∈ IR, ∃ a real number y such that x +y = 0.
a. Rewrite this proposition in English without the use of the quantiﬁers.
b. Find the negation of the given proposition.
Problem 4.13
Given the proposition: ∃x ∈ IR, ∀y ∈ IR, x +y = 0.
a. Rewrite this proposition in English without the use of the quantiﬁers.
b. Find the negation of the given proposition.
Problem 4.14
Consider the proposition ”Somebody is older than everybody.” Rewrite this
proposition in the form ”∃ a person x such that ∀ .”
Problem 4.15
Given the proposition: There exists a program that gives the correct answer
to every question that is posed to it.”
a. Rewrite this proposition using quantiﬁers and variables.
b. Find a negation for the given proposition.
Problem 4.16
Given the proposition: ∀x ∈ IR, ∃y ∈ IR such that x < y.
a. Write a proposition by interchanging the symbols ∀ and ∃.
b. State which is true: the given proposition, the one in part (a), neither, or
both.
Problem 4.17
Find the contrapositive, converse, and inverse of the proposition ”∀x ∈ IR, if
x(x + 1) > 0 then x > 0 or x < −1.”
Problem 4.18
Rewrite the following proposition in ifthen form :” Earning a grade of C
−
in this course is a suﬃcient condition for it to count toward graduation.”
Problem 4.19
Rewrite the following proposition in ifthen form :” Being on time each day
is a necessary condition for keeping this job.”
Problem 4.20
Rewrite the following proposition without using the words ”necessary” or ”
suﬃcient” : ”Divisibility by 4 is not a necessary condition for divisibility by
2.”
5 ARGUMENTS WITH QUANTIFIED PREMISES 41
5 Arguments with Quantiﬁed Premises
In this section we discuss three types of valid arguments that involve the
universal quantiﬁer.
• The rule of universal instantiation:
∀x ∈ D, P(x)
a ∈ D
˙ .. P(a)
Example 5.1
Use universal instantiation to ﬁll in valid conclusion for the following argu
ment.
All positive integers are greater than or equal to 1
3 is a positive integer
˙ ..
Solution.
All positive integers are greater than or equal to 1
3 is a positive integer
˙ .. 3 ≥ 1
• Universal Modus Ponen:
∀x ∈ D, if P(x) then Q(x)
P(a) for some a ∈ D
˙ .. Q(a)
Example 5.2
Use the rule of the universal modus ponens to ﬁll in valid conclusion for the
following argument.
∀n ∈ IN, if n = 2k for some k ∈ IN then n is even.
0 = 2.0
˙ ..
Solution.
∀n ∈ IN, if n = 2k for some k ∈ IN then n is even.
42 FUNDAMENTALS OF MATHEMATICAL LOGIC
0 = 2.0
˙ ..0 is even
• Universal Modus Tollens:
∀x ∈ D, if P(x) then Q(x)
∼ Q(a) for some a ∈ D
˙ .. ∼ P(a)
Example 5.3
Use the rule of the universal modus tonens to ﬁll in valid conclusion for the
following argument.
All healthy people eat an apple a day.
Harry does not eat an apple a day.
˙ ..
Solution.
All healthy people eat an apple a day.
Harry does not eat an apple a day.
˙ .. Harry is not healthy
Next, we discuss a couple of invalid arguments whose premises involve quan
tiﬁers.
• The rule of converse error:
∀x ∈ D, if P(x) then Q(x)
Q(a) for some a ∈ D
˙ .. P(a)
Example 5.4
What kind of error does the following invalid argument exhibit?
All healthy people eat an apple a day.
Helen eats an apple a day.
˙ .. Helen is healthy
Solution.
This invalid argument exhibits the converse error
5 ARGUMENTS WITH QUANTIFIED PREMISES 43
• The rule of inverse error:
∀x ∈ D, if P(x) then Q(x)
∼ P(a) for some a ∈ D
˙ .. ∼ Q(a)
Example 5.5
What kind of error does the following invalid argument exhibit?
All healthy people eat an apple a day.
Hubert is not a healthy person.
˙ .. Hubert does not eat an apple a day.
Solution.
This invalid argument exhibits the inverse error
44 FUNDAMENTALS OF MATHEMATICAL LOGIC
Review Problems
Problem 5.1
Use the rule of universal modus ponens to ﬁll in valid conclusion for the ar
gument.
For all real numbers a, b, c, and d, if b = 0 and d = 0 then
a
b
+
c
d
=
ad+bc
bd
.
a = 2, b = 3, c = 4, and d = 5 are particular real numbers such that b = 0
and d = 0.
˙ ..
Problem 5.2
Use the rule of universal modus tonens to ﬁll in valid conclusion for the ar
gument.
If a computer is correct, then compilation of the program does not produce
error messages.
Compilation of this program produces error messages.
˙ ..
Problem 5.3
Use the rule of universal modus ponens to ﬁll in valid conclusion for the ar
gument.
All freshmen must take writing.
Caroline is a freshman.
˙ .. .
Problem 5.4
What kind of error does the following invalid argument exhibit?
All cheaters sit in the back row.
George sits in the back row.
˙ .. George is a cheater.
Problem 5.5
What kind of error does the following invalid argument exhibit?
All honest people pay their taxes.
Darth is not honest.
˙ .. Darth does not pay his taxes.
6 PROJECT I: DIGITAL LOGIC DESIGN 45
6 Project I: Digital Logic Design
In this section we discuss the logic of digital circuits which are considered to
be the basic components of most digital systems, such as electronic comput
ers, electronic phones, traﬃc light controls, etc.
The purpose of digital systems is to manipulate discrete information which
are represented by physical quantities such as voltages and current. The
smallest representation unit is one bit, short for binary digit. Since electronic
switches have two physical states, namely high voltage and low voltage we
attribute the bit 1 to high voltage and the bit 0 for low voltage.
A logic gate is the smallest processing unit in a digital system. It takes one
or few bits as input and generates one bit as an output.
A circuit is composed of a number of logic gates connected by wires. It
takes a group of bits as input and generates one or more bits as output.
The six basic logic gates are the following:
(1) NOT gate (also called inverter): Takes an input of 0 to an output
of 1 and an input of 1 to an output of 0. The corresponding logical symbol
is ∼ P.
(2) AND gate: Takes two bits, P and Q, and outputs 1 if P and Q are 1 and
0 otherwise. The logical symbol is P ∧ Q.
(3) OR gate: outputs 1 if either P or Q is 1 and 0 otherwise. The logical
symbol is P ∨ Q.
(4) NAND gate: outputs a 0 if both P and Q are 1 and 1 otherwise. The
symbol is ∼ (P ∧ Q). Also, denoted by P[Q, where [ is called a Scheﬀer
stroke.
(5) NOR gate: output a 0 if at least one of P or Q is 1 and 1 otherwise. The
symbol is ∼ (P ∨ Q) or P ↓ Q, where ↓ is a Pierce arrow
The logic gates have the following graphical representations:
46 FUNDAMENTALS OF MATHEMATICAL LOGIC
Problem 6.1
Construct the truth tables of the gates discussed in this section.
If you are given a set of input signals for a circuit, you can ﬁnd its output
by tracing through the circuit gate by gate.
Problem 6.2
Give the output signal S for the following circuit, given that P = 0, Q = 1,
and R = 0 :
Problem 6.3
Write the input/output table for the circuit of the previous problem.
A variable with exactly two possible values is called a Boolean variable.
A Boolean expression is an expression composed of Boolean variables and
connectives (which are the gates in this section).
6 PROJECT I: DIGITAL LOGIC DESIGN 47
Problem 6.4
Find the Boolean expression that corresponds to the circuit of Problem 6.1.
Problem 6.5
Construct the circuit corresponding to the Boolean expression: (P ∧ Q)∨ ∼
R.
Problem 6.6
For the following input/output table, construct (a) the corresponding Boolean
expression and (b) the corresponding circuit:
P Q R S
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 1
0 1 0 0
0 0 1 0
0 0 0 0
Two digital logic circuits are equivalent if, and only if, their corresponding
Boolean expressions are logically equivalent.
Problem 6.7
Show that the following two circuits are equivalent:
Problem 6.8
Consider the following circuit
48 FUNDAMENTALS OF MATHEMATICAL LOGIC
Let P and Q be single binary digits and P + Q = RS. Complete the fol
lowing table
P Q R S
1 1
1 0
0 1
0 0
The given circuit is called a halfadder. It computes the sum of two single
binary digits.
Several methods have been used for expressing negative numbers in the com
puter. The most obvious way is to convert the number to binary and stick
on another bit to indicate sign, 0 for positive and 1 for negative. Suppose
that integers are stored using this signedmagnitude technique in 8 bits so
that the leftmost bit holds the sign while the remaining bits represent the
magnitude. Thus, +41
10
= 00101001 and −41
10
= 10101001.
The above procedure has a gap. How one would represent the bit 0? Well,
there are two ways for storing 0. One way is 00000000 which represents
+0 and a second way 10000000 represents −0. A method for representing
numbers that avoid this problem is called the two’s complement. Con
sidering −41
10
again, ﬁrst, convert the absolute value to binary obtaining
41
10
= 00101001. Then take the complement of each bit obtaining 11010110.
This is called the one complement of 41. To complete the procedure, in
crement by 1 the one’s complement to obtain −41
10
= 11010111.
Conversion of +41
10
to two’s complement consists merely of expressing the
number in binary, i.e. +41
10
= 00101001.
6 PROJECT I: DIGITAL LOGIC DESIGN 49
Problem 6.9
Express the numbers 104 and −104 in two’s complement representation with
8 bits.
Now, an algorithm to ﬁnd the decimal representation of the integer with a
given 8bit two’s complement is the following:
1. Find the two’s complement of the given two’s complement,
2. write the decimal equivalent of the result.
Problem 6.10
What is the decimal representation for the integer with two’s complement
10101001?
50 FUNDAMENTALS OF MATHEMATICAL LOGIC
7 Project II: Number Systems
In this section we consider three number systems that are of importance
in applications, namely, the decimal system, the binary system, and the
hexadecimal system. Decimal numbers are used in communication among
human beings whereas binary numbers are used by computers to represent
numbers.
Consider ﬁrst the decimal system. If n is a positive integer then n can
be written as
n = d
k
d
k−1
d
1
d
0
,
where the digits d
0
, d
1
, , d
k
are elements of the set ¦0, 1, 2, , 9¦.
The number n can be expressed as a sum of powers of 10 as follows:
n = d
k
10
k
+d
k−1
10
k−1
+ +d
1
10
1
+d
0
10
0
.
For example,
5049 = 5(10
3
) + 0(10
2
) + 4(10
1
) + 9(10
0
).
A number in binary system is a number n that can be written in the form
n = b
k
b
k−1
b
1
b
0
,
where b
i
is either 0 or 1.
We will use subscript to tell the base of which a number is represented.
Thus, we write n
2
= b
k
b
k−1
b
1
b
0
to indicate that the number n is in base
2.
If n is a number in base 2 then its decimal value (i.e. base 10) is found by
the formula:
n
2
= b
k
(2
k
) +b
k−1
(2
k−1
) + +b
1
(2
1
) +b
0
(2
0
) = m
10
.
Problem 7.1
Find the decimal value of the following binary numbers:
a. 1100101
2
b. 110110
2
7 PROJECT II: NUMBER SYSTEMS 51
To convert a positive integer n from base 10 to base 2 we use the division
algorithm as follows:
(1) n = q
0
(2) + r
0
, where q
0
is the quotient of the division of n by 2 and r
0
is the remainder.
(2) If q
0
= 0 then n is already in base 2. If not then divide q
0
by 2 to obtain
q
0
= q
1
(2) +r
1
.
(3) If q
1
= 0 then n
10
= r
1
r
0
. If not repeat the process. Note that the
remainders are all less than 2.
Suppose that q
k
= 0 then
n
10
= r
k
r
k−1
r
1
r
0
.
Problem 7.2
Represent the following decimal integers in binary notation:
a. 1297
10
b. 458
10
Problem 7.3
Evaluate the following sums:
a. 11011101
2
+ 1001011010
2
b. 101101
2
+ 11101
2
Another useful number system is the hexadecimal system. The possible
digits in an hexadecimal system are :
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
where A, B, C, D, E, F stand for 10, 11, 12, 13, 14, and 15 respectively.
The conversion of a number from base 16 to base 10 is similar to the conver
sion of numbers from base 2 to base 10. The conversion of a number from
base 10 to base 16 is similar to the conversion of a decimal number to base
2.
Problem 7.4
Convert the number A2BC
16
to base 10.
To convert an integer from base 16 to base 2 one performs the following:
(1) Write each hexadecimal digit of the integer in ﬁxed 4bit binary notation.
(2) Juxtapose the results.
52 FUNDAMENTALS OF MATHEMATICAL LOGIC
Problem 7.5
Convert the number B53DF8
16
to base 2.
To convert an integer from base 2 to base 16:
(1) Group the digits of the binary number into sets of four bits, starting from
the right and adding leading zeros as needed.
(2) Convert the binary numbers in (1) to base 16.
(3) Juxtapose the results of (2)
Problem 7.6
Convert the number 101101111000101
2
to base 16.
Fundamentals of Mathematical
Proofs
In this chapter we discuss some common methods of proof and the standard
terminology that accompanies them.
8 Methods of Direct Proof I
A mathematical system consists of axioms, deﬁnitions, and undeﬁned
terms. An axiom is a statement that is assumed to be true. A deﬁnition
is used to create new concepts in terms of existing ones. A theorem is a
proposition that has been proved to be true. A lemma is a theorem that
is usually not interesting in its own right but is useful in proving another
theorem. A corollary is a theorem that follows quickly from a theorem.
Example 8.1
The Euclidean geometry furnishes an example of mathematical system:
• points and lines are examples of undeﬁned terms.
• An example of a deﬁnition: Two angles are supplementary if the sum of
their measures is 180
◦
.
• An example of an axiom: Given two distinct points, there is exactly one
line that contains them.
• An example of a theorem: If two sides of a triangle are equal, then the
angles opposite them are equal.
• An example of a corollary: If a triangle is equilateral, then it is equiangular.
An argument that establishes the truth of a theorem is called a proof. Logic
is a tool for the analysis of proofs.
53
54 FUNDAMENTALS OF MATHEMATICAL PROOFS
First we discuss methods for proving a theorem of the form ”∃x such that
P(x).” This theorem guarantees the existence of at least one x for which the
predicate P(x) is true. The proof of such a theorem is constructive: that
is, the proof is either by ﬁnding a particular x that makes P(x) true or by
exhibiting an algorithm for ﬁnding x.
Example 8.2
Show that there exists a positive integer which can be written as the sum of
the squares of two numbers.
Solution.
Indeed, one example is 5
2
= 3
2
+ 4
2
Example 8.3
Show that there exists an integer x such that x
2
= 15, 129.
Solution.
Applying the wellknown algorithm of extracting the square root we ﬁnd that
x = 123
By a nonconstructive existence proof we mean a method that involves
either showing the existence of x using a proved theorem (or axioms) or the
assumption that there is no such x leads to a contradiction. The disadvan
tage of nonconstructive method is that it may give virtually no clue about
where or how to ﬁnd x.
Theorems are often of the form ”∀x ∈ D if P(x) then Q(x).” We call P(x)
the hypothesis and Q(x) the conclusion.
Let us ﬁrst consider a proposition of the form ∀x ∈ D, P(x). Then this
can be written in the form ”∀x, if x ∈ D then P(x).” If D is a ﬁnite set, then
one check the truth value of P(x) for each x ∈ D. This method is called the
method of exhaustion.
Example 8.4
Show that for each integer 1 ≤ n ≤ 10, n
2
−n + 11 is a prime number.
Solution.
The given proposition can be written in the form ”∀n ∈ IN, if 1 ≤ n ≤ 10
8 METHODS OF DIRECT PROOF I 55
then P(n)” where P(n) = n
2
− n + 11. Using the method of exhaustion we
see that
P(1) = 11 ; P(2) = 13 ; P(3) = 17 ; P(4) = 23
P(5) = 31 ; P(6) = 41 ; P(7) = 53 ; P(8) = 67
P(9) = 83 ; P(10) = 101.
The most powerful technique for proving a universal proposition is one that
works regardless of the size of the domain over which the proposition is
quantiﬁed. It is called the method of generalizing from the generic
particular.
The method consists of picking an arbitrary element x of the domain (known
as a generic element) for which the hypothesis P(x) is satisﬁed, and then
using deﬁnitions, previously established results, and the rules of inference to
conclude that Q(x) is also true.
By a direct method of proof we mean a method that consists of showing
that if P(x) is true for x ∈ D then Q(x) is also true.
The following shows the format of the proof of a theorem.
Theorem 8.1
For all n, m ∈ ZZ, if m and n are even then so is m+n.
Proof.
Let m and n be two even integers. Then there exist integers k
1
and k
2
such
that n = 2k
1
and m = 2k
2
. We must show that m + n is even, that is, an
integer multiple of 2. Indeed,
m+n = 2k
1
+ 2k
2
= 2(k
1
+k
2
)
= 2k
where k = k
1
+k
2
∈ ZZ. Thus, by the deﬁnition of even, m+n is even
Example 8.5
Prove the following theorem.
Theorem Every integer is a rational number.
56 FUNDAMENTALS OF MATHEMATICAL PROOFS
Solution.
Proof. Let n be an arbitrary integer. Then n =
n
1
. By the deﬁnition of
rational numbers, n is rational
Theorem 8.2
If a, b ∈ I Q then a +b ∈ I Q.
Proof.
Let a and b be two rational numbers. Then there exist integers a
1
, a
2
, b
1
= 0,
and b
2
= 0 such that a =
a
1
b
1
and b =
a
2
b
2
. By the property of addition of two
fractions we have
a +b =
a
1
b
1
+
a
2
b
2
=
a
1
b
2
+a
2
b
1
b
1
b
2
By letting p = a
1
b
2
+ a
2
b
1
∈ ZZ and q = b
1
b
2
∈ ZZ
∗
we get a + b =
p
q
. That is,
a +b ∈ I Q
Corollary 8.1 The double of a rational number is rational.
Proof.
Let a = b in the previous theorem we see that 2a = a +a = a +b ∈ I Q
Next, we point out of some common mistakes that must be avoided in prov
ing theorems.
• Arguing from examples. The validity of a general statement can not be
proved by just using a particular example.
• Using the same letters to mean two diﬀerent things. For example, sup
pose that m and n are any two given even integers. Then by writing m = 2k
and n = 2k this would imply that m = n which is inconsistent with the
statement that m and n are arbitrary.
• Jumping to a conclusion. Let us illustrate by an example. Suppose that
we want to show that if the sum of two integers is even so is their diﬀerence.
Consider the following proof: Suppose that m+n is even. Then there is an
integer k such that m+n = 2k. Then, m = 2k −n and so m−n is even.
The problem with this proof is that the crucial step m− n = 2k − n − n =
2(k − n) is missing. The author of the proof has jumped prematurely to a
8 METHODS OF DIRECT PROOF I 57
conclusion.
• Begging the question. By that we mean that the author of a proof uses in
his argument a fact that he is supposed to prove.
Finally, to show that a proposition of the form ∀x ∈ D, if P(x) then Q(x)
is false it suﬃces to ﬁnd an element x ∈ D where P(x) is true but Q(x) is
false. Such an x is called a counterexample.
Example 8.6
Disprove the proposition ∀a, b ∈ IR, if a < b then a
2
< b
2
.
Solution.
A counterexample is the following. Let a = −2 and b = −1. Then a < b but
a
2
> b
2
58 FUNDAMENTALS OF MATHEMATICAL PROOFS
Review Problems
A real number r is called rational if there exist two integers a and b = 0
such that r =
a
b
. A real number that is not rational is called irrational.
Problem 8.1
Show that the number r = 6.321521521... is a rational number.
Problem 8.2
Prove the following theorem.
Theorem. The product of two rational numbers is a rational number.
Problem 8.3
Use the previous exercise to prove the following.
Corollary. The square of any rational number is rational.
Problem 8.4
Use the method of constructive proof to show that if r and s are two real
numbers then there exists a real number x such that r < x < s.
Problem 8.5
The following Pascal program segment does not ﬁnd the minimum value in
a data set of N integers. Find a counterexample.
MINN := 0;
FOR I := 1 TO N DO
BEGIN
READLN (A);
If A < MINN THEN MINN := A
END
9 MORE METHODS OF PROOF 59
9 More Methods of Proof
A vacuous proof is a proof of an implication p → q in which it is shown
that p is false.
Example 9.1
Use the method of vacuous proof to show that if x ∈ ∅ then David is playing
pool.
Solution.
Since the proposition x ∈ ∅ is always false, the given proposition is vacuously
true
A trivial proof of an implication p → q is one in which q is shown to
be true without any reference to p.
Example 9.2
Use the method of trivial proof to show that if n is an even integer then n is
divisible by 1.
Solution.
Since the proposition n is divisible by 1 is always true, the given implication
is trivially true
The method of proof by cases is a direct method of proving the condi
tional proposition p
1
∨p
2
∨ ∨p
n
→q. The method consists of proving the
conditional propositions p
1
→q, p
2
→q, , p
n
→q.
Example 9.3
Show that if n is a positive integer then n
3
+n is even.
Solution.
We use the method of proof by cases.
Case 1. Suppose that n is even. Then there is k ∈ IN such that n = 2k. In
this case, n
3
+n = 8k
3
+ 2k = 2(4k
3
+k) which is even.
Case 2. Suppose that n is odd. Then there is a k ∈ IN such that n = 2k +1.
So, n
3
+n = 2(4k
3
+ 6k
2
+ 4k + 1) which is even
60 FUNDAMENTALS OF MATHEMATICAL PROOFS
Example 9.4
Use the proof by cases to prove the triangle inequality: [x +y[ ≤ [x[ +[y[.
Solution.
Case 1. x ≥ 0 and y ≥ 0. Then x +y ≥ 0 and so [x +y[ = x +y = [x[ +[y[.
Case 2. x ≥ 0 and y < 0. Then x + y < x + 0 < [x[ ≤ [x[ + [y[. On the
other hand, −(x + y) = −x + (−y) ≤ 0 + (−y) = [y[ ≤ [x[ + [y[. Thus,
if [x + y[ = x + y then [x + y[ < [x[ + [y[ and if [x + y[ = −(x + y) then
[x +y[ ≤ [x[ +[y[.
Case 3. The case x < 0 and y ≥ 0 is similar to case 2.
Case 4. Suppose x < 0 and y < 0. Then x + y < 0 and therefore [x + y[ =
−(x +y) = (−x) + (−y) = [x[ +[y[.
So in all four cases [x +y[ ≤ [x[ +[y[.
Now, given a real number x. The largest integer n such that n ≤ x < n + 1
is called the ﬂoor of x and is denoted by x. The smallest integer n such
that n −1 < x ≤ n is called the ceiling of x and is denoted by x.
Example 9.5
Compute x and x of the following values of x :
a. 37.999 b. −
57
2
c. −14.001
Solution.
a. 37.999 = 37, 37.999 = 38.
b. −
57
2
 = −29, −
57
2
 = −28.
c. −14.001 = −15, −14.001 = −14.
Example 9.6
Use the proof by a counterexample to show that the proposition ”∀x, y ∈
IR, x +y = x +y” is false.
Solution.
Let x = y = 0.5. Then x +y = 1 and x +y = 0
The following gives another example of the method of proof by cases.
Theorem 9.1
For any integer n,
n
2
 =
n
2
, if n is even
n−1
2
, if n is odd
9 MORE METHODS OF PROOF 61
Proof.
Let n be any integer. Then we consider the following two cases.
Case 1. n is odd. In this case, there is an integer k such that n = 2k + 1.
Hence,
n
2
 =
2k + 1
2
 = k +
1
2
 = k
since k ≤ k +
1
2
< k + 1. Since n = 2k + 1 then solving this equation for k
we ﬁnd k =
n−1
2
. It follows that
n
2
 = k =
n −1
2
.
Case 2. Suppose n is even. Then there is an integer k such that n = 2k.
Hence,
n
2
 = k = k =
n
2
.
62 FUNDAMENTALS OF MATHEMATICAL PROOFS
Review Problems
Problem 9.1
Prove that for any integer n the product n(n + 1) is even.
Problem 9.2
Prove that the square of any integer has the form 4k or 4k + 1 for some
integer k
Problem 9.3
Prove that for any integer n, n(n
2
−1)(n + 2) is divisible by 4.
Theorem 9.2
Given any nonnegative integer n and a positive integer d there exist integers
q and r such that n = dq + r and 0 ≤ r < d. The number q is called the
quotient of the division of n by d and we write q = n div d. The number r
is called the remainder and we write r = n mod d or n ≡ r(mod d).
Proof.
The proof uses the fact that any nonempty subset of IN has a smallest ele
ment. So let S = ¦n − d k ∈ IN : k ∈ ZZ¦. This set is nonempty. Indeed, if
n ∈ IN then n = n−0 d ≥ 0 and if n < 0 then n−d n = n (1−d) ≥ 0. Thus,
S is a nonempty subset of IN so it has a smallest elements, called r. That is,
there is an integer q such that n−d q = r or n = d q +r. It remains to show
that r < d. Suppose the contrary, i.e. r ≥ d. Then n−d (q +1) = r −d ≥ 0
so that n−d (q +1) ∈ S. Hence, r ≤ n−d (q +1) = r −d, a contradiction.
Hence, r < d
The following theorem shows a way for ﬁnding q and r.
Theorem 9.3
If n is a nonnegative integer and d is a positive integer by letting q =
n
d

and r = n −d
n
d
, we have
n = dq +r, and 0 ≤ r < d.
Proof.
Suppose n is a nonnegative integer, d is a positive integer,q =
n
d
 and
r = n −d
n
d
. By substitution we have
dq +r = d
n
d
 +n −d
n
d
 = n.
9 MORE METHODS OF PROOF 63
It remains to show that 0 ≤ r < d. By the deﬁnition of the ﬂoor function we
have
q ≤
n
d
< q + 1.
Multiplying through by d we ﬁnd
dq ≤ n < dq +d.
This implies that
0 ≤ n −dq < d.
But
r = n −d
n
d
 = n −dq.
Hence, 0 ≤ r < d. This completes a proof of the theorem
Problem 9.4
State a necessary and suﬃcient condition for the ﬂoor function of a real
number to equal that number
Problem 9.5
Prove that if n is an even integer then
n
2
 =
n
2
.
Problem 9.6
Show that the equality x −y = x −y is not valid for all real numbers
x and y.
Problem 9.7
Show that the equality x +y = x +y is not valid for all real numbers
x and y.
Problem 9.8
Prove that for all real numbers x and all integers m, x +m = x +m.
Problem 9.9
Show that if n is an odd integer then
n
2
 =
n+1
2
.
64 FUNDAMENTALS OF MATHEMATICAL PROOFS
10 Methods of Indirect Proofs: Contradiction
and Contraposition
Recall that in a direct proof one starts with the hypothesis of an implication
p → q and then prove that the conclusion is true. Any other method of
proof will be referred to as an indirect proof. In this section we study two
methods of indirect proofs, namely, the proof by contradiction and the proof
by contrapositive.
• Proof by contradiction: We want to show that p is true. we assume it
is not and therefore ∼ p is true and then derive a contradiction. By the rule
of contradiction discussed in Chapter 1, p must be true.
Theorem 10.1
If n
2
is an even integer so is n.
Proof.
Suppose the contrary. That is suppose that n is odd. Then there is an integer
k such that n = 2k + 1. In this case, n
2
= 2(2k
2
+ 2k) + 1 is odd and this
contradicts the assumption that n
2
is even. Hence, n must be even
Theorem 10.2
The number
√
2 is irrational.
Proof.
Suppose not. That is, suppose that
√
2 is rational. Then there exist two
integers m and n with no common divisors such that
√
2 =
m
n
. Squaring
both sides of this equality we ﬁnd that 2n
2
= m
2
. Thus, m
2
is even. By
Theorem 10.1, m is even. That is, 2 divides m. But then m = 2k for some
integer k. Taking the square we ﬁnd that 2n
2
= m
2
= 4k
2
, that is n
2
= 2k
2
.
This says that n
2
is even and by Theorem 10.1, n is even. We conclude that
2 divides both m and n and this contradcits our assumption that m and n
have no common divisors. Hence,
√
2 must be irrational
Theorem 10.3
The set of prime numbers is inﬁnite.
10 METHODS OF INDIRECT PROOFS: CONTRADICTIONANDCONTRAPOSITION65
Proof.
Suppose not. That is, suppose that the set of prime numbers is ﬁnite. Then
these prime numbers can be listed, say, p
1
, p
2
, , p
n
. Now, consider the inte
ger N = p
1
p
2
p
n
+1. By the Unique Factorization Theorem, ( See Exercise
??) N can be factored into primes. Thus, there is a prime number p
i
such
that p
i
[N. But since p
i
[p
1
p
2
p
n
then p
i
[(N −p
1
p
2
p
n
) = 1, a contradic
tion since p
i
> 1.
• Proof by contrapositive: We already know that p →q ≡∼ q →∼ p. So
to prove p →q we sometimes instead prove ∼ q →∼ p.
Theorem 10.4
If n is an integer such that n
2
is odd then n is also odd.
Proof.
Suppose that n is an integer that is even. Then there exists an integer k such
that n = 2k. But then n
2
= 2(2k
2
) which is even.
66 FUNDAMENTALS OF MATHEMATICAL PROOFS
Review Problems
Problem 10.1
Use the proof by contradiction to prove the proposition ”There is no greatest
even integer.”
Problem 10.2
Prove by contradiction that the diﬀerence of any rational number and any
irrational number is irrational.
Problem 10.3
Use the proof by contraposition to show that if a product of two positive real
numbers is greater than 100, then at least one of the numbers is greater than
10.
Problem 10.4
Use the proof by contradiction to show that the product of any nonzero
rational number and any irrational number is irrational.
11 METHOD OF PROOF BY INDUCTION 67
11 Method of Proof by Induction
With the emphasis on structured programming has come the development of
an area called program veriﬁcation, which means your program is correct
as you are writing it.
One technique essential to program veriﬁcation is mathematical induc
tion, a method of proof that has been useful in every area of mathematics
as well.
Consider an arbitrary loop in Pascal starting with the statement
FOR I := 1 TO N DO
If you want to verify that the loop does something regardless of the particular
integral value of N, you need mathematical induction.
Also, sums of the form
n
¸
k=1
k =
n(n + 1)
2
are very useful in analysis of algorithms and a proof of this formula is math
ematical induction.
Next we examine this method. We want to prove that some predicate P(n)
is true for any nonnegative integer n ≥ n
0
. The steps of mathematical induc
tion are as follows:
(i) (Basis of induction) Show that P(n
0
) is true.
(ii) (Induction hypothesis) Assume P(n) is true.
(iii) (Induction step) Show that P(n + 1) is true.
Example 11.1
Use the technique of mathematical induction to show that
1 + 2 + 3 + +n =
n(n + 1)
2
, n ≥ 1.
Solution.
Let S(n) = 1 + 2 + +n. Then
(i) (Basis of induction) S(1) = 1 =
1(1+1)
2
. That is, S(1)is true.
(ii) (Induction hypothesis) Assume S(n) is true. That is, S(n) =
n(n+1)
2
.
68 FUNDAMENTALS OF MATHEMATICAL PROOFS
(iii) (Induction step) We must show that S(n + 1) =
(n+1)(n+2)
2
. Indeed,
S(n + 1) = 1 + 2 + +n + (n + 1)
= S(n) + (n + 1)
=
n(n+1)
2
+ (n + 1)
=
(n+1)(n+2)
2
Example 11.2 (Geometric progression)
a. Let S(n) =
¸
n
k=0
ar
k
, n ≥ 0 where r = 1. Use induction to show that
S(n) =
a(1−r
n+1
)
1−r
.
b. Show that 1 +
1
2
+ +
1
2
n−1
≤ 2, for all n ≥ 1.
Solution.
a. We use the method of proof by mathematical induction.
(i) (Basis of induction) S(0) = a =
¸
0
k=0
ar
k
. That is, S(1)is true.
(ii) (Induction hypothesis) Assume S(n) is true. That is, S(n) =
¸
n
k=0
ar
k
.
(iii) (Induction step) We must show that S(n + 1) =
a(1−r
n+2
)
1−r
. Indeed,
S(n + 1) =
¸
n+1
k=0
ar
k
= S(n) +ar
n+1
= a
1−r
n+1
1−r
+ar
n+1 1−r
1−r
= a
1−r
n+1
+r
n+1
−r
n+2
1−r
= a
1−r
n+2
1−r
.
b. By a. we have
1 +
1
2
+
1
2
2
+ +
1
2
n−1
=
1−(
1
2
)
n
1−
1
2
= 2(1 −(
1
2
)
n
)
= 2 −
1
2
n−1
≤ 2.
Example 11.3 (Arithmetic progression)
Let S(n) =
¸
n
k=1
(a + (k −1)r), n ≥ 1. Use induction to show that S(n) =
n
2
[2a + (n −1)r].
Solution.
We use the method of proof by mathematical induction.
11 METHOD OF PROOF BY INDUCTION 69
(i) (Basis of induction) S(1) = a =
1
2
[2a + (1 −1)r]. That is, S(1)is true.
(ii) (Induction hypothesis) Assume S(n) is true. That is, S(n) =
n
2
[2a+(n−
1)r].
(iii) (Induction step) We must show that S(n + 1) =
(n+1)
2
[2a +nr]. Indeed,
S(n + 1) =
¸
n+1
k=1
(a + (k −1)r)
= S(n) +a + (n + 1 −1)r
=
n
2
[2a + (n −1)r] +a +nr
=
2an+n
2
r−nr+2a+2nr
2
=
2a(n+1)+n(n+1)r
2
=
n+1
2
[2a +nr].
We next exhibit a theorem whose proof uses mathematical induction.
Theorem 11.1
For all integers n ≥ 1, 2
2n
−1 is divisible by 3.
Proof.
Let P(n) : 2
2n
−1 is divisible by 3. Then
(i) (Basis of induction) P(1) is true since 3 is divisible by 3.
(ii) (Induction hypothesis) Assume P(n) is true. That is, 2
2n
−1 is divisible
by 3.
(iii) (Induction step) We must show that 2
2n+2
−1 is divisible by 3. Indeed,
2
2n+2
−1 = 2
2n
(4) −1
= 2
2n
(3 + 1) −1
= 2
2n
3 + (2
2n
−1)
= 2
2n
3 +P(n)
Since 3[(2
2n
−1) and 3[(2
2n
3) we have 3[(2
2n
3+2
2n
−1). This ends a proof
of the theorem
Example 11.4
a. Use induction to prove that n < 2
n
for all nonnegative integers n.
b. Use induction to prove that 2
n
< n! for all nonnegative integers n ≥ 4.
Solution.
a. Let S(n) = 2
n
−n, n ≥ 0. We want to show that S(n) > 0 is valid for all
70 FUNDAMENTALS OF MATHEMATICAL PROOFS
n ≥ 0. By the method of mathematical induction we have
(i) (Basis of induction) S(0) = 2
0
−0 = 1 > 0. That is, S(0)is true.
(ii) (Induction hypothesis) Assume S(n) is true. That is, S(n) > 0.
(iii) (Induction step) We must show that S(n + 1) > 0. Indeed,
S(n + 1) = 2
n+1
−(n + 1)
= 2
n
.2 −n −1
= 2
n
(1 + 1) −n −1
= 2
n
−n + 2
n
−1
= (2
n
−1) +S(n)
> 2
n
−1
≥ 0
since the smallest value of n is 0 and in this case 2
0
−1 = 0.
b. Let S(n) = n! −2
n
, n ≥ 4. We want to show that S(n) > 0 for all n ≥ 4.
By the method of mathematical induction we have
(i) (Basis of induction) S(4) = 4! −2
4
= 8 > 0. That is, S(4)is true.
(ii) (Induction hypothesis) Assume S(n) is true. That is, S(n) > 0, n ≥ 4.
(iii) (Induction step) We must show that S(n + 1) > 0. Indeed,
S(n + 1) = (n + 1)! −2
n+1
= (n + 1)n! −2
n
(1 + 1)
= n! −2
n
+nn! −2
n
> 2(n! −2
n
) = 2S(n)
> 0
where we have used the fact that if n ≥ 1 then nn! ≥ n!
Example 11.5 (Bernoulli’s inequality)
Let h > −1. Use induction to show that
(1 +nh) ≤ (1 +h)
n
, n ≥ 0.
Solution.
Let S(n) = (1+h)
n
−(1+nh). We want to show that S(n) ≥ 0 for all n ≥ 0.
We use mathematical induction as follows.
(i) (Basis of induction) S(0) = (1 +h)
0
−(1 + 0h) = 0. That is, S(0)is true.
(ii) (Induction hypothesis) Assume S(n) is true. That is, S(n) ≥ 0, n ≥ 0.
11 METHOD OF PROOF BY INDUCTION 71
(iii) (Induction step) We must show that S(n + 1) ≥ 0. Indeed,
S(n + 1) = (1 +h)
n+1
−(1 + (n + 1)h)
= (1 +h)(1 +h)
n
−nh −1 −h
≥ (1 +h)(1 +nh) −nh −1 −h
= nh
2
≥ 0.
Example 11.6
Deﬁne the following sequence of numbers: a
1
= 2 and for n ≥ 2, a
n
= 5a
n−1
.
Find a formula for a
n
and then prove its validity by mathematical induction.
Solution.
Listing the ﬁrst few terms we ﬁnd, a
1
= 2, a
2
= 10, a
3
= 50, a
4
= 250. Thus,
a
n
= 2.5
n−1
. We will show that this formula is valid for all n ≥ 1 by the
method of mathematical induction.
(i) (Basis of induction) a
1
= 2 = 2.5
1−1
. That is, a
1
is true.
(ii) (Induction hypothesis) Assume a
n
is true. That is, a
n
= 2.5
n−1
(iii) (Induction step) We must show that a
n+1
= 2.5
n
. Indeed,
a
n+1
= 5a
n
= 5(2.5
n−1
)
= 2.5
n
.
72 FUNDAMENTALS OF MATHEMATICAL PROOFS
Review Problems
Problem 11.1
Use the method of induction to show that
2 + 4 + 6 + + 2n = n
2
+n
for all integers n ≥ 1.
Problem 11.2
Use mathematical induction to prove that
1 + 2 + 2
2
+ + 2
n
= 2
n+1
−1
for all integers n ≥ 0.
Problem 11.3
Use mathematical induction to show that
1
2
+ 2
2
+ +n
2
=
n(n + 1)(2n + 1)
6
for all integers n ≥ 1.
Problem 11.4
Use mathematical induction to show that
1
3
+ 2
3
+ +n
3
=
n(n + 1)
2
2
for all integers n ≥ 1.
Problem 11.5
Use mathematical induction to show that
1
1 2
+
1
2 3
+ +
1
n(n + 1)
=
n
n + 1
for all integers n ≥ 1.
11 METHOD OF PROOF BY INDUCTION 73
Problem 11.6
Use the formula
1 + 2 + +n =
n(n + 1)
2
to ﬁnd the value of the sum
3 + 4 + + 1, 000.
Problem 11.7
Find the value of the geometric sum
1 +
1
2
+
1
2
2
+ +
1
2
n
.
Problem 11.8
Let S(n) =
¸
n
k=1
k
(k+1)!
. Evaluate S(1), S(2), S(3), S(4), and S(5). Make a
conjecture about a formula for this sum for general n, and prove your con
jecture by mathematical induction.
Problem 11.9
For each positive integer n let P(n) be the proposition 4
n
−1 is divisible by 3.
a. Write P(1). Is P(1) true?
b. Write P(k).
c. Write P(k + 1).
d. In a proof by mathematical induction that this divisibility property holds
for all integers n ≥ 1, what must be shown in the induction step?
Problem 11.10
For each positive integer n let P(n) be the proposition 2
3n
−1 is divisible by
7. Prove this property by mathematical induction.
Problem 11.11
Show that 2
n
< (n + 2)! for all integers n ≥ 0.
Problem 11.12
a. Use mathematical induction to show that n
3
> 2n + 1 for all integers
n ≥ 2.
b. Use mathematical induction to show that n! > n
2
for all integers n ≥ 4.
Problem 11.13
A sequence a
1
, a
2
, is deﬁned by a
1
= 3 and a
n
= 7a
n−1
for n ≥ 2. Show
that a
n
= 3 7
n−1
for all integers n ≥ 1.
74 FUNDAMENTALS OF MATHEMATICAL PROOFS
12 Project III: Elementary Number Theory
and Mathematical Proofs
Recall that the set of positive integers together with zero is denoted by IN.
The set of all integers is denoted by ZZ and the set of rational numbers is
denoted by I Q.
We say that an integer n is even if and only if there exists an integer k
such that n = 2k. An integer n is said to be odd if and only if there exists
an integer k such that n = 2k + 1.
Problem 12.1
Let m and n be two integers.
a. Is 6m+ 8n an even integer?
b. Is 6m+ 4n
2
+ 3 odd?
Let a and b be two integers with a = 0. We say that b is divisible by a,
written a[b, if there exists an integer k such that b = ka. In this case we say
that a divides b, a is a factor of b, and b is a multiple of a. For example,
3 [7 whereas 3[12.
Problem 12.2
Prove the following theorem.
Theorem 12.1
Let a = 0, b = 0, and c be integers.
(i) If a[b and a[c then a[(b ±c).
(ii) If a[b then a[bc.
(iii) If a[b and b[c then a[c.
A positive integer p > 1 is called prime if 1 and p are the only divisors of p.
A number which is not prime is called a composite number. For example,
3 is prime whereas 10 is composite.
Problem 12.3
Let m and n be positive integers with m > n. Is m
2
−n
2
composite?
Problem 12.4
Write the ﬁrst 7 prime numbers.
12 PROJECT III: ELEMENTARYNUMBER THEORYANDMATHEMATICAL PROOFS75
Problem 12.5
If a positive number p is composite then one can always write p as the product
of primes, where the prime factors are written in increasing order. This result
is known as the Fundamental Theorem of Arithmetic or the Unique
Factorization Theorem. Write the prime factorization of 180.
The following important theorem shows that if a number is not divisible by
any prime less than to its square root then the number must be prime.
Theorem 12.2
If n is a composite integer, then n has a prime divisor less than or equal to
√
n.
Proof.
Since n is composite, there is a divisor a of n such that 1 < a < n. Write
n = ab. If a >
√
n and b >
√
n then n = ab >
√
n
√
n = n, a false conclusion.
Thus, either a ≤
√
n or b ≤
√
n. Hence, n has a positive divisor which is
less than or equal to
√
n. This divisor is either prime or, by the Fundamental
Theorem of Arithmetic has a prime divisor. In either case, n has a prime
divisor less than or equal to
√
n
Problem 12.6
Use the previous theorem to show that the number 101 is prime.
76 FUNDAMENTALS OF MATHEMATICAL PROOFS
13 Project IV: The Euclidean Algorithm
Problem 13.1
Let a and b be two integers not both equal to zero. We say that d is the
greatest common divisor of a and b, written d = gcd(a, b), if d is the
largest integer such that d[a and d[b. If d = 1 then we say that a and b are
relatively prime. To ﬁnd d one writes the prime factorization of both a
and b, say a = p
a
1
1
p
a
2
2
p
an
n
, b = p
b
1
1
p
b
2
2
p
bn
n
, then
d = p
min(a
1
,b
1
)
1
p
min(a
2
,b
2
)
2
p
min(an,bn)
n
.
(i) Find gcd(120, 500).
(ii) Show that 17 and 22 are relatively prime.
Problem 13.2
We say that m is the least common multiple of two positive integers a
and b, written m = lcm(a, b), if m is the smallest positive integer that is
divisible by both a and b. Using the notation of the previous exercise m is
given by m = p
max(a
1
,b
1
)
1
p
max(a
2
,b
2
)
2
p
max(an,bn)
n
. Find lcm(120, 500).
Problem 13.3
Recall that a ≡ b mod n if and only if a −b = kn for some integer k.
(i) Show that if a ≡ b mod n and c ≡ d mod n then a +c ≡ b +d mod n.
(ii) Show that if a ≡ b mod n and c ≡ d mod n then ac ≡ bd mod n.
(iii) What are the solutions of the linear congruences 3x ≡ 4(mod7)?
Lemma 13.1 (Euclidean Algorithm)
Let a, b, q, and r be integers such that a = bq +r. Then gcd(a, b) = gcd(b, r).
Proof.
Let d
1
= gcd(a, b) and d
2
= gcd(b, r). We will show that d
1
= d
2
. Since d
2
[b,
d
2
[bq. Also d
2
[r. Consequently d
2
[(bq + r) that is d
2
[a. Hence, d
2
≤ d
1
. A
similar argument shows that d
1
≤ d
2
. We conclude that d
1
= d
2
Using Lemma 13.1 we derive an algorithm, called the Euclidean Algo
rithm, for ﬁnding the greatest common divisor of two nonnegative integers
a and b with b = 0.
Dividing a by b we obtain
a = bq +r
1
, where 0 ≤ r
1
< b.
13 PROJECT IV: THE EUCLIDEAN ALGORITHM 77
By Lemma 13.1 we have gcd(a, b) = gcd(b, r
1
). If r
1
= 0 then we divide b by
r
1
to obtain
b = r
1
q
1
+r
2
, where 0 ≤ r
2
< r
1
.
Again by Lemma 13.1 we have gcd(b, r
1
) = gcd(r
1
, r
2
). If r
2
= 0 then we
divide r
1
by r
2
to obtain
r
1
= r
2
q
2
+r
3
, where 0 ≤ r
3
< r
2
.
By Lemma 13.1 we have gcd(r
1
, r
2
) = gcd(r
2
, r
3
). Repeating the above process,
ultimately, we will end up with r
n
= r
n+1
q
n+1
. In this case r
n+1
= gcd(a, b).
Problem 13.4
a. Use the Euclidean algorithm to ﬁnd gcd(414, 662).
b. Use the Euclidean algorithm to ﬁnd gcd(287, 91).
78 FUNDAMENTALS OF MATHEMATICAL PROOFS
14 Project V: Induction and the Algebra of
Matrices
In this section, we introduce the concept of a matrix. We also examine four
operations on matrices equality, addition, scalar multiplication, and multi
plication.
A matrix A of size mn is a rectangular array of the form
A =
¸
¸
¸
a
11
a
12
... a
1n
a
21
a
22
... a
2n
... ... ... ...
a
m1
a
m2
... a
mn
where the a
ij
’s are the entries of the matrix, m is the number of rows, n
is the number of columns. The zero matrix 0 is the matrix whose entries
are all 0. The n n identity matrix I
n
is a square matrix whose main
diagonal consists of 1
s and the oﬀ diagonal entries are all 0. A matrix A can
be represented with the following compact notation A = (a
ij
). The ith row
of the matrix A is
[a
i1
, a
i2
, ..., a
in
]
and the jth column is
¸
¸
¸
¸
a
1j
a
2j
.
.
.
a
mj
In what follows we discuss the basic arithmetic of matrices.
Two matrices are said to be equal if they have the same size and their cor
responding entries are all equal. If the matrix A is not equal to the matrix
B we write A = B.
Problem 14.1
Find x
1
, x
2
and x
3
such that
¸
x
1
+x
2
+ 2x
3
0 1
2 3 2x
1
+ 4x
2
−3x
3
4 3x
1
+ 6x
2
−5x
3
5
=
¸
9 0 1
2 3 1
4 0 5
14 PROJECT V: INDUCTION AND THE ALGEBRA OF MATRICES 79
Problem 14.2
Solve the following matrix equation for a, b, c, and d
a −b b +c
3d +c 2a −4d
=
8 1
7 6
Next, we introduce the operation of addition of two matrices. If A and B are
two matrices of the same size, then the sum A + B is the matrix obtained
by adding together the corresponding entries in the two matrices. Matrices
of diﬀerent sizes cannot be added.
Problem 14.3
Consider the matrices
A =
2 1
3 4
, B =
2 1
3 5
, C =
2 1 0
3 4 0
Compute, if possible, A +B, A +C and B +C.
If A is a matrix and c is a scalar, then the product cA is the matrix obtained
by multiplying each entry of A by c. Hence, −A = (−1)A. We deﬁne, A−B =
A + (−B). The matrix cI
n
is called a scalar matrix.
Problem 14.4
Consider the matrices
A =
2 3 4
1 2 1
, B =
0 2 7
1 −3 5
Compute A −3B.
Problem 14.5
Let A be an mn matrix. The transpose of A, denote by A
T
, is the nm
whose columns are the rows of A. Find the transpose of the matrix
A =
2 3 4
1 2 1
,
80 FUNDAMENTALS OF MATHEMATICAL PROOFS
Now, let A be a matrix of size m n and entries a
ij
; B is a matrix of size
np and entries b
ij
. Then the product matrix is a matrix of size mp and
entries
c
ij
= a
i1
b
1j
+a
i2
b
2j
+ +a
in
b
nj
that is c
ij
is obtained by multiplying componentwise the entries of the ith
row of A by the entries of the jth column of B. It is very important to keep
in mind that the number of columns of the ﬁrst matrix must be equal to the
number of rows of the second matrix; otherwise the product is undeﬁned.
Problem 14.6
Consider the matrices
A =
1 2 4
2 6 0
, B =
¸
4 1 4 3
0 −1 3 1
2 7 5 2
Compute, if possible, AB and BA.
Problem 14.7
Prove by induction on n ≥ 1 that
2 1
0 2
n
=
2
n
n2
n−1
0 2
n
.
Fundamentals of Set Theory
Set is the most basic term in mathematics and computer science. Hardly
any discussion in either subject can proceed without set or some synonym
such as class or collection. In this chapter we introduce the concept of sets
and its various operations and then study the properties of these operations.
15 Basic Deﬁnitions
We ﬁrst consider the following known as the barber puzzle:” The army
captain orders his company barber to shave all members of the company
provided they do not shave themselves. The barber is so busy at ﬁrst that
his own beard begins to be unsightly. Just as he lathers up, the impossibility
of his position strikes him: If he shaves himself, he disobeys the captain’s or
der. If he does not shave himself, then by the captain’s order he is supposed
to shave himself.”
A situation like this is known as a paradox. To resolve the problem one has
to take the barber out of the company. Another well known paradox is
Russell’s Paradox. Deﬁne the set A = ¦X : X is a set, X ∈ X¦.
Since A is a set then saying that A ∈ A will imply that A ∈ A by the deﬁni
tion of A. Saying that A ∈ A means that A ∈ A by the deﬁnition of A. Thus
in either case the assumption that A is a set leads to an untenable paradox:
A ∈ A and A ∈ A. Hence, A is not a set.
Such a paradox indicated the necessity of a formal axiomatization of set the
ory.
We deﬁne a set A as a collection of welldeﬁned objects (called elements or
members of A) such that for any given object x either one (but not both)
of the following holds:
81
82 FUNDAMENTALS OF SET THEORY
• x belongs to A and we write x ∈ A.
• x does not belong to A, and in this case we write x ∈ A.
We denote sets by capital letters A, B, C, and elements by lowercase let
ters a, b, c, Sets consisting of sets will be denoted by script letters.
There are two diﬀerent ways to represent a set. The ﬁrst one is to list,
without repetition, the elements of the set. The other way is to describe a
property that characterizes the elements of the set.
We deﬁne the empty set, denoted by ∅, to be the set with no elements.
Example 15.1
List the elements of the following sets.
a. ¦x[x is a real number such that x
2
= 1¦.
b. ¦x[x is an integer such that x
2
−3 = 0¦.
Solution.
a. ¦−1, 1¦.
b. ∅
Example 15.2
Use a property to give a description of each of the following sets.
a. ¦a, e, i, o, u¦.
b. ¦1, 3, 5, 7, 9¦.
Solution.
a. ¦x[x is a vowel¦.
b. ¦n ∈ IN
∗
[n is odd and less than 10¦
Let A and B be two sets. We say that A is a subset of B, denoted by
A ⊆ B, if and only if every element of A is also an element of B. Symboli
cally:
A ⊆ B ⇔∀x, x ∈ A implies x ∈ B
If there exists an element of A which is not in B then we write A ⊆ B.
Since the proposition x ∈ ∅ is always false then for any set A we have
∅ ⊆ A ⇔∀x, x ∈ ∅ implies x ∈ A
15 BASIC DEFINITIONS 83
Example 15.3
Suppose that A = ¦2, 4, 6¦, B = ¦2, 6¦, and C = ¦4, 6¦. Determine which of
these sets are subsets of which other of these sets.
Solution.
B ⊆ A and C ⊆ A
If sets A and B are represented as regions in the plane, relationships be
tween A and B can be represented by pictures, called Venn diagram.
Example 15.4
Represent A ⊆ B using Venn diagram.
Solution.
Two sets A and B are said to be equal if and only if A ⊆ B and B ⊆ A.
We write A = B. Thus, to show that A = B it suﬃces to show the double
inclusions mentioned in the deﬁnition. For nonequal sets we write A = B.
Example 15.5
Determine whether each of the following pairs of sets are equal.
(a) ¦1, 3, 5¦ and ¦5, 3, 1¦.
(b) ¦¦1¦¦ and ¦1, ¦1¦¦.
Solution.
(a) ¦1, 3, 5¦ = ¦5, 3, 1¦.
(b) ¦¦1¦¦ = ¦1, ¦1¦¦ since 1 ∈ ¦¦1¦¦
84 FUNDAMENTALS OF SET THEORY
Let A and B be two sets. We say that A is a proper subset of B, de
noted by A ⊂ B, if A ⊆ B and A = B. Thus, to show that A is a proper
subset of B we must show that every element of A is an element of B and
there is an element of B which is not in A.
Example 15.6
Order the sets of numbers: ZZ, IR, I Q, IN using ⊂
Solution.
IN ⊂ ZZ ⊂ I Q ⊂ IR
Example 15.7
Determine whether each of the following statements is true or false.
(a) x ∈ ¦x¦ (b) ¦x¦ ⊆ ¦x¦ (c) ¦x¦ ∈ ¦x¦
(d) ¦x¦ ∈ ¦¦x¦¦ (e) ∅ ⊆ ¦x¦ (f) ∅ ∈ ¦x¦
Solution.
(a) True (b) True (c) False (d) True (e) True (f) False
If U is a given set whose subsets are under consideration, then we call U
a universal set.
Let U be a universal set and A, B be two subsets of U. The absolute com
plement of A is the set
A
c
= ¦x ∈ U[x ∈ A¦.
The relative complement of A with respect to B is the set
B −A = ¦x ∈ U[x ∈ B and x ∈ A¦.
Example 15.8
Let U = IR. Consider the sets A = ¦x ∈ IR[x < −1 or x > 1¦ and
B = ¦x ∈ IR[x ≤ 0¦. Find
a. A
c
.
b. B −A.
Solution.
a. A
c
= [−1, 1].
15 BASIC DEFINITIONS 85
b. B −A = [−1, 0]
Let A and B be two sets. The union of A and B is the set
A ∪ B = ¦x[x ∈ A or x ∈ B¦.
where the ’or’ is inclusive. This defenition can be extended to more than two
sets. More precisely, if A
1
, A
2
, , are sets then
∪
∞
n=1
A
n
= ¦x[x ∈ A
i
for some i¦.
Let A and B be two sets. The intersection of A and B is the set
A ∩ B = ¦x[x ∈ A and x ∈ B¦.
If A∩B = ∅ we say that A and B are disjoint sets. Given the sets A
1
, A
2
, ,
we deﬁne
∩
∞
n=1
A
n
= ¦x[x ∈ A
i
for all i¦.
Example 15.9
Let A = ¦a, b, c¦, B = ¦b, c, d¦, and C = ¦b, c, e¦.
a. Find A ∪ (B ∩ C), (A ∪ B) ∩ C, and (A ∪ B) ∩ (A ∪ C). Which of
these sets are equal?
b. Find A ∩ (B ∪ C), (A ∩ B) ∪ C, and (A ∩ B) ∪ (A ∩ C). Which of these
sets are equal?
c. Find A −(B −C) and (A −B) −C. Are these sets equal?
Solution.
a. A ∪ (B ∩ C) = A, (A ∪ B) ∩ C = ¦b, c¦, (A ∪ B) ∩ (A ∪ C) = ¦b, c¦ =
(A ∪ B) ∩ C.
b. A ∩ (B ∪ C) = ¦b, c¦, (A ∩ B) ∪ C = C, (A ∩ B) ∪ (A ∩ C) = ¦b, c¦ =
(A ∩ B) ∪ C.
c. A −(B −C) = A and (A −B) −C = ¦a¦ = A −(B −C).
Example 15.10
For each n ≥ 1, let A
n
= ¦x ∈ IR : x < 1 +
1
n
¦. Show that
∩
∞
n=1
A
n
= ¦x ∈ IR : x ≤ 1¦.
86 FUNDAMENTALS OF SET THEORY
Solution.
The proof is by double inclusions method. Let y ∈ ¦x ∈ IR : x ≤ 1¦. Then
for all positive integer n we have y ≤ 1 < 1 +
1
n
. That is, y ∈ ∩
∞
n=1
A
n
. This
shows that ¦x ∈ IR : x ≤ 1¦ ⊆ ∩
∞
n=1
A
n
.
Conversely, let y ∈ ∩
∞
n=1
A
n
. Then y < 1+
1
n
for all n ≥ 1. Now take the limit
of both sides as n →∞ to obtain y ≤ 1. That is, y ∈ ¦x ∈ IR : x ≤ 1¦. This
shows that ∩
∞
n=1
A
n
⊆ ¦x ∈ IR : x ≤ 1¦.
Example 15.11
The symmetric diﬀerence of A and B, denoted by A∆B, is the set contain
ing those elements in either A or B but not both. Find A∆B if A = ¦1, 3, 5¦
and B = ¦1, 2, 3¦.
Solution.
A∆B = ¦2, 5¦
The notation (a
1
, a
2
, , a
n
) is called an ordered ntuples. We say that
two ntuples (a
1
, a
2
, , a
n
) and (b
1
, b
2
, , b
n
) are equal if and only if a
1
=
b
1
, a
2
= b
2
, , a
n
= b
n
.
Given n sets A
1
, A
2
, , A
n
the Cartesian product of these sets is the set
A
1
A
2
A
n
= ¦(a
1
, a
2
, , a
n
) : a
1
∈ A
1
, a
2
∈ A
2
, , a
n
∈ A
n
¦
Example 15.12
Let A = ¦x, y¦, B = ¦1, 2, 3¦, and C = ¦a, b¦. Find
a. A B C.
b. (A B) C.
Solution.
a.
A B C = ¦(x, 1, a), (x, 2, a), (x, 3, a), (y, 1, a), (y, 2, a),
(y, 3, a), (x, 1, b), (x, 2, b), (x, 3, b), (y, 1, b)
(y, 2, b), (y, 3, b)¦
b.
(A B) C = ¦((x, 1), a), ((x, 2), a), ((x, 3), a), ((y, 1), a), ((y, 2), a),
((y, 3), a), ((x, 1), b), ((x, 2), b), ((x, 3), b), ((y, 1), b)
((y, 2), b), ((y, 3), b)¦
15 BASIC DEFINITIONS 87
Next, we introduce one more special kind of sets, denoted by Σ
∗
. An al
phabet is a ﬁnite nonempty set Σ whose members are called letters and
with the restrictions that Σ does not contain letters which are themselves
strings beginning with other letters of Σ. Thus, Σ = ¦a, b, c, ca¦ is not an
alphabet. A word is any ﬁnite string of letters from Σ. We denote the set of
all words using letters from Σ by Σ
∗
. Any subset of Σ
∗
is called a language.
For example, if Σ consists of the twenty six letters of the english alphabet,
then the American language can be deﬁned as the subset of Σ
∗
consisting of
words in the latest edition of the Webster’s World dictionary of the American
Language.
The empty word or the null word is the string with no letters. It is de
noted by .
We deﬁne the length of a word w to be the number of letters from Σ in
w and we write [w[. Note that in order to deﬁne the length of a word the
restriction given in the deﬁnition is needed. To be more precise, suppose that
Σ = ¦a, b, ab¦. Then what is the length of the word aab? Is this a word with
two letters a and ab or three letters a, a, and b? So obviously there is no way
to tell. This ambiguity is resolved by making the restriction stated in the
deﬁnition above.
Finally, by Σ
n
we mean the set of all words over Σ of length n. That is, Σ
n
is the cartesian product of n copies of Σ.
Example 15.13
Let Σ = ¦a, b¦. List all the elements of the set
A = ¦w ∈ Σ
∗
: [w[ = 2¦.
Solution.
A = ¦aa, ab, ba, bb¦
88 FUNDAMENTALS OF SET THEORY
Review Problems
Problem 15.1
Which of the following sets are equal?
a. ¦a, b, c, d¦
b. ¦d, e, a, c¦
c. ¦d, b, a, c¦
d. ¦a, a, d, e, c, e¦
Problem 15.2
Let A = ¦c, d, f, g¦, B = ¦f, j¦, and C = ¦d, g¦. Answer each of the following
questions. Give reasons for your answers.
a. Is B ⊆ A?
b. Is C ⊆ A?
c. Is C ⊆ C?
d. Is C is a proper subset of A?
Problem 15.3
a. Is 3 ∈ ¦1, 2, 3¦?
b. Is 1 ⊆ ¦1¦?
c. Is ¦2¦ ∈ ¦1, 2¦?
d. Is ¦3¦ ∈ ¦1, ¦2¦, ¦3¦¦?
e. Is 1 ∈ ¦1¦?
f. Is ¦2¦ ⊆ ¦1, ¦2¦, ¦3¦¦?
g. Is ¦1¦ ⊆ ¦1, 2¦?
h. Is 1 ∈ ¦¦1¦, 2¦?
i. Is ¦1¦ ⊆ ¦1, ¦2¦¦?
j. Is ¦1¦ ⊆ ¦1¦?
Problem 15.4
Let A = ¦b, c, d, f, g¦ and B = ¦a, b, c¦. Find each of the following:
a. A ∪ B.
b. A ∩ B.
c. A −B.
d. B −A.
Problem 15.5
Indicate which of the following relationships are true and which are false:
a. ZZ
+
⊆ I Q.
15 BASIC DEFINITIONS 89
b. IR
−
⊂ I Q.
c. I Q ⊂ ZZ.
d. ZZ
+
∪ ZZ
−
= ZZ.
e. I Q∩ IR = I Q.
f. I Q∪ ZZ = ZZ.
g. ZZ
+
∩ IR = ZZ
+
h. ZZ ∪ I Q = I Q.
Problem 15.6
Let A = ¦x, y, z, w¦ and B = ¦a, b¦. List the elements of each of the following
sets:
a. A B
b. B A
c. A A
d. B B.
Problem 15.7
Let Σ = ¦x, y¦ be an alphabet.
a. Let L
1
be the language consisting of all strings over Σ that are palindromes
and have length ≤ 4. List the elements L
1
.
b. Let L
2
be the language consisting of all strings over Σ that begins with x
and have length ≤ 3. List the elements L
2
.
c. Let L
3
be the language consisting of all strings over Σ with length ≤ 3
and for which all the x
s appear to the left of all the y
s. List the elements
L
3
.
d. List the elements of Σ
4
, the set of all strings of length 4 over Σ.
e. Let A = Σ
3
∪ Σ
4
. Describe A, B, and A ∪ B in words.
90 FUNDAMENTALS OF SET THEORY
16 Properties of Sets
The following exercise shows that the operation ⊆ is reﬂexive and transitive,
concepts that will be discussed in the next chapter.
Example 16.1
a. Suppose that A, B, C are sets such that A ⊆ B and B ⊆ C. Show that
A ⊆ C.
b. Find two sets A and B such that A ∈ B and A ⊆ B.
c. Show that A ⊆ A.
Solution.
a. We need to show that every element of A is an element of C. Let x ∈ A.
Since A ⊆ B then x ∈ B. But B ⊆ C so that x ∈ C.
b. A = ¦x¦ and B = ¦x, ¦x¦¦.
c. The proposition if x ∈ A then x ∈ A is always true. Thus, A ⊆ A
Theorem 16.1
Let A and B be two sets. Then
a. A ∩ B ⊆ A and A ∩ B ⊆ B.
b. A ⊆ A ∪ B and B ⊆ A ∪ B.
Proof.
a. If x ∈ A ∩ B then x ∈ A and x ∈ B. This still imply that x ∈ A. Hence,
A ∩ B ⊆ A. A similar argument holds for A ∩ B ⊆ B.
b. The proposition ”if x ∈ A then x ∈ A ∪ B” is always true. Hence,
A ⊆ A ∪ B. A similar argument holds for B ⊆ A ∪ B
Theorem 16.2
Let A be a subset of a universal set U. Then
a. ∅
c
= U.
b. U
c
= ∅.
c. (A
c
)
c
= A.
d. A ∪ A
c
= U.
e. A ∩ A
c
= ∅.
Proof.
a. If x ∈ U then x ∈ U and x ∈ ∅. Thus, U ⊆ ∅
c
. Conversely, suppose that
x ∈ ∅
c
. Then x ∈ U and x ∈ ∅. This implies that x ∈ U. Hence, ∅
c
⊆ U.
16 PROPERTIES OF SETS 91
b. It is always true that ∅ ⊆ U
c
. Conversely, the proposition ”x ∈ U and
x ∈ U implies x ∈ ∅” is vacuously true since the hypothesis is false. This
says that U
c
⊆ ∅.
c. Let x ∈ (A
c
)
c
. Then x ∈ U and x ∈ A
c
. That is, x ∈ U and (x ∈ U or
x ∈ A). Since x ∈ U then x ∈ A. Hence (A
c
)
c
⊆ A. Conversely, suppose that
x ∈ A. Then x ∈ U and x ∈ A. That is, x ∈ U and x ∈ A
c
. Thus, x ∈ (A
c
)
c
.
This shows that A ⊆ (A
c
)
c
.
d. It is clear that A ∪ A
c
⊆ U. Conversely, suppose that x ∈ U. Then either
x ∈ A or x ∈ A. But this is the same as saying that x ∈ A ∪ A
c
.
e. By deﬁnition ∅ ⊆ A ∩ A
c
. Conversely, the conditional proposition ”x ∈ A
and x ∈ A implies x ∈ ∅” is vacuously true since the hypothesis is false. This
shows that A ∩ A
c
⊆ ∅
Theorem 16.3
If A and B are subsets of U then
a. A ∪ U = U.
b. A ∪ A = A.
c. A ∪ ∅ = A.
d. A ∪ B = B ∪ A.
e. (A ∪ B) ∪ C = A ∪ (B ∪ C).
Proof.
a. Clearly, A ∪ U ⊆ U. Conversely, let x ∈ U. Then deﬁnitely, x ∈ A ∪ U.
That is, U ⊆ A ∪ U.
b. If x ∈ A then x ∈ A or x ∈ A. That is, x ∈ A ∪ A and consequently
A ⊆ A ∪ A. Conversely, if x ∈ A ∪ A then x ∈ A. Hence, A ∪ A ⊆ A.
c. If x ∈ A∪∅ then x ∈ A since x ∈ ∅. Thus, A∪∅ ⊆ A. Conversely, if x ∈ A
then x ∈ A or x ∈ ∅. Hence, A ⊆ A ∪ ∅.
d. If x ∈ A ∪ B then x ∈ A or x ∈ B. But this is the same thing as saying
x ∈ B or x ∈ A. That is, x ∈ B ∪ A. Now interchange the roles of A and B
to show that B ∪ A ⊆ A ∪ B.
e. Let x ∈ (A∪B) ∪C. Then x ∈ (A∪B) or x ∈ C. Thus, (x ∈ A or x ∈ B)
or x ∈ C. This implies x ∈ A or (x ∈ B or x ∈ C). Hence, x ∈ A∪ (B ∪ C).
The converse is similar
Theorem 16.4
Let A and B be subsets of U. Then
a. A ∩ U = A.
92 FUNDAMENTALS OF SET THEORY
b. A ∩ A = A.
c. A ∩ ∅ = ∅.
d. A ∩ B = B ∩ A.
e. (A ∩ B) ∩ C = A ∩ (B ∩ C).
Proof.
a. If x ∈ A ∩ U then x ∈ A. That is , A ∩ U ⊆ A. Conversely, let x ∈ A.
Then deﬁnitely, x ∈ A and x ∈ U. That is, x ∈ A ∩ U. Hence, A ⊆ A ∩ U.
b. If x ∈ A then x ∈ A and x ∈ A. That is, A ⊆ A ∩ A. Conversely, if
x ∈ A ∩ A then x ∈ A. Hence, A ∩ A ⊆ A.
c. Clearly ∅ ⊆ A∩ ∅. Conversely, if x ∈ A∩ ∅ then x ∈ ∅. Hence, A∩ ∅ ⊆ ∅.
d. If x ∈ A∩ B then x ∈ A and x ∈ B. But this is the same thing as saying
x ∈ B and x ∈ A. That is, x ∈ B∩A. Now interchange the roles of A and B
to show that B ∩ A ⊆ A ∩ B.
e. Let x ∈ (A ∩ B) ∩ C. Then x ∈ (A ∩ B) and x ∈ C. Thus, (x ∈ A and
x ∈ B) and x ∈ C. This implies x ∈ A and (x ∈ B and x ∈ C). Hence,
x ∈ A ∩ (B ∩ C). The converse is similar
Theorem 16.5
If A, B, and C are subsets of U then
a. A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).
b. A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C).
Proof.
a. Let x ∈ A∩(B∪C). Then x ∈ A and x ∈ B∪C. Thus, x ∈ A and (x ∈ B
or x ∈ C). This implies that (x ∈ A and x ∈ B) or (x ∈ A and x ∈ C).
Hence, x ∈ A∩ B or x ∈ A∩ C, i.e. x ∈ (A∩ B) ∪ (A∩ C). The converse is
similar.
b. Let x ∈ A ∪ (B ∩ C). Then x ∈ A or x ∈ B ∩ C. Thus, x ∈ A or (x ∈ B
and x ∈ C). This implies that (x ∈ A or x ∈ B) and (x ∈ A or x ∈ C).
Hence, x ∈ A ∪ B and x ∈ A ∪ C, i.e. x ∈ (A ∪ B) ∩ (A ∪ C). The converse
is similar
Theorem 16.6 (De Morgan’s Laws)
Let A and B be subsets of U then
a. (A ∪ B)
c
= A
c
∩ B
c
.
b. (A ∩ B)
c
= A
c
∪ B
c
.
16 PROPERTIES OF SETS 93
Proof.
a. Let x ∈ (A ∪ B)
c
. Then x ∈ U and x ∈ A ∪ B. Hence, x ∈ U and (x ∈ A
and x ∈ B). This implies that (x ∈ U and x ∈ A) and (x ∈ U and x ∈ B).
It follows that x ∈ A
c
∩ B
c
. Now, go backward for the converse.
b. Let x ∈ (A ∩ B)
c
. Then x ∈ U and x ∈ A ∩ B. Hence, x ∈ U and (x ∈ A
or x ∈ B). This implies that (x ∈ U and x ∈ B) or (x ∈ U and x ∈ A). It
follows that x ∈ A
c
∪ B
c
. The converse is similar
Theorem 16.7
Suppose that A ⊆ B. Then
a. A ∩ B = A.
b. A ∪ B = B.
Proof.
a. If x ∈ A ∩ B then by the deﬁnition of intersection of two sets we have
x ∈ A. Hence, A ∩ B ⊆ A. Conversely, if x ∈ A then x ∈ B as well since
A ⊆ B. Hence, x ∈ A ∩ B. This shows that A ⊆ A ∩ B.
b. If x ∈ A ∪ B then x ∈ A or x ∈ B. Since A ⊆ B then x ∈ B. Hence,
A∪B ⊆ B. Conversely, if x ∈ B then x ∈ A∪B. This shows that B ⊆ A∪B.
Example 16.2
Let A and B be arbitrary sets. Show that (A −B) ∩ B = ∅.
Solution.
Suppose not. That is, suppose (A−B) ∩B = ∅. Then there is an element x
that belongs to both A−B and B. By the deﬁnition of A−B we have that
x ∈ B. Thus, x ∈ B and x ∈ B which is a contradiction
A collection of nonempty subsets ¦A
1
, A
2
, , A
n
¦ of A is said to be a par
tition of A if and only if
(i) A = ∪
n
k=1
A
k
.
(ii) A
i
∩ A
j
= ∅ for all i = j.
Example 16.3
Let A = ¦1, 2, 3, 4, 5, 6¦, A
1
= ¦1, 2¦, A
2
= ¦3, 4¦, A
3
= ¦5, 6¦. Show that
¦A
1
, A
2
, A
3
¦ is a partition of A.
94 FUNDAMENTALS OF SET THEORY
Solution.
(i) A
1
∪ A
2
∪ A
3
= A.
(ii) A
1
∩ A
2
= A
1
∩ A
3
= A
2
∩ A
3
= ∅.
The number of elements of a set is called the cardinality of the set. We
write [A[ to denote the cardinality of the set A. If A has a ﬁnite cardinality
we say that A is a ﬁnite set. Otherwise, it is called inﬁnite.
Example 16.4
What is the cardinality of each of the following sets.
(a) ∅.
(b) ¦∅¦.
(c) ¦a, ¦a¦, ¦a, ¦a¦¦¦.
Solution.
(a) [∅[ = 0
(b) [¦∅¦[ = 1
(c) [¦a, ¦a¦, ¦a, ¦a¦¦¦[ = 3
Let A be a set. The power set of A, denoted by {(A), is the empty set
together with all possible subsets of A.
Example 16.5
Find the power set of A = ¦a, b, c¦.
Solution.
{(A) = ¦∅, ¦a¦, ¦b¦, ¦c¦, ¦a, b¦, ¦a, c¦,
¦b, c¦, ¦a, b, c¦¦
Theorem 16.8
If A ⊆ B then {(A) ⊆ {(B).
Proof.
Let X ∈ {(A). Then X ⊆ A. Since A ⊆ B then X ⊆ B. Hence, X ∈ {(B)
Example 16.6
a. Use induction to show that if [A[ = n then [{(A)[ = 2
n
.
b. If {(A) has 256 elements, how many elements are there in A?
16 PROPERTIES OF SETS 95
Solution.
a. If n = 0 then A = ∅ and in this case {(A) = ¦∅¦. Thus [{(A)[ = 1.
As induction hypothesis, suppose that if [A[ = n then [{(A)[ = 2
n
. Let
B = A∪¦a
n+1
¦. Then {(B) consists of all subsets of A and all subsets of A
with the element a
n+1
added to them. Hence, [{(B)[ = 2
n
+2
n
= 22
n
= 2
n+1
.
b. Since [{(A)[ = 256 = 2
8
then [A[ = 8
96 FUNDAMENTALS OF SET THEORY
Review Problems
Problem 16.1
Let A, B, and C be sets. Prove that if A ⊆ B then A ∩ C ⊆ B ∩ C.
Problem 16.2
Find sets A, B, and C such that A ∩ C = B ∩ C but A = B.
Problem 16.3
Find sets A, B, and C such that A ∩ C ⊆ B ∩ C and A ∪ C ⊆ B ∪ C but
A = B.
Problem 16.4
Let A and B be two sets. Prove that if A ⊆ B then B
c
⊆ A
c
.
Problem 16.5
Let A, B, and C be sets. Prove that if A ⊆ C and B ⊆ C then A ∪ B ⊆ C.
Problem 16.6
Let A, B, and C be sets. Show that A (B ∪ C) = (A B) ∪ (A C).
Problem 16.7
Let A, B, and C be sets. Show that A (B ∩ C) = (A B) ∩ (A C).
Problem 16.8
a. Is the number 0 in ∅? Why?
b. Is ∅ = ¦∅¦? Why?
c. Is ∅ ∈ ¦∅¦? Why?
Problem 16.9
Let A and B be two sets. Prove that (A −B) ∩ (A ∩ B) = ∅.
Problem 16.10
Let A and B be two sets. Show that if A ⊆ B then A ∩ B
c
= ∅.
Problem 16.11
Let A, B and C be three sets. Prove that if A ⊆ B and B ∩ C = ∅ then
A ∩ C = ∅.
16 PROPERTIES OF SETS 97
Problem 16.12
Find two sets A and B such that A ∩ B = ∅ but A B = ∅.
Problem 16.13
Suppose that A = ¦1, 2¦ and B = ¦2, 3¦. Find each of the following:
a. {(A ∩ B).
b. {(A).
c. {(A ∪ B).
d. {(A B).
Problem 16.14
a. Find {(∅).
b. Find {({(∅)).
c. Find {({({(∅))).
Problem 16.15
Determine which of the following statements are true and which are false.
Prove each statement that is true and give a counterexample for each state
ment that is false.
a. {(A ∪ B) = {(A) ∪ {(B).
b. {(A ∩ B) = {(A) ∩ {(B).
c. {(A) ∪ {(B) ⊆ {(A ∪ B).
d. {(A B) = {(A) {(B).
98 FUNDAMENTALS OF SET THEORY
17 Project VI: Boolean Algebra
A Boolean algebra is a nonempty set S together with two operations ⊕
and that satisfy the following axioms:
• a ⊕b ∈ S and a b ∈ S for all a, b ∈ S.
• a ⊕b = b ⊕a and a b = b a, ∀a, b ∈ S.
• a ⊕(b ⊕c) = (a ⊕b) ⊕c and a (b c) = (a b) c), ∀a, b, c ∈ S.
• a ⊕(b c) = (a ⊕b) (a ⊕c) and a (b ⊕c) = a b ⊕a c ∀a, b, c ∈ S.
• There exist distinct elements 0 and 1 in S such that a⊕0 = a and a1 = a
∀a ∈ S.
• For each a ∈ S there exits an element a such that a ⊕a = 1 and a a = 0.
We call a the complement or the negation of a.
We write (S, ⊕, ).
Problem 17.1
Show that if S is a collection of propositions with ﬁnite propositional variables
then (S, ∨, ∧) is a Boolean algebra.
Problem 17.2
Show that for a given nonempty set S, ({(S), ∪, ∩) is a Boolean algebra.
Relations and Functions
The reader is familiar with many relations which are used in mathematics
and computer science, i.e. ”is a subset of”, ” is less than” and so on.
One frequently wants to compare or contrast various members of a set, per
haps to arrange them in some appropriate order or to group together those
with similar properties. The mathematical framework to describe this kind
of organization of sets is the theory of relations.
There are three kinds of relations which we discuss in this chapter: (i) equiv
alence relations, (ii) order relations, (iii) functions.
18 Equivalence Relations
Let A be a given set. An ordered pair (a, b) of elements in A is deﬁned
to be the set ¦a, ¦a, b¦¦. The element a (resp. b) is called the ﬁrst (resp.
second) component.
Example 18.1
a. Show that if a = b then (a, b) = (b, a).
b. Show that (a, b) = (c, d) if and only if a = c and b = d.
Solution.
a. If a = b then ¦a, ¦a, b¦¦ = ¦b, ¦a, b¦¦. That is, (a, b) = (b, a).
b. (a, b) = (c, d) if and only if ¦a, ¦a, b¦ = ¦c, ¦c, d¦¦ and this is equivalent
to a = c and ¦a, b¦ = ¦c, d¦ by the deﬁnition of equality of sets. Thus, a = c
and b = d.
Example 18.2
Find x and y such that (x +y, 0) = (1, x −y).
99
100 RELATIONS AND FUNCTIONS
Solution.
By the previous exercise we have the system
x + y = 1
x − y = 0
Solving by the method of elimination one ﬁnds x =
1
2
and y =
1
2
.
If A and B are sets, we let A B denote the set of all ordered pairs (a, b)
where a ∈ A and b ∈ B. We call A B the Cartesian product of A and
B.
Example 18.3
a. Show that if A is a set with m elements and B is a set of n elements then
A B is a set of mn elements.
b. Show that if A B = ∅ then A = ∅ or B = ∅.
Solution.
a. Consider an ordered pair (a, b). There are m possibilities for a. For each
ﬁxed a, there are n possibilities for b. Thus, there are m n ordered pairs
(a, b). That is, [A B[ = mn.
b. We use the proof by contrapositive. Suppose that A = ∅ and B = ∅. Then
there is at least an a ∈ A and an element b ∈ B. That is, (a, b) ∈ A B
and this shows that A B = ∅. A contradiction to the assumption that
A B = ∅
Example 18.4
Let A = ¦1, 2¦, B = ¦1¦. Show that A B = B A.
Solution.
We have A B = ¦(1, 1), (2, 1)¦ = ¦(1, 1), (1, 2)¦ = B A.
A binary relation R from a set A to a set B is a subset of A B. If
(a, b) ∈ R we write aRb and we say that a is related to b. If a is not related
to B we write a Rb. In case A = B we call R a binary relation on A.
The set
Dom(R) = ¦a ∈ A[(a, b) ∈ R for some b ∈ B¦
is called the domain of R. The set
Range(R) = ¦b ∈ B[(a, b) ∈ R for some a ∈ A¦
is called the range of R.
18 EQUIVALENCE RELATIONS 101
Example 18.5
a. Let A = ¦2, 3, 4¦ and B = ¦3, 4, 5, 6, 7¦. Deﬁne the relation R by aRb if
and only if a divides b. Find, R, Dom(R), Range(R).
b. Let A = ¦1, 2, 3, 4¦. Deﬁne the relation R by aRb if and only if a ≤ b.
Find, R, Dom(R), Range(R).
Solution.
a. R = ¦(2, 4), (2, 6), (3, 3), (3, 6), (4, 4)¦, Dom(R) = ¦2, 3, 4¦, and Range(R) =
¦3, 4, 6¦.
b. R = ¦(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)¦, Dom(R) =
A, Range(R) = A.
A function is a special case of a relation. A function from A to B, de
noted by f : A → B, is a relation from A to B such that for every x ∈ A
there is a unique y ∈ B such that (x, y) ∈ f. The element y is called the
image of x and we write y = f(x). The set A is called the domain of f and
the set of all images of f is called the range of f. Functions will be discussed
in more details in Section 4.3.
Example 18.6
a. Show that the relation
f = ¦(1, a), (2, b), (3, a)¦
deﬁnes a function from A = ¦1, 2, 3¦ to B = ¦a, b, c¦. Find its range.
b. Show that the relation f = ¦(1, a), (2, b), (3, c), (1, b)¦ does not deﬁne a
function from A = ¦1, 2, 3¦ to B = ¦a, b, c¦.
Solution.
a. Note that each element of A has exactly one image. Hence, f is a function
with domain A and range Range(f) = ¦a, b¦.
b. The relation f does not deﬁne a function since the element 1 has two
images, namely a and b.
An informative way to picture a relation on a set is to draw its digraph. To
draw a digraph of a relation on a set A, we ﬁrst draw dots or vertices to
represent the elements of A. Next, if (a, b) ∈ R we draw an arrow (called a
directed edge) from a to b. Finally, if (a, a) ∈ R then the directed edge is
simply a loop.
102 RELATIONS AND FUNCTIONS
Example 18.7
Draw the directed graph of the relation in part (b) of Problem 18.5.
Solution.
Next we discuss three ways of building new relations from given ones. Let R
be a relation from a set A to a set B. The inverse of R is the relation R
−1
from Range(R) to Dom(R) such that
R
−1
= ¦(b, a) ∈ B A : (a, b) ∈ R¦.
Example 18.8
Let R = ¦(1, y), (1, z), (3, y)¦ be a relation from A = ¦1, 2, 3¦ to B =
¦x, y, z¦.
a. Find R
−1
.
b. Compare (R
−1
)
−1
and R.
Solution.
a. R
−1
= ¦(y, 1), (z, 1), (y, 3)¦.
b. (R
−1
)
−1
= R.
Let R and S be two relations from a set A to a set B. Then we deﬁne
the relations R ∪ S and R ∩ S by
R ∪ S = ¦(a, b) ∈ A B[(a, b) ∈ R or (a, b) ∈ S¦,
and
R ∩ S = ¦(a, b) ∈ A B[(a, b) ∈ A and (a, b) ∈ B¦.
18 EQUIVALENCE RELATIONS 103
Example 18.9
Given the following two relations from A = ¦1, 2, 4¦ to B = ¦2, 6, 8, 10¦ :
aRb if and only if a[b.
aSb if and only if b −4 = a.
List the elements of R, S, R ∪ S, and R ∩ S.
Solution.
R = ¦(1, 2), (1, 6), (1, 8), (1, 10), (2, 2), (2, 6), (2, 8), (2, 10), (4, 8)¦
S = ¦(2, 6), (4, 8)¦
R ∪ S = R
R ∩ S = S
Now, If we have a relation R from A to B and a relation S from B to C
we can deﬁne the relation S ◦ R, called the composition relation, to be the
relation from A to C deﬁned by
S ◦ R = ¦(a, c)[(a, b) ∈ R and (b, c) ∈ S for some b ∈ B¦.
Example 18.10
Let
R = ¦(1, 2), (1, 6), (2, 4), (3, 4), (3, 6), (3, 8)¦
S = ¦(2, u), (4, s), (4, t), (6, t), (8, u)¦
Find S ◦ R.
Solution.
S ◦ R = ¦(1, u), (1, t), (2, s), (2, t), (3, s), (3, t), (3, u)¦
We next deﬁne four types of binary relations. A relation R on a set A is
called reﬂexive if (a, a) ∈ R for all a ∈ A. In this case, the digraph of R has
a loop at each vertex.
Example 18.11
a. Show that the relation a ≤ b on the set A = ¦1, 2, 3, 4¦ is reﬂexive.
b. Show that the relation on IR deﬁned by aRb if and only if a < b is not
reﬂexive.
104 RELATIONS AND FUNCTIONS
Solution.
a. By Problem 242, each vertex has a loop.
b. Indeed, for any real number a we have a −a = 0 and not a −a < 0.
A relation R on A is called symmetric if whenever (a, b) ∈ R then we
must have (b, a) ∈ R. The digraph of a symmetric relation has the property
that whenever there is a directed edge from a to b, there is also a directed
edge from b to a.
Example 18.12
a. Let A = ¦a, b, c, d¦ and R = ¦(a, a), (b, c), (c, b), (d, d)¦. Show that R is
symmetric.
b. Let IR be the set of real numbers and R be the relation aRb if and only
if a < b. Show that R is not symmetric.
Solution.
a. bRc and cRb so R is symmetric.
b. 2 < 4 but 4 < 2.
A relation R on a set A is called antisymmetric if whenever (a, b) ∈ R
and a = b then (b, a) ∈ R. The digraph of an antisymmetric relation has the
property that between any two vertices there is at most one directed edge.
Example 18.13
a. Let IN be the set of nonnegative integers and R the relation aRb if and
only if a divides b. Show that R is antisymmetric.
b. Let A = ¦a, b, c, d¦ and R = ¦(a, a), (b, c), (c, b), (d, d)¦. Show that R is
not antisymmetric.
Solution.
a. Suppose that a[b and b[a. We must show that a = b. Indeed, by the def
inition of division, there exist positive integers k
1
and k
2
such that b = k
1
a
and a = k
2
b. This implis that a = k
2
k
1
a and hence k
1
k
2
= 1. Since k
1
and k
2
are positive integers then we must have k
1
= k
2
= 1. Hence, a = b.
b. bRc and cRb with b = c.
A relation R on a set A is called transitive if whenever (a, b) ∈ R and
(b, c) ∈ R then (a, c) ∈ R. The digraph of a transitive relation has the prop
erty that whenever there are directed edges from a to b and from b to c then
there is also a directed edge from a to c.
18 EQUIVALENCE RELATIONS 105
Example 18.14
a. Let A = ¦a, b, c, d¦ and R = ¦(a, a), (b, c), (c, b), (d, d)¦. Show that R is
not transitive.
b. Let ZZ be the set of integers and R the relation aRb if a divides b. Show
that R is transitive.
Solution.
a. (b, c) ∈ R and (c, b) ∈ R but (b, b) ∈ R.
b. Suppose that a[b and b[c. Then there exist integers k
1
and k
2
such that
b = k
1
a and c = k
2
b. Thus, c = (k
1
k
2
)a which means that a[c.
Now, let A
1
, A
2
, , A
n
be a partition of a set A. That is, the A
i
s are
subsets of A that satisfy
(i) ∪
n
i=1
A
i
= A
(ii) A
i
∩ A
j
= ∅ for i = j.
Deﬁne on A the binary relation x R y if and only if x and y belongs to the
same set A
i
for some 1 ≤ i ≤ n.
Theorem 18.1
The relation R deﬁned above is reﬂexive, symmetric, and transitive.
Proof.
• R is reﬂexive: If x ∈ A then by (i) x ∈ A
k
for some 1 ≤ k ≤ n. Thus, x
and x belong to A
k
so that x R x.
• R is symmetric: Let x, y ∈ A such that x R y. Then there is an index k
such that x, y ∈ A
k
. But then y, x ∈ A
k
. That is, y R x.
• R is transitive: Let x, y, z ∈ A such that x R y and y R z. Then there exist
indices i and j such that x, y ∈ A
i
and y, z ∈ A
j
. Since y ∈ A
i
∩ A
j
then
by (ii) we must have i = j. This implies that x, y, z ∈ A
i
and in particular
x, z ∈ A
i
. Hence, x R z.
A relation that is reﬂexive, symmetric, and transitive on a set A is called
an equivalence relation on A. For example, the relation ”=” is an equiv
alence relation on IR.
Example 18.15
Let ZZ be the set of integers and n ∈ ZZ. Let R be the relation on ZZ deﬁned
by aRb if a −b is a multiple of n. We denote this relation by a ≡ b (mod n)
read ”a congruent to b modulo n.” Show that R is an equivalence relation
on ZZ.
106 RELATIONS AND FUNCTIONS
Solution.
≡ is reﬂexive: For all a ∈ ZZ, a −a = 0 n. That is, a ≡ a (mod n).
≡ is symmetric: Let a, b ∈ ZZ such that a ≡ b (mod n). Then there is an
integer k such that a −b = kn. Multiply both sides of this equality by (−1)
and letting k
= −k we ﬁnd that b −a = k
n. That is b ≡ a (mod n).
≡ is transitive: Let a, b, c ∈ ZZ be such that a ≡ b (mod n) and b ≡ c (mod n).
Then there exist integers k
1
and k
2
such that a − b = k
1
n and b − c = k
2
n.
Adding these equalities together we ﬁnd a − c = kn where k = k
1
+ k
2
∈ ZZ
which shows that a ≡ c (mod n).
Theorem 18.2
Let R be an equivalence relation on A. For each a ∈ A let
[a] = ¦x ∈ A[xRa¦
A/R = ¦[a][a ∈ A¦.
Then the union of all the elements of A/R is equal to A and the intersection
of any two distinct members of A/R is the empty set. That is, the family
A/R forms a partition of A.
Proof.
By the deﬁnition of [a] we have that [a] ⊆ A. Hence, ∪
a∈A
[a] ⊆ A. We
next show that A ⊆ ∪
a∈A
[a]. Indeed, let a ∈ A. Since A is reﬂexive then
a ∈ [a] and consequently a ∈ ∪
b∈A
[b]. Hence, A ⊆ ∪
b∈A
[b]. It follows that
A = ∪
a∈A
[a]. This establishes (i).
It remains to show that if [a] = [b] then [a] ∩[b] = ∅ for a, b ∈ A. Suppose the
contrary. That is, suppose [a] ∩[b] = ∅. Then there is an element c ∈ [a] ∩[b].
This means that c ∈ [a] and c ∈ [b]. Hence, a R c and b R c. Since R is
symmetric and transitive then a R b. We will show that the conclusion a R b
leads to [a] = [b]. The proof is by double inclusions. Let x ∈ [a]. Then x R a.
Since a R b and R is transitive then x R b which means that x ∈ [b]. Thus,
[a] ⊆ [b]. Now interchange the letters a and b to show that [b] ⊆ [a]. Hence,
[a] = [b] which contradicts our assumption that [a] = [b]. This establishes
(ii). Thus, A/R is a partition of A.
The sets [a] deﬁned in the previous exercise are called the equivalence
classes of A given by the relation R. The element a in [a] is called a repre
sentative of the equivalence class [a].
18 EQUIVALENCE RELATIONS 107
Review Problems
Problem 18.1
Let X = ¦a, b, c¦. Recall that {(X) is the power set of X. Deﬁne a binary
relation 1 on {(X) as follows:
A, B ∈ {(x), A 1 B ⇔[A[ = [B[.
a. Is ¦a, b¦1¦b, c¦?
b. Is ¦a¦1¦a, b¦?
c. Is ¦c¦1¦b¦?
Problem 18.2
Let Σ = ¦a, b¦. Then Σ
4
is the set of all strings over Σ of length 4. Deﬁne a
relation R on Σ
4
as follows:
s, t ∈ Σ
4
, s R t ⇔ s has the same ﬁrst two characters as t.
a. Is abaa R abba?
b. Is aabb R bbaa?
c. Is aaaa R aaab?
Problem 18.3
Let A = ¦4, 5, 6¦ and B = ¦5, 6, 7¦ and deﬁne the binary relations R, S, and
T from A to B as follows:
(x, y) ∈ A B, (x, y) ∈ R ⇔x ≥ y.
(x, y) ∈ A B, x S y ⇔2[(x −y).
T = ¦(4, 7), (6, 5), (6, 7)¦.
a. Draw arrow diagrams for R, S, and T.
b. Indicate whether any of the relations S, R, or T are functions.
Problem 18.4
Let A = ¦3, 4, 5¦ and B = ¦4, 5, 6¦ and deﬁne the binary relation R as
follows:
(x, y) ∈ A B, (x, y) ∈ R ⇔x < y.
List the elements of the sets R and R
−1
.
108 RELATIONS AND FUNCTIONS
Problem 18.5
Let A = ¦2, 4¦ and B = ¦6, 8, 10¦ and deﬁne the binary relations R, S, and
T from A to B as follows:
(x, y) ∈ A B, (x, y) ∈ R ⇔x[y.
(x, y) ∈ A B, x S y ⇔y −4 = x.
List the elements of A B, R, S, R ∪ S, and R ∩ S.
Problem 18.6
Consider the binary relation on IR deﬁned as follows:
x, y ∈ R, x R y ⇔x ≥ y.
Is R reﬂexive? symmetric? transitive?
Problem 18.7
Consider the binary relation on IR deﬁned as follows:
x, y ∈ R, x R y ⇔xy ≥ 0.
Is R reﬂexive? symmetric? transitive?
Problem 18.8
Let Σ = ¦0, 1¦ and A = Σ
∗
. Consider the binary relation on A deﬁned as
follows:
x, y ∈ A, x R y ⇔[x[ < [y[,
where [x[ denotes the length of the string x. Is R reﬂexive? symmetric?
transitive?
Problem 18.9
Let A = ∅ and {(A) be the power set of A. Consider the binary relation on
{(A) deﬁned as follows:
X, Y ∈ {(A), X R Y ⇔X ⊆ Y.
Is R reﬂexive? symmetric? transitive?
18 EQUIVALENCE RELATIONS 109
Problem 18.10
Let E be the binary relation on ZZ deﬁned as follows:
a E b ⇔m ≡ n (mod 2).
Show that E is an equivalence relation on ZZ and ﬁnd the diﬀerent equivalence
classes.
Problem 18.11
Let I be the binary relation on IR deﬁned as follows:
a I b ⇔a −b ∈ ZZ.
Show that I is an equivalence relation on IR and ﬁnd the diﬀerent equivalence
classes.
Problem 18.12
Let A be the set all straight lines in the cartesian plane. Let [[ be the binary
relation on A deﬁned as follows:
l
1
[[l
2
⇔l
1
is parallel to l
2
.
Show that [[ is an equivalence relation on A and ﬁnd the diﬀerent equivalence
classes.
Problem 18.13
Let A = IN IN. Deﬁne the binary relation R on A as follows:
(a, b) R (c, d) ⇔a +d = b +c.
a. Show that R is reﬂexive.
b. Show that R is symmetric.
c. Show that R is transitive.
d. List ﬁve elements in [(1, 1)].
e. List ﬁve elements in [(3, 1)].
f. List ﬁve elements in [(1, 2)].
g. Describe the distinct equivalence classes of R.
Problem 18.14
Let R be a binary relation on a set A and suppose that R is symmetric and
transitive. Prove the following: If for every x ∈ A there is a y ∈ A such that
x R y then R is reﬂexive and hence an equivalence relation on A.
110 RELATIONS AND FUNCTIONS
19 Partial Order Relations
A relation ≤ on a set A is called a partial order if ≤ is reﬂexive, antisym
metric, and transitive. In this case we call A a poset.
Example 19.1
Show that the set ZZ of integers together with the relation of inequality ≤ is
a poset.
Solution.
≤ is reﬂexive: For all x ∈ ZZ we have x ≤ x since x = x.
≤ is antisymmetric: By the trichotomy law of real numbers, for a given pair
of numbers x and y only one of the following is true: x < y, x = y, or x > y.
So if x ≤ y and y ≤ x then we must have x = y.
≤ is transitive: By the transitivity property of < in IR if x < y and y < z
then x < z. Thus, if x ≤ y and y ≤ z then the deﬁnition of ≤ and the above
property imply that x ≤ z.
Example 19.2
Show that the relation a[b in IN
∗
is a partial order relation.
Solution.
Reﬂexivity: Since a = 1 a then a[a.
Antisymmetry: Suppose that a[b and b[a. Then there exist positive integers
k
1
and k
2
such that b = k
1
a and a = k
2
b. Hence, a = k
1
k
2
a which implies
that k
1
k
2
= 1. Since k
1
, k
2
∈ IN
∗
then we must have k
1
= k
2
= 1; that is,
a = b.
Transitivity: Suppose that a[b and b[c. Then there exist positive integers k
1
and k
2
such that b = k
1
a and c = k
2
b. Thus, c = k
1
k
2
a which means that
a[c.
Example 19.3
Let / be a collection of subsets. Let R be the relation deﬁned by
A R B ⇔A ⊆ B.
Show that / is a poset.
19 PARTIAL ORDER RELATIONS 111
Solution.
⊆ is reﬂexive: For any set X ∈ /, X ⊆ X.
⊆ is antisymmetric: By the deﬁnition of = if X ⊆ Y and Y ⊆ X then X = Y,
where X, Y ∈ /.
⊆ is transitive: We have seen in Chapter 3 that if X ⊆ Y and Y ⊆ Z then
X ⊆ Z.
To ﬁgure out which of two words comes ﬁrst in an English dictionary, one
compares their letters one by one from left to right. If all the letters have
been the same to a certain point and one word is runs out of letters, that word
comes ﬁrst in the dictionary. For example, play comes before playground. If
all the letters up to a certain point are the same and the next letters diﬀer,
then the word whose next letter is located earlier in the alphabet comes ﬁrst
in the dictionary. For example, playground comes before playmate. This type
of order relation is called lexicographic or dictionary order. A general de
ﬁnition is the following:
Let Σ
∗
be the set of words with letters from an ordered set Σ. Deﬁne the
relation ≤ on Σ
∗
as follows: for all w, z ∈ Σ
∗
, w ≤ z if and only if either
(a)z = wu for some u ∈ Σ
∗
, or
(b)w = xu and z = xv where u, v ∈ Σ
∗
such that the ﬁrst letter of u precedes
the ﬁrst letter of v in the ordering of Σ.
Then it can be shown that ≤ is a partial order relation on Σ
∗
.
Example 19.4
Let Σ = ¦a, b¦ and suppose that Σ has the partial order relation R =
¦(a, a), (a, b), (b, b)¦. Let ≤ be the corresponding lexicographic order on Σ
∗
.
Indicate which of the following statements are true.
a. aab ≤ aaba.
b. bbab ≤ bba.
c. ≤ aba.
d. aba ≤ abb.
e. bbab ≤ bbaa.
f. ababa ≤ ababaa.
g. bbaba ≤ bbabb.
112 RELATIONS AND FUNCTIONS
Solution.
a. True since aaba = (aab)a.
b. False since bba ≤ bbab.
c. True since aba = aba.
d. True since aba = (ab)a, abb = (ab)b and a R b.
e. False since bbaa ≤ bbab.
f. True since ababaa = (ababa)a.
g. True since bbaba = (bbab)a, bbabb = (bbab)b and a R b.
Another simple pictorial representation of a partial order is the so called
Hasse diagram. The Hasse diagram of a partial order on the set A is a
drawing of the points of A and some of the arrows of the digraph of the order
relation. We assume that the directed edges of the digraph point upward.
There are rules to determine which arrows are drawn and which are omitted,
namely,
• omit all arrows that can be inferred from transitivity
• omit all loops
• draw arrows without ”heads”.
Example 19.5
Let A = ¦1, 2, 3, 9, 18¦ and the ”divides” relation on A. Draw the Hasse
diagram of this relation.
Solution.
The directed graph of the given relation is
The corresponding Hasse diagram is given by
19 PARTIAL ORDER RELATIONS 113
Now, given the Hasse diagram of a partial order relation one can ﬁnd the
diagraph as follows:
• Reisert the direction markers on the arrows making all arrows point upward
• add loops at each vertex
• for each sequence of arrows from one point to a second point and from that
second point to a third point, add an arrow from the ﬁrst point to the third.
Example 19.6
Let A = ¦1, 2, 3, 4¦ be a poset. Find the directed graph corresponding to the
following Hasse diagram on A.
114 RELATIONS AND FUNCTIONS
Solution.
Next, if A is a poset then we say that a and b are comparable if either
a ≤ b or b ≤ a. If every pair of elements of A are comparable then we call ≤
a totally ordered relation.
Example 19.7
Consider the ”divides” relation deﬁned on the set A = ¦5, 15, 30¦. Prove that
this relation is a total order on A.
Solution.
The facts that ”divides” relation is a partial order relation is easy to verify.
Since 5[15, 5[30, and 15[30 then any pair of elements in A are comparable.
Thus, the ”divides” relation is a total order relation on A.
Example 19.8
Show that the ”divides” relation on IN
∗
is not a total partial order.
Solution.
A counterexample of two noncomparable numbers are 2 and 3. Since 2 does
not divide 3 and 3 does not divide 2.
19 PARTIAL ORDER RELATIONS 115
Review Problems
Problem 19.1
Let Σ = ¦a, b¦ and let Σ
∗
be the set of all strings over Σ. Deﬁne the relation
R on Σ
∗
as follows: for all s, t ∈ Σ
∗
,
s R t ⇔l(s) ≤ l(t),
where l(x) denotes the length of the word x. Is R antisymmetric? Prove or
give a counterexample.
Problem 19.2
Deﬁne a relation R on ZZ as follows: for all m, n ∈ ZZ
m R n ⇔m+n is even.
Is R a partial order? Prove or give a counterexample.
Problem 19.3
Deﬁne a relation R on IR as follows: for all m, n ∈ IR
m R n ⇔m
2
≤ n
2
.
Is R a partial order? Prove or give a counterexample.
Problem 19.4
Let S = ¦0, 1¦ and consider the partial order relation R deﬁned on S S as
follows: for all ordered pairs (a, b) and (c, d) in S S
(a, b) R (c, d) ⇔a ≤ c and b ≤ d.
Draw the Hasse diagram for R.
Problem 19.5
Consider the ”divides” relation deﬁned on the set A = ¦1, 2, 2
2
, , 2
n
¦,
where n is a nonnegative integer.
a. Prove that this relation is a total order on A.
b. Draw the Hasse diagram for this relation when n = 3.
116 RELATIONS AND FUNCTIONS
20 Functions: Deﬁnitions and Examples
A function is a special case of a relation. A function f from a set A to a
set B is a relation from A to B such that for every x ∈ A there is a unique
y ∈ B such that (x, y) ∈ f. For (x, y) ∈ f we use the notation y = f(x). We
call y the image of x under f. The set A is called the domain of f whereas
B is called the codomain. The collection of all images of f is called the
range of f.
Example 20.1
Show that the relation f = ¦(1, a), (2, b), (3, a)¦ deﬁnes a function from A =
¦1, 2, 3¦ to B = ¦a, b, c¦. Find its range.
Solution.
Since every element of A has a unique image then f is a function. Its range
consists of the elements a and b.
Example 20.2
Show that the relation f = ¦(1, a), (2, b), (3, c), (1, b)¦ does not deﬁne a func
tion from A = ¦1, 2, 3¦ to B = ¦a, b, c¦.
Solution.
Indeed, since 1 has two images in B then f is not a function.
Example 20.3
A sequence of elements of a set A is a function from IN
∗
to A. We write
(a
n
) and we call a
n
the nth term of the sequence.
a. Deﬁne the sequence a
n
= n, n ≥ 1. Compute
¸
n
k=1
a
k
.
b. Deﬁne the sequence a
n
= n
2
. Compute the sum
¸
n
k=1
a
k
.
Solution.
a. Let S
n
=
¸
n
k=1
a
k
. Then write S
n
in two diﬀerent ways, namely, S
n
=
1 + 2 + + n and S
n
= n + (n − 1) + + 1. Adding, we obtain 2S
n
=
(n + 1) + (n + 1) + + (n + 1) = n(n + 1). Thus, S
n
=
n(n+1)
2
.
b. First note that (n + 1)
3
− n
3
= 3n
2
+ 3n + 1. From this we obtain the
following chain of equalities:
2
3
− 1
3
= 3(1)
2
+ 3(1) + 1
3
3
− 2
3
= 3(2)
2
+ 3(2) + 1
.
.
.
(n + 1)
3
− n
3
= 3n
2
+ 3n + 1
20 FUNCTIONS: DEFINITIONS AND EXAMPLES 117
Adding these equalities we ﬁnd
3
n
¸
k=1
k
2
+ 3
n
¸
k=1
k +n = (n + 1)
3
−1.
Using a. we ﬁnd
3
n
¸
k=1
k
2
+
3n(n + 1)
2
+n = n
3
+ 3n
2
+ 3n.
A simple arithmetic shows that
n
¸
k=1
k
2
=
n(n + 1)(2n + 1)
6
.
Example 20.4
Let A = ¦a, b, c¦. Deﬁne the function f : {(A) → IN by f(X) = [X[. Find
the range of f.
Solution.
By applying f to each member of {(A) we ﬁnd Range(f) = ¦0, 1, 2, 3¦.
Example 20.5
Consider the alphabet Σ = ¦a, b¦ and the function f : Σ
∗
→ ZZ deﬁned as
follows: for any string s ∈ Σ
∗
f(s) = the number of a
s in s.
Find f(), f(ababb), and f(bbbaa).
Solution.
f() = 0, f(ababb) = 2, and f(bbbaa) = 2.
Example 20.6 (Equality of Functions)
Two functions f and g deﬁned on the same domain D are said to be equal if
and only if f(x) = g(x) for all x ∈ D. Show that the functions f, g : IR →IR
deﬁned by f(x) = [x[ and g(x) =
√
x
2
are equal.
Solution.
A simple argument by the method of proof by cases shows that
√
x
2
= [x[.
118 RELATIONS AND FUNCTIONS
Example 20.7 (Hamming distance function)
Let Σ = ¦0, 1¦ and Σ
n
be the set of all strings of 0’s and 1’s of length n.
Deﬁne the function H : Σ
n
Σ
n
→IN as follows: for any (s, t) ∈ Σ
n
Σ
n
H(s, t) = number of positions in which s and t have different values.
For the case n = 5, ﬁnd H(00101, 01110) and H(10001, 01111).
Solution.
H(00101, 01110) = 3 and H(10001, 01111) = 4.
Example 20.8 (Boolean functions)
An nplace Boolean function f is a function from the Cartesian product
¦0, 1¦
n
to ¦0, 1¦. Consider the 3place Boolean function f : ¦0, 1¦
3
→¦0, 1¦
deﬁned by
f(x
1
, x
2
, x
3
) = (x
1
+x
2
+x
3
) mod 2.
Describe f using an input/output table.
Solution.
x
1
x
2
x
3
f(x
1
, x
2
, x
3
)
1 1 1 1
1 1 0 0
1 0 1 0
1 0 0 1
0 1 1 0
0 1 0 1
0 0 1 1
0 0 0 0
Example 20.9 (Encoding and Decoding functions)
Let Σ = ¦0, 1¦ and Σ
∗
be the set of all strings of 0’s and 1’s. Let L be the
set of all strings over Σ that consist of consecutive triples of identical bits.
Thus, 111000 ∈ L. A message consisting of 0’s and 1’s is encoded by writing
each bit in it three times. The encoded message is decoded by replacing each
section of three identical bits by the one bit to which all three are equal.
We deﬁne the encoding function E : Σ
∗
→L by
E(s) = the string obtained from s by replacing each bit of s
by the same bit written three times
20 FUNCTIONS: DEFINITIONS AND EXAMPLES 119
and we deﬁne the decoding function D : L →Σ
∗
by
D(s) = the string obtained from s by replacing consecutive triple of bits
of s by a single copy of that bit.
Find E(0110) and D(111111000111).
Solution.
We have E(0110) = 000111111000 and D(111111000111) = 1101.
Now, let A and B be subsets of IR. A function f : A → B is called a
realvalued function of a real variable. In this case, each ordered pair
(x, f(x)) can be represented by a point in the Cartesian plane. The collection
of all such points is called the graph of f.
Example 20.10
Consider the power function f
a
(x) = x
a
, where a, x ∈ IR
+
∪ ¦0¦. Graph on
the same Cartesian plane the functions f
0
(x), f
1
(x), f1
2
(x), and f
2
(x).
Solution.
Example 20.11
Graph the functions f(x) = x and g(x) = x on the closed interval [−4, 4].
120 RELATIONS AND FUNCTIONS
Solution.
Example 20.12
Graph the function f : IN →IR deﬁned by f(n) =
√
n.
Solution.
20 FUNCTIONS: DEFINITIONS AND EXAMPLES 121
Example 20.13
Let D
f
be the domain of a function f and S ⊆ D
f
. We say that f is increas
ing on S if and only if, for all x
1
, x
2
∈ S, if x
1
< x
2
then f(x
1
) < f(x
2
).
Show that the function f : IR → IR deﬁned by f(x) = 2x − 3 is increasing
on IR.
Solution.
Indeed, for any real numbers x
1
and x
2
such that x
1
< x
2
, we have 2x
1
−3 <
2x
2
−3. That is, f(x
1
) < f(x
2
) so that f is increasing.
Example 20.14
Let D
f
be the domain of a function f and S ⊆ D
f
. We say that f is de
creasing on S if and only if, for all x
1
, x
2
∈ S, if x
1
< x
2
then f(x
1
) > f(x
2
).
Show that the function f : IR → IR deﬁned by f(x) =
x+2
x+1
is decreasing on
(−∞, −1) and (−1, ∞).
Solution.
Indeed, for any real numbers x
1
, x
2
∈ (−∞, −1) or x
1
, x
2
∈ (−1, ∞) such that
x
1
< x
2
, we have (x
1
+ 1)(x
2
+ 1) > 0. This implies, that f(x
1
) − f(x
2
) =
x
2
−x
1
(x
1
+1)(x
2
+1)
> 0. Thus, f is decreasing on the given intervals.
122 RELATIONS AND FUNCTIONS
Review Problems
Problem 20.1
Let f, g : IR →IR be the functions f(x) = 2x and g(x) =
2x
3
+2x
2
x
2
+1
. Show that
f = g.
Problem 20.2
Let H, K : IR →IR be the functions H(x) = x + 1 and K(x) = x. Does
H = K? Explain.
Problem 20.3
Find functions deﬁned on the set of nonnegative integers that deﬁne the
sequences whose ﬁrst six terms are given below.
a. 1, −
1
3
,
1
5
, −
1
7
,
1
9
, −
1
11
.
b. 0, −2, 4, −6, 8, −10.
Problem 20.4
Let A = ¦1, 2, 3, 4, 5¦ and let F : {(A) →ZZ be deﬁned as follows:
F(X) =
0 if X has an even number of elements
1 if X has an odd number of elements
Find the following
a. F(¦1, 3, 4¦)
b. F(∅).
c. F(¦2, 3¦).
d. F(¦2, 3, 4, 5¦).
Problem 20.5
Let Σ = ¦a, b¦ and Σ
∗
be the set of all strings over Σ.
a. Deﬁne f : Σ
∗
→ZZ as follows:
f(s) =
the number of b
s to the left of the left −most a in s
0 if s contains no a
s
Find f(aba), f(bbab), and f(b). What is the range of f?
b. Deﬁne g : Σ
∗
→Σ
∗
as follows:
g(s) = the string obtained by writing the characters of s in reverse order.
Find g(aba), g(bbab), and g(b). What is the range of g?
20 FUNCTIONS: DEFINITIONS AND EXAMPLES 123
Problem 20.6
Let E and D be the encoding and decoding functions.
a. Find E(0110) and D(111111000111).
b. Find E(1010) and D(000000111111).
Problem 20.7
Let H denote the Hamming distance function on Σ
5
.
a. Find H(10101, 00011).
b. Find H(00110, 10111).
Problem 20.8
Consider the threeplace Boolean function f : ¦0, 1¦
3
→ ¦0, 1¦ deﬁned as
follows:
f(x
1
, x
2
, x
3
) = (3x
1
+x
2
+ 2x
3
) mod 2
a. Find f(1, 1, 1) and f(0, 1, 1).
b. Describe f using an input/output table.
Problem 20.9
Draw the graphs of the power functions f1
3
(x) and f1
4
(x) on the same set of
axes. When, 0 < x < 1, which is greater: x
1
3
or x
1
4
? When x > 1, which is
greater s
1
3
or x
1
4
?
Problem 20.10
Graph the function f(x) = x −x on the interval (−∞, ∞).
Problem 20.11
Graph the function f(x) = x −x on the inerval (−∞, ∞).
Problem 20.12
Graph the function h : IN →IR deﬁned by h(n) =
n
2
.
Problem 20.13
Let k : IR → IR be the function deﬁned by the formula k(x) =
x−1
x
for all
nonzero real numbers x.
a. Show that k is increasing on (0, ∞).
b. Is k increasing or decreasing on (−∞, 0)? Prove your answer.
124 RELATIONS AND FUNCTIONS
21 Bijective and Inverse Functions
Let f : A → B be a function. We say that f is injective or onetoone if
and only if for all x, y ∈ A, if f(x) = f(y) then x = y. Using the concept of
contrapositive, a function f is injective if and only if for all x, y ∈ A, if x = y
then f(x) = f(y). Taking the negation of this last conditional implication
we see that f is not injective if and only if there exist two distinct elements
a and b of A such that f(a) = f(b).
Example 21.1
a. Show that the identity function I
A
on a set A is injective.
b. Show that the fucntion f : ZZ →ZZ deﬁned by f(n) = n
2
is not injective.
Solution.
a. Let x, y ∈ A. If I
A
(x) = I
A
(y) then x = y by the deﬁnition of I
A
. This
shows that I
A
is injective.
b. Since 1
2
= (−1)
2
and 1 = −1, f is not injective.
Example 21.2 (Hash Functions)
Let m > 1 be a positive integer . Show that the function h : ZZ →ZZ deﬁned
by h(n) = n mod m is not injective.
Solution.
Indeed, since m > 1 then 2m + 1 = m + 1 and h(m + 1) = h(2m + 1) = 1.
So h is not injective.
Example 21.3
Show that if f : IR →IR is increasing then f is onetoone.
Solution.
Suppose that x
1
= x
2
. Then without lost of generality we can assume that
x
1
< x
2
. Since f is increasing then f(x
1
) < f(x
2
). That is, f(x
1
) = f(x
2
).
Hence, f is onetoone.
Example 21.4
Show that the composition of two injective functions is also injective.
Solution.
Let f : A →B and g : B →C be two injective functions. We will show that
g◦f : A →C is also injective. Indeed, suppose that (g◦f)(x
1
) = (g◦f)(x
2
) for
21 BIJECTIVE AND INVERSE FUNCTIONS 125
x
1
, x
2
∈ A. Then g(f(x
1
)) = g(f(x
2
)). Since g is injective then f(x
1
) = f(x
2
).
Now since f is injective then x
1
= x
2
. This completes the proof that g ◦ f is
injective.
Now, for any function f : A → B we have Range(f) ⊆ B. If equality holds
then we say that f is surjective or onto. It follows from this deﬁnition that
a function f is surjective if and only if for each y ∈ B there is an x ∈ A such
that f(x) = y. By taking the negation of this we see that f is not onto if
there is a y ∈ B such that f(x) = y for all x ∈ A.
Example 21.5
a. Show that the function f : IR →IR deﬁned by f(x) = 3x−5 is surjective.
b. Show that the function f : ZZ → ZZ deﬁned by f(n) = 3n − 5 is not
surjective.
Solution.
a. Let y ∈ IR. Is there an x ∈ IR such that f(x) = y? That is, 3x − 5 = y.
But solving for x we ﬁnd x =
y+5
3
∈ IR and f(x) = y. Thus, f is onto.
b. Take m = 3. If f is onto then there should be an n ∈ ZZ such that f(n) = 3.
That is, 3n − 5 = 3. Solving for n we ﬁnd n =
8
3
which is not an integer.
Hence, f is not onto.
Example 21.6 (Projection Functions)
Let A and B be two nonempty sets. The functions pr
A
: AB →A deﬁned
by pr
A
(a, b) = a and pr
B
: A B → B deﬁned by pr
B
(a, b) = b are called
projection functions. Show that pr
A
and pr
B
are surjective functions.
Solution.
We prove that pr
A
is surjective. Indeed, let a ∈ A. Since B is not empty
then there is a b ∈ B. But then (a, b) ∈ AB and pr
A
(a, b) = a. Hence, pr
A
is surjective. The proof that pr
B
is surjective is similar.
Example 21.7
Show that the composition of two surjective functions is also surjective.
Solution.
Let f : A → B and g : B → C, where Range(f) ⊆ C, be two surjective
functions. We will show that g ◦ f : A → D is also surjective. Indeed, let
z ∈ D. Since g is surjective then there is a y ∈ B such that g(y) = z. Since f
126 RELATIONS AND FUNCTIONS
is surjective then there is an x ∈ A such that f(x) = y. Thus, g(f(x)) = z.
This shows that g ◦ f is surjective.
Now, we say that a function f is bijective or onetoone correspondence
if and only if f is both injective and surjective. A bijective function on a set
A is called a permutation.
Example 21.8
a. Show that the function f : IR →IR deﬁned by f(x) = 3x−5 is a bijective
function.
b. Show that the function f : IR →IR deﬁned by f(x) = x
2
is not bijective.
Solution.
a. First we show that f is injective. Indeed, suppose that f(x
1
) = f(x
2
).
Then 3x
1
−5 = 3x
2
−5 and this implies that x
1
= x
2
. Hence, f is injective.
f is surjective by Exercise 309 (a).
b. f is not injective since f(−1) = f(1) but −1 = 1. Hence, f is not bijective.
Example 21.9
Show that the composition of two bijective functions is also bijective.
Solution.
This follows from Example 21.4 and Example 21.7
Theorem 21.1
Let f : X →Y be a bijective function. Then there is a function f
−1
: Y →X
with the following properties:
a. f
−1
(y) = x if and only if f(x) = y.
b. f
−1
◦ f = I
X
and f ◦ f
−1
= I
Y
where I
X
denotes the identity function on
X.
c. f
−1
is bijective.
Proof.
For each y ∈ Y there is a unique x ∈ X such that f(x) = y since f is
bijective. Thus, we can deﬁne a function f
−1
: Y →X by f
−1
(y) = x where
f(x) = y.
a. Follows from the deﬁnition of f
−1
.
21 BIJECTIVE AND INVERSE FUNCTIONS 127
b. Indeed, let x ∈ X such that f(x) = y. Then f
−1
(y) = x and (f
−1
◦f)(x) =
f
−1
(f(x)) = f
−1
(y) = x = I
X
(x). Since x was arbitrary then f
−1
◦ f = I
X
.
The proof that f ◦ f
−1
= I
Y
is similar.
c. We show ﬁrst that f
−1
is injective. Indeed, suppose f
−1
(y
1
) = f
−1
(y
2
).
Then f(f
−1
(y
1
)) = f(f
−1
(y
2
)); that is, (f ◦ f
−1
)(y
1
) = (f ◦ f
−1
)(y
2
). By b.
we have I
Y
(y
1
) = I
Y
(y
2
). From the deﬁnition of I
Y
we obtain y
1
= y
2
. Hence,
f
−1
is injective. We next show that f
−1
is surjective. Indeed, let y ∈ Y .
Since f is onto there is a unique x ∈ X such that f(x) = y. By the deﬁntion
of f
−1
, f
−1
(y) = x. Thus, for every element y ∈ Y there is an element x ∈ X
such that f
−1
(y) = x. This says that f
−1
is surjective and completes a proof
of the theorem
Example 21.10
Show that f : IR → IR deﬁned by f(x) = 3x − 5 is bijective and ﬁnd a
formula for its inverse function.
Solution.
We have already proved that f is bijective. We will just ﬁnd the formula
for its inverse function f
−1
. Indeed, if y ∈ Y we want to ﬁnd x ∈ X such
that f
−1
(y) = x, or equivalently, f(x) = y. This implies that 3x −5 = y and
solving for x we ﬁnd x =
y+5
3
. Thus, f
−1
(y) =
y+5
3
128 RELATIONS AND FUNCTIONS
Review Problems
Problem 21.1
a. Deﬁne g : ZZ →ZZ by g(n) = 3n −2.
(i) Is g onetoone? Prove or give a counterexample.
(ii) Is g onto? Prove or give a counterexample.
b. Deﬁne G : IR → IR by G(x) = 3x − 2. Is G onto? Prove or give a
counterexample.
Problem 21.2
Determine whether the function f : IR → IR given by f(x) =
x+1
x
is oneto
one or not.
Problem 21.3
Determine whether the function f : IR →IR given by f(x) =
x
x
2
+1
is oneto
one or not.
Problem 21.4
Let f : IR →ZZ be the ﬂoor function f(x) = x.
a. Is f onetoone? Prove or give a counterexample.
b. Is f onto? Prove or give a counterexample.
Problem 21.5
Let Σ = ¦0, 1¦ and let l : Σ
∗
→IN denote the length function.
a. Is l onetoone? Prove or give a counterexample.
b. Is l onto? Prove or give a counterexample.
Problem 21.6
If : IR →IR and g : IR →IR are onetoone functions, is f +g also onetoone?
Justify your answer.
Problem 21.7
Deﬁne F : {¦a, b, c¦ → IN to be the number of elements of a subset of
{¦a, b, c¦.
a. Is F onetoone? Prove or give a counterexample.
b. Is F onto? Prove or give a counterexample.
Problem 21.8
If : IR → IR and g : IR → IR are onto functions, is f + g also onto? Justify
your answer.
21 BIJECTIVE AND INVERSE FUNCTIONS 129
Problem 21.9
Let Σ = ¦a, b¦ and let l : Σ
∗
→ IN be the length function. Let f : IN →
¦0, 1, 2¦ be the hash function f(n) = n mod 3. Find (f◦l)(abaa), (f◦l)(baaab),
and (f ◦ l)(aaa).
Problem 21.10
Show that the function F
−1
: IR → IR given by F
−1
(y) =
y−2
3
is the inverse
of the function F(x) = 3x + 2.
Problem 21.11
If f : X →Y and g : Y →Z are functions and g ◦ f : X →Z is onetoone,
must both f and g be onetoone? Prove or give a counterexample.
Problem 21.12
If f : X →Y and g : Y →Z are functions and g ◦ f : X →Z is onto, must
both f and g be onto? Prove or give a counterexample.
Problem 21.13
If f : X →Y and g : Y →Z are functions and g ◦ f : X →Z is onetoone,
must f be onetoone? Prove or give a counterexample.
Problem 21.14
If f : X →Y and g : Y →Z are functions and g ◦ f : X →Z is onto, must
g be onto? Prove or give a counterexample.
Problem 21.15
Let f : W →X, g : X →Y and h : Y →Z be functions. Must h ◦ (g ◦ f) =
(h ◦ g) ◦ f? Prove or give a counterexample.
Problem 21.16
Let f : X →Y and g : Y →Z be two bijective functions. Show that (g◦f)
−1
exists and (g ◦ f)
−1
= f
−1
◦ g
−1
.
130 RELATIONS AND FUNCTIONS
22 Recursion
A recurrence relation for a sequence a
0
, a
1
, is a relation that deﬁnes
a
n
in terms of a
0
, a
1
, , a
n−1
. The formula relating a
n
to earlier values in
the sequence is called the generating rule. The assignment of a value to
one of the a’s is called an initial condition.
Example 22.1
The Fibonacci sequence
1, 1, 2, 3, 5,
is a sequence in which every number after the ﬁrst two is the sum of the
preceding two numbers. Find the generating rule and the initial conditions.
Solution.
The initial conditions are a
0
= a
1
= 1 and the generating rule is a
n
=
a
n−1
+a
n−2
, n ≥ 2.
Example 22.2
Let n ≥ 0 and ﬁnd the number s
n
of words from the alphabet Σ = ¦0, 1¦ of
length n not containing the pattern 11 as a subword.
Solution.
Clearly, s
0
= 1(empty word) and s
1
= 2. We will ﬁnd a recurrence relation
for s
n
, n ≥ 2. Any word of length n with letters from Σ begins with either
0 or 1. If the word begins with 0, then the remaining n − 1 letters can be
any sequence of 0’s or 1’s except that 11 cannot happen. If the word begins
with 1 then the next letter must be 0 since 11 can not happen; the remaining
n − 2 letters can be any sequence of 0’s and 1’s with the exception that 11
is not allowed. Thus the above two categories form a partition of the set of
all words of length n with letters from Σ and that do not contain 11. This
implies the recurrence relation
s
n
= s
n−1
+s
n−2
, n ≥ 2
A solution to a recurrence relation is an explicit formula for a
n
in terms of
n.
The most basic method for ﬁnding the solution of a sequence deﬁned recur
sively is by using iteration. The iteration method consists of starting with
the initial values of the sequence and then calculate successive terms of the
22 RECURSION 131
sequence until a pattern is observed. At that point one guesses an explicit
formula for the sequence and then uses mathematical induction to prove its
validity.
Example 22.3
Find a solution for the recurrence relation
a
0
= 1
a
n
= a
n−1
+ 2, n ≥ 1
Solution.
Listing the ﬁrst ﬁve terms of the sequence one ﬁnds
a
0
= 1
a
1
= 1 + 2
a
2
= 1 + 4
a
3
= 1 + 6
a
4
= 1 + 8
Hence, a guess is a
n
= 2n +1, n ≥ 0. It remains to show that this formula is
valid by using mathematical induction.
Basis of induction: For n = 0, a
0
= 1 = 2(0) + 1.
Induction hypothesis: Suppose that a
n
= 2n + 1.
Induction step: We must show that a
n+1
= 2(n+1) +1. By the deﬁnition of
a
n+1
we have a
n+1
= a
n
+ 2 = 2n + 1 + 2 = 2(n + 1) + 1.
Example 22.4
Consider the arithmetic sequence
a
n
= a
n−1
+d, n ≥ 1
where a
0
is the initial value. Find an explicit formula for a
n
.
Solution. Listing the ﬁrst four terms of the sequence after a
0
we ﬁnd
a
1
= a
0
+d
a
2
= a
0
+ 2d
a
3
= a
0
+ 3d
a
4
= a
0
+ 4d
132 RELATIONS AND FUNCTIONS
Hence, a guess is a
n
= a
0
+ nd. Next, we prove the validity of this formula
by induction.
Basis of induction: For n = 0, a
0
= a
0
+ (0)d.
Induction hypothesis: Suppose that a
n
= a
0
+nd.
Induction step: We must show that a
n+1
= a
0
+ (n + 1)d. By the deﬁnition
of a
n+1
we have a
n+1
= a
n
+d = a
0
+nd +d = a
0
+ (n + 1)d.
Example 22.5
Consider the geometric sequence
a
n
= ra
n−1
, n ≥ 1
where a
0
is the initial value. Find an explicit formula for a
n
.
Solution.
Listing the ﬁrst four terms of the sequence after a
0
we ﬁnd
a
1
= ra
0
a
2
= r
2
a
0
a
3
= r
3
a
0
a
4
= r
4
a
0
Hence, a guess is a
n
= r
n
a
0
. Next, we prove the validity of this formula by
induction.
Basis of induction: For n = 0, a
0
= r
0
a
0
.
Induction hypothesis: Suppose that a
n
= r
n
a
0
.
Induction step: We must show that a
n+1
= r
n+1
a
0
. By the deﬁnition of a
n+1
we have a
n+1
= ra
n
= r(r
n
a
0
) = r
n+1
a
0
.
Example 22.6
Find a solution to the recurrence relation
a
0
= 0
a
n
= a
n−1
+ (n −1), n ≥ 1
Solution.
Writing the ﬁrst ﬁve terms of the sequence we ﬁnd
a
0
= 0
a
1
= 0
a
2
= 0 + 1
a
3
= 0 + 1 + 2
a
4
= 0 + 1 + 2 + 3
22 RECURSION 133
A guessing formula is that
a
n
= 0 + 1 + 2 + + (n −1) =
n(n −1)
2
.
We next show that the formula is valid by using induction on n ≥ 0.
Basis of induction: a
0
= 0 =
0(0−1)
2
.
Induction hypothesis: Suppose that a
n
=
n(n−1)
2
.
Induction step: We must show that a
n+1
=
n(n+1)
2
. Indeed,
a
n+1
= a
n
+n
=
n(n−1)
2
+n
=
n(n+1)
2
Example 22.7
Consider the recurrence relation
a
0
= 1
a
n
= 2a
n−1
+n, n ≥ 1
Is it true that a
n
= 2
n
+n is a solution to the given recurrence relation?
Solution.
If so then we must be able to prove its validity by mathematical induction.
Basis of induction: a
0
= 2
0
+ 1.
Induction hypothesis: Suppose that a
n
= 2
n
+n.
Induction step: We must show that a
n+1
= 2
n+1
+(n+1). If this is so then we
will have 2
n+1
+(n+1) = 2a
n
+n = 2
n+1
+2n+n+1. But this would imply
that n = 0 which contradicts the fact that n is any nonnegative integer.
Example 22.8
Deﬁne a sequence, a
1
, a
2
, , recursively as follows:
a
1
= 1
a
n
= 2 a
n
2
, n ≥ 2
a. Use iteration to guess an explicit formula for this sequence.
b. Use induction to prove the validity of the formula found in a.
134 RELATIONS AND FUNCTIONS
Solution.
Computing the ﬁrst few terms of the sequence we ﬁnd
a
1
= 1
a
2
= 2
a
3
= 2
a
4
= 4
a
5
= 4
a
6
= 4
a
7
= 4
a
8
= = a
15
= 8
Hence, for 2
i
≤ n < 2
i+1
, a
n
= 2
i
. Moreover, i ≤ log
2
n < i + 1 so that
i = log
2
n and a formula for a
n
is
a
n
= 2
log
2
n
, n ≥ 1.
b. We prove the above formula by mathematical induction.
Basis of induction: For n = 1, a
1
= 1 = 2
log
2
1
.
Induction hypothesis: Suppose that a
n
= 2
log
2
n
.
Induction step: We must show that a
n+1
= 2
log
2
(n+1)
. Indeed, for n odd
(i.e. n + 1 even) we have
a
n+1
= 2 a
n+1
2
= 2 an+1
2
= 2 2
log
2
n+1
2
= 2
log
2
(n+1)−1+1
= 2
log
2
(n+1)−1+1
= 2
log
2
(n+1)
A similar argument holds when n is even.
When iteration does not apply, other methods are available for ﬁnding ex
plicit formulas for special classes of recursively deﬁned sequences. The method
explained below works for sequences of the form
a
n
= Aa
n−1
+Ba
n−2
(22.1)
22 RECURSION 135
where n is greater than or equal to some ﬁxed nonnegative integer k and A
and B are real numbers with B = 0. Such an equation is called a second
order linear homogeneous recurrence relation with constant coeﬃ
cients.
Example 22.9
Does the Fibonacci sequence satisfy a secondorder linear homogeneous re
lation with constant coeﬃcients?
Solution.
Recall that the Fibonacci sequence is deﬁned recursively by a
n
= a
n−1
+a
n−2
for n ≥ 2 and a
0
= a
1
= 1. Thus, a
n
satisﬁes a secondorder linear homoge
neous relation with A = B = 1.
The following theorem gives a technique for ﬁnding solutions to (22.1).
Theorem 22.1
Equation (22.1) is satisﬁed by the sequence 1, t, t
2
, , t
n
, where t = 0 if
and only if t is a solution to the characteristic equation
t
2
−At −B = 0 (22.2)
Proof.
(=⇒): Suppose that t is a nonzero real number such that the sequence
1, t, t
2
, satisﬁes (22.1). We will show that t satisﬁes the equation t
2
−
At −B = 0. Indeed, for n ≥ k we have
t
n
= At
n−1
+Bt
n−2
.
Since t = 0 we can divide through by t
n−2
and obtain t
2
−At −B = 0.
(⇐=) : Suppose that t is a nonzero real number such that t
2
−At −B = 0.
Multiply both sides of this equation by t
n−2
to obtain
t
n
= At
n−1
+Bt
n−2
.
This says that the sequence 1, t, t
2
, satisﬁes (22.1)
Example 22.10
Consider the recurrence relation
a
n
= a
n−1
+ 2a
n−2
, n ≥ 2.
Find two sequences that satisfy the given generating rule and have the form
1, t, t
2
, .
136 RELATIONS AND FUNCTIONS
Solution.
According to the previous theorem t must satisfy the characteristic equation
t
2
−t −2 = 0.
Solving for t we ﬁnd t = 2 or t = −1. So the two solutions to the given
recurrence sequence are 1, 2, 2
2
, , 2
n
, and 1, −1, , (−1)
n
,
Are there other solutions then the ones provided by Theorem 34.1? The
answer is yes according to the following theorem.
Theorem 22.2
If s
n
and t
n
are solutions to (22.1) then for any real numbers C and D the
sequence
a
n
= Cs
n
+Dt
n
, n ≥ 0
is also a solution.
Proof.
Since s
n
and t
n
are solutions to (22.1), for n ≥ 2 we have
s
n
= As
n−1
+Bs
n−2
t
n
= At
n−1
+Bt
n−2
Therefore,
Aa
n−1
+Ba
n−2
= A(Cs
n−1
+Dt
n−1
) +B(Cs
n−2
+Dt
n−2
)
= C(As
n−1
+Bs
n−2
) +D(At
n−1
+Bt
n−2
)
= Cs
n
+Dt
n
= a
n
so that a
n
satisﬁes (22.1)
Example 22.11
Find a solution to the recurrence relation
a
0
= 1, a
1
= 8
a
n
= a
n−1
+ 2a
n−2
, n ≥ 2.
Solution.
By the previous theorem and Example 22.10, a
n
= C2
n
+D(−1)
n
, n ≥ 2 is
a solution to the recurrence relation
a
n
= a
n−1
+ 2a
n−2
.
22 RECURSION 137
If a
n
satisﬁes the system then we must have
a
0
= C2
0
+D(−1)
0
a
1
= C2
1
+D(−1)
1
This yields the system
C +D = 1
2C −D = 8
Solving this system to ﬁnd C = 3 and D = −2. Hence, a
n
= 3 2
n
−2(−1)
n
.
Example 22.12
Find an explicit formula for the Fibonacci sequence
a
0
= a
1
= 1
a
n
= a
n−1
+a
n−2
Solution.
The roots of the characteristic equation
t
2
−t −1 = 0
are t =
1−
√
5
2
and t =
1+
√
5
2
. Thus,
a
n
= C(
1 +
√
5
2
)
n
+D(
1 −
√
5
2
)
n
is a solution to
a
n
= a
n−1
+a
n−2
.
Using the values of a
0
and a
1
we obtain the system
C +D = 1
C(
1+
√
5
2
) +D(
1−
√
5
2
) = 1.
Solving this system to obtain
C =
1 +
√
5
2
√
5
and D = −
1 −
√
5
2
√
5
.
Hence,
a
n
=
1
√
5
(
1 +
√
5
2
)
n+1
−
1
√
5
(
1 −
√
5
2
)
n+1
Next, we discuss the case when the characteristic equation has a single root.
138 RELATIONS AND FUNCTIONS
Theorem 22.3
Let A and B be real numbers and suppose that the characteristic equation
t
2
−At −B = 0
has a single root r. Then the sequences ¦1, r, r
2
, ¦ and ¦0, r, 2r
2
, 3r
3
, , nr
n
, ¦
both satisfy the recurrence relation
a
n
= Aa
n−1
+Ba
n−2
.
Proof.
Since r is a root to the characteristic equation, the sequence ¦1, r, r
2
, ¦ is
a solution to the recurrence relation
a
n
= Aa
n−1
+Ba
n−2
.
Now, since r is the only solution to the characteristic equation we have
(t −r)
2
= t
2
−At −B.
This implies that A = 2r and B = −r
2
. Let s
n
= nr
n
, n ≥ 0. Then
As
n−1
+Bs
n−2
= A(n −1)r
n−1
+B(n −2)r
n−2
= 2r(n −1)r
n−1
−r
2
(n −2)r
n−2
= 2(n −1)r
n
−(n −2)r
n
= nr
n
= s
n
So s
n
is a solution to a
n
= Aa
n−1
+Ba
n−2
.
Example 22.13
Find an explicit formula for
a
0
= 1, a
1
= 3
a
n
= 4a
n−1
−4a
n−2
, n ≥ 2
Solution.
Solving the characteristic equation
t
2
−4t + 4 = 0
we ﬁnd the single root r = 2. Thus,
a
n
= C2
n
+Dn2
n
22 RECURSION 139
is a solution to the equation a
n
= 4a
n−1
− 4a
n−2
. Since a
0
= 1 and a
1
= 3
then we obtain the following system of equations:
C = 1
2C + 2D = 3
Solving this system to obtain C = 1 and D =
1
2
. Hence, a
n
= 2
n
+
n
2
2
n
.
Example 22.14
Let A
1
, A
2
, , A
n
be subsets of a set S.
a. Give a recursion deﬁnition for ∪
n
i=1
A
i
.
b. Give a recursion deﬁnition for ∩
n
i=1
A
i
.
Solution.
a. ∪
1
i=1
A
i
= A
1
and ∪
n
i=1
A
i
= (∪
n−1
i=1
A
i
) ∪ A
n
, n ≥ 2.
b. ∩
1
i=1
A
i
= A
1
and ∩
n
i=1
A
i
= (∩
n−1
i=1
A
i
) ∩ A
n
, n ≥ 2.
Example 22.15
Use mathematical induction to prove the following generalized De Morgan’s
law.
(∪
n
i=1
A
i
)
c
= ∩
n
i=1
A
c
i
Solution.
Basis of induction: (∪
1
i=1
A
i
)
c
= A
c
i
= ∩
1
i=1
A
c
i
.
Induction hypothesis: Suppose that (∪
n
i=1
A
i
)
c
= ∩
n
i=1
A
c
i
.
Induction step: We must show that (∪
n+1
i=1
A
i
)
c
= ∩
n+1
i=1
A
c
i
. Indeed,
(∪
n+1
i=1
A
i
)
c
= ((∪
n
i=1
A
i
) ∪ A
n+1
)
c
= (∪
n
i=1
A
i
)
c
) ∩ A
c
n+1
= (∩
n
i=1
A
c
i
) ∩ A
c
n+1
= ∩
n+1
i=1
A
c
i
Example 22.16
Let a
1
, a
2
, , a
n
be numbers.
a. Give a recursion deﬁnition for
¸
n
i=1
a
i
.
b. Give a recursion deﬁnition for Π
n
i=1
a
i
.
Solution.
a.
¸
1
i=1
a
i
= a
1
and
¸
n
i=1
a
i
= (
¸
n−1
i=1
a
i
) +a
n
, n ≥ 2.
b. Π
1
i=1
a
i
= a
1
and Π
n
i=1
a
i
= (Π
n−1
i=1
a
i
) a
n
, n ≥ 2.
140 RELATIONS AND FUNCTIONS
Example 22.17
A function is said to be deﬁned recursively or to be a recursive function
if its rule of deﬁnition refers to itself. Deﬁne the factorial function recursively.
Solution.
f(0) = 1
f(n) = nf(n −1), n ≥ 1.
Example 22.18
Let G : IN →ZZ be the relation given by
G(n) =
1, if n = 1
1 +G(
n
2
), if n is even
G(3n −1), if n > 1 is odd
Show that G is not a function.
Solution.
Assume that G is a function so that G(5) exists. Listing the ﬁrst ﬁve values
of G we ﬁnd
G(1) = 1
G(2) = 2
G(3) = G(8) = 1 +G(4) = 2 +G(2) = 4
G(4) = 1 +G(2) = 3
G(5) = G(14) = 1 +G(7)
= 1 +G(20)
= 2 +G(10)
= 3 +G(5)
But the last equality implies that 0 = 3 which is impossible. Hence, G does
not deﬁne a function.
22 RECURSION 141
Review Problems
Problem 22.1
Find the ﬁrst four terms of the following recursively deﬁned sequence:
v
1
= 1, v
2
= 2
v
n
= v
n−1
+v
n−2
+ 1, n ≥ 3
Problem 22.2
Prove each of the following for the Fibonacci sequence:
a. F
2
k
−F
2
k−1
= F
k
F
k+1
−F
k+1
F
k−1
, k ≥ 1.
b. F
2
k+1
−F
2
k
−F
2
k−1
= 2F
k
F
k−1
, k ≥ 1.
c. F
2
k+1
−F
2
k
= F
k−1
F
k+2
, k ≤ 1.
d. F
n+2
F
n
−F
2
n+1
= (−1)
n
for all n ≥ 0.
Problem 22.3
Find lim
n→∞
F
n+1
Fn
where F
0
, F
1
, F
2
, is the Fibonacci sequence. (Assume
that the limit exists.)
Problem 22.4
Deﬁne x
0
, x
1
, x
2
, as follows:
x
n
=
2 +x
n−1
, x
0
= 0.
Find lim
n→∞
x
n
.
Problem 22.5
a. Make a list of all bit strings of lengths zero, one, two, three, and four that
do not contain the pattern 111.
b. For each n ≥ 0 let d
n
= the number of bit strings of length n that do not
contain the bit pattern 111. Find d
0
, d
1
, d
2
, d
3
, and d
4
.
c. Find a recurrence relation for d
0
, d
1
, d
2
,
d. Use the results of (b) of (c) to ﬁnd the number of bit strings of length ﬁve
that do not contain the pattern 111.
Problem 22.6
Find a formula for each of the following sums:
a. 1 + 2 + + (n −1), n ≥ 2.
b. 3 + 2 + 4 + 6 + 8 + + 2n, n ≥ 1.
c. 3 1 + 3 2 + 3 3 + 3 n, n ≥ 1.
142 RELATIONS AND FUNCTIONS
Problem 22.7
Find a formula for each of the following sums:
a. 1 + 2 + 2
2
+ + 2
n−1
, n ≥ 1.
b. 3
n−1
+ 3
n−2
+ + 3
2
+ 3 + 1, n ≥ 1.
c. 2
n
+ 3 2
n−2
+ 3 2
n−3
+ + 3 2
2
+ 3 2 + 3, n ≥ 1.
d. 2
n
−2
n−1
+ 2
n−2
−2
n−3
+ + (−1)
n−1
2 + (−1)
n
, n ≥ 1.
Problem 22.8
Use iteration to guess a formula for the following recusively deﬁned sequence
and then use mathematical induction to prove the validity of your formula:
c
1
= 1, c
n
= 3c
n−1
+ 1, for all n ≥ 2.
Problem 22.9
Use iteration to guess a formula for the following recusively deﬁned sequence
and then use mathematical induction to prove the validity of your formula:
w
0
= 1, w
n
= 2
n
−w
n−1
, for all n ≥ 2.
Problem 22.10
Determine whether the recursively deﬁned sequence: a
1
= 0 and a
n
= 2a
n−1
+
n −1 satisﬁes the explicit formula a
n
= (n −1)
2
, n ≥ 1.
Problem 22.11
Which of the following are secondorder homogeneous recurrence relations
with constant coeﬃcients?
a. a
n
= 2a
n−1
−5a
n−2
.
b. b
n
= nb
n−1
+b
n−2
.
c. c
n
= 3c
n−1
c
2
n−2
.
d. d
n
= 3d
n−1
+d
n−2
.
e. r
n
= r
n−1
−r
n−2
−2.
f. s
n
= 10s
n−2
.
Problem 22.12
Let a
0
, a
1
, a
2
, be the sequence deﬁned by the explicit formula
a
n
= C 2
n
+D, n ≥ 0
where C and D are real numbers.
a. Find C and D so that a
0
= 1 and a
1
= 3. What is a
2
in this case?
b. Find C and D so that a
0
= 0 and a
1
= 2. What is a
2
in this case?
22 RECURSION 143
Problem 22.13
Let a
0
, a
1
, a
2
, be the sequence deﬁned by the explicit formula
a
n
= C 2
n
+D, n ≥ 0
where C and D are real numbers. Show that for any choice of C and D,
a
n
= 3a
n−1
−2a
n−2
, n ≥ 2.
Problem 22.14
Let a
0
, a
1
, a
2
, be the sequence deﬁned by the explicit formula
a
0
= 1, a
1
= 2
a
n
= 2a
n−1
+ 3a
n−2
, n ≥ 2
Find an explicit formula for the sequence.
Problem 22.15
Let a
0
, a
1
, a
2
, be the sequence deﬁned by the explicit formula
a
0
= 1, a
1
= 4
a
n
= 2a
n−1
−a
n−2
, n ≥ 2
Find an explicit formula for the sequence.
Problem 22.16
The triangle inequality for absolute value states that for all real numbers a
and b, [a+b[ ≤ [a[+[b[. Use the recursive deﬁnition of summation, the triangle
inequality, the deﬁnition of absolute value, and mathematical induction to
prove that for all positive integers n, if a
1
, a
2
, , a
n
are real numbers then
[
n
¸
k=1
a
k
[ ≤
n
¸
k=1
[a
k
[.
Problem 22.17
Use the recursive deﬁnition of union and intersection to prove the following
general distributive law: For all positive integers n, if A and B
1
, B
2
, , B
n
are sets then
A ∩ (∪
n
k=1
B
k
) = ∪
n
k=1
(A ∩ B
k
).
144 RELATIONS AND FUNCTIONS
Problem 22.18
Use mathematical induction to prove the following generalized De Morgan’s
law.
(∩
n
i=1
A
i
)
c
= ∪
n
i=1
A
c
i
Exercise 367
Show that the relation F : IN →ZZ given by the rule
F(n) =
1 if n = 1.
F(
n
2
) if n is even
1 −F(5n −9) if n is odd and n > 1
does not deﬁne a function.
23 PROJECT VII: APPLICATIONS TO RELATIONS 145
23 Project VII: Applications to Relations
Part I: Relational Database
The ”bi” in binary relation R refers to the fact that R is a subset of the
cartesian product of two sets. Let A
1
, A
2
, , A
n
be given sets. If R is a
subset of A
1
A
2
A
n
then we call R an nary relation. An nary
relation can be represented by a table or a set of ordered ntuples.
Example 23.1
ID# Name Position Age
22012 Johnsonbaugh c 22
93831 Glover of 24
58199 Battey p 18
84341 Cage c 30
01180 Homer lb 37
26710 Score p 22
61049 Johnsonbaugh of 30
39826 Singleton 2b 31
A database is a collection of records that are manipulated by a computer.
Database management systems are programs that help users access the
information in databases. The relational database model is based on the
concept of an nary relation.
When an nary relation is represented by a table then the columns in this ta
ble are called attributes. In the above table, the attributes are ID Number,
Name, Position, and Age. A single attribute or a combination of attributes
for a relation is called a key if the values of the attributes uniquely deﬁne
an ntuple. For example, in the above table, we can take the attribute ID
Number as a key since every person has a unique identiﬁcation number. The
attribute Name is not a key because diﬀerent persons can have the same
name. For the same reason, we cannot take the attribute Age as a key. A
database management system responds to queries. A query is a request for
information from the database. For example, ”Find all persons that are 22
years old”.
146 RELATIONS AND FUNCTIONS
Problem 23.1
a. Express the above 4ary as a set of 4tuples.
b. Answer the query: PLAYER[Name]
c. Answer the query: PLAYER[Name, Position]
Part II: Representing a Relation by a Matrix.
Let A be a set with n elements and R be a binary relation on A. Deﬁne
the n n matrix M(R) = (m
ij
) as follows:
m
ij
=
1 if (a
i
, b
j
) ∈ R
0 if (a
i
, b
j
) ∈ R
If the numbers on the main diagonal of M(R) are all equal to 1 then R is
reﬂexive. If M(R)
T
= M(R), where M(R)
T
is the transpose of M(R), then
the relation R is symmetric. If m
ij
= 0 or m
ji
= 0 for i = j then R is
antisymmetric.
Problem 23.2
Let A = ¦1, 2, 3¦ and R = ¦(1, 1), (1, 2), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)¦.
Find M(R) and use it to determine if the relation R is reﬂexive, symmetric
or antisymmetric.
Part III: Cryptology
An important application to congruences is cryptology, which is the study of
secret messages.
(a) The process of making a message secret is called encryption. This
process consists of assigning the alphabet A, B, C, , Z by the integers
0, 1, 2, , 25. Then the encrypted version of the message, the letter rep
resented by p is replaced with the letter represented by the remainder of the
division of (p + 3) by 26.
Problem 23.3
What is the encrypted message produced from the message ”MEET YOU
IN THE PARK”?
(b) Decryption is the process of determining the original message. In this
case the letter represented by p is replaced by the letter represented by the
remainder of the division of (p −3) by 26.
23 PROJECT VII: APPLICATIONS TO RELATIONS 147
Problem 23.4
What is the message produced from the encrypted message ”PHHW BRX
LQ WKH SDUN”?
148 RELATIONS AND FUNCTIONS
24 Project VIII: WellOrdered Sets and Lat
tices
Let [A, ≤] be a poset. Let B ⊆ A. An element b ∈ B is called a least
element of B if and only if b ≤ x for all x ∈ B. If x ≥ b for all x ∈ B then
we call b the greatest element of B.
Problem 24.1
Consider the set IN with the inequality relation ≤ . Let B = ¦2, 4, 5, 6, 7, 8, 9¦.
What is the least element of B? What is the greatest element of B?
A poset [A, ≤] is said to be wellordered if and only if ≤ is a total order
and every subset of A has a least element.
Problem 24.2
a. Show that (IN, ≤) is wellordered.
b. Show that (ZZ, ≤) is not wellordered.
An element a ∈ A is called a lower bound of B if a ≤ x for all x ∈ B. We
call a ∈ A an upper bound of B if x ≤ a for all x ∈ B. Note that a lower
bound or an upper bound is not unique.
Problem 24.3
Consider the poset [IN, ≤]. Let B = ¦2, 4, 8, 10¦. Find a lower bound of B as
well as an upper bound.
The greatest element of the set of lower bounds of B is called the greatest
lower bound, in symbol g.l.b(B). The least upper bound of the set of upper
bounds of B is called the least upper bound, in symbol l.u.b(B).
Problem 24.4
Consider the poset [IR, ≤] and B = (−1, 1). Find g.l.b(B) and l.u.b(B).
A lattice is a poset [A, ≤] such that every pair of elements in A have a l.u.b
and g.l.b in A.
Problem 24.5
Show that [IR, ≤] is a lattice.
Problem 24.6
Let A = ¦2, 3, 4, 9, 12, 18¦ and R be the binary relation ”divides” on A. Show
that [A, R] is not a lattice.
25 PROJECT IX: THE PIGEONHOLE PRINCIPLE 149
25 Project IX: The Pigeonhole Principle
The Pigeonhole principle asserts that if n pigeons ﬂy into k holes with
n > k then some of the pigeonholes contain at least two pigeons. The
reason this statement is true can be seen by arguing by contradiction. If the
conclusion is false, each pigeonhole contains at most one pigeon and, in this
case, we can account for at most k pigeons. Since there are more pigeons
than holes, we have a contradiction.
Problem 25.1
Ten persons have ﬁrst names George, William, and Laura and last names
Bush, Perry, and Gramm. Show that at least two persons have the same
ﬁrst and last names.
A mathematical way to formulate the pigeonhole principle is given by the
following exercise
Problem 25.2
Let S be a ﬁnite set and ¦A
1
, A
2
, , A
n
¦ be a partition of S. Use the method
of contradiction to show that there is an index 1 ≤ i ≤ n such that [A
i
[ ≥
S
n
.
One can uses the previous exercise to solve the following exercise.
Problem 25.3
Let S and T be two ﬁnite sets such that [S[ > k[T[ where k is a positive
integer. Show that for any function f : S →T there is a t ∈ T such that the
set ¦s ∈ S : f(s) = t¦ has more than k elements.
Hint: Show that the family A
t
= ¦s ∈ S : f(s) = t¦, where t ∈ T, partitions
S into n sets with n ≤ [T[. Then apply the previous exercise.
As a consequence of the above exercise we have
Problem 25.4
If S and T are ﬁnite sets such that [S[ > [T[ then any function f : S →T is
not onetoone.
150 RELATIONS AND FUNCTIONS
26 Project X: Countable Sets
We say that two sets have the same cardinality if and only if there is a
bijective function between them. A set A is called countably inﬁnite if
and only if A has the same cardinality as the set IN
∗
of positive integers. A
set A is called countable if it is either ﬁnite or countably inﬁnite. A set
that is not countable is said to be uncountable. Examples of uncountable
sets are IR and the intervals in IR..
The purpose of this project is to look at some countably inﬁnite sets.
Problem 26.1
Show that the function f : IN
∗
→ IN given by f(n) = n − 1 is a bijective
function. Thus, IN is countably inﬁnite.
Problem 26.2
Show that the function f : IN
∗
→ZZ deﬁned by
f(n) =
n
2
if n is even
1−n
2
if n is odd
is bijective. Hence, ZZ is countably inﬁnite.
Problem 26.3
Show that the function f : ZZ → 2ZZ deﬁned by f(n) = 2n is a bijective
function. Hence, the set of even integers is countably inﬁnite.
Problem 26.4
Show that the set of rational numbers I Q is countably inﬁnite. (Hint:
26 PROJECT X: COUNTABLE SETS 151
)
152 RELATIONS AND FUNCTIONS
27 Project XI: FiniteState Automaton
A ﬁnitestate machine can be looked at as a mathematical model that can
accept input, store and process information and produce output. Examples
include digital computers, compilers, vending machines, coin changers, tele
phones, and elevators.
This model has an input/output unit, and, consequently, has a way of com
municating with the world using a set of symbols. Let I be the set of input
symbols and O, the set of output symbols. In the case of an elevator I might
be up, down, and ﬂoor selection, while O might be stops on particular ﬂoors.
Besides input and output symbols, there is a set of states S for our model. A
state is like a snapshot of what is happening in the machine at a particular
instant. An elevator might be in a state of going down to the ﬁrst ﬂoor to
pick up a passenger or in a state of stopping on the third ﬂoor on the way
up to the ﬁfth ﬂoor. There are always an intial state of our model, denoted
by s
0
, and ﬁnal or accepting state(s).
Also, our model has a function, called the next state function. This function
returns the next state based on the present state and input. For instance, if
the elevator is in the state of moving up to the ﬁfth ﬂoor and has an input
of someone pressing the down button on the third ﬂoor, it goes to a state
that says,” Remember, when coming back down from stopping and picking
someone on the third ﬂoor.”
The above discussion is formalized as follows:
A ﬁnitestate automaton A consists of ﬁve objects:
1. a set I, called the input alphabet, of input symbols;
2. a set O, called the output alphabet, of output symbols;
3. a set S of states the machine can be in;
4. a subset of S whose elements are called accepting states;
5. a nextstate function or transition function N : S I → S. If s ∈ S
and m ∈ I then N(s, m) is the state to which A goes if m is input to A when
A is in state s. The initial state of the machine is s
0
.
The operation of a ﬁnitestate machine is commomly described by a dia
gram called a transition diagram. The edges labeled with inputs and
nodes with states. A double circle stands for the ﬁnal or accepting state(s).
Problem 27.1
Consider the ﬁnitestate automaton deﬁned by the transition diagram
27 PROJECT XI: FINITESTATE AUTOMATON 153
a. What are the elements of S?
b. What are the input symbols?
c. What is the initial state?
d. What are the accepting states?
e. Find N(s
3
, 1) and N(s
3
, 0).
Let A be a ﬁnitestate automaton with input alphabet I. Let I
∗
be the set
of all words with letters from I. A word w ∈ I
∗
is said to be accepted by
A if, and only if, A goes to an accepting state when the symbols of w are
input to A in sequence starting when A is in its initial state. The language
accepted by A, denoted by L(A), is the set of all words that are accepted
by A.
Problem 27.2
Consider the ﬁnitestate automaton deﬁned by the following transition dia
gram
154 RELATIONS AND FUNCTIONS
a. To what states does A go if the symbols of the following words are input
to A in sequence starting from the initial state?
(i) 1101 (ii) 0011 (iii) 0101010.
b. Which of the words in part (a) send A to an accepting state?
c. Show that L(A) = ¦0(10)
n
: n ≥ 0¦ where (10)
n
= 1010 with n copies
of 10 juxtaposed into one word.
Let A be a ﬁnitestate automaton with input alphabet I and states S. Let
N
∗
: S I
∗
→S be the function deﬁned as follows: N
∗
(s, w) is the state to
which A goes if the symbols of w are input to A in sequence starting when
A is in state s. We call N
∗
the eventual state function.
Problem 27.3
A ﬁnitestate automaton A, given by the transition diagram below, has tran
sition function N and eventualstate functioin N
∗
.
27 PROJECT XI: FINITESTATE AUTOMATON 155
a. Find N(s
2
, 0) and N(s
1
, 0).
b. Find N
∗
(s
2
, 11010) and N
∗
(s
0
, 01000).
Problem 27.4
Design a ﬁnitestate machine that recognizes words of the form 01, 011, 0111, 01111, .
156 RELATIONS AND FUNCTIONS
Introduction to the Analysis of
Algorithms
Informally, an algorithm is any welldeﬁned computational procedure that
takes a set of values as input and produces a set of values as output.
The subject of the analysis of algorithms consists of the study of eﬃciency of
algorithms. Two aspects of the algorithm eﬃciency are: the amount of time
required to execute the algorithm and the memory space it consumes. In this
chapter we introduce the basic techniques for calculating time eﬃciency.
28 Time Complexity and ONotation
The primary eﬃciency criterion for analyzing the eﬃciency of an algorithm
is the running time of the algorithm as a function of the number of values
it processes. The running time of an algorithm is not measured by counting
the minutes and seconds for the algorithm written in a particular language
and running on a particular machine. Rather it is deﬁned to be an estimate
of the number of operations performed by the algorithm given a particular
number of input values.
Generally, given an algorithm that performs a task, we will be interested in
estimating the running time as a function of the problem size. For example,
let us consider the sequential search of an item X from a list of n items.
Here, we say that the problem size is n. Let T(n) be a measure of the time
required to execute an algorithm of problem size n. We call T(n) the time
complexity function of the algorithm. If n is suﬃciently small then the
algorithm will not have a long running time. Thus, the interesting question
is:”How fast T(n) increases as n increases?” This is called the asymptotic
behavior of the time complexity function.
In our time analysis we will restrict ourselves to the worst case behavior of
157
158 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
an algorithm; that is, the longest running time for any input of size n.
Since we are considering asymptotic eﬃciency of algorithms, basically we will
be focusing on the leading term of T(n). For example, if T(n) = 4n
3
−2n
2
+
n +5 then T(n) = n
3
(4 −
2
n
+
1
n
+
5
n
) and for large n we have T(n) ∼ n
3
. We
say that T(n) has a growth of order n
3
.
We say that one algorithm is more eﬃcient then another if its worse case
running time has a lower order of growth.
Example 28.1
Estimate the time complexity of the following algorithm:
i := 1
p := 1
for i := 1 to n
p := p i
i := i + 1
next i
Solution.
Prior to entering the loop, it takes two assignment statements to initialize
the variables i and p. The loop is executed n times, and each time it executes
the two assignment statements in the body of the loop with a total of two
arithmetic operations. Thus, the time complexity of the algorithm is given
by
T(n) = 4n + 2
so the growth is of order n.
Example 28.2
What is the runtime complexity based on n for the following program sege
ment:
for i := 1 To n
for j := 1 To n
A(i,j) := x
next j
next i
Solution.
The inner loop is executed n times and the outer loop also is executed n
28 TIME COMPLEXITY AND ONOTATION 159
times. Hence, T(n) = n
2
so that the growth is of order n
2
.
In the above two problems we found a precise expression for the time com
plexity of the algorithm. What usually interests us is the order of growth.
We next introduce some of the concepts of growth orders. Let g : IN → IR.
We deﬁne the set
O(g(n)) = ¦f(n) : there exists positive constants n
0
and C such that
[f(n)[ ≤ C[g(n)[, for n ≥ n
0
¦.
We say that a function f is order at most g or f bigoh of g if and
only if f(n) ∈ O(g(n)). Sometimes We write f(n) = O(g(n)). Graphically,
this means that for n ≥ n
0
the graph of f is below the graph of g.
Example 28.3
Show that the time complexity found in Exercise 390 is O(n).
Solution.
To show that T(n) = O(n) we must produce constants C and n
0
such that
T(n) ≤ Cn for n ≥ n
0
. Indeed, T(n) ≤ 5n for n ≥ 2 so that n
0
= 2 and
C = 5.
Example 28.4
Show that the runtime complexity based on n for the following program
segement is O(n
2
).
s := 0
for i := 1 To n
for j := 1 To i
s := s +j (i −j + 1)
next j
next i
Solution.
Prior to entering the loop there is one assignment statement. Now, there are
two additions, one subtraction, one multiplication and one assignment for
each iteration of the inner loop. The total number of time the inner loop is
executed is
1 + 2 + 3 + +n =
n(n + 1)
2
160 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
Hence, T(n) = 5
n(n+1)
2
+1 ≤ 5n
2
, n ≥ 1 so that C = 5 and n
0
= 1. Hence,
T(n) ∈ O(n
2
).
We say that a function f is of polynomial complexity if and only if
f ∈ O(n
p
) for some p ∈ IN. If p = 0 then we say that f is of constant
complexity. If p = 1 we say that the complexity is linear.
Example 28.5
Show that
1 + 2 + 3 + +n = O(n
2
).
Solution.
Indeed, since n ≥ 1 then
1 + 2 + 3 + +n ≤ n +n +n + +n = n
2
so that C = 1 and n
0
= 1.
Example 28.6
Show that n
3
∈ O(n
2
).
Solution.
We proceed by contradiction. Suppose that n
3
∈ O(n
2
). Then there exist
constants C and n
0
such that n
3
≤ Cn for all n ≥ n
0
. Dividing through by
n
2
to obtain n ≤ C. This leads to a contradiction since the lefthand side can
be made as large as we please whereas the righthand side is constant.
Example 28.7
Show that if f(n) ∈ O(g(n)) and g(n) ∈ O(h(n)) then f(n) ∈ O(h(n)).
Solution.
Since f(n) ∈ O(g(n)), there exist n
1
and C
1
such that [f(n)[ ≤ C
1
[g(n)[ for all
n ≥ n
1
. Similarly, there exist constants C
2
and n
2
such that [g(n)[ ≤ C
2
[h(n)[
for all n ≥ n
2
. Let n
0
= max¦n
1
, n
2
¦ and C = C
1
C
2
. Then for n ≥ n
0
we
have
[f(n)[ ≤ C
1
[g(n)[ ≤ C
1
C
2
[h(n)[ = C[h(n)[
28 TIME COMPLEXITY AND ONOTATION 161
Example 28.8
Suppose we want to arrange the elements of a one dimensional array a[1], a[2], , a[n]
in increasing order. An insertion sort compares every pair of elements,
switching the values of those that are out of order, a[i −1] > a[i].
a. How many possible pairs are compared?
b. What is the maximum number of exchanges?
c. What time the complexity of this algorithm in the worst case?
d. Is this a polynomialtime algorithm?
Solution.
a. The number of possible pairs to compare in the algorithm is
1 + 2 + + (n −1) =
n(n −1)
2
.
b. From part a. it follows that the maximum number of exchanges is
n(n−1)
2
.
c. T(n) =
n(n−1)
2
.
d. For n ≥ 1, T(n) ≤
n
2
2
so that T(n) ∈ O(n
2
).
Next, we recall the following deﬁnition from calculus. If L = lim
x→∞
f(x)
then for any > 0 there is a positive integer N such that [f(x) − L[ <
whenever n ≥ N.
Using this deﬁnition, we have the following important theorem.
Theorem 28.1
Suppose that lim
n→∞
f(n)
g(n)
= L with L ≥ 0. Then f(n) ∈ O(g(n)). Moreover,
a. if L > 0 then g(n) ∈ O(f(n)), and
b. if L = 0 then g(n) ∈ O(f(n)).
Proof.
Let = 1. Then there is a positive integer n
0
such that [
f(n)
g(n)
−L[ < 1 whenever
n ≥ n
0
. This implies that [
f(n)
g(n)
[ < 1 +L for n ≥ n
0
. Hence, [f(n)[ < C[g(n)[
where C = (1 +L) and n ≥ n
0
. But this is just saying that f(n) ∈ O(g(n)).
a. Now, suppose that L > 0. Then lim
n→∞
g(n)
f(n)
=
1
L
. Interchange the roles
of f and g in the previous argument to ﬁnd that [g(n)[ < C[f(n)[ where
C = 1 +
1
L
and n ≥ n
0
for some positive integer n
0
. Hence, g(n) ∈ O(f(n)).
b. Now suppose that L = 0. We use contradiction to show that g(n) ∈
O(f(n)). So suppose that g(n) ∈ O(f(n)). Then there exist positive constants
162 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
C and M
1
such that [g(n)[ ≤ C[f(n)[ for all n ≥ M
1
. On the other hand, by
letting =
1
C
we can ﬁnd a positive integer M
2
such that [
f(n)
g(n)
[ < whenever
n ≥ M
2
. Let n
0
= max¦M
1
, M
2
¦. Then for n ≥ n
0
we have
C < [
g(n)
f(n)
[ ≤ C
which is a contradiction. Hence, we must have g(n) ∈ O(f(n)).
28 TIME COMPLEXITY AND ONOTATION 163
Review Problems
Problem 28.1
Find the worst case running time of the following segment of an algorithm:
for i := 1 to n
for j := 1 to
i+1
2

a := (n −i) (n −j)
next j
next i
Problem 28.2
Find the worst case running time of the following segment of an algorithm:
for i := 1 to n
for j := 1 to 2n
for k := 1 to n
x := i j k
next k
next j
next i
Problem 28.3
Construct a table showing the result of each step when insertion sort is
applied to the array a[1] = 6, a[2] = 2, a[3] = 1, a[4] = 8, a[5] = 4.
Problem 28.4
How many comparisons actually occur when insertion sort is applied to the
array of the previous exercise?
Problem 28.5
Selection sort is another algorithm for arranging the elements of a one
dimensional array a[1], a[2], , a[n] in increasing order. The sorting works
by selecting the smallest item in the list, moving it to the front of the list,
and then ﬁnding the smallest of the remaining items and moving it to the
second position in the list, and so on. When two items in the list, say a[k]
and a[m], have to be interchanged, we write switch(a[k], a[m]). The following
is the selection algorithm:
for i := 1 to n −1
164 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
min := i
for j := i + 1 to n
if a[min] > a[j] then
switch(a[min], a[i])
next j
next i
Construct a table showing the result of each step when selection sort is ap
plied to the array a[1] = 5, a[2] = 3, a[3] = 4, a[4] = 6, a[5] = 2.
Problem 28.6
How many comparisons actually occur when selection sort is applied to the
array of the previous exercise?
Problem 28.7
Show that
√
n ∈ O(
√
n).
Problem 28.8
Show that
1
2
+ 2
2
+ +n
2
∈ O(n
3
).
Problem 28.9
Show that
1
3
+ 2
3
+ +n
3
∈ O(n
4
).
Problem 28.10
a. Use mathematical induction to show that
1
1
3
+ 2
1
3
+ +n
1
3
≤ n
4
3
for all n ≥ 1.
b. What can you conclude from part (a) about the order of the above sum?
29 LOGARITHMIC AND EXPONENTIAL COMPLEXITIES 165
29 Logarithmic and Exponential Complexities
In this section we assume that the reader is familiar with the deﬁnitions and
rules of both exponential and logarithmic functions. Unless explicitly stated,
all logarithms in this chapter are to base 2 mainly because of the following
theorem
Theorem 29.1
For any a > 1, O(log
a
n) = O(log
2
n).
Proof.
We must show that there exist constants C
1
, C
2
and n
0
such that log
a
n ≤
C
1
log
2
n and log
2
n ≤ C
2
log
a
n for all n ≥ n
0
. By the change of bases formula
we have
log
a
n =
log
2
n
log
2
a
.
Now, let C
1
=
1
log
2
a
, C
2
= log
2
a, and n
0
= 1.
If f(n) ∈ O(log
2
n) we say that f(n) has logarithmic complexity. A function
f(n) is said to be of exponential complexity if and only if f(n) ∈ O(a
n
)
for some a > 1.
Example 29.1
Show that n +nlog
2
n ∈ O(nlog
2
n).
Solution.
Since lim
n→∞
n
nlog
2
n
= 0, there is a positive integer n
0
such that n < nlog
2
n
for all n ≥ n
0
. Thus,n+nlog
2
n < 2nlog
2
n = Cnlog
2
n, n ≥ n
0
. This shows
that n +nlog
2
n ∈ O(nlog
2
n).
Example 29.2
a. Show that n! = O(n
n
).
b. Show that n = O(2
n
).
c. Use b. to show that log
2
n = O(n).
Solution.
a. Since n −i ≤ n for 0 ≤ i ≤ n we have
n! = n(n −1)(n −2) 2 1
≤ n n n n n = n
n
166 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
It follows that n! = O(n
n
).
b. We show by induction on n ≥ 0 that n ≤ 2
n
.
Basis of induction: For n = 0 we have 0 ≤ 2
0
.
Induction hypothesis: Suppose that n ≤ 2
n
.
Induction step: We must show that n + 1 ≤ 2
n+1
. Indeed,
n + 1 ≤ n +n
≤ 2
n
+ 2
n
= 2
n+1
Hence, n = O(2
n
).
c. Take the logarithm of both sides of b. to obtain log
2
n ≤ n, n ≥ 1. That
is, log
2
n = O(n).
Example 29.3
a. Show that log
2
n! = O(nlog
2
n).
b. Show that nlog
2
n = O(log
2
n!).
Solution.
a. We have shown that n! = O(n
n
). That is, n! ≤ n
n
for n ≥ 1. Take loga
rithm of both sides to obtain log
2
n! ≤ nlog
2
n. That is, log
2
n! = O(nlog
2
n).
b. It is easy to see that (n −i)(i + 1) ≥ n for all 0 ≤ i ≤ n −1. In this case
(n!)
2
= [n (n −1) 2 1][1 2 (n −1) n]
= (n 1)[(n −1) 2] [2 (n −1)](1 n)
≥ n n n n
= n
n
.
Now take the logarithm of both sides to obtain nlog
2
n ≤ 2 log
2
n!. That is,
nlog
2
n = O(log
2
n!).
Example 29.4
a. Show that if f
1
(n) ∈ O(g(n)) and f
2
(n) ∈ O(g(n)) then f
1
(n) + f
2
(n) ∈
O(g(n)).
b. Show that if f
1
(n) ∈ O(g
1
(n)) and f
2
(n) ∈ O(g
2
(n)) then f
1
(n) f
2
(n) ∈
O(g
1
(n) g
2
(n)).
c. Use a. and b. to show that
3nlog
2
n! + (n
2
+ 3) log
2
n = O(n
2
log
2
n).
29 LOGARITHMIC AND EXPONENTIAL COMPLEXITIES 167
Solution.
a. Since f
1
(n) ∈ O(g(n)) then there exist n
1
and C
1
such that [f
1
(n)[ ≤
C
1
[g(n)[ for all n ≥ n
1
. Similarly, there exist constants C
2
and n
2
such that
[f
2
(n)[ ≤ C
2
[g(n)[ for all n ≥ n
2
. Let n
0
= max¦n
1
, n
2
¦ and C = C
1
+ C
2
.
Then for n ≥ n
0
we have
[f
1
(n) +f
2
(n)[ ≤ C
1
[g(n)[ +C
2
[g(n)[ = C[g(n)[.
b. Now since f
1
(n) ∈ O(g
1
(n)), there exist n
1
and C
1
such that [f
1
(n)[ ≤
C
1
[g
1
(n)[ for all n ≥ n
1
. Similarly, there exist constants C
2
and n
2
such that
[f
2
(n)[ ≤ C
2
[g
2
(n)[ for all n ≥ n
2
. Let n
0
= max¦n
1
, n
2
¦ and C = C
1
C
2
.
Then for n ≥ n
0
we have
[f
1
(n) f
2
(n)[ ≤ C[g
1
(n)g
2
(n)[.
c. Using b. above and a. of the previous exercise we have 3nlog
2
n! =
O(n
2
log
2
n). Since (n
2
+3) log
2
n = O(n
2
log
2
n) then by a. and b. the result
follows.
168 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
Review Problems
Problem 29.1
Show that 1 + 2 + 2
2
+ + 2
n
∈ O(2
n+1
).
Problem 29.2
Show that
2n
3
+
2n
3
2
+
2n
3
3
+ +
2n
3
n
∈ O(n).
Problem 29.3
Show that n
2
+ 2n ∈ O(2
n
).
Problem 29.4
a. Show that
1
2
+
1
3
+ +
1
n
≤ ln n, n ≥ 2.
b. Use part a. to show that for n ≥ 3
1 +
1
2
+ +
1
n
≤ ln n.
c. Use b. to show that n +
n
2
+
n
3
+ +
n
n
∈ O(nln n).
Problem 29.5
Show that 2
n
∈ O(n!).
30 Θ AND ΩNOTATIONS 169
30 Θ and ΩNotations
The Onotation asymptotically bounds a function from above. When we
have bounds from above and below, we use Θ notation. For a given function
g(n), we denote by Θ(g(n)) to be the set of all functions f such that there
exist positive constants C
1
, C
2
, and n
0
such that C
1
[g(n)[ ≤ [f(n)[ ≤ C
2
[g(n)[
for all n ≥ n
0
. If f ∈ Θ(g(n)) we write f(n) = Θ(g(n)).
Example 30.1
Show that
1
2
n
2
−3n = Θ(n
2
).
Solution.
Let C
1
and C
2
be positive constants such that
C
1
n
2
≤
1
2
n
2
−3n ≤ C
2
n
2
.
This is equivalent to
C
1
≤
1
2
−
3
n
≤ C
2
.
Since
1
2
−
3
n
≤
1
2
for all n ≥ 1, we choose C
2
≥
1
2
. Since
1
2
−
3
n
≥
1
4
for all
n ≥ 12, we choose C
1
≤
1
4
. Finally, we choose n
0
= 12.
Example 30.2
Show that 6n
3
= Θ(n
2
).
Solution.
We use the argument by contradiction. Suppose that 6n
3
= Θ(n
2
). Then
there exist positive constants C
1
, C
2
and n
0
such that
C
1
n
2
≤ 6n
3
≤ C
2
n
2
for all n ≥ n
0
. The righthand side inequality yields 6n ≤ C
2
for n ≥ n
0
.
This says that the lefthand side can be made as large as we want whereas
the righthand side is ﬁxed. A contradiction.
Theorem 30.1
For given two functions f(n) and g(n), f(n) = Θ(g(n)) if and only if f(n) =
O(g(n)) and g(n) = O(f(n)).
170 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
Proof.
Suppose that f(n) = Θ(g(n)). Then there exist positive constants C
1
, C
2
,
and n
0
such that C
1
[g(n)[ ≤ [f(n)[ ≤ C
2
[g(n)[ for all n ≥ n
0
. The lefthand
side inequality implies that g(n) = O(f(n)) whereas the righthand side in
equality implies that f(n) = O(g(n)). Now go backward for the converse.
Just as O provides an asymptotic upper bound on a function, Ω−notation
provides an asymptotic lower bound. For a given function g(n), let Ω(g(n))
denote the set of all funtions f(n) such that there exist positive constants
C and n
0
such that C[g(n)[ ≤ [f(n)[ for all n ≥ n
0
. For f(n) ∈ Ω(g(n)) we
write f(n) = Ω(g(n)).
Example 30.3
Show that log
2
n! = Ω(nlog
2
n).
Solution.
Since (n!)
2
≥ n
n
for all n ≥ 1 we ﬁnd nlog
2
n ≤ 2 log
2
n!. That is,
1
2
nlog
2
n ≤
log
2
n! for n ≥ 1. This says that log
2
n! = Ω(nlog
2
n).
Theorem 30.2
For given two functions f(n) and g(n), f(n) = Θ(g(n)) if and only if f(n) =
O(g(n)) and f(n) = Ω(g(n)).
Proof.
Suppose ﬁrst that f(n) = Θ(g(n)). Then there exist positive constants C
1
, C
2
and n
0
such that C
1
[g(n)[ ≤ [f(n)[ ≤ C
2
[g(n)[ for n ≥ n
0
. The righthand
side inequality implies that f(n) = O(g(n)) whereas the lefthand side in
equality implies that f(n) = Ω(g(n)).
Conversely, suppose that f(n) = O(g(n)) and f(n) = Ω(g(n)). Then there
exist constants C
1
, C
2
, n
1
and n
2
such that [f(n)[ ≤ C
2
[g(n)[ for n ≥ n
2
and
C
1
[g(n)[ ≤ [f(n)[ for n ≥ n
1
. Let n
0
= max¦n
1
, n
2
¦. Then for n ≥ n
0
we
have C
1
[g(n)[ ≤ [f(n)[ ≤ C
2
[g(n)[. That is, f(n) = Θ(g(n)).
Example 30.4
Let f(n) and g(n) be two given functions. We say that f(n) = o(g(n)) if and
only if lim
n→∞
f(n)
g(n)
= 0.
a. Show that if f(n) = o(g(n)) then f(n) = O(g(n)).
b. Find two functions f(n) and g(n) such that f(n) = O(g(n) but f(n) =
o(g(n)).
30 Θ AND ΩNOTATIONS 171
Solution.
a. Suppose that f(n) = o(g(n)). Then there is a positive integer n
0
such
that [
f(n)
g(n)
[ ≤ 1 for n ≥ n
0
. That is, [f(n)[ ≤ [g(n)[ for all n ≥ n
0
. Hence,
f(n) = O(g(n)).
b. Let f(n) = 2n
2
and g(n) = n
2
.
172 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
Fundamentals of Counting and
Probability Theory
The major goal of this chapter is to establish several techniques for counting
large ﬁnite sets without actually listing their elements. Also, the fundamen
tals of probablity theory are discussed.
31 Elements of Counting
For a set X, [X[ denotes the number of elements of X. It is easy to see that
for any two sets A and B we have the following result known as the Inclu
sion  Exclusion Principle
[A ∪ B[ = [A[ +[B[ −[A ∩ B[.
Indeed, [A[ gives the number of elements in A including those that are com
mon to A and B. The same holds for [B[. Hence, [A[ + [B[ includes twice
the number of common elements. Hence, to get an accurate count of the
elements of A ∪ B, it is necessary to subtract [A ∩ B[ from [A[ +[B[.
Note that if A and B are disjoint then [A ∩ B[ = 0 and consequently
[A ∪ B[ = [A[ +[B[.
Example 31.1 (The Addition Rule)
Show by induction on n, that if ¦A
1
, A
2
, , A
n
¦ is a collection of pairwise
disjoint sets then
[A
1
∪ A
2
∪ ∪ A
n
[ = [A
1
[ +[A
2
[ + +[A
n
[.
Solution.
Basis of induction: For n = 2 the result holds by the InclusionExclusion
173
174 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Principle.
Induction hypothesis: Suppose that for any collection ¦A
1
, A
2
, , A
n
¦ of
pairwise disjoint sets we have
[A
1
∪ A
2
∪ ∪ A
n
[ = [A
1
[ +[A
2
[ + +[A
n
[.
Induction step: Let ¦A
1
, A
2
, , A
n
, A
n+1
¦ be a collection of pairwise disjoint
sets. Since (A
1
∪A
2
∪ ∪A
n
) ∩A
n+1
= (A
1
∩A
n+1
) ∪ ∪(A
n
∩A
n+1
) = ∅
then by the InclusionExclusion Principle and the induction hypothesis we
have
[A
1
∪ A
2
∪ ∪ A
n
∪ A
n+1
[ = [A
1
∪ A
2
∪ ∪ A
n
[ +[A
n+1
[
= [A
1
[ +[A
2
[ + +[A
n
[ +[A
n
[
Example 31.2
A total of 35 programmers interviewed for a job; 25 knew FORTRAN, 28
knew PASCAL, and 2 knew neither languages. How many knew both lan
guages?
Solution.
Let A be the group of programmers that knew FORTRAN, B those who
knew PASCAL. Then A ∩ B is the group of programmers who knew both
languages. By the InclusionExclusion Principle we have
[A ∪ B[ = [A[ +[B[ −[A ∩ B[.
That is,
33 = 25 + 28 −[A ∩ B[.
Solving for [A ∩ B[ we ﬁnd [A ∩ B[ = 20.
Another important rule of counting is the multiplication rule. It states
that if a decision consists of k steps, where the ﬁrst step can be made in n
1
diﬀerent ways, the second step in n
2
ways, , the kth step in n
k
ways, then
the decision itself can be made in n
1
n
2
n
k
ways.
Example 31.3
a. How many possible outcomes are there if 2 distinguishable dice are rolled?
b. Suppose that a state’s license plates consist of 3 letters followed by four
digits. How many diﬀerent plates can be manufactured? (no repetitions)
31 ELEMENTS OF COUNTING 175
Solution.
a. By the multiplication rule there are 6 6 = 36 possible outcomes.
b. By the multiplication rule there are 26 25 24 10 9 8 7 possible
license plates.
Example 31.4
Let Σ = ¦a, b, c, d¦ be an alphabet with 4 letters. Let Σ
2
be the set of all
words of length 2 with letters from Σ. Find the number of all words of length
2 where the letters are not repeated. First use the product rule. List the
words by means of a tree diagram.
Solution.
By the multiplication rule there are 43 = 12 diﬀerent words. Constructing
a tree diagram
we ﬁnd that the words are
¦ab, ac, ad, ba, bc, bd, ca, cb, cd, da, db, dc¦
An rpermutation of n objects, in symbol P(n, r), is an ordered selection
of r objects from a given n objects.
Example 31.5
a. Use the product rule to show that P(n, r) =
n!
(n−r)!
.
b. Find all possible 2permutations of the set ¦1, 2, 3¦.
Solution.
a. We can treat a permutation as a decision with r steps. The ﬁrst step
can be made in n diﬀerent ways, the second in n − 1 diﬀerent ways, ...,
the rth in n − r + 1 diﬀerent ways. Thus, by the multiplication rule there
are n(n − 1) (n − r + 1) rpermutations of n objects. That is, P(n, r) =
n(n −1) (n −r + 1) =
n!
(n−r)!
.
b. P(3, 2) =
3!
(3−2)!
= 6.
176 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Example 31.6
How many license plates are there that start with three letters followed by 4
digits (no repetitions)?
Solution.
P(26, 3) P(10, 4) = 78, 624, 000.
An rcombination of n objects, in symbol C(n, r), is an unordered selec
tion of r of the n objects. Thus, C(n, r) is the number of ways of choosing
r objects from n given objects without taking order in account. But the
number of diﬀerent ways that r objects can be ordered is r!. Since there are
C(n, r) groups of r objects from a given n objects then the number of ordered
selection of r objects from n given objects is r!C(n, r) = P(n, r). Thus
C(n, r) =
P(n, r)
r!
=
n!
r!(n −r)!
.
Example 31.7
In how many diﬀerent ways can a hand of 5 cards be selected from a deck of
52 cards?(no repetition)
Solution.
C(52, 5) = 2, 598, 960.
Example 31.8
Prove the following identities:
a. C(n, 0) = C(n, n) = 1 and C(n, 1) = C(n, n −1) = n.
b. Symmetry property: C(n, r) = C(n, n −r), r ≤ n.
c. Pascal’s identity: C(n + 1, k) = C(n, k −1) +C(n, k), n ≥ k.
Solution.
a. Follows immediately from the deﬁnition of of C(n, r).
b. Indeed, we have
C(n, n −r) =
n!
(n−r)!(n−n+r)!
=
n!
r!(n−r)!
= C(n, r)
31 ELEMENTS OF COUNTING 177
c.
C(n, k −1) +C(n, k) =
n!
(k−1)!(n−k+1)!
+
n!
k!(n−k)!
=
n!k
k!(n−k+1)!
+
n!(n−k+1)
k!(n−k)!
=
n!
k!(n−k+1)!
(k +n −k + 1)
=
(n+1)!
(n+1−k)!
= C(n + 1, k)
Pascal’s identity allows one to construct the following triangle known as
Pascal’s triangle (for n = 5) as follows
1
1 → 1
1 → 2 → 1
1 → 3 → 3 →1
1 → 4 → 6 →4 → 1
The following theorem provides an expension of (x + y)
n
where n is a non
negative integer.
Theorem 31.1 (Binomial Theorem)
Let x and y be variables, and let n be a positive integer. Then
(x +y)
n
=
n
¸
k=0
C(n, k)x
n−k
y
k
where C(n, k) is called the binomial coeﬃcient.
Proof.
The proof is by induction.
Basis of induction: For n = 1 we have
(x +y)
1
=
1
¸
k=0
C(1, k)x
1−k
y
k
= x +y.
Induction hypothesis: Suppose that the theorem is true for n.
Induction step: Let us show that it is still true for n + 1. That is
(x +y)
n+1
=
n+1
¸
k=0
C(n + 1, k)x
n−k+1
y
k
.
178 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Indeed, we have
(x +y)
n+1
= (x +y)(x +y)
n
= x(x +y)
n
+y(x +y)
n
= x
n
¸
k=0
C(n, k)x
n−k
y
k
+y
n
¸
k=0
C(n, k)x
n−k
y
k
=
n
¸
k=0
C(n, k)x
n−k+1
y
k
+
n
¸
k=0
C(n, k)x
n−k
y
k+1
= C(n, 0)x
n+1
+C(n, 1)x
n
y +C(n, 2)x
n−1
y
2
+ +C(n, n)xy
n
+C(n, 0)x
n
y
+ C(n, 1)x
n−1
y
2
+ +C(n, n −1)xy
n
+ C(n, n)y
n+1
= C(n + 1, 0)x
n+1
+C(n + 1, 1)x
n
y +C(n + 1, 2)x
n−1
y
2
+ +C(n + 1, n)xy
n
+C(n + 1, n + 1)y
n+1
=
n+1
¸
k=0
C(n + 1, k)x
n−k+1
y
k
.
Example 31.9
Expand (x +y)
6
using the binomial theorem.
Solution.
By the Binomial Theorem and Pascal’s triangle we have
(x +y)
6
= x
6
+ 6x
5
y + 15x
4
y
2
+ 20x
3
y
3
+ 15x
2
y
4
+ 6xy
5
+y
6
Example 31.10
a. Show that
¸
n
k=0
C(n, k) = 2
n
.
b. Show that
¸
n
k=0
(−1)
k
C(n, k) = 0.
Solution.
a. Letting x = y = 1 in the binomial theorem we ﬁnd
2
n
= (1 + 1)
n
=
n
¸
k=0
C(n, k).
b. This follows from the binomial theorem by letting x = 1 and y = −1
31 ELEMENTS OF COUNTING 179
Review Problems
Problem 31.1
a. How many ways can we get a sum of 4 or a sum of 8 when two distin
guishable dice are rolled?
b. How many ways can we get a sum of 8 when two undistinguishable dice
are rolled?
Problem 31.2
a. How many 4digit numbers can be formed using the digits, 1, 2, , 9
(with repetitions)? How many can be formed if no digit can be repeated?
b. How many diﬀerent license plates are there that involve 1, 2, or 3 letters
followed by 4 digits (with repetitions)?
Problem 31.3
a. In how many ways can 4 cards be drawn, with replacement, from a deck
of 52 cards?
b. In how many ways can 4 cards be drawn, without replacement, from a
deck of 52 cards?
Problem 31.4
In how many ways can 7 women and 3 men be arranged in a row if the three
men must always stand next to each other.
Problem 31.5
A menu in a Chinese restaurant allows you to order exactly two of eight
main dishes as part of the dinner special. How many diﬀerent combinations
of main dishes could you order?
Problem 31.6
Find the coeﬃcient of a
5
b
7
in the binomial expansion of (1 −2b)
12
.
Problem 31.7
Use the binomial theorem to prove that
3
n
=
n
¸
k=0
2
k
C(n, k).
180 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
32 Basic Probability Terms and Rules
Probability theory is one of the serious branch of mathematics with applica
tions to many sciences, namely the theory of statistics. This section intro
duces the most basic ideas of probabiltiy.
An experiment is any operation whose outcomes cannot be predicted with
certainty. The sample space S of an experiment is the set of all possible
outcomes for the experiment. For example, if you roll a die one time then
the experiment is the roll of the die. A sample space for this experiment is
S = ¦1, 2, 3, 4, 5, 6¦ where each digit represents a face of the die.
An event is any subset of a sample space. Thus, if S is the sample space
then the collection of all possible events is the power set {(S).
The Probability of an event E is the measure of occurrence of E. It is a
number between 0 and 1. If the event is impossible to occur then its proba
bility is 0. If the occurrence is certain then the probability is 1. The closer
to 1 the probability is, the more likely the event is. The probability of oc
currence of an event E (called its success) will be denoted by P(E). Thus,
0 ≤ P(E) ≤ 1. If an event has no outcomes, that is as a subset of S if E = ∅
then P(∅) = 0. On the other hand, if E = S then P(S) = 1.
Example 32.1
Which of the following numbers cannot be the probability of some event? (a)
0.71 (b)−0.5 (c) 150% (d)
4
3
.
Solution.
(a) Yes. (b) No. Since the number is negative. (c) No since the number is
greater than 1. (d) No.
Various probability concepts exist nowadays. The classical probability con
cept applies only when all possible outcomes are equally likely, in which
case we use the formula
P(E) =
number of outcomes favorable to event
total number of outcomes
=
[E[
[S[
,
where [E[ is the number of elements in E.
Example 32.2
What is the probability of drawing an ace from a wellshuﬂed deck of 52
playing cards?
32 BASIC PROBABILITY TERMS AND RULES 181
Solution.
P(Ace) =
4
52
=
1
13
.
Example 32.3
What is the probability of rolling a 3 or a 4 with a fair die?
Solution.
P(3 or 4) =
2
6
=
1
3
.
A major shortcoming of the classical probability concept is its limited applica
bility, for there are many situations in which the various outcomes cannot
all regarded as equally likely. This would be the case, for instance, when
we wonder whether a person will get a raise or when we want to predict the
outcome of an election. A widely used probability concept is the estimated
probability which uses the relative frequency of an event and is given by the
formula:
P(E) = Relative frequency =
f
n
,
where f is the frequency of the event and n is the size of the sample space.
Example 32.4
Records show (over a period of time) that 468 of 600 jets from Dallas to
Phoenix arrived on time. Estimate the probability that any one jet from
Dallas to Phoenix will arrive on time.
Solution.
P(E) =
f
n
=
468
600
=
39
50
We deﬁne the probability of nonoccurrence of an event E (called its fail
ure) by the formula
P(E
c
) = 1 −P(E).
Note that
P(E) +P(E
c
) = 1.
Example 32.5
The probability that a college student without a ﬂu shot will get the ﬂu is
0.45. What is the probability that a college student without the ﬂu shot will
not get the ﬂu?
182 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Solution.
The probability is 1 −0.45 = .55.
Next, we discuss some of the rules of probability. The union of two events
A and B is the event A ∪ B whose outcomes are either in A or in B. The
intersection of two events A and B is the event A ∩ B whose outcomes
are outcomes of both events A and B. Two events A and B are said to be
mutually exclusive if they have no outcomes in common. In this case
A ∩ B = ∅.
Example 32.6
If A and B are mutually exclusive then what is P(A ∩ B)?
Solution.
P(∅) = 0.
Theorem 32.1
For any events A and B the probability of A ∪ B is given by the addition
rule
P(A ∪ B) = P(A) +P(B) −P(A ∩ B).
If A and B are mutually exclusive then by Exercise 443 the above formula
reduces to
P(A ∪ B) = P(A) +P(B).
Proof.
By the InclusionInclusion Principle we have
[A ∪ B[ = [A[ +[B[ −[A ∩ B[.
Thus,
P(A ∪ B) =
A∪B
S
=
A
S
+
B
S
−
A∩B
S
= P(A) +P(B) −P(A ∩ B).
Example 32.7
For any event E of a sample space S show that P(E) =
¸
x∈E
P(x).
Solution.
This follows from the previous theorem
32 BASIC PROBABILITY TERMS AND RULES 183
Example 32.8
M&M plain candies come in a variety of colors. According to the manufac
turer, the color distribution is:
(a) Orange: 15% (b) Green: 10% (c) Red: 20% (d) Yellow: 20% (e)
Brown: 30% (f) Tan: 5%.
Suppose you have a large bag of plain candies and you reach in and take one
candy at random. Find
1. P(orange candy Or tan candy). Are these outcomes mutually exclusive?
2. P(not brown candy).
Solution.
1. P(orange candy Or tan candy) = .15 + .05 = .2 = 20%. The outcomes
are mutually exclusive.
2. P(not brown candy) = 1 −.3 = .7 = 70%
Example 32.9
If A is the event ”drawing an ace” from a deck of cards and B is the event
”drawing a spade”. Are A and B mutually exclusive? Find P(A ∪ B).
Solution.
The events are not mutually exclusive since there is an ace that is also a
spade.
P(A ∪ B) = P(A) +P(B) −P(A ∩ B) =
4
13
+
13
52
−
1
52
= 31%
Now, given two events A and B belonging to the same sample space S.
The conditional probability P(A[B) denotes the probability that event A
will occur given that event B has occurred. It is given by the formula
P(A[B) =
P(A ∩ B)
P(B)
.
Example 32.10
Consider the experiment of tossing two dice. What is the probability that
the sum of two dice equals six given that the ﬁrst die is a four?
184 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Solution.
The possible outcomes of our experiment are
¦(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6)¦.
Thus, the probability that the sum is six given that the ﬁrst die is four is
1
6
.
Assuming that the experiment consists of tossing the two dice then by letting
B be the event that the ﬁrst die is 4 and A be the even that the sum of the
two dice is 6 then
P(A[B) =
P(A ∩ B)
P(B)
=
1
36
6
36
=
1
6
If P(A[B) = P(A), we say that the two events A and B are independent.
That is, the occurrence of A is independent whether or not B occurs. If two
events are not independent, we say that they are dependent.
Example 32.11
Show that A and B are independent if and only if
P(A ∩ B) = P(A) P(B).
Solution.
Suppose that A and B are independent. Then P(A) = P(A[B) =
P(A∩B)
P(B)
.
That is, P(A ∩ B) = P(A) P(B). Conversely, if P(A ∩ B) = P(A) P(B)
then P(A[B) =
P(A∩B)
P(B)
= P(A).
Example 32.12
You roll two fair dice: a green one and a red one.
a. Are the outcomes on the dice independent?
b. Find P(5 on green die and 3 on red die).
c. Find P(3 on green die and 5 on red die).
d. Find P((5 on green die and 3 on red die) or (3 on green die and 5 on red
die)).
Solution.
a. Yes.
b. P(5 on green die and 3 on red die) =
1
6
1
6
=
1
36
.
c. P(3 on green die and 5 on red die) =
1
36
.
d. P((5 on green die and 3 on red die) or (3 on green die and 5 on red die))
=
1
36
+
1
36
=
1
18
.
32 BASIC PROBABILITY TERMS AND RULES 185
Example 32.13
Show that
P(B[A) =
P(B) P(A[B)
P(A)
.
Solution.
This follows from the fact that P(A ∩ B) = P(B ∩ A) and the formula of
P(A[B) given above.
Example 32.14
Prove Bayes’ Theorem
P(A[B) =
P(B[A)P(A)
P(B[A)P(A) +P(B[A
c
)P(A
c
)
.
Solution.
Note ﬁrst that ¦A
c
∩ B, A ∩ B¦ form a partition of B. Thus,
P(B) = P(A ∩ B) +P(A
c
∩ B).
Now by the previous exercise we have
P(A[B) =
P(A)·P(BA)
P(B)
=
P(BA)P(A)
P(BA)P(A)+P(BA
c
)P(A
c
)
Example 32.15
Consider two urns. The ﬁrst contains two white and seven black balls and
the second contains ﬁve white and six black balls. We ﬂip a fair coin and
then draw a ball from the ﬁrst urn or the second urn depending on whether
the outcome was head or tail. What is the conditional probability that the
outcome of the toss was head given that a white ball was selected?
Solution.
Let W be the event that a white ball is drawn, and let H be the event that
the coin comes up heads. The desired probability P(H[W) may be calculated
as follows:
P(H[W) =
P(H∩W)
P(W)
=
P(WH)P(H)
P(W)
=
P(WH)P(H)
P(WH)P(H)+P(WH
c
)P(H
c
)
=
2
9
1
2
2
9
1
2
+
5
11
1
2
=
22
67
186 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
It frequently occurs that in performing an experiment we are mainly inter
ested in some functions of the outcome as opposed to the outcome itself. For
example, in tossing dice we are interested in the sum of the dice and are not
really concerned about the actual outcome. These realvalued functions de
ﬁned on the sample space are known as random variables. If the range is
a ﬁnite subset of IN then the random variable is called discrete. Otherwise,
the random variable is said to be continuous. Discrete random variable are
usually the result of a count whereas a continuous random variable is usually
the result of a measurement.
A probability distribution is a correspondence that assigns probabilities
to the values of a random variable. The graph of a probability distribution
is called is a histogram.
Example 32.16
Let f denote the random variable that is deﬁned as the sum of two fair dice.
Find the probability distribution of f.
Solution.
P(f = 2) = P(¦(1, 1)¦) =
1
36
,
P(f = 3) = P(¦(1, 2), (2, 1)¦) =
2
36
,
P(f = 4) = P(¦(1, 3), (2, 2), (3, 1)¦) =
3
36
,
P(f = 5) = P(¦(1, 4), (2, 3), (3, 2), (4, 1)¦) =
4
36
,
P(f = 6) = P(¦(1, 5, (5, 1), (2, 4), (4, 2), (3, 3)¦) =
5
36
,
P(f = 7) = P(¦(1, 6), (6, 1), (2, 5), (5, 2), (4, 3), (3, 4)¦) =
6
36
,
P(f = 8) = P(¦(2, 6), (6, 2), (3, 5), (5, 3), (4, 4)¦) =
5
36
,
P(f = 9) = P(¦(3, 6), (6, 3), (4, 5), (5, 4)¦) =
4
36
,
P(f = 10) = P(¦(4, 5), (5, 4), (5, 5)¦) =
3
36
,
P(f = 11) = P(¦(5, 6), (6, 5)¦) =
2
36
,
P(f = 12) = P(¦(6, 6)¦) =
1
36
.
Example 32.17
Construct the histogram of the random variable of the previous exercise.
32 BASIC PROBABILITY TERMS AND RULES 187
Solution.
For a discrete random variable f we deﬁne the expected value ( or mean)
of f by the formula
E(f) =
¸
x∈S
f(x)P(x)
In other words, E(f) is a weighted average of the possible values that f can
take on, each value being weighted by the probability that f assumes that
value.
Example 32.18
Find E(f) where f is the outcome when we roll a fair die.
Solution.
Since P(1) = P(2) = = P(6) =
1
6
we ﬁnd
E(f) = 1(
1
6
) + 2(
1
6
) + + 6(
1
6
) =
7
2
188 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Another quantity of interest is the variance of a random variable f, de
noted by V ar(f), which is deﬁned by
V ar(f) = E[(f −E(f))
2
].
In other words, the variance measures the expected square of the deviation
of f from its expected value. The standard deviation of a random variable
f is the quantity is deﬁned to be the square root of the variance.
Example 32.19
Show that if f and g are random variables then E(f + cg) = E(f) + cE(g)
where c is a constant.
Solution.
Indeed,
E(f +cg) =
¸
x∈S
(f +cg)(x)P(x)
=
¸
x∈S
f(x)P(x) +c
¸
x∈S
g(x)P(x)
= E(f) +cE(g)
Theorem 32.2
V ar(f) = E(f
2
) −(E(f))
2
.
Proof.
Indeed, using the previous exercise we have
V ar(f) = E(f
2
−2E(f)f + (E(f))
2
)
= E(f
2
) −2E(f)E(f) + (E(f))
2
= E(f
2
) −(E(f))
2
Example 32.20
Calculate V ar(f) when f represents the outcome when a fair die is rolled.
Solution.
First note that
E(f
2
) = (f(1))
2
P(1) + + (f(6))
2
P(6) =
91
6
.
By the above theorem we have
V ar(f) = E(f
2
) −(E(f))
2
=
91
6
−(
7
2
)
2
=
35
12
32 BASIC PROBABILITY TERMS AND RULES 189
Review Problems
Problem 32.1
What is the probability of drawing a red card from a well shuﬄed deck of
52 playing cards?
Problem 32.2
If we roll a fair die, what are the probabilities of getting
a. a 1 or a 6;
b. an even number?
Problem 32.3
A department store’s records show that 782 of 920 women who entered the
store on a saturday afternoon made at least one purchase. Estimate the
probability that a woman who enters the store on a Saturday afternoon will
make at least one purchase.
Problem 32.4
Which of the following are mutually exclusive? Explain your answers.
a. A driver getting a ticket for speeding and a ticket for going through a red
light.
b. Being foreignborn and being President of the United States.
Problem 32.5
If A and B are the events that a consumer testing service will rate a given
stereo system very good or good, P(A) = 0.22, P(B) = 0.35. Find
a. P(A
c
);
b. P(A ∪ B);
c. P(A ∩ B).
Problem 32.6
If the probabilities are 0.20, 0.15, and 0.03 that a student will get a failing
grade in Statistics, in English, or in both, what is the probability that the
student will get a failing grade in at least one of these subjects?
Problem 32.7
If the probability that a research project will be well planned is 0.60 and the
probability that it will be well planned and well executed is 0.54, what is the
probability that a well planned research project will be well executed?
190 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Problem 32.8
Given three events A, B, and C such that P(A)=0.50, P(B)=0.30, and P(A∩
B) = 0.15. Show that the events A and B are independent.
Problem 32.9
There are 16 equally likely outcomes by ﬂipping four coins. Let f repre
sent the number of heads. Find the probability distribution and graph the
corresponding histogram.
33 BINOMIAL RANDOM VARIABLES 191
33 Binomial Random Variables
In this section we discuss an important example of a discrete random variable.
Binomial experiments are problems that consist of a ﬁxed number of
trials n, with each trial having exactly two possible outcomes: Success and
failure. The probability of a success is denoted by p = P(S) and that of a
failure by q = P(F). Moreover, p and q are related by the formula
p +q = 1.
Also, we assume that the trials are independent, that is what happens to
one trial does not aﬀect the probability of a success in any other trial. The
central question of a binomial experiment is to ﬁnd the probability of r suc
cesses out of n trials. Now, anytime we make selections from a population
without replacement, we do not have independent trials. For example, se
lecting a ball from a box that contain balls of two diﬀerent colors. If the
selection is without replacement then the trials are dependent.
Example 33.1
The registrar of a college noted that for many years the withdrawal rate from
an introductory chemistry course has been 35% each term. We wish to ﬁnd
the probability that 55 students out of 80 will register for the course.
a. What makes a trial?
b. What is a success? a failure?
c. What are the values of n, p, q, r?
Solution.
a. The decision of each student to withdraw or complete the course can be
thought as a trial. Thus, there are a total of 80 trials.
b. S = completing the course, F = withdrawing from course.
c. n = 80, p = .65, q = .35, r = 55.
Example 33.2
Harper’s Index states that 10% of all adult residents in Washington D.C.,
are lawyers. For a random sample of 15 adult Washington, D.C., residents,
we want to ﬁnd the probability that 3 are lawyers.
a. What makes a trial?
192 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
b. What is a success? a failure?
c. What are the values of n, p, q, r?
Solution.
a. A trial is whether an adult resident of Washington, D.C. is a lawyer or
not.
b. S = being a lawyer, F = not being a lawyer.
c. n = 15, p = .1, q = .9, r = 3.
As mentioned earlier, the central problem of a binomial experiment is to
ﬁnd the probability of r successes out of n independent trials. We next see
how to ﬁnd these probabilities.
Recall from Section 6.1 the formula for ﬁnding the number of combinations
of n distinct objects taken r at a time
C(n, r) =
n!
r!(n −r)!
.
We call the number C(n, r) the binomial coeﬃcient. One commonly used
procedure for ﬁnding these coeﬃcients is by means of Pascal’s triangle.
Now, the probability of r successes out of n independent trials is given by
the binomial distribution formula
P(r) = C(n, r)p
r
q
n−r
where p = P(S) and q = P(F) = 1 − p. The validity of the above equation
may be veriﬁed by ﬁrst noting that the probability of any particular sequence
of the n outcomes with r successes and n−r failures is, by the independence
of trials, p
r
(1−p)
n−r
. Since C(n, r) counts the number of outcomes that have
r successes and n −r failures then the equation above follows.
Example 33.3
Find the probability that in tossing a fair coin three times there will appear
(a) 3 heads, (b)2 heads and 1 tail, (c) 2 tails and 1 head, and (d) 3 tails.
Solution.
a. C(3, 3)(.5)
3
(.5)
3−3
=
1
8
.
b. P(2) = C(3, 2)(.5)
2
(.5) =
3
8
.
c. P(1) = C(3, 1)(.5)(.5)
2
=
3
8
.
d. P(0) = C(3, 0)(.5)
3
=
1
8
33 BINOMIAL RANDOM VARIABLES 193
Example 33.4
The probability that an entering college student will graduate is 0.4. Deter
mine the probability that out of 5 students (a) none, (b) 1, (c) at least 1, (d)
all will graduate.
Solution.
(a) C(5, 0)(.6)
5
.
(b) C(5, 1)(.4)(.6)
4
.
(c) 1 −C(5, 0)(.6)
5
.
(d) C(5, 5)(.4)
5
.
Example 33.5
Find the probability of guessing correctly at least 6 of the 10 answers on a
truefalse examination.
Solution.
P(6) +P(7) +P(8) +P(9) +P(10).
We next derive formulas for ﬁnding the expected value and standard de
viation for the binomial random variable.
Theorem 33.1
a. The mean of a binomial random variable is given by µ = np.
b. The variance of a binomial random variable is given by σ
2
= npq.
Proof.
a. Using the deﬁnition of µ we have
µ =
¸
n
i=0
iP(i)
=
¸
n
i=1
iC(n, i)p
i
q
n−i
= np
¸
n
i=1
n!
(i−1)!(n−i)
p
i−1
q
n−i−1
= np
¸
n−1
i=0
C(n −1, i)p
i
q
n−1−i
= np(p +q)
n−1
= np.
194 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
b. Note ﬁrst that i
2
= i(i −1) +i. Then
E(X
2
) =
¸
n
i=0
i
2
P(i)
=
¸
n
i=0
i(i −1)C(n, i)p
i
q
n−i
+µ
=
¸
n
i=2
n!
(n−i)!(i−2)!
p
i
q
n−i
+µ
= n(n −1)p
2
¸
n
i=2
(n−2)!
(n−i)!(i−2)!
p
i
q
n−i
+µ
= n(n −1)p
2
¸
n−2
j=0
C(n −2, j)p
j
q
n−2−j
+µ
= n(n −1)p
2
(p +q)
n−2
+µ
= n(n −1)p
2
+µ
It follows that
σ
2
= E(X
2
) −µ
2
= n(n −1)p
2
+np −n
2
p
2
= npq
33 BINOMIAL RANDOM VARIABLES 195
Review Problems
Problem 33.1
At Community Hospital, the nursing staﬀ is large enough so that 80% of the
time a nurse can respond to a room call within 3 minutes. Last night there
were 73 room calls. We wish to ﬁnd the probability nurses responded to 62
of them within 3 minutes.
a. What makes a trial?
b. What is a success? a failure?
c. What are the values of n, p, q, r?
Problem 33.2
Find the probability that in a family of 4 children there will be (a) at least 1
boy and (b) at least 1 boy and 1 girl. Assume that the probability of a male
birth is
1
2
.
Problem 33.3
An insurance salesperson sells policies to 5 men, all of identical age and in
good health. According to the actuarial tables, the probability that a man
of this particular age will be alive 30 years is
2
3
. Find the probability that in
30 years (a) all 5 men, (b) at least 3 men, (c) only 2 men, (d) none will be
alive.
196 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Elements of Graph Theory
In this chapter we present the basic concepts related to graphs and trees such
as the degree of a vertex, connectedness, Euler and Hamiltonians circuits,
isomorphisms of graphs, rooted and spanning trees.
34 Graphs, Paths, and Circuits
An undirected graph G consists of a set V
G
of vertices and a set E
G
of
edges such that each edge e ∈ E
G
is associated with an unordered pair of
vertices, called its endpoints.
A directed graph or digraph G consists of a set V
G
of vertices and a set
E
G
of edges such that each edge e ∈ E
G
is associated with an ordered pair
of vertices.
We denote a graph by G = (V
G
, E
G
).
Two vertices are said to be adjacent if there is an edge connecting the two
vertices. Two edges associated to the same vertices are called parallel. An
edge incident to a single vertex is called a loop. A vertex that is not incident
on any edge is called an isolated vertex. A graph with neither loops nor
parallel edges is called simple graph.
Example 34.1
Consider the following graph G
197
198 ELEMENTS OF GRAPH THEORY
a. Find E
G
and V
G
.
b. List the isolated vertices.
c. List the loops.
d. List the parallel edges.
e. List the vertices adjacent to v
3
..
f. Find all edges incident on v
4
.
Solution.
a. E
G
= ¦e
1
, e
2
, e
3
, e
4
, e
5
, e
6
¦ and V
G
= ¦v
1
, v
2
, v
3
, v
4
, v
5
, v
6
, v
7
¦.
b. There is only one isolated vertex, v
5
.
c. There is only one loop, e
5
.
d. ¦e
2
, e
3
¦.
e. ¦v
2
, v
4
¦.
f. ¦e
1
, e
4
, e
5
¦.
Example 34.2
Which one of the following graphs is simple.
Solution.
a. G is not simple since it has a loop and parallel edges.
b. G is simple.
A complete graph on n vertices, denoted by K
n
, is the simple graph that
contains exactly one edge between each pair of distinct vertices.
Example 34.3
Draw K
2
, K
3
, K
4
, and K
5
.
34 GRAPHS, PATHS, AND CIRCUITS 199
Solution.
A graph in which the vertices can be partitioned into two disjoint sets V
1
and V
2
with every edge incident on one vertex in V
1
and one vertex of V
2
is
called bipartite graph.
Example 34.4
a. Show that the graph G is bipartite.
b. Show that K
3
is not bipartite.
Solution.
a. Clear from the deﬁnition and the graph.
b. Any two sets of vertices of K
3
will have opposite parity. Thus, according
to the deﬁnition of bipartite graph, K
3
is not bipartite.
A complete bipartite graph K
m,n
, is the graph that has its vertex set
partitioned into two disjoint subsets of m and n vertices, respectively. More
200 ELEMENTS OF GRAPH THEORY
over, there is an edge between two vertices if and only if one vertex is in the
ﬁrst set and the other vertex is in the second set.
Example 34.5
Draw K
2,3
, K
3,3
.
Solution.
The degree of a vertex v in an undirected graph, in symbol deg(v), is the
number of edges incident on it. By deﬁnition, a loop at a vertex contributes
twice to the degree of that vertex. The total degree of G is the sum of the
degrees of all the vertices of G.
Example 34.6
What are the degrees of the vertices in the following graph
Solution.
deg(v
1
) = 0, deg(v
2
) = 2, deg(v
3
) = 4.
34 GRAPHS, PATHS, AND CIRCUITS 201
Theorem 34.1
For any graph G = (V
G
, E
G
) we have
2[E
G
[ =
¸
v∈V (G)
deg(v).
Proof.
Suppose that V
G
= ¦v
1
, v
2
, , v
n
¦ and [E
G
[ = m. Let e ∈ E
G
. If e is a loop
then it contributes 2 to the total degree of G. If e is not a loop then let v
i
and
v
j
denote the endpoints of e. Then e contributes 1 to deg(v
i
) and contributes
1 to the deg(v
j
). Therefore, e contributes 2 to the total degree of G. Since
e was arbitrarily, this shows that each edge of G contributes 2 to the total
degree of G. Thus,
2[E
G
[ =
¸
v∈V (G)
deg(v)
The following is easily deduced from the previous theorem.
Theorem 34.2
In any graph there are an even number of vertices of odd degree.
Proof.
Let G = (V
G
, E
G
) be a graph. By the previous theorem, the sum of all the
degrees of the vertices is T = 2[E
G
[, an even number. Let E be the sum of
the numbers deg(v), each which is even and O the sum of numbers deg(v)
each which is odd. Then T = E + O. That is, O = T − E. Since both T
and E are even then T is also even. This implies that there must be an even
number of the odd degrees. Hence, there must be an even number of vertices
with odd degree.
Example 34.7
Find a formula for the number of edges in K
n
.
Solution.
Since G is complete, each vertex is adjacent to the remaining vertices. Thus,
the degree of each of the n vertices is n −1, and we have the sum of the de
grees of all of the vertices being n(n−1). By Theorem 34.1, n(n−1) = 2[E
G
[.
This completes a proof of the theorem
202 ELEMENTS OF GRAPH THEORY
In an undirected graph G a sequence P of the form v
0
e
1
v
1
e
2
v
n−1
e
n
v
n
is called a path of length n or a path connecting v
0
to v
n
. If P is a path
such that v
0
= v
n
then it is called a circuit or a cycle. A path or circuit is
simple if it does not contain the same edge more than once. A graph that
does not contain any circuit is called acyclic.
Example 34.8
In the graph below, determine whether the following sequences are paths,
simple paths, circuits, or simple circuits.
a. v
0
e
1
v
1
e
10
v
5
e
9
v
2
e
2
v
1
.
b. v
3
e
5
v
4
e
8
v
5
e
10
v
1
e
3
v
2
.
c. v
1
e
2
v
2
e
3
v
1
.
d. v
5
e
9
v
2
e
4
v
3
e
5
v
4
e
6
v
4
e
8
v
5
.
Solution.
a. a path (no repeated edge), not a simple path (repeated vertex v
1
), not a
circuit
b. a simple path
c. a simple circuit
d. a circuit, not a simple circuit (vertex v
4
is repeated)
An undirected graph is called connected if there is a path between every
pair of distinct vertices of the graph. A graph that is not connected is said
to be disconnected.
34 GRAPHS, PATHS, AND CIRCUITS 203
Example 34.9
Determine which graph is connected and which one is disconnected.
Solution.
a. Connected.
b. Disconnected since there is no path connecting the vertices v
1
and v
4
.
A simple path that contains all edges of a graph G is called an Euler path.
If this path is also a circuit, it is called an Euler circuit.
Theorem 34.3
If a graph G has an Euler circuit then every vertex of the graph has even
degree.
Proof.
Let G be a graph with an Euler circuit. Start at some vertex on the circuit
and follow the circuit from vertex to vertex, erasing each edge as you go
along it. When you go through a vertex you erase one edge going in and one
edge going out, or else you erase a loop. Either way, the erasure reduces the
degree of the vertex by 2. Eventually every edge gets erased and all the ver
tices have degree 0. So all vertices must have had even degree to begin with.
It follows from the above theorem that if a graph has a vertex with odd
degree then the graph can not have an Euler circuit.
The following provide a converse to the above theorem.
204 ELEMENTS OF GRAPH THEORY
Theorem 34.4 (Euler Theorem)
If all the vertices of a connected graph have even degree, then the graph has
an Euler circuit.
Example 34.10
Show that the following graph has no Euler circuit.
Solution.
Vertices v
1
and v
3
both have degree 3, which is odd. Hence, by the remark
following the previous theorem, this graph does not have an Euler circuit.
A path is called a Hamiltonian path if it visits every vertex of the graph
exactly once. A circuit that visits every vertex exactly once except for the
last vertex which duplicates the ﬁrst one is called a Hamiltonian circuit.
Example 34.11
Find a Hamiltonian circuit in the graph
Solution.
vwxyzv
34 GRAPHS, PATHS, AND CIRCUITS 205
Example 34.12
Show that the following graph has a Hamiltonian path but no Hamiltonian
circuit.
Solution.
vwxyz is a Hamiltonian path. There is no Hamiltonian circuit since no cycle
goes through v.
206 ELEMENTS OF GRAPH THEORY
Review Problems
Problem 34.1
The union of two graphs G
1
= (V
1
, E
1
) and G
2
= (V
2
, E
2
) is the graph
G
1
∪G
2
= (V
1
∪V
2
, E
1
∪E
2
). The intersection of two graphs G
1
= (V
1
, E
1
)
and G
2
= (V
2
, E
2
) is the graph G
1
∩ G
2
= (V
1
∩ V
2
, E
1
∩ E
2
).
Find the union and the intersection of the graphs
Problem 34.2
Graphs can be represented using matrices. The adjacency matrix of a graph
G with n vertices is an nn matrix A
G
such that each entry a
ij
is the number
of edges connecting v
i
and v
j
. Thus, a
ij
= 0 if there is no edge from v
i
to v
j
.
a. Draw a graph with the adjacency matrix
0 1 1 0
1 0 0 1
1 0 0 1
0 1 1 0
¸
¸
¸
¸
b. Use an adjacency matrix to represent the graph
34 GRAPHS, PATHS, AND CIRCUITS 207
Problem 34.3
A graph H = (V
H
, E
H
) is a subgraph of G = (V
G
, E
G
) if and only if V
H
⊆ V
G
and E
H
⊆ E
G
.
Find all nonempty subgraphs of the graph
When (u, v) is an edge in a directed graph G then u is called the ini
tial vertex and v is called the terminal vertex. In a directed graph,
the indegree of a vertex v, denoted by deg
−
(v), is the number of edges
with v as their terminal vertex. Similarly, the outdegree of v, denoted
by deg
+
(v), is the number of edges with v as an initial vertex. Note that
deg(v) = deg
+
(v) +deg
−
(v).
208 ELEMENTS OF GRAPH THEORY
Problem 34.4
Find the indegree and outdegree of each of the vertex in the graph G with
directed edges.
Problem 34.5
Show that for a digraph G = (V
G
, E
G
) we have
[E
G
[ =
¸
v∈V (G)
deg
−
(v) =
¸
v∈V (G)
deg
+
(v).
Another useful matrix representation of a graph is known as the incidence
matrix. It is constructed as follows. We label the rows with the vertices
and the columns with the edges. The entry for row v and column e is 1 if e
is incident on v and 0 otherwise. If e is a loop at v we assign the value 2. It
is easy to see that the sum of entries of each column is 2 and that the sum
of entries of a row gives the degree of the vertex corresponding to that row.
Problem 34.6
Find the incidence matrix corresponding to the graph
34 GRAPHS, PATHS, AND CIRCUITS 209
Problem 34.7
If each vertex of an undirected graph has degree k then the graph is called a
regular graph of degree k.
How many edges are there in a graph with 10 vertices each of degree 6?
Problem 34.8
Two simple graphs G
1
and G
2
are isomorphic, in symbol, G
1
· G
2
, if there
is onetoone onto function, f : V (G
1
) →V (G
2
) and A
G
1
= A
G
2
. Show that
the following graphs are isomorphic.
Warning: The number of vertices, the number of edges, and the degrees of
the vertices are all invariants under isomorphism. If any of these quantities
210 ELEMENTS OF GRAPH THEORY
diﬀer in two graphs, these graphs cannot be isomorphic. However, when these
invariants are the same, it does not necessarily mean that the two graphs are
isomorphic.
The isomorphism between two graphs G
1
= (V
G
1
, E
G
1
) and G
2
= (V
G
2
, E
G
2
)
with parallel edges or loops requires two bijections f : V
G
1
→ V
G
2
and g :
E
G
1
→ E
G
2
such that if e ∈ E
G
1
is an edge with endpoints (u, v) then
g(e) ∈ E
G
2
is an edge with endpoints (f(u), f(v)).
Problem 34.9
Show that the following graphs are not isomorphic.
Problem 34.10
Show that the following graph has no Hamiltonian path.
35 TREES 211
35 Trees
An undirected graph is called a tree if each pair of distinct vertices has ex
actly one path. Thus, a tree has no parallel edges and no loops.
We next show a result that is needed for the proof of our ﬁrst main theorem
of trees.
Theorem 35.1
Any tree with more than one vertex has at least one vertex of degree 1.
Proof.
Let v
0
and v
n
be two distinct vertices. Then there is a path connecting v
0
to
v
n
. By the deﬁnition of a tree, there is only one edge incident on either v
0
or
v
n
. Thus deg(v
0
) = deg(v
1
) = 1. .
The following is the ﬁrst of the two main theorems about trees:
Theorem 35.2
A tree with n vertices has exactly n −1 edges.
Proof.
The proof is by induction on n ≥ 1. Let P(n) be the property: Any tree with
n vertices has n −1 edges.
Basis of induction: P(1) is valid since a tree with one vertex has zero edges.
Induction hypothesis: Suppose that P(n) holds up to n ≥ 1.
Induction Step: We must show that any tree with n+1 vertices has n edges.
Indeed, let T be any tree with n + 1 vertices. Since n + 1 ≥ 2 then by the
previous theorem, T has a vertex v of degree 1. Let T
0
be the graph obtained
by removing v and the edge attached to v. Then T
0
is a tree with n vertices.
By the induction hypothesis, T
0
has n −1 edges and so T has n edges
Example 35.1
Which of the following graphs are trees?
212 ELEMENTS OF GRAPH THEORY
Solution.
The ﬁrst graph satisﬁes the deﬁnition of a tree. The second and third graphs
do not satisfy the conclusion of Theorem 35.2 and therefore they are not
trees.
The second major theorem about trees is the following theorem whose proof
is omitted.
Theorem 35.3
Any connected graph with n vertices and n −1 edges is a tree.
A rooted tree is a tree in which a particular vertex is designated as the
root. The level of a vetex v is the length of the simple path from the root
to v. The height of a rooted tree is the maximum level number that occurs.
Example 35.2
Find the level of each vertex and the height of the following rooted tree.
35 TREES 213
Solution.
v
1
is the root of the given tree.
vertex level
v
2
1
v
3
1
v
4
2
v
5
2
v
6
2
v
7
2
The height of the tree is 2.
Let T be a rooted tree with root v
0
. Suppose (v
0
, v
1
, , v
n
) is a simple
path in T and x, y, z are three vertices. Then
(a) v
n−1
is the parent of v
n
.
(b) v
0
, v
1
, , v
n−1
are the ancestors of v
n
.
(c) v
n
is the child of v
n−1
.
(d) If x is an ancestor of y then y is a descendant of x.
(e) If x and y are children of z then x and y are siblings.
(f) If x has no children, then x is a leaf.
(g) The subtree of T rooted at x is the graph with vertex V and edge set
E, where V is x together with the descendants of x and
E = ¦e[e is an edge on a simple path from x to some vertex in V ¦.
Example 35.3
Consider the rooted tree
214 ELEMENTS OF GRAPH THEORY
a. Find the parent of v
6
.
b. Find the ancestors of v
13
.
c. Find the children of v
3
.
d. Find the descendants of v
11
.
e. Find an example of a siblings.
f. Find the leaves.
g. Construct the subtree rooted at v
7
.
Solution.
a. v
2
.
b. v
1
, v
3
, v
7
.
c. v
7
, v
8
, v
9
.
d. None.
e. ¦v
2
, v
3
, v
4
, v
5
¦.
f. ¦v
4
, v
5
, v
6
, v
9
, v
9
, v
10
, v
11
, v
12
, v
13
¦.
g.
A binary tree is a rooted tree such that each vertex has at most two chil
dren. Moreover, each child is designated as either a left child or a right
child.
Example 35.4
a. Show that the following tree is a binary tree.
35 TREES 215
b. Find the left child and the right child of vertex v
5
.
c. A full binary tree is a binary tree in which each vertex has either two
children or zero children. Construct an example of a full binary tree.
Solution.
a. Follows from the deﬁnition of a binary tree.
b. The left child is v
6
and the right child is v
7
.
c.
Example 35.5
A forest is a simple graph with no circuits. Which of the following graphs
is a forest?
216 ELEMENTS OF GRAPH THEORY
Solution.
The ﬁrst graph is a forest whereas the second is not.
Example 35.6
a. Let T be a subgraph of a graph G such that T is a tree containing all of
the vertices of G. Such a tree is called a spanning tree. Find a spanning
tree of the following graph.
b. The following algorithm ﬁnds a spanning tree. In this algorithm S denotes
a sequence. Let G be a connected graph with vertices ordered
v
1
, v
2
, , , v
n
1. Let T be the tree with root v
1
and no edges.
2. Add to T all edges (v
1
, x) and vertices on which they are incident, provided
35 TREES 217
that (v
1
, x) deos not produce a circuit. If no edges can be added, stop (T is
a spanning tree)
3. Replace S by the children in T of S ordered consistently with the original
ordering. Go to step 2.
Use the above algorithm to ﬁnd the spanning tree of part a.
Solution.
a.
218 ELEMENTS OF GRAPH THEORY
Review Problems
Problem 35.1
Find the level of each vertex and the height of the following rooted tree.
Problem 35.2
Consider the rooted tree
a. Find the parent of v
6
.
b. Find the ancestors of v
10
.
35 TREES 219
c. Find the children of v
4
.
d. Find the descendants of v
1
.
e. Find all the siblings.
f. Find the leaves.
g. Construct the subtree rooted at v
1
.
Problem 35.3
The binary tree below gives an algorithm for choosing a restaurant. Each
internal vertex asks a question. If we begin at the root, answer each ques
tion, and follow the appropriate edge, we will eventually arrive at a terminal
vertex that chooses a restaurant. Such a tree is called a decision tree.
Construct a decision tree that sorts three given numbers a
1
, a
2
, a
3
in as
cending order.
Problem 35.4
A binary search tree is a binary tree T in which data are associated with
the vertices. The data are arranged so that, for each vertex v in T, each data
item in the left subtree of v is less than the data item in v and each data item
in the right subtree of v is greater than the data item in v. Using numerical
order, form a binary search tree for a number in the set ¦1, 2, , 15¦.
Problem 35.5
Procedures for systematically visiting every vertex of a tree are called tra
versal algorithms. In the preorder traversal, the root r is listed ﬁrst
220 ELEMENTS OF GRAPH THEORY
and then the subtrees T
1
, T
2
, , T
n
are listed, from left to right, in order
of their roots. The preorder traversal begins by visiting r. It continues by
traversing T
1
in preorder, thenT
2
in preorder, and so on, until T
n
is traversed
in preorder. In which order does a preorder traversal visit the vertices in the
following rooted tree?
2
Preface
This book is designed for a one semester course in discrete mathematics for sophomore or junior level students. The text covers the mathematical concepts that students will encounter in many disciplines such as computer science, engineering, Business, and the sciences. Besides reading the book, students are strongly encouraged to do all the excercises. Mathematics is a discipline in which working the problems is essential to the understanding of the material contained in this book. Students are encouraged ﬁrst to do the problems without referring to the solutions. Solutions to problems found at the end of this book can only be used when you are stuck. Exert a reasonable amount of eﬀorts towards solving a problem before you look up the answer, and rework any problem you miss. Students are strongly encouraged to keep up with the exercises and the sequel of concepts as they are going along, for mathematics builds on itself. Solution Manual for the text can be requested from the author through email:mﬁnan@atu.edu Marcel B. Finan May 2001
3
4
PREFACE
. . . . . . . . . . . . . . . Fundamentals of Set Theory 81 15 Basic Deﬁnitions . . . . . . . . .Contents Preface Fundamentals of Mathematical Logic 1 Propositions and Related Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 7 8 18 24 33 41 45 50 53 53 59 64 67 74 76 78 . . . . . . . . . . . . . . . . . . . . 6 Project I: Digital Logic Design . . . . . . . . . . . . . . Fundamentals of Mathematical Proofs 8 Methods of Direct Proof I . . . . . 4 Propositions and Quantiﬁers . . 90 17 Project VI: Boolean Algebra . 110 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Methods of Indirect Proofs: Contradiction and Contraposition . . . . . . . . . . . . . . . . . . . . . 12 Project III: Elementary Number Theory and Mathematical Proofs 13 Project IV: The Euclidean Algorithm . . 9 More Methods of Proof . . . . . . . . . . . 11 Method of Proof by Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Arguments with Quantiﬁed Premises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Project V: Induction and the Algebra of Matrices . . . . . . 2 Conditional and Biconditional Propositions 3 Rules of Inferential Logic . . . . . . . . . . . 99 19 Partial Order Relations . 81 16 Properties of Sets . . . . . . . 98 Relations and Functions 99 18 Equivalence Relations . . . . . . . . . 7 Project II: Number Systems . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 29 Logarithmic and Exponential Complexities . . Paths. . . . . 165 30 Θ. . . . . . . Project X: Countable Sets . . . . . . . 191 Elements of Graph Theory 197 34 Graphs. . . . . . . . 180 . 173 . . . . . . and Circuits . . . . . . . 169 Fundamentals of Counting and Probability Theory 31 Elements of Counting . . . . . . . . . . 32 Basic Probability Terms and Rules . . . . . . 116 124 130 145 148 149 150 152 Introduction to the Analysis of Algorithms 157 28 Time Complexity and ONotation . . . 173 . . . . . . . . 33 Binomial Random Variables . . . . . . . .and ΩNotations . . . . . . . . . . . . . . . . . . . . 197 35 Trees . . . . Bijective and Inverse Functions . . . . . . . .6 20 21 22 23 24 25 26 27 Functions: Deﬁnitions and Examples . . . . . . . . . . Project XI: FiniteState Automaton . . . . . . . . . . . . . . . . . . CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 . . . . . . . . . . . . . . . . . . . Project VIII: WellOrdered Sets and Lattices Project IX: The Pigeonhole Principle . . . . . . . . . . . . . . . . Recursion . . . Project VII: Applications to Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The emphasis here will be on logic as a working tool. 7 . • At the software level a knowledge of symbolic logic is helpful in the design of programs. We will develop some of the symbolic techniques required for computer logic.Fundamentals of Mathematical Logic Logic is commonly known as the science of reasoning. Some of the reasons to study logic are the following: • At the hardware level the design of ’logic’ circuits to implement instructions is greatly simpliﬁed by the use of symbolic logic.
How are you? Solution. b. a. d. but not both. 2 + 2 = 4. b. The truth value of a proposition is true. c. r. The diﬀerence of two primes. is the capital of New York.8 FUNDAMENTALS OF MATHEMATICAL LOGIC 1 Propositions and Related Concepts A proposition is any meaningful statement that is either true or false. Not a proposition Example 1. b. A proposition with truth value (T).1 Which of the following are propositions? Give the truth value of the propositions. A proposition with truth value (F). Julius Ceasar was president of the United States. c. c. to represent propositions. 2 + 3 = 7. if it is a false statement. Example 1. A proposition wiht truth value (F).C. Not a proposition. d. We will use lowercase letters. A proposition with truth value (F).2 Which of the following are propositions? Give the truth value of the propositions. Not a proposition since no truth value can be assigned to this statement. Be quiet ! Solution. if it is a true statement and false. denoted by F. c. b. denoted by T. such as p. a. q. Washington D. · · · . What time is it? d. a. Statements that are not propositions include questions and commands. . We will also use the notation p:1+1=3 to deﬁne p to be the proposition 1 + 1 = 3. a.
Let p and q be propositions. is the proposition: p or q. Construct the propositions p ∧ q and p ∨ q. The conjunction of p and q. Construct the propositions p ∧ q and p ∨ q. The disjunction of the propositions p and q is the proposition p ∨ q : 5 < 9 or 9 < 7 Example 1. Not a proposition 9 New propositions called compound propositions or propositional functions can be obtained from old ones by using symbolic connectives which we discuss next.3 Let p: 5<9 q : 9 < 7. .1 PROPOSITIONS AND RELATED CONCEPTS d. Example 1. is the proposition: p and q. Solution. This proposition is false only when both p and q are false. The ’or’ is used in an inclusive way. denoted p ∧ q. otherwise it is true.4 Consider the following propositions p: q: It is Friday It is raining. The conjunction of the propositions p and q is the proposition p ∧ q : 5 < 9 and 9 < 7. denoted p ∨ q. This proposition is deﬁned to be true only when both p and q are true and it is false otherwise. The disjunction of p and q. The propositions that form a propositional function are called the propositional variables.
. The truth table of the exclusive ’or’ is displayed below p T T F F q T F T F p⊕q F T T F Example 1. Construct a truth table for p ⊕ p. Solution. The exclusive or of p and q. The disjunction of the propositions p and q is the proposition p ∨ q : It is F riday or It is raining A truth table displays the relationships between the truth values of propositions. Construct a truth table for (p ⊕ q) ⊕ r. The conjunction of the propositions p and q is the proposition p ∧ q : It is F riday and it is raining.5 a. p T T F F p T T F F q T F T F q T F T F p∧q T F F F p∨q T T T F Let p and q be two propositions. a. is the proposition that is true when exactly one of p and q is true and is false otherwise. Next. we display the truth tables of p ∧ q and p ∨ q. denoted p ⊕ q. b.10 FUNDAMENTALS OF MATHEMATICAL LOGIC Solution.
p T F p⊕p F F q T T F F T T F F r T F T F T F T F p⊕q F F T T T T F F (p ⊕ q) ⊕ r T F F T F T T F 11 The ﬁnal operation on a proposition p that we discuss is the negation of p.6 Consider the following propositions: p: Today is Thursday. is the proposition not p. denoted ∼ p. Construct the truth table of [∼ (p ∧ q)] ∨ r. q: 2 + 1 = 3. The negation of p. p T T F F q T T T T r T F T F p ∧q T T F F ∼ (p ∧ q) F F T T [∼ (p ∧ q)] ∨ r T F T T . Solution.1 PROPOSITIONS AND RELATED CONCEPTS p T T T T F F F F b. The truth table of ∼ p is displayed below p T F ∼p F T Example 1. r: There is no pollution in New Jersey.
c. Show that ∼ (∼ p) ≡ p.8 a.12 FUNDAMENTALS OF MATHEMATICAL LOGIC Example 1. We write p ≡ q.9 a. Show that ∼ (p ∨ q) ≡∼ p∧ ∼ q. Solution. the given proposition is a tautology. Example 1. Construct the truth table of the proposition (p∧q)∨(∼ p∨ ∼ q). regardless of the truth values of the basic propositions which comprise it. Example 1. a. p T F ∼p F T p∨ ∼ p T T Again. Two propositions are equivalent if they have exactly the same truth values under all circumstances. Determine if this proposition is a tautology. Solution. this proposition is a tautology. Show that p∨ ∼ p is a tautology. Show that ∼ (p ∧ q) ≡∼ p∨ ∼ q. p T T F F q T F T F ∼p F F T T ∼q F T F T ∼ p∨ ∼ q F T T T p∧q T F F F (p ∧ q) ∨ (∼ p∧ ∼ q) T T T T Thus. The negation of p is the proposition ∼ p : x > 0 or x ≤ −5 A compound proposition is called a tautology if it is always true. . and b. b. are known as DeMorgan’s laws. b. a.7 Find the negation of the proposition p : −5 < x ≤ 0. b.
a. Solution. p T T F F b. Show that p ∧ q ≡ q ∧ p and p ∨ q ≡ q ∨ p. Show that (p ∧ q) ∨ r ≡ (p ∨ r) ∧ (q ∨ r) and (p ∨ q) ∧ r ≡ (p ∧ r) ∨ (q ∧ r). p T T F F p T T F F q T F T F q T F T F p∧q T F F F p∨q T T T F q∧p T F F F q∨p T T T F . b. Show that (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) and (p ∧ q) ∧ r ≡ p ∧ (q ∧ r). c.10 a. p T F ∼p F T ∼ (∼ p) T F q T F T F ∼p F F T T ∼q F T F T p∧q T F F F ∼ (p ∧ q) F T T T ∼ p∨ ∼ q F T T T q T F T F ∼p F F T T ∼q F T F T p∨q T T T F ∼ (p ∨ q) F F F T ∼ p∧ ∼ q F F F T 13 Example 1. a.1 PROPOSITIONS AND RELATED CONCEPTS Solution. p T T F F c.
p∧q T T F F F F F F p∨r T T T T T F T F q∨r T T T F T T T F (p ∧ q) ∨ r T T T F T F T F (p ∨ r) ∧ (q ∨ r) T T T F T F T F p T T T T F F F F q T T F F T T F F r T F T F T F T F .14 b. FUNDAMENTALS OF MATHEMATICAL LOGIC p T T T T F F F F q T T F F T T F F r T F T F T F T F p∨q T T T T T T F F q∨r T T T F T T T F (p ∨ q) ∨ r T T T T T T T F p ∨ (q ∨ r) T T T T T T T F p T T T T F F F F q T T F F T T F F r T F T F T F T F p∧q T T F F F F F F q∧r T F F F T F F F (p ∧ q) ∧ r T F F F F F F F p ∧ (q ∧ r) T F F F F F F F c.
1 PROPOSITIONS AND RELATED CONCEPTS p T T T T F F F F q T T F F T T F F r T F T F T F T F p∨q T T T T T T F F p∧r T F T F F F F F q∧r T F F F T F F F (p ∨ q) ∧ r T F T F T F F F (p ∧ r) ∨ (q ∧ r) T F T F T F F F 15 Example 1. the order of operations is that ∼ is performed ﬁrst. The operations ∨ and ∧ are executed in any order. p T T F F q T F T F ∼p F F T T ∼q F T F T p∧q T F F F ∼ (p ∧ q) ∼ p∧ ∼ q F F T = F T = F T T A compound proposition that has the value F for all possible values of the propositions in it is called a contradiction. We will use truth tables to prove the claim. Example 1.11 Show that ∼ (p ∧ q) ≡∼ p∧ ∼ q Solution. . Solution. p T F ∼p F T p∧ ∼ p F F In propositional functions.12 Show that the proposition p∧ ∼ p is a contradiction.
128 = 26 d. Problem 1. 1. Problem 1. Problem 1.8 Use De Morgan’s laws to write the negation for the proposition:”This computer program has a logical error in the ﬁrst ten lines or it is being run with an incomplete data set. Use symbolic connectives to represent the proposition ”Juan is a math major but not a computer science major.2 Consider the propositions: p: Juan is a math major.5 Let t be a tautology.” . q: Juan is a computer science major.” Problem 1.” Problem 1. b. Show that p ∨ c ≡ p. Show that p ∨ t ≡ t.024 is the smallest fourdigit number that is perfect square. a. c. x = 26 .16 FUNDAMENTALS OF MATHEMATICAL LOGIC Review Problems Problem 1. Problem 1.6 Let c be a contradiction. She is a mathematics major.1 Indicate which of the following sentences are propositions.4 Write the truth table for the proposition: (p ∨ (∼ p ∨ q))∧ ∼ (q∧ ∼ r).3 In the following sentence is the word ”or” used in its inclusive or exclusive sense? ”A team wins the playoﬀs if it wins two games in a row or a total of three games. Problem 1.7 Show that (r ∨ p) ∧ [(∼ r ∨ (p ∧ q)) ∧ (r ∨ q)] ≡ p ∧ q.
. c. p ∧ c ≡ c. Use De Morgan’s laws to write the negation for the proposition:0 ≥ x > −5. d. b.13 a. Is (p ⊕ q) ⊕ r ≡ p ⊕ (q ⊕ r)? Justify your answer. Problem 1. where c is a contradiction. Problem 1. Find simpler proposition forms that are logically equivalent to p ⊕ p and p ⊕ (p ⊕ p). where t is a tautology.11 Show that the proposition s = (p ∧ q) ∨ (∼ p ∨ (p∧ ∼ q)) is a tautology.14 Show the following: a. Problem 1. p ∨ p ≡ p and p ∧ p ≡ p. Is (p ⊕ q) ∧ r ≡ (p ∧ r) ⊕ (q ∧ r)? Justify your answer.10 Assume x ∈ IR. ∼ t ≡ c and ∼ c ≡ t.12 Show that the proposition s = (p∧ ∼ q) ∧ (∼ p ∨ q) is a contradiction.” Problem 1. Problem 1.1 PROPOSITIONS AND RELATED CONCEPTS 17 Problem 1.9 Use De Morgan’s laws to write the negation for the proposition:”The dollar is at an alltime high and the stock market is at a record low. c. p ∧ t ≡ p. b.
In terms of words the proposition p → q also reads: (a) if p then q. The truth table is p T T F F Example 2.18 FUNDAMENTALS OF MATHEMATICAL LOGIC 2 Conditional and Biconditional Propositions Let p and q be propositions. (b) p implies q. (e) p only if q. regardless of the truth value of q. The implication p → q is the the proposition that is false only when p is true and q is false. We say that p → q is true by default or vacuously true. The connective → is called the conditional connective. Solution. (c) p is a suﬃcient condition for q. p T T F F q T F T F ∼p F F T T p→q T F T T ∼p∨q T F T T q T F T F p→q T F T T It follows from the previous example that the proposition p → q is always true if the hypothesis p is false. Example 2. otherwise it is true.2 Show that p → q ≡∼ p ∨ q. p is called the hypothesis and q is called the conclusion. (d) q is a necessary condition for p. Solution. .1 Construct the truth table of the implication p → q.
” Solution. The contrapositive of p → q is the proposition ∼ q →∼ p. The opposite: If today is not Thursday then I don’t have a test today.5 Find the converse.6 Show that p → q ≡∼ q →∼ p. If I catch the 8:05 bus then I am on time for work In propositional functions that invlove the connectives ∼.” Solution.4 a. then I have a test today. and → the order of operations is that ∼ is performed ﬁrst and → is performed last.3 Use the ifthen form to rewrite the statement ”I am on time for work if I catch the 8:05 bus. The converse: If I have a test today then today is Thursday.” Solution. Example 2. Example 2. ∼ (p → q) ≡ ∼ (∼ p ∨ q) ≡ ∼ (∼ p)∧ ∼ q ≡ p∧ ∼ q. . then I cannot go to class. We use De Morgan’s laws as follows. Show that ∼ (p → q) ≡ p∧ ∼ q. b. ”My car in the repair shop and I can get to class. Find the negation of the statement ” If my car in the repair shop. opposite. ∧. b. and the contrapositive of the implication: ” If today is Thursday. ∨. The contrapositive: If I don’t have a test today then today in not Thursday Example 2.” The converse of p → q is the proposition q → p.2 CONDITIONAL AND BICONDITIONAL PROPOSITIONS 19 Example 2. The opposite or inverse of p → q is the proposition ∼ p →∼ q. a.
20
FUNDAMENTALS OF MATHEMATICAL LOGIC
Solution. We use De Morgan’s laws as follows. p→q ≡ ∼p∨q ≡ ∼ (p∧ ∼ q) ≡ ∼ (∼ q ∧ p) ≡ ∼∼ q∨ ∼ p ≡ q∨ ∼ p ≡ ∼ q →∼ p Example 2.7 Using truth tables show the following: a. p → q ≡ q → p b. p → q ≡∼ p →∼ q Solution. a. It suﬃces to show that ∼ p ∨ q ≡∼ q ∨ p. p T T F F p T T F F q T F T F q T F T F ∼p F F T T ∼p F F T T ∼q F T F T ∼q F T F T ∼p∨q T F T T ∼p∨q T F T T ∼q∨p T = T = F T p∨ ∼ q T = T = F T
b. We will show that ∼ p ∨ q ≡ p∨ ∼ q.
Example 2.8 Show that ∼ q →∼ p ≡ p → q Solution. We use De Morgan’s laws as follows. ∼ q →∼ p ≡ q∨ ∼ p ≡ ∼ (∼ q ∧ p) ≡ ∼ (p∧ ∼ q) ≡ ∼ p∨ ∼∼ q ≡ ∼p∨q ≡ p→q
2 CONDITIONAL AND BICONDITIONAL PROPOSITIONS
21
The biconditional proposition of p and q, denoted by p ↔ q, is the propositional function that is true when both p and q have the same truth values and false if p and q have opposite truth values. Also reads, ”p if and only if q” or ”p is a necessary and suﬃcient condition for q.” Example 2.9 Construct the truth table for p ↔ q. Solution. p T T F F q T F T F p↔q T F F T
Example 2.10 Show that the biconditional proposition of p and q is logically equivalent to the conjunction of the conditional propositions p → q and q → p. Solution. p T T F F q T F T F p→q T F T T q→p T T F T p↔q T F F T (p → q) ∧ (q → p) T F F T
The order of operations for the ﬁve logical connectives is as follows: 1. ∼ 2. ∧, ∨ in any order. 3. →, ↔ in any order.
22
FUNDAMENTALS OF MATHEMATICAL LOGIC
Review Problems
Problem 2.1 Rewrite the following proposition in ifthen form: ” This loop will repeat exactly N times if it does not contain a stop or a go to.” Problem 2.2 Construct the truth table for the proposition: ∼ p ∨ q → r. Problem 2.3 Construct the truth table for the proposition: (p → r) ↔ (q → r). Problem 2.4 Write negations for each of the following propositions. (Assume that all variables represent ﬁxed quantities or entities, as appropriate.) a. If P is a square, then P is a rectangle. b. If today is Thanksgiving, then tomorrow is Friday. c. If r is rational, then the decimal expansion of r is repeating. d. If n is prime, then n is odd or n is 2. e. If x ≥ 0, then x > 0 or x = 0. f. If Tom is Ann’s father, then Jim is her uncle and Sue is her aunt. g. If n is divisible by 6, then n is divisible by 2 and n is divisible by 3. Problem 2.5 Write the contrapositives for the propositions of Exercise 40. Problem 2.6 Write the converse and inverse for the propositions of Exercise 40. Problem 2.7 Use the contrapositive to rewrite the proposition ” The Cubs will win the penant only if they win tomorrow’s game” in ifthen form in two ways. Problem 2.8 Rewrite the proposition :” Catching the 8:05 bus is suﬃcient condition for my being on time for work” in ifthen form.
2 CONDITIONAL AND BICONDITIONAL PROPOSITIONS
23
Problem 2.9 Use the contrapositive to rewrite the proposition ” being divisible by 3 is a necessary condition for this number to be divisible by 9” in ifthen form in two ways. Problem 2.10 Rewrite the proposition ”A suﬃcient condition for Hal’s team to win the championship is that it wins the rest of the games” in ifthen form. Problem 2.11 Rewrite the proposition ”A necessary condition for this computer program to be correct is that it not produce error messages during translation” in ifthen form.
Thus. Then the . the truth or falsity of each of the propositions has no bearing on that of the others Example 3. The truth of the conclusion. Indeed. ˙ r The symbol . Solution. Example 3. and strawberries are red. suppose that the premises of an argument are all true. ˙ Now. ”Mark is a lawyer” and ”all lawyers have gone to law school..” The above argument can be represented as follows: Let p: Mark is a lawyer. ”Mark went to law school. So Mark went to law school since all lawyers have gone to law school” form an argument. is to indicate the inferrenced conclusion. Solution. we will usually consider a group of related propositions. q: All lawyers have gone to law school. The transition from premises to conclusion is the inference upon which the argument relies.2 Show that the propositions:”Mark is a lawyer.24 FUNDAMENTALS OF MATHEMATICAL LOGIC 3 Rules of Inferential Logic The main concern of logic is how the truth of some propositions is connected with the truth of another.” is inferred or deduced from its premises. This is an argument. An argument is a set of two or more propositions related to each other in such a way that all but one of them (the premises) are supposed to provide support for the remaining one (the conclusion). Then p∧q .1 Show that the propositions ”The star is made of milk. r: Mark went to law school. My dog has ﬂeas..” do not form an argument.
.. ˙ r is valid.4 (Modus Ponens or the method of aﬃrming) a.3 RULES OF INFERENTIAL LOGIC 25 conclusion may be either true or false. We construct the truth table as follows. b. To test an argument for validity one proceeds as follows: (1) Identify the premises and the conclusion of the argument. When the conclusion is true then the argument is said to be valid. Show that the argument ∼p∨q → r ∼p∨q . if the conclusion is true then the argument is valid. (2) Construct a truth table including the premises and the conclusion. otherwise the argument is invalid. (4) In each row of Step (3). (3) Find rows in which all premises are true. The argument is then invalid Example 3. Example 3.3 Show that the argument p → q q → p . p ∨ q ˙ is invalid Solution. Show that the argument p → q p . .. When the conclusion is false then the argument is said to be invalid. q ˙ is valid. p q p→q q→p T T T T T F F T F T T F F F T T p∨q T T T F From the last row we see that the premises are true but the conclusion is false.
5 Show that the argument p → q q . p ˙ is invalid. The truth table is as follows. Follows from by replacing p with ∼ ∨q and q with r Example 3. The truth table is as follows... a. ∼ p ˙ is valid. p T T F F q T F T F p→q T F T T The ﬁrst row shows that the argument is valid. Solution.26 FUNDAMENTALS OF MATHEMATICAL LOGIC Solution. b. An argument of this form is referred to as converse error because the conclusion of the argument would follows from the premises if p → q is replaced by its converse q → p Example 3. p T T F F q T F T F p→q T F T T Because of the third row the argument is invalid. .6 (Modus Tollens or the method of denial) Show that the argument p → q ∼q .
p ∨ q ˙ is valid. This is known as inverse error because the conclusion of the argument would follow from the premises if p → q is replaced by the inverse q → p Example 3.3 RULES OF INFERENTIAL LOGIC Solution.7 Show that the argument p → q ∼p . p T T F F q T F T F p→q T F T T ∼q F T F T ∼p F F T T The third row shows that the argument is invalid. ∼ q ˙ is invalid. p T T F F q T F T F p→q T F T T ∼q F T F T ∼p F F T T 27 The last row shows that the argument is valid Example 3.. . Solution. Show that the argument p .. The truth table is as follows. p ∨ q ˙ is valid.8 (Disjunctive Addition) a. The truth table is as follows.. Show that the argument q . b.
p T T F F q T F T F p∨q T T T F The ﬁrst and second rows show that the argument is valid.. The truth table is as follows.9 (Conjunctive Simpliﬁcation) a. Show that the argument p∧q . The ﬁrst row shows that the argument is valid Example 3. Show that the argument p∧q . Solution. The ﬁrst and third rows show that the argument is valid Example 3. ˙ p is valid.28 FUNDAMENTALS OF MATHEMATICAL LOGIC Solution. The truth table is as follows. b. Show that the argument p∨q ∼q .. a.. p T T F F q T F T F p∧q T F F F The ﬁrst row shows that the argument is valid. ˙ p . ˙ q is valid. b. b.10 (Disjunctive Syllogism) a. a.
The truth table is as follows. b.11 (Hypothetical Syllogism) Show that the argument p→q q→r . b. ﬁfth.3 RULES OF INFERENTIAL LOGIC is valid. p T T T T F F F F q T T F F T T F F r T F T F T F T F p→q T T F F T T T T q→r T F T T T F T T p→r T F T F T T T T The ﬁrst .. The third row shows that the argument is valid Example 3. ˙ p→r is valid. a. ˙ q is valid. and eighth rows show that the argument is valid . Show that the argument p∨q ∼p .. Solution. seventh. The truth table is as follows. Solution. p T T F F q T F T F ∼p F F T T ∼q F T F T p∨q T T T F 29 The second row shows that the argument is valid.
Constructing the truth table we ﬁnd c F F p T F ∼p→c T F The ﬁrst row shows that the argument is valid .12 (Rule of contradiction) Show that if c is a contradiction then the following argument is valid for any p.30 FUNDAMENTALS OF MATHEMATICAL LOGIC Example 3. ∼p→c . ˙ p Solution..
p→q q→p . p p→q ∼q∨r .4 Use truth table to determine whether the argument below is valid. then Hua is on team B. If logic is easy. then I am a monkey’s uncle.. ˙ r Problem 3.3 Use truth table to determine whether the argument below is valid. . b . If Tom is not on team A.. . ˙ Problem 3. p ∨ q ˙ Problem 3. ˙ . then Tom is on team A.1 Use modus ponens or modus tollens to ﬁll in the blanks in the argument below so as to produce valid inferences.. ˙ Problem 3. then 2 = a for some integers a and b. I am not a monkey’s uncle. If Hua is not on team B.3 RULES OF INFERENTIAL LOGIC 31 Review Problems Problem 3.2 Use modus ponens or modus tollens to ﬁll in the blanks in the argument below so as to produce valid inferences. Tom is not on team A or Hua is not on team B... b √ It is not true that 2 = a for some integers a and b.5 Use symbols to write the logical form of the given argument and then use a truth table to test the argument for validity. √ √ If 2 is rational.
.8 Use the valid argument forms of this section to deduce the conclusion from the premises. then Jules obtained the answer 2. ˙ Problem 3. ∼p∨q →r s∨ ∼ q ∼t p→t ∼ p ∧ r →∼ s . identify the rule of inference that guarantees its validity. then its square is larger than 4... Jules obtained the answer 2. The square of this number is not larger than 4. Otherwise state whether the converse or the inverse error is made. Otherwise state whether the converse or the inverse error is made. ..7 Use symbols to write the logical form of the given argument. This number is not larger than 2. ∼ p → r∧ ∼ s t→s u →∼ p ∼w u∨w . If this number is larger than 2. If the argument is valid. Jules solved this problem correctly. If the argument is valid. ˙ ∼q Problem 3. ˙ ∼t∨w .32 FUNDAMENTALS OF MATHEMATICAL LOGIC Problem 3.9 Use the valid argument forms of this section to deduce the conclusion from the premises. identify the rule of inference that guarantees its validity. ˙ Problem 3. . If Jules solved this problem correctly.6 Use symbols to write the logical form of the given argument.
Since every number appearing in TP also appears in TQ then P (x) ⇒ Q(x) If two predicates P (x) and Q(x) with a common domain D are such that TP = TQ then we use the notation P (x) ⇔ Q(x). What are the truth values of the propositions Q(1. · · · ). By substitution in the expression of Q we ﬁnd: Q(1. For instance. the numbers 0. 1. 2) is false since 1 = x = y + 3 = 5. These statements are not propositions when the variables are not speciﬁed. 4.1 Let Q(x. Solution. 4} and TQ = {1. On the contrary. one can produce propositions from such statements. The set of true values of a predicate P (x) is called the truth set and will be denoted by TP . Example 4. Show that P (x) ⇒ Q(x). 2. 8}. 0)? Solution. P (n) : n is prime is a predicate on the natural numbers.e. In the expression P (x). 0) is true since x = 3 = 0 + 3 = y + 3 If P (x) and Q(x) are two predicates with a common domain D then the notation P (x) ⇒ Q(x) means that every element in the truth set of P (x) is also an element in the truth set of Q(x). 2. However. . P (2) is true. Finding the truth set of each predicate we have: TP = {1.4 PROPOSITIONS AND QUANTIFIERS 33 4 Propositions and Quantiﬁers Statements such as ”x > 3” are often found in mathematical assertions and in computer programs. A predicate is an expression involving one or more variables deﬁned on some domain. called the domain of discourse. 2.2 Consider the two predicates P (x) : x is a factor of 4 and Q(x) : x is a factor of 8. As x varies the truth value of P (x) varies as well. Substitution of a particular value for the variable(s) produces a proposition which is either true or false. Observe that P (1) is false. Example 4. 2) and Q(3. Q(3. y) : x = y+3 with domain the collection of natural numbers (i. x is called a free variable.
x > Solution. then the predicate P (k) : 2k is even is true for all k ∈ IN. For example ∀x ∈ D. Solving this inequality we ﬁnd that −2 ≤ x ≤ 2. x ∈ TP Another way to generate propositions is by means of quantiﬁers. x < 0. The symbol ∃ is called the existential quantiﬁer. x > 0. otherwise it is false.34 FUNDAMENTALS OF MATHEMATICAL LOGIC Example 4. P (x) is a proposition that is true if there is at least one value of x ∈ D where P (x) is true. if x is an element in TQ then x ≤ 2. The symbol ∀ is called the universal quantiﬁer. For example. P (x) is a proposition which is true if P (x) is true for all values of x in the domain D of P. The proposition ∀x ∈ D.5 Write in the form ∀x ∈ D. or x = 0. Solution.i. . 1 2 < 2 = 1. The notation ∃x ∈ D.3 Let D = IR. P (x) the proposition :” every real number is either positive. Example 4. A counterexample is x = 1 . Show that P (x) ⇔ Q(x). if k is an nonnegative integer. Consider the two predicates P (x) : −2 ≤ x ≤ 2 and Q(x) : x ≤ 2. P (x) is false if P (x) is false for at least one value of x. ∀k ∈ IN. negative or 0. ∀x ∈ IR.” Solution. 1 2 Example 4. In this case x is called a counterexample.e. Indeed. That is. 2 1 x is false. We write. Clearly. x ≤ 2 and hence x belongs to TQ . That is. (x−2)(x+2) ≤ 0. Now. (2k is even).4 Show that the proposition ∀x ∈ IR. if x in TP then the distance from x to the origin is at most 2.
the given proposition is true The proposition ∀x ∈ D. P (x) → Q(x) is called the universal conditional proposition. P (x)? c. Find the contrapositive. P (x) → Q(x)) ≡ ∃x ∈ D. Since P (x) → Q(x) ≡ (∼ P (x)) ∨ Q(x) then ∼ (∀x ∈ D. What is the negation of the proposition ∀x ∈ D.6 Let P (x) denote the statement ”x > 3. ∃x ∈ D. P (x)? b.9 Consider the universal conditional proposition ∀x ∈ D. ∼ P (x). Solution. b. P (x) and ∼ Q(x) Example 4. the proposition ∀x ∈ IR. Example 4. if P (x) then Q(x). c. For example. if x is an interger then x is a rational number Example 4. P (x). a. Find the converse. What is the negation of the proposition ∃x ∈ D. What is the negation of the proposition ∀x ∈ D. ∀x ∈ D. b.7 Rewrite the proposition ”if a real number is an integer then it is a rational number” as a universal conditional proposition. ∼ P (x). P (x) → Q(x)? Solution.8 a.” What is the truth value of the proposition ∃x ∈ IR. if x > 2 then x2 > 4 is a universal conditional proposition.4 PROPOSITIONS AND QUANTIFIERS 35 Example 4. Find the inverse. a. Solution. ∀x ∈ IR. c. Since 4 ∈ IR and 4 > 3. .
if ∼ Q(x) then ∼ P (x). Q(x. For otherwise.36 FUNDAMENTALS OF MATHEMATICAL LOGIC Solution. y)? Solution. There exists a triangle with the property that the sum of angles is greater than 180◦ . ∃ a positive number δ such that if x − a ≤ δ then f (x) − L < . ∀x ∈ D. The given proposition is always true. For any triangle. P (x. y). one can choose x = −y to obtain 0 = x + y = 0 which is impossible Example 4. Let P (x. a.11 a. y)? b. y) denote the statement ”x + y = y + x. b. y). b. if ∼ P (x) then ∼ Q(x) Example 4.” What is the truth value of the proposition (∃y ∈ IR)(∀x ∈ IR). a. Solution. P (x.12 Find the negation of the following propositions: a. the sum of the angles is less than or equal to 180◦ Next. c. P (x. ∀x ∈ D. A typical example is the deﬁnition of a limit. b. ∀x∃y. There exists a polynomial that is not continuous everywhere. c. We say that L = limx→a f (x) if and only if ∀ > 0. b. The proposition is false. Example 4. c. a. .” What is the truth value of the proposition (∀x ∈ IR)(∀y ∈ IR). ∀x ∈ IR. if Q(x) then P (x). Every polynomial function is continuous. x > 3 → x2 > 9. b. ∃x ∈ IR. x > 3 and x2 ≤ 9. Let Q(x. we discuss predicates that contain multiple quantiﬁers.10 Write the negation of each of the following propositions: a. ∀x ∈ D. y) denote the statement ”x + y = 0. ∃x∀y.
∼ P (x. ∃!x ∈ IR. True.4 PROPOSITIONS AND QUANTIFIERS Solution. ∀x∃y. Solution. ∼ P (x. b. a. Let x = 1. Which of the following statements are true and which are false. y). 1 b. ∀y ∈ IR. xy = y. y) 37 Example 4. ∃! integer x such that x is an integer. a.13 The symbol ∃! stands for the phrase ”there exists a unique”. b. a. False since 1 and −1 are both integers with integer reciprocals . ∃x∀y.
Problem 4. if then . for some real number x. The sum of any two even integers is even. b. Some real numbers have square 2.5 Rewrite each of the following statements in the form ”∀ a. ∃ a set A such that A has 16 subsets. .n ≥ m + n” is false. There is at least one real number whose square is 2.4 Rewrite each of the following statements in the form ”∃ a. b. b. x such that ”: . Which of the following are equivalent ways of expressing this statement? a. show that the proposition:” For all positive integers n and m. Some real numbers are rational.38 FUNDAMENTALS OF MATHEMATICAL LOGIC Review Problems Problem 4. ∀ squares x. b. c. The square of each real number is 2. f. then x2 = 2. Problem 4.1 By ﬁnding a counterexample. The number x has square 2. If x is a real number.2 Consider the statement ∃x ∈ IR such that x2 = 2. d.3 Rewrite the following propositions informally in at least two diﬀerent ways without using the symbols ∃ and ∀ : a. e. c. Any valid argument with true premises has a true conclusion. Some real number has square 2. d. The product of any two odd integers is odd. x is a rectangle.”: All COBOL programs have at least 20 lines. Problem 4. m. Problem 4. Some exercises have answers.
9 Write the negation of the proposition :∀x ∈ IR. 36}. c. Problem 4. if n2 is even then n is not even.8 Let D = {−48. ∀x ∈ D. −8. 32.” For each x given below.83 b. ∃ an integer n such that n > x. if n2 is even then n is even.4 PROPOSITIONS AND QUANTIFIERS 39 Problem 4. 1. ∀x ∈ D. c. . b. then it is even. 10 a. Problem 4. x = 1010 .6 Which of the following is a negation for ”Every polynomial function is continuous”? a.10 Write the negation of the proposition : If an integer is divisible by 2. Determine which of the following propositions are true and which are false. Some polynomial functions are continuous. if x is even then x ≤ 0. e. −14. 23. 3.11 Given the following true propostion:” ∀ real numbers x. ﬁnd an n to make the predicate n > x true. Problem 4. a. if x is odd then x > 0. 26. Every polynomial function fails to be continuous. 0. d. b. then the tens digit is 1 or 2 Problem 4. ∀x ∈ D.7 Determine whether the proposed negation is correct. if the ones digit of x is 6. write a correct negation. d. Proposed negation : For all integer n. 16. x = 15. There is a noncontinuous polynomial function. Proposition : For all integers n. If it is not. if x is less than 0 then x is even. if the ones digit of x is 2. Problem 4. if x(x + 1) > 0 then x > 0 or x < −1. ∀x ∈ D. No polynomial function is continuous. ∀x ∈ D. then the tens digit is 3 or 4. x = 108 c. Provide counterexamples for those propositions that are false.
” . State which is true: the given proposition. b. ∃y ∈ IR such that x < y.” proposition in the form ”∃ a person x such that ∀ Problem 4. ∃ a real number y such that x + y = 0.16 Given the proposition: ∀x ∈ IR. Find the negation of the given proposition. a. b.” Rewrite this . a.” Problem 4.20 Rewrite the following proposition without using the words ”necessary” or ” suﬃcient” : ”Divisibility by 4 is not a necessary condition for divisibility by 2.” Problem 4.15 Given the proposition: There exists a program that gives the correct answer to every question that is posed to it. Problem 4. Rewrite this proposition using quantiﬁers and variables. Problem 4. neither.13 Given the proposition: ∃x ∈ IR. Problem 4.40 FUNDAMENTALS OF MATHEMATICAL LOGIC Problem 4.17 Find the contrapositive. Find the negation of the given proposition. b. Find a negation for the given proposition. and inverse of the proposition ”∀x ∈ IR. or both. b. Rewrite this proposition in English without the use of the quantiﬁers.” a.18 Rewrite the following proposition in ifthen form :” Earning a grade of C − in this course is a suﬃcient condition for it to count toward graduation. the one in part (a). Rewrite this proposition in English without the use of the quantiﬁers. converse. if x(x + 1) > 0 then x > 0 or x < −1. Problem 4. x + y = 0.19 Rewrite the following proposition in ifthen form :” Being on time each day is a necessary condition for keeping this job. a.12 Given the proposition: ∀x ∈ IR.” Problem 4. ∀y ∈ IR. Write a proposition by interchanging the symbols ∀ and ∃.14 Consider the proposition ”Somebody is older than everybody.
˙ Solution.1 Use universal instantiation to ﬁll in valid conclusion for the following argument. if n = 2k for some k ∈ IN then n is even. if n = 2k for some k ∈ IN then n is even. ∀n ∈ IN.5 ARGUMENTS WITH QUANTIFIED PREMISES 41 5 Arguments with Quantiﬁed Premises In this section we discuss three types of valid arguments that involve the universal quantiﬁer. All positive integers are greater than or equal to 1 3 is a positive integer . ˙ P (a) Example 5. if P (x) then Q(x) P (a) f or some a ∈ D . • The rule of universal instantiation: ∀x ∈ D. 3 ≥ 1 ˙ • Universal Modus Ponen: ∀x ∈ D.2 Use the rule of the universal modus ponens to ﬁll in valid conclusion for the following argument.. All positive integers are greater than or equal to 1 3 is a positive integer ...0 .. ˙ Q(a) Example 5. . ∀n ∈ IN.. 0 = 2. P (x) a∈D . ˙ Solution.
.. • The rule of converse error: ∀x ∈ D..0 . Helen is healthy ˙ Solution. Harry does not eat an apple a day.. . ˙ ∼ P (a) Example 5.42 0 = 2. we discuss a couple of invalid arguments whose premises involve quantiﬁers.0 is even ˙ FUNDAMENTALS OF MATHEMATICAL LOGIC • Universal Modus Tollens: ∀x ∈ D. if P (x) then Q(x) Q(a) f or some a ∈ D . This invalid argument exhibits the converse error . . All healthy people eat an apple a day. Harry does not eat an apple a day.3 Use the rule of the universal modus tonens to ﬁll in valid conclusion for the following argument. ˙ Solution. Harry is not healthy ˙ Next.. Helen eats an apple a day. ˙ P (a) Example 5. ..4 What kind of error does the following invalid argument exhibit? All healthy people eat an apple a day. if P (x) then Q(x) ∼ Q(a) f or some a ∈ D . All healthy people eat an apple a day.
Hubert is not a healthy person. . if P (x) then Q(x) ∼ P (a) f or some a ∈ D . ˙ Solution. Hubert does not eat an apple a day. This invalid argument exhibits the inverse error . ˙ ∼ Q(a) Example 5.5 What kind of error does the following invalid argument exhibit? All healthy people eat an apple a day.5 ARGUMENTS WITH QUANTIFIED PREMISES 43 • The rule of inverse error: ∀x ∈ D...
1 Use the rule of universal modus ponens to ﬁll in valid conclusion for the argument. Darth is not honest. and d. b = 3.3 Use the rule of universal modus ponens to ﬁll in valid conclusion for the argument. George sits in the back row. then compilation of the program does not produce error messages. ˙ Problem 5..5 What kind of error does the following invalid argument exhibit? All honest people pay their taxes. b. George is a cheater. . c. .44 FUNDAMENTALS OF MATHEMATICAL LOGIC Review Problems Problem 5. Darth does not pay his taxes. ˙ Problem 5. and d = 5 are particular real numbers such that b = 0 and d = 0. c For all real numbers a..4 What kind of error does the following invalid argument exhibit? All cheaters sit in the back row. . if b = 0 and d = 0 then a + d = ad+bc . All freshmen must take writing. If a computer is correct. c = 4..2 Use the rule of universal modus tonens to ﬁll in valid conclusion for the argument. Compilation of this program produces error messages.. Caroline is a freshman.. ˙ Problem 5. b bd a = 2. . ˙ . . ˙ Problem 5. .
A logic gate is the smallest processing unit in a digital system. The symbol is ∼ (P ∨ Q) or P ↓ Q. such as electronic computers. It takes one or few bits as input and generates one bit as an output. and outputs 1 if P and Q are 1 and 0 otherwise. The logical symbol is P ∧ Q. denoted by P Q. where  is called a Scheﬀer stroke. traﬃc light controls. The symbol is ∼ (P ∧ Q). Also. where ↓ is a Pierce arrow The logic gates have the following graphical representations: . namely high voltage and low voltage we attribute the bit 1 to high voltage and the bit 0 for low voltage. (5) NOR gate: output a 0 if at least one of P or Q is 1 and 1 otherwise. etc. (4) NAND gate: outputs a 0 if both P and Q are 1 and 1 otherwise. The purpose of digital systems is to manipulate discrete information which are represented by physical quantities such as voltages and current. The smallest representation unit is one bit. electronic phones. The corresponding logical symbol is ∼ P. The six basic logic gates are the following: (1) NOT gate (also called inverter): Takes an input of 0 to an output of 1 and an input of 1 to an output of 0.6 PROJECT I: DIGITAL LOGIC DESIGN 45 6 Project I: Digital Logic Design In this section we discuss the logic of digital circuits which are considered to be the basic components of most digital systems. Since electronic switches have two physical states. P and Q. The logical symbol is P ∨ Q. short for binary digit. It takes a group of bits as input and generates one or more bits as output. A circuit is composed of a number of logic gates connected by wires. (2) AND gate: Takes two bits. (3) OR gate: outputs 1 if either P or Q is 1 and 0 otherwise.
A Boolean expression is an expression composed of Boolean variables and connectives (which are the gates in this section). Q = 1. . given that P = 0.2 Give the output signal S for the following circuit. If you are given a set of input signals for a circuit.3 Write the input/output table for the circuit of the previous problem. and R = 0 : Problem 6.46 FUNDAMENTALS OF MATHEMATICAL LOGIC Problem 6.1 Construct the truth tables of the gates discussed in this section. A variable with exactly two possible values is called a Boolean variable. Problem 6. you can ﬁnd its output by tracing through the circuit gate by gate.
6 PROJECT I: DIGITAL LOGIC DESIGN 47 Problem 6. construct (a) the corresponding Boolean expression and (b) the corresponding circuit: P 1 1 1 1 0 0 0 0 Q 1 1 0 0 1 1 0 0 R 1 0 1 0 1 0 1 0 S 0 1 0 0 1 0 0 0 Two digital logic circuits are equivalent if. Problem 6.8 Consider the following circuit .4 Find the Boolean expression that corresponds to the circuit of Problem 6. and only if.7 Show that the following two circuits are equivalent: Problem 6.1. Problem 6.6 For the following input/output table.5 Construct the circuit corresponding to the Boolean expression: (P ∧ Q)∨ ∼ R. Problem 6. their corresponding Boolean expressions are logically equivalent.
there are two ways for storing 0. +4110 = 00101001 and −4110 = 10101001. This is called the one complement of 41. The above procedure has a gap. increment by 1 the one’s complement to obtain −4110 = 11010111. Conversion of +4110 to two’s complement consists merely of expressing the number in binary. Complete the following table P Q R S 1 1 1 0 0 1 0 0 The given circuit is called a halfadder. 0 for positive and 1 for negative. To complete the procedure. . Thus.48 FUNDAMENTALS OF MATHEMATICAL LOGIC Let P and Q be single binary digits and P + Q = RS. Several methods have been used for expressing negative numbers in the computer. convert the absolute value to binary obtaining 4110 = 00101001. Suppose that integers are stored using this signedmagnitude technique in 8 bits so that the leftmost bit holds the sign while the remaining bits represent the magnitude. Then take the complement of each bit obtaining 11010110. One way is 00000000 which represents +0 and a second way 10000000 represents −0. ﬁrst. A method for representing numbers that avoid this problem is called the two’s complement. The most obvious way is to convert the number to binary and stick on another bit to indicate sign.e. Considering −4110 again. It computes the sum of two single binary digits. +4110 = 00101001. i. How one would represent the bit 0? Well.
Now. write the decimal equivalent of the result. Problem 6.10 What is the decimal representation for the integer with two’s complement 10101001? .9 Express the numbers 104 and −104 in two’s complement representation with 8 bits. 2.6 PROJECT I: DIGITAL LOGIC DESIGN 49 Problem 6. an algorithm to ﬁnd the decimal representation of the integer with a given 8bit two’s complement is the following: 1. Find the two’s complement of the given two’s complement.
d1 . Consider ﬁrst the decimal system. namely. Thus. · · · . Decimal numbers are used in communication among human beings whereas binary numbers are used by computers to represent numbers. the decimal system. If n is a number in base 2 then its decimal value (i. base 10) is found by the formula: n2 = bk (2k ) + bk−1 (2k−1 ) + · · · + b1 (21 ) + b0 (20 ) = m10 . 2. we write n2 = bk bk−1 · · · b1 b0 to indicate that the number n is in base 2. For example. 5049 = 5(103 ) + 0(102 ) + 4(101 ) + 9(100 ). A number in binary system is a number n that can be written in the form n = bk bk−1 · · · b1 b0 . · · · . the binary system. and the hexadecimal system. where bi is either 0 or 1.e. If n is a positive integer then n can be written as n = dk dk−1 · · · d1 d0 . The number n can be expressed as a sum of powers of 10 as follows: n = dk 10k + dk−1 10k−1 + · · · + d1 101 + d0 100 .1 Find the decimal value of the following binary numbers: a. 1101102 .50 FUNDAMENTALS OF MATHEMATICAL LOGIC 7 Project II: Number Systems In this section we consider three number systems that are of importance in applications. We will use subscript to tell the base of which a number is represented. Problem 7. 1. dk are elements of the set {0. 9}. 11001012 b. where the digits d0 .
45810 Problem 7. and 15 respectively. The conversion of a number from base 10 to base 16 is similar to the conversion of a decimal number to base 2. E. The conversion of a number from base 16 to base 10 is similar to the conversion of numbers from base 2 to base 10. If not then divide q0 by 2 to obtain q0 = q1 (2) + r1 . 7.7 PROJECT II: NUMBER SYSTEMS 51 To convert a positive integer n from base 10 to base 2 we use the division algorithm as follows: (1) n = q0 (2) + r0 . 5. (2) Juxtapose the results. 9. (2) If q0 = 0 then n is already in base 2. . 6. 1. 12. 2. If not repeat the process. 110111012 + 10010110102 b.3 Evaluate the following sums: a. Problem 7. To convert an integer from base 16 to base 2 one performs the following: (1) Write each hexadecimal digit of the integer in ﬁxed 4bit binary notation. 13. Suppose that qk = 0 then n10 = rk rk−1 · · · r1 r0 . 1011012 + 111012 Another useful number system is the hexadecimal system. B. Note that the remainders are all less than 2. C. Problem 7. 8. The possible digits in an hexadecimal system are : 0. E. 11. 14. C. D. B. (3) If q1 = 0 then n10 = r1 r0 .4 Convert the number A2BC16 to base 10. 129710 b. where q0 is the quotient of the division of n by 2 and r0 is the remainder. A. F where A. 4. F stand for 10. 3. D.2 Represent the following decimal integers in binary notation: a.
(2) Convert the binary numbers in (1) to base 16.52 FUNDAMENTALS OF MATHEMATICAL LOGIC Problem 7.5 Convert the number B53DF 816 to base 2. To convert an integer from base 2 to base 16: (1) Group the digits of the binary number into sets of four bits. starting from the right and adding leading zeros as needed. (3) Juxtapose the results of (2) Problem 7. .6 Convert the number 1011011110001012 to base 16.
there is exactly one line that contains them. 8 Methods of Direct Proof I A mathematical system consists of axioms. Example 8. A lemma is a theorem that is usually not interesting in its own right but is useful in proving another theorem. then the angles opposite them are equal. An axiom is a statement that is assumed to be true. deﬁnitions.1 The Euclidean geometry furnishes an example of mathematical system: • points and lines are examples of undeﬁned terms. • An example of a theorem: If two sides of a triangle are equal. A deﬁnition is used to create new concepts in terms of existing ones. • An example of a corollary: If a triangle is equilateral. Logic is a tool for the analysis of proofs. A theorem is a proposition that has been proved to be true. A corollary is a theorem that follows quickly from a theorem. An argument that establishes the truth of a theorem is called a proof. 53 .Fundamentals of Mathematical Proofs In this chapter we discuss some common methods of proof and the standard terminology that accompanies them. and undeﬁned terms. • An example of an axiom: Given two distinct points. • An example of a deﬁnition: Two angles are supplementary if the sum of their measures is 180◦ . then it is equiangular.
then one check the truth value of P (x) for each x ∈ D. Solution.54 FUNDAMENTALS OF MATHEMATICAL PROOFS First we discuss methods for proving a theorem of the form ”∃x such that P (x). Let us ﬁrst consider a proposition of the form ∀x ∈ D.” This theorem guarantees the existence of at least one x for which the predicate P (x) is true. n2 − n + 11 is a prime number. Solution.3 Show that there exists an integer x such that x2 = 15. Theorems are often of the form ”∀x ∈ D if P (x) then Q(x). The disadvantage of nonconstructive method is that it may give virtually no clue about where or how to ﬁnd x. the proof is either by ﬁnding a particular x that makes P (x) true or by exhibiting an algorithm for ﬁnding x.” If D is a ﬁnite set. This method is called the method of exhaustion. The proof of such a theorem is constructive: that is. if 1 ≤ n ≤ 10 . Example 8. Indeed. 129. P (x). Example 8. Then this can be written in the form ”∀x.4 Show that for each integer 1 ≤ n ≤ 10. if x ∈ D then P (x). Applying the wellknown algorithm of extracting the square root we ﬁnd that x = 123 By a nonconstructive existence proof we mean a method that involves either showing the existence of x using a proved theorem (or axioms) or the assumption that there is no such x leads to a contradiction. Solution. The given proposition can be written in the form ”∀n ∈ IN. one example is 52 = 32 + 42 Example 8.2 Show that there exists a positive integer which can be written as the sum of the squares of two numbers.” We call P (x) the hypothesis and Q(x) the conclusion.
8 METHODS OF DIRECT PROOF I 55 then P (n)” where P (n) = n2 − n + 11. By a direct method of proof we mean a method that consists of showing that if P (x) is true for x ∈ D then Q(x) is also true. P (2) = 13 P (5) = 31 . Indeed. It is called the method of generalizing from the generic particular. Theorem Every integer is a rational number. Theorem 8. P (4) = 23 . m + n is even Example 8. . and then using deﬁnitions. m ∈ Z . Then there exist integers k1 and k2 such that n = 2k1 and m = 2k2 . Proof. The following shows the format of the proof of a theorem. if m and n are even then so is m + n.5 Prove the following theorem. that is. an integer multiple of 2. We must show that m + n is even. Using the method of exhaustion we see that P (1) = 11 . by the deﬁnition of even. The method consists of picking an arbitrary element x of the domain (known as a generic element) for which the hypothesis P (x) is satisﬁed. m + n = 2k1 + 2k2 = 2(k1 + k2 ) = 2k where k = k1 + k2 ∈ Z . P (6) = 41 P (9) = 83 . previously established results.1 For all n. P (8) = 67 The most powerful technique for proving a universal proposition is one that works regardless of the size of the domain over which the proposition is quantiﬁed. Thus. P (3) = 17 . Let m and n be two even integers. . P (10) = 101. P (7) = 53 . and the rules of inference to conclude that Q(x) is also true.
suppose that m and n are any two given even integers. The author of the proof has jumped prematurely to a . Proof. Proof. q a + b ∈Q I Corollary 8. I I n . • Arguing from examples. Then by writing m = 2k and n = 2k this would imply that m = n which is inconsistent with the statement that m and n are arbitrary. For example. • Using the same letters to mean two diﬀerent things. Then. b1 = 0. That is. The problem with this proof is that the crucial step m − n = 2k − n − n = 2(k − n) is missing. Then there is an integer k such that m + n = 2k. Suppose that we want to show that if the sum of two integers is even so is their diﬀerence. The validity of a general statement can not be proved by just using a particular example. By the property of addition of two b b fractions we have 1 2 a + b = a1 + a2 b b a1 b2 +a2 b1 = b1 b2 By letting p = a1 b2 + a2 b1 ∈ Z and q = b1 b2 ∈ Z ∗ we get a + b = p .1 The double of a rational number is rational. m = 2k − n and so m − n is even. Let us illustrate by an example. 1 By the deﬁnition of Proof. 2 1 and b2 = 0 such that a = a1 and b = a2 . a2 . n is rational Theorem 8.56 FUNDAMENTALS OF MATHEMATICAL PROOFS Solution.2 If a. we point out of some common mistakes that must be avoided in proving theorems. Let a = b in the previous theorem we see that 2a = a + a = a + b ∈ Q I Next. Let a and b be two rational numbers. Then n = rational numbers. Consider the following proof: Suppose that m + n is even. Then there exist integers a1 . • Jumping to a conclusion. Let n be an arbitrary integer. b ∈ Q then a + b ∈ Q.
Such an x is called a counterexample.8 METHODS OF DIRECT PROOF I conclusion. to show that a proposition of the form ∀x ∈ D. Then a < b but a2 > b 2 . A counterexample is the following. Finally. b ∈ IR. if a < b then a2 < b2 .6 Disprove the proposition ∀a. Let a = −2 and b = −1. Example 8. Solution. if P (x) then Q(x) is false it suﬃces to ﬁnd an element x ∈ D where P (x) is true but Q(x) is false. 57 • Begging the question. By that we mean that the author of a proof uses in his argument a fact that he is supposed to prove.
The product of two rational numbers is a rational number.4 Use the method of constructive proof to show that if r and s are two real numbers then there exists a real number x such that r < x < s. A real number that is not rational is called irrational.58 FUNDAMENTALS OF MATHEMATICAL PROOFS Review Problems A real number r is called rational if there exist two integers a and b = 0 such that r = a . Corollary. is a rational number. If A < MINN THEN MINN := A END .3 Use the previous exercise to prove the following. Problem 8.1 Show that the number r = 6.2 Prove the following theorem. b Problem 8. MINN := 0.5 The following Pascal program segment does not ﬁnd the minimum value in a data set of N integers. Problem 8.321521521. Find a counterexample. Theorem. The square of any rational number is rational. Problem 8.. Problem 8.. FOR I := 1 TO N DO BEGIN READLN (A).
· · · . Then there is k ∈ IN such that n = 2k. Solution. Since the proposition n is divisible by 1 is always true. Since the proposition x ∈ ∅ is always false. Example 9.3 Show that if n is a positive integer then n3 + n is even. Then there is a k ∈ IN such that n = 2k + 1. n3 + n = 8k 3 + 2k = 2(4k 3 + k) which is even. Case 1. the given implication is trivially true The method of proof by cases is a direct method of proving the conditional proposition p1 ∨ p2 ∨ · · · ∨ pn → q. pn → q. In this case.1 Use the method of vacuous proof to show that if x ∈ ∅ then David is playing pool. Case 2. Suppose that n is even. the given proposition is vacuously true A trivial proof of an implication p → q is one in which q is shown to be true without any reference to p. Solution. n3 + n = 2(4k 3 + 6k 2 + 4k + 1) which is even . The method consists of proving the conditional propositions p1 → q. We use the method of proof by cases.9 MORE METHODS OF PROOF 59 9 More Methods of Proof A vacuous proof is a proof of an implication p → q in which it is shown that p is false. p2 → q.2 Use the method of trivial proof to show that if n is an even integer then n is divisible by 1. Solution. So. Suppose that n is odd. Example 9. Example 9.
999 = 38. The largest integer n such that n ≤ x < n + 1 is called the ﬂoor of x and is denoted by x . Then x + y < 0 and therefore x + y = −(x + y) = (−x) + (−y) = x + y.001 = −15. 2 2 c. x ≥ 0 and y < 0.5. − 57 c. Case 1. 37. −14. n = 2 n . Thus. Then x + y < x + 0 < x ≤ x + y. Let x = y = 0.001 = −14. Solution. Then x + y = 1 and x + y = 0 The following gives another example of the method of proof by cases. 2 if n is even if n is odd .1 For any integer n. y ∈ IR. Example 9.4 Use the proof by cases to prove the triangle inequality: x + y ≤ x + y. 37. b. Now. So in all four cases x + y ≤ x + y.999 = 37. x ≥ 0 and y ≥ 0. Case 4. The smallest integer n such that n − 1 < x ≤ n is called the ceiling of x and is denoted by x . −14. − 57 = −28. The case x < 0 and y ≥ 0 is similar to case 2.60 FUNDAMENTALS OF MATHEMATICAL PROOFS Example 9. −(x + y) = −x + (−y) ≤ 0 + (−y) = y ≤ x + y. − 57 = −29. a. Suppose x < 0 and y < 0. x + y = x + y ” is false. 37. given a real number x. Theorem 9. Case 2. Solution. 2 n−1 .999 b.5 Compute x and x of the following values of x : a. On the other hand. Case 3. Example 9.6 Use the proof by a counterexample to show that the proposition ”∀x. Then x + y ≥ 0 and so x + y = x + y = x + y. if x + y = x + y then x + y < x + y and if x + y = −(x + y) then x + y ≤ x + y. −14.001 2 Solution.
61 Case 1. Let n be any integer. n is odd. Then we consider the following two cases. 2 2 . Hence. Suppose n is even.9 MORE METHODS OF PROOF Proof. 2 2 Case 2. Then there is an integer k such that n = 2k. there is an integer k such that n = 2k + 1. In this case. Hence. n = k = k = n . It follows that 2 n n−1 =k= . Since n = 2k + 1 then solving this equation for k 2 we ﬁnd k = n−1 . n 2k + 1 1 = = k+ =k 2 2 2 since k ≤ k + 1 < k + 1.
a contradiction. Suppose n is a nonnegative integer.2 Given any nonnegative integer n and a positive integer d there exist integers q and r such that n = dq + r and 0 ≤ r < d. So let S = {n − d · k ∈ IN : k ∈ Z }.3 If n is a nonnegative integer and d is a positive integer by letting q = and r = n − d n . Then n − d · (q + 1) = r − d ≥ 0 so that n − d · (q + 1) ∈ S.3 Prove that for any integer n. i. Problem 9. there is an integer q such that n − d · q = r or n = d · q + r. By substitution we have d dq + r = d n n +n−d = n. called r. The number q is called the quotient of the division of n by d and we write q = n div d. Thus. r ≥ d.2 Prove that the square of any integer has the form 4k or 4k + 1 for some integer k Problem 9.e.1 Prove that for any integer n the product n(n + 1) is even. n(n2 − 1)(n + 2) is divisible by 4. d d n d n d and . Theorem 9.q = r = n − d n . Hence. r < d The following theorem shows a way for ﬁnding q and r. That is. The number r is called the remainder and we write r = n mod d or n ≡ r(mod d). Hence. d is a positive integer. and 0 ≤ r < d. The proof uses the fact that any nonempty subset of IN has a smallest element. Theorem 9. we have d n = dq + r. if n ∈ IN then n = n−0·d ≥ 0 and if n < 0 then n−d·n = n·(1−d) ≥ 0. r ≤ n − d · (q + 1) = r − d.62 FUNDAMENTALS OF MATHEMATICAL PROOFS Review Problems Problem 9. This set is nonempty. Proof. Suppose the contrary. Indeed. It remains to show that r < d. S is a nonempty subset of IN so it has a smallest elements. Proof.
0 ≤ r < d. Problem 9.4 State a necessary and suﬃcient condition for the ﬂoor function of a real number to equal that number Problem 9. n = n − dq.8 Prove that for all real numbers x and all integers m. Problem 9. x + m = x + m. By the deﬁnition of the ﬂoor function we have n q ≤ < q + 1.9 Show that if n is an odd integer then n 2 n+1 .6 Show that the equality x − y = x − y is not valid for all real numbers x and y.9 MORE METHODS OF PROOF 63 It remains to show that 0 ≤ r < d. This completes a proof of the theorem r =n−d Problem 9. This implies that 0 ≤ n − dq < d.5 Prove that if n is an even integer then n 2 But = n. d Hence. d Multiplying through by d we ﬁnd dq ≤ n < dq + d. 2 = . 2 Problem 9.7 Show that the equality x + y = x + y is not valid for all real numbers x and y. Problem 9.
. Hence. 2 must be irrational Theorem 10. the proof by contradiction and the proof by contrapositive. That is. Squaring n both sides of this equality we ﬁnd that 2n2 = m2 . This says that n2 is even and by Theorem 10. Any other method of proof will be referred to as an indirect proof. Proof.2 √ The number 2 is irrational. That is suppose that n is odd. • Proof by contradiction: We want to show that p is true. But then m = 2k for some integer k. By the rule of contradiction discussed in Chapter 1. By Theorem 10. n must be even Theorem 10.64 FUNDAMENTALS OF MATHEMATICAL PROOFS 10 Methods of Indirect Proofs: Contradiction and Contraposition Recall that in a direct proof one starts with the hypothesis of an implication p → q and then prove that the conclusion is true.1. Taking the square we ﬁnd that 2n2 = m2 = 4k 2 . n2 = 2(2k 2 + 2k) + 1 is odd and this contradicts the assumption that n2 is even. we assume it is not and therefore ∼ p is true and then derive a contradiction. Thus. We conclude that 2 divides both m and n and this contradcits our assumption that m and n √ have no common divisors. Theorem 10. In this section we study two methods of indirect proofs. Proof. Then there is an integer k such that n = 2k + 1. That is. In this case.1. √ Suppose not. n is even. 2 divides m. Then there exist two √ integers m and n with no common divisors such that 2 = m . namely.1 If n2 is an even integer so is n. m2 is even. Suppose the contrary. suppose that 2 is rational. Hence. that is n2 = 2k 2 .3 The set of prime numbers is inﬁnite. p must be true. m is even.
Proof. · · · . suppose that the set of prime numbers is ﬁnite. Theorem 10. Now. pn .10 METHODS OF INDIRECT PROOFS: CONTRADICTION AND CONTRAPOSITION65 Proof. ( See Exercise ??) N can be factored into primes. . So to prove p → q we sometimes instead prove ∼ q →∼ p. Then these prime numbers can be listed. say. p1 . p2 . Thus. But since pi p1 p2 · · · pn then pi (N − p1 p2 · · · pn ) = 1. But then n2 = 2(2k 2 ) which is even. That is. Suppose that n is an integer that is even. Then there exists an integer k such that n = 2k. • Proof by contrapositive: We already know that p → q ≡∼ q →∼ p.4 If n is an integer such that n2 is odd then n is also odd. there is a prime number pi such that pi N. Suppose not. a contradiction since pi > 1. consider the integer N = p1 p2 · · · pn +1. By the Unique Factorization Theorem.
Problem 10. then at least one of the numbers is greater than 10.” Problem 10.4 Use the proof by contradiction to show that the product of any nonzero rational number and any irrational number is irrational.1 Use the proof by contradiction to prove the proposition ”There is no greatest even integer. Problem 10.66 FUNDAMENTALS OF MATHEMATICAL PROOFS Review Problems Problem 10. .2 Prove by contradiction that the diﬀerence of any rational number and any irrational number is irrational.3 Use the proof by contraposition to show that if a product of two positive real numbers is greater than 100.
a method of proof that has been useful in every area of mathematics as well. Also. you need mathematical induction.1 Use the technique of mathematical induction to show that 1 + 2 + 3 + ··· + n = n(n + 1) . S(n) = n(n+1) . sums of the form n n(n + 1) k= 2 k=1 are very useful in analysis of algorithms and a proof of this formula is mathematical induction. Then (i) (Basis of induction) S(1) = 1 = 1(1+1) . Consider an arbitrary loop in Pascal starting with the statement F OR I := 1 T O N DO If you want to verify that the loop does something regardless of the particular integral value of N. (iii) (Induction step) Show that P (n + 1) is true. 2 n ≥ 1.11 METHOD OF PROOF BY INDUCTION 67 11 Method of Proof by Induction With the emphasis on structured programming has come the development of an area called program veriﬁcation. Next we examine this method. Example 11. Let S(n) = 1 + 2 + · · · + n. We want to prove that some predicate P (n) is true for any nonnegative integer n ≥ n0 . One technique essential to program veriﬁcation is mathematical induction. which means your program is correct as you are writing it. That is. That is. (ii) (Induction hypothesis) Assume P (n) is true. 2 . Solution. The steps of mathematical induction are as follows: (i) (Basis of induction) Show that P (n0 ) is true. 2 (ii) (Induction hypothesis) Assume S(n) is true. S(1)is true.
k=0 (ii) (Induction hypothesis) Assume S(n) is true. Show that 1 + 1 + · · · + 2n−1 ≤ 2. 2 (iii) (Induction step) We must show that S(n + 1) = Indeed. 1−r 1 b. That is. By a. k=0 a(1−r n+2 ) (iii) (Induction step) We must show that S(n + 1) = 1−r . S(1)is true. Let S(n) = n ark . S(n) = n ark . (i) (Basis of induction) S(0) = a = 0 ark .2 (Geometric progression) a. 1−r b. n+1 k S(n + 1) = k=0 ar n+1 = S(n) + ar 1−r n+1 1−r = a 1−r + arn+1 1−r n+1 +r n+1 −r n+2 = a 1−r 1−r n+2 = a 1−r . n ≥ 0 where r = 1. Indeed. . Use induction to show that k=0 n+1 S(n) = a(1−r ) . we have 1+ 1 + 2 1 22 + ··· + 1 2n−1 = 1−( 1 )n 2 1− 1 2 = = ≤ 2(1 − ( 1 )n ) 2 1 2 − 2n−1 2. 2 Solution. Use induction to show that S(n) = k=1 n [2a + (n − 1)r]. for all n ≥ 1. We use the method of proof by mathematical induction. We use the method of proof by mathematical induction. That is. a. 2 Solution. Example 11.3 (Arithmetic progression) Let S(n) = n (a + (k − 1)r). S(n + 1) = 1 + 2 + · · · + n + (n + 1) = S(n) + (n + 1) n(n+1) = + (n + 1) 2 (n+1)(n+2) = 2 Example 11.68 FUNDAMENTALS OF MATHEMATICAL PROOFS (n+1)(n+2) . n ≥ 1.
Let P (n) : 22n − 1 is divisible by 3. S(n) = n [2a + (n − 2 1)r]. Indeed. Use induction to prove that 2n < n! for all nonnegative integers n ≥ 4. 22n+2 − 1 = 22n (4) − 1 2n = 2 (3 + 1) − 1 2n = 2 · 3 + (22n − 1) = 22n · 3 + P (n) Since 3(22n − 1) and 3(22n · 3) we have 3(22n · 3 + 22n − 1). Proof. This ends a proof of the theorem Example 11.4 a. Then (i) (Basis of induction) P (1) is true since 3 is divisible by 3. 22n − 1 is divisible by 3. a. (iii) (Induction step) We must show that S(n + 1) = (n+1) [2a + nr].1 For all integers n ≥ 1. That is. 22n − 1 is divisible by 3. Theorem 11. Solution. (iii) (Induction step) We must show that 22n+2 − 1 is divisible by 3. b. Indeed. S(1)is true. Let S(n) = 2n − n. That is. 2 (ii) (Induction hypothesis) Assume S(n) is true. Use induction to prove that n < 2n for all nonnegative integers n. (ii) (Induction hypothesis) Assume P (n) is true. That is.11 METHOD OF PROOF BY INDUCTION 69 (i) (Basis of induction) S(1) = a = 1 [2a + (1 − 1)r]. 2 S(n + 1) = = = = = = + (k − 1)r) S(n) + a + (n + 1 − 1)r n [2a + (n − 1)r] + a + nr 2 2an+n2 r−nr+2a+2nr 2 2a(n+1)+n(n+1)r 2 n+1 [2a + nr]. n ≥ 0. We want to show that S(n) > 0 is valid for all . 2 n+1 k=1 (a We next exhibit a theorem whose proof uses mathematical induction.
(ii) (Induction hypothesis) Assume S(n) is true. (iii) (Induction step) We must show that S(n + 1) > 0.5 (Bernoulli’s inequality) Let h > −1. n ≥ 0. (iii) (Induction step) We must show that S(n + 1) > 0. By the method of mathematical induction we have (i) (Basis of induction) S(0) = 20 − 0 = 1 > 0. n ≥ 4. We want to show that S(n) ≥ 0 for all n ≥ 0. (i) (Basis of induction) S(0) = (1 + h)0 − (1 + 0h) = 0.70 FUNDAMENTALS OF MATHEMATICAL PROOFS n ≥ 0. n ≥ 0. That is. S(n) > 0.2 − n − 1 n = 2 (1 + 1) − n − 1 = 2n − n + 2n − 1 = (2n − 1) + S(n) > 2n − 1 ≥ 0 since the smallest value of n is 0 and in this case 20 − 1 = 0. (ii) (Induction hypothesis) Assume S(n) is true. By the method of mathematical induction we have (i) (Basis of induction) S(4) = 4! − 24 = 8 > 0. b. That is. That is. Let S(n) = n! − 2n . Let S(n) = (1 + h)n − (1 + nh). (ii) (Induction hypothesis) Assume S(n) is true. S(n + 1) = 2n+1 − (n + 1) = 2n . S(n) > 0. Solution. S(0)is true. That is. That is. We use mathematical induction as follows. S(4)is true. Use induction to show that (1 + nh) ≤ (1 + h)n . Indeed. Indeed. That is. S(n) ≥ 0. n ≥ 4. We want to show that S(n) > 0 for all n ≥ 4. . S(n + 1) = (n + 1)! − 2n+1 = (n + 1)n! − 2n (1 + 1) = n! − 2n + nn! − 2n > 2(n! − 2n ) = 2S(n) > 0 where we have used the fact that if n ≥ 1 then nn! ≥ n! Example 11. S(0)is true.
an = 2. an = 2. a3 = 50. Find a formula for an and then prove its validity by mathematical induction.5n−1 . (i) (Basis of induction) a1 = 2 = 2. S(n + 1) = (1 + h)n+1 − (1 + (n + 1)h) = (1 + h)(1 + h)n − nh − 1 − h ≥ (1 + h)(1 + nh) − nh − 1 − h = nh2 ≥ 0. (ii) (Induction hypothesis) Assume an is true.51−1 .5n−1 ) = 2. Thus. a4 = 250. Indeed.5n . an+1 = 5an = 5(2. We will show that this formula is valid for all n ≥ 1 by the method of mathematical induction. a1 = 2.5n−1 (iii) (Induction step) We must show that an+1 = 2. a1 is true. Solution. Indeed. Listing the ﬁrst few terms we ﬁnd. an = 5an−1 . That is. a2 = 10. . That is. 71 Example 11.5n .6 Deﬁne the following sequence of numbers: a1 = 2 and for n ≥ 2.11 METHOD OF PROOF BY INDUCTION (iii) (Induction step) We must show that S(n + 1) ≥ 0.
Problem 11. Problem 11.72 FUNDAMENTALS OF MATHEMATICAL PROOFS Review Problems Problem 11.5 Use mathematical induction to show that 1 1 1 n + + ··· + = 1·2 2·3 n(n + 1) n+1 for all integers n ≥ 1. Problem 11.1 Use the method of induction to show that 2 + 4 + 6 + · · · + 2n = n2 + n for all integers n ≥ 1. Problem 11.2 Use mathematical induction to prove that 1 + 2 + 22 + · · · + 2n = 2n+1 − 1 for all integers n ≥ 0.4 Use mathematical induction to show that 1 + 2 + ··· + n = for all integers n ≥ 1. 3 3 3 n(n + 1)(2n + 1) 6 n(n + 1) 2 2 .3 Use mathematical induction to show that 12 + 22 + · · · + n2 = for all integers n ≥ 1.
Evaluate S(1).12 a. 2 2 2 Problem 11. In a proof by mathematical induction that this divisibility property holds for all integers n ≥ 1. b. Make a k=1 conjecture about a formula for this sum for general n. Show that an = 3 · 7n−1 for all integers n ≥ 1. Prove this property by mathematical induction.11 Show that 2n < (n + 2)! for all integers n ≥ 0. . Problem 11. a2 . S(3). Problem 11.11 METHOD OF PROOF BY INDUCTION Problem 11. Use mathematical induction to show that n3 > 2n + 1 for all integers n ≥ 2. and prove your conjecture by mathematical induction. c.8 k Let S(n) = n (k+1)! .13 A sequence a1 . · · · is deﬁned by a1 = 3 and an = 7an−1 for n ≥ 2. d. Write P (k + 1). 000. Is P (1) true? b.7 Find the value of the geometric sum 1 1 1 1 + + 2 + ··· + n. Use mathematical induction to show that n! > n2 for all integers n ≥ 4.6 Use the formula 1 + 2 + ··· + n = to ﬁnd the value of the sum 3 + 4 + · · · + 1. 73 n(n + 1) 2 Problem 11. Write P (1). what must be shown in the induction step? Problem 11.10 For each positive integer n let P (n) be the proposition 23n − 1 is divisible by 7. Write P (k). S(4). and S(5). S(2). Problem 11.9 For each positive integer n let P (n) be the proposition 4n −1 is divisible by 3. a. Problem 11.
3 Let m and n be positive integers with m > n. Problem 12. a.1 Let a = 0.74 FUNDAMENTALS OF MATHEMATICAL PROOFS 12 Project III: Elementary Number Theory and Mathematical Proofs Recall that the set of positive integers together with zero is denoted by IN. Is 6m + 4n2 + 3 odd? Let a and b be two integers with a = 0. For example. Problem 12. (i) If ab and ac then a(b ± c). An integer n is said to be odd if and only if there exists an integer k such that n = 2k + 1. In this case we say that a divides b. . a is a factor of b. 3 7 whereas 312. For example. We say that b is divisible by a. I We say that an integer n is even if and only if there exists an integer k such that n = 2k. Problem 12.2 Prove the following theorem. The set of all integers is denoted by Z and the set of rational numbers is denoted by Q. A number which is not prime is called a composite number.1 Let m and n be two integers. Theorem 12. (iii) If ab and bc then ac. Is 6m + 8n an even integer? b. (ii) If ab then abc. and b is a multiple of a. and c be integers. b = 0. Is m2 − n2 composite? Problem 12. written ab. A positive integer p > 1 is called prime if 1 and p are the only divisors of p.4 Write the ﬁrst 7 prime numbers. 3 is prime whereas 10 is composite. if there exists an integer k such that b = ka.
where the prime factors are written in increasing order. . This divisor is either prime or.5 If a positive number p is composite then one can always write p as the product of primes. by the Fundamental Theorem of Arithmetic has √ prime divisor. The following important theorem shows that if a number is not divisible by any prime less than to its square root then the number must be prime. Write √ √ √ √ and then n = ab > n n = n. n = ab. n has a positive divisor which is √ less than or equal to n. Hence.6 Use the previous theorem to show that the number 101 is prime.2 If n is a composite integer. Since n is composite. n has a prime a divisor less than or equal to n Problem 12. then n has a prime divisor less than or equal to √ n. a false conclusion.12 PROJECT III: ELEMENTARY NUMBER THEORY AND MATHEMATICAL PROOFS75 Problem 12. Theorem 12. there is a divisor a of n such that 1 < a < n. either a ≤ n or b ≤ n. This result is known as the Fundamental Theorem of Arithmetic or the Unique Factorization Theorem. In either case. Proof. Write the prime factorization of 180. If a > n √ b > n√ Thus.
for ﬁnding the greatest common divisor of two nonnegative integers a and b with b = 0. n (i) Find gcd(120. r). d2 ≤ d1 . d2 bq.b2 ) p2 · · · pmin(an . Also d2 r. if d is the largest integer such that da and db. We say that d is the greatest common divisor of a and b. Since d2 b. b.b2 ) · · · pn . 500). Proof. if m is the smallest positive integer that is divisible by both a and b. We conclude that d1 = d2 Using Lemma 13.2 We say that m is the least common multiple of two positive integers a and b.bn ) . where 0 ≤ r1 < b. b).bn ) max(a1 . r). b = pb1 pb2 · · · pbn . Dividing a by b we obtain a = bq + r1 .b1 ) max(a2 . b) = gcd(b. (ii) Show that 17 and 22 are relatively prime. (i) Show that if a ≡ b mod n and c ≡ d mod n then a + c ≡ b + d mod n. q.1 we derive an algorithm. (iii) What are the solutions of the linear congruences 3x ≡ 4(mod7)? Lemma 13. then 1 2 1 2 n n d = p1 min(a1 . and r be integers such that a = bq + r. b) and d2 = gcd(b. If d = 1 then we say that a and b are relatively prime. Using the notation of the previous exercise m is max(an . Hence. 500). Let d1 = gcd(a. Consequently d2 (bq + r) that is d2 a. p2 given by m = p1 Problem 13. .1 (Euclidean Algorithm) Let a. (ii) Show that if a ≡ b mod n and c ≡ d mod n then ac ≡ bd mod n. written m = lcm(a. Problem 13. A similar argument shows that d1 ≤ d2 . To ﬁnd d one writes the prime factorization of both a and b. called the Euclidean Algorithm. Find lcm(120.3 Recall that a ≡ b mod n if and only if a − b = kn for some integer k. b). We will show that d1 = d2 . Then gcd(a.b1 ) min(a2 .76 FUNDAMENTALS OF MATHEMATICAL PROOFS 13 Project IV: The Euclidean Algorithm Problem 13.1 Let a and b be two integers not both equal to zero. say a = pa1 pa2 · · · pan . written d = gcd(a.
b) = gcd(b. Repeating the above process. r2 ). Use the Euclidean algorithm to ﬁnd gcd(287. we will end up with rn = rn+1 qn+1 . Use the Euclidean algorithm to ﬁnd gcd(414. r1 ) = gcd(r1 .1 we have gcd(b. ultimately.13 PROJECT IV: THE EUCLIDEAN ALGORITHM 77 By Lemma 13.4 a. 91). b). b. r1 ). By Lemma 13. Again by Lemma 13. r2 ) = gcd(r2 . . If r2 = 0 then we divide r1 by r2 to obtain r1 = r2 q2 + r3 . Problem 13.1 we have gcd(a. If r1 = 0 then we divide b by r1 to obtain b = r1 q1 + r2 . where 0 ≤ r2 < r1 . where 0 ≤ r3 < r2 . r3 ). In this case rn+1 = gcd(a.1 we have gcd(r1 . 662).
We also examine four operations on matrices. amn where the aij ’s are the entries of the matrix. . .... The ith row of the matrix A is [ai1 ..78 FUNDAMENTALS OF MATHEMATICAL PROOFS 14 Project V: Induction and the Algebra of Matrices In this section.1 Find x1 .. Two matrices are said to be equal if they have the same size and their corresponding entries are all equal.. . addition. . A matrix A can be represented with the following compact notation A = (aij ).. ai2 . A= ... we introduce the concept of a matrix. n is the number of columns. The n × n identity matrix In is a square matrix whose main diagonal consists of 1 s and the oﬀ diagonal entries are all 0. am1 am2 . m is the number of rows. The zero matrix 0 is the matrix whose entries are all 0. Problem 14.. If the matrix A is not equal to the matrix B we write A = B.equality... x2 and x3 such that x1 + x2 + 2x3 0 1 9 0 1 2 3 2x1 + 4x2 − 3x3 = 2 3 1 4 3x1 + 6x2 − 5x3 5 4 0 5 .. a21 a22 . array of the form a1n a2n . A matrix A of size m × n is a rectangular a11 a12 .. .. and multiplication. ain ] and the jth column is a1j a2j . amj In what follows we discuss the basic arithmetic of matrices.. scalar multiplication..
c. The transpose of A.B = 2 1 3 5 .5 Let A be an m × n matrix. b. We deﬁne. Problem 14. Problem 14. then the product cA is the matrix obtained by multiplying each entry of A by c. then the sum A + B is the matrix obtained by adding together the corresponding entries in the two matrices. A + C and B + C. Hence. and d a−b b+c 3d + c 2a − 4d = 8 1 7 6 Next. Matrices of diﬀerent sizes cannot be added. Find the transpose of the matrix A= 2 3 4 1 2 1 . if possible.14 PROJECT V: INDUCTION AND THE ALGEBRA OF MATRICES 79 Problem 14. A−B = A + (−B).3 Consider the matrices A= 2 1 3 4 . 2 3 4 1 2 1 . is the n × m whose columns are the rows of A. −A = (−1)A. Problem 14.C = 2 1 0 3 4 0 Compute. The matrix cIn is called a scalar matrix. we introduce the operation of addition of two matrices.2 Solve the following matrix equation for a. denote by AT . If A and B are two matrices of the same size.B = 0 2 7 1 −3 5 . If A is a matrix and c is a scalar.4 Consider the matrices A= Compute A − 3B. A + B.
Problem 14. B is a matrix of size n × p and entries bij . B = 0 −1 3 1 2 7 5 2 Compute. AB and BA.7 Prove by induction on n ≥ 1 that 2 1 0 2 n = 2n n2n−1 0 2n . if possible. .80 FUNDAMENTALS OF MATHEMATICAL PROOFS Now. Then the product matrix is a matrix of size m × p and entries cij = ai1 b1j + ai2 b2j + · · · + ain bnj that is cij is obtained by multiplying componentwise the entries of the ith row of A by the entries of the jth column of B. let A be a matrix of size m × n and entries aij .6 Consider the matrices A= 1 2 4 2 6 0 4 1 4 3 . It is very important to keep in mind that the number of columns of the ﬁrst matrix must be equal to the number of rows of the second matrix. Problem 14. otherwise the product is undeﬁned.
The barber is so busy at ﬁrst that his own beard begins to be unsightly. To resolve the problem one has to take the barber out of the company. Deﬁne the set A = {X : X is a set. Since A is a set then saying that A ∈ A will imply that A ∈ A by the deﬁnition of A. A is not a set. We deﬁne a set A as a collection of welldeﬁned objects (called elements or members of A) such that for any given object x either one (but not both) of the following holds: 81 . Hardly any discussion in either subject can proceed without set or some synonym such as class or collection. then by the captain’s order he is supposed to shave himself. Thus in either case the assumption that A is a set leads to an untenable paradox: A ∈ A and A ∈ A. X ∈ X}. Another well known paradox is Russell’s Paradox. Hence. Saying that A ∈ A means that A ∈ A by the deﬁnition of A. In this chapter we introduce the concept of sets and its various operations and then study the properties of these operations. 15 Basic Deﬁnitions We ﬁrst consider the following known as the barber puzzle:” The army captain orders his company barber to shave all members of the company provided they do not shave themselves.Fundamentals of Set Theory Set is the most basic term in mathematics and computer science.” A situation like this is known as a paradox. he disobeys the captain’s order. the impossibility of his position strikes him: If he shaves himself. Just as he lathers up. Such a paradox indicated the necessity of a formal axiomatization of set theory. If he does not shave himself.
b. to be the set with no elements. without repetition. the elements of the set. if and only if every element of A is also an element of B. The ﬁrst one is to list. denoted by ∅. denoted by A ⊆ B. b. and in this case we write x ∈ A. • x does not belong to A. 7. C. There are two diﬀerent ways to represent a set. 9}. a. {n ∈ IN∗ n is odd and less than 10} Let A and B be two sets. We denote sets by capital letters A. 1}. Solution. {xx is an integer such that x2 − 3 = 0}.1 List the elements of the following sets. ∅ Example 15. a. Symbolically: A ⊆ B ⇔ ∀x. x ∈ ∅ implies x ∈ A . {a. Example 15. i. {−1. b. 5. We deﬁne the empty set. b. e. x ∈ A implies x ∈ B If there exists an element of A which is not in B then we write A ⊆ B. · · · Sets consisting of sets will be denoted by script letters. 3. Since the proposition x ∈ ∅ is always false then for any set A we have ∅ ⊆ A ⇔ ∀x. · · · and elements by lowercase letters a. o. Solution. a. B. {xx is a vowel}.82 FUNDAMENTALS OF SET THEORY • x belongs to A and we write x ∈ A. {1.2 Use a property to give a description of each of the following sets. c. a. u}. b. We say that A is a subset of B. {xx is a real number such that x2 = 1}. The other way is to describe a property that characterizes the elements of the set.
(a) {1. Thus. 1}. (b) {{1}} = {1. {1}} since 1 ∈ {{1}} . and C = {4. Determine which of these sets are subsets of which other of these sets. 5} = {5. to show that A = B it suﬃces to show the double inclusions mentioned in the deﬁnition. (b) {{1}} and {1. For nonequal sets we write A = B. Two sets A and B are said to be equal if and only if A ⊆ B and B ⊆ A.5 Determine whether each of the following pairs of sets are equal. 5} and {5. Example 15. 6}. We write A = B. Solution. Example 15. Solution. B = {2. 3.3 Suppose that A = {2. 3. B ⊆ A and C ⊆ A If sets A and B are represented as regions in the plane. 3. called Venn diagram. Solution. (a) {1. 6}. 1}.15 BASIC DEFINITIONS 83 Example 15. 3. relationships between A and B can be represented by pictures.4 Represent A ⊆ B using Venn diagram. 4. 6}. {1}}.
Find a. We say that A is a proper subset of B. b. Example 15. Consider the sets A = {x ∈ IRx < −1 or x > 1} and B = {x ∈ IRx ≤ 0}. Q. The relative complement of A with respect to B is the set B − A = {x ∈ U x ∈ B and x ∈ A}.7 Determine whether each of the following statements is true or false. IN ⊂ Z ⊂ Q ⊂ IR I Example 15. IR. if A ⊆ B and A = B. B − A. . Solution. (a) True (b) True (c) False (d) True (e) True (f) False If U is a given set whose subsets are under consideration. Ac . 1]. to show that A is a proper subset of B we must show that every element of A is an element of B and there is an element of B which is not in A. Example 15. then we call U a universal set. Let U be a universal set and A. B be two subsets of U. a. denoted by A ⊂ B. Thus.8 Let U = IR. IN using ⊂ I Solution.6 Order the sets of numbers: Z . Ac = [−1.84 FUNDAMENTALS OF SET THEORY Let A and B be two sets. (a) x ∈ {x} (b) {x} ⊆ {x} (c) {x} ∈ {x} (d) {x} ∈ {{x}} (e) ∅ ⊆ {x} (f) ∅ ∈ {x} Solution. The absolute complement of A is the set Ac = {x ∈ U x ∈ A}.
(A ∩ B) ∪ C = C.10 1 For each n ≥ 1. If A∩B = ∅ we say that A and B are disjoint sets.15 BASIC DEFINITIONS b. Given the sets A1 . d}. we deﬁne ∩∞ An = {xx ∈ Ai f or all i}. c}. (A ∩ B) ∪ (A ∩ C) = {b. Find A ∩ (B ∪ C). (A ∪ B) ∩ C = {b. c. (A ∩ B) ∪ C. let An = {x ∈ IR : x < 1 + n }. · · · . Find A ∪ (B ∩ C). The intersection of A and B is the set A ∩ B = {xx ∈ A and x ∈ B}. c. 85 where the ’or’ is inclusive. This defenition can be extended to more than two sets. (A ∪ B) ∩ (A ∪ C) = {b. B = {b. Find A − (B − C) and (A − B) − C. c}. A2 . b. A ∩ (B ∪ C) = {b. Which of these sets are equal? b. A − (B − C) = A and (A − B) − C = {a} = A − (B − C). and (A ∪ B) ∩ (A ∪ C). a. b. e}. n=1 Let A and B be two sets. and C = {b. The union of A and B is the set A ∪ B = {xx ∈ A or x ∈ B}. (A ∪ B) ∩ C. Are these sets equal? Solution. Which of these sets are equal? c. · · · . a. and (A ∩ B) ∪ (A ∩ C). Example 15. 0] Let A and B be two sets.9 Let A = {a. if A1 . n=1 Example 15. are sets then ∪∞ An = {xx ∈ Ai f or some i}. B − A = [−1. A2 . n=1 . More precisely. Show that ∩∞ An = {x ∈ IR : x ≤ 1}. c. A ∪ (B ∩ C) = A. c} = (A ∩ B) ∪ C. c} = (A ∪ B) ∩ C. c}.
a2 = b2 . (A × B) × C. 1). 1). ((x. ((y. B = {1. let y ∈ ∩∞ An . b). b2 . (x. a). Find A∆B if A = {1. 5} and B = {1. 1. ((y. 2. a). This n=1 shows that {x ∈ IR : x ≤ 1} ⊆ ∩∞ An . 3. · · · . A × B × C = {(x. Now take the limit n=1 of both sides as n → ∞ to obtain y ≤ 1. ((x. 1). b)} . 3). a. b). ((x. 5} The notation (a1 . Given n sets A1 . a). 2). 3. ((x. 1). We say that two ntuples (a1 . an ∈ An } Example 15. (y. b). a). · · · . b}. an ) : a1 ∈ A1 . 3). 3. a). y ∈ {x ∈ IR : x ≤ 1}. a2 . ((y. This shows that ∩∞ An ⊆ {x ∈ IR : x ≤ 1}. (x. (x. 2). a). 2. denoted by A∆B. 2). b). · · · . b. (A × B) × C = {((x. The proof is by double inclusions method. an ) and (b1 . Let y ∈ {x ∈ IR : x ≤ 1}. A∆B = {2. · · · . That is. ((y. 2. b)} b. a2 ∈ A2 . 3}. bn ) are equal if and only if a1 = b1 .86 FUNDAMENTALS OF SET THEORY Solution.11 The symmetric diﬀerence of A and B. y ∈ ∩∞ An . ((y. A × B × C. a). ((x. 2. b). Find a. (y. a). 3). Solution. Then 1 for all positive integer n we have y ≤ 1 < 1 + n . · · · . 2.12 Let A = {x. (y. (y. That is. 3. a2 . · · · . a). b). 1. y}. b) (y. b) ((y. · · · . is the set containing those elements in either A or B but not both. a). A2 . (x. 2. an = bn . a2 . (y. Solution. an ) is called an ordered ntuples. Then y < 1 + n for all n ≥ 1. a). and C = {a. b). n=1 Example 15. a). (x. 3}. 1. n=1 1 Conversely. 2). 1. 3). b). An the Cartesian product of these sets is the set A1 × A2 × · · · × An = {(a1 . 3.
b}. To be more precise. denoted by Σ∗ . We deﬁne the length of a word w to be the number of letters from Σ in w and we write w. Example 15. suppose that Σ = {a. a. ab}. Solution. Thus. For example. This ambiguity is resolved by making the restriction stated in the deﬁnition above. The empty word or the null word is the string with no letters. by Σn we mean the set of all words over Σ of length n. It is denoted by . Finally. if Σ consists of the twenty six letters of the english alphabet. Any subset of Σ∗ is called a language. We denote the set of all words using letters from Σ by Σ∗ . Note that in order to deﬁne the length of a word the restriction given in the deﬁnition is needed. List all the elements of the set A = {w ∈ Σ∗ : w = 2}. and b? So obviously there is no way to tell. ca} is not an alphabet. A word is any ﬁnite string of letters from Σ. That is. ba. ab.15 BASIC DEFINITIONS 87 Next. A = {aa.13 Let Σ = {a. bb} . b. c. Σn is the cartesian product of n copies of Σ. Then what is the length of the word aab? Is this a word with two letters a and ab or three letters a. we introduce one more special kind of sets. b. An alphabet is a ﬁnite nonempty set Σ whose members are called letters and with the restrictions that Σ does not contain letters which are themselves strings beginning with other letters of Σ. then the American language can be deﬁned as the subset of Σ∗ consisting of words in the latest edition of the Webster’s World dictionary of the American Language. Σ = {a.
Is {2} ⊆ {1. {2}. f. a. {2}. Is {1} ⊆ {1. Is {1} ⊆ {1. d. d. B − A. c} c. Is C ⊆ A? c. Is {1} ⊆ {1}? Problem 15. a. Problem 15. Is C is a proper subset of A? Problem 15. 2}? d.2 Let A = {c. g} and B = {a. A ∩ B. Give reasons for your answers. e} Problem 15. c. Is C ⊆ C? d. A − B.88 FUNDAMENTALS OF SET THEORY Review Problems Problem 15. Is 1 ⊆ {1}? c. e. {3}}? g. I . Is 1 ∈ {1}? f. b. a. 3}? b. j}. c. Is {2} ∈ {1. {a. A ∪ B. b. g}. Is B ⊆ A? b. d} b. 2. Is 1 ∈ {{1}. f. c}.3 a. B = {f. Is 3 ∈ {1. {3}}? e. d. {d. c.1 Which of the following sets are equal? a. Is {3} ∈ {1. e. {a. {2}}? j. Answer each of the following questions. 2}? h. {d. c. Z + ⊆ Q. g}. b.4 Let A = {b. b. 2}? i. a. d. and C = {d.5 Indicate which of the following relationships are true and which are false: a. Find each of the following: a. c} d.
y. y} be an alphabet. the set of all strings of length 4 over Σ. I c. Q ∪ Z = Z . I I f. Q ∩ IR = Q. List the elements of each of the following sets: a. d. Let L3 be the language consisting of all strings over Σ with length ≤ 3 and for which all the x s appear to the left of all the y s. Problem 15. A × B b. List the elements L3 .7 Let Σ = {x. b}. I d. B × A c. B. IR− ⊂ Q. a. e.6 Let A = {x. Z ∪ Q = Q. List the elements L1 .15 BASIC DEFINITIONS b. I I 89 Problem 15. e. A × A d. Let L2 be the language consisting of all strings over Σ that begins with x and have length ≤ 3. Z + ∪ Z − = Z . b. Describe A. c. . List the elements L2 . B × B. Q ⊂ Z . and A ∪ B in words. Let A = Σ3 ∪ Σ4 . w} and B = {a. List the elements of Σ4 . Let L1 be the language consisting of all strings over Σ that are palindromes and have length ≤ 4. z. Z + ∩ IR = Z + h. I g.
Thus. Find two sets A and B such that A ∈ B and A ⊆ B. b. Conversely. But B ⊆ C so that x ∈ C. The proposition if x ∈ A then x ∈ A is always true. Hence.1 Let A and B be two sets. A ⊆ A ∪ B and B ⊆ A ∪ B. a. U ⊆ ∅c .1 a. Solution. Then a. A ∩ B ⊆ A. a. Show that A ⊆ C. Suppose that A. If x ∈ U then x ∈ U and x ∈ ∅. A ⊆ A ∪ B. A similar argument holds for B ⊆ A ∪ B Theorem 16. b. (Ac )c = A. a. concepts that will be discussed in the next chapter. Example 16. b. This implies that x ∈ U. ∅c ⊆ U. U c = ∅. A = {x} and B = {x. A similar argument holds for A ∩ B ⊆ B. c. Proof. Hence. A ∩ Ac = ∅. Let x ∈ A. Then a. If x ∈ A ∩ B then x ∈ A and x ∈ B. This still imply that x ∈ A. suppose that x ∈ ∅c . B. A ∪ Ac = U. A ∩ B ⊆ A and A ∩ B ⊆ B. Then x ∈ U and x ∈ ∅. The proposition ”if x ∈ A then x ∈ A ∪ B” is always true. Show that A ⊆ A. Since A ⊆ B then x ∈ B.2 Let A be a subset of a universal set U.90 FUNDAMENTALS OF SET THEORY 16 Properties of Sets The following exercise shows that the operation ⊆ is reﬂexive and transitive. b. d. . Proof. c. We need to show that every element of A is an element of C. Hence. Thus. b. A ⊆ A Theorem 16. ∅c = U. {x}}. C are sets such that A ⊆ B and B ⊆ C. e. c.
Clearly.4 Let A and B be subsets of U . Now interchange the roles of A and B to show that B ∪ A ⊆ A ∪ B. The converse is similar Theorem 16. U ⊆ A ∪ U. x ∈ A ∪ (B ∪ C). Let x ∈ (A ∪ B) ∪ C. A ∪ A ⊆ A. suppose that x ∈ A. b. e. Conversely. Proof. Since x ∈ U then x ∈ A. Hence. Conversely. A ∪ B = B ∪ A. That is. d. It is clear that A ∪ Ac ⊆ U. . Thus. This shows that A ⊆ (Ac )c . This implies x ∈ A or (x ∈ B or x ∈ C). if x ∈ A then x ∈ A or x ∈ ∅. Hence. That is. Conversely. Then a. If x ∈ A ∪ B then x ∈ A or x ∈ B. the proposition ”x ∈ U and x ∈ U implies x ∈ ∅” is vacuously true since the hypothesis is false. A ⊆ A ∪ ∅. e. A ∪ ∅ ⊆ A. x ∈ A ∪ U. This shows that A ∩ Ac ⊆ ∅ Theorem 16. (A ∪ B) ∪ C = A ∪ (B ∪ C). Then x ∈ U and x ∈ A. d. x ∈ A ∪ A and consequently A ⊆ A ∪ A. A ∪ U ⊆ U. Then x ∈ (A ∪ B) or x ∈ C. Thus. That is. Conversely. (x ∈ A or x ∈ B) or x ∈ C. d. Hence (Ac )c ⊆ A. Conversely. suppose that x ∈ U. By deﬁnition ∅ ⊆ A ∩ Ac . A ∪ ∅ = A. the conditional proposition ”x ∈ A and x ∈ A implies x ∈ ∅” is vacuously true since the hypothesis is false. It is always true that ∅ ⊆ U c . if x ∈ A ∪ A then x ∈ A. A ∪ A = A. Hence. That is. This says that U c ⊆ ∅. x ∈ U and (x ∈ U or x ∈ A). If x ∈ A ∪ ∅ then x ∈ A since x ∈ ∅. Then either x ∈ A or x ∈ A. c. But this is the same thing as saying x ∈ B or x ∈ A. Let x ∈ (Ac )c . c. Then x ∈ U and x ∈ Ac . b. A ∩ U = A. e. Thus. x ∈ (Ac )c . If x ∈ A then x ∈ A or x ∈ A. x ∈ B ∪ A. Conversely. let x ∈ U .16 PROPERTIES OF SETS 91 b. x ∈ U and x ∈ Ac . c. Then deﬁnitely. Conversely. That is. But this is the same as saying that x ∈ A ∪ Ac . A ∪ U = U. a.3 If A and B are subsets of U then a.
This implies that (x ∈ A and x ∈ B) or (x ∈ A and x ∈ C). Then x ∈ A and x ∈ B ∪ C. A ∩ A ⊆ A. b.e. A ∩ A = A. Clearly ∅ ⊆ A ∩ ∅. This implies x ∈ A and (x ∈ B and x ∈ C). The converse is similar. d. Hence. x ∈ A or (x ∈ B and x ∈ C). i. Let x ∈ A ∪ (B ∩ C). Now interchange the roles of A and B to show that B ∩ A ⊆ A ∩ B. Let x ∈ (A ∩ B) ∩ C. if x ∈ A ∩ ∅ then x ∈ ∅. Hence. b. Conversely.6 (De Morgan’s Laws) Let A and B be subsets of U then a. i. A ⊆ A ∩ A. b. Hence. x ∈ A and x ∈ U. Proof. FUNDAMENTALS OF SET THEORY Proof. Then x ∈ A or x ∈ B ∩ C. Thus. A ∩ B = B ∩ A. c. Thus. That is. d. x ∈ (A ∩ B) ∪ (A ∩ C). That is. Hence. A ∩ ∅ ⊆ ∅. (x ∈ A and x ∈ B) and x ∈ C. A ⊆ A ∩ U.e. x ∈ (A ∪ B) ∩ (A ∪ C). (A ∩ B) ∩ C = A ∩ (B ∩ C). x ∈ A ∩ U. x ∈ B ∩ A. e. A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C). and C are subsets of U then a. B. This implies that (x ∈ A or x ∈ B) and (x ∈ A or x ∈ C). If x ∈ A ∩ U then x ∈ A. e. Thus. The converse is similar Theorem 16. (A ∪ B)c = Ac ∩ B c . a.92 b. If x ∈ A ∩ B then x ∈ A and x ∈ B. x ∈ A ∪ B and x ∈ A ∪ C. b.5 If A. A ∩ U ⊆ A. (A ∩ B)c = Ac ∪ B c . Hence. . Then x ∈ (A ∩ B) and x ∈ C. A ∩ ∅ = ∅. The converse is similar Theorem 16. That is . A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C). Let x ∈ A ∩ (B ∪ C). Conversely. If x ∈ A then x ∈ A and x ∈ A. Conversely. let x ∈ A. a. Then deﬁnitely. That is. if x ∈ A ∩ A then x ∈ A. c. x ∈ A and (x ∈ B or x ∈ C). x ∈ A ∩ B or x ∈ A ∩ C. Hence. But this is the same thing as saying x ∈ B and x ∈ A. x ∈ A ∩ (B ∩ C).
A2 = {3. k=1 (ii) Ai ∩ Aj = ∅ for all i = j. A∪B ⊆ B. · · · . Conversely. Let x ∈ (A ∩ B)c . A ∪ B = B. An } of A is said to be a partition of A if and only if (i) A = ∪n Ak . b. Example 16. 4. 6}. 2}. A1 = {1. . A2 . Suppose not. Then there is an element x that belongs to both A − B and B. Now. if x ∈ A then x ∈ B as well since A ⊆ B. It follows that x ∈ Ac ∪ B c . A3 = {5. if x ∈ B then x ∈ A∪B. b. A3 } is a partition of A. That is. Hence. Hence. b. Let x ∈ (A ∪ B)c . This implies that (x ∈ U and x ∈ A) and (x ∈ U and x ∈ B). The converse is similar Theorem 16. Solution. x ∈ U and (x ∈ A or x ∈ B). x ∈ A ∩ B. Then x ∈ U and x ∈ A ∩ B. This shows that B ⊆ A∪B. a.2 Let A and B be arbitrary sets. Hence. a. 3. Example 16. suppose (A − B) ∩ B = ∅. Thus. 5. Hence. 2. Conversely. Show that {A1 . Show that (A − B) ∩ B = ∅. If x ∈ A ∩ B then by the deﬁnition of intersection of two sets we have x ∈ A. x ∈ B and x ∈ B which is a contradiction A collection of nonempty subsets {A1 . This shows that A ⊆ A ∩ B. This implies that (x ∈ U and x ∈ B) or (x ∈ U and x ∈ A).16 PROPERTIES OF SETS 93 Proof. A2 . A ∩ B ⊆ A. Then a. Hence. 4}.3 Let A = {1. Then x ∈ U and x ∈ A ∪ B. By the deﬁnition of A − B we have that x ∈ B. go backward for the converse. Since A ⊆ B then x ∈ B. 6}. It follows that x ∈ Ac ∩ B c . A ∩ B = A.7 Suppose that A ⊆ B. Proof. x ∈ U and (x ∈ A and x ∈ B). If x ∈ A ∪ B then x ∈ A or x ∈ B.
8 If A ⊆ B then P(A) ⊆ P(B). {a. (a) ∅ = 0 (b) {∅} = 1 (c) {a. Since A ⊆ B then X ⊆ B. Otherwise. Let X ∈ P(A). (c) {a. {a}. {a}. If A has a ﬁnite cardinality we say that A is a ﬁnite set. We write A to denote the cardinality of the set A. The number of elements of a set is called the cardinality of the set. {a}}} = 3 Let A be a set. {a. {a. how many elements are there in A? .6 a. Then X ⊆ A. c}} Theorem 16. (b) {∅}. {a}. b. (i) A1 ∪ A2 ∪ A3 = A. Proof. denoted by P(A). is the empty set together with all possible subsets of A. Example 16. b}. Use induction to show that if A = n then P(A) = 2n . X ∈ P(B) Example 16. {a. b. {c}. Solution.94 FUNDAMENTALS OF SET THEORY Solution. {a. The power set of A. c}. Example 16. {a}}}. it is called inﬁnite. Solution. (a) ∅. c}.4 What is the cardinality of each of the following sets. {b. Hence. (ii) A1 ∩ A2 = A1 ∩ A3 = A2 ∩ A3 = ∅. P(A) = {∅. b. If P(A) has 256 elements.5 Find the power set of A = {a. c}. {b}.
suppose that if A = n then P(A) = 2n . a. P(B) = 2n +2n = 2·2n = 2n+1 . If n = 0 then A = ∅ and in this case P(A) = {∅}.16 PROPERTIES OF SETS 95 Solution. Let B = A ∪ {an+1 }. Thus P(A) = 1. Hence. b. As induction hypothesis. Then P(B) consists of all subsets of A and all subsets of A with the element an+1 added to them. Since P(A) = 256 = 28 then A = 8 .
B.2 Find sets A. Is the number 0 in ∅? Why? b. and C such that A ∩ C ⊆ B ∩ C and A ∪ C ⊆ B ∪ C but A = B. Problem 16. B.96 FUNDAMENTALS OF SET THEORY Review Problems Problem 16. B. Show that A × (B ∪ C) = (A × B) ∪ (A × C). B. Problem 16. Prove that (A − B) ∩ (A ∩ B) = ∅. Is ∅ ∈ {∅}? Why? Problem 16. Problem 16.10 Let A and B be two sets. Problem 16. Is ∅ = {∅}? Why? c.6 Let A. and C be sets.1 Let A. B and C be three sets.4 Let A and B be two sets. B. and C such that A ∩ C = B ∩ C but A = B. and C be sets. and C be sets.11 Let A. Prove that if A ⊆ C and B ⊆ C then A ∪ B ⊆ C. Prove that if A ⊆ B and B ∩ C = ∅ then A ∩ C = ∅. B. and C be sets.7 Let A.8 a. . Show that A × (B ∩ C) = (A × B) ∩ (A × C).9 Let A and B be two sets. Prove that if A ⊆ B then A ∩ C ⊆ B ∩ C.5 Let A. Problem 16. Problem 16. Prove that if A ⊆ B then B c ⊆ Ac . Problem 16.3 Find sets A. Problem 16. Show that if A ⊆ B then A ∩ B c = ∅. Problem 16.
P(A × B) = P(A) × P(B).15 Determine which of the following statements are true and which are false. d.16 PROPERTIES OF SETS Problem 16. b. Find P(P(P(∅))). P(A × B). P(A ∩ B). 3}. 2} and B = {2. Find each of the following: a.12 Find two sets A and B such that A ∩ B = ∅ but A × B = ∅. b. d. P(A ∪ B) = P(A) ∪ P(B). P(A) ∪ P(B) ⊆ P(A ∪ B).13 Suppose that A = {1. P(A).14 a. . c. a. c. Problem 16. c. P(A ∩ B) = P(A) ∩ P(B). Find P(P(∅)). Problem 16. Prove each statement that is true and give a counterexample for each statement that is false. Find P(∅). P(A ∪ B). b. 97 Problem 16.
• a ⊕ (b ⊕ c) = (a ⊕ b) ⊕ c and a (b c) = (a b) c). (P(S). b. Problem 17. • a ⊕ b = b ⊕ a and a b = b a. b ∈ S.1 Show that if S is a collection of propositions with ﬁnite propositional variables then (S. ∩) is a Boolean algebra. ∪. • For each a ∈ S there exits an element a such that a ⊕ a = 1 and a a = 0.98 FUNDAMENTALS OF SET THEORY 17 Project VI: Boolean Algebra A Boolean algebra is a nonempty set S together with two operations ⊕ and that satisfy the following axioms: • a ⊕ b ∈ S and a b ∈ S for all a. Problem 17. c ∈ S. ). We call a the complement or the negation of a. ∨. ∧) is a Boolean algebra. ∀a. b. ∀a. b ∈ S. ⊕. . • a ⊕ (b c) = (a ⊕ b) (a ⊕ c) and a (b ⊕ c) = a b ⊕ a c ∀a. We write (S.2 Show that for a given nonempty set S. c ∈ S. • There exist distinct elements 0 and 1 in S such that a⊕0 = a and a 1 = a ∀a ∈ S.
18 Equivalence Relations Let A be a given set. The element a (resp. b}}. b) = (c. b) is called the ﬁrst (resp. i.1 a. a). b} = {c. x − y). There are three kinds of relations which we discuss in this chapter: (i) equivalence relations. One frequently wants to compare or contrast various members of a set. b. Example 18. d) if and only if {a. 99 . b) = (b. The mathematical framework to describe this kind of organization of sets is the theory of relations. second) component. d) if and only if a = c and b = d. If a = b then {a. Show that if a = b then (a. (ii) order relations. Thus. {a. a. (iii) functions. {a.2 Find x and y such that (x + y. d}} and this is equivalent to a = c and {a. ” is less than” and so on. An ordered pair (a. b) = (c.e. Solution. (a. {a. b}}.Relations and Functions The reader is familiar with many relations which are used in mathematics and computer science. b) = (b. d} by the deﬁnition of equality of sets. b. a = c and b = d. b} = {c. (a. a). ”is a subset of”. b}} = {b. Example 18. {c. That is. Show that (a. 0) = (1. b) of elements in A is deﬁned to be the set {a. {a. perhaps to arrange them in some appropriate order or to group together those with similar properties.
The set Dom(R) = {a ∈ A(a. 2)} = B × A. 1).4 Let A = {1. Show that A × B = B × A. If a is not related to B we write a Rb. Then there is at least an a ∈ A and an element b ∈ B. Thus. Solution. b). we let A × B denote the set of all ordered pairs (a. By the previous exercise we have the system x + y = 1 x − y = 0 Solving by the method of elimination one ﬁnds x = 1 2 1 and y = 2 . Show that if A is a set with m elements and B is a set of n elements then A × B is a set of mn elements. For each ﬁxed a. (a. Consider an ordered pair (a. B = {1}. That is. There are m possibilities for a. A contradiction to the assumption that A×B =∅ Example 18. b) ∈ R we write aRb and we say that a is related to b. b.3 a. Solution. We have A × B = {(1. A × B = mn. 1)} = {(1. 1). Example 18. b). 2}. b) ∈ R f or some b ∈ B} is called the domain of R. b) ∈ R f or some a ∈ A} is called the range of R. If (a. We call A × B the Cartesian product of A and B. Suppose that A = ∅ and B = ∅. (2. (1. In case A = B we call R a binary relation on A.100 RELATIONS AND FUNCTIONS Solution. b) ∈ A × B and this shows that A × B = ∅. We use the proof by contrapositive. a. there are n possibilities for b. Show that if A × B = ∅ then A = ∅ or B = ∅. That is. . b) where a ∈ A and b ∈ B. If A and B are sets. A binary relation R from a set A to a set B is a subset of A × B. b. The set Range(R) = {b ∈ B(a. there are m × n ordered pairs (a.
b. Range(R). 3). 4). (2. R = {(1. 3. 2. b. c}. (4. (1. Range(R) = A. (1. a). 4)}. b). a. Let A = {2. 2. (1. Dom(R) = {2. 6. 2. a) ∈ R then the directed edge is simply a loop. if (a. Dom(R). The relation f does not deﬁne a function since the element 1 has two images. To draw a digraph of a relation on a set A. c}. (3. b. Dom(R). 3. R. The element y is called the image of x and we write y = f (x). 2). Deﬁne the relation R by aRb if and only if a ≤ b. Find. a. (3. A function from A to B. namely a and b. a). y) ∈ f. 4}. Functions will be discussed in more details in Section 4. Show that the relation f = {(1. (1. we ﬁrst draw dots or vertices to represent the elements of A. (2. 3} to B = {a. (2. 4}. Find. 3). (2. 7}. (2. Solution. A function is a special case of a relation. (4. a)} deﬁnes a function from A = {1. (3. R = {(2. f is a function with domain A and range Range(f ) = {a.6 a. Solution. c). The set A is called the domain of f and the set of all images of f is called the range of f. and Range(R) = {3. is a relation from A to B such that for every x ∈ A there is a unique y ∈ B such that (x. Find its range. Note that each element of A has exactly one image. (3.3. R. b}. 3} to B = {a. Next. Example 18. 2). An informative way to picture a relation on a set is to draw its digraph. Show that the relation f = {(1. b. b)} does not deﬁne a function from A = {1. 5. 6). (3. Finally. 1).5 a. b. (3. 4. 4} and B = {3. 4). Deﬁne the relation R by aRb if and only if a divides b. b. 6). 3. 3). denoted by f : A → B. 4. 6}. 4)}. 4). Hence. . if (a. b).18 EQUIVALENCE RELATIONS 101 Example 18. Let A = {1. 3). Dom(R) = A. b) ∈ R we draw an arrow (called a directed edge) from a to b. 4). (2. Range(R).
a) ∈ B × A : (a. b) ∈ R or (a. Let R and S be two relations from a set A to a set B. y). 3)}. Next we discuss three ways of building new relations from given ones. b. 1). b) ∈ S}. R−1 = {(y. a. Compare (R−1 )−1 and R. (R−1 )−1 = R. b) ∈ A × B(a.7 Draw the directed graph of the relation in part (b) of Problem 18. Solution. b) ∈ A and (a.8 Let R = {(1. b) ∈ A × B(a. 3} to B = {x. y)} be a relation from A = {1. . a. Find R−1 . and R ∩ S = {(a. b) ∈ B}. (3. Example 18. Solution. Let R be a relation from a set A to a set B.5. y. z). 1). Then we deﬁne the relations R ∪ S and R ∩ S by R ∪ S = {(a. (z.102 RELATIONS AND FUNCTIONS Example 18. z}. (1. (y. b. The inverse of R is the relation R−1 from Range(R) to Dom(R) such that R−1 = {(b. 2. b) ∈ R}.
6). u). (4. (3. (1. Show that the relation a ≤ b on the set A = {1. b. 8)} = R = S Now. 2). c)(a. 10). 8)} = {(2. (8. aSb if and only if b − 4 = a. 10). 6). (6. . b) ∈ R and (b. (2.10 Let R = {(1. Example 18. t). (4. 8. 6). Solution. (2. 2). 2). called the composition relation. (1. u). t). (3. (2. (4. 2. In this case.18 EQUIVALENCE RELATIONS 103 Example 18. 4} is reﬂexive. and R ∩ S. (3. List the elements of R. 4). Solution. 8)} S = {(2. (3. 6). (2. (2. 10} : aRb if and only if ab. (2. u)} We next deﬁne four types of binary relations. 3. If we have a relation R from A to B and a relation S from B to C we can deﬁne the relation S ◦ R. t). (1. (2.9 Given the following two relations from A = {1. Example 18. s). 4} to B = {2. t). s). c) ∈ S f or some b ∈ B}. to be the relation from A to C deﬁned by S ◦ R = {(a. (3.11 a. 2. (4. u)} Find S ◦ R. A relation R on a set A is called reﬂexive if (a. 6). a) ∈ R for all a ∈ A. (1. R S R∪S R∩S = {(1. 8). 6. the digraph of R has a loop at each vertex. (1. 8). R ∪ S. Show that the relation on IR deﬁned by aRb if and only if a < b is not reﬂexive. 4). t). (3. s). S ◦ R = {(1. S.
(d. bRc and cRb with b = c. a. d} and R = {(a. b. Let A = {a. b) ∈ R and a = b then (b. (b. Show that R is symmetric. for any real number a we have a − a = 0 and not a − a < 0.13 a. d)}. Hence. Let IN be the set of nonnegative integers and R the relation aRb if and only if a divides b. a. Suppose that ab and ba. b. Example 18. Since k1 and k2 are positive integers then we must have k1 = k2 = 1. a = b. b) ∈ R and (b. by the definition of division. Example 18. a). Show that R is not symmetric. there is also a directed edge from b to a. Indeed. The digraph of a transitive relation has the property that whenever there are directed edges from a to b and from b to c then there is also a directed edge from a to c. The digraph of an antisymmetric relation has the property that between any two vertices there is at most one directed edge. By Problem 242. Show that R is not antisymmetric. Solution. b. a). c) ∈ R. The digraph of a symmetric relation has the property that whenever there is a directed edge from a to b. b) ∈ R then we must have (b. Solution. c). A relation R on A is called symmetric if whenever (a. b). (d. (c. We must show that a = b. c) ∈ R then (a. d)}. 2 < 4 but 4 < 2.104 RELATIONS AND FUNCTIONS Solution. each vertex has a loop. b. Let A = {a. d} and R = {(a. (b. b. This implis that a = k2 k1 a and hence k1 k2 = 1. a. c. bRc and cRb so R is symmetric. c. b). A relation R on a set A is called transitive if whenever (a. there exist positive integers k1 and k2 such that b = k1 a and a = k2 b. Let IR be the set of real numbers and R be the relation aRb if and only if a < b. a) ∈ R. b. b. (c. . A relation R on a set A is called antisymmetric if whenever (a. Show that R is antisymmetric.12 a. c). a) ∈ R. Indeed.
Deﬁne on A the binary relation x R y if and only if x and y belongs to the same set Ai for some 1 ≤ i ≤ n. Theorem 18. (b. b) ∈ R but (b. • R is reﬂexive: If x ∈ A then by (i) x ∈ Ak for some 1 ≤ k ≤ n. d} and R = {(a. z ∈ A such that x R y and y R z. z ∈ Ai and in particular x. Thus. Thus. A relation that is reﬂexive. Hence. b. . Then there is an index k such that x. the relation ”=” is an equivalence relation on IR. (d.1 The relation R deﬁned above is reﬂexive. For example. That is.14 a.15 Let Z be the set of integers and n ∈ Z . y ∈ Ai and y. y. (b. x ∈ Ak . symmetric. let A1 . x and x belong to Ak so that x R x. Solution. x R z. That is. d)}. a. c). b. b. z ∈ Ai .” Show that R is an equivalence relation on Z . y. Since y ∈ Ai ∩ Aj then by (ii) we must have i = j. c) ∈ R and (c. y R x. a). y ∈ Ak . symmetric. An be a partition of a set A. Then there exist integers k1 and k2 such that b = k1 a and c = k2 b. Example 18. But then y. • R is symmetric: Let x. c. c = (k1 k2 )a which means that ac. (c. Let A = {a. Show that R is not transitive.18 EQUIVALENCE RELATIONS 105 Example 18. b). Let Z be the set of integers and R the relation aRb if a divides b. • R is transitive: Let x. z ∈ Aj . This implies that x. Now. Proof. A2 . Let R be the relation on Z deﬁned by aRb if a − b is a multiple of n. the Ai s are subsets of A that satisfy (i) ∪n Ai = A i=1 (ii) Ai ∩ Aj = ∅ for i = j. b) ∈ R. Suppose that ab and bc. and transitive. Show that R is transitive. · · · . Then there exist indices i and j such that x. and transitive on a set A is called an equivalence relation on A. y ∈ A such that x R y. We denote this relation by a ≡ b (mod n) read ”a congruent to b modulo n.
We will show that the conclusion a R b leads to [a] = [b]. ≡ is transitive: Let a. ≡ is symmetric: Let a. It remains to show that if [a] = [b] then [a] ∩ [b] = ∅ for a. Since A is reﬂexive then a ∈ [a] and consequently a ∈ ∪b∈A [b]. Now interchange the letters a and b to show that [b] ⊆ [a]. [a] ⊆ [b]. Adding these equalities together we ﬁnd a − c = kn where k = k1 + k2 ∈ Z which shows that a ≡ c (mod n). By the deﬁnition of [a] we have that [a] ⊆ A. Thus. suppose [a] ∩ [b] = ∅. Then the union of all the elements of A/R is equal to A and the intersection of any two distinct members of A/R is the empty set. Since R is symmetric and transitive then a R b. Thus. This establishes (i). A ⊆ ∪b∈A [b]. The element a in [a] is called a representative of the equivalence class [a]. The sets [a] deﬁned in the previous exercise are called the equivalence classes of A given by the relation R. The proof is by double inclusions. Indeed. b ∈ Z such that a ≡ b (mod n). . Hence. Hence. A/R is a partition of A. That is b ≡ a (mod n). ∪a∈A [a] ⊆ A. ≡ is reﬂexive: For all a ∈ Z . Proof. a − a = 0 · n.2 Let R be an equivalence relation on A. the family A/R forms a partition of A.106 RELATIONS AND FUNCTIONS Solution. This establishes (ii). Suppose the contrary. b ∈ A. Let x ∈ [a]. [a] = [b] which contradicts our assumption that [a] = [b]. It follows that A = ∪a∈A [a]. let a ∈ A. a R c and b R c. Then there exist integers k1 and k2 such that a − b = k1 n and b − c = k2 n. Hence. Since a R b and R is transitive then x R b which means that x ∈ [b]. Hence. Then x R a. c ∈ Z be such that a ≡ b (mod n) and b ≡ c (mod n). This means that c ∈ [a] and c ∈ [b]. We next show that A ⊆ ∪a∈A [a]. That is. Then there is an element c ∈ [a] ∩ [b]. b. That is. Then there is an integer k such that a − b = kn. That is. a ≡ a (mod n). For each a ∈ A let [a] = {x ∈ AxRa} A/R = {[a]a ∈ A}. Theorem 18. Multiply both sides of this equality by (−1) and letting k = −k we ﬁnd that b − a = k n.
5). b}? c. B ∈ P(x). Recall that P(X) is the power set of X. Deﬁne a relation R on Σ4 as follows: s. 5. and T from A to B as follows: (x. a. (x. (x. c}? b. a. y) ∈ A × B. Deﬁne a binary relation R on P(X) as follows: A. a.1 Let X = {a. Is aaaa R aaab? Problem 18. 7} and deﬁne the binary relations R. S. Then Σ4 is the set of all strings over Σ of length 4. or T are functions.18 EQUIVALENCE RELATIONS 107 Review Problems Problem 18. 6. Is {a. x S y ⇔ 2(x − y). Is aabb R bbaa? c. c}. b. and T. b}. y) ∈ R ⇔ x ≥ y. S. Is {c}R{b}? Problem 18. . Indicate whether any of the relations S. b}R{b. y) ∈ A × B. Is {a}R{a. R. s R t ⇔ s has the same ﬁrst two characters as t. T = {(4. 4. 7)}.2 Let Σ = {a. List the elements of the sets R and R−1 . (x. 6} and B = {5. y) ∈ A × B. Is abaa R abba? b. 7). Draw arrow diagrams for R.4 Let A = {3. 6} and deﬁne the binary relation R as follows: (x. t ∈ Σ4 . 5. (6. A R B ⇔ A = B.3 Let A = {4. y) ∈ R ⇔ x < y. Problem 18. (6. 5} and B = {4. b.
Problem 18. Is R reﬂexive? symmetric? transitive? Problem 18.5 Let A = {2. y) ∈ A × B. and R ∩ S. 8. and T from A to B as follows: (x. Consider the binary relation on A deﬁned as follows: x.9 Let A = ∅ and P(A) be the power set of A. 10} and deﬁne the binary relations R. Is R reﬂexive? symmetric? transitive? Problem 18. where x denotes the length of the string x. y ∈ A. x R y ⇔ x ≥ y. (x. 4} and B = {6.108 RELATIONS AND FUNCTIONS Problem 18. S. X R Y ⇔ X ⊆ Y. y ∈ R.6 Consider the binary relation on IR deﬁned as follows: x. List the elements of A × B. x R y ⇔ x < y. 1} and A = Σ∗ . x R y ⇔ xy ≥ 0. Y ∈ P(A). R. y) ∈ R ⇔ xy. Is R reﬂexive? symmetric? transitive? Problem 18. R ∪ S. S. y ∈ R. Is R reﬂexive? symmetric? transitive? .8 Let Σ = {0. y) ∈ A × B. (x. Consider the binary relation on P(A) deﬁned as follows: X. x S y ⇔ y − 4 = x.7 Consider the binary relation on IR deﬁned as follows: x.
a. Show that R is symmetric.12 Let A be the set all straight lines in the cartesian plane. . e. List ﬁve elements in [(1. Describe the distinct equivalence classes of R. Show that R is reﬂexive. 2)]. d) ⇔ a + d = b + c. List ﬁve elements in [(1. f. Show that I is an equivalence relation on IR and ﬁnd the diﬀerent equivalence classes. c. 109 Show that E is an equivalence relation on Z and ﬁnd the diﬀerent equivalence classes. d. g. Deﬁne the binary relation R on A as follows: (a.11 Let I be the binary relation on IR deﬁned as follows: a I b ⇔ a − b ∈ Z.13 Let A = IN × IN. 1)]. Prove the following: If for every x ∈ A there is a y ∈ A such that x R y then R is reﬂexive and hence an equivalence relation on A. b.10 Let E be the binary relation on Z deﬁned as follows: a E b ⇔ m ≡ n (mod 2). Problem 18. Problem 18.18 EQUIVALENCE RELATIONS Problem 18.14 Let R be a binary relation on a set A and suppose that R is symmetric and transitive. Problem 18. Let  be the binary relation on A deﬁned as follows: l1 l2 ⇔ l1 is parallel to l2 . b) R (c. Show that  is an equivalence relation on A and ﬁnd the diﬀerent equivalence classes. 1)]. Show that R is transitive. List ﬁve elements in [(3. Problem 18.
x = y.1 Show that the set Z of integers together with the relation of inequality ≤ is a poset. Hence. Then there exist positive integers k1 and k2 such that b = k1 a and a = k2 b. for a given pair of numbers x and y only one of the following is true: x < y. So if x ≤ y and y ≤ x then we must have x = y. Solution. a = b. Then there exist positive integers k1 and k2 such that b = k1 a and c = k2 b. that is.2 Show that the relation ab in IN∗ is a partial order relation. c = k1 k2 a which means that ac. Antisymmetry: Suppose that ab and ba. Since k1 . Example 19. or x > y. In this case we call A a poset. Thus. Solution. if x ≤ y and y ≤ z then the deﬁnition of ≤ and the above property imply that x ≤ z. a = k1 k2 a which implies that k1 k2 = 1. ≤ is reﬂexive: For all x ∈ Z we have x ≤ x since x = x. Transitivity: Suppose that ab and bc. ≤ is transitive: By the transitivity property of < in IR if x < y and y < z then x < z. Thus. . Example 19. and transitive. Let R be the relation deﬁned by A R B ⇔ A ⊆ B. k2 ∈ IN∗ then we must have k1 = k2 = 1. Show that A is a poset.3 Let A be a collection of subsets. antisymmetric.110 RELATIONS AND FUNCTIONS 19 Partial Order Relations A relation ≤ on a set A is called a partial order if ≤ is reﬂexive. Example 19. ≤ is antisymmetric: By the trichotomy law of real numbers. Reﬂexivity: Since a = 1 · a then aa.
. This type of order relation is called lexicographic or dictionary order. X ⊆ X. Indicate which of the following statements are true. bbaba ≤ bbabb. bbab ≤ bbaa. Let ≤ be the corresponding lexicographic order on Σ∗ . Y ∈ A. a). one compares their letters one by one from left to right. b)}. aab ≤ aaba. or (b)w = xu and z = xv where u.19 PARTIAL ORDER RELATIONS 111 Solution. A general deﬁnition is the following: Let Σ∗ be the set of words with letters from an ordered set Σ. If all the letters up to a certain point are the same and the next letters diﬀer.4 Let Σ = {a. (a. w ≤ z if and only if either (a)z = wu for some u ∈ Σ∗ . b. v ∈ Σ∗ such that the ﬁrst letter of u precedes the ﬁrst letter of v in the ordering of Σ. aba ≤ abb. ⊆ is transitive: We have seen in Chapter 3 that if X ⊆ Y and Y ⊆ Z then X ⊆ Z. playground comes before playmate. ababa ≤ ababaa. g. For example. then the word whose next letter is located earlier in the alphabet comes ﬁrst in the dictionary. z ∈ Σ∗ . ≤ aba. play comes before playground. b). where X. bbab ≤ bba. Deﬁne the relation ≤ on Σ∗ as follows: for all w. To ﬁgure out which of two words comes ﬁrst in an English dictionary. e. ⊆ is antisymmetric: By the deﬁnition of = if X ⊆ Y and Y ⊆ X then X = Y. c. ⊆ is reﬂexive: For any set X ∈ A. If all the letters have been the same to a certain point and one word is runs out of letters. that word comes ﬁrst in the dictionary. Example 19. Then it can be shown that ≤ is a partial order relation on Σ∗ . a. f. For example. b} and suppose that Σ has the partial order relation R = {(a. d. (b.
18} and the ”divides” relation on A. Draw the Hasse diagram of this relation. Example 19. 2. True since bbaba = (bbab)a. True since ababaa = (ababa)a. True since aba = aba. a. True since aaba = (aab)a. Solution. True since aba = (ab)a.5 Let A = {1. c. • omit all arrows that can be inferred from transitivity • omit all loops • draw arrows without ”heads”. The Hasse diagram of a partial order on the set A is a drawing of the points of A and some of the arrows of the digraph of the order relation. namely. g. There are rules to determine which arrows are drawn and which are omitted. False since bba ≤ bbab. bbabb = (bbab)b and a R b. Another simple pictorial representation of a partial order is the so called Hasse diagram. We assume that the directed edges of the digraph point upward. e. 9. False since bbaa ≤ bbab. 3. b. The directed graph of the given relation is The corresponding Hasse diagram is given by .112 RELATIONS AND FUNCTIONS Solution. f. abb = (ab)b and a R b. d.
19 PARTIAL ORDER RELATIONS 113 Now.6 Let A = {1. Example 19. 4} be a poset. add an arrow from the ﬁrst point to the third. 2. 3. given the Hasse diagram of a partial order relation one can ﬁnd the diagraph as follows: • Reisert the direction markers on the arrows making all arrows point upward • add loops at each vertex • for each sequence of arrows from one point to a second point and from that second point to a third point. . Find the directed graph corresponding to the following Hasse diagram on A.
114 Solution. and 1530 then any pair of elements in A are comparable. . Prove that this relation is a total order on A. 15. Since 2 does not divide 3 and 3 does not divide 2. RELATIONS AND FUNCTIONS Next.7 Consider the ”divides” relation deﬁned on the set A = {5. the ”divides” relation is a total order relation on A. If every pair of elements of A are comparable then we call ≤ a totally ordered relation. Example 19. Example 19. 530. A counterexample of two noncomparable numbers are 2 and 3. Thus.8 Show that the ”divides” relation on IN∗ is not a total partial order. 30}. if A is a poset then we say that a and b are comparable if either a ≤ b or b ≤ a. The facts that ”divides” relation is a partial order relation is easy to verify. Solution. Since 515. Solution.
5 Consider the ”divides” relation deﬁned on the set A = {1. Is R antisymmetric? Prove or give a counterexample.2 Deﬁne a relation R on Z as follows: for all m. Draw the Hasse diagram for this relation when n = 3. where n is a nonnegative integer. n ∈ Z m R n ⇔ m + n is even. b. b) and (c. b) R (c.4 Let S = {0.19 PARTIAL ORDER RELATIONS 115 Review Problems Problem 19.3 Deﬁne a relation R on IR as follows: for all m. Problem 19. d) ⇔ a ≤ c and b ≤ d. 2n }. Problem 19. 2. · · · . Draw the Hasse diagram for R. Deﬁne the relation R on Σ∗ as follows: for all s. Prove that this relation is a total order on A. where l(x) denotes the length of the word x. n ∈ IR m R n ⇔ m2 ≤ n2 . b} and let Σ∗ be the set of all strings over Σ.1 Let Σ = {a. d) in S × S (a. a. Problem 19. Is R a partial order? Prove or give a counterexample. 22 . . Problem 19. Is R a partial order? Prove or give a counterexample. 1} and consider the partial order relation R deﬁned on S × S as follows: for all ordered pairs (a. t ∈ Σ∗ . s R t ⇔ l(s) ≤ l(t).
a)} deﬁnes a function from A = {1. Example 20. Sn = n(n+1) . k=1 Solution. The set A is called the domain of f whereas B is called the codomain. a. Deﬁne the sequence an = n2 . Find its range. Compute the sum n ak . For (x. 2. b). c). Example 20. Solution. We call y the image of x under f. a). b)} does not deﬁne a function from A = {1. From this we obtain the following chain of equalities: 23 33 . . b. Then write Sn in two diﬀerent ways. namely. . Solution. (2. we obtain 2Sn = (n + 1) + (n + 1) + · · · + (n + 1) = n(n + 1). k=1 b.2 Show that the relation f = {(1. y) ∈ f. Since every element of A has a unique image then f is a function. b). Thus. (3. a. − 13 = 3(1)2 + 3(1) + 1 − 23 = 3(2)2 + 3(2) + 1 3n2 + 3n + 1 (n + 1)3 − n3 = . c}. b. 2 b. A function f from a set A to a set B is a relation from A to B such that for every x ∈ A there is a unique y ∈ B such that (x.3 A sequence of elements of a set A is a function from IN∗ to A. c}. Let Sn = n ak . Deﬁne the sequence an = n. Its range consists of the elements a and b. n ≥ 1. a). Indeed. 3} to B = {a. Compute n ak .1 Show that the relation f = {(1.116 RELATIONS AND FUNCTIONS 20 Functions: Deﬁnitions and Examples A function is a special case of a relation. First note that (n + 1)3 − n3 = 3n2 + 3n + 1. Adding. We write (an ) and we call an the nth term of the sequence. Example 20. since 1 has two images in B then f is not a function. 3} to B = {a. y) ∈ f we use the notation y = f (x). The collection of all images of f is called the range of f. Sn = k=1 1 + 2 + · · · + n and Sn = n + (n − 1) + · · · + 1. 2. (1. (3. (2.
1. Find the range of f.6 (Equality of Functions) Two functions f and g deﬁned on the same domain D are said to be equal if and only if f (x) = g(x) for all x ∈√ Show that the functions f. we ﬁnd n 3 k=1 k2 + 3n(n + 1) + n = n3 + 3n2 + 3n. b} and the function f : Σ∗ → Z deﬁned as follows: for any string s ∈ Σ∗ f (s) = the number of a s in s. 3}. Solution. √ A simple argument by the method of proof by cases shows that x2 = x. Find f ( ). Solution. Using a. c}. and f (bbbaa). . and f (bbbaa) = 2.20 FUNCTIONS: DEFINITIONS AND EXAMPLES Adding these equalities we ﬁnd n n 117 3 k=1 k +3 k=1 2 k + n = (n + 1)3 − 1. f (ababb). Example 20. f (ababb) = 2.4 Let A = {a. Deﬁne the function f : P(A) → IN by f (X) = X. Solution.5 Consider the alphabet Σ = {a. deﬁned by f (x) = x and g(x) = x2 are equal. By applying f to each member of P(A) we ﬁnd Range(f ) = {0. 6 Example 20. Example 20. 2 A simple arithmetic shows that n k2 = k=1 n(n + 1)(2n + 1) . g : IR → IR D. f ( ) = 0. b. 2.
H(00101.9 (Encoding and Decoding functions) Let Σ = {0. x2 . 01111). Thus. x1 1 1 1 1 0 0 0 0 x2 1 1 0 0 1 1 0 0 x3 1 0 1 0 1 0 1 0 f (x1 . 01111) = 4. Let L be the set of all strings over Σ that consist of consecutive triples of identical bits.8 (Boolean functions) An nplace Boolean function f is a function from the Cartesian product {0. t) ∈ Σn × Σn H(s. 111000 ∈ L. 1}3 → {0. 01110) = 3 and H(10001. ﬁnd H(00101. We deﬁne the encoding function E : Σ∗ → L by E(s) = the string obtained f rom s by replacing each bit of s by the same bit written three times . The encoded message is decoded by replacing each section of three identical bits by the one bit to which all three are equal. t) = number of positions in which s and t have dif f erent values. Solution. 1} and Σn be the set of all strings of 0’s and 1’s of length n. 1}. Describe f using an input/output table. For the case n = 5. Deﬁne the function H : Σn × Σn → IN as follows: for any (s. 1} and Σ∗ be the set of all strings of 0’s and 1’s. x3 ) 1 0 0 1 0 1 1 0 Example 20. A message consisting of 0’s and 1’s is encoded by writing each bit in it three times. Example 20. x3 ) = (x1 + x2 + x3 ) mod 2. Consider the 3place Boolean function f : {0. 1} deﬁned by f (x1 . Solution. 01110) and H(10001.7 (Hamming distance function) Let Σ = {0.118 RELATIONS AND FUNCTIONS Example 20. x2 . 1}n to {0.
. x ∈ IR+ ∪ {0}. A function f : A → B is called a realvalued function of a real variable. Now. Find E(0110) and D(111111000111). f1 (x).20 FUNCTIONS: DEFINITIONS AND EXAMPLES and we deﬁne the decoding function D : L → Σ∗ by 119 D(s) = the string obtained f rom s by replacing consecutive triple of bits of s by a single copy of that bit. and f2 (x).10 Consider the power function fa (x) = xa . f (x)) can be represented by a point in the Cartesian plane. Example 20. The collection of all such points is called the graph of f. We have E(0110) = 000111111000 and D(111111000111) = 1101. 4]. where a. In this case. 2 Solution. Graph on the same Cartesian plane the functions f0 (x).11 Graph the functions f (x) = x and g(x) = x on the closed interval [−4. Solution. each ordered pair (x. let A and B be subsets of IR. f 1 (x). Example 20.
120 Solution.
RELATIONS AND FUNCTIONS
Example 20.12 √ Graph the function f : IN → IR deﬁned by f (n) = n. Solution.
20 FUNCTIONS: DEFINITIONS AND EXAMPLES
121
Example 20.13 Let Df be the domain of a function f and S ⊆ Df . We say that f is increasing on S if and only if, for all x1 , x2 ∈ S, if x1 < x2 then f (x1 ) < f (x2 ). Show that the function f : IR → IR deﬁned by f (x) = 2x − 3 is increasing on IR. Solution. Indeed, for any real numbers x1 and x2 such that x1 < x2 , we have 2x1 − 3 < 2x2 − 3. That is, f (x1 ) < f (x2 ) so that f is increasing. Example 20.14 Let Df be the domain of a function f and S ⊆ Df . We say that f is decreasing on S if and only if, for all x1 , x2 ∈ S, if x1 < x2 then f (x1 ) > f (x2 ). Show that the function f : IR → IR deﬁned by f (x) = x+2 is decreasing on x+1 (−∞, −1) and (−1, ∞). Solution. Indeed, for any real numbers x1 , x2 ∈ (−∞, −1) or x1 , x2 ∈ (−1, ∞) such that x1 < x2 , we have (x1 + 1)(x2 + 1) > 0. This implies, that f (x1 ) − f (x2 ) = x2 −x1 > 0. Thus, f is decreasing on the given intervals. (x1 +1)(x2 +1)
122
RELATIONS AND FUNCTIONS
Review Problems
Problem 20.1 Let f, g : IR → IR be the functions f (x) = 2x and g(x) = f = g.
2x3 +2x2 . x2 +1
Show that
Problem 20.2 Let H, K : IR → IR be the functions H(x) = x + 1 and K(x) = x . Does H = K? Explain. Problem 20.3 Find functions deﬁned on the set of nonnegative integers that deﬁne the sequences whose ﬁrst six terms are given below. 1 1 a. 1, − 1 , 1 , − 7 , 1 , − 11 . 3 5 9 b. 0, −2, 4, −6, 8, −10. Problem 20.4 Let A = {1, 2, 3, 4, 5} and let F : P(A) → Z be deﬁned as follows: F (X) = Find the following a. b. c. d. F ({1, 3, 4}) F (∅). F ({2, 3}). F ({2, 3, 4, 5}). 0 1 if X has an even number of elements if X has an odd number of elements
Problem 20.5 Let Σ = {a, b} and Σ∗ be the set of all strings over Σ. a. Deﬁne f : Σ∗ → Z as follows: f (s) = the number of b s to the lef t of the lef t − most a in s 0 if s contains no a s
Find f (aba), f (bbab), and f (b). What is the range of f ? b. Deﬁne g : Σ∗ → Σ∗ as follows: g(s) = the string obtained by writing the characters of s in reverse order. Find g(aba), g(bbab), and g(b). What is the range of g?
20 FUNCTIONS: DEFINITIONS AND EXAMPLES Problem 20.6 Let E and D be the encoding and decoding functions. a. Find E(0110) and D(111111000111). b. Find E(1010) and D(000000111111). Problem 20.7 Let H denote the Hamming distance function on Σ5 . a. Find H(10101, 00011). b. Find H(00110, 10111).
123
Problem 20.8 Consider the threeplace Boolean function f : {0, 1}3 → {0, 1} deﬁned as follows: f (x1 , x2 , x3 ) = (3x1 + x2 + 2x3 ) mod 2 a. Find f (1, 1, 1) and f (0, 1, 1). b. Describe f using an input/output table. Problem 20.9 Draw the graphs of the power functions f 1 (x) and f 1 (x) on the same set of
3
axes. When, 0 < x < 1, which is greater: x 3 or x 4 ? When x > 1, which is 1 1 greater s 3 or x 4 ? Problem 20.10 Graph the function f (x) = x − x on the interval (−∞, ∞). Problem 20.11 Graph the function f (x) = x − x on the inerval (−∞, ∞). Problem 20.12 Graph the function h : IN → IR deﬁned by h(n) =
n 2
1
1
4
.
x−1 x
Problem 20.13 Let k : IR → IR be the function deﬁned by the formula k(x) = nonzero real numbers x. a. Show that k is increasing on (0, ∞). b. Is k increasing or decreasing on (−∞, 0)? Prove your answer.
for all
Solution. f is not injective. if x = y then f (x) = f (y). Suppose that x1 = x2 . if f (x) = f (y) then x = y. We will show that g◦f : A → C is also injective. since m > 1 then 2m + 1 = m + 1 and h(m + 1) = h(2m + 1) = 1. suppose that (g◦f )(x1 ) = (g◦f )(x2 ) for . Show that the identity function IA on a set A is injective. This shows that IA is injective. Example 21. If IA (x) = IA (y) then x = y by the deﬁnition of IA . y ∈ A. We say that f is injective or onetoone if and only if for all x. Since 12 = (−1)2 and 1 = −1. Show that the function h : Z → Z deﬁned by h(n) = n mod m is not injective. Indeed. So h is not injective. Then without lost of generality we can assume that x1 < x2 . Solution. Indeed. Let x. Show that the fucntion f : Z → Z deﬁned by f (n) = n2 is not injective. Let f : A → B and g : B → C be two injective functions.1 a. Taking the negation of this last conditional implication we see that f is not injective if and only if there exist two distinct elements a and b of A such that f (a) = f (b). a function f is injective if and only if for all x.124 RELATIONS AND FUNCTIONS 21 Bijective and Inverse Functions Let f : A → B be a function. Example 21. Using the concept of contrapositive. Hence. y ∈ A. a.3 Show that if f : IR → IR is increasing then f is onetoone. y ∈ A. b. Example 21. Solution.2 (Hash Functions) Let m > 1 be a positive integer . b. f (x1 ) = f (x2 ). f is onetoone. Solution. Example 21. Since f is increasing then f (x1 ) < f (x2 ).4 Show that the composition of two injective functions is also injective. That is.
21 BIJECTIVE AND INVERSE FUNCTIONS
125
x1 , x2 ∈ A. Then g(f (x1 )) = g(f (x2 )). Since g is injective then f (x1 ) = f (x2 ). Now since f is injective then x1 = x2 . This completes the proof that g ◦ f is injective. Now, for any function f : A → B we have Range(f ) ⊆ B. If equality holds then we say that f is surjective or onto. It follows from this deﬁnition that a function f is surjective if and only if for each y ∈ B there is an x ∈ A such that f (x) = y. By taking the negation of this we see that f is not onto if there is a y ∈ B such that f (x) = y for all x ∈ A. Example 21.5 a. Show that the function f : IR → IR deﬁned by f (x) = 3x − 5 is surjective. b. Show that the function f : Z → Z deﬁned by f (n) = 3n − 5 is not surjective. Solution. a. Let y ∈ IR. Is there an x ∈ IR such that f (x) = y? That is, 3x − 5 = y. But solving for x we ﬁnd x = y+5 ∈ IR and f (x) = y. Thus, f is onto. 3 b. Take m = 3. If f is onto then there should be an n ∈ Z such that f (n) = 3. That is, 3n − 5 = 3. Solving for n we ﬁnd n = 8 which is not an integer. 3 Hence, f is not onto. Example 21.6 (Projection Functions) Let A and B be two nonempty sets. The functions prA : A × B → A deﬁned by prA (a, b) = a and prB : A × B → B deﬁned by prB (a, b) = b are called projection functions. Show that prA and prB are surjective functions. Solution. We prove that prA is surjective. Indeed, let a ∈ A. Since B is not empty then there is a b ∈ B. But then (a, b) ∈ A × B and prA (a, b) = a. Hence, prA is surjective. The proof that prB is surjective is similar. Example 21.7 Show that the composition of two surjective functions is also surjective. Solution. Let f : A → B and g : B → C, where Range(f ) ⊆ C, be two surjective functions. We will show that g ◦ f : A → D is also surjective. Indeed, let z ∈ D. Since g is surjective then there is a y ∈ B such that g(y) = z. Since f
126
RELATIONS AND FUNCTIONS
is surjective then there is an x ∈ A such that f (x) = y. Thus, g(f (x)) = z. This shows that g ◦ f is surjective. Now, we say that a function f is bijective or onetoone correspondence if and only if f is both injective and surjective. A bijective function on a set A is called a permutation. Example 21.8 a. Show that the function f : IR → IR deﬁned by f (x) = 3x − 5 is a bijective function. b. Show that the function f : IR → IR deﬁned by f (x) = x2 is not bijective. Solution. a. First we show that f is injective. Indeed, suppose that f (x1 ) = f (x2 ). Then 3x1 − 5 = 3x2 − 5 and this implies that x1 = x2 . Hence, f is injective. f is surjective by Exercise 309 (a). b. f is not injective since f (−1) = f (1) but −1 = 1. Hence, f is not bijective.
Example 21.9 Show that the composition of two bijective functions is also bijective. Solution. This follows from Example 21.4 and Example 21.7 Theorem 21.1 Let f : X → Y be a bijective function. Then there is a function f −1 : Y → X with the following properties: a. f −1 (y) = x if and only if f (x) = y. b. f −1 ◦ f = IX and f ◦ f −1 = IY where IX denotes the identity function on X. c. f −1 is bijective. Proof. For each y ∈ Y there is a unique x ∈ X such that f (x) = y since f is bijective. Thus, we can deﬁne a function f −1 : Y → X by f −1 (y) = x where f (x) = y. a. Follows from the deﬁnition of f −1 .
21 BIJECTIVE AND INVERSE FUNCTIONS
127
b. Indeed, let x ∈ X such that f (x) = y. Then f −1 (y) = x and (f −1 ◦f )(x) = f −1 (f (x)) = f −1 (y) = x = IX (x). Since x was arbitrary then f −1 ◦ f = IX . The proof that f ◦ f −1 = IY is similar. c. We show ﬁrst that f −1 is injective. Indeed, suppose f −1 (y1 ) = f −1 (y2 ). Then f (f −1 (y1 )) = f (f −1 (y2 )); that is, (f ◦ f −1 )(y1 ) = (f ◦ f −1 )(y2 ). By b. we have IY (y1 ) = IY (y2 ). From the deﬁnition of IY we obtain y1 = y2 . Hence, f −1 is injective. We next show that f −1 is surjective. Indeed, let y ∈ Y . Since f is onto there is a unique x ∈ X such that f (x) = y. By the deﬁntion of f −1 , f −1 (y) = x. Thus, for every element y ∈ Y there is an element x ∈ X such that f −1 (y) = x. This says that f −1 is surjective and completes a proof of the theorem Example 21.10 Show that f : IR → IR deﬁned by f (x) = 3x − 5 is bijective and ﬁnd a formula for its inverse function. Solution. We have already proved that f is bijective. We will just ﬁnd the formula for its inverse function f −1 . Indeed, if y ∈ Y we want to ﬁnd x ∈ X such that f −1 (y) = x, or equivalently, f (x) = y. This implies that 3x − 5 = y and solving for x we ﬁnd x = y+5 . Thus, f −1 (y) = y+5 3 3
128
RELATIONS AND FUNCTIONS
Review Problems
Problem 21.1 a. Deﬁne g : Z → Z by g(n) = 3n − 2. (i) Is g onetoone? Prove or give a counterexample. (ii) Is g onto? Prove or give a counterexample. b. Deﬁne G : IR → IR by G(x) = 3x − 2. Is G onto? Prove or give a counterexample. Problem 21.2 Determine whether the function f : IR → IR given by f (x) = one or not. Problem 21.3 Determine whether the function f : IR → IR given by f (x) = one or not. Problem 21.4 Let f : IR → Z be the ﬂoor function f (x) = x . a. Is f onetoone? Prove or give a counterexample. b. Is f onto? Prove or give a counterexample. Problem 21.5 Let Σ = {0, 1} and let l : Σ∗ → IN denote the length function. a. Is l onetoone? Prove or give a counterexample. b. Is l onto? Prove or give a counterexample. Problem 21.6 If : IR → IR and g : IR → IR are onetoone functions, is f +g also onetoone? Justify your answer. Problem 21.7 Deﬁne F : P{a, b, c} → IN to be the number of elements of a subset of P{a, b, c}. a. Is F onetoone? Prove or give a counterexample. b. Is F onto? Prove or give a counterexample. Problem 21.8 If : IR → IR and g : IR → IR are onto functions, is f + g also onto? Justify your answer.
x+1 x
is oneto
x x2 +1
is oneto
13 If f : X → Y and g : Y → Z are functions and g ◦ f : X → Z is onetoone. Let f : IN → {0.15 Let f : W → X. (f ◦l)(baaab).11 If f : X → Y and g : Y → Z are functions and g ◦ f : X → Z is onetoone. Find (f ◦l)(abaa). Problem 21.12 If f : X → Y and g : Y → Z are functions and g ◦ f : X → Z is onto. must both f and g be onetoone? Prove or give a counterexample. 1.9 Let Σ = {a.21 BIJECTIVE AND INVERSE FUNCTIONS 129 Problem 21. y−2 3 is the inverse Problem 21.16 Let f : X → Y and g : Y → Z be two bijective functions. Show that (g ◦f )−1 exists and (g ◦ f )−1 = f −1 ◦ g −1 . Problem 21. Problem 21. must g be onto? Prove or give a counterexample.14 If f : X → Y and g : Y → Z are functions and g ◦ f : X → Z is onto. and (f ◦ l)(aaa). 2} be the hash function f (n) = n mod 3. Must h ◦ (g ◦ f ) = (h ◦ g) ◦ f ? Prove or give a counterexample.10 Show that the function F −1 : IR → IR given by F −1 (y) = of the function F (x) = 3x + 2. Problem 21. b} and let l : Σ∗ → IN be the length function. . Problem 21. must both f and g be onto? Prove or give a counterexample. g : X → Y and h : Y → Z be functions. must f be onetoone? Prove or give a counterexample. Problem 21.
Solution. 1.2 Let n ≥ 0 and ﬁnd the number sn of words from the alphabet Σ = {0. n ≥ 2 A solution to a recurrence relation is an explicit formula for an in terms of n. 5. · · · is a sequence in which every number after the ﬁrst two is the sum of the preceding two numbers. s0 = 1(empty word) and s1 = 2. We will ﬁnd a recurrence relation for sn . n ≥ 2. This implies the recurrence relation sn = sn−1 + sn−2 . then the remaining n − 1 letters can be any sequence of 0’s or 1’s except that 11 cannot happen.1 The Fibonacci sequence 1. If the word begins with 0. The formula relating an to earlier values in the sequence is called the generating rule. an−1 . The initial conditions are a0 = a1 = 1 and the generating rule is an = an−1 + an−2 . · · · is a relation that deﬁnes an in terms of a0 . Clearly.130 RELATIONS AND FUNCTIONS 22 Recursion A recurrence relation for a sequence a0 . If the word begins with 1 then the next letter must be 0 since 11 can not happen. · · · . n ≥ 2. The iteration method consists of starting with the initial values of the sequence and then calculate successive terms of the . the remaining n − 2 letters can be any sequence of 0’s and 1’s with the exception that 11 is not allowed. a1 . Find the generating rule and the initial conditions. The most basic method for ﬁnding the solution of a sequence deﬁned recursively is by using iteration. 2. a1 . Example 22. Solution. Example 22. 3. Thus the above two categories form a partition of the set of all words of length n with letters from Σ and that do not contain 11. The assignment of a value to one of the a’s is called an initial condition. 1} of length n not containing the pattern 11 as a subword. Any word of length n with letters from Σ begins with either 0 or 1.
Solution. a guess is an = 2n + 1. n ≥ 1 Solution. By the deﬁnition of an+1 we have an+1 = an + 2 = 2n + 1 + 2 = 2(n + 1) + 1. Induction step: We must show that an+1 = 2(n + 1) + 1. At that point one guesses an explicit formula for the sequence and then uses mathematical induction to prove its validity. a0 = 1 = 2(0) + 1. Listing the ﬁrst ﬁve terms of the sequence one ﬁnds a0 a1 a2 a3 a4 = = = = = 1 1+2 1+4 1+6 1+8 Hence. Induction hypothesis: Suppose that an = 2n + 1. n ≥ 1 where a0 is the initial value. Find an explicit formula for an . Example 22. Listing the ﬁrst four terms of the sequence after a0 we ﬁnd a1 a2 a3 a4 = a0 + d = a0 + 2d = a0 + 3d = a0 + 4d .22 RECURSION 131 sequence until a pattern is observed. Example 22.3 Find a solution for the recurrence relation a0 =1 an = an−1 + 2. Basis of induction: For n = 0. It remains to show that this formula is valid by using mathematical induction. n ≥ 0.4 Consider the arithmetic sequence an = an−1 + d.
we prove the validity of this formula by induction. a guess is an = a0 + nd. n ≥ 1 Solution.132 RELATIONS AND FUNCTIONS Hence. Induction hypothesis: Suppose that an = rn a0 . a guess is an = rn a0 . Basis of induction: For n = 0. Basis of induction: For n = 0.5 Consider the geometric sequence an = ran−1 . Find an explicit formula for an . Writing the ﬁrst ﬁve terms of the sequence we ﬁnd a0 a1 a2 a3 a4 = 0 = 0 = 0+1 = 0+1+2 = 0+1+2+3 . we prove the validity of this formula by induction. Solution. Example 22. Next. a0 = r0 a0 . a0 = a0 + (0)d. Example 22. Induction step: We must show that an+1 = a0 + (n + 1)d. Next. By the deﬁnition of an+1 we have an+1 = ran = r(rn a0 ) = rn+1 a0 . Induction step: We must show that an+1 = rn+1 a0 . n ≥ 1 where a0 is the initial value. By the deﬁnition of an+1 we have an+1 = an + d = a0 + nd + d = a0 + (n + 1)d. Induction hypothesis: Suppose that an = a0 + nd. Listing the ﬁrst four terms of the sequence after a0 we ﬁnd a1 a2 a3 a4 = ra0 = r 2 a0 = r 3 a0 = r 4 a0 Hence.6 Find a solution to the recurrence relation a0 =0 an = an−1 + (n − 1).
Induction step: We must show that an+1 = 2n+1 +(n+1). a1 . 2 133 We next show that the formula is valid by using induction on n ≥ 0. n ≥ 1 Is it true that an = 2n + n is a solution to the given recurrence relation? Solution. Example 22. Use induction to prove the validity of the formula found in a. a2 . n ≥ 2 2 a. recursively as follows: a1 =1 an = 2 · a n . 2 Induction step: We must show that an+1 = n(n+1) . If this is so then we will have 2n+1 + (n + 1) = 2an + n = 2n+1 + 2n + n + 1. But this would imply that n = 0 which contradicts the fact that n is any nonnegative integer. an + n n(n−1) +n 2 n(n+1) 2 . Basis of induction: a0 = 0 = 0(0−1) .8 Deﬁne a sequence. Induction hypothesis: Suppose that an = 2n + n. 2 an+1 = = = Example 22. If so then we must be able to prove its validity by mathematical induction. 2 Induction hypothesis: Suppose that an = n(n−1) . · · · .22 RECURSION A guessing formula is that an = 0 + 1 + 2 + · · · + (n − 1) = n(n − 1) .7 Consider the recurrence relation a0 =1 an = 2an−1 + n. Use iteration to guess an explicit formula for this sequence. Basis of induction: a0 = 20 + 1. b. Indeed.
Computing the ﬁrst few terms of the sequence we ﬁnd a1 a2 a3 a4 a5 a6 a7 a8 = 1 = 2 = 2 = 4 = 4 = 4 = 4 = · · · = a15 = 8 Hence. We prove the above formula by mathematical induction. n ≥ 1. an = 2i . Induction hypothesis: Suppose that an = 2 log2 n .e. The method explained below works for sequences of the form an = Aan−1 + Ban−2 (22. for n odd (i. i ≤ log2 n < i + 1 so that i = log2 n and a formula for an is an = 2 log2 n .1) . a1 = 1 = 2 log2 1 . When iteration does not apply. for 2i ≤ n < 2i+1 . Moreover. Indeed. other methods are available for ﬁnding explicit formulas for special classes of recursively deﬁned sequences. Induction step: We must show that an+1 = 2 log2 (n+1) . Basis of induction: For n = 1. b.134 RELATIONS AND FUNCTIONS Solution. n + 1 even) we have an+1 = 2 · a n+1 2 = 2 · a n+1 2 n+1 = 2 · 2 log2 2 = 2 log2 (n+1)−1 +1 = 2 log2 (n+1) −1+1 = 2 log2 (n+1) A similar argument holds when n is even.
· · · where t = 0 if and only if t is a solution to the characteristic equation t2 − At − B = 0 (22. . Recall that the Fibonacci sequence is deﬁned recursively by an = an−1 + an−2 for n ≥ 2 and a0 = a1 = 1. for n ≥ k we have tn = Atn−1 + Btn−2 . · · · . t2 . Theorem 22. t.1) Example 22. Since t = 0 we can divide through by tn−2 and obtain t2 − At − B = 0. (=⇒): Suppose that t is a nonzero real number such that the sequence 1. Thus. t. We will show that t satisﬁes the equation t2 − At − B = 0. Such an equation is called a secondorder linear homogeneous recurrence relation with constant coeﬃcients. Example 22. Indeed.1). t2 . · · · . tn . t. · · · satisﬁes (22.10 Consider the recurrence relation an = an−1 + 2an−2 . an satisﬁes a secondorder linear homogeneous relation with A = B = 1.1).1 Equation (22.1) is satisﬁed by the sequence 1. Multiply both sides of this equation by tn−2 to obtain tn = Atn−1 + Btn−2 . t. t2 . n ≥ 2.2) Proof.22 RECURSION 135 where n is greater than or equal to some ﬁxed nonnegative integer k and A and B are real numbers with B = 0. This says that the sequence 1. The following theorem gives a technique for ﬁnding solutions to (22. Find two sequences that satisfy the given generating rule and have the form 1. (⇐=) : Suppose that t is a nonzero real number such that t2 − At − B = 0. · · · satisﬁes (22. t2 .9 Does the Fibonacci sequence satisfy a secondorder linear homogeneous relation with constant coeﬃcients? Solution.
2.1).1) Example 22. Theorem 22. Proof. for n ≥ 2 we have sn = Asn−1 + Bsn−2 tn = Atn−1 + Btn−2 Therefore.2 If sn and tn are solutions to (22. n ≥ 2 is a solution to the recurrence relation an = an−1 + 2an−2 . Aan−1 + Ban−2 = A(Csn−1 + Dtn−1 ) + B(Csn−2 + Dtn−2 ) = C(Asn−1 + Bsn−2 ) + D(Atn−1 + Btn−2 ) = Csn + Dtn = an so that an satisﬁes (22. Solving for t we ﬁnd t = 2 or t = −1. 22 . −1. According to the previous theorem t must satisfy the characteristic equation t2 − t − 2 = 0. (−1)n . So the two solutions to the given recurrence sequence are 1. · · · . a1 = 8 an = an−1 + 2an−2 . Since sn and tn are solutions to (22. an = C2n + D(−1)n . · · · and 1. n ≥ 0 is also a solution. · · · .1? The answer is yes according to the following theorem. By the previous theorem and Example 22. Solution.10.11 Find a solution to the recurrence relation a0 = 1.136 RELATIONS AND FUNCTIONS Solution. · · · Are there other solutions then the ones provided by Theorem 34. 2n . n ≥ 2.1) then for any real numbers C and D the sequence an = Csn + Dtn . .
2 5 2 5 Hence. √ √ 1 1 + 5 n+1 1 1 − 5 n+1 an = √ ( ) −√ ( ) 2 2 5 5 Next. . The roots of the characteristic equation t2 − t − 1 = 0 are t = √ 1− 5 2 √ 1+ 5 . 2 and t = Thus. Example 22. an = 3 · 2n − 2(−1)n . is a solution to Using the values of a0 and a1 we obtain the system √ C( 1+2 5 ) C +D √ = 1 1− 5 + D( 2 ) = 1.22 RECURSION If an satisﬁes the system then we must have a0 = C20 + D(−1)0 a1 = C21 + D(−1)1 This yields the system C +D = 1 2C − D = 8 137 Solving this system to ﬁnd C = 3 and D = −2. √ √ 1− 5 n 1+ 5 n ) + D( ) an = C( 2 2 an = an−1 + an−2 .12 Find an explicit formula for the Fibonacci sequence a0 = a1 = 1 an = an−1 + an−2 Solution. Solving this system to obtain √ √ 1+ 5 1− 5 C= √ and D = − √ . we discuss the case when the characteristic equation has a single root. Hence.
r. · · · } and {0. · · · . This implies that A = 2r and B = −r2 . an = C2n + Dn2n . n ≥ 0. Now. r2 . since r is the only solution to the characteristic equation we have (t − r)2 = t2 − At − B. n ≥ 2 Solution.138 RELATIONS AND FUNCTIONS Theorem 22. Then Asn−1 + Bsn−2 = A(n − 1)rn−1 + B(n − 2)rn−2 = 2r(n − 1)rn−1 − r2 (n − 2)rn−2 = 2(n − 1)rn − (n − 2)rn = nrn = sn So sn is a solution to an = Aan−1 + Ban−2 . Then the sequences {1. Since r is a root to the characteristic equation.13 Find an explicit formula for a0 = 1. the sequence {1. nrn . Proof. Let sn = nrn . 2r2 . a1 = 3 an = 4an−1 − 4an−2 . Solving the characteristic equation t2 − 4t + 4 = 0 we ﬁnd the single root r = 2. Thus. · · · } is a solution to the recurrence relation an = Aan−1 + Ban−2 . 3r3 .3 Let A and B be real numbers and suppose that the characteristic equation t2 − At − B = 0 has a single root r. · · · } both satisfy the recurrence relation an = Aan−1 + Ban−2 . r2 . Example 22. r. r.
2 2 Example 22. (∪n Ai )c = ∩n Ac i=1 i=1 i Solution. n ≥ 2. A2 . n ≥ 2. i=1 b. Give a recursion deﬁnition for n ai . i=1 i=1 Example 22. 1 ai = a1 and n ai = ( i=1 ai ) + an . i=1 i=1 i (∪n+1 Ai )c = ((∪n Ai ) ∪ An+1 )c i=1 i=1 = (∪n Ai )c ) ∩ Ac i=1 n+1 = (∩n Ac ) ∩ Ac n+1 i=1 i = ∩n+1 Ac i=1 i Example 22. an be numbers. An be subsets of a set S. i=1 i=1 i Induction step: We must show that (∪n+1 Ai )c = ∩n+1 Ac . i=1 i i=1 i Induction hypothesis: Suppose that (∪n Ai )c = ∩n Ac .15 Use mathematical induction to prove the following generalized De Morgan’s law. · · · . a. Give a recursion deﬁnition for ∩n Ai . ∩1 Ai = A1 and ∩n Ai = (∩i=1 Ai ) ∩ An . i=1 b. n ≥ 2. · · · .22 RECURSION 139 is a solution to the equation an = 4an−1 − 4an−2 . Give a recursion deﬁnition for Πn ai . Since a0 = 1 and a1 = 3 then we obtain the following system of equations: C = 1 2C + 2D = 3 Solving this system to obtain C = 1 and D = 1 . i=1 i=1 n−1 b. Indeed. Basis of induction: (∪1 Ai )c = Ac = ∩1 Ac .14 Let A1 . n−1 a. i=1 Solution. i=1 i=1 i=1 n−1 b. an = 2n + n 2n . Give a recursion deﬁnition for ∪n Ai . i=1 Solution. i=1 i=1 .16 Let a1 . a2 . a. a. Π1 ai = a1 and Πn ai = (Πi=1 ai ) · an . ∪1 Ai = A1 and ∪n Ai = (∪n−1 Ai ) ∪ An . n ≥ 2. Hence.
G(n) = G(3n − 1). Solution.18 Let G : IN → Z be the relation given by 1. Example 22.140 RELATIONS AND FUNCTIONS Example 22. Solution. G does not deﬁne a function. n ≥ 1. Deﬁne the factorial function recursively. Assume that G is a function so that G(5) exists. if n = 1 n if n is even 1 + G( 2 ). f (0) =1 f (n) = nf (n − 1). Listing the ﬁrst ﬁve values of G we ﬁnd G(1) G(2) G(3) G(4) G(5) = 1 = 2 = G(8) = 1 + G(4) = 2 + G(2) = 4 = 1 + G(2) = 3 = G(14) = 1 + G(7) = 1 + G(20) = 2 + G(10) = 3 + G(5) But the last equality implies that 0 = 3 which is impossible. . Hence. if n > 1 is odd Show that G is not a function.17 A function is said to be deﬁned recursively or to be a recursive function if its rule of deﬁnition refers to itself.
c. d3 . · · · d. · · · is the Fibonacci sequence.) Problem 22. Find d0 .3 n+1 Find limn→∞ FFn where F0 . and four that do not contain the pattern 111. c. F2 . Problem 22.1 Find the ﬁrst four terms of the following recursively deﬁned sequence: v1 = 1. Fk − Fk−1 = Fk Fk+1 − Fk+1 Fk−1 .4 Deﬁne x0 . Fk+1 − Fk = Fk−1 Fk+2 .6 Find a formula for each of the following sums: a. and d4 . 2 2 2 b. Make a list of all bit strings of lengths zero. b. Use the results of (b) of (c) to ﬁnd the number of bit strings of length ﬁve that do not contain the pattern 111.5 a. Fn+2 Fn − Fn+1 = (−1)n for all n ≥ 0. Fk+1 − Fk − Fk−1 = 2Fk Fk−1 . three. 3 · 1 + 3 · 2 + 3 · 3 + · · · 3 · n. n ≥ 1. x2 . F1 . d1 . n ≥ 1. v2 = 2 vn = vn−1 + vn−2 + 1. n ≥ 3 Problem 22. d2 . two. Problem 22. 3 + 2 + 4 + 6 + 8 + · · · + 2n. k ≤ 1. Problem 22. x1 . b. 2 d. (Assume that the limit exists.2 Prove each of the following for the Fibonacci sequence: 2 2 a. n ≥ 2.22 RECURSION 141 Review Problems Problem 22. . d1 . 1 + 2 + · · · + (n − 1). d2 . 2 2 c. · · · as follows: xn = Find limn→∞ xn . x0 = 0. k ≥ 1. one. 2 + xn−1 . k ≥ 1. Find a recurrence relation for d0 . For each n ≥ 0 let dn = the number of bit strings of length n that do not contain the bit pattern 111.
rn = rn−1 − rn−2 − 2. n−2 d. n ≥ 1. n ≥ 1. f. · · · be the sequence deﬁned by the explicit formula an = C · 2n + D. What is a2 in this case? . bn = nbn−1 + bn−2 .12 Let a0 . b. c. a1 .7 Find a formula for each of the following sums: a. a. Find C and D so that a0 = 1 and a1 = 3. Find C and D so that a0 = 0 and a1 = 2.9 Use iteration to guess a formula for the following recusively deﬁned sequence and then use mathematical induction to prove the validity of your formula: w0 = 1. sn = 10sn−2 . Problem 22. Problem 22. dn = 3dn−1 + dn−2 . 3n−1 + 3n−2 + · · · + 32 + 3 + 1. e. n ≥ 1.11 Which of the following are secondorder homogeneous recurrence relations with constant coeﬃcients? a. b. 2n − 2n−1 + 2n−2 − 2n−3 + · · · + (−1)n−1 · 2 + (−1)n .8 Use iteration to guess a formula for the following recusively deﬁned sequence and then use mathematical induction to prove the validity of your formula: c1 = 1. Problem 22. for all n ≥ 2. Problem 22. d. an = 2an−1 − 5an−2 . What is a2 in this case? b. Problem 22. c. cn = 3cn−1 · c2 .142 RELATIONS AND FUNCTIONS Problem 22. cn = 3cn−1 + 1. 2n + 3 · 2n−2 + 3 · 2n−3 + · · · + 3 · 22 + 3 · 2 + 3.10 Determine whether the recursively deﬁned sequence: a1 = 0 and an = 2an−1 + n − 1 satisﬁes the explicit formula an = (n − 1)2 . 1 + 2 + 22 + · · · + 2n−1 . n ≥ 1. a2 . for all n ≥ 2. n ≥ 0 where C and D are real numbers. wn = 2n − wn−1 . n ≥ 1.
if a1 . Use the recursive deﬁnition of summation. Show that for any choice of C and D.15 Let a0 . n ≥ 2. a2 . a2 . and mathematical induction to prove that for all positive integers n. if A and B1 .13 Let a0 .14 Let a0 . · · · be the sequence deﬁned by the explicit formula an = C · 2n + D.16 The triangle inequality for absolute value states that for all real numbers a and b.17 Use the recursive deﬁnition of union and intersection to prove the following general distributive law: For all positive integers n. n ≥ 0 143 where C and D are real numbers. a2 . · · · . Problem 22. an are real numbers then n n  k=1 ak  ≤ k=1 ak . k=1 k=1 . n ≥ 2 Find an explicit formula for the sequence. Problem 22. B2 . the triangle inequality. Problem 22. the deﬁnition of absolute value. an = 3an−1 − 2an−2 . · · · be the sequence deﬁned by the explicit formula a0 = 1. a1 .22 RECURSION Problem 22. a1 = 4 an = 2an−1 − an−2 . · · · be the sequence deﬁned by the explicit formula a0 = 1. Bn are sets then A ∩ (∪n Bk ) = ∪n (A ∩ Bk ). a2 . · · · . a1 = 2 an = 2an−1 + 3an−2 . a+b ≤ a+b. a1 . n ≥ 2 Find an explicit formula for the sequence. a1 . Problem 22.
(∩n Ai )c = ∪n Ac i=1 i=1 i Exercise 367 Show that the relation F : IN → Z given by the rule 1 if n = 1. n if n is even F(2) F (n) = 1 − F (5n − 9) if n is odd and n > 1 does not deﬁne a function.18 Use mathematical induction to prove the following generalized De Morgan’s law.144 RELATIONS AND FUNCTIONS Problem 22. .
A database management system responds to queries. For the same reason. Example 23. An be given sets. The attribute Name is not a key because diﬀerent persons can have the same name. Database management systems are programs that help users access the information in databases. An nary relation can be represented by a table or a set of ordered ntuples. in the above table. A single attribute or a combination of attributes for a relation is called a key if the values of the attributes uniquely deﬁne an ntuple. the attributes are ID Number. we cannot take the attribute Age as a key. Name. ”Find all persons that are 22 years old”. A query is a request for information from the database. For example. In the above table. If R is a subset of A1 × A2 × · · · × An then we call R an nary relation. we can take the attribute ID Number as a key since every person has a unique identiﬁcation number. For example. The relational database model is based on the concept of an nary relation.23 PROJECT VII: APPLICATIONS TO RELATIONS 145 23 Project VII: Applications to Relations Part I: Relational Database The ”bi” in binary relation R refers to the fact that R is a subset of the cartesian product of two sets. Position.1 ID# 22012 93831 58199 84341 01180 26710 61049 39826 Name Johnsonbaugh Glover Battey Cage Homer Score Johnsonbaugh Singleton Position c of p c lb p of 2b Age 22 24 18 30 37 22 30 31 A database is a collection of records that are manipulated by a computer. When an nary relation is represented by a table then the columns in this table are called attributes. A2 . and Age. . Let A1 . · · · .
Problem 23.2 Let A = {1. C. bj ) ∈ R 0 if (ai .3 What is the encrypted message produced from the message ”MEET YOU IN THE PARK”? (b) Decryption is the process of determining the original message. · · · . (a) The process of making a message secret is called encryption. Problem 23. b. (3.146 RELATIONS AND FUNCTIONS Problem 23. (2. the letter represented by p is replaced with the letter represented by the remainder of the division of (p + 3) by 26. 25. (1. (3. (2. 3)}. then the relation R is symmetric. In this case the letter represented by p is replaced by the letter represented by the remainder of the division of (p − 3) by 26. 3} and R = {(1. Position] Part II: Representing a Relation by a Matrix. 3). Express the above 4ary as a set of 4tuples.1 a. · · · . Answer the query: PLAYER[Name. 2). If mij = 0 or mji = 0 for i = j then R is antisymmetric. which is the study of secret messages. where M (R)T is the transpose of M (R). 2. 2). 1. (3. Part III: Cryptology An important application to congruences is cryptology. Answer the query: PLAYER[Name] c. Z by the integers 0. 1). . If M (R)T = M (R). symmetric or antisymmetric. Deﬁne the n × n matrix M (R) = (mij ) as follows: mij = 1 if (ai . 2. 2). Let A be a set with n elements and R be a binary relation on A. 1). Find M (R) and use it to determine if the relation R is reﬂexive. bj ) ∈ R If the numbers on the main diagonal of M (R) are all equal to 1 then R is reﬂexive. B. This process consists of assigning the alphabet A. Then the encrypted version of the message.
4 What is the message produced from the encrypted message ”PHHW BRX LQ WKH SDUN”? .23 PROJECT VII: APPLICATIONS TO RELATIONS 147 Problem 23.
A lattice is a poset [A.148 RELATIONS AND FUNCTIONS 24 Project VIII: WellOrdered Sets and Lattices Let [A. What is the least element of B? What is the greatest element of B? A poset [A. 12. ≤] is said to be wellordered if and only if ≤ is a total order and every subset of A has a least element.3 Consider the poset [IN. Problem 24.b(B). ≤) is not wellordered. 5. 9. 4. Z An element a ∈ A is called a lower bound of B if a ≤ x for all x ∈ B. Problem 24. 18} and R be the binary relation ”divides” on A.b(B) and l.2 a. 4.b(B). .b in A.b and g. The greatest element of the set of lower bounds of B is called the greatest lower bound.4 Consider the poset [IR. ≤) is wellordered.u. ≤] is a lattice. Let B ⊆ A. in symbol l. ≤].u. ≤] such that every pair of elements in A have a l. b.l. If x ≥ b for all x ∈ B then we call b the greatest element of B. Let B = {2.u.6 Let A = {2. We call a ∈ A an upper bound of B if x ≤ a for all x ∈ B.5 Show that [IR. 10}. Problem 24. 6. Find a lower bound of B as well as an upper bound.l. 3. An element b ∈ B is called a least element of B if and only if b ≤ x for all x ∈ B. Show that (Z .b(B). 4. Find g. ≤] and B = (−1. Problem 24. The least upper bound of the set of upper bounds of B is called the least upper bound. 9}. 7. Note that a lower bound or an upper bound is not unique. Show that (IN. Problem 24.l. in symbol g. Show that [A. Problem 24. R] is not a lattice. ≤] be a poset.1 Consider the set IN with the inequality relation ≤ . Let B = {2. 8. 8. 1).
Since there are more pigeons than holes. Show that at least two persons have the same ﬁrst and last names. and Laura and last names Bush. If the conclusion is false.2 Let S be a ﬁnite set and {A1 . and Gramm. Show that for any function f : S → T there is a t ∈ T such that the set {s ∈ S : f (s) = t} has more than k elements. William. we can account for at most k pigeons. Then apply the previous exercise. Problem 25. in this case. n One can uses the previous exercise to solve the following exercise. partitions S into n sets with n ≤ T . The reason this statement is true can be seen by arguing by contradiction. A mathematical way to formulate the pigeonhole principle is given by the following exercise Problem 25. · · · . Perry. A2 . we have a contradiction. . Use the method of contradiction to show that there is an index 1 ≤ i ≤ n such that Ai  ≥ S .25 PROJECT IX: THE PIGEONHOLE PRINCIPLE 149 25 Project IX: The Pigeonhole Principle The Pigeonhole principle asserts that if n pigeons ﬂy into k holes with n > k then some of the pigeonholes contain at least two pigeons.1 Ten persons have ﬁrst names George.4 If S and T are ﬁnite sets such that S > T  then any function f : S → T is not onetoone. Problem 25. As a consequence of the above exercise we have Problem 25. Hint: Show that the family At = {s ∈ S : f (s) = t}. each pigeonhole contains at most one pigeon and. where t ∈ T. An } be a partition of S.3 Let S and T be two ﬁnite sets such that S > kT  where k is a positive integer.
Problem 26. The purpose of this project is to look at some countably inﬁnite sets. Problem 26. A set that is not countable is said to be uncountable. Problem 26.2 Show that the function f : IN∗ → Z deﬁned by n 2 1−n 2 f (n) = if n is even if n is odd is bijective.4 Show that the set of rational numbers Q is countably inﬁnite. IN is countably inﬁnite. Examples of uncountable sets are IR and the intervals in IR.3 Show that the function f : Z → 2Z deﬁned by f (n) = 2n is a bijective Z function.. Thus. Problem 26. (Hint: I . A set A is called countable if it is either ﬁnite or countably inﬁnite.150 RELATIONS AND FUNCTIONS 26 Project X: Countable Sets We say that two sets have the same cardinality if and only if there is a bijective function between them. Z is countably inﬁnite. the set of even integers is countably inﬁnite. Hence. A set A is called countably inﬁnite if and only if A has the same cardinality as the set IN∗ of positive integers. Hence.1 Show that the function f : IN∗ → IN given by f (n) = n − 1 is a bijective function.
26 PROJECT X: COUNTABLE SETS 151 ) .
3. vending machines. Examples include digital computers. m) is the state to which A goes if m is input to A when A is in state s. Problem 27. The operation of a ﬁnitestate machine is commomly described by a diagram called a transition diagram. called the output alphabet. Besides input and output symbols. An elevator might be in a state of going down to the ﬁrst ﬂoor to pick up a passenger or in a state of stopping on the third ﬂoor on the way up to the ﬁfth ﬂoor. consequently. a subset of S whose elements are called accepting states. when coming back down from stopping and picking someone on the third ﬂoor. denoted by s0 . there is a set of states S for our model. down. of output symbols. 2. coin changers.1 Consider the ﬁnitestate automaton deﬁned by the transition diagram . For instance. A state is like a snapshot of what is happening in the machine at a particular instant. The edges labeled with inputs and nodes with states. a set O. and ﬁnal or accepting state(s).” The above discussion is formalized as follows: A ﬁnitestate automaton A consists of ﬁve objects: 1. store and process information and produce output. compilers. telephones. called the input alphabet. called the next state function. This model has an input/output unit. 4. the set of output symbols. and.152 RELATIONS AND FUNCTIONS 27 Project XI: FiniteState Automaton A ﬁnitestate machine can be looked at as a mathematical model that can accept input. if the elevator is in the state of moving up to the ﬁfth ﬂoor and has an input of someone pressing the down button on the third ﬂoor. of input symbols.” Remember. our model has a function. Let I be the set of input symbols and O. it goes to a state that says. A double circle stands for the ﬁnal or accepting state(s). If s ∈ S and m ∈ I then N (s. a nextstate function or transition function N : S × I → S. There are always an intial state of our model. and elevators. In the case of an elevator I might be up. has a way of communicating with the world using a set of symbols. a set S of states the machine can be in. Also. a set I. This function returns the next state based on the present state and input. 5. The initial state of the machine is s0 . while O might be stops on particular ﬂoors. and ﬂoor selection.
The language accepted by A. and only if.27 PROJECT XI: FINITESTATE AUTOMATON 153 a. Let A be a ﬁnitestate automaton with input alphabet I.2 Consider the ﬁnitestate automaton deﬁned by the following transition diagram . d. e. 1) and N (s3 . c. b. Problem 27. is the set of all words that are accepted by A. Let I ∗ be the set of all words with letters from I. 0). A goes to an accepting state when the symbols of w are input to A in sequence starting when A is in its initial state. A word w ∈ I ∗ is said to be accepted by A if. What are the elements of S? What are the input symbols? What is the initial state? What are the accepting states? Find N (s3 . denoted by L(A).
. Problem 27. Which of the words in part (a) send A to an accepting state? c. b. Let N ∗ : S × I ∗ → S be the function deﬁned as follows: N ∗ (s. given by the transition diagram below.3 A ﬁnitestate automaton A.154 RELATIONS AND FUNCTIONS a. Let A be a ﬁnitestate automaton with input alphabet I and states S. has transition function N and eventualstate functioin N ∗ . w) is the state to which A goes if the symbols of w are input to A in sequence starting when A is in state s. Show that L(A) = {0(10)n : n ≥ 0} where (10)n = 1010 · · · with n copies of 10 juxtaposed into one word. We call N ∗ the eventual state function. To what states does A go if the symbols of the following words are input to A in sequence starting from the initial state? (i) 1101 (ii) 0011 (iii) 0101010.
Find N ∗ (s2 . · · · . 11010) and N ∗ (s0 .27 PROJECT XI: FINITESTATE AUTOMATON 155 a. 011. Problem 27.4 Design a ﬁnitestate machine that recognizes words of the form 01. 0111. b. Find N (s2 . 0) and N (s1 . 01000). 0). 01111. .
156 RELATIONS AND FUNCTIONS .
Let T (n) be a measure of the time required to execute an algorithm of problem size n. Two aspects of the algorithm eﬃciency are: the amount of time required to execute the algorithm and the memory space it consumes. If n is suﬃciently small then the algorithm will not have a long running time. given an algorithm that performs a task. an algorithm is any welldeﬁned computational procedure that takes a set of values as input and produces a set of values as output. For example. In our time analysis we will restrict ourselves to the worst case behavior of 157 . we say that the problem size is n. Here. The running time of an algorithm is not measured by counting the minutes and seconds for the algorithm written in a particular language and running on a particular machine. 28 Time Complexity and ONotation The primary eﬃciency criterion for analyzing the eﬃciency of an algorithm is the running time of the algorithm as a function of the number of values it processes. In this chapter we introduce the basic techniques for calculating time eﬃciency. the interesting question is:”How fast T (n) increases as n increases?” This is called the asymptotic behavior of the time complexity function. Thus. Rather it is deﬁned to be an estimate of the number of operations performed by the algorithm given a particular number of input values. we will be interested in estimating the running time as a function of the problem size. We call T (n) the time complexity function of the algorithm. Generally. The subject of the analysis of algorithms consists of the study of eﬃciency of algorithms.Introduction to the Analysis of Algorithms Informally. let us consider the sequential search of an item X from a list of n items.
The inner loop is executed n times and the outer loop also is executed n . Prior to entering the loop. We say that T (n) has a growth of order n3 .j) := x next j next i Solution. Example 28. it takes two assignment statements to initialize the variables i and p. the longest running time for any input of size n. that is.158 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS an algorithm. For example. basically we will be focusing on the leading term of T (n). if T (n) = 4n3 − 2n2 + 2 1 5 n + 5 then T (n) = n3 (4 − n + n + n ) and for large n we have T (n) ∼ n3 . We say that one algorithm is more eﬃcient then another if its worse case running time has a lower order of growth.2 What is the runtime complexity based on n for the following program segement: for i := 1 To n for j := 1 To n A(i. Thus. The loop is executed n times. Since we are considering asymptotic eﬃciency of algorithms. the time complexity of the algorithm is given by T (n) = 4n + 2 so the growth is of order n. Example 28. and each time it executes the two assignment statements in the body of the loop with a total of two arithmetic operations.1 Estimate the time complexity of the following algorithm: i := 1 p := 1 for i := 1 to n p := p · i i := i + 1 next i Solution.
Hence.4 Show that the runtime complexity based on n for the following program segement is O(n2 ). We deﬁne the set O(g(n)) = {f (n) : there exists positive constants n0 and C such that f (n) ≤ Cg(n). Let g : IN → IR. Sometimes We write f (n) = O(g(n)). In the above two problems we found a precise expression for the time complexity of the algorithm. Graphically. this means that for n ≥ n0 the graph of f is below the graph of g. We say that a function f is order at most g or f bigoh of g if and only if f (n) ∈ O(g(n)). Prior to entering the loop there is one assignment statement. one subtraction. Indeed. We next introduce some of the concepts of growth orders. What usually interests us is the order of growth. T (n) = n2 so that the growth is of order n2 .28 TIME COMPLEXITY AND ONOTATION 159 times. Solution. Example 28. s := 0 for i := 1 To n for j := 1 To i s := s + j · (i − j + 1) next j next i Solution. one multiplication and one assignment for each iteration of the inner loop. there are two additions. Example 28. T (n) ≤ 5n for n ≥ 2 so that n0 = 2 and C = 5. f or n ≥ n0 }.3 Show that the time complexity found in Exercise 390 is O(n). Now. To show that T (n) = O(n) we must produce constants C and n0 such that T (n) ≤ Cn for n ≥ n0 . The total number of time the inner loop is executed is n(n + 1) 1 + 2 + 3 + ··· + n = 2 .
there exist constants C2 and n2 such that g(n) ≤ C2 h(n) for all n ≥ n2 . Solution. Let n0 = max{n1 . If p = 1 we say that the complexity is linear. T (n) = 5 · T (n) ∈ O(n2 ). n2 } and C = C1 C2 . Example 28. + 1 ≤ 5n2 .160 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS n(n+1) 2 Hence. Since f (n) ∈ O(g(n)). If p = 0 then we say that f is of constant complexity.7 Show that if f (n) ∈ O(g(n)) and g(n) ∈ O(h(n)) then f (n) ∈ O(h(n)). This leads to a contradiction since the lefthand side can be made as large as we please whereas the righthand side is constant. We say that a function f is of polynomial complexity if and only if f ∈ O(np ) for some p ∈ IN. Example 28. Solution.6 Show that n3 ∈ O(n2 ). Suppose that n3 ∈ O(n2 ). Solution. since n ≥ 1 then 1 + 2 + 3 + · · · + n ≤ n + n + n + · · · + n = n2 so that C = 1 and n0 = 1. Dividing through by n2 to obtain n ≤ C. Example 28. Similarly. We proceed by contradiction. Hence. Then there exist constants C and n0 such that n3 ≤ Cn for all n ≥ n0 .5 Show that 1 + 2 + 3 + · · · + n = O(n2 ). Indeed. Then for n ≥ n0 we have f (n) ≤ C1 g(n) ≤ C1 C2 h(n) = Ch(n) . there exist n1 and C1 such that f (n) ≤ C1 g(n) for all n ≥ n1 . n ≥ 1 so that C = 5 and n0 = 1.
· · · . Is this a polynomialtime algorithm? Solution. if L > 0 then g(n) ∈ O(f (n)). a[i − 1] > a[i]. Then there is a positive integer n0 such that  f (n) −L < 1 whenever g(n) n ≥ n0 . Hence. From part a. suppose that L > 0. 2 2 d.1 Suppose that limn→∞ f (n) = L with L ≥ 0. This implies that  f (n)  < 1 + L for n ≥ n0 . Let = 1. a[2]. How many possible pairs are compared? b. Now. Now suppose that L = 0. What is the maximum number of exchanges? c.8 Suppose we want to arrange the elements of a one dimensional array a[1]. T (n) ≤ n so that T (n) ∈ O(n2 ). 2 Next. Theorem 28. If L = limx→∞ f (x) then for any > 0 there is a positive integer N such that f (x) − L < whenever n ≥ N. g(n) 1 a. 2 b. The number of possible pairs to compare in the algorithm is 1 + 2 + · · · + (n − 1) = n(n − 1) . it follows that the maximum number of exchanges is c. But this is just saying that f (n) ∈ O(g(n)). we recall the following deﬁnition from calculus. T (n) = n(n−1) . if L = 0 then g(n) ∈ O(f (n)). we have the following important theorem. Moreover. What time the complexity of this algorithm in the worst case? d. We use contradiction to show that g(n) ∈ O(f (n)). Using this deﬁnition. For n ≥ 1. 2 n(n−1) . Interchange the roles of f and g in the previous argument to ﬁnd that g(n) < Cf (n) where 1 C = 1 + L and n ≥ n0 for some positive integer n0 . So suppose that g(n) ∈ O(f (n)). Hence. a[n] in increasing order. Then limn→∞ f (n) = L . switching the values of those that are out of order. An insertion sort compares every pair of elements. b. Then there exist positive constants .28 TIME COMPLEXITY AND ONOTATION 161 Example 28. a. f (n) < Cg(n) g(n) where C = (1 + L) and n ≥ n0 . a. g(n) a. Proof. and b. Then f (n) ∈ O(g(n)). g(n) ∈ O(f (n)).
we must have g(n) ∈ O(f (n)). M2 }. Hence. Let n0 = max{M1 . Then for n ≥ n0 we have C< g(n) ≤C f (n) which is a contradiction.162 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS C and M1 such that g(n) ≤ Cf (n) for all n ≥ M1 . . On the other hand. by 1 letting = C we can ﬁnd a positive integer M2 such that  f (n)  < whenever g(n) n ≥ M2 .
Problem 28. have to be interchanged. moving it to the front of the list. a[n] in increasing order. When two items in the list. we write switch(a[k]. a[2]. a[4] = 8. The sorting works by selecting the smallest item in the list.2 Find the worst case running time of the following segment of an algorithm: for i := 1 to n for j := 1 to 2n for k := 1 to n x := i · j · k next k next j next i Problem 28. a[5] = 4. The following is the selection algorithm: for i := 1 to n − 1 . and then ﬁnding the smallest of the remaining items and moving it to the second position in the list.3 Construct a table showing the result of each step when insertion sort is applied to the array a[1] = 6.28 TIME COMPLEXITY AND ONOTATION 163 Review Problems Problem 28. a[2] = 2. · · · . say a[k] and a[m].5 Selection sort is another algorithm for arranging the elements of a onedimensional array a[1]. a[3] = 1.1 Find the worst case running time of the following segment of an algorithm: for i := 1 to n for j := 1 to i+1 2 a := (n − i) · (n − j) next j next i Problem 28.4 How many comparisons actually occur when insertion sort is applied to the array of the previous exercise? Problem 28. a[m]). and so on.
7 √ √ n ∈ O( n). Problem 28. Show that Problem 28. Problem 28.9 Show that 13 + 23 + · · · + n3 ∈ O(n4 ). a[3] = 4.10 a. a[i]) next j next i Construct a table showing the result of each step when selection sort is applied to the array a[1] = 5.164 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS min := i for j := i + 1 to n if a[min] > a[j] then switch(a[min]. Use mathematical induction to show that 13 + 23 + · · · + n3 ≤ n3 for all n ≥ 1. What can you conclude from part (a) about the order of the above sum? 1 1 1 4 . b.8 Show that 12 + 22 + · · · + n2 ∈ O(n3 ). Problem 28. a[4] = 6. a[2] = 3. a[5] = 2.6 How many comparisons actually occur when selection sort is applied to the array of the previous exercise? Problem 28.
to show that log2 n = O(n). Show that n! = O(nn ). Example 29. Proof. C2 log2 a = log2 a. Unless explicitly stated. A function f (n) is said to be of exponential complexity if and only if f (n) ∈ O(an ) for some a > 1. Solution. n Since limn→∞ n log n = 0. O(loga n) = O(log2 n). a. Thus.n + n log2 n < 2nlog2 n = Cn log2 n.1 Show that n + n log2 n ∈ O(n log2 n). there is a positive integer n0 such that n < n log2 n 2 for all n ≥ n0 . Since n − i ≤ n for 0 ≤ i ≤ n we have n! = n(n − 1)(n − 2) · · · 2 · 1 ≤ n · n · n · · · n · n = nn . loga n = log2 a Now. Show that n = O(2n ). C2 and n0 such that loga n ≤ C1 log2 n and log2 n ≤ C2 loga n for all n ≥ n0 . Example 29. This shows that n + n log2 n ∈ O(n log2 n). c.1 For any a > 1. n ≥ n0 . b. By the change of bases formula we have log2 n . all logarithms in this chapter are to base 2 mainly because of the following theorem Theorem 29. Solution.2 a. let C1 = 1 .29 LOGARITHMIC AND EXPONENTIAL COMPLEXITIES 165 29 Logarithmic and Exponential Complexities In this section we assume that the reader is familiar with the deﬁnitions and rules of both exponential and logarithmic functions. and n0 = 1. We must show that there exist constants C1 . Use b. If f (n) ∈ O(log2 n) we say that f (n) has logarithmic complexity.
log2 n! = O(n log2 n).166 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS It follows that n! = O(nn ). Show that log2 n! = O(n log2 n). to show that 3n log2 n! + (n2 + 3) log2 n = O(n2 log2 n). Basis of induction: For n = 0 we have 0 ≤ 20 . Induction hypothesis: Suppose that n ≤ 2n . That is. It is easy to see that (n − i)(i + 1) ≥ n for all 0 ≤ i ≤ n − 1. n ≥ 1. In this case (n!)2 = [n · (n − 1) · · · 2 · 1][1 · 2 · · · (n − 1) · n] = (n · 1)[(n − 1) · 2] · · · [2 · (n − 1)](1 · n) ≥ n · n···n · n = nn . Use a.3 a. Show that if f1 (n) ∈ O(g(n)) and f2 (n) ∈ O(g(n)) then f1 (n) + f2 (n) ∈ O(g(n)). Example 29. Show that n log2 n = O(log2 n!). That is. Indeed. n log2 n = O(log2 n!). Show that if f1 (n) ∈ O(g1 (n)) and f2 (n) ∈ O(g2 (n)) then f1 (n) · f2 (n) ∈ O(g1 (n) · g2 (n)). a. Take the logarithm of both sides of b. Solution. n+1 ≤n+n ≤ 2n + 2n = 2n+1 Hence. log2 n = O(n). Now take the logarithm of both sides to obtain n log2 n ≤ 2 log2 n!. Example 29. We have shown that n! = O(nn ). to obtain log2 n ≤ n. n = O(2n ). We show by induction on n ≥ 0 that n ≤ 2n . Induction step: We must show that n + 1 ≤ 2n+1 . c. b. . and b. That is. b. That is.4 a. n! ≤ nn for n ≥ 1. b. b. c. Take logarithm of both sides to obtain log2 n! ≤ n log2 n.
c. there exist constants C2 and n2 such that f2 (n) ≤ C2 g2 (n) for all n ≥ n2 . Then for n ≥ n0 we have f1 (n) + f2 (n) ≤ C1 g(n) + C2 g(n) = Cg(n). Then for n ≥ n0 we have f1 (n) · f2 (n) ≤ Cg1 (n)g2 (n). n2 } and C = C1 · C2 . Since f1 (n) ∈ O(g(n)) then there exist n1 and C1 such that f1 (n) ≤ C1 g(n) for all n ≥ n1 . there exist n1 and C1 such that f1 (n) ≤ C1 g1 (n) for all n ≥ n1 . Using b. Since (n2 + 3) log2 n = O(n2 log2 n) then by a. Let n0 = max{n1 .29 LOGARITHMIC AND EXPONENTIAL COMPLEXITIES 167 Solution. . Let n0 = max{n1 . n2 } and C = C1 + C2 . Similarly. b. above and a. a. of the previous exercise we have 3n log2 n! = O(n2 log2 n). Similarly. there exist constants C2 and n2 such that f2 (n) ≤ C2 g(n) for all n ≥ n2 . and b. Now since f1 (n) ∈ O(g1 (n)). the result follows.
n 2 1 1 + · · · + ≤ ln n. to show that n + Problem 29. 3 b. 2 n n 3 + + ··· + n n ∈ O(n ln n).1 Show that 1 + 2 + 22 + · · · + 2n ∈ O(2n+1 ).4 1 1 a. Show that 2 + 1 + · · · + n ≤ ln n. to show that for n ≥ 3 1+ c. Use part a. n ≥ 2. .5 Show that 2n ∈ O(n!). Problem 29. Problem 29.3 Show that n2 + 2n ∈ O(2n ).2 Show that 2n + 3 2n 32 2n 33 2n 3n + + ··· + ∈ O(n).168 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS Review Problems Problem 29. Use b. Problem 29.
and n0 such that C1 g(n) ≤ f (n) ≤ C2 g(n) for all n ≥ n0 .and ΩNotations The Onotation asymptotically bounds a function from above.1 For given two functions f (n) and g(n). Example 30. C2 . we choose C2 ≥ 1 . Suppose that 6n3 = Θ(n2 ).2 Show that 6n3 = Θ(n2 ). .1 1 Show that 2 n2 − 3n = Θ(n2 ). we choose n0 = 12. When we have bounds from above and below. Then there exist positive constants C1 . For a given function g(n). The righthand side inequality yields 6n ≤ C2 for n ≥ n0 . we denote by Θ(g(n)) to be the set of all functions f such that there exist positive constants C1 . Theorem 30. A contradiction. 4 − 3 n ≥ 1 4 for all Example 30. 2 n 1 2 1 3 Since 2 − n ≤ 1 for all n ≥ 1. We use the argument by contradiction. C2 and n0 such that C1 n2 ≤ 6n3 ≤ C2 n2 for all n ≥ n0 . f (n) = Θ(g(n)) if and only if f (n) = O(g(n)) and g(n) = O(f (n)). 2 This is equivalent to C1 ≤ 1 3 − ≤ C2 . Let C1 and C2 be positive constants such that 1 C1 n2 ≤ n2 − 3n ≤ C2 n2 . If f ∈ Θ(g(n)) we write f (n) = Θ(g(n)). Finally. Solution. we use Θ notation. Solution.AND ΩNOTATIONS 169 30 Θ. Since 2 2 n ≥ 12. we choose C1 ≤ 1 .30 Θ. This says that the lefthand side can be made as large as we want whereas the righthand side is ﬁxed.
2 n log2 n ≤ log2 n! for n ≥ 1.170 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS Proof. Then there exist constants C1 . Solution. f (n) = Θ(g(n)). C2 and n0 such that C1 g(n) ≤ f (n) ≤ C2 g(n) for n ≥ n0 .2 For given two functions f (n) and g(n). Show that if f (n) = o(g(n)) then f (n) = O(g(n)). Let n0 = max{n1 . We say that f (n) = o(g(n)) if and only if limn→∞ f (n) = 0. For a given function g(n). Conversely. Suppose that f (n) = Θ(g(n)). let Ω(g(n)) denote the set of all funtions f (n) such that there exist positive constants C and n0 such that Cg(n) ≤ f (n) for all n ≥ n0 . b. Ω−notation provides an asymptotic lower bound.4 Let f (n) and g(n) be two given functions. n2 }. Then there exist positive constants C1 . f (n) = Θ(g(n)) if and only if f (n) = O(g(n)) and f (n) = Ω(g(n)). C2 . Find two functions f (n) and g(n) such that f (n) = O(g(n) but f (n) = o(g(n)). That is. The righthand side inequality implies that f (n) = O(g(n)) whereas the lefthand side inequality implies that f (n) = Ω(g(n)). Theorem 30.3 Show that log2 n! = Ω(n log2 n). C2 . Just as O provides an asymptotic upper bound on a function. Example 30. g(n) a. . Suppose ﬁrst that f (n) = Θ(g(n)). Now go backward for the converse. Example 30. n1 and n2 such that f (n) ≤ C2 g(n) for n ≥ n2 and C1 g(n) ≤ f (n) for n ≥ n1 . suppose that f (n) = O(g(n)) and f (n) = Ω(g(n)). This says that log2 n! = Ω(n log2 n). and n0 such that C1 g(n) ≤ f (n) ≤ C2 g(n) for all n ≥ n0 . Then for n ≥ n0 we have C1 g(n) ≤ f (n) ≤ C2 g(n). That is. For f (n) ∈ Ω(g(n)) we write f (n) = Ω(g(n)). The lefthand side inequality implies that g(n) = O(f (n)) whereas the righthand side inequality implies that f (n) = O(g(n)). Proof. 1 Since (n!)2 ≥ nn for all n ≥ 1 we ﬁnd n log2 n ≤ 2 log2 n!. Then there exist positive constants C1 .
f (n) ≤ g(n) for all n ≥ n0 . Then there is a positive integer n0 such that  f (n)  ≤ 1 for n ≥ n0 . Let f (n) = 2n2 and g(n) = n2 . . a.30 Θ. Hence. That is. g(n) f (n) = O(g(n)). Suppose that f (n) = o(g(n)). b.AND ΩNOTATIONS 171 Solution.
172 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS .
it is necessary to subtract A ∩ B from A + B. Indeed. Example 31. An } is a collection of pairwise disjoint sets then A1 ∪ A2 ∪ · · · ∪ An  = A1  + A2  + · · · + An . A + B includes twice the number of common elements. to get an accurate count of the elements of A ∪ B.Exclusion Principle A ∪ B = A + B − A ∩ B. A2 . A gives the number of elements in A including those that are common to A and B. the fundamentals of probablity theory are discussed. that if {A1 .Fundamentals of Counting and Probability Theory The major goal of this chapter is to establish several techniques for counting large ﬁnite sets without actually listing their elements. Basis of induction: For n = 2 the result holds by the InclusionExclusion 173 . Note that if A and B are disjoint then A ∩ B = 0 and consequently A ∪ B = A + B. Hence.1 (The Addition Rule) Show by induction on n. X denotes the number of elements of X. It is easy to see that for any two sets A and B we have the following result known as the Inclusion . 31 Elements of Counting For a set X. Also. Hence. Solution. The same holds for B. · · · .
where the ﬁrst step can be made in n1 diﬀerent ways. Induction hypothesis: Suppose that for any collection {A1 . It states that if a decision consists of k steps. · · · . the second step in n2 ways. Since (A1 ∪ A2 ∪ · · · ∪ An ) ∩ An+1 = (A1 ∩ An+1 ) ∪ · · · ∪ (An ∩ An+1 ) = ∅ then by the InclusionExclusion Principle and the induction hypothesis we have A1 ∪ A2 ∪ · · · ∪ An ∪ An+1  = A1 ∪ A2 ∪ · · · ∪ An  + An+1  = A1  + A2  + · · · + An  + An  Example 31. and 2 knew neither languages. 28 knew PASCAL. That is. An } of pairwise disjoint sets we have A1 ∪ A2 ∪ · · · ∪ An  = A1  + A2  + · · · + An . 33 = 25 + 28 − A ∩ B. A2 . Solving for A ∩ B we ﬁnd A ∩ B = 20. Suppose that a state’s license plates consist of 3 letters followed by four digits.3 a. Let A be the group of programmers that knew FORTRAN. An+1 } be a collection of pairwise disjoint sets. Induction step: Let {A1 . An . Example 31. B those who knew PASCAL.174 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Principle. A2 . 25 knew FORTRAN. · · · . the kth step in nk ways. How many knew both languages? Solution. Another important rule of counting is the multiplication rule. How many diﬀerent plates can be manufactured? (no repetitions) .2 A total of 35 programmers interviewed for a job. · · · . How many possible outcomes are there if 2 distinguishable dice are rolled? b. then the decision itself can be made in n1 n2 · · · nk ways. By the InclusionExclusion Principle we have A ∪ B = A + B − A ∩ B. Then A ∩ B is the group of programmers who knew both languages.
Find all possible 2permutations of the set {1. Example 31. dc} An rpermutation of n objects. the rth in n − r + 1 diﬀerent ways.4 Let Σ = {a. Constructing a tree diagram we ﬁnd that the words are {ab. ac. Example 31. b. cb. P (n. bd. ca. r). List the words by means of a tree diagram. d} be an alphabet with 4 letters. First use the product rule. P (3. Let Σ2 be the set of all words of length 2 with letters from Σ. the second in n − 1 diﬀerent ways. Thus. .. That is. cd. db. By the multiplication rule there are 26 × 25 × 24 × 10 × 9 × 8 × 7 possible license plates. 3! b. . bc. Find the number of all words of length 2 where the letters are not repeated. da. Solution. We can treat a permutation as a decision with r steps. r) = n! n(n − 1) · · · (n − r + 1) = (n−r)! . 2) = (3−2)! = 6.5 n! a. c. a. b. b. is an ordered selection of r objects from a given n objects. Solution. ba. Use the product rule to show that P (n. The ﬁrst step can be made in n diﬀerent ways. r) = (n−r)! . in symbol P (n.31 ELEMENTS OF COUNTING 175 Solution. 2. By the multiplication rule there are 4 × 3 = 12 diﬀerent words. ad.. 3}. by the multiplication rule there are n(n − 1) · · · (n − r + 1) rpermutations of n objects. By the multiplication rule there are 6 × 6 = 36 possible outcomes.. a.
b. Thus. n − r). n) = 1 and C(n. in symbol C(n. 0) = C(n. r) groups of r objects from a given n objects then the number of ordered selection of r objects from n given objects is r!C(n. Solution. k). 5) = 2. Symmetry property: C(n. is an unordered selection of r of the n objects. Since there are C(n. b. n − r) = = = n! (n−r)!(n−n+r)! n! r!(n−r)! C(n. r). Thus C(n.8 Prove the following identities: a. r ≤ n. n ≥ k.7 In how many diﬀerent ways can a hand of 5 cards be selected from a deck of 52 cards?(no repetition) Solution. 960. r) . we have C(n. r) = C(n. r). 624. P (26. r). 598. C(52. C(n.6 How many license plates are there that start with three letters followed by 4 digits (no repetitions)? Solution. 3) · P (10. r) = n! P (n. C(n. k) = C(n. 4) = 78. But the number of diﬀerent ways that r objects can be ordered is r!. k − 1) + C(n. r! r!(n − r)! Example 31. 1) = C(n. c. r) is the number of ways of choosing r objects from n given objects without taking order in account. Follows immediately from the deﬁnition of of C(n.176 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Example 31. Indeed. n − 1) = n. An rcombination of n objects. r) = P (n. 000. a. r) = . Example 31. Pascal’s identity: C(n + 1.
1 (Binomial Theorem) Let x and y be variables. k)xn−k+1 y k . k)x1−k y k = x + y. k) is called the binomial coeﬃcient. 177 C(n. . k) (n+1−k)! Pascal’s identity allows one to construct the following triangle known as Pascal’s triangle (for n = 5) as follows 1 1 1 1 1 → → → → 1 2 → 1 3 → 3 →1 4 → 6 →4 → 1 The following theorem provides an expension of (x + y)n where n is a nonnegative integer. k) = = = = n! n! + k!(n−k)! (k−1)!(n−k+1)! n!k + n!(n−k+1) k!(n−k+1)! k!(n−k)! n! (k + n − k + 1) k!(n−k+1)! (n+1)! = C(n + 1. k)xn−k y k where C(n. Induction step: Let us show that it is still true for n + 1. Then n (x + y) = k=0 n C(n.31 ELEMENTS OF COUNTING c. Proof. Theorem 31. k − 1) + C(n. and let n be a positive integer. That is n+1 (x + y) n+1 = k=0 C(n + 1. The proof is by induction. Basis of induction: For n = 1 we have 1 (x + y) = k=0 1 C(1. Induction hypothesis: Suppose that the theorem is true for n.
k) = 2n . This follows from the binomial theorem by letting x = 1 and y = −1 . 2)xn−1 y 2 · · · + C(n + 1. k) = 0.178 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Indeed. k)xn−k+1 y k . k)x n−k k y +y k=0 n C(n. we have (x + y)n+1 = (x + y)(x + y)n = x(x + y)n + y(x + y)n n n = x k=0 n C(n. n − 1)xy n C(n. n + 1)y n+1 n+1 C(n + 1. k=0 Solution. By the Binomial Theorem and Pascal’s triangle we have (x + y)6 = x6 + 6x5 y + 15x4 y 2 + 20x3 y 3 + 15x2 y 4 + 6xy 5 + y 6 Example 31.10 a. k=0 Example 31. 0)xn+1 + C(n + 1. n)y n+1 C(n + 1. n)xy n + C(n. b. 2)xn−1 y 2 · · · + C(n. k=0 b. a. 1)x y + C(n. 0)x + C(n. 1)xn−1 y 2 + · · · + C(n. 0)xn y C(n. Letting x = y = 1 in the binomial theorem we ﬁnd n 2 = (1 + 1) = k=0 n n C(n. n)xy n + C(n + 1. k). k)xn−k y k C(n. Solution. 1)xn y + C(n + 1. k)xn−k+1 y k + n+1 k=0 n = + + + = + = C(n. Show that n (−1)k C(n. k)xn−k y k+1 = k=0 C(n.9 Expand (x + y)6 using the binomial theorem. Show that n C(n.
31 ELEMENTS OF COUNTING 179 Review Problems Problem 31. Problem 31. In how many ways can 4 cards be drawn. .6 Find the coeﬃcient of a5 b7 in the binomial expansion of (1 − 2b)12 . Problem 31. How many diﬀerent combinations of main dishes could you order? Problem 31.4 In how many ways can 7 women and 3 men be arranged in a row if the three men must always stand next to each other. How many diﬀerent license plates are there that involve 1. from a deck of 52 cards? Problem 31. 2. · · · . from a deck of 52 cards? b. or 3 letters followed by 4 digits (with repetitions)? Problem 31. with replacement. 2. 1. How many ways can we get a sum of 8 when two undistinguishable dice are rolled? Problem 31. How many 4digit numbers can be formed using the digits.2 a.7 Use the binomial theorem to prove that n 3 = k=0 n 2k C(n. In how many ways can 4 cards be drawn. without replacement.3 a. How many ways can we get a sum of 4 or a sum of 8 when two distinguishable dice are rolled? b.1 a. 9 (with repetitions)? How many can be formed if no digit can be repeated? b.5 A menu in a Chinese restaurant allows you to order exactly two of eight main dishes as part of the dinner special. k).
(d) No.1 Which of the following numbers cannot be the probability of some event? (a) 4 0. Example 32. if S is the sample space then the collection of all possible events is the power set P(S). Solution. 6} where each digit represents a face of the die. if E = S then P (S) = 1. An event is any subset of a sample space. namely the theory of statistics.71 (b)−0. The probability of occurrence of an event E (called its success) will be denoted by P (E). (c) No since the number is greater than 1. total number of outcomes S where E is the number of elements in E. 2. The Probability of an event E is the measure of occurrence of E. 4. An experiment is any operation whose outcomes cannot be predicted with certainty. The sample space S of an experiment is the set of all possible outcomes for the experiment. 5. (a) Yes. Since the number is negative.5 (c) 150% (d) 3 . The closer to 1 the probability is. On the other hand. It is a number between 0 and 1. The classical probability concept applies only when all possible outcomes are equally likely. This section introduces the most basic ideas of probabiltiy. Example 32. If an event has no outcomes. the more likely the event is. Various probability concepts exist nowadays. If the occurrence is certain then the probability is 1. in which case we use the formula P (E) = number of outcomes f avorable to event E = . For example. that is as a subset of S if E = ∅ then P (∅) = 0. Thus. Thus. A sample space for this experiment is S = {1. 0 ≤ P (E) ≤ 1. (b) No. 3.180 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY 32 Basic Probability Terms and Rules Probability theory is one of the serious branch of mathematics with applications to many sciences. If the event is impossible to occur then its probability is 0.2 What is the probability of drawing an ace from a wellshuﬂed deck of 52 playing cards? . if you roll a die one time then the experiment is the roll of the die.
4 P (Ace) = 52 = 181 1 .45. Example 32.5 The probability that a college student without a ﬂu shot will get the ﬂu is 0. P (3 or 4) = 2 6 1 = 3.32 BASIC PROBABILITY TERMS AND RULES Solution. Estimate the probability that any one jet from Dallas to Phoenix will arrive on time. for there are many situations in which the various outcomes cannot all regarded as equally likely. Note that P (E) + P (E c ) = 1. Example 32. when we wonder whether a person will get a raise or when we want to predict the outcome of an election.4 Records show (over a period of time) that 468 of 600 jets from Dallas to Phoenix arrived on time. This would be the case. f P (E) = n = 468 600 39 50 = We deﬁne the probability of nonoccurrence of an event E (called its failure) by the formula P (E c ) = 1 − P (E). n where f is the frequency of the event and n is the size of the sample space.3 What is the probability of rolling a 3 or a 4 with a fair die? Solution. for instance. A widely used probability concept is the estimated probability which uses the relative frequency of an event and is given by the formula: f P (E) = Relative f requency = . Solution. 13 Example 32. What is the probability that a college student without the ﬂu shot will not get the ﬂu? . A major shortcoming of the classical probability concept is its limited applicability.
Proof. P (∅) = 0.7 For any event E of a sample space S show that P (E) = Solution. Thus.45 = . Theorem 32. This follows from the previous theorem x∈E P (x).182 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Solution. Next. we discuss some of the rules of probability. In this case A ∩ B = ∅.6 If A and B are mutually exclusive then what is P (A ∩ B)? Solution. Two events A and B are said to be mutually exclusive if they have no outcomes in common. . Example 32. By the InclusionInclusion Principle we have A ∪ B = A + B − A ∩ B. The probability is 1 − 0. A∪B P (A ∪ B) = S A + B − A∩B = S S S = P (A) + P (B) − P (A ∩ B).55.1 For any events A and B the probability of A ∪ B is given by the addition rule P (A ∪ B) = P (A) + P (B) − P (A ∩ B). The union of two events A and B is the event A ∪ B whose outcomes are either in A or in B. The intersection of two events A and B is the event A ∩ B whose outcomes are outcomes of both events A and B. Example 32. If A and B are mutually exclusive then by Exercise 443 the above formula reduces to P (A ∪ B) = P (A) + P (B).
15 + . the color distribution is: (a) Orange: 15% (b) Green: 10% (c) Red: 20% (d) Yellow: 20% (e) Brown: 30% (f) Tan: 5%.05 = . Solution. What is the probability that the sum of two dice equals six given that the ﬁrst die is a four? . It is given by the formula P (AB) = P (A ∩ B) . P(not brown candy) = 1 − .8 M &M plain candies come in a variety of colors. The events are not mutually exclusive since there is an ace that is also a spade. P(not brown candy).32 BASIC PROBABILITY TERMS AND RULES 183 Example 32.10 Consider the experiment of tossing two dice. P (A ∪ B) = P (A) + P (B) − P (A ∩ B) = 13 1 4 + − = 31% 13 52 52 Now. Suppose you have a large bag of plain candies and you reach in and take one candy at random.7 = 70% Example 32. P(orange candy Or tan candy) = . The conditional probability P (AB) denotes the probability that event A will occur given that event B has occurred. The outcomes are mutually exclusive. Are these outcomes mutually exclusive? 2. Find 1.2 = 20%. According to the manufacturer. Solution.3 = . Are A and B mutually exclusive? Find P (A ∪ B). 2. given two events A and B belonging to the same sample space S. P(orange candy Or tan candy).9 If A is the event ”drawing an ace” from a deck of cards and B is the event ”drawing a spade”. P (B) Example 32. 1.
184 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Solution. (4. c. d. Yes. P (A ∩ B) = P (A) · P (B). 3). the probability that the sum is six given that the ﬁrst die is four is 1 . Then P (A) = P (AB) = P P (B) . Find P(5 on green die and 3 on red die). 6 Assuming that the experiment consists of tossing the two dice then by letting B be the event that the ﬁrst die is 4 and A be the even that the sum of the two dice is 6 then P (AB) = P (A ∩ B) = P (B) 1 36 6 36 = 1 6 If P (AB) = P (A). (4. if P (A ∩ B) = P (A) · P (B) (A∩B) then P (AB) = P P (B) = P (A). P((5 on green die and 3 on red die) or (3 on green die and 5 on red die)) 1 1 1 = 36 + 36 = 18 . Solution. (A∩B) Suppose that A and B are independent. 6)}. . If two events are not independent. the occurrence of A is independent whether or not B occurs. 6 6 1 c. (4. Thus. we say that they are dependent.11 Show that A and B are independent if and only if P (A ∩ B) = P (A) · P (B). 4). Solution. Find P((5 on green die and 3 on red die) or (3 on green die and 5 on red die)). (4. P(3 on green die and 5 on red die) = 36 . Example 32. Find P(3 on green die and 5 on red die). (4. Conversely. That is.12 You roll two fair dice: a green one and a red one. d. That is. 1 b. we say that the two events A and B are independent. Are the outcomes on the dice independent? b. The possible outcomes of our experiment are {(4. 2). 1). a. P(5 on green die and 3 on red die) = 1 · 1 = 36 . a. Example 32. 5).
32 BASIC PROBABILITY TERMS AND RULES Example 32.13 Show that P (BA) =
185
P (B) · P (AB) . P (A)
Solution. This follows from the fact that P (A ∩ B) = P (B ∩ A) and the formula of P (AB) given above. Example 32.14 Prove Bayes’ Theorem P (AB) = P (BA)P (A) . P (BA)P (A) + P (BAc )P (Ac )
Solution. Note ﬁrst that {Ac ∩ B, A ∩ B} form a partition of B. Thus, P (B) = P (A ∩ B) + P (Ac ∩ B). Now by the previous exercise we have P (AB) = =
P (A)·P (BA) P (B) P (BA)P (A) P (BA)P (A)+P (BAc )P (Ac )
Example 32.15 Consider two urns. The ﬁrst contains two white and seven black balls and the second contains ﬁve white and six black balls. We ﬂip a fair coin and then draw a ball from the ﬁrst urn or the second urn depending on whether the outcome was head or tail. What is the conditional probability that the outcome of the toss was head given that a white ball was selected? Solution. Let W be the event that a white ball is drawn, and let H be the event that the coin comes up heads. The desired probability P (HW ) may be calculated as follows: P (H∩W ) P (HW ) = P (W ) P (W H)P (H) = P (W ) P (W H)P (H) = P (W H)P (H)+P (W H c )P (H c ) =
2 1 9 2 21 5 1 + 11 2 92
=
22 67
186 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
It frequently occurs that in performing an experiment we are mainly interested in some functions of the outcome as opposed to the outcome itself. For example, in tossing dice we are interested in the sum of the dice and are not really concerned about the actual outcome. These realvalued functions deﬁned on the sample space are known as random variables. If the range is a ﬁnite subset of IN then the random variable is called discrete. Otherwise, the random variable is said to be continuous. Discrete random variable are usually the result of a count whereas a continuous random variable is usually the result of a measurement. A probability distribution is a correspondence that assigns probabilities to the values of a random variable. The graph of a probability distribution is called is a histogram.
Example 32.16 Let f denote the random variable that is deﬁned as the sum of two fair dice. Find the probability distribution of f.
Solution. 1 P (f = 2) = P ({(1, 1)}) = 36 , 2 P (f = 3) = P ({(1, 2), (2, 1)}) = 36 , 3 P (f = 4) = P ({(1, 3), (2, 2), (3, 1)}) = 36 , 4 P (f = 5) = P ({(1, 4), (2, 3), (3, 2), (4, 1)}) = 36 , 5 P (f = 6) = P ({(1, 5, (5, 1), (2, 4), (4, 2), (3, 3)}) = 36 , P (f = 7) = P ({(1, 6), (6, 1), (2, 5), (5, 2), (4, 3), (3, 4)}) = 5 P (f = 8) = P ({(2, 6), (6, 2), (3, 5), (5, 3), (4, 4)}) = 36 , 4 P (f = 9) = P ({(3, 6), (6, 3), (4, 5), (5, 4)}) = 36 , 3 P (f = 10) = P ({(4, 5), (5, 4), (5, 5)}) = 36 , 2 P (f = 11) = P ({(5, 6), (6, 5)}) = 36 , 1 P (f = 12) = P ({(6, 6)}) = 36 .
6 , 36
Example 32.17 Construct the histogram of the random variable of the previous exercise.
32 BASIC PROBABILITY TERMS AND RULES Solution.
187
For a discrete random variable f we deﬁne the expected value ( or mean) of f by the formula E(f ) = f (x)P (x)
x∈S
In other words, E(f ) is a weighted average of the possible values that f can take on, each value being weighted by the probability that f assumes that value. Example 32.18 Find E(f ) where f is the outcome when we roll a fair die. Solution. Since P (1) = P (2) = · · · = P (6) =
1 6
we ﬁnd
1 1 7 1 E(f ) = 1( ) + 2( ) + · · · + 6( ) = 6 6 6 2
188 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Another quantity of interest is the variance of a random variable f , denoted by V ar(f ), which is deﬁned by V ar(f ) = E[(f − E(f ))2 ]. In other words, the variance measures the expected square of the deviation of f from its expected value. The standard deviation of a random variable f is the quantity is deﬁned to be the square root of the variance. Example 32.19 Show that if f and g are random variables then E(f + cg) = E(f ) + cE(g) where c is a constant. Solution. Indeed, E(f + cg) = = = Theorem 32.2 V ar(f ) = E(f 2 ) − (E(f ))2 . Proof. Indeed, using the previous exercise we have V ar(f ) = E(f 2 − 2E(f )f + (E(f ))2 ) = E(f 2 ) − 2E(f )E(f ) + (E(f ))2 = E(f 2 ) − (E(f ))2 Example 32.20 Calculate V ar(f ) when f represents the outcome when a fair die is rolled. Solution. First note that E(f 2 ) = (f (1))2 P (1) + · · · + (f (6))2 P (6) = By the above theorem we have V ar(f ) = E(f 2 ) − (E(f ))2 = 91 7 35 − ( )2 = 6 2 12 91 . 6 + cg)(x)P (x) x∈S g(x)P (x) x∈S f (x)P (x) + c E(f ) + cE(g)
x∈S (f
Being foreignborn and being President of the United States.6 If the probabilities are 0.15.03 that a student will get a failing grade in Statistics. and 0.35.20. a 1 or a 6.3 A department store’s records show that 782 of 920 women who entered the store on a saturday afternoon made at least one purchase. P (B) = 0.54.1 What is the probability of drawing a red card from a well.5 If A and B are the events that a consumer testing service will rate a given stereo system very good or good. what is the probability that the student will get a failing grade in at least one of these subjects? Problem 32.32 BASIC PROBABILITY TERMS AND RULES 189 Review Problems Problem 32. P (A ∪ B). b. Problem 32.22. b. P (A ∩ B). or in both. b. a.shuﬄed deck of 52 playing cards? Problem 32.7 If the probability that a research project will be well planned is 0. what are the probabilities of getting a.2 If we roll a fair die. in English. Find a. P (A) = 0.60 and the probability that it will be well planned and well executed is 0. A driver getting a ticket for speeding and a ticket for going through a red light. an even number? Problem 32. Estimate the probability that a woman who enters the store on a Saturday afternoon will make at least one purchase. Problem 32. c. 0.4 Which of the following are mutually exclusive? Explain your answers. what is the probability that a well planned research project will be well executed? . Problem 32. P (Ac ).
30. Problem 32. . B. Let f represent the number of heads. and C such that P(A)=0.9 There are 16 equally likely outcomes by ﬂipping four coins.190 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY Problem 32. P(B)=0. Show that the events A and B are independent. and P (A∩ B) = 0.8 Given three events A. Find the probability distribution and graph the corresponding histogram.15.50.
1 The registrar of a college noted that for many years the withdrawal rate from an introductory chemistry course has been 35% each term. p.2 Harper’s Index states that 10% of all adult residents in Washington D. c. What makes a trial? b. a.. Now. q = . If the selection is without replacement then the trials are dependent. we want to ﬁnd the probability that 3 are lawyers.33 BINOMIAL RANDOM VARIABLES 191 33 Binomial Random Variables In this section we discuss an important example of a discrete random variable. The central question of a binomial experiment is to ﬁnd the probability of r successes out of n trials. there are a total of 80 trials. D. p = . Example 33. selecting a ball from a box that contain balls of two diﬀerent colors.65. are lawyers. b. a. Also..35. p and q are related by the formula p + q = 1. The probability of a success is denoted by p = P (S) and that of a failure by q = P (F ). F = withdrawing from course.C. We wish to ﬁnd the probability that 55 students out of 80 will register for the course. For a random sample of 15 adult Washington. Thus. What makes a trial? . residents. we do not have independent trials. S = completing the course. For example. anytime we make selections from a population without replacement. What are the values of n. Moreover. Binomial experiments are problems that consist of a ﬁxed number of trials n. r? Solution. we assume that the trials are independent. q. that is what happens to one trial does not aﬀect the probability of a success in any other trial. with each trial having exactly two possible outcomes: Success and failure. a. What is a success? a failure? c. r = 55. Example 33. The decision of each student to withdraw or complete the course can be thought as a trial.C. n = 80.
Now. (b)2 heads and 1 tail.5) = 8 .5)(. is a lawyer or not. P (1) = C(3. P (2) = C(3. r) = n! . What is a success? a failure? c. Solution. 8 3 b. p. F = not being a lawyer. S = being a lawyer. r = 3. C(3. n = 15. We next see how to ﬁnd these probabilities. r? Solution. Recall from Section 6. r) counts the number of outcomes that have r successes and n − r failures then the equation above follows. q = . pr (1−p)n−r .9.5) = 8 .3 Find the probability that in tossing a fair coin three times there will appear (a) 3 heads. What are the values of n.1. c. Since C(n. (c) 2 tails and 1 head. p = . A trial is whether an adult resident of Washington. r)pr q n−r where p = P (S) and q = P (F ) = 1 − p. q.192 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY b. a. Example 33.5)3 (. r!(n − r)! We call the number C(n. 1 d. the central problem of a binomial experiment is to ﬁnd the probability of r successes out of n independent trials. One commonly used procedure for ﬁnding these coeﬃcients is by means of Pascal’s triangle. the probability of r successes out of n independent trials is given by the binomial distribution formula P (r) = C(n. 3)(. b.5)3−3 = 1 .5)3 = 8 .1 the formula for ﬁnding the number of combinations of n distinct objects taken r at a time C(n. As mentioned earlier. 0)(. r) the binomial coeﬃcient. The validity of the above equation may be veriﬁed by ﬁrst noting that the probability of any particular sequence of the n outcomes with r successes and n − r failures is. D. 3 2 c. by the independence of trials.C.5)2 (. a. and (d) 3 tails. 2)(. 1)(. P (0) = C(3.
6)5 . (a) C(5. .5 Find the probability of guessing correctly at least 6 of the 10 answers on a truefalse examination. 0)(. (c) 1 − C(5. 5)(. Solution. (d) C(5. (c) at least 1. (b) C(5.4)5 . i)p q n n! = np i=1 (i−1)!(n−i) pi−1 q n−i−1 n−1 = np i=0 C(n − 1.4)(. (d) all will graduate. Theorem 33. (b) 1. The variance of a binomial random variable is given by σ 2 = npq. 0)(. Example 33.6)5 . Using the deﬁnition of µ we have n µ = i=0 iP (i) n i n−i = i=1 iC(n. b.4.4 The probability that an entering college student will graduate is 0. Solution.6)4 . Proof. We next derive formulas for ﬁnding the expected value and standard deviation for the binomial random variable. 1)(. Determine the probability that out of 5 students (a) none.1 a. The mean of a binomial random variable is given by µ = np. i)pi q n−1−i = np(p + q)n−1 = np.33 BINOMIAL RANDOM VARIABLES 193 Example 33. P (6) + P (7) + P (8) + P (9) + P (10). a.
Note ﬁrst that i2 = i(i − 1) + i. i)p q n n! pi q n−i + µ = i=2 (n−i)!(i−2)! (n−2)! = n(n − 1)p2 n (n−i)!(i−2)! pi q n−i + µ i=2 = n(n − 1)p2 n−2 C(n − 2.194 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY b. j)pj q n−2−j + µ j=0 = n(n − 1)p2 (p + q)n−2 + µ = n(n − 1)p2 + µ It follows that σ2 = E(X 2 ) − µ2 = n(n − 1)p2 + np − n2 p2 = npq . Then n 2 E(X 2 ) = i=0 i P (i) n i n−i = +µ i=0 i(i − 1)C(n.
2 Problem 33. According to the actuarial tables. (c) only 2 men. (d) none will be alive. the probability that a man 2 of this particular age will be alive 30 years is 3 . the nursing staﬀ is large enough so that 80% of the time a nurse can respond to a room call within 3 minutes. Last night there were 73 room calls. What makes a trial? b. all of identical age and in good health. p.2 Find the probability that in a family of 4 children there will be (a) at least 1 boy and (b) at least 1 boy and 1 girl. r? Problem 33. Find the probability that in 30 years (a) all 5 men.3 An insurance salesperson sells policies to 5 men. What are the values of n.33 BINOMIAL RANDOM VARIABLES 195 Review Problems Problem 33. Assume that the probability of a male birth is 1 . . (b) at least 3 men. q. What is a success? a failure? c.1 At Community Hospital. We wish to ﬁnd the probability nurses responded to 62 of them within 3 minutes. a.
196 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY .
called its endpoints. EG ). A graph with neither loops nor parallel edges is called simple graph. We denote a graph by G = (VG . rooted and spanning trees. Example 34. Two edges associated to the same vertices are called parallel. Two vertices are said to be adjacent if there is an edge connecting the two vertices. 34 Graphs. Paths. and Circuits An undirected graph G consists of a set VG of vertices and a set EG of edges such that each edge e ∈ EG is associated with an unordered pair of vertices.Elements of Graph Theory In this chapter we present the basic concepts related to graphs and trees such as the degree of a vertex. An edge incident to a single vertex is called a loop. A directed graph or digraph G consists of a set VG of vertices and a set EG of edges such that each edge e ∈ EG is associated with an ordered pair of vertices. isomorphisms of graphs. connectedness. A vertex that is not incident on any edge is called an isolated vertex.1 Consider the following graph G 197 . Euler and Hamiltonians circuits.
G is not simple since it has a loop and parallel edges. e5 . e5 }.3 Draw K2 . c. e3 . b. e2 . Example 34. List the parallel edges. d. {v2 .2 Which one of the following graphs is simple. e4 . EG = {e1 . {e1 . b. a. . denoted by Kn . Solution. K4 . e5 . A complete graph on n vertices. d. e3 }. e4 . There is only one loop.198 a. e. v4 . List the loops.. Example 34. b. Find EG and VG . v7 }. f. ELEMENTS OF GRAPH THEORY Solution. K3 . a. There is only one isolated vertex. e6 } and VG = {v1 . G is simple. c. v5 . v3 . List the vertices adjacent to v3 . v4 }. List the isolated vertices. is the simple graph that contains exactly one edge between each pair of distinct vertices. e. v5 . {e2 . Find all edges incident on v4 . f. and K5 . v2 . v6 .
A complete bipartite graph Km. More . according to the deﬁnition of bipartite graph. Show that the graph G is bipartite. a. Clear from the deﬁnition and the graph. Any two sets of vertices of K3 will have opposite parity. respectively.34 GRAPHS. Thus. Show that K3 is not bipartite. b. is the graph that has its vertex set partitioned into two disjoint subsets of m and n vertices. b.n . Solution. Example 34. K3 is not bipartite. 199 A graph in which the vertices can be partitioned into two disjoint sets V1 and V2 with every edge incident on one vertex in V1 and one vertex of V2 is called bipartite graph.4 a. PATHS. AND CIRCUITS Solution.
By deﬁnition. Solution. Example 34. in symbol deg(v). deg(v3 ) = 4. The total degree of G is the sum of the degrees of all the vertices of G. . deg(v2 ) = 2.3 .6 What are the degrees of the vertices in the following graph Solution.200 ELEMENTS OF GRAPH THEORY over.3 . The degree of a vertex v in an undirected graph. K3. Example 34. deg(v1 ) = 0.5 Draw K2. there is an edge between two vertices if and only if one vertex is in the ﬁrst set and the other vertex is in the second set. is the number of edges incident on it. a loop at a vertex contributes twice to the degree of that vertex.
there must be an even number of vertices with odd degree. Then T = E + O. PATHS. Theorem 34.1. AND CIRCUITS Theorem 34. That is. n(n−1) = 2EG . · · · . By Theorem 34. Example 34. Then e contributes 1 to deg(vi ) and contributes 1 to the deg(vj ). v2 .1 For any graph G = (VG . the degree of each of the n vertices is n − 1. each vertex is adjacent to the remaining vertices. Proof. Let E be the sum of the numbers deg(v).7 Find a formula for the number of edges in Kn . By the previous theorem. Therefore. This implies that there must be an even number of the odd degrees. 2EG  = deg(v) v∈V (G) The following is easily deduced from the previous theorem. Thus. Let G = (VG . Since e was arbitrarily. Solution. O = T − E. If e is not a loop then let vi and vj denote the endpoints of e. Proof. This completes a proof of the theorem . each which is even and O the sum of numbers deg(v) each which is odd. EG ) we have 2EG  = v∈V (G) 201 deg(v). Thus.2 In any graph there are an even number of vertices of odd degree. Suppose that VG = {v1 . vn } and EG  = m. EG ) be a graph.34 GRAPHS. and we have the sum of the degrees of all of the vertices being n(n−1). Let e ∈ EG . Since both T and E are even then T is also even. the sum of all the degrees of the vertices is T = 2EG . an even number. this shows that each edge of G contributes 2 to the total degree of G. Since G is complete. Hence. If e is a loop then it contributes 2 to the total degree of G. e contributes 2 to the total degree of G.
a path (no repeated edge). a simple path c. d. circuits. . v0 e1 v1 e10 v5 e9 v2 e2 v1 . c. v5 e9 v2 e4 v3 e5 v4 e6 v4 e8 v5 . b. If P is a path such that v0 = vn then it is called a circuit or a cycle. a circuit. a. not a circuit b. Solution. A graph that is not connected is said to be disconnected. or simple circuits. A path or circuit is simple if it does not contain the same edge more than once.202 ELEMENTS OF GRAPH THEORY In an undirected graph G a sequence P of the form v0 e1 v1 e2 · · · vn−1 en vn is called a path of length n or a path connecting v0 to vn . a. not a simple circuit (vertex v4 is repeated) An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph. A graph that does not contain any circuit is called acyclic. v3 e5 v4 e8 v5 e10 v1 e3 v2 . v1 e2 v2 e3 v1 .8 In the graph below. simple paths. a simple circuit d. determine whether the following sequences are paths. Example 34. not a simple path (repeated vertex v1 ).
b. If this path is also a circuit. .3 If a graph G has an Euler circuit then every vertex of the graph has even degree. the erasure reduces the degree of the vertex by 2. Connected. Theorem 34. Let G be a graph with an Euler circuit. A simple path that contains all edges of a graph G is called an Euler path. So all vertices must have had even degree to begin with. a. It follows from the above theorem that if a graph has a vertex with odd degree then the graph can not have an Euler circuit. erasing each edge as you go along it. AND CIRCUITS Example 34. Proof. it is called an Euler circuit. 203 Solution.9 Determine which graph is connected and which one is disconnected. Disconnected since there is no path connecting the vertices v1 and v4 . The following provide a converse to the above theorem. When you go through a vertex you erase one edge going in and one edge going out. or else you erase a loop. Either way. Start at some vertex on the circuit and follow the circuit from vertex to vertex.34 GRAPHS. PATHS. Eventually every edge gets erased and all the vertices have degree 0.
4 (Euler Theorem) If all the vertices of a connected graph have even degree. Vertices v1 and v3 both have degree 3. Example 34. A path is called a Hamiltonian path if it visits every vertex of the graph exactly once. A circuit that visits every vertex exactly once except for the last vertex which duplicates the ﬁrst one is called a Hamiltonian circuit. this graph does not have an Euler circuit. Example 34.10 Show that the following graph has no Euler circuit. by the remark following the previous theorem. Hence. then the graph has an Euler circuit. vwxyzv .204 ELEMENTS OF GRAPH THEORY Theorem 34. which is odd.11 Find a Hamiltonian circuit in the graph Solution. Solution.
There is no Hamiltonian circuit since no cycle goes through v.12 Show that the following graph has a Hamiltonian path but no Hamiltonian circuit.34 GRAPHS. PATHS. vwxyz is a Hamiltonian path. AND CIRCUITS 205 Example 34. . Solution.
a. The adjacency matrix of a graph G with n vertices is an n×n matrix AG such that each entry aij is the number of edges connecting vi and vj . E1 ) and G2 = (V2 .206 ELEMENTS OF GRAPH THEORY Review Problems Problem 34. The intersection of two graphs G1 = (V1 . Thus. Find the union and the intersection of the graphs Problem 34. Draw a graph with the adjacency matrix 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 b. aij = 0 if there is no edge from vi to vj .1 The union of two graphs G1 = (V1 . E1 ) and G2 = (V2 . E1 ∩ E2 ). E2 ) is the graph G1 ∪ G2 = (V1 ∪ V2 . Use an adjacency matrix to represent the graph . E1 ∪ E2 ).2 Graphs can be represented using matrices. E2 ) is the graph G1 ∩ G2 = (V1 ∩ V2 .
v) is an edge in a directed graph G then u is called the initial vertex and v is called the terminal vertex. Find all nonempty subgraphs of the graph When (u. EH ) is a subgraph of G = (VG . the outdegree of v. Note that deg(v) = deg + (v) + deg − (v). denoted by deg − (v). In a directed graph. AND CIRCUITS 207 Problem 34. is the number of edges with v as their terminal vertex. Similarly. is the number of edges with v as an initial vertex.34 GRAPHS. PATHS. denoted by deg + (v).3 A graph H = (VH . EG ) if and only if VH ⊆ VG and EH ⊆ EG . . the indegree of a vertex v.
We label the rows with the vertices and the columns with the edges. It is easy to see that the sum of entries of each column is 2 and that the sum of entries of a row gives the degree of the vertex corresponding to that row. Problem 34. Problem 34. Another useful matrix representation of a graph is known as the incidence matrix.5 Show that for a digraph G = (VG . The entry for row v and column e is 1 if e is incident on v and 0 otherwise. EG ) we have EG  = v∈V (G) deg − (v) = v∈V (G) deg + (v).6 Find the incidence matrix corresponding to the graph . If e is a loop at v we assign the value 2.4 Find the indegree and outdegree of each of the vertex in the graph G with directed edges.208 ELEMENTS OF GRAPH THEORY Problem 34. It is constructed as follows.
in symbol.7 If each vertex of an undirected graph has degree k then the graph is called a regular graph of degree k. the number of edges. G1 G2 . if there is onetoone onto function.8 Two simple graphs G1 and G2 are isomorphic. Show that the following graphs are isomorphic. If any of these quantities . and the degrees of the vertices are all invariants under isomorphism. PATHS. f : V (G1 ) → V (G2 ) and AG1 = AG2 . How many edges are there in a graph with 10 vertices each of degree 6? Problem 34. AND CIRCUITS 209 Problem 34. Warning: The number of vertices.34 GRAPHS.
EG2 ) with parallel edges or loops requires two bijections f : VG1 → VG2 and g : EG1 → EG2 such that if e ∈ EG1 is an edge with endpoints (u. Problem 34.210 ELEMENTS OF GRAPH THEORY diﬀer in two graphs. Problem 34.9 Show that the following graphs are not isomorphic.10 Show that the following graph has no Hamiltonian path. The isomorphism between two graphs G1 = (VG1 . However. . EG1 ) and G2 = (VG2 . v) then g(e) ∈ EG2 is an edge with endpoints (f (u). these graphs cannot be isomorphic. it does not necessarily mean that the two graphs are isomorphic. f (v)). when these invariants are the same.
there is only one edge incident on either v0 or vn . By the induction hypothesis. Indeed.35 TREES 211 35 Trees An undirected graph is called a tree if each pair of distinct vertices has exactly one path.1 Which of the following graphs are trees? . Let v0 and vn be two distinct vertices. . T0 has n − 1 edges and so T has n edges Example 35. Basis of induction: P (1) is valid since a tree with one vertex has zero edges. Induction Step: We must show that any tree with n + 1 vertices has n edges.1 Any tree with more than one vertex has at least one vertex of degree 1. By the deﬁnition of a tree. Theorem 35. Then there is a path connecting v0 to vn .2 A tree with n vertices has exactly n − 1 edges. We next show a result that is needed for the proof of our ﬁrst main theorem of trees. The following is the ﬁrst of the two main theorems about trees: Theorem 35. Proof. Since n + 1 ≥ 2 then by the previous theorem. Then T0 is a tree with n vertices. Let P (n) be the property: Any tree with n vertices has n − 1 edges. The proof is by induction on n ≥ 1. Proof. Induction hypothesis: Suppose that P (n) holds up to n ≥ 1. let T be any tree with n + 1 vertices. Thus deg(v0 ) = deg(v1 ) = 1. a tree has no parallel edges and no loops. Let T0 be the graph obtained by removing v and the edge attached to v. T has a vertex v of degree 1. Thus.
The second major theorem about trees is the following theorem whose proof is omitted. A rooted tree is a tree in which a particular vertex is designated as the root.3 Any connected graph with n vertices and n − 1 edges is a tree.2 Find the level of each vertex and the height of the following rooted tree. The second and third graphs do not satisfy the conclusion of Theorem 35. . The height of a rooted tree is the maximum level number that occurs.2 and therefore they are not trees. Example 35. The ﬁrst graph satisﬁes the deﬁnition of a tree. Theorem 35. The level of a vetex v is the length of the simple path from the root to v.212 ELEMENTS OF GRAPH THEORY Solution.
v1 is the root of the given tree.35 TREES Solution. v1 . Suppose (v0 . (e) If x and y are children of z then x and y are siblings.3 Consider the rooted tree . v1 . Example 35. · · · . y. 213 Let T be a rooted tree with root v0 . Then (a) vn−1 is the parent of vn . (c) vn is the child of vn−1 . (d) If x is an ancestor of y then y is a descendant of x. (f) If x has no children. where V is x together with the descendants of x and E = {ee is an edge on a simple path f rom x to some vertex in V }. vn ) is a simple path in T and x. vertex level v2 1 v3 1 v4 2 v5 2 v6 2 v7 2 The height of the tree is 2. (g) The subtree of T rooted at x is the graph with vertex V and edge set E. then x is a leaf. (b) v0 . vn−1 are the ancestors of vn . z are three vertices. · · · .
v4 .214 ELEMENTS OF GRAPH THEORY a. v9 . e. c. Find an example of a siblings. v1 . Solution. Show that the following tree is a binary tree. c. v8 . v11 . g. Find the descendants of v11 . v12 . Example 35. v7 . Construct the subtree rooted at v7 . v13 }. A binary tree is a rooted tree such that each vertex has at most two children. v3 . g. v2 . b.4 a. b. v6 . v5 }. Find the parent of v6 . f. None. e. . v9 . Moreover. d. a. v7 . v5 . f. v9 . v10 . each child is designated as either a left child or a right child. Find the leaves. v3 . Find the ancestors of v13 . {v2 . d. Find the children of v3 . {v4 .
The left child is v6 and the right child is v7 . a. c. b.5 A forest is a simple graph with no circuits. Follows from the deﬁnition of a binary tree.35 TREES 215 b. Which of the following graphs is a forest? . Example 35. Construct an example of a full binary tree. Find the left child and the right child of vertex v5 . A full binary tree is a binary tree in which each vertex has either two children or zero children. c. Solution.
The ﬁrst graph is a forest whereas the second is not. vn 1. . Example 35. Let T be the tree with root v1 and no edges. Such a tree is called a spanning tree. Let T be a subgraph of a graph G such that T is a tree containing all of the vertices of G. v 2 .216 ELEMENTS OF GRAPH THEORY Solution. The following algorithm ﬁnds a spanning tree. · · · . Find a spanning tree of the following graph. b.6 a. x) and vertices on which they are incident. provided . Add to T all edges (v1 . Let G be a connected graph with vertices ordered v 1 . 2. In this algorithm S denotes a sequence.
Replace S by the children in T of S ordered consistently with the original ordering. stop (T is a spanning tree) 3. . a. Go to step 2. If no edges can be added. x) deos not produce a circuit.35 TREES 217 that (v1 . Solution. Use the above algorithm to ﬁnd the spanning tree of part a.
. b. Find the ancestors of v10 .218 ELEMENTS OF GRAPH THEORY Review Problems Problem 35.1 Find the level of each vertex and the height of the following rooted tree.2 Consider the rooted tree a. Find the parent of v6 . Problem 35.
Find the descendants of v1 . Find the children of v4 . form a binary search tree for a number in the set {1. e. If we begin at the root. 219 Problem 35.3 The binary tree below gives an algorithm for choosing a restaurant.4 A binary search tree is a binary tree T in which data are associated with the vertices. 2.35 TREES c.5 Procedures for systematically visiting every vertex of a tree are called traversal algorithms. a2 . d. the root r is listed ﬁrst . Construct a decision tree that sorts three given numbers a1 . In the preorder traversal. Each internal vertex asks a question. for each vertex v in T. answer each question. a3 in ascending order. Problem 35. we will eventually arrive at a terminal vertex that chooses a restaurant. Using numerical order. Find all the siblings. each data item in the left subtree of v is less than the data item in v and each data item in the right subtree of v is greater than the data item in v. The data are arranged so that. 15}. Find the leaves. f. Construct the subtree rooted at v1 . · · · . g. Problem 35. Such a tree is called a decision tree. and follow the appropriate edge.
from left to right. In which order does a preorder traversal visit the vertices in the following rooted tree? . until Tn is traversed in preorder. Tn are listed.220 ELEMENTS OF GRAPH THEORY and then the subtrees T1 . It continues by traversing T1 in preorder. thenT2 in preorder. T2 . · · · . in order of their roots. The preorder traversal begins by visiting r. and so on.
This action might not be possible to undo. Are you sure you want to continue?
7736026LectureNotesinDiscreteMathematics will be available on