0% found this document useful (0 votes)
292 views675 pages

Classnotes Discrete Math

Uploaded by

bszw5eys5v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
292 views675 pages

Classnotes Discrete Math

Uploaded by

bszw5eys5v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 675

CLASS NOTES FOR DISCRETE MATHEMATICS

NOTE ADDED 14 June 2008

These class notes were used for fifteen years in a discrete math class taught at
Case Western Reserve University until I retired in 1999. I am making them available
as
a resource to anyone who wishes to use them. They may be copied and distributed for
educational use, provided that the recipients are charged only the copying costs.

If I were revising these notes today I would make some sizeable changes. The
most important would be to reformulate the definition of division on page 4 to
require that
the divisor be nonzero. The result would change the statement “0 divides 0” from
true to
false, and would affect the answers to a number of exercises.

I will be glad to receive comments and suggestions at [email protected].


Interested readers may wish to look at my other books and websites concerned with
teaching:

The Abstract Math website

Astounding Math Stories

The Handbook of Mathematical Discourse

Charles Wells

Charles (at) abstractmath.org

DISCRETE

MATHEMATICS

Charles Wells

June 22, 1999

Supported in part by the Fund for the Improvement of Post-Secondary Education


(Grant
GCO8730463)

Charles Wells

Department of Mathematics
Case Western Reserve University
10900 Euclid Avenue
Cleveland, OH 44106-7058, USA
Email: [email protected]

Home Page: http://www.cwru.edu/artsci/math/wells/home.html

Copyright ©1999 by Charles Frederick Wells

Contents

39

Functions

56

40

The graph of a function

61

How to read these notes

41

Some important types of functions

63
2

Integers

42

Anonymous notation for functions

64

Definitions and proofs in mathematics

43

Predicates determine functions

65

Division

44

Sets of functions

66

5
More about proofs

45

Binary operations

67

Primes

10

46

Fixes

68

Rational numbers

11

47

More about binary operations

69

Real numbers

12
48

Associativity

70

Decimal representation of real numbers

12

49

Commutativity

71

10

Decimal representation of rational num-

50

Identities

72

bers

14

51

Relations

73
11

Propositions

15

52

Relations on a single set

75

12

Predicates

16

53

Relations and functions

75

13

Universally true

19

54

Operations on relations

77

14

Logical Connectives
21

55

Reflexive relations

77

15

Rules of Inference

24

56

Symmetric relations

78

16

Sets

25

57

Antisymmetric relations

79

17

List notation for sets

26
58

Transitive relations

80

18

Setbuilder notation

27

59

Irreflexive relations

81

19

Variations on setbuilder notation

29

60

Quotient and remainder

82

20

Sets of real numbers

31

61

Trunc and Floor


86

21

A specification for sets

32

62

Unique factorization for integers

87

22

The empty set

33

63

The GCD

88

23

Singleton sets

34

64

Properties of the GCD

90

24
Russell’s Paradox

35

65

Euclid’s Algorithm

92

25

Implication

35

66

Bases for representing integers

93

26

Vacuous truth

37

67

Algorithms and bases

97

27

How implications are worded


38

68

Computing integers to different bases

99

28

Modus Ponens

40

69

The DeMorgan Laws

102

29

Equivalence

40

70

Propositional forms

104

30

Statements related to an implication

42

71
Tautologies

105

31

Subsets and inclusion

43

72

Contradictions

107

32

The powerset of a set

46

73

Lists of tautologies

107

33

Union and intersection

47

74

The tautology theorem

110
34

The universal set and complements

48

75

Quantifiers

112

35

Ordered pairs

49

76

Variables and quantifiers

114

36

Tuples

50

77

Order of quantifiers

115

37
Cartesian Products

52

78

Negating quantifiers

116

38

Extensions of predicates

79

Reading and writing quantified state-

with more than one variable

55

ments

117

IV

80

Proving implications: the Direct Method 119

120 The quotient of a function

184
81

Proving implications: the Contrapositive

121 The fundamental bijection theorem

186

Method

120

122 Elementary facts about finite sets

and

82

Fallacies connected with implication

121

functions

187

83

Proving equivalences

122

123 The Pigeonhole Principle

189

84
Multiple equivalences

123

124 Recurrence relations in counting

189

85

Uniqueness theorems

124

125 The number of subsets of a set

190

86

Proof by Contradiction

125

126 Composition of relations

195

87

Bezout’s Lemma

127

127 Closures

197

88
A constructive proof of Bezout’s Lemma

128

128 Closures as intersections

198

89

The image of a function

131

129 Equivalence relations

200

90

The image of a subset of the domain

132

130 Congruence

201

91

Inverse images

132

131 The kernel equivalence of a function

203

92
Surjectivity

133

132 Equivalence relations and partitions

204

93

Injectivity

134

133 Partitions give equivalence relations

205

94

Bijectivity

136

134 Orderings

206

95

Permutations

137

135 Total orderings

208
96

Restrictions and extensions

137

136 Preorders

209

97

Tuples as functions

138

137 Hasse diagrams

210

98

Functional composition

140

138 Lexical ordering

211

99

Idempotent functions

143

139 Canonical ordering

212
100

Commutative diagrams

144

140 Upper and lower bounds

212

101

Inverses of functions

146

141 Suprema

213

102

Notation for sums and products

150

142 Lattices

215

103

Mathematical induction

151

143 Algebraic properties of lattices

216
104

Least counterexamples

154

144 Directed graphs

218

105

Recursive definition of functions

157

145 Miscellaneous topics about digraphs

220

106

Inductive and recursive

159

146 Simple digraphs

221

107

Functions with more than one starting

147 Isomorphisms

223
point

160

148 The adjacency matrix of a digraph

224

108

Functions of several variables

163

149 Paths and circuits

225

109

Lists

164

150 Matrix addition and multiplication

227

110

Strings

167

151 Directed walks and matrices

228

111
Formal languages

169

152 Undirected graphs

230

112

Families of sets

171

153 Special types of graphs

233

113

Finite sets

173

154 Subgraphs

234

114

Multiplication of Choices

174

155 Isomorphisms

234

115
Counting with set operations

176

156 Connectivity in graphs

236

116

The Principle of Inclusion and Exclusion 178

157 Special types of circuits

237

117

Partitions

180

158 Planar graphs

239

118

Counting with partitions

182

159 Graph coloring

241

119
The class function

183

Answers to Selected Exercises

243

Bibliography

253

Index of Symbols

260

Index

254

About these notes

These class notes are for MATH 304, Fall semester, 1999. Previous versions are not
usable because the text has been rewritten.
It would be a good idea to leaf through this copy to see that all the pages are
there and correctly printed.

Labeled paragraphs This text is written in an innovative style intended to make


the logical status of each part of the text as clear as possible. Each part is
marked
with labels such as “Theorem” , “Remark” , “Example” , and so on that describe
the intent of that part of the text. These descriptions are discussed in more
detail
in Chapter 1.

Exercises The key to learning the mathematics presented in these notes is in doing
all the exercises. Many of them are answered in the back; when that is so, the text
gives you the page the answer is on. You should certainly attempt every exercise
that has an answer and as many of the others that you have time for.

Exercises marked “(discussion)” may be open-ended or there may be disagree-


ment as to the answer. Exercises marked “(Mathematica)” either require Mathema-
tica or will be much easier to do using Mathematica. A few problems that require
knowledge of first-year calculus are marked “(calculus)”.

Indexes On each page there is a computer-generated index of the words that occur
on that page that are defined or discussed somewhere in the text. In addition,
there
is a complete computer-generated index on page 254. In some cases the complete
index has entries for later pages where significant additional information is given
for
the word.

There is also an index of symbols (page 260).

Bibliography The bibliography is on page 253. References to books in the bib-


liography are written like this: [Hofstadter, 1979]. Suggestions for other books to
include would be welcome.

Acknowledgments A grant from the Fund for the Improvement of Post- Secondary
Education supported the development of these class notes. A grant from the Con-
solidated Natural Gas Corporation supported the development of the Mathematica
package dmfuncs.m and the concomitant revisions to these notes.

I would like to thank Michael Barr, Richard Charnigo, Otornar Hajek, Ernest
Leach, Marshall Leitman and Arthur Obrock for finding mistakes and making many
helpful suggestions.

I would appreciate being notified of any errors or ambiguities. You may contact
me at [email protected].

Charles Wells

1
1. How to read these notes proposition 15

specification 2

This text introduces you to the subject matter of discrete mathematics; it includes
a theorem 2
substantial portion of the basic language of mathematics used by all
mathematicians,
as well as many topics that have turned out to be useful in computer science.

In addition, this text constitutes a brief introduction to mathematical reasoning.

This may very well be the first mathematics course in which you are expected
to produce a substantial amount of correct mathematical reasoning as well as to
compute answers to problems.

Most important concepts can be visualized in more than one way, and it is vital
to be able to conceive of these ideas in some of the ways that mathematicians and
computer scientists conceive of them. There is discussion in the text about most of
the concepts to help you in doing this. The problem is that this type of discussion
in general cannot be cited in proofs ; the steps of a proof are allowed to depend
only
on definitions, and previously proved theorems. That is why the text has labels
that
distinguish the logical status of each part.

What follows is a brief glossary that describes many of the types of prose that
occur in this book.

1.1 Glossary

Corollary A corollary to a theorem P is another theorem that follows easily


from P .

Definition Provides a definition of one or more concepts. Every statement to be


proved should be rewritten to eliminate terms that have definitions. This is
discussed
in detail in Chapter 3.

Not all concepts are defined in this text. Basic ideas such as integers and real
numbers are described but not defined; we depend on your familiarity with them
from earlier courses. We give a specification for some of these.

Example An example of a concept is a mathematical object that fits the definition


of the concept. Thus in Definition 4.1, we define “divides” for integers, and then
Example 4.1.1 we observe that 3 and 6 form an example of “divides” (3 divides
6 ).

For study purposes it is worthwhile to verify that each example does fit the
definition. This is usually easy.

A few examples are actually non-examples: mathematical objects that you might
think are examples of the concept but in fact are not.

Fact A fact is a precise statement about mathematics that is correct. A fact is


a theorem, but one that is easy to verify and not necessarily very important. The
statements marked “fact” in this text are usually immediately obvious from the
definitions.
This usage is peculiar to these notes. Many texts would mark what we call facts
as “propositions”, but here the word “proposition” is used in a slightly different
way.

corollary 1
fact 1
lemma 2
proof 4
theorem 2
usage 2
warning 2

Lemma A lemma is a theorem that is regarded as a tool to be used in proving


other theorems rather than as interesting in its own right. In fact, some theorems
are traditionally called lemmas that in fact are now perceived as quite important.

Method A paragraph marked “Method” provides a method for calculating some


object or for determining the truth of a certain type of statement.

Proof A mathematical proof of a statement is a sequence of closely reasoned claims


about mathematical objects (numbers, sets, functions and so on) with each claim
depending on the given assumptions of the statement to be proved, on known def-
initions and previously proved theorems (including lemmas, corollaries and facts),
and on the previous statements in the proof.

Proofs are discussed in more detail in Chapters 3,5, and in a sequence of chapters
beginning with Chapter 80. Particular proof techniques are described in smaller
sections throughout the text.

“Show” is another word for “prove”. (Not all math texts use the word “show”
in this way.)

Remark A remark is a statement that provides some additional information about


a concept. It may describe how to think about the concept, point out some aspects
that follow (or don’t follow!) from the definition that the reader on first reading
might miss, or give further information about the concept.

Note: As of this revision (June 22, 1999) there are some statements called
“remark” that perhaps should be called “fact”, “usage” or “warning”. The author
would appreciate being told of any mislabeled statement.

Specification A specification of a mathematical concept describes some basic


properties of the concept but does not pin down the concept in terms of other
concepts the way a definition does.

Theorem A theorem is a precise statement about mathematics that has been


proved (proved somewhere — not always in this text). Theorems may be quoted as
reasons in a proof, unless of course the statement to be proved is the theorem
being
quoted!
Corollaries, lemmas and facts are all theorems. Statements marked “Theorem”
are so marked because they are important. Particularly important theorems are
enclosed in a box.

Usage A paragraph marked “Usage” describes the way some terminology or sym-
bolism is used in mathematical practice. Sometimes usage varies from text to text
(example: Section 2.2.1) and in many cases, the usage of a term or symbol in mathe-
matical texts is different, often in subtle ways, from its usage in other texts
(example:
Section 14.1.2).

Warning A paragraph marked “Warning” tells you about a situation that has
often (in my experience) misled students.

2. Integers

2.1 Specification: integer

An integer is any whole number. An integer can be zero, greater than


zero or less than zero.

2.1.1 Remark Note that this is not a formal definition; it is assumed that you
are familiar with the integers and their basic properties.

2.1.2 Example —3, 0, 55 and one million are integers.

definition 4
integer 3
natural number 3
negative 3
nonnegative integer 3
nonnegative 3
positive integer 3
positive 3
specification 2
theorem 2
usage 2

2.2 Definition: Properties of integers

For any integer n:

a) n is positive if n > 0 .

b) n is negative if n < 0.
c) n is nonnegative if n > 0.

d) An integer n is a natural number if n is nonnegative.

2.2.1 Usage

a) A few authors define zero to be both positive and negative, but that is not
common mathematical practice in the USA.

b) In pure mathematics the phrase “natural number” historically meant positive


integer, but the meaning “nonnegative integer” used in this book has become
more common in recent years.

The following theorem records some familiar facts.

2.3 Theorem

If m and n are integers, then so are m + n, m — n and mn . If m and


n are not both zero and n is nonnegative, then m n is also an integer.

2.3.1 Remarks

a) In this text, 0° is undefined.

b) Observe that m n may not be an integer if n is negative.

2.3.2 Exercise Describe precisely all integers m and n for which m n is an integer.
Note that Theorem 2.3 does not quite answer this question!

boldface 4
definition 4
divide 4
integer 3
negative integer 3
nonnegative integer 3
positive integer 3

3. Definitions and proofs in mathematics

Each Definition in this text gives the word or phrase being defined in boldface.
Each definition gives a precise description of what is required for an object to
fit
that definition. The only way one can verify for sure that a statement about a
defined object is correct is to give a proof that it is correct based on the
definition
or on previous facts proved using the definition.

Definition 2.2 gives a precise meaning to the words “positive”, “negative”, “non-
negative” and “natural number”. Any question about whether a given integer is
positive or negative or is a natural number must be answered by checking this defi-
nition.

Referring to the definition in trying to understand a concept is the first of many


methods which are used throughout the book. We will give such methods formal
status, like this:

3.1.1 Method

To prove that a statement involving a concept is true, begin by using


the definition of the concept to rewrite the statement.

3.1.2 Example The statement “0 is positive” is false. This claim can be justified
by rewriting the statement using Definition 2.2: “0 > 0”. Since this last statement
is false, 0 is not positive.

3.1.3 Remark The preceding example illustrates the use of Method 3.1.1: I jus-
tified the claim that “0 is positive” is false by using the definition of
“positive”.

3.1.4 Example It also follows from Definition 2.2 that 0 is not negative (because
the statement 0 < 0 is false), but it is nonnegative (because the statement 0 > 0
is
true) .

3.1.5 Exercise Is —(—3) positive? (Answer on page 243.)

4. Division

4.1 Definition: division

An integer n divides an integer rn if there is an integer q for which


m = qn. The symbol for “divides” is a vertical line: n\m means n
divides m.

4.1.1 Example Because 6 = 2 x 3, it is true that 3 | 6. It is also true that —3 |


6,
since 6 = (—2) x (—3) , but it is not true that 4 | 14 since there is no integer q
for
which 14 = 4 q. There is of course a fraction q = 14/4 for which 14 = 4 q, but 14/4
is not an integer.
5

definition 4
divide 4
divisor 5
even 5

existential state-
ment 5, 113
factor 5
integer 3
odd 5
usage 2

4.1.6 Exercise Find all the factors of 7, 24, 26 and 111.

4.1.7 Remarks

a) Warning: Don’t confuse the vertical line a verb meaning “divides”, with
the slanting line “/” used in fractions. The expression “3 | 6” is a sentence, but
the expression “6/3” is the name of a number, and does not form a complete
sentence in itself.

b) Warning: Definition 4.1 of “divides” requires that the numbers involved be


integers. So it doesn’t make sense in general to talk about one real number
dividing another. It is tempting, for example, to say that 2 divides 27 t, but
according to the definition given here, that statement is meaningless.

c) Definition 4.1 does not say that there is only one integer q for which m = qn.
However, it is true that if n is nonzero then there is only one such q , because
then q = m/n. On the other hand, for example 0 = 5- 0 = 42-0 so 0 | 0 and
there is more than one q proving that fact.

d) Definition 4.1 says that m\n if an integer q exists that satisfies a certain
property. A statement that asserts the existence of an object with a property
is called an existential statement. Such statements are discussed in more
detail on page 113.

4.1.8 Example According to the definition, 0 divides itself, since 0 = 0x0. On


the other hand, 0 divides no other integer, since if m/0, then there is no integer
q for which m = q x 0 .

4.1.2 Exercise Does 13 | 52 ? (Answer on page 243.)

4.1.3 Exercise Does — 37 | 111 ?

4.1.4 Usage If n divides m, one also says that n is a factor of m or that n is


a divisor of m.

4.1.5 Worked Exercise Find all the factors of 0, 1, 10 and 30.

Answer Number Factors

0 every integer

1 - 1 , 1

10 -1, -2, -5, -10, 1, 2, 5, 10

30 -1, -2, -3, -5, -6, -10, -15, -30, 1, 2, 3, 5, 6, 10, 15, 30

4.1.9 Usage Many authors add the requirement that n/0 to Definition 4.1,
which has the effect of making the statement 0 | 0 meaningless.

4.1.10 Exercise Find all the integers m for which m | 2. (Answer on page 243.)

4.2 Definition: even and odd

An integer n is even if 2 | n . An odd integer is an integer that is not


even.

4.2.1 Example —12 is even, because —12 = (—6) x 2, and so 2 | —12.

definition 4
divide 4
division 4
integer 3
proof 4
theorem 2

5. More about proofs

We will state and prove some simple theorems about division as an illustration of
some techniques of proof (Methods 5.1.2 and 5.3.3 below.)

5.1 Theorem

Every integer divides itself.

Proof Let m be any integer. We must prove that m\ m. By Definition 4.1, that
means we must find an integer q for which m = gm. By first grade arithmetic, we
can use q= 1 .
5.1.1 How to write a proof (1) In the preceding proof, we start with what is
given (an arbitrary integer to ) , we write down what must be proved (that m\m),
we apply the definition (so we must find an integer q for which to = qrn ) , and we
then write down how to accomplish our goal (which is one step in this simple proof
- let q= 1 ) .

We will continue this discussion in Section 5.3.7.

The proof of Theorem 5.1 also illustrates a method:

5.1.2 Method: Universal Generalization

To prove a statement of the form “Every x with property P has property


Q" , begin by assuming you have an x with property P and prove without
assuming anything special about x (other than its given properties) that
it has property Q.

5.1.3 Example Theorem 5.1 asked us to prove that every integer divides itself.
Property P is that of being an integer and property Q is that of dividing itself.
So we began the proof by assuming m is an integer. (Note that we chose a name,
to, for the integer. Sometimes the theorem to be proved gives you a name; see
for example Theorem 5.4 on page 8.) The proof then proceeds without assuming
anything special about to. It would have been wrong, for example, to say
something
like “Assume to. = 5” because then you would have proved the theorem only for
5.

5.2 Theorem

Every integer divides 0.

Proof Let to be an integer (Method 5.1.2!). By Definition 4.1, we must find an


integer q for which 0 = qm. By first grade arithmetic, we can use q = 0.

5.2.1 Remark Theorem 5.2 may have surprised you. You can even find texts in
which the integer q in the definition of division is required to be unique. For
those
texts, it is false that every integer divides 0.

This illustrates two important points:

a) The definition of a mathematical concept determines the truth of every


state-
ment about that concept. Your intuition and experience don’t count in deter-
mining the mathematical truth of a statement. Of course they do count in
being able to do mathematics effectively!

b) There is no agency that standardizes mathematical terminology. (There are


such agencies for physics and chemistry.)
5.3 Theorem

1 divides every integer.

divide 4
factor 5
integer 3
proof 4
theorem 2

Proof Let m be any integer. By Definition 4.1, we must find an integer q for
which m = q T . By first grade arithmetic, we can use q = m.

5.3.1 Exercise Prove that if m\n and a and b are nonnegative integers such
that a <b, then m a \ n b .

5.3.2 Worked Exercise Prove that 42 is a factor of itself.

Proof Theorem 5.1 says that every integer is a factor of itself. Since 42 is an
integer, it is a factor of itself.

This worked exercise uses another proof method:

5.3.3 Method: Universal Instantiation

If a theorem says that a certain statement is true of every object of a


certain type, and c is an object of that type, then the statement is true
of c.

5.3.4 Example In Example 5.3.2, the theorem was Theorem 5.1, the type of
object was “integer”, and c was 42.

5.3.5 Remark Make sure you understand the difference between Method 5.1.2
and Method 5.3.3.

5.3.6 Worked Exercise Prove that 0 is even.

Answer Bu definition of even, we must show that 2 | 0. By Theorem 5.15.2, every


integer divides 0. Hence 2 divides 0 (Method 5.3.3).

5.3.7 How to write a proof (2) Worked Exercise 5.3.8 below illustrates a more
complicated proof. In writing a proof you should normally include all these
steps:
PS.l Write down what is given , and translate it according to the definitions
of the
terms involved in the statement of what is given. This translation may involve
naming some of the mathematical objects mentioned in the statement to be
proved.

PS. 2 Write down what is to be proved, and translate it according to the


definitions
of the terms involved.

PS. 3 Carry out some reasoning that, beginning with what is given, deduces what
is
to be proved.

The third step can be quite long. In some very simple proofs, steps PS-1 and
PS-2
may be trivial. For example, Theorem 5.3 is a statement about every integer. So
for
step PS-1, one merely names an arbitrary integer: “Let m be any integer.” Even,
here, however, we have named what we will be talking about.

Another very important aspect of proofs is that the logical status of every
state-
ment should be clear. Each statement is either:

divide 4
integer 3

nonnegative integer 3
positive integer 3
proof 4
theorem 2
universal instantia-
tion 7
usage 2

a) Given by the hypothesis of the theorem.

b) A statement of what one would like to prove (a goal). Complicated proofs


will
have intermediate goals on the way to the final goal.

c) A statement that has been deduced from preceding known statements. For
each of these, a reason must be given, for example “Universal Instantiation”
or “high school algebra” .

5.3.8 Worked Exercise Prove that any two nonnegative integers which divide
each other are the same.

Answer First, we follow PS-1 and write down what we are given and translate it
according to the definition of the words involved (“divides” in this case):
Assume
we are given integers m and n. Suppose m\n and n\m. By Definition 4.1, the
first statement means that for some q, n = qm .. The second statement means
that
for some q' , m = q'n. Now we have written and translated what we are given.

PS-2: We must prove that m = n. (This translates the phrase “are the same”
using the names we have given the integers.)

PS-3: We put these statements that we have assumed together by simple


algebra:
rn = q'n = q'qm . Now we have two cases: either m = 0 or m/ 0.

a) If m = 0 , then n = qm = g x 0 = 0 , so m = n.

b) If m / 0, then also n / 0, since m = q'n. Then the fact that m = q'n =


q'qm
means that we can cancel the m (because it is nonzero!) to get qq' = 1 .
This
means either q = q' = 1 , so m = n, or q = q' = — 1 , so m = —n. But the
latter
case is impossible since m and n are both positive. So the only possibility
that is left is that m = n.

We give another illustration of writing a proof by rewriting what is given


and what
is to be proved using the definitions by proving this proposition:

5.4 Theorem

For all integers k, m and n, if k\m and k\n then k\m + n.

Proof What we are given is that k \ m and k\n. If we rewrite these


statements
using Definition 4.1, we get that there are integers q and q' for which m =
qk and
n = q'k. What we want to show, rewritten using the definition, is that
there is an
integer q" for which m + n = q"k . Putting the hypotheses together gives

m + n = qk + q'k = (q + q')k

so we can set q" = q + q' to prove the theorem.

5.4.1 Usage In the preceding paragraph, I follow common mathematical


practice
in putting primes on a variable like q or r in order to indicate another
variable q'
of the same type. This prime has nothing to do with the concept of
derivative used
in the calculus.

5.4.2 Existential Bigamy In the proof of Theorem 5.4, we were given that
k \ m
and k\n. By using the definition of division, we concluded that there are
integers
q and q' for which m = qk and n = q'k. It is a common mistake called
existential
bigamy to conclude that there is one integer q for which m = qk and n = qk.

Consider that the phrase “Thurza is married” by definition means that there
is
a person P to whom Thurza is married. If you made the mistake just
described
you would assume that if Amy and Thurza were both married, then they would
be
married to the same person. That is why it is called “existential bigamy” .

Mrs. Thurza Golightly White was the author’s great great grandmother, and
Mrs. Amy
Golightly Walker was her sister. They were very definitely married to
different people.

5.5 Exercise set

In problems 5.5.1 through 5.5.5, you are asked to prove certain statements
about
integers and division. Your proofs should involve only integers — no
fractions should
appear. This will help insure that your proof is based on the definition of
division
and not on facts about division you learned in high school. As I mentioned
before,
you may use algebraic facts you learned in high school, such as that fact
that for
any integers, a(b + c) = ab + ac.

5.5.1 Exercise Prove that 37 | 333. (Answer on page 243.)

5.5.2 Exercise Prove that if n > 0, then any nonnegative integer less than
n
which is divisible by n must be 0. (Answer on page 243.)

5.5.3 Exercise Prove that if k is an integer which every integer divides,


then
k = 0.

5.5.4 Exercise Prove that if k is an integer which divides every integer,


then
k = 1 or k = — 1 .

5.5.5 Exercise Prove that if k \ m and m \ n then k\n.

5.6 Factors in Mathematica

The DmFuncs package contains the function DividesQ [k,n] . It returns True
if k | n and False otherwise. For example, DividesQ [3 , 12] returns True
but
DividesQ [5 , 12] returns False.

You can get a list of all the positive factors of n by typing


AllFactors [n] .
Thus AllFactors [12] returns {1,2,3,4,6,12]-. As always, lists in
Mathematica
are enclosed in braces.

divide 4
division 4

existential bigamy 9
factor 5
integer 3

nonnegative integer 3

5.6.1 Remark AllFactors returns only the positive factors of an


integer. In this
text, however, the phrase “all factors” includes all the positive and
all the negative
factors.

10

composite integer 10

composite 10, 140

definition 4

even 5

factor 5

integer 3

odd 5

positive integer 3
prime 10

6. Primes

Prime numbers are those, roughly speaking, which don’t have nontrivial
factors.
Here is the formal definition:

6.1 Definition: prime number

A positive integer n is a prime if and only if it is greater than 1 and


its only positive factors are 1 and n. Numbers bigger than 1 which are
not primes are called composite numbers.

6.1.1 Example The first few primes are 2,3,5,7,11,13,17,... .

6.1.2 Example 0 and 1 are not primes.

6.1.3 Worked Exercise Let k be a positive integer. Prove that 4k-\-2 is


not a
prime.

Answer 4&i + 2 = 2(2k+ 1) Thus it has factors 1, 2, 2k + 1 and 4k + 2.


We know
that 2 ^ 4k + 2 because k is positive. Therefore 4k + 2 has other
positive factors
besides 1 and 4k + 2, so 4k + 2 is not prime.

6.1.4 Exercise Prove that any even number bigger than 2 is composite.

6.1.5 Exercise Which of these integers are prime and which are
composite? Fac-
tor the composite ones: 91, 98, 108, 111. (Answer on page 243.)

6.1.6 Exercise Which of these integers are prime and which are
composite? Fac-
tor the composite ones: 1111, 5567, 5569.

6.1.7 Exercise Prove that the sum of two odd primes cannot be a prime.

6.2 Primes in Mathematica

The command PrimeQ determines if an integer is prime (it is guaranteed


to work for
n < 2.5 X 10 10 ). Thus PrimeQ [41] will return True and PrimeQ [111]
will return
False.

The command Prime [n] gives the nth prime in order. For example. Prime
[1]
gives 2, Prime [2] gives 3, and Prime [100] gives 541.

6.2.1 Exercise (Mathematica) Find all the factors of your student


number.

11

7. Rational numbers

7.1 Definition: rational number


A rational number is a number representable as a fraction m/n, where
m and n are integers and n 0 .

7.1.1 Example The numbers 3/4 and —11/5 are rational. 6 is rational
because
6 = 6/1. And .33 is rational because .33 = 33/100.

7.2 Theorem

Any integer is rational.

definition 4
divide 4
divisor 5
fact 1
integer 3
lowest terms 11
proof 4

rational number 11
rational 11
representation 15
theorem 2

Proof The integer n is the same as the fraction n/1.

7.2.1 Remark The representation of a rational number as a fraction is


not unique.
For example,

3 _ 6 _ -9

4 “ 8 “ —12

7.2.2 Fact Two representations m/n and r/s give the same rational
number if
and only if ms = nr .

7.3 Definition: lowest terms

Let m/n be the representation of a rational number with m fiO and


n > 0. The representation is in lowest terms if there is no integer
d > 1 for which d \ m and d\n.

7.3.1 Example 3/4 is in lowest terms but 6/8 is not, because 6 and 8
have 2 as
a common divisor.

7.3.2 Exercise Is ^ in lowest terms?


7.4 Theorem

The representation in lowest terms described in Definition 7.3 exists


for
every rational number and is unique.

Proof Left for you to do (Problems 64.2.5 and 63.4.1).

7.4.1 Warning You can’t ask if a rational number is in lowest terms,


only if its
representation as a fraction of integers is in lowest terms.

7.5 Operations on rational numbers

Rational numbers are added, multiplied, and divided according to the


familiar rules
for operating with fractions. Thus for rational numbers a/b and c/d, we
have

a c ac

b X d bd

and

ad + be
bd

(7.1)

7.5.1 Exercise If a/b and c/d are representations of rational


numbers in lowest
terms, must their sum ( ad + bc) /bd and their product ac/bd be in
lowest terms?
(Answer on page 243.)
12

decimal expansion 12
decimal representa-
tion 12
decimal 12, 93
digit 93
integer 3
rational 11
real number 12
specification 2
usage 2

8. Real numbers

8.1 Specification: real number

A real number is a number which can be represented as a directed


distance on a straight line. A real number r is positive if r > 0
and

negative if r < 0 .

8.1.1 Remark Specification 8.1 is informal, but it’s all you are
going to get, since
a formal definition is quite involved.

8.1.2 Example Any integer or rational number is a real number, and


so are num-
bers such as 7 r and \/2. We will see a proof in Section 86
that \/2 is not rational,
which shows that there are real numbers that are not rational.

8.1.3 Usage The symbol \f\ denotes 2. It does not denote —2. In
general, for
a positive real number x , the notation \J x denotes the positive
square root of x ,
which is precisely the unique positive real number r with the
property that r 2 = x.
The unique negative number s such that s 2 = x is denoted by —\fx.

This usage may conflict with usage you saw in high school, but it
is standard in
college-level and higher mathematics.

8.1.4 Exercise For what real numbers x is it true that \J (— x') 2


= xl

8.2 Infinity

In calculus you may have used the symbols oo and — oo in connection


with limits.
By convention, oo is bigger than any real number and — oo is less
than any real
number. However, they are not themselves real numbers. There is no
largest real
number and there is no smallest real number.

9. Decimal representation of real numbers

A real number always has a decimal representation, possibly with an


unending
sequence of digits in the representation. For example, as you know,
the first few
decimal places of 7r are 3.14159 .... As a general rule, you don’t
expect to know the
exact value of a real number, but only an approximation to it by
knowing its first
few decimal places. Note that 22/7 is not i r, although it is close
to it.

9.1.1 Usage The decimal representation is also called the decimal


expansion.

9.1.2 Approximations Mathematicians on the one hand and scientists


and engi-

neers on the other tend to treat expressions such as “3.14159” in


two different ways.
The mathematician will think of it as a precisely given number,
namely , so

in particular it represents a rational number. The scientist or


engineer will treat it
as the known part of the decimal representation of a real number.
From their point
of view, one knows 3.14159 to six significant figures. This book
always takes the
mathematician’s point of view.

13
Mathematicians referring to an approximation may use an ellipsis
(three dots),
as in “ 7 r is approximately 3.14159...”.

The decimal representations of two different real numbers must be


different. How-
ever, two different decimal representations can, in certain
circumstances, represent
the same real number. This is specified precisely by the following
rule:

9.2 Theorem

If m = do.did 2 d, 3 . . . and n = eo-eie 2 e 3 . . . , where all


the di and et are
decimal digits, and for some integer k > 0 the following four
statements
are all correct, then m = n:

DR.l di = e* for 0 <i <k;

DR. 2 dk = + 1 ;

DR.3 di = 0 for all i > k; and


DR.4 e* = 9 for all i> k.

Moreover, if the decimal representations of m and n are not


identical but
do not follow this pattern for some k , then m ^n.

decimal 12, 93
digit 93
integer 3
real number 12
string 93, 167
theorem 2
usage 2

9.2.1 Usage We use a line over a string of digits to indicate


that they are repeated
infinitely often.

9.2.2 Example 4.9 = 5 (here k = 0 in Theorem 9.2) and 1.459 =


1.46 (here k =

2 ).

9.2.3 Remarks

a) As it stands, Theorem 9.2 applies only to real numbers


between 0 and 10,
but that was only to avoid cumbersome notation. By multiplying
or dividing
by the appropriate power of 10, you can apply it to any real
number. For
example, 499.9 = 500, since Theorem 9.2 applies to those
numbers divided by
100 .

b) The proofs of Theorems 9.2 and 10.1 (below) are based on the
theory of
geometric series (and are easy if you are familiar with that
subject) but that
belongs to continuous mathematics rather than discrete
mathematics and will
not be pursued here.

9.2.4 Exercise Which of these pairs of real numbers are equal?

a) 1.414, y/2.

b) 473,472.999.

c) 4.09, 4.1.

(Answer on page 243.)

9.2.5 Exercise Which of these pairs of real numbers are equal?

a) 53.9, 53.0.

b) 39/13, 2.9.

c) 5698/11259 and .506084.

14

decimal 12,93 9.2.6 Exercise If possible, give two different


decimal representations of each num-

digit 93 ber. If not possible, explain why not.

lowest terms 11
rational 11
real number 12
theorem 2

a) f .

b) f •

c) 105.3.
10. Decimal representation of rational numbers

The decimal representation of a rational number m/n is


obtainable by dividing n
into m using long division. Thus 9/5 = 1.8 and 1/3 = 0.333...

A decimal representation which is all 0’s after a certain point


has to be the
decimal representation of a rational number. For example, 1.853
is the rational
number 1853/10 3 . On the other hand, the example of 1/3 shows
that the decimal
representation of a rational number can go on forever.

The following fact is useful: If the decimal representation of


a number n starts
repeating in blocks after a certain point, then n is rational.
For example, 1/7 =
0.142857 with the block 142857 repeated forever.

The following theorem says exactly which rational number is


represented by a
decimal representation with a repeating block of consecutive
digits:

10.1 Theorem

If n = O.bbb. . . , where b is a block of k consecutive digits,


then n =
b/(10 k — 1).

10.1.1 Example 0.13 is 13/99. As another example, the theorem


says that 0.3
is 3/9, which of course is correct.

10.1.2 Exercise Give the exact rational value in lowest terms


of 5.1, 4.36, and
4.136. (Answer on page 243.)

10.1.3 Remark Theorem 10.1 says that if the decimal


representation of a real
number repeats in blocks then the number is rational, and
moreover it tells you how
to calculate it. Actually, the reverse is true, too: the
decimal representation of a
rational number must repeat in blocks after a certain point.

You can see why this is true by thinking about the process of
long division:
Suppose you have gone far enough that you have used up all the
digits in the
dividend (so all further digits are zero). Then, if you get a
certain remainder in the
quotient twice, the process necessarily repeats the second time
what it did the first
time.

15

10.2 Representations in general

It is important to distinguish between a mathematical object


such as a number and
its representation, for example its decimal representation or
(in the case of a rational
number) its representation as a fraction of integers. Thus 9/5,
27/15 and 1.8 all
represent the same number which is in fact a rational number.
We will return to
this idea several times, for example in Section 17.1.3 and in
Section 66.8.

10.3 Types of numbers in Mathematica

Mathematica knows about integers, rational numbers and real


numbers. It treats a
number with no decimal point as an integer, and an explicit
fraction, for example
6/ 14, as a rational number. If the number has a decimal point,
it is always regarded
as real number.

IntegerQ [n] returns True if n is represented as an integer in


the sense just
described. Thus IntegerQ [3] returns True, but IntegerQ [3 . 0]
returns False.

Mathematica will store a number given as the fraction of two


integers as a ratio-
nal number in lowest terms. For example, if you type 6/14, you
will get 3/7 as the
answer. It will return the sum, product, difference and
quotient of rational numbers
as rational numbers, too. Try typing 3/7+5/6 or (3/7)/ (5/6),
for example.

The function that gives you the decimal representation of a


number is N. For
example, N[3/7] gives 0.4285714285714286. You may give a second
input to N
that gives the number of decimal digits that you want. Thus N
[3/7, 20] gives

decimal 12, 93
digit 93
integer 3
lowest terms 11
positive integer 3
predicate 16
proposition 15
rational 11
real number 12
specification 2
usage 2

0.42857142857142857143

You can invoke N by typing //N after an expression, too. For


example, instead
of typing N [3/7+5/4] , you can type 3/7 + 5/4 //N.

11. Propositions

Sentences in English can express emotion, state facts, ask


questions, and so on. A
sentence in a computer language may state a fact or give a
command. In this section
we are concerned with sentences that are either true or false.

11.1 Specification: proposition


A proposition is a statement which is either true or false.

11.1.1 Example Let P be the proposition “4 > 2”, and Q the


proposition “25 <
—2”. Both statements are meaningful; P is true and Q is false.

11.1.2 Example In Example 3.1.2, page 4, we showed that 0 is


not positive by
using the definition of positive to see that 0 is positive if
the proposition 0 > 0 is
true. Since it is not true, 0 is not positive.

11.1.3 Example The statement x > 4 is not a proposition, since


we don’t know
what x is. It is an example of a predicate.

11.1.4 Usage In many textbooks on logic a proposition is called


a sentence.

algebraic expres-
sion 16
instance 16
integer 3
predicate 16
proposition 15
relational symbols
specification 2
usage 2

16

11.1.5 Remark Textbooks on logic define propositions (and


predicates, the sub-
ject of the next chapter) rather than merely specifying them as
we have done. The
definition is usually by an recursive process and can be fairly
complicated. In order
to prove theorems about logic, it is necessary to do this. This
text explains some of
the basic ideas about logic but does not prove theorems in
logic.

11.2 Propositions in Mathematica

A statement such as 2 < 3 is a proposition in Mathematica; if


you type it in, it will
return True. The symbol for equals is == rather than “ = ”, so
for example 2 == 3
returns False.

12. Predicates

12.1 Specification: predicate

A predicate is a meaningful statement containing variables that


becomes true or false when appropriate values are substituted
for the
variables. The proposition obtained by substituting values for
each of
the variables in a predicate is called an instance of the
predicate.

12.1.1 Usage In other texts, a predicate may be called a


“formula” or an “open
sentence” .

12.1.2 Example If x is a variable of type integer, the


statement “25 < x” is
a predicate. If you substitute an integer for x, the statement
becomes true or
false depending on the integer. If you substitute 44 for x you
get the proposition
“25 < 44” , which is true; if you substitute 5 for x, you get
the proposition “25 < 5” ,
which is false.
12.1.3 Usage We will regard a proposition as a predicate with
no variables. In
other words, every proposition is a predicate.

12.1.4 Algebraic expressions and predicates An algebraic


expression is

an arrangement of symbols such as

x 2 --+4 y (12.1)

It consists of variables {x and y in this case) and operation


symbols. The expression
must be correctly formed according to the rules of algebra.

A predicate is analogous to an algebraic expression, except


that it also con-
tains symbols such as “<” and “=” (called relational symbols)
that make the
expression denote a statement instead of a number.

12.1.5 Example The expression

x 2 b4 y>x + y (12.2)

is a predicate.

17

integer 3
predicate 16
proposition 15
real number 12

On the other hand, if data of the correct type are substituted


into a predicate
the result is not a number but a statement which is true or
false, in other words a
proposition.

12.2.2 Example If you substitute x = 3 into the predicate x 2 <


4 you get the
proposition 9 < 4, which is false. The substitution x = 1 gives
1 < 4, which is true.
12.2.3 Example Substituting x = 2 and y = 3 into the expression
(12.2) gives
the proposition 13 > 5, which is true.

12.2.4 Exercise Find a pair of numbers x and y that when


substituted in 12.2
give a false statement.

12.2 Substitution

When numbers are substituted for the variables in an algebraic


expression, the result
is a number.

12.2.1 Example Setting x = 2 and y = 3 in the expression (12.1)


gives the num-
ber 13.

12.2.5 Example Expressions can be substituted into other


expressions as well.
For example one can substitute xy for x in the expression
(12.2) to get

22 6 .

xy b4 y>xy + y

xy

In doing such substitution you must take into account the rules
concerning how
algebra is written; for example to substitute x + y for x and y
+ z for y in (12.1)
you must judiciously add parentheses:

{x + y) 2

b 4 (y + z) > x + y + y + z

x + y

And the laws of algebra sometimes disallow a substitution; for


example you cannot
substitute 0 for x in 12.2.

12.2.6 Exercise Write the result of substituting x for both x


and for y in 12.2.
(Answer on page 243.)

12.3 Types

In this book, variables are normally assumed to be of a


particular type; for example
the variable x mentioned in Example 12.1.2 is of type integer.
We do not always
specify the type of variables; in that case, you can assume
that the variable can
be replaced by any data that makes the predicate make sense.
For example, in the
predicate x < 25, x can be any number for which “<” makes sense
— thus any
real number number, but not a complex number. This informal
practice would have
to be tightened up for a correct formal treatment of
predicates; the intent here is
to provide an informal introduction to the subject in which
predicates are used the
way they are normally used in common mathematical practice.

18

divide 4
integer variable
predicate 16
proposition 15
real variable 18
substitution 17
usage 2

12.3.1 Usage A real variable is a variable of type real. An


integer variable is
18 a variable of type integer. Don’t forget that both integer
variables and real variables

are allowed to have negative values.

12.3.2 Worked Exercise Let x be a variable of type real. Find a


value of x
that makes the statement “ x > 1 and x < 2” true, and another
that makes it false.
Do the same for the case that x is an integer variable.

Answer Any real number between 1 and 2 makes “x > 1 and x < 2”
true, for
example x = \ or x = \[2 . The values x = 0 , x = 1 , x = — 1 ,
and x = 42 all make
it false.

No integer value of x makes the statement true; it is false for


every integer.

12.4 Exercise set

Let m be an integer variable. For each predicate in problems


12.4.1 through 12.4.5,
give (if it is possible) a value of m for which it is true and
another value for which

it is false.

12.4.1

m 4

. (Answer on page 243.)

12.4.2

m =

m. (Answer on page 243.

12.4.3

m =

m + 1 .

12.4.4

m =

2 m.

12.4.5

9
m =

- m.

12.5 Naming predicates

We will name predicates with letters in much the same way that
we use letters to
denote numbers in algebra. It is allowed, but not required , to
show the variable(s)
in parentheses. For example, we can say: let P{x) denote the
predicate “25 < x ” .
Then P(42) would denote the proposition “25<42”, which is true;
but P(— 2)
would be false. P(42) is obtained from P{x) by substitution.

We can also say, “Let P denote the predicate 25 < x” without


the x being
exhibited. This is useful when we want to refer to an arbitrary
predicate without
specifying how many variables it has.

Predicates can have more than one variable. For example, let
Q(x,y ) be “x <
y" . Then Q(25,42) denotes the proposition obtained by
substituting 25 for x and
42 for y. Q( 25,42) is true; on the other hand, Q( 25,-2) is
false, and Q(25,y) is a
predicate, neither true nor false.

12.5.1 Worked Exercise Let m and n be integer variables. Let


P(n) denote the
predicate n < 42 and Q(m,n ) the predicate n \ (m + n ) . Which
of these predicates
is true when 42 is substituted for m and 4 is substituted for n
?

Answer P(4) is 4 < 42, which is true, and <3(42,4) is 4 | 46,


which is false.

19

12.5.2 Exercise If Q(x) is the predicate x 2 <4, what are Q(—l)


and Q(x— 1)?
(Answer on page 243.)

12.5.3 Exercise Let P(x,y,z ) be the predicate xy<x + z + 1.


Write out each
of these predicates.
a) P(l,2,3).

b) P(l,3,2).

c) P(x,x,y)

d) P(x,x + y,y + z) .

(Answer on page 243.)

12.5.4 Exercise Let P be the predicate of Exercise 12.5.3.


Write out P(x, x,x)
and P(x,x — l,x + 1) and for each predicate give a value of x
for which it is true
and another value for which it is false.

12.5.5 Warning You may have seen notation such as “ f(x) ” to


denote a function.
Thus if f(x) is the function whose value at x is 2x + 5, then /
( 3) = 11. We
will consider functions formally in Chapter 39. Here we only
want to call your
attention to a difference between that notation and the
notation for predicates: If
f(x) = 2x + 5, then “/(x)” is an expression. It is the name of
something. On the
other hand, if P(x) denotes the predicate “25 < x”, then P(x)
is a statement - a
complete sentence with a subject and a verb. It makes sense to
say, “If a = 42 , then
P(a)" , for that is equivalent to saying, “If a = 42, then 25 <
a”. It does not make
sense to say, “If a = 42, then /(a)”, which would be “If a =
42, then 2a + 5”. Of
course, it is meaningful to say “If a = 42, then /(a) = 89”.

12.6 Predicates in Mathematica

A statement such as 2 < x is a predicate. If x has not been


given a value, if you type
2 < x you will merely get 2 < x back, since Mathematica doesn’t
know whether it
is true or false.

definition 4
law 19
predicate 16
real number 12
type (of a vari-
able) 17

universally true 19
usage 2

13. Universally true


13.1 Definition: universally true predicate

A predicate containing a variable of some type that is true for


any value
of that type is called universally true.

13.1.1 Example If x is a real number variable, the predicate “x


2 — 1 = (x +
l)(x — 1)” is true for any real number x. In this example the
variable of the defini-
tion is x, its type is “real”, and so any value of that type
means any real number.
In particular, 42 is a real number so we know that 42 2 — 1 =
(42 + 1)(42 — 1)

13.1.2 Usage In some contexts, a universally true predicate is


called a law. When
a universally true predicate involves equality, it is called an
identity.

20

definition 4
predicate 16
quantifier 20, 113
real number 12
type (of a vari-
able) 17
usage 2

13.1.3 Example The predicate “x 2 — 1 = (x + 1) (x — 1) ” is an


identity. An exam-
ple of a universally true predicate which is not an identity is
“x + 3 > x ” (again, x
is real number).

13.1.4 Remark If P(x) is a predicate and c is some particular


value for x for
which -P(c) is false, then P(x) is not universally true. For
example, x > 4 is not
universally true because 3 > 4 is false (in this case, c = 3).
This is discussed further
in Chapter 75.

13.2 Definition: V
We will use the notation (Vx) to denote that the predicate
following it
is true of all x of a given type.

13.2.1 Example (Vx)(x + 3 > x) means that for every x, x + 3>x.

13.2.2 Worked Exercise Let x be a real variable. Which is true?


(a) (Vx)(x >
x). (b) (\/x)(x > x) . (c) (Vx)(x/0).

Answer (a) is false, (b) is true and (c) is false.

13.2.3 Remark In Exercise 13.2.2, it would be wrong to say that


the answer to
(c) is “almost always true” or to put any other qualification
on it. Any universal
statement is either true or false, period.

13.2.4 Example The statement “i/O” is true for x = 3 and false


for x = 0, but
the statement (Vx)(x / 0) is just plain false.

13.2.5 Exercise Let x be a real variable. Which is true? (a)


(Vx)(x x) . (b)
(Vx)((Vy)(x^y)). (c) (Vx) ((Vy)(x > y )) .

13.2.6 Usage The symbol “V” is called a quantifier We take a


more detailed
look at quantifiers in Chapter 75.

13.2.7 Exercise Which of these statements are true? n is an


integer and x a
real number.

a) (Vn)(n + 3 > n) .

b) (Vx) (x + 3 > x) .

c) (Vn)(3n>n).

d) (Vn)(3n + 1 > n) .

e) (Vx)(3x>x).

(Answer on page 243.)

21

14. Logical Connectives

Predicates can be combined into compound predicates using


combining words called
logical connectives. In this section, we consider “and”, “or”
and “not”.

14.1 Definition: “and”

If P and Q are predicates, then P f\Q (“P and Q”) is also a


predicate,
and it is true precisely when both P and Q are true.

14.1.1 Worked Exercise Let n be an integer variable and let


P(n) be the pred-
icate (n > 3 and n is even) . State whether P( 2) , P(6) and P(
7) are true.
Answer P( 2) is false, P( 6) is true and P(7) is false.

14.1.2 Usage

a) A predicate of the form “FAQ” is called a conjunction.

b) Another notation for PaQ is “PQ”. In Mathematica, “PaQ” is


written

P && Q.

14.2 Definition: “or”

PV Q (“P or Q”) is a predicate which is true when at least one


of P
and Q is true.

14.2.1 Usage

a) A compound predicate of the form P V Q is called a


disjunction.

b) Often “P + Q” is used for “PVQ”. In Mathematica, it is


written P | | Q.

14.2.2 Example If P is “4 > 2” and Q is “25 < —2”, then “PaQ”


is false but
“PVQ” is true.

14.2.3 Exercise For each predicate P(n) given, state whether


these propositions
are true: P( 2), P( 6), P( 7).

a) (n > 3 or n is even)

b) (n | 6 or 6 | n)

c) n is prime or (n | 6)
(Answer on page 243.)

14.2.4 Exercise For each predicate give (if possible) an


integer n for which the
predicate is true and another integer for which it is false.

a) (n + 1 = n) V (n = 5) .

b) (n > 7) V (n < 4) .

c) (n > 7) A (n < 4) .

d) (n < 7) V (n > 4) .

(Answer on page 243.)

14.2.5 Exercise Which of the predicates in Problem 14.2.4 are


universally true
for integers? (Answer on page 243.)

and 21, 22
conjunction 21
definition 4
disjunction 21
divide 4
even 5
integer 3
predicate 16
prime 10
proposition 15
usage 2

22

definition 4
even 5
fact 1
integer 3
negation 22
or 21, 22
positive integer 3
predicate 16
truth table 22
usage 2

14.3 Truth tables

The definitions of the symbols ‘A’ and ‘V’ can be


summarized in truth tables:

P Q PAQ

T T T

T F F

FT F
F F F

P Q PVQ
T T T
T F T
FT T
F F F

14.3.1 Remark As the table shows, the definition of ‘V’


requires that PVQ be
true if either or both of P and Q are true; in other words,
this is “or” in the sense
of “and/or”. This meaning of “or” is called “inclusive or”.

14.3.2 Usage In computer science, “1” is often used for


“true” and “0” for
“false”.

14.4 Definition: “xor”

If P and Q are predicates, the compound predicate PXORQ is


true if
exactly one of P and Q is true.

14.4.1 Fact The truth table of XOR is

P Q P XOR Q
T T F

T F T

FT T

F F F

14.4.2 Usage
a) XOR in Mathematica is Xor. PXORQ may be written either P
~Xor~ Q or
Xor [P,Q] .

b) In mathematical writing, “or” normally denotes the


inclusive or, so that a
statement like, “Either a number is bigger than 2 or it is
smaller than 4”
is considered correct. The writer might take pity on the
reader and add the
phrase, “or both”, but she is not obliged to.

14.4.3 Worked Exercise Which of the following sentences say


the same thing?

In each sentence, n is an integer.

a) Either n is even or it is positive.

b) n is even or positive or both.

c) n is both even and positive.

Answer (a) and (b) say the same thing, (c) is not true of
7, for example, but (a)

and (b) are true of 7.

14.5 Definition: “not”

The symbol ‘->P’ denotes the negation of the predicate P .

14.5.1 Example For real numbers x and y, —>(x < y ) means


the same thing as
x>y.

23

14.5.2 Fact Negation has the very simple truth table

P -nP
~T F
F T

14.5.3 Usage

a) Other notations for —>P are P and ~ P .


b) The symbol in Mathematica for “not” is ! , the
exclamation point. —> P is
written !P.

c) The symbol ‘ -i ’ always applies to the first predicate


after it only. Thus in the
expression —>P V Q , only P is negated. To negate the whole
expression P V Q
you have to write (P V Q) ” .

divide 4
fact 1
integer 3
negation 22
predicate 16
truth table 22
usage 2

14.5.4 Warning Negating a predicate is not (usually) the


same thing as stating
its opposite. If P is the statement “3 > 2”, then -> P is
“3 is not greater than 2”,
rather than “3 < 2”. Of course, —>P can be reworded as “3 <
2”.

14.5.5 Example Writing the negation of a statement in


English can be surpris-
ingly subtle. For example, consider the (false) statement
that 2 divides every inte-
ger. The negation of this statement is true; one way of
wording it is that there is
some integer which is not divisible by 2. In particular,
the statement, “All integers
are not divisible by 2” is not the negation of the
statement that 2 divides every
integer.

We will look at this sort of problem more closely in


Section 77.

14.6 Truth Tables in Mathematica

The dmfuncs.m package has a command TruthTable that


produces the truth table
of a given Mathematica logical expression. For example, if
you define the expression

e = a && (b | | ! c)

then TruthTable [e] produces


a b c a Sz&z (b || ! c)

T T T T

T T F T

TFT F

T F F T

F T T F

F T F F

F F T F

F F F F

24

and 21, 22
definition 4
logical connective 21
or 21, 22
propositional vari-
able 104

rule of inference 24
usage 2

15. Rules of Inference

15.1 Definition: rule of inference

Let P±, P- 2 , ■■■P n and Q be predicates. An expression of


the form

Pi,,,. ,P n |— Q

is a rule of inference. Such a rule of inference is valid


if whenever Pi ,

P 2 . . . and P n are all true then Q must be true as well.

15.1.1 Example If you are in the middle of proving


something and you discover
that P A Q is true, then you are entitled to conclude that
(for example) P is true,
if that will help you proceed with your proof. Hence
PAQ \- P (15.1)

is a valid rule of inference.

That is not true for ‘V’, for example: If PVQ is true,


you know that at least
one of P and Q are true, but you don’t know which one.
Thus the purported rule
of inference “PVQ |— P” is invalid.

15.1.2 Usage The symbol ‘h’ is called the “turnstile”.


In this context, it can be
read “yields”.

15.1.3 Example The basic rules of inference for “or”


are

P |— PVQ and Q |— PVQ (15.2)

These say that if you know P , you know PvQ, and if you
know Q , you know
PVQ.

15.1.4 Example Another rule of inference for “and” is

P,Q f- PAQ (15.3)

15.1.5 Exercise Give at least two nontrivial rules of


inference for XOR. The rules
should involve only propositional variables and XOR and
other logical connectives.

15.1.6 Exercise Same instructions as for Exercise


15.1.5 for each of the connec-
tives defined by these truth tables:

P Q P*Q

T T F

T F F

FT T
F F F

(a)

P Q P NAND Q
T T F
T F T

FT T

F F T

(b)

P Q P NOR Q
T T F

T F F

FT F

F F T

(c)

25

15.2 Definitions and Theorems give rules of inference

What Method 3.1.1 (page 4) says informally can be


stated more formally this way:
Every definition gives a rule of inference.

Similarly, any Theorem gives a rule of inference.

15.2.1 Example The rule of inference corresponding to


Definition 4.1, page 4, is
that for m, n and q integers,

m = qn |— n \ m

One point which is important in this example is that it


must be clear in the rule
of inference what the types of the variables are. In
this case, we required that the
variables be of type integer. Although 14 = (7/2) x 4,
you cannot conclude that
4 | 14, because 7/2 is not an integer.

divide 4
integer 3
natural number 3
nonnegative integer 3
positive integer 3
positive 3
rational 11
real number 12
rule of inference 24
truth table 22
usage 2

15.2.2 Worked Exercise State Theorem 5.4, page 8, as a


rule of inference.
Answer k\m,k\n |— k\m + n.

15.2.3 Exercise (discussion) What is the truth table


for the English word
“but”?

16 . Sets

The concept of set, introduced in the late nineteenth


century by Georg Cantor, has
had such clarifying power that it occurs everywhere in
mathematics. Informally, a
set is a collection of items. An example is the set of
all integers, which is traditionally
denoted Z.

We give a formal specification for sets in 21.1.

16.1.1 Example Any data type determines a set — the set


of all data of that
type. Thus there is a set of integers, a set of natural
numbers, a set of letters of the
English alphabet, and so on.

16.1.2 Usage The items which constitute a set are


called the elements or mem-
bers of the set.

16.2 Standard notations

The following notation for sets of numbers will be used


throughout the book.

a) N is the set of all nonnegative integers

b) N + is the set of all positive integers.

c) Z is the set of all integers.

d) Q is the set of all rational numbers.

e) R is the set of all real numbers.

f) R + is the set of all nonnegative real numbers.


g) R ++ is the set of all positive real numbers.

16.2.1 Usage Most authors adhere to the notation of the


preceding table, but
some use N for N + or I for Z .

26

definition 4
integer 3
set 25, 32
type (of a vari-
able) 17

16.3 Definition: “e”

If x is a member of the set A, one writes “x € A if it


is not a member
of A, “xgA”.

16.3.1 Example 4eZ, — 5 G Z, but 4/3 0 Z.

16.4 Sets, types and quantifiers

When using the symbol V, as in Section 13.1, the type


of the variable can be
exhibited explicitly with a colon followed by the name
of a set, as is done in Pas-
cal and other computer languages. Thus to make it clear
that x is an integer, one
could write (Vx:Z )P{x).

16.4.1 Worked Exercise Which of these statements is


true?

a) (Vx:Z)x > 0

b) (Vx:N)x > 0

Answer Part (a) says that every integer is nonnegative.


That is false; for example,
—3 is negative. On the other hand, part (b) is true.

17. List notation for sets

There are two common methods for defining sets: list


notation, discussed here, and
setbuilder notation, discussed in the next chapter.
17.1 Definition: list notation

A set with a small number of members may be denoted by


listing them
inside curly brackets.

17.1.1 Example The set {2,5,6} contains the numbers 2,


5 and 6 as elements,
and no others. So 2 e {2,5,6} but 7 ^ {2,5,6}.

17.1.2 Remark

a) In list notation, the order in which the elements


are given is irrelevant: {2,5,6}
and {5,2,6} are the same set.

b) Repetitions don’t matter, either: {2,5,6}, {2, 2, 5,


6} and {2, 5, 5, 5, 6, 6} are
all the same set. Note that {2, 5, 5, 6, 6} has three
elements.

17.1.3 Remark The preceding remarks indicate that the


symbols {2,5,6} and
{2, 2, 5, 6} are different representations of the same
set. We discussed different rep-
resentations of numbers in Section 10.2. Many
mathematical objects have more
than one representation.

27

17.1.4 Exercise How many elements does the set {1,1, 2,


2, 3,1} have? (Answer
on page 243.)

17.2 Sets in Mathematica

In Mathematica, an expression such as

12,2,5,6}

denotes a list rather than a set. (Lists are treated in


detail in Chapter 109.) Both
order and repetition matter. In particular, 12,2,5,6}
is not the same as 12,5,6}
and neither are the same as 12,6,5} .
A convenient way to list the first n integers is Table
[k , Ik , 1 , n}] . For example,
Table [k, Ik, 1,10}] returns 11,2,3,4,5,6,7,8,9,10}.

comprehension 27,

29

defining condition 27
definition 4
integer 3
predicate 16
setbuilder nota-
tion 27
set 25, 32
type (of a vari-
able) 17
usage 2

17.3 Sets as elements of sets

A consequence of Specification 21.1 is that a set,


being a “single entity”, can be
an element of another set. Furthermore, if it is, its
elements are not necessarily
elements of that other set.

17.3.1 Example Let A = {{1,2}, {3}, 2, 6}. It has four


elements, two of which
are sets.

Observe that 1 € {1,2} and {1,2} 6 A, but the number 1


is not an element
of A. The set {1,2} is distinct from its elements , so
that even though one of its
elements is 1, the set {1,2} itself is not 1. On the
other hand, 2 is an element
of A because it is explicitly listed as such.

17.3.2 Exercise Give an example of a set that has {1,2}


as an element and 2 as
an element but which does not have 1 as an element.

18. Setbuilder notation

18.1 Definition: setbuilder notation

A set may be denoted by the expression {x \ P(x)} ,


where P is a pred-
icate. This denotes the set of all elements of the type
x for which the
predicate P(x) is true. Such notation is called
setbuilder notation.
The predicate P is called the defining condition for
the set, and the
set {x | -P(x)} is called the extension of the
predicate P .

18.1.1 Usage

a) Sometimes a colon is used instead of ‘ | ’ in the


setbuilder notation.

b) The fact that one can define sets using setbuilder


notation is called compre-
hension. See 18.1.11.

18.1.2 Example The set {n | n is an integer and 1 < n <


6} denotes the set
{ 2 , 3 , 4 , 5 }.

28

and 21, 22
extension (of a
predicate) 27
integer 3
predicate 16
prime 10
real number 12
set 25, 32
subset 43
type (of a vari-
able) 17
usage 2

18.1.3 Example The set S = {n \ n is an integer and n


is prime} is the set of all
primes.

18.1.4 Worked Exercise List the elements of these sets,


where n is of type
integer.

a) {n | n 2 = 1} .
b) {n | n divides 12} .

c) {?r | 1 < n < 3} .

Answer a) {-1,1}. b) {1,2, 3, 4, 6, 12, -1,-2, -3, -4,


-6, -12}. c) {2}.

18.1.5 Exercise How many elements do each of the


following sets have? In each
case, x is real.

a) {2, 1,1,1} c) {x | x 2 — 1 = 0}

b) { 1 , 2 , — 1 , x/4, | — 1 1 } d) {x | x 2 + 1 = 0}

(Answer on page 243.)

18.1.6 Example The extension of the predicate

is the set {3,4} .

(x e Z) A (x < 5) A (x > 2)

18.1.7 Example The extension of a predicate whose main


verb is “equals” is what
one would normally call the solution set of the
equation. Thus the extension of the
predicate x 2 = 4 is {—2,2}.

18.1.8 Exercise Write predicates whose extensions are


the sets in exercise 18.1.5
(a) and (b). Use a real variable x.

18.1.9 Exercise Give these sets in list notation, where


n is of type integer.

a) {n | n > 1 and n < 4} .

b) {n | n is a factor of 3} .

18.1.10 Usage In some texts, a predicate is defined to


be what we have called its
extension here: in those texts, a predicate P(x) is a
subset (see Chapter 31) of the
set of elements of type x. In such texts, “(x = 2) V (x
= —2)” would be regarded as
the same predicate as “x 2 = 4”.
29

18.1.11 Method: Comprehension

Let P(x) be a predicate and let A = {x | P(a;)} . Then


if you know that
a G A , it is correct to conclude that P(a) . Moreover,
if P(a) , then you
know that a£i.

18.1.12 Remark The Method of Comprehension means that


the elements of
{x | P(x)} are exactly all those x that make P(x) true.
If A = {x | P(x)}, then
every x for which P{x) is an element of A, and nothing
else is.

This means that in the answer to Worked Exercise


18.1.4, the only correct
answer to part (b) is {1,2,3,4,6,12,— 1,-2,— 3,— 4,— 6,
— 12}. For example, the
set {1,2, 3, 4, 6, —3, —4, —6, —12} would not be a
correct answer because it does not
include every integer that makes the statement “n
divides 12” true (it does not
contain —2, for example).

infinite 174
integer 3
predicate 16
real number 12
rule of inference 24
setbuilder nota-
tion 27
set 25, 32
type (of a vari-
able) 17
unit interval 29
usage 2

18.1.13 Rules of inference for sets It follows that we


have two rules of infer-
ence: If P(x) is a predicate, then for any item a of
the same type as x ,

and

P(a) |- a e {x -P(x)}
(18.1)

a e {x P(x)} |- P(a)

(18.2)

18.1.14 Example

The set

I = {x \ x is real and 0 < x < 1}

(18.3)

which has among its elements 0, 1/4, 7r/4, 1, and an


infinite number of other
numbers. I is fairly standard notation for this set —
it is called the unit interval.

18.1.15 Usage Notation such as “a < x < 6” means a < x


and x < b. So the
statement “0 < x < 1” in the preceding example means “0
< x” and “x < 1”. Note
that it follows from this that 5 < x < 3 means (5 < x)
A (x < 3) — there are no
numbers x satisfying that predicate. It does not means
“(5 < x) V (x < 3)”!

18.1.16 Exercise What is required to show that a ^ {x \


P(x)}? (Answer on
page 243.)

19. Variations on setbuilder notation

Frequently an expression is used left of the vertical


line in setbuilder notation,
instead of a single variable.

19.1 Typing the variable


One can use an expression on the left side of
setbuilder notation to indicate the type
of the variable.

30

and 21, 22
integer 3
predicate 16
rational 11
real number 12
set 25, 32
unit interval 29

19.1.1 Example The unit interval I could be defined as

I = {x 6 R | 0 < x < 1}

making it clear that it is a set of real numbers rather


than, say rational numbers.

19.2 Other expressions on the left side

Other kinds of expressions occur before the vertical


line in setbuilder notation as
well.

19.2.1 Example The set {n 2 | n£Z} consists of all the


squares of integers; in
other words its elements are 0, 1,4,9, 16, ....

19.2.2 Example Let A ={1,3,6}. Then

{n - 2 | n G A} = {—1,1,4}

19.2.3 Remark The notation introduced in the preceding


examples is another
way of putting an additional condition on elements of
the set. Most such defini-
tions can be reworded by introducing an extra variable.
For example, the set in
Example 19.2.1 could be rewritten as

{n 2 | n € Z} = {k \ (k = n 2 ) A (n G Z)}
and the set in Example 19.2.2 as

{n — 2 | n G A} = {m | (m = n-2)A(n£ A)}
19.2.4 Warning Care must be taken in reading such
expressions: for example,
the integer 9 is an element of the set {n 2 | n£ZAn/3},
because although 9 = 3 2 ,
it is also true that 9 = (— 3) 2 , and —3 is an integer
not ruled out by the predicate
on the right side of the definition.

19.2.5 Exercise Which of these equations are true?

a) R + = {x 2 | x G R}

b) N = {x 2 | x G N}

c) R = {x 3 | x G R}

(Answer on page 243.)

19.2.6 Exercise List the elements of these sets.

a) {n — 1 G Z | n divides 12}

b) {n 2 G N | n divides 12}

c) {n 2 G Z | n divides 12}

(Answer on page 243.)

19.2.7 Exercise List the elements of these sets, where


x and y oare of type real:

a) {x + y | y = 1 — x}.

b) {3.x | x 2 = 1} .

31

19.2.8 Exercise How many elements does the set

have?

,, | x = — , -,—2,2}
x 2 1 2 2

19.3 More about sets in Mathematica


The Table notation described in 17.2 can use the
variations described in 19. For
example, Table [k"2 , {k, 1 , 5}] returns
{1,4,9,16,25}.

Defining a set by setbuilder notation in Mathematica is


accomplished using the
command Select. Select [list , criterion] lists all the
elements of the list that
meet the criterion. For example, Select [{2, 5, 6,7,8},
PrimeQ] returns {2,5,7}.
The criterion must be a Mathematica command that
returns True or False for each
element of the list. The criterion can be such a
command you defined yourself; it
does not have to be built in.

closed interval 31
definition 4
open interval 31
real number 12
setbuilder nota-
tion 27
set 25, 32
usage 2

19.3.1 Exercise (Mathematica) Explain the result you


get when you type
Select [{2 ,4, Pi , 5 . 0 , 6 . 0} , Integer Q]

in Mathematica.

20. Sets of real numbers

Now we use the setbuilder notation to define a notation


for intervals of real numbers.

20.1 Definition: interval


An open interval

(a . . b) = {x G R | a < x < b}

(20.1)
for any specific real numbers a and b. A closed
interval includes its
endpoints, so is of the form

[a . . b] = {x G R | a < x < 6}

(20.2)

20.1.1 Example The interval I defined in (18.3),


page 29, is [0 . . 1] .

20.1.2 Usage The more common notation for these


sets uses a comma instead of
two dots, but that causes confusion with the
notation for ordered pair which will be
introduced later.

20.1.3 Exercise Which of these are the same set? x


is real.

a) {0,1,— 1} d) {x | x 3 = — x}

b) {x | x = — x} e) [— 1..1]

c) {x | x 3 = x} f) (— 1..1)

(Answer on page 243.)

32

real number 12
setbuilder nota-
tion 27
set 25, 32
specification 2

20.2 Bound and free variables

The variable in setbuilder notation, such as the x


in Equation (18.3), is bound, in
the sense that you cannot substitute anything for
it. The “dummy variable” x in
an integral such as j ^ f(x) dx is bound in the
same sense. On the other hand, the
a and b in Equation (20.2) are free variables: by
substituting real numbers for a
and b you get specific sets such as [0 . . 2] or [—
5.. 3]. Free variables which occur in
a definition in this way are also called parameters
of the definition.

21. A specification for sets

We said that Method 18.1.11 “determines the set {x


| P(x)} precisely.” Actually,
what the method does is explain how the notation
determines the elements of the set
precisely. But that is the basic fact about sets: a
set is determined by its elements.

Indeed, the following specification contains


everything about what a set is that
you need to know (for the purposes of reading this
book!).

21.1 Specification: set

A set is a single entity distinct from, but


completely determined by, its
elements (if there are any).

21.1.1 Remarks

a) This is a specification, rather than a


definition. It tells you the operative
properties of a set rather than giving a definition
in terms of previously known
objects.

Thus a set is a single abstract thing (entity) like


a number or a point, even
though it may have many elements. It is not the
same thing as its elements,
although it is determined by them.

b) In most circumstances which arise in mathematics


or computer science, a kind
of converse to Specification 21.1 holds: any
collection of elements forms a set.
However, this is not true universally. (See Section
24.)

21.2 Consequences of the specification for sets

A consequence of Specification 21.1 is the


observation in Section 17.1 that, in using
the list notation, the order in which you list the
elements of a set is irrelevant.
Another consequence is the following method.
21.2.1 Method

For any sets A and B , A = B means that

a) Every element of A is an element of B and

b) Every element of B is an element of A.

33

21.2.2 Example For x real,

{x | x 2 = 1} = {x | (x = 1) V (x = —1)}

We will prove this using Method 21.2.1. Let

A = {x | x 2 = 1} and B = {x \ (x = 1) V (x = —1)}

Suppose x 6 A. Then x 2 = 1 by 18.2. Then x 2 — 1 =


0, so (x — l)(x + 1) = 0, so
x = 1 or x = —1. Hence x 6 B by 18.1. On the other
hand, if i£ 5, then x = 1
or x = — 1 , so x 2 = 1 , so

definition 4
empty set 33
extension (of a
predicate) 27
interval 31
or 21, 22
predicate 16
real number 12
set 25, 32
usage 2

21.2.3 Remark The two statements, “x 2 = 1” and “(x


= 1) V (x = —1)” are dif-
ferent statements which nevertheless say the same
thing. On the other hand, the
descriptions {x | x 2 = 1} and {x | (x = 1) V (x =
— 1)} denote the same set; in other
words, the predicates “x 2 = 1” and “(x = 1) V (x =
—1)” have the same extension.
This illustrates that the defining property for a
particular set can be stated in var-
ious equivalent ways, but what the set is is
determined precisely by its elements.
22. The empty set

22.1 Definition: empty set

The empty set is the unique set with no elements at


all. It is denoted
{} or (more commonly) 0.

22.1.1 Remark The existence and uniqueness of the


empty set follows directly
from Specification 21.1.

22.1.2 Example {x £ R | x 2 < 0} = 0.

22.1.3 Example The interval notation “[a.. 6]”


introduced in 20.1 defines the
empty set if a> b. For example, [3. .2] =0.

22.1.4 Example Since the empty set is a set, it can


be an element of another set.
Consider this: although “0” and “{}” both denote
the empty set, {0} is not the
empty set; it is a set whose only element is the
empty set.

22.1.5 Usage This symbol “0” should not be confused


with the Greek letter phi,
written <p , nor with the way the number zero is
sometimes written by older printing
terminals for computers.

22.1.6 Exercise Which of these sets is the empty


set?

a) {0}.

b) {0,0}-

c) {x G Z | x 2 < 0} .

d) {x G Z | x 2 = 2} .

(Answer on page 243.)

34

definition 4
divisor 5
empty set 33
integer 3
positive integer 3
set 25, 32
singleton set 34
singleton 34

23. Singleton sets

23.1 Definition: singleton

A set containing exactly one element is called a


singleton set.

23.1.1 Example {3} is the set whose only element is


3.

23.1.2 Example {0} is the set whose only element is


the empty set.

23.1.3 Remark Because a set is distinct from its


elements, a set with exactly one
element is not the same thing as the element. Thus
{3} is a set, not a number,
whereas 3 is a number, not a set. Similarly, the
President is not the same as the
Presidency, although the President is the only
holder of that office.

23.1.4 Example [3.. 3] is a singleton set, but (3..


3) is the empty set.

23.1.5 Exercise Which of these describe (i) the


empty set (ii) a singleton?

a) {1,-1} e) {x € R + | x < 1}

b) {x £ N | x < 1} f) {x € R | x 2 — 1 = 0}

c) {x G R | x 2 = 0} g) {x e R j x 3 + x = 0}

d) {x £ R | x 2 < 0}

(Answer on page 243.)

23.1.6 Exercise For each positive integer n, let D


n be the set of positive divisors
of n.

a) For which integers n is D n a singleton?

b) Which integers k are elements of D n for every


positive integer n?
(Answer on page 243.)

23.1.7 Exercise Simplify these descriptions of sets


as much as possible, where n
is of type integer.

a) {n | 1 < n < 2} .

b) {n j |n| < 2} .

c) {?r | for all integers m, n < m } .

35

24. Russell’s Paradox

The setbuilder notation has a bug: for some


predicates P(x) , the notation

{x | P(x)} does not define a set. An example is the


predicate “x is a set”. In
that case, if {x | x is a set} were a set, it would
be the set of all sets. However,
there is no such thing as the set of all sets. This
can be proved using the theory of
infinite cardinals, but will not be done here.

We now give another example of a definition {x |


P(x)} which does not give a
set, and we will prove that it does not give a set.
It is historically the first such
example and is due to Bertrand Russell. He took
P(x) to be “x is a set and x is
not an element of itself.” This gives the
expression “{x | x ^ x}”.

We now prove that that expression does not denote a


set. Suppose S =
{x | x^x} is a set. There are two possibilities:
(i) S € S. Then by definition
of S , S is not an element of itself i.e. , S S .
(This follows from the rule of infer-
ence (18.1) on page 29.) (ii) S ^ S . In this case,
since S is not an element of S
and S is the set of all sets which are not elements
of themselves, it follows from
Rule (18.1) that S G S . Both cases are impossible,
so there is no such set as S .
This is an example of a proof by contradiction,
which we will study in detail in
Section 86, page 125.

As a result of the phenomenon that the setbuilder


notation can’t be depended on
to give a set, set theory as a mathematical science
(as opposed to a useful language)
had to be developed on more abstract grounds
instead of in the naive way described
in this book. The most widely-accepted approach is
via Zermelo-Frankel set theory,
which unfortunately is complicated and not very
natural in comparison with the
way mathematicians actually use sets.

Luckily, for most practitioners of mathematics or


computer science, this diffi-
culty with the setbuilder notation does not usually
arise. In most applications, the
notation “{x | P(x)}” has x varying over a specific
type whose instances (unlike
the type “set”) are already known to constitute a
set (e.g., x is real — the real num-
bers form a set). In that case, any meaningful
predicate defines a set {x | P(x)} of
elements of that type.

For more about Russell’s Paradox, see [Wilder,


1965], starting on page 57.

and 21, 22
implication 35, 36
or 21, 22
predicate 16
real number 12
rule of inference 24
Russell’s Paradox 35
setbuilder nota-
tion 27
set 25, 32
type (of a vari-
able) 17

24.0.8 Exercise (discussion) In considering


Russell’s Paradox, perhaps you
tried unsuccessfully to think of a set which is an
element of itself. In fact, most
axiomatizations of set theory rule out the
possibility of a set being an element of
itself. Does doing this destroy Russell’s example?
What does it say about the
collection of all sets?

25. Implication

In Chapter 14, we described certain operations such


as “and” and “or” which com-
bine predicates to form compound predicates. There
is another logical connective
which denotes the relationship between two
predicates in a sentence of the form
“If P, then Q” , or “P implies Q” . Such a
statement is called an implication.

36

antecedent 36 Implications are at the very heart of


mathematical reasoning. Mathematical proofs

conclusion 36 typically consist of chains of


implications.

conditional sen-

tence 36

25.1 Definition: implication

consequent 36, 121


definition 4
hypothesis 36

For predicates P and Q , the implication P => Q is


a predicate defined
by the truth table

implication 35, 36

P Q

P => Q

logical connective 21

T T

T
material condi-

T F

tional 36
predicate 16
truth table 22

F T
F F

type (of a vari-


able) 17

In the implication P Q , P is the hypothesis or


antecedent and Q

is the conclusion or consequent.

usage 2

25.1.1 Example Implication is the logical


connective used in translating state-
ments such as “If m> 5 and 5 > n, then m > n” into
logical notation. This state-
ment could be reworded as, “m > 5 and 5 > n implies
that rn > n.” If we take
P(m,n) to be “(m > 5) A (5 > n)” and Q(m,n) to be
“m > n”, then the statement
“If m > 5 and 5 >n, then m > n” is “P(m,n) =>
Q(m,n)” .

25.1.2 Usage The implication connective is also


called the material condi-
tional, and P => Q is also written P D Q . An
implication, that is, a sentence
of the form P => Q, is also called a conditional
sentence.
25.1.3 Remarks

a) Definition 25.1 gives a technical meaning to the


word “implication”. It also
has a meaning in ordinary English. Don’t confuse
the two. The technical
meaning makes the word “implication” the name of a
type of statement.

b) Warning: The truth table for implication has


surprising consequences which
can cause difficulties in reading technical
articles. The first line of the truth
table says that if P and Q are both true then P =>
Q is true. In Exam-
ple 25.1.1, we have “7 > 5 and 5 > 3 implies 7 > 3”
which you would surely
agree is true.

However, the first line of the truth table also


means that other statements
such as “If 2 > 1 then 3 x 5 = 15” are true. You
may find this odd, since the
fact that 3 x 5 = 15 doesn’t seem to have anything
to do with the fact that
2 > 1 . Still, it fits with the truth table.
Certainly you wouldn’t want the fact
that P and Q are both true to be grounds for P =4>
Q being false.

25.1.4 Exercise Which of these statements are true


for all integers ml

a) m > 7 =4> m > 5 .

b) m > 5 =4- m > 7 .

c) m 2 =4 => m = 2.

(Answer on page 243.)

37

conclusion 36
definition 4
divide 4
fourtunate 37
hypothesis 36
implication 35, 36
integer 3
natural number 3
odd 5
predicate 16
proposition 15
truth table 22
vacuously true 37

26.1.2 Example Both these statements are vacuously


true:

a) If 4 is odd then 3 = 3.

b) If 4 is odd then 3/3.

26.1.3 Remarks Although this situation may be


disturbing when you first see it,
making either statement in Example 26.1.2 false
would result in even more peculiar
situations. For example, if you made P => Q false
when P and Q are both false,
you would then have to say that the statement
discussed previously,

“For any integers m and n, if m > 5 and 5 > n then


rn > n,”

is not always true (substitute 3 for rn and 4 for n


and you get both P and Q
false). This would surely be an unsatisfactory
state of affairs.

Most of the time in mathematical writing the


implications which are actually
stated involve predicates containing variables, and
the assertion is typically that the
implication is true for all instances of the
predicates. Implications involving propo-
sitions occur only implicitly in the process of
checking instances of the predicates.
That is why a statement such as, “If 3 > 5 and 5 >
4, then 3 > 4” seems awkward
and unfamiliar.

26.1.4 Example Vacuous truth can cause surprises in


connection with certain
concepts which are defined by using implication.
Let’s look at a made-up example
here: to say that a natural number n is fourtunate
(the spelling is intentional)
means that if 2 divides n then 4 divides n. Thus
clearly 4, 8, 12 are all fourtunate.
But so are 3 and 5. They are vacuously fourtunate!

26.1.5 Exercise For each implication, give (if


possible) an integer n for which it
is true and another for which it is false.

a) (n > 7) => (n < 4) d) (n = lVn = 3) 4 (n is odd)


b) (n > 7) =>- (n > 4) e) (n = 1 A n = 3) =>- (n is
odd)

c) (n > 7) =>- (n > 9) f) (n = 1 V n = 3) =>- n = 3

(Answer on page 243.)

26. Vacuous truth

The last two lines of the truth table for


implication mean that if the hypothesis of
an implication is false, the implication is
automatically true.

26.1 Definition: vacuously true

In the case that P => Q is true because P is false,


the implication
P => Q is said to be vacuously true.

26.1.1 Remark The word “vacuous” refers to the fact


that in that case the impli-
cation says nothing interesting about either the
hypothesis or the conclusion. In
particular, the implication may be true, yet the
conclusion may be false (because of
the last line of the truth table).

38

implication 35, 36 26.1.6 Exercise If possible,


give examples of predicates P and Q for which each

logical connective 21 of these is (i) true and (ii)


false,
predicate 16 a ) p =>. (p =>. Q)

b) Q => (P => Q)

c) (P =*► Q) =► P

d) (P => Q) =>■ Q

27. How implications are worded

Implication causes more trouble in reading


mathematical prose than all the other
logical connectives put together. An implication
may be worded in various ways; it
takes some practice to get used to understanding
all of them as implications.
The five most common ways of wording P Q are
WI.l If P, then Q.

WI.2 P only if Q.

WI.3 P implies Q.

WI.4 P is a sufficient condition for Q.

WI.5 Q is a necessary condition for P.

27.1.1 Example For all x G Z,

a) If x > 3 , then x >2.

b) x > 3 only if x > 2 .

c) x > 3 implies x > 2 .

d) That x > 3 is sufficient for x > 2.

e) That x > 2 is necessary for x > 3 .


all mean the same thing.

27.1.2 Remarks

a) Watch out particularly for Example 27.1.1(b): it


is easy to read this statement
backward when it occurs in the middle of a
mathematical argument. Perhaps
the meaning of (b) can be clarified by expanding
the wording to read: “x can
be greater than 3 only if x > 2 .”

Note that sentences of the form “P only if Q” about


ordinary everyday
things generally do not mean the same thing as “If
P then Q ” ; that is because
in such situations there are considerations of time
and causation that do not
come up with mathematical objects. Consider “If it
rains, I will carry an
umbrella” and “It will rain only if I carry an
umbrella” .

b) Grammatically, Example 27.1.1(c) is quite


different from the first two. For
example, (a) is a statement about x. whereas (c) is
a statement about state-
ments about x. However, the information they
communicate is the same.
See 27.3 below.

39
27.1.3 Exercise You have been given four cards each
with an integer on one side
and a colored dot on the other. The cards are laid
out on a table in such a way
that a 3, a 4, a red dot and a blue dot are
showing. You are told that, if any of
the cards has an even integer on one side, it has a
red dot on the other. What is
the smallest number of cards you must turn over to
verify this claim? Which ones
should be turned over? Explain your answer.

27.2 Universally true implications

Implications which are universally true are


sometimes stated using the word “every”
or “all”. For example, the implication, “If x > 3,
then x > 2”, could be stated this
way: “Every integer greater than 3 is greater than
2” or “All integers greater than
3 are greater than 2” . You can recognize such a
statement as an implication if what
comes after the word modified by “every” or “all”
can be reworded as a predicate
(“greater than 3” in this case).

even 5

implication 35, 36
integer 3
positive real num-
ber 12
predicate 16
proposition 15
real number 12
rule of inference 24

27.2.1 Exercise Which of the following sentences


say the same thing?

a) If a real number is positive, it has a square


root.

b) If a real number has a square root, it is


positive.

c) A real number is positive only if it has a


square root.

d) Every positive real number has a square root.

e) For a real number to be positive, it is


necessary that it have a square root.
f) For a real number to be positive, it is
sufficient that it have a square root.
(Answer on page 243.)

27.2.2 Exercise Suppose you have been told that the


statement P =>• Q is false.
What do you know about PI About Q‘l

27.3 Implications and rules of inference

Suppose P and Q are any predicates. If P =$■ Q ,


then the rule of inference P |— Q
is valid, and conversely if P |— Q is valid, then P
=>■ Q must be true. This is stated
formally as a theorem in texts on logic, but that
requires that one give a formal
definition of what propositions and predicates are.
We will take it as known here.

27.3.1 Example It is a familiar fact about real


numbers that for all x and y,
(x > y) =>• (x > y — 1) . This can be stated as the
rule of inference x > y x > y — 1.

40

biconditional 40
conclusion 36
definition 4
divide 4
equivalence 40
equivalent 40
hypothesis 36
implication 35, 36
predicate 16
rule of inference 24
truth table 22

28. Modus Ponens

The truth table for implication may be summed up by


saying:

An implication is true unless the hypothesis is


true and the conclusion is false.

This fits with the major use of implications in


reasoning: if you know that the
implication is true and you know that its
hypothesis is true, then you know its
conclusion is true. This fact is called “modus
ponens”, and is the most important
rule of inference of all:

28.1 Definition: modus ponens


Modus ponens is the rule of inference

(P, P => Q) \- Q

which is valid for all predicates P and Q .

(28.1)

28.1.1 Remark That modus ponens is valid is a


consequence of the truth table
for implication (Definition 25.1). If P is true
that means that one of the first two
lines of the truth table holds. If P =4> Q is
true, one of lines 1, 3 or 4 must hold.
The only possibility, then, is line 1, which
says that Q is true.

28.2 Uses of modus ponens

A theorem (call it Theorem T) in a mathematical


text generally takes the form of
an implication: “If [hypotheses H \,. . . , H n
] are true, then [conclusion].” It will then
typically be applied in the proof of some
subsequent theorem using modus ponens.
In the application, the author will verify that
the hypotheses H i, . . . , H n of Theorem
T are true, and then will be able to assert
that the conclusion is true.

28.2.1 Example As a baby example of this, we


prove that 3 | 6 using Theorem 5.1
and Theorem 5.4. By Theorem 5.1, 3 | 3. The
hypotheses of Theorem 5.4 are that
k | m and k\n. Using k = m = n = 3 this becomes
3 | 3 and 3 | 3, which is true.
Therefore the conclusion 3 | 3 + 3 must be true
by Theorem 5.4. Since 3 + 3 = 6 we
have that 3 I 6 .

29. Equivalence
29.1 Definition: equivalence

Two predicates P and Q are equivalent, written


P <=> Q . if for any
instance, both P and Q are true or else both P
and Q are false. The
statement P Q is called an equivalence or a
biconditional.

41

29.1.1 Fact The truth table for equivalence is

PaaQ

T
This is the same as (P =4- Q) A (Q =>• P) .

equivalent 40
fact 1

implication 35, 36
logical connective 21
or 21, 22
predicate 16
theorem 2
truth table 22
usage 2

29.1.2 Usage The usual way of saying that P 44


Q is, “P if and only if Q” , or
“P is equivalent to Q.” The notation “iff” is
sometimes used as an abbreviation
for “if and only if” .

29.1.3 Example x > 3 if and only if both


x>3 and

29.1.4 Warning The statement “P44(2” does


not say that P is true.

29.2 Theorem

Two expressions involving predicates and


logical connectives are equiva-
lent if they have the same truth table.

29.2.1 Example P =4- Q is equivalent to —>


P V Q , as you can see by constructing
the truth tables. This can be understood as
saying that P =$■ Q is true if and only
if either P is false or Q is true.

29.2.2 Worked Exercise Construct a


truth table that shows that (PVQ) AP
is equivalent to (P A R) V (Q A R) .

Answer

P Q R P\JQ
T T T T

T T F T

TFT T
T F F T

F T T T

F T F T

F F T F

F F F F

(PVQ)AP PAR QAR

T T T

F F F

T T F

F F F

T FT

F F F

F F F

F F F

(PAP) V(QAP)

29.2.3 Exercise Construct truth tables


showing that the following three state-
ments are equivalent:

a) P =>■ Q

b) ~^P\J Q

c) -.(PA -.<2)

29.2.4 Exercise Write English sentences


in the form of the three sentences in
Exercise 29.2.3 that are equivalent to

(x>2) =4- (x> 2)

contrapositive 42
converse 42
decimal expansion
decimal 12, 93
definition 4
equivalent 40
implication 35, 36
rational 11
real number 12
theorem 2
truth table 22

42

30. Statements related to an


implication

12

30.1

is

If x > 2 , then x > 3

The first is true for all real numbers


x, whereas there are real numbers for which
the seconxd one is false: An
implication does not say the same thing as its converse.
(If it’s a cow, it eats grass, but if
it eats grass, it need not be a cow.)

30.1.2 Example In Chapter 10, we


pointed out that if the decimal expansion of
a real number r is all 0’s after a
certain point, then r is rational. The converse of
this statement is that if a real number
r is rational, then its decimal expansion is all
0’s after a certain point. This is
false , as the decimal expansion of r = 1/3 shows.

The following Theorem says more about


an implication and its converse:

30.2 Theorem

If P =>• Q and its converse are both


true, then P Q .

30.2.1 Exercise Prove Theorem 30.2


using truth tables and Theorem 29.2.

30.3 Definition: contrapositive

The contrapositive of an implication P


Q is the implication
-i Q -i P . (Note the reversal.)

30.3.1 Example The contrapositive of

If x > 3 , then x > 2

is (after a little translation)

If x < 2 , then x < 3

These two statements are equivalent.


This is an instance of a general rule:

30.4 Theorem

An implication and its contrapositive


are equivalent.

30.4.1 Exercise Prove Theorem 30.4


using truth tables.

30.4.2 Remark To say, “If it’s a cow,


it eats grass,” is logically the same as
saying, “If it doesn’t eat grass, it
isn’t a cow.” Of course, the emphasis is different,
but the two statements communicate the
same facts. In other words,

(P Q) (-■ Q ->P)

Make sure you verify this by truth


tables. The fact that a statement and its contra-
positive say the same thing causes many
students an enormous amount of trouble
in reading mathematical proofs.
30.1 Definition: converse

The converse of an implication P =>■ Q


is Q =4> P.

.1 Example The converse of

If x > 3 , then x > 2

43

30.4.3 Example Let’s look again at this


(true) statement (see Section 10,
page 14):

If the decimal expansion of a real


number r has all 0’s after a certain
point, it is rational.

The contrapositive of this statement is


that if r is not rational, then its decimal
expansion does not have all 0’s after
any point. In other words, no matter how
far out you go in the decimal expansion
of a real number that is not rational,
you can find a nonzero entry further
out. This statement is true because it is the
contrapositive of a true statement.

30.4.4 Remark Stating the


contrapositive of a statement P => Q requires form-
ing the statement —>Q => —> P, which
requires negating each of the statements P
and Q . The preceding example shows
that this involves subtleties, some of which
we consider in Section 77.

30.4.5 Exercise Write the


contrapositive and converse of “If 3 | n then n is
prime”. Which is true? (Answer on page
243.)

30.4.6 Exercise Write the converse and


the contrapositive of each statement in
Exercise 26.1.5 without using

contrapositive 42
converse 42
decimal 12, 93
definition 4
divide 4
extension (of a
predicate) 27
implication 35, 36
include 43
integer 3
predicate 16
prime 10
rational 11
real number 12
rule of inference 24
set 25, 32
subset 43
theorem 2
type (of a vari-
able) 17
usage 2

31. Subsets and inclusion

Every integer is a rational number (see


Chapter 7). This means that the sets Z and
Q have a special relationship to each
other: every element of Z is an element of Q .
This is the relationship captured by
the following definition:

31.1 Definition: inclusion

For all sets A and B , AC B if and only


if xC A => xC B is true for
all x.

31.1.1 Usage The statement A C B is


read “A is included in B v or “A is a
subset of B" .

31.1.2 Example Z C Q, QCR and ICR.

Definition 31.1 gives an immediate rule


of inference and a method:

31.1.3 Method

To show that A C B , prove that every


element of A is an element of B .

31.1.4 Remark If P{x) is a predicate


whose only variable is x and x is of type S
for some set S, then the extension of
P(x), namely {x | P(x)}, is a subset of S.

Some useful consequences of


Definition 31.1 are included in the following theo-

rem.

44

definition 4
equivalent 40
hypothesis 36
implication 35, 36
include 43
proof 4

properly included
set 25, 32
vacuous 37

31.2 Theorem

a) For any set A, AC A.

b ) For any set A, 0 C A.

c) For any sets A and B , A = B if


and only if A C B and B C A .

Proof Using Definition 31.1, the


statement AC A translates to the statement
x&A =y x&A, which is trivially
true. The statement 0 C A is equivalent to the
statement x £ 0 =t- x^A, which is
vacuously true for any x whatever (the hypoth-
esis is always false). We leave the
third statement to you.

31.2.1 Exercise Prove part (c) of


Theorem 31.2.

31.3 Definition: strict inclusion

If A C B but Af^B then every


element of A is in B but there is at
least one element of B not in A .
This is symbolized by A B , and is
read “A is properly included in £”.
31.3.1 Warning Don’t confuse the
statement U A(^ B ” with “-i(AC£)”: the
latter means that there is an
element of A not in B .

31.3.2 Exercise Prove that for all


sets A and B, (A B) =y — 1 ( B C A).

31.4 Inclusion and elementhood

The statement “4 C 5” must be


carefully distinguished from the statement

31.4.1 Example Consider these sets:

A = {1,2,3}

£ = { 1 , 2 , { 1 , 2 , 3 }}

C = {1,2, 3, {1,2, 3}}

A and B have three elements each


and C has four. A £ B because A occurs in
the list which defines B . However,
A is not included in B since 3 G A but 3 ^ B .
On the other hand, AgC and AC C
both.

31.4.2 Exercise Answer each of (i)


through (iii) for the sets X and Y as defined:

(i) age,

(ii) X C Y , and

(iii) X = Y.

a) X={ 1 ,3} , Y={1,3,5}.

b) X={ 1 ,2} , Y= { 1 , { 1 , 2 } }
.

c) X={1,2}, Y={2,1,1}.

d) X={1,2,{1,3}}, Y={1,3,{1,2}}.

e) X={1,2,{1,3}}, Y={ 1 ,{ 1 ,2},{1


,3}} .

(Answer on page 243.)

45
definition 4
include 43
nontrivial subset 45
proper subset 45
set 25, 32
subset 43
usage 2

31.5.1 Usage

a) The word “contain” is ambiguous


as mathematicians usually use it. If iGl,
one often says “A contains x” , and
if B C A, one often says “ A contains B"\

One thing that keeps the


terminological situation from being worse than it
is is that most of the time in
practice either none of the elements of a set are
sets or all of them are. In fact,
sets such as B and C in Example 31.4.1 which
have both sets and numbers as
elements almost never occur in mathematical
writing except as examples in texts
such as this which are intended to bring
out the difference between “element
of” and “included in”!

Nevertheless, when this book uses


the word “contain” in one of these senses,
one of the phrases “as an element”
or “as a subset” is always added.

b) The original notation for “A C


B" was “AcB”. In recent years authors of
high school and college texts have
begun using the symbol ‘ C ’ by analogy
with '<’. However, the symbol ‘C’
is still the one used most by research
mathematicians. Some authors have
used it to mean ‘C^\ but that is an
entirely terrible idea considering
that ‘ C ’ originally meant and is still widely
used to mean ‘C’. This text avoids
the symbol ‘c’ altogether.

31.5.2 Exercise Explain why each


statement is true for all sets A and B , or give
an example showing it is false for
some sets A and B :

a) 0 «E A

b) If A C 0 , then A = 0 .
c) If A = B , then A C B .

d) If 0 € A then A ^ 0.

e) If A £ B and B £ C , then AcC .

f) If AC B and B C C , then ACC.

g) If A C/_ B and B C , then Ac^C .

h) If A B and B ^ C , then 4/C.

31.5.3 Exercise Given two sets S


and T, how do you show that S is not a subset
of T? (Answer on page 244.)

31.4.3 Remark The fact that A C A


for any set A means that any set is a subset
of itself. This may not be what you
expected the word “subset” to mean. This leads
to the following definition:

31.5 Definition: proper

A proper subset of a set A is a set


B with the property that B C A
and B ^ A. A nontrivial subset of A
is a set B with the property
that B C A and B ^ 0 .

46

definition 4
empty set 33
fact 1
include 43
powerset 46
rule of inference
set builder nota-
tion 27
set 25, 32
subset 43

32. The powerset of a set

32.1 Definition: powerset


If A is any set, the set of all
subsets of A is called the powerset of A
and is denoted VA.

32.1.1 Remark Using setbuilder


notation, VA = {X \ X C A}.

32.1.2 Example The powerset of


{1,2} is {0,{1},{2},{1,2}}, and the powerset
of {1} is {0,{1}}.

32.1.3 Fact The definition of


powerset gives two rules of inference:

BCA |- B € VA

and

B £ VA \- BCA

(32.1)

(32.2)

32.1.4 Example The empty set is an


element of the powerset of every set, since
it is a subset of every set.

32.1.5 Warning The empty set is not


an element of every set; for example, it is
not an element of {1,2}.

32.1.6 Exercise How many elements


do each of the following sets have?

a) {1,2, 3, {1,2, 3}}

b) 0

c) {0}

d) {0,{0}}

(Answer on page 244.)

32.1.7 Exercise Write the powerset


of {5,6,7}. (Answer on page 244.)

32.1.8 Exercise State whether each


item in the first column is an element of each
set in the second column.

a)

a)

b)

b)

c)

7 r

c)

{1,3,7}

d)

{1,3}

d)

{xGR x

e)

{3,tt}

e)
V(Z)

f)

f)

g)

g)

{Z,R}

(Answer on page 244.)

47

33. Union and intersection

33.1 Definition: union

For any sets A and B , the union A


U B of A and B is defined by

Au B = {x | x&A VxG-B} (33.1)

33.2 Definition: intersection

For any sets A and B , intersection


.4 f] B is defined by

AnB = {x I xeA AxeB} (33.2)


definition 4
disjoint 47
extension (of a
predicate) 27
intersection 47
logical connective 21
powerset 46
predicate 16
set 25, 32
union 47

33.2.1 Example Let A = {1,2} and B


= {2,3,4}. Then 4U B = {1,2, 3, 4} and
4nB = {2}. If C = {3,4,5} , then
AnC = 0.

33.2.2 Exercise What are {1,2, 3} U


{2, 3, 4, 5} and {1,2, 3} n{2,3,4, 5}? (Answer
on page 244.)

33.2.3 Exercise What are NUZ and


NnZ? (Answer on page 244.)

33.2.4 Remark Union and


intersection mirror the logical connectives ‘V’ and
‘A’ of section 14. The connection
is by means of the extensions of the predicates
involved. The extension of PV Q is
the union of the extensions of P and of Q , and
the extension of P A Q is the
intersection of the extensions of P and of Q .

33.2.5 Example Let S' be a set of


poker chips, each of which is a single color,
either red, green or blue. Let R,
G, B be respectively the sets of red, green and
blue chips. Then PUP is the set of
chips which are either red or blue; the ‘U’
symbol mirrors the “or” . And R n B
= 0 , since it is false that a chip can be both
red and blue.

33.2.6 Warning Although union


corresponds with “V”, the set RU B of the
preceding example could also be
described as “the set of red chips and blue chips” !

33.2.7 Exercise Prove that for any


sets A and B , An B C AU B . (Answer on
page 244.)

33.2.8 Exercise Prove that for any


sets A and B, AnB C A and A C AU B .
33.3 Definition: disjoint

If A and B are sets and An B = 0


then A and B are said to be disjoint.

33.3.1 Exercise Name three


different subsets of Z that are disjoint from N.
(Answer on page 244.)

33.3.2 Exercise If A and B are


disjoint, must V(A) and V(B) be disjoint?

48

complement 48
definition 4
fact 1

set difference 48
set of all sets 35
set 25, 32
subset 43
type (of a vari-
able) 17
universal set 48
usage 2

34. The universal set and


complements

Since we cannot talk about the set


of all sets, there is no universal way to mir-
ror TRUE as a set. However, in many
situations, all elements are of a particular
type. For example, all the elements
in Example 33.2.5 are chips. The set of all ele-
ments of that type constitutes a
single set containing as subsets all the sets under
consideration. Such a set is called
a universal set, and is customarily denoted U .

Given a universal set, we can


define an operation corresponding to ‘ — i ’, as in the
following defintion.

34.1 Definition: complement

If A is a set, A c is the set of


all elements in U but not in 4. A c is
called the complement of A (note
the spelling).

34.1.1 Usage A c may be denoted A


or A 1 in other texts.

34.1.2 Example The complement of N


in Z is the set of all negative integers.

34.2 Definition: set difference

Let A and B be any two sets. The


set difference A — B is the set
defined by

A — B = {x \ x&AAx^B} (34.1)

34.2.1 Example Let A = {1,2,3} and


B = {3,4,5} ; then A — B = {1,2} .

34.2.2 Exercise What is Z — N? What


is N — Z? (Answer on page 244.)

34.2.3 Fact If there is a universal


set U . then A c = U — A.

34.2.4 Usage A — B is written A\B


in many texts..

34.2.5 Exercise Let A = {1,2,3}, H


= {2,3,4,5} and (7 = 11,7,8}. Write out
the elements of the following sets:

a)

AUB

f)

B-C

b)

AnB
g)

dn(BuC)

c)

BUC

h)

Bu(AnC)

d)

Bnc

i)

Bll(A-C)

e)

A-B

(Answer on page 244.)

49

34.2.6 Exercise State whether each


item in the first column is an element of each
set in the second column. A =
{1,3,7}, B = {1,2, 3, 4, 5}, and the universal set is
Z.
1 ) 1

2) 4

3) 7

4) -2

5) 0

6) {2,4,5}

7) {1,3}

1) AUB

2) AnB

3) A-B

4) A- Z

5) B c

6) VA

7) V(AnB)

(Answer on page 244.)

equivalent 40
first coordinate 49
include 43
integer 3
powerset 46
real number 12
second coordinate 49
set 25, 32
specification 2
type (of a vari-
able) 17
universal set 48

34.2.7 Exercise Explain why the


following statements are true for all sets A
and B or give examples showing they
are false for some A and B .

a) V{A)nV(B)=V(AnB)
b) V{A)uV{B)=V{AuB)

c) V(A)-V(B)=V(A-B)

34.2.8 Exercise Show that for any


sets A and B included in a universal set IA .
if A U B = U and 4nB = 0, then B =
A c .

35. Ordered pairs

In analytic geometry, one


specifies points in the plane by ordered pairs of real
numbers, for example (3,5).
(Most books use round parentheses instead of pointy
ones.) This is not the same as
the two-element set {3,5}, because in the ordered
pair the order matters: (3,5)
is not the same as (5,3).

In the ordered pair (3,5), 3 is


the first coordinate and 5 is the second
coordinate. Sometimes, the two
coordinates are the same: for example, (4,4) has
first and second coordinates
both equal to 4 .

An ordered pair in general need


not have its first and second coordinates of the
same type. For example, one
might consider ordered pairs whose first coordinate is
an integer and whose second
coordinate is a letter of the alphabet, such as (5, ‘a’)
and (—3 ,‘d’).

The following specification


gives the operational properties of ordered pairs:

35.1 Specification: ordered


pair

An ordered pair (x,y) is a


mathematical object distinct from x and y
which is completely determined
by the fact that its first coordinate is x
and its second coordinate is y.

35.1.1 Remark Specification


35.1 implies that ordered pairs are the same if and
only if their coordinates are
the same:

((x,y) = (, x f ,y ')) 44 (x =
x' A y = y')
Thus we have a method:

50

coordinate 49
definition 4
integer 3
ordered pair 49
ordered triple 50
specification 2
tuple 50, 139, 140
union 47
usage 2

35.1.2 Method

To prove two ordered pairs


(x,y) and (. x',y ') are the same, prove that
x = x' and y = y' .

35.1.3 Exercise Which of these


pairs of ordered pairs are equal to each other?

a) (2,3), (3,2).

b) (3 , V / 4), (3,2).

c) (2,>/4), (V4,2).

(Answer on page 244.)

35.1.4 Exercise (discussion) In


texts on the foundations of mathematics, an
ordered pair (a, b) is often
defined to be the set j{a,6},{a}j. Prove that at least
when a and b are numbers this
definition satisfies Specification 35.1 (with a suitable
definition of “coordinate”).

36. Tuples

In order to generalize the idea


of ordered pair to allow more than two coordinates,
we need some notation.
36.1 Definition: n

Let n be an integer, n > 1 .


Then n is defined to be the set

{i G N | 1 < i < n}

36.1.1 Example 3 = {1,2,3}.

36.1.2 Exercise Let m and n be


positive integers. What is mfln? What is
mUn? (Answer on page 244.)

A tuple is a generalization of
the concept of ordered pair. A tuple satisfies this
specification:

36.2 Specification: tuple

A tuple of length n, or n
-tuple, is a mathematical object which
T.l has an ith entry for each i
6 n, and
T.2 is distinct from its
entries, and

T.3 is completely determined by


specifying the ith entry for every

i G n.

36.2.1 Example An ordered pair


is the same thing as a 2 -tuple.

36.2.2 Usage

a) A 3 -tuple is usually called


an ordered triple.

b) The usual way of denoting a


tuple is by listing its entries in order inside angle
brackets.

51

36.2.3 Example (1,3,3,— 2) is a


tuple of integers. It has length 4. The integer
3 occurs as an entry in this 4-
tuple twice, for i = 2 and i = 3.
36.2.4 Usage Tuples and their
coordinates are often named according to a sub-
scripting convention, by which
one refers to the ith entry by subscripting i to the
name of the tuple. For example,
let a = (1,3,3, —2} ; then ci2 = 3 and 04 = —2. One
often makes this convention
clear by saying, “Let a = (ai)i en be an n-tuple.”

Many authors would use curly


brackets here: “{aj}i en .” Nevertheless, a is not
a set.

coordinate 49
empty set 33
equivalent 40
integer 3
null tuple 51
set 25, 32
theorem 2
tuple 50, 139, 140
usage 2

36.2.5 Usage Many computer


scientists refer to a tuple as a “vector”. Although
this usage is widespread, it is
not desirable; in mathematics, a vector is a geometric
object which can be represented
as a tuple, but is not itself a tuple.

It follows from Specification


36.2 that two n-tuples are equal if and only if they
have the same entries.
Formally:

36.3 Theorem: How to tell if


tuples are equal

Let a and b be n-tuples. Then

a = 6 44 (Vi:n)(ai = 6*)

36.3.1 Exercise Which of these


pairs of tuples are equal?

a) (3,3), (3,3,3).

b) (2,3), (2,3,3).

c) (2,3,2), (3,2,2).

(Answer on page 244.)


36.4 Special tuples

For formal completeness, one


also has the concept of the null tuple (or empty
tuple) () , which has length 0
and no entries, and a 1 -tuple, which has length 1 and
one entry.

The index set for the null


tuple is the empty set. There is only one null tuple.
In the context of formal
language theory the unique null tuple is often denoted “A”
(capital lambda) or sometimes
“e” (small epsilon). We will use the notation A here.

36.4.1 Exercise For each tuple,


give the integer n for which it is an n-tuple and
also give its second entry.

a)

b)

c)

(Answer on page 244.)

(3,4,0) d) (((2, (1,5)), 7), 9)

((3,4), (1,5)) e) (3, {1,2})

(3, (5, (2,1))) f) (N,Z,Q,R)

52

Cartesian product
coordinate 49
definition 4
diagonal 52
factor 5
ordered pair 49
real number 12
set 25, 32
subset 43
theorem 2
tuple 50, 139, 140

52 37. Cartesian Products


37.1 Definition: Cartesian
product of two sets

Let A and B be sets. Ax B is


the set of all ordered pairs whose first
coordinate is an element of A
and whose second coordinate is an element
of B. Ax B is called the
Cartesian product of A and B (in that
order) .

37.1.1 Example if A = {1,2} and


B = {2,3,4} , then

AxB= {(1,2), (1,3), (1,4), (2,


2), (2, 3), (2, 4)}

and

B x A = | (2, 1), (2,2), (3,


1), (3,2), (4, 1), (4,2) j

37.1.2 Exercise Write out the


elements of {1,2} x {a, b} . (Answer on page 244.)

37.2 Theorem

If A is any set, then Ax0 = 0xA


= 0.

37.2.1 Exercise Prove Theorem


37.2.

37.2.2 Example R x R is often


called the “real plane” , since it consists of all
ordered pairs of real numbers,
and each ordered pair represents a point in the plane
once a coordinate system is
given. Graphs of straight lines and curves are subsets
of R x R. For example, the x-
axis is j(x,0) | x G r| and the parabola y = x 2

is | (x,y) | x € R A y = x 2
j , which could be written |(x,x 2 ) | x £ R j (recall the
discussion in Section 19.2).

37.3 Definition: diagonal

For any set A, the subset |


(a,a) | o £ a| of A x A of all pairs whose
two coordinates are the same is
called the diagonal of A , denoted A a ■
37.3.1 Worked Exercise Write
out the diagonal of {1,2} x {1,2}.

Answer {(1, 1), (2,2)} .

37.3.2 Example The diagonal Ar


of R x R is the 45-degree line from lower left
to upper right. It is the graph
of the equation y = x.

37.4 Cartesian products in


general

The notion of Cartesian product


can be generalized to more than two factors using
the idea of tuple.

53

37.5 Definition: Cartesian


product

Let Ai,A 2 ,... ,A n be sets —


in other words, let (Aj)j 6n be an n-tuple
of sets. Then A± x A 2 x • • •
x A n is the set

|(oi,a 2 ,... ,a n ) | (V*:n)


(aj G A { ) j (37.1)

of all n-tuples whose ith


coordinate lies in A{ .

37.5.1 Example The set R x Z x


R has triples as elements; it contains as an
element the ordered triple (n,—
2,3), but not, for example, (— 2, 7r, 3) .

37.5.2 Warning Observe that


RxNxR, (RxN)xR and R x (N x R) are three
different sets; in fact, any
two of them are disjoint. Of course, in an obvious sense
they all represent the same
data.

Cartesian product 52
coordinate 49
definition 4
disjoint 47
ordered triple 50
powerset 46
proper subset 45
relation 73
set 25, 32
subset 43
tuple 50, 139, 140
union 47

37.5.3 Example Consider the set

D = {(m,n) | m divides n}

where m and n are of type


integer. Thus (3,6), (—3,6) and (5,0) are elements of
D but not (3,5). D is not a
Cartesian product, although it is a (proper) subset of
the cartesian product Z x Z .
The point is that a pair in Ax B can have any element
of A as its first coordinate
and any element of B as its second coordinate, regardless
of what the first coordinate
is. In D what the second coordinate is depends on what
the first coordinate is.

A set such as D is a relation,


a concept discussed later.

37.6 Exercise set

Exercises 37.6.1 through 37.6.6


give “facts” which may or may not be correct for
all sets A, B and C. State
whether each “fact” is true for all sets A, B and C,
or false for some sets A, B or
C , and for those that are not true for all sets, give
examples of sets for which they
are false.

37.6.1 AxA = A. (Answer on page


244.)

37.6.2 Ax B = B x A.

37.6.3 Au{BxC) = {AuB)x{AuC).

37.6.4 An{BxC) = {AnB)x{AnC).

37.6.5 Ax(BxC) = (AxB)xC.

37.6.6 V{AxB)=V{A)xV{B).

37.7 Exercise set


The statements in problems
37.7.1 through 37.7.3 are true for all sets A, B and C ,
except that in some cases some
of the sets A , B and C have to be nonempty if the
statement is to be true for all
other sets named. Amend the statement in each case
so that it is true.

54

Cartesian powers 54
Cartesian product 52
Cartesian square 54
implication 35, 36
include 43
powerset 46
set 25, 32
singleton 34
tuple 50, 139, 140
union 47

37.7.1 For all sets A, B and


C , A x C = B x C =t- A = B . (Answer on page
244.)

37.7.2 For all sets A and B , A


x B = B x A => A = B .

37.7.3 For all sets A, B and


C , 4C B =t- (A x C) C (B x C) .

37.8 Cartesian product in


Mathematica

The dmfuncs .m package contains


the command CartesianProduct, which gives the
Cartesian product of a sequence
of sets. For example,

produces

CartesianProduct [{1 , 2} ,
{a,b, c} , {x,y}]
{{1, a, x>, {1, a, y>, {I, b,
x>, {1, b, y>, {1, c, x>, {1, c, y>,
{2, a, x>, {2, a, y>, {2, b,
x>, {2, b, y>, {2, c, x>, {2, c, y»

37.8.1 Exercise (Mathematica)


The command CartesianProduct mentioned
in 37.8 works on any lists, not
just sets (see 17.2, page 27). Write a precise descrip-
tion of the result given when
CartesianProduct is applied to a sequence of lists,
some of which contain repeated
entries.

37.9 Exponential notation

If all the sets in a Cartesian


product are the same, exponential notation is also used.
Thus A 2 = Ax A, A 3 = Ax Ax A,
and in general

A n = Ax Ax ■■■ x A

(n times). These are called


Cartesian powers of A ; in particular, A 2 is the
Cartesian square of A. This
notation is extended to 0 and 1 by setting A° = {()}
(the singleton set containing
the null tuple as an element) and A 1 = A.

37.9.1 Exercise

set:

Let

A = {1,2} and B = {3,4,5}.


Write all the elements of each

a)

A 0

f)
BxA

b)

A 1

g)

Ax AxB

c)

A 2

h)

Ax (AxB)

d)

A 3

i)

(AxB)uA

e)

AxB

j)

(Ax B)nA

(Answer on page 244.)

37.9.2 Exercise For each pair


of numbers ( m,n ) € {1,2, 3, 4, 5,6,7} x {1,2, 3, 4, 5, 6, 7},
state whether item m in the
first column is an element of the set in item n of the
second column. A = {1,3,7}, B =
{1,2, 3,4,5} .

55

1.

(3,5)

1. Ax A

Cartesian product 52

2.

(3,3)

2. A 3

diagonal 52

3.

(3,3,5)

3. Ax B

extension (of a

4.

{(3,5), (7,5)}

4. B x A

predicate) 27
intersection 47
5.

({3, 7}, {3, 5})

5. V(A x B)

powerset 46

6.

6. VA x VB

predicate 16

7.

(1,7,7)

7. B 2

real number 12

(Answer on page 244.)

set 25, 32
subset 43

38. Extensions of predicates


with more than one variable

In section 18.1, page 27, we


discussed the extension of a predicate containing one
variable; the extension is a
subset of the type set of the variable. For example, the
extension of u x < 5” (x real)
is the subset {x \ x < 5} of R.

38.1.1 Remark A predicate can


contain several occurrences of one variable. If
it contains no occurrences of
other variables, it is still said to contain one variable.
For example, “(x < 5) A (x >
1)” contains two occurrences of one variable, namely
x . On the other hand, “ (x — y
< 5) A (x + y > 1) ” contains two variables, x and y .

A predicate with more than one


variable, such as u x < y” ( x,y real), has an
extension which is a subset of
a Cartesian product of its variable types.

38.1.2 Example The extension of


“x < y” in R x R is

{{x,y) | x < y}

which is a subset of R x R .

38.1.3 Example The extension of


the predicate “x = x” in R is the subset R of
R, whereas the extension of the
predicate “x = y” in R x R is Ar , the diagonal
subset of R x R .

38.1.4 Worked Exercise Write


out the extension of the predicate “has the same
prime divisors as” in {2,3,4,
6} 2 .

Answer { (2, 2) , (3, 3) , (2,


4) , (4, 2) , (4, 4) , (6, 6) } .

38.1.5 Remark The Cartesian


product in which the extension of a predicate lies
is not uniquely determined. For
example, the predicate “x < y” has an extension
in the set R x R x R, namely
the subset j (x,y,z) \ x < y} . In this case, there is
no condition on the variable
z . There is a good reason for allowing this situation.
For example, the predicate “y <
z” also has an extension in R x R x R, namely
| (x,y,z) | y < zj. Looking at
it this way allows us to say that the extension of
“x<yAy<z” in RxRxR is the
intersection of the extensions of “x < y” and
“y < z”.
56

Cartesian product 52
character 93
codomain 56
coordinate 49
domain 56
extension (of a
predicate) 27
integer 3
predicate 16
real number 12
set 25, 32
specification 2
string 93, 167
tuple 50, 139, 140
type (of a vari-
able) 17
value 56, 57

By the way, we could have


regarded R x R x R as the set of tuples

\{y,z,x) | x,y,z £ r|

Then the extension of “x < y"


would be j (y,z,x) \ x < yj . Because of this sort of
thing, it pays to be careful to
describe exactly what set the extension of a predicate
lies in.

38.2 Exercise set

In Problems 38.2.1 through


38.2.4, describe explicitly the extensions of the predi-
cates in the given set; x, y
and z are real and n is an integer. Associate x,y,z
with coordinates in a tuple in
alphabetical order.

38.2.1 x > n, in R x N. (Answer


on page 244.)

38.2.2 x + y = x + l,inRxR.
(Answer on page 244.)

38.2.3 y = 1 , in R. (Answer on
page 244.)

38.2.4 x + y = z, in RxRxRxR.
(Answer on page 244.)

39. Functions

39.1 The concept of function

In analytic geometry or
calculus class you may have studied a real-valued function
such as G(x) = x 2 + 2x + 5 .
This function takes as input a real number and gives
a real number as value; for
example, the statement that G( 3) = 20 means that an
input of 3 gives an output of
20. It also means that the point (3,20) is on the
graph of the equation y =
G(x) .

The concept of function to be


studied here is more general than that example in
several ways. In the first
place, a function F can have one type of input and another
type of output. An example is
the function which gives the number of characters in
an English word: the input is a
string of characters, say ‘cat’, and the output is its
length, 3 in this case. Also,
the most general sort of function need not be given by
a formula the way G is. For
example, a price list is a function with input the name
of an item and output the price
of the item. The relationship between the name
and the price is rarely given
by a formula.

Here is the specification:

39.2 Specification: function

A function F is a mathematical
object which determines and is com-
pletely determined by the
following data:

F.l F has a domain, which is a


set and is denoted domF.

F.2 F has a codomain, which is


also a set and is denoted codF.

F.3 For each element a £ domF,


F has a value at a. This value is
completely determined by a and
F and must be an element of
codF. It is denoted by F(a) .
57

39.2.1 Warning This


specification for function is both complicated and subtle
and has conceptual traps. One
of the complications is that the concept of function
given here carries more
information with it than what is usually given in calculus
books. One of the traps is that
you may tend to think of a function in terms of a
formula for computing it,
whereas a major aspect of our specification is that what
a function is is independent of
how you compute it.

39.2.2 Usage The standard


notation F:A-^B communicates the information
that F is a function with
domain A and codomain B. A and B are sets; A
consists of exactly those data
which you can use as input to (you can “plug into” )
the function F , and every
value of F must lie in B . (Not every element of B has
to be a value.)

In the expression u F(a)” , a


is called the argument or independent variable
or input to F and F(a) is the
value or dependent variable or output. The
operation of finding F(a) given
F and a is called evaluation or application.

If F(a) = b, one may say U F


takes a to 6” or “a goes to b under F" .

It follows from the definition


that we have the following rule of inference:

F:A->B, aeA (- F(a) <E B (39.1)

39.2.3 Warning You should


distinguish between F , which is the name of the
function, and F(a), which is
the value of F at the input value a. Nevertheless, a
function is often referred to
as F(x) — a notation which has the value of telling
you what the notation for the
input variable is.

39.2.4 Usage Functions are also


called mappings, although in some texts the
word “mapping” is given a
special meaning.

39.3 Examples of functions


We give some simple examples of
functions to illustrate the basic idea, and then
after some more discussion and
terminology we will give more substantial examples.

39.3.1 Example The first


example is the function G : R — > R defined by G(x) =
x 2 + 2x + 5 , which was
discussed previously. Referring to it as G : R — > R specifies
that the domain and codomain
are both R.

39.3.2 Usage As is often the


case in analytic geometry and calculus texts, we
did not formally specify the
domain and codomain of G when we defined it at the
beginning of this section. In
such texts, the domain is often defined implicitly as the
set of all real numbers for
which the defining formula makes sense. For example, a
text might set S(x) = l/x,
leaving you to see that the domain is R — {0} . Normally
the codomain is not mentioned
at all; it may usually be assumed to be R. In this
text, on the other hand, every
function will always have an explicit domain and
codomain.

39.3.3 Example Here is an


example of a function with a finite domain and codo-
rnain. Let A = {1,2,3} and B =
{2,4, 5, 6}. Let F:A-^B be defined by requiring
that F(l) = 4 and F( 2) = F( 3)
= 5 .

application 57
argument 57
codomain 56
dependent vari-
able 57
domain 56
evaluation 57
finite 173
function 56
independent vari-
able 57
input 57
output 57
real number 12
rule of inference 24
set 25, 32
usage 2
value 56, 57
58

codomain 56
divisor 5
domain 56
finite 173
function 56
powerset 46
prime 10
set 25, 32

39.3.4 Example Let S be some


set of English words, for example the set of
words in a given dictionary.
Then the length of a word is a function L : S — > N . For
example, L(‘caf’) = 3 and L( l
abbadabbadoo ’) = 12. (This function in Mathematica
is StringLength. For example,
StringLength["cat"] returns 3.)

39.3.5 Example Let F: N — )• N


be defined by requiring that F( 0) = 0 and for
n > 0, F(n) is the rath prime
in order. Thus F(l) = 2, F( 2) = 3, F( 3) = 5, and
.F(IOO) = 541. (This function
is given by the word Prime in Mathematica.)

39.3.6 Remarks The preceding


examples illustrate several points:

a) You don’t have to give a


formula to give a function. In the case of Exam-
ple 39.3.3, we defined F by
giving its value explicitly at every element of the
domain. Of course, this is
possible only when the domain is a small finite set.

b) There must be a value F(x)


for every element x of the domain, but not every
element of the codomain has to
be a value of the function. Thus 4 is not a
value of the function in
39.3.5.

c) Different elements of the


domain can have the same value (different inputs
can give the same output). This
happens in Example 39.3.1 too; thus G(l) =
G(— 3) = 8.

39.3.7 Exercise Let A = {1, 2,


3} . Let F : A -> VTA be defined by requiring that
F(n) = {B G VA | n G B} . What
are F( 1) and F( 2)? (Answer on page 244.)
39.3.8 Exercise Let A be as in
the preceding exercise, and define G : A — > WA
by G(n) = {B G VA \ n ^ B} .
What are G(l) and G(2)?

39.3.9 Exercise Let F : Z — »


VZ be defined by requiring that F(n) be the set of
divisors of n. What are F( 0) ,
F(l), F( 6) and F(12)?

39.3.10 Exercise Give an


example of a function F : R — > R with the property

r is an integer if and only if


F(r) is not an integer

39.3.11 Exercise Let S be a set


and G:S -^VS a function. Let the subset A
of S be defined by

A = {x | x £ G(x)}

Show that there is no element x


G S for which G(x) = A.

39.4 Functions in Mathematica

In Mathematica, the name of the


function is followed by the input in square brackets.
For example, sinx is entered as
Sin[x] .

You can define your own


functions in Mathematica. The function G(x) = x 2 +
2x + 5 of Example 39.3.1 can be
defined by typing

g[x_] := x~2 + 2 x + 5 (39.2)

Then if you typed g [3] ,


Mathematica would return 20, and if you typed g [t] ,
Mathematica would return 5 + 2
t + t‘2. Comments:

59

a) All built-in Mathematica


functions, such as Sin, start with a capital letter.
It is customary for the user to
use lowercase names so as to avoid overwriting
the Mathematica definition of
some function. (You could define Sin to be
anything you want, but that
would be undesirable.) Thus there would be no
error message if you typed G
instead of g in (39.2), but it is not the Done
Thing.

b) On the left side of a


definition, the variable must be followed by an underline.
This is how Mathematica
distinguishes between a function and the value of a
function.

c) One normally writes := for


the equals sign in making a definition. There are
occasions when the ordinary
equals sign may be used, but a rule of thumb for
definitions is to use : =.

A function that is defined by


giving individual values instead of a formula can
be defined in Mathematica by
doing just that. For example, the function F in
Example 39.3.3 can be defined
by entering

codomain 56
domain 56
equivalent 40
function 56
theorem 2

F [1] := 4; F [2] := 5; F
[3] := 5 (39.3)

(When commands are strung


together with semicolons in this way, Mathematica
answers with the last value, 5
in this case. These commands could have been
entered on separate lines.)

Mathematica does not keep track


of the domain and codomain of the function.
If you try to evaluate the
function at an input for which it has not been defined,
you get back what you typed.
For example, if you had entered only the commands
in (39.3) and then typed F
[6] , Mathematica would return F [6] .

39.5 More about the input to a


function

Let’s look at the function G of


Example 39.3.1 again. We can calculate that G( 3) =
20. Since 1 + 2 = 3, it follows
that (7(1 + 2) = 20. Since \/9 = 3, it follows that
G(y/ 9) = 20. It is the element
x (here 3) of the domain (here R) that is being given
as input to G, not the name of
the element. It doesn’t matter how you represent
3, the value of G at 3 is still
20.

This is summed up by the


following theorem:

39.6 Theorem: The Substitution


Property

Let F : A—t B be any function,


and suppose that a G A and a' £ A. If
a = a' , then F(a) = F(a') .

The last sentence of


Specification 39.2 can be stated more precisely this way:

39.7 Theorem: How to tell if


functions are equal

If Fj : Aj — >■ Bj , (i = 1,2),
are two functions, then

(Fi = F 2 ) ^

60

codomain 56
domain 56
equivalence 40
function 56

39.7.2 Exercise Suppose F : A—$


B and G : B . What do you have to do to

prove that F / G?

39.7.3 Warning Since Formula


(39.4) is an equivalence, this means that the func-
tion S : R — > R for which S(x)
= x 2 is not the same as the function T : R — > R + for
which T (x) = x 2 . They have
the same domain and the same value at every element
of the domain, but they do not
have the same codomain. This distinction is often
not made in the literature. In
some theoretical contexts it is vital to make it, but
in others (for example
calculus) it makes no difference and is therefore quite rightly
ignored. In this text we are
purposely making all the distinctions made in a sizeable
fraction of the research
literature.

39.8 The abstract idea of


function

As was noted previously, the


specification given for functions says nothing about
the formula for the function.
The function G in Example 39.3.1 was defined by the
formula G(x) = x 2 + 2x + 5 ,
but the definition of the function called F in Exam-
ple 39.3.3 never mentioned a
formula.

Until late in the nineteenth


century, functions were usually thought of as defined
by formulas. However, problems
arose in the theory of Fourier analysis which made
mathematicians require a more
general notion of function. The definition of func-
tion given here is the modern
version of that more general concept.lt replaces the
algorithmic and dynamic idea of
a function as a way of computing an output value
given an input value by the
static, abstract concept of a function as having a domain,
a codomain, and a value lying
in the codomain for each element of the domain. Of
course, often a definition by
formula will give a function in this modern sense. How-
ever, there is no requirement
that a function be given by a formula.

The modern concept of function


has been obtained from the formula-based idea
by abstracting basic properties
the old concept had and using them as the basis of
the new definition. This
process of definition by abstracting properties is a major
tool in mathematics, and you
will see more examples of it later in the book (see
Chapter 51, for example).

The concept of function as a


formula never disappeared entirely, but was studied
mostly by logicians who
generalized it to the study of function-as-algorithm. (This
is an oversimplification of
history.) Of course, the study of algorithms is one of
the central topics of modern
computer science, so the notion of function-as-formula
(more generally, function-as-
algorithm) has achieved a new importance in recent
years.

Nevertheless, computer science


needs the abstract definition of function given
here. Functions such as sin may
be (and quite often are) programmed to look up
their values in a table instead
of calculating them by a formula, an arrangement
which gains speed at the
expense of using more memory.

39.7.1 Method

To show that two functions are


the same you have to show they have the
same domain, the same codomain
and for each element of the domain
they have the same value.

61

Cartesian product 52
coordinate 49
definition 4
domain 56
fact 1
function 56
graph (of a func-
tion) 61

implication 35, 36
ordered pair 49
single- valued 61
subset 43
usage 2

40.1.2 Example For the function


G of Example 39.3.1, the graph

r(G) = j(x,G(x)) | x € R j = |
(x,y) \ x G R A y = x 2 + 2x + 5|

which is a subset of R x R.
T(G) is of course what is usually called the graph of G
in analytic geometry — in this
case it is a parabola.

40.1.3 Example The graph of the


function F of Example 39.3.3 is

{(1,4), (2,5), (3,5)}


40.2 Properties of the graph of
a function

Using the notion of graph,


Specification 39.2 can be reworded as requiring the
following statements to be true
about a function F : A-^ B:

GS.l domF is exactly the set of


first coordinates of the graph, and

GS.2 For every aei, there is


exactly one element b of B such that (a, b) 6 F(F) .

40.2.1 Fact GS-2 implies that,


for all agi and b E B ,

^(a,6) € r(F) A (a,b') G T(F)^


=>• b = b ' (40.1)

40.2.2 Usage The requirement of


formula (40.1) is sometimes described by saying
that functions have to be
single- valued.

40.2.3 Warning Do not confuse


the property of being single- valued with the Sub-
stitution Property of Theorem
39.6, which in terms of the graph can be stated this
way: For all a & A and b £ B ,

40. The graph of a function

40.1 Definition: graph of a


function
The graph of a function F : A—$
B is the set

|(a,F(a)) | a G A j

of ordered pairs whose first


coordinates are all the elements of A with
the second coordinate in each
case being the value of F at the first
coordinate. The graph of F is
denoted by T(F)

40.1.1 Fact T(F) is necessarily


a subset of Ax B .

a,b) €T(F) A a = a') =>


(a',b)eT
(40.2)

62

Cartesian product 52
codomain 56
coordinate 49
functional prop-
erty 62
functional 62
function 56
graph (of a func-
tion) 61

implication 35, 36
include 43
opposite 62, 77, 220
ordered pair 49
usage 2

40.2.4 Remark When a function


goes from R to R the way the function G of
Example 39.3.1 does, its graph
can be drawn, and then the single- valued property
implies that a vertical line
will cross the graph only once. In general, you can’t draw
the graph of a function (for
example, the length function defined on words, as in
Example 39.3.4).

40.2.5 Remark Not every set of


ordered pairs can be the graph of a function. A
set P of ordered pairs is said
to be functional or to have the functional property
if

({a,b)£P A (a.i'Je?)

b = b'

(40.3)
Of course, Formula (40.1)
above says that the graph of a function is functional.
Conversely, if a set P of
ordered pairs is functional, then there are sets A and B
and a function F : B for
which T (F) = P . F is constructed this way:

FC.l A must be the set of


first coordinates of pairs in P .

FC.2 B can be any set


containing as elements all the second coordinates of pairs
in P.

FC.3 For each a £ A, define


F(a) = b, where (a, b) is the ordered pair in P with
a as first coordinate:
there is only one such by the functional property.

40.2.6 Exercise For A =


{1,2, 3, 4}, B = {3, 4,5,6} , which of these sets of ordered
pairs is the graph of a
function from A to B?

a) {(1,3), (2, 3), (3, 4),


(4, 6)}.

b) {(1,3), <2, 3), <4, 5),


<4, 6)}.

c) {(1,3), (2, 3), (4, 6)}.

d) {(1,3), (2, 4), (3, 5),


(4, 6)}.

(Answer on page 245.)

40.2.7 Exercise If P C A x
B , then the opposite of P is the set P op = {(6, a) \
(a,b) £ P | . Give examples
of:

a) a function F : A—t B for


which (T(F)) op is the graph of a function.

b) a function G : A—> B for


which (r(G)) op is not the graph of a function.

40.2.8 Exercise Create a


Mathematica command InGraphQ with the property
that the expression
InGraphQ [F , {x , y] } returns True if (. x,y ) &T(F) and False
otherwise.
40.2.9 Usage

a) In mathematical texts in
complex function theory, and in older texts in general,
functions are not always
assumed single- valued.

b) As you can see, part FD.


2 requires T(F) to have the functional property. In
texts which do not require
that a function’s codomain be specified, a function
is often defined simply as
a set of ordered pairs with the functional property.

63

40.3 Explicit definitions


of function

In many texts, the concept


of function is defined explicitly (as opposed to being
given a specification) by
some such definition as this: A function F is an ordered
triple (A,B,T(F)} for which
FD.l A and B are sets and
T(F) C A x B , and

FD.2 If a € A, then there


is exactly one ordered pair in T(F) whose first coordinate
is a.

41. Some important types of


functions

41.1.1 Identity function


For any set A, the identity function id a'-A-^t A is
the function that takes an
element to itself; in other words, for every element a £ A,
idyi (a) = a- Thus its
graph is the diagonal of Ax A (see 37.3).

41.1.2 Warning Do not


confuse the identity function with the concept of identity
for a predicate of Section
13.1.2, or with the concept of identity for a binary operation
of Section 45.

binary operation 67
codomain 56
constant function 63
coordinate 49
diagonal 52
domain 56
empty function 63
empty set 33
function 56
graph (of a func-
tion) 61

identity function 63
identity 72
include 43
inclusion function 63
ordered pair 49
ordered triple 50
take 57

tuple 50, 139, 140

41.1.3 Inclusion
function If A C B , then there is an inclusion function

inc :A—t B which takes


every element in A to itself regarded as an element of B .
In other words, inc(a)
= a for every element a £ A. Observe that the graph of inc
is the same as the
graph of idyi and they have the same domain, so that the only
difference between them
is what is considered the codomain ( A for idyi , B for the
inclusion of A in B ) .

41.1.4 Constant
function If A and B are nonempty sets and b is a specific
element of B , then the
constant function Cf,: A — > B is the function that takes
every element of A to
6; that is, Cb(a) = b for all a £ A. A constant function from
R to R has a horizontal
line as its graph.

41.1.5 Empty function


If A is any set, there is exactly one function E : 0 — > A.
Such a function is an
empty function. Its graph is empty, and it has no values.
“An identity function
does nothing. An empty function has nothing to do.”

41.1.6 Coordinate
function If A and B are sets, there are two coordinate
functions (or
projection functions) pi : A x B — > A and p 2 : A x B -> B . The
function p t takes an
element to its i th coordinate ( i = 1,2). Thus for a £ A and
b 6 B , pi (a, b) = a
and p 2 {a,b) = b. More generally, for any Cartesian product
ntiA there are n
coordinate functions; the ith one takes a tuple (ai,... ,a n ) to

cii .

41.1.7 Binary
operations The operation of adding two real numbers gives a
function

+ : R X R ->• R

which is an example of
a binary operation, treated in detail in Chapter 45.

64

anonymous nota-
tion 64

constant function 63
function 56
graph (of a func-
tion) 61

identity function 63
identity 72
inclusion function 63
lambda notation 64

41.1.8 Exercise For


each function F:A-^B, give F( 2) and F( 4).

a) A = B = R, F is the
identity function.

b) A = B = R, F = C 42
(the constant function).

c) A = R+,B = R, F is
the inclusion function.

(Answer on page 245.)

41.1.9 Exercise Give


the graphs of these functions. A = {1,2,3}, B = {2,3}.

a) id, 4 .

b) The inclusion of B
into A.

c) The inclusion of B
into Z .

d) C 3 :A-+B.

e) pi : Ax B A.

(Answer on page 245.)

42. Anonymous notation


for functions

The curly-brackets
notation for sets has the advantage that it allows you to refer to
a set without giving it
a name. For example, you can say, “{1,2,3} has three ele-
ments,” instead of,
“The set A whose elements are 1 , 2 and 3 has three elements.”
This is useful when you
only want to refer to it once or twice. A notation which
describes without
naming is called anonymous notation.

The notation we have


introduced for functions does not have that advantage.
When the two versions
of the squaring function were discussed, it was necessary to
call them S and T in
order to say anything about them.

42.1 Lambda notation

Two types of anonymous


notation for functions are used in mathematics. The older
one is called lambda
notation and is used mostly in logic and computer science.
To illustrate, the
squaring function would be described as “the function Xx.x 2 ”.
The format is: A, then
a letter which is the independent variable, then a period,
then a formula in terms
of the independent variable which gives the value of the
function. In the A-
notation, the variable is bound and so can be changed without
changing the function:
Xx.x 2 and A t.t 2 denote the same function.

42.1.1 Example The


function defined in Example 39.3.1 is Xx.(x 2 + 2x + 5) .

42.1.2 Example On a set


A, the identity function idyi is Xx.x.

65
42.2 Barred arrow
notation

The other type of


anonymous notation is the barred arrow notation, which has
in recent years gained
wide acceptance in pure mathematics and appears in some
texts on computer
science, too. In this notation, the squaring function would be
called the function x H
> x 2 : R — > R, and the function in Example 39.3.1 could be
written x +->• x 2 + 2x
+ 5 .

The barred arrow tells


you what an element of the domain is changed to by the
function. The straight
arrow goes from domain to codomain, the barred arrow from
element of the domain
to element of the codomain.

42.2.1 Example On a set


A , the identity function id^ is x H > x : A — > A .

42.2.2 Other notations


One would write Function [x,x"2] or #"2& in Mathe-
rnatica for x H > x 2
or Xx.x 2 . The # sign stands for the variable and the & sign at
the end indicates that
this is a function rather than an expression to evaluate. More
complicated examples
require parentheses; for example, x H > x 2 + 2x + 5 becomes

(#"2+2 #+5) &.

42.2.3 Exercise Write


the following functions using A notation and using barred
arrow notation. A and B
are any sets.

a) F : R — > R given by
F(x) = x 3 .

b) p\\ Ax B — >• A.

c) Addition on R.

(Answer on page 245.)

anonymous nota-
tion 64

barred arrow nota-


tion 65
characteristic func-
tion 65
codomain 56
constant function 63
definition 4
domain 56
even 5

extension (of a
predicate) 27
fact 1
function 56
identity function 63
identity 72
integer 3

lambda notation 64
predicate 16
subset 43

43. Predicates
determine functions

43.1 Definition:
characteristic function

Let A be a set. Any


subset B of A determines a characteristic
function : A -> {TRUE,
FALSE} defined by requiring that Xb ( x ) =
TRUE if x € B and Xb( x
) = FALSE if x i B.

43.1.1 Example If A =
{1,2, 3, 4} and B = {1,4} then Xb(1) = TRUE and
Xs(2) = FALSE.

43.1.2 Fact xjf is th e


constant function which is always FALSE, and Xa i s
constant TRUE.

43.1.3 Predicates as
characteristic functions Since the extension of a predi-
cate is a subset of its
data type, the truth value of a predicate is the characteristic
function of its
extension. For example, the statement “n is even” (about integers)
is TRUE if n is even
and FALSE otherwise, so that the value of the characteristic
function of the subset
E of Z consisting of the even integers is the truth value of
the predicate “n is
even”.
66

Cartesian product 52
characteristic func-
tion 65

constant function 63
definition 4
extension (of a
predicate) 27
function 56
graph (of a func-
tion) 61
integer 3
odd 5

predicate 16
subset 43

43.1.5 Exercise Suppose


that a predicate P regarded as the characteristic func-
tion of its extension
is a constant function. What can you say about PI

44. Sets of functions

As mathematical
entities, functions can be elements of sets; in fact the discovery of
function spaces, in
which functions are regarded as points in a space, was one of the
great advances of
mathematics.

44.1 Definition: D J ^

If A and B are sets,


the set of all functions F : A — >■ B is denoted B ^ .

44.1.1 Warning The


notation B ^ refers to the functions from A to 11, from the
exponent to the base.
It is easy to read this notation backward.

44.1.2 Remark Remark


97.1.5, page 139, and Theorem 122.3, page 188, explain
why the notation B ^ is
used.

44.1.3 Example The


function G of Example 39.3.1 is an element of the set R ,
and the function of
Example 39.3.3 is an element of the set

{2,4,5,6}{ 1,2,3 }
44.1.4 Example The
function + : R x R — > R is an element of R^ x ^ .

Predicates with more


than one variable similarly correspond to characteristic
functions of subsets of
Cartesian products. Thus the truth value of the statement
“ rn < n” (about
integers) is the characteristic function of the subset

| (m,n) | m < j

of Z x Z .

43.1.4 Exercise Give


the graphs of these functions. A = {1,2,3}, B = { 2,3}.

a) Xb : A ->•{ TRUE,
FALSE}.

b) The predicate “n is
odd” where n is an element of A, regarded as a function
to {TRUE, FALSE}.

c) + : B x B Z.

(Answer on page 245.)

67

44.1.5 Exercise Let A =


{1,2, 3,4,5} . For each item in the first column, state
which of the items in
the second column it is an element of.

a) id R 1) R R

b) the inclusion of A
in Z 2)

c) (1,2,1) 3) Rx Z x R

d) .t e- )• x 2 : R — >
R 4) (R+) R

(Answer on page 245.)

45. Binary operations


45.1 Definition: binary
operation

For any set S, a


function S x S — > S is called a binary operation on

5 .

binary operation 67
Cartesian product 52
codomain 56
complement 48
definition 4
divide 4
domain 56
function 56
identity 72
inclusion function 63
intersection 47
powerset 46
real number 12
right band 67
take 57

unary operation 67

45.1.1 Remark The


domain of a binary operation is the Cartesian square of
its codomain. Thus a
binary operation on a set S is an element of the function
set x ^ . i n
particular, a function G : Ax B — >• C is a binary operation only if
A = B = C.

45.1.2 Example The


function that takes (1,2) to 1, and (1,1), (2,1) and (2,2)
all to 2 is a binary
operation on the set {1,2}.

45.1.3 Example The


usual operations of addition, subtraction and multiplication
are binary operations
on the set R of real numbers. Thus addition is the function

(x, y) i-4 x + y : R x
R — > R

45.1.4 Example Division


is a function from R x (R — {0}) to R, and so does not
fit our definition of
binary operation. Restricted to the nonzero reals, however, it
is a function from R —
{0} x R — {0} to R — {0} (this says if you divide a nonzero
number by another one,
you get a nonzero number), and so is a binary operation
on R — {0} .

45.1.5 Example For any


set A, union and intersection are binary operations on
VA. This means that
each of union and intersection is a function from VA x VA
to VA (not from Ax A to
A).

45.1.6 Example For any


set A, define the binary operation P on A by requiring
that aPb = b for all a
and b in A . P is called the right band on A .

45.1.7 Unary operations


In the context of abstract algebra, a function from a
set A to A is called a
unary operation on A by analogy with the concept of
binary operation.

45.1.8 Example Taking


the complement of a set is a unary operation on a pow-
erset.

68

argument 57
binary operation 67
function 56
infix notation 68
negative integer 3
Polish notation 68
postfix notation 68
prefix notation 68
reverse Polish nota-
tion 68
take 57

45.1.9 Example The


function — : Z — >■ Z (similarly for R) that takes a number
r to its negative — r
is a unary operation on R. This is distinct from the binary
operation of
subtraction (m,n) i-4 m — n.
46. Fixes

46.1 Prefix notation

I have normally written


the name of the function to the left of the argument (input
value), thus: E(x).
This is called prefix notation for functions and is familiar
from analytic geometry
and calculus texts.

46.1.1 Parentheses
around the argument Trigonometric functions like sinx
are also written in
prefix notation, but it is customary to omit parentheses around
the argument. (Pascal
and many other computer languages require the parentheses,
however, and
Mathematica requires square brackets). Many mathematical writers
omit the parentheses in
other situations too, writing “Ex” instead of “E(x)”. It is
important not to
confuse evaluation written like this with multiplication.

46.2 Infix notation

Many common binary


operations are normally written between their two arguments,
“a + 6” instead of “+
(a,6)”. This is called infix notation and naturally applies
only to functions with
two arguments.

46.2.1 Example The


expression 3 — (5 + 2) is in infix notation. In prefix notation,
the same expression is
—(3, +(5,2)).

46.3 Postfix notation

Some authors write


functions on the right, for example “xE” or “(x)E” instead
of “E(x)”. This is
called postfix notation. This has real advantages which will
become apparent when we
look at composition in Chapter 98.

46.4 Polish notation

When binary operations


are written in either prefix or postfix notation, parentheses
are not necessary to
resolve ambiguities. In infix notation, for example, parentheses
are necessary to
distinguish between “a + 6*c” (which is the same as “a+ (b*c) n )
and “(a + 6)*c”. In
prefix notation, “a + 6*c” can be written “+ a * b c” and
u (a + b)*c ,, can be
written “* + a b c”. Note the use of spaces to separate
the items. This is
particularly important when multidigit constants are used: for
example 35 22 + in
postfix notation returns 57.

Writing functions of
two or more arguments using prefix notation and no paren-
theses is called Polish
notation after the eminent Polish logician Jan Lukasiewicz,
who invented the
notation in the 1920’s. Writing functions on the right which are
normally infixed,
without parentheses, is naturally called reverse Polish nota-
tion.

69

Most computer languages


use prefix and infix notation similar to that of ordinary
algebra. The language
Lisp uses prefix notation (with parentheses) and the various
dialects of Forth
characteristically use reverse Polish notation (no parentheses).
Either prefix or
postfix notation in a computer language makes it easier to write an
interpreter or compiler
for the language.

46.4.1 Example The


expression of Example 46.2.1 in prefix notation without
using parentheses is —
3 + 5 2 . In postfix notation it is 3 5 2 + — .

46.4.2 Example a + b +
c in reverse Polish notation can be written either as a b +
c+orasa6c + +.

46.4.3 Exercise Write


(35 + 22) (6 + 5) in reverse Polish notation. Use * for
multiplication. (Answer
on page 245.)

46.4.4 Exercise Write b


2 — 4aci in reverse Polish notation. Use * for multiplica-
tion and don’t use
exponents.

Fix notation in
Mathematica Mathematica gives the user control over whether
a function is written
in infix notation or not. For example, we remarked in Sec-
tion 14.4 that in
Mathematica one writes Xor[p,q] for the expression pXORg.
However, by putting
tildes before and after the name of a function in Mathematica,
you can use it as an
infix; thus you can write p ~Xor~ q instead of for Xor [p,q] .

A function F can be
used in postfix form by prefixing it with //. For example,
one can write Sqrt [2]
or 2 // Sqrt.

47. More about binary


operations

47.1 Notation

In discussing binary
operations in general, we will refer to an operation A on a
set A ; thus A : A x A
— > A. This operation will be used in infix notation, the way
addition and
multiplication are normally written, so that we write aAb for A (a,b) .
Using an unfamiliar
symbol like ‘A’ avoids the sneaky way familiar symbols like
“+” cause you to fall
into habits acquired by long practice in algebra (for example,
assuming commutativity)
that may not be appropriate for a given situation.

47.1.1 Warning Don’t


confuse A , representing a binary operation, with the diag-
onal A^ C Ax A defined
in Definition 37.3, page 52.

47.1.2 Multiplication
tables We will sometimes give a binary operation A on a
small finite set by
means of a multiplication table: For example, here is a binary
operation on the set
{a,b,c}.

b
c

binary operation 67
Cartesian product 52
diagonal 52
finite 173
function 56
include 43
infix notation 68
multiplication
table 69

postfix notation 68
prefix notation 68

70
associative 70
binary operation
definition 4
function 56
intersection 47
multiplication
table 69
postfix notation
powerset 46
prefix notation 68
real number 12
right band 67
union 47

67

The value of x Ay is in
the row marked x and the column marked y . This means
for example that a A b
= c and c A a = a .

47.1.3 Example The


binary operation of Example 45.1.2 is

68

2
2

47.1.4 Exercise

{1,2,3}.

Give the
multiplication table for the right band on the set

47.1.5 Exercise
Give the multiplication table for the operation of union on the
powerset of
{1,2,3}.

48. Associativity

48.1 Definition:
associative

A binary operation
A is associative if for any elements x, y, z of A,

x A (y Az) = (x Ay)
Az (48.1)

48.1.1 Remark In
ordinary functional notation (prefix notation), the definition
of associative says
A(x,A (y,z) = A(A (x,y,),z)) . In postfix notation: x y A z A =
x y z A A.

48.1.2 Example The


usual operations of addition and multiplication are asso-
ciative, but not
subtraction; for example, 3 — (5 — 7) / (3 — 5) — 7. The opera-
tion given in
47.1.2 is not associative; for example, (a A a) A c = b A c = a, but
a A (a Ac) = a Aa =
b.

48.1.3 Example For


any nonempty set X , union and intersection are associative
binary operations
in VX .

48.1.4 Example For


real numbers r and s , let max : II x II — > R and min : R x
R — > R be the
functions defined by: max(r, s ) is the larger of r and s and min(r, s)
the smaller. If r =
s then max(r, s) = min(r, s) = r = s. These are both associative
binary operations
on the set R of real numbers.

48.1.5 Exercise
Prove that for any set S , union is an associative binary operation
on VS. (Answer on
page 245.)

48.1.6 Exercise
Prove that for any set S, intersection is an associative binary
operation on VS .

48.1.7 Exercise
Show that the right band operation on any set A is associative.

71

48.1.8 Exercise
Find a binary operation A on some set A with the property
that, for some
element a € A,

(a A a) A a) / a A
(a A a)

48.1.9 Exercise Is
the binary operation A given by this table associative? Give
reasons for your
answer.

a
a

associative 70
binary operation 67
commutative 71
definition 4
General Associative
Law 71
max 70
subset 43

48.1.10 Exercise
Prove that max: R x R — > R is associative (see Example 48.1.4).

48.2 The general


associative law

If A is an
associative operation on A, then it is associative in a more general sense,
in that it
satisfies the General Associative Law: Any two meaningful products
involving A and
ai,a2,--,a n (names of elements of A) in that order denote the
same element of A.

48.2.1 Example If a
A (bA c) = (aAb)Ac, then all five meaningful ways of writ-
ing the product of
four elements are the same:

a A (b A (c A d)) =
aA((bAc)Ad) = (aAb)A(cAd)

=
((aAb)Ac)Ad=(aA(bAc))Ad

49. Commutativity

49.1 Definition:
commutative
A binary operation
A on a set A is commutative if for all x,y £ A,
x Ay = y Ax.

49.1.1 Example The


operations of addition and multiplication, but not subtrac-
tion, are
commutative operations on R.

49.1.2 Example The


binary operations mentioned in Examples 48.1.2, 48.1.3 and
48.1.4 are
commutative.

49.1.3 Exercise Let


C be a set. Define the binary operation A for all subsets A
and B of C by

AAB = (A(J B) — (An


B)

a) Show that A is
commutative.

b) Show that AAB =


(A — B) U (B — A) .

72

associative 70
binary operation
commutative 71
definition 4
even 5

identity function
identity 72
integer 3
max 70
powerset 46
right band 67
unity 72

49.1.4 The General


Commutative Law There is a general commutative law
67 analogous to the
general associative law: It says that if A is commutative and
associative, then
the names a\,...,a n in an expression a\ A a 2 A ... A a n can be
rearranged in any
way without changing the value of the expression. We will not
prove that law
here.

Do

50. Identities

50.1 Definition:
identity

If A is a binary
operation on a set A , an element e is a unity or
identity for A if
for all x G A,

xAe = eAx = x
(50.1)

50.1.1 Warning
Don’t confuse the concept of identity for a binary operation with
the concept of an
identity function in 41.1.1, page 63. These are two different ideas,
but there is a
relationship between them (see 98.2.3, page 141).

50.1.2 Example The


binary operation of Example 45.1.2 has no identity.

50.1.3 Example The


number 1 is an identity for the binary operation of multi-
plication on R ,
and 0 is an identity for + .

50.1.4 Exercise
Which of these binary operations (i) is associative, (ii) is com-
mutative, (iii) has
an identity?

A
a

c
c

( 1 ) ( 2 )

(Answer on page
245.)

50.1.5 Exercise
Show that the right band operation on a set with more than one
element does not
have an identity.

50.1.6 Example The


binary operation of multiplication on the set of even integers
is associative and
commutative, but it has no identity.

50.1.7 Exercise Let


S be any set. What is the identity element for the binary
operation of union
on VS 1 (Answer on page 245.)

50.1.8 Exercise Let


S be any set. What is the identity element for the binary
operation of
intersection on V SI

50.1.9 Exercise
Does max :RxR-^R have an identity? What about max : R + x
R + — > R + defined
the same way?

The basic fact


about identities is:
73

50.2 Theorem:
Uniqueness theorem for identities

If A is a binary
operation on a set A with identity e, then e is the only
identity for A .

Proof This follows


immediately from Definition 50.1: if e and / are both identi-
ties, then e = eAf
because / is an identity, and eAf = f because e is an identity.

50.2.1 Exercise
Give a rule of inference that allows one to conclude that a certain
object is an
identity for a binary operation A .

50.2.2 Exercise
(hard) Find all the binary operations on the set {a, b} , and
state whether each
one is associative, is commutative, and has an identity element.

51. Relations

The mathematical
concept of relation is an abstraction of the properties of relations
such as “=” and “<”
in much the same way as the modern concept of function was
abstracted from the
concrete functions considered in freshman calculus, as described
in Section 39.8.

associative 70
binary operation 67
Cartesian product
52
commutative 71
definition 4
equivalence 40
equivalent 40
fact 1
function 56
identity 72
predicate 16
proof 4
relation 73
rule of inference
24
subset 43
theorem 2
type (of a vari-
able) 17
usage 2

51.1 Definition:
binary relation

A binary relation a
from a set A to a set B is a subset of A x B . If
(a, b) G a , then
one writes a ab.

51.1.1 Remark Any


subset of Ax B for any sets A and B is a binary relation
from A to B.

51.1.2 Fact
Definition 51.1 gives the following equivalence, which describes two
different ways of
writing the same thing:

a ab 44 (a, 6) G a
(51.1)

51.1.3 Usage A
relation corresponds to a predicate with two variables, one of
type A and the
other of type B : the predicate is true if a ab (that is, if (a, b) G a)
and false
otherwise. Logic texts often define a relation to be a predicate of this type,
but the point of
view taken here (that a relation is a set of ordered pairs) is most
common in
mathematics and computer science.

51.1.4 Example Let


A = {1,2, 3, 6} and B = {1,2, 3, 4, 5}. Then

a= | <2, 2), (1,5),


(1,3), (2,5), <2, 1) j

is a binary
relation from A to B . For this definition, we know 1 cc 5 and 2 a 1 but
it is not true that
1 a 2 .

74
Cartesian product
coordinate func-
tion 63
definition 4
digraph 74, 218
divide 4

empty relation 74
finite 173
function 56
include 43
ordered pair 49
powerset 46
relation 73
subset 43
total relation 74

52 51.1.5 Exercise
Write all ordered pairs in the relation from A to B:

a) A = {1,2,3} , B
= {1,3,5} . a is “/”.

b) A = {2, 3, 5,
7}, B = {1,2,3,4,5,6,7,8,9,10}, a is “divides”.

c) A = {0,1, 2, 3},
B = {1,2,3}, a is “divides”.

(Answer on page
245.)

51.2 Picturing
relations

A relation on a
small finite set can be exhibited by drawing dots representing the
elements of A and B
and an arrow from x to y if and only if x ay . Here is the
relation in Example
51.1.4 exhibited in this way:

1 2

v v

3 5

Such a picture is
called the digraph representing the relation. Digraphs are studied
in depth in
Chapters 144 and 151.
51.2.1 Example Two
not very interesting binary relations from A to B are the
empty relation 0 C
Ax B and the total relation Ax B . If E denotes the
empty relation,
then aE6 is false for any a £ A and b G B , and if T denotes the
total relation, aT6
is true for any a € A and b £ B .

51.2.2 Example In a
university, the pairs of the form (student, class) where the
student is
registered for the class form a relation from the set of students to the set
of classes.

51.3 Definition:
Rcl(A,i?)

The set of all


relations from A to B is denoted by Rel(A,R).

51.3.1 Remark By
Definition 51.1, Rel(A,R) is the same thing as the powerset
V(A x B) ; the only
difference is in point of view.

51.4 The
projections from a relation

A relation a from A
to B is a subset of Ax B by definition, so there are func-
tions Pi : a — >■ A
, P2 : a — >■ B , which are the restrictions of the coordinate func-
tioncoordinate
(projection) functions (see 41.1.6, page 63) from Ax B to A and to
B.

51.4.1 Example If a
is defined as in Example 51.1.4, then : a — > {1,2, 3, 6}
and p2 : a ► {1,2,
3, 4, 5} . In particular, p“((l,5)) = 1 .

75

52. Relations on a
single set
52.1 Definition:
relation on a set

If ct is a relation
from A to A for some set A, then a is a subset of
Ax A. In that case,
a is called a relation on A.

52.1.1 Example “>”


is a relation on R; one element of it is (5,3).

52.1.2 Example A
particular relation that any set A has on it is the diagonal
A a ; A a = {(a, a)
\ a E A}. A a is simply the equals relation on A. Don’t confuse
this with the use
of A to denote an arbitrary binary operation as in Chapter 45.

52.1.3 Exercise Let


A = {1, 2, 3,4} . Write out all the ordered pairs in the relation
R on A if

a) aRb o a < b

b) aRb a = b

c) aR6 6 = 3.

d) aR6 a and 6 are


both odd.

(Answer on page
245.)

Cartesian product
52
codomain 56
definition 4
diagonal 52
domain 56
equivalent 40
functional prop-
erty 62

functional relation
75
function 56
graph (of a func-
tion) 61

implication 35, 36
odd 5

ordered pair 49
relation on 75
relation 73
subset 43
usage 2

53. Relations and


functions

53.1 Functional
relations

The graph T(F) of a


function F : A — > B is a binary relation from A to B . It
relates a E A to 6
£ B precisely when 6 = F(a ) . Of course, not any relation can be
the graph of a
function: to be the graph of a function, a binary relation a from A
to B must have the
functional property described in 40.2:

(a a b and a a b')
=4> b = b' (53.1)

A relation
satisfying Equation (53.1) is called a functional relation.

This requirement
can fail because there are ordered pairs (a, 6) and (a,b r ) in a
with 6 yf b' . Even
if it is satisfied, a may not be the graph of a function from A to
B , since there may
be elements a E A for which there is no ordered pair (a, 6) E a .
However, a
functional relation in Rel(A,L>) is always the graph of a function whose
domain is some
subset of A .

53.1.1 Usage For


some authors a function is simply a functional relation. For
them, the domain
and codomain are not part of the definition.

53.1.2 Exercise
Which of these are functional relations?

a) {(1,3), (2,3),
(3,4)}.

b) {(1,1), (1,2),
(2, 3)}.

c) {(x,y/x) | igR}.

d) {(y/x,x) | iGR}.

e) {(y/x,x) j x G R
+ } .

(Answer on page
245.)
76

definition 4
empty set 33
equivalent 40
function 56
integer 3
ordered pair 49
powerset 46
relation 73
singleton 34
subset 43

As we have seen,
the concept of relation from A to B is a generalization of the
concept of function
from A to B . In general, for a given a & A there may be no
ordered pairs ( a,b
) E a or there may be more than one. Another way of saying this
is that for a given
element a E A, there is a set {b E B \ (a,b) E a}. For a to be
a function from A
to B , each such set must be a singleton. In general, a relation
associates a
(possibly empty) subset of B to each element of A.

53.2 Definition:
relation as function to powerset

If a is a relation
from A to B, let a*:A-^-VB denote the function
defined by a* (a) =
{6 E B \ (a, b) E a} .

53.2.1 Remark
Definition 53.2 gives us a process that constructs a function from
A to the powerset
of B for each relation from A to B . For any a E A and b E B ,

b E a* (a) 44 aab

53.2.2 Example For


the relation a of Example 51.1.4, we have a*(l) = {3,5},
a*(2) = {1,2,5} and
a*( 3) =0.

53.2.3 Exercise
Write the function a* : A -^VB corresponding to the relation in
Problem 51.1.5(a).
(Answer on page 245.)

Conversely, if we
have a function F : A— >VB , we can construct a relation:

53.3 Definition:
relation induced by a function to a pow-
erset

Given F : A — >
VB , the relation ap from A to B is defined by aapb if
and only if b E
F(a) .

53.3.1 Remark In
the preceding definition, it makes sense to talk about b E F(a ) ,
because F(a) is a
subset of B.

53.3.2 Example Let


F : {1,2,3} — »• "P({1,2,3}) be defined by F(1) = {1,2},
F{ 2) = {2} and
F(3) = 0. Then a F = {( 1,1), (1,2), (2,2)}.

53.3.3 Exercise A
function F : Z — y PZ has F{ 1) = {3,4}, F{ 2) = {1,3,4},
F(— 666) = {0}, and
F(n) = 0 for all other integers n. List the ordered pairs
in the
corresponding relation a.p on Z. (Answer on page 245.)

53.3.4 Exercise Let


F be the function of Problem 39.3.9, page 58. List the
ordered pairs in ay
that have 6 as first element.

77

54. Operations on
relations

54.1 Union and


intersection
Since relations
from A to B are subsets of A x B , all the usual set operations such
as union and
intersection can be performed on them.

54.1.1 Example On
R, the union of Ar and “<” is (of course!) “< ”, and the
intersection of “<”
and “>” is Ar. These statements translate into the obviously
true statements

r<s»(r<sVr = s)

and

(r<sAr>s)<S>r = s

definition 4
equivalence 40
equivalent 40
fact 1
function 56
include 43
intersection 47
near 77

opposite 62, 77,


220
powerset 46
reflexive 77
relation 73
subset 43
union 47

54.2 Definition:
opposite

The opposite of a
relation a £ Rel(A,.E>) is the relation a op E Rel(.B, A)
defined by a op = j
(6, a) | (a, b) E aj.

54.2.1 Fact This


definition gives an equivalence

ba op a aab
It follows that a i
— > a op : Rel(A,H) — >• Rel(H, A) is a function.

54.2.2 Example On R
the opposite of “>” is “<” and the opposite of “<” is
Of course, for any
set A, the opposite of Aq is Aq .

55. Reflexive
relations

55.1 Definition:
reflexive

Let a be a binary
relation on 1. a is reflexive if a a a for every
element a E A.

55.1.1 Example Aq
is reflexive on any set A, and the relation “< ” is reflexive
on R.

55.1.2 Example On
the powerset of any set the relation “C” is reflexive.

55.1.3 Example The


relation “<” is not reflexive on R, and neither is the rela-
tion S “is the
sister of” on the set W of all women, since no one is the sister of
herself.

55.1.4 Example
Another important type of reflexive relation are the relations

like xM y \x — y\ <
0.1 , defined on R. “A7” stands for “near”. The choice of 0.1

as a criterion for
nearness is not important; what is important is that it is a fixed
number.

The relations S and


M will be used several times below in examples.

78

definition 4
divide 4
equivalent 40
fact 1

implication 35, 36
nearness relation
77
reflexive 77
relation 73
sister relation 77
symmetric 78, 232
vacuous 37

55.1.5 Fact Let a


be a relation on a set A. Then a is reflexive if and only if
Aq C a.

55.1.6 Remark The


statement that a relation a defined on a set A is reflexive
depends on both a
and A. For example, the relation

{( 1 , 1 ), ( 1 , 2
), ( 2 , 2 )}

is reflexive on
{1,2} but not on {1,2,3}.

55.1.7 Warning It
is wrong to say that the relation a of 55.1.6 is “reflexive at 1
but not at 3”.
Reflexivity and irreflexivity are properties of the relation and the
set it is defined
on, not of particular elements of the set on which the relation is
defined. This
comment also applies to the other properties of relations discussed in
this section.

55.1.8 Fact The


digraph of a reflexive relation must have a loop on every node.

55.1.9 Exercise
Which of these relations is reflexive?

a) a = {(1, 1),
(2,2), (3,3)} on {1,2,3}.

b) a = {(1,1), (2,
2), (3, 3)} on N.

c) “divides” on Z.

d) a on R defined
by xay x 2 = y 2 .
(Answer on page
245.)

56. Symmetric
relations

56.1 Definition:
symmetric

A relation a on a
set A is symmetric if for all a, b £ A,

a ab => baa

56.1.1 Example The


equals relation on any set is symmetric, and so is the near-
ness relation J\f
(see Example 55.1.4). The sister relation S (Example 55.1.2) is
not symmetric on
the set of all people, but its restriction to the set of all women is
symmetric.

56.1.2 Warning It
is important to understand the precise meaning of the defini-
tion of symmetric.
It is given in the form of an implication: a ab =t- baa. Thus
(a) it could be
vacuously true (the empty relation is symmetric!) and (b) it does
not assert that a
ab for any particular elements a and b : that a is symmetric does
not mean (a ab) A
(6 a a) .

56.1.3 Remark The


digraph of a symmetric relation has the property that
between two
distinct nodes there must either be two arrows, one going each way, or
no arrow at all.

79

56.1.4 Exercise
Which of these relations is symmetric?

a) a = {<1,2), <2,
3), <1, 3), <2, 1), <4, 1)} on {1,2, 3, 4}.

b) a = {<1, 1), <2,


2), <3,3)} on N.
c) The empty
relation on N.

d) “is the brother


of” on the set of all people.

(Answer on page
245.)

56.1.5 Exercise
Show that if a relation a on a set A is not symmetric, then A
has at least two
distinct elements.

antisymmetric 79
definition 4
divide 4

implication 35, 36
include 43
nearness relation
77
negation 22
powerset 46
relation 73
symmetric 78, 232
vacuous 37

57. Antisymmetric
relations

57.1 Definition:
antisymmetric

A relation a on a
set A is antisymmetric if for all a,b G A,

(a a b Aba a) =4- a
= b

57.1.1 Warning
Antisymmetry is not the negation of symmetry; there are rela-
tions such as A
which are both symmetric and antisymmetric and others such as
“divides” on Z
which are neither symmetric nor antisymmetric.

57.1.2 Exercise
Prove that on any set A, Aa is antisymmetric.

57.1.3 Exercise
Prove that on Z, “divides” is neither symmetric nor antisym-
metric.

57.1.4 Remark The


digraph of an antisymmetric relation may not have arrows
going both ways
between two distinct nodes.

57.1.5 Example
Antisymmetry is typical of many order relations: for example,
the relations “<”
and “<” on R are antisymmetric. Orderings are covered in
Chapter 134.

57.1.6 Example The


inclusion relation on the powerset of a set is antisymmetric.
This says that for
any sets A and B , A C B and B C A together imply A = B .

57.1.7 Example The


relation “<” is vacuously antisymmetric, and on any set
S , A s is both
symmetric and antisymmetric.

57.1.8 Example The


nearness relation J\f is not antisymmetric; for example,
0.25A70.3 and
0.3A70.25, but 0.25/0.3.

80

antisymmetric 79
definition 4
equivalent 40
implication 35, 36
include 43
nearness relation
77
relation 73
sister relation 77
symmetric 78, 232
transitive 80, 227
vacuous 37

57.1.9 Exercise
Which of these relations is antisymmetric?

a) a = {<1,2), <2,
3), <3, 1), <2, 2}} on N.

b) “divides” on N.
c) > on R.

d) “is the brother


of” on the set of all people.

(Answer on page
245.)

57.1.10 Exercise
Show that if a relation a on a set A is not antisymmetric, then
A has at least two
distinct elements.

57.1.11 Exercise
Let a be a relation on a set A. Prove that a is antisymmetric
if and only if afla
op C Aq. (Another problem like this is Problem 84.2.5, page 124.)

58. Transitive
relations

58.1
Definition: transitive

A relation a on
A is transitive if for all elements a, b and c of A,

(a a b Abac) =>
aac

58.1.1 Example
All the relations Aq , “<”, “<” and “C” are obviously tran-
sitive. That
equals is transitive is equivalent to the statement from high-school
geometry that
two things equal to the same thing are equal to each other.

58.1.2 Example
The sister relation S is not transitive, not even on the set of
all women. Thus
Agatha may be Bertha’s sister, whence Bertha is Agatha’s sister,
but Agatha is
not her own sister. This illustrates the general principle that when a
definition uses
different letters to denote things, they don’t have to denote different
things. In the
definition of transitivity, a, b and c may be but don’t have to be
different.

58.1.3 Example
Nearness relations are not transitive.

58.1.4 Example
Let A be the set {{1,2}, {3}, 2, 6, {{1,3}, {1,2}}} The relation
“G” on A is not
transitive, since 2 £ {1,2} and {1,2} £ {{1,3}, {1,2}}, but 2 ^
{{1,3}, {1,2}}.

58.1.5 Warning
Transitivity is defined by an implication and can be vacuously
true. In fact,
all the properties so far have been defined by implications except
reflexivity.
And indeed the empty relation is symmetric, antisymmetric and transi-
tive!

81

58.1.6 Remark
The digraph of a transitive relation must have the property that
every “path of
length two” , such as

must be
completed to a triangle, like this:

antisymmetric
79
definition 4
equivalent 40
irreflexive 81
negation 22
reflexive 77
relation 73
symmetric 78,
232
transitive 80,
227

Paths are
covered formally in Section 149.

58.1.7 Exercise
Give an example of a nonempty, symmetric, transitive relation
on the set
{1,2} that is not reflexive.

58.1.8 Exercise
State and prove a theorem similar to Problem 56.1.5 for non-
transitive
relations.

58.1.9 Exercise
Let the relation R be defined on the set {x £ R | 0 < x < 1} by

xRy ■&3t(x + t
= y and 0 < t < 1)

Is R
transitive?

58.1.10
Exercise (hard) If possible, give examples of relations on the set {1,2, 3}
which have
every possible combination of the properties reflexive, symmetric, anti-
symmetric and
transitive and their negations. (HINT: There are 14 possible com-
binations and
two impossible ones.)

59. Irreflexive
relations

59.1
Definition: irreflexive

A relation a is
irreflexive if a a a is false for every a € A.

59.1.1 Example
The “<” relation on R is irreflexive.

59.1.2 Warning
Irreflexive is not the negation of reflexive: a relation might be
neither
reflexive nor irreflexive, such as for example the relation

a = {(1,1),
(1,2), (2, 2)}

on {1,2,3}.

82

antisymmetric
79
definition 4
divide 4
div 82

equivalent 40
integer 3
irreflexive 81
mod 82, 204
positive 3
reflexive 77
relation 73
remainder 83
symmetric 78,
232
transitive 80,
227

(d) (e) (/)

(Answer on page
245.)

59.1.4 Exercise
List the properties (reflexive, symmetric, antisymmetric, transi-
tive, and
irreflexive) of each relation.

a) “not equals”
on R.

b) x a y 44 x 2
= y 2 on R

c) x a y ^ x =
—y on R

d) x a y 44 x <
y 2 on R

e) “divides” on
N

f) “leaves the
same remainder when divided by 3” on N

g) {(1,1),
(2,3), (3,2), (3,4)} on {1,2, 3, 4}

(Answer on page
245.)

59.1.5 Exercise
Let /? be an irreflexive, antisymmetric relation on a set S. Show
that at most
one of the statements u ai3b ” and “6/3a” holds for any pair of elements
a,b of S.

60. Quotient
and remainder
Let m and n be
positive integers with n / 0 . If you divide n into m you get a
quotient and a
remainder; for example, if you divide 4 into 14 you get a quotient 3
and a remainder
2 . We will write the quotient when m is divided by n as m div n
and the
remainder as mnrodn, so that 14 div 4 = 3 and 14 mod 4 = 2. The basis
for the formal
definition given below is the property that 14 = 3x4 + 2.

The
following formal definition allows m and n to be negative as well as positive.
This has
surprising consequences discussed in Section 61.3.

59.1.3
Exercise List the properties (reflexive, symmetric, antisymmetric, transi-
tive, and
irreflexive) of the relations given by each picture.

83

60.1
Definition: quotient and remainder

Let m and n
be integers. Then q = mdivn and r = mmodn if and
only if q
and r are integers that satisfy both the following equations:
Q.l m = qn
+ r, and
Q.2 0 < r <
\n\ .

If q =
mdivn, then q is the quotient (of integers) when m is divided
by n . If r
= m mod n , then r is the remainder when m is divided by

n.

definition
4
div 82
integer 3
mod 82, 204
quotient
(of inte-
gers) 83
remainder
83

60.1.1
Remarks

a) It
follows from the definition that the equation

m =
(mdivn)n + (mmodn) (60.1)

is always
true for n / 0 .

b) On the
other hand, if n = 0, Q.2 cannot be true no matter what r is. In other
words,
“mdivO” and “mmodO” are not defined for any integer m.

60.1.2
Exercise Find the quotient (of integers) and remainder when m is divided
by n:

a) m = 2 ,
n = 4 .

b) m = 0, n
= 4.

c) m = 24,
n = 12.

d) rn = 37,
n = 12.

(Answer on
page 245.)

60.1.3
Warning For q to be ?ndivn and r to be mmodn, both Q.l and Q.2
must be
true. For example, 14 = 2 x 4 + 6 (so Q.l is satisfied with q = 2 and r = 6),
but 14 mod
4 / 6 because Q.2 is not satisfied.

60.1.4
Exercise Suppose that a and b leave the same remainder when divided
by m. Show
that a — b is divisible by m. (Answer on page 245.)

60.1.5
Exercise Suppose that a — b is divisible by m. Show that a and b leave
the same
remainder when divided by m.
60.1.6
Exercise Suppose that adivm = 6divm. Show that \a — b\<\m\.

60.1.7
Exercise Is the converse of Exercise 60.1.6 true? That is, if \a — b\ < \m \ ,
must it be
true that arnodm = b mod rri ?

The
following theorem is what mathematicians call an “existence and uniqueness”
theorem for
quotient and remainder.

84

divide 4
div 82
function 56
integer 3
mod 82, 204
negative
integer 3
nonnegative
integer 3
proof 4

quotient
(of inte-
gers) 83
remainder
83
theorem 2

60.2
Theorem: Existence and Uniqueness Theorem for
quotient
and remainder

For given
integers rn and n with n / 0 , there is exactly one pair of
integers q
and r satisfying the requirements of Definition 60.1.

60 . 2.1
Remark This theorem says that when jj/ 0 there is a quotient and a
remainder,
i.e. , there is a pair of numbers q and r satisfying Q.l and Q.2, and that
there is is
only one such pair.
60 . 2.2
Worked Exercise Suppose that m = 3n + 5 and n > 7 . What is mdivn?
Answer m
divn = 3. The fact that m = 3n + 5 and n > 7 (hence n > 5) means
that q = 3
and r = 5 satisfy the requirements of Definition 60.1.

60 . 2.3
Exercise Suppose a, b, m . and n are integers with m and n nonnegative
such that m
= (a + l)n + b + 2 and m div n = a. Show that b is negative. (Answer
on page
245.)

60 . 2.4
Exercise Suppose n > 0, 0 < s < n and n\s. Show that s = 0. (Answer
on page
246.)

There is a
connection between these ideas and the idea of “divides” from Defini-
tion 4.1
(page 4):

60.3
Theorem

If n 7 ^ 0
and rn mod n = 0 , then n\m.

Proof If
mmodn = 0, then by Q.l, m = (mdivn)n, so by Definition 4.1 (using
mdivn for
q), n divides m.

60.4 Mod
and div in Mathematica

To compute
mdivn in Mathematica, you type Quotient [m,n] , and to compute
mmodn, you
type Mod[m,n], You can if you wish place either of these function
names
between the inputs surrounded with tildes: m "Quotient" n is the same as
Quotient
[m,n] , and m "Mod" n is the same as Mod[m,n] .

60.5 Proof
of uniqueness

We will
prove that the quotient and remainder exist in Section 104.3.2, page 156.
It is
worthwhile to see the proof that the quotient and remainder are unique, since
it shows
how it is forced by Definition 60.1.

Suppose m =
qn + r = q'n + r' and both pairs (q,r) and ( q',r '} satisfy Q.2. We
must show
that the two ordered pairs are the same, that is, that q = q’ and r = r'.

By Q.2 we
have 0 < r < \n\ and 0 < r' < |n|. Since r and r' are between 0
and \n\ on
the number line, the distance between them, which is |r — r'\ , must also
be less
than n. A little algebra shows that

\r — r'\ =
| q' — q | |n|

It then
follows from Definition 4.1, page 4, that | r — r'\ is divisible by |n| . But a
non-
negative
integer less than |n| which is divisible by \n\ must be 0 (Exercise 60.2.4).

85

So r = r
' . Since qn + r = q'n + r ' , it must be that q = q ' , too. So there can be only
one pair of
numbers q and r satisfying Q.l and Q.2.

This proof
uses the following method.

60.5.1
Method

To prove
that an object that satisfies a certain condition is unique,
assume
there are two objects A and A! that satisfy the condition and
show that A
= A' .

characterize 85
div 82
integer 3
mod 82, 204
quotient
(of inte-
gers) 83
remainder
83
well-
defined 85
60.5.2
Exercise Use Definition 60.1 and Theorem 60.2 to prove that when 37 is
divided by
5, the quotient is 7 and the remainder is 2. (Answer on page 246.)

60.5.3
Exercise Use Definition 60.1 and Theorem 60.2 to prove that 115 div 37 =
3.

60.5.4
Exercise Suppose that fn = 36q + 40 . What is m mod 36? (Answer on
page 246.)

60.5.5
Exercise Prove that if q, m and n are integers and 0 <m — qn< \n\,
then q = m
div n .

60.5.6
Exercise Show that if a and b are positive integers and amod4 = 6mod
4 = 3, then
ab mod 4 = 1.

60.5.7
Exercise Prove that for any integer c, c 2 mod3 is either 0 or 1.

60.6 More
about definitions

Observe
that Definition 60.1 defines “mdivn” and “mrnodn” without telling you
how to
compute them. Normally, you would calculate them using long division, but
the
uniqueness Theorem 60.2 tells you that if you can find them some other way
you know
you have the right ones. A mathematician would say that Theorem 60.2
ensures
that the quotient (of integers) m divn and the remainder mrnodn are well-
defined, or
that Definition 60.1 and Theorem 60.2 work together to characterize
the
quotient and remainder.

It is
typical of definitions in abstract mathematics that they characterize a con-
cept
without telling you how to compute it. The technique of separating the two
ideas,
“what is it?” and “how do you compute it?”, is fundamental in mathematics.
86

decimal 12,
93
definition
4
digit 93
div 82
fact 1
floor 86

greatest
integer 86
integer 3
mod 82, 204
quotient
(of inte-
gers) 83
real number
12
rule of
inference 24
trunc 86
usage 2

61. Trunc
and Floor

Many
computer languages have one or both of two operators trunc and floor which
are related
to div and are confusingly similar. Both are applied to real numbers.

61.1
Definition: floor

Floor (r),
or the greatest integer in r, is the largest integer n with
the
property n < r .

61.1.1
Example floor(3.1415) = 3, floor(7/8) =0, and floor(— 4.3) = —5.

61.1.2
Usage Floor(r) is denoted by |_rj in modern texts, or by [r] in older ones.

61.1.3
Exercise State a rule of inference for floor(?’) . (Answer on page 246.)
61.2
Definition: trunc

Trunc (r)
is obtained from r by expressing r in decimal notation and
dropping
all digits after the decimal point.

61.2.1 Fact
The function trunc satisfies the equation

trunc(r)

floor(r) r
> 0 or r an integer
floor(r) +
1 r < 0 and not an integer

61.2.2
Example trunc(— 4.3) = —4, but floor(— 4.3) = —5. On the other hand,
trunc(— 4)
= floor(— 4) = —4, and if r is any positive real number, trunc(r) =
floor(r) .

61.2.3
Exercise Find trunc(x') and floor(x) for

a) x = 7/5.

b) x =
-7/5.

c) x = — 7.

d) x = —
6.7.

(Answer on
page 246.)

61.3
Quotients and remainders for negative integers

61.3.1
Example According to Definition 60.1, — 17div5 = — 4 and — 17mod5 =
3, because
—17 = (—4) -5 + 3 and 0 < 3 < 5. In other words, the quotient is
floor(—
17/5) , but not trunc(— 17/5) .
87

61.3.2
Usage A computer language which has an integer division (typically called
div or
“/” ) which gives this answer for the quotient is said to have floored division.

Mathenratica has floored division.

Other
possibilities include allowing the remainder in Definition 60.1 to be nega-
tive when m
is negative. This results in the quotient being trunc instead of floor,
and, when
implemented in a computer language, is called centered division. That
is how many
implementations of Pascal behave. When n is negative the situation
also allows
several possibilities (depending on whether m is negative or not).

In this
book, integer division means floored division, so that it conforms to
Definition
60.1.

62. Unique
factorization for integers

62.1 The
Fundamental Theorem of Arithmetic

It is a
fact, called The Fundamental Theorem of Arithmetic, that a given
positive
integer m> 1 has a unique factorization into a product of positive primes.
Thus 12 = 2
x 2 x 3, 111 = 3 x 37, and so on. The factorization of a prime is that
prime
itself: thus the prime factorization of 5 is 5. The Fundamental Theorem of
Arithmetic
is proved in a series of problems in Chapter 103 as an illustration of the
proof
techniques discussed there.

The
factorization into primes is unique in the sense that different prime factor-
izations
differ only in the order they are written.
Here is the
formal statement:

62.2
Theorem

Let m be an
integer greater than 1 . Then for some integer n > 1 there
is a unique
list of primes p\,p 2 ,... ,p n and a unique list of integers
h,k
2 ,... ,k n such that
FT.l pi <
pi + i for 1 < i < n.

FT. 2 m =
p\ x p 2 2 ■ ■ -Pn 1 ■

62.2.1
Example

12 = 2x2x3
= 2x3x2 = 3x2x2

Theorem
62.2 specifically gives 12 = 2 2 x 3 1 . Here n = 2, p\ = 2, p 2 = 3, k\ = 2
and k 2 =
l.

62.2.2
Exercise Give the prime factorizations of 30, 35, 36, 37 and 38.
(Answer on
page 246.)

62.3
Definition: exponent of a prime in an integer

The largest
power of a prime p which divides a positive integer n is the
exponent of
p in n and is denoted e p (n) .

62.3.1
Example The exponent of 2 in 24 is 3; in other words, e2(24) = 3. You
can check
that e 37 (lll) = 1 and e 37 ( 110 ) = 0.

centered
division 87
definition
4
divide 4
div 82
exponent 87
floored
division 87
floor 86

Fundamental
Theo-
rem of
Arith-
metic 87
integer 3
negative
integer 3
positive
integer 3
prime 10
quotient
(of inte-
gers) 83
remainder
83
theorem 2
trunc 86
usage 2

88

coordinate
49
definition
4
divide 4
divisor 5
exponent 87
GCD 88
greatest
common
divisor 88
integer 3

least
common multi-
ple 88

nonnegative
integer 3
positive
integer 3
prime 10
theorem 2

62.3.2
Exercise Find the exponent of each of the primes 3, 7 and 37 in the
integers
98, 99, 100, 111, 1332, and 1369. (Answer on page 246.)

The fact
that the prime factorization is unique implies the following theorem:

62.4
Theorem

Let m and n
be positive integers. If m\n and p is a prime, then
e p (m) <e
p (n). Conversely, if for every prime p, e p (m) <e p (n), then
m\n.

62.5 Prime
factorization in Mathematica

Factorlnteger is the Mathematica command for finding the factors of an integer.


The answer
is given as a list of pairs; the first coordinate in each pair is a prime and
the second
coordinate is the exponent of the prime in the number being factored.
Thus if you
type Factorlnteger [360] , the answer will be {{2, 3}, {3, 2 }, {5, 1}},
meaning
that 360 = 2 3 • 3 2 • 5 .

62.5.1
Exercise Factor all the two-digit positive integers that begin with 9.
(Answer on
page 246.)

62.5.2
Exercise Show that for every positive integer k, there is an integer n that
has exactly
k positive divisors.

62.5.3
Exercise (hard) Prove Theorem 62.4.

62.5.4
Exercise (discussion) Type Factorlnteger [6/7] in Mathematica.
Explain the
answer you get. Should the name “Factorlnteger” be changed to
some other
phrase?

63. The GCD


63.1
Definition: greatest common divisor

The
greatest common divisor or GCD of two nonnegative integers
m and n is
0 if m = n = 0 ; otherwise the GCD is the largest number
which
divides both of them.

63.2
Definition: least common multiple

The least
common multiple (LCM) of two nonnegative integers m
and n is 0
if either m or n is 0; otherwise it is the smallest positive
integer
which both m . and n divide.

63.2.1
Example It follows from the definition that GCD(0,0) = 0, GCD(0,4) =
GCD(4,0)
=4, GCD(16,24) = 8, and GCD(5,6) = 1. Similarly, LCM(0,0) = 0,
LCM(1, 1) =
1, LCM(8,12) = 24 and LCM(5,6) =30.

89

63.2.2
Exercise Find GCD(12,12), GCD(12,13), GCD(12,14), GCD(12,24),
and also
find the LCM’s of the same pairs of numbers. (Answer on page 246.)

63.2.3
Exercise Compute GCD(48,72) and LCM(48,72).

63.2.4
Exercise If m and n are positive integers and d = GCD(m,n) , must
GCD (m/d,n)
= 1? Explain your answer. (Answer on page 246.)

63.2.5
Exercise Let A = {1, 2, 3,4} . Write out all the ordered pairs in the relation
a on A
where a is defined by: aab 44 GCD (a, 6) = 1. (Answer on page 246.)

63.2.6
Exercise Let a be the relation on Z defined by aab 44 GCD(a,6) = 1.
Determine
which of these properties a satisfies: Reflexive, symmetric, transitive,

antisymmetric.

63.2.7
Usage Some texts call the GCD the Greatest Common Factor (GCF).

63.2.8
Remark In general, GCD(0,m) = GCD(m,0) = m for any nonnegative
integer m.
Note that Definition 63.1 defined GCD(0,0) as a special case. This
is
necessary because every integer divides 0, so there is no largest integer that
divides 0.
This awkward detail occurs because our definition is in a certain sense
not the
best definition. (See Corollary 64.2 below.)

63.3
Definition: relatively prime

If GCD(m,n)
= 1, then m and n are relatively prime.

63.3.1
Example 5 and 6 are relatively prime, but 74 and 111 are not relatively
prime since
their GCD is 37.

63.3.2
Exercise Show that for any integer n, n and n+1 are relatively prime.
(Answer on
page 246.)

63.3.3
Exercise

a) Show
that if n + 1 distinct integers are chosen from the set {1,2, .. . ,2n} , then
two of them
are relatively prime.

b) Show
that there is a way to choose n integers from {1,2,... ,2n} so that no
two
different ones are relatively prime.

63.3.4
Warning The property “relatively prime” concerns two integers. It makes
no sense to
speak of a single integer as being “relatively prime” .
63.4
Definition: lowest terms

A rational
number m/n is in lowest terms (see Definition 7.3, page 11)
if m and n
are relatively prime.

63.4.1
Exercise Prove that if m/n and r/s are rational numbers represented in
lowest
terms and m/n = r/s, then \m\ = \r\ and |n| = |s| .

definition 4
divide
4

equivalent 40
GCD 88
integer
3
lowest
terms 11

nonnegative integer 3
ordered
pair 49

positive integer 3

relation 73

relatively prime 89
usage 2

90

Cartesian product 52

commutative 71

corollary 1
divide
4
exponent 87

Fundamental Theo-
rem of
Arith-
metic
87
GCD 88
integer
3
lowest
terms 11

nonnegative integer 3

positive integer 3
prime
10

relatively prime 89
theorem
2

64.
Properties of the GCD

If in >
1 and n > 1 , and you know the prime factorizations of both of them, the
GCD and
LCM can be calculated using the following theorem, in which e p (m)
denotes
the exponent of p in m (Definition 62.3), min(r, s) denotes the smaller of r
and s
and max(r, s) the larger.

64.1
Theorem

Let p
be a prime and m and n positive integers. Then
e p
(GCD(m,n)) = min(e p (m),e p (n))

and

e p
(LCM(m,n)) = max(e p (m),e p (n))

64.1.1
Example 60 = 2 2 x 3 x 5 and 72 = 2 3 x 3 2 . Their GCD is 12 = 2 2 x 3, in
which 2
occurs min(2,3) times, 3 occurs min(l,2) times, and 5 occurs min(l,0)
times.
Their LCM is 360 = 2 3 x 3 2 x 5.
64.2
Corollary

Let m
and n he nonnegative integers. GCD(m,n) is the unique non-

negative integer with these properties:

a)
GCD(m,n) divides both m and n.

b) Any
integer e which divides both m and n must divide
GCD
(m,n) .

64.2.1
Remark The property of GCD given in this corollary is often taken as the

definition of GCD. Note that no special consideration has to be given to the case
m = n =
0 .

64.2.2
Exercise Prove Corollary 64.2. (This corollary can be proved without
using
the Fundamental Theorem of Arithmetic. See Exercise 88.3.8, page 130.)
(Answer
on page 246.)

64.2.3
Exercise Use Theorems 62.4 and 64.1 to prove these facts about the GCD
and the
LCM:

a)
GCD(m,n)LCM(m,ri) = mn for any positive integers m and n.

b) If m
and n are relatively prime, then LCM(m,n) =mn.

64.2.4
Exercise Prove that if d = GCD (m,n), then m/d and n/d are relatively
prime.
(Answer on page 246.)

64.2.5
Exercise Prove that every rational number has a representation in lowest
terms.

64.2.6
Exercise Prove that GCD is commutative: for all integers m and n,
GCD(m,
n) = GCD(n, m) .
91

64.2.7
Exercise Prove that GCD is associative:

GCD((GCD (k,m),n) = GCD(fc,GCD(m,n))

Hint:
Use Theorem 64.1 and the fact that the smallest of the numbers x, y and z
is

min(x,min(y,z)) = min(min(a;,y),,z) = va.m(x,y,z)

64.2.8
Exercise (Mathematica)

a) Use
Mathematica to determine which ordered pairs ( a,b ) of integers, with
a € {1,
. . . , 10} , b £ {1, . . . , 10} , have the property that the sequence a + b,2a +

b, . . . , 10a + b contains a prime.

b) Let
(C) be the statement:

associative 70

commutative 71

definition 4
divide
4

function 56
GCD 88
integer
3
ordered
pair 49

predicate 16
prime
10

There
is an integer k > 0 for which ak + b is prime.
(The
integer k does not have to be less than or equal to 10.) Based on
the
results, formulate a predicate P(a,b) such that the condition (C) implies
P(a,b).
The predicate P should not mention k.

c)
Prove that (C) implies P(a,b).

Note:
Define a function by typing t [a_ , b_] : = Table [a k + b , {k , 1 , 10}] (notice
the
spacing and the underlines). Then if you type, for example, t[3,5], you will
get
{8,11,14,17,20,23,26,29, 32,35}. If L is a list, Select [L,PrimeQ] produces
a list
of primes occurring in L.

64.3
Extensions of the definition of GCD

GCD is
often defined for all integers, so that GCD(m,n) is GCD(|m| , |n|) . For

example, GCD(— 6,4) = GCD(6,— 4) = GCD(— 6,— 4) = 2. With this extended

definition, GCD is an associative and commutative binary operation on Z (Sec-


tion
143.2.1). Associativity means it is unambiguous to talk about the GCD of
more
than two integers. In fact, we can define that directly:

64.4
Definition: generalized GCD

Let
ni , ri 2 ,...,nfc be integers. Then GCD(rai, . . . T rik) is the largest
integer
that divides all the numbers |ni| , |ri 2 1 , ■ • ■ ,\rik\-

64.4.1
Example GCD(4,6, -8, 12) = 2.

64.4.2
Remarks

a)
Similar remarks can be made about the LCM.

b)
These functions are implemented in Mathematica using the same names. For

example, GCD [4 , 6 , -8 , 12] returns 2.


92

divide
4
div 82

Euclidean algo-
rithm
92
GCD 88
integer
3

nonnegative integer 3
proof 4

remainder 83
theorem
2

65.
Euclid’s Algorithm

Theorem
64.1 is fine for finding the GCD or LCM of two numbers when you know
their
prime factorization. Unfortunately, the known algorithms for finding the prime

factorization are slow for large numbers. There is another, more efficient method
for
finding the GCD of two numbers which does not require knowledge of the prime

factorization. It is based on this theorem:

65.1 Theorem: Euclid’s Algorithm

For
all nonnegative integers m and n :

EA.l GCD(m,0)=m and GCD(0,n)=n.

EA.2 Let r be the remainder when m is divided by n. Then


GCD(m,n) = GCD(n,r)

Proof Both parts of Theorem 65.1 follow from Definition 6.1, page 10. EA.l

follows because every integer divides 0 (Theorem 5.1(2)), so that if m/ 0, then

largest integer dividing m and 0 is the same as the largest integer dividing m,

which of course is m.

To
prove EA.2, suppose d is an integer that divides both m and n. Since
r =
m — qn . where q = m div n , it follows from Theorem 5.4, page 8, that d divides
r.
Thus d divides both n and r.

Now
suppose e divides both n and r . Since m = qn + r, it follows that e divides
m.
Thus e divides both m and n.

In
the preceding two paragraphs, I have shown that m and n have the same

common divisors as n and r. It follows that m and n have the same greatest

common divisor as n and r, in other words GCD(m,n) = GCD(n,?’).

65.1.1 How to compute the GCD Theorem 65.1 provides a computational

process for determining the GCD . This process is the Euclidean algorithm. The

process always terminates because every time EA.2 is used, the integers involved
are
replaced by smaller ones (because of Definition 60.1(Q.2), page 83) until one of

them becomes 0 and EA.l applies.

65.1.2 Example

GCD(164,48) = GCD(48,20) = GCD(20,8) = GCD(8,4) = GCD(4,0) = 4

65.2 Pascal program for Euclid’s algorithm

A
fragment of a Pascal program implementing the Euclidean algorithm is given

formally in Program 65.1.


93

{M>0 , N>0 , K=M, L=N}

while N <> 0 do

begin

rem : = M mod N ;

M := N;

N := rem;

end;

{M=GCD(K,L)}

decimal 12, 93

integer 3

positive integer 3

specification 2

string 93, 167

Program 65.1: Pascal Program for GCD

66. Bases for representing integers

66.1 Characters and strings

The number of states in the United States of America is an integer. In the usual

notation, that integer is written ‘50’.


In this section, we discuss other, related ways of expressing integers which are

useful in applications to computer science. In doing this it is important to


distinguish

between numerals like ‘5’ and ‘0’ and the integers they represent. In particular,
the

sequence of numerals ‘50’ represents the integer which is the number of states in
the

USA, but it is not the same thing as that integer.

Numerals, as well as letters of the alphabet and punctuation marks, are char-

acters. Characters are a type of data, distinct from integers or other numerical

types. In order to distinguish between a character like ‘5’ and the number 5 we put

characters which we are discussing in single quotes. Pascal has a data type CHAR

of which numerals and letters of the alphabet are subtypes. Single quotes are used

in Pascal as we use them.

66.2 Specification: string

A sequence of characters, such as ‘50’ or ‘cat’, is also a type of data

called a string.

66.2.1 Remarks

a) Strings will be discussed from a theoretical point of view in Chapter 109.

b) In this book we put strings in single quotes when we discuss them. Thus ‘cat’

is a string of characters whereas “cat” is an English word (and a cat is an

animal!).

66.3 Bases

The decimal notation we usually use expresses an integer as a string formed of the

numerals ‘O’, ‘1’, ... ,‘9’. These numerals are the decimal digits. The word
“digit”

is often used for the integers they represent, as well. The notation is based on
the

fact that any positive integer can be expressed as a sum of numbers, each of which

is the value of a digit times a power of ten. Thus

258 = 2 x 10 2 + 5 x 10 1 + 8 x 10° .

94

base 94

decimal 12, 93

definition 4

digit 93

integer 3

least significant

digit 94

more significant 94

most significant

digit 94

nonnegative integer 3

octal notation 94

radix 94

The expression ‘258’ gives you the digits multiplying each power of 10 in decreas-

ing order, the rightmost numeral giving the digit which multiplies 1 = 10° .

Any integer greater than 1 can be used instead of 10 in an analogous way to


express integers. The integer which is used is the base or radix of the notation.
In

octal notation, for example, the base is 8, and the octal digits are ‘O’,
‘1’, ... , ‘7’.

For example,

258 = 4 x 8 2 + 0 x 8 1 + 2 x 8°

so the number represented by ‘258’ in decimal notation is represented in octal

notation by ‘402’ .

Here is the general definition for the representation of an integer in base b.

66.4 Definition: base

If n and b are nonnegative integers and b > 1 , then the expression

dm d m — 1 d m — 2 •••dido’ (66.1)

represents n in base b notation if for each i , d* is a symbol (base- b

digit) representing the integer n . L ,

n = n m b m + n m -ib m ~ l 4 f n 0 b° (66.2)

and for all i ,

0 < rii < b — 1

(66.3)

66.4.1 Remarks

a) We will say more about the symbols d* below. For bases b < 10 these symbols
are normally the usual decimal digits,

do = ‘O’, di = ‘l’,...,d 9 = ‘9’

as illustrated in the preceding discussion.

b) Efficient ways of determining the base- b representation of some integer are

discussed in Chapter 68. Note that you can do the exercises in this section

without knowing how to find the base- 6 representation of an integer — all you

need to know is its definition.

66.4.2 Notation When necessary, we will use the base as a subscript to make

it clear which base is being used. Thus 258io = 402s , meaning that the number

represented by ‘258’ in base 10 is represented by ‘402’ in base 8.

66.5 Definition: significance

The digit d,; is more significant than dj if i> j. Thus, if a number

n is represented by ‘d m d m _i . . .dido’, then do is the least significant

digit and, if d m does not denote 0, it is the most significant digit.

66.5.1 Example The least significant digit in 258io is 8 and the most significant

is 2.

95

66.5.2 Remark For a given b and n, the following theorem says that the rep-

resentation given by definition 66.4 is unique, except for the choice of the
symbols
representing the rii . We will take this theorem as known.

66.6 Theorem

If n and b are positive integers with b > 1 , then there is only one

sequence no,ni,... ,n m of integers for which n m / 0 and formulas (66.2)

and (66.3) are true.

66.6.1 Worked Exercise Prove that the base 4 representation of 365 is 11231.

Answer 365 = 1 • 4 4 + 1 • 4 3 + 2 • 4 2 + 3 • 4 1 + 1 • 4° , and 1,2,3 are all


less than 4 , so

the result follows from Theorem 66.6.

Note that in this answer we merely showed that 11231 fit the definition. That

is all that is necessary. Of course, if you are not given the digits as you were in
this

problem, you need some way of calculating them. We will describe ways of doing

that in Chapter 68.

66.6.2 Exercise Prove that the base 8 representation of 365 is 555.

66.6.3 Exercise Prove that if an integer n is represented by • • • d\ in

base b, then ‘c? TO d m _i • • • g?iO’ represent bn in base b notation. (Answer on


page

246.)

66.6.4 Exercise Suppose b is an integer greater than 1 and suppose n is an

integer such that the base b representation of n is 352. Prove using only the

definition of representation to base b that the base b representation of b 2 n + 1


is

35201.

66.7 Specific bases


66.7.1 Base 2 The digits for base 2 are ‘O’ and ‘1’ and are called bits. Base 2

notation is called binary notation.

66.7.2 Bases larger than 10 For bases b< 10, the usual numerals are used,

as mentioned before. A problem arises for bases bigger than 10: you need single

symbols for the integers 10, 11, .... Standard practice is to use the letters of
the

alphabet (lowercase here, uppercase in many texts): ‘a’ denotes 10, ‘b’ denotes 11,

and so on. This allows bases up through 36.

66.7.3 Base 16 Base 16 (giving hexadecimal notation) is very commonly used

in computing. For example, 95io is 5fi@, and 266io is hexadecimal lOaig (read

this “one zero a”, not “ten a”!) In texts in which decimal and nondecimal bases are

mixed, the numbers expressed nondecimally are often preceded or followed by some

symbol; for example, many authors write $10a or HlOa to indicate 266io expressed

hexadecimally.

alphabet 93, 167

base 94

binary notation 95

decimal 12, 93

digit 93

hexadecimal nota-

tion 95

hexadecimal 95

integer 3

positive integer 3

theorem 2
96

base 94

decimal 12, 93

digit 93

integer 3

least significant

digit 94

nonnegative integer 3

positive integer 3

prime 10

realizations 96

66.8 About representations

(This continues the discussion of representations in Section 10.2 and Remark


17.1.3.)

It is important to distinguish between the (abstract) integer and any


representation

of it. The number of states in the U.S.A is represented as ‘50’ in decimal


notation,

as ‘110010’ in binary, and as a pattern of electrical charges in in a computer.


These

are all representations or realizations of the abstract integer. (The word


“realiza-

tion” here has a technical meaning, roughly made real or made concrete.) All the

representations are matters of convention, in other words, are based on agreement

rather than intrinsic properties. Moreover, no one representation is more fundamen-

tal or correct than another, although one may be more familiar or more convenient

than another.
There is also a distinction to be made between properties of an integer and

properties of the representation of an integer. For example, being prime is a


property

of the integer; whether it is written in decimal or binary is irrelevant. Whether


its

least significant digit is 0, on the other hand, is a property of the


representation:

the number of states in the USA written in base 10 ends in ‘O’, but in base 3 it
ends

in ‘2’.

66.8.1 Exercise Suppose b is an integer greater than 1, a is an integer dividing

b, and n is an integer. When n is written in base b, how do you tell from the
digits

of n whether n is divisible by a? Prove that your answer is correct.

66.8.2 Exercise Would Theorem 66.6 still be true if the requirement that 0 <

rii < b — 1 for all i were replaced by the requirement that the n t be nonnegative?

66.8.3 Exercise (Mathematica) A positive integer is a repunit if all its decimal

digits are 1 .

a) Use Mathematica to determine which of the repunits up to a billion are divis-

ible by 3 .

b) Based on the results of part (a), formulate a conjecture as to which repunits

are divisible by 3 . The conjecture should apply to all repunits, not just those

less than a billion.

c) Prove the conjecture.

66.8.4 Exercise (discussion) Some computer languages (FORTH is an example)

have a built-in integer variable BASE. Whatever integer you set BASE to will be
used

as the base for all numbers output. How would you discover the current value of

BASE in such a language? (Assume you print the value of a variable X by writing

PRINT (X)).

97

67. Algorithms and bases

Among the first algorithms of any complexity that most people learn as children are

the algorithms for adding, subtracting, multiplying and dividing integers written
in

decimal notation. In medieval times, the word “algorithm” referred specifically to

these processes.

67.1 Addition

The usual algorithm for addition you learned in grade school works for numbers in

other bases than 10 as well. The only difference is that you have to use a
different

addition table for the digits.

67.1.1 Example To add 95a and b87 in hexadecimal you write them one above

the other:

95a

+b87

14el

Here is a detailed description of how this is done, all in base 16.

• Calculate a+7 = 11m, with a carry of 1 since 11m > 10m- (Pronounce 10m
as “one-zero”, not “ten”, since it denotes sixteen, and similarly for 11m which

denotes seventeen. By the way, the easiest way to figure out what a + 7 is is to

count on your fingers!)

• Then add 5 and 8 and get d (not 13!) and the carry makes e. e < 10m so there

is no carry.

• Finally, 9 + b = 14m-

So the answer is 14e lm • The whole process is carried out in hexadecimal without

any conversion to decimal notation.

67.1.2 Addition in binary The addition table for binary notation is especially

simple: 0 + 0 = 0 without carry, l + 0 = 0+ l = l without carry, and 1 + 1 = 0 with

carry.

67.2 Multiplication

The multiplication algorithm similarly carries over to other bases. Normally in a

multiplication like

346 (multiplicand)

X527 (multiplier)

2422

6920 (partial products)

173000

182342 (product)

you produce successive partial products, and then you add them. The partial prod-

uct resulting from multiplying by the ith digit of the multiplier is


base 94

decimal 12, 93

digit 93

hexadecimal nota-

tion 95

integer 3

digit x multiplicand x 10*

98

base 94

digit 93

hexadecimal nota

tion 95

67.2.2 Example With trailing zeroes suppressed:

1101

X1101

1101

1101

1101
10101001

67.2.3 Exercise Perform these additions and multiplications in binary.

a) 110001 b) 1011101 c) 10011 d) 11100

+ 101111 +1110101 XIOlOl X11001

(Answer on page 246.)

67.2.4 Exercise Perform these additions in hexadecimal:

a) 9ae b) 389 c) feed

+b77 +777 +dad

(Answer on page 246.)

67.2.5 Exercise Show that in adding two numbers in base b, the carry is never

more than 1 , and in multiplying in base b , the carry is never more than b — 2.

67.2.6 Exercise (discussion) Because subtracting two numbers using pencil and

paper is essentially a solitary endeavor, most people are not aware that there are

two different algorithms taught in different public school systems. Most American

states’ school systems teach one algorithm (Georgia used to be an exception), and

many European countries teach another one. Ask friends from different parts of the

world to subtract 365 from 723 while you watch, explaining each step, and see if

you detect anyone doing it differently from the way you do it.

(Most people are taught in grade school to suppress the zeroes to the right of the

multiplying digit.)

67.2.1 Binary multiplication Multiplication in binary has a drastic simplifica-

tion. In binary notation, the only digits are 0, which causes a missing line, and
1,

which involves only shifting the top number. So multiplying one number by another
in binary consists merely of shifting the first number once for each 1 in the
second

number and adding.

99

68. Computing integers to different bases

68.1 Representing an integer

68.1.1 Remark Given a nonnegative integer n and a base b, the most significant

nonzero digit of n when it is represented in base b is the quotient when n is


divided

by the largest power of b less than n. For example, in base 10, the most
significant

digit of 568 is 5, and indeed 5 = 568 div 100 (100 is the largest power of 10 less
than

568). Furthermore, 68 is the remainder when 568 is divided by 500.

This observation provides a way of computing the base- b representation of an

integer.

base 94

digit 93

div 82

integer 3

mod 82, 204

most significant

digit 94

nonnegative integer 3

quotient (of inte-


gers) 83

remainder 83

68.1.2 Method

Suppose the representation for n to base b is l d m d m - \ ■

represents the integer n t in base b. Then

■ ■ do , where di

d m = n div b m

and

d m - 1 = (n - d m b m ) div b m ~ l

In general, for all i = 0, 1, . . . ,m — 1 ,

di = (n i+ 1 - d i+1 b l+1 ) div b l

(68.1)

where

n m = n
(68.2)

and for i = 0,l,...,m — 1,

rii = n i+ 1 - di + ±b l+1

(68.3)

68.1.3 Example The ‘6’ in 568 is

(568 - 5 • 100) div 10

(here m = 2: note that the 5 in 568 is since we start counting on the right at 0).

68.1.4 Remark Observe that (68.1) can be written

di = (n mod b l+l ) div b l (68.4)

which is correct for all i = 0,1,... ,m. The way (68.1) is written shows that the

computation of nmodfr*" 1 " 1 uses the previously-calculated digit d l+ \ .

68.1.5 Example We illustrate this process by determining the representation of

775 to base 8. Note that 512 = 8 3 :

a) 775 div 512 = 1.

b) 775-1 x 512 = 263.

c) 263div64 = 4.

d) 263-4 x 64 = 7.
100

base 94

digit 93

div 82

integer 3

mod 82, 204

octal notation 94

string 93, 167

e) 7 div 8 = 0.

f) 7 — 0 x 8 = 7.

g) 7 div 1 = 7.

And 775 in octal is indeed 1407.

68.2 The algorithm in Pascal

The algorithm just described is expressed in Pascal in Program 68.1. This algorithm

is perhaps the most efficient for pencil-and-paper computation. As given, it only

works as written for bases up to and including 10; to have it print out ‘a’ for 11,
‘b’

for 12 and so on would require modifying the “write (place)” statement.

var N, base, count, power, limit, place: integer;

(* Requires B > 0 and base > 1 *)

begin

power := 1; limit := N div base;


(♦calculate the highest power of the base less than N*)

while power <= limit do

begin

power := power*base

end;

while power > 1 do

begin

place := N div power; write (place) ;

n := n-place*power ; power := power div base

end

end

Program 68.1: Program for Base Conversion

68.3 Another base conversion algorithm

Another algorithm, which computes the digits backwards, stores them in an array,

and then prints them out in the correct order, is given in Program 68.2. It is more

efficient because it is unnecessary to calculate the highest power of the base less

than N first. This program starts with the observation that the least significant

digit in a number n expressed in base b notation is nrnodfo. The other digits in

the representation of n represent (n — (nrnod b))/b. For example, 568modl0 = 8,

and the number represented by the other digits, 56, is (568 — 8)/10.

In the program in Program 68.2, count and u are auxiliary variables of type

integer. The size longest of the array D has to be known in advance, so there

is a bound on the size of integer this program can compute, in contrast to the
previous algorithm. It is instructive to carry out the operations of the program in

Program 68.2 by hand to see how it works.

68.4 Comments on the notation for integers

Suppose n is written . . . do’ i n base b. Then the exact significance of

d m , namely the power b m that its value n m is multiplied by in Equation (66.2)


of

Definition 66.4 (page 94), depends on the length of the string of digits
representing

101

var count, u, N, base: integer;

var D: array [0.. longest] of integer;

begin

count : = 0 ; u : = N ;

while u<>0 do

begin

D [count] := u mod base;

u := (u-D [count]) div base;

count := count+1

end;

while countoO do

begin

count := count- 1;

write D [count]
end

end;

base 94

digit 93

hexadecimal nota-

tion 95

integer 3

octal notation 94

Program 68.2: Faster Program for Base Conversion

n (the length is m + 1 because the count starts at 0). If you read the digits from
left

to right, as is usual in English, you have to read to the end before you know what

m is. On the other hand, the significance of the right digit do is known without

knowing the length m. In particular, the program in Program 68.1 has to read to

the end of the representation to know the power b m to start with.

The fact that the significance of a digit is determined by its distance from the

right is the reason a column of integers you want to add is always lined up with
the

right side straight. In contrast to this, the sentences on a typewritten page are
lined

up with the left margin straight.

There is a good reason for this state of affairs: this notation was invented by

Arab mathematicians, and Arabic is written from right to left.

68.4.1 Exercise Represent the numbers 100, 111, 127 and 128 in binary, octal,
hexadecimal and base 36. (Answer on page 246.)

68.4.2 Exercise Represent the numbers 3501, 29398 and 602346 in hexadecimal

and base 36.

68.5 Exercise set

Exercises 68.5.1 through 68.5.4 are designed to give a proof of Formula (68.4),

page 99, so they should be carried out without using facts about how numbers

are represented in base b. In these exercises, all the variables are of type
integer.

68.5.1 Exercise Let b > 1 . Prove that if for all i > 0, 0 < d{ < b, then

d m b m + d m -ib m ~ l + --- + d 1 b + d 0 < b m+1

68.5.2 Exercise Let 6>1 and n>0. Let n = d m b m + \-d\b + do with 0<

di <b for i = 0, 1 , . . . , m . Prove that for any i > 0 ,

n — b'\d m b" 1 ' + d m —ib" 1 ' 1 + • • • + di] + di—ib‘ 1 + • • • + d\b + do

102

conjunction 21

defining condition 27

definition 4

DeMorgan Law 102

div 82

equivalent 40

mod 82, 204


proposition 15

rule of inference 24

unit interval 29

and 0 < dj-ib 1 1 H b d\b + do < b l . (Hint: Use Exercise 68.5.1.)

68.5.3 Exercise Let b > 1 and n > 0 and let n = d m b m -\ \-d\b + do with 0 <

di < b for * = 0,1,... , m . Prove that for any i > 0 ,

d m b m ~ l + d m -ib m ~ l ~ l -\ b di = n div b l

and

dib 1 H b d\b + do = nrnod b l+1

68.5.4 Exercise Prove Equation (68.4), page 99.

69. The DeMorgan Laws

Consider what happens when you negate a conjunction. The statement — i(P A Q )

means that it is false that P and Q are both true; thus one of them must be false.

In other words, either —>P is true or — i Q is true. This is one of the two
DeMorgan

Laws:

69.1 Definition: DeMorgan Laws

The DeMorgan Laws are:

DM.1 ~^{PAQ)

DM.2 — i(P V Q) 44 — '-P A — 'Q .

These laws are true no matter what propositions P and Q are.


69.1.1 Remark The DeMorgan Laws give rules of inference

—i(P AQ) \— -iP V-iQ and —>P\/—^Q \— — >(P AQ) (69.1)

and

~ i(PVQ) |— — <P A~ <Q and — <P A— <Q |— —> (P\/Q ) (69.2)

69.1.2 Example The negation of (x + y = 10) A (x < 7) is (x + y / 10) V-i(x < 7) .

Of course, ~^{x < 7) is the same as x > 7.

69.2 Using the DeMorgan Laws in proofs

The unit interval I = {x | 0 < x < 1} , which means that x G I if and only if 0 < x

and x < 1 . Therefore to prove that some number a is not in I , you must prove the

negation of the defining condition, namely that it is not true that 0 < x and x < 1
.

By the DeMorgan Laws, this means you must prove

-■(0 < x) V -i(x < 1)

which is the same as proving that (0 > x) V {x > 1) .

103

69.2.1 Warning When proving that a conjunction is false, it is easy to forget the

DeMorgan Laws and try to prove that both negatives are true. In the preceding

example, this would require showing that both 0 > x and x > 1 , which is obviously

impossible.

In contrast, if you must prove that a disjunction P\/ Q is false, you must show
that both P and Q are false. An error here is even more insidious, because if you

are tempted to prove that only one of P and Q is false, you often can do that

without noticing that you have not done everything required.

69.2.2 Example Consider the statement, “A positive integer is either even or it

is prime”. This statement is false. To show it is false, you must find a positive

integer such as 9 which is both odd and nonprime.

and 21, 22

conjunction 21

DeMorgan Law 102

even 5

integer 3

odd 5

positive integer 3

predicate 16

prime 10

real number 12

union 47

69.2.3 Method

To prove that P V Q is false, prove that ->P A~*Q is true. To prove that

P A Q is false, prove that ~*P V -i Q is true.

69.2.4 Example Given two sets A and B , how does one show that 4/ B? By

Method 21.2.1 on page 32, A = B means that every element of A is an element of

B and every element of B is an element of A. By DeMorgan, to prove A^ B you

must show that one of those two statements is false: you must show either that
there is an element of A that is not an element of B or that there is an element of

B that is not an element of A. You needn’t show both, and indeed you often can’t

show both. For example, {1,2} ^ {1,2,3}, yet every element of the first one is an

element of the second one.

69.2.5 Worked Exercise Let A and B be sets. How do you prove x <£. AU B?

How do you prove x ^ An B?

Answer To prove that x (ji Au B , you must prove both that x (j A and that

x B . This follows from the DeMorgan Law and the definition of union. To prove

x (f An B , you need only show x ^ A or x ^ B .

69.3 Exercise set

Reword the predicates in Exercises 69.3.1 through 69.3.3 so that they do not begin

with “-i”. x is real.

69.3.1 -i(x < 10) A(x> 12) . (Answer on page 246.)

69.3.2 -i(x < 10) A (x < 12) . (Answer on page 247.)

69.3.3 — 1 ( — i(a: > 5) A -<(x < 6)) .

104

DeMorgan Law 102

logical connective 21

predicate 16

propositional

form 104

propositional vari-
able 104

proposition 15

70. Propositional forms

The letters P and Q in the DeMorgan Laws are called propositional variables.

They are like variables in algebra except that you substitute propositions or pred-

icates for them instead of numbers. Don’t confuse propositional variables with the

variables which occur in predicates such as “x < y n . The variables in predicates


are

of the type of whatever you are talking about, presumably numbers in the case of

“x < y ” . Propositional variables are of type “proposition”: they vary over


proposi-

tions in the same way that x and y in the statement “x < y” vary over numbers.

70.1.1 Worked Exercise Write the result of substituting x = 7 for P and

for Q in the expression —>P V (P A Q) .

Answer x / 7 V (x = 7 Ax / 5) .

70.2 Variables in Pascal

Pascal does not have variables or expressions of type proposition. It does have

Boolean variables, which have TRUE and FALSE as their only possible values.

An expression such as ‘A < Y' has numerical variables, and a Boolean value

TRUE or FALSE, so it might correctly be described as a proposition (assuming

the program has already given values to X and Y). However, if B is a Boolean

variable, an assignment statement of the form B: = X <Y sets B equal to the truth

value of the statement ‘A < Y ’ at that point on the program; B is not set equal to

the proposition l X <Y\ If A and Y are later changed, changing the truth value
of ‘A <Y\ the value of B will not automatically be changed.

70.2.1 Example The following program prints TRUE. Here B is type BOOLEAN

and X is of type INTEGER:

X := 3;

B := X < 5;

X : = 7;

PRINT (B) ;

70.3 Propositional forms

Meaningful expressions made up of propositional variables and logical connectives

are called propositional forms or propositional expressions. The expressions

in DM.1 and DM.2 are examples of propositional forms. Two simpler ones are

P V —>P (70.1)

and

-i P V Q

(70.2)

70.3.1 Substituting in propositional forms If you substitute propositions for

each of the variables in a propositional form you get a proposition.

You may also substitute predicates for the propositional variables in a proposi-

tional form and the result will be a predicate.


105

70.3.2 Example If you substitute the proposition “3 < 5” in formula (70.1) you

get (after a little rewording) “3 < 5 or 3 > 5” which is a proposition (a true one,
in

fact).

If you substitute x < 5 for P in formula (70.1) you get “x < 5 or x > 5”, which

is true for any real number x. This is not surprising because formula (70.1) is a

tautology (discussed later).

If you substitute x < 5 for P and x / 6 for Q in ->P V Q you get “x > 5 or

x^6”, which is true for some x and false for others.

70.3.3 Remarks

a) This would be a good time to reread Section 12.1.4. Propositional forms are

a third type of expression beside algebraic expressions and predicates. In an

algebraic expression the variables are some type of number and the output

when you substitute the correct type of data for the variables is a number.

In a predicate the output is a proposition: a statement that is either true or

false. And now in propositional forms the variables are propositions and when

you substitute a proposition for each propositional variable the output is a

proposition.

b) We have not given a formal definition of “meaningful expression”. This is

done in texts on formal logic using definitions which essentially constitute a

context-free grammar.

algebraic expres-
sion 16

definition 4

DeMorgan Law 102

equivalent 40

expression 16

fact 1

predicate 16

propositional

form 104

propositional vari-

able 104

proposition 15

tautology 105

71. Tautologies

71.1 Discussion

Each DeMorgan Law is the assertion that a certain propositional form is true no

matter what propositions are plugged in for the variables. For example, the first

DeMorgan Law is

—'(P A Q) 44- —iP V —'Q

No matter which predicates we let P and Q be in this statement, the result is a

true statement.

71.1.1 Example let P be the statement x < 5 and Q be x = 42. Then the first

DeMorgan Law implies that

1 ((x < 5) A (x = 42)) 44 ((x > 5) V (x / 42))


is a true statement.

71.2 Definition: tautology

A propositional form which is true for all possible substitutions of propo-

sitional variables is called a tautology.

71.2.1 Fact The truth table for a tautology S has all T’s in the column under S .

106

equivalence 40

equivalent 40

implication 35, 36

law of the excluded

middle 106

predicate 16

propositional vari-

able 104

proposition 15

real number 12

tautology 105

truth table 22

71.2.2 Example Both DeMorgan laws are tautologies, and so is the formula (70.1),

which is called The law of the excluded middle. Both lines of its truth table

have T.
P -.P PV-.P

~T F T

FT T

71.2.3 Warning Don’t confuse tautologies with predicates all of whose instances

are true. A tautology is an expression containing propositional variables which

is true no matter which propositions are substituted for the variables. Expres-

sion (70.2) is not a tautology, but some instances of it, for example “not x > 5

or x > 3” are predicates which are true for all values (of the correct type) of the

variables.

71.2.4 Example Formula (70.2) (page 104) is not a tautology. For example,

let P be “4 > 3” and Q be “4 > 5”, where x ranges over real numbers; then

Formula (70.2) becomes the proposition “(not 4 > 3) or 4 > 5”, i.e. , “4 < 3 or 4 >

5”, which is false.

71.2.5 Exercise Show that FV Q 44 -i(->P /\—>Q) is a tautology. (Answer on

page 247.)

71.2.6 Exercise Show that the following are tautologies.

a) P A Q 44 — 1 ( — 'P V — 'Q)

b) (P A —iP) => Q

c) P =4- (Q V -i Q)

d) Pv(P =s> Q)

e) ((PAQ) => P) 44 [p =► (Q => R)j

f) P A (Q V R) => PV(QAP)
71.2.7 Remark Many laws of logic are equivalences like the DeMorgan laws. By

Theorem 29.2, an equivalence between two expressions is a tautology if the truth

tables for the two expressions are identical. Thus the truth tables for -i(PaQ) and

— i P V -i Q are identical:

P Q PAQ

T T T

T F F

FT F

F F F

-i(PAQ) -i P -i Q

F F I 7

T FT

T T F

T T T

—>P V —i Q

71.2.8 Example You can check using this method that -> P\/Q (i.e., For-

mula (70.2)) is equivalent to P =4- Q.


71.2.9 Exercise Prove by using Theorem 29.2 that the propositional forms P =>

Q, -'P V Q and -i(PA-iQ) are all equivalent. (Answer on page 247.)

71.2.10 Exercise Prove that (P =>• Q) Q is equivalent to PVQ.

107

72. Contradictions

72.1 Definition: contradiction

A propositional form is a contradiction if it is false for all possible

substitutions of propositional variables.

72.1.1 Fact The truth table for a contradiction has all F’s.

72.1.2 Example The most elementary example of a contradiction is “PA-iP”.

72.1.3 Exercise Show that the following are contradictions.

a) ~<(P V —<P) ■

b) n(PV(P =}► Q)).

c) Q A -i (P => Q ) .

72.1.4 Exercise If possible, give an example of a propositional form involving

“ =>• ” that is neither a tautology nor a contradiction.

associative 70

commutative 71
complement 48

contradiction 107

definition 4

fact 1

idempotent 143

implication 35, 36

intersection 47

predicate 16

propositional calcu-

lus 107

propositional vari-

able 104

proposition 15

transitive 80, 227

truth table 22

universal set 48

73. Lists of tautologies

Tables 72.1 and 72.2 give lists of tautologies. Table 72.1 is a list of tautologies

involving “and” , “or” and “not” . Because union, intersection and complementation

for sets are defined in terms of “and”, “or” and “not”, the tautologies correspond

to universally true statements about sets, which are given alongside the
tautologies.

Table 72.2 is a list of tautologies involving implication. Because of the modus

ponens rule, the major role implication plays in logic is to provide successive
steps

in proofs. These laws can be proved using truth tables or be deriving them from

the laws in Table 72.1 and the first law in Table 72.2, which allows you to define
‘ =>■ ’ in terms of ‘ — > ’ and ‘V’. It is an excellent exercise to try to
understand why

the tautologies in both lists are true, either directly or by using truth tables.

73.1 The propositional calculus

The laws in Tables 72.1 and 72.2 allow a sort of computation with propositions in
the

way that the rules of ordinary algebra allow computation with numbers, such as the

distributive law for multiplication over addition which says that 3(x + 5) = 3x +
15.

This system of computation is called the propositional calculus, a phrase which

uses the word “calculus” in its older meaning “computational system”. (What is

called “calculus” in school used to be taught in two parts called the “differential

calculus” and the “integral calculus”.)

Recall that every predicate becomes a proposition (called an “instance” of the

predicate) when constants are substituted for all its variables. Thus when
predicates

are substituted for the propositional variables in these laws, they become
predicates

which are true in every instance.

108

equivalent 40

(consistency)

J J

t t
u c = $

Q) C = U

(unity)

P AT AA P

PVFO P

Anu = A

AuQ) = A

(nullity)

PAFaa f

P\J T aaT

II H

si 15

C D

(idempotence)

PAPaaP

P\j P aaP

II II
C D

^1 ^1

(commutativity)

P AQ AA Q AP

PV QaaQm P

AnB=BnA

AUB = BUA

(associativity)

pa(Qar)

aa(paQ)ar

PV(QVP)

4A (PVQ) VP

An(BrC)

= (AnB)nC

AU{BUC)

= {AUB)UC

(distributivity)

P A (Q V P)

4A(PAQ)V(PAP)
pv(Qap)

4A (P V Q) A (P V P)

An{BuC)

= {AnB)u{AnC)

Au{BnC)

= ( AuB)n{Auc )

(complement)

E-i tin

$ $

CL, eg

r r

> <

eg eg

it* ^

D C

it* it*

o o

II II

s s;

(double negation)
^P4VP

(A C ) C = A

(absorption)

PA(PVQ)4AP

PV(PAQ)4AP

it* it*

C D

D C

II II

it* it*

(DeMorgan)

-i(P V Q) 4A -iP A -iQ

— '(P A Q) 4A — 'P V — '<5

(AUB) C = (A c )n(B c )

{AnB) c ={A c UB c )

Table 72.1: Boolean Laws

109
(‘ => ’-elimination)

(transitivity)

(modus ponens)

(modus tollens)

(inclusion)

(simplification)

(cases)

(everything implies true)

(false implies everything)

(P =4- Q) 44 (- 1 PV Q)

(( P =4 Q) A (Q =4 R)) =4 (P =4 P)

(PA(P =4 Q)) =4 Q

(~>QA(P =4- Q)) =4- -iP

P => (PvQ)

(PAQ) => P

(n?A(PVQ)) =4 Q

Q =>• (P =>• Q)

iP => (P => Q)

Table 72.2: Laws of Implication


equivalent 40

implication 35, 36

logical connective 21

truth table 22

73.1.1 Example When you substitute x > 7 for P and x = 5 for Q i n the second

absorption law PV(PAQ)<t>P you get, in words, “Either r >7 or both x > 7

and x = 5” is the same thing as saying “x > 7”. This statement is certainly true:

it is true by its form, not because of anything to do with the individual


statements

“x > 7” and “x = 5” .

73.1.2 Exercise Define the logical connective NAND by requiring that PNAND

Q be true provided at least one of P and Q is false.

a) Give the truth table for NAND .

b) Write a statement equivalent to “PNAND Q” using only ‘A’, ‘V’, ‘-T, ‘P’,

‘ Q ’ and parentheses.

c) Give statements equivalent to P”, “PAQ” and “PVQ” using only ‘P’,

‘ Q ‘NAND’, parentheses and spaces.

73.1.3 Exercise Do the same as Problem 73.1.2 for the connective NOR, where

PNORQ is true only if both P and Q are false.

73.1.4 Exercise Show how to define implication in terms of each of the connec-

tives NAND and NOR of exercises 73.1.2 and 73.1.3.

73.1.5 Exercise Let denote the operation XOR discussed in Chapter 11.

Prove the following laws:

a) P * Q Q * P .
b) P*(Q*P)4A(P*Q)*P.

c) PA(Q*P)4A(PAQ)*(PAP).

73.1.6 Exercise (Mathematica)

a) Show that there are 16 possible truth tables for a Boolean expression with

two variables.

110

distributive law 110

equivalent 40

implication 35, 36

logical connective 21

modus ponens 40

proof 4

propositional

form 104

proposition 15

rule of inference 24

tautology 105

theorem 2

truth table 22

b) Produce Boolean expressions with and “ =>■ ” as the only logical connec-

tives that give each of the possible truth tables. Both variables must appear

in each expression. Include a printout of Mathematica commands that verify


that each expression gives the table claimed.

(Enter p =>• q as p ~ Implies' q.)

73.1.7 Exercise (hard) A distributive law involving binary operations ‘A’

and ‘ V ’ is a tautology of the form

PV{QAR) 4A (PVQ)A(PVP)

Let be defined as in Problem 73.1.5. Give examples showing that of the four

possible distributive laws combining with ‘A’ or ‘V’, the only correct one is that

in Problem 73.1.5(c).

74. The tautology theorem

In Section 28, we discussed the rule of inference called “modus ponens”:

P, P => Q b Q

This rule is closely related to the tautology also called modus ponens in section
71:

(pa(P =► Q)') => Q

This tautology is a propositional form which is true for any proposition P and Q .

This is a special case of the general fact that, roughly speaking, any implication

involving propositional forms which is a tautology is equivalent to a rule of


inference:

74.1 Theorem: The Tautology Theorem

Suppose that F\ , . . . , F n and G are propositional forms. Then

F u ...,F n b G

is a valid rule of inference if and only if


(F\ A ... A F n ) =f- G

is a tautology.

(74.1)

(74.2)

Proof If the rule of inference (74.1) is correct, then whenever all the
propositions

Fi, . . . , F n are true, G must be true, too. Then if F\ A ■ ■ ■ A F n is true,


then every

one of F{,. . . ,F n is true, so G must be true. This means that (74.2) must be a

tautology, for the only way it could be false is if Fi A ■ ■ ■ A F n is true and G


is false.

(This is because any implication P =^> Q is equivalent to -i(PA-iQ).)

On the other hand, if (74.2) is a tautology, then whenever T\, . . . , F n are all
true,

then F\ A • • ■ A F n is true, so that G has to be true, too. That means that


(74.1) is

a valid rule of inference.

Ill

74.1.1 Example The preceding theorem applies to modus ponens: Take F\ to be


equivalent 40

the formula P, F -2 to be “P =4- Q ” , and G to be Q. Since ( PA(P =4- Q) ] =4- Q |


m P^ ca ^ on ^5,

V v / logical connective 21
is a tautology, the validity of the rule of inference called modus ponens follows
by modus ponens 40

the Tautology Theorem from the tautology called modus ponens. propositional

form 104

74.1.2 Remark Not all rules of inference come from tautologies - only those rule of
inference 24

involving propositional forms. We have already seen examples of rules of inference


Tautology Theo-

not involving propositional forms in 18.1.11, page 29. rem ^

tautology 105

74.1.3 Warning The Tautology Theorem does not say that “|— ” is the same

thing as “ . “ [— ” is not a logical connective and cannot be used in formulas the

way “ =4- ” can be. For example you may write P A (P =4- Q) but not P A (P |- Q) .

“ |— ” may be used only in rules of inference.

74.2 Exercise set

For problems 74.2.1 to 74.2.6, state whether the given rule is a valid rule of
inference.

74.2.1 -i P, PVQ |- Q (Answer on page 247.)

74.2.2 -iQ, P =4- (QAR) \- -i P (Answer on page 247.)

74.2.3 -i P, (PAQ) =4- R \- -i R (Answer on page 247.)

74.2.4 nPAQ, Q |- -.P


74.2.5 {PvQ) ^ R, P ^ R

74.2.6 (P A Q) =4- R, ~ i R |— — 'PA - <Q

74.2.7 Exercise Show that the statement (P = 4 - Q) = 4 > Q is not a tautology by

giving an example of statements P and Q for which it is false. (Answer on page

247.)

74.2.8 Exercise Show that the following statements are not tautologies by giving

examples of statements P and Q for which they are false.

a) (P 44 Q) => P

b) f(P => Q) => r) 44 (p => {Q =► R))

74.2.9 Exercise Use the Tautology Theorem to prove that the following rules of

inference are valid:

a) Q \- P =4 Q

b) P, Q b PAQ

c) PAQ h P

d) ^P (- P =4 Q

e) nQ,P4()h -P

112

counterexample 112

definition 4

implication 35, 36
real number 12

universal quanti-

fier 112

75. Quantifiers

75.1 Definition: universal quantifier

Let Q(x) be a predicate. The statement (Mx)Q(x) is true if and only if

Q(x) is true for every value of the variable x. The symbol V is called

the universal quantifier.

75.1.1 Example Let P(x) be the statement (x > 5) =>• (x > 3) . P(x) is uni-

versally true, that is, it is true for every real number x. Therefore, the
expression

(Vx)-P(x) is true.

We defined V in 13.2; now we will go into more detail.

75.1.2 Showing the types of the variables A short way of saying that x is

of type real and that (Mx)Q(x) is to write (Vx:R)Q(a:) , read “for all x of type R,

Q(x)" or “for all real numbers x. Q(x)” .

75.1.3 Example The statement (Vn:Z)((n > 5) is false because “n > 5” is false

for n = 3 (and for an infinite number of other values of n).

75.1.4 Example The statement (Vn:Z)((n > 5) V (n < 5)) is false because the

statement “(n > 5) V (n < 5)” is false when n = 5. Note that in contrast to Exam-

ple 75.1.3, n = 5 is the only value for which the statement “(n > 5) V (n < 5)” is

false.
A statement like (\/x)Q(x) is true if Q(x) is true no matter what is substituted
for

x (so long as it is of the correct type). If there is even one x for which Q(x) is

false, then (\/x)Q(x) is false. A value of x with this property is important


enought

to have a name:

75.2 Definition: counterexample

Let Q(x) denote a predicate. An instance of x for which Q(x) is false

is called a counterexample to the statement (Vx)Q( x) . If there is a

counterexample to the statement (Vx)Q(x) , then that statement is false.

75.2.1 Example (Vx:N)((x < 5) V (x > 6)) is true, but (V.x:R)((a: < 5) V (x > 6))

is false (counterexample: ).

75.2.2 Example A counterexample to the statement (Vn:Z)((n > 5) is 3; in fact

there are an infinite number of counterexamples to this statement. In contrast, the

statement (Vn:Z)((n > 5) V (n < 5)) has exactly one counterexample.

75.2.3 Exercise Find a universal statement about integers that has exactly 42

counterexamples .

75.2.4 Exercise Find a universal statement about real numbers that has exactly

42 counterexamples.

113

75.3 Definition: existential quantifier


Let Q(x) be a predicate. The statement (3x)Q(x) means there is some

value of x for which the predicate Q{x ) is true. The symbol 3 is called

an existential quantifier, and a statement of the form ( 3x)Q(x ) is

called an existential statement. A value c for which Q(c) is true is

called a witness to the statement ( 3x)Q(x ).

75.3.1 Remark One may indicate the type of the variable in an existential state-

ment in the same way as in a universal statement.

75.3.2 Example Let x be a real variable and let Q{x ) be the predicate x > 50.

This is certainly not true for all integers x . Q(40) is false, for example.
However,

Q(62) is true. Thus there are some integers x for which Q(x) is true. Therefore

(zh:R)<5(x) is true, and 62 is a witness.

75.3.3 Exercise Find an existential statement about real numbers with exactly

42 witnesses.

counterexample 112

definition 4

even 5

existential quanti-

fier 113

existential state-

ment 5, 113

implication 35, 36

infinite 174

integer 3

natural number 3
predicate calcu-

lus 113

predicate 16

prime 10

propositional calcu-

lus 107

usage 2

witness 113

75.3.4 Exercise In the following sentences, the variables are always natural num-

bers. P(n) means n is a prime, E{n) means n is even. State which are true and

which are false. Give reasons for your answers.

a) (3n) (E(n) A P(n ))

b) (Vn)(L(n)VP(n))

c) (3n)(E(n) =4- P(n))

d) (\/n)(E(n) =4- P(n))

(Answer on page 247.)

75.3.5 Exercise Which of these statements are true for all possible one-variable

predicates P(x) and Q(x)? Give counterexamples for those which are not always

true.

a) (\/x)(P(x) A Q(x)) =4- (V.x)P(x) A (\/x)Q(x)

b) (Vx)P(x) A (\/x)Q(x) =t- (\/x)(P(x) A Q(x))

c) (3x)(P(x) A Q(x)) =4- (3x)P(x) A (3x)Q(x)


d) (3x)P(x) A (3x)Q(x) =4- (3x)(P(x) A Q(x))

(Answer on page 247.)

75.3.6 Exercise Do the same as for Problem 75.3.5 with ‘V’ in the statements in

place of ‘A’.

75.3.7 Exercise Do the same as for Problem 75.3.5 with ‘ =t- ’ in the statements

in place of ‘A’.

75.3.8 Usage The symbols V and 3 are called quantifiers. The use of quantifiers

makes an extension of the propositional calculus called the predicate calculus

which allows one to say things about an infinite number of instances in a way that

the propositional calculus does not.

114

divide 4

GCD 88

implication 35, 36

integer 3

predicate 16

proposition 15

76. Variables and quantifiers

If a predicate P{x) has only one variable x in it, then using any quantifier in
front

of P{x) with respect to that variable turns the statement into one which is either

true or false — in other words, into a proposition.


76.1.1 Example If we let P{n) be the statement (n > 4) A (n < 6) , for n rang-

ing over the integers, then (3 n)P(n), since P( 5) is true (5 is a witness).


However,

(Vn)P(n) is false, because for example P( 6) is false (6 is a counterexample). Both

statements (3 n)P(n) and (Vn)P(n) are propositions; propositions, unlike predi-

cates, are statements which are definitely true or false.

76.1.2 Predicates with more than one variable When a predicate has more

than one variable, complications ensue. Let P(x,y) be the predicate (x > 5) V (5 >

y) . Let Q(y) be the predicate (Vx:N )P(x,y). Then Q(y) is the statement: “For

every integer x , x > 5 or 5 > y.” This is still not a proposition. It contains one

variable y . for which you can substitute an integer. It makes no sense to


substitute

an integer for x in Q(y) (what would “For all 14, 14 > 5 or 5 > y” mean?) which

is why x is not shown in the expression “Q(y) n .

76.1.3 Bound and free A variable which is controlled by a quantifier in an

expression is bound in the sense of 20.2. A logical expression in which all vari-

ables are bound is a proposition which is either true or false. If there are one or

more free variables, it is not a proposition, but it is still a predicate.

76.1.4 Exercise Let P(x,y ) be the predicate

(x = y) V (x > 5)

If possible, find a counterexample to (Vy)P(14,y) and find a witness to


(3x)P(x,3) .

(Answer on page 247.)

76.1.5 Exercise Let Q(m,n) be each of the following statements. Determine in

each case if (Vm:N)Q(m, 12) and (3n:Z)Q(3,ro) are true and give a counterexample

or witness when appropriate.


a) m\n.

b) GCD(m,n) = l.

c) (m | n) =>■ (m | 2 n) .

d) ( m | n) =4- (mn = 12) .

115

Archimedean prop-

erty 115

implication 35, 36

integer 3

proof 4

real number 12

rule of inference 24

theorem 2

trunc 86

In other words, “For any real number x there is an integer n bigger than x.”

Proof If you are given a real number x, then trunc(x) + 1 is an integer bigger

than x.

77.1.2 Example On the other hand, the statement

(3n:N)(Vx:R)(x < n) (77.2)

is false. It says there is an integer which is bigger than any real number. That is

certainly not true: if you think 456,789 is bigger than any real number, then I
reply,

“It is not bigger than 456,790”. In general, for any integer n, n + 1 is bigger —
and

of course it is a real number, like any integer.

As these examples illustrate, in general, (\/x)(3y)P(x,y) does not mean the same

as (3y)(\/x)P(x,y) , although of course for particular statements both might be


true.

On the other hand, two occurrences of the same quantifier in a row can be

interchanged:

77.2 Theorem

For any statement P(x,y),

(Vx)(Vy)P(x,y) |- (Vy)(Vx)P(x,y)

(77.3)

and

(\/y)(\/x)P(x,y) |- (\/x)(Vy)P(x,y)
(77.4)

and similarly

(3x)(3y)P(x,y) \- (3y)(3x)P(x,y)

(77.5)

and

{3y)(3x)P(x,y) |- (3x)(3y)P(x,y)

(77.6)

77.2.1 Exercise Are these statements true or false? Explain your answers. All

variables are real.

a) (Vx)(3y)(x>y).

b) (3x)(Vy)(x>y)

c) (3x)(3y)((x>y) => (x = y)).

(Answer on page 247.)


77. Order of quantifiers

Many important mathematical principles are statements with several quantified

variables. The ordering of the quantifiers matters. The subtleties involved can

be confusing.

77.1.1 Example The following statement is the Archimedean property of the

real numbers.

(Vx:R)(3n:N)(x < n) (77. 1)

116

counterexample 112

divide 4

equivalence 40

equivalent 40

implication 35, 36

integer 3

negation 22

positive integer 3

predicate 16

prime 10

proof 4

proposition 15

real number 12

theorem 2
77.2.2 Exercise Are these statements true or false? Explain your answers. All

variables are of type integer.

a) (Vm)(3n)(m | n) .

b) (3m)(Vn)(m | n) .

c) (Vm)(3n) ((m | n) =4- (m\mn)).

d) (3m)(Vn) ((m | n) =4- (m|?nn)).

77.2.3 Exercise Are these statements true or false? Give counterexamples if they

are false. In these statements, p and q are primes and m and n are positive
integers.

a) (Vp) (Vm) (Vn) ((p | m =4> p \ n) =4 m \ n)

b) (Vm)(Vn)(m|n =4 (3p)(p | m Ap | n))

77.2.4 Exercise (hard) Are these equivalences true for all predicates P and Q1

Assume that the only variable in P is x and the only variables in Q are x and y.

Give reasons for your answer.

a) (Vx)(3y)(P(z) =4 Q(x,y)) 44 (Vx) (P(x) (3 y)Q(x,y))

b) (3 x)(\/y)(P(x) => Q(x,y)) <&(3x){P(x) => (Vy)Q{x,y))

78. Negating quantifiers

Negating quantifiers must be handled with care, too:

78.1 Theorem: Moving “not” past a quantifier

For any predicate P ,


Q.l -((3 x)P{x)) 44 (Vx)(-iP(s))

Q.2 -.((Vs)P(x)) 44 (3z)(-.P(z)).

Proof We give the argument for Q.l; the argument for Q.2 is similar.

For (3 x:A)P(x) to be false requires that P(x) be false for every x of type A;

in other words, that —>P(x) be true for every x of type A. For example, if P(x) is

the predicate (x > 5) A (x < 3) , then (Bx:R)P(x) is false. In other words, the
rule

Q.l is valid.

78.1.1 Remark Finding the negation of a proposition with several quantifiers can

be done mechanically by applying the rules (Q.l) and (Q.2) over and over.

78.1.2 Example The negation of the Archimedean property can take any of the

following equivalent forms:

a) -i((Vx:R)(3?r:N)(x < n))

b) (3x:R)-i((3ro:N)(x < n))

c) (3x:R)(Vn:N)(x > n)

The last version is easiest to read, and clearly false — there is no real number

bigger than any integer. It is usually true that the easiest form to understand is
the

one with the ‘ -i ’ as “far in as possible” .

117

78.1.3 Worked Exercise Express the negation of (Vx)(x < 7) without using a

word or symbol meaning “not”.


Answer (3.x) (x > 7) .

78.1.4 Exercise Express the negation of (3x)(x < 7) without using a word or

symbol meaning “not” .

78.1.5 Exercise Write a statement in symbolic form equivalent to the negation

of

(Vx)(P(x) => Q(x))

equivalent 40

implication 35, 36

negation 22

nonnegative integer 3

predicate calcu-

lus 113

predicate 16

real number 12

without using the ‘V’ symbol.

78.1.6 Exercise Write a statement in symbolic form equivalent to the negation

of the expression “(3x)(P(x) =$■ -> Q(x))" without using ‘3’, ‘ =$■ ’ or ‘-i’.

79. Reading and writing quantified statements

An annoying fact about the predicate calculus is that even when you get pretty

good at disentangling complicated logical statements, you may still have trouble

reading mathematical proofs. One reason for this may be unfanriliarity with certain
techniques of proof, some of which are discussed in the next chapter. Another is

the variety of ways a statement in logic can be written in English prose. You have

already seen the many ways an implication can be written (Section 27).

Much more about reading mathematical writing may be found in the author’s

works [Wells, 1995], [Bagchi and Wells, 1998b], [Bagchi and Wells, 1998a], and

[Wells, 1998].

79.1.1 Example The true statement, for real numbers,

(Vx)(x>0 => (3y)(y 2 = x)) (79.1)

could be written in a math text in any of the following ways:

a) If x > 0 , then there is a y for which y 2 = x.

b) For any x > 0 , there is some y such that y 2 = x .

c) If x is nonnegative, then it is the square of some real number.

d) Any nonnegative real number is the square of another one.

e) A nonnegative real number has a square root.

Or it could be set off this way

x > 0 =4- (3 y)(y 2 =x) (x)

with the (x) on the far right side denoting “Vx”. Sometimes (x) is used instead of

Vx next to the predicate, too:

(x)(x > 0 =>- (3 y)(y 2 = x))

118
implication 35, 36

integer 3

predicate 16

quantifier 20, 113

real number 12

79.1.2 Warning The words “any”, “all” and “every” have rather delicate rules of

usage, as well. Sometimes they are interchangeable and sometimes not. The Archi-

medean axiom could be stated, “For every real x there is an integer n > x,” or “For

any real x there is an integer n > x.” But it would be misleading, although perhaps

not strictly wrong, to say, “For all real numbers x there is an integer n > x ,”
which

could be misread as claiming that there is one integer n that works for all x.

79.1.3 Warning Observe that the statements in (a), (c) and (e) have no obvious

English word corresponding to the quantifier. This usage there is somewhat similar

to the use of the word “dog” in a sentence such as, “A wolf mates for life”,
meaning

every wolf mates for life.

Students sometimes respond to a question such as, “Prove that an integer divis-

ible by 4 is even” with an answer such as, “The integer 12 is divisible by 4 and it

is even”. However, the question means, “Prove that every integer divisible by 4 is

even.” This blunder is the result of not understanding the way a universal
quantifier

can be signaled by the indefinite article.

79.1.4 Example Consider the well-known remark, “All that glitters is not gold.”

This statement means


-i(Vx) (GLITTER(x) => GOLD(x))

rather than

(Vx) (GLITTER(x) => ^GOLD(x))

In other words, it means, “Not all that glitters is gold.” (We do not say the

statement is incorrect English or correct English with a different meaning; we only

give it as an illustration of the subtleties involved in translating from English


to

logic.)

79.1.5 Worked Exercise Write these statements in logical notation. Make up

suitable names for the predicates.

a) All people are mortal.

b) Some people are not mortal.

c) All people are not mortal.

Answer (a) (Vx) (Person(x) => Mortal(x))

(b) (3x) (Person(x) A -Mortal(x))

(c) (Vx) (Person(x) =4- -iMortal(x))

79.1.6 Exercise Write these statements in logical notation.

a) Everybody likes somebody.

b) Everybody doesn’t like something.

c) Nobody likes everything.

d) You can fool all of the people some of the time and some of the people all of
the time, but you can’t fool all of the people all of the time.

79.1.7 Exercise Write the statement in GS.2, page 61, using quantifiers.

119

80. Proving implications: the Direct Method

Because so many mathematical theorems are implications, it is worthwhile consid-

ering the ways in which an implication can be proved. We consider two common

approaches in this chapter.

80.1 The direct method

If you can deduce Q from P , then P =>- Q must be true. That is because the only

line of the truth table for ‘ => ’ (Table 25.1) which has an ‘F’ is the line for
which

P is true and Q is false, which cannot happen if you can deduce Q from P . This

gives:

80.1.1 Method: Direct Method

To prove P =>■ Q , assume P is true and deduce Q .

direct method 119

divide 4

Fundamental Theo-

rem of Arith-

metic 87

hypothesis 36
implication 35, 36

integer 3

positive integer 3

prime 10

proof 4

theorem 2

truth table 22

80.1.2 Remark Normally, in proving Q, you would use other facts at your dis-

posal as well as the assumption that P is true. As an illustration of the direct

method, we prove the following theorem.

80.2 Theorem

If a positive integer is divisible by 2 then 2 occurs in its prime factor-

ization.

Proof Let n be divisible by 2. (Thus we assume the hypothesis is true.) Then 2

divides n, so that by definition of division n = 2m for some integer m. Let

m = pf 1 x ... x p^f

be the prime factorization of m. Then

n = 2 xpf 1 x ... x p

is a factorization of n into primes (since 2 is a prime), so is the prime


factorization

of n because the prime factorization is unique by the Fundamental Theorem of

Arithmetic.

80.2.1 Coming up with proofs In a more complicated situation, you might

have to prove P => P \ , P\ =A P 2 , . . . , Pk =>• Q in a series of deductions.


Normally, although your final proof would be written up in that order, you

would not think up the proof by thinking up P\,p 2 ,. . . in order. What happens

usually is that you think of statements which imply Q, statements which imply

them (backing up), and at the same time you think of statements which P implies,

statements which they imply (going forward), and so on, until your chain meets in

the middle (if you are lucky) . Thinking up a proof is thus a creative act rather
than

the cut-and-dried one of grinding out conclusions from hypotheses.

80.2.2 Exercise Prove by the direct method that for any integer n, if n is even

so is n 2 .

120

conclusion 36

contrapositive 42

direct method 119

divide 4

equivalent 40

even 5

hypothesis 36

implication 35, 36

integer 3

odd 5

positive integer 3

prime 10

proof 4

theorem 2
universal generaliza-

tion 6

81. Proving implications: the Contrapositive Method

It is very common to use the contrapositive to prove an implication. Since “P =4>


Q”

is equivalent to Q => -cP” , you can prove " P =$■ Q” by using the direct method

to prove u -iQ =>• -> P” . In detail:

81.0.3 Method: Contrapositive Method

(The contrapositive method) To prove P Q , assume Q is false and

deduce that P is false.

81.0. 4 Warning This method is typically used in math texts without mentioning

that the contrapositive is being used. You have to realize that yourself.

81.0. 5 Example The proof of the following theorem is an illustration of the use

of the contrapositive, written the way it might be written in a math text. Recall

that an integer k is even if 2 | k .

81.1 Theorem

For all positive integers n, if n 2 is even, so is n.

Proof Let n be odd. Then 2 does not occur in the prime factorization of n. But

the prime factorization of n 2 merely repeats each prime occurring in the


factoriza-

tion of n, so no new primes occur. So 2 does not occur in the factorization of n 2

either, so by Theorem 80.2, n 2 is odd. This proves the theorem.


81.1.1 Remarks

a) If you didn’t think of proving the contrapositive, you might be dumbfounded

when you saw that a proof of a theorem which says “if n 2 is even then n is

even” begins with, “Let n be odd...” The contrapositive of the statement to

be proved is, “If n is odd, then n 2 is odd.” The proof of the contrapositive

proceeds like any direct-method proof, by assuming the hypothesis ( n is odd) .

b) The contrapositive of Theorem 80.2 is used in the proof of Theorem 81.1. That

theorem says that if n is even, then its prime factorization contains 2. Here

we are using it in its contrapositive form: if 2 does not occur in the prime

factorization of n, then n is not even, i.e., n is odd. Again, the proof does

not mention the fact that it is using Theorem 80.2 in the contrapositive form.

c) Theorem 81.1, like most theorems in mathematics, is a universally quanti-

fied implication, so using universal generalization we showed that if n is an

arbitrary positive integer satisfying the hypothesis, then it must satisfy the

conclusion. In such a proof, we are not allowed to make any special assump-

tions about n except that it satisfies the hypothesis. On the other hand,

if we suspected that the theorem were false, we could prove that it is false

merely by finding a single positive integer n satisfying the hypothesis but not

the conclusion. (Consider the statement, “If n is prime, then it is odd.”)

This phenomenon has been known to give students the impression that prov-

ing statements is much harder than disproving them, which somehow doesn’t

seem fair.

121
81.1.2 Exercise Prove by the contrapositive method that if n 2 is odd then so

is n.

81.2 Exercise set

Exercises 81.2.1 through 81.2.3 provide other methods of proof.

81.2.1 Exercise Prove that

(P A -iQ) -i(P =4- Q) (81.1)

is a tautology. Thus to prove that an implication is false, you must show that

its hypothesis is true and its conclusion is false. In particular, the negation of
an

implication is not an implication.

81.2.2 Exercise Prove that the rule

affirming the hypoth-

esis 121

conclusion 36

definition 4

denying the conse-

quent 121

divisor 5

equivalent 40

fallacy 121

hypothesis 36

implication 35, 36

negation 22

prime 10
rule of inference 24

tautology 105

=*. Q |_ P\/ Q

(81.2)

is a valid inference rule. (A proof using this rule would typically begin the proof
of

PVQ by saying, “Assume -i P ..." and then proceed to deduce Q.)

81.2.3 Exercise Prove that the rule

P^Q,Q^R^P^R

is a valid inference rule. (This allows proofs to be strung together.)

81.2.4 Exercise (hard) Use the methods of this chapter to prove that n is prime

if and only if n > 1 and there is no divisor k of n satisfying 1 < k < \/n.

82. Fallacies connected with implication

82.1 Definition: fallacy

An argument which does not use correct rules of inference is called a

fallacy.

82.1.1 Example Two very common fallacies concerning implications are


F.l assuming that from P =>- Q and Q you can derive P (“A cow eats grass. This

animal eats grass, so it must be a cow.”) and

F.2 assuming that from P => Q and —> P that you can derive —>Q (“A cow eats

grass. This animal is not a cow, so it won’t eat grass.”)

82.1.2 Remark You will sometimes hear these fallacies used in political argu-

ments. F.l is called affirming the hypothesis and F.2 is called denying the

consequent.

82.1.3 Remark Fallacious arguments involve an incorrect use of logic, although

both the hypothesis and the conclusion might accidentally be correct. Fallacious

arguments should be distinguished from correct arguments based on faulty assump-

tions.

122

conclusion 36

contrapositive 42

equivalence 40

equivalent 40

even 5

hypothesis 36

implication 35, 36

integer 3

odd 5

positive integer 3

prime 10
82.1.4 Example The statement, “A prime number bigger than 2 is odd. 5 is odd,

so 5 is prime” is fallacious, even though the conclusion is true. (The hypothesis


is

true, too!). It is an example of affirming the hypothesis.

82.1.5 Example The statement “An odd number is prime, 15 is odd, so 15 is

prime” is not fallacious- it is a logically correct argument based on an incorrect

hypothesis (“garbage in, garbage out”).

82.1.6 Example The argument, “Any prime is odd, 16 is even, so 16 is not a

prime” is a logically correct argument with a correct conclusion, but the


hypothesis,

“Any prime is odd”, is false. The latter is a case of “getting the right answer for

the wrong reason,” which is a frequent source of friction between students and math

teachers.

82.2 Exercise set

In Problems 82.2.1 through 82.2.5, some arguments are valid and some are
fallacious.

Some of the valid ones have false hypotheses and some do not. (The hypothesis is in

square brackets.) State the method of proof used in those that are valid and
explain

the fallacy in the others. The variable n is of positive integer type.

82.2.1 [n > 5 only if n> 3]. Since 17 > 5, it must be that 17 > 3. (Answer on

page 247.)

82.2.2 [n > 5 only if n > 3]. Since 4 > 3, it must be that 4 > 5. (Answer on page

247.)

82.2.3 [If n is odd, then n / 2], 6 is not odd, so 6 = 2. (Answer on page 247.)
82.2.4 [n is odd only if it is prime]. 17 is odd, so 17 is a prime. (Answer on page

247.)

82.2.5 [If n is even and n > 2, then n is not prime]. 15 is odd, so 15 is prime.

(Answer on page 247.)

83. Proving equivalences

83.1.1 Method

An equivalence “P 44 Q” is proved by proving both P => Q

and Q =4- P.

83.1.2 Remark Remember the slogan: To prove an equivalence you must prove

two implications.

83.1.3 Remark Quite commonly the actual proof proves (for example) P => Q

and -i P =4- -iQ (the contrapositive of Q =4- P), so the proof has two parts: the

first part begins, “Assume P” , and the second part begins, “Assume —>P...”

123

83.1.4 Example Here is an example of a theorem with such a proof. The proof

avoids the use of the Fundamental Theorem of Arithmetic, which would make it

easier, so as to provide a reasonable example of the discussion in the preceding

paragraph.

83.2 Theorem
For any integer n, 2 | n if and only if 4 | n 2 .

Proof If 2 | n then by definition there is an integer k for which n = 2k. Then

n 2 = 4 k 2 , so n 2 is divisible by 4.

Now suppose 2 does not divide n , so that n is odd. That means that n = 2k + 1

for some integer k . Then n 2 = 4k 2 + Ak + 1 = 2(2k 2 + 2k) + 1 which is odd, so


is

not divisible by 2, much less by 4.

contrapositive

method 120

direct method 119

divide 4

equivalent 40

even 5

Fundamental Theo-

rem of Arith-

metic 87

implication 35, 36

integer 3

odd 5

positive integer 3

proof 4

theorem 2

83.2.1 Remark The preceding proof is written the way such proofs commonly

appear in number theory texts: no overt statement is made concerning the structure
of the proof. You have to deduce the structure by the way it proceeds. In this
proof,

P is the statement “2 | n” and Q is the statement “4 | n 2 ”. To prove P 44 Q , the

proof proceeds to prove first (before the phrase “Now suppose”) that P =>■ Q by

the direct method, and then to prove that Q => P by the contrapositive method,

that is, by proving —>P => — i Q by the direct method.

83.2.2 Exercise Prove that for all integers m and n, m + n is even if and only

if rn — n is even.

83.2.3 Exercise Let cc be a relation on a set A. Prove that a is reflexive if and

only if C a .

83.2.4 Exercise Let a be a relation on a set A. Prove that a is antisymmetric

if and only if

a n a op C Aq

84. Multiple equivalences

Some theorems are in the form of assertions that three or more statements are

equivalent.

This theorem provides an example:

84.2 Theorem

The following are equivalent for a positive integer n:

D.l n is divisible by 4.

D.2 n/2 is an even integer.


D.3 n/4 is an integer.

124

conclusion 36

div 82

equivalent 40

implication 35, 36

include 43

integer 3

mod 82, 204

nonnegative integer 3

positive integer 3

quotient (of inte-

gers) 83

relation 73

remainder 83

rule of inference 24

symmetric 78, 232

84.2.1 Remark In proving such a theorem, it is only necessary to prove three

implications, not six, provided the three are chosen correctly. For example, it
would

be sufficient to prove P => Q , Q => R and R => P . Then for example Q => P

follows from Q =>■ R and R =>■ P. (See Problem 84.2.3).

84.2.2 Warning Theorem 84.2 does not say that n is divisible by 4. It says that

if one of the statements is true, the other two must be true also (so if one is
false

the other two must be false). It therefore says

(P 44 Q) A (Q 44 R) A (P 44 R)

for certain statements P, Q and R. That is the same as asserting six implications,

P=^Q,Q=^P,P=^R,R=^P,Q=^R, and R =>■ Q .

84.2.3 Exercise Write out careful proofs of Theorem 84.2 in two ways:

a) (D.l) => (D.2), (D.2) =$■ (D.3), and (D.3) =4- (D.l), and

b) (D.l) => (D.3), (D.3) => (D.2), and (D.2) =* (D.l).

84.2.4 Exercise Prove that the following three statements are equivalent for any

sets A and B:

a) AC B

b) AU B = B

c) AnB = A

84.2.5 Exercise Let a be a relation on a set A. Prove that the following three

statements are equivalent.

a) a is symmetric.

b) a C a op .

c) a = a op .

85. Uniqueness theorems

In a particular system such as the positive integers, any uniqueness theorem gives
a

rule of inference. Such a rule only applies to the data type for which the
uniqueness

theorem is stated.

85.1.1 Example Theorem 60.2 says that the quotient and remainder are uniquely

determined by Definition 60.1. This provides a rule of inference for nonnegative

integers:

m = qn + r, 0 < r < n (— (q = mdivn) A (r = mmodn) (85.1)

85.1.2 Remark The conclusion of this rule of inference can be worded this way:

q is the quotient and r is the remainder when rn is divided by n. For example,

because to = 50, n = 12, q = 4 and r = 2 satisfy Rule (85.1), 4 = 50 div 12 and

2 = 50 mod 12. You do not have to do a long division to verify that; it follows
from

Rule (85.1).

125

85.1.3 Exercise Prove that if 0 <m — qn<n, then q = mdivn. (Answer on

page 247.)

85.1.4 Exercise Use Rule (85.1) to prove that if r = mmodn and r' = m/rnodn,

then (m + m^modn is either r + r' or r + r 7 — n.

85.1.5 Exercise Use Rule (85.1) to prove that if r = mmodn, then n\m — r.

85.1.6 A rule for GCD’s For positive integers m and n, the greatest common

divisor GCD(m,?r) is the largest integer dividing both m and n; this definition was

also given in Chapter 60. This obviously determines the GCD uniquely — there

cannot be two largest integers which divide both m and n. This can be translated

into a rule of inference:


conclusion 36

divide 4

div 82

exponent 87

GCD 88

implication 35, 36

integer 3

mod 82, 204

positive integer 3

prime 10

rule of inference 24

tautology 105

theorem 2

(Ve) (^[d | m) A (d \ n) A ((e | m A e | n) =4- e<d)^j (— d = GCD(m,n) (85.2)

85.1.7 Example Let’s use the rule just given to prove Theorem 64.1. We must

prove that the number d which is the product of all the numbers p mm ( e p( m )> e
p( n ))

for all primes p which divide m or n or both is GCD(m,n) .

First, d | m and d | n, since the exponent of any prime p in d, which is

min(e p (m),e p (n))

is obviously less than or equal to e p (m) and to e p (n) , so Theorem 62.4


applies. Thus

we have verified two of the three hypotheses of Rule (85.2). As for the third,
suppose

e | m and e\n. Then e p (e) < e p (m ) and e p (e) < e p (n) , so e p (e) < min(e p
(m),e p (n)) ,
so e | d. But if e\d, then e < d, so the third part of Rule (85.2) is correct.
Hence

the conclusion that d = GCD (m,n) must be true.

85.1.8 Exercise State and prove a rule like Rule (85.2) for LCM(m,?i).

86. Proof by Contradiction

Another hard-to-understand method of proof is proof by contradiction, one form of

which is expressed by this rule of inference:

86.1 Theorem

-iQ, P => Q (— -i-P

( 86 . 1 )

86.1.1 Remarks

a) Theorem 86.1 follows from the tautology

(-.QA(P Q )) -i P

b) This rule says that to prove -i P it suffices to prove ~>Q and that P =f- Q .

126

decimal 12, 93

divide 4

even 5
factor 5

finite 173

Fundamental Theo-

rem of Arith-

metic 87

implication 35, 36

infinite 174

integer 3

odd 5

prime 10

proof by contradic-

tion 126

proof 4

rational 11

real number 12

reductio ad absur-

dum 126

remainder 83

rule of inference 24

theorem 2

usage 2

86.1.2 Usage A proof using the inference rule of Theorem 86.1 is called proof

by contradiction, or reductio ad absurdum (“r.a.a”).

86.1.3 Remarks

a) In practice it frequently happens that Q is obviously false so that the work

goes into proving P =t- Q . Thus a proof of —> P by contradiction might begin,
“Suppose P is true ... ” !

b) Authors typically don’t tell the reader they are doing a proof by contradiction.

It is generally true that mathematical authors are very careful to tell the reader

which previous or known theorems his proof depends on, but says nothing at

all about the rule of inference or method of proof being used.

As an illustration of proof by contradiction, we will prove this famous theorem:

86.2 Theorem

V2 is not rational.

86.2.1 Remarks

a) The discovery of this theorem by an unknown person in Pythagoras’ religious

colony in ancient Italy caused quite a scandal, because the “fact” that any

real number could be expressed as a fraction of integers was one of the beliefs

of their religion (another was that beans were holy).

b) Theorem 86.2 is a remarkable statement: it says that there is no fraction m/n

for which (m/n) 2 = 2. Although y/2 is approximately equal to 1414/1000, it

is not exactly equal to any fraction of integers whatever. The fact that y/2

has a nonterminating decimal expansion does not of course prove this, since

plenty of fractions (e.g., 1/3) have nonterminating decimal expansions.

How on earth do you prove an impossibility statement like that? After all,

you can’t go through the integers checking every fraction m/n. It is that sort

of situation that demands a proof by contradiction.

Proof Here is the proof, using the Fundamental Theorem of Arithmetic. Suppose

y/2 is rational, so that for some integers m and n, 2 = (m/n) 2 . Then 2 n 2 = m


2 .

Every prime factor in the square of an integer must occur an even number of times.

Thus e 2 (m 2 ) is even and ^(n 2 ) is even. But e2(2n 2 ) = l + e 2 (n 2 ), so


e2(2n 2 ) is

odd, a contradiction.

86.2.2 Remark In fact, n (and many other numbers used in calculus) is not

rational either, but the proof is harder.

86.2.3 Worked Exercise Use the Fundamental Theorem of Arithmetic to prove

that there are an infinite number of primes.

Answer This will be a proof by contradiction. Suppose there is a finite number

of primes: suppose that p\,p 2 ,... ,Pk are all the primes. Let m = p\ -p 2 ■ ■ -pk
+ 1 •

Then the remainder when m is divided by any prime is 1 . Since no prime divides

m, it cannot have a prime factorization, contradicting the Fundamental Theorem

of Arithmetic.

127

86.2.4 Exercise Use proof by contradiction to prove that if p is a prime and

p > 2, then p is odd. (Answer on page 247.)

86.2.5 Exercise Prove that for all rational numbers x, ( x 2 < 2) ( x 2 < 2) .

86.2.6 Exercise Give an example of a pair of distinct irrational numbers r and

s with the property that r + s is rational.

86.2.7 Exercise Use proof by contradiction to prove that if r and s are real

numbers and r is rational and s is not rational, then r + s is not rational.


86.2.8 Exercise Use proof by contradiction to prove that for any integer k > 1

and prime p, the k th root of p is not rational.

86.2.9 Exercise (hard) Use Problem 86.2.8 to prove that the kth. root of a

positive integer is either an integer or is not rational.

definition 4

equivalent 40

even 5

Fundamental Theo-

rem of Arith-

metic 87

integer 3

integral linear combi-

nation 127

mod 82, 204

odd 5

positive integer 3

prime 10

proof by contradic-

tion 126

rational 11

86.2.10 Exercise (hard) Show that there are infinitely many primes p such that

p mod 4 = 3. Hint: Use proof by contradiction. Assume there are only finitely

many such primes, and consider the number m which is the product of all of them.

Consider two cases, rn mod 4 = 1 and mmod4 = 3, and ask what primes can divide
771 + 2 or 777 + 4. Use problem 60.5.6, page 85 and other similar facts. Note that
the

similar statement about p mod 4 = 1 is also true but much harder to prove.

87. Bezout’s Lemma

The Fundamental Theorem of Arithmetic, that every integer greater than one has a

unique factorization as a product of primes, was stated without proof in Chapter


62.

It actually follows from certain facts about the GCD by a fairly complicated proof
by

contradiction. This proof is based on Theorem 87.2 below, a theorem which is worth

knowing for its own sake. The proof of the Fundamental Theorem is completed in

Problems 104.4.1 through 104.4.4.

87.1 Definition: integral linear combination

If 777 and 77 are integers, an integral linear combination of 777 . and n

is an integer d which is expressible in the form d = am + bn , where a

and b are integers.

87.1.1 Example 2 is an integral linear combination of 10 and 14, since

3x10-2x14 = 2

However, 1 is not an integral linear combination of 10 and 14, since any integral

linear combination of 10 and 14 must clearly be even.

87.1.2 Remark Note that in the definition of integral linear combination, the

expression d = am . + bn does not determine a and b uniquely for a given m and n .

128
divide 4

Euclidean algo-

rithm 92

Fundamental Theo-

rem of Arith-

metic 87

GCD 88

integer 3

integral linear combi-

nation 127

intersection 47

mod 82, 204

positive integer 3

theorem 2

87.1.3 Example 3x10 — 2x14 = 2 and — 4 x 10 + 3 x 14 = 2. (See Exer-

cise 88.3.7.)

87.1.4 Exercise Show that if d\m and d\n then d divides any integral linear

combination of m and n.

87.2 Theorem: Bezout’s Lemma

If m and n are positive integers, then GCD(m,n) is the smallest positive

integral linear combination of m and n .

87.2.1 Remark Bezout’s Lemma should not be confused with Bezout’s Theorem,
which is a much more substantial mathematical result concerning intersections of

surfaces defined by polynomial equations.

87.2.2 Example GCD(10,14) = 2, and 2 is an integral linear combination of 10

and 14 (2 = 3 • 10 + (— 2) • 14) but 1 is not, so 2 is the smallest positive


integral

linear combination of 10 and 14.

87.2.3 Proof of Bezout’s Lemma We prove this without using the Fundamental

Theorem of Arithmetic, since the lemma will be used later to prove the Fundamental

Theorem.

Let e be the smallest positive integral linear combination of m and n . Suppose

e = am J rbn. Let d = GCD(m,n).

First, we show that d < e. We know that d \ m and d\n, so there are integers h

and k for which m = dh and n = dk. Then e = am + bn = adh + bdk = d(ah + bk )

is divisible by d . It follows that d<e.

Now we show that e | m and e | n . Let m = eq + r with 0 < r < e . Then

r = m — eq = m — ( am. + bn)q = (1 — aq)m — bqn

so r is an integral linear combination of m and n. Since e is the smallest positive

integral linear combination of m and n and r < e , this means r = 0 , so e | m . A

similar argument shows that e | n .

It follows that e is a common divisor of m and n and d is the greatest common

divisor ; hence e <d. Combined with the previous result that d < e, we see that

d = e, as required.

88. A constructive proof of Bezout’s Lemma

The preceding proof of Bezout’s Lemma does not tell us how to calculate the
integers
a and b for which am + bn = GCD (m,n). For example, see how fast you can find

integers a and b for which 13a + 216= 1. (See Exercise 107.3.4.)

We now give a modification of the Euclidean algorithm which constructs integers

a and 6 for which GCD(m,n) = am + bn. The Euclidean algorithm is given as

program 65.1, page 93, based on Theorem 65.1, which says that for any integers rn

and n, GCD(m,n) = GCD(n,mnrodn) . Program 65.1 starts with M and N and

129

repeatedly replaces N by M mod N and M by N . The last value of N before it

becomes 0 is the GCD. This lemma shows how being an integral linear combination

is preserved by that process:

88.1 Lemma

Let m and n be positive integers.

B.l The integers m and n are integral linear combinations of m and

n.

B.2 If u and v are integral linear combinations of m and n and

then umodv is also an integral linear combination of m and n.

div 82

Euclidean algo-

rithm 92

GCD 88
integer 3

integral linear combi-

nation 127

lemma 2

mod 82, 204

positive integer 3

proof 4

Proof B.l is trivial: m=lxm + 0xn and n = 0xm+lxn. As for B.2, suppose

u = wm + xn and v = yrri + zn . Let u = qv + r with 0 < r < u , so r = u mod v .

Then

r = u — qv = wm + xn — q(ym + zn) = (w — qy)m + (x — qz)n

so r is an integral linear combination of m and n, too.

88.2 A method for calculating the Bezout coefficients

We now describe a method for calculating the Bezout coefficients based on Lemma
88.1.

Given positive integers m and n with d = GCD(m,n) , we calculate integers a and

b for which am + bn = d as follows: Make a table with columns labeled u, v, iv

and w = am + bn .

1. Put u = m, v = n, w = mrnodn in the first row, and in the last column put

the equation w = m — (mdivn)n. Note that this equation expresses mrnodn

in the form am + bn (here a = 1 and b = — m divn).

2. Make each succeeding row v! , v' , w' , w' = a' m + b'n by setting u! =v (the

entry under v in the preceding row) , v' = w and w' = v mod w , and solving
for a' and b' by using the equation w' = v! — (u' divv')v' and the equations in

the preceding rows. Note that the entry in the last column always expresses

w in terms of the original m and n, not in terms of the u and v in that row.

3. Continue this process until the entry under w is GCD(?n,n) (this always

happens because the first three columns in the process constitute the Euclidean

algorithm) .

88.2.1 Example The following table shows the calculation of integers a and b

for which 100a + 366 = 4 .

u v w

100 36 28 28 = 100-2-36 Note that 100 div 36 = 2

36 28 8 8 = 36- 28 = 36- (100-2 -36) = 3-36- 100

28 8 4 4 = 28- 3 -8 = 100- 2 -36-3(3-36- 100) =4- 100- 11 -36

so that a = 4 , 6 = — 11.

130

constructive 130

divide 4

Fundamental Theo-

rem of Arith-

metic 87

GCD 88

infinite 174
integer 3

integral linear combi-

nation 127

nonconstructive 130

relatively prime 89

rule of inference 24

88.3 Constructive and nonconstructive

The two proofs we have given for Theorem 87.2 illustrate a common phenomenon

in mathematics. The first proof is nonconstructive; it shows that the requisite

integers a and 6 exist but does not tell you how to get them. The second proof is

constructive; it is more complicated but gives an explicit way of constructing a

and b.

88.3.1 Exercise Express a as an integral linear combination of b and c, or explain

why this cannot be done.

12

16
4

12

16

26

30

26

30

26

30

51

100
(Answer on page 247.)

88.3.2 Exercise Express 1 as an integral linear combination of 13 and 21.

88.3.3 Exercise (M. Leitman) Suppose a, b, m and n are integers. Prove that

if m and n are relatively prime and am + bn = e, then there are integers a' and b'

for which a'm + b'n = e + 1 . (Answer on page 247.)

88.3.4 Exercise Prove without using the Fundamental Theorem of Arithmetic

that if GCD(m,n) = 1 and m \ nr then m\r . (Use Bezout’s Lemma, page 128.)

88.3.5 Exercise Suppose that a, b and c are positive integers for which c =

12a — 86. Show that GCD(a,6) < |.

88.3.6 Exercise Prove that the following rule of inference is valid (use Bezout’s

Lemma, page 128).

e\m, e\n (— e | GCD(m,n)

(It follows that the statement “e < d” in Rule (85.2) can be replaced by “e | d” .)

88.3.7 Exercise (hard) Prove that if d is an integral linear combination of m

and n then there are an infinite number of different pairs of integers a and 6 for

which d = am + bn .

88.3.8 Exercise Use Bezout’s Lemma (page 128) to prove Corollary 64.2 on

page 90 without using the Fundamental Theorem of Arithmetic.

131
89. The image of a function

If F : A — >■ B is a function, it can easily happen that not every element of B is

a value of F . For example, the function x >— > x 2 : R — > R takes only
nonnegative

values.

89.1 Definition: image of a function

The image of F : A-^ B is the set of all values of F , in other words

the set {b £ B \ (3a: A)(F(a) = b)} . The image of F is also denoted

Irn(F) .

codomain 56

definition 4

equivalence 40

equivalent 40

fact 1

function 56

image 131

include 43

real number 12

take 57

usage 2

89.1.1 Fact This definition gives the equivalence:

(3a)(F(a) = b) 44 feelrnF
89.1.2 Fact For any function F, Im(F)CcodF.

89.1.3 Usage Many authors use the word “range” for the image, but others use

“range” for the codomain.

89.1.4 Example The image of the squaring function x i — > x 2 : R — > R is the set
of

nonnegative real numbers.

89.1.5 Example Let the function F : {1,2,3} — > {2, 4, 5, 6} be defined by F( 1) =


4

and F( 2) = F( 3) = 5. Then F has image {4,5}.

89.1.6 Remark The image of a function can be difficult to determine if it is

given by a formula; for example it requires a certain amount of analytic geometry

(or calculus) to determine that the image of the function G(x ) = x 2 + 2x + 5 is


the

set of real numbers > 4 , and determining the image of more complicated functions

can be very difficult indeed.

89.1.7 Exercise Find the image of the function n+ 1 : N — >• N. (Answer on

page 247.)

89.1.8 Exercise Find the image of the function m — > n — 1 : Z — > Z.

89.1.9 Exercise Find the image of the function x>— > x 2 — 1 : R — >-R.

89.1.10 Exercise Find the image of the function x>— )-x 2 + a: + l:R— >-R.

132

definition 4

function 56
image function 132

image 131

include 43

interval 31

inverse image 132

powerset 46

under 57, 132

90. The image of a subset of the domain

The word “image” is used in a more general way which actually makes the image a

function itself.

90.1 Definition: Image of a subset

Let F : A-^ B is a function, and suppose CCA. Then F{C) denotes

the set {F(x) \ x € C} , and is called the image of C under F . The

map C H > F(C) defines a function from VA to VB called the image

function of F .

90.1.1 Remark In particular, F(A) is what we called Inr(T 1 ) in Chapter 89.

90.1.2 Example If F : {1,2,3} — > {2, 4, 5, 6} is defined as in 89.1.5 by F(l) = 4

and F( 2) = F( 3) = 5, then F({1,2}) = {4,5} and F($) = 0. Thus the image of

{1,2} under F is {4,5}.

90.1.3 Warning The image function is not usually distinguished from F in nota-

tion. A few texts use F* : VA — > VB , and so would write F(x) for x G A but F*(C)

for a subset CCA. In this text, as in almost all mathematics texts, we simply write
F(C). Context usually disambiguates this notation (but there are exceptions!).

90.1.4 Exercise Describe a function where our notation F(C) is ambiguous.

90.1.5 Exercise Let F be defined as in Example 90.1.2. What are F({2,3}) and

F({3})? (Answer on page 247.)

90.1.6 Exercise Let F : R — > R be defined by F(x) = x 2 + 1 . What is F((3 . .


4)) ?

What is FQ-1..1])?

90.1.7 Exercise Let F be defined as in Example 90.1.2. How many ordered pairs

are in the graph of the image function of FI

91. Inverse images

91.1 Definition: Inverse image

Let F : A—> B be a function. For any subset C C B , the set

{acA | F(a) € C }

is called the inverse image of C under F . also written 1 ?_1 (C').

91.1.1 Example Let F : {1,2,3} — > {2, 4, 5, 6} be defined (as in Example 89.1.5)

by F{ 1) = 4 and F{ 2) = F( 3) = 5. Then F-^^,6}) = {1}, E“ 1 ({5}) = {2,3},

and F~ 1 ({2,6}) =0.

133

91.1.2 Example For the function F : R — >■ R defined by F(x) = x 2 + 1 ,


F“ 1 ([2..3]) = [l..\/2]U[-v/2..-l]

and

F- 1 ([0..1]) = {0}

91.1.3 Inverse image as function Like the image function, this inverse image

function can also be defined as a function F :VB — > V A (note the reversal), where

F~ 1 (D) = {xeA | F(x)eD}

for any D C B . F~ 1 is sometimes denoted F* .

91.1.4 Usage It is quite common to write F~ 1 (x) instead of _F _1 ({x}).

91.1.5 Example For the function of Example 91.1.2, F _1 (3) = {— \/2, V2)} .

codomain 56

definition 4

fact 1

function 56

graph (of a func-

tion) 61

image 131

include 43

inverse image 132

onto 133

powerset 46

real number 12

surjection 133

surjective 133

union 47

usage 2
91.1.6 Exercise Let F : R -> R be defined by F(x) = x 2 + 1 . What is F 1 ({1,2})?

What is F- 1 ^!.^))?

91.1.7 Exercise For any function F : A-+ B , what is F 1 (0)? What is F 1 (B)7

92. Surjectivity

92.1 Definition: surjective

Let F : A—> B be a function. F is said to be surjective if and only if

Im (F) = B.

92.1.1 Fact F : A—t B is surjective if and only if for every element element b 6 B

there is an element a G A for which F(a) = b.

92.1.2 Usage If F is surjective, it is said to be a surjection or to be onto.

92.1.3 Warning Whether a function is surjective or not depends on the codomain

you specify for it.

92.1.4 Example For the two functions S : R — > R and T : R — > R + of 39.7.3, with

S(x) = T(x) = x 2 , S is not surjective but T is. To say that T is surjective is to

say that every nonnegative real number has a square root. Authors who do not

normally specify codomains have to say, “T is surjective onto R + .”

92.1.5 Example A function F : R — > R is surjective if every horizontal line


crosses

its graph.
134

contrapositive 42

converse 42

coordinate func-

tion 63

definition 4

fact 1

function 56

identity function 63

identity 72

image 131

implication 35, 36

inclusion function 63

injection 134

injective 134

one to one 134

powerset 46

reflexive 77

relation 73

surjective 133

take 57

usage 2

92.1.6 Exercise How do you prove that a function F : A->- B is not surjective?

92.1.7 Exercise Let a be a relation on A.

a) Show that if a is reflexive, then the coordinate functions pf : a — > A and


P 2 '-u->A are surjective.

b) Show that the converse of (a) need not be true.

92.1.8 Exercise (hard) Show that there for any set S , no function from S to

VS is surjective. Do not assume S is finite.

Extended hint: If F : S — >■ VS is a function, consider the subset

{x | x is not an element of E(x)}

No argument that says anything like “the powerset of a set has more elements than
the

set” can possibly work for this problem, and therefore such arguments will not be
given

even part credit. The reason is that we have developed none of the theory of what
it means

to talk about the number of elements of an infinite set, and in any case this
problem is a

basic theorem of that theory.

Let’s be more specific: One such invalid argument is that the function that takes x
to

{cc} is an injective function from S to VS , and it clearly leaves out the empty
set (and

many others) so VS has “more elements” than S . This is an invalid argument.


Consider

the function from N to N that takes n to 42n. This is injective and leaves out lots
of

integers, so does N have more elements than itself?? (In any case you can come up
with

other functions from N to N that don’t leave out elements.)

93. Injectivity

93.1 Definition: injective


F : A—t B is injective if and only if different inputs give different out-

puts, in other words if a yf a! => F(a) / F(a') for all a, a' £ A.

93.1.1 Fact To say F : A — >• B is injective is equivalent to saying that F(a) =

F(a') =4- a = a' for all a, a' € A (the contrapositive of the definition).

93.1.2 Usage An injective function is called an injection or is said to be one to

one.

93.1.3 Example The squaring function S : R — > R is not injective since S(x) =

S(—x) for every x £ R. The cubing function x x 3 : R — > R of course is injective,

and so is any identity function or inclusion function on any set.

93.1.4 Exercise In this problem, A = {1,2, 3, 4} and B = {2,3,4}. For each of

these functions, state whether the function is injective, whether it is surjective,


and

give its image explicitly.

a) F:A-tB, T(F) = {(1,4), (2,4), (3,2), (4,3)} .

b) F : A-* B , T(F) = j (1,3), (2,2), (3,2), (4,3) j .

c) id, 4 .

135

d) The inclusion of B into A.

e) The inclusion of B into Z.

f) C 3 : A — >• B (the constant function).


g) {TRUE, FALSE}.

h) pi : A x B — > A.

i) + : B x B ^ Z.

j) The predicate “n is even” regarded as a characteristic function with domain

A.

(Answer on page 247.)

93.1.5 Exercise Same instructions as for Exercise 93.1.4

a) x 3x — 4 : R — >■ R .

b) x 1 — y x 3 : R — )■ R.

c) F = Xx.(x 2 + 1) : R -» R.

d) ii->2-s 2 :R-^R.

(Answer on page 248.)

93.1.6 Exercise Let F : A—> B be a function of the type indicated. Give a precise

description of all the sets A and B for which F is injective, and a precise
description

of all the sets A and B for which F is surjective.

a) An identity function.

b) An inclusion function.

c) A constant function.

d) An empty function.

e) A coordinate function.
93.1.7 Exercise How do you prove that a function F : A B is not injective?

(Answer on page 248.)

93.1.8 Exercise Prove that the function (m,n) >->• 2 m 3 n — 1 : N x N — >■ N is


injec-

tive.

93.1.9 Exercise Give an example of a function F : R — > R with the property that

F is not injective but TjN is injective.

93.1.10 Exercise (calculus)

a) Show that if a cubic polynomial function x *->• ax 3 + bx 2 + cx + d is not


injec-

tive, then b 2 — 3 ac > 0. (The “3” is not a misprint.)

b) Show that the converse of the statement in (a) is not true.

c) Think of a more sophisticated condition involving a, b, c and d that is true

if and only if the function is injective.

characteristic func-

tion 65

constant function 63

coordinate func-

tion 63

empty function 63

even 5

function 56

identity function 63

inclusion function 63

injective 134
lambda notation 64

predicate 16

surjective 133

136

bijection 136

bijective 136

Cartesian product 52

coordinate func-

tion 63

definition 4

functional relation 75

function 56

graph (of a func-

tion) 61

identity 72

injective 134

one to one correspon-

dence 136

positive real num-

ber 12

relation 73

restriction 137

subset 43

surjective 133

usage 2
94. Bijectivity

94.1 Definition: bijective

A function which is both injective and surjective is bijective.

94.1.1 Remark A bijection F : A — > B matches up the elements of A and B

each element of A corresponds to exactly one element of B and each element of B

corresponds to exactly one element of A.

94.1.2 Usage A bijective function is called a bijection and is said to be a one

to one correspondence.

94.1.3 Example For any set A, id^:A — > A is bijective. Another example is the

function F : {1,2,3} — > {2,3,4} defined by F( 1) = 3, F( 2) = 2, F( 3) = 4.

94.1.4 Exercise Show that the function G:N — >■ Z defined by

is a bijection.

G{n)

— | n even

^±1 n odd

94.1.5 Exercise Show how to construct bijections (3 as follows for any sets A, B
and C.

a) (3: AxB^-BxA.

b) (3: {Ax B)xC -> Ax{BxC).

c) f3 : {1} x A -» A.

94.1.6 Exercise Let a be a relation from A to B.

a) Prove that a is functional if and only if the first coordinate function pf is

injective. (See Section 51.4.)

b) Prove that a is the graph of a function from A to B if and only if the first

coordinate function is bijective.

94.1.7 Exercise Give an example of a function F: R — R ++ for which F is bijec-

tive. (R ++ is the set of positive real numbers.)

94.1.8 Exercise (hard) Give an example of a function F : R — - > R + for which F

is bijective. (R + is the set of nonnegative real numbers.)

94.1.9 Exercise (hard) Let F : A — >■ B be a function. Prove that the restriction

to T{F) of the first coordinate function from Ax B is a bijection.

94.1.10 Exercise (hard) Prove that a subset C of AxB is the graph of a

function from A to B if and only if the restriction to C of the first coordinate

function is a bijection.

137
94.1.11 Exercise (hard) Let /3:Kel(A,B) — >■ (' PB)^ be the function which takes

a relation a to the function a* : A -> VB defined by a* (a) = {6 e B \ aab} (see

Definition 53.2). Show that (3 is a bijection. (This function is studied further in

Problem 100.1.8, page 145, and in Problem 101.5.10, page 150.)

94.1.12 Exercise (hard) Let A, B and C be sets. In this exercise we define a

particular function (3 from the set B ^ x C ^ to the set ( B x (7) , so that (3

as input a pair of functions (f,g) , with / : A—t B and g : A — >• C , and outputs
a

function f3(f,g) from A to B x C . Here is the definition of (3: for all a & A,

/3{f,g)(a) = ( f(a),g(a ))

bijection 136

definition 4

function 56

identity 72

include 43

permutation 137

powerset 46

relation 73

restriction 137

take 57

usage 2

Prove that (3 is a bijection.

95. Permutations
95.1 Definition: permutation

A permutation of a set A is a bijection f3: A—t A.

95.1.1 Example The fact just noted that id/i is a bijection says that id^ is a

(not very interesting) permutation of A for any set A.

95.1.2 Example The function F : {1,2,3} — >■ {1,2,3} that takes 1 to 2, 2 to 1

and 3 to 3 is a permutation of {1,2,3}.

95.1.3 Usage Many books define a permutation to be a list exhibiting a rear-

rangement of the set {1,2, .. . ,n} for some n. If the ith entry in the list is a*
that

indicates that the permutation takes i to a* .

95.1.4 Example The permutation of Example 95.1.2 would be given in the list

notation as (2,1,3) .

95.1.5 Worked Exercise List all the permutations of {1,2, 3, 4} that take 1 to

3 and 2 to 4.

Answer (3,4, 1,2) and (3,4,2, 1),

95.1.6 Exercise List all six permutations of {1,2,3}.

96. Restrictions and extensions

96.1 Definition: restriction

Suppose F :A—> B is a function and A' C A. The restriction of F

to A' is a function denoted F\A! : A' — » B, whose value ( F\A')(a ) for

a € A' is F(a) .
96.1.1 Remark Note that the codomain of the restriction is the codomain of the

function.

138

codomain 56

constant function 63

coordinate 49

definition 4

domain 56

function 56

graph (of a func-

tion) 61

identity 72

inclusion function 63

injective 134

integer 3

lambda notation 64

positive integer 3

predicate 16

restriction 137

subset 43

surjective 133

tuple 50, 139, 140

usage 2
96.1.2 Example Let F : {1,2,3} — > {2, 4, 5, 6} be defined by F(l) = 4 and F(2) =

F( 3) = 5, as before. Then F restricted to {2,3} has graph |(2,5), (3,5)| and

F|{1,3} has graph |(1,4), (3,5)| . Observe that F|{2,3} is a constant function and

-F|{1,3} is injective, whereas F is neither constant nor injective.

96.2 Definition: extension of a function

Let F : A — > B and let C be a set containing A as a subset. Any function

G'.C^rB for which G\ A = F is called an extension of F to C.

96.2.1 Remark Note that both “restriction” and “extension” have to do with the

domain.

96.2.2 Example Let F : {1,2,3} — > {2, 4, 5, 6} be defined by F(l) = 4 and F(2) =

F( 3) = 5, as before. Then F has four extensions F\ , F 2 , T3, and F 4 , to {1,2,


3, 7 },

defined by F\(7) = 2 , F 2 (7) = 4 ,Fs(7) = 5 and F 4 (7) = 6. (Of course in all


cases

Fi(n) is the same as F(n) for n = 1,2,3).

96.2.3 Example The absolute value function ABS :R — > R is an extension of the

inclusion of R + into R, and id^ is a different extension of the same function.

96.2.4 Usage The meaning just given of “extension” is a different usage of the

word from the meaning used in Definition 18.1 of the set of data items for which a

predicate is true.

You may wonder how the word “extension” got two such different meanings.

The answer is that the concept of extension of a predicate was named by logicians,

whereas the concept of extension of a function was named by mathematicians.


96.2.5 Exercise For each of these functions from R to R, state whether the

function is injective or surjective, and state whether its restriction to R + = {r£

R | r > 0} is injective or surjective.

a) xH’i 2 .

b) \x.x-\-l.

c) Ax.l — x.

(Answer on page 248.)

97. Tuples as functions

Let n be a positive integer, and let

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

An n-tuple

a — (ai , • • • , a n )

in A n associates to each element i of n an element at of A. This determines a

function i i-y a t with domain n and codomain A. Conversely, any such function

determines an n-tuple in A n by setting its coordinate at i to be its value at i .

139
When a £ A\ x A 2 x • • • x A n , so that different components are in different
sets,

this way of looking at n-tuples is more complicated. Every coordinate ai is an

element of the union C = A\ U A -2 U • • • U A n , so that a can be thought of as a

function from n — >• C. In this case, however, not every such function is a tuple
in

A\ x A 2 x • • • x A n : we must impose the additional requirement that a* E A t .

We sum all this up in an alternative definition of tuple:

97.1 Definition: tuple as function

A tuple in rnuA is a function

a : n -> Ai U A 2 U • • • U A n

with the property that for each i , a(i) E Ai .

Cartesian product 52

coordinate 49

decimal 12, 93

definition 4

digit 93

domain 56

function 56

graph (of a func-

tion) 61

set 25, 32

string 93, 167

tuple 50, 139, 140

union 47
97.1.1 Example The tuple (2,1,3) is the function 1 1 — > 2 , 2 1 — >• 1 , 3 1 — >3
(compare

Section 95.1.3).

97.1.2 Example The tuple (5, 5, 5, 5) is the constant function C§ : {1,2, 3, 4} — >
Z.

97.1.3 Exercise Write the domain and the graph of these tuples regarded as

functions on the index set.

a) (2, 5, -1,3, 6).

b) <7T, 5, 7T — 1, x/2) .

c) ((3, 5), (8, -7), (5, 5)).

(Answer on page 248.)

97.1.4 Example A simple database might have records each of which consists of

the name of a student, the student’s student number, and the number of classes the

student takes. Such a record would be a triple (w, x, n ) , where w is an element


of the

set A* of strings of English letters and spaces (this notation is introduced


formally

in Definitions 109.2 and 110.1), x is an element of the set D* of strings of


decimal

digits, and n E N. This triple corresponds to a function F : {1,2,3} A* x D* x N

with the property that F( 1) E A* , F( 2) € D* and F( 3) E N.

Modeling detabases this way is the principle behind relational database theory.

97.1.5 Remark In the case that all the Ai are the same, so that a E A n , we

now have the situation that A n (the set of functions from n to A, where n =

{1,2,... , n}) and A n (the set of n-tuples in A ) are essentially the same thing.
That is the origin of the notation B ^ .

97.2 Tuples with other index sets

The discussion above suggests that by regarding a tuple as a function set, we can

use any set as index set.

97.2.1 Example In computer science it is often convenient to start a list at 0

instead of at 1 , giving a tuple (ao,ai, . . . ,a n ) . This is then a tuple


indexed by the

set {0,1,... ,n} for some n (so it has n+1 entries!).

140

composite (of func-

tions) 140

composite 10, 140

definition 4

domain 56

family of elements

of 140

field names 140

functional composi-

tion 140

function 56

indexed by 140

infinite 174

integer 3
set 25, 32

tuple 50, 139, 140

97.2.2 Example An infinite sequence of integers is indexed by N + , so it is an

element of .

97.2.3 Example This is another look at Example 97.1.4. The point of view

that a triple (Jones, 1235551212,4) is a function with domain {1,2,3} has an arbi-

trary nature: it doesn’t matter that the name is first, the student number sec-

ond and the number of classes third. What matters is that Jones is the name,

1235551212 is the student number and 4 is the number of classes. Thus it would

be conceptually better to regard the triple as a function whose domain is the set

{Name,StudentNumber,NumberOfClasses}, with the property that /(Name) G A* ,

-F(StudentNumber) £ D* and T/NumberOfClasses) GN. This eliminates the spu-

rious ordering of data imposed by using the set {1,2,3} as domain.

In this context, the elements of a set such as

{Name,StudentNumber,NumberOfClasses}

are called the field names of the database.

97.3 Definition: function as tuple

A function T : S — > A is is also called an A-tuple or a family of ele-

ments of A indexed by S .

97.3.1 Exercise Write each of these functions as tuples.

a) F : {1,2, 3,4, 5} — >■ R, T(E) = { (2,5), (1,5), (3,3), (5,-1), (4, 17)} .

b) F : {1,2, 3,4,5} — > R, F(n) = (n + l)ir .


c) x i — y : {1,2, 3, 4, 5, 6} — y R .

(Answer on page 248.)

98. Functional composition

98.1 Definition: composition of functions

If F : A — > B and G : B — » C , then G ° F : A — > C is the function defined

for all a G A by (G° F) (a) = G(xxF(a )) . G° F is the composite of F

and G, and the operation is called functional composition.

98.1.1 How to think about composition The composite of two functions is

obtained by feeding the output of one into the input of the other. Suppose F: A—> B

and G : B — >■ C are functions. If a is any element of A, then F(a ) is an element


of

B , and so G(F(a)) is an element of C . Thus applying F . then G, gives a function

from A to C , and that is the composite G° F : A — > C .

98.1.2 Remarks

a) You may be familiar with the idea of functional composition in connection

with the chain rule in calculus.

141

b) Our definition of G°F requires that the codomain of F be the domain of G.


Actually, the expression G(F(a)) makes sense even if codF is only included

in dornG, and many authors allow the composite G°F to be formed in that

case, too. We will not follow that practice here.

98.1.3 Example If A = {1,2, 3,4} , B = {3,4, 5, 6}, C = {1,3, 5, 7}, F is defined

by F(l) = F( 3) =5, F( 2) = 3 and F(4) = 6, and G is defined by G(3) = 7, G( 4) =

5 , G(5) = 1 and G(6) = 3 , then G ° F takes 1 1, 2 H > 7 , 3 e- )• 1 and 4 1 — > 3


.

98.1.4 Warning Applying the function G°F to an element of A involves apply-

ing F , then G — in other words, the notation “G°F” is read from right to left.

Functional composition is associative when it is defined:

98.2 Theorem

If F : A — >■ B , G : B — * C and H : C — > D are all functions, then

H°(G°F ) and ( H°G)°F are both defined and

H°(G°F) = (H°G)°F

Proof Let a 6 A. Then by applying Definition 98.1 twice,

(ffo(Gof)J(a) =H((G°F)(a)'j = H(G(F(a )))

and similarly

^(H °G) (a) = (H°G)(F(a)) = H(G(F(a)))

so H°(G°F) = {H°G)°F.

98.2.1 Warning Commutativity is a different story. If F :A—> B and G:B — » C ,

G ° F is defined, but F ° G is not defined unless A = C . If A = C , then G°F:A^C

and F°G :C — )■ A, so normally F°G G° F . Commutativity may fail even when

A = B = C: For example, let S = x >-)• x 2 : R — > R and T = ii->a: + l:R->R. Then

for any ilR, S{T(x )) = (x + l) 2 and T(S(x )) =x 2 + l,so S°T / T° S .


Pondering the following examples of functional composition may be helpful in

understanding the idea of composition.

98.2.2 Example Let SQ = x i->- x 2 : R — > R + and SQRT = i4 y Ax : R + — >• R.

(yT denotes the nonnegative square root of x.) Let ABS denote the absolute

value function from R to R. Then the following are true.

(i) SQRT°SQ = ABS:R-> R.

(ii) (SQRT°SQ)|R+ = id R+ .

(iii) SQ°SQRT = id R + .

98.2.3 Example If F : A—} B is any function, then

(i) F ° id^ = F and

(ii) id b ° F = F.

This is analogous to the property that an identity element for a binary operation

has (see 50.1), but in fact composition of functions is not a binary operation
since

it is not defined for all pairs of functions.

associative 70

binary operation 67

codomain 56

commutative 71

composite (of func-

tions) 140

composition (of

functions) 140

domain 56
function 56

identity 72

include 43

proof 4

take 57

theorem 2

142

bijective 136

codomain 56

composition (of

functions) 140

domain 56

function 56

graph (of a func-

tion) 61

include 43

inclusion function

injective 134

surjective 133

98.2.4 Example If A C B and BCC, and i:A^-B and j : B — >■ C are the

corresponding inclusion functions, then j°i is the inclusion of A into C .

98.2.5 Example If F : A B and CCA with inclusion map i:C—>A, then

F\C = F°i. In other words, restriction is composition with inclusion.


98.2.6 Exercise Describe explicitly (give the domain and codomain and either

the graph or a formula) the composite G°F if

a) F : {1,2, 3, 4} — »• {3, 4, 5, 6}, with 1 ^ 3, 2 i— >4, 3e-)-6, and 4 i — >- 5 ,


and G :

{3, 4, 5, 6} —>■ {1,3, 5, 7, 9} with 3^1, 4^7, 5^7 and 6^3.

b) F : x !->• x 3 : R — > R, G : x e-x 2x : R — > R.

c) F : x e-x 2x : R — > R. G : x e-t x 3 : R -> R,

d) F = inclusion : N — >■ R , G : x (x/2) : R — > R.

e) F = p\ : R X R — >• R, G:rH’(3,i):R-tRxR.

(Answer on page 248.)

98.2.7 Exercise Let F : A—t B , G : B —$■ C . Show the following facts:

a) If F and G are both injective, so is G°F .

b) If F and G are both surjective, so is G°F .

c) If F and G are both bijective, so is G° F .

d) If G°F is surjective, so is G.

e) If G°F is injective, so is F .

98.2.8 Exercise Give examples of functions F and G for which G°F is defined

and

a) F is injective but G°F is not.

b) G is surjective but G°F is not.

c) G°F is injective but G is not.


d) G°F is surjective but F is not.

98.2.9 Exercise (hard) Let A, B and C be sets.

a) Prove that if F : A — > B is a function and C is nonempty, then G i— >• F°G :

C 1 C 1

is a function which is injective if and only if F is injective, and

surjective if and only if F is surjective.

b) Prove that if H : B — >■ C is a function and A has more than one element, then

TD

G e - > (G°H) : 4 U — » A D is a function which is injective if and only if H is

surjective, and surjective if and only if H is injective.

143

99. Idempotent functions

99.1 Definition: Idempotent function

A function F : A — >■ A is idempotent if F° F = F .

99.1.1 How to think about idempotent functions F is idempotent if doing

F twice is the same as doing it once: If you do F , then do it again, the second
time

nothing happens.

99.1.2 Example The function (i,|/) 4 (i,0):RxR->RxR is idempotent.

Note the close connection between this function and the first coordinate function
p\ : R x R y R .

Cartesian product 52

coordinate func-

tion 63

definition 4

fixed point 143

function 56

idempotent 143

identity 72

image 131

injective 134

surjective 133

theorem 2

usage 2

99.1.3 Example Let S be a set of files that contains a sorted version of every

file in the set. Then “sort” is a function that takes each file in the set to a
possibly

different file. Sorting a file that is already sorted does not change it (that is
true

of many sorting functions found on computers, but not all). Thus sorting and then

sorting again is the same as sorting once, so sorting is idempotent.

99.1.4 Usage Following Example 99.1.2, the word “projection” is used in some

branches of mathematics to mean “idempotent function”. In other brances, “pro-

jection” means “coordinate function” .)

99.1.5 Exercise Let A = {1,2,3}. Give an example of an idempotent function

F : A — > A that is not id 4 . (Answer on page 248.)


99.1.6 Exercise Show that if F : A — > A is injective and idempotent, then F =

id .4 •

99.2 Definition: Fixed point

Let F : A — > A be any function. An element x £ A is a fixed point of

F if F{x) = x.

This is the fundamental theorem on idempotent functions:

99.3 Theorem

A function F : A — > A is idempotent if and only if every element of ImF

is a fixed point of F .

99.3.1 Exercise Prove Theorem 99.3.

99.3.2 Exercise Use Theorem 99.3 to show that if F : A — > A is surjective and

idempotent, then F = id^.

144

codomain 56

commutative

gram 144

definition 4

domain 56

function 56
identity 72

dia-

100. Commutative diagrams

F : A — >■ B and G : B — >• C can be illustrated by this diagram:

(100.1)

If the two ways of evaluating functions along paths from A to C in this diagram

give the same result, then, by definition of composition, H = G°F .

100.1 Definition: commutative diagram

A diagram with the property that any two paths between the same

two nodes compose to give the same function is called a commutative

diagram.

100.1.1 Example To say that the following diagram commutes is to say that

H°F = K°G\ in other words, that for all a € A, H ^F(a)^ = K ^G(a)^ .

F
*■ B

(100.2)

100.1.2 Remarks

a) Commutative diagrams exhibit more of the data involved in a statement such

as U H°F = K°G ” than the statement itself shows (in particular it shows

what the domains and codomains are), and moreover they exhibit it in a

geometric way which is easily grasped.

b) Warning: The concept of commutativity of diagrams and the idea of the

commutative law for operations such as addition are distinct and not very

closely related ideas, in spite of their similar names.

100.1.3 Example Example 98.2.3 on page 141 says that for any function F , this

diagram commutes:

(100.3)
145

100.1.4 Example Theorem 98.2 says that if both triangles in this diagram com-

mute,

■>■ B

(100.4)

then the whole diagram commutes. Thus the associative law for for functional

composition becomes a statement that commutative triangles can be pasted together

in a certain way.

100.1.5 Exercise Draw commutative diagrams expressing these facts:

a) The square of the square root of a nonnegative real number is the number

itself.

b) The positive square root of the square of a real number is the absolute value

of the number.

(Answer on page 248.)


associative 70

commutative dia-

gram 144

composition (of

functions) 140

equivalent 40

function 56

idempotent 143

identity 72

positive real num-

ber 12

powerset 46

real number 12

relation 73

take 57

100.1.6 Exercise Draw commutative diagrams which express each of the follow-

ing facts. No one arrow should be labeled with a composite of two functions -

draw a separate arrow for each function.

a) Addition, as a binary operation on Z, is commutative.

b) Addition as in (a) is associative.

100.1.7 Exercise Prove that if F : A — > A is an idempotent function, then there

is a set B and functions G : A — > B and H : B — > A such that both the following

diagrams commute:
100.1.8 Exercise (hard) Let /? be defined as in Problem 94.1.11, page 137. Let

F : A' A and G : B' -+ B . Let

H:Rel{A,B)-^Rel{A , ,B')

be the function which takes a to the relation a! defined by a' a' b' 44 F(a') a
G(b') .

Let /

K : (VB) A — >• (VB') A

be the function which takes r : A — >■ VB to the function r' : A! -^r VB' defined
by

r'(a') = G~ 1 (r(F(a))

146

commutative 71

composition (of

functions) 140

definition 4

fact 1

function 56

identity 72

inverse function 146

invertible 146

left inverse 146

powerset 46

right inverse 146

usage 2
Show that the following diagram commutes.

Rel(A,B)

Re\(A',B')

(VB)

(VB

'i\A!

101. Inverses of functions


(100.5)

The number 1/2 is the “multiplicative inverse” of the number 2 because their prod-

uct is 1 . A similar relationship can hold between functions, but because


functional

composition is not normally commutative, one has to specify which way the com-

posite is taken.

101.1 Definition: inverse of a function

If F : A — >• B and G : B — »• A, then G is a left inverse to F , and F is

a right inverse to G. if

G°F = id a (101.1)

If G is both a left and a right inverse to F, in other words if both

Equation (101.1) and

FoG = id B (101.2)

hold, then G is an inverse to F.

101.1.1 Usage A function that has an inverse is said to be invertible.

101.1.2 Fact It follows from the definition that if G is an inverse to F , then F

is an inverse to G.

101.1.3 Fact The definition of inverse function can be expressed in other ways

equivalent to Definition 101.1.

a) G is the inverse of F if and only if for all a £ A, G(F(a )) = a and for all

b G B , F(G(b)) = b. ( Both equations must hold.)


b) G is the inverse of F if and only if the following diagrams commute:

(101.3)

147

101.1.4 Example Let F : {1,3,5} — > {2,3,4} be the function that takes 1 to 3,

3 to 4 and 5 to 2. Then the function G: {2,3,4} — > {1,3,5} that takes 2 to 5, 3

to 1 and 4 to 3 is the inverse of F . (And F is the inverse of G.)

101.1.5 Example Example 98.2.2(3) above says that the squaring function is a

left inverse to the square root function: squaring the positive square root gives
you

what you started with. It is not the inverse, however: taking the square root of
the

square won’t give you the number you started with if it is negative. On the other

hand, the cubing function is the inverse of the cube root function.

A function can have more than one left inverse (Problem 101.2.6) but not more than

one inverse:

floor 86

function 56

graph (of a func-

tion) 61

identity 72

inverse function 146


positive real num-

ber 12

proof 4

rule of inference 24

take 57

theorem 2

usage 2

101.2 Theorem: Uniqueness Theorem for Inverses

If F : A—> B has an inverse G : B — >• A, then G is the only inverse to

F.

Proof The proof uses the definition of inverse, Theorem 98.2 and Example 98.2.3:

If H : B — >■ A is another inverse of F , then

H = Hoid B = H°(F°G) = {H°F)°G = id A °G = G

101.2.1 Usage The fact that if a function has an inverse, it has only one, means

that we can give the inverse a name: The inverse of F, if it exists, is denoted F^
1 .

101.2.2 Remark The uniqueness theorem also means we have a rule of inference:

Given F : A — > B and G : B — > A ,

G°F = id A , FoG = id B b G = F~ 1 (101.4)

101.2.3 Exercise Which of the following functions have inverses? If it has one,

give the inverse (by describing its graph or by a formula).

a) F : {1,2, 3, 4} — > {3, 4, 5, 6} , with 1 1 — y 3 , 2 i — >- 4 , 3 >-)• 6, and 4


1 — 5 .
b) G : {1,2, 3, 4} — > {3, 4, 5, 6, 7}, with 1 1 — >- 3 , 2 i->- 4, 3 i— >6, and 4
i — >■ 5 .

c) H : {1,2, 3,4} — >■ {3, 4, 5, 6} with 1 1 — 3 , 2 i — >• 5, 3 i-4 6, and 4 i — >


5.

d) m->2n:N->N.

e) n i-4 n+ 1 : N — » N.

f) 1 : Z Z.

g) n !->• (1/n) : N — {0} — > R.

h) K : {1,2, 3,4,5} — >■ {1,2,3} with K(n) = floor((n+ l)/2) .

(Answer on page 248.)

101.2.4 Exercise Which of the functions in Exercise 101.2.3 have (a) left inverses,

(b) right inverses? (Answer on page 248.)

101.2.5 Exercise Show that if a function G has an inverse F , then it has only

one left inverse and that is F . (Answer on page 248.)

148

composition (of

functions) 140

function 56

identity 72

inclusion function 63

infinite 174

inverse function 146


proof 4

theorem 2

101.2.6 Exercise Let I :R + — »• R denote the inclusion function. Show that I has

infinitely many left inverses.

The inverse of the composite of two functions which have inverses is the composite

of the inverses, only in the reverse order:

101.3 Theorem: The Shoe-Sock Theorem

If F : A—t B and G: B — > C both have inverses, then

(G°F)- 1 = F- 1 °G~ 1

101.3.1 Remark The name comes from the fact that the inverse of putting on

your socks and then putting on your shoes is taking off your shoes and then taking

off your socks.

Proof To prove the Shoe-Sock Theorem, we will prove that

(F- 1 °G~ 1 )o(G°F) =id A

and

(G°F)°(F~ 1 °G~ 1 ) = idc

(101.5)

(101.6)
and then apply Rule (101.4), page 147. To prove Equation (101.5), we note that

the following diagram commutes: the left and right triangles are the diagrams in

Figure (101.3), and the middle triangle is the left triangle in Figure (100.3).

(101.7)

Equation (101.6) is proved similarly.

Another fact with a similar proof (left as an exercise) is:

101.4 Theorem

If F has an inverse, then (F -1 ) -1 = F.

101.4.1 Remark Another way of saying this is that a function is the inverse of

its own inverse.

101.4.2 Exercise Prove Theorem 101.4.

A final fact about inverses is the very important:

149

101.5 Theorem: Characterization of invertible functions

A function F : A — >■ B has an inverse if and only if it is a bijection.


101.5.1 Remark The importance of Theorem 101.5 lies in the fact that having

an inverse is defined in terms of functional composition but being a bijection is

defined in terms of application of the function to an element of its domain. Any

time a mathematical fact connects two such differently-described ideas it is


probably

useful.

Proof I will go through the proof in some detail since it ties together several

of the ideas of this chapter. We have to prove an equivalence, which means two

implications.

First we show that if F has an inverse then it is a bijection. Suppose F has

an inverse. We must show that it is injective and surjective. To show that it is

injective, suppose F(a) = F(a'). Then

a = F~ 1 (F(a)) = F~ 1 (F(a')) = a

(The first and last equations follow from 101.1.3a and the middle equation from the

substitution property, Theorem 39.6.) So F is injective.

To show F is surjective, let b £ B . We must find an element a 6 A for which

F(a) = b. The element is F _1 (6), since F(F~ 1 (b)) = b. Thus F is bijective.

Now we must show that if F is bijective, then it has an inverse. Suppose F

is bijective. We must define a function G : B — > A which is the inverse of F . Let

b 6 B . Then, since F is surjective, there is an element a £ A for which F(a) = b.

Since F is injective there is exactly one such a. Let G(b) = a. Since F(a) = b,

that says that G(F(a)) = a, which is half of what we need to show to prove (using

Definition 101.1) that G = F _1 . The other thing needed is that F(G(b)) = b. But

by definition of G, G(b) is the element a for which F(a) = b, so F(G(b)) = b. That

finishes the proof.

101.5.2 Remarks
a) The second part of the proof says this: If F(a) = b , then F _1 (6) = a, and if

F~ l (b) = a, then F(a) = b.

b) You might experiment with proving the contrapositives of the two implications

in the preceding proof; some people find them easier to understand.

101.5.3 Exercise Write a formula for the inverse of each of these bijections.

a) in’! 2 : R + R + .

b) iH’S-LRH’R.

c) x i — y 2x : R — y R.

d) x i — y (1/x) : R — y R .

(Answer on page 248.)

101.5.4 Exercise Prove that a function has a left inverse if and only if it is
injec-

tive.

101.5.5 Exercise Prove that a function has a right inverse if and only if it is

surjective.

bijection 136

bijective 136

contrapositive 42

domain 56

equivalence 40

function 56

implication 35, 36

injective 134

inverse function 146


proof 4

surjective 133

theorem 2

150

Cartesian product 52

definition 4

dummy variable 150

expression 16

function 56

GCD 88

injective 134

integer 3

inverse function 146

left cancellable 150

powerset 46

relation 73

surjective 133

take 57

101.5.6 Exercise Give a right inverse of the function GCD :N + x N + — )• N + .


(You

are being asked to give the right inverse explicitly, not merely show it exists.)

101.5.7 Exercise Show that GCD:N + x N + — > N + does not have a left inverse.

101.5.8 Exercise (hard) A function F:A-^B is left cancellable if whenever


G : D — >■ A and H : D — >• A are functions for which F °G = F° H , then G must be

the same as H . Right cancellable is defined analogously. Prove that a function

is left cancellable if and only if it is injective and right cancellable if and


only if it

is surjective.

101.5.9 Exercise (hard) Let F:A—>B be a function and suppose A has more

than one element. Show that if F has exactly one left inverse then the left inverse

is also a right inverse (hence F has an inverse).

101.5.10 Exercise (hard) Let A and B be sets. Let /3 : Rel(A,R) — > (VB)^

defined in Problem 94.1.11, page 137. Let 7 : ( VB )^ — >• Rel {A,B) be the
function

(defined in Definition 53.3, page 76) that takes a function F : A — > VB to the
relation

ap defined by

aa,pb if and only if b G F(a)

Prove that 7 is the inverse of (3 (hence j3 is the inverse of 7 ).

102. Notation for sums and products

In this section we introduce a notation for sums and products that may be familiar

to you from calculus. This will be used in studying induction in Chapter 103.

102.1 Definition: sum and product of a sequence

Let 01 , 02 , . . . ,a n be a sequence of numbers (not necessarily integers).

The expression Y17= 1 a * d en °tes the sum ai + 02 H I -a n of the num-

bers in the sequence and the expression nf=i a * denotes the product

ai 02 • • • a n of the numbers in the sequence.


102.1.1 Example £* =1 * = 1 + 2 + 3 + 4 = 10 and 1}*=!* = 1 * 2 x 3 x 4 = 24.

102.1.2 Example 2A: — 1 = 1 + 3 + 5 + 7 + 9 = 25 . The sum 2i — 1 also

gives 25 — the i is a dummy variable just like the x in J 3 5 x 2 dx , which has


the

same value as /!? t 2 dt . On the other hand, ]C 5 =I 2fc — l = 10fc — 5.

102.1.3 Exercise What is J^ = 1 fc 2 ? What is f[fc=i (Answer on page 248.)

102.1.4 Example For b any fixed number, y )- 1 b = b+b+b+b = 4 b and

Hl =1 b = b-b-b-b = b i .

102.1.5 Remark The numbering of the sequence does not have to start at 1.

Thus a sequence 03 , 04 ,... ,012 would have sum X^= 3 a *-

151

102.1.6 Exercise What are Y%= i 2 ^ Ylt= o 2 (& + l) an d J2k= o 2 ^+l? Two of
direct method 119

them are the same. Explain why. hypothesis 36

implication 35, 36

102.1.7 Sums and products in Mathematica To compute infinite 174

integer 3

odd 5

positive integer 3

range expression 151


in Mathematica, you type the expression Sum [2 k-1 , {k, 1 ,5}] . Similarly, the
rule of inference 24

expression Product [k , {k , 1 , 6}] calculates 1-2-3-4-5-6.

The expression {k,l,5} is a range expression; range expressions are used

in many Mathematica commands. The range expression {x,a,b}- means that the

variable x ranges from the value of a to the value of b.

E 2 *- 1

k = 1

103. Mathematical induction

The positive integers contain some fascinating patterns. For example,

1 = 1, 1+3+5+7 = 16,

1+3 = 4, 1+3+5+7+9 = 25,

1+3+5 = 9, 1+3+5+7+9+11 = 36,

In general it appears that the sum of the first n odd positive integers is n 2 .
This

is a statement Q(n) about an infinite number of positive integers n.

The subject of this section is an inference rule allowing the proof of such state-

ments. Before the rule is stated, we will reformulate Q{n) and see why it is true.

Using summation notation, Q(n) is the statement

J2( 2k ~l ) = n 2
k = 1

(You should check that 2k — l is indeed the fcth odd positive integer.) Clearly
Q( 1)

is true: it says 1 = 1.

I will now prove that for any positive integer n, Q(n) =+ Q(n + 1), using the

direct method. The direct method requires us to assume the hypothesis is true, so

suppose we knew that Q(n) is true, that is that the sum of the first n odd integers

is n 2 . Then the sum of the first n + 1 odd integers is

(the sum of the first n odd integers) + (the n+lst odd integer)

We know the left term is n 2 because we are assuming Q(n) , and the right term is

2n + 1 . Hence the sum of the first n + 1 odd integers is n 2 + 2n + 1 . But n 2 +


2 n +

1 = (n+ l) 2 , in other words the sum of the first n + 1 odd integers is (n + l)


2 , so

that Q(n + 1) is true. This proves that Q(n) =+ Q(n + 1).

Now we know these two things:

a) Q(l).

b) For any n, Q(n) +> Q(n + 1).

152

basis step 152

contrapositive

method 120

direct method 119

divide 4
implication 35, 36

induction hypothe-

sis 152

induction step 152

induction 152

inductive proof 152

integer 3

negative integer 3

nonnegative integer 3

positive integer 3

rule of inference 24

theorem 2

usage 2

Using these facts, you should be able to convince yourself that Q(n) is true for
any

positive integer, since Q( 1) is true, and the implication Q(n) => Q(n + 1) allows

you to see that Q( 2) is true, Q(3) is true, . . . , jacking the proof up, so to
speak, until

you get to any positive integer. You need to know both Q(l) and the implication

Q(n) => Q{n + 1) for all ji to make this work.

This approach is the basis for the following rule of inference:

103.2 Theorem: The principle of mathematical induction

For any statement about the positive integers, this rule of inference is

valid:

P( 1), (Vn:N + ) (P(n) => P(n + 1)) b (Vn:N+)P(n)


103.2.1 Usage A proof using the principle of mathematical induction is called

an inductive proof. The proof that P(l) is true is the basis step and that

P(n) =>- P(n+1) is the induction step.

103.2.2 Remarks

a) The induction step is sometimes stated as P(n — 1) => P(n) , which must hold

for all integers > 1 , but that is only a change in notation.

b) The proof of the induction step, which is an implication, may be carried out

by the direct method as was done above, or by the contrapositive method.

If it is carried out by the direct method, one assumes that P(n ) is true and

deduces P(n + 1). In doing this, P(n) is called the induction hypothesis.

c) The principle of mathematical induction gives you a scheme for proving a

statement about all positive integers. You still have to be clever somewhere in

the proof. In the example just given, algebraic cleverness was required in the

induction step.

103.3 Other starting points for proofs by induction

We have formulated mathematical induction as a scheme for proving a statement

about all positive integers. One can similarly prove statements about all
nonnegative

integers by starting the induction at 0 instead of at 1 (see Example 103.3.1


below).

In that case you must prove P(0) and

(Vn:N) (P(n) =► P(n + 1))

Indeed, a proof by mathematical induction can be started at any integer, positive

or negative. For example, if you prove P(— 47) and P(n) => P(n + 1) for n > —47,
then P(n) is true for all n > —47.

One could also go down instead of up, but we won’t do that in this text.

103.3.1 Example Let’s prove that for all nonnegative integers n, 3 | n 3 + 2n.

Basis step: We must show 3 | 0 3 + 0, which is obvious.

153

Induction step: assume 3|n 3 + 2n. (This is the induction hypothesis.) Then

n 3 + 2n = 3k for some integer k . Then

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

= n 3 + 2n + 3n 2 + 3n + 3 (103.1)

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

so is divisible by 3 as required.

103.3.2 Remark The statement 3 | n 3 + 2 n is true of negative integers, too. Once

you know it for positive integers, the proof for negative integers is easy:
substitute

— n for n in the statement and do a little algebra. This trick often works for
proving

things about all integers. However, the principle of mathematical induction by


itself

is not a valid method of proof for proving statements about all integers.

103.3.3 Example A statement about the value of a sum or product can often be

proved by induction. Let us prove that

n 1
^2 k = 2 n ( n+1 )

k = 1

Proof Basis step: A; = 1 = | • 1 • 2 , as required.

Induction step:

Efci i k = ra+l + EL i k

= n + 1 + \n{n + 1) (by the induction hypothesis)

= {\n + l)(n + 1)

= ^(n + 1) (n + 2) (by algebra)

This proof uses a basic trick: separate out the term in the sum (or product) of

highest index, in this case n + 1 . Then the rest of the sum can be evaluated using

the induction hypothesis.

103.3.4 Remark In all proofs by induction you should label the basis step, the

induction step and the induction hypothesis. If you find yourself writing “and so

on...” or “continuing in this way...” or anything like that, you are not doing an

inductive proof.

103.4 Exercise set

Prove the statements in Exercises 103.4.1 through 103.4.8 by induction.

103.4.1 ££ =1 = n ” r (Answer on page 248.)

103.4.2

U ( —

£(-i)‘* = l T±i)

k= 1 2
(Answer on page 249.)

103.4.3 J2k= i k i k + 1) = \n{n + l)(n + 2).

basis step 152

divide 4

even 5

induction hypothe-

sis 152

induction step 152

induction 152

integer 3

negative integer 3

odd 5

positive integer 3

proof 4

(n even)

(n odd)

154

counterexample 112

even 5

induction 152
integer 3

nonnegative integer 3

positive integer 3

theorem 2

universal quanti-

fier 112

usage 2

well-ordered 154

103.4.4 ELi^ = |n(n+l)(2ra + l).

103.4.5 ELi 2 k = 2 n+1 - 2.

103.4.6 ELi k2k = (« - l)2 n+1 + 2.

103.4.7 ELi^ 3 = •

103.4.8 ELiC- 1 )^ 2 = ( ^Y~ri{n+ 1).

103.4.9 Exercise Prove the following inequalities by induction.

a) 2 n > 2n + 1 for n > 3.

b) 2 n > n 2 for n > 4.

104. Least counterexamples

Proof by induction as described in Chapter 103 is based on a very basic fact about

the positive integers that has wider applications. Suppose P(n) is a statement

about positive integers, and suppose the statement (Vn:N + )P(?r) is false. Then

there is a counterexample m, a positive integer for which P(m) is false. Among all

such counterexamples, there is a smallest one:


104.1 Theorem: The Principle of the Least

Counterexample

Every false statement of the form (Vn:N + )P(?r) about the positive inte-

gers has a smallest counterexample.

104.1.1 Usage This property of the positive integers is often referred to by saying

the positive integers are well-ordered.

104.1.2 Remark Of course, one can replace the positive integers by the nonneg-

ative integers, or by the set of all integers greater than a particular one, in the

statement of Theorem 104.1.

The existence of least counterexamples is characteristic of such sets; for most

other data types, least counterexamples need not exist. For example, the statement,

“All integers are even” is a false universally quantified statement about the
integers

which has many counterexamples, but no smallest one.

155

104.2 Least counterexample and induction

The principle of mathematical induction, in other words Theorem 103.2, can be

proved using the principle of the least counterexample. The proof is by contradic-

tion.

Suppose that the hypotheses of the theorem are true: P(l) , and

(Vn:N + )^P(n) =► P(n+ 1)


Suppose that (Vn:N + )P(n) is false. Then there is a least counterexample m, so

P(k) is true if k < m but P(m) is false. Now we have two cases.

(i) m = 1. Then P( 1) is false — but this contradicts one of the hypotheses of

the theorem.

(ii) m > 1 . In this case, P{m ) is false, since m is a counterexample to the

statement (Vn:N + )P(n). Since m is the least counterexample, the statement

P(m — 1) is true. It follows from the truth table for implication that the

statement P(m— 1) => P(m) is false. But that means the hypothesis

counterexample 112

equivalent 40

Fundamental Theo-

rem of Arith-

metic 87

implication 35, 36

induction hypothe-

sis 152

induction 152

integer 3

least counterexam-

ple 154

proof by contradic-

tion 126

strong induction 155


(Vn:N + ) f P(n) => P(n + 1)

is false since n = m — 1 provides a counterexample.

So in either case, one of the hypotheses of Theorem 103.2 must be false. There-

fore there can be no least counterexample, so by Theorem 104.1 there can be no

counterexample. Hence (Vn:N + )P(n) is true.

The principle of mathematical induction and the principle of the least counterex-

ample are actually equivalent.

104.2.1 Exercise Use the principle of mathematical induction (Theorem 103.2)

to prove Theorem 104.1.

104.3 Strong induction

The principle of the least counterexample is useful in its own right for proving
things.

For example, it is used in Problems 104.3.3 and 104.4.4 to prove the Fundamental

Theorem of Arithmetic.

The principle allows you to assume as a kind of induction hypothesis that P(k)

is true for all k <n, not just for n — 1. This is stated formally in Exercise
104.3.1

below. It is handy for proving things about factoring integers, since the prime

factorization of an integer n has little to do with the factorization of n — 1 .


This

more general approach is often called strong induction, and another statement of

it is in Problem 104.3.1.

In this book, proofs using this technique are usually presented as direct appli-

cations of the least counterexample principle.


156

divide 4

finite 173

Fundamental Theo-

rem of Arith-

metic 87

GCD 88

implication 35, 36

integer 3

least counterexam-

ple 154

nonnegative integer 3

positive integer 3

prime 10

Principle of Strong

Induction 156

proof by contradic-

tion 126

quotient (of inte-

gers) 83

remainder 83

rule of inference 24
104.3.1 Exercise Use the principle of the least counterexample to prove the fol-

lowing rule of inference for positive integers n. This rule is called the Principle
of

Strong Induction.

(Vn:N + ) ^(Vm:N + ) ^ m < n =>• P(m)^ =4- P(n)^ (— (Vn:N + )P(n)

104.3.2 Example: Existence of quotient and remainder We will use the

Principle of the Least Counterexample to prove the existence half of Theorem 60.2,

page 84. That is, we will prove that for given integers m and n with n / 0, there

are integers q and r satisfying

Q.l m = qn + r, and

Q.2 0 < r < \n\ .

That there is only one such pair of integers was proved on page 84.

We will give the proof for m > 0 and n > 0 and leave the other cases to you

(Exercise 104.3.4). Let S be the set of all nonnegative integers of the form m —
xn.

S is nonempty (any negative x makes m — xn positive, but there may also be

positive x that do so). Let m — qn be the smallest element of S. Let r = m — qn.

Then qn + r = qn + m — qn = m, so Q.l is true. Since m — qn G N by assumption,

we know that r, which is m — qn, is nonnegative, which is half of Q.2. As for

the other half, suppose for the purpose of proof by contradiction that r > n. Then

m — qn>n, that is, m > n + qn = (q + l)n. But then m — (q + l)n is nonnegative,

and it is certainly smaller than m — qn, contradicting our choice of m — qn as the

least element of S .

104.3.3 Exercise (hard) Show that if m is any integer greater than 1 , then there

is a finite list of primes pi,... ,Pk and integers ei, . . . ,e& for which m = n!
°=iPi’ • Use

the principle of the least counterexample. Do not use the Fundamental Theorem of
Arithmetic. Note that if m is prime, then this holds for k = 1, p\ = m, and e\ = 1.

104.3.4 Exercise Complete the proof that the quotient (of integers) and remain-

der exist (see 104.3.2).

104.4 Proof of the Fundamental Theorem of Arithmetic

Exercises 104.4.1 through 104.4.4, together with Exercise 104.3.3, lead up to a

proof of the Fundamental Theorem of Arithmetic. Thus the Fundamental Theorem

should not be used in the proofs of those problems.

104.4.1 Exercise Show that if p is a prime and m an integer not divisible by p,

then GCD(p,7b) = 1. (Answer on page 249.)

104.4.2 Exercise Show that if p is a prime and m and n are integers for which

p | mn but p does not divide m, then p\n. (Hint: Use Problem 104.4.1 and Bezout’s

Lemma, page 128.) (Answer on page 249.)

Suppose p is prime, p\mn, but p does not divide m. Then GCD (p,m) = 1,

so there are integers a and b for which ap + bm = 1 . There is also an integer k

for which mn = pk . Putting these facts together, n = anp + bmn = anp + bkp =

( an + bk)p , so n is divisible by p.

157

104.4.3 Exercise Use Problem 104.4.2 to show that if p is a prime and mi , . . . ,


to*,

are positive integers for which p | JXf=i m i , then for some i , p | rn % .

104.4.4 Exercise (hard) Show that if p\ < p 2 < ■ ■ ■ < Pk in the prime factor-

ization m = YIa-iPT in Exercise 104.3.3, then the factorization is unique. (Hint:


Assume m is the least positive integer which has two such factorizations and use

Problem 104.4.3 to obtain a prime which occurs in both factorizations. Then divide

by that prime to obtain a smaller integer with two factorizations.)

divide 4

function 56

integer 3

iterative 157

positive integer 3

prime 10

recursive 157

105. Recursive definition of functions

Many functions are defined in such a way that the value at one input is defined in

terms of other values of the function. Such a definition is called recursive.

105.1.1 Example One way of defining the function F : N — > N for which F(n) =

2 n would be to say

{ F(n + 1) = 2 • F(n) (105.1)

for all n € N .

Programs 105.1 and 105.2 give Pascal functions which calculate 2 n .

FUNCTION TWOREC (N: INTEGER) : INTEGER;

BEGIN
IF N=0 THEN TWOREC := 1

ELSE TWOREC := 2*TW0REC (N-l)

END;

Program 105.1: Program for 2 n

Program 105.1 simply copies Definition 105.1. Since the function TWOREC calls

itself during its execution, this program is also said to be recursive. Program
105.2

is a translation of Definition 105.1 which avoids the function calling itself.


Since it

is implemented by a loop it is called an iterative implementation of the function.

105.1.2 Remark Many common algorithms are easily to define recursively, so the

study of recursively-defined functions and how to implement them is a major part of

computer science. Very often, the iterative implementation like Program 105.2 is to

be preferred to the recursive one, but in complicated situations it is not always


easy

to transform the recursive definition into an iterative one. In some applications,


for

example in writing programs to parse expressions, the recursively written program

may be the preferred method for writing the first attempt, since the iterative
version

can be much harder to understand and debug.

158

divide 4

factorial function 158

function 56

inductive defini-
tion 159

integer 3

FUNCTION TW0IT(N : INTEGER) : INTEGER; VAR COUNT: INTEGER;

BEGIN

COUNT := 0; POWER := 1;

(♦POWER is a integer variable declared in

the program containing this procedure.*)

WHILE COUNT <N DO

BEGIN

POWER := 2*P0WER;

COUNT := COUNT+1

END

TWO IT := POWER

END;

Program 105.2: Another program for 2 n

105.1.3 Exercise Find the values for n = 1 through 5 of the functions defined as

follows:

a) F(0) = — 3, F(n + 1) = (n + l)F(n)

b) F(l) = 1 , F(n) = n 2 + F(n - 1)

. f 0 if 3 1 n
c) F(n ) = <

( 1 + F(n + 1) otherwise

d) F(0) = 1, F(l) = 3, F{n) = F(n — 1) + F(n — 2)

e) F(1)=0, F( 2) = 1, F{n) = (n — 1) ^F(n — 1) + F(n — 2)^

(Answer on page 249.)

105.1.4 Example For a fixed sequence {dfc} fcgN + ,

F(n) = ^a k

k = 1

is a function from N + to N + which has a natural definition by induction:

f Sfc=l a k — a \

l Sfcil a k = a n+ 1 + ^2k= 1 a k

(105.2)

105.1.5 Example The product has a similar definition:

f n fe =i a k =

i re;i«»=on + i'(nhi«b
(105.3)

105.1.6 The factorial function A particularly important function which can be

defined by induction is the factorial function. Its value at n is denoted n! and it

is defined this way:

I 0 ! = 1

\ (n + 1)! = (n+ 1) • n\

(105.4)

159

Thus for n > 0 , n\ = H£ =1 k ; you can prove this by induction because both n\ and

the product are defined by induction (Exercise 105.2.1). The factorial function
will

be used in various combinatorial formulas in later sections.

105.2 Proofs involving inductively defined functions

Defining a function by induction makes it convenient to prove things about it by

induction. For example, let us use induction to prove that n\ > 2" for n > 3 . We

start the induction at n = 4. Then 4! = 24 and 2 4 = 16, so the statement is true

for n = 4. For the induction step, suppose n ! > 2 n and n > 4. It is necessary to

prove that (n + 1)! > 2 n+1 . Both these functions are defined by induction, so we

can apply their definitions and the induction hypothesis to get

(n + 1)! = (n + 1) • n\ > 2 • n\ > 2 • T = 2 n+1


as required.

defined by induc-

tion 159

domain 56

function 56

induction hypothe-

sis 152

induction step 152

induction 152

inductive defini-

tion 159

integer 3

ninety-one func-

tion 159

positive integer 3

recursive defini-

tion 157

105.2.1 Exercise Prove directly from the inductive definition of n\ that n ! =

nLi ^ f° r all positive integers n. (Answer on page 249.)

105.2.2 Exercise Prove that for all integers n > 0, 2 n < 2(n!) .

105.2.3 Exercise Find constants C and D for which for all integers n > 0 , 3 n <

C(nl) and 4 n < D(nl). Prove your answers are correct.


106. Inductive and recursive

Definition 105.1 gives the value at n in terms of the value of the function at a
smaller

integer. In general, a function F : N — >■ N is defined by induction if certain


initial

values -F(0),-F(1),. . . ,F(k) are defined and for each n£N, F{n- 1-1) is defined
in

terms of some or all of the preceding values F(0),F(1), . . . ,F(n). Thus inductive

definition is a special case of recursive definition. In a more formal treatment of


this

subject, the phrase “in terms of” would have to be precisely defined.

Recursive definitions which are not inductive may involve domains other than N

which have no natural ordering (so that “in terms of smaller values” makes no
sense)

or functions on N which involve definition in terms of both larger and smaller


values.

The general concept of recursion is fundamental to much of theoretical computer

science. It is a common theme uniting the different threads in [Hofstadter, 1979].

106.1.1 Example The ninety-one function F: N — >• N is defined by:

F(n) =

(n < 100)

(n > 100)

(106.1)
This is a well defined function. It has the property that F{n) = 91 if n < 100 and

F(n) = n — 10 if n > 100.

160

Collatz function

definition 4

even 5

Fibonacci func-

tion 160

function 56

odd 5

160 106.1.2 Example The Collatz function T :N + — > N + defined by:

( 1 (if n = 1)

T(n) = < T(|) (if n is even)

\ T(3n+1) (if n is odd and n > 1)

Looking at the formula, there is no reason to believe that the computation wouldn’t

loop forever for some value of the input, but no one has ever been able to discover

such a value or to prove that such a value does not exist. (Every input that has
ever

been computed does in fact given an answer, namely 1 .) In other words, although

we called it “the Collatz function”, we don’t actually know that it is a function!

Note that if you change the ‘3n+ 1’ to ‘3n — 1’ in the third line, then T( 5) is
not

defined. There is much more about this in [Guy, 1981], Problem E-16, page 120 and
in [Lagarias, 1985].

106.1.3 Exercise (hard) Prove that the ninety-one function defined by Equa-

tion (106.1) on page 159 satisfies F(n ) = 91 if n < 100 and F(n) = n— 10 if n >
100.

107. Functions with more than one starting point

The Fibonacci function is an example of a function defined in terms of two previous

values (hence requiring two initial conditions):

107.1 Definition: Fibonacci function

The Fibonacci function F : N — > N is defined by

r f(o)=o

{ F( 1) = 1

[ F(n) = F(n — 1) + F(n — 2)

(107.1)

107.1.1 Remarks

a) The Fibonacci function is called “Fibonacci” after Leonardo di Pisa, who

described it in 1220 AD. He was the son (Fi, short for Figlio) of Bonaccio.

b) The Fibonacci function has traditionally been described as the formula for the

number of pairs of rabbits you have after n months under these assumptions:

initially you have just one pair of rabbits, and every month each pair of rabbits
over one month old have a pair of children, one male and one female. And

none of them die.

Suppose you buy (trap?) the first pair of rabbits at the beginning of

month 1. Then -F(O) =0 and F( 1) = 1. At the nth month, F must satisfy

the equation

F(n) = F(n — 1) + F(n — 2) (n > 2)

since the F{n— 1) rabbits you had one month ago are still around and you

have a new pair for each of the F(n — 2) pairs born two or more months ago.

161

This explanation bears no relation to reality since rabbits take six months,

not one, to mature sexually, and they do not reliably produce one male and

one female each gestation period.

107.1.2 Example The Perrin function is defined with three starting points:

P(0) = 3

P(1) = 0

P( 2) = 2

P(n) = P(n — 2) + P(n — 3)

(107.2)
For integers larger than 1 up to a fairly large number, this function has the
property

n | P(n) n is prime.

The smallest integer > 1 for which this is false is apparently 271,441 , which is
521 2 ,

but I have not been able to check this.

A number n for which n \ P(n) is called a Perrin pseudoprime.

107.2 Recurrence relations

Since the Fibonacci function has domain N, it is the same as an infinite sequence
(see

Example 97.2.2). The values F(0),F(1),F(2),... are often called the Fibonacci

numbers. When expressed in sequence notation, the definition becomes

divide 4

domain 56

equivalent 40

Fibonacci func-

tion 160

Fibonacci num-

bers 161

induction 152

inductive defini-

tion 159

infinite 174

integer 3

odd 5
Perrin function 161

Perrin pseudo-

prime 161

recurrence rela-

tion 161

recurrence 161

/o = 0

/l = l

fn = fn— 1 T fn—2

(107.3)

Fibonacci function is called a recurrence relation or simply a recurrence.

Sometimes, but not always, a function defined by a recurrence relation can

be given a nonin ductive definition by a formula. Finding such a “closed form”

definition is called solving the recurrence relation. We have already solved

some recurrence relations. For example, the statement that the sum of the first

n odd integers is n 2 can be reworded to say that the solution to the recurrence

relation

{ :::u + i+ s „ <io7 - 4 >

is s n = n 2 .

If you can guess a solution to a recurrence relation, you can often prove it is

correct by induction. Problem 107.3.11 gives a closed solution to the Fibonacci

recurrence. Note that it would generally be better to calculate Fibonacci numbers


for small n using the recurrence relation rather that the complicated formula given

in Problem 107.3.11.

107.3 Exercise set

Exercises 107.3.2 through 107.3.11 refer to the Fibonacci sequence.

162

divide 4

div 82

even 5

GCD 88

integer 3

mod 82, 204

nonnegative integer 3

positive integer 3

107.3.1 Exercise Prove that for all nonnegative integers n, f%+i ~ fnfn +2 =

(— l) n . (Answer on page 249.)

107.3.2 Exercise Prove that for all nonnegative integers n, f n is even if and only

if 3 | n.

107.3.3 Exercise Prove that for all [positive integers n, / n +idiv/ n = l and
,/n+l mod fn = f n —l .

107.3.4 Exercise Prove that for all nonnegative integers n,

fnfn + 3-fn+lfn + 2 = (-l) n+1

107.3.5 Exercise Prove that for all nonnegative integers n, GCD(/ n +i,/ n ) = 1.

(Hint: You can use Exercise 107.3.3, or you can look at Exercise 107.3.4 and
meditate

upon Bezout.)

107.3.6 Exercise Prove by induction that

SLl/fc = fnfn+1

107.3.7 Exercise Give a proof by induction on n that for all n > 0,

fn + 2 > (|)"

(You can also prove this using Problem 107.3.11 below.)

107.3.8 Exercise Show that for all n > 0, /^ +1 — ,/ n ,/n+i — fn = ±1 •

107.3.9 Exercise (hard) (Matijasevich) Prove that if x and y are nonnegative

integers such that y 2 — xy — x 2 = ±1 , then for some nonnegative integer n , x =


f n

and y = f n +i ■ (Be careful: You are not being asked to show that (f n ,f n + i)
is a

solution of the equation for each n — that is what the Problem 107.3.8 asks for.

You are being asked to show that no other pair of integers is a solution.)

107.3.10 Exercise (hard) (Matijasevich) Show that for all nonnegative integers

m and n , if | f n , then f m \n.

107.3.11 Exercise (hard) Prove that for all nonnegative integers n,


f n = (l/Vb)(r n -s n )

where r and s are the two roots of the equation x 2 — x — 1 = 0 and r > s.

107.3.12 Exercise Let a function F:N — > N be defined by

'F(O) = 0

< .F(l) = 1

-F(ro) = 5F(n — 1) — 6F(n — 2) (n > 1)

Prove by induction that for all n > 0 , F(n) = 3 n — 2 n .

163

107.3.13 Exercise Define a function F:N— >-N by

f F(0) = F(l) = 1

\ F(n) = 2F(n — 1) + F(n — 2) (n > 1).

Show

a) F(n) is always odd.

b) -F(4fc + 2) is divisible by 3 for any integer k > 0.

function 56

integer 3

natural number 3

odd 5

successor func-
tion 163

take 57

107.3.14 Exercise (hard) (Myerson and van der Poorten [1995]) Define a func-

tion G: N^N by G(l) = G(3) = G(5) =0, G(0) = G(4) = 8, G(2) = 9, and G(n +

6) = 6G(n + 4) — 12G(n + 2) + 8G(n) for n> 5. Show that G(n) = 0 if n is odd

and

G{n) = (n- 8) 2 -2^

otherwise.

107.3.15 Exercise (Myerson and van der Poorten [1995]) Define a function G:

N — >■ Z by G(0) = 0, G(l) = 1 , G(2) = — 1 , and

G(n) = — G(n - 1) + G(n - 2) + G(n - 3)

for n > 2 . Show that

G'(n)

— ^ n even

^ odd

(Compare Exercise 94.1.4, page 136.)

108. Functions of several variables


Functions F : N 2 — > N can be defined by induction, too. One technique is to
define

a function of two variables for all values of one variable by induction on the
other

variable.

108.1.1 Example Multiplication in N, which is a function N 2 — > N, can be

defined by

f m- 0 = 0

\ m ■ (n + 1) = m ■ n + m

(108.1)

This defines m ■ n for each m € N by induction on n . The definition shows how to

define multiplication in terms of adding one.

108.1.2 Exercise The successor function s : N — > N is the function which takes

each natural number to the next one: s(n) = n + 1 . Show how to define addition

inductively in terms of the successor function.

108.1.3 Exercise Show how to define the operation (m,n) i->- m n inductively in

terms of the successor function and multiplication (defined inductively in Exam-

ple 108.1.1).

164
definition 4

empty list 164

GCD 88

head 164

nonempty list 164

recursive defini-

tion 157

recursive 157

tail 164

tuple 50, 139, 140

108.1.4 Example Theorem 65.1, page 92, gives a recursive definition of the GCD

function. It translates directly into the Pascal function in Program 108.1.

FUNCTION GCD (M,N: INTEGER) ;

BEGIN

IF M=0 THEN GCD : = N

ELSE

IF N=0 THEN GCD : = M

ELSE

GCD := GCD(N,M MOD N)

END;

Program 108.1: Program to compute the GCD


108.1.5 Exercise Define the function A : N x N — >■ N by

' A(0,y) = 1

< - 4 ( 1 ) 0 ) = 2

A(x, 0) = x + 2 for x > 2

A(x,y) = A(A(x-l,y),y-l)

a) Prove by induction that A(x, 1) = 2x for all x > 1 .

b) Prove by induction that A{x,2) = 2 X for all x > 0.

c) Prove by induction that A(x,3) = 2 j4 ( a:_1 ’ 3 ) for all x > 0.

d) Calculate A(4,4).

109. Lists

Informally, a list of elements of a set A consists of elements of A arranged from


first

to last, with order and repetition mattering. We will write them using the same

notation that we use for tuples. Thus (1,4, 3, 3, 2) is a list of elements of N. It


is

not the same list as (1,4, 3, 2) or as (4, 1,3, 3, 2) . A particular list is the
empty list,

denoted () .

We could have said that a list of elements of A is just a tuple of elements of A.

However, the specification for lists is different from that for tuples, so our
formal

treatment will start from scratch. The definition is recursive.

109.1 Definition: list


For any set A, a list of elements of A is either the empty list () or

a nonempty list. A nonempty list of elements of A has a head, which

is an element of A, and a tail, which is a list of elements of A. The list

with head a and tail (&i,... , &&) is denoted (a,bi ,... , bjf) . The list with

head a and empty tail is denoted (a ) . Every list of elements of A is

constructed by repeated application of this definition starting with the

empty list.

165

109.1.1 Remark The head of a nonempty list is not a list, but the tail is a list.

The empty list does not have a head or a tail.

109.1.2 Example () , (5), (2,1,1,— 3) and (3,3,3) are all lists of elements of Z

(lists of integers). The head of (2,1,1,— 3) is 2 and the tail is (1,1,— 3). The
head

of (5) is 5 and the tail is () .

109.2 Definition: set of lists

The set of all lists of elements of A is denoted A * . The set of all

nonempty lists of elements of A is denoted A + .

cons 165

definition 4

empty list 164

integer 3

length (of a list) 165


list constructor

function 165

list 164

recursive 157

union 47

109.2.1 Example Let A be the English alphabet. Then the lists (), (a, a, 6)

and (c,a,t,c,h) are all elements of A*. The list (2,2) is an element of N*, and

(c,a,t,c,h, 2,2) is an element of (dUN)* but not of A* or of N* .

109.2.2 Lists in Mathematica A list such as (1,5, 3, 6) in Mathematica is writ-

ten {1,5, 3, 6}.

109.3 The list constructor

Most concepts connected with lists are defined recursively using Definition 109.1.

To make this easy, we introduce the list constructor function cons :SxS*^S +

(note carefully the domain and codomain of this function), which is defined by

requiring

cons(a, <61,62, - - - ,b n )) = (a,b 1 ,b 2 ,... ,b n ) (109.1)

Thus cons (c,(a,t,c,h)) = ( c,a,t,c,h ) and cons(o, ()) = (a).

109.4 Definition: length of a list

The length (of a list) of a list L of elements of S is denoted \L\ and

is defined by

LL.l |()|=0.

LL.2 |cons(a,L)| = 1 + \L\ .


109.4.1 Example |(c,a,t)| = 3, because, by repeatedly applying Rule (109.1),

page 165, and LL.l and LL.2, we have

|<c,a,t)|

|cons(c, (a,t))|

|cons(c, cons(a, (t)))\

|cons(c,cons(a,cons(f, ())))|

1 + |cons(a,cons(f, ()))|

1 + 1 + | cons (f, ())|

1 + 1 + 1 + IOI

1 + 1 + 1 + 0 = 3

166

cons 165

definition 4

induction hypothe-

sis 152

induction 152

length (of a list) 165

list 164

proof 4

recursive 157
theorem 2

tuple 50, 139, 140

109.4.2 Remark It can be proved by induction on the length of a list that a list

of length k satisfies the specification for a fc-tuple (Definition 36.2, page 50).
Nev-

ertheless, the recursive definition of list given above has provides a useful
alternative

approach to the idea which simplifies much of the theory of lists.

109.5 Concatenation

Informally, the concatenate of two lists is obtained by writing the entries of one

and then the other in a single list. Concatenation is denoted by juxtaposition;


thus

<1,4, 4)<2, 3) = <1,4, 4, 2, 3) and <3,2,2)<) = (3,2,2) .

Again, we give a formal definition by induction.

109.6 Definition: concatenate of lists

The concatenate LN of two lists L and N is defined recursively as

follows:

CL.l ()N = N

CL. 2 cons(a, L)N = cons(a, LN) .

109.6.1 Example

(c,a,t)(c,h)

cons(c, ( a,t))(c,h )
cons(c, (a,t)(c,h))

cons (c, cons (a, ( t))(c,h ))

cons(c,cons(a, ( t){c,h )))

cons(c,cons(a,cons(f, (})(c,h)))

cons(c,cons(a,cons(f, ()(c, h))))

cons(c,cons(a,cons(f, (c, h))))

cons(c,cons(a, ( t,c,h .)))

cons(c, (a,t,c,h))

( c,a,t,c,h )

109.6.2 Remark Definition 109.6 implies that, for example, ( )(c,a,t ) = (c,a,t).

We would expect that (c,a,t)() = (c, a,f) as well. This can be proved by induction:

109.7 Theorem

For any list L, L{) = L.

Proof If L has length 0, that is, if L = () , then L() = ()() = () by CL.l. Other-

wise, assume the theorem is true for lists of length k and let L have length k +
1 .

Then L = cons (a, L') for some element a and list L' of length k, and

L() = cons (a,L r )() = cons (a,L r Q) = cons (a, L r ) = L

by CL. 2 and the induction hypothesis.

167

109.8 Theorem
Concatenation is associative. Precisely, for any lists L, M and N,

(. LM)N = L(MN ).

Proof This is also proved by induction on the length of L. If L = (} , then

(. LM)N = (( )M)N = M N = () (MN) by CL.l applied twice. Now assume that

L = cons(a,L / ) and that (L'M)N = L\MN). Then

(LM)N = (cons (a,L')M)N

= cons (a,L'M)N

by CL. 2

= cons (a,(L'M)N)

by CL. 2

= cons (a,L'(MN))

induction hypothesis

= cons (a,L')(MN)

by CL. 2

= L(MN)

109.8.1 Exercise Prove by induction that the length of the concatenate of two
lists is the sum of the lengths of the lists. Use Definitions 109.4 and 109.6
explicitly.

alphabet 93, 167

associative 70

character 93

cons 165

definition 4

digit 93

induction hypothe-

sis 152

induction 152

inductive defini-

tion 159

list 164

proof 4

real number 12

string 93, 167

theorem 2

tuple 50, 139, 140

usage 2

109.8.2 Exercise Give an inductive definition of the last entry of a list. (Answer

on page 249.)

109.8.3 Exercise Give an inductive definition of the maximum of a nonempty list

of real numbers. It should satisfy max(l,3, 17,2) = 17 and max(5) = 5, for example.
109.8.4 Exercise Give an inductive definition of the sum of the entries of a list

of real numbers. It should satisfy SUM(3,4,2,3) = 12 and SUM(42) = 42. The sum

of the empty list should be zero.

109.8.5 Exercise (hard) Prove that a list of length k satisfies the specification

for a tuple of length k (Definition 36.2, page 50).

110. Strings

110.1 Definition: string

A string is a list of characters in some alphabet.

110.1.1 Example (c,a,t) is a string in the English alphabet.

110.1.2 Usage It is customary to denote such a string by writing the characters

down next to each other and enclosing them in quotes. We will use single quotes.

Thus ‘cat’ is another notation for the string (c,a,t). We specifically regard ‘ cat

and ( c,a,t ) as the same mathematical object written using two different
notations.

110.1.3 Remarks

a) Note carefully that ‘cat’ is a string, “cat” is an English word, and a cat is a

mammal! Similarly, ‘52’ is a string and 52 is a number.

b) The alphabet can be any set of characters. For example ‘0101’ is a string in

the alphabet of binary digits.

168
concatenate (of

lists) 166

cons 165

even 5

induction 152

inductive defini-

tion 159

odd 5

string 93, 167

110.2 Concatenation of strings

In string notation, concatenation is simply juxtaposition: to say that the concate-

nate of ‘cat’ and ‘ch' is ‘ catch ’ , we write

l cat'‘ch' = ‘ catch '

Strings are often denoted by lowercase letters, particularly those late in the

alphabet. For example, let w = ‘cat' and x = ‘doggie'. Then wx = ‘catdoggie ' ,

ww = ‘ catcat ’ and xw = ‘doggiecat' . It is very important to distinguish w, which

here is the name of a string, from ‘w' which is a string of length one.

110.3 The empty string

The empty string could be denoted ”, but this makes it hard to read, so we will

follow common practice and use a symbol to denote the empty string. In this text,

the symbol will be A. Other texts use e or 0.

110.3.1 Example A. 1 abba' = ‘abba' = ‘abba' A, and AA = A.

110.3.2 Remark Note carefully that ‘cat' is a string, but that “A” is the name
of a string.

110.4 Exponential notation for concatenation

To designate a string concatenated with itself several times an exponential


notation

is used. If w is a string, w n is the concatenate of the string w with itself n


times.

110.4.1 Example Let w = ‘0110’. Then it follows that

iv 2 = ‘01100110’ and w 3 = ‘011001100110’

Note in particular that ‘O’ 3 = ‘000’ and ‘ 1 ,2 ‘0’ 4 = ‘110000’. We always take w
1 = w

and w° = A.

110.4.2 Exercise Find the concatenate wx if

a) w = ‘Oil’, x = ‘1010’ d) w = x = A.

b) w = A, x = ‘Oil’ e)

c) w = ‘011’, x = A. f)

w = ‘Oil’, x = w 2 .

x = ‘011’, w = x 2 .

(Answer on page 249.)

110.4.3 Exercise Let A = {a, 6} and let E be the set of strings in A* of even
length. Give an inductive definition of E . (Answer on page 249.)

110.4.4 Exercise Give an inductive definition of the set of strings in {a,b} of

odd length.

110.4.5 Exercise Give an inductive definition of the k th entry of a string. It

should exist for strings of length k or greater but not for strings of length less
than

k. Follow the pattern of the answer to Exercise 109.8.2, using cons.

110.4.6 Exercise Give an inductive definition of w n for an arbitrary string w.

The induction should be on n.

169

111. Formal languages

111.1 Definition: language

A language is a set of strings in some finite alphabet A.

111.1.1 Usage

a) In the research literature, this concept of language is often call “formal lan-

guage” .

b) If L is a language consisting of strings in A* for some finite alphabet A , then

one says that L is a “language in A" . This is common terminology but may

be slightly confusing since in fact the elements of L are not elements of A,


they are elements of A* .

111.1.2 Remark The definition says that a language is a subset of A* . Note that

the language may be infinite although the alphabet is finite.

111.1.3 Example The empty language is the set 0. No strings are elements of

the empty language.

111.1.4 Example Another example is the language {A} whose only element is

the empty string. It is important to distinguish this from the empty language 0.

111.1.5 Example Another uninteresting language is the language A* , containing

as elements every string in the alphabet A.

111.1.6 Example The set {‘01 ’,‘011’, ‘1’} is a language in {0,1}.

111.1.7 Example The set of strings in {0,1}* with 1 in the second place is a

language. Note that ‘0110’ is in the language but ‘1’ and ‘100’ are not in the

language.

111.1.8 Example If n is a positive integer, then A n denotes the set of strings

in the alphabet A of length n. Thus if A = {0,1}, then A 2 = {‘00’, ‘01’, ‘10’,


‘11’} .

We take A 0 = {A}. Note that A 1 is the set of strings of length 1 in A, and so is

not the same thing as A.

111.1.9 Example The set L of strings in {0,1}* which read the same forward

and backward is a language. For example, ‘0110’ G L, but ‘10010’ ^ L. Such strings

are called palindromes.

111.2 Theorem

For any alphabet A,

A* = A 0 U A 1 U • • • U A n U • • • (111.1)
the union of the infinite sequence of languages A 0 , A 1 ,... ,A n ,... .

Proof This follows from the fact that every string in A* has some length n.

alphabet 93, 167

definition 4

empty language 169

empty string 168

finite 173

infinite 174

integer 3

language 169

positive integer 3

proof 4

string 93, 167

subset 43

theorem 2

union 47

usage 2

170

alphabet 93, 167

definition 4

empty string 168

induction 152

inductive defini-
tion 159

infinite 174

integer 3

string 93, 167

111.2.1 Remark An element of A* is a string of finite length. A* contains as

elements no infinite sequences of elements of A, although Equation (111.1)


expresses

it as the union of an infinite sequence of sets. This follows from the definition
of

“union”: to be in A* according to 111.1, an element has to be in A n for some

integer n , so has to be a string of length n for some n .

111.3 Inductive definition of languages

A language can sometimes be given an inductive definition paralleling the


definition

of A* given previously.

111.3.1 Example Let L be the set of strings in {0,1} of the form 0 fc l fc , for k
= 1 ,

2, .... In other words, L consists of A, ‘01’, ‘0011’, ‘000111’, ‘00001111’, and so

on. Then L can be defined by induction this way:

L.l The empty string A is a string in L.

L.2 If wei, then ‘0’u/l’ £ L.

L.3 Every string in L is given by one of the preceding rules.

111.3.2 Example The set P of palindromes can be defined this way:

111.4 Definition: the set of palindromes

Let A be a set.
PAL.l The empty string A is a string in P .

PAL. 2 If a £ A, then ‘a’ is a string in P.

PAL. 3 If re is a string in P and a £ A, then awa is a string in P .

PAL. 4 Every string in P is given by one of the preceding rules.

111.4.1 Remark Thus to show that ‘a66a’ is a palindrome, we say that A is a

palindrome by PAL.l, so ‘66’ (which is ‘6A6’) is a palindrome by PAL. 3, so ‘a66a’,

which is ‘a’‘66’‘a’, is a palindrome by PAL. 3.

111.4.2 Exercise Give inductive definitions of the following languages in the

alphabet {a, 6}:

a) The set of strings containing no o’ s.

b) The set of strings containing exactly one a.

c) The set of strings containing exactly two a’s.

171

112. Families of sets

112.1 Definition: family of sets

A tuple whose coordinates are sets is called a family of sets.

112.1.1 Usage A variant of this concept is to consider a set whose elements are

sets. For some authors, a family of sets is a set of sets instead of a tuple of
sets.
112.1.2 Example Let A\ = {1,2,3}, A 2 = {2,3,4,5} and A 3 = {3, 4, 5, 7}. Then

(Ai , A 2 , A 3 ) is a family of sets, and so is (Ai,{4,5,6},0) .

112.2 Definition: union and intersection

of a family of sets

Let S = (Aj)i £n be an n-tuple of sets Ai,A 2 ,... ,A n Then

ur=i A i = i x I 3*( X € Ai)} (112.1)

nr=i A i = i x \ x ^ A i)} (112.2)

Archimedean prop-

erty 115

coordinate 49

definition 4

family of sets 171

infinite 174

real number 12

subset 43

tuple 50, 139, 140

union 47

usage 2

112.2.1 Example Let A\ = {1,2,3}, A 2 = {2,3,4,5} and A 3 = {3, 4, 5, 7}. Then

UL^ = 11,2,3,4,5,7} and ft=iA = {3}.

112.2.2 Example This notation is frequently used for infinite sets. As an exam-

ple, recall that ( a..b ) denotes the subset {r £ R | a < r < b} of the reals. Then
if

T = {(— n..n) | n £ N + }, then = (— 1..1), and, by the Archimedean property,


IJJF = R. This is often written in the notation of infinite sequences:

OO OO

|^J (— n..n) = R and P| (— n. .n) = (— 1 . . 1)

n=l n — 1

112.2.3 Warning The symbol (jf=i Ai denotes A 1 UA 2 UA 3 . In contrast, the

symbol denotes the union of all the sets A* for each positive integer i ,

specifically not including anything denoted A^. Since “ 00 ” is not an integer, A^

(if such a thing has been defined) is not included in the union.

Thus “ U )= 1 A i ” goes up to 3 and includes 3, but does not include “ 00 ”.

There is notation analogous to that of Definition 112.2 for a set of sets (in
contrast

to a tuple of sets).

112.3

If T is

Definition: union and intersection

of a set of sets

a set whose elements are sets, then

[fiT = {x (3A £ F)(x £ A)}


(112.3)

and

n^={x| (VA £ JF)(x £ A)}

(112.4)

172

empty set 33

equivalent 40

family of sets 171

hypothesis 36

implication 35, 36

intersection 47

powerset 46

subset 43

union 47

vacuous 37

112.3.1 Example Let J 7 = {{1,2, 3}, {2, 3}, {3, 4}}. Then = {1,2, 3, 4} and

rv !••*}•

112.3.2 Exercise Give an explicit description of these sets.


a) U“i(-*--* + 2 )

b) U“i(-l/i"V0

c) n“i("l/i-l + (V0)

d)

e)

112.4 Intersection and union over the empty set

If T is a family of subsets of a set B, then we can reword the definition of the

intersection of the sets in J 7 as follows: it is the set T defined by the


property:

(V5)(5e.A ^ xeS)^x&T

If J 7 is empty, the hypothesis is vacuously true, so x G T for every x £ B ; in


other

words, T = B . Thus we define the intersection of the empty set of subsets of a set

B to be B itself. Note that this definition is relative to a set containing as


subsets

all the sets in J 7 , in contrast to the intersection of families of sets in


general as

defined in the preceding section.

The union U of a family of sets T of subsets of B can be described by the

property:

(35) (S^J 7 /\x^S)<^x^U

(note the placement of the parentheses). If J 7 is empty, then there is no 5 6 J


7 , so

we define the union of an empty family of sets to be the empty set.

112.4.1 Warning In discussing sets of sets, remember that if J 7 is a set of sets,

an element of T is a set. It is a mistake to think of the words “element” and “set”


as contrasting with each other. An element of a set may or may not be a set itself.

Also, any set 5 is an element of some other set, for example of {5} .

112.4.2 Exercise Give an explicit description of IJiF and |"| J- for each of these

families of subsets of R:

a) J 7 = {{2, 4}, {1,3, 4}, {2, 5}}.

b) J 7 = {(—3. .3), (—2 . .2), (— 1 . . 1)} .

c) -T 7 = {(— 1 • • 1), (1 • • 2), (2 . . 3)} .

(Answer on page 249.)

112.4.3 Exercise What are {JVA and f) VA for any set A?

173

113. Finite sets

We begin by giving a mathematical definition of the idea that a set has n elements.

No doubt you have no trouble understanding a statement such as “S has 5 elements”

without a formal definition; however, giving a formal meaning to such statements

allows us to prove theorems about the number of elements of a set that have turned

out to have many applications.

In this definition we use the set n = {?' £ N | 1 < i < ra} (Definition 36.1,

page 50).

bijection 136

cardinality 173
definition 4

divisor 5

empty set 33

finite set 173

finite 173

integer 3

nonnegative integer 3

positive integer 3

113.1 Definition: number of elements

of a finite set

Let n be a nonnegative integer. The statement, “A set S has n ele-

ments” means there is a bijection F : n — > S .

113.1.1 Example A set has 5 elements if there is a bijection from {1,2, 3, 4, 5}

to the set. Thus the formal definition captures the usual meaning of number of

elements: if a set has 5 elements, the process of counting them — “This is the
first

element, this is the second element, ...” — in effect constructs a bijection from n

to the set.

113.1.2 Exercise Give an explicit proof that the set of positive divisors of 8 has

4 elements. (Answer on page 249.)

113.2 Definition: finite

A finite set is a set with n elements, where n is some nonnegative

integer.

113.2.1 Example The empty set is finite, since it has 0 elements, and the set

{1,3, 5, 7, 9} is finite because it has 5 elements.


113.3 Definition: cardinality

The number of elements of a finite set is the cardinality of the set. For

any finite set A, the cardinality of A is denoted |A| .

113.3.1 Example |0|=O and | {1 , 3}| = 2 .

113.3.2 Exercise Show that if A is a finite set and /3: B — )• A is a bijection


then

B is finite.

113.3.3 Exercise Show that a subset of a finite set is finite. Make sure you use

the definition of finite in your proof.

174

bijection 136

countably infi-

nite 174

definition 4

finite 173

independent 174

infinite 174

integer 3

nonnegative integer 3
positive integer 3

113.4 Infinite sets

A set which is not finite is infinite. Sets such as N, Z and R are infinite. Since

“infinite” merely means “not finite”, to say that R (for example) is infinite means

just that there is no nonnegative integer n for which the statement “R has n

elements” is true. This is certainly correct in the case of R, since if you claim
(for

example) that R has 42 elements, all I have to do is add up the absolute values of

those 42 numbers to get a number which is bigger than all of them, so is a 43rd

element.

We do not go into the extensive theory of infinite sets in this book, but it is

important to understand the difference between “finite” and “infinite” since many

theorems, such as the ones in this section, concern only finite sets.

113.4.1 Warning It is tempting when faced with proving a theorem about pos-

sibly infinite sets to talk about one set having “more elements than another” .
Such

arguments are often fallacious. For example: “There cannot possibly be an injec-

tive function from N x N to N since N x N has more elements than N.” But there

are such functions: see Exercises 93.1.8 and 113.5.3. Compare the extended hint to

Exercise 92.1.8.

113.5 Exercise set

A set S is countably infinite if there is a bijection /3:N — > S . Problems 113.5.1

through 113.5.4 explore this property.

113.5.1 Exercise Show that the set N + of positive integers is countably infinite.
(Answer on page 249.)

113.5.2 Exercise Show that Z is countably infinite.

113.5.3 Exercise Show that N x N is countably infinite.

113.5.4 Exercise (hard) Show that Q is countably infinite.

114. Multiplication of Choices

The principle of multiplication of choices, stated below, is behind the sort of


rea-

soning illustrated in the following argument: You are at a restaurant whose menu

has three columns, A, B and C. To have a complete meal, you order one of the three

items in column A, one of the five items in column B, and one of the three items in

column C. You can therefore choose 45 = 3 x 5 x 3 different meals.

114.1 Definition: independent tasks

Suppose that there are k tasks Ti, T 2 , . . . , T) 0 which must be done in

order, and, for each i = 1,2, . . . , k, there are n t ways of doing task 7) .

Suppose furthermore that doing T t in any particular way does not change

the number nj ways of doing any later task Tj . Then we say that the

tasks are independent of each other.

175

114.2 Theorem: The Principle of

Multiplication of Choices
Suppose there are k independent tasks Ti (i = 1, . . . ,k) and suppose that

for each i there are nt ways of doing T t (i = 1, . . . , k) . Then there are

nil n i = nin 2 ■ ■ - Tifc ways of doing the tasks Ti, . . . ,T k in order.

Proof We prove Theorem 114.2 by induction on k, starting at 1.

If you have one task Ti which can be done in ri\ different ways, Theorem 114.2

says you can do Ti in n!=i n * = n i different ways, which of course is true.

Now suppose the theorem is true for k tasks. Assume you have k + 1 tasks

Ti,... ,T k ,T k+ i, and for each i there are n* ways of doing task T % . Let m be
the

total number of ways of doing the tasks Ti, . . . ,T k in order. Suppose you have
done

them in one of the m ways. Then you can do T k+ \ in any of ni+i ways. Thus

for each of the m ways of doing the first k tasks, you have ni + \ ways of doing
the

(k + l)st; therefore, there are altogether n l+ \ + n ,; + 1 H hnj+i (sum of m


terms)

ways of doing the k + 1 tasks. This means that there are m x m+ 1 ways to do

Ti,... ,T k+ 1 in order.

By induction hypothesis, m = n!=i n i > so the number of ways of doing the tasks

Ti,... ,T k+ 1 is

n k+ 1 • (J^n*)

1=1

which by 105.1.5 is nf=i lra *> as required.

114.2.1 Worked Exercise How many three-digit integers (in decimal notation)

are there whose second digit is not 5?


Answer Writing such a sequence of digits can be perceived as carrying out three

tasks in a row:

T.l Write any digit except 0.

T.2 Write any digit except 5.

T.3 Write any digit.

There are 9 ways to do T.l, 9 ways to do T.2, and 10 ways to do T.3, so

according to Theorem 114.2, there are 810 ways to do T.l, T.2, T.3 in order.

114.2.2 Worked Exercise Find the number of strings of length n in {a,b,c}*

that contain exactly one a.

Answer This requires us to look at the problem in a slightly different way from

Worked Exercise 114.2.1. To construct a string of length in {a,b,c}* with exactly

one a requires us to

a) Choose which of n possible locations to put the one and only a (n ways to

do this).

b) For each of the n — 1 other locations, choose whether to put a b or c there (2

choices for each location, 2 n_1 choices altogether).

It follows that there are n-2” _1 such strings.

decimal 12, 93

digit 93

induction hypothe-

sis 152

induction 152
integer 3

proof 4

theorem 2

176

digit 93

even 5

finite 173

include 43

integer 3

powerset 46

string 93, 167

theorem 2

114.2.3 Exercise Find the number of 5-digit integers with ‘3’ in the middle place.

(Answer on page 249.)

114.2.4 Exercise Find the number of even 5-digit integers. (Answer on page

249.)

114.3 Exercise set

In exercises 114.3.2 through 114.3.5, A = {a,b,c}.

114.3.1 Exercise Find the number of strings of length n in {a,b,c}* with no

a’s. (Answer on page 249.)

114.3.2 Exercise Find a formula F{n) for the number of strings in A* of length

n, for each n £ N. (Answer on page 249.)


114.3.3 Exercise Find a formula G{n ) for the number of strings in A* of length

n which begin and end with a. (Answer on page 249.)

114.3.4 Exercise Find a formula H{n ) for the number of strings in A* of length

n which do not begin or end with c.

114.3.5 Exercise Find a formula for the number of strings in A* of length n> 2

which have a ‘a’ in the third place.

114.3.6 Exercise In the USA a local telephone number consists of a string of 7

digits, the first two of which cannot be 0 or 1 . How many possible local telephone

numbers are there?

115. Counting with set operations

Almost every operation associated with set theory has a corresponding combinatorial

principle or counting technique applicable to finite sets associated with it. Some
of

these are obvious, others are more subtle. The first example has to do with
inclusion:

115.1 Theorem

If A and B are finite sets and A C B , then \ A\ < \B\ .

(We told you some of the principles were obvious!)

115.1.1 Exercise Show that if A and B are finite then |Anl?| < |A|.

There is a principle for powersets, too.

177
115.2 Theorem

If a set A has n elements then VA has 2 n elements.

Proof The easiest proof of this theorem uses the Principle of Multiplication of

Choices (Theorem 114.2). If A has n elements and you want to describe a subset of

A, you may go through the n elements of A one by one and say whether each one

is in the subset. There are two choices (yes or no) for each element and n
elements,

so the Principle of Multiplication of Choices says that you can make 2 n choices

altogether.

115.2.1 Remark As is the case with any counting technique based on the Prin-

ciple of Multiplication of Choices, it is also possible to prove Theorem 115.2 by

a direct argument using induction. (Recall that the Principle of Multiplication of

Choices was proved by induction.)

Cartesian product 52

even 5

induction 152

Multiplication of

Choices 175

odd 5

powerset 46

proof 4

singleton 34

subset 43

theorem 2
115.2.2 Worked Exercise How many subsets with an even number of elements

does a set with n elements have? Explain your answer.

Answer A set S with n elements has 2 n ~ 1 subsets with an even number of ele-

ments. Proof: To give a subset A of S, for each element of S except the last one

you must choose whether that element is in A. That requires 2 n ~ 1 independent

choices. You have no choice concerning the last element: if at that point the
subset

has an odd number of elements so far, you must include the last one, and if it has

an even number so far, you must not include the last one.

115.2.3 Exercise Let S be an ra-element set. How many elements do the follow-

ing sets have?

a) The set of nonempty subsets of S .

b) The set of singleton subsets of S .

c) The set of subsets of the powerset of S .

(Answer on page 249.)

The following theorem can be proved using Multiplication of Choices.

115.3 Theorem

If A and B are finite, then \A x B\ = \A\ \B

115.3.1 Exercise If A has m elements and B has n elements, how many ele-

ments do each of these sets have?

a) Ax A
b) V(AxA)

c) V(A x B)

115.3.2 Exercise Prove Theorem 115.1.

115.3.3 Exercise Prove Theorem 115.3.

178

family of sets

finite 173

function 56

proof 4

subset 43

theorem 2

union 47

171 115.3.4 Exercise Suppose A has m elements and B has n elements.

a) Prove that MAX(m,n) < |TU B\ < m + n.

b) Prove that 0 < \A(^B\ < MIN(m,n) .

c) Prove that the symbols ‘ < ’ in (a) and (b) cannot be replaced by ‘ < ’ .

115.3.5 Exercise Let A be a finite set and F:A—$B a function. Prove that
\T(F)\ = \A\.

116. The Principle of Inclusion and Exclusion

116.1 Theorem

Let A and B be finite sets. Then

\AUB\ = \A\ + \B\-\AHB\ (116.1)

Proof This follows from the fact that the expression |T| + \B\ counts the elements

which are in both sets twice, so to get the correct count for \AlJB\, you have to

subtract \AnB\.

116.1.1 Remark More generally, if C and D are also finite sets, then

\AUBUC\ = \A\ + \B\ + \C\ -\AnB\-\Anc\-\Bnc\ + \AnBnc\

and

\AUBUCUD\ = \A\ + \B\ + \C\ + \D\

- \AnB\ - |AnC| - \ACD\

-\Bnc\-\BnD\-\cnD\

+ \AnBnC\ + \AnBnD\

+ \AnCnD\ + \BnCnD\

-\AnBnCnD\

(116.2)
(116.3)

116.1.2 The general principle Equations (116.1)-(116.3) are special cases of a

general principle which requires some notation to state properly. Let T be a family

of n distinct finite sets. For each k = 1,2,. . . ,n, let Fk be the set of fc-
element

subsets of F . For example, if F = {A,B,C,D} , then

F 3 = {{A,B,C},{A,B,D},{A,C,D},{B,C,D}}

Then we have:

179

116.2 Theorem: The Principle of

Inclusion and Exclusion

Using the notation of Section 116.1.2,

W = £1*1- £ |nG|

+ £ |nG| - ...

(116.4)

XeT G&X 2
G&T . 3

-(-P E i n °i +

Ge^fe

•••-(-I) n |n^|

116.2.1 Remarks

a) The first sum is over the elements of T (which are themselves sets), whereas

the others are over intersections of subfamilies G of J- , with a plus sign for

subfamilies with an odd number of elements and a minus sign for those with

an even number of elements.

b) You should check that Equations (116.1)— (116.3) are special cases of this Prin-

ciple.

c) The Principle of Inclusion and Exclusion will not be proved here, but you

should be able to see with no trouble why it is true for families of three or

four sets.

116.2.2 Example The Principle of Inclusion and Exclusion is stated as an equa-

tion, so you can solve for one of its terms if you know all the others.

For example, suppose there was a party with 9 people, including 5 Norwegians.

There was only one man at the party who was neither a vegetarian nor a Norwe-

gian. All the vegetarians were Norwegians and two of the women were Norwegians.

Exactly one woman was a vegetarian. How many women were at the party?
To solve this, let W be the set of women, N the set of Norwegians, and V

the set of vegetarians. The party had 9 people, and only one was not in W U

N U V, so |ITUlVUH| = 8. We are given that \N\ = 5. Since 2 of the women

were Norwegians, |WnIV| =2, and since one woman was a vegetarian and every

vegetarian was a Norwegian, we know \W n V\ = | W n IVn V| = 1 and also |H| =

\NHV\.

Thus in the sum

\WUNUV\ = \W\ + \N\ + \V\-

\wnN\-\wnv\-\Nnv\ + \wnNnv\

we have

8=\w\ + 5 + \v\-2-\wnv\-\Nnv\ + \wnNnv\

or since |H| = \N D V \ ,

8 = \ W\ + 5 — 2 = \ W\ + 3

even 5

inclusion and exclu-

sion 179

intersection 47

odd 5

theorem 2

so that there were 5 women at the party.


180

definition 4

fact 1

family of sets 171

finite 173

implication 35, 36

pairwise disjoint 180

partition 180

subset 43

union 47

usage 2

116.2.3 Exercise You have a collection of American pennies. Three of them are

zinc pennies and eight of them were minted before 1932. What do you have to know

to determine the total number of pennies? Explain your answer! (Answer on page

249.)

116.2.4 Exercise A, B and C are finite sets with the following properties: A U

BuC has 10 elements; B has twice as many elements as A; C has 5 elements; B

and C are disjoint; and there is just one element in A that is also in B . Show
that

A has at least 2 elements.

116.2.5 Exercise Suppose that A, B and C are finite sets with the following

properties:

(i) B has one more element than A.


(ii) C has one more element than B .

(iii) AnB is twice as big as An C .

(iv) B and C have no elements in common.

Prove that |AU BL)C\ is divisible by 3.

116.2.6 Exercise Cornwall Computernut has 5 computers with hard disk drives

and one without. Of these, several have speech synthesizers, including the one
with-

out hard disk. Several have Pascal, including all those with synthesizers. Exactly
3

of the computers with hard disk have Pascal. How many have Pascal?

117. Partitions

117.1 Definition: partition

If C is a set, a family n of nonempty subsets of C is called a partition

of C if

PAR.l C = un, and

PAR. 2 For all A, B e n , A^B => AnB = 0 .

117.1.1 Usage The elements of the partition n are called the blocks of n. If

igC, the block of n that has x as an element is denoted [x]n> or just [x] if the

partition is clear from context.

117.1.2 Fact P.2 says the blocks of n (remember that these subsets of C) are

pairwise disjoint: if they are different, they can’t overlap.

117.1.3 Fact P.l and P.2 together are equivalent to saying that every element of
C is in exactly one block of n.

117.1.4 Example Here are three partitions of the set {1,2, 3, 4, 5}:

a) n 1 = {{l,2},{3,4},{5}}.

b) H 2 = {{1},{2},{3},{4},{5}}.

c) n 3 = {{1,2, 3, 4, 5}}.

181

117.1.5 Example The set {{1,2},{3,4},{5},0} is not a partition of any set

because it contains the empty set as an element.

117.1.6 Example Let S be any nonempty set and A any proper nontrivial subset

of A. Then {S', S' — A} is a partition of A with two blocks.

117.1.7 Example The empty set has a unique partition which is also the empty

set. It has no blocks.

117.1.8 Exercise Why does Example 117.1.6 have to require that A bea proper

nontrivial subset of A?

block 180

empty set 33

finite 173

infinite 174

nontrivial subset 45

partition 180
proper subset 45

tuple 50, 139, 140

union 47

usage 2

117.1.9 Worked Exercise Let S be a nonempty finite set with n elements. How

many partititions of S with exactly two blocks are there?

Answer There are 2 n — 1 nonempty subsets of S and, except for S itself, each one

induces a two-block partition as in Example 117.1.6. This does not mean that there

are 2 n — 2 two-block partitions because that would count each two-block partition

twice (a subset and its complement each induce the same two-block partition). So

the correct answer is that there are

l(2 n -2) = 2 n - 1 -l

two-block partitions.

117.1.10 Warning One of the commonest mistakes made by people just begin-

ning to learn counting is to come up with a seemingly reasonable technique which

unfortunately counts some things more than once.

117.1.11 Exercise Find a formula for the number of partitions with exactly three

blocks of an n -element set.

117.1.12 Usage A partition with a finite number of blocks (even though the

blocks might be infinite sets) is commonly written as a tuple, e.g., n = (Aj)j en .

Even so, if n' is another partition which is the same as n except for ordering,
they

are regarded as the same partition even though they are different tuples. We will

follow that practice here.


117.1.13 Exercise Which of the following are partitions of S' = {1,2, 3, 4, 5}?

Here, A = {1,2}, B = {3,4,5}, U7 = {3} , L> = {4,5}.

a)

b)

c)

d)

{A,B} e) {S}

{A,B,C} f) {{4 |zGS}

{A,C,D} g) {C,S-C}

{A,H,0} h) {AuC,D}

(Answer on page 250.)

182

block 180

family of sets 171

finite 173

floored division 87

inclusion and exclu-

sion 179

infinite 174
integer 3

negative integer 3

partition 180

positive integer 3

remainder 83

theorem 2

117.2 Partition of Z by remainders

Any poesitive integer n induces a very important partition of the set Z of


integers.

This partition is denoted Z/n. The blocks of Z/n are the n sets

C r = {m £ Z | m leaves a remainder of r when divided by n}

for 0 < r < n. For negative m floored division must be used. (Observe that the

notation “ C r ” requires you to depend on context to know what n is.) Thus Z/n =

{C r | 0 < r < n}.

117.2.1 Remark It is important to understand that Z/n is a finite set, even

though each block is an infinite set.

117.2.2 Example If n = 3, Z/3 has three blocks. One of them is C\ , which is

the set of integers which leave a remainder of 1 when divided by 3. Thus 1, —2

and 16 are in C\ . Cq is the set of integers divisible by 3. Thus Z/3 = {Cq,Ci,C


2 } ■

117.3 Exercise set

In problems 117.3.1 through 117.3.5, provide an example of a partition II of Z with

the given property.

117.3.1 II has at least one block with exactly three elements. (Answer on page
250.)

117.3.2 {1,2} and {3} are blocks of II.

117.3.3 II has at least one finite block and at least one infinite block.

117.3.4 II has an infinite number of finite blocks.

117.3.5 II has an infinite number of infinite blocks.

118. Counting with partitions

P.2 in Definition 117.1 implies that, in the statement of the Principle of


Inclusion

and Exclusion, the sums over families with more than one element disappear. This

gives the following theorem, which is obvious anyway:

118.1 Theorem

If II = (Aj)j en is a partition of a finite set C , then \C\ = £” =1 \Ai\ .

This Theorem together with the phenomenon of Example 117.1.6 gives a method:

183

118.1.1 Method

To count the number of elements of a subset A of a set S, count the

number of elements of S and subtract the number of elements of the

complement S — A.

118.1.2 Worked Exercise How many strings of length n in {a,b,c}* are there

that have more than one a?


Answer We will use Method 118.1.1. We know from Exercises 114.2.2 and 114.3.1

that there are 2 n strings with no a and n ■ 2 n ~ 1 strings with one a. Since
there are

3 n strings of length n in {a, b, c}* , the answer is 3 n — 2 n — n ■ 2 n ~ 1 .

block 180

class function 183

definition 4

partition 180

surjective 133

take 57

usage 2

118.1.3 Exercise How many strings of length n in {a, b}* are there that have

more than one a?

118.1.4 Exercise How many strings of length n in {a, b}* are there that satisfy

the following requirement: If it has an a in it, it has at least two.

118.1.5 Exercise How many strings of length n in {a,b,c}* are there that have

exactly two different letters in them (so each one is either all a’s and 6’s, all
a’s

and c’s, or all b 1 s and c’s.)?

118.1.6 Exercise In the USA the identifying name of a radio station consist of

strings of letters of length 3 or 4, beginning with K or W. Upper and lower case

are not distinguished. How many legal identifying names are there?
119. The class function

119.1 Definition: the class function

If n is a partition of a set A, then the class function clsn : A — > n

takes an element a of A to the block of n that has it as an element.

119.1.1 Example If A = {1,2, 3, 4, 5} and H = {{1,2},{3,4,5}}, then clsn (3) =

{3,4,5}.

119.1.2 Usage A common notation for the class function is [] : A — > n; in Exam-

ple 119.1.1, one would write [3] = {3,4,5}.

119.1.3 Example In Example 117.1.4, [2]n 1 = {l,2}.

119.1.4 Warning Note that in Example 119.1.1, [3] = [4] = [5] , but [2] / [3] . In

mathematics, the fact that two different names are used does not mean they name

different things. (This point was made before, in Example 58.1.2.)

119.1.5 Example If n is the partition Z/3, then [2] = [5] = [—1] = C' 2 , and [3] =

C 0 .

119.1.6 Exercise Prove that for any set S with partition n, the class function

els : S — > n is surjective.

184

block 180

definition 4
family of sets 171

floored division 87

function 56

image 131

integer 3

list 164

mod 82, 204

negative integer 3

partition 180

quotient set (of a

function) 184

remainder 83

take 57

theorem 2

120. The quotient of a function

We mentioned the partition Z/n = {C r | 0 < r < n} in section 117.2. It is a


special

case of a construction which works for any function:

120.1 Theorem

Let F : A—¥ B be a function. Then the family of sets

{F _1 (6) | belmF}

is a partition of A .

120.2 Definition: quotient set


The set {T 1_1 (6) | b G ImT 1 } is denoted A/F and is called the quotient

set of F .

120.2.1 Example Consider the function F : {1,2,3} — > {2, 4, 5, 6} defined by

F(l) = 4 and F( 2) = F( 3) = 5. Its quotient set (of a function) is {{1},{2,3}}.

120.2.2 Example The quotient set (of a function) of the squaring function S :

R — > R defined by S(x) = x 2 is

R/S = {{r, — ?'} | r G R}

Every block of R/S has two elements with the exception of the block {0}. The

notation “{{r,— r} | r G R}” for R/S 1 lists {0} as {0,-0}, but that is the same

set as |0j. Note that every set except |0| is listed twice in the expression

“{{r,-r} | r G R}” .

120.2.3 Example Let’s look at the remainder function R n (k ) = fcmodn for a

fixed integer n. This function takes an integer k to its remainder when divided by
n.

(As earlier, we use floored division for negative k). For a particular remainder r,

the set of integers which leave a remainder of r when divided by n is the set we

called C r earlier in the section. Thus the quotient set of R n is the set we
called

Z /n.

120.3 Proof of Theorem 120.1

We must show that the blocks of A/F are nonempty and that every element of A

is in exactly one block of A/F .

That the blocks are nonempty follows the fact that A/F consists of those 1 ?_1 (6)

for which b G ImF; if b G ImF, then there is some a G A with F(a) = b, which

implies that a G F~ 1 (6), so that F _1 (6) is nonempty. Since a G F~ 1 (F(a )) ,


every
element of A is in at least one block. If a G F~ 1 (b) also, then F(a) = b by
definition,

so F~ 1 (F(a)) = F _1 (6) , so no element is in more than one block.

120.3.1 Exercise For a function F : S —> T , define a condition on the quotient

set S/F which is true if and only if F is injective. (Answer on page 250.)

185

120.3.2 Exercise Give examples of two functions F : N — > N and G : N — >■ N with

the property that F is surjective, G is not surjective and F and G have the same

quotient set. (Thus, in contrast to Exercise 120.3.1, there is no condition on the

quotient set of a function that forces the function to be surjective.)

120.4 Exercise set

In Problems 120.4.1 through 120.4.5, provide an example of a function F : R — > R

for which R /F has the given property.

120.4.1 R /F has at least one block with exactly three elements. (Answer on

page 250.)

120.4.2 R/F has exactly three blocks.

120.4.3 R/F is finite.

120.4.4 Every block of R/F is finite.

120.4.5 Every block of R/F has exactly two elements.

120.4.6 Exercise Suppose F : A — >• B is a function, and x and y are distinct

elements of B . Suppose also that |A| = 7, |£>| = 4, ImF = B — {y} , and that the
function F | (A — F~ 1 (x) s ) is injective.

a) How many elements does A/F have?

b) How many elements are there in each block of A/ FI

120.4.7 Exercise (hard) Let A be a set, n a partition of A and B a subset of

A. Define the set n|R of subsets of B by

U\B = {CnB I Gen and CnR/0}

a) Prove that n|L> is a partition of B .

b) Give an example to show that the set {CnB \ C 6 n} need not be a partition

of B .

120.4.8 Exercise (hard) Let A be a set, n a partition of A, and $ a partition

of n . For any block C € 4> , let Be be the union of all the blocks Bg n for which

B G C . Show that {Be \ C £ <h} is a partition of A. (For many people, this


exercise

will be an excellent example of a common phenomenon in conceptual mathematics:

It seems incomprehensible at first, but when you finally figure out what the
notation

means, you see that it is obviously true.)

block 180

finite 173

function 56

image 131

injective 134

partition 180

subset 43
186

bijection 136

block 180

codomain 56

function 56

image 131

injective 134

surjective 133

theorem 2

121. The fundamental bijection theorem

The following theorem forms a theoretical basis for very important constructions in

abstract mathematics:

121.1 Theorem: The Fundamental Bijection Theorem

for functions

Let F : A-$ B be a function, and define @f to be the function F~ l {b) >-)•

b. Then (3p is a bijection fip : A/F ->ImF.

121.1.1 Example For the function F : {1,2,3} — > {2, 4, 5, 6} defined by F(l)=4

and F( 2) = F( 3) = 5, we have /3f({1}) = 4 and ^({2,3}) = 5.

121.1.2 Remark The input to the bijection is a set, namely a block of A/F , and

the output is an element of the codomain of F . The statement that /3p({2,3}) = 5

means that when you plug {2,3} into (5f ( not when you plug 2 in or 3 in!) you

get 5.
121.2 Proof of Theorem 121.1

It is easy to see that (5f really is a bijection. If b £ Irn F , then there is some
element

a £ A for which F(a) = b, so 1 ?_1 (6) is nonempty and hence an element of A/F .

Then /3 f(F -1 (&)) = b so (3f is surjective.

Proving injectivity reduces to showing that if F _1 (&) T 7, 1 (c) , then bfic.

If F _1 (6) F-\c), then there is some element a £ A for which a £ 1 ? ^ 1 (6) but

a $/ F~ x {c) (or vice versa). The statement a £ 1 ?_1 (6) means that F(a) = b, and

the statement a ^ F _1 (c) means that F(a) c. Thus bfic, as required.

121.2.1 Exercise Let A = {1,2, 3,4,5} . For each function F : A R given below,

write out all the values of the bijection fip '■ A/F — > ImP given by Theorem
121.1.

a) F(l) = F( 3) = F( 5) = 4, F( 4) = 6, F( 2) = 0.

b) F(n) = 3 for all n £ A .

c) F(n) = n for all n £ A.

d) F(n) = n 2 for all n £ A.

e) F(n) = 7i 3 — 3n 2 + 2n — 5 for all n £ A.

(Answer on page 250.)

187

122. Elementary facts about finite sets and functions


This chapter contains miscellaneous results, mostly easy, concerning finite sets
and

functions between them. The facts about finite sets A and B in the following

theorem are not difficult to see using examples. We give part of the proof and
leave

the rest to you.

122.1 Theorem

Let A and B be finite sets. Then:

a) |T| = \B\ if and only if there is a bijection (3: A—t B .

b) |T| < \B\ if and only if there is an injective function F : A—> B .

c) If B is nonempty, |T| > \B\ if and only if there is a surjective

function G : T — > B .

bijection 136

bijective 136

composition (of

functions) 140

finite 173

function 56

image 131

injective 134

proof 4

quotient set (of a

function) 184

subset 43

surjective 133
theorem 2

Proof By Definition 113.1, if A and B both have n elements then there are

bijections (3 : n — > A and f3':n—^B. Then, using Theorem 101.5, page 149, Theo-

rem 101.3, page 148 and Exercise 98.2.7 of Chapter 98, (3 ' ° (3~ l : A -» B is a
bijection.

To finish the proof of (a), we must show that if there is a bijection (3: T — >■ B
then

A and B have the same number of elements. This is left as an exercise.

We also leave (b) as an exercise, and prove half of (c). Suppose A has m

elements and B has n elements with m>n> 0 . Then there are bijections f3 : m — >

A and f3' : n — >■ B . Let us define a function F : m — > n by: F(k) = k if k < n,

and F(k) = n if k > n. F is surjective, because if 1 < i < n, then F(i) = i . Then

(3' °F° (3~ l : A—> B is the composite of a bijection, a surjection and a


bijection, so

is a surjection by Exercise 98.2.7 of Chapter 98.

122.1.1 Exercise Complete the proof of Theorem 122.1.

122.1.2 Exercise Use the principles of counting for finite sets that we have intro-

duced to prove that if II is a partition of a finite set A , then |II| < 14 -

Here is another useful theorem:

122.2 Theorem

If A and B are finite sets and \A\ = \B\ , then a function F : A—> B is

injective if and only if it is surjective.

Proof Let F : T — >■ B be injective. Then ImL, being a subset of B , has no more

than \B\ elements by Theorem 115.1. Since F is injective, ImF has at least |T|
elements by Theorem 122.1(a). Since |T| = |L>|, it follows that ImL has exactly

\B\ elements, so Im F = B. Hence F is surjective.

Conversely, if F is not injective, then the quotient A/F has fewer elements

than A. The fundamental bijection theorem (Theorem 121.1) says that then ImF

has fewer elements than A, so it has fewer elements than B since |T| = |L>|. That

means ImF B , so F is not surjective.

188

alphabet 93, 167

bijection 136

decimal 12, 93

digit 93

finite 173

function 56

include 43

infinite 174

injective 134

integer 3

Multiplication of

Choices 175

powerset 46

proof 4

shift function 188

surjective 133

theorem 2
122.2.1 Warning Observe that if |A| = \B\, then Theorem 122.1(a) says there

is an injection from A to B and Theorem 122.1(b) says that there is a surjection

from A to B . But Theorems 122.1(a) and (b) do not say that the injection and

the surjection have to he the same function, so it would be a fallacy to deduce

Theorem 122.2 from those two facts.

122.2.2 Warning Theorem 122.2 allows you to determine whether a function

from a finite set to itself is a bijection by testing either injectivity or


surjectivity —

you don’t have to test both. However, you have to test both for infinite sets. For

example, the shift function m- )-n+l:N— >N is injective but not surjective (0

is not a value) and 0 i — 0 , nun - 1 for n > 0 defines a function N — > N which is

surjective but not injective, since 0 and 1 both have value 0.

Here is a counting principle for function sets:

122.3 Theorem

If A = n and \B

| = m, then there are m n functions from A to B . In

other words,

b a

II
Proof To construct an element of B , that is, a function from A to B, you have

to say what F(a) is for each element of A. For each a you have m choices for

B(a) since F(a) has to be an element of B and B has m elements. There are

n elements a of A for each of which you have to make these choices, so by the

Principle of Multiplication of Choices there are m n possibilities altogether.

122.3.1 Exercise How many ways are there of assigning a letter of the alphabet

to each decimal digit, allowing the same letter to be assigned to different digits?

(Answer on page 250.)

122.3.2 Exercise

a) Show by quoting principles enunciated here that if A and B are finite, A C B

and Af^B, then there is no bijection from A to B .

b) Show that the statement in (a) can be false if A and B are infinite.

122.3.3 Exercise Let F{n) be the number of functions from VS to S , where S

is a set with n elements, and let G(n ) be the number of functions from S to its

powerset. For which integers n is F(n ) = G(n)l

189

123. The Pigeonhole Principle

In its contrapositive form. Theorem 122.1(b) says the following:

123.1 Theorem

For any finite sets A and B , if |A| > \B\ , then no function from A to
B is injective.

123.1.1 Example If you have a set A of pigeons and a set B of pigeonholes,

\A\ > \B\, and you put each pigeon in a pigeonhole (thereby giving a function from

A to B ) , then at least one pigeonhole has to have two pigeons in it (the function
is

not injective). For this reason, Theorem 123.1 is called the Pigeonhole Principle.

block 180

contrapositive 42

function 56

injective 134

partition 180

Pigeonhole Princi-

ple 189

recurrence 161

subset 43

theorem 2

123.1.2 Example An obvious example of the use of the Pigeonhole Principle is

that in any room containing 367 people, two of them must have the same birthday.

Note that the Pigeonhole Principle gives you no way to find out who they are.

123.1.3 Worked Exercise Let S = {n:N | 1 < n < 10}. Show that any subset

T of S with more than 5 elements contains two numbers that add up to 11.

Answer The following are all the two-elenrent subsets of S whose elements add

up to 11: {1,10}, {2,9}, {3,8}, {4,7}, {5,6}. They form a partition of S with

five blocks. Every element of T is in one of these subsets, and since T has more

than five elements, by the Pigeonhole Principle two different elements must be in

the same block of the partition.


123.1.4 Exercise Let S be as in Worked Exercise 123.1.3. Show that if T C S

and \T\ > 4 then there are two different elements of T that have the same remainder

when divides by 3.

123.1.5 Exercise Let A = {n : N | 1 < n < 12} . Find the least integer n so that

the following statement is true: If T C A and |T| > n, then T contains two distinct

elements whose product is 12.

124. Recurrence relations in counting

Many counting formulas can be derived as recurrence relations. In many cases, you

can then find a closed formula which evaluates the recurrence relation, but even

if you cannot do that, the recurrence relation gives you a way of evaluating the

formula for successive values of n.

124.1 Theorem

If A has n elements, then there are n\ different permutations of A .

To prove this, it is useful to prove something more general.

190

bijection 136

definition 4

even 5
odd 5

proof 4

recurrence 161

string 93, 167

subset 43

124.2 Theorem

The number of bijections between two n-element sets is n\ .

Proof Let P(n) be the number of bijections between two n-element sets. Then

P(0) = P(l) = 1. Let A and B be two sets with n+ 1 elements. Let a G A. Then

in constructing a bijection from A to B we have n + 1 choices for the value of the

bijection at a. If we choose b £ B , then what is left is a bijection from A — {a}


to

B — {b} . These are both n-element sets, so there are P(ji) of these, by definition

of P(n) . Hence

P(n + 1) = (n + 1) • P(n)

This is the recurrence relation which (with P(0) = 1) defines n! (see Section
105.1.6,

page 158), so P{n ) =n!.

Here is another example of using recurrences in counting:

124.2.1 Worked Exercise Derive a formula or recurrence relation for the number

of strings of length n in {0,1}* with an even number of l’s.

Answer Let Fiji) be the number of such strings. Obviously F( 0) = T\l) = 1.

There are Fiji) strings of length n with an even number of ones and 2 n — Fiji)

with an odd number of ones. (Note that there is no justification at this point for

assuming that the number of strings of length n with an even number of ones and

the number with an odd number of ones are the same.) You can adjoin a 0 to a
string of the first type and a 1 to a string of the second type to get a string of
length

n + 1 with an even number of ones. Thus Fiji + 1) = Fiji) + 2 n — Fiji) = 2 n .


This

is a case of a recurrence relation that solves itself!

124.2.2 Exercise Derive a formula or recurrence relation for the number of ways

to arrange n people around a circular table. (All that matters is who sits on each

person’s left and who sits on his or her right.)

124.2.3 Exercise Derive a formula or recurrence relation for the amount of money

in a savings account after n years if the interest rate is i% compounded annually

and you start with $100.

125. The number of subsets of a set

125.1 Definition: binomial coefficient

C(n,k) denotes the number of A; -element subsets of an n-element set.

125.1.1 Example (7(4,0) = 1 (there is exactly one subset with no elements in a

set with 4 elements), (7(4,1) = 4 (there are four singleton subsets of a four-
element

set) and (7(4,2) =6 (count them).

We can deduce some immediate consequences of the definition:

191

125.2 Theorem
For all n> 0 and k> 0 ,

a) C(n, 0) = 1 .

b) C(n,n) = 1.

c) C(n,k) = C(n,n— k) .

d) C(n,k) = 0 ifk>n.

Proof

a) There is exactly one empty subset of any set, so C(n, 0) = 1 for any n.

b) An n-element set clearly has exactly one subset with n elements, namely

itself.

c) This follows from the fact that for a particular k there is a bijection between

k element subsets of an n-element set and their complements, which of course

are (n — k) -element subsets.

d) Obvious.

C(n,k ) is called a binomial coefficient because of the formula in the following

theorem. C(n,k) is also written

125.3 Theorem

For all real x and y and all nonnegative integers n and k,

(x + y) n = J2C(n,k)x n - k y k (125.1)

k = 0

I won’t give a formal proof, but just sketch the idea.


(x + y) n = (x + y)(x + y)---(x + y) (125.2)

where (x + y) occurs n times in the expression on the right. In the expanded


version

of {x + y) n , each term occurs by selecting an x or a y in each factor of the


right side

of Equation (125.2) and multiplying them together (try this on {x + y) (x + y) (x +

y) ). You get one occurrence of x n ~ k y k by choosing a subset of k factors (out


of the

n that occur) and using y from those factors and x from the n — k other factors.

There are C(n,k) ways to do this, so that Equation (125.1) follows.

125.4 Recurrence relation for C(n,k )

We can get a recurrence relation for C(n,k) which will allow us to calculate it.

Suppose, for a fixed k, we want to know C(n + 1 ,k) , the number of k -element

subsets of an n + 1 -element set A . Let a £ A . Then we can get each subset of A

that has a in it exactly once by adjoining a to a ( k — l)-element subset of A —


{a} ,

so there are C(n,k — 1) A; -element subsets of A that have a as an element. On the

other hand, every A’ -element subset of A that does not contain a as an element is

a A -element subset of A — {a}, so there are C(n,k) of them.

Every subset of A either has a as an element or not, so we have the following

theorem:

binomial coeffi-

cient 191

empty set 33

proof 4

recurrence 161
subset 43

theorem 2

192

basis step 152

recurrence rela-

tion 161

theorem 2

125.5 Theorem

For all n> 0 and k > 0 ,

(7(71,0) = 1

C(n,k ) = 0 if k > n (125.3)

C(n + l,k) = C(n,k — 1) + C(n,k) otherwise.

125.5.1 Example

(7(4,2) = (7(3,1) + (7(3, 2)

= (7(2,0) + (7(2,1) + (7(2,1) + (7(2, 2)

= 1 + 2 -(7(2,1) + (7(2,2)

= 1 + 2((7(1,0) + (7(1, 1)) + (7(1, 1) + (7(1,2)

= 1 + 2(1 + (7(0, 0) + (7(0, 1)) + (7(0, 0) + (7(0, 1)

= l + 2- 2 + l = 6
(125.4)

(125.5)

125.5.2 Example The recurrence relation for C(n,k) can be used to give an

inductive proof of Theorem 125.3.

The basis step is to prove that

(x + y)° = ^(7(O,£0*-y

k = 0

The sum on the right has only one term, namely (7(0, 0)x°y° , which is 1, as is the

expression on the left.

Inductive step: Assume

(x + y) n = Y,C(n,k)x n - k y k

k = 0

We must prove

n + 1

(* + y) n+1 = J2 C ( n + 1 ,k)x n+1 ~ k y k

k = 0

We now make a calculation. In this calculation it is convenient to define C(n, — 1)


193

to be 0.

(■ x + y) n+1 = ( x + y)(x + y) n

= (■ x + y ) E C(n,k)x n k y k by induction hypothesis

k= 0

n n

= x^C(n, k)x n ~ k y k + y^2 C(n , k)x n ~ k y k

k= 0 k= 0

n n

= ^ <?(«, k)x n+1 ~ k y k + C(n, k)x n ~ k y k+1

k= 0 k= 0

(now change k to k — 1 in the second term)

n n+l

= J2 C ( n ’ k)x n+1 ~ k y k + ^2 <?+ k - 1 ) x ”-( fc - 1 )y fc

fc=0 fc=l

n+l

= fe) + C(n,k — l])x n+l ~ k y k

k= 0

n+l
= y^C(n + l,fc)g w+1 ~ fc y fc by Theorem 125.5

fc=0

Note that I changed the limits on the sum in the next to last line of this proof,
using

the facts that C(n,n + 1) = 0 and C(n, — 1) = 0.

There is a sense in which this proof forces you to believe Theorem 125.3, but

the earlier proof (on page 191) explains why it is true. Mathematicians sometimes

call a proof like the earlier one a conceptual proof.

The following theorem gives an explicit formula for the binomial coefficient.

125.6 Theorem

For 0 <k <n,

77 1

c{n ’ k) = W^W. <125 ' 6)

The proof is omitted.

125.6.1 Worked Exercise Find the number of strings of length n in {a,b,c}*

that contain exactly two a’s.

Answer Now that we have the function C(n,r) we can solve this using the idea of

Worked Exercise 114.2.2. To construct such a string, we must choose two locations

in the string where the two a’s will be. There are C(n, 2) ways of doing this. Then

there are two choices (b or c) for each of the other locations, so the answer is

C(n,2) -2 n ^ 2 , which by Theorem 125.6 is

n ( n ~ 1) on- 2

2
conceptual proof 193

theorem 2

194

binomial coeffi-

cient 191

identity (predi-

cate) 19

recurrence rela-

tion 161

recurrence 161

string 93, 167

125.6.2 Proving identities for the binomial coefficient An enormous num-

ber of identities are known for the binomial coefficient. We consider one here to

illustrate how one goes about proving such identities. The identity is

^2C(n,k) 2 = C(2n,n) (125.7)

k = 0

This can be proved using the recurrence relation of Theorem 125.5, but the

proof is rather tedious. I quail with terror at the idea of using the formula in

Theorem 125.6 to prove this theorem.

It is much easier to use Definition 125.1. C(2n,n) is the number of ways of

choosing n balls from a set of 2 n balls. Now suppose that we have 2 n balls and

n of them are red and n of them are green. Then an alternative way of looking at
the task of choosing n balls from this set is that we must choose k red balls and

n — k green balls for some integer k such that 0 < k < n . For a particular k there

are C(n,k)C(n,n — k) ways of doing this. By Theorem 125.2(c), this is the same as

C{n,k) 2 . Altogether this alternative method of choosing a n -element subset gives

5 Z C (n,k ) 2

k = 0

possibilities.

125.6.3 Remark Like most concepts in mathematics, C{n,k ) has a conceptual

definition, namely Definition 125.1, and a method of calculating it, in this case
two

of them: Theorems 125.5 and 125.6. It is generally good advice to try the
conceptual

approach first.

In this case there is a second conceptual description, as coefficients in a polyno-

mial (Formula 125.1), and in fact that formula allows a faily easy second proof of

Formula (125.7).

125.6.4 Exercise Prove that Ylk= oC(n,k) = 2 n .

125.6.5 Exercise Prove that ^fe=o( — 7) k C(n,k) = 0 for n > 0.

125.6.6 Exercise Prove two ways that for all n > 4,

71 — 2

C(n,3) = — -C(n,2)

a) Prove it by using the definition of C(n,k).

b) Prove it using formula (125.6).


125.6.7 Exercise Prove Theorem 125.6. (It can be done by induction, but is a

bit complicated.)

125.6.8 Exercise Prove Formula (125.7) using Formula (125.1).

125.6.9 Exercise Let F(n,k ) be the number of strings of length n in {a,b,c}*

with exactly k b’ s. Find a formula or recurrence relation for F(n,k).

195

125.6.10 Exercise Derive a formula or recurrence relation for the number of

strings of length n in {a, b}* with the same number of a’s as b 's.

125.6.11 Exercise (hard) Find a recurrence relation for the number of partitions

of an n-element set that have exactly k blocks.

125.6.12 Exercise (hard) Prove formula (125.6).

126 . Composition of relations

126.1 Definition: composition of relations

Let a be a relation from A to B and (3 be a relation from B to C .

The composite a° (3 is a relation from A to C, defined this way: For

all a € A and c € C ,

a(a ° (3)c 36 £ B (o a b A b /3 c)

126.1.1 Example Let A = {1,2, 3, 4, 5}, B = {3,5, 7, 9} and C = { 1,2, 3,4, 5, 6},
with

a= | <1) 3), (1,5), (2,7), (3,5), (3,9), (5,7) j

and

P = {<3, 1), (3,2), (3,3), (7,4), (9,4), (9,5), (9,6)}

Then

ao/3= {(1,1), (1,2), (1,3), (2, 4), (3, 4), (3, 5), (3, 6), (5, 4)}

126.1.2 Usage As you can see, although functions are composed from right to

left, relations are composed from left to right. It is not hard to see that if F :
A — > B

and G : B — >■ C are functions, then

T(G°F) = r(F)°T(G)

126.1.3 Exercise Let A = {2,3, 4, 5}, B = {6, 7, 8, 9}, C = {a,b, c,d, e} , and a€

Rel(A,L>), p € Rel(R,C) be defined as follows. Give the ordered pairs in a°(3.

a) a is “divides”, /3 is |(6,a), (6,c), (7, 6), (9,d)| .

b) a is “divides”, (3 is |(7,a), (7,6), (7,c)| .

c) a ={(2,7), (2, 8), (3, 7), (3, 9), (4, 8), (4, 9)} and

P= |(6,a),(6,6),(7,c),(8,c),(9,c),(9,d),(9,e)}

(Answer on page 250.)

block 180

definition 4

divide 4

equivalent 40
function 56

ordered pair 49

partition 180

recurrence 161

relation 73

string 93, 167

theorem 2

usage 2

196

associative 70

composite (of rela-

tions) 195

composition pow-

ers 196

definition 4

functional relation

include 43

interpolative 196

proof 4

relation 73

transitive 80, 227

126.2 Theorem

Composition of relations is associative: if a G Rel(A,R), f3 G Rel(S,C),


and 7 G Rel(C, D) , then

(a ° (3) ° 7 = a ° ((3 ° 7 ) G Rel(A, D )

75 Proof Left as Problem 126.3.4.

126.3 Definition: composition powers

The composition powers of a relation a on a set A are o° = Aa (the

equals relation), a 1 = a, of = a° a, and in general a n = a 0 a” -1 .

126.3.1 Exercise For each relation R in Exercise 52.1.3, page 75, determine

whether 1R 2 3, 1R 3 3, and 3R 2 1. (Answer on page 250.)

126.3.2 Exercise Prove that if F:A—*B and G : B — >• C are functions, then

T(G°F) = T(F)°T(G).

126.3.3 Exercise Let A = {1,2, 3, 4}.

a) Construct a nonempty relation a on A for which a 2 is empty.

b) Construct a relation a f A x A on A for which a 2 = A x A.

126.3.4 Exercise Prove that composition of relations is associative.

126.3.5 Exercise Show that the composite of functional relations is a functional

relation.

126.3.6 Exercise Let a be a relation on a set A. Prove that a is transitive if

and only if a 0 a C a .

126.3.7 Exercise A relation a on a set A is interpolative if a C a°a. Show

that <, as a relation on R, is interpolative, but as a relation on Z, it is not

interpolative.
197

127. Closures

Given any relation a on S, and any property P that a relation can have there

may be a “smallest” relation with property P containing a as a subset. It may not

exist, but if it does, it is called the P-closure of a. Here is the formal


definition.

127.1 Definition: closure

A relation f3 on A is the P-closure of a if

C.l (3 has property P.

C.2 a.C/3.

C.3 If 7 has property P and a C 7 , then /? C 7 .

127.1.1 How to think of closures ft is the “smallest” (in the sense of inclusion)

relation with property P containing a as a subset.

127.1.2 Fact The reflexive, symmetric, and transitive closures of relations always

exist. We will look at each of these in turn. The antisymmetric closure of a


relation

need not exist (Problem 128.2.5).

127.2 Theorem

The reflexive closure of a relation a is a U A g . It is denoted by a R .

Proof To prove this formally you must show that it fits Definition 127.1; that is,
that

RC.l aUAs is reflexive,

RC.2 a C a U As, and

RC.3 if 7 is a reflexive relation and a C 7 , then aU As C 7 .

RC.l and RC.2 are obvious. As for RC.3, suppose that a C 7 and 7 is reflexive.

If i(aUAs)z then either x a z or x = z (that is, rAsz). In the first case ary z

because a C 7 , and in the second case, ary z because 7 is reflexive. Thus

x(aU Ag)y =$■ ary y

so a U As C 7 , as required.

127.2.1 Exercise What is the reflexive closure of the relation “<” on R?

(Answer on page 250.)

127.3 Theorem

The symmetric closure of a relation a is

a s = a U a op

127.3.1 Exercise What is the symmetric closure of “<” on R? (Answer on

page 250.)

127.3.2 Exercise What is the symmetric closure of “<” on R?

127.3.3 Exercise Give an example of a relation whose symmetric closure has

exactly three elements.

definition 4

fact 1
implication 35, 36

include 43

P-closure 197

proof 4

reflexive 77

relation 73

subset 43

symmetric 78, 232

theorem 2

union 47

198

family of sets 171

include 43

integer 3

intersection 47

ordered pair 49

positive integer 3

proof 4

relation 73

theorem 2

transitive 80, 227

union 47

127.3.4 Exercise Show that the symmetric closure of a relation a is a Ua op .

(Answer on page 250.)


The most important type of closure in practice is the transitive closure:

127.4 Theorem

Let a be a relation on a set S . The transitive closure a T of a is

U^ =1 a fc , where a k = a° a ° ...° a (k times), the composition power.

Proof Let f3 = U 7 £ =1 a k . Any member of a family of sets is enclosed in the


union

of the family, so a C (3 . This verifies C.2 of Definition 127.1. As for C.3,


suppose

7 is transitive and a C 7 . Then a k C 7 (Exercise 127.4.2), so (3 C 7 because any

ordered pair in (3 is in at least one of the sets a k .

Finally, we must show that (3 is transitive. Suppose x(3z and z(3y. Then for

some integers k and m, xa k z and za m y. Then it is easy to see that xa k+m y, so

x(3y as required.

127.4.1 Exercise What is the transitive closure of the relation a on Z defined

by xay if and only if y = x + 1 ?

127.4.2 Exercise Suppose 7 is transitive and a C 7 . Show that a k C 7 for all

positive integers k.

a U A g is the only reflexive closure of a . That is why we could use the notation

a R — it means only one thing. It is always true that if a relation has a P-


closure,

it has only one:

127.5 Theorem

Let P be a property of relations, and suppose (3 and (3 ' are P-closures


of a relation a on a set S . Then (3 = f3' .

Proof By C.2 of Definition 127.1, a C. (3 and a C (3' . Then by C.3, f3 C f3' and

f3' C (3 . Thus (3 = (3' .

128. Closures as intersections

The following set-theoretic description of P-closures is useful. It does not make

the P-closure easy to calculate, but it does give a conceptual description useful
for

proving properties of closures.

199

128.1 Definition: intersection-closed

A property P of relations on a set A is intersect ion- closed if:

IC.l A x A has property P.

IC.2 For any set S of relations on A, all of which have property P, the

intersection of all the relations in S also has property P.

128.1.1 Remark The set Ax A can be regarded as the intersection of the empty

family of relations on A. The reasoning is this: In the case of relations, each


relation

on A is a subset of Ax A, and by Section 112.4 the intersection of the empty family

of relations on A is Ax A. From this point of view, IC.l is unnecessary.

definition 4
empty set 33

family of sets 171

include 43

intersection-

closed 199

intersection 47

proof 4

relation 73

subset 43

theorem 2

128.2 Theorem

Let P be an intersection-closed, property of relations. Then for any rela-

tion a, the P-closure of a exists and is the intersection of the set of all

P-closed relations containing a as a subset.

Proof Let (3 be the intersection of all the P-closed relations containing a as a


sub-

set. We must verify C.l, C.2 and C.3. (3 has property P because P is intersection-

closed. a C (3 because a C Ax A and Ax A has property P, and [3 is the inter-

section of all the relations with property P that contain a as a subset. Finally,
the

intersection of a family of sets is included in any member of the family.

128.2.1 Exercise Prove that for any property P, if a has property P then the

P-closure of a is a itself.

128.2.2 Exercise Show that the following hold for any relation a:

a) a RS = a SR .

b) a R1 = a TR .
128.2.3 Exercise

a) Prove that for any relation a , a TS C a ST .

b) Give an example of a relation a for which a TS a ST .

128.2.4 Exercise Let P be the property of a relation [3 that either 1/32 or

2/31. On the set S = {1,2}, let a = {(1,1)}. Let /3 = {(1,1), (1,2)} and 7 =

{(1, 1), (2, 1)} . Then /3 and 7 both include a and both have property P. On the

other hand, a does not have property P. Does this contradict Theorem 127.5?

128.2.5 Exercise Show that a relation need not have an “antisymmetric closure” .

200

definition 4

equivalence rela-

tion 200

equivalence 40

equivalent 40

even 5

natural number 3

nearness relation 77

odd 5

partition 180

predicate 16

proposition 15

reflexive 77
relation 73

symmetric 78, 232

transitive 80, 227

union 47

129. Equivalence relations

If an object a is like an object b in some specified way, then b is like a in that

respect. And surely a is like itself — in every respect! Thus if you want to give

an abstract definition of a type of relation intended to capture the idea of being

alike in some respect, two of the properties you could require are reflexivity and

symmetry. Relations with those two properties are studied in the literature (the

nearness relation J\f in Section 55.1.4 is such a relation), but here we are going
to

require the additional property of transitivity, which roughly speaking forces the

objects to fall into discrete types, making a partition of the set of objects being

studied.

129.1 Definition: equivalence relation

An equivalence relation on a set S' is a reflexive, symmetric, transitive

relation on S .

129.1.1 Remark This is an abstract definition — you don’t have to have some

property or mode of similarity in mind to define an equivalence relation.

129.1.2 Example Let A = {1,2, 3, 4,5,6} . Here is an equivalence relation a on

the set A:

a = «n, n) \ n e A} U {(2, 5) , (5, 2) , (3, 4) , (4,3) , (3, 6) , (6, 3) , (4,


6) , (6, 4)} (129. 1)
129.1.3 Example The relation “equals” on any set is an equivalence relation.

129.1.4 Example The relation “has the same parity as” on the set N of natural

numbers is an equivalence relation. Two numbers have the same parity if they are

both even or both odd.

129.1.5 Example The relation of being in the same suit on a deck of cards is an

equivalence relation.

129.1.6 Example Both the congruence relation and the similarity relation on the

set of triangles are equivalence relations.

129.1.7 Example The relation called equivalence on the set of propositions or

the set of predicates is an equivalence relation. (This example requires that the
set

of propositions or predicates be precisely defined, which is done in formal


treatments

of logic but which has not been done in this text.)

129.2 Exercise set

In questions 129.2.1 through 129.2.9, let E be the relation defined in the question

on Z. Is L an equivalence relation? Explain your answer.

129.2.1 mEn ■&m<n (Answer on page 250.)

129.2.2 mEn 44 m 2 = n (Answer on page 250.)

201

129.2.3 mEw 44 m = n+ 1 V n = m + 1 (Answer on page 250.)


129.2.4 mEn 44 2 | m — n V 3 | m — n (Answer on page 250.)

129.2.5 mE?r 44 fn 2 = n 2

129.2.6 mEn 44 m \ n A n \ m

129.2.7 mEn 44 \m — ro| < 6.

129.2.8 mEn 44 12 | (m — n+ 1) .

129.2.9 mEn 44 (6 | (m — n) and 8 | (m — n)) .

129.3 Exercise set

In questions 129.3.1 through 129.3.6, let E be the relation defined in the question

on R. Is i? an equivalence relation?

congruent (mod

k) 201

definition 4

divide 4

equivalence rela-

tion 200

equivalent 40

floor 86

integer 3

modulus of congru-

ence 201

positive integer 3

relation 73

remainder 83
union 47

usage 2

129.3.1 rEs 44 r/s = 1 (Answer on page 250.)

129.3.2 rEs 44 floor(?’) = floor(s) . (Answer on page 250.)

129.3.3 rEs 44[r = sV(0<r<lA0<s<l)] (Answer on page 250.)

129.3.4 rEs 44 r + s = 1 .

129.3.5 rE.s 44 r — s G N.

129.3.6 rEs 44 r — s G Z

129.3.7 Exercise If E and F are equivalence relations on a set S, are EP\F

and EU F always equivalence relations?

130. Congruence

130.1 Definition: congruence (mod k )

Let k be a fixed positive integer. Two integers rn and n are congruent

(mod k), written “m = n (mod k ) ” , if k divides m — n, in other words,

if there is an integer q for which m — n = qk.

130.1.1 Example 9 = 3 (mod 6) , —5 = 16 (mod 7), 146 = —22 (mod 12).

130.1.2 Usage
a) In the phrase “m = n (mod k ) n , k is called the modulus of congruence.

b) The syntax for “mod” here is different from that of the operator “MOD” used

in Pascal and other languages. In Pascal, “MOD” is a binary operator like

“ + ”; when used between two variables, as in the phrase “M MOD K” , it causes

the calculation of the remainder when M is divided by K. Thus “5 MOD 3”,

for example, is an expression (not a statement) having value 2. The phrase

“5 = 2 (mod 3)”, on the other hand, is a sentence that is either true or false.

202

divide 4

equivalence rela-

tion 200

hypothesis 36

integer 3

mod 82, 204

positive integer 3

proof 4

quotient (of inte-

gers) 83

remainder 83

theorem 2

transitive 80, 227

130 . 1.3 Exercise List all the positive integers < 100 that are congruent to 3 mod
24. (Answer on page 250.)

130 . 1.4 Exercise List all the positive integers < 100 that are congruent to —3

mod 24.

130 . 1.5 Remark Recall that the remainder when m is divided by k is the unique

integer r with 0 < r < \k\ for which there is an integer q such that m = qk + r.
Then

we can prove:

130.2 Theorem

Two positive integers m and n are congruent mod k if and only if m

and n leave the same remainder when divided by k .

Proof If in = qk + r and n = q'k + r (same r ) , then m — n=(q — q')k, so k divides

m — n. Then by definition m = n (mod k ) .

Conversely, if m = n (mod k ) , let r be the remainder when m is divided by

k and r' the remainder when n is divided by k. Then there are quotients q and

q' for which m = qk + r and n = q'k + r 1 . Then r — r' = (m — qk) — (n — q'k) =

m — n+ ( q' — q)k. Since m — n is divisible by k , this means r — r' is divisible


by k .

Since r and r' are both between 0 and k (not including k ) , this means r = r' , as

required.

130.3 Theorem

Congruence ( modk ) is an equivalence relation.

Proof Here is the proof that it is transitive; the rest is left to you. Suppose
that

m = n (mod k) and n = p (mod k ) . Then m leaves the same remainder as n when

divided by k, and n leaves the same remainder as p when divided by k. Since

remainders are unique, m leaves the same remainder as p when divided by k, so,
by Theorem 130.2 m = p (mod k ) .

Congruence has an important special property connected with addition and multi-

plication that has given it extensive applications in computer science:

130.4 Theorem

If m = m' (modk) and n = n' (modk) then m + n = m' + n' (modk)

and mn = m!n! (mod k) .

Proof The hypothesis translates into the statement

k | m — in and k\n — n

Then (in + n) — (m' + n') = m — m' + n — n! is the sum of two numbers divisible

by k, so is divisible by k. Hence m + n = m' + n' (mod A;). Also mn — m'n l =

mn — mn' + mn' — m'n' = m(n — n') + n'(m — m') , again the sum of two numbers

divisible by k, so that mn = m'n' (mod k) .

203

130.4.1 Remark The consequence of Theorem 130.4 is that if you have an expres-

sion involving integers, addition and multiplication, you can freely substitute
inte-

gers congruent to the integers you replace and the expression will evaluate to an

integer that, although it may be different, will be congruent (mod k) to the


original

value.

130.4.2 Example As an example, what is 5 8 congruent to (mod 16)? The arith-


metic is much simplified if you reduce each time you multiply by 5 :

5=5 (mod 16)

5 2 = 25 = 9 (mod 16)

5 3 = 5-9 = 45 = 13 (mod 16) (130.1)

5 4 = 5-13 = 65 = 1 (mod 16)

5 8 = (5 4 ) 2 = l 2 = 1 (mod 16)

definition 4

divide 4

domain 56

equivalence rela-

tion 200

equivalent 40

fact 1

function 56

integer 3

kernel equiva-

lence 203

relation 73

remainder func-

tion 203

remainder 83

130.4.3 Remark This ability to compute powers fast is the basis of an important

technique in cryptography.

130.4.4 Exercise Compute:


a) 5 12 (mod 4)

b) 5 12 (mod 10)

c) 5 12 (mod 16)

(Answer on page 250.)

130.4.5 Exercise Prove that if s\t, then

ms = ns (mod t) 44 rri = n (mod t/s)

131. The kernel equivalence of a function

If F : A—> B is a function, it induces an equivalence relation K(F ) on its domain

A by identifying elements that go to the same thing in B . Formally:

131.1 Definition: kernel equivalence

If F : A — >■ B is a function, the kernel equivalence of P on A, denoted

K ( F ) , is defined by

aK(F)a! 44 F(a) = F(a')

131.1.1 Fact It is easy to see that the kernel equivalence of a function is an

equivalence relation.

131.1.2 Example The congruence relations described in the preceding section

are kernel equivalences. Let A: be a fixed integer > 2. The remainder function

F : Z — > Z is defined by F(n) = n (mod k) , the remainder when n is divided by k.

Theorem 130.2, reworded, says exactly that the relation of congruence (mod k ) is

the kernel equivalence of the remainder function.


204

block 180

definition 4

division 4

empty set 33

equivalence class 204

equivalence rela-

tion 200

fact 1

include 43

mod 82, 204

partition 180

proof 4

quotient set (of

an equivalence

relation) 204

remainder 83

subset 43

symmetric 78, 232

theorem 2

transitive 80, 227

131.1.3 Exercise Give an example of a function F: N — >• N with the property

that 3/1 (F)5 but ~‘(3K(F)6. (Answer on page 250.)


132. Equivalence relations and partitions

132.0.4 Discussion If an equivalence relation E is given on a set S , the elements

of S can be collected together into subsets, with two elements in the same subset

if they are related by E. This collection of subsets of S is a set denoted S/E ,


the

quotient set of S by E. Here is the formal definition of S/E:

132.1 Definition: quotient set of

an equivalence relation

Let E be an equivalence relation on a set S . For each x G S , the equiva-

lence class of x mod E, denoted [x]e, is the subset {y G S \ yEx} of

S. The quotient set (of an equivalence relation) S/E of E is the

set {[x\e | x £ S}.

132.1.1 Example The quotient set of the equivalence relation a defined in 129.1

above is {{1}, {2, 5}, {3, 4, 6}}, which is a partition.

132.1.2 Example The quotient set of congruence (mod 6) is the partition of Z

by remainders upon division by 6 . The quotient set is always a partition:

132.2 Theorem

If S is a set and E is an equivalence relation on S , then the quotient

set S/E is a partition of S .

Proof To see why S/E is a partition, we have to see why

a) every element of S is in an equivalence class in S/E,

b) no element of S is in two equivalence classes in S/E, and


c) S/E does not contain the empty set as an element.

(This just spells out the definition of partition.)

Part (a) is easy: if x G S then, by reflexivity, xEx , so [x\e-

Part (c) is similar: by definition of S/E, an element of S/E is an equivalence

class [x\e for some iGS; since x G [x\e , [x\e is not empty.

As for (b) , x G [x] e ; if also x G [y\E for some y G S , then we have to show
that

[v\e = [x\e- To do this, we have to show two things:

(i) [v\e Q [x\ E , and

(h) \x\eQ\v\e-

For (i), let z G [v]e- Then zEy by definition. Since x G \v\ei xEy. By symmetry

and transitivity, zEx, so z € [x\e ■ Hence [y]E C [x\e-

For (ii), let z G [x\e- Then zEx . Since x G [v]e, xEy. So by transitivity, zEy .

Hence z G \v\ei as required.

132.2.1 Fact The equivalence class [x\e is a block of the partition S/E.

205

132.2.2 Worked Exercise Let S = {1,2, 3,4,5} . Find S/E if

E = A5 U {(1,3), (3, 1), (3,4), (4,3), (1,4), (4, 1)}

Answer
{{1,3, 4}, {2}, {5}}

132.2.3 Exercise Let S = {1,2, 3, 4,5,6} . Find S/E if

E = As U {<1,3), (3, 1), <3, 4), <4, 3), <1 , 4) , <4, 1), <2, 5), <5, 2)}

132.2.4 Exercise Let S = {1,2, 3, 4, 5}. Find two different equivalence relations

E and E' with the property that the subset {1,2} is an element of both S/E and

S/E'. (Answer on page 250.)

132.2.5 Exercise Give an example of an equivalence relation E on the set R

with the property that

{x £ R | 0 < x < 1}

block 180

equivalence rela-

tion 200

equivalent 40

identifies 205

partition 180

proof 4

quotient set (of

an equivalence

relation) 204

reflexive 77

relation 73

symmetric 78, 232

theorem 2

transitive 80, 227

union 47
is one of the equivalence classes of E.

132.2.6 Exercise Let S = {1,2, 3, 4, 5}. Find two different equivalence relations

E and E' on S with the property that S/EnS/E' = {{1,5}, {3}}

132.2.7 How to think of equivalence relations If E is an equivalence relation

on S , the quotient set S/E is often thought of as obtained by merging equivalent

elements of S . One often says that one identifies equivalent elements. Here,
“iden-

tify” means “make identical” rather than “discover the identity of” .
Mathematicians

informally will say we glue equivalent elements together.

133. Partitions give equivalence relations

For a partition n of a set S , we will use the notation [x]n or just [x] if the
context

makes clear which partition is being used, to denote the (unique) block of n that

has x as an element. Given a partition n, you get an equivalence relation En by

the definition:

xE n y (x £ [y]n)

(133.1)

133.1 Theorem
If n is a partition of a set S , then the relation En defined by (133.1)

is an equivalence relation.

Proof To see that xEnx requires x £ [x], which is true by definition of [x] . Hence

En is reflexive. If xEn y then x £ [y] . That means [x] = \y\ , since by definition
of

partition an element is in only one block. Since y £ [y\ by definition and [x] = [y
\ ,

we know that y £ [x] , so yEnx . Hence En is symmetric. Note that we now know

that xEn y if and only if x and y are in the same block of n . To prove
transitivity,

206

antisymmetric 79

bijection 136

block 180

definition 4

domain 56

equivalence rela-

tion 200

function 56

include 43

inverse function 146

irreflexive 81

ordering 206

partition 180

quotient set (of a

function) 184

quotient set (of


an equivalence

relation) 204

reflexive 77

relation 73

strict ordering 206

subset 43

transitive 80, 227

weak ordering 206

suppose xEn y and yE-^z. Then x and y are in the same block, and y and z are

in the same block, so [x] = [y\ = [z ] . This means xEnz , so En is transitive.

133.2 The fundamental theorem on equivalence relations

We gave two constructions in the preceding sections. Given an equivalence relation

E , in Definition 132.1 we constructed a partition S/E, and given a partition II,


in

Section 133 we constructed an equivalence relation En .

If we let 7 tS denote the set of partitions of S (this is standard notation) and


E(S)

denote the set of equivalence relations on S (there is no standard notation for


this),

we now have functions E e-)- S/E : E(S) — > ttS and II >-)• En : nS — > E(S ) ,
where En

is defined in formula (133.1) above. The basic fact about these constructions is
that

these two functions are bijections and each is the inverse of the other. This fact
is

the “fundamental theorem on equivalence relations.”

In other words, if you have an equivalence relation E, construct the quotient

set S/E, which is a partition, and then construct the equivalence relation E s / e

corresponding to that partition, you get the equivalence relation E you started
with. And if you have a partition II of S , construct the corresponding equivalence

relation En, and then construct the quotient set S'/En of E, you get the partition

II back again. The proof of the fundamental theorem involves the same sort of

arguments given earlier, and is left as a problem.

133.2.1 Exercise Prove the fundamental theorem on equivalence relations.

133.2.2 Exercise Prove that any partition of a set A is the quotient of some

function with domain A.

134. Orderings

An ordering is a special sort of relation that is the mathematical formulation of

the concept of comparison or priority. It includes as special cases the relation “


< ”

between numbers and the relation of inclusion between subsets of a set. Here is the

formal definition:

134.1 Definition: ordering

A relation a on a set A is an ordering if it is antisymmetric and

transitive. If it is also reflexive, it is a weak ordering, and if it is also

irreflexive, it is a strict ordering.

134.1.1 Example The relation “<” on a set of numbers is a weak ordering, and

“<” is a strict ordering.

134.1.2 Example An example of an ordering a on a set S that is neither weak

nor strict is the relation

{(1,1), (1,2), (2,3), (1,3)}


on the set {1,2,3}. It is not reflexive because 2 is not related to itself, but it
is not

irreflexive because 1 is related to itself.

207

134.1.3 Remark Essentially all the orderings considered in this text are either

weak orderings or strict orderings, but the more general concept is occasionally

useful.

134.2 Definition: ordered set

If a is an ordering on A, then (A, a) is an ordered set. If a is a weak

ordering, (A, a) is a poset.

134.2.1 Example (R, <) and (R, >) are posets, and so is (' VA,C. ) for any set

A. The set of all relations on a set S is ordered by inclusion; it is the poset

(V(SxS),Q.

134.2.2 Usage In many texts, a weak ordering is called a partial ordering, and

“poset” is short for “partially ordered set” .

antisymmetric 79

definition 4

divide 4

include 43

integer 3
ordered set 207

partial ordering 207

poset 207

positive integer 3

powerset 46

reflexive 77

relation 73

theorem 2

transitive 80, 227

usage 2

134.2.3 Example Not only are “<” and “<” orderings on R, but so are “>”

and “>”.

134.2.4 Example The relation m \ n on N is a weak ordering; thus (N, |) is a

poset. Reflexivity is the obvious fact that n \ n for any n £ N, transitivity


requires

proving that if m\n and n \ p then rn \ p . and antisymmetry is the almost obvious

fact that if m\n and n \ rn then m = n.

I will prove antisymmetry and leave the others to you. By definition, m | n

means that n = hm for some positive integer h . Likewise n \ m means that m = kn

for some positive integer k . Thus m = kn = khm . If m / 0 you can cancel m and

get kh = 1 . Since k and h are positive integers, that means k = h = 1 . Hence

m = n. As for the case m = 0, the fact that n = hm means n = 0, so m = n again.

134.2.5 Example If you have a collection T of tasks, there is a natural ordering

of T defined this way: t a u if task t must be done before task u can be started.

This is obviously transitive. If a were not antisymmetric, that would say there are
two different tasks t and u, each of which had to be done before the other, so that
it

is in fact impossible to perform the set of tasks. Thus for any reasonable
collection

f of tasks, (T, a) is antisymmetric as well as transitive and therefore an


ordering.

134.3 Theorem

Let a be an ordering. Then a op (see Section 54-2, page 11) is also an

ordering. Moreover, a op is strict if a is strict and weak if a is weak.

134.3.1 How to think of orderings If a is an ordering on a set S and a a b,

one says that “a is smaller than 6” . This phraseology has to be used with caution

one would not use it, for example, for the relation “>” on R. More subtle problems

with this terminology arise with other orderings. For example, in the poset (N, |),

3 is smaller than 6 but 3 is not smaller than 5 . Nor, for that matter, is 5
smaller

than 3. You have to be very clear that “smaller” here is not the usual relation “<”

on N.

208

definition 4

divide 4

include 43

linear ordering 208

powerset 46
reflexive 77

relation 73

strict total order-

ing 208

theorem 2

total ordering 208

transitive 80, 227

trichotomy 208

usage 2

The following Theorem, whose proof is left to you, shows that a relationship analo-

gous to that between “<” and “<” holds for all orderings.

134.4 Theorem

For any ordering a on a set S , a — As is a strict ordering of S and

the reflexive closure a R is a weak ordering.

135. Total orderings

135.1 Definition: total ordering

An ordering a on a set A with the property that for any pair of elements

a, b E A , either a a b or b a a , is a total ordering.

135.1.1 Usage A total ordering is also called a linear ordering.

135.1.2 Example The relations “<” and “>” are total orderings on R, as well

as other sets of numbers.


135.1.3 Example The ordered set (N, |) is not totally ordered: as we observed

previously, 3 and 5 are not related to (do not divide) each other.

135.1.4 Example If A has more than one element, then (VA, C) is not a totally

ordered set.

135.2 Theorem

A total ordering is reflexive, in other words is a weak ordering.

135.2.1 Exercise Prove Theorem 135.2.

135.2.2 Usage In most writing in pure mathematics, a total ordering is a type of

strict ordering, defined axiomatically in Definition 135.3 below. We call it


“strict

total ordering” here.

135.3 Definition: strict total ordering

A relation cc on a set S' is a strict total ordering if it is transitive

and satisfies trichotomy: For all a, 6 £ S , exactly one of the following

statements hold:

(i) a a b

(ii) baa

(iii) a = b.

135.3.1 Remark This definition has the consequence that a strict total ordering

is not a total ordering in the sense of Definition 135.1. However, it is


straightforward

to prove that if a is a strict total ordering then a R is a total ordering in the


sense

of Definition 135.1.
209

The relation “divides” on Z is not an ordering because it is not antisymmetric.

For example, 6 | — 6 and — 6 | 6 but 67 ^— 6 . “Divides” is, however, reflexive and

transitive on Z .

135.3.2 Exercise Let a be a relation on a set A. Prove that if a is a strict total

ordering in the sense of Definition 135.3, then a is a strict ordering. (Answer on

page 250.)

135.3.3 Exercise Let ct be a relation on a set A.

a) Assume that a is a strict total ordering in the sense of Definition 135.3. Prove

that a R is a total ordering in the sense of Definition 135.1.

b) Prove that if a is a total ordering then a — A a is a strict total ordering.

135.3.4 Exercise How many total orderings of an n -element set are there? Prove

your answer correct.

135.3.5 Exercise For any natural number n, let D(n ) denote the set of positive

divisors of N. Thus D( 6 ) = {1,2, 3, 6 }. Show that (D(n),\) is totally ordered if

and only if n is a power of a prime.

136. Preorders

136.1 Definition: preordering


A reflexive, transitive relation a on a set A is called a preorder or

preordering on A, and (A, a) is a preordered set.

antisymmetric 79

definition 4

divide 4

divisor 5

equivalence rela-

tion 200

equivalent 40

function 56

natural number 3

positive integer 3

preordered set 209

preordering 209

preorder 209

prime 10

quotient set (of a

function) 184

reflexive closure 197

reflexive 77

relation 73

strict ordering 206

strict total order-

ing 208

total ordering 208

transitive 80, 227

usage 2
136.1.1 Usage Sometimes “quasi-ordering” is used for “preordering”, but that

word is used with other meanings, too.

136.1.2 Remark Every preorder can be converted into a partial order by a pro-

cess resembling the construction of the quotient of a function. This process is

explored in exercises below.

136.1.3 Exercise (hard) Let a be a preorder on a set S .

a) Prove that the relation E defined by

xEy 44 {xay A yax)

is an equivalence relation.

b) Define a relation A on S/E by

[x]A[y] 44 xay

Prove that A is well-defined, that is, that if [x\ = [V] , [y] = \y'], and [x]A[y],

then [x']A[y'].

c) Prove that A is an ordering

210

divide 4

division 4

divisor 5
Hasse diagram 210

include 43

ordering 206

poset 207

positive integer 3

relation 73

subset 43

total ordering 208

transitive 80, 227

weak ordering 206

137. Hasse diagrams

Exhibiting an ordering using a digraph as in Section 51.2 tends to be messy-


looking

because transitivity causes lots of arrows to exist. Orderings are normally


illustrated

using a different sort of picture called a Hasse diagram. The elements of the set

are represented as dots, as before, and the diagram is drawn so that when there is

a rising line from a to b, then a a b. (“Rising” means toward the top of the page.)

The rising line from a to b does not have to go directly from a to b, but may pass

through other nodes; this makes use of the fact that the relation is transitive.
Note

that the diagram does not show whether a node is related to itself. In this text,

Hasse diagrams are used only for weak orderings.

(137.1)

137.1.1 Example The two Hasse diagrams in Figure 137.1 show the inclusion
relation on the set of subsets of {1,2,3} and the relation of division on the set

{1,2, 3, 4, 5, 6}.

137.1.2 Remark Note that b can be higher on the page than a without it being

true that a a b — there must be a rising line from a to b to make a a b. For

example, in the right diagram, 5 is not less than 6.

137.1.3 Exercise Draw the Hasse diagram of the indicated poset (A, a):

a) A = {1,2, 3, 4, 5} ,

a = {(1,1), <2, 2), <3, 3), <4, 4), <5, 5), (1,2), (2, 3), (1,3), (5, 4), (4, 3),
(5, 3)}

b) A = {0,{1},{2},{1,2},{2,3}}, a is inclusion.

c) A =set of positive divisors of 20, a is divisibility.

d) A =set of positive divisors of 25, a is divisibility.

(Answer on page 250.)

137.1.4 Exercise Which of the posets in Exercise 137.1.3 are total orderings?

(Answer on page 251.)

137.1.5 Exercise Draw the Hasse diagram for the relation “divides” on:

1. The set of positive divisors of 12.

2. The set {n G N | 1 < n < 12} .

211

138. Lexical ordering


A finite totally ordered set A used as an alphabet induces a total order on the

strings in A* called the lexical order on A* . When A is the English alphabet,

the result is the familiar alphabetical ordering of strings.

To define lexical ordering, we need a preliminary idea.

138.1 Definition: initial segment

A string u is an initial segment of a string w if w = ux for some string

x in A* .

alphabet 93, 167

definition 4

finite 173

infinite 174

initial segment 211

lexical ordering 211

lexical order 211

string 93, 167

total ordering 208

138.1.1 Example ‘ ab’ is an initial segment of ‘abbac’.

138.1.2 Example Any string is an initial segment of itself (since A £ A*) .

138.1.3 Example A is an initial segment of any string.

138.2 Definition: lexical order


Let (A, a) be a finite totally ordered set. Then the lexical order or

lexical ordering A on A* is defined as follows: wXx if either

LE.l w is an initial segment of x, or

LE.2 If i is the first position where w and x differ, then Wi a x* .

138.2.1 Example If A is the English alphabet with the usual ordering, ‘car’

comes before ‘card’ in alphabetical ordering because ‘car’ is an initial segment of

‘card’, and ‘car’ comes before ‘cat’ because the first place where ‘car’ and ‘cat’
differ

is the third place, and ‘r’ comes before ‘t’.

138.2.2 Example If A is nonempty, A* is an infinite set. Consider the lexical

ordering on {0,1}*, where {0,1} is ordered so that 0 comes first. The first few

elements of {0,1}* are A, ‘O’, ‘00’, ‘000’, ‘0000’, ‘00000’, ... Thus if you go
through

the strings in order, there are strings such as ‘1’ that you can’t get to in a
finite

amount of time: there are an infinite number of strings in {0,1}* before ‘1’.

138.2.3 Exercise Prove that the lexical ordering on {0, 1}* (with 0 < 1 ) is a
total

ordering.

212

alphabet 93, 167

base 94

canonical order-

ing 212

definition 4
fact 1

finite 173

include 43

integer 3

lexical ordering 211

string 93, 167

total ordering 208

upper bound 212

139. Canonical ordering

The canonical ordering, defined below, is often used on infinite sets of strings to

remedy the problem described in Example 138.2.2. It is the most commonly used

ordering on {0,1}*.

139.1 Definition: canonical ordering

The canonical ordering on {0,1}*, usually denoted “<”, is defined

this way: w < x if

a) w is shorter than x (|w| < |x|) or

b) |ir| = | a: | and the integer represented by w in binary notation

is less than or equal to the integer represented by x in binary

notation.

139.1.1 Example 1110 comes before 00001 because it is shorter, and 0011 comes

before 0101 because 0011 is 3 in binary and 0101 is 5.


139.1.2 Example In the canonical ordering of {0,1}*, the first few strings are

A, 0, 00, 01, 10, 11, 000, 001, 010, 011, 100, ...

139.1.3 Fact The canonical ordering is linear and, unlike the lexical ordering,

there are only a finite number of strings between any two strings.

139.1.4 Remark This idea can obviously be extended to strings in the alphabet

{0, 1, . . . ,n} where n is a small integer (use base n + 1).

139.1.5 Exercise List the elements of the set

A = {00,01,110, 111,0101,0111,10101,10111,01111}

in the lexical ordering and in the canonical ordering. (Answer on page 251.)

139.1.6 Exercise Prove that the canonical ordering on {0, 1}* is a total ordering,

and that there are only a finite number of strings between any two given strings.

140. Upper and lower bounds

140.1 Definition: upper bound

If (A, a) is a poset and RCA, an element a € A is an upper bound

of B in (A, a) if baa for every 6 g5.

140.1.1 Remark Note that the upper bound a of Definition 140.1 need not be

in B.

140.1.2 Example In the right poset in Figure 137.1, 6 is an upper bound (in fact

the only one) of {1,2,3} and the set {1,2, 3, 4} has no upper bound.
213

140.1.3 Example {1,2, 3, 4} has many upper bounds in the poset (N, |) , for

example 12, 24 and 144.

140.1.4 Remark A lower bound of a subset is defined in the analogous way: a

is a lower bound of B if a a b for all 6 G B .

140.2 Definition: maximum

Let A be a poset and B a subset of A. The maximum of B (plural

“maxima” ) is an element rn of B with the property that for all b G B ,

6am.

140.2.1 Fact The maximum of B, if it exists, is clearly an upper bound of B;

unlike an upper bound, however, it must actually be in B. More is true:

140.3 Theorem

The maximum of a subset B of a poset A, if it exists, is unique.

definition 4

divide 4

fact 1

include 43

least upper

bound 213

lower bound 213


maximum 213

minimum 213

proof 4

rule of inference 24

subset 43

supremum 213

theorem 2

upper bound 212

Proof If m and m! were both maxima of B, then both would be elements of B

and so it would have to be the case that m a m' and m f a m . Then antisymmetry

forces m. = m'.

140.3.1 Remark The minimum of B is an element n of B with nab for all

6 E B . A similar proof shows that a subset B has at most one minimum. Note that

the minimum of B in A is the minimum of B in the opposite poset of A.

140.3.2 Exercise Find all the maxima and minima of the posets in Exer-

cise 137.1.3 of Chapter 134. (Answer on page 251.)

140.3.3 Exercise What are the maxima and minima, if any, of (N, | ) ? Of (N —

{0}, |) ? Of (N — {0,1},|)7 (Answer on page 251.)

141. Suprema

The two ideas of upper bound and minimum combine to form a concept that is more

important than either of them.

141.1 Definition: supremum


Let A be a poset with subset B . An element rn E A is a supremum

of B, or least upper bound of B, if it is the minimum of the set of

upper bounds of B .

141.1.1 Fact The supremum m must be unique if it exists, and it may or may

not be in B. Because of its uniqueness, we denote the supremum of B as supB.

141.1.2 Reformulation of the definition It is worth spelling out the definition

of supremum: If B C A and m £ A , then m . is the supremum of B if m is an upper

bound of B and m a a for every other upper bound a of B. This gives rise to a

rule of inference.

214

definition 4

divide 4

division 4

fact 1

implication 35, 36

infhnum 214

interval 31

join 214

meet 214

ordering 206

positive integer 3

powerset 46
prime 10

rule of inference 24

subset 43

supremum 213

theorem 2

141.2 Theorem

If (A, a) is a poset and B C A, then

(Vb:B)(b am), (\/a:A) ((\/b:B)(b a a) =>■ m a a) (- m = sup.B

141.2.1 Fact Note that m is the “least” upper bound in the sense of the ordering

a: if a is an upper bound of B , then m a a. Specifically, no upper bound can be

unrelated to m.

141.2.2 Example The supremum of {{1},{1,2},{3}} in the set of all subsets of

{1,2,3} is {1,2,3} itself (See Figure 137.1).

141.2.3 Example The supremum in (R, <) of the open interval (0 . . 1) is 1 , which

is also the supremum of the closed interval [0 . . 1] .

141.2.4 Example The set

S' = {xGQ|0<x and x 2 < 2} = {x € Q | 0 < x < y/2}

has no supremum in (Q, <) . That is because if it had a supremum m G Q , m would

have to be its supremum in R, too, but the supremum in R is \/2, which is not

in Q.

141.3 Definition: infimum


The infimum of B, or infR, if it exists, is the unique element n for

which

a) nab for all b £ B , and

b) if a a 6 for all b e B , then a an.

141.3.1 Example In the set {1,2, 3, 4, 5, 6} ordered by division, the supremum of

the subset {2,5} does not exist, and the infimum is 1.

141.3.2 Exercise Find the suprema and infima, if they exist, of the subset S of

the poset [T, a) :

a) S = {3,4,5} , T = N, a is “<”.

b) S = {3,4,5}, T = N, a is “divides”.

c) S is the set of all positive primes, T = N, and a is “<”.

d) S is the set of all positive primes, T = N, a is “divides”.

e) S = {{1,2}, {2, 3}}, T = V{ 1,2,3}, a is inclusion.

(Answer on page 251.)

141.3.3 Least upper bounds of two elements There is a special notation for

suprema and infima of subsets of two elements. If (A, a) is a poset and a,b € A,

then the supremum of {a,b} is denoted a V b and called the join of a and b, and

the infimum is denoted a/\b and called the meet of a and b. Using this notation,

Rule (141.2) then gives this rule of inference:

aac, b a c, ((Vd)(a a d and bad) =>■ c a d) |— c = a V 6


There is a similar rule for a A b .

215

141.3.4 Exercise (hard) Let ( T,a ) be a poset, and suppose A C S CT .

a) Show that if m is the supremum of A in S' and n is the supremum of A in

T , then n <m.

b) Show that if n is the supremum of A in T and n £ S, then n is the supremum

of A in S.

c) Give an example where the situation in (a) holds and m^n.

141.3.5 Exercise (hard) Show that if a and ft are real numbers and

J = {t£Q\a<t<b}

then the supremum of J in Q, if it exists, is 6, so that b is rational. (Hint: Let


n

be the supremum of J in Q. Use Problem 141.3.4 to show that ft < n. Now assume

b < n and use the Archimedean property to get an integer k for which 1 /(n — b ) <
k ,

so that b < n — (l/k) <n and n — (l/k) is rational.)

142. Lattices

142.1 Definition: lattice

A poset (A, a) with the property that for any two elements a and b,

a/\b and a Vft always exist, is called a lattice. If a Aft always exists, but
not necessarily aVft, then (A, a) is called a lower semilattice, and if

oVft always exists but not necessarily a Aft, it is an upper semilattice.

Archimedean prop-

erty 115

definition 4

include 43

integer 3

join 214

lattice 215

lower semilattice 215

max 70

meet 214

minimum 213

min 70

powerset 46

rational 11

real number 12

subset 43

supremum 213

total ordering 208

union 47

unit interval 29

upper semilattice 215

weak ordering 206

142.1.1 Remark Some texts require that a lattice have a minimum and a mini-

mum, as well.
142.1.2 Example The following are Hasse diagrams of lattices. Note that, for

example, in (d) , xA z = b, xV z = t, and x V y = x .

(142.1)

142.1.3 Example In the unit interval I = {r£R|0<r'<l}, the meet r As and

the join r Vs with respect to the usual weak ordering < always exist, and in fact

rAs = min(r, s) and r V s = max(r, s) . Thus (I,<) is a lattice. More generally,


any

total ordering is a lattice (Exercise 142.1.11).

142.1.4 Example Let A be a set and B and C subsets of A. Then in (VA, C),

B A C and BV C always exist and moreover B AC = B nC and B V C = B U C .

Thus (VA, C) is a lattice. (See Exercise 142.1.7.)

216

divide 4

divisor 5

finite 173

GCD 88

include 43

infimum 214
integer 3

lattice 215

lower semilattice 215

minimum 213

natural number 3

positive integer 3

powerset 46

proof 4

relation 73

subset 43

supremum 213

theorem 2

upper semilattice 215

142.1.5 Example Let m and n be natural numbers. Then in (N, |) , m An and

mV n always exist, and moreover m An = GCD(m,ro) and mVn = LCM(m,n).

Thus (N, | ) is a lattice. This follows immediately from Corollary 64.2, page 90.

142.1.6 Exercise Which of these posets are lattices?

a) (N, <) .

b) (Z,<).

c) (R, <)•
d) ( A , |) , where A is the set of positive divisors of 25.

e) ( A , |) , where A is the set of positive divisors of 30.

f) (A, I) , where A = {1,2, 3, 4, 5, 6}.

(Answer on page 251.)

142.1.7 Exercise Prove that for any set A, (PA,C) is a lattice. (Answer on

page 251.)

142.1.8 Exercise Give an example of a lattice in which for some elements a, b

and c, a A (bV c) ^ (a Ab) V (a A c) .

142.1.9 Exercise Show that in the lattice (N — {0}, |) , every subset has an infi-

mum and every finite subset has a supremum, but not every subset has a supremum.

142.1.10 Exercise Let n be a positive integer. Show that the set of positive

divisors of n with “divides” as the relation is a lattice.

142.1.11 Exercise Prove that if ( L,a ) is a lattice, then a is a total ordering if

and only if x V y is the minimum of x and y and x A y is the minimum of x and y .

143. Algebraic properties of lattices

The following theorem gives algebraic properties of meet and join.

143.1 Theorem

If (A, a) is an upper semilattice, then for all a,b,c€ A,

a) aVa = a (idempotence).
b) aVb = bVa (commutativity).

c) aV (bV c) = (aV b)V c (associativity).

Similarly, if (A, a) is a lower semilattice, then for all a, b, c € A ,

a) a Aa = a.

b) aAb=bAa

c) a A (b A c) = (a A b) A c.

Proof We will prove the associativity of A and leave the rest as an exercise. This

proof involves applying the definition of infimum repeatedly to prove that each
side

of the equation is the infimum of the set {a,b,c}, and using the uniqueness of the

infimum. I will show that a A (6 Ac) =inf{a,6, c} and leave the other side to you.

The definition of infimum tells us that all the following are true:

217

( 1 ) b Acab

(2) bAcac

(3) a A (b Ac) a a

( 4 ) aA(bAc)abAc.

Putting (1), (2) and (4) together and using transitivity gives that

(5) aA(bAc)ab
( 6 ) a A(b Ac) ac

(3), (5) and (6) tells us that

( 7 ) a A (b Ac) a inf{a, b , c} .

On the other hand, by definition

(8) inf{a,6,c} a 6

(9) inf {a,b,c}ac

so

( 10 ) inf{a,6,c} a bAc.

Also

( 11 ) inf- {a, b, c} a a

so by (10) and (11),

( 12 ) inf {a, b,c} a a A (b Ac) .

Now (7), (12) and antisymmetry give us the desired result.

143.1.1 Exercise Complete the proof of Theorem 143.1.

143.1.2 Exercise Prove that in a lattice, xay^Ax = xAy^Ay = x\/y.

143.2 The Axiomatic Method

The proof that A and V are associative is rather long, although conceptually not

difficult. The value is that having done it once, we know it is true for every
situation

in which A and V occur.

143.2.1 Example We now know immediately, by examples 142.1.3 through

142.1.5, that max and min, intersection, union, and GCD and LCM are all

idempotent, commutative and associative. It is not hard to prove these directly


(although the proof for GCD and LCM is not trivial), but once we know Theo-

rem 143.1 and the corresponding fact for sups, the associativity doesn’t need
proof.

143.2.2 The idea is that we have extracted salient properties of union,


intersection,

GCD and LCM and made them into axioms', then any theorem derived from those

axioms is true in all the cases all at once. This is an example of the axiomatic

method in mathematics. The axiomatic method is largely responsible for the power

of modern mathematics.

associative 70

axiomatic

method 217

commutative 71

equivalent 40

GCD 88

idempotent 143

intersection 47

max 70

min 70

transitive 80, 227

218

arrow 218

definition 4

digraph 74, 218

directed graph 218


finite 173

function 56

graph 230

infinite 174

node 218, 230

source 218

target 218

144. Directed graphs

144.1 About graphs in general

A graph is a mathematical construction that is used to encode information about

connections between things. There are two main types of graphs, the kind called

“undirected graph” in which only the connection between two things matters, and

the kind called “directed graph” or “digraph” in which the direction of the connec-

tion matters. Each of these main types occurs in numerous subvarieties, only some

of which are commonly used in computer science.

The terminology for different kinds of graphs in the literature is notoriously

varied; it is probably true that if two graph theory books by different authors use

the same terminology, one of the authors was the graduate student of the other one.

The terminology in this text is similar to the usage in many (but not all) computer

science books, but is quite different from that in books written by


combinatorialists

or graph theorists.

In this book, “graph” means undirected graph and “digraph” means directed

graph. All graphs here are finite; although the definitions work for infinite
graphs,

many of the theorems are not true as stated for the infinite case.
144.1.1 Digraphs Informally, a digraph is a bunch of dots called nodes with

arrows going from some nodes to others. Here are two examples.

Here is a more precise definition:

x < ^ y

I b

(144.1)

144.2 Definition: directed graph

A directed graph or digraph G consists of two finite sets Go and G\

and two functions source :Gi — > Go and target \G\ — > Go-

The elements of Go are called the nodes or vertices (singular: vertex)

of G and the elements of Gi are the arrows or directed edges of G.

If an arrow a has source x and target y we write a:x — »• y in the same

way we write functions.


144.2.1 Drawing digraphs A digraph (Go,Gi,s,i) is conventionally drawn

using dots or labels for the nodes, and an (actual) arrow going from node x to node

y for each arrow a (element of Gi) with source x and target y.

144.2.2 Exercise Draw the following digraphs:

a) The graph with nodes {A,B,C, D} and exactly one arrow from each node

to A.

b) G = (Go,Gi,s,t) where Go = {1,2,3}, Gi = {a,b,c, d,e}, s(a) = s(e) = l,

s(b) = s(c ) = s(d) = 2 , t(a) = 2 , t(b) = t(c) = 1 , and t(d) = t(e) = 3 .

219

(Answer on page 251.)

144.2.3 Exercise Draw the graph Go = {2,3,4,5,6,7,8,9,10}, with n arrows

going from r to s if and only if r n \ s and r n+1 does not divide s.

144.3 Definition: abstract description

The information about a digraph given by the definition, that is the

sets Go, Gi and the source and target functions, is called the abstract

description of the digraph.

144.3.1 Remark We will frequently encode the abstract description for a digraph

as an ordered quadruple: thus “G is the digraph (Go,Gi,s,f)” means Go is the set

of nodes, Gi the set of arrows, and s and t are the source and target functions.

144.3.2 Example The abstract description of the digraph on the left of Fig-

ure (144.1) has Go = {x,y,z,w} , G\ = {a,b,c,d,e,u} ,


source(a) = source (6) = source (ci) = target (c) = x

target (a) = target (6) = target (e) = source (it) = target (it) = y

and source(c) = source(e) = z.

144.4 Graphs and abstraction

A digraph is defined here in an abstract way, not as a picture. The interplay


between

the abstract definitions and the pictures is analogous to that between the formula

of a function such as f(x) = x 2 + 1 and its graph (a parabola) in analytic


geometry.

The pictures are more suggestive and comprehensible than the abstract definition,

but it is difficult to prove things using pictures because it is hard to be sure


you

have the most general case. It may also be difficult or wasteful (or both) to store

pictures directly in the computer. The abstract treatment is both more rigorous

and more amenable to computation.

144.5 Digraphs in applications

144.5.1 Example Digraphs provide a natural way to encode data about certain

kinds of complex systems. The flow chart of a program, for example, is a digraph.

The commutative diagrams of sets and functions in Chapter 98 are examples of

labeled digraphs. However, the information concerning the composites of the func-

tions is additional information not encoded by the description of the diagrams as a

digraph.

144.5.2 Example Digraphs are the natural way to model the sequencing of a

collection of tasks that must be performed to accomplish a goal. Each node is a

task and there is an arrow from task a to task b if task a must be completed before

task b can be started. For example, the task of computing log(x 2 + y 3 ) can be
arrow 218

commutative dia-

gram 144

composite (of func-

tions) 140

definition 4

digraph 74, 218

divide 4

function 56

graph 230

labeling 221

node 218, 230

source 218

target 218

220

arrow 218

definition 4

digraph 74, 218

function 56

graph 230

indegree 220

loop 220

node 218, 230

opposite 62, 77, 220

outdegree 220
source 218

modeled this way:

start

calculate x 2

add calculate log

calculate y 3

(144.2)

This graph shows, for example, that if you had two people or two processors to

perform the squaring you could speed up the computation. Digraphs arising in this

way often have a weight function on the arrows.

144.5.3 Exercise Draw the digraph modeling the computation of the truth value

of the equation

2 , 2 2

x + xy = x — y
145. Miscellaneous topics about digraphs

145.1 Definition: loop

An arrow a from a node to itself, in other words a : x — > x for some node

x, is called a loop.

145.1.1 Example u is a loop in the left digraph in Figure (144.1).

145.2 Definition: indegree and outdegree

The number of arrows that have a node as source is called the outdegree

of the node, and the number of arrows that have the node as target is

the indegree.

145.2.1 Example The node y in the left graph of Figure (144.1) has indegree 4

and outdegree 1 .

145.3 Definition: opposite of a graph

The opposite of a digraph G is the digraph with the same nodes and

all the arrows reversed. It is called G op . Thus if G = (Go,Gi,s,t ) , then

G°v = {G 0 ,G 1 ,t,s).

221
145.3.1 Example

The digraphs below are opposites of each other.

A »- B

C D

A* B

C D

145.4 Labeling

A labeling of the nodes of a digraph G is a function L : Gq — >■ S , where S is a


set.

If x is a node, its label is L(x ) . Similarly a function L : G\ — )■ S would label


the

arrows. As an example, the digraph below shows the cost of traveling by rail in a

(mythical) mountainous country between three cities A, B, and C . (The fare for

going to a higher elevation is more than for going to a lower one.)

arrow 218

definition 4
digraph 74, 218

function 56

injective 134

integer 3

labeling 221

node 218, 230

real number 12

weight function 221

(145.1)

The nodes are labeled by {A, B,C} and the arrows are labeled by integers repre-

senting cost. Here the labeling is a function F : G\ — >■ Z. A function labeling


arrows

by integers or real numbers is commonly called a weight function on the arrows.

You can see that the labeling of the nodes is injective but the labeling of the
arrows

is not. When the labeling of the nodes is injective, there is usually no harm in
tak-

ing the attitude that the labels are actually the nodes; a similar remark applies
to

an injective labeling of the arrows.

146. Simple digraphs

146.1 Definition: simple digraph


A digraph is simple if for two distinct arrows a and b, either source(a) ^

source(fe) or target (a) ^ target (6) . In other words, only one arrow can

go from a node to another node. (However, one arrow is allowed each

way.)

146.1.1 Example The left graph in Figure (144.1), page 218, is not a simple

digraph, whereas the right one is.

146.1.2 Exercise What is the largest number of arrows a simple digraph with n

nodes can have?

999

arrow 218

Cartesian product 52

coordinate func-

tion 63

coordinate 49

definition 4

digraph 74, 218

fact 1

include 43

node 218, 230

relational descrip-

tion 222

simple digraph 221

source 218

subset 43
target 218

146.1.3 Variation in terminology In many books the word “digraph” is used

only for simple digraphs; those that allow more than one arrow from a node to a

node are called “multigraphs” or “multidigraphs” .

A simple digraph can be given a much simpler (!) abstract description (of a graph).

Since there can be at most one arrow from a node to another one, all you have to do

to describe the digraph is to give the set Go of nodes and the subset A of Go x Go

of ordered pairs of those nodes that have an arrow going from the first node to the

second one. This is summed up in the following definition.

146.2 Definition: relational description

The relational description of a simple digraph G is (Go, A), where

A C Go x Go is the set of ordered pairs

{(m,n) | There is an arrow from rn to n}

146.2.1 Remark We saw this correspondence between simple digraphs and rela-

tions from the opposite point of view in 51.2.

146.2.2 Example In the case of the right graph in Figure (144.1), which is simple,

G 0 is {x,y,z} and A is {(x,y), (y,x), (x, z)j .

146.2.3 Exercise Which of the digraphs in Exercise 144.2.2 are simple? Give the

relational description of each one that is. (Answer on page 251.)

146.2.4 Exercise Give the relational description of the graph (147.1), page 223.

146.2.5 Fact The relational description can be converted to the original definition
of digraph by calling a pair (x,y) in A an arrow from x to y; thus the source is

the first coordinate and the target is the second.

To sum up:

(i) If (Go,Gi,s,t) is the abstract description (of a graph) of a simple digraph,

you get the relational description (G, A) of the same graph by taking G = Go

and

A = {(x,y) G G 0 x G 0 | (3s)(s :x -» y) in Gi}

(ii) If ( G,A ) is the relational description of a simple digraph, the abstract


descrip-

tion (of a graph) of the same graph is defined to be (Go,Gi,s,f), where

Gq = G , Gi = A , s = pi (the first coordinate function) and t = p 2 ■

223

147. Isomorphisms

The two digraphs below are abstractly identical in a sense that can be made
precise.

The idea is that node a in the left digraph plays the same role as node 2 in the

right digraph, and similarly b and 1 match up and c and 3 match up. “Playing

the same role” means precisely that if you match node x in one digraph to node m

in another, and similarly node y to n, then the arrows from x to y must match

up with the arrows from m to n. (You should check these two digraphs to see that

this happens).
c

This is made precise this way:

147.1 Definition: isomorphism

Let G = (Go,G\,s,t) and G' = {G^G'^s' ,t') be digraphs. An iso-

morphism from G to G’ is a pair of bijections /3q : Gq — > G' 0 and

Pi: G i — >• G\ with the property that a:x — >• y in G if and only if

Pi{a) : Po{x) Po(y) in G' .

147.1.1 Remark Since there is rarely any problem with ambiguity, the subscripts

may be omitted from Pq and Pi .

147.1.2 Example In Figure 147.1 there is an isomorphism P from the left figure

to the right figure defined by

/3(a) = 2 P(f)=v

P{b) = 1 P(g) = u

P(c) = 3 P(h) = w

P(k) = x

The inverse of this isomorphism (meaning (/J^ 1 ,/?^ 1 )) is also an isomorphism;


in

fact the inverse of any digraph isomorphism is also an isomorphism.

147.1.3 Remark It is easily possible for two digraphs to be isomorphic in more

than one way. This happens in Figure 147.1, for example.

147.1.4 Exercise (hard) Show that two digraphs are isomorphic if and only if

there is an ordering of their nodes for which their adjacency matrices are
identical.
147.1.5 Exercise Draw both (nonisonrorphic) simple digraphs that have only one

node, and all ten (nonisonrorphic) simple digraphs that have two nodes.

147.1.6 Exercise Let G = (Go,Gi,s,t) and G' = (G^G^s' ,t') be digraphs.

Prove that Pq\Gq^- G’q and Pi : Gi — > G' x constitute an isomorphism if and only
if

P and P' are bijections and s' ° P\ = Po°s and t! ° P\ = Po°t.

bijection 136

definition 4

digraph 74, 218

inverse function 146

isomorphism 223,

235

node 218, 230

224

adjacency

matrix 224, 232

automorphism 224

Cartesian product 52

definition 4

digraph 74, 218

identity function 63

integer 3

node 218, 230


nonnegative integer 3

positive integer 3

147.1.7 Exercise Let /? = ((3® : Go -4- G' 0 , : G\ — > G' x ) be a digraph


isomorph-

ism from G= (Go,Gi,s,t) to G' = {G' 0 ,G \ , s' ,t') . Show that (3~ l , i.e. , (Pq
1 ,^ 1 ),

is a digraph isomorphism from G' to G .

147.2 Definition: automorphism

An isomorphism P : G — > G of a digraph with itself is called an auto-

morphism.

147.2.1 Example For any digraph, the identity function is an automorphism.

The digraphs in Figure 147.1 each have two automorphisms, the identity and one

other.

147.2.2 Exercise Find the automorphisms of the digraphs in exercise 144.2.2.

(Answer on page 251.)

147.2.3 Exercise (hard) Let G be a digraph with exactly n automorphisms, and

let G' be a digraph isomorphic to G . Show that there are exactly n isomorphisms

from G to G'.

147.2.4 Exercise (hard) For any positive integer n, show how to construct a

digraph with exactly n automorphisms.

148. The adjacency matrix of a digraph

A convenient way for representing a digraph G in a computer program is by means

of its adjacency matrix.


148.1 Definition: adjacency matrix

The adjacency matrix of a digraph G is a matrix of nonnegative

integers whose entries are indexed by Go x Go and whose entry in the

location indexed by the pair of nodes ( x , y) is the number of arrows from

x to y .

148.1.1 Example For the left digraph in Figure 144.1 the adjacency matrix is

x y z w

x 0 2 1 0

2/0100

z 1 1 0 0

0 0 0 0

148.1.2 Remark The adjacency matrix depends on the way the nodes are

ordered; thus if you permute the nodes you get a different adjacency matrix for

the same graph. Note that the adjacency matrix does not contain the information

concerning the names of the arrows.

225

definition 4

digraph 74, 218

directed walk 225

divide 4

equivalent 40
node 218, 230

prime 10

tuple 50, 139, 140

148.1.4 Exercise Give the relational description of the digraph in Exercise


148.1.3.

(Answer on page 251.)

148.1.5 Uses of the adjacency matrix You can use the adjacency matrix of a

graph to determine properties of the graph:

(i) It is simple if no entry in the adjacency matrix is greater than 1 .

(ii) It has no loops if the entries down the main diagonal (the one from upper left

to lower right) are all 0.

(iii) The outdegree of a node is the sum over its row and the indegree is the sum

over its column.

The adjacency matrix will be used in the next section to calculate which nodes

can be reached from a given node.

148.1.6 Exercise Give the adjacency matrices of the digraphs in Figure 147.1.

(Answer on page 251.)

148.1.7 Exercise Draw this digraph and give its adjacency matrix: The nodes

are the numbers 1,2,3,4,6,12 and there is an arrow from a to b if and only if a and

b have the same prime factors (in other words, for all primes p. p \ a 44 p \ b).

148.1.3 Exercise Draw the graph with this adjacency matrix:

12 3 4

10 111
2 0 0 1 1

3 0 10 1

4 10 0 0

(Answer on page 251.)

149. Paths and circuits

149.1 Definition: directed walk

A directed walk of length k from a node p to a node q in a digraph

is a tuple (a\,. .. ,aj~) of arrows for which

P.l source(ai) = p;

P.2 target(afc) = q ; and

P.3 if k > 1 , then for each i = 1 , ... ,k — 1 , source(aj + i) = target(aj) .

149.1.1 Remarks

a) By definition, the length of a directed walk is the number of arrows it goes

through. If it goes through an arrow twice, the arrow is counted twice. A

directed walk of length n will thus make n + 1 visits to nodes, counting the

start and finish nodes, and the same node may be visited more than once.

b) We allow the empty walk () from any node to itself.

226
definition 4

digraph 74, 218

directed circuit 226

directed path 226

function 56

node 218, 230

recursive 157

simple directed

path 226

149.1.2 Example All these refer to digraph (149.1) below.

a) The walk (u) on the left digraph is of length one and touches the node y

twice.

b) The empty walk () from y to y is also a walk (of length 0); it is not the same

as (u) .

c) The walk (c, d, e) goes from z to y and touches z twice.

d) The walk (c, d, c, d) goes from z to z and touches each of x and z twice.

e) (e,a,d) is not a directed walk because an arrow goes the wrong way.

149.2 Definition: directed path

A directed path is a directed walk in which the arrows a\, . . . , are

all different.

149.2.1 Example In the digraph (149.1):

a) (c,a,u) is a directed path of length 3 from z to y.


b) (d, c, a) is a directed path of length 3 from x to y .

c) (e) is a directed path of length 1 from z to y .

d) (d, c, d, e ) is a directed walk that is not a directed path.

149.3 Definition: directed circuit

A directed circuit is a directed path from a node to itself.

149.3.1 Remark A directed circuit must be a path, not merely a walk.

149.3.2 Example In the digraph (149.1), the only directed circuits are the three

empty paths, (c,d), ( d,c ) and (u ) . (Thus a loop is a directed circuit.)

149.4 Definition: simple directed path

A simple directed path is a directed path not containing any directed

circuits, so that you never hit a node twice.

149.4.1 Example The only simple directed paths from z to y in the digraph (149.1)

are (c,a), (c, 6), and (e) .

149.4.2 Example Programs in many languages such as Pascal are made up of

procedures or functions that call on each other. It is often useful to draw a


digraph

in which the nodes are the procedures and functions and there is an arrow from P

to Q if Q is called when P is run. A loop in such a digraph indicates a procedure

or function that calls itself recursively. Larger circuits indicate indirect


recursion.
227

149.4.3 Exercise Find all the simple directed paths from 1 to 3 in the digraph

G = (Go, G\,s,t), where Go = {1,2,3}, G\ = {a, 6, c, d, e} , s(a) = s(e) = l, s(b)


=

s(c) = s(d ) = 2, t(a) = 2, t(b ) = t(c) = 1, and t(d) = t(e) = 3. (This is the
same as

the digraph in Exercise 144.2.2(b).) (Answer on page 251.)

149.4.4 Exercise A digraph is transitive if whenever there are arrows x — > y

and y — » z, there must be an arrow x—>z. Show that a digraph is transitive if and

only if whenever there is a walk from x to y there is an arrow x — >• y .

150. Matrix addition and multiplication

The adjacency matrix of a digraph can be used to compute directed walks from one

node to another. This involves the concepts of matrix addition and multiplication,

which are described briefly here.

associative 70

Cartesian product 52

commutative 71

definition 4

digraph 74, 218

fact 1

function 56

integer 3

node 218, 230

positive integer 3

scalar product 227


transitive 80, 227

tuple 50, 139, 140

usage 2

150.1 Definition: scalar product

Let V and W be two n-tuples of real numbers. The scalar product

V ■ W is the sum E” =1 VjtR .

150.1.1 Example ( 3 , 5 , - 1 , 0 ) • ( 1 , 2 , 3 , 4 ) = 10 .

150.1.2 Usage The scalar product is also called the “dot” product. You may be

familiar with its geometrical meaning when the tuples represent vectors.

150.1.3 Remark The scalar product is only defined for two tuples of the same

length. For each positive integer n, it is a function R n x R n — > R.

150.2 Definition: product of matrices

Let A be a k x m matrix with real entries, and B an mx n matrix

with real entries; specifically, A has the same number of columns as B

has rows. Then the product AB of the matrices is the k x n matrix

whose (i,j ) th entry is the scalar product of the zth row of A and the

j th column of B . In other words,

(AB)ij = Y% =l A ik B kj ( 150 . 1 )

150.2.1 Example

/ 1 3 0

\2 2 2
2 10 5

3 - 21-1

5 110

11 -5 3 2 \

20 0 4 8 )

( 150 . 2 )

150.2.2 Fact Matrix multiplication is associative, when it is defined; in other

words, for a k x m matrix A, an m x n matrix B and an nxp matrix C , ( AB)C =

A(BC) . Matrix multiplication is not, however, commutative. There are nxn

matrices A and B for which AB ^ BA. (Note that if AB and BA are both

defined, then A and B must be square matrices.)

228

associative 70

commutative 71

definition 4

digraph 74, 218

induction hypothe-

sis 152

induction 152
integer 3

node 218, 230

proof 4

theorem 2

150.2.3 Exercise Give examples of 2 x 2 matrices showing that matrix multipli-

cation is not commutative.

150.2.4 Exercise Show that matrix multiplication is associative when it is

defined.

150.3 Definition: sum of matrices

Let M and N be m x n matrices. Then the sum M + N is defined by

requiring that (M + N)ij = M t j + Nij .

150.3.1 Remark Two matrices can be added if and only if they have the same

dimensions.

150.3.2 Example

(150.3)

150.4 Powers of matrices

In the following, we will use powers of square matrices with integer coefficients.
If

M is a square m x m matrix, M n denotes M multiplied by itself n — 1 times. This

is best defined by induction: M° = I , M 1 = M, and M n = M n ~ l ■ M . It follows

from this and Definition 150.2 that


(M'% = E f =1 {M n - l ) ik M kj (150.4)

151. Directed walks and matrices

151.1 Theorem

If G = (Go,Gi,s,t) is a digraph with adjacency matrix M, then the

number of directed walks of length k from node p to node q is the (p, q) th

entry of M k .

Proof This fact can be proved by induction on k. It is clear for k = 1, since a

directed walk of length 1 is just an arrow, and the ( p , q) th entry in M 1 = M is


the

number of arrows from p to q by definition.

Suppose it is true that for all nodes p and q, the (p,q) th entry of M k is the

number of directed walks of length k from p to q . A directed walk of length k + 1

from p to q is a directed walk of length k from p to some node r followed by

an arrow (directed walk of length 1) from r to q. By the induction hypothesis,

there are ( M k ) pr directed walks of length k from p to r, and there are M rq


arrows

from r to q . Hence the number of directed walks of length k + 1 from p to q that

consist of a directed walk of length k from p to r followed by an arrow from r to

q is ( M k ) pr x M rq . The total number of directed walks of length k + 1 from p


to q

must be obtained by adding up this number ( M k ) pr x M rq for each node r of the

229
Or — 3 Clr — 2 — 1 ®r+s— 1 ®r+s+ 2 ®r+s+3

corollary 1

digraph 74, 218

node 218, 230

nonnegative integer 3

proof 4

reachable 229

Figure 151.1: Walk with loop.

digraph; in other words, if there are n nodes in the digraph, the total number of

walks is

E? =1 |(MVK,M rg j (151.1)

That sum, by formula (150.1), is the (p,q ) th entry of Af fc+1 , which is M k x M,

and that is what we had to prove.

151.2 Reachability

Let p and q be nodes of a digraph G. One says that q is reachable from p if

there is at least one directed walk of some length (possibly zero) from p to q.

Since a directed walk of length k touches k + 1 nodes, it follows from the pigeon-

hole principle that a directed walk of length n or more in a digraph G with n nodes

must touch some node twice. Suppose such a walk (gi,... ,«*) touches a node x

twice; say arrow a r has source x and arrow a r + s (with s > 0) has target x. Then

the directed walk (a r , . . . , a r + s ) can be eliminated from the walk, as in


Figure 151.1,
giving

(ttl , . . . , Q>r—\ , Gr+s+1 > • ■ ■ j (151.2)

from p to q. (Note: if r = 1 or r + s = k, the walk (151.2) has to be modified in

an obvious way.)

Clearly, by successively eliminating circuits, one can replace the walk by a path

(not just a walk) of length < n. This leads to:

151.3 Corollary

Let G be a digraph as in Theorem 151.1 with n nodes and matrix M .

Then q is reachable from p if and only if the ( p , q) th entry of the matrix

K = I + M + M 2 + . . . + Af n_1 is nonzero.

Proof If there is a directed walk from p to q, then the argument before the state-

ment of the Corollary shows that there must be one of length n — 1 or less. This

means that one of the matrices M , A/ 2 , ... , M n ~ l has a nonzero (p,q ) th


entry.

Since all the entries in these matrices are nonnegative, this means that the (p,q)
th

230

definition 4

digraph 74, 218

even 5

finite 173

function 56

graph 230
implication 35, 36

reachability

matrix 230

subset 43

transitive

(digraph) 227

entry of K is nonzero. Conversely, if that entry is nonzero it must be because the

(p,q) th entry in M* for some i is nonzero.

151.3.1 Exercise Use matrix multiplication to find all the directed walks of

length 1,2,3 and 4 that go from 1 to 3 in these digraphs:

(151.3)

(Answer on page 251.)

151.4 Definition: reachability matrix

The matrix

K = I + M + M 2 + ... + M n ~ l

is called the reachability matrix for the digraph G.

151.4.1 Exercise Calculate the reachability matrices for the digraphs in Fig-

ure 144.1, page 218. (Answer on page 251.)

151.4.2 Exercise Let G be the digraph whose set of nodes is {1,2, 3, 4}, with an

arrow from a to b if and only if a is even and b is 2 or 3. Find the reachability

matrix of G by counting paths and by direct addition and multiplication of


matrices.
(You may use Mathenratica for the latter.)

151.4.3 Exercise Let D be a digraph with adjacency matrix M . Show that D

is transitive (as defined in the preceding problem) if and only if

( M 2 )ij / 0 =>- Mij / 0

for all pairs (i,j) .

152. Undirected graphs

In Chapters 144 through 151, we considered digraphs that consisted of nodes and

arrows between some of the nodes. The graphs considered in this section have nodes

with edges between them, but the edges have no direction assigned to them.

152.1 Definition: graph

A graph G consists of two finite sets Go and Gi together with a func-

tion r from G\ to the set of two-elenrent subsets of Go • The elements

of Go are called nodes or xvertices of G and the elements of G± are

called edges.

231

(a)

(b)
definition 4

edge 230

graph 230

injective 134

node 218, 230

simple graph 231

subset 43

Table 152.1: Some graphs

152.2 Definition: simple graph

G is a simple graph if T is injective, so that there is no more than one

edge connecting two nodes.

152.2.1 Exercise Which of the graphs in Table (152.1) are simple? (Answer on

page 251.)

152.2.2 Remark We will sometimes use the word “multigraph” to emphasize

that we are talking about a graph that is not necessarily simple.

152.2.3 Drawing graphs One draws a graph by using dots for the nodes, and

drawing a line between nodes p and q for each edge e for which T(e) = {p, q} . In

common with most of the literature on the subject, our graphs do not have loops:

the requirement that T have values in the set of two-element subsets rules out the

possibility of loops.
232

adjacency

matrix 224, 232

adjacent 232

definition 4

fact 1

graph 230

incident 232

symmetric 78, 232

152.2.4 Example The figure below shows two graphs; the one on the right is

simple.

In the left graph the set of nodes is {q,r,s,t}, the set of edges is {a,b,
u,v,x,w,y} ,

and, for example, T(a) = {r,t} .

152.3 Definition: incidence

If e is an edge in a graph and T(e) = {p, q} then e is said to be incident

on p (and on q ). Two nodes connected by an edge in a simple graph

are adjacent. If n edges connect two nodes the nodes are said to be

adjacent with multiplicity n.


152.4 Definition: adjacency matrix

The adjacency matrix of a graph is the square matrix A whose rows

and columns are indexed by the set of nodes, with A(p,q) =the number

of edges between p and q .

152.4.1 Fact It follows from the definition that for any (multi)graph with adja-

cency matrix A,

(i) for any node p, A(p,p ) = 0;

(ii) for any nodes p and q, A(p,q) = A(q,p) (this says A is symmetric); and

(iii) if the graph is simple, A has only 0’s and l’s as entries.

152.4.2 Remark Because of 152.4. l(i) and (ii), all the information about the

graph is contained in the triangular matrix consisting of the entries A(p,q) with

p < q.

152.4.3 Example The adjacency matrix of the left graph in Figure (152.1) is

0
l

s
0

233

152.5 Definition: degree

The degree of node is the number of edges incident on that node.

152.5.1 Example The degree of the node c in the right graph in Figure (152.1),

page 232, is 3, and the degree of d is 1.

152.5.2 Fact The degree of a node is the sum over the row (and also over the

column) of the adjacency matrix corresponding to that node.

152.5.3 Exercise Show that the sum of the degrees of the nodes of a graph is

twice the number of edges.

153. Special types of graphs

Two special kinds of graphs that will be referred to later are given in the
following

definitions.
153.1 Definition: complete graph on n nodes

A complete graph on n nodes is a simple graph with n nodes, each

pair of which are adjacent. Such a graph is denoted K n .

153.1.1 Example I\ 4 is shown in diagram (153.1) below.

153.1.2 Exercise Give a formula for the number of edges of I\ n for n > 0.

153.2 Definition: bipartite graph

A bipartite graph G is a graph whose nodes are the union of two dis-

joint nonempty subsets A and B , called its moieties, with the property

that every edge of G connects a node of A to a node of B .

153.2.1 Fact It follows from Definition 153.2 that no two nodes of A are adjacent,

and similarly for B .

153.3 Definition: complete bipartite graph

A bipartite graph G with moieties A and B is a complete bipartite

graph if every node of A is connected to every node of B . A complete

bipartite graph for which A has m elements and B has n elements with

m<n is denoted K m ^ n .

153.3.1 Example The right graph in the following figure is A 3 , 4 .

iu

adjacency

matrix 224, 232


bipartite graph 233

complete bipartite

graph 233

complete graph on n

nodes 233

definition 4

degree 233

edge 230

fact 1

graph 230

moiety 233

node 218, 230

subset 43

(153.1)

234

definition 4

digraph 74, 218

fact 1

full subgraph 234

full 234

function 56

graph 230
restriction 137

simple graph 231

subgraph 234

subset 43

usage 2

153.3.2 Exercise Which of the graphs in Table (152.1), page 231 are complete

graphs? (Answer on page 251.)

153.3.3 Exercise Which of the graphs in Table (152.1), page 231 are bipartite

graphs? Which are complete bipartite graphs? (Answer on page 251.)

1 53.3.4 Exercise Give a formula for the number of edges of the complete bipartite

graph K rnn .

154. Subgraphs

154.1 Definition: subgraph

A subgraph of a graph G is a graph G' whose nodes Gq are a subset

of the nodes Go of G, and for which every edge of G' is an edge of G

between nodes of G' . If every edge of G that connects nodes of G' is

an edge of G ' , then G' is a full subgraph of G .

154.1.1 Usage For some authors, “subgraph” means what we call a full subgraph.

154.1.2 Fact If G' is a subgraph of G, the edge function T 7 for G' is the restric-

tion to G o of the edge function T of G .

154.1.3 Example The following graph is a non-full subgraph of the left graph in

Figure (152.1), page 232.


r

(154.1)

154.1.4 Exercise Show that if K n is a subgraph of a simple graph G, then it is

a full subgraph. Is the same true of K rnn ?

155. Isomorphisms

155.0.5 Remark Isomorphism of graphs is analogous to isomorphism of digraphs:

it captures the idea that two graphs are the same in their connectivity — there is
a

way of matching up the nodes so that the edges match up too.

235

155.1 Definition: isomorphism

Let G and H be simple graphs. A function (3 : Gq — > Hq is an iso-

morphism from G to H if it is a bijection with the property that p


and q are adjacent in G if and only if /3(p) and /3(q) are adjacent in H.

G and H are isomorphic if there is an isomorphism from G to H .

155.1.1 Usage In electrical engineering, isomorphic graphs are said to have the

“same topology” .

155.1.2 Example In general there may be more than one isomorphism between

G and H . The graphs below are isomorphic. Altogether, there are 12 isomorphisms

between them.

adjacent 232

bijection 136

complete bipartite

graph 233

complete graph 233

definition 4

full subgraph 234

function 56

graph 230

identity function 63

integer 3

isomorphic 235

isomorphism 223,

235

moiety 233

node 218, 230

usage 2
155.1.3 Example The left graph below is not isomorphic to the right graph. The

identity map is a bijection on the nodes, and if nodes are adjacent in the left
graph,

they are adjacent in the right graph, but there are nodes in the right graph that

are adjacent there but not in the left graph. The definition of isomorphism
requires

that p and q be adjacent if and only if j3(p) and /3(q) are adjacent.

(155.2)

155.1.4 Exercise Group the graphs in Table (152.1), page 231 according to which

are isomorphic to each other. (Answer on page 251.)

155.1.5 Exercise In Table (152.1), page 231, show that (b) is isomorphic to a

full subgraph of (c), and to a nonfull subgraph of (c). (Answer on page 251.)

155.1.6 Exercise

a) Prove that any two complete graphs on n nodes are isomorphic.

b) Prove that if n < m, then a complete graph on n nodes is isomorphic to a full

subgraph of a complete graph on m nodes.

c) Prove that for fixed integers m and n, two complete bipartite graphs, each of

which has one moiety with m nodes and the other moiety with n nodes, are

isomorphic.
236

circuit 236

connected compo-

nent 236

connected 236

cycle 236

definition 4

digraph 74, 218

edge 230

fact 1

graph 230

isomorphic 235

isomorphism 223,

235

length 236

list 164

node 218, 230

path 236

simple graph 231

simple path 236

theorem 2

walk 236

155.1.7 Exercise

a) Give a definition of isomorphism for multigraphs.


b) Prove that a graph isomorphic to a simple graph (using your definition of

isomorphic) is simple.

c) Prove that for simple graphs your definition of isomorphism is the same as

Definition 147.1.

156. Connectivity in graphs

We talk about walks, paths and circuits in graphs in much the same way as for

digraphs.

156.1 Definition: walk

A walk from node p to node q in a graph is a sequence

(no,ei,rai,e 2 ,... ,rik- i,ek,rik)

of alternating nodes and edges for which no = p ■ nk = q, and e* is inci-

dent on rii - 1 and n t for i = 1, 2, . . . , k . The length of such a walk is k ,

which is the number of edges occurring in the list (counting repetitions),

or one less than the number of nodes ocurring in the list.

156.2 Definition: path

A path in a graph is a walk in which no edges are repeated. A simple

path is a path in which no nodes are repeated.

156.3 Definition: circuit

A circuit is a path (not a walk) from a node to itself, and a cycle is

a circuit in which no nodes are repeated except that the beginning and

end are the same.


156.3.1 Fact It is easy to see (eliminate circuits) that if there is a walk between

two nodes then there is a simple path between them.

156.4 Definition: connected

A graph is connected if there is a path (hence a simple path) between

any two nodes. If p is a node in a graph, let C (p) denote the set

consisting of p and of all nodes q for which there is a path between p

and q. The sets C (p) are called the connected components of the

graph G.

156.4.1 Fact Part (a) of the theorem below implies that two nodes in a graph are

joined by a path if and only if they are in the same connected component. A graph

is therefore connected if and only if it has just one connected component.

237

156.5 Theorem

Let G be a graph.

a) Let p be a node in G . For any two nodes q and r in C (p) there

is a path from q to r .

b) If q G C(p) then C(p) = C(q) .

c) The set {C(p) \ p £ Go} is a partition of G .


Proof For (a), if p = q or p = r there is a path from q to r by definition of C (p)
.

Otherwise, just connect the path from p to q to the path from p to r. The result

might only be a walk, but by eliminating circuits, you get a path. That proves (a).

If q £ C(p) , (a) implies there is a path from p to r if and only if there is a


path

from g to r, so (b) follows. Finally, any node p is an element of C(p) ; this and
(b)

implies that every node is in exactly one set C (p) , so the sets C (p) form a
partition

of the nodes. That proves (c).

circuit 236

connected graph 236

cycle 236

definition 4

diameter 237

distance 237

edge 230

Eulerian circuit 237

graph 230

node 218, 230

partition 180

path 236

proof 4

simple path 236

theorem 2

walk 236
156.6 Definition: distance

The distance between two nodes p and q in a connected graph is the

length of the shortest simple path between p and q.

156.6.1 Example In the right graph of Figure (152.1), the distance between

nodes d and / is 3 . There are of course simple paths of length 4 and 5 between

nodes d and / , but the shortest one has length 3 .

156.7 Definition: diameter

The diameter of a connected graph is the maximum distance between

any two nodes in the graph.

156.7.1 Example The diameter of the graph just mentioned is 3.

157. Special types of circuits

157.1 Definition: Eulerian circuit

An Eulerian circuit is a circuit in a graph which contains each edge

exactly once. It need not be a cycle; in other words, nodes may be

repeated, but not edges.

A graph need not have an Eulerian circuit. For example, the graph in Fig-

ure (152.1) has no Eulerian circuit. There is a simple criterion for whether a
graph

has an Eulerian circuit:


238

circuit 236

connected graph 236

connected 236

converse 42

definition 4

degree 233

edge 230

Eulerian circuit 237

even 5

fact 1

finite 173

graph 230

Hamiltonian cir-

cuit 238

incident 232

integer 3

node 218, 230

proof 4

157.2 Theorem

A connected graph G has an Eulerian circuit if and only if the degree of

every node is even.

Proof Suppose G has an Eulerian circuit. As you go around the circuit, you

have to hit every edge exactly once. Every time you go through a node, you must

therefore leave by a different edge from the one you entered. So for each node p.
you can divide the edges incident to p into two groups: those you enter p on and

those you leave p on. Since you enter and leave p the same number of times, these

two groups of edges must have the same number of elements. Thus the number of

edges incident on p is even.

Now for the converse: suppose every node of G has even degree. To construct

an Eulerian circuit, pick a node p. If that is the only node in G you are finished.

Otherwise, there is an edge on p. Travel along that edge to some node q and mark

the edge so you won’t use it again. Because there are an even number of edges

incident on q . there is an unmarked edge. Leave on the edge and repeat the process

until you arrive at p again.

This process will produce a circuit containing p. No edge can be repeated

because you are marking the ones you use, and because of finiteness you have to

return to p sometime. However, the circuit may not pass over every edge. If it does

not, there is an unmarked edge e incident on some node q already in your circuit,

because G is connected. Start with that node and that edge and repeat the process,

continuing until you return to q. This will give another circuit containing q. Note

that the second circuit may hit nodes of the first circuit, but there will always
be

an unmarked edge to leave on because each node in the first circuit has even degree

and an even number of marked edges. You now can put these two circuits together

into a big circuit — go around the first circuit starting at p until you get to q,
go

around the second circuit until you return to q, and then continue around the first

circuit until you get back to p. If you still don’t hit all the edges, you can
repeat

this process a second time, and so on until all the edges are used up. The result
will

be an Eulerian circuit.

This problem was first solved by Leonhard Euler, who was asked whether it was
possible to walk around the city of Konigsberg (then in Prussia, now in Russia and

called Kaliningrad) in such a way that you could traverse each of its seven bridges

exactly once. The arrangement of bridges in Euler’s time is represented by the left

graph in Figure (152.1), page 232 (each edge represents a bridge), which clearly
has

no Eulerian circuit since in fact none of its nodes has even degree.

157.2.1 Exercise For which integers n does K n have an Eulerian circuit?

157.2.2 Exercise For which integers m and n does K m , n have Eulerian circuit?

157.3 Definition: Hamiltonian circuit

A Hamiltonian circuit in a graph is a circuit which hits each node

exactly once.

157.3.1 Fact Such a graph must be connected (why?).

239

157.3.2 Remark Our main purpose in mentioning Hamiltonian circuits is to con-

trast their theory with that of Eulerian circuits: there is no known simple
criterion

to determine whether a graph has a Hamiltonian circuit or not. The problem is com-

putationally difficult in general, although for special classes of graphs the


question

can be answered more easily (Problems 157.4.5 and 157.3.3).


157.3.3 Exercise For which integers m and n does K rnn have a Hamiltonian

circuit?

157.4 Exercise set

Exercises 157.4.1 through 157.4.3 concern the graphs in Table 152.1, page 231.

definition 4

diameter 237

edge 230

embedded in the

plane 239

Eulerian circuit 237

graph 230

Hamiltonian cir-

cuit 238

integer 3

planar 239

157.4.1 Give the diameter of each graph. (Answer on page 251.)

157.4.2 Which of the graphs has an Eulerian circuit? (Answer on page 252.)

157.4.3 Which of the graphs has a Hamiltonian circuit? (Answer on page 252.)

157.4.4 Give examples of:

a) A graph which has an Eulerian circuit but not a Hamiltonian circuit.

b) A graph which has a Hamiltonian circuit but not an Eulerian circuit.

157.4.5 For which integers n does K n have a Hamiltonian circuit?


158. Planar graphs

158.1 Definition: Planar

A graph is embedded in the plane if it is drawn in such a way that

no two edges cross. It is planar if can can be embedded in the plane.

158.1.1 Example Graphs can be used to represent electric circuits. It is desirable

in a printed circuit that no two lines (edges of the graph) cross each other. This
is

exactly the statement that the graph is embedded in the plane.

158.1.2 Example The left graph in Figure (155.1), page 235, can be embedded

in the plane as the right graph in the same figure.

158.1.3 Warning The fact that a graph is drawn with edges crossing does not

mean it is not planar. For example, K 4 is planar, in spite of the way it is drawn
in

Figure (153.1), page 233.

240

complete bipartite

graph 233

complete graph 233

definition 4

edge 230

embedded in the

plane 239
graph 230

node 218, 230

planar 239

subdivision 240

subgraph 234

theorem 2

utility graph 240

158.1.4 Exercise Which graphs on page 231, are planar? (Answer on page 252.)

158.1.5 Example Not all graphs can be embedded in the plane. For example,

the complete graph on 5 vertices (left graph below) cannot be embedded in the

plane. Another such graph is the utility graph, the right graph below (which is

the complete bipartite graph 143 , 3 ). It arises if you have three houses a, b and
c

that must each be connected to the water, sewer and gas plants (w, s and g ). If it

is drawn in the plane, edges must cross.

(158.1)

k 5

A',3,3

There is an easy-to-use criterion to determine whether a graph is planar. It

requires a new concept:

158.2 Definition: subdivision


A subdivision of a graph is obtained by repeatedly applying the fol-

lowing process zero or more times: take an edge e connecting two nodes

x and y and replace it by a new node z and two edges e! and ef' with

e' connecting x and z and e" connecting y and z.

158.2.1 Example The graph H below is a subdivision of G ; it is obtained by

subdividing three times. Note that a graph is always a subdivision of itself.

(158.2)

158.3 Theorem: Kuratowski’s Theorem

A graph is not planar if and only if it contains as a subgraph either a

subdivision of K$ or a subdivision of the utility graph

158.3.1 Remark This theorem has a fairly technical proof that will not be given

here. Note that it turns a property that it would appear difficult to verify into
one

that is fairly easy to verify.

241

159. Graph coloring

Some very difficult questions arise concerning labeling the node of a simple graph.

159.1 Definition: coloring


A coloring of a simple graph G is a labeling L : G$ — >■ S (where S is

some finite set) with the property that if nodes p and q are adjacent,

then L(p) ^ L(q ) . In this context the elements of S are called colors.

159.1.1 Remark This terminology arises from the problem of coloring a map

of countries in such a way that countries with a common border are colored with

different colors. In the (very large) literature on coloring problems, two states
or

countries that have only a point on their borders in common, such as Arizona and

Colorado in the U.S.A., are regarded as not bordering each other. The common

border must have a nonzero length.

characteristic func-

tion 65

chromatic num-

ber 241

coloring 241

color 241

definition 4

edge 230

finite 173

graph 230

labeling 221

node 218, 230

odd 5

simple graph 231

159.1.2 Example The state of Kentucky in the U.S.A., and the seven states
bordering it, require four colors to color them in such a way that adjoining states

do not have the same color. This is turned into a problem of graph theory by

drawing a graph with one node for each state and an edge between two nodes if the

corresponding states border each other:

MO TN

(159.1)

159.2 Definition: chromatic number

The smallest number of colors needed to color a simple graph G is called

the chromatic number of G, denoted x(G).

Warning: Note that we have already used x f° r the characteristic function of

a subset of a set.

159.2.1 Example The chromatic number of the graph in Figure (159.1) is 4, and

the chromatic number of the right graph in Figure (152.1) is 3.

159.2.2 Exercise Show that a graph with at least one edge is bipartite if and

only if its chromatic number is 2 .

159.2.3 Exercise Show that a graph has chromatic number 2 if and only if it has

no cycles of odd length.

242
bipartite graph 233

chromatic num-

ber 241

coloring 241

color 241

complete graph 233

Four Color Theo-

rem 242

graph 230

Kempe graph 242

Kuratowski’s Theo-

rem 240

moiety 233

node 218, 230

planar 239

subgraph 234

subset 43

159.2.4 Remark It is in general a nontrivial question to determine the chromatic

number of a graph. However, some things can be said.

a) The complete graph on n nodes has chromatic number n, since every node is

adjacent to every other one.

b) A bipartite graph has chromatic number 2 (if it has any edges): since none

of the nodes in one of the moieties are adjacent to each other, they can all

be colored the same color, and the nodes in the other moiety can be colored

another color.
c) It is known that any planar graph has chromatic number < 4. This fact is

called the Four Color Theorem and is difficult to prove.

159.2.5 Example As an indication of the problems involved in proving the Four

Color Theorem, observe that the graph of states in Figure (159.1) has chromatic

number 4, although it does not contain the complete graph K 4 as a subgraph.

In other words, although there is no four-element subset of the states involved in

Figure (159.1) that all border each other (thus turning into a copy of K 4 in
(159.1)),

it nevertheless takes four colors to color the whole graph. It follows that you
can’t

use Kuratowski’s Theorem to prove the Four Color Theorem: the fact that no

planar graph contains K 5 as a subgraph does not rule out the possibility that a

planar graph needs five colors to color it.

159.2.6 Exercise Give an example of a graph with chromatic number 3 that does

not contain a subgraph isomorphic to K 3 .

159.2.7 Exercise Find a place in the world with four political subdivisions that

all border each other. (There are no four states in the U.S.A. like this, although
you

will observe that North Carolina, South Carolina, Georgia and the Atlantic Ocean

all “border” each other.)

159.2.8 Exercise A Kempe graph is a graph with n+1 nodes, consisting of

n nodes in a cycle and another node connected to each node in the cycle, and no

other edges. Figure (159.1), page 241, is a Kempe graph.

a) Show that a Kempe graph is planar.

b) Find the chromatic number of a Kempe graph. (It will depend on n.)

159.2.9 Garbage routes The effort to prove the Four Color Theorem resulted in
the discovery of fast coloring algorithms and of a lot of detailed information
about

graph coloring. This has other applications besides coloring maps. For example,

consider the following problem: A city is divided into a number of garbage pickup

routes. Some of the routes overlap, because businesses must be picked up more

often than residences and therefore are assigned to two or more routes. What is

the best way to distribute the routes among the five working days of the week, with

each route traveled once a week?

If each route is regarded as a node, with two routes adjacent if they overlap,

the result is a graph. A scheduling of the routes that avoids scheduling


overlapping

routes on the same day is a five-coloring of this graph. An efficient way of


coloring

the graph would be a start towards finding a good schedule. Note that this problem

has nothing to do with planarity or the Four Color Theorem.

243

Answers to Selected Exercises

3 . 1.5 Yes, because —(—3) = 3 and 3 > 0, so by

Definition 2.2, —(—3) is positive.

4 . 1.2 Yes, because 52 = 4-13.

4 . 1.10 -2, -1, 1, 2.

5 . 5.1 333 = 9 x 37 and 9 is an integer, so 37 | 333

by Definition 4.1.
5 . 5.2 Suppose 0 < k < n and suppose k is divisi-

ble by n. By Definition 4.1, there is an integer q for

which k = qn. Since k and n are nonnegative, so is

q . Since k = qn < n , dividing through the inequal-

ity by n (which is positive) gives q < 1 . Since q is

nonnegative, it must be 0 . Since k = qn, k = 0 as

well.

6 . 1.5 91 = 7x13; 98 = 2 x 7 2 ; 108 = 2 2 x 3 3 ;

111 = 3 x 37 ; 211 is prime

7 . 5.1 No. For example,

112 ,232

- + - = - and - - = -

9 . 2.4 Only the pair in (c) are equal.

10 . 1.2 5.1 = 46/9; 4.36 = 48/11; 4.136 = 91/22.

12 . 2.6 x 2 — | + 4x > 2x .

12 . 4.1 to = 2 makes it true and to = 8 makes it

false.

12 . 4.2 Any to makes it true. No value of to

makes it false.

12 . 5.2 Q(-l) is 1 < 4 and Q(x — 1) is (x — l) 2 <

4.

12 . 5.3 a. 2<5. b. 3<4. c. x 2 < x + y + 1 . d.


x{x + y ) <x + y + z + l.

13 . 2.7 (a) and (b) are true, and the others are

false. It is wrong to say that (c) is “sometimes

true” or “usually true” . The statement that 3 • 0 > 0

is false, so the statement (Va;:N)(3a; > x) is simply

false, with no qualification.

14 . 2.3

2 6

T T

T T

T T

14 . 2.4 a) True: n = 5. False: Any n other than

5.

b) True: n = 8, for example, or n = 0. False: n =

4, 5, 6, 7 are the only ones.


c) True: Impossible. False: any n.

d) True: Any n.

14 . 2.5 Only (d).

17 . 1.4 3.

18 . 1.5 a) 2. b) 3. c) 2. d) 0. (For (b), see

Remark 8.1.3.)

18 . 1.16 You must show that P(a) is false.

19 . 2.5 (a) and (c) are true and (b) is false.

19 . 2.6 -13, -7, -5, -4, -3, -2, 0,1, 2, 3, 5, 11. b)

1,4,9,16,36,144. c) Same as (b).

20 . 1.3 (a) and (c) are the same, and so are (b)

and (d).

22 . 1.6 Only (d) is the empty set.

23 . 1.5 d is the empty set and b, c and g are single-

tons.

23 . 1.6 (a) Di is the only singleton, (n) 1 is the

only integer which is an element of D n for every

positive integer n.

25 . 1.4 Item (a) is true for all integers to but

(b) and (c) are false. For example, (b) is false for

to = 6 (then the hypothesis is true and the conclu-

sion is false, and that is the line in the truth table

that makes the implication false), and (c) is false for

to = — 2 .
26 . 1.5 a) True: n = 6, for example (this is vacu-

ously true). False: n= 8.

b) True: any n. False: not possible.

c) True: n = 10. False: n = 8.

d) True: any n. False: not possible.

e) True: any n (always vacuously true). False: not

possible.

f) True: Any n except 1 . False: n = 1 .

27 . 2.1 (a), (c), (d) and (e) say the same thing,

and (b) and (f) say the same thing.

30 . 4.5 The contrapositive is “If n is not prime,

then 3 does not divide n”, which is not true for

some integers n. The converse is “If n is prime,

then 3 | n”, which is also false for some n.

244

=
a)

b)

c)

d)

N
N

e)

31.5.3 You must show that there is an element

x G S that is not an element of T . This is because

of Definition 31.1, which defines AC B to mean the

implication x £ A => x £ B , and the only way that

implication can be false is for the hypothesis to be

true and the conclusion false.

32.1.6

a: 4.

b: 0

. c

: 1. d:
2.

32.1.7

{0,{5},{6},

{7}, {5

',6}

,{6,

7}, {5

',7}, {5,6,7}}

32.1.8

cl
e

b
Y

N
N

N
N

g
N

33.2.2

{1,

2,3}

U {2,3,4,

5}

= {1,2,3

,4,5}
and

{1,2,3} n

{2,3

,4,5}

{2,3}

33.2.3

NU

Z = Z

and NflZ

= N
33.2.7

By

Definition 31.

1,

we :

must

show

that

if x € An B ,

then

GiU

B.

By
Definition

33.2

(of intersection), x

cAnB

implies

that

x £ A

and

x G B . By Definition 33.1 (of union), if x G A, then

x G AuB.

33.3.1 There are of course an infinite number

of answers. Some correct answers are: The set of

all negative integers, the set of all negative even

integers, {— 1,— 2,— 3}, {—42}, and the empty set

(which is disjoint from every set).

34.2.2 Z — N is the set of all negative integers.

N — Z = 0.

34.2.5 (a) 1,2, 3, 4, 5; (b) 2,3; (c) 1,2, 3, 4, 5, 7, 8;

(d) none; (e) 1; (f) 2, 3, 4, 5; (g) 1,2,3; (h) 1,2, 3, 4, 5;


(i) 2, 3, 4, 5.

34.2.6 1) 1 and 2. 2) 1. 3) 1, 3 and 5. 4) 5. 5) 6

and 7. 6) None. 7) 6 and 7.

35.1.3 The pairs in (a) are different; the pairs in

(b) and (c) are equal.

36.1.2 m fin is k , where k is the minimum of m

and n , and m U n is l , where l is the maximum of

to and n.

36.3.1 None of them are equal.

36.4.1 1. a) 3,4. b) 2, (1,5). c) 2, (5, (2,1)).

d) 2,9. e) 2, {1,2}. f) 4, Z.

37.1.2 (l,o), (1,6), (2,o), (2, 6).

37.6.1 This is false for any nonempty set A

because the elements of A x A are pairs of elements

of A, and an ordered pair is distinct from its coor-

dinates (see 35.1). (The last statement implies that

in fact for nonempty A, Ax A and A have no ele-

ments in common.) The statement A x A = A is

true if 4 = 0.

37.7.1 “For all sets A and B and all nonempty

sets C , . . . ”

37.9.1

(a) A
(b) 1,2

(c) (1,1), (1,2), (2,1), (2, 2)

(d) (1,1,1), (1,1, 2), (1,2,1), (1,2, 2),

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

(e) (1,3), (1,4), (1,5), (2, 3), (2, 4), (2, 5)

(f) (3,1), (3, 2), (4,1), (4, 2), (5,1), (5, 2)

(g) (1,1, 3), (1,1, 4), (1,1, 5), (1,2, 3), (1,2, 4), (1,2, 5),

(2, 1,3), (2, 1,4), (2, 1,5), (2, 2, 3), (2, 2, 4), (2, 2, 5)

(h) (1,(1, 3)), (1,(1, 4)), (1,(1, 5)), (1,(2, 3)),

(1,(2, 4)), (1,(2, 5)), (2, (1,3)), (2, (1,4)),

(2, (1,5)), (2, (2, 3)), (2, (2, 4)), (2, (2, 5))

(i) (1,3), (1,4), (1,5), (2, 3), (2, 4), (2, 5), 1,2

(j) 0

37.9.2

4
5

N
Y

N
N

6
N

N
38.2.1 j(a:,n) | a: > ?rj C R x N.

38.2.2 {(x,y) \ x G R ,y = l} = |(x,l) | x G

R j C R x R

38.2.3 {1} CR,

245

38.2.4 ^(x,y,z,w) \ x + y = z j CRxRxRxR.

39.3.7 F(l) = {{1}, {1,2}, {1,3}, {1,2, 3}} and

F(2) = {{2},{1,2},{2,3},{1,2,3}}.

40.2.6 (a) and (d) only.

41.1.8 F( 2) F(4)

a) 2 4

b) 42 42

c) 2 4

41.1.9 a) (2,2), (3,3)

b) (2,2), (3,3)

c) (2,2), (3,3)

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

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


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

42.2.3 a) \x.x 3 \ x i-+ x 3 : R — ► R b) A (a, 6). a;

(a, 6) i->- a: Ax B -+ A. c) A (a,b).a + b\ (a, 6) i — >•

a + b R. x R. — y R.

43.1.4 a) (1, FALSE), (2, TRUE), (3, TRUE)

b) (1,TRUE), (2, FALSE), (3, TRUE)

c) ((2, 2), 4), ((2, 3), 5), ((3, 2), 5), ((3, 3), 6)

44.1.5 a) (1) only, b) (2) only, c) (3) only, d) (1)

only. Note that (4) is not an answer to (d) because

the function is given as having codomain R. Of

course there is a function x H > x 2 : R — > R + with the

same graph but it is technically a different function.

For many purposes, this is merely a technicality, but

there are places in mathematics where the distinc-

tion is quite important.

46.4.3 35 22 + 6 5 +*.

48.1.5 We must show, for all subsets A, B and

C of S, that dU(5UC) = (4UB)U(7. We will

do this using Method 21.2.1, page 32. Suppose that

x £ iU(BUC) . Then by (33.1), page 47, either x £

A or x £ BUC . If x £ A, then x £ AuB , so x £

(A\J B)U C by using the definition of union twice.

If x £ B U C , then either x £ B or x £C . If x £ B ,

then x £ AU B , so x £ (AU B) U C . If x £ C , then

again by definition of union, x £ ( A U B) U C . So we


have verified that in every case,

x £ AU(BUC) => x£(AUB)\JC

so that by Definition 31.1, page 43, AU(BUC) C

(A UB)UC. A similarly tedious argument shows

that (A U B) U C C A U (B U C) . Therefore by

Method 21.2.1, A U (B U C) = (A U B) U C.

50 . 1.4 (1) is associative, not commutative, and

does not have an identity. (2) is not associative

(because (aA6)Ac = abut a A (b Ac) = b), is com-

mutative, and does not have an identity.

50 . 1.7 The empty set, since for any subset A of

S, AU0 = 0UA = A.

51 . 1.5

a) (1,3), (1,5), (2,1), (2, 3), (2, 5), (3,1), (3, 5)

b) (2, 2), (2, 4), (2, 6), (2, 8), (2, 10), (3, 3),

(3, 6), (3, 9), (5, 5), (5, 10), (7, 7)

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

52 . 1.3

a) (1,2), (1,3), (1,4), (2, 3), (2, 4), (3, 4)

b) (1,1), (2, 2), (3, 3), (4, 4). (This is A a .)

c) (1,3), (2, 3), (3, 3), (4, 3).


d) (1,1), (3, 3), (1,3), (3,1).

53 . 1.2 (a), (c) and (e) are functional relations.

53 . 2.3 1 ^ {3,5} , 2 h+ {1,3,5}, 3 h>{1,5}.

53 . 3.3 {(1,3), (1,4), (2,1), (2, 3), (2, 4), (-666,0)}

55 . 1.9 (b) is not reflexive, the others are reflexive.

56 . 1.4 (b) and (c) are symmetric, (a) and (d) are

not.

57 . 1.9 (a), (b) and (c) are antisymmetric; (d) is

not. Note that (c) is vacuously antisymmetric.

59 . 1.3

ref

sym i

N
b

cl

Y
f

59 . 1.4

ref

sym

c
N

cl

N
N

concerning (d):

2 <

3 2 , 3 <

60 . 1.2

a: q -

= 0, r

= 2. b:

r = 0. d:

q = 3

, r =

1.

ant

trs
irr

Y
N

ant trs irr Note

N N Y

N Y N

N N N

N N N

Y Y N

N Y N

N N N

2 2 , 8 < 3 2 .

g = 0, r = 0. c: q = 2,

246

60.1.4 Suppose a=qm + r and b=q'm + r.


Then a — b = qm — q'm = (q — q')m so it is divisi-

ble by to.

60.2.3 Since m div n — a, m = an + r for some

integer r such that 0 < r < n. We are given

that m = an + n + b+2, so r = n + 6 + 2 . Hence

n + b + 2 < n , so that 6 + 2 < 0 , so 6 < 0 .

60.2.4 Since n\s, s = qn for some integer q . q

is not less than 0 since n and s are nonnegative. It

is not greater than 0 since then qn>n>s but we

are given s = qn. So q must be 0 , so that s is 0

too.

60.5.2 By Definition 60.1, we must show that

37 = 7 • 5 + 2 and that 0 < 2 < 5 . Both are simple

arithmetic. It follows from Theorem 60.2 that the

quotient is 7 and the remainder 2 as claimed. (Yes,

you knew this in fourth grade. The point here is

that it follows from the definitions and theorems we

have.)

60.5.4 4, because to = 36g + 40 = 36(g + 1) + 4

and 0 < 4 < 36 .

61.1.3 n < r < n + 1 | — n = floor(?’) , where n is

of type integer.
61 . 2.3 a: trunc(7/5) = floor(7/5)

= 1.

b: trunc(— 7/5) = — 1;

floor (— 7/5) =

= -2.

c: trunc(— 7) = floor (-

-7) = -7.

d: trunc(— 6.7) = — 6;

floor (— 6.7) =

-7.

62 . 2.2 30 = 2 1 x 3

1 x5 1 , 35 =
5 1 x7 1 , 36

2 2 x 3 2 , 37 = 37 1 , 38 =

= 2 1 x 19 1 .

62 . 3.2

prime 98 99

100 111 1332

1369

3 0 2

0 1

7 2 0

0 0
0

37 0 0

0 1

62 . 5.1

90 =

2 1 x 3 2 x 5 1

91 =

7 1 x 13 1
92 =

2 2 x 23 1

93 =

3 1 x 31 1

94 =

2 1 x 47 1

95 =

5 1 x 19 1

96 =

2 5 x 3 1
97 =

97 1

98 =

2 1 x 7 2

99 =

3 2 x ll 1

63 . 2.2

PAIR

GCD

LCM

12, 12
12

12

12, 13

156

12, 14

84

12, 24

12

24

63 . 2.4

False:
for

example GCD (4, 2) =

GCD(2,2)

= 2. If

you said

“TRUE” you may have

fallen into the trap of saying “the GCD of to and n

is the product of the primes that m and n have in

common,” which is incorrect.

63 . 2.5 (1,1), (1,2), (1,3), (1,4), (2,1), (2, 3),

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

63 . 3.2 If d divides both n and n+ 1 it must

divide their difference, which is 1 . Hence the largest

integer dividing n and n + 1 is 1 .

64 . 2.2 Suppose e | to and e\n. Let p be any

prime. Then e p (e) must be less than or equal to

e p (m) and also less than or equal to e p (n). Thus

it is less than or equal to e p (d), which by Theo-

rem 64.1 is the minimum of e p ( to) and e p (n) . This

is true for every prime p, so in the prime factoriza-


tion of e, every prime occurs no more often than it

does in d, so by Theorem 62.4, e\d.

64 . 2.4 Let p be any prime. By Theorem 64.1,

e p (d) = min (e p (m),e p (n)) . Observe that e p (m/d) =

e p (m) — e p (d) and e p {n/d) = e p (n) — e p (d) . We

know that e p (d) = min(e p (m),e p (n)) , so one of the

numbers e p (w) — e p (d) and e p (n) — e p (d) is zero.

That means p does not divide both in and n.

Since p was assumed to be any prime, this means

no prime divides both m and n. Therefore,

GCD (m/d,n/d) = 1, as required.

66 . 6.3 By Definition 66.4,

n = d m b m -\ 1- dib 1 + dob 0

so

bn = d m b m+1 -\ 1- d\b 2 + d 0 b 1 + 06°

which means that bn is represented by

dm.dm—1 * * ' d\Q .

67 . 2.3 a) 1100000. b) 11010010. c) 110001111.

d) 1010111100.

67 . 2.4 a) 1525. b) bOO. c) 10c9a.

68 . 4.1

247
DEC

OCT

HEX

BASE

36

BINARY

100

144

64

2s

1100100

111

157

6f

33
1101111

127

177

7f

3j

1111111

128

200

80

3k

10000000

69.3.1 ( x > 10) V (x < 12) . Of course, this is true

of all real numbers.

69.3.2 (x > 10) V (x > 12) . Of course, this is the

same as saying x >10.


71.2.5 Here are the truth tables:

P Q

PVQ =P

~^Q

—iP A —iQ

-1 ( _, P A —iQ)

T T

T F

F
T

F T

F F

T
F

The third and seventh columns are the same.

71.2.9

P Q -

P V Q P => Q

_i Q PA-iQ -i(PA-.Q)

T T

F F

T F

F
F

T T

F T

F F

F F

T F
T

The fourth, fifth and eighth columns are the

same.

74.2.1 Valid.

74.2.2 Valid.

74.2.3 Invalid.

74.2.7 Let P be 3 >5 and Q be 4 >6. Then

P => Q is true because both hypothesis and conclu-

sion are false; on the other hand, Q is false. Since

the hypothesis of (P => Q) => Q is therefore true

and the conclusion false, the statement is false.

75.3.4 a: True. Witness: 2. b: False. Coun-

terexample: 9. c: True. Witness: 2. d: False.

Counterexample: 3.

75.3.5 (a) True, (b) True, (c) True, (d) False;

a counterexample is given by taking P to be x > 7

and Q to be x <7 .

76.1.4 There are no counterexamples to

(Vy)P(14,j/) since it is the statement

(Vy) ((14 = y) V (14 > 5))

which is true because “14 > 5” is true.

The number 3 and any number greater than 5


is a witness to (3x)P(x,3).

77.2.1 (a) means that for every real number the

statement (3 y)(x > y) is true. A witness for that

statement is x — 1 , so the statement is true, (b)

means that there is a real number greater than any

real number, which is false, (c) is true. Witness: Let

x = y = 3. Then the statement becomes ((3 > 3) =>

(3 = 3)), which is (vacuously) true.

82.2.1 valid: direct method.

82.2.2 invalid: fallacy of affirming the hypothesis.

82.2.3 invalid: fallacy of denying the conse-

quence.

82.2.4 valid with false hypothesis.

82.2.5 invalid: fallacy of denying the conse-

quence.

85.1.3 This follows from Rule (85.1), page 124,

going from top to bottom. To use it, we must ver-

ify the two hypotheses of the rule with r = to — qn.

The first is qn + r = qn+ (to — qn) = m , as required.

The other, 0 < r < n, is immediate. Therefore the

conclusion, part of which states that q = in div n ,

must be true.

86.2.4 This is a proof by contradiction. Suppose

p > 2 and p is not odd. Then p is even, so it is


divisible by 2 . Therefore p is divisible by a num-

ber other that p and 1 (namely 2, which is not p

because p> 2 ) . This contradiction to the definition

of prime (Definition 6.1, page 10) shows that the

claim is correct.

88.3.1 a b c

12

16

Impossible, since

GCD( 12,16) =4.

12

16

4= 16-12.

26
30

2 = 7x 26-6 x 30.

26

30

4 = 14 x 26 - 12 x 30

26

30

-2 = 6 x 30 -7x 26.

51

100

1 = 25 x 100-49 x 51

88.3.3 If to and n are relatively prime, then


by Theorem 87.2 there are integers a " and b" for

which a"m + b"n = 1 . Then (a + a”)m+ (b+b")n =

am +bn + a"m + b"n = e + 1 . Note: If you reasoned

as follows: “Because a and b are relatively prime

and am. + bn = e , it follows that e = 1 by Theo-

rem 87.2,” then you are guilty of the fallacy of affirm-

ing the hypothesis (page 121).

89.1.7 The set of positive integers.

248

90.1.5 E({2,3} = {5} and F({3}) is also {5}.

inj?

surj?

image

a)

B
b)

{2,3}

c)

d)

e)

N
B

f)

{3}

g)

{TRUE, FALSE}

h )

i)
N

{4, 5, 6, 7, 8}

j)

{TRUE, FALSE}

inj?

surj?

image

a)

b)
Y

c)

{r € R r > 1}

d)

{r € R r < 2}

93.1.7 You must show that there are two differ-

ent elements a and a' of A for which F(a) = F (a') .

That is because the definition of injective is the

implication

a' => F(a) ^ F(a')


and the negation of that implication is the statement

a^a'A —i(F(a) ^ F(a'))

in other words

7^ a'

A F(a) =

F(a’)

domain

R+

inj'

? surj?

inj?

surj?
a)

b)

c)

Y
N

If the answers in the last column puzzle you, remem-

ber that the codomain of the restriction of a function

is the same as the codomain of the function.

97.1.3 a) Domain: {1,2, 3, 4, 5}.

Graph: { (1 , 2) , (2, 5) , (3, - 1) , (4, 3) , (5, 6) } .

b) Domain: {1,2, 3, 4}.

Graph: |(1 ,tt), (2, 5), (3,tt - 1) , (4, v / 2}|.

c) Domain: {1,2,3}.

Graph: { (1, (3, 5)), (2, (8, -7)), (3, (5,5))} .

97.3.1 a) (5,5,3, 17, — 1) . b) (27r,37r,47r,57r,67r) .

c) (1,4,9,16,25,36).

98.2.6

a) G° F : {1,2, 3, 4} -A {1,3, 5, 7, 9}, graph

{(1,1), (2, 7), (3, 3), (4, 7)}.

b) G° F : R — x R , (G° F)(x) = 2x 3 .

c) G° F : R — x R , (G°F)(x) = 8x 3 .

d) n t-x (n/2) : N — X R.

e) (i,|/)i->(3,i):RxR->RxR.

99.1.5 li-xl, 2 i— x 2, 3 i — >- 2 .


100.1.5

X I X Jx

R+ *-R +

101.2.3 Only (a) and (f) have inverses. For

(a) the inverse is F~ Y : {3, 4, 5, 6} — X {1,2, 3, 4} with

graph {(3,1), (4, 2), (6, 3), (5, 4)}. For (f) it is n i-x

n — 1 : Z — x Z .

101.2.4 All except (c) and (h) have left inverses,

(a), (f) and (h) have right inverses.

101.2.5 If L is a left inverse of G\A— >B,

then for any x in the domain of G , L = L° ids =

L°(G°F) = (L°G)°F = id A °F = F.

101.5.3

a) a; i— x y/x .

b) x i— x x + 1 .

c) xi->x/2.

d) This one is its own inverse.

102.1.3 i fc 2 = 55 and f{^ = i k 2 = 14,400.


249

103 . 4.1 Basis: Ylk=i k(k+ 1) = \ • Eduction step:

n+l .. j n 1

' b(h +- 1 i f rj 4- 1 i (n -I- 9i '

^ jfe(jfe + l)

(n + l)(n + 2) 4-^fc(fc + l)

1 n

(n + l)(n + 2) n + l

1 + n(n + 2)

(n + 1) (n + 2)

n 2 + 2?r + 1

(n + 1) (n + 2)

(n + l) 2

(n + 1) (n + 2)

n + l

n + 2

as required.

103 . 4.2 Induction step: If n is even,


n+l n

E(-l) fcfc = -(»+!) + £(-!)**

k = 1

fe=l

= -(n + l) + -

= ^ (n — 2n — 2)

—n — 2

-(n + l + 1)

as required, and if n is odd,

n+l n

E(-l)+ = (n + l) + E(-l) fe fc

k— 1 fc=l

. n + l

= n + l —

n + l
105 . 2.1 1! = 1, and (n + l)! = (n+l)n! which by

the induction hypothesis is

{n + mi^k = JT k t\k

as required.

107 . 3.1 For n = 1 , this is l 2 — 0 = (— l) 2 . For the

induction step, suppose / 2 -/„_i/„+i = (-l) n+1 .

Then

/n+l - fnfn+2 = fn+1 ~ fn{fn + /n+l)

= fn+1 fn fnfn+1

fn+1 — fnfn + 1 .fn—lfn+1

fn + fn—lfn+1

The first three terms are /„+i(/ n +i - /„ - f n -i) ,

which is 0 by definition of the Fibonacci recurrence.

By the induction hypothesis, the last two terms are

(— 1)(— l) n+1 = (— l) n+2 as required.

109 . 8.2 The last entry of (a) is a, and the last

entry of cons(a,L) is the last entry of L.

110 . 4.2 (a) ‘0111010’. (b) ‘Oil’, (c) ‘Oil’,

(d) A. (e) ‘011011011’. (f) ‘011011011’.

110 . 4.3
EV.l The empty string A is a string in E .

EV.2 If w is a string in E then ‘aw’ , ‘ awb’ , ‘ bwa ’

and 'b'wb' are all strings in E.

EV.3 Every string in E is given by one of the pre-

ceding rules.

112 . 4.2

a) = {1,2, 3, 4, 5}, f+ = 0-

b) U^=(-3.-3), f+=(~ 1-1).

c) = (—1.. 3) — {1,2}, n^ = 0-

again as required.

104 . 4.1 Suppose d is a positive integer and d\p

and d\m. The only divisors of p are 1 and p . If

d = p, then p does not divide m . So the only possi-

bility is that d = 1 . Thus 1 is the largest divisor of

p and m, so GCD(p,m) = 1.

2
3

a)

-3

-6

-18

-72

-360

b)

14

30

55
c)

d)

11

18

e)

1
2

44

113 . 1.2 The set of positive divisors of 8 is

{1,2, 4, 8}. Let the bijection /3 required by Defi-

nition 113.1 be defined by: /3( 1) = 1, /3(2) = 2,

/?(3) =4, and /3(4) = 8.

113 . 5.1 x e+ x + 1 : N -+ N + is a bijection.

114 . 2.3 9 -10 -10 -10 = 9000.

114 . 2.4 9 -10 -10- 10 -5 = 45,000.

114 . 3.1 2 n — 1 .

114 . 3.2 F(n) = 3" .

114 . 3.3 G(0) = 0, G(l) = 1, and for n > 2,

G(n) = 3” -2 .

104 . 4.2

105 . 1.3

250
115 . 2.3 (a) 2” — 1 . (b) n. (c) 2 ^ .

116 . 2.3 Let Z the set of zinc pennies, B the set

of pennies minted before 1932, and A the set of pen-

nies that are neither zinc nor minted before 1932.

Let P be your whole collection. Then

\P\ = \Z\ + \B\ + \A\-\ZnB\-\ZnA\

-\AnB\ + \znAnB\

Since

\znA\ = \AnB\ = \AnBnz\ = o

we have

\P\ = 3 + 8+ |A| - \ZnB\

so you need to know the number of pennies that are

neither zinc nor minted before 1932 and the number

of zinc pennies minted before 1932. (In fact, all zinc

pennies were minted in 1943.)

117 . 1.13 All are partitions except (b) and (d).

Even though every element of S is an element of

exactly one set in (d), (d) is not a partition because

it contains the empty set as an element.

117 . 3.1 Let A = {1,3,5} and let 11= {A,Z-A}.

120 . 3.1 Every block of S/F must be a singleton.

120 . 4.1 Let F(l) = F( 2) = F(ir) = 42 and

F(x) = 41 for all other real numbers x.


121 . 2.1

a) /3 _f({1,3,5}) = 4; /? F ({4})=6; 0 F ({ 2})=0.

b) 0 f {A) = 3.

c) Pp({n}) = n for n£ A.

d) 0 F ({n}) = n 2 for n£A. (Observe that for

(c) and (d), A/F is the same set.)

e) 0 F ({1,2}) = -5; /3 F ({3}) = 1; /3 F ({4}) = 21;

/? f ({5}) = 55.

122 . 3.1 26 10 .

126 . 1.3

a) | (2,a), (2,c), (3, a), <3, c) , (3, rf) }

b) 0

c) | (2, c) , (3, c) , (3, d) , (3, e) , (4, c) , (4, d) , (4, e) j .

1 R 2 3?

1 R 3 3?

3R 2 1?

Y
N

Y
127 . 2.1

127 . 3.1 R x R — A : any two different real num-

bers are related.

127 . 3.4 By Definition 127.1, we must show that

C.l aU a op is symmetric.

C.2 a C aU a op .

C.3 If 7 is symmetric and a C 7, then aUa op C 7.

To prove C.l, suppose x(aU a op )y . Then xay and

xa op y, so ya op x and y(a op ) op x, that is, yax. So

y(aLia op )x. Hence aUa op is symmetric.

C.2 follows because for any sets S and T, S C

SUT. As for C.3, suppose 7 is symmetric and

a C 7 . Suppose xa op y . Then yax , so y^x because

a C 7. Since 7 is symmetric, xjy. Thus a^Cy.

We already know that aCy, so it follows that

a U a° p C 7 as required.

129 . 2.1 No; not symmetric.

129 . 2.2 No; not symmetric or transitive.

129 . 2.3 No. Not reflexive or transitive.

129 . 2.4 No. Not transitive.

129 . 3.1 No, not symmetric or transitive.

129 . 3.2 Yes. [0] E = [0..1) and [3] E = [3..4) .


129 . 3.3 Yes. [0] E = [0..1] and [3] E = {3}.

130 . 1.3 3, 27, 51, 75, 99.

130 . 4.4 a) 1. b) 5. c) 1.

131 . 1.3 F(6) = 0, F(n) = 1 otherwise. (There

are many answers.)

132 . 2.4 Here are all the possible values of E and

E ' :

E S/E

As U {(1,2), (2,1)} {{1,2}, {3}, {4}, {5}}

As U {(1, 2), (2, 1), (3,4), (4,3)} {{1,2}, {3, 4}, {5}}

A s U { (1, 2) , (2, 1) , (3, 5), (5, 3)} {{1,2}, {3, 5}, {4}}

As U {(1, 2), (2, 1), (4,5), (5,4)} {{1,2}, {3}, {4, 5}}

As U {(1,2), (2,1), (3,4), (3,5),

(5,4), (5,3), (4,5), (5,4)} {{1,2}, {3, 4, 5}}

135 . 3.2 We must show that a is antisymmetric,

transitive, and irreflexive. If aab and baa , this

contradicts the requirement that exactly one of the

statements in 135.3 holds unless a = b. Thus aab

and baa imply a=b , so a is antisymmetric, a

is transitive by assumption. Finally, for any a £ A,

a = a, so that rules out a a a, so a is irreflexive.

251
137 . 1.3

20

{1,2} {2,3}

10

25

/ \

/ 1

2 4

{1} {2}

2"

5
/

1 5

\ /

. /

(a)

(b)

(c)
(d)

137 . 1.4

Only (d).

139 . 1.5

Lexical ordering: 00,

01,

0101,

0111,

01111 , 10101 , 10111 , 110 , 111 .

Canonical ordering: 00, 01, 110, 111, 0101, 0111,

01111 , 10101 , 10111 .

140 . 3.2 ( a) max= 3, no min.

(b) no max, min= 0.

(c) max= 20, min= 1.


(d) max= 25, min= 1.

140 . 3.3 (a) max= 0, min= 1 (b) no max, min= 1

(c) no max, no min.

141 . 3.2 (a) sup = 5, ninf= 3

(b) sup= 60, inf= 1

(c) no sup, inf= 2

(d) sup= 0, inf= 1

(e) sup= {1,2,3}, inf= {2}

142 . 1.6 All except (f).

142 . 1.7 We will show that the infimum of any

two elements is the intersection. The proof for the

supremum is similar. By Theorem 141.2, we must

show

144 . 2.2

BCD

%/ \d

• ' a

(b)
3

146 . 2.3 (a) is simple. The relational definition of

(a) is:

G 0 = {A,B,C,D}

Gi = {(A,A),(B,A),(C,A),(D,A)}

147 . 2.2 There are six automorphisms of (a), rep-

resenting every possible way of permuting the set

{B,C, D} . There are two automorphisms of (b) (the

identity and the one that switches b and c.

148 . 1.3

1 2

3 ^4

148 . 1.4

Go = {1,2, 3, 4}

Gi. = {(1,2), (1,3), <1, 4), <2, 3), (2,4), (3,2), (3,4), (4,1)}

148 . 1.6

(left) a b c
a 0 1 1

6 10 1

c 0 0 0

(right) 12 3

10 11

2 10 1

3 0 0 0

149 . 4.3 (e) and (a,d) . Note that a path of length

n or more in a digraph with n nodes cannot be sim-

ple.

(i) If B C A and CCA, then B n C C B and

unc C G.

(ii) If B C A, CCA, DCB and D C G, then

DCBHC.

To see (i), suppose x £ BflC. By Definition 33.2,

page 47, x £ B and x £ C . Then by Definition 31.1,

B fl G C B and B fl G C G. For (ii), suppose x € D .

Then by assumption, x G B and x £ C . Then by

Definition 33.2, x £ B fl G. Hence D C B fl G.

151 . 3.1
(a) 1 of length 1 , 1 of length 2 , 2 of length 3 , 2

of length 4 .

(b) 1 each of length 1 and 2, 2 of length 3 and 4

of length 4 .

151 . 4.1 (a) x y z w (b) 2 1 1

a: 2 10 2 0 121

2/0400 001

^ 2 8 2 0

w 0 0 0 1

252

152 . 2.1 All but c and e.

153 . 3.2 b and d.

153 . 3.3 a and f are bipartite, a is complete bipar-

tite.

157 . 4.1 b and cl have diameter 1, f has diameter

3, the others have diameter 2.

157 . 4.2 a and b.

155 . 1.4 No pair of the graphs are isomorphic.


155 . 1.5 Map (b) to the triangle with horizontal

bottom edge (full) and to one of the triangles with

horizontal top edge (nonfull).

157 . 4.3 All of them.

158 . 1.4 All of them!

Bibliography

At the end of each entry, the pages on which that entry is cited are listed in
parentheses.

Bagchi, A. and C. Wells (1998). “On the communication of mathematical reasoning”.


PRIMUS , volume 8,

pages 15-27. Also available by web browser from URL:


http://www.cwru.edu/artsci/math/wells/

pub/papers . html. (117)

Bagchi, A. and C. Wells (1998). “Varieties of mathematical prose”. PRIMUS, volume


8, pages 116-136.

Also available by web browser from URL:


http://www.cwru.edu/artsci/math/wells/pub/papers.

html. (117)

Ebbinglraus, H. D., J. Flum, and W. Thomas (1984). Mathematical Logic. Springer-


Verlag.

Graham, R. L., D. E. Knuth, and O. Patashnik (1989). Concrete Mathematics. Addison-


Wesley.

Guy, R. (1981). Unsolved Problems in Number Theory. Springer- Verlag. (160)

Hofstadter, D. (1979). Godel, Escher, Bach: An Eternal Golden Braid. Basic Books,
(vi, 159)
Knuth, D. E. (1971). The Art. of Computer Programming, Volume 2. Addison- Wesley.

Lagarias, J. (1985). “The 3x +1 problem and its generalizations”. American


Mathematical Monthly ,

volume 92. (160)

Myerson, G. and A. J. van der Poorten (1995). “Some problems concerning recurrence
sequences”. American

Mathematical Monthly , volume 102. (163)

Raymond, E. S. (1991). The New Hacker’s Dictionary. The MIT Press.

Riesel, H. (1985). Prime Numbers and Computer Methods for Factorization.


Birklrauser.

Rosen, K. H. (1992). Elementary Number Theory and its Applications, Third Edition.
Addison- Wesley.

Skiena, S. (1990). Implementing Discrete Mathematics. Addison- Wesley.

Wells, C. (1995). “Communicating mathematics: Useful ideas from computer science”.


American Mathe-

matical Monthly, volume 102, pages 397-408. Also available by web browser from URL:
http://www.

cwru. edu/ artsci/math/wells/pub/papers .html. (117)

Wells, C. (1998). “Handbook of mathematical discourse”. URL:


http://www.cwru.edu/artsci/math/

wells/pub/papers .html. (117)

Wilder, R. L. (1965). Introduction to the Foundations of Mathematics. Second


Edition. John Wiley and

Sons. (35)

Wilf, H. (1990). Generatingfunctionology. Academic Press.

253
Index

The page number(s) in boldface indicate where the definition or basic explanation
of the word is found.

The other page numbers refer to examples and further information about the word.

1 -tuple, 51

absolute value, 138

abstract description

examples, 219

abstract description (of a

graph), 219

abstraction, 60, 73, 200, 219

addition, 11, 66, 67, 69-71, 97,

107, 163, 202

addition (of matrices), 228

addition of rational numbers,

11

adjacency matrix, 224 , 232

examples, 224

adjacent, 232

adjacent with multiplicity n,

232

affirming the hypothesis, 121


algebraic expression, 16 , 105

algorithm, 97

algorithm for addition, 97

algorithm for multiplication,

97, 98

AllFactors, 9

alphabet, 93 , 167

and, 21 , 22 , 24, 102, 108

examples, 21

anonymous notation, 64

antecedent, 36

antisymmetric, 79

examples, 79

antisymmetric closure, 199

application, 57

Archimedean property, 115

argument, 57

arrow, 218

associative, 70 , 71

associativity (in lattices), 216

automorphism, 224

axiomatic method, 217

barred arrow notation, 65

base, 94

examples, 99

basis step, 152


Bezout’s Lemma, 128-130, 156,

162

biconditional, 40

bijection, 136 , 149, 186

bijective, 136 , 187

examples, 136

binary notation, 95 , 97, 98

binary operation, 67 , 69

examples, 67, 70, 91

binary relation

examples, 74

binomial coefficient, 191, 191 ,

192

examples, 190, 192

bipartite graph, 233

bit, 95

block, 180 , 182

boldface, 4

Boolean variable, 104

bound (variable), 32, 64, 114

calculus, 107

canonical ordering, 212

examples, 212

cardinality, 173

examples, 173

carry, 97, 98
Cartesian powers, 54

Cartesian product, 52, 52 , 54,

177

examples, 52, 53, 74

Cartesian square, 54

CartesianPoduct, 54

centered division, 87

character, 93

characteristic function, 65

examples, 65

characterize, 85

chromatic number, 241

circuit, 236

class function, 183

examples, 183

closed interval, 31

closure, 197

codomain, 56 , 131

Collatz function, 160

color, 241

coloring, 241

commutative, 71

examples, 71

commutative diagram, 144

examples, 145

commutativity (in lattices),


216

complement, 48 , 108

examples, 67

complete bipartite graph, 233

complete graph, 233

complete graph on n nodes,

233

component (of a graph), 236

composite, 10 , 140

examples, 10

composite (of functions), 140

examples, 141, 142

composite (of relations), 195

examples, 195

composite integer, 10

composition, 195

composition (of functions) , 140

composition powers, 196

Comprehension, 28

comprehension, 27 , 29

concatenate (of lists), 166 , 168

conceptual proof, 193

conclusion, 36

conditional sentence, 36

congruence, 200

congruent (mod fc), 201

examples, 201, 203


conjunction, 21 , 103

connected, 236

connected component, 236

connected graph, 236

cons, 165

consequent, 36 , 121

constant function, 63

constructive, 130

contain, 45

contradiction, 107

contrapositive, 42

examples, 43, 120

Contrapositive Method, 120

contrapositive method, 120

254

255

converse, 42

examples, 42

coordinate, 49 , 143

coordinate function, 63 , 74

examples, 74

corollary, 1

countably infinite, 174

counterexample, 112 , 154


cycle, 236

decimal, 12 , 93

decimal expansion, 12

decimal representation, 12 , 14,

15

defined by induction, 159

defining condition, 27

definition, 1, 4 , 25

examples, 15

degree, 233

DeMorgan Law, 102

DeMorgan law

examples, 103, 105

denying the consequent, 121

dependent variable, 57

diagonal, 52 , 69

diameter, 237

digit, 14, 93

digraph, 74 , 218 , 222

Direct Method, 119

direct method, 119

directed circuit, 226

directed edge, 218

directed graph, 218

directed path, 226

directed walk, 225

disjoint, 47

disjunction, 21 , 103
distance, 237

distributive law, 110

div, 82

divide, 4 , 6, 8, 207

examples, 4

divides

examples, 5

DividesQ, 9

division, 4 , 87

division (of real numbers), 67

divisor, 5

domain, 56

dummy variable, 150

edge, 230

element, 25, 172

embedded in the plane, 239

empty function, 63

empty language, 169

empty list, 164

empty relation, 74

empty set, 33 , 34, 46, 63, 108

empty string, 168, 168

empty tuple, 51

equivalence, 40 , 122, 123

examples, 123, 200

equivalence class, 204


equivalence relation, 200 , 206

examples, 200

equivalent, 40 , 41, 42, 109

examples, 41, 42, 106

Euclidean algorithm, 92

Eulerian circuit, 237

evaluation, 57

even, 5 , 200

examples, 5, 10

example, 1

existential bigamy, 9

existential quantifier, 113

examples, 113, 115

existential statement, 5 , 113

exponent, 87

examples, 87

exponential notation, 54

exponential notation for

strings, 168

expression, 16 , 105

extension (of a function), 138

examples, 138

extension (of a predicate), 27 ,

55

examples, 28, 55

fact, 1

factor, 5 , 9

factorial function, 158 , 159,


189

Factorlnteger, 88

factorization, 87

fallacy, 121

examples, 121, 122

family of elements of, 140

family of sets, 171

examples, 171

Fibonacci function, 160

Fibonacci numbers, 161

field names, 140

finite, 173, 173 , 182, 187

examples, 173

finite set, 173, 173 , 187

first coordinate, 49

first coordinate function, 63

fixed point, 143

floor, 86

examples, 86

floored division, 87

formal language, 169

formula, 16

Forth, 69

Four Color Theorem, 242

fourtunate, 37

free variable, 32
full, 234

full subgraph, 234

Function, 65

function, 56, 56 , 57, 59, 60, 62,

63, 68, 75, 131, 184, 186

examples, 57, 58, 61, 63, 67

function as algorithm, 60

function set, 66, 67, 188

examples, 66

functional, 62

functional composition, 140

functional property, 62 , 75

functional relation, 75

functions in Mathematica, 58

Fundamental Theorem of

Arithmetic, 87 , 127

GCD, 88, 90-92, 125, 128, 164

examples, 88, 90-92, 128

GCD, 91

General Associative Law, 71

graph, 230

graph (of a function), 61

examples, 138

greatest common divisor, 88

greatest integer, 86
Hamiltonian circuit, 238

Hasse diagram, 210

examples, 210

head, 164

hexadecimal, 95

hexadecimal notation, 95 , 97

hypothesis, 36

idempotence (in lattices), 216

idempotent, 143

identifies, 205

256

identity, 72

examples, 72

identity (for a binary opera-

tion), 72

identity (predicate), 19

examples, 20

identity function, 63, 64, 65,

72, 141

examples, 64, 137

image, 131

examples, 131

image function, 132

image of a subset, 132


implication, 35 , 36 , 37-39, 41,

42, 107, 109, 119

examples, 36-39, 117, 118

implies, 107, 109, 119

incident, 232

include, 43, 44, 45, 77, 176,

207, 208

examples, 43, 63, 79, 207

inclusion, 79

inclusion and exclusion, 179

examples, 179

inclusion function, 63 , 138, 142

inclusive or, 22

indegree, 220

examples, 220

independent, 174

independent variable, 57

indexed by, 140

induction, 152 , 159, 175, 192

examples, 152, 153

induction hypothesis, 152

induction step, 152

inductive definition, 159

examples, 157, 158, 161

inductive proof, 152

infimum, 214, 214

examples, 214
infinite, 174 , 182

infinity symbol, 12

infix notation, 68

initial segment, 211

examples, 211

injection, 134

injective, 134 , 187, 189

examples, 134, 138

injective function, 187

input, 57

instance, 16

integer, 3 , 15, 87, 93, 127

examples, 3

integer variable, 18

IntegerQ, 15

integral linear combination,

127 , 129

examples, 127-129

interpolative, 196

intersect

examples, 171, 172

intersection, 47 , 67, 77, 108,

199, 217

examples, 47, 55, 77, 172,

178
intersection-closed, 199

interval, 31

examples, 31, 33

inverse function, 146

examples, 147

inverse image, 132

invertible, 146 , 149

irreflexive, 81

examples, 81

isomorphic, 235

isomorphism, 223 , 235

examples, 223

iterative, 157

join, 214

examples, 215

Kempe graph, 242

kernel equivalence, 203

examples, 203

Kuratowski’s Theorem, 240

labeling, 221

lambda notation, 64

examples, 64

language, 169

examples, 169, 170

lattice, 215

examples, 215
law, 19 , 39

law of the excluded middle,

106

LCM, 88, 90

LCM, 91

least common multiple, 88

least counterexample, 154

least significant digit, 94

least upper bound, 213

left cancellable, 150

left inverse, 146

lemma, 2

length, 236

length (of a list), 165

examples, 165

lexical order, 211

lexical ordering, 211

examples, 211

linear ordering, 208

List, 69

list, 27, 164

examples, 165

list constructor function, 165

list notation

examples, 26
list notation (for sets), 26 , 32

logical connective, 21 , 35

loop, 220

examples, 220

lower bound, 213

lower semilattice, 215 , 216

lowest terms, 11

examples, 11

mapping, 57

material conditional, 36

Mathematica, vi, 9, 10, 15, 16,

19, 21-23, 27, 31, 54, 58,

59, 62, 65, 68, 69, 84, 87,

88, 91, 96, 109, 151, 165

mathematical induction, 152 ,

175

matrix addition, 228

matrix multiplication, 227

max, 70 , 167, 215

maximum, 70, 167, 213, 213

meet, 214

examples, 215

member, 25

method, 2

min, 70 , 215

minimum, 70, 213

Mod, 84

mod, 82 , 204
modulus of congruence, 201

modus ponens, 40 , 109, 110

moiety, 233

more significant, 94

examples, 94

most significant digit, 94

multidigraph, 222

multigraph, 222, 231

257

multiplication, 11, 67, 69-72,

97, 107, 163, 202

multiplication (of matrices),

227

multiplication algorithm, 97,

98

Multiplication of Choices, 175

multiplication of rational

numbers, 11

multiplication table, 69

N, 15

NAND, 109

natural number, 3
near, 77

nearness relation, 77 , 78-80,

200

negation, 22 , 23

examples, 23, 102, 116

negative, 3

negative integer, 3

negative real number, 12

ninety-one function, 159

node, 218 , 230

nonconstructive, 130

nonempty list, 164

nonnegative, 3

nonnegative integer, 3

nontrivial subset, 45

NOR, 109

not, 22, 102, 108

null tuple, 51 , 54

number of elements of a finite

set, 173

examples, 173

octal notation, 94

odd, 5, 200

one to one, 134

one to one correspondence, 136

onto, 133

open interval, 31

open sentence, 16
opposite, 62 , 77 , 220

examples, 77

or, 21 , 22, 22 , 24, 102, 108

examples, 21

ordered pair, 49, 49 , 50

ordered set, 207

ordered triple, 50

ordering, 206

examples, 206-208

outdegree, 220

examples, 220

output, 57

P-closure, 197

pairwise disjoint, 180

palindrome, 169

parameter, 32

partial ordering, 207

partition, 180 , 181-185, 195,

204, 206, 237

examples, 180-183

Pascal, 26, 68, 87, 92, 93, 100,

104, 157, 164, 180, 201,

226

path, 236

permutation, 137

examples, 137
Perrin function, 161

Perrin pseudoprime, 161

Pigeonhole Principle, 189

examples, 189

planar, 239

Polish notation, 68

poset, 207

examples, 207

positive, 3

positive integer, 3

positive real number, 12

postfix notation, 68

power (of matrices), 228

power set

examples, 207

powerset, 46 , 74, 76, 77, 132,

133, 177, 207

examples, 46, 67, 76

predicate, 16 , 73, 105

examples, 16, 19, 20

predicate calculus, 113

prefix notation, 68

preorder, 209

preordered set, 209

preordering, 209

Prime, 10, 58

prime, 10, 10 , 58, 87, 127

examples, 10
prime factorization, 87, 92

examples, 87

PrimeQ, 10

Principle of Inclusion and

Exclusion, 179

examples, 179

Principle of mathematical

induction, 152

Principle of Multiplication of

Choices, 175

Principle of Strong Induction,

156

Principle of the Least Coun-

terexample, 154

Product, 151

product, 150, 150 , 153

examples, 150, 158

product (of matrices), 227

product (of matrices), 228

projection, 63 , 74, 143

proof, 2, 4, 4

proof by contradiction, 126

proper subset, 45

properly included, 44

proposition, 15 , 17, 104


examples, 15

propositional calculus, 107

propositional expression, 104

propositional form, 104

propositional variable, 104

quantifier, 20, 20 , 113

examples, 112, 115, 116, 118

Quotient, 84

quotient, 84, 156

quotient (of integers), 83

quotient set (of a function),

184

examples, 184

quotient set (of an equivalence

relation), 204 , 206

examples, 204

rabbit, 160

radix, 94

range, 131

range expression, 151

rational, 11, 126

examples, 11, 13, 14

rational number, 11, 11 , 12,

14, 15

addition, 11
multiplication, 11

representation, 11

reachability matrix, 230

reachable, 229

real number, 12, 12 , 13-15, 22,

115

258

real variable, 18

realizations, 96

recurrence, 161

recurrence relation, 161 , 189

examples, 191

recursive, 157 , 164

recursive definition, 157 , 159

examples, 157, 159, 160, 163,

164, 170

reductio ad absurdum, 126

reflexive, 77

examples, 77

reflexive closure, 197, 197

relation, 73 , 74, 76, 77

examples, 74, 75, 195

relation on, 75

relational database, 139

relational description, 222


relational symbols, 16

relatively prime, 89

examples, 89

remainder, 83 , 84, 92, 156, 182,

184

examples, 184

remainder function, 203

remark, 2

representation, 15 , 96

representation (of a rational

number), 11

representation (of a set), 26

restriction, 137 , 142

examples, 138

reverse Polish notation, 68

right band, 67 , 70, 72

right cancellable, 150

right inverse, 146

rule of inference, 24 , 25, 39,

110

examples, 24, 25, 39, 40, 43,

46, 110, 125, 147, 152, 213

Russell’s Paradox, 35

scalar product, 227

scandalous theorem, 126

second coordinate, 49
second coordinate function, 63

Select, 31

semicolons in Mathematica, 59

sentence, 15

set, 25 , 32 , 35, 172, 174

examples, 25-28, 33, 34

set difference, 48

examples, 48

set of all sets, 35 , 48

set of functions

examples, 140

setbuilder notation, 27 , 29, 35

examples, 27-29, 33

sets of numbers, 25

sex, 161

shift function, 188

shoe-sock theorem, 148

show, 2

significant figures, 12

simple, 231

simple digraph, 221

simple directed path, 226

simple graph, 231

simple path, 236

single- valued, 61

singleton, 34
singleton set, 34

sister relation, 77 , 78, 80

solution set, 28

solve (a recurrence relation),

161

sorting, 143

source, 218

specification, 2

square root symbol, 12

statement, 19

strict ordering, 206

examples, 206

strict total ordering, 208

string, 93 , 167

examples, 167

StringLength, 58

strong induction, 155

subdivision, 240

subgraph, 234

subset, 43 , 45, 190

substitution, 17

subtraction, 67, 68, 70, 71

successor function, 163

Sum, 151

sum, 150, 150 , 153

examples, 150, 158

supremum, 213 , 214

examples, 214
surjection, 133

surjective, 133 , 187

examples, 133, 138

Swedish rock group, 170

symmetric, 78 , 124, 232

examples, 78

symmetric closure, 197

symmetric matrix, 232

Table, 27, 31

tail, 164

take, 57

target, 218

tautology, 105

examples, 106

Tautology Theorem, 110

terrible idea, 45

theorem, 2

total ordering, 208

examples, 208

total relation, 74

transitive, 80 , 196, 227

examples, 80

transitive (digraph), 227

transitive closure, 198

transitivity (of implication),

109

trichotomy, 208
trunc, 86, 86

examples, 86

truth table, 22

TruthTable, 23

tuple, 50, 50 , 52, 138, 139 ,

140

examples, 51, 139, 140

tuple as function, 138

turnstile, 24

type (of a variable), 17 , 25, 26,

29, 104

unary operation, 67

examples, 67

under, 57 , 132

union, 47 , 67, 77, 108, 217

examples, 47, 77, 169, 171,

172, 178, 233

unit interval, 29

unity, 72

Universal Generalization, 6

universal generalization, 6

Universal Instantiation, 7

universal instantiation, 7

universal quantifier, 112 , 154

examples, 112, 115, 118

universal set, 48 , 108

universally true, 19 , 39

examples, 19, 20
259

upper bound, 212

examples, 212

upper semilattice, 215 , 216

usage, 2

utility graph, 240

vacuous, 37

vacuously true, 37

examples, 37

valid (rule of inference), 24

value, 56 , 57

value (of a function), 56, 59, 60

variable, 8, 16, 17

vertex, 218 , 230

vertices, 218

walk, 236

warning, 2

weak ordering, 206

examples, 206

weight function, 221

well-defined, 85
well-ordered, 154

witness, 113

Xor, 22

xor, 22

yields, 24

Zermelo-Frankel set theory, 35

zero, 3-5, 33

260

Index of Symbols

23, 158

to | n 4

:= 59

-n 22, 102, 108

(A, a) 207

to mod n 83

X 65
NOR 109

(a..b) 171

n! 158, 189

Xi 65

M 77

(x)F 68

n (mod k) 203

= 201

N+ 25

/ 5

PAQ 21

cons 165

o 140, 195

// 69

P <=>Q 40
A 69

C 45

0 4, 5

P => Q 36

52, 77

V 21, 22, 23, 24,

() 51, 225

pvg 21

div 82

102, 108

{a, b) 49

pop 62

1 4

A 48

(&i)i£ n 51
K 63, 74

0 33, 63, 108

n 180

(xi,...,x n ) 51

R n 184

4A 40, 109

n 205

A' 48

5/P 204

3 113

n?=i 150

A-B 48

w n 168

(3 x:Q)(x) 113
nLi 158

A/F 184

xF 68

e p 87

PA 46

A\B 48

x i-a f(x) 65

E n 205

V 46

A c 108

[a., b] 31

floor 86

Q 25

AcB 26

[a] 183
V 20, 26, 112

R 25, 52

AC B 43

[r] 86

B A 66

Rel(A,P) 74

AnB 47

[x] 180, 205

r 6i

R+ 25

Ac B 45

[x] E 204

r(p). 6i

R++ 25

A(^B 44
[x] n 205

GCD 88, 128, 164

{x | P(x)} 27

Ax B 52

& 65

I 29

44

AuB 47

&& 21

kU 63

‘cat’ 93

flVfc 215

\A\ 173

=> 36, 109

rr=i 150
aAb 215

a 73

G 26, 80

EL i 158

A* 165, 211

a* 76

C 43

sup 213

A+ 165

cxf 76

oo 12

els 183

A c 48

a° p 195
n 47, 108

x 52

A n 54

a op 77, 124, 207

A 211

-> 57

B A 188

a" 196

A x.f(x) 64

trunc 86

C(n,k) 190

197

A 51, 168

U 47

C b 63
a s 197

A 64

U 108

C r 182

a T 198

LCM 88

U 48, 108

F(a) 57

(Vx:Z)P(x) 26

\A\ 187

h 24

F-.A-+B 57

(Vx)P(x) 112

< 206

V 215
F~ l 147

(Vx)Q(x) 112

[rj 86

A 215

F* 133

A 21, 22, 102, 108

< 206

Z 25

F~ l 132, 184

^ 65

max 70

Z/n 184

G° F 140

Pf 186

min 70
Z„ 182

i:A—>B 142

171

mod 82

{xi, — ,x n } 26

K(F) 203

mu ^ 171

N 25

| 27

m = n 201

IJJ 17 171

n 50, 173

II 21

to div n 83
Uti A i 171

NAND 109

You might also like